[gnome-2048/app-menu: 1/3] Move HeaderBar to ui file
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-2048/app-menu: 1/3] Move HeaderBar to ui file
- Date: Thu, 4 Oct 2018 17:43:46 +0000 (UTC)
commit ecfa0adc2b6a7f5965c057ec177da619772b5376
Author: Jan Tojnar <jtojnar gmail com>
Date: Thu Oct 4 18:48:47 2018 +0200
Move HeaderBar to ui file
data/mainwindow.ui | 68 +++++++++++++++++++++++++++++++++++++++-------------
src/application.vala | 20 +++++-----------
2 files changed, 57 insertions(+), 31 deletions(-)
---
diff --git a/data/mainwindow.ui b/data/mainwindow.ui
index dc6aacb..8841cce 100644
--- a/data/mainwindow.ui
+++ b/data/mainwindow.ui
@@ -1,15 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.1 -->
+<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkApplicationWindow" id="applicationwindow">
<property name="can_focus">False</property>
- <property name="title" translatable="yes">GNOME 2048</property>
<property name="window_position">center</property>
<property name="default_width">600</property>
<property name="default_height">600</property>
<property name="icon_name">gnome-2048</property>
<property name="show_menubar">False</property>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="headerbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">GNOME 2048</property>
+ <property name="show_close_button">True</property>
+ <child>
+ <object class="GtkButton" id="undo-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="action_name">app.undo</property>
+ <property name="always_show_image">True</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">edit-undo-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="new-game-button">
+ <property name="label" translatable="yes">_New Game</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="action_name">app.new-game</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="score">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">0</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
@@ -38,21 +87,6 @@
<child>
<placeholder/>
</child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
</object>
</child>
</object>
diff --git a/src/application.vala b/src/application.vala
index 44ca557..b365f6f 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -214,7 +214,7 @@ public class Application : Gtk.Application
add_window (_window);
- _create_header_bar ();
+ _create_header_bar (builder);
_create_game_view (builder);
_window.set_events (_window.get_events () | Gdk.EventMask.STRUCTURE_MASK |
Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.KEY_RELEASE_MASK);
@@ -228,24 +228,16 @@ public class Application : Gtk.Application
_window.set_geometry_hints (_window, geom, Gdk.WindowHints.MIN_SIZE);
}
- private void _create_header_bar ()
+ private void _create_header_bar (Builder builder)
{
- _header_bar = new HeaderBar ();
- _header_bar.show_close_button = true;
- _header_bar.title = "2048";
- _window.set_titlebar (_header_bar);
+ _header_bar = (HeaderBar) builder.get_object ("headerbar");
- _score = new Label ("0");
- _header_bar.pack_end (_score);
+ _score = (Label) builder.get_object ("score");
- _undo_button = new Button.from_icon_name ("edit-undo-symbolic");
- _undo_button.set_action_name ("app.undo");
- _header_bar.pack_start (_undo_button);
+ _undo_button = (Button) builder.get_object ("undo-button");
((SimpleAction) lookup_action ("undo")).set_enabled (false);
- _new_game_button = new Button.with_label (_("New Game"));
- _new_game_button.set_action_name ("app.new-game");
- _header_bar.pack_start (_new_game_button);
+ _new_game_button = (Button) builder.get_object ("new-game-button");
}
private void _create_game_view (Builder builder)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]