[hitori] Replace the menu bar with a header bar
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hitori] Replace the menu bar with a header bar
- Date: Wed, 18 Jun 2014 01:05:45 +0000 (UTC)
commit 927c13abcb060b93055d61e186d78b39bfe38927
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Thu Jun 5 18:50:14 2014 -0500
Replace the menu bar with a header bar
Depends on GTK+ 3.13.2 for RTL icon theme support.
https://bugzilla.gnome.org/show_bug.cgi?id=731312
configure.ac | 2 +-
data/hitori.ui | 109 ++++++++++++++++++++++++++++++++++++++++++-------------
src/interface.c | 14 +++----
3 files changed, 90 insertions(+), 35 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index eb2bbb7..8905693 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,7 +31,7 @@ YELP_HELP_INIT
APPDATA_XML
# Dependencies
-PKG_CHECK_MODULES([GENERAL],[glib-2.0 gtk+-3.0 gmodule-2.0 cairo >= 1.4])
+PKG_CHECK_MODULES([GENERAL],[glib-2.0 gtk+-3.0 >= 3.13.2 gmodule-2.0 cairo >= 1.4])
# Output!
AC_CONFIG_FILES([
diff --git a/data/hitori.ui b/data/hitori.ui
index a01cad4..22e5c7d 100644
--- a/data/hitori.ui
+++ b/data/hitori.ui
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<!--*- mode: xml -*-->
<interface>
+ <!-- interface-requires gtk+ 3.12 -->
<menu id="app_menu">
<section>
<item>
@@ -64,35 +65,91 @@
</section>
</menu>
- <menu id="win_menu">
- <submenu>
- <attribute name="label" translatable="yes">_Game</attribute>
- <section>
- <item>
- <attribute name="action">win.hint</attribute>
- <attribute name="label" translatable="yes">_Hint</attribute>
- <attribute name="accel"><Primary>h</attribute>
- </item>
- </section>
- <section>
- <item>
- <attribute name="action">win.undo</attribute>
- <attribute name="label" translatable="yes">_Undo</attribute>
- <attribute name="accel"><Primary>z</attribute>
- </item>
- <item>
- <attribute name="action">win.redo</attribute>
- <attribute name="label" translatable="yes">_Redo</attribute>
- <attribute name="accel"><Primary><Shift>z</attribute>
- </item>
- </section>
- </submenu>
- </menu>
-
<object class="GtkApplicationWindow" id="hitori_main_window">
- <property name="title" translatable="yes">Hitori</property>
<signal name="destroy" handler="hitori_destroy_cb"/>
<signal name="window-state-event" handler="hitori_window_state_event_cb"/>
+ <child type="titlebar">
+ <object class="GtkHeaderBar">
+ <property name="show_close_button">True</property>
+ <property name="title" translatable="yes">Hitori</property>
+ <child>
+ <object class="GtkBox" id="undo_redo_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <style>
+ <class name="linked"/>
+ </style>
+ <child>
+ <object class="GtkButton" id="undo_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="valign">center</property>
+ <property name="can_focus">True</property>
+ <property
name="focus_on_click">False</property>
+ <property
name="action_name">win.undo</property>
+ <accelerator key="Z" signal="activate"
modifiers="GDK_CONTROL_MASK"/>
+ <property name="tooltip_text"
translatable="yes">Undo your last move</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property
name="icon_name">edit-undo-symbolic</property>
+ <property
name="icon_size">1</property>
+ <property
name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="redo_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="valign">center</property>
+ <property name="can_focus">True</property>
+ <property
name="focus_on_click">False</property>
+ <property
name="action_name">win.redo</property>
+ <accelerator key="Z" signal="activate"
modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK"/>
+ <property name="tooltip_text"
translatable="yes">Redo a move</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property
name="icon_name">edit-redo-symbolic</property>
+ <property
name="icon_size">1</property>
+ <property
name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="hint_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="valign">center</property>
+ <property name="can_focus">True</property>
+ <property name="focus_on_click">False</property>
+ <property name="action_name">win.hint</property>
+ <accelerator key="H" signal="activate"
modifiers="GDK_CONTROL_MASK"/>
+ <property name="tooltip_text" translatable="yes">Get a hint
for your next move</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property
name="icon_name">dialog-question-symbolic</property>
+ <property name="icon_size">1</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkVBox" id="vbox1">
<child>
diff --git a/src/interface.c b/src/interface.c
index e335cad..2225e81 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -75,7 +75,7 @@ hitori_create_interface (Hitori *hitori)
GtkBuilder *builder;
GtkStyleContext *style_context;
const PangoFontDescription *font;
- GMenuModel *app_menu, *win_menu; /* owned */
+ GMenuModel *app_menu; /* owned */
builder = gtk_builder_new ();
@@ -106,23 +106,21 @@ hitori_create_interface (Hitori *hitori)
hitori->drawing_area = GTK_WIDGET (gtk_builder_get_object (builder, "hitori_drawing_area"));
hitori->timer_label = GTK_LABEL (gtk_builder_get_object (builder, "hitori_timer"));
- /* Set up the menus (application and window). */
+ /* Set up the app menu */
app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "app_menu"));
- g_action_map_add_action_entries (G_ACTION_MAP (hitori), app_entries, G_N_ELEMENTS (app_entries),
hitori);
gtk_application_set_app_menu (GTK_APPLICATION (hitori), app_menu);
g_object_unref (app_menu);
- win_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "win_menu"));
+ g_object_unref (builder);
+
+ /* Set up actions */
+ g_action_map_add_action_entries (G_ACTION_MAP (hitori), app_entries, G_N_ELEMENTS (app_entries),
hitori);
g_action_map_add_action_entries (G_ACTION_MAP (hitori->window), win_entries, G_N_ELEMENTS
(win_entries), hitori);
- gtk_application_set_menubar (GTK_APPLICATION (hitori), win_menu);
- g_object_unref (win_menu);
hitori->undo_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (hitori->window),
"undo"));
hitori->redo_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (hitori->window),
"redo"));
hitori->hint_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (hitori->window),
"hint"));
- g_object_unref (builder);
-
/* Set up font descriptions for the drawing area */
style_context = gtk_widget_get_style_context (hitori->drawing_area);
gtk_style_context_get (style_context, 0, GTK_STYLE_PROPERTY_FONT, &font, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]