Merge reg and reg2 variant of print check dialog back into one file

There was nothing in the duplicate file that was different
from the original one except for the plugin_page parameter
initially passed in. Turns out we don't need anything
from the plugin_page except for the very generic GtkWindow
which is actually a member of the generic GncPluginPage
base object. So pass that window instead and avoid the
need for differentiation.
This commit is contained in:
Geert Janssens 2016-03-24 22:49:27 +01:00
parent cde9d78465
commit 39bfeba930
8 changed files with 19 additions and 2706 deletions

View File

@ -14,7 +14,6 @@ SET (gnc_gnome_noinst_HEADERS
dialog-lot-viewer.h dialog-lot-viewer.h
dialog-new-user.h dialog-new-user.h
dialog-print-check.h dialog-print-check.h
dialog-print-check2.h
dialog-progress.h dialog-progress.h
dialog-sx-editor.h dialog-sx-editor.h
dialog-sx-editor2.h dialog-sx-editor2.h
@ -58,7 +57,6 @@ SET (gnc_gnome_SOURCES
dialog-price-editor.c dialog-price-editor.c
dialog-price-edit-db.c dialog-price-edit-db.c
dialog-print-check.c dialog-print-check.c
dialog-print-check2.c
dialog-progress.c dialog-progress.c
dialog-sx-editor.c dialog-sx-editor.c
dialog-sx-editor2.c dialog-sx-editor2.c

View File

@ -37,7 +37,6 @@ libgnc_gnome_la_SOURCES = \
dialog-price-editor.c \ dialog-price-editor.c \
dialog-price-edit-db.c \ dialog-price-edit-db.c \
dialog-print-check.c \ dialog-print-check.c \
dialog-print-check2.c \
dialog-progress.c \ dialog-progress.c \
dialog-sx-editor.c \ dialog-sx-editor.c \
dialog-sx-editor2.c \ dialog-sx-editor2.c \
@ -87,7 +86,6 @@ noinst_HEADERS = \
dialog-lot-viewer.h \ dialog-lot-viewer.h \
dialog-new-user.h \ dialog-new-user.h \
dialog-print-check.h \ dialog-print-check.h \
dialog-print-check2.h \
dialog-progress.h \ dialog-progress.h \
dialog-sx-editor.h \ dialog-sx-editor.h \
dialog-sx-editor2.h \ dialog-sx-editor2.h \

View File

@ -277,7 +277,6 @@ struct _print_check_dialog
GtkWidget *dialog; GtkWidget *dialog;
GtkWindow *caller_window; GtkWindow *caller_window;
GncPluginPageRegister *plugin_page;
Split *split; Split *split;
GList *splits; GList *splits;
@ -1601,7 +1600,7 @@ initialize_format_combobox (PrintCheckDialog *pcd)
* make a new print check dialog and wait for it. * * make a new print check dialog and wait for it. *
*****************************************************/ *****************************************************/
void void
gnc_ui_print_check_dialog_create(GncPluginPageRegister *plugin_page, gnc_ui_print_check_dialog_create(GtkWidget *parent,
GList *splits) GList *splits)
{ {
PrintCheckDialog *pcd; PrintCheckDialog *pcd;
@ -1612,7 +1611,7 @@ gnc_ui_print_check_dialog_create(GncPluginPageRegister *plugin_page,
Transaction *trans = NULL; Transaction *trans = NULL;
pcd = g_new0(PrintCheckDialog, 1); pcd = g_new0(PrintCheckDialog, 1);
pcd->plugin_page = plugin_page; pcd->caller_window = GTK_WINDOW(parent);
pcd->splits = g_list_copy(splits); pcd->splits = g_list_copy(splits);
builder = gtk_builder_new(); builder = gtk_builder_new();
@ -1682,9 +1681,7 @@ gnc_ui_print_check_dialog_create(GncPluginPageRegister *plugin_page,
pcd->check_rotation = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, "check_rotation_entry")); pcd->check_rotation = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, "check_rotation_entry"));
pcd->units_combobox = GTK_WIDGET(gtk_builder_get_object (builder, "units_combobox")); pcd->units_combobox = GTK_WIDGET(gtk_builder_get_object (builder, "units_combobox"));
window = GTK_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window); gtk_window_set_transient_for(GTK_WINDOW(pcd->dialog), pcd->caller_window);
gtk_window_set_transient_for(GTK_WINDOW(pcd->dialog), window);
pcd->caller_window = GTK_WINDOW(window);
/* Create and attach the date-format chooser */ /* Create and attach the date-format chooser */
table = GTK_WIDGET(gtk_builder_get_object (builder, "options_table")); table = GTK_WIDGET(gtk_builder_get_object (builder, "options_table"));

View File

@ -28,7 +28,7 @@
typedef struct _print_check_dialog PrintCheckDialog; typedef struct _print_check_dialog PrintCheckDialog;
void gnc_ui_print_check_dialog_create(GncPluginPageRegister *plugin_page, void gnc_ui_print_check_dialog_create(GtkWidget *parent,
GList *splits); GList *splits);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +0,0 @@
/********************************************************************\
* dialog-print-check2.h : dialog to control check printing *
* Copyright (C) 2000 Bill Gribble <grib@billgribble.com> *
* Copyright (C) 2006 David Hampton <hampton@employees.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
\********************************************************************/
#ifndef DIALOG_PRINT_CHECK2_H
#define DIALOG_PRINT_CHECK2_H
#include "print-session.h"
typedef struct _print_check_dialog PrintCheckDialog;
void gnc_ui_print_check_dialog_create2 (GncPluginPageRegister2 *plugin_page,
GList *splits);
#endif

View File

@ -2705,6 +2705,7 @@ gnc_plugin_page_register_cmd_print_check (GtkAction *action,
GList * splits = NULL, *item; GList * splits = NULL, *item;
GNCLedgerDisplayType ledger_type; GNCLedgerDisplayType ledger_type;
Account * account; Account * account;
GtkWidget * window;
ENTER("(action %p, plugin_page %p)", action, plugin_page); ENTER("(action %p, plugin_page %p)", action, plugin_page);
@ -2713,6 +2714,7 @@ gnc_plugin_page_register_cmd_print_check (GtkAction *action,
priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(plugin_page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(plugin_page);
reg = gnc_ledger_display_get_split_register (priv->ledger); reg = gnc_ledger_display_get_split_register (priv->ledger);
ledger_type = gnc_ledger_display_type(priv->ledger); ledger_type = gnc_ledger_display_type(priv->ledger);
window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(plugin_page));
if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT) if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT)
{ {
account = gnc_plugin_page_register_get_account (plugin_page); account = gnc_plugin_page_register_get_account (plugin_page);
@ -2724,7 +2726,7 @@ gnc_plugin_page_register_cmd_print_check (GtkAction *action,
if (xaccSplitGetAccount(split) == account) if (xaccSplitGetAccount(split) == account)
{ {
splits = g_list_append(splits, split); splits = g_list_append(splits, split);
gnc_ui_print_check_dialog_create(plugin_page, splits); gnc_ui_print_check_dialog_create(window, splits);
g_list_free(splits); g_list_free(splits);
} }
else else
@ -2735,7 +2737,7 @@ gnc_plugin_page_register_cmd_print_check (GtkAction *action,
if (split) if (split)
{ {
splits = g_list_append(splits, split); splits = g_list_append(splits, split);
gnc_ui_print_check_dialog_create(plugin_page, splits); gnc_ui_print_check_dialog_create(window, splits);
g_list_free(splits); g_list_free(splits);
} }
} }
@ -2757,14 +2759,13 @@ gnc_plugin_page_register_cmd_print_check (GtkAction *action,
{ {
if (xaccSplitGetAccount(split) != common_acct) if (xaccSplitGetAccount(split) != common_acct)
{ {
GtkWidget *dialog, *window; GtkWidget *dialog;
gint response; gint response;
const gchar *title = _("Print checks from multiple accounts?"); const gchar *title = _("Print checks from multiple accounts?");
const gchar *message = const gchar *message =
_("This search result contains splits from more than one account. " _("This search result contains splits from more than one account. "
"Do you want to print the checks even though they are not all " "Do you want to print the checks even though they are not all "
"from the same account?"); "from the same account?");
window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(plugin_page));
dialog = gtk_message_dialog_new(GTK_WINDOW(window), dialog = gtk_message_dialog_new(GTK_WINDOW(window),
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING, GTK_MESSAGE_WARNING,
@ -2786,11 +2787,11 @@ gnc_plugin_page_register_cmd_print_check (GtkAction *action,
} }
} }
} }
gnc_ui_print_check_dialog_create(plugin_page, splits); gnc_ui_print_check_dialog_create(window, splits);
} }
else else
{ {
gnc_error_dialog(gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(plugin_page)), "%s", gnc_error_dialog(window, "%s",
_("You can only print checks from a bank account register or search results.")); _("You can only print checks from a bank account register or search results."));
LEAVE("Unsupported ledger type"); LEAVE("Unsupported ledger type");
return; return;

View File

@ -56,7 +56,7 @@
#include "dialog-account.h" #include "dialog-account.h"
#include "dialog-find-transactions2.h" #include "dialog-find-transactions2.h"
#include "dialog-print-check2.h" #include "dialog-print-check.h"
#include "dialog-transfer.h" #include "dialog-transfer.h"
#include "dialog-utils.h" #include "dialog-utils.h"
#include "SX-book.h" #include "SX-book.h"
@ -2544,6 +2544,7 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
GList * splits = NULL, *item; GList * splits = NULL, *item;
GNCLedgerDisplay2Type ledger_type; GNCLedgerDisplay2Type ledger_type;
Account * account; Account * account;
GtkWidget * window;
ENTER("(action %p, plugin_page %p)", action, plugin_page); ENTER("(action %p, plugin_page %p)", action, plugin_page);
@ -2553,6 +2554,7 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
view = gnc_ledger_display2_get_split_view_register (priv->ledger); view = gnc_ledger_display2_get_split_view_register (priv->ledger);
model = gnc_ledger_display2_get_split_model_register (priv->ledger); model = gnc_ledger_display2_get_split_model_register (priv->ledger);
ledger_type = gnc_ledger_display2_type (priv->ledger); ledger_type = gnc_ledger_display2_type (priv->ledger);
window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page));
if (ledger_type == LD2_SINGLE || ledger_type == LD2_SUBACCOUNT) if (ledger_type == LD2_SINGLE || ledger_type == LD2_SUBACCOUNT)
{ {
@ -2592,7 +2594,7 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
if (xaccSplitGetAccount(split) == account) if (xaccSplitGetAccount(split) == account)
{ {
splits = g_list_append(splits, split); splits = g_list_append(splits, split);
gnc_ui_print_check_dialog_create2 (plugin_page, splits); gnc_ui_print_check_dialog_create (window, splits);
g_list_free(splits); g_list_free(splits);
} }
else else
@ -2603,7 +2605,7 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
if (split) if (split)
{ {
splits = g_list_append(splits, split); splits = g_list_append(splits, split);
gnc_ui_print_check_dialog_create2 (plugin_page, splits); gnc_ui_print_check_dialog_create (window, splits);
g_list_free(splits); g_list_free(splits);
} }
} }
@ -2625,14 +2627,13 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
{ {
if (xaccSplitGetAccount (split) != common_acct) if (xaccSplitGetAccount (split) != common_acct)
{ {
GtkWidget *dialog, *window; GtkWidget *dialog;
gint response; gint response;
const gchar *title = _("Print checks from multiple accounts?"); const gchar *title = _("Print checks from multiple accounts?");
const gchar *message = const gchar *message =
_("This search result contains splits from more than one account. " _("This search result contains splits from more than one account. "
"Do you want to print the checks even though they are not all " "Do you want to print the checks even though they are not all "
"from the same account?"); "from the same account?");
window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page));
dialog = gtk_message_dialog_new (GTK_WINDOW (window), dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING, GTK_MESSAGE_WARNING,
@ -2654,11 +2655,11 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
} }
} }
} }
gnc_ui_print_check_dialog_create2 (plugin_page, splits); gnc_ui_print_check_dialog_create (window, splits);
} }
else else
{ {
gnc_error_dialog (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page)), "%s", gnc_error_dialog (window, "%s",
_("You can only print checks from a bank account register or search results.")); _("You can only print checks from a bank account register or search results."));
LEAVE("Unsupported ledger type"); LEAVE("Unsupported ledger type");
return; return;