[gnome-clocks] Make headerbar a titlebar. Convert Window to a Template.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Make headerbar a titlebar. Convert Window to a Template.
- Date: Sun, 9 Jun 2013 20:04:32 +0000 (UTC)
commit 8662e90d2ae3c1b8ea030111b967ff3d8deca74c
Author: Evgeny Bobkin <evgen ibqn gmail com>
Date: Sat Jun 8 18:10:13 2013 +0200
Make headerbar a titlebar. Convert Window to a Template.
https://bugzilla.gnome.org/show_bug.cgi?id=701858
Makefile.am | 4 +++-
configure.ac | 7 ++++---
data/ui/window.ui | 30 ++++++++++--------------------
src/window.vala | 45 ++++++++++++++++++++++++++++++++++++---------
4 files changed, 53 insertions(+), 33 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 024993d..0be7c4c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -83,13 +83,15 @@ AM_CPPFLAGS = \
-DDATADIR=\""$(datadir)"\"
AM_VALAFLAGS = \
+ --target-glib=2.36 \
--vapidir=egg-list-box \
--vapidir=libgd \
--pkg gio-2.0 \
--pkg gtk+-3.0 \
--pkg libcanberra \
--pkg libnotify \
- --pkg gd-1.0
+ --pkg gd-1.0 \
+ --gresources $(top_srcdir)/data/gnome-clocks.gresource.xml
bin_PROGRAMS = gnome-clocks
diff --git a/configure.ac b/configure.ac
index cc4fe93..b6d07a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
AC_PREREQ(2.63)
AC_INIT([gnome-clocks],
- [3.8.1],
+ [3.9.2],
[http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-clocks],
[gnome-clocks])
@@ -26,7 +26,7 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext d
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
-AM_PROG_VALAC([0.17.4])
+AM_PROG_VALAC([0.20.1.19])
# _NL_TIME_FIRST_WEEKDAY is an enum and not a define
AC_MSG_CHECKING([for _NL_TIME_FIRST_WEEKDAY])
@@ -49,7 +49,8 @@ PKG_PROG_PKG_CONFIG([0.22])
PKG_CHECK_MODULES(CLOCKS, [
gio-2.0 >= 2.30.0
- gtk+-3.0 >= 3.7.12
+ glib-2.0 >= 2.36
+ gtk+-3.0 >= 3.9.0
libcanberra >= 0.30
gweather-3.0 >= 3.9.2
gnome-desktop-3.0 >= 3.7.90
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 2a696f7..3a29d49 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -1,43 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <!-- interface-requires gtk+ 3.0 -->
- <object class="GtkGrid" id="main_panel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
+ <!-- interface-requires gtk+ 3.8 -->
+ <template class="ClocksWindow" parent="Gtk.ApplicationWindow">
+ <property name="title" translatable="yes">Clocks</property>
+ <child type="titlebar">
<object class="ClocksHeaderBar" id="header_bar">
<property name="visible">True</property>
<property name="vexpand">False</property>
+ <property name="hexpand">True</property>
</object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
</child>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
+ <property name="vexpand">True</property>
+ <property name="hexpand">True</property>
<style>
<class name="view"/>
<class name="content-view"/>
</style>
<child>
<object class="GdStack" id="stack">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
</object>
</child>
</object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
</child>
- </object>
+ </template>
</interface>
diff --git a/src/window.vala b/src/window.vala
index c274ba5..109c49a 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -18,6 +18,7 @@
namespace Clocks {
+[GtkTemplate (ui = "/org/gnome/clocks/ui/window.ui")]
public class Window : Gtk.ApplicationWindow {
private const GLib.ActionEntry[] action_entries = {
// app menu
@@ -29,15 +30,18 @@ public class Window : Gtk.ApplicationWindow {
{ "select-none", on_select_none_activate }
};
+ [GtkChild]
private HeaderBar header_bar;
+ [GtkChild]
private Gd.Stack stack;
private GLib.Settings settings;
private Gtk.Widget[] panels;
+ private Gtk.Separator separator;
+ private Gtk.Button close_button;
public Window (Application app) {
- Object (application: app, title: _("Clocks"));
+ Object (application: app);
- set_hide_titlebar_when_maximized (true);
add_action_entries (action_entries, this);
settings = new Settings ("org.gnome.clocks.state.window");
@@ -52,12 +56,6 @@ public class Window : Gtk.ApplicationWindow {
settings.get ("size", "(ii)", out width, out height);
resize (width, height);
- var builder = Utils.load_ui ("window.ui");
-
- var main_panel = builder.get_object ("main_panel") as Gtk.Widget;
- header_bar = builder.get_object ("header_bar") as HeaderBar;
- stack = builder.get_object ("stack") as Gd.Stack;
-
panels = new Gtk.Widget[N_PANELS];
panels[PanelId.WORLD] = new World.MainPanel (header_bar);
@@ -71,6 +69,31 @@ public class Window : Gtk.ApplicationWindow {
header_bar.set_stack (stack);
+ separator = new Gtk.Separator (Gtk.Orientation.VERTICAL);
+ separator.no_show_all = true;
+ separator.valign = Gtk.Align.FILL;
+ header_bar.pack_end (separator);
+
+ close_button = new Gtk.Button ();
+ Gtk.Image close_image = new Gtk.Image.from_icon_name ("window-close-symbolic", Gtk.IconSize.MENU);
+ close_button.set_image (close_image);
+ close_button.get_style_context ().add_class ("image-button");
+ close_button.relief = Gtk.ReliefStyle.NONE;
+ close_button.valign = Gtk.Align.CENTER;
+ close_button.clicked.connect (() => {
+ Gdk.Event event;
+
+ event = new Gdk.Event (Gdk.EventType.DESTROY);
+
+ event.any.window = this.get_window ();
+ event.any.send_event = 1;
+
+ Gtk.main_do_event (event);
+ });
+
+ close_button.no_show_all = true;
+ header_bar.pack_end (close_button);
+
var stack_id = stack.notify["visible-child"].connect (() => {
update_header_bar ();
});
@@ -98,7 +121,6 @@ public class Window : Gtk.ApplicationWindow {
update_header_bar ();
- add (main_panel);
show_all ();
}
@@ -178,6 +200,11 @@ public class Window : Gtk.ApplicationWindow {
clock.update_header_bar ();
((Gtk.Widget) clock).grab_focus ();
}
+
+ if (header_bar.mode != HeaderBar.Mode.SELECTION) {
+ separator.show ();
+ close_button.show ();
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]