[gnome-clocks] Port LocationDialog to composite template.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Port LocationDialog to composite template.
- Date: Wed, 19 Jun 2013 19:51:02 +0000 (UTC)
commit 445df4f5d68c5f12a80d6ff7417af9387401e7fc
Author: Evgeny Bobkin <evgen ibqn gmail com>
Date: Wed Jun 19 00:15:58 2013 +0200
Port LocationDialog to composite template.
https://bugzilla.gnome.org/show_bug.cgi?id=702606
Makefile.am | 1 +
data/gnome-clocks.gresource.xml | 1 +
data/ui/world.ui | 36 -------------
data/ui/worldlocationdialog.ui | 111 +++++++++++++++++++++++++++++++++++++++
po/POTFILES.in | 1 +
src/world.vala | 38 ++++++--------
6 files changed, 130 insertions(+), 58 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 0b0313b..c0351d3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -140,6 +140,7 @@ EXTRA_DIST = \
data/ui/stopwatch.ui \
data/ui/timer.ui \
data/ui/window.ui \
+ data/ui/worldlocationdialog.ui \
data/ui/world.ui
CLEANFILES = \
diff --git a/data/gnome-clocks.gresource.xml b/data/gnome-clocks.gresource.xml
index 680fede..0fba83a 100644
--- a/data/gnome-clocks.gresource.xml
+++ b/data/gnome-clocks.gresource.xml
@@ -8,6 +8,7 @@
<file preprocess="xml-stripblanks">css/button-border-stop-active.svg</file>
<file preprocess="xml-stripblanks">ui/menu.ui</file>
<file preprocess="xml-stripblanks">ui/window.ui</file>
+ <file preprocess="xml-stripblanks">ui/worldlocationdialog.ui</file>
<file preprocess="xml-stripblanks">ui/world.ui</file>
<file preprocess="xml-stripblanks">ui/alarm.ui</file>
<file preprocess="xml-stripblanks">ui/stopwatch.ui</file>
diff --git a/data/ui/world.ui b/data/ui/world.ui
index 2d3f6c6..a681911 100644
--- a/data/ui/world.ui
+++ b/data/ui/world.ui
@@ -40,42 +40,6 @@
</packing>
</child>
</object>
- <object class="GtkGrid" id="location_dialog_content">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="border_width">5</property>
- <property name="row_spacing">6</property>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Search for a city:</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="GWeatherLocationEntry" id="location_entry">
- <property name="width_request">400</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="activates-default">True</property>
- </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>
<object class="GtkGrid" id="standalone_content">
<property name="visible">True</property>
<property name="can_focus">False</property>
diff --git a/data/ui/worldlocationdialog.ui b/data/ui/worldlocationdialog.ui
new file mode 100644
index 0000000..0a16245
--- /dev/null
+++ b/data/ui/worldlocationdialog.ui
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires libgweather 3.0 -->
+ <!-- interface-requires gtk+ 3.10 -->
+ <template class="ClocksWorldLocationDialog" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Add a New World Clock</property>
+ <property name="type_hint">normal</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button2">
+ <property name="label">gtk-add</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="location_dialog_content">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="border_width">5</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Search for a city:</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="GWeatherLocationEntry" id="location_entry">
+ <property name="width_request">400</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="activates_default">True</property>
+ <signal name="activate" handler="location_changed" object="ClocksWorldLocationDialog"
swapped="no"/>
+ <signal name="changed" handler="location_changed" object="ClocksWorldLocationDialog"
swapped="no"/>
+ <signal name="icon-release" handler="icon_released" object="ClocksWorldLocationDialog"
swapped="no"/>
+ </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>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">button1</action-widget>
+ <action-widget response="1">button2</action-widget>
+ </action-widgets>
+ </template>
+</interface>
\ No newline at end of file
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 76e2ada..eac7181 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,4 +14,5 @@ src/world.vala
[type: gettext/glade]data/ui/stopwatch.ui
[type: gettext/glade]data/ui/timer.ui
[type: gettext/glade]data/ui/window.ui
+[type: gettext/glade]data/ui/worldlocationdialog.ui
[type: gettext/glade]data/ui/world.ui
diff --git a/src/world.vala b/src/world.vala
index 4c8353c..48bc5af 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -159,36 +159,30 @@ private class Item : Object, ContentItem {
}
}
+[GtkTemplate (ui = "/org/gnome/clocks/ui/worldlocationdialog.ui")]
private class LocationDialog : Gtk.Dialog {
- private GWeather.LocationEntry entry;
+ [GtkChild]
+ private GWeather.LocationEntry location_entry;
public LocationDialog (Gtk.Window parent) {
- Object (transient_for: parent, modal: true, title: _("Add a New World Clock"));
-
- add_buttons (Gtk.Stock.CANCEL, 0, Gtk.Stock.ADD, 1);
- set_default_response (1);
- set_response_sensitive (1, false);
-
- var builder = Utils.load_ui ("world.ui");
-
- var grid = builder.get_object ("location_dialog_content") as Gtk.Grid;
- get_content_area ().add (grid);
-
- entry = builder.get_object ("location_entry") as GWeather.LocationEntry;
+ Object (transient_for: parent);
+ }
- entry.changed.connect (() => {
- location_changed ();
- });
- entry.activate.connect (() => {
- location_changed ();
- });
+ [GtkCallback]
+ private void icon_released () {
+ if (location_entry.secondary_icon_name == "edit-clear-symbolic") {
+ location_entry.set_text ("");
+ }
}
+ [GtkCallback]
private void location_changed () {
GWeather.Location? l = null;
GWeather.Timezone? t = null;
- if (entry.get_text () != "") {
- l = entry.get_location ();
+
+ if (location_entry.get_text () != "") {
+ l = location_entry.get_location ();
+
if (l != null) {
t = l.get_timezone ();
@@ -202,7 +196,7 @@ private class LocationDialog : Gtk.Dialog {
}
public Item? get_location () {
- var location = entry.get_location ();
+ var location = location_entry.get_location ();
return location != null ? new Item (location) : null;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]