Generalize Account Filter By... (step 4)

Fixup comments forgotten in step 3.
Factor out and export most of the account filter dialog creation.
Eventually this function should live somewhere else.



git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12213 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker 2005-12-31 00:00:49 +00:00
parent cba693c30c
commit aeeac3fd9c
2 changed files with 37 additions and 24 deletions

View File

@ -1329,7 +1329,7 @@ gnc_plugin_page_account_tree_filter_accounts (Account *account,
* *
* @param button The GtkCheckButton that was toggled. * @param button The GtkCheckButton that was toggled.
* *
* @param page A pointer to the account tree page to update. */ * @param fd A pointer to the account filter dialog struct. */
void void
gppat_filter_hide_zero_toggled_cb (GtkToggleButton *button, gppat_filter_hide_zero_toggled_cb (GtkToggleButton *button,
AccountFilterDialog *fd) AccountFilterDialog *fd)
@ -1348,7 +1348,7 @@ gppat_filter_hide_zero_toggled_cb (GtkToggleButton *button,
* *
* @param button The button that was clicked. * @param button The button that was clicked.
* *
* @param page A pointer to the account tree page to update. */ * @param fd A pointer to the account filter dialog struct. */
void void
gppat_filter_clear_all_cb (GtkWidget *button, gppat_filter_clear_all_cb (GtkWidget *button,
AccountFilterDialog *fd) AccountFilterDialog *fd)
@ -1374,7 +1374,7 @@ gppat_filter_clear_all_cb (GtkWidget *button,
* *
* @param button The button that was clicked. * @param button The button that was clicked.
* *
* @param page A pointer to the account tree page to update. */ * @param fd A pointer to the account filter dialog struct. */
void void
gppat_filter_select_all_cb (GtkWidget *button, gppat_filter_select_all_cb (GtkWidget *button,
AccountFilterDialog *fd) AccountFilterDialog *fd)
@ -1417,7 +1417,7 @@ gppat_filter_select_default_cb (GtkWidget *button,
* *
* @param button The button that was clicked. * @param button The button that was clicked.
* *
* @param page A pointer to the account tree page to update. */ * @param fd A pointer to the account filter dialog struct. */
static void static void
gppat_filter_selection_changed_cb (GtkTreeSelection *selection, gppat_filter_selection_changed_cb (GtkTreeSelection *selection,
AccountFilterDialog *fd) AccountFilterDialog *fd)
@ -1441,7 +1441,7 @@ gppat_filter_selection_changed_cb (GtkTreeSelection *selection,
* *
* @param response The response code from closing the dialog. * @param response The response code from closing the dialog.
* *
* @param page A pointer to the account tree page to update. */ * @param fd A pointer to the account filter dialog struct. */
void void
gppat_filter_response_cb (GtkWidget *dialog, gppat_filter_response_cb (GtkWidget *dialog,
gint response, gint response,
@ -1470,23 +1470,19 @@ gppat_filter_response_cb (GtkWidget *dialog,
LEAVE("types 0x%x", types); LEAVE("types 0x%x", types);
} }
static void void
gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action, account_filter_dialog_create(AccountFilterDialog *fd, GncPluginPage *page)
GncPluginPageAccountTree *page)
{ {
GncPluginPageAccountTreePrivate *priv;
GtkWidget *dialog, *button; GtkWidget *dialog, *button;
GtkTreeView *view; GtkTreeView *view;
GtkTreeSelection *selection; GtkTreeSelection *selection;
GladeXML *xml; GladeXML *xml;
gchar *title; gchar *title;
g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page)); ENTER("(fd %p, page %p)", fd, page);
ENTER("(action %p, page %p)", action, page);
priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page); if (fd->dialog) {
if (priv->fd.dialog) { gtk_window_present(GTK_WINDOW(fd->dialog));
gtk_window_present(GTK_WINDOW(priv->fd.dialog));
LEAVE("existing dialog"); LEAVE("existing dialog");
return; return;
} }
@ -1494,7 +1490,7 @@ gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action,
/* Create the dialog */ /* Create the dialog */
xml = gnc_glade_xml_new ("account.glade", "Filter By"); xml = gnc_glade_xml_new ("account.glade", "Filter By");
dialog = glade_xml_get_widget (xml, "Filter By"); dialog = glade_xml_get_widget (xml, "Filter By");
priv->fd.dialog = dialog; fd->dialog = dialog;
gtk_window_set_transient_for(GTK_WINDOW(dialog), gtk_window_set_transient_for(GTK_WINDOW(dialog),
GTK_WINDOW(GNC_PLUGIN_PAGE(page)->window)); GTK_WINDOW(GNC_PLUGIN_PAGE(page)->window));
/* Translators: The %s is the name of the plugin page */ /* Translators: The %s is the name of the plugin page */
@ -1504,37 +1500,51 @@ gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action,
g_free(title); g_free(title);
/* Remember current state */ /* Remember current state */
priv->fd.original_visible_types = priv->fd.visible_types; fd->original_visible_types = fd->visible_types;
priv->fd.original_hide_zero_total = priv->fd.hide_zero_total; fd->original_hide_zero_total = fd->hide_zero_total;
/* Update the dialog widgets for the current state */ /* Update the dialog widgets for the current state */
button = glade_xml_get_widget (xml, "hide_zero"); button = glade_xml_get_widget (xml, "hide_zero");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
priv->fd.hide_zero_total); fd->hide_zero_total);
view = GTK_TREE_VIEW(glade_xml_get_widget (xml, FILTER_TREE_VIEW)); view = GTK_TREE_VIEW(glade_xml_get_widget (xml, FILTER_TREE_VIEW));
priv->fd.model = gnc_tree_model_account_types_master(); fd->model = gnc_tree_model_account_types_master();
gtk_tree_view_set_model(view, priv->fd.model); gtk_tree_view_set_model(view, fd->model);
gtk_tree_view_insert_column_with_attributes gtk_tree_view_insert_column_with_attributes
(view, (view,
-1, _("Account Types"), gtk_cell_renderer_text_new(), -1, _("Account Types"), gtk_cell_renderer_text_new(),
"text", GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME, NULL); "text", GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME, NULL);
selection = gtk_tree_view_get_selection(view); selection = gtk_tree_view_get_selection(view);
gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
gnc_tree_model_account_types_set_selection(view, priv->fd.visible_types); gnc_tree_model_account_types_set_selection(view, fd->visible_types);
priv->fd.selection_changed_cb_id = fd->selection_changed_cb_id =
g_signal_connect(G_OBJECT(selection), "changed", g_signal_connect(G_OBJECT(selection), "changed",
G_CALLBACK(gppat_filter_selection_changed_cb), &priv->fd); G_CALLBACK(gppat_filter_selection_changed_cb), fd);
/* Wire up the rest of the callbacks */ /* Wire up the rest of the callbacks */
glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
&priv->fd); fd);
/* Show it */ /* Show it */
gtk_widget_show_all(dialog); gtk_widget_show_all(dialog);
LEAVE(" "); LEAVE(" ");
} }
static void
gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action,
GncPluginPageAccountTree *page)
{
GncPluginPageAccountTreePrivate *priv;
g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page));
ENTER("(action %p, page %p)", action, page);
priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
account_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(page));
LEAVE(" ");
}
static void static void
gnc_plugin_page_account_tree_cmd_reconcile (GtkAction *action, gnc_plugin_page_account_tree_cmd_reconcile (GtkAction *action,
GncPluginPageAccountTree *page) GncPluginPageAccountTree *page)

View File

@ -77,6 +77,9 @@ typedef struct {
gulong selection_changed_cb_id; gulong selection_changed_cb_id;
} AccountFilterDialog; } AccountFilterDialog;
void
account_filter_dialog_create(AccountFilterDialog *fd, GncPluginPage *page);
/* function prototypes */ /* function prototypes */
/** Retrieve the type number for an "account tree" plugin page. /** Retrieve the type number for an "account tree" plugin page.