From 273b7439aa362dc1e23dcf0cb2aeb440f787be17 Mon Sep 17 00:00:00 2001
From: Robert Fewell <14uBobIT@gmail.com>
Date: Sun, 30 Oct 2022 13:29:59 +0000
Subject: [PATCH] Changes for sx plugin pages
---
gnucash/gnome/gnc-plugin-page-sx-list.c | 78 ++++++----
gnucash/gnucash-gresources.xml | 1 +
gnucash/ui/gnc-plugin-page-sx-list.ui | 190 ++++++++++++++++++++++++
3 files changed, 241 insertions(+), 28 deletions(-)
create mode 100644 gnucash/ui/gnc-plugin-page-sx-list.ui
diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c
index 83db9d06b1..40be33ced3 100644
--- a/gnucash/gnome/gnc-plugin-page-sx-list.c
+++ b/gnucash/gnome/gnc-plugin-page-sx-list.c
@@ -124,6 +124,7 @@ static void gnc_plugin_page_sx_list_cmd_new (GSimpleAction *simple, GVariant *pa
static void gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
static void gnc_plugin_page_sx_list_cmd_delete (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
static void gnc_plugin_page_sx_list_cmd_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
+static void gnc_plugin_page_sx_list_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
/* Command callbacks */
static GActionEntry gnc_plugin_page_sx_list_actions [] =
@@ -133,6 +134,7 @@ static GActionEntry gnc_plugin_page_sx_list_actions [] =
{ "SxListEditAction", gnc_plugin_page_sx_list_cmd_edit, NULL, NULL, NULL },
{ "SxListDeleteAction", gnc_plugin_page_sx_list_cmd_delete, NULL, NULL, NULL },
{ "ViewRefreshAction", gnc_plugin_page_sx_list_cmd_refresh, NULL, NULL, NULL },
+ { "EditTaxOptionsAction", gnc_plugin_page_sx_list_cmd_edit_tax_options, NULL, NULL, NULL },
};
/** The number of actions provided by this plugin. */
static guint gnc_plugin_page_sx_list_n_actions = G_N_ELEMENTS(gnc_plugin_page_sx_list_actions);
@@ -161,6 +163,17 @@ static GncDisplayItem gnc_plugin_page_sx_list_display_items [] =
/** The number of display items provided by this plugin. */
static guint gnc_plugin_page_sx_list_n_display_items = G_N_ELEMENTS(gnc_plugin_page_sx_list_display_items);
+/** The default menu items that need to be add to the menu */
+static const gchar *gnc_plugin_load_ui_items [] =
+{
+ "EditPlaceholder3",
+ "EditPlaceholder5",
+ "ViewPlaceholder4",
+ "SchedulePlaceholder0",
+ NULL,
+};
+
+
GncPluginPage *
gnc_plugin_page_sx_list_new (void)
{
@@ -188,6 +201,16 @@ gnc_plugin_page_sx_list_focus_widget (GncPluginPage *sx_plugin_page)
GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(sx_plugin_page);
GtkTreeView *tree_view = priv->tree_view;
+ /* Disable the Transaction Menu */
+ GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(sx_plugin_page->window), "TransactionAction");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
+ /* Enable the Schedule Menu */
+ action = gnc_main_window_find_action (GNC_MAIN_WINDOW(sx_plugin_page->window), "ScheduledAction");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
+
+ gnc_main_window_update_menu (GNC_MAIN_WINDOW(sx_plugin_page->window), sx_plugin_page,
+ gnc_plugin_load_ui_items);
+
if (GTK_IS_TREE_VIEW(tree_view))
{
if (!gtk_widget_is_focus (GTK_WIDGET(tree_view)))
@@ -384,26 +407,6 @@ gppsl_model_populated_cb (GtkTreeModel *tree_model, GncPluginPageSxList *page)
}
}
-static void
-gpps_new_cb (GtkMenuItem *menuitem, GncPluginPageSxList *page)
-{
- gnc_plugin_page_sx_list_cmd_new (NULL, NULL, page);
- return;
-}
-
-static void
-gpps_edit_cb (GtkMenuItem *menuitem, GncPluginPageSxList *page)
-{
- gnc_plugin_page_sx_list_cmd_edit (NULL, NULL, page);
- return;
-}
-
-static void
-gpps_delete_cb (GtkMenuItem *menuitem, GncPluginPageSxList *page)
-{
- gnc_plugin_page_sx_list_cmd_delete (NULL, NULL, page);
- return;
-}
static void
treeview_popup (GtkTreeView *treeview, GdkEvent *event, GncPluginPageSxList *page)
@@ -413,21 +416,27 @@ treeview_popup (GtkTreeView *treeview, GdkEvent *event, GncPluginPageSxList *pag
GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view);
gint count_selection = gtk_tree_selection_count_selected_rows (selection);
GtkWidget *menu, *menuitem;
+ gchar *full_action_name;
+ const gchar *group_name = gnc_plugin_page_get_simple_action_group_name (GNC_PLUGIN_PAGE(page));
menu = gtk_menu_new();
menuitem = gtk_menu_item_new_with_mnemonic (_("_New"));
- g_signal_connect (menuitem, "activate", G_CALLBACK(gpps_new_cb), page);
+ full_action_name = g_strconcat (group_name, ".SxListNewAction", NULL);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name);
+ g_free (full_action_name);
gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_menu_item_new_with_mnemonic (_("_Edit"));
- g_signal_connect (menuitem, "activate", G_CALLBACK(gpps_edit_cb), page);
- gtk_widget_set_sensitive (menuitem, count_selection > 0);
+ full_action_name = g_strconcat (group_name, ".SxListEditAction", NULL);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name);
+ g_free (full_action_name);
gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_menu_item_new_with_mnemonic (_("_Delete"));
- g_signal_connect (menuitem, "activate", G_CALLBACK(gpps_delete_cb), page);
- gtk_widget_set_sensitive (menuitem, count_selection > 0);
+ full_action_name = g_strconcat (group_name, ".SxListDeleteAction", NULL);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name);
+ g_free (full_action_name);
gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (priv->tree_view), NULL);
@@ -542,15 +551,13 @@ gnc_plugin_page_sx_list_create_widget (GncPluginPage *plugin_page)
selection = gtk_tree_view_get_selection (priv->tree_view);
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
- gtk_tree_selection_select_path (selection, path);
- gtk_tree_path_free (path);
g_signal_connect (G_OBJECT(selection), "changed", (GCallback)gppsl_selection_changed_cb, (gpointer)page);
g_signal_connect (G_OBJECT(priv->tree_view), "row-activated", (GCallback)gppsl_row_activated_cb, (gpointer)page);
g_signal_connect (G_OBJECT(gtk_tree_view_get_model (GTK_TREE_VIEW(priv->tree_view))),
"model-populated", (GCallback)gppsl_model_populated_cb, (gpointer)page);
- gppsl_selection_changed_cb (selection, page);
+ gtk_tree_selection_select_path (selection, path);
gtk_tree_path_free (path);
}
@@ -810,6 +817,21 @@ gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple,
g_list_free (selected_paths);
}
+
+static void
+gnc_plugin_page_sx_list_cmd_edit_tax_options (GSimpleAction *simple,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GncPluginPageSxList *plugin_page = user_data;
+ GtkWidget *window = GTK_WIDGET(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page)));
+
+ ENTER ("(action %p, page %p)", simple, plugin_page);
+ gnc_tax_info_dialog (window, NULL);
+ LEAVE (" ");
+}
+
+
static void
gppsl_row_activated_cb (GtkTreeView *tree_view,
GtkTreePath *path,
diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml
index e3320694d3..39d0c02904 100644
--- a/gnucash/gnucash-gresources.xml
+++ b/gnucash/gnucash-gresources.xml
@@ -21,6 +21,7 @@
ui/gnc-plugin-page-account-tree.ui
ui/gnc-plugin-page-budget.ui
ui/gnc-plugin-page-register.ui
+ ui/gnc-plugin-page-sx-list.ui
ui/gnc-plugin-ofx.ui
ui/gnc-plugin-aqbanking.ui
diff --git a/gnucash/ui/gnc-plugin-page-sx-list.ui b/gnucash/ui/gnc-plugin-page-sx-list.ui
new file mode 100644
index 0000000000..5ff5a5a912
--- /dev/null
+++ b/gnucash/ui/gnc-plugin-page-sx-list.ui
@@ -0,0 +1,190 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+