Commit ff11ba06 authored by Paolo Borelli's avatar Paolo Borelli

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
parent 8517d90f
......@@ -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"));
}
......@@ -1649,6 +1652,14 @@ _gedit_app_get_window_menu (GeditApp *app)
return app->priv->window_menu;
}
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)
{
......
......@@ -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,
......
......@@ -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>
......
......@@ -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);
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.8 -->
<menu id="menu_model">
<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>
<template class="GeditNotebookPopupMenu" parent="GtkMenu">
<property name="visible">True</property>
</template>
</interface>
......@@ -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>
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment