[gnome-weather/wip/gjs-experiments: 6/6] Use the ui file for the New Location dialog



commit 3fde86528374571d8af5e078e161d939dd5eab04
Author: Paolo Borelli <pborelli gnome org>
Date:   Fri Mar 8 21:16:39 2013 +0100

    Use the ui file for the New Location dialog
    
    Also rework the dialog slightly (a proper label, larger entry etc)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695457

 data/window.ui |   22 ++++++++++++++++++++++
 src/window.js  |   19 ++++++++++++++++---
 2 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/data/window.ui b/data/window.ui
index b9cbf57..e28d240 100644
--- a/data/window.ui
+++ b/data/window.ui
@@ -77,4 +77,26 @@
       </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>
+  </object>
 </interface>
diff --git a/src/window.js b/src/window.js
index 53010bc..33927ff 100644
--- a/src/window.js
+++ b/src/window.js
@@ -254,10 +254,23 @@ const MainWindow = new Lang.Class({
         let dialog = new Gtk.Dialog({ title: _("New Location"),
                                       transient_for: this.get_toplevel(),
                                       modal: true });
-        let entry = new GWeather.LocationEntry({ top: this._world });
 
-        dialog.get_content_area().add(entry);
-        dialog.add_button('gtk-add', Gtk.ResponseType.OK);
+        let builder = Util.loadUI('/org/gnome/weather/window.ui');
+
+        let grid = builder.get_object('location-dialog-content');
+
+        let find_icon = Gio.ThemedIcon.new_with_default_fallbacks ("edit-find-symbolic");
+        let entry = new GWeather.LocationEntry({ top: this._world,
+                                                 width_request: 400,
+                                                 activates_default: true });
+        entry.set_size_request(400, -1);
+        entry.set_icon_from_gicon(Gtk.EntryIconPosition.SECONDARY, find_icon);
+
+        grid.attach(entry, 0, 1, 1, 1);
+        dialog.get_content_area().add(grid);
+
+        dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL);
+        dialog.add_button(Gtk.STOCK_ADD, Gtk.ResponseType.OK);
 
         dialog.connect('response', Lang.bind(this, function(dialog, response) {
             dialog.destroy();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]