[gedit] Move also the notebook popup menu model in gedit-menu



commit ff11ba06defbdd230e20b1375bdba8bcfcf3895e
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Feb 16 14:50:38 2014 +0100

    Move also the notebook popup menu model in gedit-menu
    
    It is better if there is just one instance per app of each menu model
    so that if needed we can expose this to plugins

 gedit/gedit-app.c                  |   11 +++++++++++
 gedit/gedit-app.h                  |    3 +++
 gedit/gedit-menu.ui                |   28 ++++++++++++++++++++++++++++
 gedit/gedit-notebook-popup-menu.c  |   19 +++++--------------
 gedit/gedit-notebook-popup-menu.ui |   35 -----------------------------------
 gedit/gedit.gresource.xml          |    1 -
 po/POTFILES.in                     |    3 ++-
 7 files changed, 49 insertions(+), 51 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 494bffd..def7698 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -79,6 +79,7 @@ struct _GeditAppPrivate
        GSettings         *window_settings;
 
        GMenuModel        *window_menu;
+       GMenuModel        *notebook_menu;
        GMenuModel        *tab_width_menu;
 
        PeasExtensionSet  *extensions;
@@ -492,6 +493,8 @@ gedit_app_startup (GApplication *application)
                {
                        app->priv->window_menu = G_MENU_MODEL (gtk_builder_get_object (builder, 
"gear_menu_noappmenu"));
                }
+
+               app->priv->notebook_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "notebook_menu"));
                app->priv->tab_width_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "tab_width_menu"));
        }
 
@@ -1650,6 +1653,14 @@ _gedit_app_get_window_menu (GeditApp *app)
 }
 
 GMenuModel *
+_gedit_app_get_notebook_menu (GeditApp *app)
+{
+       g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
+
+       return app->priv->notebook_menu;
+}
+
+GMenuModel *
 _gedit_app_get_tab_width_menu (GeditApp *app)
 {
        g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
diff --git a/gedit/gedit-app.h b/gedit/gedit-app.h
index d4cd72a..5955b0e 100644
--- a/gedit/gedit-app.h
+++ b/gedit/gedit-app.h
@@ -136,6 +136,9 @@ void                         _gedit_app_set_default_print_settings  (GeditApp         
*app,
 GObject                        *_gedit_app_get_settings                (GeditApp  *app);
 
 GMenuModel             *_gedit_app_get_window_menu             (GeditApp  *app);
+
+GMenuModel             *_gedit_app_get_notebook_menu           (GeditApp  *app);
+
 GMenuModel             *_gedit_app_get_tab_width_menu          (GeditApp  *app);
 
 GeditMenuExtension     *_gedit_app_extend_menu                 (GeditApp    *app,
diff --git a/gedit/gedit-menu.ui b/gedit/gedit-menu.ui
index 8c22906..7522054 100644
--- a/gedit/gedit-menu.ui
+++ b/gedit/gedit-menu.ui
@@ -250,6 +250,34 @@
       </item>
     </section>
   </menu>
+  <menu id="notebook_menu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Move _Left</attribute>
+        <attribute name="action">move-left</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Move _Right</attribute>
+        <attribute name="action">move-right</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Move to New _Window</attribute>
+        <attribute name="action">move-to-new-window</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Move to New Tab _Group</attribute>
+        <attribute name="action">move-to-new-tab-group</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Close</attribute>
+        <attribute name="action">close</attribute>
+      </item>
+    </section>
+  </menu>
   <menu id="tab_width_menu">
     <section>
       <item>
diff --git a/gedit/gedit-notebook-popup-menu.c b/gedit/gedit-notebook-popup-menu.c
index c6646cf..0713c90 100644
--- a/gedit/gedit-notebook-popup-menu.c
+++ b/gedit/gedit-notebook-popup-menu.c
@@ -18,11 +18,11 @@
  * along with gedit. If not, see <http://www.gnu.org/licenses/>.
  */
 
-
-#include "gedit-notebook-popup-menu.h"
-#include "gedit-multi-notebook.h"
-#include "gedit-commands.h"
 #include <glib/gi18n.h>
+#include "gedit-app.h"
+#include "gedit-commands.h"
+#include "gedit-multi-notebook.h"
+#include "gedit-notebook-popup-menu.h"
 
 struct _GeditNotebookPopupMenuPrivate
 {
@@ -30,7 +30,6 @@ struct _GeditNotebookPopupMenuPrivate
        GeditTab *tab;
 
        GSimpleActionGroup *action_group;
-       GMenuModel *menu_model;
 };
 
 enum
@@ -157,7 +156,6 @@ static void
 gedit_notebook_popup_menu_class_init (GeditNotebookPopupMenuClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
        object_class->get_property = gedit_notebook_popup_menu_get_property;
        object_class->set_property = gedit_notebook_popup_menu_set_property;
@@ -181,11 +179,6 @@ gedit_notebook_popup_menu_class_init (GeditNotebookPopupMenuClass *klass)
                                                              GEDIT_TYPE_TAB,
                                                              G_PARAM_READWRITE |
                                                              G_PARAM_CONSTRUCT_ONLY));
-
-       gtk_widget_class_set_template_from_resource (widget_class,
-                                                    "/org/gnome/gedit/ui/gedit-notebook-popup-menu.ui");
-
-       gtk_widget_class_bind_template_child_private (widget_class, GeditNotebookPopupMenu, menu_model);
 }
 
 static void
@@ -279,10 +272,8 @@ gedit_notebook_popup_menu_init (GeditNotebookPopupMenu *menu)
 {
        menu->priv = gedit_notebook_popup_menu_get_instance_private (menu);
 
-       gtk_widget_init_template (GTK_WIDGET (menu));
-
        gtk_menu_shell_bind_model (GTK_MENU_SHELL (menu),
-                                  menu->priv->menu_model,
+                                  _gedit_app_get_notebook_menu (GEDIT_APP (g_application_get_default ())),
                                   "popup",
                                   TRUE);
 
diff --git a/gedit/gedit.gresource.xml b/gedit/gedit.gresource.xml
index d0c1dc6..c6d99d4 100644
--- a/gedit/gedit.gresource.xml
+++ b/gedit/gedit.gresource.xml
@@ -13,7 +13,6 @@
     <file preprocess="xml-stripblanks">gedit-highlight-mode-dialog.ui</file>
     <file preprocess="xml-stripblanks">gedit-highlight-mode-selector.ui</file>
     <file preprocess="xml-stripblanks">gedit-window.ui</file>
-    <file preprocess="xml-stripblanks">gedit-notebook-popup-menu.ui</file>
     <file>gedit-style.css</file>
   </gresource>
 </gresources>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index be62280..22a9efd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -22,11 +22,12 @@ gedit/gedit-encodings-dialog.c
 gedit/gedit-file-chooser-dialog.c
 gedit/gedit-highlight-mode-dialog.c
 [type: gettext/glade]gedit/gedit-highlight-mode-dialog.ui
+gedit/gedit-highlight-mode-selector.c
+[type: gettext/glade]gedit/gedit-highlight-mode-selector.ui
 gedit/gedit-io-error-info-bar.c
 [type: gettext/glade]gedit/gedit-menu.ui
 gedit/gedit-notebook.c
 gedit/gedit-notebook-popup-menu.c
-[type: gettext/glade]gedit/gedit-notebook-popup-menu.ui
 gedit/gedit-plugins-engine.c
 gedit/gedit-preferences-dialog.c
 [type: gettext/glade]gedit/gedit-preferences-dialog.ui


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