diff --git a/gnucash/gnome-utils/gnc-embedded-window.c b/gnucash/gnome-utils/gnc-embedded-window.c index e0855f6f5f..7ff112bb43 100644 --- a/gnucash/gnome-utils/gnc-embedded-window.c +++ b/gnucash/gnome-utils/gnc-embedded-window.c @@ -39,6 +39,7 @@ #include "gnc-ui.h" #include "gnc-window.h" #include "dialog-utils.h" +#include "gnc-gtk-utils.h" /** Names of signals generated by the embedded window. */ enum @@ -72,8 +73,12 @@ typedef struct GncEmbeddedWindowPrivate * stored here when the UI manager provides them to the main * window. */ GtkWidget *menu_dock; - /* The toolbar created by the UI manager. This pointer provides - * easy access for showing/hiding the toolbar. */ + /** The menubar */ + GtkWidget *menubar; //FIXMEb added + /** The menubar_model */ + GMenuModel *menubar_model; //FIXMEb added + /** The toolbar. This pointer provides easy access for + * showing/hiding the toolbar. */ GtkWidget *toolbar; /** A pointer to the status bar at the bottom edge of the window. * This pointer provides easy access for updating/showing/hiding @@ -83,7 +88,7 @@ typedef struct GncEmbeddedWindowPrivate /** The group of all actions provided by the main window itself. * This does not include any action provided by menu or content * plugins. */ - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; //FIXMEb added /** The currently selected page. */ GncPluginPage *page; @@ -123,8 +128,6 @@ gnc_embedded_window_open_page (GncEmbeddedWindow *window, gtk_box_pack_end(GTK_BOX(window), page->notebook_page, TRUE, TRUE, 2); gnc_plugin_page_inserted (page); - - gnc_plugin_page_merge_actions (page, window->ui_merge); LEAVE(" "); } @@ -153,9 +156,6 @@ gnc_embedded_window_close_page (GncEmbeddedWindow *window, priv->page = NULL; gnc_plugin_page_removed (page); - gnc_plugin_page_unmerge_actions (page, window->ui_merge); - gtk_ui_manager_ensure_update (window->ui_merge); - gnc_plugin_page_destroy_widget (page); g_object_unref(page); LEAVE(" "); @@ -236,8 +236,8 @@ gnc_embedded_window_init (GncEmbeddedWindow *window, void *data) gnc_embedded_window_setup_window (window); - gnc_gobject_tracking_remember(G_OBJECT(window), - G_OBJECT_CLASS(klass)); + gnc_gobject_tracking_remember (G_OBJECT(window), + G_OBJECT_CLASS(klass)); LEAVE(" "); } @@ -274,6 +274,7 @@ gnc_embedded_window_dispose (GObject *object) ENTER("object %p", object); window = GNC_EMBEDDED_WINDOW (object); priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); + if (priv->page) { DEBUG("unreffing page %p (count currently %d)", priv->page, @@ -287,30 +288,6 @@ gnc_embedded_window_dispose (GObject *object) } -static void -gnc_embedded_window_add_widget (GtkUIManager *merge, - GtkWidget *widget, - GncEmbeddedWindow *window) -{ - GncEmbeddedWindowPrivate *priv; - - ENTER("merge %p, new widget %p, window %p", merge, widget, window); - priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); - if (GTK_IS_TOOLBAR (widget)) - { - priv->toolbar = widget; - gtk_toolbar_set_style (GTK_TOOLBAR(priv->toolbar), - GTK_TOOLBAR_BOTH); - gtk_toolbar_set_icon_size (GTK_TOOLBAR(priv->toolbar), - GTK_ICON_SIZE_SMALL_TOOLBAR); - } - - gtk_box_pack_start (GTK_BOX (priv->menu_dock), widget, FALSE, FALSE, 0); - gtk_widget_show (widget); - LEAVE(" "); -} - - /** Initialize the data structures of a gnucash embedded window. * * @param window The object to initialize. */ @@ -334,15 +311,7 @@ gnc_embedded_window_setup_window (GncEmbeddedWindow *window) gtk_widget_show (priv->statusbar); gtk_box_pack_end (GTK_BOX (window), priv->statusbar, FALSE, TRUE, 0); - window->ui_merge = gtk_ui_manager_new (); - g_signal_connect (G_OBJECT (window->ui_merge), "add_widget", - G_CALLBACK (gnc_embedded_window_add_widget), window); - - /* Use the "connect-proxy" signal for tooltip display in the status bar */ - g_signal_connect (G_OBJECT (window->ui_merge), "connect-proxy", - G_CALLBACK (gnc_window_connect_proxy), priv->statusbar); - - priv->action_group = NULL; + priv->simple_action_group = NULL; LEAVE(" "); } @@ -350,7 +319,7 @@ gnc_embedded_window_setup_window (GncEmbeddedWindow *window) /** Create a new gnc embedded window plugin. */ GncEmbeddedWindow * gnc_embedded_window_new (const gchar *action_group_name, - GtkActionEntry *action_entries, + GActionEntry *action_entries, gint n_action_entries, const gchar *ui_filename, GtkWidget *enclosing_win, @@ -361,48 +330,61 @@ gnc_embedded_window_new (const gchar *action_group_name, GncEmbeddedWindow *window; gchar *ui_fullname; GError *error = NULL; - guint merge_id; + GtkBuilder *builder; + GtkAccelGroup *accel_group; ENTER("group %s, first %p, num %d, ui file %s, parent %p, add accelerators %d, user data %p", action_group_name, action_entries, n_action_entries, ui_filename, enclosing_win, add_accelerators, user_data); + window = g_object_new (GNC_TYPE_EMBEDDED_WINDOW, NULL); priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); - /* Determine the full pathname of the ui file */ - ui_fullname = gnc_filepath_locate_ui_file (ui_filename); - g_return_val_if_fail (ui_fullname != NULL, NULL); + builder = gtk_builder_new (); + gtk_builder_set_translation_domain (builder, PROJECT_NAME); + + ui_fullname = g_strconcat ("/org/gnucash/ui/", ui_filename, NULL); + + gtk_builder_add_from_resource (builder, ui_fullname, &error); + + if (error) + { + g_critical ("Failed to load, Error %s", error->message); + g_error_free (error); + return NULL; //FIXMEb this may need changing + } + + priv->menubar_model = (GMenuModel *)gtk_builder_get_object (builder, "embeddedwin-menu"); + + priv->menubar = gtk_menu_bar_new_from_model (priv->menubar_model); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), priv->menubar); //FIXMEb this may need changing + gtk_widget_show (GTK_WIDGET(priv->menubar)); + + priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, "embeddedwin-toolbar"); + g_object_set (priv->toolbar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(priv->toolbar)); //FIXMEb this may need changing + gtk_widget_show (GTK_WIDGET(priv->toolbar)); + + g_object_unref (builder); + + priv->simple_action_group = g_simple_action_group_new (); + + g_action_map_add_action_entries (G_ACTION_MAP(priv->simple_action_group), + action_entries, + n_action_entries, + user_data); + + gtk_widget_insert_action_group (GTK_WIDGET(window), "embeddedwin", + G_ACTION_GROUP(priv->simple_action_group)); priv->parent_window = enclosing_win; - /* Create menu and toolbar information */ - priv->action_group = gtk_action_group_new (action_group_name); - gtk_action_group_set_translation_domain(priv->action_group, PROJECT_NAME); - gtk_action_group_add_actions (priv->action_group, action_entries, - n_action_entries, user_data); - gtk_ui_manager_insert_action_group (window->ui_merge, priv->action_group, 0); - merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, ui_fullname, - &error); + // need to add the accelerator keys + accel_group = gtk_accel_group_new (); + gtk_window_add_accel_group (GTK_WINDOW(enclosing_win), accel_group); + gnc_add_accelerator_keys_for_menu (GTK_WIDGET(priv->menubar), accel_group); - /* Error checking */ - g_assert(merge_id || error); - if (error) - { - g_critical("Failed to load ui file.\n Filename %s\n Error %s", - ui_fullname, error->message); - g_error_free(error); - g_free(ui_fullname); - LEAVE("window %p", window); - return window; - } - - /* Add accelerators (if wanted) */ - if (add_accelerators) - gtk_window_add_accel_group (GTK_WINDOW(enclosing_win), - gtk_ui_manager_get_accel_group(window->ui_merge)); - - gtk_ui_manager_ensure_update (window->ui_merge); - g_free(ui_fullname); + g_free (ui_fullname); LEAVE("window %p", window); return window; } @@ -446,6 +428,58 @@ gnc_embedded_window_get_statusbar (GncWindow *window_in) } +/** Retrieve the menu bar associated with an embedded window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GtkWidget * +gnc_embedded_window_get_menubar (GncWindow *window) +{ + GncEmbeddedWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW(window), NULL); + + priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); + + return priv->menubar; +} + +/** Retrieve the tool bar associated with an embedded window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GtkWidget * +gnc_embedded_window_get_toolbar (GncWindow *window) +{ + GncEmbeddedWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW(window), NULL); + + priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); + + return priv->toolbar; +} + +/** Retrieve the display hash table associated with an embedded window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GMenuModel * +gnc_embedded_window_get_menubar_model (GncWindow *window) +{ + GncEmbeddedWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW(window), NULL); + + priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); + + return priv->menubar_model; +} + + /** Initialize the generic window interface for an embedded window. * * @param iface A pointer to the interface data structure to @@ -453,6 +487,9 @@ gnc_embedded_window_get_statusbar (GncWindow *window_in) static void gnc_window_embedded_window_init (GncWindowIface *iface) { - iface->get_gtk_window = gnc_embedded_window_get_gtk_window; - iface->get_statusbar = gnc_embedded_window_get_statusbar; + iface->get_gtk_window = gnc_embedded_window_get_gtk_window; + iface->get_statusbar = gnc_embedded_window_get_statusbar; + iface->get_menubar = gnc_embedded_window_get_menubar; + iface->get_toolbar = gnc_embedded_window_get_toolbar; + iface->get_menubar_model = gnc_embedded_window_get_menubar_model; } diff --git a/gnucash/gnome-utils/gnc-embedded-window.h b/gnucash/gnome-utils/gnc-embedded-window.h index d893982951..86774b174f 100644 --- a/gnucash/gnome-utils/gnc-embedded-window.h +++ b/gnucash/gnome-utils/gnc-embedded-window.h @@ -57,9 +57,6 @@ typedef struct { /** The parent object for an embedded window. */ GtkBox vbox; - /** A pointer to the UI Manager data structure for the whole - * window. */ - GtkUIManager *ui_merge; } GncEmbeddedWindow; @@ -88,12 +85,12 @@ GType gnc_embedded_window_get_type (void); * @return A pointer to the new object. */ GncEmbeddedWindow *gnc_embedded_window_new (const gchar *action_group_name, - GtkActionEntry *action_entries, - gint n_action_entries, - const gchar *ui_filename, - GtkWidget *enclosing_win, - gboolean add_accelerators, - gpointer user_data); + GActionEntry *action_entries, + gint n_action_entries, + const gchar *ui_filename, + GtkWidget *enclosing_win, + gboolean add_accelerators, + gpointer user_data); /** Display a data plugin page in a window. diff --git a/gnucash/gnome-utils/gnc-gtk-utils.c b/gnucash/gnome-utils/gnc-gtk-utils.c index 70686c6902..b9b8840d8a 100644 --- a/gnucash/gnome-utils/gnc-gtk-utils.c +++ b/gnucash/gnome-utils/gnc-gtk-utils.c @@ -332,3 +332,698 @@ gnc_get_dialog_widget_from_id (GtkDialog *dialog, const gchar *id) GtkWidget *content_area = gtk_dialog_get_content_area (dialog); return find_widget_func (content_area, id); } + + +/** Disable all the actions in a simple action group + * + * @param action_group The GSimpleActionGroup + */ +void +gnc_disable_all_actions_in_group (GSimpleActionGroup *action_group) +{ + gchar **actions; + gint num_actions; + + g_return_if_fail (action_group != NULL); + + actions = g_action_group_list_actions (G_ACTION_GROUP(action_group)); + num_actions = g_strv_length (actions); + + // Disable the actions + for (gint i = 0; i < num_actions; i++) + { + GAction *action = g_action_map_lookup_action (G_ACTION_MAP(action_group), + actions[i]); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + } + g_strfreev (actions); +} + + +static void +add_accel_for_menu_lookup (GtkWidget *widget, gpointer user_data) +{ + if (GTK_IS_MENU_ITEM(widget)) + { + GtkMenuItem* menuItem = GTK_MENU_ITEM(widget); + GtkWidget* subMenu = gtk_menu_item_get_submenu (menuItem); + GtkWidget *accel_label = gtk_bin_get_child (GTK_BIN(widget)); + + if (accel_label) + { + guint key; + GdkModifierType mods; + + gtk_accel_label_get_accel (GTK_ACCEL_LABEL(accel_label), &key, &mods); + + if (key > 0) + gtk_widget_add_accelerator (GTK_WIDGET(widget), "activate", + GTK_ACCEL_GROUP(user_data), + key, mods, GTK_ACCEL_VISIBLE); + } + if (GTK_IS_CONTAINER(subMenu)) + gtk_container_foreach (GTK_CONTAINER(subMenu), + add_accel_for_menu_lookup, user_data); + } +} + +/** Add accelerator keys for menu item widgets + * + * @param menu The menu widget. + * + * @param accel_group The accelerator group to use. + */ +void +gnc_add_accelerator_keys_for_menu (GtkWidget *menu, GtkAccelGroup *accel_group) +{ + g_return_if_fail (GTK_IS_WIDGET(menu)); + g_return_if_fail (accel_group != NULL); + + gtk_container_foreach (GTK_CONTAINER(menu), add_accel_for_menu_lookup, accel_group); +} + + +static gpointer +find_menu_item_func (GtkWidget *widget, const gchar *action_name, const gchar *action_label) +{ + GtkWidget *ret = NULL; + + if (GTK_IS_MENU_ITEM(widget)) + { + GtkWidget* subMenu; + + if (action_name) + { + if (GTK_IS_ACTIONABLE(widget)) + { + const gchar *a_name = gtk_actionable_get_action_name (GTK_ACTIONABLE(widget)); + + if (g_strcmp0 (a_name, action_name) == 0) + return widget; + } + } + + if (action_label) + { + GtkWidget *accel_label = gtk_bin_get_child (GTK_BIN(widget)); + + if (accel_label) + { + // use gtk_label_get_text to get text with no underlines + const gchar *al_name = gtk_label_get_label (GTK_LABEL(accel_label)); + + if (g_strcmp0 (al_name, action_label) == 0) + return widget; + } + } + + subMenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(widget)); + + if (GTK_IS_CONTAINER(subMenu)) + { + GList *container_list = gtk_container_get_children (GTK_CONTAINER(subMenu)); + for (GList *n = container_list; !ret && n; n = n->next) + ret = find_menu_item_func (n->data, action_name, action_label); + g_list_free (container_list); + } + } + return ret; +} + +/** Search the menu for the menu item based on action name + * + * @param menu The menu widget. + * + * @param action_name The GAction name. + * + * @return The menu item widget or NULL. + */ +GtkWidget * +gnc_find_menu_item_by_action_name (GtkWidget *menu, const gchar *action_name) +{ + GtkWidget *ret = NULL; + const gchar *action_label = NULL; + + g_return_val_if_fail (GTK_IS_WIDGET(menu), NULL); + g_return_val_if_fail (action_name != NULL, NULL); + + if (GTK_IS_CONTAINER(menu)) + { + GList *container_list = gtk_container_get_children (GTK_CONTAINER(menu)); + for (GList *n = container_list; !ret && n; n = n->next) + ret = find_menu_item_func (n->data, action_name, action_label); + g_list_free (container_list); + } + return ret; +} + + +/** Search the menu for the menu item based on the action label + * + * @param menu The menu widget. + * + * @param action_label The GtkMenuItem label. + * + * @return The menu item widget or NULL. + */ +GtkWidget * +gnc_find_menu_item_by_action_label (GtkWidget *menu, const gchar *action_label) +{ + GtkWidget *ret = NULL; + const gchar *action_name = NULL; + + g_return_val_if_fail (GTK_IS_WIDGET(menu), NULL); + g_return_val_if_fail (action_label != NULL, NULL); + + if (GTK_IS_CONTAINER(menu)) + { + GList *container_list = gtk_container_get_children (GTK_CONTAINER(menu)); + for (GList *n = container_list; !ret && n; n = n->next) + ret = find_menu_item_func (n->data, action_name, action_label); + g_list_free (container_list); + } + return ret; +} + + +static void +menu_item_list (GtkWidget *widget, gpointer user_data) +{ + GList **list = user_data; + + if (GTK_IS_MENU_ITEM(widget)) + { + GtkWidget* subMenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(widget)); + + *list = g_list_prepend (*list, widget); + + if (GTK_IS_CONTAINER(subMenu)) + gtk_container_foreach (GTK_CONTAINER(subMenu), + menu_item_list, user_data); + } +} + +/** Return a list of GtkMenuItems + * + * @param menu The menu widget. + * + * @return A GList of menu items or NULL. + */ +GList * +gnc_menu_get_items (GtkWidget *menu) +{ + GList *list = NULL; + + g_return_val_if_fail (GTK_IS_WIDGET(menu), NULL); + + gtk_container_foreach (GTK_CONTAINER(menu), menu_item_list, &list); + + return list; +} + + +struct find_tool_item_struct +{ + GtkWidget *found_tool_item; + const gchar *action_name; +}; + +static void +find_tool_action (GtkWidget *widget, gpointer user_data) +{ + struct find_tool_item_struct *ftis = user_data; + + if (GTK_IS_ACTIONABLE(widget)) + { + // this returns the full action name + const gchar *item_action_name = gtk_actionable_get_action_name (GTK_ACTIONABLE(widget)); + + if (g_str_has_suffix (item_action_name, ftis->action_name)) + ftis->found_tool_item = GTK_WIDGET(widget); + } +} + +/** Search the toolbar for the tool item based on the action name + * + * @param toolbar The toolbar widget. + * + * @param action_name The GAction name. + * + * @return The tool item widget or NULL. + */ +GtkWidget * +gnc_find_toolbar_item (GtkWidget *toolbar, const gchar *action_name) +{ + struct find_tool_item_struct ftis; + + g_return_val_if_fail (GTK_IS_TOOLBAR(toolbar), NULL); + g_return_val_if_fail (action_name != NULL, NULL); + + ftis.action_name = action_name; + ftis.found_tool_item = NULL; + + gtk_container_foreach (GTK_CONTAINER(toolbar), find_tool_action, &ftis); + + return ftis.found_tool_item; +} + + +static void +extract_items_from_model (GMenuModel *model, + gint item, + gpointer user_data) +{ + GMenuAttributeIter *iter; + const gchar *key; + GVariant *value; + GncMenuModelSearch *gsm = user_data; + const gchar *action = NULL; + const gchar *label = NULL; + const gchar *tooltip = NULL; + + iter = g_menu_model_iterate_item_attributes (model, item); + while (g_menu_attribute_iter_get_next (iter, &key, &value)) + { + if (g_str_equal (key, GNC_MENU_ATTRIBUTE_TOOLTIP) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + tooltip = g_variant_get_string (value, NULL); + else if (g_str_equal (key, G_MENU_ATTRIBUTE_LABEL) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + label = g_variant_get_string (value, NULL); + else if (g_str_equal (key, G_MENU_ATTRIBUTE_ACTION) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + action = g_variant_get_string (value, NULL); + + g_variant_unref (value); + } + + if (action && gsm->search_action_name) + { + if (g_str_has_suffix (action, gsm->search_action_name)) + { + gsm->model = model; + gsm->index = item; + gsm->tooltip = tooltip; + gsm->search_action_label = label; + } + } + if (label && gsm->search_action_label) + { + if (g_strcmp0 (label, gsm->search_action_label) == 0) + { + gsm->model = model; + gsm->index = item; + gsm->tooltip = tooltip; + gsm->search_action_name = action; + } + } + g_object_unref (iter); +} + +static void +items_from_model (GMenuModel *model, + gpointer user_data) +{ + GncMenuModelSearch *gsm = user_data; + + for (gint i = 0; i < g_menu_model_get_n_items (model); i++) + { + GMenuLinkIter *iter; + GMenuModel *sub_model; + + if (gsm->model) + return; + + extract_items_from_model (model, i, user_data); + + iter = g_menu_model_iterate_item_links (model, i); + while (g_menu_link_iter_get_next (iter, NULL, &sub_model)) + { + items_from_model (sub_model, user_data); + g_object_unref (sub_model); + } + g_object_unref (iter); + } +} + +/** Find a GtkMenu item from the action name. This is done by first finding + * the action name in the GMenuModel and then doing a search for the + * label text in the GtkMenu. + * + * NOTE: This is done this way as the action_name field of the GtkMenuItem + * is not populated from the model. + * + * @param menu_model The GMenuModel of the menu. + * + * @param gsm The GncMenuModelSearch structure. + * + * @return TRUE if GMenuModel item found or FALSE if not. + */ +gboolean +gnc_menubar_model_find_item (GMenuModel *menu_model, GncMenuModelSearch *gsm) +{ + + g_return_val_if_fail (menu_model != NULL, FALSE); + g_return_val_if_fail (gsm != NULL, FALSE); + + gsm->model = NULL; + + items_from_model (menu_model, gsm); + + if (gsm->model) + return TRUE; + + return FALSE; +} + + +/** Find a GtkMenu item from the action name. This is done by first finding + * the action name in the GMenuModel and then doing a search for the + * label text in the GtkMenu. + * + * NOTE: This is done this way as the action_name field of the GtkMenuItem + * is not populated from the model. + * + * @param menu_model The GMenuModel of the menu. + * + * @param menu The GtkMenu built from the model. + * + * @param action_name The action name of the menu item to find. + * + * @return The GtkMenuItem if found or NULL + */ +GtkWidget * +gnc_menubar_model_find_menu_item (GMenuModel *menu_model, GtkWidget *menu, const gchar *action_name) +{ + GncMenuModelSearch *gsm; + GtkWidget *menu_item = NULL; + + g_return_val_if_fail (menu_model != NULL, NULL); + g_return_val_if_fail (menu != NULL, NULL); + g_return_val_if_fail (action_name != NULL, NULL); + + gsm = g_new0 (GncMenuModelSearch, 1); + + gsm->search_action_label = NULL; + gsm->search_action_name = action_name; + + if (gnc_menubar_model_find_item (menu_model, gsm)) + menu_item = gnc_find_menu_item_by_action_label (menu, gsm->search_action_label); + + g_free (gsm); + return menu_item; +} + + +/** Update the GMenuModel item based on the action name by copying + * existing item, removing it and inserting a new one in same location. + * + * @param menu_model The GMenuModel of the menu. + * + * @param action_name The action name to update. + * + * @param label The new menu label text. + * + * @param tooltip The new tooltip text if any. + * + * @return TRUE if item found and updated or FALSE if not. + */ +gboolean +gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name, + const gchar *label, const gchar *tooltip) +{ + GncMenuModelSearch *gsm; + GtkWidget *menu_item = NULL; + gboolean found = FALSE; + + g_return_val_if_fail (menu_model != NULL, FALSE); + g_return_val_if_fail (action_name != NULL, FALSE); + g_return_val_if_fail (label != NULL, FALSE); + + gsm = g_new0 (GncMenuModelSearch, 1); + + gsm->search_action_label = NULL; + gsm->search_action_name = action_name; + + if (gnc_menubar_model_find_item (menu_model, gsm)) + { + GMenuAttributeIter *iter; + const gchar *key; + GVariant *value; + GVariant *old_target = NULL; + const gchar *old_action = NULL; + const gchar *old_label = NULL; + const gchar *old_temp = NULL; + const gchar *old_accel = NULL; + GMenuItem *item; + + iter = g_menu_model_iterate_item_attributes (gsm->model, gsm->index); + while (g_menu_attribute_iter_get_next (iter, &key, &value)) + { + if (g_str_equal (key, GNC_MENU_ATTRIBUTE_TEMPORARY) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + old_temp = g_variant_get_string (value, NULL); + else if (g_str_equal (key, G_MENU_ATTRIBUTE_LABEL) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + old_label = g_variant_get_string (value, NULL); + else if (g_str_equal (key, G_MENU_ATTRIBUTE_ACTION) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + old_action = g_variant_get_string (value, NULL); + else if (g_str_equal (key, GNC_MENU_ATTRIBUTE_ACCELERATOR) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + old_accel = g_variant_get_string (value, NULL); + else if (g_str_equal (key, G_MENU_ATTRIBUTE_TARGET)) + old_target = g_variant_ref (value); + + g_variant_unref (value); + } + + item = g_menu_item_new (label, old_action); + + if (tooltip) + g_menu_item_set_attribute (item, GNC_MENU_ATTRIBUTE_TOOLTIP, "s", tooltip); + + if (old_temp) + g_menu_item_set_attribute (item, GNC_MENU_ATTRIBUTE_TEMPORARY, "s", old_temp); + + if (old_accel) + g_menu_item_set_attribute (item, GNC_MENU_ATTRIBUTE_ACCELERATOR, "s", old_accel); + + if (old_target) + { + g_menu_item_set_attribute_value (item, G_MENU_ATTRIBUTE_TARGET, old_target); + g_variant_unref (old_target); + } + g_menu_remove (G_MENU(gsm->model), gsm->index); + g_menu_insert_item (G_MENU(gsm->model), gsm->index, item); + found = TRUE; + } + g_free (gsm); + return found; +} + + +typedef struct +{ + GMenuModel *model; + gint index; +} to_remove; + +static void +item_to_remove_from_model (GMenuModel *model, + gint item, + GList **remove_list, + const gchar *attrib) +{ + GVariant *value = g_menu_model_get_item_attribute_value (model, item, + attrib, NULL); + + if (value && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + { + to_remove *tr = g_new0 (to_remove, 1); + tr->model = model; + tr->index = item; + + // to keep the order append + *remove_list = g_list_append (*remove_list, tr); + g_variant_unref (value); + } +} + +static void +remove_items_from_model (GMenuModel *model, + GList **remove_list, + const gchar *attrib) +{ + // Note: item high to low + for (gint i = g_menu_model_get_n_items (model) -1; i >= 0; i--) + { + GMenuLinkIter *iter; + GMenuModel *sub_model; + + item_to_remove_from_model (model, i, remove_list, attrib); + + iter = g_menu_model_iterate_item_links (model, i); + while (g_menu_link_iter_get_next (iter, NULL, &sub_model)) + { + remove_items_from_model (sub_model, remove_list, attrib); + g_object_unref (sub_model); + } + g_object_unref (iter); + } +} + +static void +remove_items (gpointer data, gpointer user_data) +{ + to_remove *tr = (to_remove*)data; + g_menu_remove (G_MENU(tr->model), tr->index); + g_free (tr); +} + +/** Remove GMenuModel entries based on having an attribute value equal + * to attrib, it does not matter what the value is. + * + * @param menu_model The GMenuModel of the menu. + * + * @param attrib The attribute to look for. + */ +void +gnc_menubar_model_remove_items_with_attrib (GMenuModel *menu_model, const gchar *attrib) +{ + GList *remove_list = NULL; + + g_return_if_fail (menu_model != NULL); + g_return_if_fail (attrib != NULL); + + remove_items_from_model (menu_model, &remove_list, attrib); + + g_list_foreach (remove_list, (GFunc)remove_items, NULL); + g_list_free (remove_list); +} + + +static void +statusbar_push (GtkWidget *statusbar, const gchar *text) +{ + gtk_statusbar_push (GTK_STATUSBAR(statusbar), 0, + text ? text : " "); +} + +static void +statusbar_pop (GtkWidget *statusbar) +{ + gtk_statusbar_pop (GTK_STATUSBAR(statusbar), 0); +} + +static void +menu_item_select_cb (GtkWidget *menu_item, GtkWidget *statusbar) +{ + GtkWidget *accel_label = gtk_bin_get_child (GTK_BIN(menu_item)); + GMenuModel *menubar_model = g_object_get_data (G_OBJECT(statusbar), "menu-model"); + + if (!menubar_model) + return; + + if (accel_label) + { + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + + gsm->search_action_label = gtk_label_get_label (GTK_LABEL(accel_label)); + gsm->search_action_name = NULL; + + if (gnc_menubar_model_find_item (menubar_model, gsm)) + { + if (gsm->model) + statusbar_push (statusbar, gsm->tooltip); + } + g_free (gsm); + } +} + +static void +menu_item_deselect_cb (GtkWidget *menu_item, GtkWidget *statusbar) +{ + statusbar_pop (statusbar); +} + +/** Setup the callbacks for menu bar items so the tooltip can be + * displayed in the status bar. + * + * @param menu_item The menubar menu item widget. + * + * @param statusbar The statusbar widget to display the tooltip. + */ +void +gnc_menu_item_setup_tooltip_to_statusbar_callback (GtkWidget *menu_item, + GtkWidget *statusbar) +{ + g_return_if_fail (menu_item != NULL); + g_return_if_fail (statusbar != NULL); + + if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_item), "added-callbacks"))) + return; + + g_signal_connect (menu_item, "select", + G_CALLBACK(menu_item_select_cb), + statusbar); + g_signal_connect (menu_item, "deselect", + G_CALLBACK(menu_item_deselect_cb), + statusbar); + g_object_set (G_OBJECT(menu_item), "has-tooltip", FALSE, NULL); + + g_object_set_data (G_OBJECT(menu_item), "added-callbacks", GINT_TO_POINTER(1)); +} + + +static gboolean +tool_item_enter_event (GtkWidget *button, GdkEvent *event, + gpointer user_data) +{ + GtkWidget *tool_item = gtk_widget_get_parent (button); + gchar *tooltip = gtk_widget_get_tooltip_text (tool_item); + statusbar_push (user_data, tooltip); + g_free (tooltip); + return FALSE; +} + +static gboolean +tool_item_leave_event (GtkWidget *button, GdkEvent *event, + gpointer user_data) +{ + statusbar_pop (user_data); + return FALSE; +} + +/** Setup the callbacks for tool bar items so the tooltip can be + * displayed in the status bar. + * + * @param tool_item The toolbar tool item widget. + * + * @param statusbar The statusbar widget to display the tooltip. + */ +void +gnc_tool_item_setup_tooltip_to_statusbar_callback (GtkWidget *tool_item, + GtkWidget *statusbar) +{ + GtkWidget *child; + + g_return_if_fail (tool_item != NULL); + g_return_if_fail (statusbar != NULL); + + child = gtk_bin_get_child (GTK_BIN(tool_item)); + + gtk_widget_add_events (GTK_WIDGET(child), + GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK + | GDK_FOCUS_CHANGE_MASK); + + g_signal_connect (child, "enter-notify-event", + G_CALLBACK (tool_item_enter_event), + statusbar); + + g_signal_connect (child, "leave-notify-event", + G_CALLBACK (tool_item_leave_event), + statusbar); + + g_object_set (G_OBJECT(tool_item), "has-tooltip", FALSE, NULL); +} diff --git a/gnucash/gnome-utils/gnc-gtk-utils.h b/gnucash/gnome-utils/gnc-gtk-utils.h index b227eec0c8..43e2c0375e 100644 --- a/gnucash/gnome-utils/gnc-gtk-utils.h +++ b/gnucash/gnome-utils/gnc-gtk-utils.h @@ -41,6 +41,10 @@ @{ */ +#define GNC_MENU_ATTRIBUTE_ACCELERATOR "accel" +#define GNC_MENU_ATTRIBUTE_TOOLTIP "tooltip" +#define GNC_MENU_ATTRIBUTE_TEMPORARY "temp" + void gnc_cbwe_set_by_string(GtkComboBox *cbwe, const gchar *text); void gnc_cbwe_add_completion (GtkComboBox *cbwe); void gnc_cbwe_require_list_item (GtkComboBox *cbwe); @@ -55,6 +59,41 @@ void gnc_style_context_get_border_color (GtkStyleContext *context, GtkWidget *gnc_get_dialog_widget_from_id (GtkDialog *dialog, const gchar *id); +void gnc_disable_all_actions_in_group (GSimpleActionGroup *action_group); + +void gnc_add_accelerator_keys_for_menu (GtkWidget *menu, GtkAccelGroup *accel_group); + +GtkWidget *gnc_find_menu_item_by_action_name (GtkWidget *menu, const gchar *action_name); +GtkWidget *gnc_find_menu_item_by_action_label (GtkWidget *menu, const gchar *action_label); +GList *gnc_menu_get_items (GtkWidget *menu); + +GtkWidget *gnc_find_toolbar_item (GtkWidget *toolbar, const gchar *action_name); + +void gnc_menu_item_setup_tooltip_to_statusbar_callback (GtkWidget *menu_item, + GtkWidget *statusbar); + +void gnc_tool_item_setup_tooltip_to_statusbar_callback (GtkWidget *tool_item, + GtkWidget *statusbar); + +struct _GncMenuModelSearch +{ + const gchar *search_action_name; + const gchar *search_action_label; + const gchar *tooltip; + GMenuModel *model; + gint index; +}; + +typedef struct _GncMenuModelSearch GncMenuModelSearch; + +gboolean gnc_menubar_model_find_item (GMenuModel *menu_model, GncMenuModelSearch *gsm); +GtkWidget *gnc_menubar_model_find_menu_item (GMenuModel *menu_model, GtkWidget *menu, const gchar *action_name); + +gboolean gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name, + const gchar *label, const gchar *tooltip); + +void gnc_menubar_model_remove_items_with_attrib (GMenuModel *menu_model, const gchar *attrib); + /** @} */ #endif /* GNC_GTK_UTILS_H */ diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index c07dc4cfd1..33873f2414 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -95,6 +95,7 @@ enum { PAGE_ADDED, PAGE_CHANGED, + MENU_CHANGED, //FIXMEb added LAST_SIGNAL }; @@ -134,6 +135,9 @@ enum **/ extern gboolean gnc_book_options_dialog_apply_helper(GncOptionDB * options); +/** Max number of windows allowed */ +constexpr auto gnc_main_window_max_number {10}; + /* Static Globals *******************************************************/ /** The debugging module that this .o belongs to. */ @@ -153,7 +157,7 @@ static guint secs_to_save = 0; /* Declarations *********************************************************/ static void gnc_main_window_class_init (GncMainWindowClass *klass); static void gnc_main_window_init (GncMainWindow *window, - void *data); + void *data); static void gnc_main_window_finalize (GObject *object); static void gnc_main_window_destroy (GtkWidget *widget); @@ -164,7 +168,6 @@ static void gnc_main_window_update_all_menu_items (void); #endif /* Callbacks */ -static void gnc_main_window_add_widget (GtkUIManager *merge, GtkWidget *widget, GncMainWindow *window); static void gnc_main_window_switch_page (GtkNotebook *notebook, gpointer *notebook_page, gint pos, GncMainWindow *window); static void gnc_main_window_page_reordered (GtkNotebook *notebook, GtkWidget *child, guint pos, GncMainWindow *window); static void gnc_main_window_plugin_added (GncPlugin *manager, GncPlugin *plugin, GncMainWindow *window); @@ -172,41 +175,46 @@ static void gnc_main_window_plugin_removed (GncPlugin *manager, GncPlugin *plugi static void gnc_main_window_engine_commit_error_callback( gpointer data, QofBackendError errcode ); /* Command callbacks */ -static void gnc_main_window_cmd_page_setup (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_file_properties (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_file_close (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_file_quit (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_edit_cut (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_edit_copy (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_edit_paste (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_edit_preferences (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_view_refresh (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_view_toolbar (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_view_summary (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_view_statusbar (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_view_tab_position (GtkAction *action, GtkRadioAction *current, GncMainWindow *window); -static void gnc_main_window_cmd_actions_reset_warnings (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_actions_rename_page (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_window_new (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_window_move_page (GtkAction *action, GncMainWindow *window); +static void gnc_main_window_cmd_redirect (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_page_setup (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_file_properties (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_file_close (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_file_quit (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_edit_cut (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_edit_copy (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_edit_paste (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_edit_preferences (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_view_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_view_toolbar (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_view_summary (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_view_statusbar (GSimpleAction *simple, GVariant *paramter, gpointer user_data); + +static void gnc_main_window_cmd_view_tab_position (GSimpleAction *simple, GVariant *parameter, gpointer user_data); + +static void gnc_main_window_cmd_actions_reset_warnings (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_actions_rename_page (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_window_new (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_window_move_page (GSimpleAction *simple, GVariant *paramter, gpointer user_data); #ifndef MAC_INTEGRATION -static void gnc_main_window_cmd_window_raise (GtkAction *action, GtkRadioAction *current, GncMainWindow *window); +static void gnc_main_window_cmd_window_raise (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #endif -static void gnc_main_window_cmd_help_tutorial (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_help_contents (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_help_about (GtkAction *action, GncMainWindow *window); +static void gnc_main_window_cmd_help_tutorial (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_help_contents (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_help_about (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void do_popup_menu(GncPluginPage *page, GdkEventButton *event); static GtkWidget *gnc_main_window_get_statusbar (GncWindow *window_in); -static void statusbar_notification_lastmodified(void); +static void statusbar_notification_lastmodified (void); static void gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_data); static void gnc_main_window_remove_prefs (GncMainWindow *window); #ifdef MAC_INTEGRATION -static void gnc_quartz_shutdown(GtkosxApplication *theApp, gpointer data); -static gboolean gnc_quartz_should_quit(GtkosxApplication *theApp, GncMainWindow *window); -static void gnc_quartz_set_menu(GncMainWindow* window); +static void gnc_quartz_shutdown (GtkosxApplication *theApp, gpointer data); +static gboolean gnc_quartz_should_quit (GtkosxApplication *theApp, GncMainWindow *window); +static void gnc_quartz_set_menu (GncMainWindow* window); #endif +static void gnc_main_window_init_menu_updaters (GncMainWindow *window); + /** The instance private data structure for an embedded window * object. */ @@ -217,8 +225,12 @@ typedef struct GncMainWindowPrivate * manager and stored here when the UI manager provides them * to the main window. */ GtkWidget *menu_dock; - /** The toolbar created by the UI manager. This pointer - * provides easy access for showing/hiding the toolbar. */ + /** The menubar */ + GtkWidget *menubar; //FIXMEb added + /** The menubar_model */ + GMenuModel *menubar_model; //FIXMEb added + /** The toolbar. This pointer provides easy access for + * showing/hiding the toolbar. */ GtkWidget *toolbar; /** The notebook containing all the pages in this window. */ GtkWidget *notebook; @@ -232,12 +244,6 @@ typedef struct GncMainWindowPrivate * window that is contained in the status bar. This pointer * provides easy access for updating the progressbar. */ GtkWidget *progressbar; - - /** The group of all actions provided by the main window - * itself. This does not include any action provided by menu - * or content plugins. */ - GtkActionGroup *action_group; - /** A list of all pages that are installed in this window. */ GList *installed_pages; /** A list of pages in order of use (most recent -> least recent) */ @@ -248,258 +254,93 @@ typedef struct GncMainWindowPrivate gint event_handler_id; /** Array for window position. */ gint pos[2]; - /** A hash table of all action groups that have been installed - * into this window. The keys are the name of an action - * group, the values are structures of type - * MergedActionEntry. */ - GHashTable *merged_actions_table; /** Set when restoring plugin pages */ gboolean restoring_pages; + + const gchar *previous_plugin_page_name; //FIXMEb added + const gchar *previous_menu_qualifier; //FIXMEb added + + /** The accelerator group for the window */ + GtkAccelGroup *accel_group; //FIXMEb added + + GHashTable *display_item_hash; //FIXMEb added + gint num_item_q; //FIXMEb temp added + } GncMainWindowPrivate; -GNC_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_WINDOW, +GNC_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_APPLICATION_WINDOW, G_ADD_PRIVATE (GncMainWindow) G_IMPLEMENT_INTERFACE (GNC_TYPE_WINDOW, - gnc_window_main_window_init)) + gnc_window_main_window_init)) #define GNC_MAIN_WINDOW_GET_PRIVATE(o) \ ((GncMainWindowPrivate*)gnc_main_window_get_instance_private((GncMainWindow*)o)) -/** This data structure maintains information about one action groups - * that has been installed in this window. */ -typedef struct -{ - /** The merge identifier for this action group. This number - * is provided by the UI manager. */ - guint merge_id; - /** The action group itself. This contains all actions added - * by a single menu or content plugin. */ - GtkActionGroup *action_group; -} MergedActionEntry; - /** A holding place for all the signals generated by the main window * code. */ static guint main_window_signals[LAST_SIGNAL] = { 0 }; +static void +toggle_change_state (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + g_simple_action_set_state (simple, state); +} + +static void +radio_change_state (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + g_simple_action_set_state (simple, state); +} /** An array of all of the actions provided by the main window code. * This includes some placeholder actions for the menus that are * visible in the menu bar but have no action associated with * them. */ -static GtkActionEntry gnc_menu_actions [] = +static GActionEntry gnc_menu_actions [] = { - /* Toplevel */ + { "FilePageSetupAction", gnc_main_window_cmd_page_setup, nullptr, nullptr, nullptr }, + { "FilePropertiesAction", gnc_main_window_cmd_file_properties, nullptr, nullptr, nullptr }, + { "FileCloseAction", gnc_main_window_cmd_file_close, nullptr, nullptr, nullptr }, + { "FilePrintAction", gnc_main_window_cmd_redirect, nullptr, nullptr, nullptr }, + { "FileQuitAction", gnc_main_window_cmd_file_quit, nullptr, nullptr, nullptr }, - { "FileAction", nullptr, N_("_File"), nullptr, nullptr, nullptr, }, - { "EditAction", nullptr, N_("_Edit"), nullptr, nullptr, nullptr }, - { "ViewAction", nullptr, N_("_View"), nullptr, nullptr, nullptr }, - { "ActionsAction", nullptr, N_("_Actions"), nullptr, nullptr, nullptr }, - { "TransactionAction", nullptr, N_("Tra_nsaction"), nullptr, nullptr, nullptr }, - { "ReportsAction", nullptr, N_("_Reports"), nullptr, nullptr, nullptr }, - { "ToolsAction", nullptr, N_("_Tools"), nullptr, nullptr, nullptr }, - { "ExtensionsAction", nullptr, N_("E_xtensions"), nullptr, nullptr, nullptr }, - { "WindowsAction", nullptr, N_("_Windows"), nullptr, nullptr, nullptr }, - { "HelpAction", nullptr, N_("_Help"), nullptr, nullptr, nullptr }, + { "EditCutAction", gnc_main_window_cmd_edit_cut, nullptr, nullptr, nullptr }, + { "EditCopyAction", gnc_main_window_cmd_edit_copy, nullptr, nullptr, nullptr }, + { "EditPasteAction", gnc_main_window_cmd_edit_paste, nullptr, nullptr, nullptr }, + { "EditPreferencesAction", gnc_main_window_cmd_edit_preferences, nullptr, nullptr, nullptr }, - /* File menu */ + { "ActionsForgetWarningsAction", gnc_main_window_cmd_actions_reset_warnings, nullptr, nullptr, nullptr }, + { "ActionsRenamePageAction", gnc_main_window_cmd_actions_rename_page, nullptr, nullptr, nullptr }, - { "FileImportAction", nullptr, N_("_Import"), nullptr, nullptr, nullptr }, - { "FileExportAction", nullptr, N_("_Export"), nullptr, nullptr, nullptr }, - { - "FilePrintAction", "document-print", N_("_Print…"), "p", - N_("Print the currently active page"), nullptr - }, -#ifndef GTK_STOCK_PAGE_SETUP -# define GTK_STOCK_PAGE_SETUP nullptr + { "TransactionAction", nullptr, nullptr, nullptr, nullptr }, + + { "ViewSortByAction", nullptr, nullptr, nullptr, nullptr }, + { "ViewFilterByAction", nullptr, nullptr, nullptr, nullptr }, + { "ViewRefreshAction", gnc_main_window_cmd_view_refresh, nullptr, nullptr, nullptr }, + { "ViewToolbarAction", gnc_main_window_cmd_view_toolbar, nullptr, "true", toggle_change_state }, + { "ViewSummaryAction", gnc_main_window_cmd_view_summary, nullptr, "true", toggle_change_state }, + { "ViewStatusbarAction", gnc_main_window_cmd_view_statusbar, nullptr, "true", toggle_change_state }, + { "ViewTabPositionAction", gnc_main_window_cmd_view_tab_position, "i", "@i 0", radio_change_state }, + + { "ScheduledAction", nullptr, nullptr, nullptr, nullptr }, + + { "ExtensionsAction", nullptr, nullptr, nullptr, nullptr }, + + { "WindowNewAction", gnc_main_window_cmd_window_new, nullptr, nullptr, nullptr }, + { "WindowMovePageAction", gnc_main_window_cmd_window_move_page, nullptr, nullptr, nullptr }, +#ifndef MAC_INTEGRATION + { "WindowAction", gnc_main_window_cmd_window_raise, "i", "@i 0", radio_change_state }, #endif - { - "FilePageSetupAction", "document-page-setup", N_("Pa_ge Setup…"), "p", - N_("Specify the page size and orientation for printing"), - G_CALLBACK (gnc_main_window_cmd_page_setup) - }, - { - "FilePropertiesAction", "document-properties", N_("Proper_ties"), "Return", - N_("Edit the properties of the current file"), - G_CALLBACK (gnc_main_window_cmd_file_properties) - }, - { - "FileCloseAction", "window-close", N_("_Close"), "W", - N_("Close the currently active page"), - G_CALLBACK (gnc_main_window_cmd_file_close) - }, - { - "FileQuitAction", "application-exit", N_("_Quit"), "Q", - N_("Quit this application"), - G_CALLBACK (gnc_main_window_cmd_file_quit) - }, - - /* Edit menu */ - - { - "EditCutAction", "edit-cut", N_("Cu_t"), "X", - N_("Cut the current selection and copy it to clipboard"), - G_CALLBACK (gnc_main_window_cmd_edit_cut) - }, - { - "EditCopyAction", "edit-copy", N_("_Copy"), "C", - N_("Copy the current selection to clipboard"), - G_CALLBACK (gnc_main_window_cmd_edit_copy) - }, - { - "EditPasteAction", "edit-paste", N_("_Paste"), "V", - N_("Paste the clipboard content at the cursor position"), - G_CALLBACK (gnc_main_window_cmd_edit_paste) - }, - { - "EditPreferencesAction", "preferences-system", N_("Pr_eferences"), nullptr, - N_("Edit the global preferences of GnuCash"), - G_CALLBACK (gnc_main_window_cmd_edit_preferences) - }, - - /* View menu */ - - { "ViewTabPositionAction", NULL, N_("Tab P_osition"), NULL, NULL, NULL }, - { - "ViewSortByAction", nullptr, N_("_Sort By…"), nullptr, - N_("Select sorting criteria for this page view"), nullptr - }, - { - "ViewFilterByAction", nullptr, N_("_Filter By…"), nullptr, - N_("Select the account types that should be displayed."), nullptr - }, - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), - G_CALLBACK (gnc_main_window_cmd_view_refresh) - }, - - /* Actions menu */ - - { "ScrubMenuAction", nullptr, N_("_Check & Repair"), nullptr, nullptr, nullptr }, - { - "ActionsForgetWarningsAction", nullptr, N_("Reset _Warnings…"), nullptr, - N_("Reset the state of all warning messages so they will be shown again."), - G_CALLBACK (gnc_main_window_cmd_actions_reset_warnings) - }, - { - "ActionsRenamePageAction", nullptr, N_("Re_name Page"), nullptr, - N_("Rename this page."), - G_CALLBACK (gnc_main_window_cmd_actions_rename_page) - }, - - /* Windows menu */ - - { - "WindowNewAction", nullptr, N_("_New Window"), nullptr, - N_("Open a new top-level GnuCash window."), - G_CALLBACK (gnc_main_window_cmd_window_new) - }, - { - "WindowMovePageAction", nullptr, N_("New Window with _Page"), nullptr, - N_("Move the current page to a new top-level GnuCash window."), - G_CALLBACK (gnc_main_window_cmd_window_move_page) - }, - - /* Help menu */ - - { - "HelpTutorialAction", "help-browser", N_("Tutorial and Concepts _Guide"), "H", - N_("Open the GnuCash Tutorial"), - G_CALLBACK (gnc_main_window_cmd_help_tutorial) - }, - { - "HelpContentsAction", "help-browser", N_("_Contents"), "F1", - N_("Open the GnuCash Help"), - G_CALLBACK (gnc_main_window_cmd_help_contents) - }, - { - "HelpAboutAction", "help-about", N_("_About"), nullptr, - N_("About GnuCash"), - G_CALLBACK (gnc_main_window_cmd_help_about) - }, + { "HelpTutorialAction", gnc_main_window_cmd_help_tutorial, nullptr, nullptr, nullptr }, + { "HelpContentsAction", gnc_main_window_cmd_help_contents, nullptr, nullptr, nullptr }, + { "HelpAboutAction", gnc_main_window_cmd_help_about, nullptr, nullptr, nullptr }, }; /** The number of actions provided by the main window. */ -static guint gnc_menu_n_actions = G_N_ELEMENTS (gnc_menu_actions); - -/** An array of all of the toggle action provided by the main window - * code. */ -static GtkToggleActionEntry toggle_actions [] = -{ - { - "ViewToolbarAction", nullptr, N_("_Toolbar"), nullptr, - N_("Show/hide the toolbar on this window"), - G_CALLBACK (gnc_main_window_cmd_view_toolbar), TRUE - }, - { - "ViewSummaryAction", nullptr, N_("Su_mmary Bar"), nullptr, - N_("Show/hide the summary bar on this window"), - G_CALLBACK (gnc_main_window_cmd_view_summary), TRUE - }, - { - "ViewStatusbarAction", nullptr, N_("Stat_us Bar"), nullptr, - N_("Show/hide the status bar on this window"), - G_CALLBACK (gnc_main_window_cmd_view_statusbar), TRUE - }, -}; -/** The number of toggle actions provided by the main window. */ -static guint n_toggle_actions = G_N_ELEMENTS (toggle_actions); - -/** An array of all of the radio actions provided by the main window - * for tab positions. */ -static GtkRadioActionEntry tab_pos_radio_entries [] = -{ - { - "ViewTabPositionTopAction", NULL, N_("To_p"), NULL, - N_("Display the notebook tabs at the top of the window."), GTK_POS_TOP - }, - { - "ViewTabPositionBottomAction", NULL, N_("B_ottom"), NULL, - N_("Display the notebook tabs at the bottom of the window."), GTK_POS_BOTTOM - }, - { - "ViewTabPositionLeftAction", NULL, N_("_Left"), NULL, - N_("Display the notebook tabs at the left of the window."), GTK_POS_LEFT - }, - { - "ViewTabPositionRightAction", NULL, N_("_Right"), NULL, - N_("Display the notebook tabs at the right of the window."), GTK_POS_RIGHT - }, -}; - -/** The number of radio actions provided by the main window for tab - * positions. */ -static guint n_tab_pos_radio_entries = G_N_ELEMENTS (tab_pos_radio_entries); - -#ifndef MAC_INTEGRATION -/** An array of all of the radio action provided by the main window - * code. */ -static GtkRadioActionEntry radio_entries [] = -{ - { "Window0Action", nullptr, N_("Window _1"), nullptr, nullptr, 0 }, - { "Window1Action", nullptr, N_("Window _2"), nullptr, nullptr, 1 }, - { "Window2Action", nullptr, N_("Window _3"), nullptr, nullptr, 2 }, - { "Window3Action", nullptr, N_("Window _4"), nullptr, nullptr, 3 }, - { "Window4Action", nullptr, N_("Window _5"), nullptr, nullptr, 4 }, - { "Window5Action", nullptr, N_("Window _6"), nullptr, nullptr, 5 }, - { "Window6Action", nullptr, N_("Window _7"), nullptr, nullptr, 6 }, - { "Window7Action", nullptr, N_("Window _8"), nullptr, nullptr, 7 }, - { "Window8Action", nullptr, N_("Window _9"), nullptr, nullptr, 8 }, - { "Window9Action", nullptr, N_("Window _0"), nullptr, nullptr, 9 }, -}; - -/** The number of radio actions provided by the main window. */ -static gsize n_radio_entries = G_N_ELEMENTS (radio_entries); -#endif - -/** These are the "important" actions provided by the main window. - * Their labels will appear when the toolbar is set to "Icons and - * important text" (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. */ -static const gchar *gnc_menu_important_actions[] = -{ - "FileCloseAction", - nullptr, -}; - +static guint gnc_menu_n_actions = G_N_ELEMENTS(gnc_menu_actions); /** The following are in the main window so they will always be * present in the menu structure, but they are never sensitive. @@ -712,10 +553,10 @@ static void gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *data) { GncMainWindowPrivate *priv; - GtkAction *action; + GAction *action; gint *pos, *geom, *order; gsize length; - gboolean max, visible, desired_visibility; + gboolean max; gchar *window_group; gsize page_start, page_count, i; GError *error = nullptr; @@ -860,53 +701,74 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da gtk_window_maximize(GTK_WINDOW(window)); } + // need to add the accelerator keys + gnc_add_accelerator_keys_for_menu (GTK_WIDGET(priv->menubar), priv->accel_group); + /* Common view menu items */ - action = gnc_main_window_find_action(window, "ViewToolbarAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - desired_visibility = g_key_file_get_boolean(data->key_file, window_group, - TOOLBAR_VISIBLE, &error); - if (error) + action = gnc_main_window_find_action (window, "ViewToolbarAction"); + if (action) { - g_warning("error reading group %s key %s: %s", - window_group, TOOLBAR_VISIBLE, error->message); - g_error_free(error); - error = nullptr; - } - else if (visible != desired_visibility) - { - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility); + GVariant *state = g_action_get_state (G_ACTION(action)); + gboolean visible = g_variant_get_boolean (state); + gboolean desired_visibility = g_key_file_get_boolean (data->key_file, window_group, + TOOLBAR_VISIBLE, &error); + + if (error) + { + g_warning ("error reading group %s key %s: %s", + window_group, TOOLBAR_VISIBLE, error->message); + g_error_free (error); + error = nullptr; + } + else if (visible != desired_visibility) + { + g_action_activate (action, nullptr); + } + g_variant_unref (state); } - action = gnc_main_window_find_action(window, "ViewSummaryAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - desired_visibility = g_key_file_get_boolean(data->key_file, window_group, - SUMMARYBAR_VISIBLE, &error); - if (error) + action = gnc_main_window_find_action (window, "ViewSummaryAction"); + if (action) { - g_warning("error reading group %s key %s: %s", - window_group, TOOLBAR_VISIBLE, error->message); - g_error_free(error); - error = nullptr; - } - else if (visible != desired_visibility) - { - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility); + GVariant *state = g_action_get_state (G_ACTION(action)); + gboolean visible = g_variant_get_boolean (state); + gboolean desired_visibility = g_key_file_get_boolean (data->key_file, window_group, + SUMMARYBAR_VISIBLE, &error); + + if (error) + { + g_warning ("error reading group %s key %s: %s", + window_group, SUMMARYBAR_VISIBLE, error->message); + g_error_free (error); + error = nullptr; + } + else if (visible != desired_visibility) + { + g_action_activate (action, nullptr); + } + g_variant_unref (state); } - action = gnc_main_window_find_action(window, "ViewStatusbarAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - desired_visibility = g_key_file_get_boolean(data->key_file, window_group, - STATUSBAR_VISIBLE, &error); - if (error) + action = gnc_main_window_find_action (window, "ViewStatusbarAction"); + if (action) { - g_warning("error reading group %s key %s: %s", - window_group, TOOLBAR_VISIBLE, error->message); - g_error_free(error); - error = nullptr; - } - else if (visible != desired_visibility) - { - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility); + GVariant *state = g_action_get_state (G_ACTION(action)); + gboolean visible = g_variant_get_boolean (state); + gboolean desired_visibility = g_key_file_get_boolean (data->key_file, window_group, + STATUSBAR_VISIBLE, &error); + + if (error) + { + g_warning ("error reading group %s key %s: %s", + window_group, STATUSBAR_VISIBLE, error->message); + g_error_free (error); + error = nullptr; + } + else if (visible != desired_visibility) + { + g_action_activate (action, nullptr); + } + g_variant_unref (state); } priv->restoring_pages = TRUE; /* Now populate the window with pages. */ @@ -924,8 +786,8 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da /* Restore page ordering within the notebook. Use +1 notation so the * numbers in the page order match the page sections, at least for * the one window case. */ - order = g_key_file_get_integer_list(data->key_file, window_group, - WINDOW_PAGEORDER, &length, &error); + order = g_key_file_get_integer_list (data->key_file, window_group, + WINDOW_PAGEORDER, &length, &error); if (error) { g_warning("error reading group %s key %s: %s", @@ -1009,9 +871,9 @@ gnc_main_window_restore_all_windows(const GKeyFile *keyfile) } void -gnc_main_window_restore_default_state(GncMainWindow *window) +gnc_main_window_restore_default_state (GncMainWindow *window) { - GtkAction *action; + GAction *action; /* The default state should be to have an Account Tree page open * in the window. */ @@ -1019,8 +881,10 @@ gnc_main_window_restore_default_state(GncMainWindow *window) if (!window) window = static_cast(g_list_nth_data(active_windows, 0)); gtk_widget_show (GTK_WIDGET(window)); - action = gnc_main_window_find_action(window, "ViewAccountTreeAction"); - gtk_action_activate(action); + action = gnc_main_window_find_action_in_group (window, + "gnc-plugin-account-tree-actions", + "ViewAccountTreeAction"); + g_action_activate (action, nullptr); } /** Save the state of a single page to a disk. This function handles @@ -1069,9 +933,9 @@ static void gnc_main_window_save_window (GncMainWindow *window, GncMainWindowSaveData *data) { GncMainWindowPrivate *priv; - GtkAction *action; + GAction *action; gint i, num_pages, coords[4], *order; - gboolean maximized, minimized, visible; + gboolean maximized, minimized, visible = true; gchar *window_group; /* Setup */ @@ -1134,21 +998,36 @@ gnc_main_window_save_window (GncMainWindow *window, GncMainWindowSaveData *data) maximized ? "maximized" : "not maximized"); /* Common view menu items */ - action = gnc_main_window_find_action(window, "ViewToolbarAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - g_key_file_set_boolean(data->key_file, window_group, - TOOLBAR_VISIBLE, visible); - action = gnc_main_window_find_action(window, "ViewSummaryAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - g_key_file_set_boolean(data->key_file, window_group, - SUMMARYBAR_VISIBLE, visible); - action = gnc_main_window_find_action(window, "ViewStatusbarAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - g_key_file_set_boolean(data->key_file, window_group, - STATUSBAR_VISIBLE, visible); + action = gnc_main_window_find_action (window, "ViewToolbarAction"); + if (action) + { + GVariant *state = g_action_get_state (G_ACTION(action)); + visible = g_variant_get_boolean (state); + g_variant_unref (state); + } + g_key_file_set_boolean (data->key_file, window_group, + TOOLBAR_VISIBLE, visible); + action = gnc_main_window_find_action (window, "ViewSummaryAction"); + if (action) + { + GVariant *state = g_action_get_state (G_ACTION(action)); + visible = g_variant_get_boolean (state); + g_variant_unref (state); + } + g_key_file_set_boolean (data->key_file, window_group, + SUMMARYBAR_VISIBLE, visible); + action = gnc_main_window_find_action (window, "ViewStatusbarAction"); + if (action) + { + GVariant *state = g_action_get_state (G_ACTION(action)); + visible = g_variant_get_boolean (state); + g_variant_unref (state); + } + g_key_file_set_boolean (data->key_file, window_group, + STATUSBAR_VISIBLE, visible); /* Save individual pages in this window */ - g_list_foreach(priv->installed_pages, (GFunc)gnc_main_window_save_page, data); + g_list_foreach (priv->installed_pages, (GFunc)gnc_main_window_save_page, data); g_free(window_group); LEAVE("window %p", window); @@ -1675,9 +1554,9 @@ gnc_main_window_generate_title (GncMainWindow *window) /* Update the menus based upon whether this is an "immutable" page. */ immutable = page && g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE); - gnc_plugin_update_actions(priv->action_group, - immutable_page_actions, - "sensitive", !immutable); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(window), + immutable_page_actions, + !immutable); /* Trigger sensitivity updtates of other actions such as Save/Revert */ g_signal_emit_by_name (window, "page_changed", page); g_free( filename ); @@ -1868,31 +1747,33 @@ statusbar_notification_lastmodified() /** This data structure is used to describe the requested state of a - * GtkRadioAction, and us used to pass data among several - * functions. */ + * GAction, and is used to pass data among several functions. */ struct menu_update { - /** The name of the GtkRadioAction to be updated. */ + /** The name of the GAction to be updated. */ gchar *action_name; - /** The new label for this GtkRadioAction. */ + /** The new label for this GAction. */ gchar *label; - /** Whether or not the GtkRadioAction should be visible. */ + /** Whether or not the GAction should be visible. */ gboolean visible; + + /** Index number in active windows list */ + gint index; }; #ifndef MAC_INTEGRATION -/** Update the label on the specified GtkRadioAction in the specified - * window. This action is displayed as a menu item in the "Windows" - * menu. This function will end up being called whenever the front - * page is changed in any window, or whenever a window is added or - * deleted. +/** Update the label on the menu item specified by the GAction in the + * specified window. This action is displayed as a menu item in the + * "Windows" menu. This function will end up being called whenever the + * front page is changed in any window, or whenever a window is added + * or deleted. * * @param window The window whose menu item should be updated. * - * @param data A data structure containing the name of the - * GtkRadioAction, and describing the new state for this action. + * @param data A data structure containing the name of the GAction and + * describing the new state for this action. * * @internal */ @@ -1901,17 +1782,45 @@ gnc_main_window_update_one_menu_action (GncMainWindow *window, struct menu_update *data) { GncMainWindowPrivate *priv; - GtkAction* action; + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + GMenuItem *item; + gint pos; + + ENTER("window %p, action %s, label %s, index %d, visible %d", window, + data->action_name, data->label, data->index, data->visible); - ENTER("window %p, action %s, label %s, visible %d", window, - data->action_name, data->label, data->visible); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - action = gtk_action_group_get_action(priv->action_group, data->action_name); - if (action) - g_object_set(G_OBJECT(action), - "label", data->label, - "visible", data->visible, - (char *)nullptr); + + gsm->search_action_label = nullptr; + gsm->search_action_name = "WindowsPlaceholder1"; // placeholder + + if (!gnc_menubar_model_find_item (priv->menubar_model, gsm)) + { + LEAVE("Could not find placeholder 'WindowsPlaceholder1' for windows entries"); + g_free (gsm); + return; + } + + pos = gsm->index + data->index + 1; + + if (!data->visible) + { + if (pos < g_menu_model_get_n_items (gsm->model)) + g_menu_remove (G_MENU(gsm->model), pos); + + g_free (gsm); + LEAVE(" "); + return; + } + + item = g_menu_item_new (data->label, "mainwin.WindowAction"); + g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_TARGET, "i", data->index); + + if (pos < g_menu_model_get_n_items (gsm->model)) + g_menu_remove (G_MENU(gsm->model), pos); + g_menu_insert_item (G_MENU(gsm->model), pos, item); + + g_free (gsm); LEAVE(" "); } @@ -1931,49 +1840,44 @@ static void gnc_main_window_update_radio_button (GncMainWindow *window) { GncMainWindowPrivate *priv; - GtkAction *action, *first_action; + GAction *action; GSList *action_list; - gchar *action_name; gsize index; ENTER("window %p", window); /* Show the new entry in all windows. */ - index = g_list_index(active_windows, window); - if (index >= n_radio_entries) + index = g_list_index (active_windows, window); + + if (index >= gnc_main_window_max_number) { - LEAVE("window %" G_GSIZE_FORMAT ", only %" G_GSIZE_FORMAT " actions", index, n_radio_entries); + LEAVE("window %" G_GSIZE_FORMAT ", only %d actions", index, gnc_main_window_max_number); return; } priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - action_name = g_strdup_printf("Window%" G_GSIZE_FORMAT "Action", index); - action = gtk_action_group_get_action(priv->action_group, action_name); + + action = g_action_map_lookup_action (G_ACTION_MAP(window), + "WindowAction"); /* Block the signal so as not to affect window ordering (top to * bottom) on the screen */ - action_list = gtk_radio_action_get_group(GTK_RADIO_ACTION(action)); - if (action_list) - { - first_action = static_cast(g_slist_last(action_list)->data); - g_signal_handlers_block_by_func(G_OBJECT(first_action), - (gpointer)gnc_main_window_cmd_window_raise, - window); - DEBUG("blocked signal on %p, set %p active, window %p", first_action, - action, window); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE); - g_signal_handlers_unblock_by_func(G_OBJECT(first_action), - (gpointer)gnc_main_window_cmd_window_raise, - window); - } - g_free(action_name); + g_signal_handlers_block_by_func (G_OBJECT(action), + (gpointer)gnc_main_window_cmd_window_raise, + window); + + DEBUG("blocked signal on action %p, window %p", action, window); + g_action_change_state (G_ACTION(action), g_variant_new_int32 (index)); + + g_signal_handlers_unblock_by_func (G_OBJECT(action), + (gpointer)gnc_main_window_cmd_window_raise, + window); LEAVE(" "); } /** In every window that the user has open, update the "Window" menu * item that points to the specified window. This keeps the "Window" - * menu items consistent across all open windows. (These items - * cannot be shared because of the way the GtkUIManager code works.) + * menu items consistent across all open windows. * * This function is called whenever the user switches pages in a * window, or whenever a window is added or deleted. @@ -1991,36 +1895,41 @@ gnc_main_window_update_menu_item (GncMainWindow *window) gsize index; ENTER("window %p", window); - index = g_list_index(active_windows, window); - if (index > n_radio_entries) + + index = g_list_index (active_windows, window); + + if (index >= gnc_main_window_max_number) { - LEAVE("skip window %" G_GSIZE_FORMAT " (only %" G_GSIZE_FORMAT " entries)", index, n_radio_entries); + LEAVE("skip window %" G_GSIZE_FORMAT " (only %d entries)", index, gnc_main_window_max_number); return; } /* Figure out the label name. Add the accelerator if possible. */ - title = gnc_main_window_generate_title(window); - strings = g_strsplit(title, "_", 0); - g_free(title); - expanded = g_strjoinv("__", strings); - if (index < 10) + title = gnc_main_window_generate_title (window); + strings = g_strsplit (title, "_", 0); + g_free (title); + expanded = g_strjoinv ("__", strings); + if (index < gnc_main_window_max_number) { - data.label = g_strdup_printf("_%" G_GSIZE_FORMAT " %s", (index + 1) % 10, expanded); - g_free(expanded); + data.label = g_strdup_printf ("_%" G_GSIZE_FORMAT " %s", (index + 1) % 10, expanded); + g_free (expanded); } else { data.label = expanded; } - g_strfreev(strings); + g_strfreev (strings); data.visible = TRUE; - data.action_name = g_strdup_printf("Window%" G_GSIZE_FORMAT "Action", index); - g_list_foreach(active_windows, - (GFunc)gnc_main_window_update_one_menu_action, - &data); - g_free(data.action_name); - g_free(data.label); +// data.action_name = g_strdup_printf ("Window%" G_GSIZE_FORMAT "Action", index); + data.index = index; + + g_list_foreach (active_windows, + (GFunc)gnc_main_window_update_one_menu_action, + &data); + +// g_free (data.action_name); + g_free (data.label); LEAVE(" "); } @@ -2039,31 +1948,32 @@ static void gnc_main_window_update_all_menu_items (void) { struct menu_update data; - gchar *label; ENTER(""); /* First update the entries for all existing windows */ - g_list_foreach(active_windows, - (GFunc)gnc_main_window_update_menu_item, - nullptr); - g_list_foreach(active_windows, - (GFunc)gnc_main_window_update_radio_button, - nullptr); + g_list_foreach (active_windows, + (GFunc)gnc_main_window_update_menu_item, + nullptr); + + g_list_foreach (active_windows, + (GFunc)gnc_main_window_update_radio_button, + nullptr); /* Now hide any entries that aren't being used. */ data.visible = FALSE; - for (gsize i = g_list_length(active_windows); i < n_radio_entries; i++) + // need i to descend from gnc_main_window_max_number + for (gsize i = gnc_main_window_max_number - 1; i > 0 && i >= g_list_length (active_windows); i--) { - data.action_name = g_strdup_printf("Window%" G_GSIZE_FORMAT "Action", i); - label = g_strdup_printf("Window _%" G_GSIZE_FORMAT, (i - 1) % 10); - data.label = gettext(label); + data.index = i; + data.action_name = g_strdup_printf ("Window%dAction", data.index); + data.label = g_strdup_printf ("mywin%" G_GSIZE_FORMAT, i % 10); - g_list_foreach(active_windows, - (GFunc)gnc_main_window_update_one_menu_action, - &data); + g_list_foreach (active_windows, + (GFunc)gnc_main_window_update_one_menu_action, + &data); - g_free(data.action_name); - g_free(label); + g_free (data.action_name); + g_free (data.label); } LEAVE(" "); } @@ -2082,7 +1992,7 @@ gnc_main_window_update_all_menu_items (void) */ static void gnc_main_window_update_tab_close_one_page (GncPluginPage *page, - gpointer user_data) + gpointer user_data) { auto new_value{static_cast(user_data)}; ENTER("page %p, visible %d", page, *new_value); @@ -2766,6 +2676,24 @@ gnc_main_window_class_init (GncMainWindowClass *klass) G_TYPE_NONE, 1, G_TYPE_OBJECT); + /** + * GncMainWindow::menu_changed: + * @param window: the #GncMainWindow + * @param page: the #GncPluginPage + * + * The "menu_changed" signal is emitted when the menu has been + * changed. This can be used to adjust other menu actions. + */ + main_window_signals[MENU_CHANGED] = + g_signal_new ("menu_changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GncMainWindowClass, menu_changed), + nullptr, nullptr, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + G_TYPE_OBJECT); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SHOW_CLOSE_BUTTON, (gpointer)gnc_main_window_update_tab_close, @@ -2799,8 +2727,6 @@ gnc_main_window_init (GncMainWindow *window, void *data) GncMainWindowClass *klass = (GncMainWindowClass*)data; priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - priv->merged_actions_table = - g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); // Set the name for this dialog so it can be easily manipulated with css gtk_widget_set_name (GTK_WIDGET(window), "gnc-id-main-window"); @@ -2810,6 +2736,15 @@ gnc_main_window_init (GncMainWindow *window, void *data) priv->restoring_pages = FALSE; + priv->display_item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nullptr); + priv->num_item_q = 0; //FIXMEb temp addded + + priv->previous_plugin_page_name = nullptr; + priv->previous_menu_qualifier = nullptr; + + priv->accel_group = gtk_accel_group_new (); + gtk_window_add_accel_group (GTK_WINDOW(window), priv->accel_group); + /* Get the show_color_tabs value preference */ priv->show_color_tabs = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_COLOR); @@ -2820,7 +2755,7 @@ gnc_main_window_init (GncMainWindow *window, void *data) gnc_main_window_setup_window (window); gnc_gobject_tracking_remember(G_OBJECT(window), - G_OBJECT_CLASS(klass)); + G_OBJECT_CLASS(klass)); } @@ -2925,7 +2860,7 @@ gnc_main_window_destroy (GtkWidget *widget) /* Do these things once */ priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - if (priv->merged_actions_table) + if (priv->event_handler_id > 0) { /* Close any pages in this window */ @@ -2944,8 +2879,7 @@ gnc_main_window_destroy (GtkWidget *widget) qof_event_unregister_handler(priv->event_handler_id); priv->event_handler_id = 0; - g_hash_table_destroy (priv->merged_actions_table); - priv->merged_actions_table = nullptr; + g_hash_table_destroy (priv->display_item_hash); /* GncPluginManager stuff */ manager = gnc_plugin_manager_get (); @@ -3160,7 +3094,6 @@ gnc_main_window_disconnect (GncMainWindow *window, priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); if (priv->current_page == page) { - gnc_plugin_page_unmerge_actions (page, window->ui_merge); gnc_plugin_page_unselected (page); priv->current_page = nullptr; } @@ -3203,7 +3136,6 @@ gnc_main_window_disconnect (GncMainWindow *window, gnc_plugin_page_removed (page); - gtk_ui_manager_ensure_update (window->ui_merge); gnc_window_set_status (GNC_WINDOW(window), page, nullptr); } @@ -3465,23 +3397,62 @@ gnc_main_window_get_current_page (GncMainWindow *window) void gnc_main_window_manual_merge_actions (GncMainWindow *window, const gchar *group_name, - GtkActionGroup *group, - guint merge_id) + GSimpleActionGroup *group) +{ + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + g_return_if_fail (group_name != nullptr); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(group)); + + gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, + G_ACTION_GROUP(group)); +} + + +static void +update_menu_model (GncMainWindow *window, const gchar *ui_filename, + const gchar **ui_updates) { GncMainWindowPrivate *priv; - MergedActionEntry *entry; + GError *error = nullptr; + const gchar *resource = "/org/gnucash/"; + gchar *res_name; + GtkBuilder *builder = gtk_builder_new (); + GMenuModel *menu_model_part; + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); - g_return_if_fail (group_name != nullptr); - g_return_if_fail (GTK_IS_ACTION_GROUP(group)); - g_return_if_fail (merge_id > 0); + g_return_if_fail (ui_filename != nullptr); + g_return_if_fail (ui_updates != nullptr); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - entry = g_new0 (MergedActionEntry, 1); - entry->action_group = group; - entry->merge_id = merge_id; - gtk_ui_manager_ensure_update (window->ui_merge); - g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry); + + gtk_builder_set_translation_domain (builder, PROJECT_NAME); + res_name = g_strconcat ("/org/gnucash/ui/", ui_filename, NULL); + + gtk_builder_add_from_resource (builder, res_name, &error); + g_free (res_name); + + if (error) + { + g_critical ("Failed to load, Error %s", error->message); + g_error_free (error); + return; //FIXMEb this may need changing + } + + for (gint i = 0; ui_updates[i]; i++) + { + menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, ui_updates[i]); + + gsm->search_action_label = nullptr; + gsm->search_action_name = ui_updates[i]; + + if (gnc_menubar_model_find_item (priv->menubar_model, gsm)) + g_menu_insert_section (G_MENU(gsm->model), gsm->index, NULL, G_MENU_MODEL(menu_model_part)); + else + PERR("Could not find '%s' in menu model", ui_updates[i]); + } + g_free (gsm); + g_object_unref (builder); } @@ -3494,59 +3465,39 @@ gnc_main_window_manual_merge_actions (GncMainWindow *window, void gnc_main_window_merge_actions (GncMainWindow *window, const gchar *group_name, - GtkActionEntry *actions, + GActionEntry *actions, guint n_actions, - GtkToggleActionEntry *toggle_actions, - guint n_toggle_actions, - const gchar *filename, + const gchar **ui_updates, + const gchar *ui_filename, gpointer user_data) { GncMainWindowPrivate *priv; GncMainWindowActionData *data; - GError *error = nullptr; - gchar *pathname; + GSimpleActionGroup *simple_action_group; - g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); g_return_if_fail (group_name != nullptr); g_return_if_fail (actions != nullptr); g_return_if_fail (n_actions > 0); - g_return_if_fail (filename != nullptr); - - pathname = gnc_filepath_locate_ui_file (filename); - if (pathname == nullptr) - return; data = g_new0 (GncMainWindowActionData, 1); data->window = window; data->data = user_data; priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - auto entry{static_cast(g_new0 (MergedActionEntry, 1))}; - entry->action_group = gtk_action_group_new (group_name); - gtk_action_group_set_translation_domain (entry->action_group, PROJECT_NAME); - gtk_action_group_add_actions (entry->action_group, actions, n_actions, data); - if (toggle_actions != nullptr && n_toggle_actions > 0) - { - gtk_action_group_add_toggle_actions (entry->action_group, - toggle_actions, n_toggle_actions, - data); - } - gtk_ui_manager_insert_action_group (window->ui_merge, entry->action_group, 0); - entry->merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, pathname, &error); - g_assert(entry->merge_id || error); - if (entry->merge_id) - { - gtk_ui_manager_ensure_update (window->ui_merge); - g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry); - } - else - { - g_critical("Failed to load ui file.\n Filename %s\n Error %s", - filename, error->message); - g_error_free(error); - g_free(entry); - } - g_free(pathname); + + simple_action_group = g_simple_action_group_new (); + + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + actions, + n_actions, + data); + + gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, + G_ACTION_GROUP(simple_action_group)); + + if (ui_filename) + update_menu_model (window, ui_filename, ui_updates); } @@ -3559,64 +3510,44 @@ void gnc_main_window_unmerge_actions (GncMainWindow *window, const gchar *group_name) { - GncMainWindowPrivate *priv; - g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); g_return_if_fail (group_name != nullptr); + gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, nullptr); +} + +GAction * +gnc_main_window_find_action (GncMainWindow *window, const gchar *action_name) +{ + GncMainWindowPrivate *priv; + GAction *action = nullptr; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + g_return_val_if_fail (action_name != nullptr, nullptr); + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - if (priv->merged_actions_table == nullptr) - return; - auto entry{static_cast(g_hash_table_lookup (priv->merged_actions_table, group_name))}; - if (entry == nullptr) - return; + action = g_action_map_lookup_action (G_ACTION_MAP(window), + action_name); - gtk_ui_manager_remove_action_group (window->ui_merge, entry->action_group); - gtk_ui_manager_remove_ui (window->ui_merge, entry->merge_id); - gtk_ui_manager_ensure_update (window->ui_merge); - - g_hash_table_remove (priv->merged_actions_table, group_name); + return action; } - -/* Force a full update of the user interface for the specified - * window. This can be an expensive function, but is needed because - * the gtk ui manager doesn't always seem to update properly when - * actions are changed. - */ -void -gnc_main_window_actions_updated (GncMainWindow *window) +GAction * +gnc_main_window_find_action_in_group (GncMainWindow *window, + const gchar *group_name, + const gchar *action_name) { - GtkActionGroup *force; + GAction *action = nullptr; - g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + g_return_val_if_fail (group_name != nullptr, nullptr); + g_return_val_if_fail (action_name != nullptr, nullptr); - /* Unfortunately gtk_ui_manager_ensure_update doesn't work - * here. Force a full update by adding and removing an empty - * action group. - */ - force = gtk_action_group_new("force_update"); - gtk_ui_manager_insert_action_group (window->ui_merge, force, 0); - gtk_ui_manager_ensure_update (window->ui_merge); - gtk_ui_manager_remove_action_group (window->ui_merge, force); - g_object_unref(force); -} + auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name); + if (action_group) + action = g_action_map_lookup_action (G_ACTION_MAP(window), action_name); - -GtkAction * -gnc_main_window_find_action (GncMainWindow *window, const gchar *name) -{ - GtkAction *action = nullptr; - const GList *groups, *tmp; - - groups = gtk_ui_manager_get_action_groups(window->ui_merge); - for (tmp = groups; tmp; tmp = g_list_next(tmp)) - { - action = gtk_action_group_get_action(GTK_ACTION_GROUP(tmp->data), name); - if (action) - break; - } return action; } @@ -3625,35 +3556,301 @@ gnc_main_window_find_action (GncMainWindow *window, const gchar *name) * This function can be used to get an group of action to be * manipulated when the front page of a window has changed. */ -GtkActionGroup * +GSimpleActionGroup * gnc_main_window_get_action_group (GncMainWindow *window, const gchar *group_name) { - GncMainWindowPrivate *priv; - - g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), nullptr); + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); g_return_val_if_fail (group_name != nullptr, nullptr); - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - if (priv->merged_actions_table == nullptr) - return nullptr; - auto entry{static_cast(g_hash_table_lookup (priv->merged_actions_table, group_name))}; - - if (entry == nullptr) - return nullptr; - - return entry->action_group; + auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name); + return (GSimpleActionGroup*)action_group; } +//FIXMEb## + + +GtkWidget * +gnc_main_window_toolbar_find_tool_item (GncMainWindow *window, const gchar *action_name) +{ + GncMainWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + g_return_val_if_fail (action_name != nullptr, nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + return gnc_find_toolbar_item (priv->toolbar, action_name); +} + +GtkWidget * +gnc_main_window_menu_find_menu_item (GncMainWindow *window, const gchar *action_name) +{ + GncMainWindowPrivate *priv; + GtkWidget *menu_item; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + g_return_val_if_fail (action_name != nullptr, nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + menu_item = GTK_WIDGET(g_hash_table_lookup (priv->display_item_hash, action_name)); + + priv->num_item_q++; //FIXMEb temp added + + if (!menu_item) + { + menu_item = gnc_menubar_model_find_menu_item (priv->menubar_model, priv->menubar, action_name); + + g_hash_table_insert (priv->display_item_hash, g_strdup (action_name), menu_item); + } + return menu_item; +} + + +void +gnc_main_window_menu_add_accelerator_keys (GncMainWindow *window) +{ + GncMainWindowPrivate *priv; + + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + gnc_add_accelerator_keys_for_menu (priv->menubar, priv->accel_group); +} + + +gboolean +gnc_main_window_update_menu_for_action (GncMainWindow *window, + const gchar *action_name, + const gchar *label, + const gchar *tooltip) +{ + GncMainWindowPrivate *priv; + gboolean found = false; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), false); + g_return_val_if_fail (action_name != nullptr, false); + g_return_val_if_fail (label != nullptr, false); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + found = gnc_menubar_model_update_item (priv->menubar_model, action_name, + _(label), _(tooltip)); + + // add tooltip redirect call backs + gnc_plugin_add_menu_tooltip_callbacks (priv->menubar, + priv->menubar_model, + priv->statusbar); + + return found; +} + +void +gnc_main_window_set_vis_of_items_by_action (GncMainWindow *window, + const gchar **action_names, + gboolean vis) +{ + GncMainWindowPrivate *priv; + + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + for (gint i = 0; action_names[i]; i++) + { + GtkWidget *tool_item = gnc_find_toolbar_item (priv->toolbar, action_names[i]); + GtkWidget *menu_item = gnc_main_window_menu_find_menu_item (window, action_names[i]); + + if (menu_item) + { + PINFO("Found menu_item %p with action name '%s', seting vis to '%s'", + menu_item, action_names[i], vis ? "true" : "false"); + gtk_widget_set_visible (menu_item, vis); + } + else + PINFO("Did not find menu_item with action name '%s' to set vis '%s'", + action_names[i], vis ? "true" : "false"); + + if (tool_item) + { + PINFO("Found tool_item %p with action name '%s', seting vis to '%s'", + tool_item, action_names[i], vis ? "true" : "false"); + gtk_widget_set_visible (tool_item, vis); + } + else + PINFO("Did not find tool_item with action name '%s' to set vis '%s'", + action_names[i], vis ? "true" : "false"); + } +} + + +void +gnc_main_window_init_short_names (GncMainWindow *window, + GncToolBarShortNames *toolbar_labels) +{ + GncMainWindowPrivate *priv; + + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + g_return_if_fail (toolbar_labels != nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + gnc_plugin_init_short_names (priv->toolbar, toolbar_labels); +} + + +static void +gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page, + const gchar *toolbar_qualifier) +{ + GncMainWindowPrivate *priv; + GtkBuilder *builder; + GAction *action; + + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + builder = gnc_plugin_page_get_builder (page); + + if (builder) + { + gchar *toolbar_name; + gtk_container_remove (GTK_CONTAINER(priv->menu_dock), priv->toolbar); + + if (toolbar_qualifier) + toolbar_name = g_strconcat ("mainwin-toolbar-", toolbar_qualifier, nullptr); + else + toolbar_name = g_strdup ("mainwin-toolbar"); + + priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, toolbar_name); + + if (!priv->toolbar) + priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, "mainwin-toolbar"); + + g_object_set (priv->toolbar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), priv->toolbar); + g_free (toolbar_name); + } + + action = gnc_main_window_find_action (window, "ViewToolbarAction"); + + // set visibility of toolbar + if (action) + { + GVariant *state = g_action_get_state (G_ACTION(action)); + gtk_widget_set_visible (priv->toolbar, g_variant_get_boolean (state)); + g_variant_unref (state); + } + // add tooltip redirect call backs + gnc_plugin_add_toolbar_tooltip_callbacks (priv->toolbar, priv->statusbar); +} + + +void +gnc_main_window_update_menu_and_toolbar (GncMainWindow *window, + GncPluginPage *page, + const gchar **ui_updates) +{ + GncMainWindowPrivate *priv; + const gchar *plugin_page_actions_group_name; + GtkBuilder *builder; + const gchar *menu_qualifier; + + GMenuModel *menu_model_part; + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + g_return_if_fail (page != nullptr); + g_return_if_fail (ui_updates != nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + builder = gnc_plugin_page_get_builder (page); + + if (!builder) + return; + + menu_qualifier = gnc_plugin_page_get_menu_qualifier (page); + + plugin_page_actions_group_name = gnc_plugin_page_get_simple_action_group_name (page); + + if (!plugin_page_actions_group_name) + return; + + gtk_widget_insert_action_group (GTK_WIDGET(window), gnc_plugin_page_get_simple_action_group_name (page), + G_ACTION_GROUP(gnc_plugin_page_get_action_group (page))); + + if ((g_strcmp0 (priv->previous_plugin_page_name, + plugin_page_actions_group_name) == 0) && + (g_strcmp0 (priv->previous_menu_qualifier, + menu_qualifier) == 0)) + return; + + priv->previous_plugin_page_name = plugin_page_actions_group_name; + priv->previous_menu_qualifier = menu_qualifier; + + gnc_main_window_update_toolbar (window, page, menu_qualifier); + + PERR("Display Item Hash size %d", g_hash_table_size (priv->display_item_hash)); //FIXMEb temp added + PERR("Display Item Q %d", priv->num_item_q); //FIXMEb temp added + + // reset hash table and remove added menu items + g_hash_table_remove_all (priv->display_item_hash); + gnc_menubar_model_remove_items_with_attrib (priv->menubar_model, + GNC_MENU_ATTRIBUTE_TEMPORARY); + priv->num_item_q = 0; //FIXMEb temp added + + for (gint i = 0; ui_updates[i]; i++) + { + gchar *menu_name; + + if (menu_qualifier) + menu_name = g_strconcat (ui_updates[i], "-", menu_qualifier, nullptr); + else + menu_name = g_strdup (ui_updates[i]); + + menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, menu_name); + + if (!menu_model_part) + menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, ui_updates[i]); + + gsm->search_action_label = nullptr; + gsm->search_action_name = ui_updates[i]; + + if (gnc_menubar_model_find_item (priv->menubar_model, gsm)) + g_menu_insert_section (G_MENU(gsm->model), gsm->index, + nullptr, G_MENU_MODEL(menu_model_part)); + else + PERR("Could not find '%s' in menu model", ui_updates[i]); + + g_free (menu_name); + } + + // add tooltip redirect call backs + gnc_plugin_add_menu_tooltip_callbacks (priv->menubar, priv->menubar_model, priv->statusbar); + + // need to add the accelerator keys + gnc_add_accelerator_keys_for_menu (priv->menubar, priv->accel_group); + + // need to signal menu has been changed + g_signal_emit_by_name (window, "menu_changed", page); + + g_free (gsm); +} + + static void gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_data) { GncMainWindow *window; GtkPositionType position = GTK_POS_TOP; + gint item = 0; GncMainWindowPrivate *priv; - GtkAction *first_action; - GtkAction *position_action; - gsize i; + GAction *action; g_return_if_fail (GNC_IS_MAIN_WINDOW(user_data)); @@ -3667,36 +3864,36 @@ gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_ return; if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM)) + { position = GTK_POS_BOTTOM; + item = 1; + } else if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT)) + { position = GTK_POS_LEFT; + item = 2; + } else if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT)) + { position = GTK_POS_RIGHT; + item = 3; + } - priv = GNC_MAIN_WINDOW_GET_PRIVATE (window); - gtk_notebook_set_tab_pos (GTK_NOTEBOOK (priv->notebook), position); + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + gtk_notebook_set_tab_pos (GTK_NOTEBOOK(priv->notebook), position); - /* Groups of radio actions use the first action for the callback and all - * change events so block/unblock signals on the first radio action. */ - first_action = gtk_action_group_get_action (priv->action_group, - tab_pos_radio_entries[0].name); + action = g_action_map_lookup_action (G_ACTION_MAP(window), + "ViewTabPositionAction"); - for (i = n_tab_pos_radio_entries - 1; i > 0; i--) - if (tab_pos_radio_entries[i].value == position) - break; - - position_action = gtk_action_group_get_action (priv->action_group, - tab_pos_radio_entries[i].name); - - g_signal_handlers_block_by_func (G_OBJECT (first_action), + g_signal_handlers_block_by_func (G_OBJECT(action), (gpointer)gnc_main_window_cmd_view_tab_position, window); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (position_action), TRUE); - g_signal_handlers_unblock_by_func (G_OBJECT (first_action), + g_action_change_state (G_ACTION(action), g_variant_new_int32 (item)); + g_signal_handlers_unblock_by_func (G_OBJECT(action), (gpointer)gnc_main_window_cmd_view_tab_position, window); - gnc_main_window_update_tab_width (NULL, (char*)GNC_PREF_TAB_WIDTH, NULL); + gnc_main_window_update_tab_width (nullptr, (char*)GNC_PREF_TAB_WIDTH, nullptr); LEAVE (""); } @@ -3710,11 +3907,12 @@ gnc_main_window_update_edit_actions_sensitivity (GncMainWindow *window, gboolean GncMainWindowPrivate *priv; GncPluginPage *page; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window)); - GtkAction *action; - gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE; + GAction *action; + gboolean can_copy = false, can_cut = false, can_paste = false; priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); page = priv->current_page; + if (page && GNC_PLUGIN_PAGE_GET_CLASS(page)->update_edit_menu_actions) { (GNC_PLUGIN_PAGE_GET_CLASS(page)->update_edit_menu_actions)(page, hide); @@ -3749,39 +3947,37 @@ gnc_main_window_update_edit_actions_sensitivity (GncMainWindow *window, gboolean { #ifdef ORIGINAL_EPIPHANY_CODE /* For now we assume all actions are possible */ - can_copy = can_cut = can_paste = TRUE; + can_copy = can_cut = can_paste = true; #else /* If its not a GtkEditable, we don't know what to do * with it. */ - can_copy = can_cut = can_paste = FALSE; + can_copy = can_cut = can_paste = false; #endif } - action = gnc_main_window_find_action (window, "EditCopyAction"); - gtk_action_set_sensitive (action, can_copy); - gtk_action_set_visible (action, !hide || can_copy); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_copy); + action = gnc_main_window_find_action (window, "EditCutAction"); - gtk_action_set_sensitive (action, can_cut); - gtk_action_set_visible (action, !hide || can_cut); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_cut); + action = gnc_main_window_find_action (window, "EditPasteAction"); - gtk_action_set_sensitive (action, can_paste); - gtk_action_set_visible (action, !hide || can_paste); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_paste); } static void gnc_main_window_enable_edit_actions_sensitivity (GncMainWindow *window) { - GtkAction *action; + GAction *action; action = gnc_main_window_find_action (window, "EditCopyAction"); - gtk_action_set_sensitive (action, TRUE); - gtk_action_set_visible (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), true); + action = gnc_main_window_find_action (window, "EditCutAction"); - gtk_action_set_sensitive (action, TRUE); - gtk_action_set_visible (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), true); + action = gnc_main_window_find_action (window, "EditPasteAction"); - gtk_action_set_sensitive (action, TRUE); - gtk_action_set_visible (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), true); + } static void @@ -3801,44 +3997,19 @@ gnc_main_window_edit_menu_hide_cb (GtkWidget *menu, static void gnc_main_window_init_menu_updaters (GncMainWindow *window) { + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); GtkWidget *edit_menu_item, *edit_menu; - edit_menu_item = gtk_ui_manager_get_widget - (window->ui_merge, "/menubar/Edit"); - edit_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (edit_menu_item)); + edit_menu_item = gnc_main_window_menu_find_menu_item (window, "EditAction"); + + edit_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(edit_menu_item)); g_signal_connect (edit_menu, "show", - G_CALLBACK (gnc_main_window_edit_menu_show_cb), window); + G_CALLBACK(gnc_main_window_edit_menu_show_cb), window); g_signal_connect (edit_menu, "hide", - G_CALLBACK (gnc_main_window_edit_menu_hide_cb), window); + G_CALLBACK(gnc_main_window_edit_menu_hide_cb), window); } -static void -gnc_main_window_window_menu (GncMainWindow *window) -{ - guint merge_id; -#ifdef MAC_INTEGRATION - gchar *filename = gnc_filepath_locate_ui_file("gnc-windows-menu-ui-quartz.xml"); -#else - gchar *filename = gnc_filepath_locate_ui_file("gnc-windows-menu-ui.xml"); - GncMainWindowPrivate *priv; -#endif - GError *error = nullptr; - g_assert(filename); - merge_id = gtk_ui_manager_add_ui_from_file(window->ui_merge, filename, - &error); - g_free(filename); - g_assert(merge_id); -#ifndef MAC_INTEGRATION - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - gtk_action_group_add_radio_actions (priv->action_group, - radio_entries, n_radio_entries, - 0, - G_CALLBACK(gnc_main_window_cmd_window_raise), - window); -#endif -}; - /* This is used to prevent the tab having focus */ static gboolean gnc_main_window_page_focus_in (GtkWidget *widget, GdkEvent *event, @@ -3851,16 +4022,60 @@ gnc_main_window_page_focus_in (GtkWidget *widget, GdkEvent *event, return FALSE; } +static GAction * +gnc_main_window_get_redirect (GncMainWindow *window, const gchar *action_name) +{ + GncMainWindowPrivate *priv; + GAction *action = nullptr; + const gchar *group_name; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), nullptr); + g_return_val_if_fail (action_name != nullptr, nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + group_name = gnc_plugin_page_get_simple_action_group_name (priv->current_page); + + PINFO("action anme is '%s', group_name is '%s'", action_name, group_name); + + if (group_name) + { + action = gnc_main_window_find_action_in_group (window, group_name, action_name); + + if (!action) + action = gnc_plugin_page_get_action (priv->current_page, action_name); + } + + PINFO("Redirect action is %p for action anme '%s' and group_name '%s'", + action, action_name, group_name); + return action; +} + +static void +main_window_realize_cb (GtkWidget *widget, gpointer user_data) +{ + GncMainWindow *window = (GncMainWindow*)user_data; + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + gnc_add_accelerator_keys_for_menu (GTK_WIDGET(priv->menubar), priv->accel_group); + + /* need to signal menu has been changed, this will call the + business function 'bind_extra_toolbuttons_visibility' */ + g_signal_emit_by_name (window, "menu_changed", nullptr); +} + static void gnc_main_window_setup_window (GncMainWindow *window) { GncMainWindowPrivate *priv; GtkWidget *main_vbox; - guint merge_id; + GtkBuilder *builder; GncPluginManager *manager; + GtkWidget *extra_item; GList *plugins; GError *error = nullptr; gchar *filename; + GAction *action; ENTER(" "); @@ -3910,65 +4125,47 @@ gnc_main_window_setup_window (GncMainWindow *window) gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(priv->progressbar), 0.01); - window->ui_merge = gtk_ui_manager_new (); + builder = gtk_builder_new (); + gtk_builder_set_translation_domain (builder, PROJECT_NAME); + gtk_builder_add_from_resource (builder, "/org/gnucash/ui/gnc-main-window.ui", &error); - /* Create menu and toolbar information */ - priv->action_group = gtk_action_group_new ("MainWindowActions"); - gtk_action_group_set_translation_domain (priv->action_group, PROJECT_NAME); - gtk_action_group_add_actions (priv->action_group, gnc_menu_actions, - gnc_menu_n_actions, window); - gtk_action_group_add_toggle_actions (priv->action_group, - toggle_actions, n_toggle_actions, - window); - gnc_plugin_update_actions(priv->action_group, - initially_insensitive_actions, - "sensitive", FALSE); - gnc_plugin_update_actions(priv->action_group, - always_insensitive_actions, - "sensitive", FALSE); - gnc_plugin_update_actions(priv->action_group, - always_hidden_actions, - "visible", FALSE); - gnc_plugin_set_important_actions (priv->action_group, - gnc_menu_important_actions); - gtk_ui_manager_insert_action_group (window->ui_merge, priv->action_group, 0); - - g_signal_connect (G_OBJECT (window->ui_merge), "add_widget", - G_CALLBACK (gnc_main_window_add_widget), window); - - /* Use the "connect-proxy" signal for tooltip display in the status bar */ - g_signal_connect (G_OBJECT (window->ui_merge), "connect-proxy", - G_CALLBACK (gnc_window_connect_proxy), priv->statusbar); - - filename = gnc_filepath_locate_ui_file("gnc-main-window-ui.xml"); - - /* Can't do much without a ui. */ - g_assert (filename); - - merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, - filename, &error); - g_assert(merge_id || error); - if (merge_id) + if (error) { - gtk_action_group_add_radio_actions (priv->action_group, - tab_pos_radio_entries, - n_tab_pos_radio_entries, - 0, - G_CALLBACK(gnc_main_window_cmd_view_tab_position), - window); - gtk_window_add_accel_group (GTK_WINDOW (window), - gtk_ui_manager_get_accel_group(window->ui_merge)); - gtk_ui_manager_ensure_update (window->ui_merge); + g_critical ("Failed to load, Error %s", error->message); + g_error_free (error); + return; //FIXMEb this may need changing } - else - { - g_critical("Failed to load ui file.\n Filename %s\n Error %s", - filename, error->message); - g_error_free(error); - g_assert(merge_id != 0); - } - g_free(filename); - gnc_main_window_window_menu(window); + + g_action_map_add_action_entries (G_ACTION_MAP(window), + gnc_menu_actions, + gnc_menu_n_actions, + window); + + priv->menubar_model = (GMenuModel *)gtk_builder_get_object (builder, "mainwin-menu"); + priv->menubar = gtk_menu_bar_new_from_model (priv->menubar_model); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), priv->menubar); //FIXMEb this may need changing + gtk_widget_show (GTK_WIDGET(priv->menubar)); + + priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, "mainwin-toolbar"); + g_object_set (priv->toolbar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(priv->toolbar)); //FIXMEb this may need changing + gtk_widget_show (GTK_WIDGET(priv->toolbar)); + + g_object_unref (builder); + + gnc_plugin_set_actions_enabled (G_ACTION_MAP(window), + initially_insensitive_actions, + FALSE); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(window), + always_insensitive_actions, + FALSE); + + gnc_main_window_set_vis_of_items_by_action (window, always_hidden_actions, + false); + + gtk_widget_insert_action_group (GTK_WIDGET(window), "mainwin", + G_ACTION_GROUP(window)); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP, (gpointer)gnc_main_window_update_tab_position, @@ -3985,19 +4182,22 @@ gnc_main_window_setup_window (GncMainWindow *window) GNC_PREF_TAB_POSITION_RIGHT, (gpointer)gnc_main_window_update_tab_position, window); - gnc_main_window_update_tab_position(nullptr, nullptr, window); + gnc_main_window_update_tab_position (nullptr, nullptr, window); - gnc_main_window_init_menu_updaters(window); + gnc_main_window_init_menu_updaters (window); + + /* Disable the Transaction menu */ + action = gnc_main_window_find_action (window, "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), false); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (window, "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), false); - /* Testing */ /* Now update the "eXtensions" menu */ if (!gnc_prefs_is_extra_enabled()) { - GtkAction* action; - - action = gtk_action_group_get_action(priv->action_group, - "ExtensionsAction"); - gtk_action_set_visible(action, FALSE); + action = gnc_main_window_find_action (window, "ExtensionsAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), false); } /* GncPluginManager stuff */ @@ -4011,6 +4211,10 @@ gnc_main_window_setup_window (GncMainWindow *window) g_signal_connect (G_OBJECT (manager), "plugin-removed", G_CALLBACK (gnc_main_window_plugin_removed), window); + // need to add the accelerator keys this way, mainly for --nofile + g_signal_connect (G_OBJECT(window), "realize", + G_CALLBACK(main_window_realize_cb), window); + LEAVE(" "); } @@ -4042,74 +4246,57 @@ gnc_quartz_should_quit (GtkosxApplication *theApp, GncMainWindow *window) } static void -gnc_quartz_set_menu(GncMainWindow* window) +gnc_quartz_set_menu (GncMainWindow* window) { + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); auto theApp{static_cast(g_object_new(GTKOSX_TYPE_APPLICATION, nullptr))}; - GtkWidget *menu; - GtkWidget *item; + GtkWidget *item = nullptr; + GAction *action; - menu = gtk_ui_manager_get_widget (window->ui_merge, "/menubar"); - if (GTK_IS_MENU_ITEM (menu)) - menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu)); - gtk_widget_hide(menu); - gtkosx_application_set_menu_bar (theApp, GTK_MENU_SHELL (menu)); + gtk_widget_hide (priv->menubar); + gtk_widget_set_no_show_all (priv->menubar, true); - item = gtk_ui_manager_get_widget (window->ui_merge, - "/menubar/File/FileQuit"); - if (GTK_IS_MENU_ITEM (item)) - gtk_widget_hide (GTK_WIDGET (item)); + gtkosx_application_set_menu_bar (theApp, GTK_MENU_SHELL(priv->menubar)); - item = gtk_ui_manager_get_widget (window->ui_merge, - "/menubar/Help/HelpAbout"); - if (GTK_IS_MENU_ITEM (item)) + // File Quit + item = gnc_main_window_menu_find_menu_item (window, "FileQuitAction"); + if (item) + gtk_widget_hide (GTK_WIDGET(item)); + + // Help About + item = gnc_main_window_menu_find_menu_item (window, "HelpAboutAction"); + if (item) { - gtkosx_application_insert_app_menu_item (theApp, GTK_WIDGET (item), 0); + gtk_widget_hide (item); + gtkosx_application_insert_app_menu_item (theApp, GTK_WIDGET(item), 0); } - item = gtk_ui_manager_get_widget (window->ui_merge, - "/menubar/Edit/EditPreferences"); - if (GTK_IS_MENU_ITEM (item)) + // Edit Preferences + item = gnc_main_window_menu_find_menu_item (window, "EditPreferencesAction"); + if (item) { - gtkosx_application_insert_app_menu_item (theApp, - gtk_separator_menu_item_new (), 1); - gtkosx_application_insert_app_menu_item (theApp, GTK_WIDGET (item), 2); + gtk_widget_hide (GTK_WIDGET(item)); + gtkosx_application_insert_app_menu_item (theApp, GTK_WIDGET(item), 2); } - item = gtk_ui_manager_get_widget (window->ui_merge, - "/menubar/Help"); - gtkosx_application_set_help_menu(theApp, GTK_MENU_ITEM(item)); - item = gtk_ui_manager_get_widget (window->ui_merge, - "/menubar/Windows"); - gtkosx_application_set_window_menu(theApp, GTK_MENU_ITEM(item)); - g_signal_connect(theApp, "NSApplicationBlockTermination", - G_CALLBACK(gnc_quartz_should_quit), window); + // Help Menu + item = gnc_main_window_menu_find_menu_item (window, "HelpAction"); + if (item) + gtkosx_application_set_help_menu (theApp, GTK_MENU_ITEM(item)); + // Windows Menu + item = gnc_main_window_menu_find_menu_item (window, "WindowsAction"); + if (item) + gtkosx_application_set_window_menu (theApp, GTK_MENU_ITEM(item)); + + g_signal_connect (theApp, "NSApplicationBlockTermination", + G_CALLBACK(gnc_quartz_should_quit), window); + gtkosx_application_set_use_quartz_accelerators (theApp, FALSE); g_object_unref (theApp); - } #endif //MAC_INTEGRATION /* Callbacks */ -static void -gnc_main_window_add_widget (GtkUIManager *merge, - GtkWidget *widget, - GncMainWindow *window) -{ - GncMainWindowPrivate *priv; - - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - if (GTK_IS_TOOLBAR (widget)) - { - priv->toolbar = widget; - gtk_toolbar_set_style (GTK_TOOLBAR(priv->toolbar), - GTK_TOOLBAR_BOTH); - gtk_toolbar_set_icon_size (GTK_TOOLBAR(priv->toolbar), - GTK_ICON_SIZE_SMALL_TOOLBAR); - } - - gtk_box_pack_start (GTK_BOX (priv->menu_dock), widget, FALSE, FALSE, 0); - gtk_widget_show (widget); -} /** Should a summary bar be visible in this window? In order to * prevent synchronization issues, the "ViewSummaryBar" @@ -4124,17 +4311,25 @@ gnc_main_window_add_widget (GtkUIManager *merge, * @return TRUE if the summarybar should be visible. */ static gboolean -gnc_main_window_show_summarybar (GncMainWindow *window, GtkAction *action) +gnc_main_window_show_summarybar (GncMainWindow *window, GAction *action) { - GncMainWindowPrivate *priv; + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + GVariant *state; + gboolean visible; - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); if (action == nullptr) - action = gtk_action_group_get_action(priv->action_group, + action = g_action_map_lookup_action (G_ACTION_MAP(window), "ViewSummaryAction"); if (action == nullptr) return TRUE; - return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); + + state = g_action_get_state (G_ACTION(action)); + + visible = g_variant_get_boolean (state); + + g_variant_unref (state); + + return visible; } /** This function is invoked when the GtkNotebook switches pages. It @@ -4165,7 +4360,6 @@ gnc_main_window_switch_page (GtkNotebook *notebook, if (priv->current_page != nullptr) { page = priv->current_page; - gnc_plugin_page_unmerge_actions (page, window->ui_merge); gnc_plugin_page_unselected (page); } @@ -4184,8 +4378,8 @@ gnc_main_window_switch_page (GtkNotebook *notebook, if (page != nullptr) { /* Update the user interface (e.g. menus and toolbars */ - gnc_plugin_page_merge_actions (page, window->ui_merge); - visible = gnc_main_window_show_summarybar(window, nullptr); + gnc_plugin_page_merge_actions (page); + visible = gnc_main_window_show_summarybar (window, nullptr); gnc_plugin_page_show_summarybar (page, visible); /* Allow page specific actions */ @@ -4197,10 +4391,9 @@ gnc_main_window_switch_page (GtkNotebook *notebook, priv->usage_order = g_list_prepend (priv->usage_order, page); } - gnc_plugin_update_actions(priv->action_group, - multiple_page_actions, - "sensitive", - g_list_length(priv->installed_pages) > 1); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(window), + multiple_page_actions, + g_list_length (priv->installed_pages) > 1); gnc_main_window_update_title(window); #ifndef MAC_INTEGRATION @@ -4273,9 +4466,31 @@ gnc_main_window_plugin_removed (GncPlugin *manager, /* Command callbacks */ static void -gnc_main_window_cmd_page_setup (GtkAction *action, - GncMainWindow *window) +gnc_main_window_cmd_redirect (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; + GAction *redirect_action; + + PINFO("Redirect action_is %p, name is '%s'", simple, g_action_get_name (G_ACTION(simple))); + + redirect_action = gnc_main_window_get_redirect (window, g_action_get_name (G_ACTION(simple))); + + if (redirect_action) + { + PINFO("Found action %p", redirect_action); + g_action_activate (redirect_action, nullptr); + return; + } +} + +static void +gnc_main_window_cmd_page_setup (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GncMainWindow *window = (GncMainWindow*)user_data; GtkWindow *gtk_window; g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); @@ -4422,14 +4637,20 @@ gnc_book_options_dialog_cb (gboolean modal, gchar *title, GtkWindow* parent) } static void -gnc_main_window_cmd_file_properties (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_file_properties (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; gnc_book_options_dialog_cb (FALSE, nullptr, GTK_WINDOW (window)); } static void -gnc_main_window_cmd_file_close (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_file_close (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindowPrivate *priv; GncPluginPage *page; @@ -4441,8 +4662,11 @@ gnc_main_window_cmd_file_close (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_file_quit (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_file_quit (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; if (!gnc_main_window_all_finish_pending()) return; @@ -4450,9 +4674,24 @@ gnc_main_window_cmd_file_quit (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_edit_cut (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_edit_cut (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window)); + GAction *redirect_action; + + PINFO("Copy action_is %p, name is '%s'", simple, g_action_get_name (G_ACTION(simple))); + + redirect_action = gnc_main_window_get_redirect (window, g_action_get_name (G_ACTION(simple))); + + if (redirect_action) + { + PINFO("Found action %p", redirect_action); + g_action_activate (redirect_action, nullptr); + return; + } if (GTK_IS_EDITABLE(widget)) { @@ -4471,9 +4710,24 @@ gnc_main_window_cmd_edit_cut (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_edit_copy (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_edit_copy (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window)); + GAction *redirect_action; + + PINFO("Copy action_is %p, name is '%s'", simple, g_action_get_name (G_ACTION(simple))); + + redirect_action = gnc_main_window_get_redirect (window, g_action_get_name (G_ACTION(simple))); + + if (redirect_action) + { + PINFO("Found action %p", redirect_action); + g_action_activate (redirect_action, nullptr); + return; + } if (GTK_IS_EDITABLE(widget)) { @@ -4490,9 +4744,24 @@ gnc_main_window_cmd_edit_copy (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_edit_paste (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_edit_paste (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window)); + GAction *redirect_action; + + PINFO("Paste action_is %p, name is '%s'", simple, g_action_get_name (G_ACTION(simple))); + + redirect_action = gnc_main_window_get_redirect (window, g_action_get_name (G_ACTION(simple))); + + if (redirect_action) + { + PINFO("Found action %p", redirect_action); + g_action_activate (redirect_action, nullptr); + return; + } if (GTK_IS_EDITABLE(widget)) { @@ -4513,25 +4782,37 @@ gnc_main_window_cmd_edit_paste (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_edit_preferences (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_edit_preferences (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; gnc_preferences_dialog (GTK_WINDOW(window)); } static void -gnc_main_window_cmd_view_refresh (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_view_refresh (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; } static void -gnc_main_window_cmd_actions_reset_warnings (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_actions_reset_warnings (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; gnc_reset_warnings_dialog(GTK_WINDOW(window)); } static void -gnc_main_window_cmd_actions_rename_page (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_actions_rename_page (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindowPrivate *priv; GncPluginPage *page; GtkWidget *label, *entry; @@ -4560,56 +4841,74 @@ gnc_main_window_cmd_actions_rename_page (GtkAction *action, GncMainWindow *windo } static void -gnc_main_window_cmd_view_toolbar (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_view_toolbar (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - GncMainWindowPrivate *priv; + GncMainWindow *window = (GncMainWindow*)user_data; + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + GVariant *state = g_action_get_state (G_ACTION(simple)); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) - { + + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state))); + + if (!g_variant_get_boolean (state)) gtk_widget_show (priv->toolbar); - } else - { gtk_widget_hide (priv->toolbar); - } + + g_variant_unref (state); } static void -gnc_main_window_cmd_view_summary (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_view_summary (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - GncMainWindowPrivate *priv; + GncMainWindow *window = (GncMainWindow*)user_data; + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); GList *item; gboolean visible; - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - visible = gnc_main_window_show_summarybar(window, action); - for (item = priv->installed_pages; item; item = g_list_next(item)) + visible = gnc_main_window_show_summarybar (window, G_ACTION(simple)); + + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!visible)); + + for (item = priv->installed_pages; item; item = g_list_next (item)) { - gnc_plugin_page_show_summarybar(static_cast(item->data), - visible); + gnc_plugin_page_show_summarybar (static_cast(item->data), + !visible); } } static void -gnc_main_window_cmd_view_statusbar (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_view_statusbar (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - GncMainWindowPrivate *priv; + GncMainWindow *window = (GncMainWindow*)user_data; + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + GVariant *state = g_action_get_state (G_ACTION(simple)); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) - { + + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state))); + + if (!g_variant_get_boolean (state)) gtk_widget_show (priv->statusbar); - } else - { gtk_widget_hide (priv->statusbar); - } + + g_variant_unref (state); } static void -gnc_main_window_cmd_window_new (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_window_new (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindow *new_window; /* Create the new window */ @@ -4620,15 +4919,18 @@ gnc_main_window_cmd_window_new (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_window_move_page (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_window_move_page (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindowPrivate *priv; GncMainWindow *new_window; GncPluginPage *page; GtkNotebook *notebook; GtkWidget *tab_widget, *menu_widget; - ENTER("action %p,window %p", action, window); + ENTER("action %p, window %p", simple, window); /* Setup */ priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); @@ -4644,6 +4946,12 @@ gnc_main_window_cmd_window_move_page (GtkAction *action, GncMainWindow *window) return; } +#ifndef MAC_INTEGRATION + if (gnc_list_length_cmp (active_windows, gnc_main_window_max_number) == 0) + gnc_info_dialog (GTK_WINDOW(window), "%s", + _("The maximum number of window menu entries reached, no more entries will be added.")); +#endif /* !MAC_INTEGRATION */ + notebook = GTK_NOTEBOOK (priv->notebook); tab_widget = gtk_notebook_get_tab_label (notebook, page->notebook_page); menu_widget = gtk_notebook_get_menu_label (notebook, page->notebook_page); @@ -4681,77 +4989,95 @@ gnc_main_window_cmd_window_move_page (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_view_tab_position (GtkAction *action, - GtkRadioAction *current, - GncMainWindow *window) +gnc_main_window_cmd_view_tab_position (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - auto value{static_cast(gtk_radio_action_get_current_value(current))}; + GncMainWindow *window = (GncMainWindow*)user_data; + gint item = g_variant_get_int32 (parameter); - if (value != GTK_POS_TOP && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP)) + g_action_change_state (G_ACTION(simple), parameter); + + if (item < 0 || item > 3) + return; + + if (item != 0 && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP)) gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP, FALSE); - if (value != GTK_POS_BOTTOM && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM)) + if (item != 1 && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM)) gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM, FALSE); - if (value != GTK_POS_LEFT && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT)) + if (item != 2 && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT)) gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT, FALSE); - if (value != GTK_POS_RIGHT && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT)) + if (item != 3 && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT)) gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT, FALSE); - switch (value) + switch (item) { - case GTK_POS_TOP: + case 0: gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP, TRUE); break; - case GTK_POS_BOTTOM: + case 1: gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM, TRUE); break; - case GTK_POS_LEFT: + case 2: gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT, TRUE); break; - case GTK_POS_RIGHT: + case 3: gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT, TRUE); break; } + } #ifndef MAC_INTEGRATION static void -gnc_main_window_cmd_window_raise (GtkAction *action, - GtkRadioAction *current, - GncMainWindow *old_window) +gnc_main_window_cmd_window_raise (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindow *new_window; - gint value; + gint item; - g_return_if_fail(GTK_IS_ACTION(action)); - g_return_if_fail(GTK_IS_RADIO_ACTION(current)); - g_return_if_fail(GNC_IS_MAIN_WINDOW(old_window)); + g_return_if_fail (G_IS_SIMPLE_ACTION(simple)); + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + + item = g_variant_get_int32 (parameter); + + ENTER("action %p, window %p, item %d", simple, window, item); + + g_action_change_state (G_ACTION(simple), parameter); + + new_window = static_cast(g_list_nth_data (active_windows, item)); + gtk_window_present (GTK_WINDOW(new_window)); - ENTER("action %p, current %p, window %p", action, current, old_window); - value = gtk_radio_action_get_current_value(current); - new_window = static_cast(g_list_nth_data(active_windows, value)); - gtk_window_present(GTK_WINDOW(new_window)); /* revert the change in the radio group * impossible while handling "changed" (G_SIGNAL_NO_RECURSE) */ - g_idle_add((GSourceFunc)gnc_main_window_update_radio_button, old_window); + g_idle_add ((GSourceFunc)gnc_main_window_update_radio_button, window); LEAVE(" "); } #endif /* !MAC_INTEGRATION */ static void -gnc_main_window_cmd_help_tutorial (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_help_tutorial (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; gnc_gnome_help (GTK_WINDOW(window), DF_GUIDE, NULL); } static void -gnc_main_window_cmd_help_contents (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_help_contents (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; gnc_gnome_help (GTK_WINDOW(window), DF_MANUAL, NULL); } @@ -4882,14 +5208,13 @@ add_about_paths (GtkDialog *dialog) } /** Create and display the "about" dialog for gnucash. - * - * @param action The GtkAction for the "about" menu item. - * - * @param window The main window whose menu item was activated. */ static void -gnc_main_window_cmd_help_about (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_help_about (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; /* Translators: %s will be replaced with the current year */ gchar *copyright = g_strdup_printf(_("Copyright © 1997-%s The GnuCash contributors."), GNC_VCS_REV_YEAR); @@ -5065,29 +5390,55 @@ gnc_main_window_get_progressbar (GncWindow *window_in) } -static void -gnc_main_window_all_ui_set_sensitive (GncWindow *unused, gboolean sensitive) +/** Retrieve the menu bar associated with a main window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GtkWidget * +gnc_main_window_get_menubar (GncWindow *window) { + GncMainWindowPrivate *priv; - for (auto winp = active_windows; winp; winp = g_list_next(winp)) - { - auto window{static_cast(winp->data)}; - auto priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); - auto groups = gtk_ui_manager_get_action_groups(window->ui_merge); - for (auto groupp = groups; groupp; groupp = g_list_next(groupp)) - { - gtk_action_group_set_sensitive(GTK_ACTION_GROUP(groupp->data), sensitive); - } + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - for (auto tmp = priv->installed_pages; tmp; tmp = g_list_next(tmp)) - { - auto close_button{static_cast(g_object_get_data(static_cast(tmp->data), PLUGIN_PAGE_CLOSE_BUTTON))}; - if (!close_button) - continue; - gtk_widget_set_sensitive (close_button, sensitive); - } - } + return priv->menubar; +} + +/** Retrieve the tool bar associated with a main window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GtkWidget * +gnc_main_window_get_toolbar (GncWindow *window) +{ + GncMainWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + return priv->toolbar; +} + +/** Retrieve the display hash table associated with a main window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GMenuModel * +gnc_main_window_get_menubar_model (GncWindow *window) +{ + GncMainWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + return priv->menubar_model; } @@ -5098,10 +5449,12 @@ gnc_main_window_all_ui_set_sensitive (GncWindow *unused, gboolean sensitive) static void gnc_window_main_window_init (GncWindowIface *iface) { - iface->get_gtk_window = gnc_main_window_get_gtk_window; - iface->get_statusbar = gnc_main_window_get_statusbar; - iface->get_progressbar = gnc_main_window_get_progressbar; - iface->ui_set_sensitive = gnc_main_window_all_ui_set_sensitive; + iface->get_gtk_window = gnc_main_window_get_gtk_window; + iface->get_statusbar = gnc_main_window_get_statusbar; + iface->get_progressbar = gnc_main_window_get_progressbar; + iface->get_menubar = gnc_main_window_get_menubar; + iface->get_toolbar = gnc_main_window_get_toolbar; + iface->get_menubar_model = gnc_main_window_get_menubar_model; } @@ -5131,29 +5484,50 @@ gnc_main_window_set_progressbar_window (GncMainWindow *window) * request). */ static void -do_popup_menu(GncPluginPage *page, GdkEventButton *event) +do_popup_menu (GncPluginPage *page, GdkEventButton *event) { - GtkUIManager *ui_merge; + GtkBuilder *builder; + GMenuModel *menu_model; GtkWidget *menu; + const gchar *menu_qualifier; + gchar *popup_menu_name; - g_return_if_fail(GNC_IS_PLUGIN_PAGE(page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); ENTER("page %p, event %p", page, event); - ui_merge = gnc_plugin_page_get_ui_merge(page); - if (ui_merge == nullptr) + + builder = gnc_plugin_page_get_builder (page); + + menu_qualifier = gnc_plugin_page_get_menu_qualifier (page); + + if (builder == nullptr) { - LEAVE("no ui merge"); + LEAVE("no builder"); return; } - menu = gtk_ui_manager_get_widget(ui_merge, "/MainPopup"); + if (menu_qualifier) + popup_menu_name = g_strconcat ("mainwin-popup-", menu_qualifier, NULL); + else + popup_menu_name = g_strdup ("mainwin-popup"); + + menu_model = (GMenuModel *)gtk_builder_get_object (builder, popup_menu_name); + + if (!menu_model) + menu_model = (GMenuModel *)gtk_builder_get_object (builder, "mainwin-popup"); + + menu = gtk_menu_new_from_model (menu_model); + if (!menu) { LEAVE("no menu"); return; } + gtk_menu_attach_to_widget (GTK_MENU(menu), GTK_WIDGET(page->window), nullptr); gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event); + g_free (popup_menu_name); + LEAVE(" "); } @@ -5208,19 +5582,25 @@ gnc_main_window_button_press_cb (GtkWidget *whatever, void gnc_main_window_all_action_set_sensitive (const gchar *action_name, - gboolean sensitive) + gboolean sensitive) { for (auto tmp = active_windows; tmp; tmp = g_list_next(tmp)) { auto action{gnc_main_window_find_action (static_cast(tmp->data), action_name)}; - gtk_action_set_sensitive (action, sensitive); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive); } } -GtkUIManager *gnc_main_window_get_uimanager (GncMainWindow *window) +GMenuModel * +gnc_main_window_get_menu_model (GncMainWindow *window) { - g_assert(window); - return window->ui_merge; + GncMainWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + return priv->menubar_model; } /** @} */ diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 6116a9c755..34331440f1 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -55,27 +55,32 @@ extern "C" /* typedefs & structures */ +typedef struct +{ + const gchar *actions; + const gchar *update_type; +} GncMenuUpdate; + /** The instance data structure for a main window object. */ typedef struct GncMainWindow { - GtkWindow gtk_window; /**< The parent object for a main window. */ - GtkUIManager *ui_merge; /**< A pointer to the UI Manager data - structure for the whole window. */ - gboolean window_quitting; /**< Set to TRUE when quitting from this window. */ - gboolean just_plugin_prefs; /**< Just remove preferences only from plugins */ + GtkApplicationWindow gtk_application_window; /**< The parent object for a main window. */ + gboolean window_quitting; /**< Set to TRUE when quitting from this window. */ + gboolean just_plugin_prefs; /**< Just remove preferences only from plugins */ } GncMainWindow; /** The class data structure for a main window object. */ typedef struct { - GtkWindowClass gtk_window; /**< The parent class for a - main window. */ + GtkApplicationWindowClass gtk_application_window; /**< The parent class for a main window. */ /* callbacks */ void (*page_added) (GncMainWindow *window, GncPluginPage *page); void (*page_changed) (GncMainWindow *window, GncPluginPage *page); + void (*menu_changed) (GncMainWindow *window, + GncPluginPage *page); //FIXMEb added } GncMainWindowClass; typedef struct @@ -137,12 +142,12 @@ void gnc_main_window_open_page (GncMainWindow *window, void gnc_main_window_close_page (GncPluginPage *page); -/* Iterator function to walk all pages in all windows, calling the - * specified function for each page. +/** Iterator function to walk all pages in all windows, calling the + * specified function for each page. * - * @param entry A pointer to the function to be called. + * @param entry A pointer to the function to be called. * - * @param user_data A data pointer passed to each call of the function. + * @param user_data A data pointer passed to each call of the function. */ void gnc_main_window_foreach_page (GncMainWindowPageFunc fn, gpointer user_data); @@ -164,12 +169,6 @@ void gnc_main_window_foreach_page (GncMainWindowPageFunc fn, */ GncPluginPage *gnc_main_window_get_current_page (GncMainWindow *window); - -/** Returns the pointer to the GtkUIManager which is used for the menu - * item merging. */ -GtkUIManager *gnc_main_window_get_uimanager (GncMainWindow *window); - - /** Update the name of the page in the main window. * * @param page The page to be updated. @@ -179,7 +178,6 @@ void main_window_update_page_name (GncPluginPage *page, const gchar *name_in); - /** Update the color on the page tabs in the main window. * * @param page The page to be updated. @@ -211,16 +209,11 @@ main_window_update_page_set_read_only_icon (GncPluginPage *page, * should be unique among all groups added to the window, and will be * needed to remove the actions from this window. * - * @param group A pointer to an array of GtkActions. These are the - * actions that will be added to the user interface. - * - * @param merge_id A merge identifier retrieved from a call to - * gtk_ui_manager_new_merge_id(). + * @param group A pointer to the GSimpleActionGroup. */ void gnc_main_window_manual_merge_actions (GncMainWindow *window, - const gchar *group_name, - GtkActionGroup *group, - guint merge_id); + const gchar *group_name, + GSimpleActionGroup *group); /** Add a set of actions to the specified window. This function @@ -236,16 +229,11 @@ void gnc_main_window_manual_merge_actions (GncMainWindow *window, * should be unique among all groups added to the window, and will be * needed to remove the actions from this window. * - * @param entries A pointer to an array of GtkActionEntry. These + * @param entries A pointer to an array of GActionEntry. These * are the actions that will be added to the user interface. * * @param n_entries The number of actions in the array. * - * @param toggle_entries A pointer to an array of GtkToggleActionEntry. - * These are the toggle actions that will be added to the user interface. - * - * @param n_toggle_entries The number of toggle actions in the array. - * * @param filename The filename containing the user interface * definition that goes with this set of actions. * @@ -254,11 +242,10 @@ void gnc_main_window_manual_merge_actions (GncMainWindow *window, */ void gnc_main_window_merge_actions (GncMainWindow *window, const gchar *group_name, - GtkActionEntry *entries, + GActionEntry *entries, guint n_entries, - GtkToggleActionEntry *toggle_entries, - guint n_toggle_entries, - const gchar *filename, + const gchar **ui_updates, + const gchar *ui_filename, gpointer user_data); @@ -276,18 +263,99 @@ void gnc_main_window_merge_actions (GncMainWindow *window, void gnc_main_window_unmerge_actions (GncMainWindow *window, const gchar *group_name); - -/** Force a full update of the user interface for the specified - * window. This can be an expensive function, but is needed because - * the gtk ui manager doesn't always seem to update properly when - * actions are changed. +/** Show or hide menu and toolbar items based on a NULL terminated + * list of action names * * @param window A pointer to the window whose user interface should * be updated. * - * @attention Is this function still needed? + * @param action_names A NULL terminated list of actions names that + * should be modified. + * + * @param vis Whether to show or hide the widget items */ -void gnc_main_window_actions_updated (GncMainWindow *window); +void gnc_main_window_set_vis_of_items_by_action (GncMainWindow *window, + const gchar **action_names, + gboolean vis); //FIXMEb added + +/** Find the menu item with the given action name for the window + * specified. + * + * @param window A pointer to the window whose user interface should + * be updated. + * + * @param action_name The action name of the tool item to find. + * + * @return The found menu item widget or NULL. + */ +GtkWidget *gnc_main_window_menu_find_menu_item (GncMainWindow *window, + const gchar *action_name); //FIXMEb added + +/** Find the toolbar item with the given action name for the window + * specified. + * + * @param window A pointer to the window whose user interface should + * be updated. + * + * @param action_name The action name of the tool item to find. + * + * @return The found tool item widget or NULL. + */ +GtkWidget * gnc_main_window_toolbar_find_tool_item (GncMainWindow *window, + const gchar *action_name); //FIXMEb added + +/** Find the GMenuModel item given the action name for the window + * specified. + * + * @param window A pointer to the window whose user interface should + * be updated. + * + * @param action_name The action name of the menu item to find. + * + * @param label The new label for the menu item. + * + * @param tooltip The new tooltip for the menu item, optional. + * + * @return TRUE if menu item found and updated or FALSE. + */ +gboolean gnc_main_window_update_menu_for_action (GncMainWindow *window, + const gchar *action_name, + const gchar *label, + const gchar *tooltip); //FIXMEb added + +/** Scan the main window menu and add accelerator keys to main window + * accelerator group. + * + * @param window A pointer to the window whose user interface should + * be updated. + * + */ +void gnc_main_window_menu_add_accelerator_keys (GncMainWindow *window); //FIXMEb added + +/** A structure for defining alternate action names for use in the + * toolbar. All toolbar buttons are homogeneous in size and are sized + * to fit the longest label. Therefore, this structure should be + * used if an action name is more than one word. This way the menu + * can have the label "Whizzy Feature", while the toolbar button only + * has the label "Whizzy". */ +typedef struct +{ + /** The name of the action. */ + const char *action_name; + /** The alternate toolbar label to use */ + const char *short_label; +} GncToolBarShortNames; //FIXMEb added + + +/** Update the labels of the toolbar items with short names. + * + * @param window The window that conatins a tool bar to update. + * + * @param toolbar_labels A pointer to a NULL terminated array of data + * GncToolBarShortNames items. + */ +void gnc_main_window_init_short_names (GncMainWindow *window, + GncToolBarShortNames *toolbar_labels); //FIXMEb added /** Retrieve a specific set of user interface actions from a window. @@ -299,12 +367,12 @@ void gnc_main_window_actions_updated (GncMainWindow *window); * @param group_name The name of a set of actions. This must be a * name provided when the actions were installed. * - * @return A pointer to a GtkActionGroup that was added with the + * @return A pointer to a GSimpleActionGroup that was added with the * specified name. If the name cannot be found, then NULL will be * returned. */ -GtkActionGroup *gnc_main_window_get_action_group (GncMainWindow *window, - const gchar *group_name); +GSimpleActionGroup *gnc_main_window_get_action_group (GncMainWindow *window, + const gchar *group_name); /** Set the window where all progressbar updates should occur. This @@ -414,17 +482,53 @@ gboolean gnc_main_window_all_finish_pending (void); * this action. */ void gnc_main_window_all_action_set_sensitive (const gchar *action_name, gboolean sensitive); -/** Find action in main window. +/** Find the GAction in the main window. * * @param window The window which should be checked for the action. * - * @param name The name of the command to be retrieved. + * @param action_name The name of the command to be retrieved. * - * @return A pointer to a GtkAction that was added with the + * @return A pointer to a GAction that was added with the * specified name. If the name cannot be found, then NULL will be * returned. */ -GtkAction *gnc_main_window_find_action (GncMainWindow *window, const gchar *name); +GAction *gnc_main_window_find_action (GncMainWindow *window, + const gchar *action_name); + +/** Find the GAction in a specific action group for window. + * + * @param window The window which should be checked for the action. + * + * @param group_name The name of the action group to search. + * + * @param name The name of the command to be retrieved. + * + * @return A pointer to the GAction if found or NULL will be returned. + */ +GAction *gnc_main_window_find_action_in_group (GncMainWindow *window, + const gchar *group_name, + const gchar *action_name); //FIXMEb added + +/** Return the GMenuModel for the main window menu bar. + * + * @param window The window for the menu bar. + * + * @return The GMenuModel or NULL. + */ +GMenuModel *gnc_main_window_get_menu_model (GncMainWindow *window); //FIXMEb added + +/** Update the main window menu with the placeholders listed in + * ui_updates and load the page specific toolbar. + * + * @param window The window which should be checked for the action. + * + * @param page The plugin page calling this function. + * + * @param ui_updates A NULL terminated list of placeholders to load + */ +void gnc_main_window_update_menu_and_toolbar (GncMainWindow *window, + GncPluginPage *page, + const gchar **ui_updates); //FIXMEb added /** * Shows all main windows. diff --git a/gnucash/gnome-utils/gnc-menu-extensions.c b/gnucash/gnome-utils/gnc-menu-extensions.c index eea7b72412..36666feffe 100644 --- a/gnucash/gnome-utils/gnc-menu-extensions.c +++ b/gnucash/gnome-utils/gnc-menu-extensions.c @@ -74,7 +74,7 @@ initialize_getters() static gboolean -gnc_extension_type (SCM extension, GtkUIManagerItemType *type) +gnc_extension_type (SCM extension, GNCMenuItemTypes *type) { char *string; @@ -89,15 +89,15 @@ gnc_extension_type (SCM extension, GtkUIManagerItemType *type) if (g_strcmp0(string, "menu-item") == 0) { - *type = GTK_UI_MANAGER_MENUITEM; + *type = GNC_MENU_ITEM; } else if (g_strcmp0(string, "menu") == 0) { - *type = GTK_UI_MANAGER_MENU; + *type = GNC_SUB_MENU_ITEM; } else if (g_strcmp0(string, "separator") == 0) { - *type = GTK_UI_MANAGER_SEPARATOR; + *type = GNC_SEPARATOR_ITEM; } else { @@ -261,10 +261,10 @@ gnc_create_extension_info (SCM extension) gchar* name; gchar* guid; - ext_info = g_new0(ExtensionInfo, 1); + ext_info = g_new0 (ExtensionInfo, 1); ext_info->extension = extension; - gnc_extension_path(extension, &ext_info->path); - if (!gnc_extension_type( extension, &ext_info->type )) + gnc_extension_path (extension, &ext_info->path); + if (!gnc_extension_type (extension, &ext_info->type)) { /* Can't parse the type passed to us. Bail now. */ g_free(ext_info); @@ -272,29 +272,29 @@ gnc_create_extension_info (SCM extension) } /* Get all the pieces */ - name = gnc_extension_name(extension); - guid = gnc_extension_guid(extension); - ext_info->ae.label = g_strdup(gettext(name)); - ext_info->ae.name = gnc_ext_gen_action_name(guid); - ext_info->ae.tooltip = gnc_extension_documentation(extension); - ext_info->ae.stock_id = NULL; - ext_info->ae.accelerator = NULL; - ext_info->ae.callback = NULL; - g_free(name); - g_free(guid); + name = gnc_extension_name (extension); + guid = gnc_extension_guid (extension); + ext_info->action_label = g_strdup (gettext (name)); + ext_info->action_name = gnc_ext_gen_action_name (guid); + ext_info->action_tooltip = gnc_extension_documentation (extension); + g_free (name); + g_free (guid); - tmp = g_strdup_printf("%s/%s", ext_info->path, ext_info->ae.label); - ext_info->sort_key = g_utf8_collate_key(tmp, -1); + tmp = g_strdup_printf ("%s/%s", ext_info->path, ext_info->action_label); + ext_info->sort_key = g_utf8_collate_key (tmp, -1); g_free(tmp); switch (ext_info->type) { - case GTK_UI_MANAGER_MENU: + case GNC_SUB_MENU_ITEM: typeStr = "menu"; break; - case GTK_UI_MANAGER_MENUITEM: + case GNC_MENU_ITEM: typeStr = "menuitem"; break; + case GNC_SEPARATOR_ITEM: + typeStr = "sepitem"; + break; default: typeStr = "unk"; break; @@ -302,31 +302,31 @@ gnc_create_extension_info (SCM extension) ext_info->typeStr = typeStr; DEBUG( "extension: %s/%s [%s] tip [%s] type %s\n", - ext_info->path, ext_info->ae.label, ext_info->ae.name, - ext_info->ae.tooltip, ext_info->typeStr ); + ext_info->path, ext_info->action_label, ext_info->action_name, + ext_info->action_tooltip, ext_info->typeStr ); - scm_gc_protect_object(extension); + scm_gc_protect_object (extension); /* need to append so we can run them in order */ - extension_list = g_slist_append(extension_list, ext_info); + extension_list = g_slist_append (extension_list, ext_info); return TRUE; } static void -cleanup_extension_info(gpointer extension_info, gpointer not_used) +cleanup_extension_info (gpointer extension_info, gpointer not_used) { ExtensionInfo *ext_info = extension_info; if (ext_info->extension) - scm_gc_unprotect_object(ext_info->extension); + scm_gc_unprotect_object (ext_info->extension); - g_free(ext_info->sort_key); - g_free((gchar *)ext_info->ae.name); - g_free((gchar *)ext_info->ae.label); - g_free((gchar *)ext_info->ae.tooltip); - g_free(ext_info->path); - g_free(ext_info); + g_free (ext_info->sort_key); + g_free ((gchar *)ext_info->action_name); + g_free ((gchar *)ext_info->action_label); + g_free ((gchar *)ext_info->action_tooltip); + g_free (ext_info->path); + g_free (ext_info); } diff --git a/gnucash/gnome-utils/gnc-menu-extensions.h b/gnucash/gnome-utils/gnc-menu-extensions.h index 122e3bd763..060ab1e3f9 100644 --- a/gnucash/gnome-utils/gnc-menu-extensions.h +++ b/gnucash/gnome-utils/gnc-menu-extensions.h @@ -25,21 +25,29 @@ #include +typedef enum +{ + GNC_MENU_ITEM, + GNC_SUB_MENU_ITEM, + GNC_SEPARATOR_ITEM, +} GNCMenuItemTypes; + typedef struct _ExtensionInfo { SCM extension; - GtkActionEntry ae; + gchar *action_label; + gchar *action_name; + gchar *action_tooltip; + gchar *path; gchar *sort_key; const gchar *typeStr; - GtkUIManagerItemType type; + + GNCMenuItemTypes type; gboolean accel_assigned; } ExtensionInfo; - -#define ADDITIONAL_MENUS_PLACEHOLDER "AdditionalMenusPlaceholder" - GSList *gnc_extensions_get_menu_list (void); void gnc_extension_invoke_cb (SCM extension, SCM window); @@ -49,11 +57,11 @@ void gnc_extension_invoke_cb (SCM extension, SCM window); * @param extension A scheme object describing the menu to be * inserted. Functions written in C should use the gnc-plugin code. */ -void gnc_add_scm_extension(SCM extension); +void gnc_add_scm_extension (SCM extension); /** This function releases any memory being held by the 'extensions' * code. It is called from the window shutdown code. */ -void gnc_extensions_shutdown(void); +void gnc_extensions_shutdown (void); #endif diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c index 00664a16d7..39d74631a0 100644 --- a/gnucash/gnome-utils/gnc-plugin-file-history.c +++ b/gnucash/gnome-utils/gnc-plugin-file-history.c @@ -44,6 +44,7 @@ #include "gnc-engine.h" #include "gnc-prefs.h" #include "gnc-uri-utils.h" +#include "gnc-gtk-utils.h" static GObjectClass *parent_class = NULL; @@ -65,12 +66,12 @@ static void gnc_plugin_file_history_remove_from_window (GncPlugin *plugin, GncMa static QofLogModule log_module = GNC_MOD_GUI; /* Command callbacks */ -static void gnc_plugin_file_history_cmd_open_file (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_file_history_cmd_open_file (GSimpleAction *simple, GVariant *parameter, gpointer user_data); /** The label given to the main window for this plugin. */ #define PLUGIN_ACTIONS_NAME "gnc-plugin-file-history-actions" /** The name of the UI description file for this plugin. */ -#define PLUGIN_UI_FILENAME "gnc-plugin-file-history-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-file-history.ui" #define GNOME1_HISTORY "History" #define GNOME1_MAXFILES "MaxFiles" @@ -80,22 +81,28 @@ static void gnc_plugin_file_history_cmd_open_file (GtkAction *action, GncMainWin * will be updated to reflect the users recent choices. This list is * limited to ten actions, although there may be a smaller limit set * by the user. The typical limit is four. */ -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - { "RecentFile0Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile1Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile2Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile3Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile4Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile5Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile6Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile7Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile8Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile9Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, + { "RecentFile0Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile1Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile2Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile3Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile4Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile5Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile6Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile7Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile8Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile9Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, }; /** The number of actions provided by this plugin. */ -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder6", + NULL, +}; /** The instance private data for a file history plugin. This data * structure is unused. */ @@ -407,46 +414,65 @@ gnc_history_update_action (GncMainWindow *window, gint index, const gchar *filename) { - GtkActionGroup *action_group; - GtkAction *action; - gchar *action_name, *label_name, *tooltip, *old_filename; + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + GtkWidget *menu_item = NULL; + gchar *action_name; gint limit; + gboolean add_item = FALSE; + gint pos; ENTER("window %p, index %d, filename %s", window, index, filename ? filename : "(null)"); - /* Get the action group */ - action_group = - gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); - action_name = g_strdup_printf("RecentFile%dAction", index); - action = gtk_action_group_get_action (action_group, action_name); + action_name = g_strdup_printf ("RecentFile%dAction", index); + + gsm->search_action_label = NULL; + gsm->search_action_name = action_name; + + if (!gnc_menubar_model_find_item (gnc_main_window_get_menu_model(window), gsm)) // could not find action_name + { + add_item = TRUE; + gsm->search_action_name = "FilePlaceholder6"; // placeholder + + if (!gnc_menubar_model_find_item (gnc_main_window_get_menu_model(window), gsm)) + { + LEAVE("Could not find 'menu_item' with action name '%s'", action_name); + g_free (gsm); + g_free (action_name); + return; + } + else + pos = gsm->index + index; + } + else + pos = gsm->index; limit = gnc_prefs_get_int (GNC_PREFS_GROUP_HISTORY, GNC_PREF_HISTORY_MAXFILES); if (filename && (strlen(filename) > 0) && (index < limit)) { - /* set the menu label (w/accelerator) */ - label_name = gnc_history_generate_label(index, filename); - tooltip = gnc_history_generate_tooltip(index, filename); - g_object_set(G_OBJECT(action), "label", label_name, - "tooltip", tooltip, - "visible", TRUE, - NULL); - g_free(label_name); - g_free(tooltip); + GMenuItem *item; + gchar *label_name = gnc_history_generate_label (index, filename); + gchar *tooltip = gnc_history_generate_tooltip (index, filename); + gchar *full_action_name = g_strconcat (PLUGIN_ACTIONS_NAME, ".", + action_name, NULL); - /* set the filename for the callback function */ - old_filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING); - if (old_filename) - g_free(old_filename); - g_object_set_data(G_OBJECT(action), FILENAME_STRING, g_strdup(filename)); + item = g_menu_item_new (label_name, full_action_name); + + g_menu_item_set_attribute (item, GNC_MENU_ATTRIBUTE_TOOLTIP, "s", tooltip); + + if (!add_item) + g_menu_remove (G_MENU(gsm->model), pos); + + g_menu_insert_item (G_MENU(gsm->model), pos, item); + + g_free (full_action_name); + g_free (label_name); + g_free (tooltip); } - else - { - gtk_action_set_visible(action, FALSE); - } - g_free(action_name); + g_free (gsm); + g_free (action_name); LEAVE(""); } @@ -466,6 +492,7 @@ gnc_history_update_menus (GncMainWindow *window) guint i; ENTER(""); + for (i = 0; i < MAX_HISTORY_FILES; i++) { pref = gnc_history_index_to_pref_name(i); @@ -518,7 +545,6 @@ gnc_plugin_history_list_changed (gpointer prefs, gnc_history_update_action (window, index, filename); g_free (filename); - gnc_main_window_actions_updated (window); LEAVE(""); } @@ -538,18 +564,18 @@ gnc_plugin_file_history_class_init (GncPluginFileHistoryClass *klass) object_class->finalize = gnc_plugin_file_history_finalize; /* plugin info */ - plugin_class->plugin_name = GNC_PLUGIN_FILE_HISTORY_NAME; + plugin_class->plugin_name = GNC_PLUGIN_FILE_HISTORY_NAME; /* function overrides */ plugin_class->add_to_window = gnc_plugin_file_history_add_to_window; - plugin_class->remove_from_window = - gnc_plugin_file_history_remove_from_window; + plugin_class->remove_from_window = gnc_plugin_file_history_remove_from_window; /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actions = gnc_plugin_actions; plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } G_DEFINE_TYPE_WITH_PRIVATE(GncPluginFileHistory, gnc_plugin_file_history, GNC_TYPE_PLUGIN) @@ -633,8 +659,8 @@ gnc_plugin_file_history_add_to_window (GncPlugin *plugin, */ static void gnc_plugin_file_history_remove_from_window (GncPlugin *plugin, - GncMainWindow *window, - GQuark type) + GncMainWindow *window, + GQuark type) { gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_HISTORY, NULL, gnc_plugin_history_list_changed, window); @@ -657,24 +683,37 @@ gnc_plugin_file_history_remove_from_window (GncPlugin *plugin, * function and we're about to close all the windows anyway. */ static void -gnc_plugin_file_history_cmd_open_file (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_file_history_cmd_open_file (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { - gchar *filename; + GncMainWindowActionData *data = user_data; + gchar *filename, *pref, *index; + const gchar *action_name; - g_return_if_fail(GTK_IS_ACTION(action)); - g_return_if_fail(data != NULL); + g_return_if_fail (G_IS_SIMPLE_ACTION(simple)); + g_return_if_fail (data != NULL); + + // action name will be of the form 'RecentFile1Action' + action_name = g_action_get_name (G_ACTION(simple)); + + index = g_utf8_substring (action_name, 10, 11); + + pref = gnc_history_index_to_pref_name (atoi (index)); + filename = gnc_prefs_get_string (GNC_PREFS_GROUP_HISTORY, pref); + + PINFO("File to open is '%s' on action '%s'", filename, action_name); - /* DRH - Do we need to close all open windows but the first? - * Which progress bar should we be using? One in a window, or - * in a new "file loading" dialog??? - */ - filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING); gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); /* also opens new account page */ gnc_file_open_file (GTK_WINDOW (data->window), filename, /*open_readonly*/ FALSE); gnc_window_set_progressbar_window (NULL); + + g_free (pref); + g_free (filename); + g_free (index); } /** @} */ diff --git a/gnucash/gnome-utils/gnc-plugin-menu-additions.c b/gnucash/gnome-utils/gnc-plugin-menu-additions.c index 7573484482..114a7fc074 100644 --- a/gnucash/gnome-utils/gnc-plugin-menu-additions.c +++ b/gnucash/gnome-utils/gnc-plugin-menu-additions.c @@ -26,7 +26,7 @@ /** @addtogroup MenuPlugins @{ */ -/** @addtogroup PluginMenuAdditions Non-GtkAction Menu Support +/** @addtogroup PluginMenuAdditions Non-GAction Menu Support @{ */ /** @file gnc-plugin-menu-additions.c @brief Functions providing menu items from scheme code. @@ -45,6 +45,7 @@ #include "gnc-window.h" #include "gnc-ui.h" #include "gnc-menu-extensions.h" +#include "gnc-gtk-utils.h" static GObjectClass *parent_class = NULL; @@ -54,6 +55,7 @@ static void gnc_plugin_menu_additions_finalize (GObject *object); static void gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type); static void gnc_plugin_menu_additions_remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type); +static void gnc_plugin_menu_additions_action_new_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); /* Command callbacks */ @@ -65,7 +67,7 @@ static QofLogModule log_module = GNC_MOD_GUI; /** Private data for this plugin. This data structure is unused. */ typedef struct GncPluginMenuAdditionsPrivate { - gpointer dummy; + GHashTable *item_hash; } GncPluginMenuAdditionsPrivate; #define GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(o) \ @@ -80,11 +82,21 @@ typedef struct _GncPluginMenuAdditionsPerWindow window. This plugin must maintain its own data because of the way the menus are currently built. */ GncMainWindow *window; - GtkUIManager *ui_manager; - GtkActionGroup *group; - gint merge_id; + GHashTable *item_hash; + GHashTable *build_menu_hash; + GMenu *report_menu; + GMenu *sub_menu; } GncPluginMenuAdditionsPerWindow; +/** An array of all of the actions provided by the account tree + * plugin. */ +static GActionEntry gnc_plugin_actions [] = +{ + { "AdditionsAction", gnc_plugin_menu_additions_action_new_cb, "s", NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + /************************************************************ * Object Implementation * ************************************************************/ @@ -105,8 +117,11 @@ gnc_plugin_menu_additions_class_init (GncPluginMenuAdditionsClass *klass) plugin_class->plugin_name = GNC_PLUGIN_MENU_ADDITIONS_NAME; /* function overrides */ - plugin_class->add_to_window = gnc_plugin_menu_additions_add_to_window; + plugin_class->add_to_window = gnc_plugin_menu_additions_add_to_window; plugin_class->remove_from_window = gnc_plugin_menu_additions_remove_from_window; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; } static void @@ -119,9 +134,15 @@ gnc_plugin_menu_additions_init (GncPluginMenuAdditions *plugin) static void gnc_plugin_menu_additions_finalize (GObject *object) { - g_return_if_fail (GNC_IS_PLUGIN_MENU_ADDITIONS (object)); + GncPluginMenuAdditionsPrivate *priv; + g_return_if_fail (GNC_IS_PLUGIN_MENU_ADDITIONS(object)); ENTER("plugin %p", object); + + priv = GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(object); + + g_hash_table_destroy (priv->item_hash); + G_OBJECT_CLASS (parent_class)->finalize (object); LEAVE(""); } @@ -161,27 +182,34 @@ gnc_main_window_to_scm (GncMainWindow *window) return SWIG_NewPointerObj(window, main_window_type, 0); } - -/** The user has selected one of the items added by this plugin. - * Invoke the callback function that was registered along with the - * menu item. - * - * @param action A pointer to the action selected by the user. This - * action represents one of the items in the file history menu. - * - * @param data A pointer to the gnc-main-window data to be used by - * this function. This is mainly to find out which window it was - * that had a menu selected. - */ static void -gnc_plugin_menu_additions_action_cb (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_menu_additions_action_new_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + GncPluginMenuAdditionsPrivate *priv; + GncMainWindowActionData *cb_data; + gsize length; + const gchar *action_name; - g_return_if_fail(GTK_IS_ACTION(action)); - g_return_if_fail(data != NULL); + g_return_if_fail (G_IS_SIMPLE_ACTION(simple)); - gnc_extension_invoke_cb(data->data, gnc_main_window_to_scm(data->window)); + ENTER(""); + priv = GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(data->data); + + action_name = g_variant_get_string (parameter, &length); + + PINFO("action name is '%s'", action_name); + + cb_data = g_hash_table_lookup (priv->item_hash, action_name); + + if (cb_data) + { + PINFO("Found action in table"); + gnc_extension_invoke_cb (cb_data->data, gnc_main_window_to_scm (cb_data->window)); + } + LEAVE(""); } @@ -201,9 +229,9 @@ gnc_menu_additions_sort (ExtensionInfo *a, ExtensionInfo *b) { if (a->type == b->type) return strcmp(a->sort_key, b->sort_key); - else if (a->type == GTK_UI_MANAGER_MENU) + else if (a->type == GNC_SUB_MENU_ITEM) return -1; - else if (b->type == GTK_UI_MANAGER_MENU) + else if (b->type == GNC_SUB_MENU_ITEM) return 1; else return 0; @@ -238,23 +266,23 @@ gnc_menu_additions_do_preassigned_accel (ExtensionInfo *info, GHashTable *table) gchar *map, *new_map, *accel_key; const gchar *ptr; - ENTER("Checking %s/%s [%s]", info->path, info->ae.label, info->ae.name); + ENTER("Checking %s/%s [%s]", info->path, info->action_label, info->action_name); if (info->accel_assigned) { LEAVE("Already processed"); return; } - if (!g_utf8_validate(info->ae.label, -1, NULL)) + if (!g_utf8_validate(info->action_label, -1, NULL)) { - g_warning("Extension menu label '%s' is not valid utf8.", info->ae.label); + g_warning ("Extension menu label '%s' is not valid utf8.", info->action_label); info->accel_assigned = TRUE; LEAVE("Label is invalid utf8"); return; } /* Was an accelerator pre-assigned in the source? */ - ptr = g_utf8_strchr(info->ae.label, -1, '_'); + ptr = g_utf8_strchr (info->action_label, -1, '_'); if (ptr == NULL) { LEAVE("not preassigned"); @@ -298,7 +326,7 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table) gint len; gboolean map_allocated = FALSE; - ENTER("Checking %s/%s [%s]", info->path, info->ae.label, info->ae.name); + ENTER("Checking %s/%s [%s]", info->path, info->action_label, info->action_name); if (info->accel_assigned) { LEAVE("Already processed"); @@ -314,7 +342,7 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table) } DEBUG("map '%s', path %s", map, info->path); - for (ptr = info->ae.label; *ptr; ptr = g_utf8_next_char(ptr)) + for (ptr = info->action_label; *ptr; ptr = g_utf8_next_char(ptr)) { uni = g_utf8_get_char(ptr); if (!g_unichar_isalpha(uni)) @@ -340,13 +368,13 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table) } /* Now build a new string in the form "_". */ - start = g_strndup(info->ae.label, ptr - info->ae.label); + start = g_strndup (info->action_label, ptr - info->action_label); DEBUG("start %p, len %ld, text '%s'", start, g_utf8_strlen(start, -1), start); new_label = g_strconcat(start, "_", ptr, (gchar *)NULL); g_free(start); - DEBUG("label '%s' -> '%s'", info->ae.label, new_label); - g_free((gchar *)info->ae.label); - info->ae.label = new_label; + DEBUG("label '%s' -> '%s'", info->action_label, new_label); + g_free((gchar *)info->action_label); + info->action_label = new_label; /* Now build a new map. Old one freed automatically. */ new_map = g_strconcat(map, buf, (gchar *)NULL); @@ -361,6 +389,29 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table) LEAVE("assigned"); } +static GMenuItem * +setup_tooltip_for_gmenu_item (ExtensionInfo *ext_info) +{ + GMenuItem *gmenu_item = NULL; + + if (g_strcmp0 (ext_info->typeStr, "menuitem") == 0) + { + gmenu_item = g_menu_item_new (ext_info->action_label, NULL); + g_menu_item_set_action_and_target_value (gmenu_item, "gnc-plugin-menu-additions-actions.AdditionsAction", + g_variant_new_string (ext_info->action_name)); + + g_menu_item_set_attribute (gmenu_item, GNC_MENU_ATTRIBUTE_TOOLTIP, "s", ext_info->action_tooltip); + } + + if (g_strcmp0 (ext_info->typeStr, "menu") == 0) + { + GMenuModel *sub_menu = G_MENU_MODEL(g_menu_new ()); + + gmenu_item = g_menu_item_new_submenu (ext_info->action_label, sub_menu); + g_object_set_data (G_OBJECT(gmenu_item), "sub-menu", sub_menu); + } + return gmenu_item; +} /** Add one extension item to the UI manager. This function creates a * per-callback data structure for easy access to the opaque Scheme @@ -376,23 +427,45 @@ gnc_menu_additions_menu_setup_one (ExtensionInfo *ext_info, GncPluginMenuAdditionsPerWindow *per_window) { GncMainWindowActionData *cb_data; + GMenuItem *item_path, *item_with_full_path; + gchar *full_path = NULL; + GMenuItem *gmenu_item = NULL; - DEBUG( "Adding %s/%s [%s] as [%s]", ext_info->path, ext_info->ae.label, - ext_info->ae.name, ext_info->typeStr ); + DEBUG("Adding %s/%s [%s] as [%s]", ext_info->path, ext_info->action_label, + ext_info->action_name, ext_info->typeStr ); cb_data = g_new0 (GncMainWindowActionData, 1); cb_data->window = per_window->window; cb_data->data = ext_info->extension; - if (ext_info->type == GTK_UI_MANAGER_MENUITEM) - ext_info->ae.callback = (GCallback)gnc_plugin_menu_additions_action_cb; + g_hash_table_insert (per_window->item_hash, g_strdup (ext_info->action_name), cb_data); - gtk_action_group_add_actions_full(per_window->group, &ext_info->ae, 1, - cb_data, g_free); - gtk_ui_manager_add_ui(per_window->ui_manager, per_window->merge_id, - ext_info->path, ext_info->ae.label, ext_info->ae.name, - ext_info->type, FALSE); - gtk_ui_manager_ensure_update(per_window->ui_manager); + if (g_str_has_suffix (ext_info->path, "_Custom")) + return; + + full_path = g_strconcat (ext_info->path, "/", ext_info->action_label, NULL); + + item_path = g_hash_table_lookup (per_window->build_menu_hash, ext_info->path); + item_with_full_path = g_hash_table_lookup (per_window->build_menu_hash, full_path); + + if (!item_path && !item_with_full_path) + { + gmenu_item = setup_tooltip_for_gmenu_item (ext_info); + + g_menu_append_item (G_MENU(per_window->report_menu), gmenu_item); + } + + if (item_path && !item_with_full_path) + { + GMenuModel *sub_menu = G_MENU_MODEL(g_object_get_data (G_OBJECT(item_path), "sub-menu")); + + gmenu_item = setup_tooltip_for_gmenu_item (ext_info); + + g_menu_append_item (G_MENU(sub_menu), gmenu_item); + } + g_hash_table_insert (per_window->build_menu_hash, g_strdup (full_path), gmenu_item); + + g_free (full_path); } @@ -410,42 +483,57 @@ gnc_menu_additions_menu_setup_one (ExtensionInfo *ext_info, */ static void gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin, - GncMainWindow *window, - GQuark type) + GncMainWindow *window, + GQuark type) { + GncPluginMenuAdditionsPrivate *priv = GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(plugin); GncPluginMenuAdditionsPerWindow per_window; static GOnce accel_table_init = G_ONCE_INIT; static GHashTable *table; GSList *menu_list; + GMenuModel *menubar_model = gnc_main_window_get_menu_model (window); + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); ENTER(" "); per_window.window = window; - per_window.ui_manager = window->ui_merge; - per_window.group = gtk_action_group_new ("MenuAdditions" ); - gtk_action_group_set_translation_domain (per_window.group, PROJECT_NAME); - per_window.merge_id = gtk_ui_manager_new_merge_id(window->ui_merge); - gtk_ui_manager_insert_action_group(window->ui_merge, per_window.group, 0); + per_window.item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - menu_list = g_slist_sort(gnc_extensions_get_menu_list(), - (GCompareFunc)gnc_menu_additions_sort); + per_window.build_menu_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + per_window.report_menu = g_menu_new (); + + menu_list = g_slist_sort (gnc_extensions_get_menu_list(), + (GCompareFunc)gnc_menu_additions_sort); /* Assign accelerators */ - table = g_once(&accel_table_init, gnc_menu_additions_init_accel_table, NULL); - g_slist_foreach(menu_list, + table = g_once (&accel_table_init, gnc_menu_additions_init_accel_table, NULL); + g_slist_foreach (menu_list, (GFunc)gnc_menu_additions_do_preassigned_accel, table); - g_slist_foreach(menu_list, (GFunc)gnc_menu_additions_assign_accel, table); + g_slist_foreach (menu_list, (GFunc)gnc_menu_additions_assign_accel, table); /* Add to window. */ - g_slist_foreach(menu_list, (GFunc)gnc_menu_additions_menu_setup_one, - &per_window); + g_slist_foreach (menu_list, (GFunc)gnc_menu_additions_menu_setup_one, + &per_window); - /* Tell the window code about the actions that were just added - * behind its back (so to speak) */ - gnc_main_window_manual_merge_actions (window, PLUGIN_ACTIONS_NAME, - per_window.group, per_window.merge_id); + priv->item_hash = per_window.item_hash; + + // add the report menu to the window + gsm->search_action_label = NULL; + gsm->search_action_name = "ReportsPlaceholder0"; + + if (gnc_menubar_model_find_item (menubar_model, gsm)) + { + g_menu_insert_section (G_MENU(gsm->model), gsm->index, NULL, G_MENU_MODEL(per_window.report_menu)); + } + else + PERR("Could not find 'ReportsAction' in menu model"); + + g_hash_table_destroy (per_window.build_menu_hash); + + g_slist_free (menu_list); + + g_free (gsm); - g_slist_free(menu_list); LEAVE(" "); } @@ -463,23 +551,19 @@ gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin, */ static void gnc_plugin_menu_additions_remove_from_window (GncPlugin *plugin, - GncMainWindow *window, - GQuark type) + GncMainWindow *window, + GQuark type) { - GtkActionGroup *group; + GSimpleActionGroup *simple_action_group; ENTER(" "); /* Have to remove our actions manually. Its only automatic if the * actions name is installed into the plugin class. */ - group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); + simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); - if (group && !window->just_plugin_prefs) - gtk_ui_manager_remove_action_group(window->ui_merge, group); - - /* Note: This code does not clean up the per-callback data structures - * that are created by the gnc_menu_additions_menu_setup_one() - * function. Its not much memory and shouldn't be a problem. */ + if (simple_action_group && !window->just_plugin_prefs) + gtk_widget_insert_action_group (GTK_WIDGET(window), PLUGIN_ACTIONS_NAME, NULL); LEAVE(" "); } diff --git a/gnucash/gnome-utils/gnc-plugin-menu-additions.h b/gnucash/gnome-utils/gnc-plugin-menu-additions.h index 43be7c916d..5ba45ceb5f 100644 --- a/gnucash/gnome-utils/gnc-plugin-menu-additions.h +++ b/gnucash/gnome-utils/gnc-plugin-menu-additions.h @@ -22,7 +22,7 @@ /** @addtogroup MenuPlugins @{ */ -/** @addtogroup PluginMenuAdditions Non-GtkAction Menu Support +/** @addtogroup PluginMenuAdditions Non-GAction Menu Support @{ */ /** @file gnc-plugin-menu-additions.h @brief Functions providing menu items from scheme code. diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index dec6e88f0c..ee570f4b11 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -75,13 +75,10 @@ enum PROP_0, PROP_PAGE_NAME, PROP_PAGE_COLOR, - PROP_PAGE_URI, PROP_BOOK, PROP_STATUSBAR_TEXT, PROP_USE_NEW_WINDOW, PROP_UI_DESCRIPTION, - PROP_UI_MERGE, - PROP_ACTION_GROUP, }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -91,11 +88,13 @@ static guint signals[LAST_SIGNAL] = { 0 }; typedef struct _GncPluginPagePrivate { /** The group of all actions provided by this plugin. */ - GtkActionGroup *action_group; - GtkUIManager *ui_merge; - guint merge_id; char *ui_description; + GtkBuilder *builder; //FIXMEb added + GSimpleActionGroup *simple_action_group; //FIXMEb added + const gchar *simple_action_group_name; //FIXMEb added + const gchar *menu_qualifier; //FIXMEb added + GList *books; gboolean use_new_window; @@ -252,47 +251,36 @@ gnc_plugin_page_recreate_page(GtkWidget *window, } -/* Add the actions for a content page to the specified window. */ void -gnc_plugin_page_merge_actions (GncPluginPage *page, - GtkUIManager *ui_merge) +gnc_plugin_page_merge_actions (GncPluginPage *page) { GncPluginPagePrivate *priv; + GError *error = NULL; + gchar *resource; g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - priv->ui_merge = ui_merge; - gtk_action_group_set_sensitive (priv->action_group, TRUE); - priv->merge_id = gnc_plugin_add_actions (priv->ui_merge, - priv->action_group, - priv->ui_description); + + if (!priv->builder) + priv->builder = gtk_builder_new (); + + resource = g_strconcat ("/org/gnucash/ui/", priv->ui_description, NULL); + + gtk_builder_set_translation_domain (priv->builder, PROJECT_NAME); + + gtk_builder_add_from_resource (priv->builder, resource, &error); + + if (error) + { + g_critical ("Failed to load ui resource %s, Error %s", resource, error->message); + g_error_free (error); + } + g_free (resource); } -/* Remove the actions for a content page from the specified window. */ -void -gnc_plugin_page_unmerge_actions (GncPluginPage *page, - GtkUIManager *ui_merge) -{ - GncPluginPagePrivate *priv; - - priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - - g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); - g_return_if_fail (priv->merge_id != 0); - g_return_if_fail (priv->action_group != NULL); - - gtk_ui_manager_remove_ui (ui_merge, priv->merge_id); - gtk_action_group_set_sensitive (priv->action_group, FALSE); - gtk_ui_manager_remove_action_group (ui_merge, priv->action_group); - - priv->ui_merge = NULL; - priv->merge_id = 0; -} - - -GtkAction * +GAction * gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name) { GncPluginPagePrivate *priv; @@ -301,9 +289,9 @@ gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name) g_return_val_if_fail (name != NULL, NULL); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - if (!priv->action_group) + if (!priv->simple_action_group) return NULL; - return gtk_action_group_get_action (priv->action_group, name); + return g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), name); } @@ -399,15 +387,6 @@ gnc_plugin_page_class_init (GncPluginPageClass *klass) NULL, G_PARAM_READWRITE)); - g_object_class_install_property - (gobject_class, - PROP_PAGE_URI, - g_param_spec_string ("page-uri", - "Page URI", - "The uri for this page.", - NULL, - G_PARAM_READWRITE)); - g_object_class_install_property (gobject_class, PROP_STATUSBAR_TEXT, @@ -439,28 +418,6 @@ gnc_plugin_page_class_init (GncPluginPageClass *klass) NULL, G_PARAM_READWRITE)); - g_object_class_install_property - (gobject_class, - PROP_UI_MERGE, - g_param_spec_object ("ui-merge", - "UI Merge", - "A pointer to the GtkUIManager object that " - "represents this pages menu hierarchy.", - GTK_TYPE_UI_MANAGER, - G_PARAM_READABLE)); - - g_object_class_install_property - (gobject_class, - PROP_ACTION_GROUP, - g_param_spec_object ("action-group", - "Action Group", - "A pointer to the GtkActionGroup object that " - "represents this pages available menu/toolbar " - "actions.", - GTK_TYPE_ACTION_GROUP, - G_PARAM_READABLE)); - - signals[INSERTED] = g_signal_new ("inserted", @@ -516,9 +473,9 @@ gnc_plugin_page_init (GncPluginPage *page, void *data) priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); priv->page_name = NULL; priv->page_color = NULL; - priv->uri = NULL; priv->page_changed_id = 0; priv->focus_source_id = 0; + priv->menu_qualifier = NULL; page->window = NULL; page->summarybar = NULL; @@ -557,9 +514,6 @@ gnc_plugin_page_finalize (GObject *object) if (priv->page_color) g_free (priv->page_color); - if (priv->uri) - g_free (priv->uri); - if (priv->statusbar_text) g_free (priv->statusbar_text); @@ -623,9 +577,6 @@ gnc_plugin_page_get_property (GObject *object, case PROP_PAGE_COLOR: g_value_set_string (value, priv->page_color); break; - case PROP_PAGE_URI: - g_value_set_string (value, priv->uri); - break; case PROP_STATUSBAR_TEXT: g_value_set_string (value, priv->statusbar_text); break; @@ -635,12 +586,6 @@ gnc_plugin_page_get_property (GObject *object, case PROP_UI_DESCRIPTION: g_value_set_string (value, priv->ui_description); break; - case PROP_UI_MERGE: - g_value_take_object (value, priv->ui_merge); - break; - case PROP_ACTION_GROUP: - g_value_take_object (value, priv->action_group); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -684,9 +629,6 @@ gnc_plugin_page_set_property (GObject *object, case PROP_PAGE_COLOR: gnc_plugin_page_set_page_color (page, g_value_get_string (value)); break; - case PROP_PAGE_URI: - gnc_plugin_page_set_uri (page, g_value_get_string (value)); - break; case PROP_STATUSBAR_TEXT: gnc_plugin_page_set_statusbar_text (page, g_value_get_string (value)); break; @@ -971,35 +913,6 @@ gnc_plugin_page_disconnect_page_changed (GncPluginPage *page) } -/* Retrieve the Uniform Resource Identifier for this page. */ -const gchar * -gnc_plugin_page_get_uri (GncPluginPage *page) -{ - GncPluginPagePrivate *priv; - - g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); - - priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - return priv->uri; -} - - -/* Set the Uniform Resource Identifier for this page. */ -void -gnc_plugin_page_set_uri (GncPluginPage *page, const gchar *name) -{ - GncPluginPagePrivate *priv; - - g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); - - priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - if (priv->uri) - g_free (priv->uri); - - priv->uri = g_strdup (name); -} - - /* Retrieve the statusbar text associated with this page. */ const gchar * gnc_plugin_page_get_statusbar_text (GncPluginPage *page) @@ -1089,44 +1002,77 @@ gnc_plugin_page_set_ui_description (GncPluginPage *page, } -/* Retrieve the GtkUIManager object associated with this page. */ -GtkUIManager * -gnc_plugin_page_get_ui_merge (GncPluginPage *page) +/* Retrieve the GtkBuilder object associated with this page. */ +GtkBuilder * +gnc_plugin_page_get_builder (GncPluginPage *page) { GncPluginPagePrivate *priv; g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - return priv->ui_merge; + return priv->builder; } -/* Retrieve the GtkActionGroup object associated with this page. */ -GtkActionGroup * -gnc_plugin_page_get_action_group(GncPluginPage *page) +/* Retrieve the menu qualifier associated with this page. */ +const gchar * +gnc_plugin_page_get_menu_qualifier (GncPluginPage *page) { GncPluginPagePrivate *priv; g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - return priv->action_group; + return priv->menu_qualifier; } -/* Create the GtkActionGroup object associated with this page. */ -GtkActionGroup * +void +gnc_plugin_page_set_menu_qualifier (GncPluginPage *page, + const char *menu_qualifier) +{ + GncPluginPagePrivate *priv; + + g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); + + priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + + priv->menu_qualifier = menu_qualifier; +} + +GSimpleActionGroup * +gnc_plugin_page_get_action_group (GncPluginPage *page) +{ + GncPluginPagePrivate *priv; + + g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); + + priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + return priv->simple_action_group; +} + +GSimpleActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_name) +{ + GncPluginPagePrivate *priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + + priv->simple_action_group = g_simple_action_group_new (); + priv->simple_action_group_name = group_name; + + return priv->simple_action_group; +} + +const gchar * +gnc_plugin_page_get_simple_action_group_name (GncPluginPage *page) { GncPluginPagePrivate *priv; - GtkActionGroup *group; + + g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - group = gtk_action_group_new (group_name); - gtk_action_group_set_translation_domain (group, PROJECT_NAME); - priv->action_group = group; - return group; + + return priv->simple_action_group_name; } gboolean diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index 9d0b7e560c..757d2b23e9 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -284,24 +284,8 @@ GncPluginPage *gnc_plugin_page_recreate_page (GtkWidget *window, * * @param plugin_page A pointer to the page whose actions should be * added to the user interface. - * - * @param merge A pointer to the UI manager data structure for a - * window. */ -void gnc_plugin_page_merge_actions (GncPluginPage *plugin_page, - GtkUIManager *merge); - - -/** Remove the actions for a content page from the specified window. - * - * @param plugin_page A pointer to the page whose actions should be - * removed from the user interface. - * - * @param merge A pointer to the UI manager data structure for a - * window. - */ -void gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page, - GtkUIManager *merge); +void gnc_plugin_page_merge_actions (GncPluginPage *plugin_page); //FIXMEb added /** Retrieve the textual name of a plugin. @@ -440,25 +424,6 @@ void gnc_plugin_page_inserted_cb (GncPluginPage *page, gpointer user_data); void gnc_plugin_page_disconnect_page_changed (GncPluginPage *page); -/** Retrieve the Uniform Resource Identifier for this page. - * - * @param page The page whose URI should be retrieved. - * - * @return The URI for this page. This string is owned by the page and - * should not be freed by the caller. - */ -const gchar *gnc_plugin_page_get_uri (GncPluginPage *page); - - -/** Set the Uniform Resource Identifier for this page. - * - * @param page The page whose URI should be set. - * - * @param name The new URI for the page. - */ -void gnc_plugin_page_set_uri (GncPluginPage *page, const char *name); - - /** Retrieve the statusbar text associated with this page. * * @param page The page whose statusbar should text be retrieved. @@ -522,28 +487,45 @@ const char *gnc_plugin_page_get_ui_description (GncPluginPage *page); * @param ui_filename The filename (no path) of the alternate UI. */ void gnc_plugin_page_set_ui_description (GncPluginPage *page, - const char *ui_filename); + const char *ui_filename); -/** Retrieve the GtkUIManager object associated with this page. +/** Retrieve the GtkBuilder object associated with this page. * * @param page The page whose UI information should be retrieved. * - * @return A pointer to the GtkUIManager object for this page. */ -GtkUIManager *gnc_plugin_page_get_ui_merge (GncPluginPage *page); + * @return A pointer to the GtkBuilder object for this page. */ +GtkBuilder *gnc_plugin_page_get_builder (GncPluginPage *page); //FIXMEb added -/** Retrieve the GtkActionGroup object associated with this page. +/** Retrieve the menu qualifier for this page. + * + * @param page The page whose quailifier string should be retrieved. + * + * @return A qualifier string for this page. + */ +const gchar * gnc_plugin_page_get_menu_qualifier (GncPluginPage *page); //FIXMEb added + +/** Set a qualifier string for this page. This string is used when there + * is more than one menu associated with the page. + * + * @param page The page whose qualifier string should be updated. + * + * @param menu_qualifier A string to be used as for the qualifier. + */ +void gnc_plugin_page_set_menu_qualifier (GncPluginPage *page, + const char *menu_qualifier); //FIXMEb added + +/** Retrieve the GSimpleActionGroup object associated with this page. * * @param page The page whose menu/toolbar action group should be * retrieved. * - * @return A pointer to the GtkActionGroup object for this page. + * @return A pointer to the GSimpleActionGroup object for this page. */ -GtkActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page); +GSimpleActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page); //FIXMEb added - -/** Create the GtkActionGroup object associated with this page. +/** Create the GSimpleActionGroup object associated with this page. * * @param page The page whose menu/toolbar action group should be * created. @@ -552,22 +534,33 @@ GtkActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page); * name is used to associate key bindings with actions, so it should * be consistent across all pages of the same type. * - * @return A pointer to the newly created GtkActionGroup object for + * @return A pointer to the newly created GSimpleActionGroup object for * this page. */ -GtkActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page, - const gchar *group_name); +GSimpleActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page, + const gchar *group_name); //FIXMEb added -/** Retrieve a GtkAction object associated with this page. +/** Retrieve the simple action group name associated with this plugin + * page. + * + * @param page The page whose simple action group should be retrieved. + * + * @return The simple action group name associated with this plugin. + */ +const gchar *gnc_plugin_page_get_simple_action_group_name (GncPluginPage *page); //FIXMEb added + + +/** Retrieve a GAction object associated with this page. * * @param page The page whose menu/toolbar action group should be * retrieved. * - * @param name The name of the GtkAction to find. + * @param action_name The name of the GAction to find. * - * @return A pointer to the retuested GtkAction object or NULL. + * @return A pointer to the requested GAction object or NULL. */ -GtkAction *gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name); +GAction *gnc_plugin_page_get_action (GncPluginPage *page, + const gchar *action_name); /* Signals */ void gnc_plugin_page_inserted (GncPluginPage *plugin_page); diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index 73c487fbc0..0f8a742284 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -42,6 +42,7 @@ #include "gnc-filepath-utils.h" #include "gnc-gnome-utils.h" #include "gnc-gobject-utils.h" +#include "gnc-gtk-utils.h" /** The debugging module that this .o belongs to. */ static QofLogModule log_module = GNC_MOD_GUI; @@ -130,7 +131,6 @@ gnc_plugin_add_to_window (GncPlugin *plugin, GQuark type) { GncPluginClass *klass; - GtkActionGroup *action_group; g_return_if_fail (GNC_IS_PLUGIN (plugin)); klass = GNC_PLUGIN_GET_CLASS (plugin); @@ -143,20 +143,11 @@ gnc_plugin_add_to_window (GncPlugin *plugin, if (klass->actions_name) { DEBUG ("%s: %d actions to merge with gui from %s", - klass->actions_name, (klass->n_actions + klass->n_toggle_actions), klass->ui_filename); + klass->actions_name, klass->n_actions, klass->ui_filename); gnc_main_window_merge_actions (window, klass->actions_name, klass->actions, klass->n_actions, - klass->toggle_actions, klass->n_toggle_actions, + klass->ui_updates, klass->ui_filename, plugin); - - - if (klass->important_actions) - { - action_group = - gnc_main_window_get_action_group(window, klass->actions_name); - gnc_plugin_set_important_actions(action_group, - klass->important_actions); - } } /* @@ -204,7 +195,7 @@ gnc_plugin_remove_from_window (GncPlugin *plugin, if (klass->actions_name && !window->just_plugin_prefs) { DEBUG ("%s: %d actions to unmerge", - klass->actions_name, (klass->n_actions + klass->n_toggle_actions)); + klass->actions_name, (klass->n_actions)); gnc_main_window_unmerge_actions (window, klass->actions_name); } LEAVE (""); @@ -231,155 +222,84 @@ gnc_plugin_get_name (GncPlugin *plugin) * * See gnc-plugin.h for documentation on the function arguments. */ void -gnc_plugin_init_short_names (GtkActionGroup *action_group, - action_toolbar_labels *toolbar_labels) +gnc_plugin_init_short_names (GtkWidget *toolbar, + GncToolBarShortNames *toolbar_labels) { - GtkAction *action; - gint i; + g_return_if_fail (toolbar != NULL); + g_return_if_fail (toolbar_labels != NULL); - for (i = 0; toolbar_labels[i].action_name; i++) + for (gint i = 0; (toolbar_labels[i].action_name); i++) { - /* Add a couple of short labels for the toolbar */ - action = gtk_action_group_get_action (action_group, - toolbar_labels[i].action_name); - gtk_action_set_short_label (action, _(toolbar_labels[i].label)); + GtkWidget *tool_item = gnc_find_toolbar_item (toolbar, toolbar_labels[i].action_name); + + if (!tool_item) + continue; + + gtk_tool_button_set_label (GTK_TOOL_BUTTON(tool_item), _(toolbar_labels[i].short_label)); + gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON(tool_item), TRUE); } } -/** Mark certain actions as "important". This means that their labels - * will appear when the toolbar is set to "Icons and important text" - * (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. - * - * See gnc-plugin.h for documentation on the function arguments. */ +/* Update the sensitivity of an action */ void -gnc_plugin_set_important_actions (GtkActionGroup *action_group, - const gchar **name) +gnc_plugin_set_actions_enabled (GActionMap *action_map, + const gchar **action_names, gboolean enable) { - GtkAction *action; - gint i; + g_return_if_fail (action_map != NULL); - for (i = 0; name[i]; i++) + for (gint i = 0; action_names[i]; i++) { - action = gtk_action_group_get_action (action_group, name[i]); - g_object_set (G_OBJECT(action), "is_important", TRUE, NULL); - } - - /* If this trips, you've got too many "important" actions. That - * can't *all* be that important, can they? */ - g_assert(i <= 3); -} - - -/* Update a property of existing UI actions. This function can - * modify actions making them visible, invisible, sensitive, or - * insensitive. - * - * See gnc-plugin.h for documentation on the function arguments. */ -void -gnc_plugin_update_actions (GtkActionGroup *action_group, - const gchar **action_names, - const gchar *property_name, - gboolean value) -{ - GtkAction *action; - gint i; - - for (i = 0; action_names[i]; i++) - { - action = gtk_action_group_get_action (action_group, action_names[i]); + GAction *action = g_action_map_lookup_action (G_ACTION_MAP(action_map), + action_names[i]); if (action) - { - g_object_set (G_OBJECT(action), property_name, value, NULL); - } + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), enable); else - { - g_warning("No such action with name '%s' in action group %s (size %d)", - action_names[i], gtk_action_group_get_name(action_group), - g_list_length(gtk_action_group_list_actions(action_group))); - } + PERR("No such action with name '%s' in action group %p)", + action_names[i], action_map); } } - -/** Load a new set of actions into an existing UI. - * - * See gnc-plugin.h for documentation on the function arguments. */ -gint -gnc_plugin_add_actions (GtkUIManager *ui_merge, - GtkActionGroup *action_group, - const gchar *filename) +void +gnc_plugin_add_menu_tooltip_callbacks (GtkWidget *menubar, + GMenuModel *menubar_model, + GtkWidget *statusbar) { - GError *error = NULL; - gchar *pathname; - gint merge_id; + GList *menu_item_list; - g_return_val_if_fail (ui_merge, 0); - g_return_val_if_fail (action_group, 0); - g_return_val_if_fail (filename, 0); + g_return_if_fail (GTK_IS_MENU_BAR(menubar)); + g_return_if_fail (G_IS_MENU_MODEL(menubar_model)); + g_return_if_fail (GTK_IS_STATUSBAR(statusbar)); - ENTER("ui_merge %p, action_group %p, filename %s", - ui_merge, action_group, filename); - gtk_ui_manager_insert_action_group (ui_merge, action_group, 0); + menu_item_list = gnc_menu_get_items (menubar); - pathname = gnc_filepath_locate_ui_file (filename); - if (pathname == NULL) + for (GList *node = menu_item_list; node; node = node->next) { - LEAVE("fail"); - return 0; - } + GtkWidget *menu_item = node->data; - merge_id = gtk_ui_manager_add_ui_from_file (ui_merge, pathname, &error); - DEBUG("merge_id is %d", merge_id); - - g_assert(merge_id || error); - if (merge_id) - { - gtk_ui_manager_ensure_update (ui_merge); + gnc_menu_item_setup_tooltip_to_statusbar_callback (menu_item, statusbar); } - else - { - g_critical("Failed to load ui file.\n Filename %s\n Error %s", - filename, error->message); - g_error_free(error); - } - - g_free(pathname); - LEAVE(" "); - return merge_id; + g_object_set_data (G_OBJECT(statusbar), "menu-model", menubar_model); + g_list_free (menu_item_list); } -#if 0 static void -gnc_plugin_base_init (gpointer klass) +for_each_tool_action (GtkWidget *widget, gpointer user_data) { - static gboolean initialized = FALSE; + GtkWidget *statusbar = user_data; - if (!initialized) - { - initialized = TRUE; - - signals[MERGE_ACTIONS] = g_signal_new ("merge-actions", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GncPluginClass, merge_actions), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - GTK_TYPE_MENU_MERGE); - signals[UNMERGE_ACTIONS] = g_signal_new ("unmerge-actions", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GncPluginClass, unmerge_actions), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - GTK_TYPE_MENU_MERGE); - } + if (GTK_IS_ACTIONABLE(widget)) + gnc_tool_item_setup_tooltip_to_statusbar_callback (widget, statusbar); +} + +void +gnc_plugin_add_toolbar_tooltip_callbacks (GtkWidget *toolbar, GtkWidget *statusbar) +{ + g_return_if_fail (GTK_IS_TOOLBAR(toolbar)); + g_return_if_fail (GTK_IS_STATUSBAR(statusbar)); + + gtk_container_foreach (GTK_CONTAINER(toolbar), for_each_tool_action, statusbar); } -#endif /** @} */ /** @} */ diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index 100afd6933..faa7585d0d 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -119,19 +119,13 @@ typedef struct const gchar *actions_name; /** An array of actions that should automatically be added to * any GnuCash "main" content window that is opened. */ - GtkActionEntry *actions; + GActionEntry *actions; //FIXMEb added /** The number of actions in the actions array. */ - guint n_actions; - /** An array of toggle actions that should automatically be added to - * any GnuCash "main" content window that is opened. */ - GtkToggleActionEntry *toggle_actions; - /** The number of toggle actions in the toggle actions array. */ - guint n_toggle_actions; - /** A NULL terminated list of actions that should be considered - * important. In the toolbar, these actions will display the - * action name when the toolbar is in "text beside icons" - * mode. */ - const gchar **important_actions; + guint n_actions; //FIXMEb added + + /** An array of ui updates for the menu model */ + const gchar **ui_updates; //FIXMEb added + /** The relative name of the XML file describing the * menu/toolbar action items. */ const gchar *ui_filename; @@ -231,6 +225,8 @@ typedef struct const char *action_name; /** The alternate toolbar label to use */ const char *label; + /** The tooltip for the label */ + const char *tooltip; } action_toolbar_labels; @@ -247,69 +243,50 @@ typedef struct * group. * * @param toolbar_labels A pointer to a NULL terminated array of data - * action_toolbar_labels items. + * GncToolBarShortNames items. */ -void gnc_plugin_init_short_names (GtkActionGroup *action_group, - action_toolbar_labels *toolbar_labels); +void gnc_plugin_init_short_names (GtkWidget *toolbar, + GncToolBarShortNames *toolbar_labels); -/** Mark certain actions as "important". This means that their labels - * will appear when the toolbar is set to "Icons and important text" - * (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. - * - * @param action_group The group of all actions associated with a - * plugin or plugin page. All actions to me modified must be in this +/** This function sets the sensitivity of a GAction in a specific * group. * - * @param name A list of actions names to be marked important. This - * list must be NULL terminated. - */ -void gnc_plugin_set_important_actions (GtkActionGroup *action_group, - const gchar **names); - - -/** Update a property on a set of existing GtkActions. This function - * can be easily used to make a list of actions visible, invisible, - * sensitive, or insensitive. - * - * @param action_group The group of all actions associated with a - * plugin or plugin page. All actions to be modified must be - * contained in this group. + * @param action_map The action map associated with the window. * * @param action_names A NULL terminated list of actions names that * should be modified. * - * @param property_name The property name to be changed on the - * specified actions. The only two GtkAction properties that it makes - * sense to modify are "visible" and "sensitive". - * - * @param value A boolean specifying the new state for the specified + * @param enable A boolean specifying the new state for the specified * property. */ -void gnc_plugin_update_actions (GtkActionGroup *action_group, - const gchar **action_names, - const gchar *property_name, - gboolean value); +void gnc_plugin_set_actions_enabled (GActionMap *action_map, + const gchar **action_names, + gboolean enable); //FIXMEb added - -/** Load a new set of actions into an existing UI. The actions from - * the provided group will be merged into the pre-existing ui, as - * directed by the specified file. +/** This function adds the tooltip callbacks to make the tooltips + * appear in the status bar. * - * @param ui_merge A pointer to the UI manager data structure for a - * window. + * @param menubar The main window menu bar widget. * - * @param action_group The set of actions provided by a given plugin. + * @param menubar_model The GMenuModel used to create the menubar. * - * @param filename The name of the ui description file. This file - * name will be searched for in the ui directory. - * - * @return The merge_id number for the newly merged UI. If an error - * occurred, the return value is 0. + * @param statusbar The status bar widget in the main window. */ -gint gnc_plugin_add_actions (GtkUIManager *ui_merge, - GtkActionGroup *action_group, - const gchar *filename); +void gnc_plugin_add_menu_tooltip_callbacks (GtkWidget *menubar, + GMenuModel *menubar_model, + GtkWidget *statusbar); //FIXMEb added + +/** This function adds the tooltip callbacks to make the tooltips + * appear in the status bar. + * + * @param toolbar The main window tool bar widget. + * + * @param statusbar The status bar widget in the main window. + */ +void gnc_plugin_add_toolbar_tooltip_callbacks (GtkWidget *toolbar, + GtkWidget *statusbar); //FIXMEb added + G_END_DECLS #endif /* __GNC_PLUGIN_H */ diff --git a/gnucash/gnome-utils/gnc-window.c b/gnucash/gnome-utils/gnc-window.c index fecacd4f92..88117856bc 100644 --- a/gnucash/gnome-utils/gnc-window.c +++ b/gnucash/gnome-utils/gnc-window.c @@ -78,7 +78,7 @@ gnc_window_get_gtk_window (GncWindow *window) return GNC_WINDOW_GET_IFACE (window)->get_gtk_window (window); } -static GtkWidget * +GtkWidget * gnc_window_get_statusbar (GncWindow *window) { g_return_val_if_fail(GNC_WINDOW (window), NULL); @@ -101,6 +101,42 @@ gnc_window_get_progressbar (GncWindow *window) return GNC_WINDOW_GET_IFACE (window)->get_progressbar (window); } +GtkWidget * +gnc_window_get_menubar (GncWindow *window) +{ + g_return_val_if_fail (GNC_WINDOW(window), NULL); + + /* optional */ + if (GNC_WINDOW_GET_IFACE(window)->get_menubar == NULL) + return NULL; + + return GNC_WINDOW_GET_IFACE(window)->get_menubar (window); +} + +GtkWidget * +gnc_window_get_toolbar (GncWindow *window) +{ + g_return_val_if_fail (GNC_WINDOW(window), NULL); + + /* optional */ + if (GNC_WINDOW_GET_IFACE(window)->get_toolbar == NULL) + return NULL; + + return GNC_WINDOW_GET_IFACE(window)->get_toolbar (window); +} + +GMenuModel * +gnc_window_get_menubar_model (GncWindow *window) +{ + g_return_val_if_fail (GNC_WINDOW(window), NULL); + + /* optional */ + if (GNC_WINDOW_GET_IFACE(window)->get_menubar_model == NULL) + return NULL; + + return GNC_WINDOW_GET_IFACE(window)->get_menubar_model (window); +} + /************************************************************ * Auxiliary status bar functions * ************************************************************/ @@ -219,93 +255,3 @@ gnc_window_show_progress (const char *message, double percentage) while (gtk_events_pending ()) gtk_main_iteration (); } - - -/* CS: This callback functions will set the statusbar text to the - * "tooltip" property of the currently selected GtkAction. - * - * This code is directly copied from gtk+/test/testmerge.c. - * Thanks to (L)GPL! */ -typedef struct _ActionStatus ActionStatus; -struct _ActionStatus -{ - GtkAction *action; - GtkWidget *statusbar; -}; - -static void -action_status_destroy (gpointer data) -{ - ActionStatus *action_status = data; - - g_object_unref (action_status->action); - g_object_unref (action_status->statusbar); - - g_free (action_status); -} - -static void -set_tip (GtkWidget *widget) -{ - ActionStatus *data; - gchar *tooltip; - - data = g_object_get_data (G_OBJECT (widget), "action-status"); - - if (data) - { - g_object_get (data->action, "tooltip", &tooltip, NULL); - - gtk_statusbar_push (GTK_STATUSBAR (data->statusbar), 0, - tooltip ? tooltip : " "); - - g_free (tooltip); - } -} - -static void -unset_tip (GtkWidget *widget) -{ - ActionStatus *data; - - data = g_object_get_data (G_OBJECT (widget), "action-status"); - - if (data) - gtk_statusbar_pop (GTK_STATUSBAR (data->statusbar), 0); -} - -void -gnc_window_connect_proxy (GtkUIManager *merge, - GtkAction *action, - GtkWidget *proxy, - GtkWidget *statusbar) -{ - if (GTK_IS_MENU_ITEM (proxy)) - { - ActionStatus *data; - - data = g_object_get_data (G_OBJECT (proxy), "action-status"); - if (data) - { - g_object_unref (data->action); - g_object_unref (data->statusbar); - - data->action = g_object_ref (action); - data->statusbar = g_object_ref (statusbar); - } - else - { - data = g_new0 (ActionStatus, 1); - - data->action = g_object_ref (action); - data->statusbar = g_object_ref (statusbar); - - g_object_set_data_full (G_OBJECT (proxy), "action-status", - data, action_status_destroy); - - g_signal_connect (proxy, "select", G_CALLBACK (set_tip), NULL); - g_signal_connect (proxy, "deselect", G_CALLBACK (unset_tip), NULL); - } - } -} -/* CS: end copied code from gtk+/test/testmerge.c */ diff --git a/gnucash/gnome-utils/gnc-window.h b/gnucash/gnome-utils/gnc-window.h index c8144dc16d..6b06f3050c 100644 --- a/gnucash/gnome-utils/gnc-window.h +++ b/gnucash/gnome-utils/gnc-window.h @@ -60,9 +60,12 @@ typedef struct GTypeInterface parent; /* Virtual Table */ - GtkWindow * (* get_gtk_window) (GncWindow *window); - GtkWidget * (* get_statusbar) (GncWindow *window); - GtkWidget * (* get_progressbar) (GncWindow *window); + GtkWindow * (* get_gtk_window) (GncWindow *window); + GtkWidget * (* get_statusbar) (GncWindow *window); + GtkWidget * (* get_progressbar) (GncWindow *window); + GtkWidget * (* get_menubar) (GncWindow *window); + GtkWidget * (* get_toolbar) (GncWindow *window); + GMenuModel * (* get_menubar_model) (GncWindow *window); void (* ui_set_sensitive) (GncWindow *window, gboolean sensitive); } GncWindowIface; @@ -78,22 +81,10 @@ void gnc_window_set_progressbar_window (GncWindow *window); GncWindow *gnc_window_get_progressbar_window (void); GtkWidget *gnc_window_get_progressbar (GncWindow *window); void gnc_window_show_progress (const char *message, double percentage); - -/** This callback functions will set the statusbar text to the - * "tooltip" property of the currently selected GtkAction - * - * @param merge A pointer to the ui manager - * - * @param action A pointer to the action - * - * @param proxy A pointer to the proxy - * - * @param statusbar A pointer to the statusbar widget - */ -void gnc_window_connect_proxy (GtkUIManager *merge, - GtkAction *action, - GtkWidget *proxy, - GtkWidget *statusbar); +GtkWidget *gnc_window_get_menubar (GncWindow *window); +GtkWidget *gnc_window_get_toolbar (GncWindow *window); +GtkWidget *gnc_window_get_statusbar (GncWindow *window); +GMenuModel *gnc_window_get_menubar_model (GncWindow *window); G_END_DECLS diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c index 5cb18cfe34..55c342ce48 100644 --- a/gnucash/gnome/dialog-invoice.c +++ b/gnucash/gnome/dialog-invoice.c @@ -2727,11 +2727,11 @@ gnc_invoice_update_doclink_for_window (GncInvoice *invoice, const gchar *uri) if (g_strcmp0 (uri, "") == 0) // deleted uri { - GtkAction *uri_action; + GAction *uri_action; // update the menu actions uri_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(iw->page), "BusinessLinkOpenAction"); - gtk_action_set_sensitive (uri_action, FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(uri_action), FALSE); gtk_widget_hide (doclink_button); } diff --git a/gnucash/gnome/dialog-sx-editor.c b/gnucash/gnome/dialog-sx-editor.c index 0f2e027cb4..ebac7a5ff5 100644 --- a/gnucash/gnome/dialog-sx-editor.c +++ b/gnucash/gnome/dialog-sx-editor.c @@ -162,14 +162,14 @@ static gboolean sxed_confirmed_cancel (GncSxEditorDialog *sxed); static gboolean editor_component_sx_equality (gpointer find_data, gpointer user_data); -static GtkActionEntry gnc_sxed_menu_entries [] = +static GActionEntry gnc_sxed_menu_entries [] = { - { "EditAction", NULL, N_("_Edit"), NULL, NULL, NULL }, - { "TransactionAction", NULL, N_("_Transaction"), NULL, NULL, NULL }, - { "ViewAction", NULL, N_("_View"), NULL, NULL, NULL }, - { "ActionsAction", NULL, N_("_Actions"), NULL, NULL, NULL }, + { "EditAction", NULL, NULL, NULL, NULL }, + { "TransactionAction", NULL, NULL, NULL, NULL }, + { "ViewAction", NULL, NULL, NULL, NULL }, + { "ActionsAction", NULL, NULL, NULL, NULL }, }; -static guint gnc_sxed_menu_n_entries = G_N_ELEMENTS (gnc_sxed_menu_entries); +static guint gnc_sxed_menu_n_entries = G_N_ELEMENTS(gnc_sxed_menu_entries); /** Implementations *****************************************************/ @@ -1284,7 +1284,7 @@ gnc_ui_scheduled_xaction_editor_dialog_create (GtkWindow *parent, /* populate */ schedXact_editor_populate (sxed); - /* Do not call show_all here. Screws up the gtkuimanager code */ + /* Do not call show_all here */ gtk_widget_show (sxed->dialog); gtk_notebook_set_current_page (GTK_NOTEBOOK (sxed->notebook), 0); @@ -1355,10 +1355,10 @@ schedXact_editor_create_ledger (GncSxEditorDialog *sxed) /* First the embedded window */ main_vbox = GTK_WIDGET (gtk_builder_get_object (sxed->builder, "register_vbox")); sxed->embed_window = - gnc_embedded_window_new ("SXWindowActions", + gnc_embedded_window_new ("embedded-win", gnc_sxed_menu_entries, gnc_sxed_menu_n_entries, - "gnc-sxed-window-ui.xml", + "gnc-embedded-register-window.ui", sxed->dialog, FALSE, /* no accelerators */ sxed); @@ -1367,8 +1367,11 @@ schedXact_editor_create_ledger (GncSxEditorDialog *sxed) /* Now create the register plugin page. */ sxed->plugin_page = gnc_plugin_page_register_new_ledger (sxed->ledger); - gnc_plugin_page_set_ui_description (sxed->plugin_page, - "gnc-sxed-window-ui-full.xml"); + + gtk_widget_insert_action_group (GTK_WIDGET(sxed->embed_window), + gnc_plugin_page_get_simple_action_group_name (sxed->plugin_page), + G_ACTION_GROUP(gnc_plugin_page_get_action_group (sxed->plugin_page))); + gnc_plugin_page_register_set_options (sxed->plugin_page, NUM_LEDGER_LINES_DEFAULT, FALSE); gnc_embedded_window_open_page (sxed->embed_window, sxed->plugin_page); diff --git a/gnucash/gnome/gnc-plugin-account-tree.c b/gnucash/gnome/gnc-plugin-account-tree.c index 049f4e72e6..b9a78b67e5 100644 --- a/gnucash/gnome/gnc-plugin-account-tree.c +++ b/gnucash/gnome/gnc-plugin-account-tree.c @@ -46,24 +46,26 @@ static void gnc_plugin_account_tree_init (GncPluginAccountTree *plugin); static void gnc_plugin_account_tree_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_account_tree_cmd_new_account_tree (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_account_tree_cmd_new_account_tree (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-account-tree-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-account-tree-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-account-tree.ui" /** An array of all of the actions provided by the account tree * plugin. */ -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - { - "ViewAccountTreeAction", NULL, N_("New Accounts _Page"), NULL, - N_("Open a new Account Tree page"), - G_CALLBACK (gnc_plugin_account_tree_cmd_new_account_tree) - }, + { "ViewAccountTreeAction", gnc_plugin_account_tree_cmd_new_account_tree, NULL, NULL, NULL }, }; /** The number of actions provided by this plugin. */ -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "ViewPlaceholder5", + NULL, +}; /** The instance private data structure for an account tree plugin. */ typedef struct GncPluginAccountTreePrivate @@ -117,10 +119,11 @@ gnc_plugin_account_tree_class_init (GncPluginAccountTreeClass *klass) plugin_class->plugin_name = GNC_PLUGIN_ACCOUNT_TREE_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } @@ -156,9 +159,11 @@ gnc_plugin_account_tree_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_account_tree_cmd_new_account_tree (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_account_tree_cmd_new_account_tree (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; GncPluginPage *page; g_return_if_fail (data != NULL); diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c index 7df1f8696b..610bd7da60 100644 --- a/gnucash/gnome/gnc-plugin-basic-commands.c +++ b/gnucash/gnome/gnc-plugin-basic-commands.c @@ -71,171 +71,78 @@ static void gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, GncMainW static void gnc_plugin_basic_commands_main_window_page_changed(GncMainWindow *window, GncPluginPage *page, gpointer user_data); /* Command callbacks */ -static void gnc_main_window_cmd_file_new (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_file_open (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_file_save (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_file_save_as (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_file_revert (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_file_export_accounts (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_edit_tax_options (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_actions_mortgage_loan (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_actions_scheduled_transaction_editor (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActionData *data); +static void gnc_main_window_cmd_file_new (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_file_open (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_file_save (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_file_save_as (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_file_revert (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_file_export_accounts (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_edit_tax_options (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_actions_mortgage_loan (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_actions_scheduled_transaction_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_actions_since_last_run (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #if CLOSE_BOOKS_ACTUALLY_WORKS -static void gnc_main_window_cmd_actions_close_books (GtkAction *action, GncMainWindowActionData *data); +static void gnc_main_window_cmd_actions_close_books (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #endif /* CLOSE_BOOKS_ACTUALLY_WORKS */ -static void gnc_main_window_cmd_tools_financial_calculator (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_close_book (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_find_transactions (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_price_editor (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_imap_editor (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_trans_doclink (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_commodity_editor (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_help_totd (GtkAction *action, GncMainWindowActionData *data); +static void gnc_main_window_cmd_tools_financial_calculator (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_close_book (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_find_transactions (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_price_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_imap_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_trans_doclink (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_commodity_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_help_totd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-basic-commands-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-basic-commands-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-basic-commands.ui" /** An array of all of the actions provided by the basic commands * plugin. */ -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - - /* File menu */ - - { - "FileNewAction", "document-new", N_("New _File"), "n", - N_("Create a new file"), - G_CALLBACK (gnc_main_window_cmd_file_new) - }, - { - "FileOpenAction", "document-open", N_("_Open…"), "o", - N_("Open an existing GnuCash file"), - G_CALLBACK (gnc_main_window_cmd_file_open) - }, - { - "FileSaveAction", "document-save", N_("_Save"), "s", - N_("Save the current file"), - G_CALLBACK (gnc_main_window_cmd_file_save) - }, - { - "FileSaveAsAction", "document-save-as", N_("Save _As…"), "s", - N_("Save this file with a different name"), - G_CALLBACK (gnc_main_window_cmd_file_save_as) - }, - { - "FileRevertAction", "document-revert", N_("Re_vert"), NULL, - N_("Reload the current database, reverting all unsaved changes"), - G_CALLBACK (gnc_main_window_cmd_file_revert) - }, - { - "FileExportAccountsAction", "go-next", - N_("Export _Accounts"), NULL, - N_("Export the account hierarchy to a new GnuCash datafile"), - G_CALLBACK (gnc_main_window_cmd_file_export_accounts) - }, - - /* Edit menu */ - - { - "EditFindTransactionsAction", "edit-find", N_("_Find…"), "f", - N_("Find transactions with a search"), - G_CALLBACK (gnc_main_window_cmd_tools_find_transactions) - }, - { - "EditTaxOptionsAction", NULL, - /* Translators: remember to reuse this - translation in dialog-account.glade */ - N_("Ta_x Report Options"), NULL, - /* Translators: currently implemented are - US: income tax and - DE: VAT - So adjust this string */ - N_("Setup relevant accounts for tax reports, e.g. US income tax"), - G_CALLBACK (gnc_main_window_cmd_edit_tax_options) - }, - - /* Actions menu */ - - { "ActionsScheduledTransactionsAction", NULL, N_("_Scheduled Transactions"), NULL, NULL, NULL }, - { - "ActionsScheduledTransactionEditorAction", NULL, N_("_Scheduled Transaction Editor"), NULL, - N_("The list of Scheduled Transactions"), - G_CALLBACK (gnc_main_window_cmd_actions_scheduled_transaction_editor) - }, - { - "ActionsSinceLastRunAction", NULL, N_("Since _Last Run…"), NULL, - N_("Create Scheduled Transactions since the last time run"), - G_CALLBACK (gnc_main_window_cmd_actions_since_last_run) - }, - { - "ActionsMortgageLoanAction", NULL, N_("_Mortgage & Loan Repayment…"), NULL, - N_("Setup scheduled transactions for repayment of a loan"), - G_CALLBACK (gnc_main_window_cmd_actions_mortgage_loan) - }, - { "ActionsBudgetAction", NULL, N_("B_udget"), NULL, NULL, NULL }, + { "FileNewAction", gnc_main_window_cmd_file_new, NULL, NULL, NULL }, + { "FileOpenAction", gnc_main_window_cmd_file_open, NULL, NULL, NULL }, + { "FileSaveAction", gnc_main_window_cmd_file_save, NULL, NULL, NULL }, + { "FileSaveAsAction", gnc_main_window_cmd_file_save_as, NULL, NULL, NULL }, + { "FileRevertAction", gnc_main_window_cmd_file_revert, NULL, NULL, NULL }, + { "FileExportAccountsAction", gnc_main_window_cmd_file_export_accounts, NULL, NULL, NULL }, + { "EditFindTransactionsAction", gnc_main_window_cmd_tools_find_transactions, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_main_window_cmd_edit_tax_options, NULL, NULL, NULL }, + { "ActionsScheduledTransactionsAction", NULL, NULL, NULL, NULL }, + { "ActionsScheduledTransactionEditorAction", gnc_main_window_cmd_actions_scheduled_transaction_editor, NULL, NULL, NULL }, + { "ActionsSinceLastRunAction", gnc_main_window_cmd_actions_since_last_run, NULL, NULL, NULL }, + { "ActionsMortgageLoanAction", gnc_main_window_cmd_actions_mortgage_loan, NULL, NULL, NULL }, + { "ActionsBudgetAction", NULL, NULL, NULL, NULL }, #ifdef CLOSE_BOOKS_ACTUALLY_WORKS - { - "ActionsCloseBooksAction", NULL, N_("Close _Books"), NULL, - N_("Archive old data using accounting periods"), - G_CALLBACK (gnc_main_window_cmd_actions_close_books) - }, + { "ActionsCloseBooksAction", gnc_main_window_cmd_actions_close_books, NULL, NULL, NULL }, #endif // CLOSE_BOOKS_ACTUALLY_WORKS - - /* Tools menu */ - { - "ToolsPriceEditorAction", NULL, N_("_Price Database"), NULL, - N_("View and edit the prices for stocks and mutual funds"), - G_CALLBACK (gnc_main_window_cmd_tools_price_editor) - }, - { - "ToolsCommodityEditorAction", NULL, N_("_Security Editor"), NULL, - N_("View and edit the commodities for stocks and mutual funds"), - G_CALLBACK (gnc_main_window_cmd_tools_commodity_editor) - }, - { - "ToolsFinancialCalculatorAction", NULL, N_("_Loan Repayment Calculator"), NULL, - N_("Use the loan/mortgage repayment calculator"), - G_CALLBACK (gnc_main_window_cmd_tools_financial_calculator) - }, - { - "ToolsBookCloseAction", NULL, N_("_Close Book"), NULL, - N_("Close the Book at the end of the Period"), - G_CALLBACK (gnc_main_window_cmd_tools_close_book) - }, - { - "ToolsImapEditorAction", NULL, N_("_Import Map Editor"), NULL, - N_("View and Delete Bayesian and non-Bayesian information"), - G_CALLBACK (gnc_main_window_cmd_tools_imap_editor) - }, - { - "ToolsTransLinkedDocsAction", NULL, N_("_Transaction Linked Documents"), NULL, - N_("View all Transaction Linked Documents"), - G_CALLBACK (gnc_main_window_cmd_tools_trans_doclink) - }, - - /* Help menu */ - - { - "HelpTipsOfTheDayAction", NULL, N_("_Tips Of The Day"), NULL, - N_("View the Tips of the Day"), - G_CALLBACK (gnc_main_window_cmd_help_totd) - }, + { "ToolsPriceEditorAction", gnc_main_window_cmd_tools_price_editor, NULL, NULL, NULL }, + { "ToolsCommodityEditorAction", gnc_main_window_cmd_tools_commodity_editor, NULL, NULL, NULL }, + { "ToolsFinancialCalculatorAction", gnc_main_window_cmd_tools_financial_calculator, NULL, NULL, NULL }, + { "ToolsBookCloseAction", gnc_main_window_cmd_tools_close_book, NULL, NULL, NULL }, + { "ToolsImapEditorAction", gnc_main_window_cmd_tools_imap_editor, NULL, NULL, NULL }, + { "ToolsTransLinkedDocsAction", gnc_main_window_cmd_tools_trans_doclink, NULL, NULL, NULL }, + { "HelpTipsOfTheDayAction", gnc_main_window_cmd_help_totd, NULL, NULL, NULL }, }; /** The number of actions provided by this plugin. */ -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); - -/** These are the "important" actions provided by the basic commands - * plugin. Their labels will appear when the toolbar is set to - * "Icons and important text" (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. */ -static const gchar *gnc_plugin_important_actions[] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - "FileSaveAction", + "FilePlaceholder0", + "FilePlaceholder2", + "FilePlaceholder3", + "FilePlaceholder5", + "EditPlaceholder3", + "EditPlaceholder5", + "ActionsPlaceholder2", + "ToolsPlaceholder1", + "HelpPlaceholder1", NULL, }; @@ -278,7 +185,7 @@ typedef struct GncPluginBasicCommandsPrivate } GncPluginBasicCommandsPrivate; #define GNC_PLUGIN_BASIC_COMMANDS_GET_PRIVATE(o) \ - ((GncPluginBasicCommandsPrivate*)gnc_plugin_basic_commands_get_instance_private((GncPluginBasicCommands*)o)) + ((GncPluginBasicCommandsPrivate*)gnc_plugin_basic_commands_get_instance_private ((GncPluginBasicCommands*)o)) /** A pointer to the parent class of a plugin page. */ static GObjectClass *parent_class = NULL; @@ -314,25 +221,27 @@ gnc_plugin_basic_commands_new (void) */ static void gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, - GncMainWindow *window, - GQuark type) + GncMainWindow *window, + GQuark type) { - GtkActionGroup *action_group = - gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); - gnc_plugin_update_actions(action_group, - gnc_plugin_initially_insensitive_actions, - "sensitive", FALSE); - g_signal_connect(window, "page_changed", - G_CALLBACK(gnc_plugin_basic_commands_main_window_page_changed), - plugin); + GSimpleActionGroup *simple_action_group = + gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); + + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), + gnc_plugin_initially_insensitive_actions, + FALSE); + + g_signal_connect (window, "page_changed", + G_CALLBACK(gnc_plugin_basic_commands_main_window_page_changed), + plugin); } /** Update the actions sensitivity */ -static void update_inactive_actions(GncPluginPage *plugin_page) +static void update_inactive_actions (GncPluginPage *plugin_page) { - GncMainWindow *window; - GtkActionGroup *action_group; + GncMainWindow *window; + GSimpleActionGroup *simple_action_group; // We are readonly - so we have to switch particular actions to inactive. gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book()); @@ -344,26 +253,26 @@ static void update_inactive_actions(GncPluginPage *plugin_page) window = GNC_MAIN_WINDOW(plugin_page->window); g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); - action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); - g_return_if_fail(GTK_IS_ACTION_GROUP(action_group)); + simple_action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (action_group, readwrite_only_active_actions, - "sensitive", is_readwrite); - gnc_plugin_update_actions (action_group, dirty_only_active_actions, - "sensitive", is_dirty); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), readwrite_only_active_actions, + is_readwrite); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), dirty_only_active_actions, + is_dirty); } static void -gnc_plugin_basic_commands_main_window_page_changed(GncMainWindow *window, - GncPluginPage *page, - gpointer user_data) +gnc_plugin_basic_commands_main_window_page_changed (GncMainWindow *window, + GncPluginPage *plugin_page, + gpointer user_data) { /* Make sure not to call this with a NULL GncPluginPage */ - if (page) + if (plugin_page) { // Update the action sensitivity due to read-only - update_inactive_actions(page); + update_inactive_actions (plugin_page); } } @@ -393,11 +302,11 @@ gnc_plugin_basic_commands_class_init (GncPluginBasicCommandsClass *klass) plugin_class->add_to_window = gnc_plugin_basic_commands_add_to_window; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->important_actions = gnc_plugin_important_actions; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } @@ -423,9 +332,9 @@ gnc_plugin_basic_commands_init (GncPluginBasicCommands *plugin) static void gnc_plugin_basic_commands_finalize (GObject *object) { - g_return_if_fail (GNC_IS_PLUGIN_BASIC_COMMANDS (object)); + g_return_if_fail (GNC_IS_PLUGIN_BASIC_COMMANDS(object)); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS(parent_class)->finalize (object); } /************************************************************ @@ -433,20 +342,28 @@ gnc_plugin_basic_commands_finalize (GObject *object) ************************************************************/ static void -gnc_main_window_cmd_file_new (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_new (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - if (!gnc_main_window_all_finish_pending()) + GncMainWindowActionData *data = user_data; + + if (!gnc_main_window_all_finish_pending ()) return; - gnc_file_new (GTK_WINDOW (data->window)); + gnc_file_new (GTK_WINDOW(data->window)); } static void -gnc_main_window_cmd_file_open (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_open (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - if (!gnc_main_window_all_finish_pending()) + if (!gnc_main_window_all_finish_pending ()) return; /* Reset the flag that indicates the conversion of the bayes KVP @@ -455,88 +372,114 @@ gnc_main_window_cmd_file_open (GtkAction *action, GncMainWindowActionData *data) gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); #ifdef HAVE_DBI_DBI_H - gnc_ui_file_access_for_open (GTK_WINDOW (data->window)); + gnc_ui_file_access_for_open (GTK_WINDOW(data->window)); #else - gnc_file_open (GTK_WINDOW (data->window)); + gnc_file_open (GTK_WINDOW(data->window)); #endif gnc_window_set_progressbar_window (NULL); } static void -gnc_main_window_cmd_file_save (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_save (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - if (!gnc_main_window_all_finish_pending()) + if (!gnc_main_window_all_finish_pending ()) return; gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); - gnc_file_save (GTK_WINDOW (data->window)); + gnc_file_save (GTK_WINDOW(data->window)); gnc_window_set_progressbar_window (NULL); } static void -gnc_main_window_cmd_file_save_as (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_save_as (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - if (!gnc_main_window_all_finish_pending()) + if (!gnc_main_window_all_finish_pending ()) return; gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); #ifdef HAVE_DBI_DBI_H - gnc_ui_file_access_for_save_as (GTK_WINDOW (data->window)); + gnc_ui_file_access_for_save_as (GTK_WINDOW(data->window)); #else - gnc_file_save_as (GTK_WINDOW (data->window)); + gnc_file_save_as (GTK_WINDOW(data->window)); #endif gnc_window_set_progressbar_window (NULL); } static void -gnc_main_window_cmd_file_revert (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_revert (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - if (!gnc_main_window_all_finish_pending()) + if (!gnc_main_window_all_finish_pending ()) return; gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); - gnc_file_revert(GTK_WINDOW (data->window)); + gnc_file_revert (GTK_WINDOW(data->window)); gnc_window_set_progressbar_window (NULL); } static void -gnc_main_window_cmd_file_export_accounts (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_export_accounts (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); #ifdef HAVE_DBI_DBI_H - gnc_ui_file_access_for_export (GTK_WINDOW (data->window)); + gnc_ui_file_access_for_export (GTK_WINDOW(data->window)); #else - gnc_file_export (GTK_WINDOW (data->window)); + gnc_file_export (GTK_WINDOW(data->window)); #endif gnc_window_set_progressbar_window (NULL); } static void -gnc_main_window_cmd_edit_tax_options (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_edit_tax_options (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - gnc_tax_info_dialog (GTK_WIDGET (data->window), NULL); + gnc_tax_info_dialog (GTK_WIDGET(data->window), NULL); } static void -gnc_main_window_cmd_actions_scheduled_transaction_editor (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_actions_scheduled_transaction_editor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - GncPluginPage *page = gnc_plugin_page_sx_list_new(); - gnc_main_window_open_page(NULL, page); + GncMainWindowActionData *data = user_data; + GncPluginPage *page = gnc_plugin_page_sx_list_new (); + gnc_main_window_open_page (NULL, page); } static void -gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_actions_since_last_run (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; GtkWindow *window; GncSxInstanceModel *sx_instances; GncSxSummary summary; @@ -546,9 +489,9 @@ gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActi g_return_if_fail (data != NULL); - window = GTK_WINDOW (data->window); + window = GTK_WINDOW(data->window); - if (qof_book_is_readonly(gnc_get_current_book())) + if (qof_book_is_readonly (gnc_get_current_book())) { /* Is the book read-only? Then don't change anything here. */ return; @@ -574,97 +517,122 @@ gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActi } else { - gnc_info_dialog(window, ngettext - /* Translators: %d is the number of transactions. This is a - ngettext(3) message. */ - ("There are no Scheduled Transactions to be entered at this time. " - "(%d transaction automatically created)", - "There are no Scheduled Transactions to be entered at this time. " - "(%d transactions automatically created)", - summary.num_auto_create_no_notify_instances), - summary.num_auto_create_no_notify_instances); + gnc_info_dialog (window, ngettext + /* Translators: %d is the number of transactions. This is a + ngettext(3) message. */ + ("There are no Scheduled Transactions to be entered at this time. " + "(%d transaction automatically created)", + "There are no Scheduled Transactions to be entered at this time. " + "(%d transactions automatically created)", + summary.num_auto_create_no_notify_instances), + summary.num_auto_create_no_notify_instances); } } - g_list_free(auto_created_txns); - g_object_unref(G_OBJECT(sx_instances)); + g_list_free (auto_created_txns); + g_object_unref (G_OBJECT(sx_instances)); } static void -gnc_main_window_cmd_actions_mortgage_loan (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_actions_mortgage_loan (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; gnc_ui_sx_loan_assistant_create (); } #ifdef CLOSE_BOOKS_ACTUALLY_WORKS static void -gnc_main_window_cmd_actions_close_books (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_actions_close_books (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_acct_period_dialog(); + GncMainWindowActionData *data = user_data; + gnc_acct_period_dialog (); } #endif /* CLOSE_BOOKS_ACTUALLY_WORKS */ static void -gnc_main_window_cmd_tools_imap_editor (GtkAction *action, GncMainWindowActionData *data) -{ - gnc_set_busy_cursor(NULL, TRUE); - gnc_imap_dialog (GTK_WIDGET (data->window)); - gnc_unset_busy_cursor(NULL); -} - -static void -gnc_main_window_cmd_tools_trans_doclink (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_imap_editor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; gnc_set_busy_cursor (NULL, TRUE); - gnc_doclink_trans_dialog (GTK_WINDOW (data->window)); + gnc_imap_dialog (GTK_WIDGET(data->window)); gnc_unset_busy_cursor (NULL); } static void -gnc_main_window_cmd_tools_price_editor (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_trans_doclink (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_set_busy_cursor(NULL, TRUE); - gnc_prices_dialog (GTK_WIDGET (data->window)); - gnc_unset_busy_cursor(NULL); + GncMainWindowActionData *data = user_data; + gnc_set_busy_cursor (NULL, TRUE); + gnc_doclink_trans_dialog (GTK_WINDOW(data->window)); + gnc_unset_busy_cursor (NULL); } static void -gnc_main_window_cmd_tools_commodity_editor (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_price_editor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_set_busy_cursor(NULL, TRUE); - gnc_commodities_dialog (GTK_WIDGET (data->window)); - gnc_unset_busy_cursor(NULL); + GncMainWindowActionData *data = user_data; + gnc_set_busy_cursor (NULL, TRUE); + gnc_prices_dialog (GTK_WIDGET(data->window)); + gnc_unset_busy_cursor (NULL); } static void -gnc_main_window_cmd_tools_financial_calculator (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_commodity_editor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_ui_fincalc_dialog_create(GTK_WINDOW (data->window)); + GncMainWindowActionData *data = user_data; + gnc_set_busy_cursor (NULL, TRUE); + gnc_commodities_dialog (GTK_WIDGET(data->window)); + gnc_unset_busy_cursor (NULL); } static void -gnc_main_window_cmd_tools_close_book (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_financial_calculator (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_ui_close_book(gnc_get_current_book(), GTK_WINDOW (data->window)); + GncMainWindowActionData *data = user_data; + gnc_ui_fincalc_dialog_create (GTK_WINDOW(data->window)); } static void -gnc_main_window_cmd_tools_find_transactions (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_close_book (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + gnc_ui_close_book (gnc_get_current_book(), GTK_WINDOW(data->window)); +} + +static void +gnc_main_window_cmd_tools_find_transactions (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GncMainWindowActionData *data = user_data; -#ifdef REGISTER2_ENABLED - /*################## Added for Reg2 #################*/ - gnc_ui_find_transactions_dialog_create2 (NULL); - /*################## Added for Reg2 #################*/ -#else gnc_ui_find_transactions_dialog_create (GTK_WINDOW(data->window), NULL); -#endif } static void -gnc_main_window_cmd_help_totd (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_help_totd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - gnc_totd_dialog(GTK_WINDOW(data->window), FALSE); + gnc_totd_dialog (GTK_WINDOW(data->window), FALSE); } /** @} */ diff --git a/gnucash/gnome/gnc-plugin-budget.c b/gnucash/gnome/gnc-plugin-budget.c index 4df93075b6..a251c3a497 100644 --- a/gnucash/gnome/gnc-plugin-budget.c +++ b/gnucash/gnome/gnc-plugin-budget.c @@ -38,7 +38,7 @@ #include "gnc-component-manager.h" #define PLUGIN_ACTIONS_NAME "gnc-plugin-budget-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-budget-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-budget.ui" static QofLogModule log_module = GNC_MOD_GUI; @@ -49,43 +49,29 @@ static void gnc_plugin_budget_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type); /* Command Callbacks */ -static void gnc_plugin_budget_cmd_new_budget (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_budget_cmd_open_budget (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_budget_cmd_copy_budget (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_budget_cmd_delete_budget (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_budget_cmd_new_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_budget_cmd_open_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_budget_cmd_copy_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_budget_cmd_delete_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - { - "NewBudgetAction", NULL, N_("_New Budget"), NULL, - N_("Create a new Budget."), - G_CALLBACK(gnc_plugin_budget_cmd_new_budget) - }, - - { - "OpenBudgetAction", NULL, N_("_Open Budget"), NULL, - N_("Open an existing Budget in a new tab. If none exists a new budget will be created."), - G_CALLBACK(gnc_plugin_budget_cmd_open_budget) - }, - - { - "CopyBudgetAction", NULL, N_("_Copy Budget"), NULL, - N_("Copy an existing Budget."), - G_CALLBACK(gnc_plugin_budget_cmd_copy_budget) - }, - { - "DeleteBudgetAction", NULL, N_("_Delete Budget"), NULL, - N_("Delete an existing Budget."), - G_CALLBACK(gnc_plugin_budget_cmd_delete_budget) - }, + { "ActionsBudgetAction", NULL, NULL, NULL, NULL }, + { "NewBudgetAction", gnc_plugin_budget_cmd_new_budget, NULL, NULL, NULL }, + { "OpenBudgetAction", gnc_plugin_budget_cmd_open_budget, NULL, NULL, NULL }, + { "CopyBudgetAction", gnc_plugin_budget_cmd_copy_budget, NULL, NULL, NULL }, + { "DeleteBudgetAction", gnc_plugin_budget_cmd_delete_budget, NULL, NULL, NULL }, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "ActionsPlaceholder3", + NULL, +}; static const gchar *plugin_writeable_actions[] = { @@ -106,7 +92,8 @@ typedef struct GncPluginBudgetPrivate static GObjectClass *parent_class = NULL; -GncPlugin * gnc_plugin_budget_new (void) +GncPlugin * +gnc_plugin_budget_new (void) { GncPluginBudget *plugin; ENTER(" "); @@ -120,23 +107,25 @@ GncPlugin * gnc_plugin_budget_new (void) return GNC_PLUGIN(plugin); } -static void page_changed (GncMainWindow *window, GncPluginPage *page, - gpointer user_data) +static void +page_changed (GncMainWindow *window, GncPluginPage *page, gpointer user_data) { - GtkActionGroup *action_group = + GSimpleActionGroup *simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); if (qof_book_is_readonly (gnc_get_current_book())) - gnc_plugin_update_actions (action_group, plugin_writeable_actions, - "sensitive", FALSE); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), plugin_writeable_actions, + FALSE); } -static void add_to_window (GncPlugin *plugin, GncMainWindow *mainwindow, GQuark type) +static void +add_to_window (GncPlugin *plugin, GncMainWindow *mainwindow, GQuark type) { g_signal_connect (mainwindow, "page_changed", G_CALLBACK (page_changed), plugin); } -static void remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type) +static void +remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type) { g_signal_handlers_disconnect_by_func (window, G_CALLBACK(page_changed), plugin); } @@ -153,12 +142,13 @@ gnc_plugin_budget_class_init (GncPluginBudgetClass *klass) parent_class = g_type_class_peek_parent (klass); object_class->finalize = gnc_plugin_budget_finalize; - plugin_class->plugin_name = GNC_PLUGIN_BUDGET_NAME; - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; - plugin_class->add_to_window = add_to_window; + plugin_class->plugin_name = GNC_PLUGIN_BUDGET_NAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; + plugin_class->add_to_window = add_to_window; plugin_class->remove_from_window = remove_from_window; LEAVE (" "); @@ -186,15 +176,17 @@ gnc_plugin_budget_finalize (GObject *object) /* Make a new budget; put it in a page; open the page. */ static void -gnc_plugin_budget_cmd_new_budget (GtkAction *action, - GncMainWindowActionData *user_data) +gnc_plugin_budget_cmd_new_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; GncBudget *budget; GncPluginPage *page; gchar *description, *date; QofBook *book = gnc_get_current_book(); - g_return_if_fail (user_data != NULL); + g_return_if_fail (data != NULL); if (!gnc_features_check_used (book, GNC_FEATURE_BUDGET_UNREVERSED)) { @@ -212,19 +204,22 @@ GnuCash 3.8 or later."); g_free (description); g_free (date); - gnc_main_window_open_page (user_data->window, page); + gnc_main_window_open_page (data->window, page); } /* If only one budget exists, open it; otherwise user selects one to open */ static void -gnc_plugin_budget_cmd_open_budget (GtkAction *action, - GncMainWindowActionData *user_data) +gnc_plugin_budget_cmd_open_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; guint count; QofBook *book; GncBudget *bgt = NULL; QofCollection *col; - g_return_if_fail (user_data != NULL); + + g_return_if_fail (data != NULL); book = gnc_get_current_book (); col = qof_book_get_collection (book, GNC_ID_BUDGET); @@ -234,26 +229,29 @@ gnc_plugin_budget_cmd_open_budget (GtkAction *action, if (count == 1) bgt = gnc_budget_get_default (book); else - bgt = gnc_budget_gui_select_budget (GTK_WINDOW(user_data->window), book); + bgt = gnc_budget_gui_select_budget (GTK_WINDOW(data->window), book); if (bgt) - gnc_main_window_open_page (user_data->window, + gnc_main_window_open_page (data->window, gnc_plugin_page_budget_new (bgt)); } else /* if no budgets exist yet, just open a new budget */ - gnc_plugin_budget_cmd_new_budget (action, user_data); + gnc_plugin_budget_cmd_new_budget (simple, parameter, user_data); } /* If only one budget exists, create a copy of it; otherwise user selects one to copy */ static void -gnc_plugin_budget_cmd_copy_budget (GtkAction *action, - GncMainWindowActionData *user_data) +gnc_plugin_budget_cmd_copy_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; guint count; QofBook *book; GncBudget *bgt = NULL; QofCollection *col; - g_return_if_fail (user_data != NULL); + + g_return_if_fail (data != NULL); book = gnc_get_current_book (); col = qof_book_get_collection (book, GNC_ID_BUDGET); @@ -263,7 +261,7 @@ gnc_plugin_budget_cmd_copy_budget (GtkAction *action, if (count == 1) bgt = gnc_budget_get_default(book); else - bgt = gnc_budget_gui_select_budget (GTK_WINDOW(user_data->window), book); + bgt = gnc_budget_gui_select_budget (GTK_WINDOW(data->window), book); if (bgt) { @@ -275,29 +273,31 @@ gnc_plugin_budget_cmd_copy_budget (GtkAction *action, gnc_budget_set_name (copy, name); g_free (name); - gnc_main_window_open_page (user_data->window, + gnc_main_window_open_page (data->window, gnc_plugin_page_budget_new (copy)); } } else /* if no budgets exist yet, just open a new budget */ - gnc_plugin_budget_cmd_new_budget (action, user_data); + gnc_plugin_budget_cmd_new_budget (simple, parameter, user_data); } /* user selects budget to delete */ static void -gnc_plugin_budget_cmd_delete_budget (GtkAction *action, - GncMainWindowActionData *user_data) +gnc_plugin_budget_cmd_delete_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; GncBudget *bgt; QofBook *book; - g_return_if_fail (user_data != NULL); + g_return_if_fail (data != NULL); book = gnc_get_current_book (); if (qof_collection_count (qof_book_get_collection (book, GNC_ID_BUDGET)) == 0) return; - bgt = gnc_budget_gui_select_budget (GTK_WINDOW(user_data->window), book); + bgt = gnc_budget_gui_select_budget (GTK_WINDOW(data->window), book); if (!bgt) return; gnc_budget_gui_delete_budget (bgt); diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index d853264ab5..b877be8dc7 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -52,6 +52,8 @@ #include "gnc-prefs.h" #include "gnc-main-window.h" +#include "gnc-window.h" +#include "gnc-gtk-utils.h" #include "gnc-plugin-page-register.h" @@ -63,80 +65,51 @@ static void gnc_plugin_business_class_init (GncPluginBusinessClass *klass); static void gnc_plugin_business_init (GncPluginBusiness *plugin); static void gnc_plugin_business_finalize (GObject *object); static void gnc_plugin_business_add_to_window (GncPlugin *plugin, - GncMainWindow *window, - GQuark type); + GncMainWindow *window, + GQuark type); /* Command callbacks */ -static void gnc_plugin_business_cmd_customer_page (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_new_customer (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_find_customer (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_new_invoice (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_find_invoice (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_new_job (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_find_job (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_process_payment (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_customer_page (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_new_customer (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_find_customer (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_new_invoice (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_find_invoice (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_new_job (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_find_job (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_process_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_vendor_page (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_new_vendor (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_find_vendor (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_new_bill (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_find_bill (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_new_job (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_find_job (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_process_payment (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_vendor_page (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_new_vendor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_find_vendor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_new_bill (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_find_bill (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_new_job (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_find_job (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_process_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_employee_page (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_employee_new_employee (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_employee_find_employee (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_employee_new_expense_voucher (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_employee_find_expense_voucher (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_employee_process_payment (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_employee_page (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_employee_new_employee (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_employee_find_employee (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_employee_new_expense_voucher (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_employee_find_expense_voucher (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_employee_process_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_doclink (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_tax_tables (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_billing_terms (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_bills_due_reminder (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_invoices_due_reminder (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_doclink (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_tax_tables (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_billing_terms (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_bills_due_reminder (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_invoices_due_reminder (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_test_search (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_test_search (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_test_init_data (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_test_init_data (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_assign_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_assign_payment (GtkAction *action, - GncMainWindowActionData *data); -static void update_inactive_actions(GncPluginPage *page); +static void update_inactive_actions (GncPluginPage *page); +static void bind_extra_toolbuttons_visibility (GncMainWindow *mainwindow); #define PLUGIN_ACTIONS_NAME "gnc-plugin-business-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-business-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-business.ui" #define GNC_PREF_EXTRA_TOOLBUTTONS "enable-toolbuttons" #define GNC_PREF_INV_PRINT_RPT "invoice-printreport" @@ -149,192 +122,56 @@ static void update_inactive_actions(GncPluginPage *page); */ static GncMainWindow *last_window = NULL; -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - /* Toplevel */ - { "BusinessAction", NULL, N_("_Business"), NULL, NULL, NULL }, + { "CustomerOverviewPageAction", gnc_plugin_business_cmd_customer_page, NULL, NULL, NULL }, + { "CustomerNewCustomerOpenAction", gnc_plugin_business_cmd_customer_new_customer, NULL, NULL, NULL }, + { "CustomerFindCustomerOpenAction", gnc_plugin_business_cmd_customer_find_customer, NULL, NULL, NULL }, + { "CustomerNewInvoiceOpenAction", gnc_plugin_business_cmd_customer_new_invoice, NULL, NULL, NULL }, + { "CustomerFindInvoiceOpenAction", gnc_plugin_business_cmd_customer_find_invoice, NULL, NULL, NULL }, + { "CustomerNewJobOpenAction", gnc_plugin_business_cmd_customer_new_job, NULL, NULL, NULL }, + { "CustomerFindJobOpenAction", gnc_plugin_business_cmd_customer_find_job, NULL, NULL, NULL }, + { "CustomerProcessPaymentAction", gnc_plugin_business_cmd_customer_process_payment, NULL, NULL, NULL }, - /* Customer submenu */ - { "CustomerMenuAction", NULL, N_("_Customer"), NULL, NULL, NULL }, - { - "CustomerOverviewPageAction", NULL, N_("Customers Overview"), NULL, - N_("Open a Customer overview page"), - G_CALLBACK (gnc_plugin_business_cmd_customer_page) - }, - { - "CustomerNewCustomerOpenAction", NULL, N_("_New Customer…"), NULL, - N_("Open the New Customer dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_new_customer) - }, - { - "CustomerFindCustomerOpenAction", NULL, N_("_Find Customer…"), NULL, - N_("Open the Find Customer dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_find_customer) - }, - { - "CustomerNewInvoiceOpenAction", NULL, N_("New _Invoice…"), NULL, - N_("Open the New Invoice dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_new_invoice) - }, - { - "CustomerFindInvoiceOpenAction", NULL, N_("Find In_voice…"), NULL, - N_("Open the Find Invoice dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_find_invoice) - }, - { - "CustomerNewJobOpenAction", NULL, N_("New _Job…"), NULL, - N_("Open the New Job dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_new_job) - }, - { - "CustomerFindJobOpenAction", NULL, N_("Find Jo_b…"), NULL, - N_("Open the Find Job dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_find_job) - }, - { - "CustomerProcessPaymentAction", NULL, N_("_Process Payment…"), NULL, - N_("Open the Process Payment dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_process_payment) - }, + { "VendorOverviewPageAction", gnc_plugin_business_cmd_vendor_page, NULL, NULL, NULL }, + { "VendorNewVendorOpenAction", gnc_plugin_business_cmd_vendor_new_vendor, NULL, NULL, NULL }, + { "VendorFindVendorOpenAction", gnc_plugin_business_cmd_vendor_find_vendor, NULL, NULL, NULL }, + { "VendorNewBillOpenAction", gnc_plugin_business_cmd_vendor_new_bill, NULL, NULL, NULL }, + { "VendorFindBillOpenAction", gnc_plugin_business_cmd_vendor_find_bill, NULL, NULL, NULL }, + { "VendorNewJobOpenAction", gnc_plugin_business_cmd_vendor_new_job, NULL, NULL, NULL }, + { "VendorFindJobOpenAction", gnc_plugin_business_cmd_vendor_find_job, NULL, NULL, NULL }, + { "VendorProcessPaymentAction", gnc_plugin_business_cmd_vendor_process_payment, NULL, NULL, NULL }, - /* Vendor submenu */ - { - "VendorOverviewPageAction", NULL, N_("Vendors Overview"), NULL, - N_("Open a Vendor overview page"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_page) - }, - { "VendorMenuAction", NULL, N_("_Vendor"), NULL, NULL, NULL }, - { - "VendorNewVendorOpenAction", NULL, N_("_New Vendor…"), NULL, - N_("Open the New Vendor dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_new_vendor) - }, - { - "VendorFindVendorOpenAction", NULL, N_("_Find Vendor…"), NULL, - N_("Open the Find Vendor dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_find_vendor) - }, - { - "VendorNewBillOpenAction", NULL, N_("New _Bill…"), NULL, - N_("Open the New Bill dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_new_bill) - }, - { - "VendorFindBillOpenAction", NULL, N_("Find Bi_ll…"), NULL, - N_("Open the Find Bill dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_find_bill) - }, - { - "VendorNewJobOpenAction", NULL, N_("New _Job…"), NULL, - N_("Open the New Job dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_new_job) - }, - { - "VendorFindJobOpenAction", NULL, N_("Find Jo_b…"), NULL, - N_("Open the Find Job dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_find_job) - }, - { - "VendorProcessPaymentAction", NULL, N_("_Process Payment…"), NULL, - N_("Open the Process Payment dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_process_payment) - }, + { "EmployeeOverviewPageAction", gnc_plugin_business_cmd_employee_page, NULL, NULL, NULL }, + { "EmployeeNewEmployeeOpenAction", gnc_plugin_business_cmd_employee_new_employee, NULL, NULL, NULL }, + { "EmployeeFindEmployeeOpenAction", gnc_plugin_business_cmd_employee_find_employee, NULL, NULL, NULL }, + { "EmployeeNewExpenseVoucherOpenAction", gnc_plugin_business_cmd_employee_new_expense_voucher, NULL, NULL, NULL }, + { "EmployeeFindExpenseVoucherOpenAction", gnc_plugin_business_cmd_employee_find_expense_voucher, NULL, NULL, NULL }, + { "EmployeeProcessPaymentAction", gnc_plugin_business_cmd_employee_process_payment, NULL, NULL, NULL }, - /* Employee submenu */ - { - "EmployeeOverviewPageAction", NULL, N_("Employees Overview"), NULL, - N_("Open a Employee overview page"), - G_CALLBACK (gnc_plugin_business_cmd_employee_page) - }, - { "EmployeeMenuAction", NULL, N_("_Employee"), NULL, NULL, NULL }, - { - "EmployeeNewEmployeeOpenAction", NULL, N_("_New Employee…"), NULL, - N_("Open the New Employee dialog"), - G_CALLBACK (gnc_plugin_business_cmd_employee_new_employee) - }, - { - "EmployeeFindEmployeeOpenAction", NULL, N_("_Find Employee…"), NULL, - N_("Open the Find Employee dialog"), - G_CALLBACK (gnc_plugin_business_cmd_employee_find_employee) - }, - { - "EmployeeNewExpenseVoucherOpenAction", NULL, N_("New _Expense Voucher…"), NULL, - N_("Open the New Expense Voucher dialog"), - G_CALLBACK (gnc_plugin_business_cmd_employee_new_expense_voucher) - }, - { - "EmployeeFindExpenseVoucherOpenAction", NULL, N_("Find Expense _Voucher…"), NULL, - N_("Open the Find Expense Voucher dialog"), - G_CALLBACK (gnc_plugin_business_cmd_employee_find_expense_voucher) - }, - { - "EmployeeProcessPaymentAction", NULL, N_("_Process Payment…"), NULL, - N_("Open the Process Payment dialog"), - G_CALLBACK (gnc_plugin_business_cmd_employee_process_payment) - }, + { "BusinessLinkedDocsAction", gnc_plugin_business_cmd_doclink, NULL, NULL, NULL }, + { "TaxTablesOpenAction", gnc_plugin_business_cmd_tax_tables, NULL, NULL, NULL }, + { "BillingTermsOpenAction", gnc_plugin_business_cmd_billing_terms, NULL, NULL, NULL }, + { "BillsDueReminderOpenAction", gnc_plugin_business_cmd_bills_due_reminder, NULL, NULL, NULL }, + { "InvoicesDueReminderOpenAction", gnc_plugin_business_cmd_invoices_due_reminder, NULL, NULL, NULL }, - /* Other menu items */ - { - "BusinessLinkedDocsAction", NULL, N_("Business Linked Documents"), NULL, - N_("View all Linked Business Documents"), - G_CALLBACK (gnc_plugin_business_cmd_doclink) - }, - { - "TaxTablesOpenAction", NULL, N_("Sales _Tax Table"), NULL, - N_("View and edit the list of Sales Tax Tables (GST/VAT)"), - G_CALLBACK (gnc_plugin_business_cmd_tax_tables) - }, - { - "BillingTermsOpenAction", NULL, N_("_Billing Terms Editor"), NULL, - N_("View and edit the list of Billing Terms"), - G_CALLBACK (gnc_plugin_business_cmd_billing_terms) - }, - { - "BillsDueReminderOpenAction", NULL, N_("Bills _Due Reminder"), NULL, - N_("Open the Bills Due Reminder dialog"), - G_CALLBACK (gnc_plugin_business_cmd_bills_due_reminder) - }, - { - "InvoicesDueReminderOpenAction", NULL, N_("Invoices _Due Reminder"), NULL, - N_("Open the Invoices Due Reminder dialog"), - G_CALLBACK (gnc_plugin_business_cmd_invoices_due_reminder) - }, - { "ExportMenuAction", NULL, N_("E_xport"), NULL, NULL, NULL }, - - /* Extensions Menu */ - { "BusinessTestAction", NULL, N_("_Business"), NULL, NULL, NULL }, - { - "BusinessTestSearchAction", NULL, N_("Test Search Dialog"), NULL, - N_("Test Search Dialog"), - G_CALLBACK (gnc_plugin_business_cmd_test_search) - }, - { - "BusinessTestInitDataAction", NULL, N_("Initialize Test Data"), NULL, - N_("Initialize Test Data"), - G_CALLBACK (gnc_plugin_business_cmd_test_init_data) - }, - - /* Toolbar */ - { - "ToolbarNewInvoiceAction", GNC_ICON_INVOICE_NEW, N_("New _Invoice…"), NULL, - N_("Open the New Invoice dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_new_invoice) - }, - - /* Register popup menu */ - { - "RegisterAssignPayment", NULL, N_("Assign as payment…"), NULL, - N_("Assign the selected transaction as payment"), - G_CALLBACK (gnc_plugin_business_cmd_assign_payment) - }, - { - "RegisterEditPayment", NULL, N_("Edit payment…"), NULL, - N_("Edit the payment this transaction is a part of"), - G_CALLBACK (gnc_plugin_business_cmd_assign_payment) - }, + { "BusinessTestSearchAction", gnc_plugin_business_cmd_test_search, NULL, NULL, NULL }, + { "BusinessTestInitDataAction", gnc_plugin_business_cmd_test_init_data, NULL, NULL, NULL }, + { "ToolbarNewInvoiceAction", gnc_plugin_business_cmd_customer_new_invoice, NULL, NULL, NULL }, + { "RegisterAssignPayment", gnc_plugin_business_cmd_assign_payment, NULL, NULL, NULL }, + { "RegisterEditPayment", gnc_plugin_business_cmd_assign_payment, NULL, NULL, NULL }, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "BusinessPlaceholder0", + "BusinessPlaceholder1", + "ExtensionsPlaceholder0", + NULL, +}; /************************************************************ * Plugin Function Implementation * @@ -387,10 +224,11 @@ gnc_plugin_business_class_init (GncPluginBusinessClass *klass) plugin_class->add_to_window = gnc_plugin_business_add_to_window; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void @@ -432,9 +270,11 @@ gnc_plugin_business_get_window() ************************************************************/ static void -gnc_plugin_business_cmd_customer_page (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_page (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginPage *page; g_return_if_fail (mw != NULL); @@ -445,9 +285,12 @@ gnc_plugin_business_cmd_customer_page (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_new_customer (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_new_customer (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; + g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -455,9 +298,11 @@ gnc_plugin_business_cmd_customer_new_customer (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_find_customer (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_find_customer (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; GncCustomer*customer; @@ -472,9 +317,11 @@ gnc_plugin_business_cmd_customer_find_customer (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_new_invoice (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_new_invoice (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -488,9 +335,11 @@ gnc_plugin_business_cmd_customer_new_invoice (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_find_invoice (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_find_invoice (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -504,9 +353,11 @@ gnc_plugin_business_cmd_customer_find_invoice (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_new_job (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_new_job (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -519,9 +370,11 @@ gnc_plugin_business_cmd_customer_new_job (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_find_job (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_find_job (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -534,9 +387,11 @@ gnc_plugin_business_cmd_customer_find_job (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_process_payment (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_process_payment (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -549,9 +404,11 @@ gnc_plugin_business_cmd_customer_process_payment (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_page (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_page (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginPage *page; g_return_if_fail (mw != NULL); @@ -562,9 +419,11 @@ gnc_plugin_business_cmd_vendor_page (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_new_vendor (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_new_vendor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -572,9 +431,11 @@ gnc_plugin_business_cmd_vendor_new_vendor (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_find_vendor (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_find_vendor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; GncVendor *vendor; @@ -589,9 +450,11 @@ gnc_plugin_business_cmd_vendor_find_vendor (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_new_bill (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_new_bill (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -605,9 +468,11 @@ gnc_plugin_business_cmd_vendor_new_bill (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_find_bill (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_find_bill (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -621,9 +486,11 @@ gnc_plugin_business_cmd_vendor_find_bill (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_new_job (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_new_job (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -636,9 +503,11 @@ gnc_plugin_business_cmd_vendor_new_job (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_find_job (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_find_job (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -651,9 +520,11 @@ gnc_plugin_business_cmd_vendor_find_job (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_process_payment (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_process_payment (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -666,9 +537,11 @@ gnc_plugin_business_cmd_vendor_process_payment (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_page (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_page (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginPage *page; g_return_if_fail (mw != NULL); @@ -679,9 +552,11 @@ gnc_plugin_business_cmd_employee_page (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_new_employee (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_new_employee (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -689,9 +564,11 @@ gnc_plugin_business_cmd_employee_new_employee (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_find_employee (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_find_employee (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; GncEmployee *employee; @@ -706,9 +583,11 @@ gnc_plugin_business_cmd_employee_find_employee (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_new_expense_voucher (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_new_expense_voucher (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -722,9 +601,11 @@ gnc_plugin_business_cmd_employee_new_expense_voucher (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_find_expense_voucher (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_find_expense_voucher (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -738,9 +619,11 @@ gnc_plugin_business_cmd_employee_find_expense_voucher (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_process_payment (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_process_payment (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -753,9 +636,11 @@ gnc_plugin_business_cmd_employee_process_payment (GtkAction *action, } static void -gnc_plugin_business_cmd_doclink (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_doclink (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -763,9 +648,11 @@ gnc_plugin_business_cmd_doclink (GtkAction *action, } static void -gnc_plugin_business_cmd_tax_tables (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_tax_tables (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -773,9 +660,11 @@ gnc_plugin_business_cmd_tax_tables (GtkAction *action, } static void -gnc_plugin_business_cmd_billing_terms (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_billing_terms (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -784,9 +673,11 @@ gnc_plugin_business_cmd_billing_terms (GtkAction *action, static void -gnc_plugin_business_cmd_bills_due_reminder (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_bills_due_reminder (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -795,9 +686,11 @@ gnc_plugin_business_cmd_bills_due_reminder (GtkAction *action, static void -gnc_plugin_business_cmd_invoices_due_reminder (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_invoices_due_reminder (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -805,15 +698,18 @@ gnc_plugin_business_cmd_invoices_due_reminder (GtkAction *action, } static void -gnc_plugin_business_cmd_test_search (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_business_cmd_test_search (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; gnc_search_dialog_test(); } -static void gnc_business_assign_payment (GtkWindow *parent, - Transaction *trans, - GncOwner *owner) +static void +gnc_business_assign_payment (GtkWindow *parent, + Transaction *trans, + GncOwner *owner) { g_return_if_fail(trans); @@ -825,9 +721,12 @@ static void gnc_business_assign_payment (GtkWindow *parent, gnc_ui_payment_new_with_txn(parent, owner, trans); } -static void gnc_plugin_business_cmd_assign_payment (GtkAction *action, - GncMainWindowActionData *mw) +static void +gnc_plugin_business_cmd_assign_payment (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin_business; GncPluginBusinessPrivate *plugin_business_priv; GncPluginPage *plugin_page; @@ -892,8 +791,7 @@ static const gchar *register_bus_txn_actions[] = static void gnc_plugin_business_update_menus (GncPluginPage *plugin_page) { - GncMainWindow *window; - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; gboolean is_txn_register, is_bus_txn = FALSE, is_bus_doc = FALSE; // We continue only if the current page is a plugin page @@ -904,11 +802,14 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) if (!GNC_IS_MAIN_WINDOW(plugin_page->window)) return; + // We are readonly - we have already set particular actions to inactive. + if (qof_book_is_readonly (gnc_get_current_book())) + return; + is_txn_register = GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page); - window = GNC_MAIN_WINDOW(plugin_page->window); - g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); - action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); - g_return_if_fail(GTK_IS_ACTION_GROUP(action_group)); + simple_action_group = gnc_main_window_get_action_group (GNC_MAIN_WINDOW(plugin_page->window), + PLUGIN_ACTIONS_NAME); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); if (is_txn_register) { @@ -918,35 +819,48 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) is_bus_doc = (xaccTransGetTxnType (trans) == TXN_TYPE_INVOICE); } // Change visibility and also sensitivity according to whether we are in a txn register - gnc_plugin_update_actions (action_group, register_txn_actions, - "sensitive", is_txn_register && !is_bus_txn && !is_bus_doc); - gnc_plugin_update_actions (action_group, register_txn_actions, - "visible", is_txn_register && !is_bus_txn && !is_bus_doc); - gnc_plugin_update_actions (action_group, register_bus_txn_actions, - "sensitive", is_txn_register && is_bus_txn && !is_bus_doc); - gnc_plugin_update_actions (action_group, register_bus_txn_actions, - "visible", is_txn_register && is_bus_txn && !is_bus_doc); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), register_txn_actions, + is_txn_register && !is_bus_txn && !is_bus_doc); + + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), register_bus_txn_actions, + is_txn_register && is_bus_txn && !is_bus_doc); } - -static void gnc_plugin_business_main_window_page_changed(GncMainWindow *window, - GncPluginPage *page, - gpointer user_data) +static void +gnc_plugin_business_main_window_page_changed (GncMainWindow *window, + GncPluginPage *page, + gpointer user_data) { - gnc_plugin_business_update_menus(page); update_inactive_actions(page); + gnc_plugin_business_update_menus(page); } +static void +gnc_plugin_business_main_window_menu_changed (GncMainWindow *window, + GncPluginPage *page, + gpointer user_data) +{ + // page could be NULL when gnucash started with --nofile + if (page == gnc_main_window_get_current_page (window)) + { + if (page) + gnc_plugin_business_main_window_page_changed (window, page, user_data); + bind_extra_toolbuttons_visibility (window); + } +} -void gnc_plugin_business_split_reg_ui_update (GncPluginPage *plugin_page) +void +gnc_plugin_business_split_reg_ui_update (GncPluginPage *plugin_page) { gnc_plugin_business_main_window_page_changed(NULL, plugin_page, NULL); } static void -gnc_plugin_business_cmd_test_init_data (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_business_cmd_test_init_data (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; QofBook *book = gnc_get_current_book(); GncCustomer *customer = gncCustomerCreate(book); GncAddress *address = gncCustomerGetAddr(customer); @@ -1011,7 +925,7 @@ gnc_plugin_business_cmd_test_init_data (GtkAction *action, gnc_account_append_child(root, tax_acct); // Launch the invoice editor - gnc_ui_invoice_edit (GTK_WINDOW (data->window), invoice); + gnc_ui_invoice_edit (GTK_WINDOW (mw->window), invoice); } /* This is the list of actions which are switched inactive in a read-only book. */ @@ -1035,10 +949,11 @@ static const gchar* readonly_inactive_actions[] = NULL }; -static void update_inactive_actions(GncPluginPage *plugin_page) +static void +update_inactive_actions (GncPluginPage *plugin_page) { - GncMainWindow *window; - GtkActionGroup *action_group; + GncMainWindow *window; + GSimpleActionGroup *simple_action_group; // We are readonly - so we have to switch particular actions to inactive. gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book()); @@ -1053,12 +968,12 @@ static void update_inactive_actions(GncPluginPage *plugin_page) window = GNC_MAIN_WINDOW(plugin_page->window); g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); - action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); - g_return_if_fail(GTK_IS_ACTION_GROUP(action_group)); + simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (action_group, readonly_inactive_actions, - "sensitive", is_readwrite); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), readonly_inactive_actions, + is_readwrite); } /* This is the list of actions which are switched invisible or visible @@ -1071,24 +986,48 @@ static const char* extra_toolbar_actions[] = /* Bind the visibility of the extra toolbar buttons to the * enable_toolbuttons preference. */ -static void bind_toolbuttons_visibility (GncMainWindow *mainwindow) +static void +bind_extra_toolbuttons_visibility (GncMainWindow *mainwindow) { - GtkActionGroup *action_group; + GtkWidget *toolbar; const char **iter; - g_return_if_fail(mainwindow); - g_return_if_fail(GNC_IS_MAIN_WINDOW(mainwindow)); + g_return_if_fail (mainwindow); + g_return_if_fail (GNC_IS_MAIN_WINDOW(mainwindow)); - /* Get the action group */ - action_group = - gnc_main_window_get_action_group(mainwindow, PLUGIN_ACTIONS_NAME); - g_assert(action_group); + toolbar = gnc_window_get_toolbar (GNC_WINDOW(mainwindow)); + if (!toolbar) + return; + + // Set the 'extra' tool items visibility for (iter = extra_toolbar_actions; *iter; ++iter) { - /* Set the action's visibility */ - GtkAction *action = gtk_action_group_get_action (action_group, *iter); - gnc_prefs_bind (GNC_PREFS_GROUP_INVOICE, GNC_PREF_EXTRA_TOOLBUTTONS, G_OBJECT (action), "visible"); + GtkWidget *tool_item = gnc_find_toolbar_item (toolbar, *iter); + + if (tool_item) + { + gnc_prefs_bind (GNC_PREFS_GROUP_INVOICE, + GNC_PREF_EXTRA_TOOLBUTTONS, + G_OBJECT(tool_item), "visible"); + } + } + + // Set the 'extra' tool item separator visibility + for (gint i = 0; i < gtk_toolbar_get_n_items (GTK_TOOLBAR(toolbar)); i++) + { + GtkToolItem *tool_item = gtk_toolbar_get_nth_item (GTK_TOOLBAR(toolbar), i); + + if (GTK_IS_SEPARATOR_TOOL_ITEM(tool_item)) + { + if (g_str_has_prefix (gtk_buildable_get_name (GTK_BUILDABLE(tool_item)), + "extra_separator")) + { + gnc_prefs_bind (GNC_PREFS_GROUP_INVOICE, + GNC_PREF_EXTRA_TOOLBUTTONS, + G_OBJECT(tool_item), "visible"); + } + } } } @@ -1098,15 +1037,18 @@ static void bind_toolbuttons_visibility (GncMainWindow *mainwindow) * * Update the toolbar button visibility each time our plugin is added * to a new GncMainWindow. */ -static void gnc_plugin_business_add_to_window (GncPlugin *plugin, - GncMainWindow *mainwindow, - GQuark type) +static void +gnc_plugin_business_add_to_window (GncPlugin *plugin, + GncMainWindow *mainwindow, + GQuark type) { - bind_toolbuttons_visibility (mainwindow); + g_signal_connect (mainwindow, "page_changed", + G_CALLBACK(gnc_plugin_business_main_window_page_changed), + plugin); - g_signal_connect(mainwindow, "page_changed", - G_CALLBACK(gnc_plugin_business_main_window_page_changed), - plugin); + g_signal_connect (mainwindow, "menu_changed", + G_CALLBACK(gnc_plugin_business_main_window_menu_changed), + plugin); } static const char* invoice_printreport_values[] = @@ -1123,7 +1065,8 @@ static const char* invoice_printreport_values[] = NULL }; -const char *gnc_plugin_business_get_invoice_printreport(void) +const char * +gnc_plugin_business_get_invoice_printreport (void) { int value = gnc_prefs_get_int (GNC_PREFS_GROUP_INVOICE, GNC_PREF_INV_PRINT_RPT); if (value >= 0 && value < 4) diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index e24e93b99e..e5b1e9f127 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -47,6 +47,7 @@ #include "dialog-transfer.h" #include "dialog-utils.h" #include "assistant-hierarchy.h" +#include "assistant-stock-transaction.h" #include "gnc-account-sel.h" #include "gnc-component-manager.h" #include "gnc-engine.h" @@ -136,44 +137,43 @@ static GncPluginPage *gnc_plugin_page_account_tree_recreate_page (GtkWidget *win /* Callbacks */ static void gnc_plugin_page_account_tree_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data); -static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - GncPluginPage *page); -static void gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *col, - GncPluginPageAccountTree *page); +static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget, GdkEventButton *event, GncPluginPage *page); +static void gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *treeview, + GtkTreePath *path, + GtkTreeViewColumn *col, + GncPluginPageAccountTree *page); static void gnc_plugin_page_account_tree_selection_changed_cb (GtkTreeSelection *selection, - GncPluginPageAccountTree *page); + GncPluginPageAccountTree *page); void gppat_populate_trans_mas_list(GtkToggleButton *sa_mrb, GtkWidget *dialog); void gppat_set_insensitive_iff_rb_active(GtkWidget *widget, GtkToggleButton *b); /* Command callbacks */ -static void gnc_plugin_page_account_tree_cmd_new_account (GtkAction *action, GncPluginPageAccountTree *plugin_page); -static void gnc_plugin_page_account_tree_cmd_file_new_hierarchy (GtkAction *action, GncPluginPageAccountTree *plugin_page); -static void gnc_plugin_page_account_tree_cmd_open_account (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_open_subaccounts (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_edit_account (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_find_account (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_find_account_popup (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_renumber_accounts (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action, GncPluginPageAccountTree *plugin_page); -static void gnc_plugin_page_account_tree_cmd_reconcile (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_refresh (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_autoclear (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_transfer (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_stock_split (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_edit_tax_options (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_lots (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_scrub (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_scrub_sub (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_scrub_all (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_cascade_account_properties (GtkAction *action, GncPluginPageAccountTree *page); +static void gnc_plugin_page_account_tree_cmd_new_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_file_new_hierarchy (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_open_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_open_subaccounts (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_edit_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_find_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_find_account_popup (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_delete_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_renumber_accounts (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_view_filter_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_reconcile (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_autoclear (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_transfer (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_stock_split (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_stock_assistant (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_lots (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_scrub (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_scrub_sub (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_scrub_all (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_cascade_account_properties (GSimpleAction *simple, GVariant *paramter, gpointer user_data); /* Account Deletion Actions. */ -static int confirm_delete_account (GtkAction *action, +static int confirm_delete_account (GSimpleAction *simple, GncPluginPageAccountTree *page, Account* ta, Account* sta, Account* saa, delete_helper_t delete_res); @@ -185,135 +185,51 @@ static void do_delete_account (Account* account, Account* saa, Account* sta, static guint plugin_page_signals[LAST_SIGNAL] = { 0 }; -static GtkActionEntry gnc_plugin_page_account_tree_actions [] = +static GActionEntry gnc_plugin_page_account_tree_actions [] = { - /* Toplevel */ - { "FakeToplevel", NULL, "", NULL, NULL, NULL }, - - /* File menu */ - { - "FileNewAccountAction", GNC_ICON_NEW_ACCOUNT, N_("New _Account…"), NULL, - N_("Create a new Account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_new_account) - }, - { - "FileAddAccountHierarchyAssistantAction", GNC_ICON_NEW_ACCOUNT, N_("New Account _Hierarchy…"), NULL, - N_("Extend the current book by merging with new account type categories"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_file_new_hierarchy) - }, - { - "FileOpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _Account"), NULL, - N_("Open the selected account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_open_account) - }, - - { - "FileOpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _SubAccounts"), NULL, - N_("Open the selected account and all its subaccounts"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_open_subaccounts) - }, - - /* Edit menu */ - { - "EditEditAccountAction", GNC_ICON_EDIT_ACCOUNT, N_("Edit _Account"), "e", - N_("Edit the selected account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_edit_account) - }, - { - "EditDeleteAccountAction", GNC_ICON_DELETE_ACCOUNT, N_("_Delete Account…"), "Delete", - N_("Delete selected account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_delete_account) - }, - { - "EditCascadeAccountAction", NULL, N_("_Cascade Account Properties…"), NULL, - N_("Cascade selected properties for account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_cascade_account_properties) - }, - { - "EditFindAccountAction", "edit-find", N_("F_ind Account"), "i", - N_("Find an account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_find_account) - }, - { - "EditFindAccountPopupAction", "edit-find", N_("F_ind Account"), "i", - N_("Find an account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_find_account_popup) - }, - { - "EditRenumberSubaccountsAction", NULL, N_("_Renumber Subaccounts…"), NULL, - N_("Renumber the children of the selected account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_renumber_accounts) - }, - { - "EditTaxOptionsAction", NULL, - /* Translators: remember to reuse this - translation in dialog-account.glade */ - N_("Ta_x Report Options"), NULL, - /* Translators: currently implemented are - US: income tax and - DE: VAT - So adjust this string */ - N_("Setup relevant accounts for tax reports, e.g. US income tax"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_edit_tax_options) - }, - /* View menu */ - { - "ViewFilterByAction", NULL, N_("_Filter By…"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_account_tree_cmd_view_filter_by) - }, - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_refresh) - }, - - /* Actions menu */ - { - "ActionsReconcileAction", NULL, N_("_Reconcile…"), NULL, - N_("Reconcile the selected account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_reconcile) - }, - { - "ActionsAutoClearAction", NULL, N_("_Auto-clear…"), NULL, - N_("Automatically clear individual transactions, given a cleared amount"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_autoclear) - }, - { - "ActionsTransferAction", NULL, N_("_Transfer…"), "t", - N_("Transfer funds from one account to another"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_transfer) - }, - { - "ActionsStockSplitAction", NULL, N_("Stoc_k Split…"), NULL, - N_("Record a stock split or a stock merger"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_stock_split) - }, - { - "ActionsLotsAction", NULL, N_("View _Lots…"), NULL, - N_("Bring up the lot viewer/editor window"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_lots) - }, - { - "ScrubAction", NULL, N_("Check & Repair A_ccount"), NULL, - N_("Check for and repair unbalanced transactions and orphan splits " "in this account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_scrub) - }, - { - "ScrubSubAction", NULL, N_("Check & Repair Su_baccounts"), NULL, - N_("Check for and repair unbalanced transactions and orphan splits " - "in this account and its subaccounts"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_scrub_sub) - }, - { - "ScrubAllAction", NULL, N_("Check & Repair A_ll"), NULL, - N_("Check for and repair unbalanced transactions and orphan splits " "in all accounts"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_scrub_all) - }, - /* Extensions Menu */ - { "Register2TestAction", NULL, N_("_Register2"), NULL, NULL, NULL }, + { "FileNewAccountAction", gnc_plugin_page_account_tree_cmd_new_account, NULL, NULL, NULL }, + { "FileAddAccountHierarchyAssistantAction", gnc_plugin_page_account_tree_cmd_file_new_hierarchy, NULL, NULL, NULL }, + { "EditOpenAccountAction", gnc_plugin_page_account_tree_cmd_open_account, NULL, NULL, NULL }, + { "EditOpenSubaccountsAction", gnc_plugin_page_account_tree_cmd_open_subaccounts, NULL, NULL, NULL }, + { "EditEditAccountAction", gnc_plugin_page_account_tree_cmd_edit_account, NULL, NULL, NULL }, + { "EditDeleteAccountAction", gnc_plugin_page_account_tree_cmd_delete_account, NULL, NULL, NULL }, + { "EditCascadeAccountAction", gnc_plugin_page_account_tree_cmd_cascade_account_properties, NULL, NULL, NULL }, + { "EditFindAccountAction", gnc_plugin_page_account_tree_cmd_find_account, NULL, NULL, NULL }, + { "EditFindAccountPopupAction", gnc_plugin_page_account_tree_cmd_find_account_popup, NULL, NULL, NULL }, + { "EditRenumberSubaccountsAction", gnc_plugin_page_account_tree_cmd_renumber_accounts, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_account_tree_cmd_edit_tax_options, NULL, NULL, NULL }, + { "ViewFilterByAction", gnc_plugin_page_account_tree_cmd_view_filter_by, NULL, NULL, NULL }, + { "ViewRefreshAction", gnc_plugin_page_account_tree_cmd_refresh, NULL, NULL, NULL }, + { "ActionsReconcileAction", gnc_plugin_page_account_tree_cmd_reconcile, NULL, NULL, NULL }, + { "ActionsAutoClearAction", gnc_plugin_page_account_tree_cmd_autoclear, NULL, NULL, NULL }, + { "ActionsTransferAction", gnc_plugin_page_account_tree_cmd_transfer, NULL, NULL, NULL }, + { "ActionsStockSplitAction", gnc_plugin_page_account_tree_cmd_stock_split, NULL, NULL, NULL }, + { "ActionsStockAssistantAction", gnc_plugin_page_account_tree_cmd_stock_assistant, NULL, NULL, NULL }, + { "ActionsLotsAction", gnc_plugin_page_account_tree_cmd_lots, NULL, NULL, NULL }, + { "ScrubAction", gnc_plugin_page_account_tree_cmd_scrub, NULL, NULL, NULL }, + { "ScrubSubAction", gnc_plugin_page_account_tree_cmd_scrub_sub, NULL, NULL, NULL }, + { "ScrubAllAction", gnc_plugin_page_account_tree_cmd_scrub_all, NULL, NULL, NULL }, }; /** The number of actions provided by this plugin. */ -static guint gnc_plugin_page_account_tree_n_actions = G_N_ELEMENTS (gnc_plugin_page_account_tree_actions); +static guint gnc_plugin_page_account_tree_n_actions = G_N_ELEMENTS(gnc_plugin_page_account_tree_actions); + +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder3", + "EditPlaceholder1", + "EditPlaceholder2", + "EditPlaceholder3", + "EditPlaceholder5", + "ViewPlaceholder1", + "ViewPlaceholder4", + "ActionsPlaceholder4", + "ActionsPlaceholder5", + "ActionsPlaceholder6", + NULL, +}; + + /** Actions that require an account to be selected before they are @@ -340,12 +256,18 @@ static const gchar *actions_requiring_subaccounts_rw[] = * enabled. Those actions can be selected even if the book is in readonly mode. */ static const gchar *actions_requiring_account_always[] = { - "FileOpenAccountAction", - "FileOpenSubaccountsAction", + "EditOpenAccountAction", + "EditOpenSubaccountsAction", "ActionsLotsAction", NULL }; +static const gchar* actions_requiring_priced_account[] = +{ + "ActionsStockAssistantAction", + NULL +}; + /* This is the list of actions which are switched inactive in a read-only book. */ static const gchar* readonly_inactive_actions[] = { @@ -364,12 +286,12 @@ static const gchar* readonly_inactive_actions[] = }; /** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = +static GncToolBarShortNames toolbar_labels[] = { - { "FileOpenAccountAction", N_("Open") }, - { "EditEditAccountAction", N_("Edit") }, - { "FileNewAccountAction", N_("New") }, - { "EditDeleteAccountAction", N_("Delete") }, + { "EditOpenAccountAction", N_("Open") }, + { "EditEditAccountAction", N_("Edit") }, + { "FileNewAccountAction", N_("New") }, + { "EditDeleteAccountAction", N_("Delete") }, { NULL, NULL }, }; @@ -468,7 +390,7 @@ gnc_plugin_page_account_tree_class_init (GncPluginPageAccountTreeClass *klass) static void gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group = NULL; GncPluginPageAccountTreePrivate *priv; GncPluginPage *parent; const GList *page_list; @@ -478,35 +400,31 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) /* Init parent declared variables */ parent = GNC_PLUGIN_PAGE(plugin_page); - g_object_set(G_OBJECT(plugin_page), - "page-name", _("Accounts"), - "page-uri", "default:", - "ui-description", "gnc-plugin-page-account-tree-ui.xml", - NULL); + g_object_set (G_OBJECT(plugin_page), + "page-name", _("Accounts"), + "ui-description", "gnc-plugin-page-account-tree.ui", + NULL); g_signal_connect (G_OBJECT (plugin_page), "selected", G_CALLBACK (gnc_plugin_page_account_tree_selected), plugin_page); /* change me when the system supports multiple books */ - gnc_plugin_page_add_book(parent, gnc_get_current_book()); + gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Is this the first accounts page? */ page_list = - gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME); + gnc_gobject_tracking_get_list (GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME); if (!page_list || plugin_page == page_list->data) { - g_object_set_data(G_OBJECT(plugin_page), PLUGIN_PAGE_IMMUTABLE, - GINT_TO_POINTER(1)); + g_object_set_data (G_OBJECT(plugin_page), PLUGIN_PAGE_IMMUTABLE, + GINT_TO_POINTER(1)); } /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group(parent, - "GncPluginPageAccountTreeActions"); - gtk_action_group_add_actions(action_group, - gnc_plugin_page_account_tree_actions, - gnc_plugin_page_account_tree_n_actions, - plugin_page); - gnc_plugin_init_short_names (action_group, toolbar_labels); + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageAccountTreeActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_account_tree_actions, + gnc_plugin_page_account_tree_n_actions, + plugin_page); /* Visible types */ priv->fd.visible_types = -1; /* Start with all types */ @@ -516,7 +434,7 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) priv->fd.filter_override = g_hash_table_new (g_direct_hash, g_direct_equal); LEAVE("page %p, priv %p, action group %p", - plugin_page, priv, action_group); + plugin_page, priv, simple_action_group); } static void @@ -625,6 +543,24 @@ gnc_plugin_page_account_tree_focus_widget (GncPluginPage *account_plugin_page) GncPluginPageAccountTreePrivate *priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(account_plugin_page); GtkTreeView *view = GTK_TREE_VIEW(priv->tree_view); + /* Disable the Transaction Menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(account_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(account_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(account_plugin_page->window), + account_plugin_page, + gnc_plugin_load_ui_items); + + // setup any short toolbar names + gnc_main_window_init_short_names (GNC_MAIN_WINDOW(account_plugin_page->window), toolbar_labels); + + /* Disable the FilePrintAction */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(account_plugin_page->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + if (!gtk_widget_is_focus (GTK_WIDGET(view))) gtk_widget_grab_focus (GTK_WIDGET(view)); } @@ -662,22 +598,22 @@ static void gnc_plugin_page_account_editing_started_cd (gpointer various, GncPluginPageRegister *page) { GncPluginPage *plugin_page = GNC_PLUGIN_PAGE(page); - GtkAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), - "EditDeleteAccountAction"); + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), + "EditDeleteAccountAction"); if (action != NULL) - gtk_action_set_sensitive (action, FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); } static void gnc_plugin_page_account_editing_finished_cb (gpointer various, GncPluginPageRegister *page) { GncPluginPage *plugin_page = GNC_PLUGIN_PAGE(page); - GtkAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), - "EditDeleteAccountAction"); + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), + "EditDeleteAccountAction"); if (action != NULL) - gtk_action_set_sensitive (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); } static GtkWidget * @@ -841,12 +777,13 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page) LEAVE("widget destroyed"); } -static void update_inactive_actions(GncPluginPage *plugin_page) +static void +update_inactive_actions (GncPluginPage *plugin_page) { GncPluginPageAccountTreePrivate *priv; - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group = NULL; Account *account = NULL; - gboolean allow_write = !qof_book_is_readonly(gnc_get_current_book()); + gboolean allow_write = !qof_book_is_readonly (gnc_get_current_book()); gboolean has_account = FALSE; gboolean subaccounts = FALSE; @@ -863,18 +800,21 @@ static void update_inactive_actions(GncPluginPage *plugin_page) } /* Get the action group */ - action_group = gnc_plugin_page_get_action_group(plugin_page); - g_return_if_fail(GTK_IS_ACTION_GROUP (action_group)); + simple_action_group = gnc_plugin_page_get_action_group (plugin_page); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP (simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (action_group, readonly_inactive_actions, - "sensitive", allow_write); - gnc_plugin_update_actions (action_group, actions_requiring_account_rw, - "sensitive", allow_write && has_account); - gnc_plugin_update_actions (action_group, actions_requiring_account_always, - "sensitive", has_account); - gnc_plugin_update_actions (action_group, actions_requiring_subaccounts_rw, - "sensitive", allow_write && subaccounts); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), readonly_inactive_actions, + allow_write); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_account_rw, + allow_write && has_account); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_account_always, + has_account); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_subaccounts_rw, + allow_write && subaccounts); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_priced_account, + account && xaccAccountIsPriced (account)); + g_signal_emit (plugin_page, plugin_page_signals[ACCOUNT_SELECTED], 0, account); } @@ -882,7 +822,8 @@ static void update_inactive_actions(GncPluginPage *plugin_page) * Called when this page is selected. * * Update the toolbar button sensitivity. */ -static void gnc_plugin_page_account_tree_selected (GObject *object, gpointer user_data) +static void +gnc_plugin_page_account_tree_selected (GObject *object, gpointer user_data) { GncPluginPage *plugin_page = GNC_PLUGIN_PAGE (object); g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page)); @@ -934,8 +875,8 @@ gnc_plugin_page_account_tree_save_page (GncPluginPage *plugin_page, * @param group_name The group name to use when restoring data. */ static GncPluginPage * gnc_plugin_page_account_tree_recreate_page (GtkWidget *window, - GKeyFile *key_file, - const gchar *group_name) + GKeyFile *key_file, + const gchar *group_name) { GncPluginPageAccountTree *account_page; GncPluginPageAccountTreePrivate *priv; @@ -963,7 +904,9 @@ gnc_plugin_page_account_tree_recreate_page (GtkWidget *window, /* Callbacks */ static void -gnc_plugin_page_account_tree_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data) +gnc_plugin_page_account_tree_summarybar_position_changed (gpointer prefs, + gchar* pref, + gpointer user_data) { GncPluginPage *plugin_page; GncPluginPageAccountTree *page; @@ -993,8 +936,8 @@ gnc_plugin_page_account_tree_summarybar_position_changed(gpointer prefs, gchar* * registered in gnc-main-window.c. */ static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - GncPluginPage *page) + GdkEventButton *event, + GncPluginPage *page) { g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE); @@ -1028,9 +971,9 @@ gppat_open_account_common (GncPluginPageAccountTree *page, static void gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *col, - GncPluginPageAccountTree *page) + GtkTreePath *path, + GtkTreeViewColumn *col, + GncPluginPageAccountTree *page) { GtkTreeModel *model; GtkTreeIter iter; @@ -1076,8 +1019,11 @@ gnc_plugin_page_account_tree_selection_changed_cb (GtkTreeSelection *selection, /* Command callbacks */ static void -gnc_plugin_page_account_tree_cmd_new_account (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_new_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = gnc_plugin_page_account_tree_get_current_account (page); GtkWindow *parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); gnc_ui_new_account_window (parent, gnc_get_current_book(), @@ -1085,15 +1031,20 @@ gnc_plugin_page_account_tree_cmd_new_account (GtkAction *action, GncPluginPageAc } static void -gnc_plugin_page_account_tree_cmd_file_new_hierarchy (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_file_new_hierarchy (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; gnc_ui_hierarchy_assistant(FALSE); } static void -gnc_plugin_page_account_tree_cmd_open_account (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_open_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account; g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page)); @@ -1102,9 +1053,11 @@ gnc_plugin_page_account_tree_cmd_open_account (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_open_subaccounts (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_open_subaccounts (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account; g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page)); @@ -1113,11 +1066,14 @@ gnc_plugin_page_account_tree_cmd_open_subaccounts (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_edit_account (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_edit_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account; GtkWindow *parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); - ENTER("action %p, page %p", action, page); + ENTER("action %p, page %p", simple, page); account = gnc_plugin_page_account_tree_get_current_account (page); g_return_if_fail (account != NULL); @@ -1127,11 +1083,14 @@ gnc_plugin_page_account_tree_cmd_edit_account (GtkAction *action, GncPluginPageA } static void -gnc_plugin_page_account_tree_cmd_find_account (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_find_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GtkWidget *window; - ENTER("action %p, page %p", action, page); + ENTER("action %p, page %p", simple, page); window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page)); @@ -1140,12 +1099,15 @@ gnc_plugin_page_account_tree_cmd_find_account (GtkAction *action, GncPluginPageA } static void -gnc_plugin_page_account_tree_cmd_find_account_popup (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_find_account_popup (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = NULL; GtkWidget *window; - ENTER("action %p, page %p", action, page); + ENTER("action %p, page %p", simple, page); account = gnc_plugin_page_account_tree_get_current_account (page); @@ -1156,12 +1118,15 @@ gnc_plugin_page_account_tree_cmd_find_account_popup (GtkAction *action, GncPlugi } static void -gnc_plugin_page_account_tree_cmd_cascade_account_properties (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_cascade_account_properties (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = NULL; GtkWidget *window; - ENTER("action %p, page %p", action, page); + ENTER("action %p, page %p", simple, page); account = gnc_plugin_page_account_tree_get_current_account (page); @@ -1507,8 +1472,11 @@ account_delete_dialog (Account *account, GtkWindow *parent, Adopters* adopt) } static void -gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_delete_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = gnc_plugin_page_account_tree_get_current_account (page); gchar *acct_name; GtkWidget *window; @@ -1579,10 +1547,10 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag adopter_match (&adopt.subtrans, GTK_WINDOW (window))) break; } - filter = g_object_get_data (G_OBJECT (dialog), DELETE_DIALOG_FILTER); + filter = g_object_get_data (G_OBJECT (dialog), DELETE_DIALOG_FILTER); gtk_widget_destroy(dialog); g_list_free(filter); - if (confirm_delete_account (action, page, adopt.trans.new_account, + if (confirm_delete_account (simple, page, adopt.trans.new_account, adopt.subtrans.new_account, adopt.subacct.new_account, adopt.delete_res) == GTK_RESPONSE_ACCEPT) @@ -1593,7 +1561,7 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag } static int -confirm_delete_account (GtkAction *action, GncPluginPageAccountTree *page, +confirm_delete_account (GSimpleAction *simple, GncPluginPageAccountTree *page, Account* ta, Account* sta, Account* saa, delete_helper_t delete_res) { @@ -1678,7 +1646,8 @@ confirm_delete_account (GtkAction *action, GncPluginPageAccountTree *page, return response; } -void do_delete_account (Account* account, Account* saa, Account* sta, Account* ta) +void +do_delete_account (Account* account, Account* saa, Account* sta, Account* ta) { GList *acct_list, *ptr; const GncGUID *guid; @@ -1741,9 +1710,11 @@ void do_delete_account (Account* account, Account* saa, Account* sta, Account* t } static void -gnc_plugin_page_account_tree_cmd_renumber_accounts (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_renumber_accounts (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account; GtkWidget *window; @@ -1756,9 +1727,11 @@ gnc_plugin_page_account_tree_cmd_renumber_accounts (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_refresh (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_refresh (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GncPluginPageAccountTreePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page)); @@ -1772,13 +1745,15 @@ gnc_plugin_page_account_tree_cmd_refresh (GtkAction *action, /*********************/ static void -gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_view_filter_by (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GncPluginPageAccountTreePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page)); - ENTER("(action %p, page %p)", action, page); + ENTER("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page); account_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(page)); @@ -1786,9 +1761,11 @@ gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_reconcile (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_reconcile (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GtkWidget *window; Account *account; RecnWindow *recnData; @@ -1802,9 +1779,11 @@ gnc_plugin_page_account_tree_cmd_reconcile (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_autoclear (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_autoclear (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GtkWidget *window; Account *account; AutoClearWindow *autoClearData; @@ -1818,9 +1797,11 @@ gnc_plugin_page_account_tree_cmd_autoclear (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_transfer (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_transfer (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GtkWidget *window; Account *account; @@ -1830,9 +1811,11 @@ gnc_plugin_page_account_tree_cmd_transfer (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_stock_split (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_stock_split (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GtkWidget *window; Account *account; @@ -1842,9 +1825,30 @@ gnc_plugin_page_account_tree_cmd_stock_split (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_edit_tax_options (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_stock_assistant (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; + Account *account; + GtkWidget *window; + + ENTER ("(action %p, page %p)", simple, page); + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); + account = gnc_plugin_page_account_tree_get_current_account (page); + window = GNC_PLUGIN_PAGE(page)->window; + gnc_stock_transaction_assistant (window, account); + + LEAVE (" "); +} + +static void +gnc_plugin_page_account_tree_cmd_edit_tax_options (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) +{ + GncPluginPageAccountTree *page = user_data; GtkWidget *window; Account *account; @@ -1854,15 +1858,18 @@ gnc_plugin_page_account_tree_cmd_edit_tax_options (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_lots (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_lots (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = gnc_plugin_page_account_tree_get_current_account (page); GtkWidget *window = GNC_PLUGIN_PAGE (page)->window; gnc_lot_viewer_dialog (GTK_WINDOW(window), account); } -static gboolean scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointer data) +static gboolean +scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointer data) { if (event->length == 0) return FALSE; @@ -1885,8 +1892,11 @@ static gboolean scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointe } static void -gnc_plugin_page_account_tree_cmd_scrub (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_scrub (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = gnc_plugin_page_account_tree_get_current_account (page); GncWindow *window; gulong scrub_kp_handler_ID; @@ -1913,8 +1923,11 @@ gnc_plugin_page_account_tree_cmd_scrub (GtkAction *action, GncPluginPageAccountT } static void -gnc_plugin_page_account_tree_cmd_scrub_sub (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_scrub_sub (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = gnc_plugin_page_account_tree_get_current_account (page); GncWindow *window; gulong scrub_kp_handler_ID; @@ -1941,8 +1954,11 @@ gnc_plugin_page_account_tree_cmd_scrub_sub (GtkAction *action, GncPluginPageAcco } static void -gnc_plugin_page_account_tree_cmd_scrub_all (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_scrub_all (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *root = gnc_get_current_root_account (); GncWindow *window; gulong scrub_kp_handler_ID; diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index cd24bf5472..b26502a59c 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -110,95 +110,48 @@ static void gppb_selection_changed_cb (GtkTreeSelection *selection, GncPluginPageBudget *page); #endif -static void gnc_plugin_page_budget_cmd_view_filter_by (GtkAction *action, - GncPluginPageBudget *page); +static void gnc_plugin_page_budget_cmd_view_filter_by (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_open_account (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_open_subaccounts (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_delete_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_view_options (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_estimate_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_allperiods_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_refresh (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_budget_note (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_budget_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_edit_tax_options (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -/* Command Callbacks */ -static void gnc_plugin_page_budget_cmd_open_account (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_open_subaccounts (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_delete_budget (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_view_options (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_estimate_budget (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_allperiods_budget (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_refresh (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_budget_note (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_budget_report (GtkAction *action, - GncPluginPageBudget *page); static void allperiods_budget_helper (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data); -static GtkActionEntry gnc_plugin_page_budget_actions [] = +static GActionEntry gnc_plugin_page_budget_actions [] = { - /* Toplevel */ - { "FakeToplevel", "", NULL, NULL, NULL, NULL }, - - /* File menu */ - { - "OpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _Account"), NULL, - N_("Open the selected account."), - G_CALLBACK(gnc_plugin_page_budget_cmd_open_account) - }, - { - "OpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, - N_("Open _Subaccounts"), NULL, - N_("Open the selected account and all its subaccounts."), - G_CALLBACK(gnc_plugin_page_budget_cmd_open_subaccounts) - }, - - /* Edit menu */ - { - "DeleteBudgetAction", GNC_ICON_DELETE_BUDGET, N_("_Delete Budget…"), - NULL, N_("Select this or another budget and delete it."), - G_CALLBACK(gnc_plugin_page_budget_cmd_delete_budget) - }, - { - "OptionsBudgetAction", "document-properties", N_("Budget _Options…"), - NULL, N_("Edit this budget's options."), - G_CALLBACK(gnc_plugin_page_budget_cmd_view_options) - }, - { - "EstimateBudgetAction", "system-run", N_("Esti_mate Budget…"), - NULL, - N_("Estimate a budget value for the selected accounts from past transactions."), - G_CALLBACK(gnc_plugin_page_budget_cmd_estimate_budget) - }, - { - "AllPeriodsBudgetAction", "system-run", N_("_All Periods…"), - NULL, - N_("Edit budget for all periods for the selected accounts."), - G_CALLBACK(gnc_plugin_page_budget_cmd_allperiods_budget) - }, - { - "BudgetNoteAction", "text-x-generic", N_("Edit Note"), - NULL, - N_("Edit note for the selected account and period."), - G_CALLBACK (gnc_plugin_page_budget_cmd_budget_note) - }, - { - "BudgetReportAction", "system-run", N_("Budget Report"), - NULL, - N_("Run the budget report."), - G_CALLBACK (gnc_plugin_page_budget_cmd_budget_report) - }, - /* View menu */ - { - "ViewFilterByAction", NULL, N_("_Filter By…"), NULL, NULL, - G_CALLBACK(gnc_plugin_page_budget_cmd_view_filter_by) - }, - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window."), - G_CALLBACK(gnc_plugin_page_budget_cmd_refresh) - }, + { "OpenAccountAction", gnc_plugin_page_budget_cmd_open_account, NULL, NULL, NULL }, + { "OpenSubaccountsAction", gnc_plugin_page_budget_cmd_open_subaccounts, NULL, NULL, NULL }, + { "DeleteBudgetAction", gnc_plugin_page_budget_cmd_delete_budget, NULL, NULL, NULL }, + { "OptionsBudgetAction", gnc_plugin_page_budget_cmd_view_options, NULL, NULL, NULL }, + { "EstimateBudgetAction", gnc_plugin_page_budget_cmd_estimate_budget, NULL, NULL, NULL }, + { "AllPeriodsBudgetAction", gnc_plugin_page_budget_cmd_allperiods_budget, NULL, NULL, NULL }, + { "BudgetNoteAction", gnc_plugin_page_budget_cmd_budget_note, NULL, NULL, NULL }, + { "BudgetReportAction", gnc_plugin_page_budget_cmd_budget_report, NULL, NULL, NULL }, + { "ViewFilterByAction", gnc_plugin_page_budget_cmd_view_filter_by, NULL, NULL, NULL }, + { "ViewRefreshAction", gnc_plugin_page_budget_cmd_refresh, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_budget_cmd_edit_tax_options, NULL, NULL, NULL }, +}; +static guint gnc_plugin_page_budget_n_actions = G_N_ELEMENTS(gnc_plugin_page_budget_actions); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder3", + "EditPlaceholder1", + "EditPlaceholder3", + "EditPlaceholder5", + "EditPlaceholder6", + "ViewPlaceholder1", + "ViewPlaceholder4", + NULL, }; static const gchar *writeable_actions[] = @@ -212,9 +165,6 @@ static const gchar *writeable_actions[] = NULL }; -static guint gnc_plugin_page_budget_n_actions = - G_N_ELEMENTS(gnc_plugin_page_budget_actions); - #if 0 static const gchar *actions_requiring_account[] = { @@ -225,7 +175,7 @@ static const gchar *actions_requiring_account[] = #endif /** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = +static GncToolBarShortNames toolbar_labels[] = { { "OpenAccountAction", N_("Open") }, { "DeleteBudgetAction", N_("Delete") }, @@ -247,9 +197,8 @@ typedef enum allperiods_action typedef struct GncPluginPageBudgetPrivate { - GtkActionGroup *action_group; - guint merge_id; - GtkUIManager *ui_merge; + GtkBuilder *builder; + GSimpleActionGroup *simple_action_group; GncBudgetView* budget_view; GtkTreeView *tree_view; @@ -348,7 +297,7 @@ gnc_plugin_page_budget_class_init (GncPluginPageBudgetClass *klass) static void gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GncPluginPageBudgetPrivate *priv; GncPluginPage *parent; @@ -359,26 +308,22 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) parent = GNC_PLUGIN_PAGE(plugin_page); g_object_set (G_OBJECT(plugin_page), "page-name", _("Budget"), - "page-uri", "default:", - "ui-description", "gnc-plugin-page-budget-ui.xml", + "ui-description", "gnc-plugin-page-budget.ui", NULL); /* change me when the system supports multiple books */ gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group (parent, - "GncPluginPageBudgetActions"); - gtk_action_group_add_actions (action_group, - gnc_plugin_page_budget_actions, - gnc_plugin_page_budget_n_actions, - plugin_page); - gnc_plugin_init_short_names (action_group, toolbar_labels); + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageBudgetActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_budget_actions, + gnc_plugin_page_budget_n_actions, + plugin_page); if (qof_book_is_readonly (gnc_get_current_book())) - gnc_plugin_update_actions (action_group, writeable_actions, - "sensitive", FALSE); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), writeable_actions, + FALSE); /* Visible types */ priv->fd.visible_types = -1; /* Start with all types */ @@ -392,7 +337,7 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) recurrenceSet (&priv->r, 1, PERIOD_MONTH, NULL, WEEKEND_ADJ_NONE); LEAVE("page %p, priv %p, action group %p", - plugin_page, priv, action_group); + plugin_page, priv, simple_action_group); } @@ -432,6 +377,23 @@ gnc_plugin_page_budget_focus_widget (GncPluginPage *budget_plugin_page) GncBudgetView *budget_view = priv->budget_view; GtkWidget *account_view = gnc_budget_view_get_account_tree_view (budget_view); + /* Disable the Transaction Menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(budget_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(budget_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the FilePrintAction */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(budget_plugin_page->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(budget_plugin_page->window), + budget_plugin_page, + gnc_plugin_load_ui_items); + + // setup any short toolbar names + gnc_main_window_init_short_names (GNC_MAIN_WINDOW(budget_plugin_page->window), toolbar_labels); + if (!gtk_widget_is_focus (GTK_WIDGET(account_view))) gtk_widget_grab_focus (GTK_WIDGET(account_view)); } @@ -721,7 +683,7 @@ static void gppb_selection_changed_cb (GtkTreeSelection *selection, GncPluginPageBudget *page) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GtkTreeView *view; GList *acct_list; gboolean sensitive; @@ -742,9 +704,9 @@ gppb_selection_changed_cb (GtkTreeSelection *selection, g_list_free (acct_list); } - action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); - gnc_plugin_update_actions (action_group, actions_requiring_account, - "sensitive", sensitive); + simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_account, + sensitive); } #endif @@ -753,9 +715,11 @@ gppb_selection_changed_cb (GtkTreeSelection *selection, * Command callbacks * ********************/ static void -gnc_plugin_page_budget_cmd_open_account (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_open_account (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GtkWidget *window; GncPluginPage *new_page; @@ -778,9 +742,11 @@ gnc_plugin_page_budget_cmd_open_account (GtkAction *action, static void -gnc_plugin_page_budget_cmd_open_subaccounts (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_open_subaccounts (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GtkWidget *window; GncPluginPage *new_page; @@ -803,9 +769,11 @@ gnc_plugin_page_budget_cmd_open_subaccounts (GtkAction *action, static void -gnc_plugin_page_budget_cmd_delete_budget (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_delete_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GncBudget *budget; @@ -818,13 +786,47 @@ gnc_plugin_page_budget_cmd_delete_budget (GtkAction *action, } +static void +gnc_plugin_page_budget_cmd_edit_tax_options (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GncPluginPageBudget *page = user_data; + GncPluginPageBudgetPrivate *priv; + GtkTreeSelection *selection; + Account *account = NULL; + GtkWidget *window; + + page = GNC_PLUGIN_PAGE_BUDGET(page); + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_BUDGET(page)); + + ENTER ("(action %p, page %p)", simple, page); + priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); + + selection = gnc_budget_view_get_selection (priv->budget_view); + window = GNC_PLUGIN_PAGE(page)->window; + + if (gtk_tree_selection_count_selected_rows (selection) == 1) + { + GList *acc_list = gnc_budget_view_get_selected_accounts (priv->budget_view); + GList *node = g_list_first (acc_list); + account = acc_list->data; + g_list_free (acc_list); + } + gnc_tax_info_dialog (window, account); + LEAVE (" "); +} + /******************************/ /* Options Dialog */ /******************************/ static void -gnc_plugin_page_budget_cmd_view_options (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_view_options (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GncRecurrence *gr; GtkBuilder *builder; @@ -1019,9 +1021,11 @@ estimate_budget_helper (GtkTreeModel *model, GtkTreePath *path, /* Estimate Dialog */ /*******************************/ static void -gnc_plugin_page_budget_cmd_estimate_budget (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_estimate_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GtkTreeSelection *sel; GtkWidget *dialog, *gde, *dtr, *hb, *avg; @@ -1148,9 +1152,11 @@ allperiods_budget_helper (GtkTreeModel *model, GtkTreePath *path, /* All Periods Value Dialog */ /*******************************/ static void -gnc_plugin_page_budget_cmd_allperiods_budget (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_allperiods_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GtkTreeSelection *sel; GtkWidget *dialog, *gde, *val, *dtr, *add, *mult; @@ -1232,9 +1238,11 @@ gnc_plugin_page_budget_cmd_allperiods_budget (GtkAction *action, } static void -gnc_plugin_page_budget_cmd_budget_note(GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_budget_note (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GtkTreeSelection *sel; GtkWidget *dialog, *note; @@ -1320,9 +1328,11 @@ equal_fn (gpointer find_data, gpointer elt_data) whereby report's report-type matches a budget report, and the report's budget option value matches the current budget. */ static void -gnc_plugin_page_budget_cmd_budget_report (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_budget_report (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; g_return_if_fail (GNC_IS_PLUGIN_PAGE_BUDGET (page)); @@ -1353,13 +1363,15 @@ gnc_plugin_page_budget_cmd_budget_report (GtkAction *action, } static void -gnc_plugin_page_budget_cmd_view_filter_by (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_view_filter_by (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_BUDGET(page)); - ENTER("(action %p, page %p)", action, page); + ENTER("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); account_filter_dialog_create (&priv->fd, GNC_PLUGIN_PAGE(page)); @@ -1368,13 +1380,15 @@ gnc_plugin_page_budget_cmd_view_filter_by (GtkAction *action, } static void -gnc_plugin_page_budget_cmd_refresh (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_refresh (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; g_return_if_fail (GNC_IS_PLUGIN_PAGE_BUDGET(page)); - ENTER("(action %p, page %p)", action, page); + ENTER("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index a0e5b847e6..8721d81a0f 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -46,6 +46,8 @@ #include "dialog-doclink.h" #include "dialog-doclink-utils.h" #include "gncInvoice.h" +#include "gnc-ui.h" +#include "gnc-gtk-utils.h" /* This static indicates the debugging module that this .o belongs to. */ static QofLogModule log_module = GNC_MOD_GUI; @@ -61,197 +63,100 @@ static void gnc_plugin_page_invoice_save_page (GncPluginPage *plugin_page, GKeyF static GncPluginPage *gnc_plugin_page_invoice_recreate_page (GtkWidget *window, GKeyFile *file, const gchar *group); static void gnc_plugin_page_invoice_window_changed (GncPluginPage *plugin_page, GtkWidget *window); -static void gnc_plugin_page_invoice_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data); +static void gnc_plugin_page_invoice_summarybar_position_changed (gpointer prefs, gchar* pref, gpointer user_data); /* Command callbacks */ -static void gnc_plugin_page_invoice_cmd_new_invoice (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_new_account (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_print (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_cut (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_copy (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_paste (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_edit (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_duplicateInvoice (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_post (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_unpost (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_refresh (GtkAction *action, GncPluginPageInvoice *plugin_page); +static void gnc_plugin_page_invoice_cmd_new_invoice (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_new_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_print (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_cut (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_copy (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_paste (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_edit (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_duplicateInvoice (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_post (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_unpost (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_sort_changed (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_enter (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_cancel (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_delete (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_blank (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_duplicateEntry (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_pay_invoice (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_save_layout (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_reset_layout (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_link (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_link_remove (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_link_open (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_company_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_entryUp (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_entryDown (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_edit_tax (GSimpleAction *simple, GVariant *paramter, gpointer user_data); -static void gnc_plugin_page_invoice_cmd_sort_changed (GtkAction *action, - GtkRadioAction *current, - GncPluginPageInvoice *plugin_page); - -static void gnc_plugin_page_invoice_cmd_enter (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_cancel (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_delete (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_blank (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_duplicateEntry (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_pay_invoice (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_save_layout (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_reset_layout (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_link (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_link_remove (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_link_open (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_company_report (GtkAction *action, GncPluginPageInvoice *plugin_page); - -static void gnc_plugin_page_redraw_help_cb( GnucashRegister *gsr, GncPluginPageInvoice *invoice_page ); +static void gnc_plugin_page_redraw_help_cb (GnucashRegister *gsr, GncPluginPageInvoice *invoice_page); static void gnc_plugin_page_invoice_refresh_cb (GHashTable *changes, gpointer user_data); -static void gnc_plugin_page_invoice_cmd_entryUp (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_entryDown (GtkAction *action, GncPluginPageInvoice *plugin_page); + +static void +radio_change_state (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + g_simple_action_set_state (simple, state); +} /************************************************************ * Actions * ************************************************************/ -static GtkActionEntry gnc_plugin_page_invoice_actions [] = +static GActionEntry gnc_plugin_page_invoice_actions [] = { - /* Toplevel */ - { "FakeToplevel", NULL, "", NULL, NULL, NULL }, - { "SortOrderAction", NULL, N_("Sort _Order"), NULL, NULL, NULL }, - - /* File menu */ - { - "FileNewAccountAction", GNC_ICON_NEW_ACCOUNT, N_("New _Account…"), NULL, - N_("Create a new account"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_new_account) - }, - { - "FilePrintAction", "document-print", "_Print Invoice", "p", - "Make a printable invoice", - G_CALLBACK (gnc_plugin_page_invoice_cmd_print) - }, - - /* Edit menu */ - { - "EditCutAction", "edit-cut", N_("_Cut"), "X", - NULL, - G_CALLBACK (gnc_plugin_page_invoice_cmd_cut) - }, - { - "EditCopyAction", "edit-copy", N_("Copy"), "C", - NULL, - G_CALLBACK (gnc_plugin_page_invoice_cmd_copy) - }, - { - "EditPasteAction", "edit-paste", N_("_Paste"), "V", - NULL, - G_CALLBACK (gnc_plugin_page_invoice_cmd_paste) - }, - { - "EditEditInvoiceAction", GNC_ICON_INVOICE_EDIT, "_Edit Invoice", NULL, - "Edit this invoice", - G_CALLBACK (gnc_plugin_page_invoice_cmd_edit) - }, - { - "EditDuplicateInvoiceAction", GNC_ICON_INVOICE_DUPLICATE, "_Duplicate Invoice", - NULL, "Create a new invoice as a duplicate of the current one", - G_CALLBACK (gnc_plugin_page_invoice_cmd_duplicateInvoice) - }, - { - "EditPostInvoiceAction", GNC_ICON_INVOICE_POST, "_Post Invoice", NULL, - "Post this invoice to your Chart of Accounts", - G_CALLBACK (gnc_plugin_page_invoice_cmd_post) - }, - { - "EditUnpostInvoiceAction", GNC_ICON_INVOICE_UNPOST, "_Unpost Invoice", NULL, - "Unpost this invoice and make it editable", - G_CALLBACK (gnc_plugin_page_invoice_cmd_unpost) - }, - - /* View menu */ - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_refresh) - }, - { - "ViewSaveLayoutAction", NULL, "_Use as Default Layout for Customer Documents", NULL, - "Use the current layout as default for all customer invoices and credit notes", - G_CALLBACK (gnc_plugin_page_invoice_cmd_save_layout) - }, - { - "ViewResetLayoutAction", NULL, "_Reset Default Layout for Customer Documents", NULL, - "Reset default layout for all customer invoices and credit notes back to built-in defaults and update the current page accordingly", - G_CALLBACK (gnc_plugin_page_invoice_cmd_reset_layout) - }, - - /* Actions menu */ - { - "RecordEntryAction", "list-add", N_("_Enter"), NULL, - N_("Record the current entry"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_enter) - }, - { - "CancelEntryAction", "process-stop", N_("_Cancel"), NULL, - N_("Cancel the current entry"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_cancel) - }, - { - "DeleteEntryAction", "edit-delete", N_("_Delete"), NULL, - N_("Delete the current entry"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_delete) - }, - { - "BlankEntryAction", "go-bottom", N_("_Blank"), NULL, - "Move to the blank entry at the bottom of the Invoice", - G_CALLBACK (gnc_plugin_page_invoice_cmd_blank) - }, - { - "DuplicateEntryAction", "edit-copy", N_("Dup_licate Entry"), NULL, - N_("Make a copy of the current entry"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_duplicateEntry) - }, - { - "EntryUpAction", "pan-up-symbolic", N_("Move Entry _Up"), NULL, - N_("Move the current entry one row upwards"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_entryUp) - }, - { - "EntryDownAction", "pan-down-symbolic", N_("Move Entry Do_wn"), NULL, - N_("Move the current entry one row downwards"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_entryDown) - }, - - /* Business menu */ - { - "BusinessNewInvoiceAction", GNC_ICON_INVOICE_NEW, "New _Invoice", "", - "Create a new invoice for the same owner as the current one", - G_CALLBACK (gnc_plugin_page_invoice_cmd_new_invoice) - }, - { - "BusinessLinkAction", NULL, "_Manage Document Link…", NULL, - "Manage link of an external document to this item.", - G_CALLBACK (gnc_plugin_page_invoice_cmd_link) - }, - { - "BusinessLinkOpenAction", NULL, "_Open Linked Document", NULL, - "Open the linked document", - G_CALLBACK (gnc_plugin_page_invoice_cmd_link_open) - }, - { - "ToolsProcessPaymentAction", GNC_ICON_INVOICE_PAY, "_Pay Invoice", NULL, - "Enter a payment for the owner of this invoice", - G_CALLBACK (gnc_plugin_page_invoice_cmd_pay_invoice) - }, - - /* Reports menu */ - { - "ReportsCompanyReportAction", NULL, N_("_Company Report"), NULL, - "Open a company report window for the owner of this invoice", - G_CALLBACK (gnc_plugin_page_invoice_cmd_company_report) - }, + { "FileNewAccountAction", gnc_plugin_page_invoice_cmd_new_account, NULL, NULL, NULL }, + { "FilePrintAction", gnc_plugin_page_invoice_cmd_print, NULL, NULL, NULL }, + { "EditCutAction", gnc_plugin_page_invoice_cmd_cut, NULL, NULL, NULL }, + { "EditCopyAction", gnc_plugin_page_invoice_cmd_copy, NULL, NULL, NULL }, + { "EditPasteAction", gnc_plugin_page_invoice_cmd_paste, NULL, NULL, NULL }, + { "EditEditInvoiceAction", gnc_plugin_page_invoice_cmd_edit, NULL, NULL, NULL }, + { "EditDuplicateInvoiceAction", gnc_plugin_page_invoice_cmd_duplicateInvoice, NULL, NULL, NULL }, + { "EditPostInvoiceAction", gnc_plugin_page_invoice_cmd_post, NULL, NULL, NULL }, + { "EditUnpostInvoiceAction", gnc_plugin_page_invoice_cmd_unpost, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_invoice_cmd_edit_tax, NULL, NULL, NULL }, + { "ViewRefreshAction", gnc_plugin_page_invoice_cmd_refresh, NULL, NULL, NULL }, + { "ViewSaveLayoutAction", gnc_plugin_page_invoice_cmd_save_layout, NULL, NULL, NULL }, + { "ViewResetLayoutAction", gnc_plugin_page_invoice_cmd_reset_layout, NULL, NULL, NULL }, + { "RecordEntryAction", gnc_plugin_page_invoice_cmd_enter, NULL, NULL, NULL }, + { "CancelEntryAction", gnc_plugin_page_invoice_cmd_cancel, NULL, NULL, NULL }, + { "DeleteEntryAction", gnc_plugin_page_invoice_cmd_delete, NULL, NULL, NULL }, + { "BlankEntryAction", gnc_plugin_page_invoice_cmd_blank, NULL, NULL, NULL }, + { "DuplicateEntryAction", gnc_plugin_page_invoice_cmd_duplicateEntry, NULL, NULL, NULL }, + { "EntryUpAction", gnc_plugin_page_invoice_cmd_entryUp, NULL, NULL, NULL }, + { "EntryDownAction", gnc_plugin_page_invoice_cmd_entryDown, NULL, NULL, NULL }, + { "BusinessNewInvoiceAction", gnc_plugin_page_invoice_cmd_new_invoice, NULL, NULL, NULL }, + { "BusinessLinkAction", gnc_plugin_page_invoice_cmd_link, NULL, NULL, NULL }, + { "BusinessLinkOpenAction", gnc_plugin_page_invoice_cmd_link_open, NULL, NULL, NULL }, + { "ToolsProcessPaymentAction", gnc_plugin_page_invoice_cmd_pay_invoice, NULL, NULL, NULL }, + { "ReportsCompanyReportAction", gnc_plugin_page_invoice_cmd_company_report, NULL, NULL, NULL }, + { "SortOrderRadioAction", gnc_plugin_page_invoice_cmd_sort_changed, "i", "@i 0", radio_change_state }, }; -static guint gnc_plugin_page_invoice_n_actions = G_N_ELEMENTS (gnc_plugin_page_invoice_actions); +static guint gnc_plugin_page_invoice_n_actions = G_N_ELEMENTS(gnc_plugin_page_invoice_actions); -static GtkRadioActionEntry radio_entries [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - { "SortStandardAction", NULL, N_("_Standard"), NULL, N_("Keep normal invoice order"), INVSORT_BY_STANDARD }, - { "SortDateAction", NULL, N_("_Date"), NULL, N_("Sort by date"), INVSORT_BY_DATE }, - { "SortDateEntryAction", NULL, N_("Date of _Entry"), NULL, N_("Sort by the date of entry"), INVSORT_BY_DATE_ENTERED }, - { "SortQuantityAction", NULL, N_("_Quantity"), NULL, N_("Sort by quantity"), INVSORT_BY_QTY }, - { "SortPriceAction", NULL, N_("_Price"), NULL, N_("Sort by price"), INVSORT_BY_PRICE }, - { "SortDescriptionAction", NULL, N_("Descri_ption"), NULL, N_("Sort by description"), INVSORT_BY_DESC }, + "FilePlaceholder3", + "EditPlaceholder1", + "EditPlaceholder3", + "EditPlaceholder5", + "ViewPlaceholder1", + "ViewPlaceholder2", + "ViewPlaceholder4", + "ActionsPlaceholder4", + "ActionsPlaceholder5", + "BusinessPlaceholder2", + "BusinessPlaceholder3", + "ReportsPlaceholder1", + NULL, }; -static guint n_radio_entries = G_N_ELEMENTS (radio_entries); static const gchar *invoice_book_readwrite_actions[] = { @@ -293,162 +198,98 @@ static const gchar *can_unpost_actions[] = static action_toolbar_labels invoice_action_labels[] = { - {"FilePrintAction", N_("_Print Invoice")}, - {"EditEditInvoiceAction", N_("_Edit Invoice")}, - {"EditDuplicateInvoiceAction", N_("_Duplicate Invoice")}, - {"EditPostInvoiceAction", N_("_Post Invoice")}, - {"EditUnpostInvoiceAction", N_("_Unpost Invoice")}, - {"BusinessNewInvoiceAction", N_("New _Invoice")}, - {"ToolsProcessPaymentAction", N_("_Pay Invoice")}, - {"BusinessLinkAction", N_("_Manage Document Link…")}, - {"BusinessLinkOpenAction", N_("_Open Linked Document")}, - {NULL, NULL}, + {"FilePrintAction", N_("_Print Invoice"), N_("Make a printable invoice")}, + {"EditEditInvoiceAction", N_("_Edit Invoice"), N_("Edit this invoice")}, + {"EditDuplicateInvoiceAction", N_("_Duplicate Invoice"), N_("Create a new invoice as a duplicate of the current one")}, + {"EditPostInvoiceAction", N_("_Post Invoice"), N_("Post this invoice to your Chart of Accounts")}, + {"EditUnpostInvoiceAction", N_("_Unpost Invoice"), N_("Unpost this invoice and make it editable")}, + {"BusinessNewInvoiceAction", N_("New _Invoice"), N_("Create a new invoice for the same owner as the current one")}, + {"BlankEntryAction", N_("Blank"), N_("Move to the blank entry at the bottom of the invoice")}, + {"ToolsProcessPaymentAction", N_("_Pay Invoice"), N_("Enter a payment for the owner of this invoice") }, + {"ReportsCompanyReportAction", N_("_Company Report"), N_("Open a customer report window for the owner of this invoice") }, + {"BusinessLinkAction", N_("_Manage Document Link..."), N_("Manage Document Link")}, + {"BusinessLinkOpenAction", N_("_Open Linked Document"), N_("Open Linked Document")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels invoice_action_layout_labels[] = { - {"ViewSaveLayoutAction", N_("_Use as Default Layout for Customer Documents")}, - {"ViewResetLayoutAction", N_("_Reset Default Layout for Customer Documents")}, - {NULL, NULL}, + {"ViewSaveLayoutAction", N_("_Use as Default Layout for Customer Documents"), + N_("Use the current layout as default for all customer invoices and credit notes")}, + {"ViewResetLayoutAction", N_("_Reset Default Layout for Customer Documents"), + N_("Reset default layout for all customer invoices and credit notes back to built-in defaults and update the current page accordingly")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels bill_action_labels[] = { - {"FilePrintAction", N_("_Print Bill")}, - {"EditEditInvoiceAction", N_("_Edit Bill")}, - {"EditDuplicateInvoiceAction", N_("_Duplicate Bill")}, - {"EditPostInvoiceAction", N_("_Post Bill")}, - {"EditUnpostInvoiceAction", N_("_Unpost Bill")}, - {"BusinessNewInvoiceAction", N_("New _Bill")}, - {"ToolsProcessPaymentAction", N_("_Pay Bill")}, - {"BusinessLinkAction", N_("_Manage Document Link…")}, - {"BusinessLinkOpenAction", N_("_Open Linked Document")}, - {NULL, NULL}, + {"FilePrintAction", N_("_Print Bill"), N_("Make a printable bill")}, + {"EditEditInvoiceAction", N_("_Edit Bill"), N_("Edit this bill")}, + {"EditDuplicateInvoiceAction", N_("_Duplicate Bill"), N_("Create a new bill as a duplicate of the current one")}, + {"EditPostInvoiceAction", N_("_Post Bill"), N_("Post this bill to your Chart of Accounts")}, + {"EditUnpostInvoiceAction", N_("_Unpost Bill"), N_("Unpost this bill and make it editable")}, + {"BusinessNewInvoiceAction", N_("New _Bill"), N_("Create a new bill for the same owner as the current one")}, + {"BlankEntryAction", N_("Blank"), N_("Move to the blank entry at the bottom of the bill")}, + {"ToolsProcessPaymentAction", N_("_Pay Bill"), N_("Enter a payment for the owner of this bill") }, + {"ReportsCompanyReportAction", N_("_Company Report"), N_("Open a vendor report window for the owner of this bill") }, + {"BusinessLinkAction", N_("_Manage Document Link..."), N_("Manage Document Link")}, + {"BusinessLinkOpenAction", N_("_Open Linked Document"), N_("Open Linked Document")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels bill_action_layout_labels[] = { - {"ViewSaveLayoutAction", N_("_Use as Default Layout for Vendor Documents")}, - {"ViewResetLayoutAction", N_("_Reset Default Layout for Vendor Documents")}, - {NULL, NULL}, + {"ViewSaveLayoutAction", N_("_Use as Default Layout for Vendor Documents"), + N_("Use the current layout as default for all vendor bills and credit notes")}, + {"ViewResetLayoutAction", N_("_Reset Default Layout for Vendor Documents"), + N_("Reset default layout for all vendor bills and credit notes back to built-in defaults and update the current page accordingly")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels voucher_action_labels[] = { - {"FilePrintAction", N_("_Print Voucher")}, - {"EditEditInvoiceAction", N_("_Edit Voucher")}, - {"EditDuplicateInvoiceAction", N_("_Duplicate Voucher")}, - {"EditPostInvoiceAction", N_("_Post Voucher")}, - {"EditUnpostInvoiceAction", N_("_Unpost Voucher")}, - {"BusinessNewInvoiceAction", N_("New _Voucher")}, - {"ToolsProcessPaymentAction", N_("_Pay Voucher")}, - {"BusinessLinkAction", N_("_Manage Document Link…")}, - {"BusinessLinkOpenAction", N_("_Open Linked Document")}, - {NULL, NULL}, + {"FilePrintAction", N_("_Print Voucher"), N_("Make a printable voucher")}, + {"EditEditInvoiceAction", N_("_Edit Voucher"), N_("Edit this voucher")}, + {"EditDuplicateInvoiceAction", N_("_Duplicate Voucher"), N_("Create a new voucher as a duplicate of the current one")}, + {"EditPostInvoiceAction", N_("_Post Voucher"), N_("Post this voucher to your Chart of Accounts")}, + {"EditUnpostInvoiceAction", N_("_Unpost Voucher"), N_("Unpost this voucher and make it editable")}, + {"BusinessNewInvoiceAction", N_("New _Voucher"), N_("Create a new voucher for the same owner as the current one")}, + {"BlankEntryAction", N_("Blank"), N_("Move to the blank entry at the bottom of the voucher")}, + {"ToolsProcessPaymentAction", N_("_Pay Voucher"), N_("Enter a payment for the owner of this voucher") }, + {"ReportsCompanyReportAction", N_("_Company Report"), N_("Open a employee report window for the owner of this voucher") }, + {"BusinessLinkAction", N_("_Manage Document Link..."), N_("Manage Document Link")}, + {"BusinessLinkOpenAction", N_("_Open Linked Document"), N_("Open Linked Document")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels voucher_action_layout_labels[] = { - {"ViewSaveLayoutAction", N_("_Use as Default Layout for Employee Documents")}, - {"ViewResetLayoutAction", N_("_Reset Default Layout for Employee Documents")}, - {NULL, NULL}, + {"ViewSaveLayoutAction", N_("_Use as Default Layout for Employee Documents"), + N_("Use the current layout as default for all employee vouchers and credit notes")}, + {"ViewResetLayoutAction", N_("_Reset Default Layout for Employee Documents"), + N_("Reset default layout for all employee vouchers and credit notes back to built-in defaults and update the current page accordingly")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels creditnote_action_labels[] = { - {"FilePrintAction", N_("_Print Credit Note")}, - {"EditEditInvoiceAction", N_("_Edit Credit Note")}, - {"EditDuplicateInvoiceAction", N_("_Duplicate Credit Note")}, - {"EditPostInvoiceAction", N_("_Post Credit Note")}, - {"EditUnpostInvoiceAction", N_("_Unpost Credit Note")}, - {"BusinessNewInvoiceAction", N_("New _Credit Note")}, - {"ToolsProcessPaymentAction", N_("_Pay Credit Note")}, - {"BusinessLinkAction", N_("_Manage Document Link…")}, - {"BusinessLinkOpenAction", N_("_Open Linked Document")}, - {NULL, NULL}, -}; - - -static action_toolbar_labels invoice_action_tooltips[] = { - {"FilePrintAction", N_("Make a printable invoice")}, - {"EditEditInvoiceAction", N_("Edit this invoice")}, - {"EditDuplicateInvoiceAction", N_("Create a new invoice as a duplicate of the current one")}, - {"EditPostInvoiceAction", N_("Post this invoice to your Chart of Accounts")}, - {"EditUnpostInvoiceAction", N_("Unpost this invoice and make it editable")}, - {"BusinessNewInvoiceAction", N_("Create a new invoice for the same owner as the current one")}, - {"BlankEntryAction", N_("Move to the blank entry at the bottom of the invoice")}, - {"ToolsProcessPaymentAction", N_("Enter a payment for the owner of this invoice") }, - {"ReportsCompanyReportAction", N_("Open a customer report window for the owner of this invoice") }, - {"BusinessLinkAction", N_("Manage Document Link")}, - {"BusinessLinkOpenAction", N_("Open Linked Document")}, - {NULL, NULL}, -}; - -static action_toolbar_labels invoice_action_layout_tooltips[] = { - {"ViewSaveLayoutAction", N_("Use the current layout as default for all customer invoices and credit notes")}, - {"ViewResetLayoutAction", N_("Reset default layout for all customer invoices and credit notes back to built-in defaults and update the current page accordingly")}, - {NULL, NULL}, -}; - -static action_toolbar_labels bill_action_tooltips[] = { - {"FilePrintAction", N_("Make a printable bill")}, - {"EditEditInvoiceAction", N_("Edit this bill")}, - {"EditDuplicateInvoiceAction", N_("Create a new bill as a duplicate of the current one")}, - {"EditPostInvoiceAction", N_("Post this bill to your Chart of Accounts")}, - {"EditUnpostInvoiceAction", N_("Unpost this bill and make it editable")}, - {"BusinessNewInvoiceAction", N_("Create a new bill for the same owner as the current one")}, - {"BlankEntryAction", N_("Move to the blank entry at the bottom of the bill")}, - {"ToolsProcessPaymentAction", N_("Enter a payment for the owner of this bill") }, - {"ReportsCompanyReportAction", N_("Open a vendor report window for the owner of this bill") }, - {"BusinessLinkAction", N_("Manage Document Link")}, - {"BusinessLinkOpenAction", N_("Open Linked Document")}, - {NULL, NULL}, -}; - -static action_toolbar_labels bill_action_layout_tooltips[] = { - {"ViewSaveLayoutAction", N_("Use the current layout as default for all vendor bills and credit notes")}, - {"ViewResetLayoutAction", N_("Reset default layout for all vendor bills and credit notes back to built-in defaults and update the current page accordingly")}, - {NULL, NULL}, -}; - -static action_toolbar_labels voucher_action_tooltips[] = { - {"FilePrintAction", N_("Make a printable voucher")}, - {"EditEditInvoiceAction", N_("Edit this voucher")}, - {"EditDuplicateInvoiceAction", N_("Create a new voucher as a duplicate of the current one")}, - {"EditPostInvoiceAction", N_("Post this voucher to your Chart of Accounts")}, - {"EditUnpostInvoiceAction", N_("Unpost this voucher and make it editable")}, - {"BusinessNewInvoiceAction", N_("Create a new voucher for the same owner as the current one")}, - {"BlankEntryAction", N_("Move to the blank entry at the bottom of the voucher")}, - {"ToolsProcessPaymentAction", N_("Enter a payment for the owner of this voucher") }, - {"ReportsCompanyReportAction", N_("Open a employee report window for the owner of this voucher") }, - {"BusinessLinkAction", N_("Manage Document Link")}, - {"BusinessLinkOpenAction", N_("Open Linked Document")}, - {NULL, NULL}, -}; - -static action_toolbar_labels voucher_action_layout_tooltips[] = { - {"ViewSaveLayoutAction", N_("Use the current layout as default for all employee vouchers and credit notes")}, - {"ViewResetLayoutAction", N_("Reset default layout for all employee vouchers and credit notes back to built-in defaults and update the current page accordingly")}, - {NULL, NULL}, -}; - -static action_toolbar_labels creditnote_action_tooltips[] = { - {"FilePrintAction", N_("Make a printable credit note")}, - {"EditEditInvoiceAction", N_("Edit this credit note")}, - {"EditDuplicateInvoiceAction", N_("Create a new credit note as a duplicate of the current one")}, - {"EditPostInvoiceAction", N_("Post this credit note to your Chart of Accounts")}, - {"EditUnpostInvoiceAction", N_("Unpost this credit note and make it editable")}, - {"BusinessNewInvoiceAction", N_("Create a new credit note for the same owner as the current one")}, - {"BlankEntryAction", N_("Move to the blank entry at the bottom of the credit note")}, - {"ToolsProcessPaymentAction", N_("Enter a payment for the owner of this credit note") }, - {"ReportsCompanyReportAction", N_("Open a company report window for the owner of this credit note") }, - {"BusinessLinkAction", N_("Manage Document Link…")}, - {"BusinessLinkOpenAction", N_("Open Linked Document")}, - {NULL, NULL}, + {"FilePrintAction", N_("_Print Credit Note"), N_("Make a printable credit note")}, + {"EditEditInvoiceAction", N_("_Edit Credit Note"), N_("Edit this credit note")}, + {"EditDuplicateInvoiceAction", N_("_Duplicate Credit Note"), N_("Create a new credit note as a duplicate of the current one")}, + {"EditPostInvoiceAction", N_("_Post Credit Note"), N_("Post this credit note to your Chart of Accounts")}, + {"EditUnpostInvoiceAction", N_("_Unpost Credit Note"), N_("Unpost this credit note and make it editable")}, + {"BusinessNewInvoiceAction", N_("New _Credit Note"), N_("Create a new credit note for the same owner as the current one")}, + {"BlankEntryAction", N_("Blank"), N_("Move to the blank entry at the bottom of the credit note")}, + {"ToolsProcessPaymentAction", N_("_Pay Credit Note"), N_("Enter a payment for the owner of this credit note") }, + {"ReportsCompanyReportAction", N_("_Company Report"), N_("Open a company report window for the owner of this credit note") }, + {"BusinessLinkAction", N_("_Manage Document Link..."), N_("Manage Document Link...")}, + {"BusinessLinkOpenAction", N_("_Open Linked Document"), N_("Open Linked Document")}, + {NULL, NULL, NULL}, }; /** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = { +static GncToolBarShortNames toolbar_labels[] = +{ {"RecordEntryAction", N_("Enter")}, {"CancelEntryAction", N_("Cancel")}, {"DeleteEntryAction", N_("Delete")}, @@ -471,6 +312,9 @@ typedef struct GncPluginPageInvoicePrivate InvoiceWindow *iw; GtkWidget *widget; + gboolean is_posted; + gboolean can_unpost; + gboolean is_readonly; gint component_manager_id; } GncPluginPageInvoicePrivate; @@ -530,7 +374,6 @@ gnc_plugin_page_invoice_new (InvoiceWindow *iw) plugin_page = GNC_PLUGIN_PAGE(invoice_page); gnc_plugin_page_invoice_update_title(plugin_page); - gnc_plugin_page_set_uri(plugin_page, "default:"); priv->component_manager_id = 0; return plugin_page; @@ -560,7 +403,7 @@ static void gnc_plugin_page_invoice_init (GncPluginPageInvoice *plugin_page) { GncPluginPage *parent; - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; gboolean use_new; /* Init parent declared variables */ @@ -568,27 +411,19 @@ gnc_plugin_page_invoice_init (GncPluginPageInvoice *plugin_page) use_new = gnc_prefs_get_bool (GNC_PREFS_GROUP_INVOICE, GNC_PREF_USE_NEW); g_object_set(G_OBJECT(plugin_page), "page-name", _("Invoice"), - "page-uri", "default:", - "ui-description", "gnc-plugin-page-invoice-ui.xml", + "ui-description", "gnc-plugin-page-invoice.ui", "use-new-window", use_new, (char *)NULL); /* change me when the system supports multiple books */ - gnc_plugin_page_add_book(parent, gnc_get_current_book()); + gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group(parent, - "GncPluginPageInvoiceActions"); - gtk_action_group_add_actions (action_group, gnc_plugin_page_invoice_actions, - gnc_plugin_page_invoice_n_actions, plugin_page); - gtk_action_group_add_radio_actions (action_group, - radio_entries, n_radio_entries, - REG_STYLE_LEDGER, - G_CALLBACK(gnc_plugin_page_invoice_cmd_sort_changed), - plugin_page); - - gnc_plugin_init_short_names (action_group, toolbar_labels); + simple_action_group = gnc_plugin_page_create_action_group (parent,"GncPluginPageInvoiceActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_invoice_actions, + gnc_plugin_page_invoice_n_actions, + plugin_page); } static void @@ -604,34 +439,44 @@ gnc_plugin_page_invoice_finalize (GObject *object) static void update_doclink_actions (GncPluginPage *plugin_page, gboolean has_uri) { - GtkAction *uri_action; - - uri_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(plugin_page), "BusinessLinkOpenAction"); - gtk_action_set_sensitive (uri_action, has_uri); + GAction *uri_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(plugin_page), + "BusinessLinkOpenAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(uri_action), has_uri); } static void -gnc_plugin_page_invoice_action_update (GtkActionGroup *action_group, - action_toolbar_labels *action_list, - void (*gtkfunc)(gpointer, gpointer)) +gnc_plugin_page_invoice_action_update (GncPluginPage *plugin_page, + action_toolbar_labels *action_list) { - GtkAction *action; - gint i; + GncMainWindow *window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window); + GtkWidget *tool_item; - for (i = 0; action_list[i].action_name; i++) + for (gint i = 0; (action_list[i].action_name != NULL); i++) { - /* update the action */ - action = gtk_action_group_get_action (action_group, - action_list[i].action_name); - gtkfunc (action, _(action_list[i].label)); + gboolean found = gnc_main_window_update_menu_for_action (window, + action_list[i].action_name, + _(action_list[i].label), + _(action_list[i].tooltip)); + + tool_item = gnc_main_window_toolbar_find_tool_item (window, + action_list[i].action_name); + + if (tool_item) + { + gtk_tool_button_set_label (GTK_TOOL_BUTTON(tool_item), _(action_list[i].label)); + gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(action_list[i].tooltip)); + g_object_set (G_OBJECT(tool_item), "has-tooltip", FALSE, NULL); + } } + // need to add the accelerator keys for the updated menu items + gnc_main_window_menu_add_accelerator_keys (window); } static void gnc_plugin_page_update_reset_layout_action (GncPluginPage *page) { GncPluginPageInvoicePrivate *priv; - GtkAction *layout_action; + GAction *layout_action; gboolean has_default = FALSE; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(page)); @@ -641,52 +486,57 @@ gnc_plugin_page_update_reset_layout_action (GncPluginPage *page) layout_action = gnc_plugin_page_get_action (page, "ViewResetLayoutAction"); if (gnc_invoice_window_document_has_user_state (priv->iw)) has_default = TRUE; - gtk_action_set_sensitive (layout_action, has_default); + g_simple_action_set_enabled (G_SIMPLE_ACTION(layout_action), has_default); } void gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, gboolean can_unpost) { - GtkActionGroup *action_group; + GncMainWindow *window; + GSimpleActionGroup *simple_action_group; + GAction *action; GncPluginPageInvoicePrivate *priv; GncInvoiceType invoice_type; GncInvoice *invoice; gint i, j; action_toolbar_labels *label_list; - action_toolbar_labels *tooltip_list; action_toolbar_labels *label_layout_list; - action_toolbar_labels *tooltip_layout_list; gboolean has_uri = FALSE; gboolean is_readonly = qof_book_is_readonly(gnc_get_current_book()); g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(page)); + window = (GncMainWindow*)gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page)); + + if (gnc_main_window_get_current_page (window) != page) + return; + priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page); invoice_type = gnc_invoice_get_type_from_window(priv->iw); + // lets remember these settings + priv->is_posted = is_posted; + priv->can_unpost = can_unpost; + priv->is_readonly = is_readonly; + switch (invoice_type) { case GNC_INVOICE_CUST_INVOICE: label_list = invoice_action_labels; - tooltip_list = invoice_action_tooltips; break; case GNC_INVOICE_VEND_INVOICE: label_list = bill_action_labels; - tooltip_list = bill_action_tooltips; break; case GNC_INVOICE_EMPL_INVOICE: label_list = voucher_action_labels; - tooltip_list = voucher_action_tooltips; break; case GNC_INVOICE_CUST_CREDIT_NOTE: // fallthrough case GNC_INVOICE_VEND_CREDIT_NOTE: // fallthrough case GNC_INVOICE_EMPL_CREDIT_NOTE: // fallthrough label_list = creditnote_action_labels; - tooltip_list = creditnote_action_tooltips; break; default: // catches GNC_INVOICE_UNDEFINED, use invoice by default label_list = invoice_action_labels; - tooltip_list = invoice_action_tooltips; } // layout actions @@ -694,21 +544,17 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g case GNC_INVOICE_CUST_INVOICE: case GNC_INVOICE_CUST_CREDIT_NOTE: label_layout_list = invoice_action_layout_labels; - tooltip_layout_list = invoice_action_layout_tooltips; break; case GNC_INVOICE_VEND_INVOICE: case GNC_INVOICE_VEND_CREDIT_NOTE: label_layout_list = bill_action_layout_labels; - tooltip_layout_list = bill_action_layout_tooltips; break; case GNC_INVOICE_EMPL_INVOICE: case GNC_INVOICE_EMPL_CREDIT_NOTE: label_layout_list = voucher_action_layout_labels; - tooltip_layout_list = voucher_action_layout_tooltips; break; default: // catches GNC_INVOICE_UNDEFINED, use invoice by default label_layout_list = invoice_action_layout_labels; - tooltip_layout_list = invoice_action_layout_tooltips; } if (is_readonly) @@ -718,28 +564,28 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g can_unpost = FALSE; } - action_group = gnc_plugin_page_get_action_group(page); - gnc_plugin_update_actions (action_group, posted_actions, - "sensitive", is_posted); - gnc_plugin_update_actions (action_group, unposted_actions, - "sensitive", !is_posted); - gnc_plugin_update_actions (action_group, can_unpost_actions, - "sensitive", can_unpost); - gnc_plugin_update_actions (action_group, invoice_book_readwrite_actions, - "sensitive", !is_readonly); + /* Enable the FilePrintAction */ + action = gnc_main_window_find_action (window, "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); - /* update the action labels */ - gnc_plugin_page_invoice_action_update (action_group, label_list, (void*)gtk_action_set_label); - /* update the action tooltips */ - gnc_plugin_page_invoice_action_update (action_group, tooltip_list, (void*)gtk_action_set_tooltip); + simple_action_group = gnc_plugin_page_get_action_group (page); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), posted_actions, + is_posted); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), unposted_actions, + !is_posted); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), can_unpost_actions, + can_unpost); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), invoice_book_readwrite_actions, + !is_readonly); + + /* update the action labels and tooltips */ + gnc_plugin_page_invoice_action_update (page, label_list); // if there is no default layout do not enable reset action gnc_plugin_page_update_reset_layout_action (page); - /* update the layout action labels */ - gnc_plugin_page_invoice_action_update (action_group, label_layout_list, (void*)gtk_action_set_label); - /* update the layout action tooltips */ - gnc_plugin_page_invoice_action_update (action_group, tooltip_layout_list, (void*)gtk_action_set_tooltip); + /* update the layout action labels and tooltips */ + gnc_plugin_page_invoice_action_update (page, label_layout_list); // update doclink buttons invoice = gnc_invoice_window_get_invoice (priv->iw); @@ -765,6 +611,22 @@ gnc_plugin_page_invoice_focus_widget (GncPluginPage *invoice_plugin_page) GtkWidget *notes = gnc_invoice_get_notes(priv->iw); GnucashSheet *sheet; + /* Disable the Transaction Menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(invoice_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(invoice_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(invoice_plugin_page->window), + invoice_plugin_page, + gnc_plugin_load_ui_items); + + gnc_plugin_page_invoice_update_menus (invoice_plugin_page, priv->is_posted, priv->can_unpost); + + // setup any short toolbar names + gnc_main_window_init_short_names (GNC_MAIN_WINDOW(invoice_plugin_page->window), toolbar_labels); + // if there is no default layout do not enable reset action gnc_plugin_page_update_reset_layout_action (invoice_plugin_page); @@ -973,7 +835,9 @@ gnc_plugin_page_invoice_window_changed (GncPluginPage *plugin_page, static void -gnc_plugin_page_invoice_summarybar_position_changed(gpointer prefs, gchar *pref, gpointer user_data) +gnc_plugin_page_invoice_summarybar_position_changed (gpointer prefs, + gchar *pref, + gpointer user_data) { GncPluginPage *plugin_page; GncPluginPageInvoice *page; @@ -1000,15 +864,17 @@ gnc_plugin_page_invoice_summarybar_position_changed(gpointer prefs, gchar *pref, /************************************************************/ static void -gnc_plugin_page_invoice_cmd_new_invoice (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_new_invoice (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_new_invoice_cb(parent, priv->iw); @@ -1016,27 +882,31 @@ gnc_plugin_page_invoice_cmd_new_invoice (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_new_account (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_new_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GtkWindow *parent = NULL; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); gnc_ui_new_account_window (parent, gnc_get_current_book(), NULL); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_print (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_print (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_printCB (parent, priv->iw); @@ -1044,57 +914,65 @@ gnc_plugin_page_invoice_cmd_print (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_cut (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_cut (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_cut_cb(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_copy (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_copy (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_copy_cb(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_paste (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_paste (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_paste_cb(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_edit (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_edit (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_editCB (parent, priv->iw); @@ -1102,15 +980,33 @@ gnc_plugin_page_invoice_cmd_edit (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_duplicateInvoice (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_edit_tax (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; + GtkWidget *parent; + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); + + ENTER("(action %p, plugin_page %p)", simple, plugin_page); + parent = GTK_WIDGET(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); + gnc_tax_info_dialog (parent, NULL); + LEAVE(" "); +} + +static void +gnc_plugin_page_invoice_cmd_duplicateInvoice (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) +{ + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_duplicateInvoiceCB(parent, priv->iw); @@ -1118,66 +1014,71 @@ gnc_plugin_page_invoice_cmd_duplicateInvoice (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_post (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_post (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_postCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_unpost (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_unpost (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_unpostCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_sort_changed (GtkAction *action, - GtkRadioAction *current, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_sort_changed (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { GncPluginPageInvoicePrivate *priv; invoice_sort_type_t value; + GncPluginPageInvoice *plugin_page = user_data; + gint item; - ENTER("(action %p, radio action %p, plugin_page %p)", - action, current, plugin_page); - LEAVE("g_return testing…"); + g_return_if_fail (G_IS_SIMPLE_ACTION(simple)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - g_return_if_fail(GTK_IS_ACTION(action)); - g_return_if_fail(GTK_IS_RADIO_ACTION(current)); - g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); + ENTER("action %p, plugin_page (%p), item is %d", + simple, plugin_page, g_variant_get_int32 (parameter)); - ENTER("…passed (action %p, radio action %p, plugin_page %p)", - action, current, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); - value = gtk_radio_action_get_current_value(current); - gnc_invoice_window_sort (priv->iw, value); + item = g_variant_get_int32 (parameter); + g_action_change_state (G_ACTION(simple), parameter); + gnc_invoice_window_sort (priv->iw, item); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_refresh (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_refresh (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gtk_widget_queue_draw (priv->widget); @@ -1185,111 +1086,127 @@ gnc_plugin_page_invoice_cmd_refresh (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_enter (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_enter (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_recordCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_cancel (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_cancel (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_cancelCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_delete (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_delete (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_deleteCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_blank (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_blank (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_blankCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_duplicateEntry (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_duplicateEntry (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_duplicateCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_entryUp (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_entryUp (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_entryUpCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_entryDown (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_entryDown (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_entryDownCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_pay_invoice (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_pay_invoice (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_payment_cb (parent, priv->iw); @@ -1297,61 +1214,66 @@ gnc_plugin_page_invoice_cmd_pay_invoice (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_save_layout (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_save_layout (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; - GtkAction *layout_action; + GAction *layout_action; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_save_document_layout_to_user_state (priv->iw); layout_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(plugin_page), "ViewResetLayoutAction"); - gtk_action_set_sensitive (layout_action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(layout_action), TRUE); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_reset_layout (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_reset_layout (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; - GtkAction *layout_action; + GAction *layout_action; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_reset_document_layout_and_clear_user_state (priv->iw); layout_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(plugin_page), "ViewResetLayoutAction"); - gtk_action_set_sensitive (layout_action, FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(layout_action), FALSE); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_link (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_link (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; - GtkAction *uri_action; GncInvoice *invoice; const gchar *uri; gchar *ret_uri; gboolean has_uri = FALSE; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); @@ -1396,17 +1318,18 @@ gnc_plugin_page_invoice_cmd_link (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_link_remove (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_link_remove (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; - GtkAction *uri_action; GncInvoice *invoice; GtkWidget *doclink_button; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); @@ -1425,16 +1348,18 @@ gnc_plugin_page_invoice_cmd_link_remove (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_link_open (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_link_open (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; GncInvoice *invoice; const gchar *uri = NULL; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); @@ -1448,15 +1373,17 @@ gnc_plugin_page_invoice_cmd_link_open (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_company_report (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_company_report (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_report_owner_cb (parent, priv->iw); diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index 056d861636..a08a57ed01 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -70,7 +70,7 @@ static QofLogModule log_module = GNC_MOD_GUI; #define PLUGIN_PAGE_ACCT_TREE_CM_CLASS "plugin-page-owner-tree" #define DELETE_DIALOG_FILTER "filter" -#define DELETE_DIALOG_OWNER "owner" +#define DELETE_DIALOG_OWNER "owner" enum { @@ -107,142 +107,78 @@ static GtkWidget *gnc_plugin_page_owner_tree_create_widget (GncPluginPage *plugi static void gnc_plugin_page_owner_tree_destroy_widget (GncPluginPage *plugin_page); static void gnc_plugin_page_owner_tree_save_page (GncPluginPage *plugin_page, GKeyFile *file, const gchar *group); static GncPluginPage *gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window, GKeyFile *file, const gchar *group); +static void set_menu_and_toolbar_qualifier (GncPluginPage *plugin_page); /* Callbacks */ static gboolean gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - GncPluginPage *page); -static void gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *col, - GncPluginPageOwnerTree *page); + GdkEventButton *event, + GncPluginPage *page); +static void gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview, + GtkTreePath *path, + GtkTreeViewColumn *col, + GncPluginPageOwnerTree *page); static void gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection, - GncPluginPageOwnerTree *page); + GncPluginPageOwnerTree *page); /* Command callbacks */ -static void gnc_plugin_page_owner_tree_cmd_new_owner (GtkAction *action, GncPluginPageOwnerTree *page); -static void gnc_plugin_page_owner_tree_cmd_edit_owner (GtkAction *action, GncPluginPageOwnerTree *page); +static void gnc_plugin_page_owner_tree_cmd_new_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_edit_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #if 0 /* Disabled due to crash */ -static void gnc_plugin_page_owner_tree_cmd_delete_owner (GtkAction *action, GncPluginPageOwnerTree *page); +static void gnc_plugin_page_owner_tree_cmd_delete_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #endif -static void gnc_plugin_page_owner_tree_cmd_view_filter_by (GtkAction *action, GncPluginPageOwnerTree *page); -static void gnc_plugin_page_owner_tree_cmd_refresh (GtkAction *action, GncPluginPageOwnerTree *page); -static void gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action, GncPluginPageOwnerTree *page); -static void gnc_plugin_page_owner_tree_cmd_owners_report (GtkAction *action, GncPluginPageOwnerTree *plugin_page); -static void gnc_plugin_page_owner_tree_cmd_owner_report (GtkAction *action, GncPluginPageOwnerTree *plugin_page); -static void gnc_plugin_page_owner_tree_cmd_process_payment (GtkAction *action, GncPluginPageOwnerTree *plugin_page); - +static void gnc_plugin_page_owner_tree_cmd_view_filter_by (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_refresh (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_owners_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_owner_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_process_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_edit_tax (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static guint plugin_page_signals[LAST_SIGNAL] = { 0 }; -static GtkActionEntry gnc_plugin_page_owner_tree_actions [] = +static GActionEntry gnc_plugin_page_owner_tree_actions [] = { - /* Toplevel */ - { "FakeToplevel", NULL, "", NULL, NULL, NULL }, - - /* Edit menu */ - { - "OTEditVendorAction", GNC_ICON_EDIT_ACCOUNT, N_("E_dit Vendor"), "e", - N_("Edit the selected vendor"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_edit_owner) - }, - { - "OTEditCustomerAction", GNC_ICON_EDIT_ACCOUNT, N_("E_dit Customer"), "e", - N_("Edit the selected customer"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_edit_owner) - }, - { - "OTEditEmployeeAction", GNC_ICON_EDIT_ACCOUNT, N_("E_dit Employee"), "e", - N_("Edit the selected employee"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_edit_owner) - }, - { - "OTNewVendorAction", GNC_ICON_NEW_ACCOUNT, N_("_New Vendor…"), NULL, - N_("Create a new vendor"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_owner) - }, - { - "OTNewCustomerAction", GNC_ICON_NEW_ACCOUNT, N_("_New Customer…"), NULL, - N_("Create a new customer"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_owner) - }, - { - "OTNewEmployeeAction", GNC_ICON_NEW_ACCOUNT, N_("_New Employee…"), NULL, - N_("Create a new employee"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_owner) - }, + { "OTEditVendorAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL }, + { "OTEditCustomerAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL }, + { "OTEditEmployeeAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL }, + { "OTNewVendorAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL }, + { "OTNewCustomerAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL }, + { "OTNewEmployeeAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL }, #if 0 /* Disabled due to crash */ - { - "EditDeleteOwnerAction", GNC_ICON_DELETE_ACCOUNT, N_("_Delete Owner…"), "Delete", - N_("Delete selected owner"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_delete_owner) - }, + { "EditDeleteOwnerAction", gnc_plugin_page_owner_tree_cmd_delete_owner, NULL, NULL, NULL }, #endif /* Disabled due to crash */ - /* View menu */ - { - "ViewFilterByAction", NULL, N_("_Filter By…"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_view_filter_by) - }, - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_refresh) - }, - - /* Business menu */ - { - "OTNewBillAction", GNC_ICON_INVOICE_NEW, N_("New _Bill…"), NULL, - N_("Create a new bill"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_invoice) - }, - { - "OTNewInvoiceAction", GNC_ICON_INVOICE_NEW, N_("New _Invoice…"), NULL, - N_("Create a new invoice"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_invoice) - }, - { - "OTNewVoucherAction", GNC_ICON_INVOICE_NEW, N_("New _Voucher…"), NULL, - N_("Create a new voucher"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_invoice) - }, - { - "OTVendorListingReportAction", "document-print-preview", N_("Vendor Listing"), NULL, - N_("Show vendor aging overview for all vendors"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owners_report) - }, - { - "OTCustomerListingReportAction", "document-print-preview", N_("Customer Listing"), NULL, - N_("Show customer aging overview for all customers"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owners_report) - }, - { - "OTVendorReportAction", NULL, N_("Vendor Report"), NULL, - N_("Show vendor report"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report) - }, - { - "OTCustomerReportAction", NULL, N_("Customer Report"), NULL, - N_("Show customer report"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report) - }, - { - "OTEmployeeReportAction", NULL, N_("Employee Report"), NULL, - N_("Show employee report"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report) - }, - { - "OTProcessPaymentAction", GNC_ICON_INVOICE_PAY, - N_("Process Payment"), NULL, N_("Process Payment"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_process_payment) - }, + { "ViewFilterByAction", gnc_plugin_page_owner_tree_cmd_view_filter_by, NULL, NULL, NULL }, + { "ViewRefreshAction", gnc_plugin_page_owner_tree_cmd_refresh, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_owner_tree_cmd_edit_tax, NULL, NULL, NULL }, + { "OTNewBillAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL }, + { "OTNewInvoiceAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL }, + { "OTNewVoucherAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL }, + { "OTVendorListingReportAction", gnc_plugin_page_owner_tree_cmd_owners_report, NULL, NULL, NULL }, + { "OTCustomerListingReportAction", gnc_plugin_page_owner_tree_cmd_owners_report, NULL, NULL, NULL }, + { "OTVendorReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL }, + { "OTCustomerReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL }, + { "OTEmployeeReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL }, + { "OTProcessPaymentAction", gnc_plugin_page_owner_tree_cmd_process_payment, NULL, NULL, NULL }, }; /** The number of actions provided by this plugin. */ -static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS (gnc_plugin_page_owner_tree_actions); +static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS(gnc_plugin_page_owner_tree_actions); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder3", + "EditPlaceholder2", + "EditPlaceholder3", + "EditPlaceholder5", + "ViewPlaceholder1", + "ViewPlaceholder4", + "ReportsPlaceholder1", + NULL, +}; /** Actions that require an owner to be selected before they are * enabled. These ones are only sensitive in a read-write book. */ @@ -282,7 +218,7 @@ static const gchar* readonly_inactive_actions[] = /** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = +static GncToolBarShortNames toolbar_labels[] = { { "OTEditVendorAction", N_("Edit") }, { "OTEditCustomerAction", N_("Edit") }, @@ -334,13 +270,11 @@ GncPluginPage * gnc_plugin_page_owner_tree_new (GncOwnerType owner_type) { GncPluginPageOwnerTree *plugin_page; - GncPluginPageOwnerTreePrivate *priv; const GList *item; - - GtkActionGroup *action_group; - GtkAction *action; - gint i; + GSimpleActionGroup *simple_action_group; + GAction *action; + gint i; g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED) && (owner_type != GNC_OWNER_NONE), NULL); @@ -364,16 +298,6 @@ gnc_plugin_page_owner_tree_new (GncOwnerType owner_type) priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page); priv->owner_type = owner_type; - /* Hide menu and toolbar items that are not relevant for the active owner list */ - action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(plugin_page)); - for (i = 0; action_owners[i].action_name; i++) - { - action = gtk_action_group_get_action (action_group, action_owners[i].action_name); - g_object_set (G_OBJECT(action), - "visible", (priv->owner_type == action_owners[i].owner_type), - NULL); - } - LEAVE("new %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page); return GNC_PLUGIN_PAGE(plugin_page); } @@ -390,6 +314,25 @@ gnc_plugin_page_owner_focus_widget (GncPluginPage *owner_plugin_page) GncPluginPageOwnerTreePrivate *priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_plugin_page); GtkTreeView *tree_view = priv->tree_view; + /* Disable the Transaction Menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(owner_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(owner_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the FilePrintAction */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(owner_plugin_page->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + set_menu_and_toolbar_qualifier (owner_plugin_page); + + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(owner_plugin_page->window), + owner_plugin_page, + gnc_plugin_load_ui_items); + + // setup any short toolbar names + gnc_main_window_init_short_names (GNC_MAIN_WINDOW(owner_plugin_page->window), toolbar_labels); + if (GTK_IS_TREE_VIEW(tree_view)) { if (!gtk_widget_is_focus (GTK_WIDGET(tree_view))) @@ -431,7 +374,7 @@ gnc_plugin_page_owner_tree_class_init (GncPluginPageOwnerTreeClass *klass) static void gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GncPluginPageOwnerTreePrivate *priv; GncPluginPage *parent; @@ -442,32 +385,27 @@ gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) parent = GNC_PLUGIN_PAGE(plugin_page); g_object_set(G_OBJECT(plugin_page), "page-name", _("Owners"), - "page-uri", "default:", - "ui-description", "gnc-plugin-page-owner-tree-ui.xml", + "ui-description", "gnc-plugin-page-owner-tree.ui", NULL); g_signal_connect (G_OBJECT (plugin_page), "selected", G_CALLBACK (gnc_plugin_page_owner_tree_selected), plugin_page); /* change me when the system supports multiple books */ - gnc_plugin_page_add_book(parent, gnc_get_current_book()); + gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group(parent, - "GncPluginPageOwnerTreeActions"); - gtk_action_group_add_actions(action_group, - gnc_plugin_page_owner_tree_actions, - gnc_plugin_page_owner_tree_n_actions, - plugin_page); - gnc_plugin_init_short_names (action_group, toolbar_labels); - + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageOwnerTreeActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_owner_tree_actions, + gnc_plugin_page_owner_tree_n_actions, + plugin_page); /* Init filter */ priv->fd.show_inactive = TRUE; priv->fd.show_zero_total = TRUE; LEAVE("page %p, priv %p, action group %p", - plugin_page, priv, action_group); + plugin_page, priv, simple_action_group); } static void @@ -486,9 +424,10 @@ gnc_plugin_page_owner_tree_finalize (GObject *object) LEAVE(" "); } -static void update_inactive_actions(GncPluginPage *plugin_page) +static void +update_inactive_actions(GncPluginPage *plugin_page) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; gboolean is_sensitive = !qof_book_is_readonly(gnc_get_current_book()); // We are readonly - so we have to switch particular actions to inactive. @@ -496,12 +435,32 @@ static void update_inactive_actions(GncPluginPage *plugin_page) g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page)); /* Get the action group */ - action_group = gnc_plugin_page_get_action_group(plugin_page); - g_return_if_fail(GTK_IS_ACTION_GROUP (action_group)); + simple_action_group = gnc_plugin_page_get_action_group (plugin_page); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (action_group, readonly_inactive_actions, - "sensitive", is_sensitive); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), readonly_inactive_actions, + is_sensitive); +} + +static void +set_menu_and_toolbar_qualifier (GncPluginPage *plugin_page) +{ + GncPluginPageOwnerTree *page = GNC_PLUGIN_PAGE_OWNER_TREE(plugin_page); + GncPluginPageOwnerTreePrivate *priv; + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(page)); + + priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page); + + if (priv->owner_type == GNC_OWNER_CUSTOMER) + gnc_plugin_page_set_menu_qualifier (plugin_page, "c"); + else if (priv->owner_type == GNC_OWNER_VENDOR) + gnc_plugin_page_set_menu_qualifier (plugin_page, "v"); + else if (priv->owner_type == GNC_OWNER_EMPLOYEE) + gnc_plugin_page_set_menu_qualifier (plugin_page, "e"); + else + gnc_plugin_page_set_menu_qualifier (plugin_page, NULL); } static void @@ -683,6 +642,8 @@ gnc_plugin_page_owner_tree_create_widget (GncPluginPage *plugin_page) G_CALLBACK(gnc_plugin_page_inserted_cb), NULL); + set_menu_and_toolbar_qualifier (plugin_page); + LEAVE("widget = %p", priv->widget); return priv->widget; } @@ -768,8 +729,8 @@ gnc_plugin_page_owner_tree_save_page (GncPluginPage *plugin_page, * @param group_name The group name to use when restoring data. */ static GncPluginPage * gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window, - GKeyFile *key_file, - const gchar *group_name) + GKeyFile *key_file, + const gchar *group_name) { GncPluginPageOwnerTree *owner_page; GncPluginPageOwnerTreePrivate *priv; @@ -840,8 +801,8 @@ static void gnc_ui_owner_edit (GtkWindow *parent, GncOwner *owner) * registered in gnc-main-window.c. */ static gboolean gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - GncPluginPage *page) + GdkEventButton *event, + GncPluginPage *page) { g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE); @@ -857,19 +818,19 @@ gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget, } static void -gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *col, - GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview, + GtkTreePath *path, + GtkTreeViewColumn *col, + GncPluginPageOwnerTree *page) { - gnc_plugin_page_owner_tree_cmd_owner_report (NULL, page); + gnc_plugin_page_owner_tree_cmd_owner_report (NULL, NULL, (gpointer*)page); } static void gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection, - GncPluginPageOwnerTree *page) + GncPluginPageOwnerTree *page) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GtkTreeView *view; GncOwner *owner = NULL; gboolean sensitive; @@ -889,11 +850,11 @@ gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection, sensitive = (owner != NULL); } - action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(page)); - gnc_plugin_update_actions (action_group, actions_requiring_owner_always, - "sensitive", sensitive); - gnc_plugin_update_actions (action_group, actions_requiring_owner_rw, - "sensitive", sensitive && is_readwrite); + simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_owner_always, + sensitive); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_owner_rw, + sensitive && is_readwrite); g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner); } @@ -1009,8 +970,12 @@ static int build_owner_report (GncOwner *owner, Account *acc) /************************************************************/ static void -gnc_plugin_page_owner_tree_cmd_new_owner (GtkAction *action, GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_new_owner (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *page = user_data; GncPluginPageOwnerTreePrivate *priv; GtkWindow *parent; @@ -1049,13 +1014,17 @@ gnc_plugin_page_owner_tree_cmd_new_owner (GtkAction *action, GncPluginPageOwnerT } static void -gnc_plugin_page_owner_tree_cmd_edit_owner (GtkAction *action, GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_edit_owner (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *page = user_data; GtkWindow *parent; GncOwner *owner = gnc_plugin_page_owner_tree_get_current_owner (page); if (NULL == owner) return; - ENTER("action %p, page %p", action, page); + ENTER("action %p, page %p", simple, page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); gnc_ui_owner_edit (parent, owner); @@ -1065,8 +1034,12 @@ gnc_plugin_page_owner_tree_cmd_edit_owner (GtkAction *action, GncPluginPageOwner #if 0 /* Disabled due to crash */ static void -gnc_plugin_page_owner_tree_cmd_delete_owner (GtkAction *action, GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_delete_owner (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *page = user_data; GncOwner *owner = gnc_plugin_page_owner_tree_get_current_owner (page); gchar *owner_name; GtkWidget *window; @@ -1135,42 +1108,66 @@ gnc_plugin_page_owner_tree_cmd_delete_owner (GtkAction *action, GncPluginPageOwn /*********************/ static void -gnc_plugin_page_owner_tree_cmd_view_filter_by (GtkAction *action, - GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_view_filter_by (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *plugin_page = user_data; GncPluginPageOwnerTreePrivate *priv; - g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page)); - ENTER("(action %p, page %p)", action, page); + g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); + ENTER("(action %p, page %p)", simple, plugin_page); - priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page); - owner_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(page)); + priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page); + owner_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(plugin_page)); LEAVE(" "); } static void -gnc_plugin_page_owner_tree_cmd_refresh (GtkAction *action, - GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_refresh (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *plugin_page = user_data; GncPluginPageOwnerTreePrivate *priv; - g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page)); + g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); - priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page); + priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page); gtk_widget_queue_draw (priv->widget); } static void -gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action, - GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_edit_tax (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageOwnerTree *plugin_page = user_data; + GtkWidget *parent; + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); + + parent = GTK_WIDGET(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); + + gnc_tax_info_dialog (parent, NULL); +} + +static void +gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + +{ + GncPluginPageOwnerTree *plugin_page = user_data; GncPluginPageOwnerTreePrivate *priv; GncOwner current_owner; GtkWindow *parent; - ENTER("action %p, page %p", action, page); + ENTER("action %p, plugin_page %p", simple, plugin_page); - priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page); + priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page); switch (priv->owner_type) { case GNC_OWNER_NONE : @@ -1180,30 +1177,30 @@ gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action, case GNC_OWNER_CUSTOMER : { gncOwnerInitCustomer(¤t_owner, - gncOwnerGetCustomer(gnc_plugin_page_owner_tree_get_current_owner (page)) ); + gncOwnerGetCustomer(gnc_plugin_page_owner_tree_get_current_owner (plugin_page))); break; } case GNC_OWNER_JOB : { gncOwnerInitJob(¤t_owner, - gncOwnerGetJob(gnc_plugin_page_owner_tree_get_current_owner (page)) ); + gncOwnerGetJob(gnc_plugin_page_owner_tree_get_current_owner (plugin_page))); break; } case GNC_OWNER_VENDOR : { gncOwnerInitVendor(¤t_owner, - gncOwnerGetVendor(gnc_plugin_page_owner_tree_get_current_owner (page)) ); + gncOwnerGetVendor(gnc_plugin_page_owner_tree_get_current_owner (plugin_page))); break; } case GNC_OWNER_EMPLOYEE : { gncOwnerInitEmployee(¤t_owner, - gncOwnerGetEmployee(gnc_plugin_page_owner_tree_get_current_owner (page)) ); + gncOwnerGetEmployee(gnc_plugin_page_owner_tree_get_current_owner (plugin_page))); break; } } - parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); if (gncOwnerGetType(¤t_owner) != GNC_OWNER_UNDEFINED) gnc_ui_invoice_new (parent, ¤t_owner, gnc_get_current_book ()); @@ -1211,13 +1208,16 @@ gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action, } static void -gnc_plugin_page_owner_tree_cmd_owners_report (GtkAction *action, - GncPluginPageOwnerTree *plugin_page) +gnc_plugin_page_owner_tree_cmd_owners_report (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *plugin_page = user_data; GncPluginPageOwnerTreePrivate *priv; int id; - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); @@ -1234,13 +1234,16 @@ gnc_plugin_page_owner_tree_cmd_owners_report (GtkAction *action, } static void -gnc_plugin_page_owner_tree_cmd_owner_report (GtkAction *action, - GncPluginPageOwnerTree *plugin_page) +gnc_plugin_page_owner_tree_cmd_owner_report (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *plugin_page = user_data; GncOwner *current_owner; int id; - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); @@ -1258,10 +1261,13 @@ gnc_plugin_page_owner_tree_cmd_owner_report (GtkAction *action, static void -gnc_plugin_page_owner_tree_cmd_process_payment (GtkAction *action, - GncPluginPageOwnerTree *plugin_page) +gnc_plugin_page_owner_tree_cmd_process_payment (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { - ENTER("(action %p, plugin_page %p)", action, plugin_page); + GncPluginPageOwnerTree *plugin_page = user_data; + ENTER("(action %p, plugin_page %p)", simple, plugin_page); g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 5cdadb98ec..cdbb80232f 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -87,6 +87,7 @@ #include "window-report.h" #include "engine-helpers.h" #include "qofbookslots.h" +#include "gnc-gtk-utils.h" /* This static indicates the debugging module that this .o belongs to. */ static QofLogModule log_module = GNC_MOD_GUI; @@ -171,103 +172,59 @@ static gchar* gnc_plugin_page_register_filter_time2dmy (time64 raw_time); static gchar* gnc_plugin_page_register_get_filter (GncPluginPage* plugin_page); void gnc_plugin_page_register_set_filter (GncPluginPage* plugin_page, const gchar* filter); -static void gnc_plugin_page_register_set_filter_tooltip ( - GncPluginPageRegister* page); +static void gnc_plugin_page_register_set_filter_tooltip (GncPluginPageRegister* page); static void gnc_ppr_update_status_query (GncPluginPageRegister* page); static void gnc_ppr_update_date_query (GncPluginPageRegister* page); /* Command callbacks */ -static void gnc_plugin_page_register_cmd_print_check (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_cut (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_copy (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_paste (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_edit_account (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_find_account (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_find_transactions (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_edit_tax_options (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_cut_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_copy_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_paste_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_void_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_unvoid_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_reverse_transaction ( - GtkAction* action, GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_view_sort_by (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_view_filter_by (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_style_changed (GtkAction* action, - GtkRadioAction* current, GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_style_double_line ( - GtkToggleAction* action, GncPluginPageRegister* plugin_page); +static void gnc_plugin_page_register_cmd_print_check (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_cut (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_copy (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_paste (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_edit_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_find_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_find_transactions (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_cut_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_copy_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_paste_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_void_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_unvoid_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_view_sort_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_view_filter_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data); -static void gnc_plugin_page_register_cmd_reconcile (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_stock_assistant (GtkAction* action, - GncPluginPageRegister* page); +static void gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_register_cmd_style_double_line (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_register_cmd_expand_transaction (GSimpleAction *simple, GVariant *parameter, gpointer user_data); + +static void gnc_plugin_page_register_cmd_reconcile (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_stock_assistant (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_autoclear (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_transfer (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_stock_split (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_lots (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_enter_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_cancel_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_delete_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_blank_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_duplicate_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_reinitialize_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_exchange_rate (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_reload (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_schedule (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_scrub_all (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_scrub_current (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_account_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_transaction_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_linked_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_linked_transaction_open (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_linked_transaction_remove (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_jump_linked_invoice (GSimpleAction *simple, GVariant *paramter, gpointer user_data); -static void gnc_plugin_page_register_cmd_autoclear (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_transfer (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_stock_split (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_lots (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_enter_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_cancel_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_delete_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_blank_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_goto_date (GtkAction* action, - GncPluginPageRegister* page); -static void gnc_plugin_page_register_cmd_duplicate_transaction ( - GtkAction* action, GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_reinitialize_transaction ( - GtkAction* action, GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_expand_transaction ( - GtkToggleAction* action, GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_exchange_rate (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_jump (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_reload (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_schedule (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_scrub_all (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_scrub_current (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_account_report (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_transaction_report (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_linked_transaction (GtkAction *action, - GncPluginPageRegister *plugin_page); -static void gnc_plugin_page_register_cmd_linked_transaction_open (GtkAction *action, - GncPluginPageRegister *plugin_page); -static void gnc_plugin_page_register_cmd_linked_transaction_remove (GtkAction *action, - GncPluginPageRegister *plugin_page); -static void gnc_plugin_page_register_cmd_jump_linked_invoice (GtkAction* action, - GncPluginPageRegister* plugin_page); static void gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr, GncPluginPageRegister* register_page); static void gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr, @@ -287,6 +244,22 @@ static void gnc_plugin_page_register_event_handler (QofInstance* entity, static GncInvoice* invoice_from_split (Split* split); static GList* invoices_from_transaction (Transaction* trans); +static void +toggle_change_state (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + g_simple_action_set_state (simple, state); +} + +static void +radio_change_state (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + g_simple_action_set_state (simple, state); +} + /************************************************************/ /* Actions */ /************************************************************/ @@ -326,278 +299,76 @@ static GList* invoices_from_transaction (Transaction* trans); #define DUPLICATE_SPLIT_TIP N_("Make a copy of the current split") #define DELETE_SPLIT_TIP N_("Delete the current split") -static GtkActionEntry gnc_plugin_page_register_actions [] = +static GActionEntry gnc_plugin_page_register_actions [] = { - /* File menu */ + { "FilePrintAction", gnc_plugin_page_register_cmd_print_check, NULL, NULL, NULL }, + { "EditCutAction", gnc_plugin_page_register_cmd_cut, NULL, NULL, NULL }, + { "EditCopyAction", gnc_plugin_page_register_cmd_copy, NULL, NULL, NULL }, + { "EditPasteAction", gnc_plugin_page_register_cmd_paste, NULL, NULL, NULL }, + { "EditEditAccountAction", gnc_plugin_page_register_cmd_edit_account, NULL, NULL, NULL }, + { "EditFindAccountAction", gnc_plugin_page_register_cmd_find_account, NULL, NULL, NULL }, + { "EditFindTransactionsAction", gnc_plugin_page_register_cmd_find_transactions, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_register_cmd_edit_tax_options, NULL, NULL, NULL }, + { "CutTransactionAction", gnc_plugin_page_register_cmd_cut_transaction, NULL, NULL, NULL }, + { "CopyTransactionAction", gnc_plugin_page_register_cmd_copy_transaction, NULL, NULL, NULL }, + { "PasteTransactionAction", gnc_plugin_page_register_cmd_paste_transaction, NULL, NULL, NULL }, + { "DuplicateTransactionAction", gnc_plugin_page_register_cmd_duplicate_transaction, NULL, NULL, NULL }, + { "DeleteTransactionAction", gnc_plugin_page_register_cmd_delete_transaction, NULL, NULL, NULL }, + { "RemoveTransactionSplitsAction", gnc_plugin_page_register_cmd_reinitialize_transaction, NULL, NULL, NULL }, + { "RecordTransactionAction", gnc_plugin_page_register_cmd_enter_transaction, NULL, NULL, NULL }, + { "CancelTransactionAction", gnc_plugin_page_register_cmd_cancel_transaction, NULL, NULL, NULL }, + { "VoidTransactionAction", gnc_plugin_page_register_cmd_void_transaction, NULL, NULL, NULL }, + { "UnvoidTransactionAction", gnc_plugin_page_register_cmd_unvoid_transaction, NULL, NULL, NULL }, + { "ReverseTransactionAction", gnc_plugin_page_register_cmd_reverse_transaction, NULL, NULL, NULL }, + { "LinkTransactionAction", gnc_plugin_page_register_cmd_linked_transaction, NULL, NULL, NULL }, + { "LinkedTransactionOpenAction", gnc_plugin_page_register_cmd_linked_transaction_open, NULL, NULL, NULL }, + { "JumpLinkedInvoiceAction", gnc_plugin_page_register_cmd_jump_linked_invoice, NULL, NULL, NULL }, + { "ViewSortByAction", gnc_plugin_page_register_cmd_view_sort_by, NULL, NULL, NULL }, + { "ViewFilterByAction", gnc_plugin_page_register_cmd_view_filter_by, NULL, NULL, NULL }, + { "ViewRefreshAction", gnc_plugin_page_register_cmd_reload, NULL, NULL, NULL }, + { "ActionsTransferAction", gnc_plugin_page_register_cmd_transfer, NULL, NULL, NULL }, + { "ActionsReconcileAction", gnc_plugin_page_register_cmd_reconcile, NULL, NULL, NULL }, + { "ActionsAutoClearAction", gnc_plugin_page_register_cmd_autoclear, NULL, NULL, NULL }, + { "ActionsStockAssistantAction", gnc_plugin_page_register_cmd_stock_assistant, NULL, NULL, NULL }, + { "ActionsStockSplitAction", gnc_plugin_page_register_cmd_stock_split, NULL, NULL, NULL }, + { "ActionsLotsAction", gnc_plugin_page_register_cmd_lots, NULL, NULL, NULL }, + { "BlankTransactionAction", gnc_plugin_page_register_cmd_blank_transaction, NULL, NULL, NULL }, + { "GotoDateAction", gnc_plugin_page_register_cmd_goto_date, NULL, NULL, NULL }, + { "EditExchangeRateAction", gnc_plugin_page_register_cmd_exchange_rate, NULL, NULL, NULL }, + { "JumpTransactionAction", gnc_plugin_page_register_cmd_jump, NULL, NULL, NULL }, + { "ScheduleTransactionAction", gnc_plugin_page_register_cmd_schedule, NULL, NULL, NULL }, + { "ScrubAllAction", gnc_plugin_page_register_cmd_scrub_all, NULL, NULL, NULL }, + { "ScrubCurrentAction", gnc_plugin_page_register_cmd_scrub_current, NULL, NULL, NULL }, + { "ReportsAccountReportAction", gnc_plugin_page_register_cmd_account_report, NULL, NULL, NULL }, + { "ReportsAcctTransReportAction", gnc_plugin_page_register_cmd_transaction_report, NULL, NULL, NULL }, - { - "FilePrintAction", "document-print", N_ ("_Print Checks…"), "p", NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_print_check) - }, - - /* Edit menu */ - - { - "EditCutAction", "edit-cut", N_ ("Cu_t"), "X", - N_ ("Cut the current selection and copy it to clipboard"), - G_CALLBACK (gnc_plugin_page_register_cmd_cut) - }, - { - "EditCopyAction", "edit-copy", N_ ("_Copy"), "C", - N_ ("Copy the current selection to clipboard"), - G_CALLBACK (gnc_plugin_page_register_cmd_copy) - }, - { - "EditPasteAction", "edit-paste", N_ ("_Paste"), "V", - N_ ("Paste the clipboard content at the cursor position"), - G_CALLBACK (gnc_plugin_page_register_cmd_paste) - }, - { - "EditEditAccountAction", GNC_ICON_EDIT_ACCOUNT, N_ ("Edit _Account"), "e", - N_ ("Edit the selected account"), - G_CALLBACK (gnc_plugin_page_register_cmd_edit_account) - }, - { - "EditFindAccountAction", "edit-find", N_ ("F_ind Account"), "i", - N_ ("Find an account"), - G_CALLBACK (gnc_plugin_page_register_cmd_find_account) - }, - { - "EditFindTransactionsAction", "edit-find", N_ ("_Find…"), "f", - N_ ("Find transactions with a search"), - G_CALLBACK (gnc_plugin_page_register_cmd_find_transactions) - }, - { - "EditTaxOptionsAction", NULL, - /* Translators: remember to reuse this - translation in dialog-account.glade */ - N_("Ta_x Report Options"), NULL, - /* Translators: currently implemented are - US: income tax and - DE: VAT - So adjust this string */ - N_("Setup relevant accounts for tax reports, e.g. US income tax"), - G_CALLBACK (gnc_plugin_page_register_cmd_edit_tax_options) - }, - - /* Transaction menu */ - - { - "CutTransactionAction", "edit-cut", CUT_TRANSACTION_LABEL, "", - CUT_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_cut_transaction) - }, - { - "CopyTransactionAction", "edit-copy", COPY_TRANSACTION_LABEL, "", - COPY_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_copy_transaction) - }, - { - "PasteTransactionAction", "edit-paste", PASTE_TRANSACTION_LABEL, "", - PASTE_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_paste_transaction) - }, - { - "DuplicateTransactionAction", "edit-copy", DUPLICATE_TRANSACTION_LABEL, "", - DUPLICATE_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_duplicate_transaction) - }, - { - "DeleteTransactionAction", "edit-delete", DELETE_TRANSACTION_LABEL, NULL, - DELETE_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_delete_transaction) - }, - { - "RemoveTransactionSplitsAction", "edit-clear", N_ ("Remo_ve Other Splits"), NULL, - N_ ("Remove all splits in the current transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_reinitialize_transaction) - }, - { - "RecordTransactionAction", "list-add", N_ ("_Enter Transaction"), NULL, - N_ ("Record the current transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_enter_transaction) - }, - { - "CancelTransactionAction", "process-stop", N_ ("Ca_ncel Transaction"), NULL, - N_ ("Cancel the current transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_cancel_transaction) - }, - { - "VoidTransactionAction", NULL, N_ ("_Void Transaction"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_void_transaction) - }, - { - "UnvoidTransactionAction", NULL, N_ ("_Unvoid Transaction"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_unvoid_transaction) - }, - { - "ReverseTransactionAction", NULL, N_ ("Add _Reversing Transaction"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_reverse_transaction) - }, - { - "LinkTransactionAction", NULL, LINK_TRANSACTION_LABEL, NULL, - LINK_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_linked_transaction) - }, - { - "LinkedTransactionOpenAction", NULL, LINK_TRANSACTION_OPEN_LABEL, NULL, - LINK_TRANSACTION_OPEN_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_linked_transaction_open) - }, - { - "JumpLinkedInvoiceAction", NULL, JUMP_LINKED_INVOICE_LABEL, NULL, - JUMP_LINKED_INVOICE_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_jump_linked_invoice) - }, - - /* View menu */ - - { - "ViewSortByAction", NULL, N_ ("_Sort By…"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_view_sort_by) - }, - { - "ViewFilterByAction", NULL, N_ ("_Filter By…"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_view_filter_by) - }, - { - "ViewRefreshAction", "view-refresh", N_ ("_Refresh"), "r", - N_ ("Refresh this window"), - G_CALLBACK (gnc_plugin_page_register_cmd_reload) - }, - - /* Actions menu */ - - { - "ActionsTransferAction", GNC_ICON_TRANSFER, N_ ("_Transfer…"), "t", - N_ ("Transfer funds from one account to another"), - G_CALLBACK (gnc_plugin_page_register_cmd_transfer) - }, - { - "ActionsReconcileAction", "edit-select-all", N_ ("_Reconcile…"), NULL, - N_ ("Reconcile the selected account"), - G_CALLBACK (gnc_plugin_page_register_cmd_reconcile) - }, - { - "ActionsAutoClearAction", "edit-select-all", N_ ("_Auto-clear…"), NULL, - N_ ("Automatically clear individual transactions, so as to reach a certain cleared amount"), - G_CALLBACK (gnc_plugin_page_register_cmd_autoclear) - }, - { - "ActionsStockAssistantAction", "applications-utilities", - N_ ("Stock Ass_istant"), NULL, N_ ("Stock Assistant"), - G_CALLBACK (gnc_plugin_page_register_cmd_stock_assistant) - }, - { - "ActionsStockSplitAction", NULL, N_ ("Stoc_k Split…"), NULL, - N_ ("Record a stock split or a stock merger"), - G_CALLBACK (gnc_plugin_page_register_cmd_stock_split) - }, - { - "ActionsLotsAction", NULL, N_ ("View _Lots…"), NULL, - N_ ("Bring up the lot viewer/editor window"), - G_CALLBACK (gnc_plugin_page_register_cmd_lots) - }, - { - "BlankTransactionAction", "go-bottom", N_ ("_Blank Transaction"), "Page_Down", - N_ ("Move to the blank transaction at the bottom of the register"), - G_CALLBACK (gnc_plugin_page_register_cmd_blank_transaction) - }, - { - "GotoDateAction", "x-office-calendar", N_ ("_Go to Date"), "G", - N_ ("Move to the split at the specified date"), - G_CALLBACK (gnc_plugin_page_register_cmd_goto_date) - }, - { - "EditExchangeRateAction", NULL, N_ ("Edit E_xchange Rate"), NULL, - N_ ("Edit the exchange rate for the current transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_exchange_rate) - }, - { -/* Translators: This is a menu item that will open a register tab for the - account of the first other account in the current transaction's split list - with focus on the current transaction's entry in that register. */ - "JumpTransactionAction", GNC_ICON_JUMP_TO, N_ ("_Jump to the other account"), NULL, - N_ ("Open a new register tab for the other account with focus on this transaction."), - G_CALLBACK (gnc_plugin_page_register_cmd_jump) - }, - { - "ScheduleTransactionAction", GNC_ICON_SCHEDULE, N_ ("Sche_dule…"), NULL, - N_ ("Create a Scheduled Transaction with the current transaction as a template"), - G_CALLBACK (gnc_plugin_page_register_cmd_schedule) - }, - { - "ScrubAllAction", NULL, - /* Translators: The following 2 are Scrub actions in register view */ - N_ ("_All transactions"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_scrub_all) - }, - { - "ScrubCurrentAction", NULL, N_ ("_This transaction"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_scrub_current) - }, - - /* Reports menu */ - - { - "ReportsAccountReportAction", NULL, N_ ("Account Report"), NULL, - N_ ("Open a register report for this Account"), - G_CALLBACK (gnc_plugin_page_register_cmd_account_report) - }, - { - "ReportsAcctTransReportAction", NULL, N_ ("Account Report - Single Transaction"), NULL, - N_ ("Open a register report for the selected Transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_transaction_report) - }, + { "ViewStyleDoubleLineAction", gnc_plugin_page_register_cmd_style_double_line, NULL, "false", toggle_change_state }, + { "SplitTransactionAction", gnc_plugin_page_register_cmd_expand_transaction, NULL, "false", toggle_change_state }, + { "ViewStyleRadioAction", gnc_plugin_page_register_cmd_style_changed, "i", "@i 0", radio_change_state }, }; +static guint gnc_plugin_page_register_n_actions = G_N_ELEMENTS(gnc_plugin_page_register_actions); -static guint gnc_plugin_page_register_n_actions = G_N_ELEMENTS ( - gnc_plugin_page_register_actions); - -static GtkToggleActionEntry toggle_entries[] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - { - "ViewStyleDoubleLineAction", NULL, N_ ("_Double Line"), NULL, - N_ ("Show a second line with \"Action\", \"Notes\", and \"Linked Document\" for each transaction."), - G_CALLBACK (gnc_plugin_page_register_cmd_style_double_line), FALSE - }, - - { - "SplitTransactionAction", GNC_ICON_SPLIT_TRANS, N_ ("S_plit Transaction"), NULL, - N_ ("Show all splits in the current transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_expand_transaction), FALSE - }, -}; - -static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries); - -static GtkRadioActionEntry radio_entries_2 [] = -{ - /* Translators: This is a menu item in the View menu */ - { - "ViewStyleBasicAction", NULL, N_ ("_Basic Ledger"), NULL, - N_ ("Show transactions on one or two lines"), REG_STYLE_LEDGER - }, - /* Translators: This is a menu item in the View menu */ - { - "ViewStyleAutoSplitAction", NULL, N_ ("_Auto-Split Ledger"), NULL, - N_ ("Show transactions on one or two lines and expand the current transaction"), REG_STYLE_AUTO_LEDGER - }, - /* Translators: This is a menu item in the View menu */ - { - "ViewStyleJournalAction", NULL, N_ ("Transaction _Journal"), NULL, - N_ ("Show expanded transactions with all splits"), REG_STYLE_JOURNAL - } -}; - -static guint n_radio_entries_2 = G_N_ELEMENTS (radio_entries_2); - -/** These are the "important" actions provided by the register page. - * Their labels will appear when the toolbar is set to "Icons and - * important text" (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. */ -static const gchar* important_actions[] = -{ - "SplitTransactionAction", + "FilePlaceholder3", + "EditPlaceholder1", + "EditPlaceholder2", + "EditPlaceholder3", + "EditPlaceholder5", + "ViewPlaceholder1", + "ViewPlaceholder2", + "ViewPlaceholder3", + "ViewPlaceholder4", + "TransPlaceholder0", + "TransPlaceholder1", + "TransPlaceholder2", + "TransPlaceholder3", + "TransPlaceholder4", + "ActionsPlaceholder4", + "ActionsPlaceholder5", + "ActionsPlaceholder6", + "ReportsPlaceholder1", NULL, }; @@ -618,6 +389,7 @@ static const gchar* view_style_actions[] = "ViewStyleBasicAction", "ViewStyleAutoSplitAction", "ViewStyleJournalAction", + "ViewStyleRadioAction", NULL }; @@ -628,7 +400,7 @@ static const gchar* actions_requiring_priced_account[] = }; /** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = +static GncToolBarShortNames toolbar_labels[] = { { "ActionsTransferAction", N_ ("Transfer") }, { "RecordTransactionAction", N_ ("Enter") }, @@ -881,7 +653,7 @@ gnc_plugin_page_register_init (GncPluginPageRegister* plugin_page) { GncPluginPageRegisterPrivate* priv; GncPluginPage* parent; - GtkActionGroup* action_group; + GSimpleActionGroup *simple_action_group; gboolean use_new; priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); @@ -892,28 +664,16 @@ gnc_plugin_page_register_init (GncPluginPageRegister* plugin_page) GNC_PREF_USE_NEW); g_object_set (G_OBJECT (plugin_page), "page-name", _ ("General Journal"), - "page-uri", "default:", - "ui-description", "gnc-plugin-page-register-ui.xml", + "ui-description", "gnc-plugin-page-register.ui", "use-new-window", use_new, NULL); /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group (parent, - "GncPluginPageRegisterActions"); - gtk_action_group_add_actions (action_group, gnc_plugin_page_register_actions, - gnc_plugin_page_register_n_actions, plugin_page); - gtk_action_group_add_toggle_actions (action_group, - toggle_entries, n_toggle_entries, - plugin_page); - gtk_action_group_add_radio_actions (action_group, - radio_entries_2, n_radio_entries_2, - REG_STYLE_LEDGER, - G_CALLBACK (gnc_plugin_page_register_cmd_style_changed), - plugin_page); - - gnc_plugin_init_short_names (action_group, toolbar_labels); - gnc_plugin_set_important_actions (action_group, important_actions); + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageRegisterActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_register_actions, + gnc_plugin_page_register_n_actions, + plugin_page); priv->lines_default = DEFAULT_LINES_AMOUNT; priv->read_only = FALSE; @@ -971,8 +731,37 @@ gnc_plugin_page_register_focus_widget (GncPluginPage* register_plugin_page) { if (GNC_IS_PLUGIN_PAGE_REGISTER (register_plugin_page)) { + GncWindow* gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(register_plugin_page)->window); GNCSplitReg *gsr = gnc_plugin_page_register_get_gsr (GNC_PLUGIN_PAGE(register_plugin_page)); + if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(register_plugin_page)->window)) + { + /* Enable the Transaction menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(register_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(register_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(register_plugin_page->window), + register_plugin_page, + gnc_plugin_load_ui_items); + } + else + { + GtkWidget *toolbar = gnc_window_get_toolbar (gnc_window); + GtkWidget *menubar = gnc_window_get_menubar (gnc_window); + GMenuModel *menubar_model = gnc_window_get_menubar_model (gnc_window); + GtkWidget *statusbar = gnc_window_get_statusbar (gnc_window); + + // add tooltip redirect call backs + gnc_plugin_add_toolbar_tooltip_callbacks (toolbar, statusbar); + gnc_plugin_add_menu_tooltip_callbacks (menubar, menubar_model, statusbar); + } + + // setup any short toolbar names + gnc_plugin_init_short_names (gnc_window_get_toolbar (gnc_window), toolbar_labels); + gnc_plugin_page_register_ui_update (NULL, GNC_PLUGIN_PAGE_REGISTER(register_plugin_page)); gnc_split_reg_focus_on_sheet (gsr); @@ -1073,26 +862,59 @@ gnc_plugin_page_register_ui_update (gpointer various, { GncPluginPageRegisterPrivate* priv; SplitRegister* reg; - GtkAction* action; + GAction* action; + GNCLedgerDisplayType ledger_type; gboolean expanded, voided, read_only = FALSE, read_only_reg = FALSE; Transaction* trans; GList* invoices; CursorClass cursor_class; const char* uri; + Account *account; + GncWindow* gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(page)->window); /* Set 'Split Transaction' */ priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); cursor_class = gnc_split_register_get_current_cursor_class (reg); expanded = gnc_split_register_current_trans_expanded (reg); - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), - "SplitTransactionAction"); - gtk_action_set_sensitive (action, reg->style == REG_STYLE_LEDGER); - g_signal_handlers_block_by_func - (action, gnc_plugin_page_register_cmd_expand_transaction, page); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), expanded); - g_signal_handlers_unblock_by_func - (action, gnc_plugin_page_register_cmd_expand_transaction, page); + + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "SplitTransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), reg->style == REG_STYLE_LEDGER); + + /* Set "style" radio button */ + ledger_type = gnc_ledger_display_type (priv->ledger); + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "ViewStyleRadioAction"); + + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), ledger_type != LD_GL); + g_action_change_state (G_ACTION(action), g_variant_new_int32 (reg->style)); + + /* Set double line */ + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "ViewStyleDoubleLineAction"); + g_action_change_state (G_ACTION(action), g_variant_new_boolean (reg->use_double_line)); + + /* Split Expand */ + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "SplitTransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), reg->style == REG_STYLE_LEDGER); + + g_signal_handlers_block_by_func (action, gnc_plugin_page_register_cmd_expand_transaction, page); + g_action_change_state (G_ACTION(action), g_variant_new_boolean (expanded)); + g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register_cmd_expand_transaction, page); + + account = gnc_plugin_page_register_get_account (page); + + /* Done like this as the register can be displayed in embedded window */ + if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window)) + { + /* Enable the FilePrintAction */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + + /* Set the vis of the StockAssistant */ + gnc_main_window_set_vis_of_items_by_action (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), + actions_requiring_priced_account, + account && gnc_prefs_is_extra_enabled () && + xaccAccountIsPriced (account)); + } /* If we are in a readonly book, or possibly a place holder * account register make any modifying action inactive */ @@ -1100,6 +922,14 @@ gnc_plugin_page_register_ui_update (gpointer various, gnc_split_reg_get_read_only (priv->gsr)) read_only_reg = TRUE; + gnc_plugin_set_actions_enabled (G_ACTION_MAP(gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page))), + actions_requiring_account, + !read_only_reg && account != NULL); + + gnc_plugin_set_actions_enabled (G_ACTION_MAP(gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page))), + actions_requiring_priced_account, + account && xaccAccountIsPriced (account)); + /* Set available actions based on read only */ trans = gnc_split_register_get_current_trans (reg); @@ -1111,8 +941,8 @@ gnc_plugin_page_register_ui_update (gpointer various, for (iter = readonly_inactive_actions; *iter; ++iter) { /* Set the action's sensitivity */ - GtkAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); - gtk_action_set_sensitive (action, TRUE); + GAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), *iter); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); } main_window_update_page_set_read_only_icon (GNC_PLUGIN_PAGE(page), FALSE); @@ -1121,43 +951,43 @@ gnc_plugin_page_register_ui_update (gpointer various, voided = xaccTransHasSplitsInState (trans, VREC); - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "CutTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "PasteTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "DeleteTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); if (cursor_class == CURSOR_CLASS_SPLIT) { - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "DuplicateTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); } - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "RemoveTransactionSplitsAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); /* Set 'Void' and 'Unvoid' */ if (read_only) voided = TRUE; - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "VoidTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !voided); if (read_only) voided = FALSE; - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "UnvoidTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), voided); } /* Set 'Open and Remove Linked Documents' */ @@ -1166,23 +996,23 @@ gnc_plugin_page_register_ui_update (gpointer various, if (trans) { uri = xaccTransGetDocLink (trans); - gtk_action_set_sensitive (GTK_ACTION(action), (uri ? TRUE:FALSE)); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), (uri ? TRUE:FALSE)); } /* Set 'ExecAssociatedInvoice' We can determine an invoice from a txn if either - it is an invoice transaction - it has splits with an invoice associated with it */ - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "JumpLinkedInvoiceAction"); if (trans) { invoices = invoices_from_transaction (trans); - gtk_action_set_sensitive (GTK_ACTION (action), (invoices != NULL)); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), (invoices != NULL)); g_list_free (invoices); } - gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE (page)); + gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE(page)); /* If we are read only, make any modifying action inactive */ if (read_only_reg) @@ -1191,49 +1021,80 @@ gnc_plugin_page_register_ui_update (gpointer various, for (iter = readonly_inactive_actions; *iter; ++iter) { /* Set the action's sensitivity */ - GtkAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); - gtk_action_set_sensitive (action, FALSE); + GAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), *iter); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); } main_window_update_page_set_read_only_icon (GNC_PLUGIN_PAGE(page), TRUE); } /* Modifying action descriptions based on cursor class */ { + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + GtkWidget *menu_item = NULL; + gboolean found = FALSE; const char** iter, **label_iter, **tooltip_iter; gboolean curr_label_trans = FALSE; iter = tran_vs_split_actions; - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); label_iter = tran_action_labels; - if (g_strcmp0 (gtk_action_get_label (action), _ (*label_iter)) == 0) + + gsm->search_action_label = NULL; + gsm->search_action_name = *iter; + + found = gnc_menubar_model_find_item (gnc_window_get_menubar_model (gnc_window), gsm); + + PINFO("Test for action '%s', found is %d, iter label is '%s'", *iter, found, _(*label_iter)); + + if (!found) + { + g_free (gsm); + return; + } + + if (g_strcmp0 (gsm->search_action_label, _(*label_iter)) == 0) curr_label_trans = TRUE; + + g_free (gsm); + if ((cursor_class == CURSOR_CLASS_SPLIT) && curr_label_trans) { + gboolean found = FALSE; label_iter = split_action_labels; tooltip_iter = split_action_tips; for (iter = tran_vs_split_actions; *iter; ++iter) { /* Adjust the action's label and tooltip */ - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); - gtk_action_set_label (action, _ (*label_iter)); - gtk_action_set_tooltip (action, _ (*tooltip_iter)); + found = gnc_menubar_model_update_item (gnc_window_get_menubar_model (gnc_window), + *iter, _(*label_iter), _(*tooltip_iter)); + + PINFO("split model_item action '%s', found is %d, iter label is '%s'", + *iter, found, _(*label_iter)); + ++label_iter; ++tooltip_iter; } } else if ((cursor_class == CURSOR_CLASS_TRANS) && !curr_label_trans) { + gboolean found = FALSE; label_iter = tran_action_labels; tooltip_iter = tran_action_tips; for (iter = tran_vs_split_actions; *iter; ++iter) { /* Adjust the action's label and tooltip */ - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); - gtk_action_set_label (action, _ (*label_iter)); - gtk_action_set_tooltip (action, _ (*tooltip_iter)); + found = gnc_menubar_model_update_item (gnc_window_get_menubar_model (gnc_window), + *iter, _(*label_iter), _(*tooltip_iter)); + + PINFO("trans model_item action '%s', found is %d, iter label is '%s'", + *iter, found, _(*label_iter)); + ++label_iter; ++tooltip_iter; } } + // now add the callbacks to the replaced menu items. + gnc_plugin_add_menu_tooltip_callbacks (gnc_window_get_menubar (gnc_window), + gnc_window_get_menubar_model (gnc_window), + gnc_window_get_statusbar (gnc_window)); } } @@ -1241,8 +1102,8 @@ static void gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) { GncPluginPageRegisterPrivate* priv ; - GtkActionGroup* action_group; - GtkAction* action; + GSimpleActionGroup *simple_action_group; + GAction *action; Account* account; SplitRegister* reg; GNCLedgerDisplayType ledger_type; @@ -1251,47 +1112,32 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); account = gnc_plugin_page_register_get_account (page); - action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE (page)); - gnc_plugin_update_actions (action_group, actions_requiring_account, - "sensitive", is_readwrite && account != NULL); - gnc_plugin_update_actions (action_group, actions_requiring_priced_account, - "visible", account && - gnc_prefs_is_extra_enabled () && - xaccAccountIsPriced (account)); + /* Get the action group */ + simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); + + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_account, + is_readwrite && account != NULL); /* Set "style" radio button */ ledger_type = gnc_ledger_display_type (priv->ledger); - gnc_plugin_update_actions (action_group, view_style_actions, - "sensitive", ledger_type == LD_SINGLE); + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "ViewStyleRadioAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), ledger_type == LD_SINGLE); reg = gnc_ledger_display_get_split_register (priv->ledger); - for (i = n_radio_entries_2 - 1; i > 0; i--) - { - DEBUG (" index %d: comparing %x to %x", i, radio_entries_2[i].value, - reg->style); - if (radio_entries_2[i].value == reg->style) - { - DEBUG ("match"); - break; - } - } - /* Either a match was found, or fell out with i = 0 */ - action = gtk_action_group_get_action (action_group, radio_entries_2[i].name); g_signal_handlers_block_by_func (action, gnc_plugin_page_register_cmd_style_changed, page); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); + g_action_change_state (G_ACTION(action), g_variant_new_int32 (reg->style)); g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register_cmd_style_changed, page); /* Set "double line" toggle button */ - action = gtk_action_group_get_action (action_group, - "ViewStyleDoubleLineAction"); + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "ViewStyleDoubleLineAction"); g_signal_handlers_block_by_func (action, gnc_plugin_page_register_cmd_style_double_line, page); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), - reg->use_double_line); + g_action_change_state (G_ACTION(action), g_variant_new_boolean (reg->use_double_line)); g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register_cmd_style_double_line, page); } @@ -1768,7 +1614,8 @@ gnc_plugin_page_register_restore_edit_menu (GncPluginPage* page, GKeyFile* key_file, const gchar* group_name) { - GtkAction* action; + GAction* action; + GVariant *state; GError* error = NULL; gchar* style_name; gint i; @@ -1793,16 +1640,22 @@ gnc_plugin_page_register_restore_edit_menu (GncPluginPage* page, if (i <= REG_STYLE_JOURNAL) { DEBUG ("Setting style: %d", i); - action = gnc_plugin_page_get_action (page, radio_entries_2[i].name); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); + action = gnc_plugin_page_get_action (page, "ViewStyleRadioAction"); + g_action_activate (G_ACTION(action), g_variant_new_int32 (i)); } /* Update the double line action on this page */ - use_double_line = - g_key_file_get_boolean (key_file, group_name, KEY_DOUBLE_LINE, &error); + use_double_line = g_key_file_get_boolean (key_file, group_name, + KEY_DOUBLE_LINE, &error); DEBUG ("Setting double_line_mode: %d", use_double_line); action = gnc_plugin_page_get_action (page, "ViewStyleDoubleLineAction"); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), use_double_line); + + state = g_action_get_state (G_ACTION(action)); + + if (use_double_line != g_variant_get_boolean (state)) + g_action_activate (G_ACTION(action), NULL); + + g_variant_unref (state); LEAVE (" "); } @@ -1915,7 +1768,7 @@ gnc_plugin_page_register_update_edit_menu (GncPluginPage* page, gboolean hide) { GncPluginPageRegisterPrivate* priv; GncPluginPageRegister* reg_page; - GtkAction* action; + GAction* action; gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE; gboolean has_selection; gboolean is_readwrite = !qof_book_is_readonly (gnc_get_current_book()); @@ -1929,14 +1782,11 @@ gnc_plugin_page_register_update_edit_menu (GncPluginPage* page, gboolean hide) can_paste = is_readwrite; action = gnc_plugin_page_get_action (page, "EditCopyAction"); - gtk_action_set_sensitive (action, can_copy); - gtk_action_set_visible (action, !hide || can_copy); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_copy); action = gnc_plugin_page_get_action (page, "EditCutAction"); - gtk_action_set_sensitive (action, can_cut); - gtk_action_set_visible (action, !hide || can_cut); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_cut); action = gnc_plugin_page_get_action (page, "EditPasteAction"); - gtk_action_set_sensitive (action, can_paste); - gtk_action_set_visible (action, !hide || can_paste); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_paste); } static gboolean is_scrubbing = FALSE; @@ -2101,7 +1951,8 @@ gnc_plugin_page_register_get_tab_color (GncPluginPage* plugin_page) } static void -gnc_plugin_page_register_check_for_empty_group (GKeyFile *state_file, const gchar *state_section) +gnc_plugin_page_register_check_for_empty_group (GKeyFile *state_file, + const gchar *state_section) { gsize num_keys; gchar **keys = g_key_file_get_keys (state_file, state_section, &num_keys, NULL); @@ -2419,7 +2270,8 @@ gnc_plugin_page_register_get_long_name (GncPluginPage* plugin_page) static void gnc_plugin_page_register_summarybar_position_changed (gpointer prefs, - gchar* pref, gpointer user_data) + gchar* pref, + gpointer user_data) { GncPluginPage* plugin_page; GncPluginPageRegister* page; @@ -3631,9 +3483,11 @@ report_helper (GNCLedgerDisplay* ledger, Split* split, Query* query) /************************************************************/ static void -gnc_plugin_page_register_cmd_print_check (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_print_check (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; Split* split; @@ -3643,17 +3497,17 @@ gnc_plugin_page_register_cmd_print_check (GtkAction* action, Account* account; GtkWidget* window; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); ledger_type = gnc_ledger_display_type (priv->ledger); - window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page)); + window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)); 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 (page); split = gnc_split_register_get_current_split (reg); trans = xaccSplitGetParent (split); @@ -3740,14 +3594,16 @@ gnc_plugin_page_register_cmd_print_check (GtkAction* action, static void -gnc_plugin_page_register_cmd_cut (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_cut (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnucash_register_cut_clipboard (priv->gsr->reg); LEAVE (""); @@ -3755,14 +3611,16 @@ gnc_plugin_page_register_cmd_cut (GtkAction* action, static void -gnc_plugin_page_register_cmd_copy (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_copy (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnucash_register_copy_clipboard (priv->gsr->reg); LEAVE (""); @@ -3770,14 +3628,16 @@ gnc_plugin_page_register_cmd_copy (GtkAction* action, static void -gnc_plugin_page_register_cmd_paste (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_paste (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnucash_register_paste_clipboard (priv->gsr->reg); LEAVE (""); @@ -3785,15 +3645,16 @@ gnc_plugin_page_register_cmd_paste (GtkAction* action, static void -gnc_plugin_page_register_cmd_edit_account (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_edit_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account* account; - GtkWindow* parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE ( - page))); + GtkWindow* parent = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page))); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); account = gnc_plugin_page_register_get_account (page); if (account) gnc_ui_edit_account_window (parent, account); @@ -3802,9 +3663,11 @@ gnc_plugin_page_register_cmd_edit_account (GtkAction* action, static void -gnc_plugin_page_register_cmd_find_account (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_find_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GtkWidget* window; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -3815,15 +3678,17 @@ gnc_plugin_page_register_cmd_find_account (GtkAction* action, static void -gnc_plugin_page_register_cmd_find_transactions (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_find_transactions (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GtkWindow* window; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); window = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); gnc_ui_find_transactions_dialog_create (window, priv->ledger); @@ -3832,16 +3697,18 @@ gnc_plugin_page_register_cmd_find_transactions (GtkAction* action, static void -gnc_plugin_page_register_cmd_edit_tax_options (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_edit_tax_options (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GtkWidget *window; Account* account; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)); account = gnc_plugin_page_register_get_account (page); @@ -3850,31 +3717,35 @@ gnc_plugin_page_register_cmd_edit_tax_options (GtkAction* action, } static void -gnc_plugin_page_register_cmd_cut_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_cut_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_cut_txn_handler (priv->gsr, NULL); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_copy_transaction (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_copy_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); gnc_split_register_copy_current (reg); @@ -3883,15 +3754,17 @@ gnc_plugin_page_register_cmd_copy_transaction (GtkAction* action, static void -gnc_plugin_page_register_cmd_paste_transaction (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_paste_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); gnc_split_register_paste_current (reg); @@ -3900,9 +3773,11 @@ gnc_plugin_page_register_cmd_paste_transaction (GtkAction* action, static void -gnc_plugin_page_register_cmd_void_transaction (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_void_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GtkWidget* dialog, *entry; SplitRegister* reg; @@ -3912,7 +3787,7 @@ gnc_plugin_page_register_cmd_void_transaction (GtkAction* action, gint result; GtkWindow* window; - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -3967,14 +3842,16 @@ gnc_plugin_page_register_cmd_void_transaction (GtkAction* action, static void -gnc_plugin_page_register_cmd_unvoid_transaction (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_unvoid_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; Transaction* trans; - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -3989,9 +3866,11 @@ gnc_plugin_page_register_cmd_unvoid_transaction (GtkAction* action, static void -gnc_plugin_page_register_cmd_reverse_transaction (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; GNCSplitReg* gsr; @@ -4001,7 +3880,7 @@ gnc_plugin_page_register_cmd_reverse_transaction (GtkAction* action, Account *account; Split *split; - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4064,8 +3943,7 @@ gnc_plugin_page_register_cmd_reverse_transaction (GtkAction* action, static gboolean gnc_plugin_page_register_show_fs_save (GncPluginPageRegister* page) { - GncPluginPageRegisterPrivate* priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE ( - page); + GncPluginPageRegisterPrivate* priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); GNCLedgerDisplayType ledger_type = gnc_ledger_display_type (priv->ledger); SplitRegister* reg = gnc_ledger_display_get_split_register (priv->ledger); @@ -4090,9 +3968,11 @@ gnc_plugin_page_register_show_fs_save (GncPluginPageRegister* page) } static void -gnc_plugin_page_register_cmd_view_sort_by (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_view_sort_by (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; GtkWidget* dialog, *button; @@ -4102,7 +3982,7 @@ gnc_plugin_page_register_cmd_view_sort_by (GtkAction* action, gchar* title; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); if (priv->sd.dialog) @@ -4175,9 +4055,11 @@ gnc_plugin_page_register_cmd_view_sort_by (GtkAction* action, } static void -gnc_plugin_page_register_cmd_view_filter_by (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_view_filter_by (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GtkWidget* dialog, *toggle, *button, *table, *hbox; time64 start_time, end_time, time_val; @@ -4188,7 +4070,7 @@ gnc_plugin_page_register_cmd_view_filter_by (GtkAction* action, int i; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); if (priv->fd.dialog) @@ -4365,17 +4247,19 @@ gnc_plugin_page_register_cmd_view_filter_by (GtkAction* action, } static void -gnc_plugin_page_register_cmd_reload (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_reload (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; - ENTER ("(action %p, page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); /* Check for trans being edited */ @@ -4389,63 +4273,75 @@ gnc_plugin_page_register_cmd_reload (GtkAction* action, } static void -gnc_plugin_page_register_cmd_style_changed (GtkAction* action, - GtkRadioAction* current, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegisterStyle value; - ENTER ("(action %p, radio action %p, plugin_page %p)", - action, current, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GTK_IS_ACTION (action)); - g_return_if_fail (GTK_IS_RADIO_ACTION (current)); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); + + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); + + value = (SplitRegisterStyle)g_variant_get_int32 (parameter); + + g_action_change_state (G_ACTION(simple), parameter); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); - value = gtk_radio_action_get_current_value (current); gnc_split_reg_change_style (priv->gsr, value, priv->enable_refresh); - gnc_plugin_page_register_ui_update (NULL, plugin_page); + gnc_plugin_page_register_ui_update (NULL, page); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_style_double_line (GtkToggleAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_style_double_line (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; gboolean use_double_line; + GVariant *state; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GTK_IS_ACTION (action)); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER(page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); - use_double_line = gtk_toggle_action_get_active (action); + state = g_action_get_state (G_ACTION(simple)); + + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state))); + + use_double_line = !g_variant_get_boolean (state); + if (use_double_line != reg->use_double_line) { gnc_split_register_config (reg, reg->type, reg->style, use_double_line); if (priv->enable_refresh) gnc_ledger_display_refresh (priv->ledger); } + g_variant_unref (state); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_transfer (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_transfer (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account* account; GncWindow* gnc_window; GtkWidget* window; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4457,14 +4353,16 @@ gnc_plugin_page_register_cmd_transfer (GtkAction* action, } static void -gnc_plugin_page_register_cmd_reconcile (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_reconcile (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account* account; GtkWindow* window; RecnWindow* recnData; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4478,13 +4376,15 @@ gnc_plugin_page_register_cmd_reconcile (GtkAction* action, } static void -gnc_plugin_page_register_cmd_stock_assistant (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_stock_assistant (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account *account; GtkWindow *window; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window)); @@ -4495,14 +4395,16 @@ gnc_plugin_page_register_cmd_stock_assistant (GtkAction* action, } static void -gnc_plugin_page_register_cmd_autoclear (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_autoclear (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account* account; GtkWindow* window; AutoClearWindow* autoClearData; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4516,13 +4418,15 @@ gnc_plugin_page_register_cmd_autoclear (GtkAction* action, } static void -gnc_plugin_page_register_cmd_stock_split (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_stock_split (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account* account; GtkWindow* window; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4533,13 +4437,15 @@ gnc_plugin_page_register_cmd_stock_split (GtkAction* action, } static void -gnc_plugin_page_register_cmd_lots (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_lots (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GtkWindow* window; Account* account; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4551,96 +4457,108 @@ gnc_plugin_page_register_cmd_lots (GtkAction* action, } static void -gnc_plugin_page_register_cmd_enter_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_enter_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnc_split_reg_enter (priv->gsr, FALSE); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_cancel_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_cancel_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnc_split_register_cancel_cursor_trans_changes (gnc_ledger_display_get_split_register (priv->ledger)); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_delete_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_delete_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_delete_handler (priv->gsr, NULL); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_linked_transaction (GtkAction *action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_linked_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_doclink_handler (priv->gsr); - gnc_plugin_page_register_ui_update (NULL, plugin_page); + gnc_plugin_page_register_ui_update (NULL, page); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_linked_transaction_open (GtkAction *action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_linked_transaction_open (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_doclink_open_handler (priv->gsr); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_linked_transaction_remove (GtkAction *action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_linked_transaction_remove (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_doclink_remove_handler (priv->gsr); - gnc_plugin_page_register_ui_update (NULL, plugin_page); + gnc_plugin_page_register_ui_update (NULL, page); LEAVE (" "); } @@ -4683,23 +4601,25 @@ GList* invoices_from_transaction (Transaction* trans) } static void -gnc_plugin_page_register_cmd_jump_linked_invoice (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_jump_linked_invoice (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; GncInvoice* invoice; Transaction *txn; GtkWidget *window; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->gsr->ledger); txn = gnc_split_register_get_current_trans (reg); invoice = invoice_from_split (gnc_split_register_get_current_split (reg)); - window = GNC_PLUGIN_PAGE(plugin_page)->window; + window = GNC_PLUGIN_PAGE(page)->window; if (!invoice) { @@ -4754,17 +4674,19 @@ Please choose one:"), _("Select"), 0, details); } static void -gnc_plugin_page_register_cmd_blank_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_blank_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); if (gnc_split_register_save (reg, TRUE)) @@ -4775,15 +4697,17 @@ gnc_plugin_page_register_cmd_blank_transaction (GtkAction* action, } static void -gnc_plugin_page_register_cmd_goto_date (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GNCSplitReg* gsr; Query* query; time64 date = gnc_time (NULL); GList *splits; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); if (!gnc_dup_time64_dialog (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)), @@ -4812,69 +4736,85 @@ gnc_plugin_page_register_cmd_goto_date (GtkAction* action, } static void -gnc_plugin_page_register_cmd_duplicate_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_duplicate_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnc_split_register_duplicate_current (gnc_ledger_display_get_split_register (priv->ledger)); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_reinitialize_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_reinitialize_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_reinit_handler (priv->gsr, NULL); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_expand_transaction (GtkToggleAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_expand_transaction (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; gboolean expand; + GVariant *state; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); - expand = gtk_toggle_action_get_active (action); + + state = g_action_get_state (G_ACTION(simple)); + + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state))); + + expand = !g_variant_get_boolean (state); + gnc_split_register_expand_current_trans (reg, expand); + g_variant_unref (state); LEAVE (" "); } /** Callback for "Edit Exchange Rate" menu item. */ static void -gnc_plugin_page_register_cmd_exchange_rate (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_exchange_rate (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); /* XXX Ignore the return value -- we don't care if this succeeds */ @@ -4883,9 +4823,11 @@ gnc_plugin_page_register_cmd_exchange_rate (GtkAction* action, } static void -gnc_plugin_page_register_cmd_jump (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GncPluginPage* new_page; GtkWidget* window; @@ -4895,12 +4837,12 @@ gnc_plugin_page_register_cmd_jump (GtkAction* action, Account* leader; Split* split; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); - window = GNC_PLUGIN_PAGE (plugin_page)->window; + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); + window = GNC_PLUGIN_PAGE (page)->window; if (window == NULL) { LEAVE ("no window"); @@ -4965,24 +4907,27 @@ gnc_plugin_page_register_cmd_jump (GtkAction* action, } static void -gnc_plugin_page_register_cmd_schedule (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_schedule (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GtkWindow* window; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); window = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE ( - plugin_page))); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + page))); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_schedule_handler (priv->gsr, window); LEAVE (" "); } -static void scrub_split (Split *split) +static void +scrub_split (Split *split) { Account *acct; Transaction *trans; @@ -5004,19 +4949,21 @@ static void scrub_split (Split *split) } static void -gnc_plugin_page_register_cmd_scrub_current (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_scrub_current (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; Query* query; Split* split; SplitRegister* reg; - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); query = gnc_ledger_display_get_query (priv->ledger); if (query == NULL) { @@ -5056,9 +5003,11 @@ scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointer data) } static void -gnc_plugin_page_register_cmd_scrub_all (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_scrub_all (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; Query* query; GncWindow* window; @@ -5067,11 +5016,11 @@ gnc_plugin_page_register_cmd_scrub_all (GtkAction* action, gulong scrub_kp_handler_ID; const char* message = _ ("Checking splits in current register: %u of %u"); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); query = gnc_ledger_display_get_query (priv->ledger); if (!query) { @@ -5082,7 +5031,7 @@ gnc_plugin_page_register_cmd_scrub_all (GtkAction* action, gnc_suspend_gui_refresh(); is_scrubbing = TRUE; gnc_set_abort_scrub (FALSE); - window = GNC_WINDOW (GNC_PLUGIN_PAGE (plugin_page)->window); + window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window); scrub_kp_handler_ID = g_signal_connect (G_OBJECT (window), "key-press-event", G_CALLBACK (scrub_kp_handler), NULL); gnc_window_set_progressbar_window (window); @@ -5122,19 +5071,21 @@ gnc_plugin_page_register_cmd_scrub_all (GtkAction* action, } static void -gnc_plugin_page_register_cmd_account_report (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_account_report (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GncMainWindow* window; int id; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (plugin_page)->window); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (page)->window); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); id = report_helper (priv->ledger, NULL, NULL); if (id >= 0) gnc_main_window_open_report (id, window); @@ -5142,9 +5093,11 @@ gnc_plugin_page_register_cmd_account_report (GtkAction* action, } static void -gnc_plugin_page_register_cmd_transaction_report (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_transaction_report (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GncMainWindow* window; SplitRegister* reg; @@ -5153,11 +5106,11 @@ gnc_plugin_page_register_cmd_transaction_report (GtkAction* action, int id; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); split = gnc_split_register_get_current_split (reg); @@ -5171,7 +5124,7 @@ gnc_plugin_page_register_cmd_transaction_report (GtkAction* action, xaccQueryAddGUIDMatch (query, xaccSplitGetGUID (split), GNC_ID_SPLIT, QOF_QUERY_AND); - window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (plugin_page)->window); + window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (page)->window); id = report_helper (priv->ledger, split, query); if (id >= 0) gnc_main_window_open_report (id, window); @@ -5214,16 +5167,16 @@ gnc_plugin_page_register_get_gsr (GncPluginPage* plugin_page) static void gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr, - GncPluginPageRegister* register_page) + GncPluginPageRegister* page) { GncPluginPageRegisterPrivate* priv; SplitRegister* reg; GncWindow* window; char* help; - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (register_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - window = GNC_WINDOW (GNC_PLUGIN_PAGE (register_page)->window); + window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window); if (!window) { // This routine can be called before the page is added to a @@ -5232,27 +5185,27 @@ gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr, } // only update status text if on current page - if (GNC_IS_MAIN_WINDOW(window) && (gnc_main_window_get_current_page - (GNC_MAIN_WINDOW(window)) != GNC_PLUGIN_PAGE(register_page))) + if (GNC_IS_MAIN_WINDOW(window) && + (gnc_main_window_get_current_page (GNC_MAIN_WINDOW(window)) != GNC_PLUGIN_PAGE(page))) return; /* Get the text from the ledger */ - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (register_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); help = gnc_table_get_help (reg->table); - gnc_window_set_status (window, GNC_PLUGIN_PAGE (register_page), help); + gnc_window_set_status (window, GNC_PLUGIN_PAGE (page), help); g_free (help); } static void gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr, - GncPluginPageRegister* register_page) + GncPluginPageRegister* page) { GncWindow* window; - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (register_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - window = GNC_WINDOW (GNC_PLUGIN_PAGE (register_page)->window); + window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window); if (!window) { // This routine can be called before the page is added to a @@ -5260,7 +5213,7 @@ gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr, return; } gnc_main_window_popup_menu_cb (GTK_WIDGET (window), - GNC_PLUGIN_PAGE (register_page)); + GNC_PLUGIN_PAGE (page)); } static void diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index 52fa4f0453..f6f12f1470 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -61,6 +61,7 @@ extern "C" #include "gnc-html-factory.h" #include "gnc-file.h" #include "gnc-filepath-utils.h" +#include "gnc-gtk-utils.h" #include "gnc-plugin.h" #include "gnc-plugin-page-report.h" #include "gnc-plugin-file-history.h" @@ -126,12 +127,13 @@ typedef struct GncPluginPageReportPrivate SCM edited_reports; /* The page is in the process of reloading the html */ - gboolean reloading; + gboolean reloading; gboolean loaded; /// the gnc_html abstraction this PluginPage contains // gnc_html *html; GncHtml *html; + gboolean webkit2; /// the container the above HTML widget is in. GtkContainer *container; @@ -174,19 +176,66 @@ static void gnc_plugin_page_report_option_change_cb(gpointer data); void gnc_plugin_page_report_remove_edited_report(GncPluginPageReportPrivate *priv, SCM report); void gnc_plugin_page_report_add_edited_report(GncPluginPageReportPrivate *priv, SCM report); +static void gnc_plugin_page_report_menu_updates (GncPluginPage *plugin_page); void gnc_plugin_page_report_raise_editor(SCM report); -static void gnc_plugin_page_report_forw_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_back_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_reload_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_stop_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_save_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_save_as_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_export_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_options_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_print_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_exportpdf_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_copy_cb(GtkAction *action, GncPluginPageReport *rep); +static void gnc_plugin_page_report_forw_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_back_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_reload_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_stop_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_save_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_save_as_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_export_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_options_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_print_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_exportpdf_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_copy_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_edit_tax_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); + +static GActionEntry report_actions[] = +{ + { "FilePrintAction", gnc_plugin_page_report_print_cb, nullptr, nullptr, nullptr }, + { "FilePrintPDFAction", gnc_plugin_page_report_exportpdf_cb, nullptr, nullptr, nullptr }, + { "EditCopyAction", gnc_plugin_page_report_copy_cb, nullptr, nullptr, nullptr }, + { "EditTaxOptionsAction", gnc_plugin_page_report_edit_tax_cb, nullptr, nullptr, nullptr }, + { "ViewRefreshAction", gnc_plugin_page_report_reload_cb, nullptr, nullptr, nullptr }, + { "ReportSaveAction", gnc_plugin_page_report_save_cb, nullptr, nullptr, nullptr }, + { "ReportSaveAsAction", gnc_plugin_page_report_save_as_cb, nullptr, nullptr, nullptr }, + { "ReportExportAction", gnc_plugin_page_report_export_cb, nullptr, nullptr, nullptr }, + { "ReportOptionsAction", gnc_plugin_page_report_options_cb, nullptr, nullptr, nullptr }, + { "ReportBackAction", gnc_plugin_page_report_back_cb, nullptr, nullptr, nullptr }, + { "ReportForwAction", gnc_plugin_page_report_forw_cb, nullptr, nullptr, nullptr }, + { "ReportReloadAction", gnc_plugin_page_report_reload_cb, nullptr, nullptr, nullptr }, + { "ReportStopAction", gnc_plugin_page_report_stop_cb, nullptr, nullptr, nullptr }, +}; +static guint num_report_actions = G_N_ELEMENTS(report_actions); + +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder3", + "FilePlaceholder4", + "FilePlaceholder5", + "EditPlaceholder6", + "ReportsPlaceholder1", + NULL, +}; + +/** Short labels for use on the toolbar buttons. */ +static GncToolBarShortNames toolbar_labels[] = +{ + { "FilePrintAction", N_("Print") }, + { "ReportExportAction", N_("Export") }, + { "ReportOptionsAction", N_("Options") }, + /* Translators: This string is meant to be a short alternative for "Save Report Configuration" + to be used as toolbar button label. */ + { "ReportSaveAction", N_("Save Config") }, + /* Translators: This string is meant to be a short alternative for "Save Report Configuration As..." + to be used as toolbar button label. */ + { "ReportSaveAsAction", N_("Save Config As...") }, + { "FilePrintPDFAction", N_("Make Pdf") }, + { nullptr, nullptr }, +}; static void gnc_plugin_page_report_get_property( GObject *obj, @@ -249,10 +298,27 @@ gnc_plugin_page_report_focus_widget (GncPluginPage *report_plugin_page) { GncPluginPageReportPrivate *priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report_plugin_page); GtkWidget *window; + GAction *action; if (!priv) return FALSE; + /* Disable the Transaction Menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(report_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(report_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(report_plugin_page->window), + report_plugin_page, + gnc_plugin_load_ui_items); + + // setup any short toolbar names + gnc_main_window_init_short_names (GNC_MAIN_WINDOW(report_plugin_page->window), toolbar_labels); + + gnc_plugin_page_report_menu_updates (report_plugin_page); + window = gnc_plugin_page_get_window (report_plugin_page); if (window && !gnc_main_window_is_restoring_pages (GNC_MAIN_WINDOW(window))) @@ -433,7 +499,7 @@ gnc_plugin_page_report_create_widget( GncPluginPage *page ) GncPluginPageReport *report; GncPluginPageReportPrivate *priv; GtkWindow *topLvl; - GtkAction *action; + GAction *action; GtkWidget *webview; URLType type; char * id_name; @@ -443,16 +509,14 @@ gnc_plugin_page_report_create_widget( GncPluginPage *page ) ENTER("page %p", page); -#ifndef WEBKIT1 - /* Hide the ExportPdf action for Webkit2 */ - action = gnc_plugin_page_get_action (page, "FilePrintPDFAction"); - gtk_action_set_sensitive (action, FALSE); - gtk_action_set_visible (action, FALSE); -#endif - report = GNC_PLUGIN_PAGE_REPORT(page); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); +#ifndef WEBKIT1 + /* Hide the ExportPdf action for Webkit2 */ + priv->webkit2 = TRUE; +#endif + topLvl = gnc_ui_get_main_window (nullptr); // priv->html = gnc_html_new( topLvl ); priv->html = gnc_html_factory_create_html(); @@ -580,10 +644,9 @@ gnc_plugin_page_report_setup( GncPluginPage *ppage ) * called after a report is loaded into the gnc_html widget ********************************************************************/ static void -//gnc_plugin_page_report_load_cb(gnc_html * html, URLType type, -gnc_plugin_page_report_load_cb(GncHtml * html, URLType type, - const gchar * location, const gchar * label, - gpointer data) +gnc_plugin_page_report_load_cb (GncHtml * html, URLType type, + const gchar * location, const gchar * label, + gpointer data) { GncPluginPageReport *report = GNC_PLUGIN_PAGE_REPORT(data); GncPluginPageReportPrivate *priv; @@ -734,7 +797,7 @@ gnc_plugin_page_report_option_change_cb(gpointer data) gnc_utf8_strip_invalid_and_controls(new_name); ENTER("Cleaned-up new report name: %s", new_name); main_window_update_page_name(GNC_PLUGIN_PAGE(report), new_name); - } + } g_free(new_name); /* it's probably already dirty, but make sure */ @@ -1055,17 +1118,15 @@ gnc_plugin_page_report_name_changed (GncPluginPage *page, const gchar *name) static void gnc_plugin_page_report_update_edit_menu (GncPluginPage *page, gboolean hide) { - GtkAction *action; + GncMainWindow *window = (GncMainWindow*)gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page)); + GAction *action; - action = gnc_plugin_page_get_action (page, "EditCopyAction"); - gtk_action_set_sensitive (action, TRUE); - gtk_action_set_visible (action, TRUE); - action = gnc_plugin_page_get_action (page, "EditCutAction"); - gtk_action_set_sensitive (action, FALSE); - gtk_action_set_visible (action, !hide); - action = gnc_plugin_page_get_action (page, "EditPasteAction"); - gtk_action_set_sensitive (action, FALSE); - gtk_action_set_visible (action, !hide); + action = gnc_main_window_find_action (window, "EditCopyAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + action = gnc_main_window_find_action (window, "EditCutAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + action = gnc_main_window_find_action (window, "EditPasteAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); } static gboolean @@ -1124,22 +1185,6 @@ gnc_plugin_page_report_destroy(GncPluginPageReportPrivate * priv) scm_gc_unprotect_object(priv->edited_reports); } -/** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = -{ - { "FilePrintAction", N_("Print") }, - { "ReportExportAction", N_("Export") }, - { "ReportOptionsAction", N_("Options") }, - /* Translators: This string is meant to be a short alternative for "Save Report Configuration" - to be used as toolbar button label. */ - { "ReportSaveAction", N_("Save Config") }, - /* Translators: This string is meant to be a short alternative for "Save Report Configuration As…" - to be used as toolbar button label. */ - { "ReportSaveAsAction", N_("Save Config As…") }, - { "FilePrintPDFAction", N_("Make Pdf") }, - { nullptr, nullptr }, -}; - static const gchar *initially_insensitive_actions[] = { nullptr @@ -1178,13 +1223,40 @@ gnc_plugin_page_report_constructor(GType this_type, guint n_properties, GObjectC } static void -gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint reportId) +gnc_plugin_page_report_menu_update (GncPluginPage *plugin_page, + action_toolbar_labels *tooltip_list) +{ + GncMainWindow *window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window); + GtkWidget *tool_item; + + for (gint i = 0; (tooltip_list[i].action_name != nullptr); i++) + { + gboolean found = gnc_main_window_update_menu_for_action (window, + tooltip_list[i].action_name, + _(tooltip_list[i].label), + _(tooltip_list[i].tooltip)); + + tool_item = gnc_main_window_toolbar_find_tool_item (window, + tooltip_list[i].action_name); + if (tool_item) + { // only need to update the tooltip here + gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(tooltip_list[i].tooltip)); + g_object_set (G_OBJECT(tool_item), "has-tooltip", false, nullptr); + } + } + // need to add the accelerator keys for the updated menu items + gnc_main_window_menu_add_accelerator_keys (window); +} + +static void +gnc_plugin_page_report_menu_updates (GncPluginPage *plugin_page) { GncPluginPageReportPrivate *priv; - GtkActionGroup *action_group; - GncPluginPage *parent; - gboolean use_new; - gchar *name; + GncPluginPageReport *report; + GncMainWindow *window; + action_toolbar_labels tooltip_list[3]; + GAction *action; + gchar *saved_reports_path = gnc_build_userdata_path (SAVED_REPORTS_FILE); gchar *report_save_str = g_strdup_printf ( _("Update the current report's saved configuration. " @@ -1193,118 +1265,70 @@ gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint report _("Add the current report's configuration to the 'Reports->Saved Report Configurations' menu. " "The report configuration will be saved in the file %s."), saved_reports_path); - GtkActionEntry report_actions[] = + report = GNC_PLUGIN_PAGE_REPORT(plugin_page); + priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); + + window = (GncMainWindow*)gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page)); + + tooltip_list[0] = { "ReportSaveAction", N_("Save _Report Configuration"), report_save_str }; + tooltip_list[1] = { "ReportSaveAsAction", N_("Save Report Configuration As..."), report_saveas_str }; + tooltip_list[2] = { nullptr, nullptr, nullptr }; + + gnc_plugin_page_report_menu_update (plugin_page, tooltip_list); + + /* Enable the FilePrintAction */ + action = gnc_main_window_find_action (window, "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), true); + + if (priv->webkit2) { - { - "FilePrintAction", "document-print", N_("_Print Report…"), "p", - N_("Print the current report"), - G_CALLBACK(gnc_plugin_page_report_print_cb) - }, - { - "FilePrintPDFAction", GNC_ICON_PDF_EXPORT, N_("Export as P_DF…"), nullptr, - N_("Export the current report as a PDF document"), - G_CALLBACK(gnc_plugin_page_report_exportpdf_cb) - }, + GtkWidget *pdf_item = gnc_main_window_menu_find_menu_item (window, "FilePrintPDFAction"); + gtk_widget_hide (pdf_item); + } + g_free (saved_reports_path); + g_free (report_save_str); + g_free (report_saveas_str); +} - { - "EditCutAction", "edit-cut", N_("Cu_t"), "X", - N_("Cut the current selection and copy it to clipboard"), - nullptr - }, - { - "EditCopyAction", "edit-copy", N_("_Copy"), "C", - N_("Copy the current selection to clipboard"), - G_CALLBACK(gnc_plugin_page_report_copy_cb) - }, - { - "EditPasteAction", "edit-paste", N_("_Paste"), "V", - N_("Paste the clipboard content at the cursor position"), - nullptr - }, - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), - G_CALLBACK (gnc_plugin_page_report_reload_cb) - }, - { - "ReportSaveAction", "document-save", N_("Save _Report Configuration"), "s", - report_save_str, G_CALLBACK(gnc_plugin_page_report_save_cb) - }, - { - "ReportSaveAsAction", "document-save-as", N_("Save Report Configuration As…"), "s", - report_saveas_str, G_CALLBACK(gnc_plugin_page_report_save_as_cb) - }, - { - "ReportExportAction", "go-next", N_("Export _Report"), nullptr, - N_("Export HTML-formatted report to file"), - G_CALLBACK(gnc_plugin_page_report_export_cb) - }, - { - "ReportOptionsAction", "document-properties", N_("_Report Options"), nullptr, - N_("Edit report options"), - G_CALLBACK(gnc_plugin_page_report_options_cb) - }, +static void +gnc_plugin_page_report_constr_init (GncPluginPageReport *plugin_page, gint reportId) +{ + GncPluginPageReportPrivate *priv; + GSimpleActionGroup *simple_action_group; + GncPluginPage *parent; + gboolean use_new; + gchar *name; - { - "ReportBackAction", "go-previous", N_("Back"), nullptr, - N_("Move back one step in the history"), - G_CALLBACK(gnc_plugin_page_report_back_cb) - }, - { - "ReportForwAction", "go-next", N_("Forward"), nullptr, - N_("Move forward one step in the history"), - G_CALLBACK(gnc_plugin_page_report_forw_cb) - }, - { - "ReportReloadAction", "view-refresh", N_("Reload"), nullptr, - N_("Reload the current page"), - G_CALLBACK(gnc_plugin_page_report_reload_cb) - }, - { - "ReportStopAction", "process-stop", N_("Stop"), nullptr, - N_("Cancel outstanding HTML requests"), - G_CALLBACK(gnc_plugin_page_report_stop_cb) - }, - }; - guint num_report_actions = G_N_ELEMENTS( report_actions ); - - DEBUG( "property reportId=%d", reportId ); + DEBUG("property reportId=%d", reportId); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(plugin_page); priv->reportId = reportId; + priv->webkit2 = FALSE; - gnc_plugin_page_report_setup( GNC_PLUGIN_PAGE(plugin_page) ); + gnc_plugin_page_report_setup( GNC_PLUGIN_PAGE(plugin_page)); /* Init parent declared variables */ parent = GNC_PLUGIN_PAGE(plugin_page); use_new = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REPORT, GNC_PREF_USE_NEW); - name = gnc_report_name( priv->initial_report ); - g_object_set(G_OBJECT(plugin_page), - "page-name", name, - "page-uri", "default:", - "ui-description", "gnc-plugin-page-report-ui.xml", - "use-new-window", use_new, - nullptr); - g_free(name); + name = gnc_report_name (priv->initial_report); + g_object_set (G_OBJECT(plugin_page), + "page-name", name, + "ui-description", "gnc-plugin-page-report.ui", + "use-new-window", use_new, + nullptr); + g_free (name); /* change me when the system supports multiple books */ - gnc_plugin_page_add_book(parent, gnc_get_current_book()); + gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group(parent, - "GncPluginPageReportActions"); - gtk_action_group_add_actions( action_group, - report_actions, - num_report_actions, - plugin_page ); - gnc_plugin_update_actions(action_group, - initially_insensitive_actions, - "sensitive", FALSE); - gnc_plugin_init_short_names (action_group, toolbar_labels); + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageReportActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + report_actions, + num_report_actions, + plugin_page); - g_free (saved_reports_path); - g_free (report_save_str); - g_free (report_saveas_str); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), initially_insensitive_actions, + FALSE); } GncPluginPage* @@ -1362,31 +1386,32 @@ close_handler (gpointer user_data) } static void -gnc_plugin_page_report_set_fwd_button(GncPluginPageReport *report, int enabled) +gnc_plugin_page_report_set_fwd_button (GncPluginPageReport *report, int enabled) { - GtkAction *act; - - act = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(report), - "ReportForwAction" ); - gtk_action_set_sensitive(act, enabled); + GAction *action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(report), + "ReportForwAction"); + if (action != NULL) + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), enabled); } static void -gnc_plugin_page_report_set_back_button(GncPluginPageReport *report, int enabled) +gnc_plugin_page_report_set_back_button (GncPluginPageReport *report, int enabled) { - GtkAction *act; - - act = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(report), - "ReportBackAction" ); - gtk_action_set_sensitive(act, enabled); + GAction *action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(report), + "ReportBackAction"); + if (action != NULL) + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), enabled); } // ------------------------------------------------------------ // GTK ACTION CALLBACKS static void -gnc_plugin_page_report_forw_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_forw_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; gnc_html_history_node * node = nullptr; @@ -1402,8 +1427,11 @@ gnc_plugin_page_report_forw_cb( GtkAction *action, GncPluginPageReport *report ) } static void -gnc_plugin_page_report_back_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_back_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; gnc_html_history_node * node; @@ -1421,12 +1449,15 @@ gnc_plugin_page_report_back_cb( GtkAction *action, GncPluginPageReport *report ) void gnc_plugin_page_report_reload (GncPluginPageReport *report) { - gnc_plugin_page_report_reload_cb (NULL, report); + gnc_plugin_page_report_reload_cb (nullptr, nullptr, report); } static void -gnc_plugin_page_report_reload_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_reload_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPage *page; GncPluginPageReportPrivate *priv; SCM dirty_report; @@ -1461,8 +1492,11 @@ gnc_plugin_page_report_reload_cb( GtkAction *action, GncPluginPageReport *report } static void -gnc_plugin_page_report_stop_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_stop_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); @@ -1618,8 +1652,23 @@ gnc_get_export_filename (SCM choice, GtkWindow *parent) } static void -gnc_plugin_page_report_save_as_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_edit_tax_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; + GtkWidget *window; + + window = GNC_PLUGIN_PAGE(report)->window; + gnc_tax_info_dialog (window, nullptr); +} + +static void +gnc_plugin_page_report_save_as_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; SCM save_func; SCM rpt_id; @@ -1649,8 +1698,11 @@ gnc_plugin_page_report_save_as_cb( GtkAction *action, GncPluginPageReport *repor } static void -gnc_plugin_page_report_save_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_save_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; SCM check_func, save_func; SCM rpt_id; @@ -1675,13 +1727,16 @@ gnc_plugin_page_report_save_cb( GtkAction *action, GncPluginPageReport *report ) * So let's create a new report template based on this report * and allow the user to change the name. */ - gnc_plugin_page_report_save_as_cb (action, report); + gnc_plugin_page_report_save_as_cb (simple, parameter, report); } } static void -gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_export_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; char * filepath; SCM export_types; @@ -1745,10 +1800,10 @@ gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report g_free (str); } else - gnc_error_dialog (parent, "%s", - _("This report must be upgraded to return a " - "document object with export-string or " - "export-error.")); + gnc_error_dialog (parent, "%s", + _("This report must be upgraded to return a " + "document object with export-string or " + "export-error.")); } result = TRUE; } @@ -1768,8 +1823,11 @@ gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report } static void -gnc_plugin_page_report_options_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_options_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; GtkWindow *parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (report))); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); @@ -1934,8 +1992,11 @@ static gchar *report_create_jobname(GncPluginPageReportPrivate *priv) } static void -gnc_plugin_page_report_print_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_print_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); gchar *job_name = report_create_jobname(priv); @@ -1951,8 +2012,11 @@ gnc_plugin_page_report_print_cb( GtkAction *action, GncPluginPageReport *report } static void -gnc_plugin_page_report_exportpdf_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_exportpdf_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); gchar *job_name = report_create_jobname(priv); GncInvoice *invoice; @@ -1966,19 +2030,19 @@ gnc_plugin_page_report_exportpdf_cb( GtkAction *action, GncPluginPageReport *rep owner = (GncOwner*) gncInvoiceGetOwner(invoice); if (owner) { - QofInstance *inst = qofOwnerGetOwner (owner); - gchar *dirname = nullptr; - qof_instance_get (inst, "export-pdf-dir", &dirname, nullptr); + QofInstance *inst = qofOwnerGetOwner (owner); + gchar *dirname = nullptr; + qof_instance_get (inst, "export-pdf-dir", &dirname, nullptr); // Yes. In the kvp, look up the key for the Export-PDF output // directory. If it exists, prepend this to the job name so that // we can export to PDF. - if (dirname && g_file_test(dirname, - (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) - { - gchar *tmp = g_build_filename(dirname, job_name, nullptr); - g_free(job_name); - job_name = tmp; - } + if (dirname && g_file_test (dirname, + (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) + { + gchar *tmp = g_build_filename (dirname, job_name, nullptr); + g_free (job_name); + job_name = tmp; + } } } @@ -1992,35 +2056,36 @@ gnc_plugin_page_report_exportpdf_cb( GtkAction *action, GncPluginPageReport *rep if (owner) { - /* As this is an invoice report with some owner, we will try - * to look up the chosen output directory from the print - * settings and store it again in the owner kvp. - */ + /* As this is an invoice report with some owner, we will try + * to look up the chosen output directory from the print + * settings and store it again in the owner kvp. + */ GtkPrintSettings *print_settings = gnc_print_get_settings(); - if (print_settings && - gtk_print_settings_has_key(print_settings, - GNC_GTK_PRINT_SETTINGS_EXPORT_DIR)) + if (print_settings && gtk_print_settings_has_key (print_settings, + GNC_GTK_PRINT_SETTINGS_EXPORT_DIR)) { - const char* dirname = gtk_print_settings_get(print_settings, - GNC_GTK_PRINT_SETTINGS_EXPORT_DIR); + const char* dirname = gtk_print_settings_get (print_settings, + GNC_GTK_PRINT_SETTINGS_EXPORT_DIR); // Only store the directory if it exists. - if (g_file_test(dirname, + if (g_file_test (dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { - QofInstance *inst = qofOwnerGetOwner(owner); - gncOwnerBeginEdit(owner); - qof_instance_set (inst, "export-pdf-dir", dirname); - gncOwnerCommitEdit(owner); + QofInstance *inst = qofOwnerGetOwner (owner); + gncOwnerBeginEdit (owner); + qof_instance_set (inst, "export-pdf-dir", dirname); + gncOwnerCommitEdit (owner); } } } - g_free (job_name); } static void -gnc_plugin_page_report_copy_cb(GtkAction *action, GncPluginPageReport *report) +gnc_plugin_page_report_copy_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c index 2935a99eb7..34d1bbc421 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.c +++ b/gnucash/gnome/gnc-plugin-page-sx-list.c @@ -62,6 +62,7 @@ #include "gnc-glib-utils.h" #include "gnc-icons.h" #include "gnc-main-window.h" +#include "gnc-plugin.h" #include "gnc-plugin-page-sx-list.h" #include "gnc-session.h" #include "gnc-sx-instance-dense-cal-adapter.h" @@ -119,38 +120,37 @@ static GncPluginPage *gnc_plugin_page_sx_list_recreate_page (GtkWidget *window, static void gppsl_row_activated_cb (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data); -static void gnc_plugin_page_sx_list_cmd_new (GtkAction *action, GncPluginPageSxList *page); -static void gnc_plugin_page_sx_list_cmd_edit (GtkAction *action, GncPluginPageSxList *page); -static void gnc_plugin_page_sx_list_cmd_delete (GtkAction *action, GncPluginPageSxList *page); -static void gnc_plugin_page_sx_list_cmd_refresh (GtkAction *action, GncPluginPageSxList *page); +static void gnc_plugin_page_sx_list_cmd_new (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +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 GtkActionEntry gnc_plugin_page_sx_list_actions [] = +static GActionEntry gnc_plugin_page_sx_list_actions [] = { - { "SxListAction", NULL, N_("_Scheduled"), NULL, NULL, NULL }, - { - "SxListNewAction", GNC_ICON_NEW_ACCOUNT, N_("_New"), NULL, - N_("Create a new scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_new) - }, - { - "SxListEditAction", GNC_ICON_EDIT_ACCOUNT, N_("_Edit"), NULL, - N_("Edit the selected scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_edit) - }, - { - "SxListDeleteAction", GNC_ICON_DELETE_ACCOUNT, N_("_Delete"), NULL, - N_("Delete the selected scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_delete) - }, - - /* View menu */ - - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_refresh) - }, + { "SxListAction", NULL, NULL, NULL, NULL }, + { "SxListNewAction", gnc_plugin_page_sx_list_cmd_new, NULL, NULL, NULL }, + { "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); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder3", + "EditPlaceholder3", + "EditPlaceholder5", + "ViewPlaceholder4", + "SchedulePlaceholder0", + NULL, +}; + + GncPluginPage * gnc_plugin_page_sx_list_new (void) { @@ -178,6 +178,20 @@ 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); + /* Disable the FilePrintAction */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(sx_plugin_page->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu_and_toolbar (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))) @@ -211,26 +225,22 @@ gnc_plugin_page_sx_list_class_init (GncPluginPageSxListClass *klass) static void gnc_plugin_page_sx_list_init (GncPluginPageSxList *plugin_page) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GncPluginPage *parent; /* Init parent declared variables */ parent = GNC_PLUGIN_PAGE(plugin_page); g_object_set(G_OBJECT(plugin_page), "page-name", _("Scheduled Transactions"), - "page-uri", "default:", - "ui-description", "gnc-plugin-page-sx-list-ui.xml", + "ui-description", "gnc-plugin-page-sx-list.ui", NULL); gnc_plugin_page_add_book (parent, gnc_get_current_book()); - action_group = - gnc_plugin_page_create_action_group (parent, - "GncPluginPageSxListActions"); - gtk_action_group_add_actions (action_group, - gnc_plugin_page_sx_list_actions, - gnc_plugin_page_sx_list_n_actions, - plugin_page); - /* gnc_plugin_init_short_names (action_group, toolbar_labels); */ + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageSxListActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_sx_list_actions, + gnc_plugin_page_sx_list_n_actions, + plugin_page); } @@ -304,18 +314,17 @@ static void gppsl_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data) { GncPluginPage *page; - GtkAction *edit_action, *delete_action; + GAction *edit_action, *delete_action; gboolean selection_state = TRUE; page = GNC_PLUGIN_PAGE(user_data); edit_action = gnc_plugin_page_get_action (page, "SxListEditAction"); delete_action = gnc_plugin_page_get_action (page, "SxListDeleteAction"); - selection_state - = gtk_tree_selection_count_selected_rows (selection) == 0 - ? FALSE - : TRUE; - gtk_action_set_sensitive (edit_action, selection_state); - gtk_action_set_sensitive (delete_action, selection_state); + selection_state = gtk_tree_selection_count_selected_rows (selection) == 0 + ? FALSE + : TRUE; + g_simple_action_set_enabled (G_SIMPLE_ACTION(edit_action), selection_state); + g_simple_action_set_enabled (G_SIMPLE_ACTION(delete_action), selection_state); } @@ -376,26 +385,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, page); - return; -} - -static void -gpps_edit_cb (GtkMenuItem *menuitem, GncPluginPageSxList *page) -{ - gnc_plugin_page_sx_list_cmd_edit (NULL, page); - return; -} - -static void -gpps_delete_cb (GtkMenuItem *menuitem, GncPluginPageSxList *page) -{ - gnc_plugin_page_sx_list_cmd_delete (NULL, page); - return; -} static void treeview_popup (GtkTreeView *treeview, GdkEvent *event, GncPluginPageSxList *page) @@ -405,21 +394,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); @@ -516,6 +511,14 @@ gnc_plugin_page_sx_list_create_widget (GncPluginPage *plugin_page) priv->instances = GNC_SX_INSTANCE_MODEL(gnc_sx_get_instances (&end, TRUE)); } + { + GAction *edit_action, *delete_action; + edit_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "SxListEditAction"); + delete_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "SxListDeleteAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(edit_action), FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(delete_action), FALSE); + } + { GtkTreeSelection *selection; GtkTreePath *path = gtk_tree_path_new_first (); @@ -529,15 +532,14 @@ 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); } g_signal_connect (G_OBJECT(priv->tree_view), "button-press-event", @@ -705,9 +707,12 @@ gnc_plugin_page_sx_list_recreate_page (GtkWidget *window, static void -gnc_plugin_page_sx_list_cmd_new (GtkAction *action, GncPluginPageSxList *page) +gnc_plugin_page_sx_list_cmd_new (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - GtkWindow *window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page))); + GncPluginPageSxList *plugin_page = user_data; + GtkWindow *window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); SchedXaction *new_sx; gboolean new_sx_flag = TRUE; @@ -725,17 +730,20 @@ gnc_plugin_page_sx_list_cmd_new (GtkAction *action, GncPluginPageSxList *page) gnc_sx_set_schedule (new_sx, schedule); } gnc_ui_scheduled_xaction_editor_dialog_create (window, new_sx, new_sx_flag); - gppsl_update_selected_list (page, TRUE, new_sx); + gppsl_update_selected_list (plugin_page, TRUE, new_sx); } static void -gnc_plugin_page_sx_list_cmd_refresh (GtkAction *action, GncPluginPageSxList *page) +gnc_plugin_page_sx_list_cmd_refresh (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageSxList *plugin_page = user_data; GncPluginPageSxListPrivate *priv; - g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(plugin_page)); - priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page); + priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page); gtk_widget_queue_draw (priv->widget); } @@ -754,10 +762,13 @@ _argument_reorder_fn (GtkTreePath* list_path_data, GncTreeViewSxList* user_tree_ static void -gnc_plugin_page_sx_list_cmd_edit (GtkAction *action, GncPluginPageSxList *page) +gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page); - GtkWindow *window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page))); + GncPluginPageSxList *plugin_page = user_data; + GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page); + GtkWindow *window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); GtkTreeSelection *selection; GList *selected_paths, *to_edit; GtkTreeModel *model; @@ -774,11 +785,11 @@ gnc_plugin_page_sx_list_cmd_edit (GtkAction *action, GncPluginPageSxList *page) (GncGMapFunc)_argument_reorder_fn, priv->tree_view); - gppsl_update_selected_list (page, TRUE, NULL); + gppsl_update_selected_list (plugin_page, TRUE, NULL); for (GList *list = to_edit; list != NULL; list = list->next) { DEBUG ("to-edit [%s]\n", xaccSchedXactionGetName ((SchedXaction*)list->data)); - gppsl_update_selected_list (page, FALSE, list->data); + gppsl_update_selected_list (plugin_page, FALSE, list->data); } g_list_foreach (to_edit, (GFunc)_edit_sx, window); @@ -787,6 +798,21 @@ gnc_plugin_page_sx_list_cmd_edit (GtkAction *action, GncPluginPageSxList *page) 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, @@ -819,9 +845,12 @@ _destroy_sx(gpointer data, gpointer user_data) static void -gnc_plugin_page_sx_list_cmd_delete (GtkAction *action, GncPluginPageSxList *page) +gnc_plugin_page_sx_list_cmd_delete (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page); + GncPluginPageSxList *plugin_page = user_data; + GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page); GtkTreeSelection *selection; GList *selected_paths, *to_delete = NULL; GtkTreeModel *model; @@ -841,7 +870,7 @@ gnc_plugin_page_sx_list_cmd_delete (GtkAction *action, GncPluginPageSxList *page (GncGMapFunc)_argument_reorder_fn, priv->tree_view); - window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page))); + window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); length = g_list_length (to_delete); @@ -852,11 +881,11 @@ gnc_plugin_page_sx_list_cmd_delete (GtkAction *action, GncPluginPageSxList *page if (gnc_verify_dialog (window, FALSE, "%s", message)) { - gppsl_update_selected_list (page, TRUE, NULL); + gppsl_update_selected_list (plugin_page, TRUE, NULL); for (GList *list = to_delete; list != NULL; list = list->next) { DEBUG("to-delete [%s]\n", xaccSchedXactionGetName ((SchedXaction*)list->data)); - gppsl_update_selected_list (page, FALSE, list->data); + gppsl_update_selected_list (plugin_page, FALSE, list->data); } g_list_foreach (to_delete, (GFunc)_destroy_sx, NULL); } diff --git a/gnucash/gnome/gnc-plugin-register.c b/gnucash/gnome/gnc-plugin-register.c index 4d6df65f0e..9e0b5c715b 100644 --- a/gnucash/gnome/gnc-plugin-register.c +++ b/gnucash/gnome/gnc-plugin-register.c @@ -42,20 +42,24 @@ static void gnc_plugin_register_add_to_window (GncPlugin *plugin, GncMainWindow static void gnc_plugin_register_remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type); /* Command callbacks */ -static void gnc_plugin_register_cmd_general_ledger (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_register_cmd_general_ledger (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-register-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-register-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-register.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - { - "ToolsGeneralJournalAction", NULL, N_("_General Journal"), NULL, - N_("Open general journal window"), - G_CALLBACK (gnc_plugin_register_cmd_general_ledger) - }, + { "ToolsGeneralJournalAction", gnc_plugin_register_cmd_general_ledger, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "ToolsPlaceholder2", + NULL, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); typedef struct GncPluginRegisterPrivate { @@ -133,10 +137,11 @@ gnc_plugin_register_class_init (GncPluginRegisterClass *klass) gnc_plugin_register_remove_from_window; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void @@ -206,9 +211,11 @@ gnc_plugin_register_remove_from_window (GncPlugin *plugin, ************************************************************/ static void -gnc_plugin_register_cmd_general_ledger (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_register_cmd_general_ledger (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; GncPluginPage *page; g_return_if_fail (data != NULL); diff --git a/gnucash/gnome/gnc-plugin-report-system.c b/gnucash/gnome/gnc-plugin-report-system.c index 621f001317..c42a9f6472 100644 --- a/gnucash/gnome/gnc-plugin-report-system.c +++ b/gnucash/gnome/gnc-plugin-report-system.c @@ -43,24 +43,25 @@ static void gnc_plugin_report_system_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_report_system_cmd_edit_style_sheet (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_report_system_cmd_edit_style_sheet (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-report-system-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-report-system-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-report-system.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - /* Menu Items */ - { - "EditStyleSheetsAction", NULL, N_("St_yle Sheets"), NULL, - N_("Edit report style sheets"), - G_CALLBACK (gnc_plugin_report_system_cmd_edit_style_sheet) - }, + { "EditStyleSheetsAction", gnc_plugin_report_system_cmd_edit_style_sheet, NULL, NULL, NULL }, }; +/** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "EditPlaceholder4", + NULL, +}; typedef struct GncPluginReportSystemPrivate { @@ -92,10 +93,11 @@ gnc_plugin_report_system_class_init (GncPluginReportSystemClass *klass) plugin_class->plugin_name = GNC_PLUGIN_REPORT_SYSTEM_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void @@ -116,10 +118,12 @@ gnc_plugin_report_system_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_report_system_cmd_edit_style_sheet (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_report_system_cmd_edit_style_sheet (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_style_sheet_dialog_open(GTK_WINDOW (data->window)); + GncMainWindowActionData *data = user_data; + gnc_style_sheet_dialog_open (GTK_WINDOW(data->window)); } /************************************************************ diff --git a/gnucash/gnome/report-menus.scm b/gnucash/gnome/report-menus.scm index 4eb08fa286..5082a6355a 100644 --- a/gnucash/gnome/report-menus.scm +++ b/gnucash/gnome/report-menus.scm @@ -90,7 +90,7 @@ (N_ "Saved Report Configurations") "4d3dcdc8890b11df99dd94cddfd72085" (N_ "Manage and run saved report configurations") - (list "Reports/SavedReportConfigs") + (list "Reports/ZSavedReportConfigs") ;; Added Z so it is last in list (lambda (window) (gnc:debug "called into custom report dialog, window is " window) (gnc-ui-custom-report window)))) diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c index 24a52143cd..f419316e92 100644 --- a/gnucash/gnome/window-reconcile.c +++ b/gnucash/gnome/window-reconcile.c @@ -49,6 +49,7 @@ #include "gnc-event.h" #include "gnc-filepath-utils.h" #include "gnc-gnome-utils.h" +#include "gnc-gtk-utils.h" //#include "gnc-main-window.h" #include "gnc-plugin-page-register.h" #include "gnc-prefs.h" @@ -78,8 +79,9 @@ struct _RecnWindow GtkWidget *window; /* The reconcile window */ - GtkUIManager *ui_merge; - GtkActionGroup *action_group; + GtkBuilder *builder; /* The builder object */ + GSimpleActionGroup *simple_action_group; /* The action group for the window */ + GncPluginPage *page; GtkWidget *starting; /* The starting balance */ @@ -133,9 +135,9 @@ static void recn_destroy_cb (GtkWidget *w, gpointer data); static void recn_cancel (RecnWindow *recnData); static gboolean recn_delete_cb (GtkWidget *widget, GdkEvent *event, gpointer data); static gboolean recn_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer data); -static void recnFinishCB (GtkAction *action, RecnWindow *recnData); -static void recnPostponeCB (GtkAction *action, gpointer data); -static void recnCancelCB (GtkAction *action, gpointer data); +static void recnFinishCB (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void recnPostponeCB (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void recnCancelCB (GSimpleAction *simple, GVariant *parameter, gpointer user_data); void gnc_start_recn_children_changed (GtkWidget *widget, startRecnWindowData *data); void gnc_start_recn_interest_clicked_cb (GtkButton *button, startRecnWindowData *data); @@ -145,24 +147,14 @@ static char * gnc_recn_make_window_name (Account *account); static void gnc_recn_set_window_name (RecnWindow *recnData); static gboolean find_by_account (gpointer find_data, gpointer user_data); - /** GLOBALS ************************************************************/ /* This static indicates the debugging module that this .o belongs to. */ G_GNUC_UNUSED static QofLogModule log_module = GNC_MOD_GUI; static time64 gnc_reconcile_last_statement_date = 0; - /** IMPLEMENTATIONS *************************************************/ -/** An array of all of the actions provided by the main window code. - * This includes some placeholder actions for the menus that are - * visible in the menu bar but have no action associated with - * them. */ -static GtkActionEntry recnWindow_actions []; -/** The number of actions provided by the main window. */ -static guint recnWindow_n_actions; - static gpointer commodity_compare(Account *account, gpointer user_data) { gboolean equal = gnc_commodity_equiv (xaccAccountGetCommodity (account), @@ -265,7 +257,7 @@ recnRecalculateBalance (RecnWindow *recnData) gchar *datestr; GNCPrintAmountInfo print_info; gboolean reverse_balance, include_children; - GtkAction *action; + GAction *action; account = recn_get_account (recnData); if (!account) @@ -301,13 +293,13 @@ recnRecalculateBalance (RecnWindow *recnData) gnc_add_colorized_amount (recnData->reconciled, reconciled, print_info, reverse_balance); gnc_add_colorized_amount (recnData->difference, diff, print_info, reverse_balance); - action = gtk_action_group_get_action (recnData->action_group, - "RecnFinishAction"); - gtk_action_set_sensitive(action, gnc_numeric_zero_p (diff)); + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "RecnFinishAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), gnc_numeric_zero_p (diff)); - action = gtk_action_group_get_action (recnData->action_group, - "TransBalanceAction"); - gtk_action_set_sensitive(action, !gnc_numeric_zero_p (diff)); + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "TransBalanceAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !gnc_numeric_zero_p (diff)); return diff; } @@ -859,7 +851,7 @@ gnc_reconcile_window_set_sensitivity(RecnWindow *recnData) { gboolean sensitive = FALSE; GNCReconcileView *view; - GtkAction *action; + GAction *action; view = GNC_RECONCILE_VIEW(recnData->debit); if (gnc_reconcile_view_num_selected(view) == 1) @@ -869,12 +861,13 @@ gnc_reconcile_window_set_sensitivity(RecnWindow *recnData) if (gnc_reconcile_view_num_selected(view) == 1) sensitive = TRUE; - action = gtk_action_group_get_action (recnData->action_group, - "TransEditAction"); - gtk_action_set_sensitive(action, sensitive); - action = gtk_action_group_get_action (recnData->action_group, - "TransDeleteAction"); - gtk_action_set_sensitive(action, sensitive); + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "TransEditAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive); + + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "TransDeleteAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive); sensitive = FALSE; @@ -886,12 +879,13 @@ gnc_reconcile_window_set_sensitivity(RecnWindow *recnData) if (gnc_reconcile_view_num_selected(view) > 0) sensitive = TRUE; - action = gtk_action_group_get_action (recnData->action_group, - "TransRecAction"); - gtk_action_set_sensitive(action, sensitive); - action = gtk_action_group_get_action (recnData->action_group, - "TransUnRecAction"); - gtk_action_set_sensitive(action, sensitive); + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "TransRecAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive); + + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "TransUnRecAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive); } @@ -929,11 +923,14 @@ gnc_reconcile_window_row_cb(GNCReconcileView *view, gpointer item, static void do_popup_menu(RecnWindow *recnData, GdkEventButton *event) { - GtkWidget *menu = gtk_ui_manager_get_widget (recnData->ui_merge, "/MainPopup"); + GMenuModel *menu_model = (GMenuModel *)gtk_builder_get_object (recnData->builder, + "recwin-popup"); + GtkWidget *menu = gtk_menu_new_from_model (menu_model); if (!menu) return; + gtk_menu_attach_to_widget (GTK_MENU(menu), GTK_WIDGET(recnData->window), NULL); gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event); } @@ -969,23 +966,25 @@ gnc_reconcile_window_button_press_cb (GtkWidget *widget, GdkEventButton *event, RecnWindow *recnData) { - GNCQueryView *qview = GNC_QUERY_VIEW(widget); - GtkTreeSelection *selection; - GtkTreePath *path; - if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { + GNCQueryView *qview = GNC_QUERY_VIEW(widget); + GtkTreePath *path; /* Get tree path for row that was clicked */ - gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(qview), - (gint) event->x, - (gint) event->y, - &path, NULL, NULL, NULL); + gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(qview), + (gint) event->x, + (gint) event->y, + &path, NULL, NULL, NULL); - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(qview)); - gtk_tree_selection_select_path(selection, path); - gtk_tree_path_free(path); - do_popup_menu(recnData, event); + if (path) + { + GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(qview)); + + gtk_tree_selection_select_path (selection, path); + gtk_tree_path_free (path); + } + do_popup_menu (recnData, event); return TRUE; } return FALSE; @@ -1196,17 +1195,21 @@ gnc_reconcile_window_get_current_split(RecnWindow *recnData) static void -gnc_ui_reconcile_window_help_cb(GtkWidget *widget, gpointer data) +gnc_ui_reconcile_window_help_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; gnc_gnome_help (GTK_WINDOW(recnData->window), DF_MANUAL, DL_RECNWIN); } static void -gnc_ui_reconcile_window_change_cb(GtkAction *action, gpointer data) +gnc_ui_reconcile_window_change_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Account *account = recn_get_account (recnData); gnc_numeric new_ending = recnData->new_ending; time64 statement_date = recnData->statement_date; @@ -1224,9 +1227,11 @@ gnc_ui_reconcile_window_change_cb(GtkAction *action, gpointer data) static void -gnc_ui_reconcile_window_balance_cb(GtkButton *button, gpointer data) +gnc_ui_reconcile_window_balance_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; GNCSplitReg *gsr; Account *account; gnc_numeric balancing_amount; @@ -1254,9 +1259,11 @@ gnc_ui_reconcile_window_balance_cb(GtkButton *button, gpointer data) static void -gnc_ui_reconcile_window_rec_cb(GtkButton *button, gpointer data) +gnc_ui_reconcile_window_rec_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; GNCReconcileView *debit, *credit; debit = GNC_RECONCILE_VIEW(recnData->debit); @@ -1268,9 +1275,11 @@ gnc_ui_reconcile_window_rec_cb(GtkButton *button, gpointer data) static void -gnc_ui_reconcile_window_unrec_cb(GtkButton *button, gpointer data) +gnc_ui_reconcile_window_unrec_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; GNCReconcileView *debit, *credit; debit = GNC_RECONCILE_VIEW(recnData->debit); @@ -1363,9 +1372,11 @@ gnc_reconcile_window_delete_set_next_selection (RecnWindow *recnData, Split *spl static void -gnc_ui_reconcile_window_delete_cb(GtkButton *button, gpointer data) +gnc_ui_reconcile_window_delete_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Transaction *trans; Split *split, *next_split; @@ -1398,9 +1409,11 @@ gnc_ui_reconcile_window_delete_cb(GtkButton *button, gpointer data) static void -gnc_ui_reconcile_window_edit_cb(GtkButton *button, gpointer data) +gnc_ui_reconcile_window_edit_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; GNCSplitReg *gsr; Split *split; @@ -1450,9 +1463,11 @@ gnc_recn_set_window_name(RecnWindow *recnData) static void -gnc_recn_edit_account_cb(GtkAction *action, gpointer data) +gnc_recn_edit_account_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Account *account = recn_get_account (recnData); if (account == NULL) @@ -1463,9 +1478,11 @@ gnc_recn_edit_account_cb(GtkAction *action, gpointer data) static void -gnc_recn_xfer_cb(GtkAction *action, gpointer data) +gnc_recn_xfer_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Account *account = recn_get_account (recnData); if (account == NULL) @@ -1476,9 +1493,11 @@ gnc_recn_xfer_cb(GtkAction *action, gpointer data) static void -gnc_recn_scrub_cb(GtkAction *action, gpointer data) +gnc_recn_scrub_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Account *account = recn_get_account (recnData); if (account == NULL) @@ -1498,9 +1517,11 @@ gnc_recn_scrub_cb(GtkAction *action, gpointer data) static void -gnc_recn_open_cb(GtkAction *action, gpointer data) +gnc_recn_open_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; gnc_reconcile_window_open_register(recnData); } @@ -1734,21 +1755,28 @@ recnWindow (GtkWidget *parent, Account *account) } -static void -recnWindow_add_widget (GtkUIManager *merge, - GtkWidget *widget, - GtkBox *dock) +static GActionEntry recWindow_actions_entries [] = { - if (GTK_IS_TOOLBAR (widget)) - { - gtk_toolbar_set_style (GTK_TOOLBAR(widget), - GTK_TOOLBAR_BOTH); - gtk_toolbar_set_icon_size (GTK_TOOLBAR(widget), - GTK_ICON_SIZE_SMALL_TOOLBAR); - } - gtk_box_pack_start (GTK_BOX (dock), widget, FALSE, FALSE, 0); - gtk_widget_show (widget); -} + { "RecnChangeInfoAction", gnc_ui_reconcile_window_change_cb, NULL, NULL, NULL }, + { "RecnFinishAction", recnFinishCB, NULL, NULL, NULL }, + { "RecnPostponeAction", recnPostponeCB, NULL, NULL, NULL }, + { "RecnCancelAction", recnCancelCB, NULL, NULL, NULL }, + + { "AccountOpenAccountAction", gnc_recn_open_cb, NULL, NULL, NULL }, + { "AccountEditAccountAction", gnc_recn_edit_account_cb, NULL, NULL, NULL }, + { "AccountTransferAction", gnc_recn_xfer_cb, NULL, NULL, NULL }, + { "AccountCheckRepairAction", gnc_recn_scrub_cb, NULL, NULL, NULL }, + + { "TransBalanceAction", gnc_ui_reconcile_window_balance_cb, NULL, NULL, NULL }, + { "TransEditAction", gnc_ui_reconcile_window_edit_cb, NULL, NULL, NULL }, + { "TransDeleteAction", gnc_ui_reconcile_window_delete_cb, NULL, NULL, NULL }, + { "TransRecAction", gnc_ui_reconcile_window_rec_cb, NULL, NULL, NULL }, + { "TransUnRecAction", gnc_ui_reconcile_window_unrec_cb, NULL, NULL, NULL }, + + { "HelpHelpAction", gnc_ui_reconcile_window_help_cb, NULL, NULL, NULL }, +}; +/** The number of actions provided by the reconcile window. */ +static guint recnWindow_n_actions_entries = G_N_ELEMENTS(recWindow_actions_entries); /********************************************************************\ @@ -1815,48 +1843,66 @@ recnWindowWithBalance (GtkWidget *parent, Account *account, gnc_numeric new_endi gtk_box_pack_start(GTK_BOX (vbox), dock, FALSE, TRUE, 0); { - gchar *filename; - gint merge_id; - GtkAction *action; - GtkActionGroup *action_group; + GtkToolbar *tool_bar; + GMenuModel *menu_model; + GtkWidget *menu_bar; + GtkAccelGroup *accel_group = gtk_accel_group_new (); + const gchar *ui = "/org/gnucash/ui/gnc-reconcile-window.ui"; GError *error = NULL; +#ifdef MAC_INTEGRATION + GtkosxApplication *theApp = g_object_new (GTKOSX_TYPE_APPLICATION, + NULL); +#endif + recnData->builder = gtk_builder_new (); - recnData->ui_merge = gtk_ui_manager_new (); - g_signal_connect (recnData->ui_merge, "add_widget", - G_CALLBACK (recnWindow_add_widget), dock); + gtk_builder_add_from_resource (recnData->builder, ui, &error); - action_group = gtk_action_group_new ("ReconcileWindowActions"); - recnData->action_group = action_group; - gtk_action_group_set_translation_domain(action_group, PROJECT_NAME); - gtk_action_group_add_actions (action_group, recnWindow_actions, - recnWindow_n_actions, recnData); - action = - gtk_action_group_get_action (action_group, "AccountOpenAccountAction"); - g_object_set (G_OBJECT(action), "short_label", _("Open"), NULL); + gtk_builder_set_translation_domain (recnData->builder, PROJECT_NAME); - gtk_ui_manager_insert_action_group (recnData->ui_merge, action_group, 0); - - filename = gnc_filepath_locate_ui_file("gnc-reconcile-window-ui.xml"); - /* Can't do much without a ui. */ - g_assert (filename); - - merge_id = gtk_ui_manager_add_ui_from_file (recnData->ui_merge, - filename, &error); - g_assert(merge_id || error); - if (merge_id) + if (error) { - gtk_window_add_accel_group (GTK_WINDOW (recnData->window), - gtk_ui_manager_get_accel_group(recnData->ui_merge)); - gtk_ui_manager_ensure_update (recnData->ui_merge); + g_critical ("Failed to load ui resource %s, Error %s", ui, error->message); + g_error_free (error); + gnc_unregister_gui_component_by_data (WINDOW_RECONCILE_CM_CLASS, recnData); + g_free (recnData); + return NULL; } - else - { - g_critical("Failed to load ui file.\n Filename %s\n Error %s", - filename, error->message); - g_error_free(error); - g_assert(merge_id != 0); - } - g_free(filename); + + menu_model = (GMenuModel *)gtk_builder_get_object (recnData->builder, "recwin-menu"); + menu_bar = gtk_menu_bar_new_from_model (menu_model); + gtk_container_add (GTK_CONTAINER(vbox), menu_bar); +#if MAC_INTEGRATION + gtk_widget_hide (menu_bar); + gtk_widget_set_no_show_all (menu_bar, TRUE); + if (GTK_IS_MENU_ITEM (menu_bar)) + menu_bar = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_bar)); + + gtkosx_application_set_menu_bar (theApp, GTK_MENU_SHELL (menu_bar)); + g_object_unref (theApp); + theApp = NULL; +#endif + tool_bar = (GtkToolbar *)gtk_builder_get_object (recnData->builder, "recwin-toolbar"); + + gtk_toolbar_set_style (GTK_TOOLBAR(tool_bar), GTK_TOOLBAR_BOTH); + gtk_toolbar_set_icon_size (GTK_TOOLBAR(tool_bar), + GTK_ICON_SIZE_SMALL_TOOLBAR); + + gtk_container_add (GTK_CONTAINER(vbox), GTK_WIDGET(tool_bar)); + + gtk_window_add_accel_group (GTK_WINDOW(recnData->window), accel_group); + + // need to add the accelerator keys + gnc_add_accelerator_keys_for_menu (menu_bar, accel_group); + + recnData->simple_action_group = g_simple_action_group_new (); + + g_action_map_add_action_entries (G_ACTION_MAP(recnData->simple_action_group), + recWindow_actions_entries, + recnWindow_n_actions_entries, + recnData); + + gtk_widget_insert_action_group (GTK_WIDGET(recnData->window), "recwin", + G_ACTION_GROUP(recnData->simple_action_group)); } g_signal_connect(recnData->window, "popup-menu", @@ -2057,19 +2103,6 @@ use Find Transactions to find them, unreconcile, and re-reconcile.")); gnc_reconcile_window_set_titles(recnData); -#ifdef MAC_INTEGRATION - { - GtkWidget *menubar = gtk_ui_manager_get_widget (recnData->ui_merge, - "/menubar"); - GtkosxApplication *theApp = g_object_new (GTKOSX_TYPE_APPLICATION, - NULL); - if (GTK_IS_MENU_ITEM (menubar)) - menubar = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menubar)); - gtk_widget_hide (menubar); - gtkosx_application_set_menu_bar (theApp, GTK_MENU_SHELL (menubar)); - g_object_unref (theApp); - } -#endif recnRecalculateBalance(recnData); gnc_window_adjust_for_screen(GTK_WINDOW(recnData->window)); @@ -2132,6 +2165,8 @@ static void recn_destroy_cb (GtkWidget *w, gpointer data) { RecnWindow *recnData = data; + gchar **actions = g_action_group_list_actions (G_ACTION_GROUP(recnData->simple_action_group)); + gint num_actions = g_strv_length (actions); gnc_unregister_gui_component_by_data (WINDOW_RECONCILE_CM_CLASS, recnData); @@ -2139,8 +2174,12 @@ recn_destroy_cb (GtkWidget *w, gpointer data) gnc_resume_gui_refresh (); //Disable the actions, the handlers try to access recnData - gtk_action_group_set_sensitive(recnData->action_group, FALSE); - + for (gint i = 0; i < num_actions; i++) + { + GAction *action = g_simple_action_group_lookup (recnData->simple_action_group, actions[i]); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + } + g_strfreev (actions); g_free (recnData); } @@ -2280,8 +2319,11 @@ acct_traverse_descendants (Account *acct, AccountProc fn) * Return: none * \********************************************************************/ static void -recnFinishCB (GtkAction *action, RecnWindow *recnData) +recnFinishCB (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + RecnWindow *recnData = user_data; gboolean auto_payment; Account *account; time64 date; @@ -2340,9 +2382,11 @@ recnFinishCB (GtkAction *action, RecnWindow *recnData) * Return: none * \********************************************************************/ static void -recnPostponeCB (GtkAction *action, gpointer data) +recnPostponeCB (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Account *account; { @@ -2370,110 +2414,10 @@ recnPostponeCB (GtkAction *action, gpointer data) static void -recnCancelCB (GtkAction *action, gpointer data) +recnCancelCB (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; recn_cancel(recnData); } - - -/** An array of all of the actions provided by the main window code. - * This includes some placeholder actions for the menus that are - * visible in the menu bar but have no action associated with - * them. */ -static GtkActionEntry recnWindow_actions [] = -{ - /* Toplevel */ - - { "ReconcileMenuAction", NULL, N_("_Reconcile"), NULL, NULL, NULL, }, - { "AccountMenuAction", NULL, N_("_Account"), NULL, NULL, NULL, }, - { "TransactionMenuAction", NULL, N_("_Transaction"), NULL, NULL, NULL, }, - { "HelpMenuAction", NULL, N_("_Help"), NULL, NULL, NULL, }, - - /* Reconcile menu */ - - { - "RecnChangeInfoAction", NULL, N_("_Reconcile Information…"), NULL, - N_("Change the reconcile information " - "including statement date and ending balance."), - G_CALLBACK (gnc_ui_reconcile_window_change_cb) - }, - { - "RecnFinishAction", "system-run", N_("_Finish"), "w", - N_("Finish the reconciliation of this account"), - G_CALLBACK(recnFinishCB) - }, - { - "RecnPostponeAction", "go-previous", N_("_Postpone"), "p", - N_("Postpone the reconciliation of this account"), - G_CALLBACK(recnPostponeCB) - }, - { - "RecnCancelAction", "process-stop", N_("_Cancel"), NULL, - N_("Cancel the reconciliation of this account"), - G_CALLBACK(recnCancelCB) - }, - - /* Account menu */ - - { - "AccountOpenAccountAction", "go-jump", N_("_Open Account"), NULL, - N_("Open the account"), - G_CALLBACK(gnc_recn_open_cb) - }, - { - "AccountEditAccountAction", NULL, N_("_Edit Account"), NULL, - N_("Edit the main account for this register"), - G_CALLBACK(gnc_recn_edit_account_cb) - }, - { - "AccountTransferAction", NULL, N_("_Transfer…"), NULL, - N_("Transfer funds from one account to another"), - G_CALLBACK(gnc_recn_xfer_cb) - }, - { - "AccountCheckRepairAction", NULL, N_("_Check & Repair"), NULL, - N_("Check for and repair unbalanced transactions and orphan splits " - "in this account"), - G_CALLBACK(gnc_recn_scrub_cb) - }, - - /* Transaction menu */ - - { - "TransBalanceAction", "document-new", N_("_Balance"), "b", - N_("Add a new balancing entry to the account"), - G_CALLBACK(gnc_ui_reconcile_window_balance_cb) - }, - { - "TransEditAction", "document-properties", N_("_Edit"), "e", - N_("Edit the current transaction"), - G_CALLBACK(gnc_ui_reconcile_window_edit_cb) - }, - { - "TransDeleteAction", "edit-delete", N_("_Delete"), "d", - N_("Delete the selected transaction"), - G_CALLBACK(gnc_ui_reconcile_window_delete_cb) - }, - { - "TransRecAction", "emblem-default", N_("_Reconcile Selection"), "r", - N_("Reconcile the selected transactions"), - G_CALLBACK(gnc_ui_reconcile_window_rec_cb) - }, - { - "TransUnRecAction", "edit-clear", N_("_Unreconcile Selection"), "u", - N_("Unreconcile the selected transactions"), - G_CALLBACK(gnc_ui_reconcile_window_unrec_cb) - }, - - /* Help menu */ - - { - "HelpHelpAction", NULL, N_("_Help"), NULL, - N_("Open the GnuCash help window"), - G_CALLBACK(gnc_ui_reconcile_window_help_cb) - }, -}; - -/** The number of actions provided by the main window. */ -static guint recnWindow_n_actions = G_N_ELEMENTS (recnWindow_actions); diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index b152e45f2e..780271d70d 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -4,5 +4,34 @@ gnucash.css gnucash-fallback.css + ui/gnc-embedded-register-window.ui + ui/gnc-main-window.ui + ui/gnc-plugin-account-tree.ui + ui/gnc-plugin-basic-commands.ui + ui/gnc-plugin-bi-import.ui + ui/gnc-plugin-budget.ui + ui/gnc-plugin-business.ui + ui/gnc-plugin-csv-export.ui + ui/gnc-plugin-csv-import.ui + ui/gnc-plugin-customer-import.ui + ui/gnc-plugin-file-history.ui + ui/gnc-plugin-log-replay.ui + ui/gnc-plugin-register.ui + ui/gnc-plugin-report-system.ui + + ui/gnc-plugin-page-account-tree.ui + ui/gnc-plugin-page-budget.ui + ui/gnc-plugin-page-invoice.ui + ui/gnc-plugin-page-owner-tree.ui + ui/gnc-plugin-page-register.ui + ui/gnc-plugin-page-report.ui + ui/gnc-plugin-page-sx-list.ui + + ui/gnc-plugin-ofx.ui + ui/gnc-plugin-aqbanking.ui + + ui/gnc-plugin-qif-import.ui + + ui/gnc-reconcile-window.ui diff --git a/gnucash/import-export/aqb/CMakeLists.txt b/gnucash/import-export/aqb/CMakeLists.txt index 8c36159d79..a275638fbd 100644 --- a/gnucash/import-export/aqb/CMakeLists.txt +++ b/gnucash/import-export/aqb/CMakeLists.txt @@ -41,8 +41,6 @@ set (aqbanking_noinst_HEADERS set(aqbanking_GLADE assistant-ab-initial.glade dialog-ab.glade dialog-ab-pref.glade) -set(aqbanking_UI gnc-plugin-aqbanking-ui.xml) - if(WITH_AQBANKING) add_library (gncmod-aqbanking ${aqbanking_SOURCES} @@ -84,15 +82,8 @@ endif() # No headers to install - install(FILES ${aqbanking_GLADE} DESTINATION ${CMAKE_INSTALL_DATADIR}/gnucash/gtkbuilder) - install(FILES ${aqbanking_UI} DESTINATION ${CMAKE_INSTALL_DATADIR}/gnucash/ui) - - foreach(ui_file ${aqbanking_UI}) - configure_file(${ui_file} ${DATADIR_BUILD}/gnucash/ui/${ui_file} COPYONLY) - endforeach() - foreach(glade_file ${aqbanking_GLADE}) configure_file(${glade_file} ${DATADIR_BUILD}/gnucash/gtkbuilder/${glade_file} COPYONLY) endforeach() diff --git a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c index b46411a0d5..ab48cc8625 100644 --- a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c +++ b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c @@ -67,86 +67,53 @@ static void gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account * static Account *main_window_to_account(GncMainWindow *window); /* Command callbacks */ -static void gnc_plugin_ab_cmd_setup(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_get_balance(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_get_transactions(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_issue_sepatransaction(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_issue_sepainternaltransaction(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_issue_inttransaction(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_issue_sepa_direct_debit(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_view_logwindow(GtkToggleAction *action, GncMainWindow *window); -static void gnc_plugin_ab_cmd_aqb_import(GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_ab_cmd_setup (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_get_balance (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_get_transactions (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_issue_sepatransaction (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_issue_sepainternaltransaction (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_issue_inttransaction (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_issue_sepa_direct_debit (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_view_logwindow (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_aqb_import (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-aqbanking-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-aqbanking-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-aqbanking.ui" #define MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW "ABViewLogwindowAction" - -static GtkActionEntry gnc_plugin_actions [] = +static void +change_state_logwindow (GSimpleAction *simple, + GVariant *state, + gpointer user_data) { - /* Menus */ - { "OnlineActionsAction", NULL, N_("_Online Actions"), NULL, NULL, NULL }, + g_simple_action_set_state (simple, state); +} - /* Menu Items */ - { - "ABSetupAction", NULL, N_("_Online Banking Setup…"), NULL, - N_("Initial setup of Online Banking access (HBCI, or OFX DirectConnect, using AqBanking)"), - G_CALLBACK(gnc_plugin_ab_cmd_setup) - }, - { - "ABGetBalanceAction", NULL, N_("Get _Balance"), NULL, - N_("Get the account balance online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_get_balance) - }, - { - "ABGetTransAction", NULL, N_("Get _Transactions…"), NULL, - N_("Get the transactions online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_get_transactions) - }, - { - "ABIssueSepaTransAction", NULL, - /* Translators: https://en.wikipedia.org/wiki/Single_Euro_Payments_Area */ - N_("Issue _SEPA Transaction…"), NULL, - N_("Issue a new international European (SEPA) transaction online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_issue_sepatransaction) - }, - { - "ABIssueSepaIntTransAction", NULL, - N_("Issue SEPA I_nternal Transaction…"), NULL, - N_("Issue a new internal European (SEPA) transaction online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_issue_sepainternaltransaction) - }, - { - "ABIssueIntTransAction", NULL, N_("_Internal Transaction…"), NULL, - N_("Issue a new bank-internal transaction online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_issue_inttransaction) - }, - { - "ABIssueSepaDirectDebitAction", NULL, N_("Issue SEPA Direct _Debit…"), NULL, - N_("Issue a new international European (SEPA) direct debit note online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_issue_sepa_direct_debit) - }, - - /* File -> Import menu item */ - { - "AQBankingImportAction", "go-previous", N_("Import using AQBanking"), - NULL, N_("Import into GnuCash any file format supported by AQBanking."), - G_CALLBACK(gnc_plugin_ab_cmd_aqb_import) - }, +static GActionEntry gnc_plugin_actions [] = +{ + { "OnlineActionsAction", NULL, NULL, NULL, NULL }, + { "ABSetupAction", gnc_plugin_ab_cmd_setup, NULL, NULL, NULL }, + { "ABGetBalanceAction", gnc_plugin_ab_cmd_get_balance, NULL, NULL, NULL }, + { "ABGetTransAction", gnc_plugin_ab_cmd_get_transactions, NULL, NULL, NULL }, + { "ABIssueSepaTransAction", gnc_plugin_ab_cmd_issue_sepatransaction, NULL, NULL, NULL }, + { "ABIssueSepaIntTransAction", gnc_plugin_ab_cmd_issue_sepainternaltransaction, NULL, NULL, NULL }, + { "ABIssueIntTransAction", gnc_plugin_ab_cmd_issue_inttransaction, NULL, NULL, NULL }, + { "ABIssueSepaDirectDebitAction", gnc_plugin_ab_cmd_issue_sepa_direct_debit, NULL, NULL, NULL }, + { "AQBankingImportAction", gnc_plugin_ab_cmd_aqb_import, NULL, NULL, NULL }, + { MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW, gnc_plugin_ab_cmd_view_logwindow, NULL, "true", change_state_logwindow }, }; +/** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GtkToggleActionEntry gnc_plugin_toggle_actions [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - { - MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW, NULL, - N_("Show _log window"), NULL, - N_("Show the online banking log window."), - G_CALLBACK(gnc_plugin_ab_cmd_view_logwindow), TRUE - }, + "FilePlaceholder1", + "ToolsPlaceholder0", + "ActionsPlaceholder1", + NULL, }; -static guint gnc_plugin_n_toggle_actions = G_N_ELEMENTS(gnc_plugin_toggle_actions); static const gchar *need_account_actions[] = { @@ -202,9 +169,8 @@ gnc_plugin_aqbanking_class_init(GncPluginAqBankingClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actions = gnc_plugin_actions; plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->toggle_actions = gnc_plugin_toggle_actions; - plugin_class->n_toggle_actions = gnc_plugin_n_toggle_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; plugin_class->add_to_window = gnc_plugin_aqbanking_add_to_window; plugin_class->remove_from_window = gnc_plugin_aqbanking_remove_from_window; } @@ -222,20 +188,26 @@ static void gnc_plugin_aqbanking_add_to_window(GncPlugin *plugin, GncMainWindow *window, GQuark type) { - GtkAction *action; + GAction *action; gnc_main_window = window; - g_signal_connect(window, "page_added", - G_CALLBACK(gnc_plugin_ab_main_window_page_added), - plugin); - g_signal_connect(window, "page_changed", - G_CALLBACK(gnc_plugin_ab_main_window_page_changed), - plugin); + g_signal_connect (window, "page_added", + G_CALLBACK(gnc_plugin_ab_main_window_page_added), + plugin); + g_signal_connect (window, "page_changed", + G_CALLBACK(gnc_plugin_ab_main_window_page_changed), + plugin); - action = gnc_main_window_find_action(window, MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); + action = gnc_main_window_find_action_in_group (window, PLUGIN_ACTIONS_NAME, + MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE); + if (action) + { + GVariant *state = g_action_get_state (G_ACTION(action)); + g_action_change_state (G_ACTION(action), g_variant_new_boolean (FALSE)); + g_variant_unref (state); + } } static void @@ -293,7 +265,7 @@ gnc_plugin_ab_main_window_page_added(GncMainWindow *window, GncPluginPage *page, static void update_inactive_actions(GncPluginPage *plugin_page) { GncMainWindow *window; - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; // We are readonly - so we have to switch particular actions to inactive. gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book()); @@ -303,13 +275,13 @@ static void update_inactive_actions(GncPluginPage *plugin_page) return; window = GNC_MAIN_WINDOW(plugin_page->window); - g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); - action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); - g_return_if_fail(GTK_IS_ACTION_GROUP(action_group)); + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (action_group, readonly_inactive_actions, - "sensitive", is_readwrite); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), readonly_inactive_actions, + is_readwrite); } @@ -318,19 +290,19 @@ static void update_inactive_actions(GncPluginPage *plugin_page) * the page that is currently selected. */ static void -gnc_plugin_ab_main_window_page_changed(GncMainWindow *window, - GncPluginPage *page, gpointer user_data) +gnc_plugin_ab_main_window_page_changed (GncMainWindow *window, + GncPluginPage *page, gpointer user_data) { - Account *account = main_window_to_account(window); + Account *account = main_window_to_account (window); /* Make sure not to call this with a NULL GncPluginPage */ if (page) { // Update the menu items according to the selected account - gnc_plugin_ab_account_selected(page, account, user_data); + gnc_plugin_ab_account_selected (page, account, user_data); // Also update the action sensitivity due to read-only - update_inactive_actions(page); + update_inactive_actions (page); } } @@ -339,44 +311,44 @@ gnc_plugin_ab_main_window_page_changed(GncMainWindow *window, * selecting another register page. Update the aqbanking menus appropriately. */ static void -gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account *account, - gpointer user_data) +gnc_plugin_ab_account_selected (GncPluginPage *plugin_page, Account *account, + gpointer user_data) { GncMainWindow *window; - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; const gchar *bankcode = NULL; const gchar *accountid = NULL; g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page)); window = GNC_MAIN_WINDOW(plugin_page->window); g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); - action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); - g_return_if_fail(GTK_IS_ACTION_GROUP(action_group)); + simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); if (account) { bankcode = gnc_ab_get_account_bankcode(account); accountid = gnc_ab_get_account_accountid(account); - gnc_plugin_update_actions(action_group, need_account_actions, - "sensitive", - (account && bankcode && *bankcode - && accountid && *accountid)); - gnc_plugin_update_actions(action_group, need_account_actions, - "visible", TRUE); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), need_account_actions, + (account && bankcode && *bankcode + && accountid && *accountid)); + gnc_main_window_set_vis_of_items_by_action (window, need_account_actions, + TRUE); + #if (AQBANKING_VERSION_INT < 60400) - gnc_plugin_update_actions(action_group, inactive_account_actions, - "sensitive", FALSE); - gnc_plugin_update_actions(action_group, inactive_account_actions, - "visible", FALSE); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), + inactive_account_actions, FALSE); + gnc_main_window_set_vis_of_items_by_action (window, inactive_account_actions, + FALSE); #endif } else { - gnc_plugin_update_actions(action_group, need_account_actions, - "sensitive", FALSE); - gnc_plugin_update_actions(action_group, need_account_actions, - "visible", FALSE); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), + need_account_actions, FALSE); + gnc_main_window_set_vis_of_items_by_action (window, need_account_actions, + FALSE); } } @@ -446,16 +418,16 @@ main_window_to_account(GncMainWindow *window) } void -gnc_plugin_aqbanking_set_logwindow_visible(gboolean logwindow_visible) +gnc_plugin_aqbanking_set_logwindow_visible (gboolean logwindow_visible) { - GtkAction *action; + GAction *action = gnc_main_window_find_action_in_group (gnc_main_window, PLUGIN_ACTIONS_NAME, + MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); - action = gnc_main_window_find_action(gnc_main_window, - MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); if (action) { - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), - logwindow_visible); + GVariant *state = g_action_get_state (G_ACTION(action)); + g_action_change_state (G_ACTION(action), g_variant_new_boolean (logwindow_visible)); + g_variant_unref (state); } } @@ -464,20 +436,26 @@ gnc_plugin_aqbanking_set_logwindow_visible(gboolean logwindow_visible) ************************************************************/ static void -gnc_plugin_ab_cmd_setup(GtkAction *action, GncMainWindowActionData *data) +gnc_plugin_ab_cmd_setup (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - ENTER("action %p, main window data %p", action, data); + GncMainWindowActionData *data = user_data; + ENTER("action %p, main window data %p", simple, data); gnc_main_window = data->window; gnc_ab_initial_assistant(); LEAVE(" "); } static void -gnc_plugin_ab_cmd_get_balance(GtkAction *action, GncMainWindowActionData *data) +gnc_plugin_ab_cmd_get_balance (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -493,12 +471,14 @@ gnc_plugin_ab_cmd_get_balance(GtkAction *action, GncMainWindowActionData *data) } static void -gnc_plugin_ab_cmd_get_transactions(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_get_transactions (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -514,12 +494,14 @@ gnc_plugin_ab_cmd_get_transactions(GtkAction *action, } static void -gnc_plugin_ab_cmd_issue_sepatransaction(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_issue_sepatransaction (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -536,12 +518,14 @@ gnc_plugin_ab_cmd_issue_sepatransaction(GtkAction *action, #if (AQBANKING_VERSION_INT >= 60400) static void -gnc_plugin_ab_cmd_issue_sepainternaltransaction(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_issue_sepainternaltransaction (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -557,23 +541,27 @@ gnc_plugin_ab_cmd_issue_sepainternaltransaction(GtkAction *action, } #else static void -gnc_plugin_ab_cmd_issue_sepainternaltransaction(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_issue_sepainternaltransaction (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); PINFO("Sepa Internal Transfer not supported by your aqbanking version!"); LEAVE("Sepa Internal Transfer not supported!"); } #endif static void -gnc_plugin_ab_cmd_issue_inttransaction(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_issue_inttransaction (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -590,12 +578,14 @@ gnc_plugin_ab_cmd_issue_inttransaction(GtkAction *action, } static void -gnc_plugin_ab_cmd_issue_sepa_direct_debit(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_issue_sepa_direct_debit (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -611,29 +601,38 @@ gnc_plugin_ab_cmd_issue_sepa_direct_debit(GtkAction *action, } static void -gnc_plugin_ab_cmd_view_logwindow(GtkToggleAction *action, GncMainWindow *window) +gnc_plugin_ab_cmd_view_logwindow (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) + GncMainWindowActionData *data = user_data; + GVariant *state; + + state = g_action_get_state (G_ACTION(simple)); + + if (g_variant_get_boolean (state)) { if (!gnc_GWEN_Gui_show_dialog()) { /* Log window could not be made visible */ - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE); + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (FALSE)); } } else { gnc_GWEN_Gui_hide_dialog(); } + g_variant_unref (state); } static void -gnc_plugin_ab_cmd_aqb_import(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_aqb_import (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; gnc_main_window = data->window; gnc_file_aqbanking_import_dialog (GTK_WINDOW (gnc_main_window)); - } /************************************************************ diff --git a/gnucash/import-export/bi-import/gnc-plugin-bi-import.c b/gnucash/import-export/bi-import/gnc-plugin-bi-import.c index 7bef0c3e1b..88e1d2192b 100644 --- a/gnucash/import-export/bi-import/gnc-plugin-bi-import.c +++ b/gnucash/import-export/bi-import/gnc-plugin-bi-import.c @@ -46,19 +46,24 @@ static void gnc_plugin_bi_import_init (GncPluginbi_import *plugin) static void gnc_plugin_bi_import_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_bi_import_cmd_test (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_bi_import_cmd_test (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-bi-import-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-bi-import-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-bi-import.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - /* Menu Items */ - { "ImportMenuAction", NULL, N_("_Import"), NULL, NULL, NULL }, - { "bi_importAction", "go-previous", N_("Import Bills & _Invoices…"), NULL, N_("Import bills and invoices from a CSV text file"), G_CALLBACK(gnc_plugin_bi_import_cmd_test) }, + { "bi_importAction", gnc_plugin_bi_import_cmd_test, NULL, NULL, NULL }, }; +/** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder1", + NULL, +}; /************************************************************ * Object Implementation * @@ -84,10 +89,11 @@ gnc_plugin_bi_import_class_init (GncPluginbi_importClass *klass) plugin_class->plugin_name = GNC_PLUGIN_BI_IMPORT_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void @@ -117,9 +123,13 @@ gnc_plugin_bi_import_create_plugin (void) ************************************************************/ static void -gnc_plugin_bi_import_cmd_test (GtkAction *action, GncMainWindowActionData *data) +gnc_plugin_bi_import_cmd_test (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - ENTER ("action %p, main window data %p", action, data); + GncMainWindowActionData *data = user_data; + + ENTER ("action %p, main window data %p", simple, data); PINFO ("bi_import"); gnc_plugin_bi_import_showGUI(GTK_WINDOW(data->window)); diff --git a/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c b/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c index 830e5d7988..0e41ba7b69 100644 --- a/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c +++ b/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c @@ -38,33 +38,28 @@ static void gnc_plugin_csv_export_init (GncPluginCsvExport *plugin); static void gnc_plugin_csv_export_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_csv_export_tree_cmd (GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_csv_export_trans_cmd (GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_csv_export_register_cmd (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_csv_export_tree_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_csv_export_trans_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_csv_export_register_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-export-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-csv-export-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-csv-export.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - { - "CsvExportTreeAction", "go-next", N_("Export Account T_ree to CSV…"), NULL, - N_("Export the Account Tree to a CSV file"), - G_CALLBACK (gnc_plugin_csv_export_tree_cmd) - }, - { - "CsvExportTransAction", "go-next", N_("Export _Transactions to CSV…"), NULL, - N_("Export the Transactions to a CSV file"), - G_CALLBACK (gnc_plugin_csv_export_trans_cmd) - }, - { - "CsvExportRegisterAction", "go-next", N_("Export A_ctive Register to CSV…") - /* _A is already used by Export Accounts */, NULL, - N_("Export the Active Register to a CSV file"), - G_CALLBACK (gnc_plugin_csv_export_register_cmd) - }, + { "CsvExportTreeAction", gnc_plugin_csv_export_tree_cmd, NULL, NULL, NULL }, + { "CsvExportTransAction", gnc_plugin_csv_export_trans_cmd, NULL, NULL, NULL }, + { "CsvExportRegisterAction", gnc_plugin_csv_export_register_cmd, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder5", + NULL, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); typedef struct GncPluginCsvExportPrivate { @@ -98,10 +93,11 @@ gnc_plugin_csv_export_class_init (GncPluginCsvExportClass *klass) plugin_class->plugin_name = GNC_PLUGIN_CSV_EXPORT_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void @@ -125,23 +121,27 @@ gnc_plugin_csv_export_finalize (GObject *object) * Command Callbacks * ************************************************************/ static void -gnc_plugin_csv_export_tree_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_export_tree_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_csv_export(XML_EXPORT_TREE); } static void -gnc_plugin_csv_export_trans_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_export_trans_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_csv_export(XML_EXPORT_TRANS); } static void -gnc_plugin_csv_export_register_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_export_register_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Query *query; Account *acc; diff --git a/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c b/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c index 43af062f3b..6a3afdad14 100644 --- a/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c +++ b/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c @@ -37,32 +37,28 @@ static void gnc_plugin_csv_import_init (GncPluginCsvImport *plugin); static void gnc_plugin_csv_import_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_csv_import_tree_cmd (GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_csv_import_trans_cmd (GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_csv_import_price_cmd (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_csv_import_tree_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_csv_import_trans_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_csv_import_price_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-import-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-csv-import-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-csv-import.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - { - "CsvImportAccountAction", "go-previous", N_("Import _Accounts from CSV…"), NULL, - N_("Import Accounts from a CSV file"), - G_CALLBACK (gnc_plugin_csv_import_tree_cmd) - }, - { - "CsvImportTransAction", "go-previous", N_("Import _Transactions from CSV…"), NULL, - N_("Import Transactions from a CSV file"), - G_CALLBACK (gnc_plugin_csv_import_trans_cmd) - }, - { - "CsvImportPriceAction", "go-previous", N_("Import _Prices from a CSV file…"), NULL, - N_("Import Prices from a CSV file"), - G_CALLBACK (gnc_plugin_csv_import_price_cmd) - }, + { "CsvImportAccountAction", gnc_plugin_csv_import_tree_cmd, NULL, NULL, NULL }, + { "CsvImportTransAction", gnc_plugin_csv_import_trans_cmd, NULL, NULL, NULL }, + { "CsvImportPriceAction", gnc_plugin_csv_import_price_cmd, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder1", + NULL, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); typedef struct GncPluginCsvImportPrivate { @@ -96,10 +92,11 @@ gnc_plugin_csv_import_class_init (GncPluginCsvImportClass *klass) plugin_class->plugin_name = GNC_PLUGIN_CSV_IMPORT_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void @@ -123,22 +120,25 @@ gnc_plugin_csv_import_finalize (GObject *object) * Command Callbacks * ************************************************************/ static void -gnc_plugin_csv_import_tree_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_import_tree_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_csv_account_import (); } static void -gnc_plugin_csv_import_trans_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_import_trans_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_csv_trans_import (); } static void -gnc_plugin_csv_import_price_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_import_price_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_csv_price_import (); } diff --git a/gnucash/import-export/customer-import/gnc-plugin-customer-import.c b/gnucash/import-export/customer-import/gnc-plugin-customer-import.c index 4fe42c0ed2..e78794031f 100644 --- a/gnucash/import-export/customer-import/gnc-plugin-customer-import.c +++ b/gnucash/import-export/customer-import/gnc-plugin-customer-import.c @@ -46,20 +46,24 @@ static void gnc_plugin_customer_import_init (GncPlugincustomer_imp static void gnc_plugin_customer_import_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_customer_import_cmd_test (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_customer_import_cmd_test (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-customer-import-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-customer-import-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-customer-import.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - /* Menu Items */ - { "ImportMenuAction", NULL, N_("_Import"), NULL, NULL, NULL }, - /* Menu entry with label and tooltip */ - { "customer_importAction", "go-previous", N_("Import _Customers & Vendors…"), NULL, N_("Import Customers and Vendors from a CSV text file."), G_CALLBACK(gnc_plugin_customer_import_cmd_test) }, + { "customer_importAction", gnc_plugin_customer_import_cmd_test, NULL, NULL, NULL }, }; +/** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder1", + NULL, +}; /************************************************************ * Object Implementation * @@ -85,10 +89,11 @@ gnc_plugin_customer_import_class_init (GncPlugincustomer_importClass *klass) plugin_class->plugin_name = GNC_PLUGIN_customer_import_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void @@ -118,9 +123,13 @@ gnc_plugin_customer_import_create_plugin (void) ************************************************************/ static void -gnc_plugin_customer_import_cmd_test (GtkAction *action, GncMainWindowActionData *data) +gnc_plugin_customer_import_cmd_test (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - ENTER ("action %p, main window data %p", action, data); + GncMainWindowActionData *data = user_data; + + ENTER ("action %p, main window data %p", simple, data); PINFO ("customer_import"); gnc_plugin_customer_import_showGUI (GTK_WINDOW(data->window)); diff --git a/gnucash/import-export/log-replay/gnc-plugin-log-replay.c b/gnucash/import-export/log-replay/gnc-plugin-log-replay.c index 951b6fe8d9..526a3e1600 100644 --- a/gnucash/import-export/log-replay/gnc-plugin-log-replay.c +++ b/gnucash/import-export/log-replay/gnc-plugin-log-replay.c @@ -36,21 +36,25 @@ static void gnc_plugin_log_replay_init (GncPluginLogreplay *plugin); static void gnc_plugin_log_replay_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_log_replay_cmd_new_log_replay (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_log_replay_cmd_new_log_replay (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-log-replay-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-log-replay-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-log-replay.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - { - "LogReplayAction", "go-previous", N_("_Replay GnuCash .log file…"), NULL, - N_("Replay a GnuCash log file after a crash. This cannot be undone."), - G_CALLBACK (gnc_plugin_log_replay_cmd_new_log_replay) - }, + { "LogReplayAction", gnc_plugin_log_replay_cmd_new_log_replay, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder1", + NULL, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); typedef struct GncPluginLogreplayPrivate { @@ -84,10 +88,11 @@ gnc_plugin_log_replay_class_init (GncPluginLogreplayClass *klass) plugin_class->plugin_name = GNC_PLUGIN_LOG_REPLAY_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void @@ -112,9 +117,11 @@ gnc_plugin_log_replay_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_log_replay_cmd_new_log_replay (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_log_replay_cmd_new_log_replay (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; gnc_suspend_gui_refresh(); gnc_file_log_replay (GTK_WINDOW (data->window)); gnc_resume_gui_refresh(); diff --git a/gnucash/import-export/ofx/CMakeLists.txt b/gnucash/import-export/ofx/CMakeLists.txt index 1de28d8717..8a9a254602 100644 --- a/gnucash/import-export/ofx/CMakeLists.txt +++ b/gnucash/import-export/ofx/CMakeLists.txt @@ -15,8 +15,6 @@ set(ofx_noinst_HEADERS gnc-plugin-ofx.h ) -set(ofx_UI gnc-plugin-ofx-ui.xml) - if (WITH_OFX) add_library(gncmod-ofx ${ofx_SOURCES} ${ofx_noinst_HEADERS}) @@ -36,12 +34,7 @@ endif() ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - install(FILES ${ofx_UI} DESTINATION ${CMAKE_INSTALL_DATADIR}/gnucash/ui) - - foreach(ui_file ${ofx_UI}) - configure_file(${ui_file} ${DATADIR_BUILD}/gnucash/ui/${ui_file} COPYONLY) - endforeach() endif() -set_local_dist(ofx_DIST_local CMakeLists.txt ${ofx_SOURCES} ${ofx_noinst_HEADERS} ${ofx_UI}) +set_local_dist(ofx_DIST_local CMakeLists.txt ${ofx_SOURCES} ${ofx_noinst_HEADERS} ) set(ofx_DIST ${ofx_DIST_local} ${test_ofx_DIST} ${ofx_gschema_DIST} PARENT_SCOPE) diff --git a/gnucash/import-export/ofx/gnc-plugin-ofx-ui.xml b/gnucash/import-export/ofx/gnc-plugin-ofx-ui.xml deleted file mode 100644 index 4a33faa06e..0000000000 --- a/gnucash/import-export/ofx/gnc-plugin-ofx-ui.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/gnucash/import-export/ofx/gnc-plugin-ofx.c b/gnucash/import-export/ofx/gnc-plugin-ofx.c index 56e8c12731..4d72b8d978 100644 --- a/gnucash/import-export/ofx/gnc-plugin-ofx.c +++ b/gnucash/import-export/ofx/gnc-plugin-ofx.c @@ -34,21 +34,25 @@ static void gnc_plugin_ofx_init (GncPluginOfx *plugin); static void gnc_plugin_ofx_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_ofx_cmd_import (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_ofx_cmd_import (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-ofx-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-ofx-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-ofx.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - { - "OfxImportAction", "go-previous", N_("Import _OFX/QFX…"), NULL, - N_("Process an OFX/QFX response file"), - G_CALLBACK (gnc_plugin_ofx_cmd_import) - }, + { "OfxImportAction", gnc_plugin_ofx_cmd_import, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder1", + NULL, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); typedef struct GncPluginOfxPrivate { @@ -82,10 +86,11 @@ gnc_plugin_ofx_class_init (GncPluginOfxClass *klass) plugin_class->plugin_name = GNC_PLUGIN_OFX_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void @@ -110,9 +115,11 @@ gnc_plugin_ofx_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_ofx_cmd_import (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ofx_cmd_import (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; gnc_file_ofx_import (GTK_WINDOW (data->window)); } diff --git a/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c b/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c index c6719a0e22..451cbf9edb 100644 --- a/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c +++ b/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c @@ -37,20 +37,24 @@ static void gnc_plugin_qif_import_init (GncPluginQifImport *plugin); static void gnc_plugin_qif_import_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_qif_import_cmd_new_qif_import (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_qif_import_cmd_new_qif_import (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-qif-import-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-qif-import-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-qif-import.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - { - "QIFImportAction", "go-previous", N_("Import _QIF…"), NULL, - N_("Import a Quicken QIF file"), - G_CALLBACK (gnc_plugin_qif_import_cmd_new_qif_import) - }, + { "QIFImportAction", gnc_plugin_qif_import_cmd_new_qif_import, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder1", + NULL, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); typedef struct GncPluginQifImportPrivate { @@ -84,10 +88,11 @@ gnc_plugin_qif_import_class_init (GncPluginQifImportClass *klass) plugin_class->plugin_name = GNC_PLUGIN_QIF_IMPORT_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void @@ -112,8 +117,9 @@ gnc_plugin_qif_import_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_qif_import_cmd_new_qif_import (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_qif_import_cmd_new_qif_import (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_qif_import(); } diff --git a/gnucash/ui/CMakeLists.txt b/gnucash/ui/CMakeLists.txt index 6cf27defd1..233e778e69 100644 --- a/gnucash/ui/CMakeLists.txt +++ b/gnucash/ui/CMakeLists.txt @@ -1,33 +1,4 @@ set (ui_SOURCES - gnc-main-window-ui.xml - gnc-plugin-account-tree-ui.xml - gnc-plugin-basic-commands-ui.xml - gnc-plugin-bi-import-ui.xml - gnc-plugin-budget-ui.xml - gnc-plugin-business-ui.xml - gnc-plugin-csv-export-ui.xml - gnc-plugin-csv-import-ui.xml - gnc-plugin-customer-import-ui.xml - gnc-plugin-file-history-ui.xml - gnc-plugin-log-replay-ui.xml - gnc-plugin-page-account-tree-ui.xml - gnc-plugin-page-budget-ui.xml - gnc-plugin-page-invoice-ui.xml - gnc-plugin-page-owner-tree-ui.xml - gnc-plugin-page-register-ui.xml - gnc-plugin-page-report-ui.xml - gnc-plugin-page-sx-list2-ui.xml - gnc-plugin-page-sx-list-ui.xml - gnc-plugin-page-sxregister-ui.xml - gnc-plugin-qif-import-ui.xml - gnc-plugin-register-ui.xml - gnc-plugin-report-system-ui.xml - gnc-reconcile-window-ui.xml - gnc-sxed-to-create-window-ui.xml - gnc-sxed-window-ui-full.xml - gnc-sxed-window-ui.xml - gnc-windows-menu-ui-quartz.xml - gnc-windows-menu-ui.xml osx_accel_map) foreach (ui_file ${ui_SOURCES}) diff --git a/gnucash/ui/gnc-embedded-register-window.ui b/gnucash/ui/gnc-embedded-register-window.ui new file mode 100644 index 0000000000..85e31a82ed --- /dev/null +++ b/gnucash/ui/gnc-embedded-register-window.ui @@ -0,0 +1,239 @@ + + + + + _Edit + embeddedwin.EditAction +
+ + Cu_t + GncPluginPageRegisterActions.EditCutAction + <Primary>x + Cut the current selection and copy it to clipboard + + + _Copy + GncPluginPageRegisterActions.EditCopyAction + <Primary>c + Copy the current selection to clipboard + + + _Paste + GncPluginPageRegisterActions.EditPasteAction + <Primary>v + Paste the clipboard content at the cursor position + +
+
+ + _Transaction + embeddedwin.TransactionAction +
+ + CutTransactionAction + GncPluginPageRegisterActions.CutTransactionAction + Cut the selected transaction into clipboard + + + CopyTransactionAction + GncPluginPageRegisterActions.CopyTransactionAction + Copy the selected transaction into clipboard + + + PasteTransactionAction + GncPluginPageRegisterActions.PasteTransactionAction + Paste the transaction from the clipboard + + + DuplicateTransactionAction + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + + + DeleteTransactionAction + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + + + Remo_ve Other Splits + GncPluginPageRegisterActions.RemoveTransactionSplitsAction + Remove all splits in the current transaction + +
+
+ + _Enter Transaction + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + + + Ca_ncel Transaction + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + +
+
+ + _View + embeddedwin.ViewAction +
+ + _Double Line + GncPluginPageRegisterActions.ViewStyleDoubleLineAction + Show a second line with \"Action\", \"Notes\", and \"Linked Document\" for each transaction + +
+
+ + _Action + membeddedwin.ActionsAction +
+ + _Transfer... + GncPluginPageRegisterActions.ActionsTransferAction + <Primary>t + Transfer funds from one account to another + + + _Blank Transaction + GncPluginPageRegisterActions.BlankTransactionAction + <Primary>Page_Down + Move to the blank transaction at the bottom of the register + +
+
+
+ + + +
+ + Dup_licate Transaction + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + + + _Delete Transaction + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + + + Remo_ve Other Splits + GncPluginPageRegisterActions.RemoveTransactionSplitsAction + Remove all splits in the current transaction + +
+
+ + _Enter Transaction + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + + + Ca_ncel Transaction + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + +
+
+ + _Blank Transaction + GncPluginPageRegisterActions.BlankTransactionAction + Move to the blank transaction at the bottom of the register + +
+
+ + + + True + False + + + True + False + Duplicate + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + True + edit-copy + + + False + True + + + + + True + False + Delete + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + True + edit-delete + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Enter + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + True + list-add + + + False + True + + + + + True + False + Cancel + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + True + process-stop + + + False + True + + + + + True + False + Blank + GncPluginPageRegisterActions.BlankTransactionAction + Move to the blank transaction at the bottom of the register + True + go-bottom + + + False + True + + + + +
+ diff --git a/gnucash/ui/gnc-main-window-ui.xml b/gnucash/ui/gnc-main-window-ui.xml deleted file mode 100644 index 64068dafc0..0000000000 --- a/gnucash/ui/gnc-main-window-ui.xml +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-main-window.ui b/gnucash/ui/gnc-main-window.ui new file mode 100644 index 0000000000..13f5a04145 --- /dev/null +++ b/gnucash/ui/gnc-main-window.ui @@ -0,0 +1,609 @@ + + + + + + + + _File + mainwin.FileAction +
+ + Placeholder + mainwin.FilePlaceholder0 + action-disabled + + + _Import + mainwin.FileImportAction + + ImportPlaceholder + mainwin.FilePlaceholder1 + action-disabled + + +
+
+ + SavePlaceholder + mainwin.FilePlaceholder2 + action-disabled + +
+
+ + PrintPlaceholder + mainwin.FilePlaceholder3 + action-disabled + + + Pa_ge Setup... + mainwin.FilePageSetupAction + <Primary><Shift>p + Specify the page size and orientation for printing + + + PdfPlaceholder + mainwin.FilePlaceholder4 + action-disabled + + + _Export + mainwin.FileExportAction + + ExportPlaceholder + mainwin.FilePlaceholder5 + action-disabled + + +
+
+ + Proper_ties + mainwin.FilePropertiesAction + <Alt>Return + Edit the properties of the current file + +
+
+ + RecentPlaceholder + mainwin.FilePlaceholder6 + action-disabled + +
+
+ + _Close + mainwin.FileCloseAction + <Primary>w + Close the currently active page + + + _Quit + mainwin.FileQuitAction + <Primary>q + Quit this application + action-disabled + +
+
+ + + _Edit + mainwin.EditAction +
+ + Placeholder + mainwin.EditPlaceholder0 + action-disabled + + + Cu_t + mainwin.EditCutAction + <Primary>x + Cut the current selection and copy it to clipboard + + + _Copy + mainwin.EditCopyAction + <Primary>c + Copy the current selection to clipboard + + + _Paste + mainwin.EditPasteAction + <Primary>v + Paste the clipboard content at the cursor position + +
+
+ + Placeholder + mainwin.EditPlaceholder1 + action-disabled + +
+
+ + Placeholder + mainwin.EditPlaceholder2 + action-disabled + +
+
+ + FindPlaceholder + mainwin.EditPlaceholder3 + action-disabled + +
+
+ + Pr_eferences + mainwin.EditPreferencesAction + Edit the global preferences of GnuCash + action-disabled + +
+
+ + StylePlaceholder + mainwin.EditPlaceholder4 + action-disabled + + + TaxPlaceholder + mainwin.EditPlaceholder5 + action-disabled + + + OptionsPlaceholder + mainwin.EditPlaceholder6 + action-disabled + +
+
+ + + _View + mainwin.ViewAction +
+ + Placeholder + mainwin.ViewPlaceholder0 + action-disabled + + + _Toolbar + mainwin.ViewToolbarAction + Show/hide the toolbar on this window + + + Su_mmary Bar + mainwin.ViewSummaryAction + Show/hide the summary bar on this window + + + Stat_us Bar + mainwin.ViewStatusbarAction + Show/hide the status bar on this window + + + Tab P_osition + + To_p + mainwin.ViewTabPositionAction + 0 + Display the notebook tabs at the top of the window + + + B_ottom + mainwin.ViewTabPositionAction + 1 + Display the notebook tabs at the bottom of the window + + + _Left + mainwin.ViewTabPositionAction + 2 + Display the notebook tabs at the left of the window + + + _Right + mainwin.ViewTabPositionAction + 3 + Display the notebook tabs at the right of the window + + +
+
+ + Placeholder + mainwin.ViewPlaceholder1 + action-disabled + +
+
+ + Placeholder + mainwin.ViewPlaceholder2 + action-disabled + +
+
+ + Placeholder + mainwin.ViewPlaceholder3 + action-disabled + +
+
+ + RefreshPlaceholder + mainwin.ViewPlaceholder4 + action-disabled + + + AccoutTreePlaceholder + mainwin.ViewPlaceholder5 + action-disabled + +
+
+ + + Tra_nsaction + mainwin.TransactionAction + action-disabled +
+ + Placeholder + mainwin.TransPlaceholder0 + action-disabled + +
+
+ + Placeholder + mainwin.TransPlaceholder1 + action-disabled + +
+
+ + Placeholder + mainwin.TransPlaceholder2 + action-disabled + +
+
+ + Placeholder + mainwin.TransPlaceholder3 + action-disabled + +
+
+ + Placeholder + mainwin.TransPlaceholder4 + action-disabled + +
+
+ + + _Actions + mainwin.ActionsAction +
+ + Placeholder + mainwin.ActionsPlaceholder0 + action-disabled + + + OnlinePlaceholder + mainwin.ActionsPlaceholder1 + action-disabled + + + SchedPlaceholder + mainwin.ActionsPlaceholder2 + action-disabled + + + BudgetPlaceholder + mainwin.ActionsPlaceholder3 + action-disabled + +
+
+ + Placeholder + mainwin.ActionsPlaceholder4 + action-disabled + +
+
+ + Placeholder + mainwin.ActionsPlaceholder5 + action-disabled + +
+
+ + Placeholder + mainwin.ActionsPlaceholder6 + action-disabled + +
+
+ + Reset _Warnings... + mainwin.ActionsForgetWarningsAction + Reset the state of all warning messages so they will be shown again + + + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + + _Business + mainwin.BusinessAction +
+ + Placeholder + mainwin.BusinessPlaceholder0 + action-disabled + +
+
+ + Placeholder + mainwin.BusinessPlaceholder1 + action-disabled + +
+
+ + Placeholder + mainwin.BusinessPlaceholder2 + action-disabled + +
+
+ + Placeholder + mainwin.BusinessPlaceholder3 + action-disabled + +
+
+ + + _Scheduled + mainwin.ScheduledAction + action-disabled +
+ + Placeholder + mainwin.SchedulePlaceholder0 + action-disabled + +
+
+ + + _Reports + mainwin.ReportsAction +
+ + Placeholder + mainwin.ReportsPlaceholder0 + action-disabled + +
+
+ + Placeholder + mainwin.ReportsPlaceholder1 + action-disabled + +
+
+ + + _Tools + mainwin.ToolsAction +
+ + OnlinePlaceholder + mainwin.ToolsPlaceholder0 + action-disabled + + + ToolsPlaceholder + mainwin.ToolsPlaceholder1 + action-disabled + + + JournalPlaceholder + mainwin.ToolsPlaceholder2 + action-disabled + +
+
+ + + E_xtensions + mainwin.ExtensionsAction + action-disabled +
+ + Placeholder + mainwin.ExtensionsPlaceholder0 + action-disabled + +
+
+ + + _Windows + mainwin.WindowsAction +
+ + Placeholder + mainwin.WindowsPlaceholder0 + action-disabled + + + _New Window + mainwin.WindowNewAction + Open a new top-level GnuCash window + + + New Window with _Page + mainwin.WindowMovePageAction + Move the current page to a new top-level GnuCash window + +
+
+ + WinPlaceholder + mainwin.WindowsPlaceholder1 + action-disabled + + + Window0Action + mainwin.WindowAction + 0 + action-disabled + +
+
+ + + _Help + mainwin.HelpAction +
+ + Placeholder + mainwin.HelpPlaceholder0 + action-disabled + + + Tutorial and Concepts _Guide + mainwin.HelpTutorialAction + <Primary>h + Open the GnuCash Tutorial + + + ToDPlaceholder + mainwin.HelpPlaceholder1 + action-disabled + + + _Contents + mainwin.HelpContentsAction + F1 + Open the GnuCash Help + + + _About + mainwin.HelpAboutAction + About GnuCash + +
+
+ +
+ + + + + + + TestAction + mainwin.TestAction + + + + + + True + False + + + True + False + Save the current file + gnc-plugin-basic-commands-actions.FileSaveAction + _Save + True + document-save + + + False + True + + + + + True + False + Close the currently active page + mainwin.FileCloseAction + _Close + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Open the New Invoice dialog + ToolbarNewInvoiceAction + gnc-plugin-business-actions.ToolbarNewInvoiceAction + New _Invoice... + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + +
diff --git a/gnucash/ui/gnc-plugin-account-tree-ui.xml b/gnucash/ui/gnc-plugin-account-tree-ui.xml deleted file mode 100644 index dd8f23e31c..0000000000 --- a/gnucash/ui/gnc-plugin-account-tree-ui.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-account-tree.ui b/gnucash/ui/gnc-plugin-account-tree.ui new file mode 100644 index 0000000000..9cfd6954c3 --- /dev/null +++ b/gnucash/ui/gnc-plugin-account-tree.ui @@ -0,0 +1,12 @@ + + + + + + New Accounts _Page + gnc-plugin-account-tree-actions.ViewAccountTreeAction + Open a new Account Tree page + + + + diff --git a/gnucash/ui/gnc-plugin-aqbanking.ui b/gnucash/ui/gnc-plugin-aqbanking.ui new file mode 100644 index 0000000000..dfa61c2342 --- /dev/null +++ b/gnucash/ui/gnc-plugin-aqbanking.ui @@ -0,0 +1,69 @@ + + + + + + Import using AQBanking + gnc-plugin-aqbanking-actions.AQBankingImportAction + Import into GnuCash any file format supported by AQBanking + + + + + + _Online Actions + gnc-plugin-aqbanking-actions.OnlineActionsAction +
+ + Get _Balance + gnc-plugin-aqbanking-actions.ABGetBalanceAction + The list of Scheduled Transactions + + + Get _Transactions... + gnc-plugin-aqbanking-actions.ABGetTransAction + Get the transactions online through Online Banking + +
+
+ + + Issue _SEPA Transaction... + gnc-plugin-aqbanking-actions.ABIssueSepaTransAction + Issue a new international European (SEPA) transaction online through Online Banking + + + Issue SEPA I_nternal Transaction... + gnc-plugin-aqbanking-actions.ABIssueSepaIntTransAction + Issue a new internal European (SEPA) transaction online through Online Banking + + + _Internal Transaction... + gnc-plugin-aqbanking-actions.ABIssueIntTransAction + Issue a new bank-internal transaction online through Online Banking + + + Issue SEPA Direct _Debit... + gnc-plugin-aqbanking-actions.ABIssueSepaDirectDebitAction + Issue a new international European (SEPA) direct debit note online through Online Banking + +
+
+ + Show _log window + gnc-plugin-aqbanking-actions.ABViewLogwindowAction + Show the online banking log window + +
+
+
+ + + + _Online Banking Setup... + gnc-plugin-aqbanking-actions.ABSetupAction + Initial setup of Online Banking access (HBCI, or OFX DirectConnect, using AqBanking) + + + +
diff --git a/gnucash/ui/gnc-plugin-basic-commands-ui.xml b/gnucash/ui/gnc-plugin-basic-commands-ui.xml deleted file mode 100644 index 3c898b86b2..0000000000 --- a/gnucash/ui/gnc-plugin-basic-commands-ui.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-basic-commands.ui b/gnucash/ui/gnc-plugin-basic-commands.ui new file mode 100644 index 0000000000..250957fd2d --- /dev/null +++ b/gnucash/ui/gnc-plugin-basic-commands.ui @@ -0,0 +1,143 @@ + + + + + + New _File + gnc-plugin-basic-commands-actions.FileNewAction + <Primary>n + Create a new file + + + _Open... + gnc-plugin-basic-commands-actions.FileOpenAction + <Primary>o + Open an existing GnuCash file + + + + + + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + <Primary>s + Save the current file + + + Save _As... + gnc-plugin-basic-commands-actions.FileSaveAsAction + <Primary><Shift>s + Save this file with a different name + + + Re_vert + gnc-plugin-basic-commands-actions.FileRevertAction + Reload the current database, reverting all unsaved changes + + + + + + _Print + mainwin.FilePrintAction + <Primary>p + Print the currently active page + yes + + + + + + Export _Accounts + gnc-plugin-basic-commands-actions.FileExportAccountsAction + Export the account hierarchy to a new GnuCash datafile + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + gnc-plugin-basic-commands-actions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + _Scheduled Transactions + gnc-plugin-basic-commands-actions.ActionsScheduledTransactionsAction +
+ + _Scheduled Transaction Editor + gnc-plugin-basic-commands-actions.ActionsScheduledTransactionEditorAction + The list of Scheduled Transactions + + + Since _Last Run... + gnc-plugin-basic-commands-actions.ActionsSinceLastRunAction + Create Scheduled Transactions since the last time run + + + _Mortgage & Loan Repayment... + gnc-plugin-basic-commands-actions.ActionsMortgageLoanAction + Setup scheduled transactions for repayment of a loan + +
+
+
+ + + + _Price Database + gnc-plugin-basic-commands-actions.ToolsPriceEditorAction + View and edit the prices for stocks and mutual funds + + + _Security Editor + gnc-plugin-basic-commands-actions.ToolsCommodityEditorAction + View and edit the commodities for stocks and mutual funds + + + _Loan Repayment Calculator + gnc-plugin-basic-commands-actions.ToolsFinancialCalculatorAction + Use the loan/mortgage repayment calculator + + + _Close Book + gnc-plugin-basic-commands-actions.ToolsBookCloseAction + Close the Book at the end of the Period + + + _Import Map Editor + gnc-plugin-basic-commands-actions.ToolsImapEditorAction + View and Delete Bayesian and non-Bayesian information + + + _Transaction Linked Documents + gnc-plugin-basic-commands-actions.ToolsTransLinkedDocsAction + View all Transaction Linked Documents + + + + + + _Tips Of The Day + gnc-plugin-basic-commands-actions.HelpTipsOfTheDayAction + View the Tips of the Day + + + +
diff --git a/gnucash/ui/gnc-plugin-bi-import-ui.xml b/gnucash/ui/gnc-plugin-bi-import-ui.xml deleted file mode 100644 index 1eba4f04a0..0000000000 --- a/gnucash/ui/gnc-plugin-bi-import-ui.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-bi-import.ui b/gnucash/ui/gnc-plugin-bi-import.ui new file mode 100644 index 0000000000..5c0b8b1620 --- /dev/null +++ b/gnucash/ui/gnc-plugin-bi-import.ui @@ -0,0 +1,12 @@ + + + + + + Import Bills & _Invoices... + gnc-plugin-bi-import-actions.bi_importAction + Import bills and invoices from a CSV text file + + + + diff --git a/gnucash/ui/gnc-plugin-budget-ui.xml b/gnucash/ui/gnc-plugin-budget-ui.xml deleted file mode 100644 index 3e9cb8cd6e..0000000000 --- a/gnucash/ui/gnc-plugin-budget-ui.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-budget.ui b/gnucash/ui/gnc-plugin-budget.ui new file mode 100644 index 0000000000..8b3b0153c6 --- /dev/null +++ b/gnucash/ui/gnc-plugin-budget.ui @@ -0,0 +1,33 @@ + + + + + + B_udget + gnc-plugin-budget-actions.ActionsBudgetAction +
+ + _New Budget + gnc-plugin-budget-actions.NewBudgetAction + Create a new Budget + + + _Open Budget + gnc-plugin-budget-actions.OpenBudgetAction + Open an existing Budget in a new tab. If none exists a new budget will be created + + + _Copy Budget + gnc-plugin-budget-actions.CopyBudgetAction + Copy an existing Budget + + + _Delete Budget + gnc-plugin-budget-actions.DeleteBudgetAction + Delete an existing Budget + +
+
+
+ +
diff --git a/gnucash/ui/gnc-plugin-business-ui.xml b/gnucash/ui/gnc-plugin-business-ui.xml deleted file mode 100644 index f3939abdab..0000000000 --- a/gnucash/ui/gnc-plugin-business-ui.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-business.ui b/gnucash/ui/gnc-plugin-business.ui new file mode 100644 index 0000000000..54476bec3f --- /dev/null +++ b/gnucash/ui/gnc-plugin-business.ui @@ -0,0 +1,176 @@ + + + + + + _Customer + gnc-plugin-business-actions.CustomerMenuAction + + Customers Overview + gnc-plugin-business-actions.CustomerOverviewPageAction + Open a Customer overview page + + + _New Customer... + gnc-plugin-business-actions.CustomerNewCustomerOpenAction + Open the New Customer dialog + + + _Find Customer... + gnc-plugin-business-actions.CustomerFindCustomerOpenAction + Open the Find Customer dialog + + + New _Invoice... + gnc-plugin-business-actions.CustomerNewInvoiceOpenAction + Open the New Invoice dialog + + + Find In_voice... + gnc-plugin-business-actions.CustomerFindInvoiceOpenAction + Open the Find Invoice dialog + + + New _Job... + gnc-plugin-business-actions.CustomerNewJobOpenAction + Open the New Job dialog + + + Find Jo_b... + gnc-plugin-business-actions.CustomerFindJobOpenAction + Open the Find Job dialog + + + _Process Payment... + gnc-plugin-business-actions.CustomerProcessPaymentAction + Open the Process Payment dialog + + + Invoices _Due Reminder + gnc-plugin-business-actions.InvoicesDueReminderOpenAction + Open the Invoices Due Reminder dialog + + + + _Vendor + gnc-plugin-business-actions.VendorMenuAction + + Vendors Overview + gnc-plugin-business-actions.VendorOverviewPageAction + Open a Vendor overview page + + + _New Vendor... + gnc-plugin-business-actions.VendorNewVendorOpenAction + Open the New Vendor dialog + + + _Find Vendor... + gnc-plugin-business-actions.VendorFindVendorOpenAction + Open the Find Vendor dialog + + + New _Bill... + gnc-plugin-business-actions.VendorNewBillOpenAction + Open the New Bill dialog + + + Find Bi_ll... + gnc-plugin-business-actions.VendorFindBillOpenAction + Open the Find Bill dialog + + + New _Job... + gnc-plugin-business-actions.VendorNewJobOpenAction + Open the New Job dialog + + + Find Jo_b... + gnc-plugin-business-actions.VendorFindJobOpenAction + Open the Find Job dialog + + + _Process Payment... + gnc-plugin-business-actions.VendorProcessPaymentAction + Open the Process Payment dialog + + + Bills _Due Reminder + gnc-plugin-business-actions.BillsDueReminderOpenAction + Open the Bills Due Reminder dialog + + + + _Employee + gnc-plugin-business-actions.EmployeeMenuAction + + Employees Overview + gnc-plugin-business-actions.EmployeeOverviewPageAction + Open a Employee overview page + + + _New Employee... + gnc-plugin-business-actions.EmployeeNewEmployeeOpenAction + Open the New Employee dialog + + + _Find Employee... + gnc-plugin-business-actions.EmployeeFindEmployeeOpenAction + Open the Find Employee dialog + + + New _Expense Voucher... + gnc-plugin-business-actions.EmployeeNewExpenseVoucherOpenAction + Open the New Voucher dialog + + + Find Expense _Voucher... + gnc-plugin-business-actions.EmployeeFindExpenseVoucherOpenAction + Open the Find Expense Voucher dialog + + + _Process Payment... + gnc-plugin-business-actions.EmployeeProcessPaymentAction + Open the Process Payment dialog + + + + Business Linked Documents + gnc-plugin-business-actions.BusinessLinkedDocsAction + View all Linked Business Documents + + + + + + Sales _Tax Table + gnc-plugin-business-actions.TaxTablesOpenAction + View and edit the list of Sales Tax Tables (GST/VAT) + + + _Billing Terms Editor + gnc-plugin-business-actions.BillingTermsOpenAction + View and edit the list of Billing Terms + + + + + + _Business + gnc-plugin-business-actions.BusinessTestAction +
+ + Test Search Dialog + gnc-plugin-business-actions.BusinessTestSearchAction + Test Search Dialog + + + Initialize Test Data + gnc-plugin-business-actions.BusinessTestInitDataAction + Initialize Test Data + +
+
+
+ +
diff --git a/gnucash/ui/gnc-plugin-csv-export-ui.xml b/gnucash/ui/gnc-plugin-csv-export-ui.xml deleted file mode 100644 index 47dd5d8c45..0000000000 --- a/gnucash/ui/gnc-plugin-csv-export-ui.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-csv-export.ui b/gnucash/ui/gnc-plugin-csv-export.ui new file mode 100644 index 0000000000..cf0d102c31 --- /dev/null +++ b/gnucash/ui/gnc-plugin-csv-export.ui @@ -0,0 +1,22 @@ + + + + + + Export Account T_ree to CSV... + gnc-plugin-csv-export-actions.CsvExportTreeAction + Export the Account Tree to a CSV file + + + Export _Transactions to CSV... + gnc-plugin-csv-export-actions.CsvExportTransAction + Export the Transactions to a CSV file + + + Export A_ctive Register to CSV... + gnc-plugin-csv-export-actions.CsvExportRegisterAction + Export the Active Register to a CSV file + + + + diff --git a/gnucash/ui/gnc-plugin-csv-import-ui.xml b/gnucash/ui/gnc-plugin-csv-import-ui.xml deleted file mode 100644 index 756cb66805..0000000000 --- a/gnucash/ui/gnc-plugin-csv-import-ui.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-csv-import.ui b/gnucash/ui/gnc-plugin-csv-import.ui new file mode 100644 index 0000000000..b2c4fc3b5d --- /dev/null +++ b/gnucash/ui/gnc-plugin-csv-import.ui @@ -0,0 +1,22 @@ + + + + + + Import _Accounts from CSV... + gnc-plugin-csv-import-actions.CsvImportAccountAction + Import Accounts from a CSV file + + + Import _Transactions from CSV... + gnc-plugin-csv-import-actions.CsvImportTransAction + Import Transactions from a CSV file + + + Import _Prices from a CSV file... + gnc-plugin-csv-import-actions.CsvImportPriceAction + Import Prices from a CSV file + + + + diff --git a/gnucash/ui/gnc-plugin-customer-import-ui.xml b/gnucash/ui/gnc-plugin-customer-import-ui.xml deleted file mode 100644 index 51a45a012d..0000000000 --- a/gnucash/ui/gnc-plugin-customer-import-ui.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-customer-import.ui b/gnucash/ui/gnc-plugin-customer-import.ui new file mode 100644 index 0000000000..24e70be9bb --- /dev/null +++ b/gnucash/ui/gnc-plugin-customer-import.ui @@ -0,0 +1,12 @@ + + + + + + Import _Customers & Vendors... + gnc-plugin-customer-import-actions.customer_importAction + Import Customers and Vendors from a CSV text file + + + + diff --git a/gnucash/ui/gnc-plugin-file-history-ui.xml b/gnucash/ui/gnc-plugin-file-history-ui.xml deleted file mode 100644 index 6e97cfd396..0000000000 --- a/gnucash/ui/gnc-plugin-file-history-ui.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-file-history.ui b/gnucash/ui/gnc-plugin-file-history.ui new file mode 100644 index 0000000000..14b9293743 --- /dev/null +++ b/gnucash/ui/gnc-plugin-file-history.ui @@ -0,0 +1,12 @@ + + + + + + RecentFile0Action + gnc-plugin-file-history-actions.RecentFile0Action + Edit the properties of the current file + + + + diff --git a/gnucash/ui/gnc-plugin-log-replay-ui.xml b/gnucash/ui/gnc-plugin-log-replay-ui.xml deleted file mode 100644 index a211fde4b0..0000000000 --- a/gnucash/ui/gnc-plugin-log-replay-ui.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-log-replay.ui b/gnucash/ui/gnc-plugin-log-replay.ui new file mode 100644 index 0000000000..bde5c67a11 --- /dev/null +++ b/gnucash/ui/gnc-plugin-log-replay.ui @@ -0,0 +1,12 @@ + + + + + + _Replay GnuCash .log file... + gnc-plugin-log-replay-actions.LogReplayAction + Replay a GnuCash log file after a crash. This cannot be undone + + + + diff --git a/gnucash/ui/gnc-plugin-ofx.ui b/gnucash/ui/gnc-plugin-ofx.ui new file mode 100644 index 0000000000..55c25411f9 --- /dev/null +++ b/gnucash/ui/gnc-plugin-ofx.ui @@ -0,0 +1,12 @@ + + + + + + Import _OFX/QFX... + gnc-plugin-ofx-actions.OfxImportAction + Process an OFX/QFX response file + + + + diff --git a/gnucash/ui/gnc-plugin-page-account-tree-ui.xml b/gnucash/ui/gnc-plugin-page-account-tree-ui.xml deleted file mode 100644 index 2769ed834a..0000000000 --- a/gnucash/ui/gnc-plugin-page-account-tree-ui.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-account-tree.ui b/gnucash/ui/gnc-plugin-page-account-tree.ui new file mode 100644 index 0000000000..aea226eec3 --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-account-tree.ui @@ -0,0 +1,444 @@ + + + + + + _Print + mainwin.FilePrintAction + <Primary>p + Print the currently active page + yes + + + + + + _Edit Account + GncPluginPageAccountTreeActions.EditEditAccountAction + <Primary>e + Edit the selected account + yes + + + _Delete Account + GncPluginPageAccountTreeActions.EditDeleteAccountAction + Delete + Edit the selected account + yes + + + F_ind Account + GncPluginPageAccountTreeActions.EditFindAccountAction + <Primary>i + Find an account + yes + + + _Cascade Account Properties... + GncPluginPageAccountTreeActions.EditCascadeAccountAction + Cascade selected properties for account + yes + + + _Renumber Subaccounts... + GncPluginPageAccountTreeActions.EditRenumberSubaccountsAction + Renumber the children of the selected account + yes + + + + + + Open _Account + GncPluginPageAccountTreeActions.EditOpenAccountAction + Open the selected account + yes + + + Open _SubAccounts + GncPluginPageAccountTreeActions.EditOpenSubaccountsAction + Open the selected account and all its subaccounts + yes + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageAccountTreeActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + + + _Filter By... + GncPluginPageAccountTreeActions.ViewFilterByAction + yes + + + + + + _Refresh + GncPluginPageAccountTreeActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + + + New _Account... + GncPluginPageAccountTreeActions.FileNewAccountAction + Create a new Account + yes + + + New Account _Hierarchy... + GncPluginPageAccountTreeActions.FileAddAccountHierarchyAssistantAction + Extend the current book by merging with new account type categories + yes + + + + + + _Transfer... + GncPluginPageAccountTreeActions.ActionsTransferAction + <Primary>t + Transfer funds from one account to another + yes + + + _Reconcile... + GncPluginPageAccountTreeActions.ActionsReconcileAction + Reconcile the selected account + yes + + + _Auto-clear... + GncPluginPageAccountTreeActions.ActionsAutoClearAction + Automatically clear individual transactions, so as to reach a certain cleared amount + yes + + + Stock Ass_istant + GncPluginPageAccountTreeActions.ActionsStockAssistantAction + Stock Assistant + yes + + + Stoc_k Split... + GncPluginPageAccountTreeActions.ActionsStockSplitAction + Record a stock split or a stock merger + yes + + + View _Lots... + GncPluginPageAccountTreeActions.ActionsLotsAction + Bring up the lot viewer/editor window + yes + + + + + + _Check & Repair + mainwin.ScrubMenuAction + yes + + Check & Repair A_ccount + GncPluginPageAccountTreeActions.ScrubAction + Check for and repair unbalanced transactions and orphan splits in this account + yes + + + Check & Repair Su_baccounts + GncPluginPageAccountTreeActions.ScrubSubAction + Check for and repair unbalanced transactions and orphan splits in this account and its subaccounts + yes + + + Check & Repair A_ll + GncPluginPageAccountTreeActions.ScrubAllAction + Check for and repair unbalanced transactions and orphan splits in all accounts + yes + + + + + + + + +
+ + _Filter By... + GncPluginPageAccountTreeActions.ViewFilterByAction + Filter accounts + + + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + Open _Account + GncPluginPageAccountTreeActions.EditOpenAccountAction + Open the selected account + + + Open _SubAccounts + GncPluginPageAccountTreeActions.EditOpenSubaccountsAction + Open the selected account and all its subaccounts + + + Edit _Account + GncPluginPageAccountTreeActions.EditEditAccountAction + Edit the selected account + + + _Cascade Account Properties... + GncPluginPageAccountTreeActions.EditCascadeAccountAction + Cascade selected properties for account + + + F_ind Account + GncPluginPageAccountTreeActions.EditFindAccountPopupAction + Find an account + +
+
+ + _Reconcile... + GncPluginPageAccountTreeActions.ActionsReconcileAction + Reconcile the selected account + + + _Auto-clear... + GncPluginPageAccountTreeActions.ActionsAutoClearAction + Automatically clear individual transactions, given a cleared amount + + + _Transfer... + GncPluginPageAccountTreeActions.ActionsTransferAction + Transfer funds from one account to another + + + Stoc_k Split... + GncPluginPageAccountTreeActions.ActionsStockSplitAction + Record a stock split or a stock merger + + + View _Lots... + GncPluginPageAccountTreeActions.ActionsLotsAction + Bring up the lot viewer/editor window + +
+
+ + New _Account... + GncPluginPageAccountTreeActions.FileNewAccountAction + Create a new Account + + + _Delete Account... + GncPluginPageAccountTreeActions.EditDeleteAccountAction + Delete selected account + +
+
+ + _Check & Repair + GncPluginPageAccountTreeActions.ScrubMenuAction + + _Check & Repair A_ccount + GncPluginPageAccountTreeActions.ScrubAction + Check for and repair unbalanced transactions and orphan splits in this account + + + Check & Repair Su_baccounts + GncPluginPageAccountTreeActions.ScrubSubAction + Check for and repair unbalanced transactions and orphan splits in this account and its subaccounts + + + Check & Repair A_ll + GncPluginPageAccountTreeActions.ScrubAllAction + Check for and repair unbalanced transactions and orphan splits in all accounts + + +
+
+ + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Open _Account + GncPluginPageAccountTreeActions.EditOpenAccountAction + Open the selected account + True + gnc-account-open + + + False + True + + + + + True + False + Edit _Account + GncPluginPageAccountTreeActions.EditEditAccountAction + Edit the selected account + True + gnc-account-edit + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Account... + GncPluginPageAccountTreeActions.FileNewAccountAction + Create a new Account + True + gnc-account-new + + + False + True + + + + + True + False + _Delete Account... + GncPluginPageAccountTreeActions.EditDeleteAccountAction + Delete selected account + True + gnc-account-delete + + + False + True + + + + + + + + + + + + + +
diff --git a/gnucash/ui/gnc-plugin-page-budget-ui.xml b/gnucash/ui/gnc-plugin-page-budget-ui.xml deleted file mode 100644 index 0dc5eeb123..0000000000 --- a/gnucash/ui/gnc-plugin-page-budget-ui.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-budget.ui b/gnucash/ui/gnc-plugin-page-budget.ui new file mode 100644 index 0000000000..b2b14db74f --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-budget.ui @@ -0,0 +1,298 @@ + + + + + + _Print + mainwin.FilePrintAction + <Primary>p + Print the currently active page + yes + + + + + + Esti_mate Budget... + GncPluginPageBudgetActions.EstimateBudgetAction + Edit the selected account + yes + + + _All Periods... + GncPluginPageBudgetActions.AllPeriodsBudgetAction + Estimate a budget value for the selected accounts from past transactions + yes + + + _Delete Budget... + GncPluginPageBudgetActions.DeleteBudgetAction + Select this or another budget and delete it + yes + + + Edit Note + GncPluginPageBudgetActions.BudgetNoteAction + Edit note for the selected account and period + yes + + + Budget Report + GncPluginPageBudgetActions.BudgetReportAction + Run the budget report + yes + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageBudgetActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + Budget _Options... + GncPluginPageBudgetActions.OptionsBudgetAction + Edit this budget's options + yes + + + + + + _Filter By... + GncPluginPageBudgetActions.ViewFilterByAction + yes + + + + + + _Refresh + GncPluginPageBudgetActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + _Test + mainwin.TestAction + + + + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Open _Account + GncPluginPageBudgetActions.EditOpenAccountAction + Open the selected account + True + gnc-account-open + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Budget _Options... + GncPluginPageBudgetActions.OptionsBudgetAction + Edit this budget's options + True + document-properties + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Esti_mate Budget... + GncPluginPageBudgetActions.EstimateBudgetAction + Estimate a budget value for the selected accounts from past transactions + True + system-run + + + False + True + + + + + True + False + _All Periods... + GncPluginPageBudgetActions.AllPeriodsBudgetAction + Edit budget for all periods for the selected accounts + True + system-run + + + False + True + + + + + True + False + _Delete Budget... + GncPluginPageBudgetActions.DeleteBudgetAction + Select this or another budget and delete it + True + gnc-account-delete + + + False + True + + + + + True + False + Edit Note + GncPluginPageBudgetActions.BudgetNoteAction + Edit note for the selected account and period + True + text-x-generic + + + False + True + + + + + True + False + Budget Report + GncPluginPageBudgetActions.BudgetReportAction + Run the budget report + True + system-run + + + False + True + + + + + diff --git a/gnucash/ui/gnc-plugin-page-invoice-ui.xml b/gnucash/ui/gnc-plugin-page-invoice-ui.xml deleted file mode 100644 index 1874687119..0000000000 --- a/gnucash/ui/gnc-plugin-page-invoice-ui.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-invoice.ui b/gnucash/ui/gnc-plugin-page-invoice.ui new file mode 100644 index 0000000000..3baed0ee8e --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-invoice.ui @@ -0,0 +1,566 @@ + + + + + + _Print + GncPluginPageInvoiceActions.FilePrintAction + <Primary>p + Print the currently active page + yes + + + + + + EditEditInvoiceAction + GncPluginPageInvoiceActions.EditEditInvoiceAction + Edit this invoice + yes + + + EditDuplicateInvoiceAction + GncPluginPageInvoiceActions.EditDuplicateInvoiceAction + Create a new invoice as a duplicate of the current one + yes + + + EditPostInvoiceAction + GncPluginPageInvoiceActions.EditPostInvoiceAction + Post this invoice to your Chart of Accounts + yes + + + EditUnpostInvoiceAction + GncPluginPageInvoiceActions.EditUnpostInvoiceAction + Unpost this invoice and make it editable + yes + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageAccountTreeActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + ViewSaveLayoutAction + GncPluginPageInvoiceActions.ViewSaveLayoutAction + Use the current layout as default for all customer invoices and credit notes + yes + + + ViewResetLayoutAction + GncPluginPageInvoiceActions.ViewResetLayoutAction + Reset default layout for all customer invoices and credit notes back to built-in defaults and update the current page accordingly + yes + + + + + + Sort _Order + GncPluginPageInvoiceActions.SortOrderAction + yes +
+ + _Standard + GncPluginPageInvoiceActions.SortOrderRadioAction + 0 + yes + + + _Date + GncPluginPageInvoiceActions.SortOrderRadioAction + 1 + yes + + + Date of _Entry + GncPluginPageInvoiceActions.SortOrderRadioAction + 2 + yes + + + _Quantity + GncPluginPageInvoiceActions.SortOrderRadioAction + 4 + yes + + + _Price + GncPluginPageInvoiceActions.SortOrderRadioAction + 5 + yes + + + Descri_ption + GncPluginPageInvoiceActions.SortOrderRadioAction + 3 + yes + +
+
+
+ + + + _Refresh + GncPluginPageInvoiceActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + _Enter + GncPluginPageInvoiceActions.RecordEntryAction + Record the current entry + yes + + + _Cancel + GncPluginPageInvoiceActions.CancelEntryAction + Cancel the current entry + yes + + + _Delete + GncPluginPageInvoiceActions.DeleteEntryAction + Delete the current entry + yes + + + _Blank + GncPluginPageInvoiceActions.BlankEntryAction + Move to the blank entry at the bottom + yes + + + + + + Dup_licate Entry + GncPluginPageInvoiceActions.DuplicateEntryAction + Make a copy of the current entry + yes + + + Move Entry _Up + GncPluginPageInvoiceActions.EntryUpAction + Move the current entry one row upwards + yes + + + Move Entry Do_wn + GncPluginPageInvoiceActions.EntryDownAction + Move the current entry one row downwards + yes + + + + + + BusinessLinkAction + GncPluginPageInvoiceActions.BusinessLinkAction + Manage link of an external document to this item + yes + + + BusinessLinkOpenAction + GncPluginPageInvoiceActions.BusinessLinkOpenAction + Open the linked document + yes + + + + + + ToolsProcessPaymentAction + GncPluginPageInvoiceActions.ToolsProcessPaymentAction + Enter a payment for the owner of this invoice + yes + + + + + + _Company Report + GncPluginPageInvoiceActions.ReportsCompanyReportAction + Open a company report window for the owner of this invoice + yes + + + + + +
+ + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + _Enter + GncPluginPageInvoiceActions.RecordEntryAction + Record the current entry + + + _Cancel + GncPluginPageInvoiceActions.CancelEntryAction + Cancel the current entry + + + _Delete + GncPluginPageInvoiceActions.DeleteEntryAction + Delete the current entry + +
+
+ + Dup_licate Entry + GncPluginPageInvoiceActions.DuplicateEntryAction + Make a copy of the current entry + + + Move Entry _Up + GncPluginPageInvoiceActions.EntryUpAction + Move the current entry one row upwards + + + Move Entry Do_wn + GncPluginPageInvoiceActions.EntryDownAction + Move the current entry one row downwards + + + _Blank + GncPluginPageInvoiceActions.BlankEntryAction + Move to the blank entry at the bottom of the Invoice + +
+
+ + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Print Invoice + gnc-plugin-business-actions.FilePrintAction + Make a printable invoice + True + document-print + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice + GncPluginPageInvoiceActions.BusinessNewInvoiceAction + Create a new invoice for the same owner as the current one + True + gnc-invoice-new + + + False + True + + + + + True + False + _Edit Invoice + GncPluginPageInvoiceActions.EditEditInvoiceAction + Edit this invoice + True + gnc-invoice-edit + + + False + True + + + + + True + False + _Duplicate Invoice + GncPluginPageInvoiceActions.EditDuplicateInvoiceAction + Create a new invoice as a duplicate of the current one + True + gnc-invoice-duplicate + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Enter + GncPluginPageInvoiceActions.RecordEntryAction + Record the current entry + True + list-add + + + False + True + + + + + True + False + _Cancel + GncPluginPageInvoiceActions.CancelEntryAction + Cancel the current entry + True + process-stop + + + False + True + + + + + True + False + _Delete + GncPluginPageInvoiceActions.DeleteEntryAction + Delete the current entry + True + edit-delete + + + False + True + + + + + True + False + Dup_licate Entry + GncPluginPageInvoiceActions.DuplicateEntryAction + Make a copy of the current entry + True + edit-copy + + + False + True + + + + + True + False + Move Entry _Up + GncPluginPageInvoiceActions.EntryUpAction + Move the current entry one row upwards + True + pan-up-symbolic + + + False + True + + + + + True + False + Move Entry Do_wn + GncPluginPageInvoiceActions.EntryDownAction + Move the current entry one row downwards + True + pan-down-symbolic + + + False + True + + + + + True + False + _Blank + GncPluginPageInvoiceActions.BlankEntryAction + Move to the blank entry at the bottom of the Invoice + True + go-bottom + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Post Invoice + GncPluginPageInvoiceActions.EditPostInvoiceAction + Post this invoice to your Chart of Accounts + True + gnc-invoice-post + + + False + True + + + + + True + False + _Unpost Invoice + GncPluginPageInvoiceActions.EditUnpostInvoiceAction + Unpost this invoice and make it editable + True + gnc-invoice-unpost + + + False + True + + + + + True + False + _Pay Invoice + GncPluginPageInvoiceActions.ToolsProcessPaymentAction + Enter a payment for the owner of this invoice + True + gnc-invoice-pay + + + False + True + + + + +
+ diff --git a/gnucash/ui/gnc-plugin-page-owner-tree-ui.xml b/gnucash/ui/gnc-plugin-page-owner-tree-ui.xml deleted file mode 100644 index 1952f3f6cf..0000000000 --- a/gnucash/ui/gnc-plugin-page-owner-tree-ui.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-owner-tree.ui b/gnucash/ui/gnc-plugin-page-owner-tree.ui new file mode 100644 index 0000000000..b57a0445e2 --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-owner-tree.ui @@ -0,0 +1,695 @@ + + + + + + _Print + mainwin.FilePrintAction + <Primary>p + Print the currently active page + yes + + + + + + E_dit Customer + GncPluginPageOwnerTreeActions.OTEditCustomerAction + <Primary>e + Edit the selected customer + yes + + + _New Customer... + GncPluginPageOwnerTreeActions.OTNewCustomerAction + Create a new customer + yes + + + + + + E_dit Vendor + GncPluginPageOwnerTreeActions.OTEditVendorAction + <Primary>e + Edit the selected vendor + yes + + + _New Vendor... + GncPluginPageOwnerTreeActions.OTNewVendorAction + Create a new vendor + yes + + + + + + E_dit Employee + GncPluginPageOwnerTreeActions.OTEditEmployeeAction + <Primary>e + Edit the selected employee + yes + + + _New Employee... + GncPluginPageOwnerTreeActions.OTNewEmployeeAction + Create a new employee + yes + + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageOwnerTreeActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + _Filter By... + GncPluginPageOwnerTreeActions.ViewFilterByAction + yes + + + + + + _Refresh + GncPluginPageOwnerTreeActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + Customer Report + GncPluginPageOwnerTreeActions.OTCustomerReportAction + Show customer report + yes + + + Customer Listing + GncPluginPageOwnerTreeActions.OTCustomerListingReportAction + Show customer aging overview for all customers + yes + + + + + + Vendor Report + GncPluginPageOwnerTreeActions.OTVendorReportAction + Show vendor report + yes + + + Vendor Listing + GncPluginPageOwnerTreeActions.OTVendorListingReportAction + Show vendor aging overview for all vendors + yes + + + + + + Employee Report + GncPluginPageOwnerTreeActions.OTEmployeeReportAction + Show employee report + yes + + + + + +
+ + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + E_dit Customer + GncPluginPageOwnerTreeActions.OTEditCustomerAction + Edit the selected customer + +
+
+ + New _Invoice... + GncPluginPageOwnerTreeActions.OTNewInvoiceAction + Create a new invoice + + + Customer Report + GncPluginPageOwnerTreeActions.OTCustomerReportAction + Show customer report + + + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + +
+
+ + +
+ + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + E_dit Vendor + GncPluginPageOwnerTreeActions.OTEditVendorAction + Edit the selected vendor + +
+
+ + New _Bill... + GncPluginPageOwnerTreeActions.OTNewBillAction + Create a new bill + + + Vendor Report + GncPluginPageOwnerTreeActions.OTVendorReportAction + Show vendor report + + + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + +
+
+ + +
+ + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + E_dit Employee + GncPluginPageOwnerTreeActions.OTEditEmployeeAction + Edit the selected customer + +
+
+ + New _Voucher... + GncPluginPageOwnerTreeActions.OTNewVoucherAction + Create a new voucher + + + Employee Report + GncPluginPageOwnerTreeActions.OTEmployeeReportAction + Show employee report + + + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + +
+
+ + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _New Customer... + GncPluginPageOwnerTreeActions.OTNewCustomerAction + Create a new customer + True + gnc-account-new + + + False + True + + + + + True + False + E_dit Customer + GncPluginPageOwnerTreeActions.OTEditCustomerAction + Edit the selected customer + True + gnc-account-edit + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + GncPluginPageOwnerTreeActions.OTNewInvoiceAction + Create a new invoice + True + gnc-invoice-pay + + + False + True + + + + + True + False + Customer Listing + GncPluginPageOwnerTreeActions.OTCustomerListingReportAction + Show customer aging overview for all customers + True + document-print-preview + + + False + True + + + + + True + False + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + True + gnc-invoice-pay + + + False + True + + + + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _New Vendor... + GncPluginPageOwnerTreeActions.OTNewVendorAction + Create a new vendor + True + gnc-account-new + + + False + True + + + + + True + False + E_dit Vendor + GncPluginPageOwnerTreeActions.OTEditVendorAction + Edit the selected vendor + True + gnc-account-edit + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Bill... + GncPluginPageOwnerTreeActions.OTNewBillAction + Create a new bill + True + gnc-invoice-pay + + + False + True + + + + + True + False + Vendor Listing + GncPluginPageOwnerTreeActions.OTVendorListingReportAction + Show vendor aging overview for all vendors + True + document-print-preview + + + False + True + + + + + True + False + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + True + gnc-invoice-pay + + + False + True + + + + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _New Employee... + GncPluginPageOwnerTreeActions.OTNewEmployeeAction + Create a new employee + True + gnc-account-new + + + False + True + + + + + True + False + E_dit Employee + GncPluginPageOwnerTreeActions.OTEditEmployeeAction + Edit the selected employee + True + gnc-account-edit + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Voucher... + GncPluginPageOwnerTreeActions.OTNewVoucherAction + Create a new voucher + True + gnc-invoice-pay + + + False + True + + + + + True + False + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + True + gnc-invoice-pay + + + False + True + + + + +
diff --git a/gnucash/ui/gnc-plugin-page-register-ui.xml b/gnucash/ui/gnc-plugin-page-register-ui.xml deleted file mode 100644 index cc57ebdb92..0000000000 --- a/gnucash/ui/gnc-plugin-page-register-ui.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-register.ui b/gnucash/ui/gnc-plugin-page-register.ui new file mode 100644 index 0000000000..5550cd5bc7 --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-register.ui @@ -0,0 +1,725 @@ + + + + + + _Print Cheques + GncPluginPageRegisterActions.FilePrintAction + <Primary>p + yes + + + + + + Assign as payment... + gnc-plugin-business-actions.RegisterAssignPayment + Assign the selected transaction as payment + yes + action-disabled + + + Edit payment... + gnc-plugin-business-actions.RegisterEditPayment + Edit the payment this transaction is a part of + yes + action-disabled + + + + + + _Edit Account + GncPluginPageRegisterActions.EditEditAccountAction + <Primary>e + Edit the selected account + yes + + + F_ind Account + GncPluginPageRegisterActions.EditFindAccountAction + <Primary>i + Find an account + yes + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageRegisterActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + + _Basic Ledger + GncPluginPageRegisterActions.ViewStyleRadioAction + 0 + Show transactions on one or two lines + yes + + + + _Auto-Split Ledger + GncPluginPageRegisterActions.ViewStyleRadioAction + 1 + Show transactions on one or two lines and expand the current transaction + yes + + + + Transaction _Journal + GncPluginPageRegisterActions.ViewStyleRadioAction + 2 + Show expanded transactions with all splits + yes + + + + + + _Double Line + GncPluginPageRegisterActions.ViewStyleDoubleLineAction + Show a second line with \"Action\", \"Notes\", and \"Linked Document\" for each transaction + yes + + + + + + + _Sort By... + GncPluginPageRegisterActions.ViewSortByAction + yes + + + _Filter By... + GncPluginPageRegisterActions.ViewFilterByAction + yes + + + + + + _Refresh + GncPluginPageRegisterActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + Cu_t Transaction + GncPluginPageRegisterActions.CutTransactionAction + Cut the selected transaction into clipboard + yes + + + _Copy Transaction + GncPluginPageRegisterActions.CopyTransactionAction + Copy the selected transaction into clipboard + yes + + + _Paste Transaction + GncPluginPageRegisterActions.PasteTransactionAction + Paste the transaction from the clipboard + yes + + + Dup_licate Transaction + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + yes + + + _Delete Transaction + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + yes + + + Remo_ve Other Splits + GncPluginPageRegisterActions.RemoveTransactionSplitsAction + Remove all splits in the current transaction + yes + + + + + + _Enter Transaction + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + yes + + + Ca_ncel Transaction + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + yes + + + + + + _Void Transaction + GncPluginPageRegisterActions.VoidTransactionAction + Void the current transaction + yes + + + _Unvoid Transaction + GncPluginPageRegisterActions.UnvoidTransactionAction + Unvoid the current transaction + yes + + + Add _Reversing Transaction + GncPluginPageRegisterActions.ReverseTransactionAction + Add a reversing transaction + yes + + + + + + Manage Document Link... + GncPluginPageRegisterActions.LinkTransactionAction + Add, change, or unlink the document linked with the current transaction + yes + + + _Open Linked Document + GncPluginPageRegisterActions.LinkedTransactionOpenAction + Open the linked document for the current transaction + yes + + + + + + Jump to Invoice + GncPluginPageRegisterActions.JumpLinkedInvoiceAction + Jump to the linked bill, invoice, or voucher + yes + + + + + + _Transfer... + GncPluginPageRegisterActions.ActionsTransferAction + <Primary>t + Transfer funds from one account to another + yes + + + _Reconcile... + GncPluginPageRegisterActions.ActionsReconcileAction + Reconcile the selected account + yes + + + _Auto-clear... + GncPluginPageRegisterActions.ActionsAutoClearAction + Automatically clear individual transactions, so as to reach a certain cleared amount + yes + + + Stock Ass_istant + GncPluginPageRegisterActions.ActionsStockAssistantAction + Stock Assistant + yes + + + Stoc_k Split... + GncPluginPageRegisterActions.ActionsStockSplitAction + Record a stock split or a stock merger + yes + + + View _Lots... + GncPluginPageRegisterActions.ActionsLotsAction + Bring up the lot viewer/editor window + yes + + + + + + _Blank Transaction + GncPluginPageRegisterActions.BlankTransactionAction + <Primary>Page_Down + Move to the blank transaction at the bottom of the register + yes + + + _Got to Date + GncPluginPageRegisterActions.GotoDateAction + <Primary>g + Move to the split at the specified date + yes + + + S_plit Transaction + GncPluginPageRegisterActions.SplitTransactionAction + Show all splits in the current transaction + yes + + + Edit E_xchange Rate + GncPluginPageRegisterActions.EditExchangeRateAction + Edit the exchange rate for the current transaction + yes + + + Sche_dule... + GncPluginPageRegisterActions.ScheduleTransactionAction + Create a Scheduled Transaction with the current transaction as a template + yes + + + + _Jump to the other account + GncPluginPageRegisterActions.JumpTransactionAction + Open a new register tab for the other account with focus on this transaction + yes + + + + + + + _Check & Repair + mainwin.ScrubMenuAction + yes + + All Transactions + GncPluginPageRegisterActions.ScrubAllAction + yes + + + This transaction + GncPluginPageRegisterActions.ScrubCurrentAction + yes + + + + + + + Account Report + GncPluginPageRegisterActions.ReportsAccountReportAction + Open a register report for this Account + yes + + + Account Report - Single Transaction + GncPluginPageRegisterActions.ReportsAcctTransReportAction + Open a register report for the selected Transaction + yes + + + + +
+ + _Sort By... + GncPluginPageRegisterActions.ViewSortByAction + Filter accounts + + + _Filter By... + GncPluginPageRegisterActions.ViewFilterByAction + Filter accounts + + + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + Dup_licate Transaction + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + + + _Delete Transaction + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + + + Remo_ve Other Splits + GncPluginPageRegisterActions.RemoveTransactionSplitsAction + Remove all splits in the current transaction + +
+
+ + _Enter Transaction + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + + + Ca_ncel Transaction + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + +
+
+ + _Manage Document Link... + GncPluginPageRegisterActions.LinkTransactionAction + Add, change, or unlink the document linked with the current transaction + + + _Open Linked Document + GncPluginPageRegisterActions.LinkedTransactionOpenAction + Open the linked document for the current transaction + +
+
+ + Jump to Invoice + GncPluginPageRegisterActions.JumpLinkedInvoiceAction + Jump to the linked bill, invoice, or voucher + +
+
+ + _Blank Transaction + GncPluginPageRegisterActions.BlankTransactionAction + Move to the blank transaction at the bottom of the register + + + _Go to Date + GncPluginPageRegisterActions.GotoDateAction + Move to the split at the specified date + + + S_plit Transaction + GncPluginPageRegisterActions.SplitTransactionAction + Show all splits in the current transaction + + + Edit E_xchange Rate + GncPluginPageRegisterActions.EditExchangeRateAction + Edit the exchange rate for the current transaction + + + Sche_dule... + GncPluginPageRegisterActions.ScheduleTransactionAction + Create a Scheduled Transaction with the current transaction as a template + + + _Jump to the other account + GncPluginPageRegisterActions.JumpTransactionAction + Open a new register tab for the other account with focus on this transaction + +
+
+ + Assign as payment... + gnc-plugin-business-actions.RegisterAssignPayment + Assign the selected transaction as payment + action-disabled + + + Edit payment... + gnc-plugin-business-actions.RegisterEditPayment + Edit the payment this transaction is a part of + action-disabled + +
+
+ + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Dup_licate Transaction + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + True + edit-copy + + + False + True + + + + + True + False + _Delete Transaction + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + True + edit-delete + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Enter Transaction + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + True + list-add + + + False + True + + + + + True + False + Ca_ncel Transaction + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + True + process-stop + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Blank Transaction + GncPluginPageRegisterActions.BlankTransactionAction + Move to the blank transaction at the bottom of the register + True + go-bottom + + + False + True + + + + + True + False + S_plit Transaction + GncPluginPageRegisterActions.SplitTransactionAction + Show all splits in the current transaction + True + gnc-split-trans + + + False + True + + + + + True + False + _Jump to the other account + GncPluginPageRegisterActions.JumpTransactionAction + Open a new register tab for the other account with focus on this transaction + True + gnc-jumpto + + + False + True + + + + + True + False + Sche_dule... + GncPluginPageRegisterActions.ScheduleTransactionAction + Create a Scheduled Transaction with the current transaction as a template + True + gnc-sx-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Transfer... + GncPluginPageRegisterActions.ActionsTransferAction + Transfer funds from one account to another + True + gnc-transfer + + + False + True + + + + + True + False + _Reconcile... + GncPluginPageRegisterActions.ActionsReconcileAction + Reconcile the selected account + True + edit-select-all + + + False + True + + + + + True + False + Stoc_k Split... + GncPluginPageRegisterActions.ActionsStockAssistantAction + Stock Assistant + True + applications-utilities + + + False + True + + + + +
diff --git a/gnucash/ui/gnc-plugin-page-report-ui.xml b/gnucash/ui/gnc-plugin-page-report-ui.xml deleted file mode 100644 index c46173f0a2..0000000000 --- a/gnucash/ui/gnc-plugin-page-report-ui.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-report.ui b/gnucash/ui/gnc-plugin-page-report.ui new file mode 100644 index 0000000000..742d944d85 --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-report.ui @@ -0,0 +1,297 @@ + + + + + + _Print Report + GncPluginPageReportActions.FilePrintAction + <Primary>p + Print the current report + yes + + + + + + _Report Options + GncPluginPageReportActions.ReportOptionsAction + Edit report style sheets + yes + + + + + + Export as P_DF... + GncPluginPageReportActions.FilePrintPDFAction + Export the current report as a PDF document + yes + + + + + + Export _Report + GncPluginPageReportActions.ReportExportAction + Export HTML-formatted report to file + yes + + + + + + Save _Report Configuration + GncPluginPageReportActions.ReportSaveAction + <Primary><Alt>s + Update the current report's saved configuration + yes + + + Save Report Configuration As... + GncPluginPageReportActions.ReportSaveAsAction + <Primary><Alt><Shift>s + Add the current report's configuration to the 'Reports->Saved Report Configurations' menu + yes + + + + + + + _Test + mainwin.TestAction + + + + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Back + GncPluginPageReportActions.ReportBackAction + Move back one step in the history + True + go-previous + + + False + True + + + + + True + False + Forward + GncPluginPageReportActions.ReportForwAction + Move forward one step in the history + True + go-next + + + False + True + + + + + True + False + Reload + GncPluginPageReportActions.ReportReloadAction + Reload the current page + True + view-refresh + + + False + True + + + + + True + False + Stop + GncPluginPageReportActions.ReportStopAction + Cancel outstanding HTML requests + True + process-stop + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Report Options + GncPluginPageReportActions.ReportOptionsAction + Edit report options + True + document-properties + + + False + True + + + + + True + False + Save _Report Configuration + GncPluginPageReportActions.ReportSaveAction + Update the current report's saved configuration + True + document-save + + + False + True + + + + + True + False + Save Report Configuration As... + GncPluginPageReportActions.ReportSaveAsAction + Add the current report's configuration to the 'Reports->Saved Report Configurations' menu + True + document-save-as + + + False + True + + + + + True + False + Export _Report + GncPluginPageReportActions.ReportExportAction + Export HTML-formatted report to file + True + go-next + + + False + True + + + + + True + False + _Print Report... + GncPluginPageReportActions.FilePrintAction + Print the current report + True + document-print + + + False + True + + + + + True + False + Export as P_DF... + GncPluginPageReportActions.FilePrintPDFAction + Export the current report as a PDF document + True + gnc-gnome-pdf + + + False + True + + + + + diff --git a/gnucash/ui/gnc-plugin-page-sx-list-ui.xml b/gnucash/ui/gnc-plugin-page-sx-list-ui.xml deleted file mode 100644 index b9dafdc3dd..0000000000 --- a/gnucash/ui/gnc-plugin-page-sx-list-ui.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - 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..1ce4863f1d --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-sx-list.ui @@ -0,0 +1,200 @@ + + + + + + _Print + mainwin.FilePrintAction + <Primary>p + Print the currently active page + yes + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageSxListActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + _Refresh + GncPluginPageSxListActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + _New + GncPluginPageSxListActions.SxListNewAction + Create a new scheduled transaction + yes + + + _Edit + GncPluginPageSxListActions.SxListEditAction + Edit the selected scheduled transaction + yes + + + _Delete + GncPluginPageSxListActions.SxListDeleteAction + Delete the selected scheduled transaction + yes + + + + + + + _Test + mainwin.TestAction + + + + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _New + GncPluginPageSxListActions.SxListNewAction + Create a new scheduled transaction + True + gnc-account-open + + + False + True + + + + + True + False + _Edit + GncPluginPageSxListActions.SxListEditAction + Edit the selected scheduled transaction + True + gnc-account-edit + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Delete + GncPluginPageSxListActions.SxListDeleteAction + Delete the selected scheduled transaction + True + gnc-account-delete + + + False + True + + + + + diff --git a/gnucash/ui/gnc-plugin-page-sx-list2-ui.xml b/gnucash/ui/gnc-plugin-page-sx-list2-ui.xml deleted file mode 100644 index 81f2be297a..0000000000 --- a/gnucash/ui/gnc-plugin-page-sx-list2-ui.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-sxregister-ui.xml b/gnucash/ui/gnc-plugin-page-sxregister-ui.xml deleted file mode 100644 index 1c6d961318..0000000000 --- a/gnucash/ui/gnc-plugin-page-sxregister-ui.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-qif-import-ui.xml b/gnucash/ui/gnc-plugin-qif-import-ui.xml deleted file mode 100644 index 3cd182e0b3..0000000000 --- a/gnucash/ui/gnc-plugin-qif-import-ui.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-qif-import.ui b/gnucash/ui/gnc-plugin-qif-import.ui new file mode 100644 index 0000000000..7a27b60b1a --- /dev/null +++ b/gnucash/ui/gnc-plugin-qif-import.ui @@ -0,0 +1,12 @@ + + + + + + Import _QIF... + gnc-plugin-qif-import-actions.QIFImportAction + Import a Quicken QIF file + + + + diff --git a/gnucash/ui/gnc-plugin-register-ui.xml b/gnucash/ui/gnc-plugin-register-ui.xml deleted file mode 100644 index 34dc08e3f8..0000000000 --- a/gnucash/ui/gnc-plugin-register-ui.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-register.ui b/gnucash/ui/gnc-plugin-register.ui new file mode 100644 index 0000000000..dfc96febe7 --- /dev/null +++ b/gnucash/ui/gnc-plugin-register.ui @@ -0,0 +1,12 @@ + + + + + + _General Journal + gnc-plugin-register-actions.ToolsGeneralJournalAction + Open general journal window + + + + diff --git a/gnucash/ui/gnc-plugin-report-system-ui.xml b/gnucash/ui/gnc-plugin-report-system-ui.xml deleted file mode 100644 index 15ecbd00d6..0000000000 --- a/gnucash/ui/gnc-plugin-report-system-ui.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-report-system.ui b/gnucash/ui/gnc-plugin-report-system.ui new file mode 100644 index 0000000000..69a6fe00f2 --- /dev/null +++ b/gnucash/ui/gnc-plugin-report-system.ui @@ -0,0 +1,12 @@ + + + + + + St_yle Sheets + gnc-plugin-report-system-actions.EditStyleSheetsAction + Edit report style sheets + + + + diff --git a/gnucash/ui/gnc-reconcile-window-ui.xml b/gnucash/ui/gnc-reconcile-window-ui.xml deleted file mode 100644 index d44dfc87a4..0000000000 --- a/gnucash/ui/gnc-reconcile-window-ui.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-reconcile-window.ui b/gnucash/ui/gnc-reconcile-window.ui new file mode 100644 index 0000000000..049433fcf0 --- /dev/null +++ b/gnucash/ui/gnc-reconcile-window.ui @@ -0,0 +1,289 @@ + + + + + _Reconcile +
+ + _Reconcile Information... + recwin.RecnChangeInfoAction + +
+
+ + _Finish + recwin.RecnFinishAction + <Primary>w + + + _Postpone + recwin.RecnPostponeAction + <Primary>p + + + _Cancel + recwin.RecnCancelAction + +
+
+ + _Account +
+ + _Open Account + recwin.AccountOpenAccountAction + + + _Edit Account + recwin.AccountEditAccountAction + +
+
+ + _Transfer... + recwin.AccountTransferAction + +
+
+ + _Check & Repair + recwin.AccountCheckRepairAction + +
+
+ + _Transaction +
+ + _Balance + recwin.TransBalanceAction + <Primary>b + + + _Edit + recwin.TransEditAction + <Primary>e + + + _Reconcile Selection + recwin.TransRecAction + <Primary>r + + + _Unreconcile Selection + recwin.TransUnRecAction + <Primary>u + + + _Delete + recwin.TransDeleteAction + <Primary>d + +
+
+ + _Help +
+ + _Help + recwin.HelpHelpAction + +
+
+
+ + + + + _Balance + recwin.TransBalanceAction + + + _Edit + recwin.TransEditAction + + + _Reconcile Selection + recwin.TransRecAction + + + _Unreconcile Selection + recwin.TransUnRecAction + + + _Delete + recwin.TransDeleteAction + + + + + + True + False + + + True + False + Add a new balancing entry to the account + recwin.TransBalanceAction + _Balance + True + document-new + + + False + True + + + + + + True + False + recwin.TransEditAction + Edit the current transaction + _Edit + True + document-properties + + + False + True + + + + + + True + False + Reconcile the selected transactions + recwin.TransRecAction + Reconcile Selection + True + emblem-default + + + False + True + + + + + + True + False + Unreconcile the selected transactions + recwin.TransUnRecAction + Unreconcile Selection + True + edit-clear + + + False + True + + + + + + True + False + Delete the selected transaction + recwin.TransDeleteAction + _Delete + True + edit-delete + + + False + True + + + + + + True + False + + + False + True + + + + + + True + False + Open the account + recwin.AccountOpenAccountAction + _Open + True + go-jump + + + False + True + + + + + + True + False + + + False + True + + + + + + True + False + Finish the reconciliation of this account + recwin.RecnFinishAction + _Finish + True + system-run + + + False + True + + + + + + True + False + Postpone the reconciliation of this account + recwin.RecnPostponeAction + _Postpone + True + go-previous + + + False + True + + + + + + True + False + Cancel the reconciliation of this account + recwin.RecnCancelAction + _Cancel + True + process-stop + + + False + True + + + +
diff --git a/gnucash/ui/gnc-sxed-to-create-window-ui.xml b/gnucash/ui/gnc-sxed-to-create-window-ui.xml deleted file mode 100644 index e3f2f0ea37..0000000000 --- a/gnucash/ui/gnc-sxed-to-create-window-ui.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/gnucash/ui/gnc-sxed-window-ui-full.xml b/gnucash/ui/gnc-sxed-window-ui-full.xml deleted file mode 100644 index c2a41d35f5..0000000000 --- a/gnucash/ui/gnc-sxed-window-ui-full.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-sxed-window-ui.xml b/gnucash/ui/gnc-sxed-window-ui.xml deleted file mode 100644 index be31e4d47e..0000000000 --- a/gnucash/ui/gnc-sxed-window-ui.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/gnucash/ui/gnc-windows-menu-ui-quartz.xml b/gnucash/ui/gnc-windows-menu-ui-quartz.xml deleted file mode 100644 index 9613e97372..0000000000 --- a/gnucash/ui/gnc-windows-menu-ui-quartz.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/gnucash/ui/gnc-windows-menu-ui.xml b/gnucash/ui/gnc-windows-menu-ui.xml deleted file mode 100644 index 78fab67236..0000000000 --- a/gnucash/ui/gnc-windows-menu-ui.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/libgnucash/gnc-module/example/gnc-plugin.example.c b/libgnucash/gnc-module/example/gnc-plugin.example.c index 40cbcb198d..b55899d17c 100644 --- a/libgnucash/gnc-module/example/gnc-plugin.example.c +++ b/libgnucash/gnc-module/example/gnc-plugin.example.c @@ -40,20 +40,19 @@ static void gnc_plugin_example_init (GncPluginexample *plugin); static void gnc_plugin_example_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_example_cmd_test (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_example_cmd_test (GSimpleAction *simple, GVariant *parameter, gpointer user_data); ++{ #define PLUGIN_ACTIONS_NAME "gnc-plugin-example-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-example-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-example.ui" -static GtkActionEntry gnc_plugin_actions [] = { - /* Menu Items */ - { "exampleAction", NULL, N_("example description…"), NULL, - N_("example tooltip"), - G_CALLBACK(gnc_plugin_example_cmd_test) }, +static GActionEntry gnc_plugin_actions [] = +{ + { "exampleAction", gnc_plugin_example_cmd_test, NULL, NULL, NULL }, }; +/** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); - /************************************************************ * Object Implementation * ************************************************************/ @@ -69,7 +68,7 @@ gnc_plugin_example_new (void) static void gnc_plugin_example_class_init (GncPluginexampleClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); GncPluginClass *plugin_class = GNC_PLUGIN_CLASS(klass); object_class->finalize = gnc_plugin_example_finalize; @@ -78,10 +77,10 @@ gnc_plugin_example_class_init (GncPluginexampleClass *klass) plugin_class->plugin_name = GNC_PLUGIN_example_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -99,9 +98,12 @@ gnc_plugin_example_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_example_cmd_test (GtkAction *action, GncMainWindowActionData *data) +gnc_plugin_example_cmd_test (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - ENTER ("action %p, main window data %p", action, data); - PINFO ("example"); - LEAVE (" "); + GncMainWindowActionData *data = user_data; + ENTER("action %p, main window data %p", simple, data); + PINFO("example"); + LEAVE(" "); } diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 12fe8707c1..7f76968787 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -54,6 +54,7 @@ function(make_gnucash_potfiles) ${CMAKE_SOURCE_DIR}/*.keys.in ${CMAKE_SOURCE_DIR}/*.scm ${CMAKE_SOURCE_DIR}/*.py ${CMAKE_SOURCE_DIR}/*/qofbookslots.h ${CMAKE_SOURCE_DIR}/*/gnc-commodity.h + ${CMAKE_SOURCE_DIR}/*.ui ) # Only consider files in a selection of the source directories and diff --git a/po/POTFILES.in b/po/POTFILES.in index efd78de8c0..a71d9ae57c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -505,6 +505,31 @@ gnucash/report/stylesheets/footer.scm gnucash/report/stylesheets/head-or-tail.scm gnucash/report/stylesheets/plain.scm gnucash/report/trep-engine.scm +gnucash/ui/gnc-embedded-register-window.ui +gnucash/ui/gnc-main-window.ui +gnucash/ui/gnc-plugin-account-tree.ui +gnucash/ui/gnc-plugin-aqbanking.ui +gnucash/ui/gnc-plugin-basic-commands.ui +gnucash/ui/gnc-plugin-bi-import.ui +gnucash/ui/gnc-plugin-budget.ui +gnucash/ui/gnc-plugin-business.ui +gnucash/ui/gnc-plugin-csv-export.ui +gnucash/ui/gnc-plugin-csv-import.ui +gnucash/ui/gnc-plugin-customer-import.ui +gnucash/ui/gnc-plugin-file-history.ui +gnucash/ui/gnc-plugin-log-replay.ui +gnucash/ui/gnc-plugin-ofx.ui +gnucash/ui/gnc-plugin-page-account-tree.ui +gnucash/ui/gnc-plugin-page-budget.ui +gnucash/ui/gnc-plugin-page-invoice.ui +gnucash/ui/gnc-plugin-page-owner-tree.ui +gnucash/ui/gnc-plugin-page-register.ui +gnucash/ui/gnc-plugin-page-report.ui +gnucash/ui/gnc-plugin-page-sx-list.ui +gnucash/ui/gnc-plugin-qif-import.ui +gnucash/ui/gnc-plugin-register.ui +gnucash/ui/gnc-plugin-report-system.ui +gnucash/ui/gnc-reconcile-window.ui libgnucash/app-utils/calculation/expression_parser.c libgnucash/app-utils/calculation/fin.c libgnucash/app-utils/file-utils.c