[gnome-builder] workbench: stub out gear menu
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] workbench: stub out gear menu
- Date: Wed, 10 Sep 2014 01:50:12 +0000 (UTC)
commit 94640b8ee3d89d463fd5095d6b75ff5eba8903d5
Author: Christian Hergert <christian hergert me>
Date: Tue Sep 9 18:50:06 2014 -0700
workbench: stub out gear menu
src/resources/gnome-builder.gresource.xml | 2 +
src/resources/gtk/menus.ui | 95 +++++++++++++++++++++++++++++
src/workbench/gb-workbench.c | 66 ++++++++++++++------
3 files changed, 142 insertions(+), 21 deletions(-)
---
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 1e0f291..72a41f7 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -5,6 +5,8 @@
<file>editor/uncrustify/uncrustify.c.cfg</file>
+ <file>gtk/menus.ui</file>
+
<file>keybindings/default.ini</file>
<file>snippets/c.snippets</file>
diff --git a/src/resources/gtk/menus.ui b/src/resources/gtk/menus.ui
new file mode 100644
index 0000000..dcd8ce3
--- /dev/null
+++ b/src/resources/gtk/menus.ui
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <menu id="app-menu">
+ <section>
+ <attribute name="id">preferences-section</attribute>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">app.preferences</attribute>
+ </item>
+ </section>
+ <section>
+ <attribute name="id">help-section</attribute>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">app.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">app.about</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Quit</attribute>
+ <attribute name="action">app.quit</attribute>
+ </item>
+ </section>
+ </menu>
+ <menu id="gear-menu">
+ <section>
+ <attribute name="id">juntion-section</attribute>
+ <attribute name="display-hint">horizontal-buttons</attribute>
+ <item>
+ <attribute name="label" translatable="yes">_Reload</attribute>
+ <attribute name="action">win.revert</attribute>
+ <attribute name="verb-icon">view-refresh-symbolic</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Print…</attribute>
+ <attribute name="action">win.print</attribute>
+ <attribute name="verb-icon">printer-symbolic</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Fullscreen</attribute>
+ <attribute name="action">win.fullscreen</attribute>
+ <attribute name="verb-icon">view-fullscreen-symbolic</attribute>
+ </item>
+ </section>
+ <section>
+ <attribute name="id">file-section</attribute>
+ </section>
+ <section>
+ <attribute name="id">file-section-1</attribute>
+ <item>
+ <attribute name="label" translatable="yes">_Save As…</attribute>
+ <attribute name="action">win.save-as</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Save _All</attribute>
+ <attribute name="action">win.save-all</attribute>
+ </item>
+ </section>
+ <section>
+ <attribute name="id">edit-section</attribute>
+ </section>
+ <section>
+ <attribute name="id">edit-section-1</attribute>
+ </section>
+ <section>
+ <attribute name="id">search-section</attribute>
+ <item>
+ <attribute name="label" translatable="yes">_Find…</attribute>
+ <attribute name="action">win.find</attribute>
+ </item>
+ </section>
+ <section>
+ <submenu>
+ <attribute name="label" translatable="yes">View</attribute>
+ </submenu>
+ <submenu>
+ <attribute name="label" translatable="yes">Tools</attribute>
+ </submenu>
+ </section>
+ <section>
+ <attribute name="id">close-section</attribute>
+ <item>
+ <attribute name="label" translatable="yes">_Close All</attribute>
+ <attribute name="action">win.close-all</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Close</attribute>
+ <attribute name="action">win.close</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index bfac0da..35aad4c 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -213,6 +213,49 @@ gb_workbench_realize (GtkWidget *widget)
gtk_widget_grab_focus (GTK_WIDGET (workbench->priv->editor));
}
+static const GActionEntry gActionEntries[] = {
+ { "new-tab", gb_workbench_activate_new_tab },
+ { "find", gb_workbench_activate_find },
+};
+
+static void
+gb_workbench_constructed (GObject *object)
+{
+ GbWorkbenchPrivate *priv;
+ GbWorkbench *workbench = (GbWorkbench *)object;
+ GtkApplication *app;
+ GMenu *menu;
+
+ g_assert (GB_IS_WORKBENCH (workbench));
+
+ ENTRY;
+
+ priv = workbench->priv;
+
+ g_action_map_add_action_entries (G_ACTION_MAP (workbench), gActionEntries,
+ G_N_ELEMENTS (gActionEntries), workbench);
+
+ load_actions (workbench, GB_WORKSPACE (priv->editor));
+ load_actions (workbench, GB_WORKSPACE (priv->devhelp));
+
+ app = GTK_APPLICATION (g_application_get_default ());
+ menu = gtk_application_get_menu_by_id (app, "gear-menu");
+ gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->gear_menu_button),
+ G_MENU_MODEL (menu));
+
+ g_signal_connect_object (priv->stack,
+ "notify::visible-child",
+ G_CALLBACK (gb_workbench_stack_child_changed),
+ workbench,
+ (G_CONNECT_SWAPPED | G_CONNECT_AFTER));
+
+ gb_workbench_stack_child_changed (workbench, NULL, priv->stack);
+
+ G_OBJECT_CLASS (gb_workbench_parent_class)->constructed (object);
+
+ EXIT;
+}
+
static void
gb_workbench_finalize (GObject *object)
{
@@ -253,6 +296,7 @@ gb_workbench_class_init (GbWorkbenchClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->constructed = gb_workbench_constructed;
object_class->finalize = gb_workbench_finalize;
object_class->get_property = gb_workbench_get_property;
object_class->set_property = gb_workbench_set_property;
@@ -305,27 +349,7 @@ gb_workbench_class_init (GbWorkbenchClass *klass)
static void
gb_workbench_init (GbWorkbench *workbench)
{
- static const GActionEntry action_entries[] = {
- { "new-tab", gb_workbench_activate_new_tab },
- { "find", gb_workbench_activate_find },
- };
- GbWorkbenchPrivate *priv;
-
- priv = workbench->priv = gb_workbench_get_instance_private (workbench);
-
- g_action_map_add_action_entries (G_ACTION_MAP (workbench), action_entries,
- G_N_ELEMENTS (action_entries), workbench);
+ workbench->priv = gb_workbench_get_instance_private (workbench);
gtk_widget_init_template (GTK_WIDGET (workbench));
-
- g_signal_connect_object (priv->stack,
- "notify::visible-child",
- G_CALLBACK (gb_workbench_stack_child_changed),
- workbench,
- (G_CONNECT_SWAPPED | G_CONNECT_AFTER));
-
- gb_workbench_stack_child_changed (workbench, NULL, priv->stack);
-
- load_actions (workbench, GB_WORKSPACE (priv->editor));
- load_actions (workbench, GB_WORKSPACE (priv->devhelp));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]