[gnumeric] Actions: merge toggles into the regular actions.



commit 9de96478819b107ef9a0aa00e54d69552dc1215e
Author: Morten Welinder <terra gnome org>
Date:   Wed Dec 9 11:51:05 2015 -0500

    Actions: merge toggles into the regular actions.
    
    We don't really need a separate repository for those.

 ChangeLog             |    5 +-
 src/gui-util.c        |   11 ++-
 src/gui-util.h        |    6 +-
 src/wbc-gtk-actions.c |  392 ++++++++++++++++++++++++++++++-------------------
 src/wbc-gtk-impl.h    |    2 +
 src/wbc-gtk.c         |   57 +++++---
 6 files changed, 292 insertions(+), 181 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c644422..e5b1c5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,10 @@
 2015-12-09  Morten Welinder  <terra gnome org>
 
+       * src/wbc-gtk.c (wbcg_find_action): New function to look in
+       multiple places for an action.
+
        * src/gui-util.c (gnm_action_group_add_actions): Handle
-       translation context.
+       translation context.  Also handle toggle actions.
 
 2015-12-08  Morten Welinder  <terra gnome org>
 
diff --git a/src/gui-util.c b/src/gui-util.c
index abb0c3c..bcc2aa5 100644
--- a/src/gui-util.c
+++ b/src/gui-util.c
@@ -1297,13 +1297,22 @@ gnm_action_group_add_actions (GtkActionGroup *group,
 
        for (i = 0; i < n; i++) {
                GnmActionEntry const *entry = actions + i;
+               const char *name = entry->name;
                const char *label =
                        gnm_ag_translate (entry->label, entry->label_context);
                const char *tip =
                        gnm_ag_translate (entry->tooltip, NULL);
                GtkAction *a;
 
-               a = gtk_action_new (entry->name, label, tip, NULL);
+               if (entry->toggle) {
+                       GtkToggleAction *ta =
+                               gtk_toggle_action_new (name, label, tip, NULL);
+                       gtk_toggle_action_set_active (ta, entry->is_active);
+                       a = GTK_ACTION (ta);
+               } else {
+                       a = gtk_action_new (name, label, tip, NULL);
+               }
+
                g_object_set (a, "icon-name", entry->icon, NULL);
 
                if (entry->callback) {
diff --git a/src/gui-util.h b/src/gui-util.h
index 124a147..0ddd92d 100644
--- a/src/gui-util.h
+++ b/src/gui-util.h
@@ -168,12 +168,14 @@ typedef struct
        const gchar *name;
        const gchar *icon;
        const gchar *label;
+       const gchar *label_context;
        const gchar *accelerator;
        const gchar *tooltip;
        GCallback callback;
 
-       /* Members beyond GtkActionEntry. */
-       const gchar *label_context;
+       /* Fields for toggles.  */
+       guint toggle : 1;
+       guint is_active : 1;
 } GnmActionEntry;
 
 void gnm_action_group_add_actions (GtkActionGroup *group,
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 4263355..4f2d585 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -1948,6 +1948,28 @@ static GNM_ACTION_DEF (cb_insert_menu)
        gtk_action_set_sensitive (action, go_components_get_mime_types () != NULL && scg && scg_sheet 
(scg)->sheet_type == GNM_SHEET_DATA);
 }
 
+#define TOGGLE_HANDLER(flag,property)                                  \
+static GNM_ACTION_DEF (cb_sheet_pref_ ## flag )                                \
+{                                                                      \
+       g_return_if_fail (GNM_IS_WBC_GTK (wbcg));               \
+                                                                       \
+       if (!wbcg->updating_ui) {                                       \
+               Sheet *sheet = wbcg_cur_sheet (wbcg);                   \
+               go_object_toggle (sheet, property);                     \
+               sheet_update (sheet);                                   \
+       }                                                               \
+}
+
+TOGGLE_HANDLER (display_formulas, "display-formulas")
+TOGGLE_HANDLER (hide_zero, "display-zeros")
+TOGGLE_HANDLER (hide_grid, "display-grid")
+TOGGLE_HANDLER (hide_col_header, "display-column-header")
+TOGGLE_HANDLER (hide_row_header, "display-row-header")
+TOGGLE_HANDLER (display_outlines, "display-outlines")
+TOGGLE_HANDLER (outline_symbols_below, "display-outlines-below")
+TOGGLE_HANDLER (outline_symbols_right, "display-outlines-right")
+TOGGLE_HANDLER (use_r1c1, "use-r1c1")
+
 /* Actions that are always sensitive */
 static GnmActionEntry const permanent_actions[] = {
        { .name = "MenuFile",
@@ -2250,6 +2272,8 @@ static GnmActionEntry const data_only_actions[] = {
        },
 };
 
+#define FULLSCREEN_ACCEL "F11"
+
 static GnmActionEntry const semi_permanent_actions[] = {
        /* Edit -> Sheet */
        { .name = "SheetReorder",
@@ -2309,9 +2333,25 @@ static GnmActionEntry const semi_permanent_actions[] = {
          .tooltip = N_("Modify the view properties"),
          .callback = G_CALLBACK (cb_workbook_attr)
        },
+
+       { .name = "ViewStatusbar",
+         .toggle = TRUE,
+         .label = N_("View _Statusbar"),
+         .tooltip = N_("Toggle visibility of statusbar"),
+         .callback = G_CALLBACK (cb_view_statusbar),
+         .is_active = TRUE
+       },
+
+       { .name = "ViewFullScreen",
+         .toggle = TRUE,
+         .icon = "view-fullscreen",
+         .label = N_("F_ull Screen"),
+         .accelerator = FULLSCREEN_ACCEL,
+         .tooltip = N_("Switch to or from full screen mode"),
+         .callback = G_CALLBACK (cb_view_fullscreen)
+       },
 };
 
-#define FULLSCREEN_ACCEL "F11"
 #define ZOOM_IN_ACCEL NULL
 #define ZOOM_OUT_ACCEL NULL
 
@@ -2754,23 +2794,20 @@ static GnmActionEntry const actions[] = {
          .callback = G_CALLBACK (cb_format_cells)
        },
        { .name = "FormatCellsCond",
-         .label = N_("_Conditional Formatting..."), .accelerator = NULL,
-         .tooltip =
-         N_("Modify the conditional formatting of the selected cells"),
+         .label = N_("_Conditional Formatting..."),
+         .tooltip = N_("Modify the conditional formatting of the selected cells"),
          .callback = G_CALLBACK (cb_format_cells_cond)
        },
        { .name = "FormatCellsFitHeight",
          .icon = "gnumeric-row-size",
-         .label = N_("Auto Fit _Height"), .accelerator = NULL,
-         .tooltip =
-         N_("Ensure rows are just tall enough to display content of selection"),
+         .label = N_("Auto Fit _Height"),
+         .tooltip = N_("Ensure rows are just tall enough to display content of selection"),
          .callback = G_CALLBACK (cb_format_cells_auto_fit_height)
        },
        { .name = "FormatCellsFitWidth",
          .icon = "gnumeric-column-size",
-         .label = N_("Auto Fit _Width"), .accelerator = NULL,
-         .tooltip =
-         N_("Ensure columns are just wide enough to display content of selection"),
+         .label = N_("Auto Fit _Width"),
+         .tooltip = N_("Ensure columns are just wide enough to display content of selection"),
          .callback = G_CALLBACK (cb_format_cells_auto_fit_width)
        },
 
@@ -3258,24 +3295,21 @@ static GnmActionEntry const actions[] = {
        },
        { .name = "InsertFormula",
          .icon = "gnumeric-formulaguru",
-         .label = N_("_Function..."), .accelerator = NULL,
-         .tooltip =
-         N_("Edit a function in the current cell"),
+         .label = N_("_Function..."),
+         .tooltip = N_("Edit a function in the current cell"),
          .callback = G_CALLBACK (cb_formula_guru)
        },
 
        { .name = "SortAscending",
          .icon = "view-sort-ascending",
-         .label = N_("Sort Ascending"), .accelerator = NULL,
-         .tooltip =
-         N_("Sort the selected region in ascending order based on the first column selected"),
+         .label = N_("Sort Ascending"),
+         .tooltip = N_("Sort the selected region in ascending order based on the first column selected"),
          .callback = G_CALLBACK (cb_sort_ascending)
        },
        { .name = "SortDescending",
          .icon = "view-sort-descending",
-         .label = N_("Sort Descending"), .accelerator = NULL,
-         .tooltip =
-         N_("Sort the selected region in descending order based on the first column selected"),
+         .label = N_("Sort Descending"),
+         .tooltip = N_("Sort the selected region in descending order based on the first column selected"),
          .callback = G_CALLBACK (cb_sort_descending)
        },
 
@@ -3468,135 +3502,196 @@ static GnmActionEntry const actions[] = {
          .tooltip = N_("Increase the indent, and align the contents to the left"),
          .callback = G_CALLBACK (cb_format_inc_indent)
        },
-};
-
-#define TOGGLE_HANDLER(flag,property)                                  \
-static GNM_ACTION_DEF (cb_sheet_pref_ ## flag )                                \
-{                                                                      \
-       g_return_if_fail (GNM_IS_WBC_GTK (wbcg));               \
-                                                                       \
-       if (!wbcg->updating_ui) {                                       \
-               Sheet *sheet = wbcg_cur_sheet (wbcg);                   \
-               go_object_toggle (sheet, property);                     \
-               sheet_update (sheet);                                   \
-       }                                                               \
-}
 
-TOGGLE_HANDLER (display_formulas, "display-formulas")
-TOGGLE_HANDLER (hide_zero, "display-zeros")
-TOGGLE_HANDLER (hide_grid, "display-grid")
-TOGGLE_HANDLER (hide_col_header, "display-column-header")
-TOGGLE_HANDLER (hide_row_header, "display-row-header")
-TOGGLE_HANDLER (display_outlines, "display-outlines")
-TOGGLE_HANDLER (outline_symbols_below, "display-outlines-below")
-TOGGLE_HANDLER (outline_symbols_right, "display-outlines-right")
-TOGGLE_HANDLER (use_r1c1, "use-r1c1")
+       /* ---------------------------------------- */
 
-static GtkToggleActionEntry const toggle_actions[] = {
-       { "SheetDisplayOutlines", NULL, N_("Display _Outlines"),
-               "<control>8", N_("Toggle whether or not to display outline groups"),
-               G_CALLBACK (cb_sheet_pref_display_outlines) },
-       { "SheetOutlineBelow", NULL, N_("Outlines _Below"),
-               NULL, N_("Toggle whether to display row outlines on top or bottom"),
-               G_CALLBACK (cb_sheet_pref_outline_symbols_below) },
-       { "SheetOutlineRight", NULL, N_("Outlines _Right"),
-               NULL, N_("Toggle whether to display column outlines on the left or right"),
-               G_CALLBACK (cb_sheet_pref_outline_symbols_right) },
-       { "SheetDisplayFormulas", "gnumeric-formulaguru",
-         N_("Display _Formul\303\246"),
-         "<control>quoteleft",
-         N_("Display the value of a formula or the formula itself"),
-               G_CALLBACK (cb_sheet_pref_display_formulas) },
-       { "SheetHideZeros", NULL, N_("_Hide Zeros"),
-               NULL, N_("Toggle whether or not to display zeros as blanks"),
-               G_CALLBACK (cb_sheet_pref_hide_zero) },
-       { "SheetHideGridlines", NULL, N_("Hide _Gridlines"),
-               NULL, N_("Toggle whether or not to display gridlines"),
-               G_CALLBACK (cb_sheet_pref_hide_grid) },
-       { "SheetHideColHeader", NULL, N_("Hide _Column Headers"),
-               NULL, N_("Toggle whether or not to display column headers"),
-               G_CALLBACK (cb_sheet_pref_hide_col_header) },
-       { "SheetHideRowHeader", NULL, N_("Hide _Row Headers"),
-               NULL, N_("Toggle whether or not to display row headers"),
-               G_CALLBACK (cb_sheet_pref_hide_row_header) },
+       { .name = "SheetDisplayOutlines",
+         .toggle = TRUE,
+         .label = N_("Display _Outlines"),
+         .accelerator = "<control>8",
+         .tooltip = N_("Toggle whether or not to display outline groups"),
+         .callback = G_CALLBACK (cb_sheet_pref_display_outlines)
+       },
+       { .name = "SheetOutlineBelow",
+         .toggle = TRUE,
+         .label = N_("Outlines _Below"),
+         .tooltip = N_("Toggle whether to display row outlines on top or bottom"),
+         .callback = G_CALLBACK (cb_sheet_pref_outline_symbols_below)
+       },
+       { .name = "SheetOutlineRight",
+         .toggle = TRUE,
+         .label = N_("Outlines _Right"),
+         .tooltip = N_("Toggle whether to display column outlines on the left or right"),
+         .callback = G_CALLBACK (cb_sheet_pref_outline_symbols_right)
+       },
+       { .name = "SheetDisplayFormulas",
+         .toggle = TRUE,
+         .icon = "gnumeric-formulaguru",
+         .label = N_("Display _Formul\303\246"),
+         .accelerator = "<control>quoteleft",
+         .tooltip = N_("Display the value of a formula or the formula itself"),
+         .callback = G_CALLBACK (cb_sheet_pref_display_formulas)
+       },
+       { .name = "SheetHideZeros",
+         .toggle = TRUE,
+         .label = N_("_Hide Zeros"),
+         .tooltip = N_("Toggle whether or not to display zeros as blanks"),
+         .callback = G_CALLBACK (cb_sheet_pref_hide_zero)
+       },
+       { .name = "SheetHideGridlines",
+         .toggle = TRUE,
+         .label = N_("Hide _Gridlines"),
+         .tooltip = N_("Toggle whether or not to display gridlines"),
+         .callback = G_CALLBACK (cb_sheet_pref_hide_grid)
+       },
+       { .name = "SheetHideColHeader",
+         .toggle = TRUE,
+         .label = N_("Hide _Column Headers"),
+         .tooltip = N_("Toggle whether or not to display column headers"),
+         .callback = G_CALLBACK (cb_sheet_pref_hide_col_header)
+       },
+       { .name = "SheetHideRowHeader",
+         .toggle = TRUE,
+         .label = N_("Hide _Row Headers"),
+         .tooltip = N_("Toggle whether or not to display row headers"),
+         .callback = G_CALLBACK (cb_sheet_pref_hide_row_header)
+       },
 
        /* TODO : Make this a sub menu when we have more convention types */
-       { "SheetUseR1C1", NULL, N_("Use R1C1 N_otation "),
-               NULL, N_("Display addresses as R1C1 or A1"),
-               G_CALLBACK (cb_sheet_pref_use_r1c1) },
-
-       { "AlignLeft", "format-justify-left",
-               N_("_Left Align"), NULL,
-               N_("Align left"), G_CALLBACK (cb_align_left), FALSE },
-       { "AlignCenter", "format-justify-center",
-               N_("_Center"), NULL,
-               N_("Center horizontally"), G_CALLBACK (cb_align_center), FALSE },
-       { "AlignRight", "format-justify-right",
-               N_("_Right Align"), NULL,
-               N_("Align right"), G_CALLBACK (cb_align_right), FALSE },
-       { "CenterAcrossSelection", "gnumeric-center-across-selection",
-               N_("_Center Across Selection"), NULL,
-               N_("Center horizontally across the selection"),
-               G_CALLBACK (cb_center_across_selection), FALSE },
-       { "MergeAndCenter", NULL,
-               N_("_Merge and Center"), NULL,
-               N_("Merge the selection into 1 cell, and center horizontally."),
-               G_CALLBACK (cb_merge_and_center), FALSE },
+       { .name = "SheetUseR1C1",
+         .toggle = TRUE,
+         .label = N_("Use R1C1 N_otation "),
+         .tooltip = N_("Display addresses as R1C1 or A1"),
+         .callback = G_CALLBACK (cb_sheet_pref_use_r1c1)
+       },
+
+       { .name = "AlignLeft",
+         .toggle = TRUE,
+         .icon = "format-justify-left",
+         .label = N_("_Left Align"),
+         .tooltip = N_("Align left"),
+         .callback = G_CALLBACK (cb_align_left)
+       },
+       { .name = "AlignCenter",
+         .toggle = TRUE,
+         .icon = "format-justify-center",
+         .label = N_("_Center"),
+         .tooltip = N_("Center horizontally"),
+         .callback = G_CALLBACK (cb_align_center)
+       },
+       { .name = "AlignRight",
+         .toggle = TRUE,
+         .icon = "format-justify-right",
+         .label = N_("_Right Align"),
+         .tooltip = N_("Align right"),
+         .callback = G_CALLBACK (cb_align_right)
+       },
+       { .name = "CenterAcrossSelection",
+         .toggle = TRUE,
+         .icon = "gnumeric-center-across-selection",
+         .label = N_("_Center Across Selection"),
+         .tooltip = N_("Center horizontally across the selection"),
+         .callback = G_CALLBACK (cb_center_across_selection)
+       },
+       { .name = "MergeAndCenter",
+         .toggle = TRUE,
+         .label = N_("_Merge and Center"),
+         .tooltip = N_("Merge the selection into 1 cell, and center horizontally."),
+         .callback = G_CALLBACK (cb_merge_and_center)
+       },
 #warning "Add justify"
 #warning "h/v distributed?"
 
 #warning "Get vertical alignment icons"
-       { "AlignTop", NULL,
-               N_("Align _Top"), NULL,
-               N_("Align Top"), G_CALLBACK (cb_align_top), FALSE },
-       { "AlignVCenter", NULL,
-               N_("_Vertically Center"), NULL,
-               N_("Vertically Center"), G_CALLBACK (cb_align_vcenter), FALSE },
-       { "AlignBottom", NULL,
-               N_("Align _Bottom"), NULL,
-               N_("Align Bottom"), G_CALLBACK (cb_align_bottom), FALSE },
-};
-
-static GtkToggleActionEntry const semi_permanent_toggle_actions[] = {
-       { "ViewStatusbar", NULL,
-               N_("View _Statusbar"), NULL,
-               N_("Toggle visibility of statusbar"),
-               G_CALLBACK (cb_view_statusbar), TRUE },
-
-       { "ViewFullScreen", "view-fullscreen",
-               N_("F_ull Screen"), FULLSCREEN_ACCEL,
-               N_("Switch to or from full screen mode"),
-               G_CALLBACK (cb_view_fullscreen), FALSE }
+       { .name = "AlignTop",
+         .toggle = TRUE,
+         .label = N_("Align _Top"),
+         .tooltip = N_("Align Top"),
+         .callback = G_CALLBACK (cb_align_top)
+       },
+       { .name = "AlignVCenter",
+         .toggle = TRUE,
+         .label = N_("_Vertically Center"),
+         .tooltip = N_("Vertically Center"),
+         .callback = G_CALLBACK (cb_align_vcenter)
+       },
+       { .name = "AlignBottom",
+         .toggle = TRUE,
+         .label = N_("Align _Bottom"),
+         .tooltip = N_("Align Bottom"),
+         .callback = G_CALLBACK (cb_align_bottom)
+       },
 };
 
-static GtkToggleActionEntry const font_toggle_actions[] = {
-       { "FontBold", "format-text-bold",
-               N_("_Bold"), "<control>b",      /* ALSO "<control>2" */
-               N_("Bold"), G_CALLBACK (cb_font_bold), FALSE },
-       { "FontItalic", "format-text-italic",
-               N_("_Italic"), "<control>i",    /* ALSO "<control>3" */
-               N_("Italic"), G_CALLBACK (cb_font_italic), FALSE },
-       { "FontUnderline", "format-text-underline",
-               N_("_Underline"), "<control>u", /* ALSO "<control>4" */
-               N_("Underline"), G_CALLBACK (cb_font_underline), FALSE },
-       { "FontDoubleUnderline", "stock_text_underlined-double",        /* from icon theme */
-               N_("_Double Underline"), "<control><shift>d",
-               N_("Double Underline"), G_CALLBACK (cb_font_double_underline), FALSE },
-       { "FontSingleLowUnderline", NULL,       /* from icon theme */
-               N_("_Single Low Underline"), "<control><shift>l",
-               N_("Single Low Underline"), G_CALLBACK (cb_font_underline_low), FALSE },
-       { "FontDoubleLowUnderline", NULL,       /* from icon theme */
-               N_("Double _Low Underline"), NULL,
-               N_("Double Low Underline"), G_CALLBACK (cb_font_double_underline_low), FALSE },
-       { "FontStrikeThrough", "format-text-strikethrough",
-               N_("_Strikethrough"), "<control>5",
-               N_("Strikethrough"), G_CALLBACK (cb_font_strikethrough), FALSE },
-       { "FontSuperscript", "gnumeric-superscript",
-               N_("Su_perscript"), "<control>asciicircum",
-               N_("Superscript"), G_CALLBACK (cb_font_superscript), FALSE },
-       { "FontSubscript", "gnumeric-subscript",
-               N_("Subscrip_t"), "<control>underscore",
-               N_("Subscript"), G_CALLBACK (cb_font_subscript), FALSE }
+static GnmActionEntry const font_actions[] = {
+       { .name = "FontBold",
+         .toggle = TRUE,
+         .icon = "format-text-bold",
+         .label = N_("_Bold"),
+         .accelerator = "<control>b",  /* ALSO "<control>2" */
+         .tooltip = N_("Bold"),
+         .callback = G_CALLBACK (cb_font_bold),
+         .is_active = FALSE },
+       { .name = "FontItalic",
+         .toggle = TRUE,
+         .icon = "format-text-italic",
+         .label = N_("_Italic"),
+         .accelerator = "<control>i",  /* ALSO "<control>3" */
+         .tooltip = N_("Italic"),
+         .callback = G_CALLBACK (cb_font_italic),
+         .is_active = FALSE },
+       { .name = "FontUnderline",
+         .toggle = TRUE,
+         .icon = "format-text-underline",
+         .label = N_("_Underline"),
+         .accelerator = "<control>u",  /* ALSO "<control>4" */
+         .tooltip = N_("Underline"),
+         .callback = G_CALLBACK (cb_font_underline),
+         .is_active = FALSE },
+       { .name = "FontDoubleUnderline",
+         .toggle = TRUE,
+         .icon = "stock_text_underlined-double",       /* from icon theme */
+         .label = N_("_Double Underline"),
+         .accelerator = "<control><shift>d",
+         .tooltip = N_("Double Underline"),
+         .callback = G_CALLBACK (cb_font_double_underline),
+         .is_active = FALSE },
+       { .name = "FontSingleLowUnderline",
+         .toggle = TRUE,
+         .label = N_("_Single Low Underline"),
+         .accelerator = "<control><shift>l",
+         .tooltip = N_("Single Low Underline"),
+         .callback = G_CALLBACK (cb_font_underline_low),
+         .is_active = FALSE },
+       { .name = "FontDoubleLowUnderline",
+         .toggle = TRUE,
+         .label = N_("Double _Low Underline"),
+         .tooltip = N_("Double Low Underline"),
+         .callback = G_CALLBACK (cb_font_double_underline_low),
+         .is_active = FALSE },
+       { .name = "FontStrikeThrough",
+         .toggle = TRUE,
+         .icon = "format-text-strikethrough",
+         .label = N_("_Strikethrough"),
+         .accelerator = "<control>5",
+         .tooltip = N_("Strikethrough"),
+         .callback = G_CALLBACK (cb_font_strikethrough),
+         .is_active = FALSE },
+       { .name = "FontSuperscript",
+         .toggle = TRUE,
+         .icon = "gnumeric-superscript",
+         .label = N_("Su_perscript"),
+         .accelerator = "<control>asciicircum",
+         .tooltip = N_("Superscript"),
+         .callback = G_CALLBACK (cb_font_superscript),
+         .is_active = FALSE },
+       { .name = "FontSubscript",
+         .toggle = TRUE,
+         .icon = "gnumeric-subscript",
+         .label = N_("Subscrip_t"),
+         .accelerator = "<control>underscore",
+         .tooltip = N_("Subscript"),
+         .callback = G_CALLBACK (cb_font_subscript), .is_active = FALSE }
 };
 
 /****************************************************************************/
@@ -4357,30 +4452,21 @@ wbc_gtk_init_actions (WBCGtk *wbcg)
        unsigned i;
 
        wbcg->permanent_actions = gtk_action_group_new ("PermanentActions");
-       gtk_action_group_set_translation_domain (wbcg->permanent_actions, GETTEXT_PACKAGE);
        wbcg->actions = gtk_action_group_new ("Actions");
-       gtk_action_group_set_translation_domain (wbcg->actions, GETTEXT_PACKAGE);
        wbcg->font_actions = gtk_action_group_new ("FontActions");
-       gtk_action_group_set_translation_domain (wbcg->font_actions, GETTEXT_PACKAGE);
        wbcg->data_only_actions = gtk_action_group_new ("DataOnlyActions");
-       gtk_action_group_set_translation_domain (wbcg->data_only_actions, GETTEXT_PACKAGE);
        wbcg->semi_permanent_actions = gtk_action_group_new ("SemiPermanentActions");
-       gtk_action_group_set_translation_domain (wbcg->semi_permanent_actions, GETTEXT_PACKAGE);
 
        gnm_action_group_add_actions (wbcg->permanent_actions,
                permanent_actions, G_N_ELEMENTS (permanent_actions), wbcg);
        gnm_action_group_add_actions (wbcg->actions,
                actions, G_N_ELEMENTS (actions), wbcg);
-       gtk_action_group_add_toggle_actions (wbcg->actions,
-               toggle_actions, G_N_ELEMENTS (toggle_actions), wbcg);
-       gtk_action_group_add_toggle_actions (wbcg->font_actions,
-               font_toggle_actions, G_N_ELEMENTS (font_toggle_actions), wbcg);
+       gnm_action_group_add_actions (wbcg->font_actions,
+               font_actions, G_N_ELEMENTS (font_actions), wbcg);
        gnm_action_group_add_actions (wbcg->data_only_actions,
                data_only_actions, G_N_ELEMENTS (data_only_actions), wbcg);
        gnm_action_group_add_actions (wbcg->semi_permanent_actions,
                semi_permanent_actions, G_N_ELEMENTS (semi_permanent_actions), wbcg);
-       gtk_action_group_add_toggle_actions (wbcg->semi_permanent_actions,
-               semi_permanent_toggle_actions, G_N_ELEMENTS (semi_permanent_toggle_actions), wbcg);
 
        wbc_gtk_init_alignments (wbcg);
        wbc_gtk_init_color_fore (wbcg);
@@ -4392,13 +4478,11 @@ wbc_gtk_init_actions (WBCGtk *wbcg)
        wbcg->font_name_vaction = wbc_gtk_init_font_name (wbcg, FALSE);
 
        for (i = G_N_ELEMENTS (toggles); i-- > 0 ; ) {
-               GtkAction *act = gtk_action_group_get_action (
-                       (toggles[i].is_font ? wbcg->font_actions : wbcg->actions),
-                       toggles[i].name);
-               G_STRUCT_MEMBER (GtkToggleAction *, wbcg, toggles[i].offset) = GTK_TOGGLE_ACTION (act);
+               GtkAction *act = wbcg_find_action (wbcg, toggles[i].name);
+               G_STRUCT_MEMBER (GtkToggleAction *, wbcg, toggles[i].offset) =
+                       (GtkToggleAction*) (act);
        }
 
-
        if (gnm_debug_flag ("actions")) {
                list_actions (wbcg->permanent_actions);
                list_actions (wbcg->actions);
diff --git a/src/wbc-gtk-impl.h b/src/wbc-gtk-impl.h
index 43e5b60..149fa5b 100644
--- a/src/wbc-gtk-impl.h
+++ b/src/wbc-gtk-impl.h
@@ -168,6 +168,8 @@ void     wbcg_font_action_set_font_desc (GtkAction *act, PangoFontDescription *d
 
 gboolean wbc_gtk_load_templates (WBCGtk *gtk);
 
+GtkAction *wbcg_find_action (WBCGtk *wbcg, const char *name);
+
 G_MODULE_EXPORT void set_uifilename (char const *name, GtkActionEntry const *actions, int nb);
 
 G_END_DECLS
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 4daaf56..362dc29 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -128,17 +128,36 @@ set_uifilename (char const *name, GtkActionEntry const *actions, int nb)
        extra_actions_nb = nb;
 }
 
-static void
-wbc_gtk_set_action_sensitivity (WBCGtk const *wbcg,
-                               char const *action, gboolean sensitive)
+/**
+ * wbcg_find_action:
+ * @wbcg: the workbook control gui
+ * @name: name of action
+ *
+ * Returns: (transfer none): The action with the given name
+ **/
+GtkAction *
+wbcg_find_action (WBCGtk *wbcg, const char *name)
 {
-       GtkAction *a = gtk_action_group_get_action (wbcg->actions, action);
+       GtkAction *a;
+
+       a = gtk_action_group_get_action (wbcg->actions, name);
        if (a == NULL)
-               a = gtk_action_group_get_action (wbcg->permanent_actions, action);
+               a = gtk_action_group_get_action (wbcg->permanent_actions, name);
        if (a == NULL)
-               a = gtk_action_group_get_action (wbcg->semi_permanent_actions, action);
+               a = gtk_action_group_get_action (wbcg->semi_permanent_actions, name);
        if (a == NULL)
-               a = gtk_action_group_get_action (wbcg->data_only_actions, action);
+               a = gtk_action_group_get_action (wbcg->data_only_actions, name);
+       if (a == NULL)
+               a = gtk_action_group_get_action (wbcg->font_actions, name);
+
+       return a;
+}
+
+static void
+wbc_gtk_set_action_sensitivity (WBCGtk *wbcg,
+                               char const *action, gboolean sensitive)
+{
+       GtkAction *a = wbcg_find_action (wbcg, action);
        g_object_set (G_OBJECT (a), "sensitive", sensitive, NULL);
 }
 
@@ -146,16 +165,13 @@ wbc_gtk_set_action_sensitivity (WBCGtk const *wbcg,
  * handling it at this end ?  That stuff should be done in the undo/redo code
  **/
 static void
-wbc_gtk_set_action_label (WBCGtk const *wbcg,
+wbc_gtk_set_action_label (WBCGtk *wbcg,
                          char const *action,
                          char const *prefix,
                          char const *suffix,
                          char const *new_tip)
 {
-       GtkAction *a = gtk_action_group_get_action (wbcg->actions, action);
-
-       if (!a)
-               a = gtk_action_group_get_action (wbcg->semi_permanent_actions, action);
+       GtkAction *a = wbcg_find_action (wbcg, action);
 
        if (prefix != NULL) {
                char *text;
@@ -176,16 +192,10 @@ wbc_gtk_set_action_label (WBCGtk const *wbcg,
 }
 
 static void
-wbc_gtk_set_toggle_action_state (WBCGtk const *wbcg,
+wbc_gtk_set_toggle_action_state (WBCGtk *wbcg,
                                 char const *action, gboolean state)
 {
-       GtkAction *a = gtk_action_group_get_action (wbcg->actions, action);
-       if (a == NULL)
-               a = gtk_action_group_get_action (wbcg->font_actions, action);
-       if (a == NULL)
-               a = gtk_action_group_get_action (wbcg->toolbar.actions, action);
-       if (a == NULL)
-               a = gtk_action_group_get_action (wbcg->semi_permanent_actions, action);
+       GtkAction *a = wbcg_find_action (wbcg, action);
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (a), state);
 }
 
@@ -1099,7 +1109,8 @@ disconnect_sheet_signals (SheetControlGUI *scg)
        g_printerr ("Disconnecting all for %s with scg=%p\n", sheet->name_unquoted, scg);
 #endif
 
-       g_signal_handlers_disconnect_by_func (sheet, cb_sheet_direction_change, gtk_action_group_get_action 
(wbcg->actions, "SheetDirection"));
+       g_signal_handlers_disconnect_by_func (sheet, cb_sheet_direction_change,
+                                             wbcg_find_action (wbcg, "SheetDirection"));
        g_signal_handlers_disconnect_by_func (sheet, cb_sheet_tab_change, scg->label);
        g_signal_handlers_disconnect_by_func (sheet, cb_sheet_visibility_change, scg);
 }
@@ -1163,7 +1174,7 @@ wbcg_sheet_add (WorkbookControl *wbc, SheetView *sv)
                          "signal::notify::name", cb_sheet_tab_change, scg->label,
                          "signal::notify::tab-foreground", cb_sheet_tab_change, scg->label,
                          "signal::notify::tab-background", cb_sheet_tab_change, scg->label,
-                         "signal::notify::text-is-rtl", cb_sheet_direction_change, 
gtk_action_group_get_action (wbcg->actions, "SheetDirection"),
+                         "signal::notify::text-is-rtl", cb_sheet_direction_change, wbcg_find_action (wbcg, 
"SheetDirection"),
                          NULL);
 
        if (wbcg_ui_update_begin (wbcg)) {
@@ -4173,7 +4184,7 @@ wbc_gtk_create_status_area (WBCGtk *wbcg)
        /* disable statusbar by default going to fullscreen */
        wbcg->hide_for_fullscreen =
                g_slist_prepend (wbcg->hide_for_fullscreen,
-                                gtk_action_group_get_action (wbcg->semi_permanent_actions, "ViewStatusbar"));
+                                wbcg_find_action (wbcg, "ViewStatusbar"));
        g_assert (wbcg->hide_for_fullscreen->data);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]