[gnumeric] Cleaned the component code.



commit 634467b6ac10ca4055a195017b5ada399d11e84a
Author: Jean Brefort <jean brefort normalesup org>
Date:   Wed May 6 16:26:38 2020 +0200

    Cleaned the component code.

 ChangeLog                       |  9 +++++++++
 component/Gnumeric-embed.xml.in |  4 +++-
 component/gnumeric.c            | 15 +++++++++++----
 src/wbc-gtk-actions.c           |  3 +++
 src/wbc-gtk-impl.h              |  3 ++-
 src/wbc-gtk.c                   | 11 +++++------
 6 files changed, 33 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9c44ee8a0..845d31bb5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-05-06  Jean Brefort  <jean brefort normalesup org>
+
+       * component/Gnumeric-embed.xml.in: fix the menus and toolbars.
+       * component/gnumeric.c (go_gnm_component_edit): ditto.
+       * src/wbc-gtk-actions.c (component_changed_cb): don't loose the component
+       before using it.
+       * src/wbc-gtk-impl.h:fix the menus and toolbars.
+       * src/wbc-gtk.c (set_uifilename), (wbc_gtk_init):  ditto.
+
 2020-05-04  Morten Welinder  <terra gnome org>
 
        * src/sheet-object.c (sheet_object_get_print_flag): New function.
diff --git a/component/Gnumeric-embed.xml.in b/component/Gnumeric-embed.xml.in
index 711921b83..f254cbd00 100644
--- a/component/Gnumeric-embed.xml.in
+++ b/component/Gnumeric-embed.xml.in
@@ -203,6 +203,7 @@
         <menuitem action="ToolsScenarioAdd"/>
       </menu>
       <menuitem action="ToolsSimulation"/>
+      <menuitem action="ToolsCompare"/>
       <separator/>
       <menuitem action="ToolsPlugins"/>
     </menu>
@@ -264,6 +265,7 @@
     </menu>
     <menu name="Data" action="MenuData">
       <menuitem action="DataSort"/>
+      <menuitem action="DataShuffle"/>
       <menu name="Fill" action="MenuEditFill">
         <menuitem action="EditFillAutofill"/>
         <menuitem action="ToolsMerge"/>
@@ -353,7 +355,7 @@
   </toolbar>
   <toolbar _name="FormatToolbar">
     <toolitem action="FontName"/>
-    <toolitem action="FontSize"/>
+    <toolitem action="VFontName"/>
     <toolitem action="FontBold"/>
     <toolitem action="FontItalic"/>
     <toolitem action="FontUnderline"/>
diff --git a/component/gnumeric.c b/component/gnumeric.c
index 782138bb9..84bba4d4d 100644
--- a/component/gnumeric.c
+++ b/component/gnumeric.c
@@ -202,11 +202,17 @@ cb_gognm_save (G_GNUC_UNUSED GtkAction *a, WBCGtk *wbcg)
                gui_file_save (wbcg, wb_control_view (GNM_WBC (wbcg)));
 }
 
-static GtkActionEntry const actions[] = {
 /* File */
-       { "FileSaveEmbed", GNM_N_STOCK_SAVE, NULL,
-               NULL, N_("Save the embedded workbook"),
-               G_CALLBACK (cb_gognm_save) }
+static GnmActionEntry const actions[] = {
+/* File */
+       { .name = "FileSaveEmbed",
+         .icon = "document-save",
+         .label = GNM_N_STOCK_SAVE,
+         .label_context = GNM_STOCK_LABEL_CONTEXT,
+         .accelerator = "<control>s",
+         .tooltip = N_("Save the current workbook"),
+         .callback = G_CALLBACK (cb_gognm_save)
+       }
 };
 
 static void
@@ -246,6 +252,7 @@ go_gnm_component_edit (GOComponent *component)
        g_object_set_data (G_OBJECT (gognm->edited), "component", gognm);
        g_signal_connect_swapped (gognm->edited->toplevel, "destroy",
                G_CALLBACK (cb_editor_destroyed), gognm);
+       gtk_window_set_title (wbcg_toplevel (gognm->edited), _("Embedded spreadsheet"));
        return wbcg_toplevel (gognm->edited);
 }
 
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 6bce5090d..433b90a17 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -1364,6 +1364,9 @@ cb_add_component_new (GOComponent *component, gpointer wbcg)
 static void
 component_changed_cb (GOComponent *component, gpointer data)
 {
+       /* we nedd to ref the component otherwise it will be destroyed when
+        it's editor window will be deleted */
+       g_object_ref (component);
        cb_add_component_new (component, data);
 }
 
diff --git a/src/wbc-gtk-impl.h b/src/wbc-gtk-impl.h
index ec9678a5b..94635149c 100644
--- a/src/wbc-gtk-impl.h
+++ b/src/wbc-gtk-impl.h
@@ -7,6 +7,7 @@
 #include <style.h>
 #include <widgets/gnm-expr-entry.h>
 #include <widgets/gnm-notebook.h>
+#include <gui-util.h>
 
 #include <goffice/goffice.h>
 
@@ -168,7 +169,7 @@ 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_MODULE_EXPORT void set_uifilename (char const *name, GnmActionEntry const *actions, int nb);
 
 G_END_DECLS
 
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 6738cf35b..1fae634d6 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -92,7 +92,7 @@ enum {
 
 static gboolean debug_tab_order;
 static char const *uifilename = NULL;
-static GtkActionEntry const *extra_actions = NULL;
+static GnmActionEntry const *extra_actions = NULL;
 static int extra_actions_nb;
 static guint wbc_gtk_signals[WBC_GTK_LAST_SIGNAL];
 static GObjectClass *parent_class = NULL;
@@ -118,7 +118,7 @@ wbcg_ui_update_end (WBCGtk *wbcg)
 /****************************************************************************/
 
 G_MODULE_EXPORT void
-set_uifilename (char const *name, GtkActionEntry const *actions, int nb)
+set_uifilename (char const *name, GnmActionEntry const *actions, int nb)
 {
        uifilename = name;
        extra_actions = actions;
@@ -5060,6 +5060,9 @@ wbc_gtk_init (GObject *obj)
                "signal::disconnect_proxy", G_CALLBACK (cb_disconnect_proxy), wbcg,
                "signal::post_activate", G_CALLBACK (cb_post_activate), wbcg,
                NULL);
+       if (extra_actions)
+               gnm_action_group_add_actions (wbcg->actions, extra_actions,
+                                             extra_actions_nb, wbcg);
        gtk_ui_manager_insert_action_group (wbcg->ui, wbcg->permanent_actions, 0);
        gtk_ui_manager_insert_action_group (wbcg->ui, wbcg->actions, 0);
        gtk_ui_manager_insert_action_group (wbcg->ui, wbcg->font_actions, 0);
@@ -5068,10 +5071,6 @@ wbc_gtk_init (GObject *obj)
        gtk_window_add_accel_group (wbcg_toplevel (wbcg),
                gtk_ui_manager_get_accel_group (wbcg->ui));
 
-       if (extra_actions)
-               gtk_action_group_add_actions (wbcg->actions, extra_actions,
-                                             extra_actions_nb, wbcg);
-
        if (uifilename) {
                if (strncmp (uifilename, "res:", 4) == 0)
                        uifile = g_strdup (uifilename);


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