[gnome-builder/editor-layout] use menu for tab stack related operations
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/editor-layout] use menu for tab stack related operations
- Date: Sun, 30 Nov 2014 13:20:48 +0000 (UTC)
commit baf1e353e1e6e3465cb9589fea228b77fd3bbe96
Author: Christian Hergert <christian hergert me>
Date: Sun Nov 30 03:56:52 2014 -0800
use menu for tab stack related operations
src/resources/gtk/menus.ui | 39 ++++++++++++++++++
src/resources/ui/gb-tab-stack.ui | 22 +---------
src/tabs/gb-tab-stack.c | 82 ++++++--------------------------------
3 files changed, 54 insertions(+), 89 deletions(-)
---
diff --git a/src/resources/gtk/menus.ui b/src/resources/gtk/menus.ui
index 85a427f..9a08812 100644
--- a/src/resources/gtk/menus.ui
+++ b/src/resources/gtk/menus.ui
@@ -111,4 +111,43 @@
</item>
</section>
</menu>
+ <menu id="stack-menu">
+ <section>
+ <attribute name="id">juntion-section</attribute>
+ <attribute name="display-hint">horizontal-buttons</attribute>
+ <item>
+ <attribute name="label" translatable="yes">Move Tab to _Left</attribute>
+ <attribute name="action">tabs.move-left</attribute>
+ <attribute name="verb-icon">builder-move-tab-left</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>
+ <item>
+ <attribute name="label" translatable="yes">Move Tab to _Right</attribute>
+ <attribute name="action">tabs.move-right</attribute>
+ <attribute name="verb-icon">builder-move-tab-right</attribute>
+ </item>
+ </section>
+ <section>
+ <attribute name="id">file-section-1</attribute>
+ <item>
+ <attribute name="label" translatable="yes">_Save</attribute>
+ <attribute name="action">workbench.save</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Save As…</attribute>
+ <attribute name="action">workbench.save-as</attribute>
+ </item>
+ </section>
+ <section>
+ <attribute name="id">close-section</attribute>
+ <item>
+ <attribute name="label" translatable="yes">_Close</attribute>
+ <attribute name="action">workbench.close-tab</attribute>
+ </item>
+ </section>
+ </menu>
</interface>
diff --git a/src/resources/ui/gb-tab-stack.ui b/src/resources/ui/gb-tab-stack.ui
index 160c5db..37ecb7a 100644
--- a/src/resources/ui/gb-tab-stack.ui
+++ b/src/resources/ui/gb-tab-stack.ui
@@ -11,10 +11,8 @@
<class name="linked"/>
</style>
<child>
- <object class="GtkButton" id="move_left">
+ <object class="GtkMenuButton" id="stack_menu">
<property name="visible">true</property>
- <property name="sensitive">false</property>
- <property name="tooltip_text">Move tab to the left</property>
<style>
<class name="image-button"/>
<class name="tab-header-first"/>
@@ -22,23 +20,7 @@
<child>
<object class="GtkImage">
<property name="visible">true</property>
- <property name="icon_name">builder-move-tab-left</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="move_right">
- <property name="visible">true</property>
- <property name="sensitive">false</property>
- <property name="tooltip_text">Move tab to the right</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="visible">true</property>
- <property name="icon_name">builder-move-tab-right</property>
+ <property name="icon_name">open-menu-symbolic</property>
</object>
</child>
</object>
diff --git a/src/tabs/gb-tab-stack.c b/src/tabs/gb-tab-stack.c
index 4c83cc6..cb3ec93 100644
--- a/src/tabs/gb-tab-stack.c
+++ b/src/tabs/gb-tab-stack.c
@@ -26,13 +26,12 @@
struct _GbTabStackPrivate
{
- GtkButton *close;
- GtkComboBox *combo;
- GtkStack *controls;
- GtkButton *move_left;
- GtkButton *move_right;
- GtkStack *stack;
- GtkListStore *store;
+ GtkButton *close;
+ GtkComboBox *combo;
+ GtkStack *controls;
+ GtkMenuButton *stack_menu;
+ GtkStack *stack;
+ GtkListStore *store;
};
G_DEFINE_TYPE_WITH_PRIVATE (GbTabStack, gb_tab_stack, GTK_TYPE_BOX)
@@ -460,18 +459,6 @@ gb_tab_stack_grab_focus (GtkWidget *widget)
gtk_widget_grab_focus (child);
}
-static void
-gb_tab_stack_real_changed (GbTabStack *stack)
-{
- gboolean sensitive;
-
- g_return_if_fail (GB_IS_TAB_STACK (stack));
-
- sensitive = !!gtk_stack_get_visible_child (stack->priv->stack);
- gtk_widget_set_sensitive (GTK_WIDGET (stack->priv->move_left), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET (stack->priv->move_right), sensitive);
-}
-
static GbTabGrid *
get_grid (GbTabStack *stack)
{
@@ -486,40 +473,6 @@ get_grid (GbTabStack *stack)
}
static void
-gb_tab_stack_do_move_left (GbTabStack *stack,
- GdkEvent *event,
- GtkButton *button)
-{
- GbTabGrid *grid;
- GbTab *tab;
-
- g_return_if_fail (GB_IS_TAB_STACK (stack));
-
- grid = get_grid (stack);
- tab = gb_tab_stack_get_active (stack);
-
- if (grid && tab)
- gb_tab_grid_move_tab_left (grid, tab);
-}
-
-static void
-gb_tab_stack_do_move_right (GbTabStack *stack,
- GdkEvent *event,
- GtkButton *button)
-{
- GbTabGrid *grid;
- GbTab *tab;
-
- g_return_if_fail (GB_IS_TAB_STACK (stack));
-
- grid = get_grid (stack);
- tab = gb_tab_stack_get_active (stack);
-
- if (grid && tab)
- gb_tab_grid_move_tab_right (grid, tab);
-}
-
-static void
gb_tab_stack_do_close_tab (GbTabStack *stack,
GdkEvent *event,
GtkButton *button)
@@ -546,16 +499,13 @@ gb_tab_stack_class_init (GbTabStackClass *klass)
widget_class->grab_focus = gb_tab_stack_grab_focus;
- klass->changed = gb_tab_stack_real_changed;
-
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/ui/gb-tab-stack.ui");
gtk_widget_class_bind_template_child_internal_private (widget_class, GbTabStack, controls);
gtk_widget_class_bind_template_child_private (widget_class, GbTabStack, close);
gtk_widget_class_bind_template_child_private (widget_class, GbTabStack, combo);
- gtk_widget_class_bind_template_child_private (widget_class, GbTabStack, move_left);
- gtk_widget_class_bind_template_child_private (widget_class, GbTabStack, move_right);
gtk_widget_class_bind_template_child_private (widget_class, GbTabStack, stack);
+ gtk_widget_class_bind_template_child_private (widget_class, GbTabStack, stack_menu);
gtk_widget_class_bind_template_child_private (widget_class, GbTabStack, store);
gSignals [CHANGED] = g_signal_new ("changed",
@@ -576,6 +526,8 @@ gb_tab_stack_init (GbTabStack *stack)
{
GtkCellLayout *layout;
GtkCellRenderer *cell;
+ GApplication *app;
+ GMenu *menu;
stack->priv = gb_tab_stack_get_instance_private (stack);
@@ -590,18 +542,6 @@ gb_tab_stack_init (GbTabStack *stack)
stack,
G_CONNECT_SWAPPED);
- g_signal_connect_object (stack->priv->move_left,
- "clicked",
- G_CALLBACK (gb_tab_stack_do_move_left),
- stack,
- G_CONNECT_SWAPPED);
-
- g_signal_connect_object (stack->priv->move_right,
- "clicked",
- G_CALLBACK (gb_tab_stack_do_move_right),
- stack,
- G_CONNECT_SWAPPED);
-
g_signal_connect_object (stack->priv->close,
"clicked",
G_CALLBACK (gb_tab_stack_do_close_tab),
@@ -616,4 +556,8 @@ gb_tab_stack_init (GbTabStack *stack)
NULL, NULL);
gtk_cell_renderer_text_set_fixed_height_from_font (
GTK_CELL_RENDERER_TEXT (cell), 1);
+
+ app = g_application_get_default ();
+ menu = gtk_application_get_menu_by_id (GTK_APPLICATION (app), "stack-menu");
+ gtk_menu_button_set_menu_model (stack->priv->stack_menu, G_MENU_MODEL (menu));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]