[gnome-clocks/wip/vala] Use glade for the empty pages



commit cdca685174baede30828ba51cb451ae092ca93cd
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Feb 17 11:10:36 2013 +0100

    Use glade for the empty pages

 src/alarm.ui     |   41 ++++++++++++++++++++++++++++++++++++++++-
 src/alarm.vala   |   35 ++++++++++++++++++-----------------
 src/widgets.vala |   26 ++++++--------------------
 src/world.ui     |   51 ++++++++++++++++++++++++++++++++++++++++++---------
 src/world.vala   |    7 ++++++-
 5 files changed, 112 insertions(+), 48 deletions(-)
---
diff --git a/src/alarm.ui b/src/alarm.ui
index 2f21be6..8e9ab3f 100644
--- a/src/alarm.ui
+++ b/src/alarm.ui
@@ -1,6 +1,45 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.6 -->
+  <object class="GtkGrid" id="empty_panel">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="halign">center</property>
+    <property name="valign">center</property>
+    <property name="row_spacing">6</property>
+    <child>
+      <object class="GtkImage" id="image1">
+        <property name="visible">True</property>
+        <property name="sensitive">False</property>
+        <property name="can_focus">False</property>
+        <property name="icon_name">alarm-symbolic</property>
+        <property name="icon-size">6</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="GtkLabel" id="label1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Select &lt;b&gt;New&lt;/b&gt; to add an alarm</property>
+        <property name="use_markup">True</property>
+        <style>
+          <class name="dim-label"/>
+        </style>
+      </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="GtkAdjustment" id="h_adjustment">
     <property name="upper">100</property>
     <property name="step_increment">1</property>
@@ -138,7 +177,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="label1">
+          <object class="GtkLabel" id="label2">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">:</property>
diff --git a/src/alarm.vala b/src/alarm.vala
index e95c7d1..d4f9f4f 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -420,24 +420,25 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
         });
 
         icon_view.item_activated.connect ((path) => {
-                Gtk.TreeIter i;
-                if (list_store.get_iter (out i, path)) {
-                    Item alarm;
-                    list_store.get (i, Column.ITEM, out alarm);
-                    var dialog = new SetupDialog ((Gtk.Window) get_toplevel (), alarm);
-                    dialog.response.connect ((dialog, response) => {
-                            if (response == 1) {
-                                ((SetupDialog) dialog).apply_to_alarm (alarm);
-                                alarm.reset ();
-                            }
-                            dialog.destroy ();
-                        });
-                    dialog.show_all ();
-                }
-            });
-
+            Gtk.TreeIter i;
+            if (list_store.get_iter (out i, path)) {
+                Item alarm;
+                list_store.get (i, Column.ITEM, out alarm);
+                var dialog = new SetupDialog ((Gtk.Window) get_toplevel (), alarm);
+                dialog.response.connect ((dialog, response) => {
+                        if (response == 1) {
+                            ((SetupDialog) dialog).apply_to_alarm (alarm);
+                            alarm.reset ();
+                        }
+                        dialog.destroy ();
+                    });
+                dialog.show_all ();
+            }
+        });
 
-        content_view = new ContentView (icon_view, "alarm-symbolic", _("Select <b>New</b> to add an alarm"));
+        var builder = Utils.load_ui ("alarm.ui");
+        var empty_view = builder.get_object ("empty_panel") as Gtk.Widget;
+        content_view = new ContentView (empty_view, icon_view);
         add (content_view);
 
         standalone = new StandalonePanel ();
diff --git a/src/widgets.vala b/src/widgets.vala
index c98602e..c5408d8 100644
--- a/src/widgets.vala
+++ b/src/widgets.vala
@@ -312,8 +312,8 @@ public class ContentView : Gtk.Bin {
     private Gtk.Overlay overlay;
     private Gtk.ScrolledWindow scrolled_window;
 
-    public ContentView (IconView icon_view, string icon, string empty_message) {
-        empty_page = create_empty_page (icon, empty_message);
+    public ContentView (Gtk.Widget empty_view, IconView icon_view) {
+        empty_page = empty_view;
 
         overlay = new Gtk.Overlay ();
         overlay.add (icon_view);
@@ -340,24 +340,7 @@ public class ContentView : Gtk.Bin {
         add (empty_page);
     }
 
-    private Gtk.Widget create_empty_page (string icon, string message) {
-        var gicon = new GLib.ThemedIcon.with_default_fallbacks (icon);
-        var image = new Gtk.Image.from_gicon (gicon, Gtk.IconSize.DIALOG);
-        image.set_sensitive (false);
-
-        var label = new Gtk.Label (message);
-        label.get_style_context ().add_class("dim-label");
-        label.set_use_markup (true);
-
-        var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
-        box.pack_start (new Gtk.Label (""), true, true, 0);
-        box.pack_start (image, false, false, 6);
-        box.pack_start (label, false, false, 6);
-        box.pack_start (new Gtk.Label (""), true, true, 0);
-        box.show_all ();
-
-        return box as Gtk.Widget;
-    }
+    public signal void delete_selected ();
 
     private Gtk.Toolbar create_selection_toolbar () {
         var toolbar = new Gtk.Toolbar ();
@@ -372,6 +355,9 @@ public class ContentView : Gtk.Bin {
 
         var delete_button = new Gtk.Button.with_label (_("Delete"));
         delete_button.hexpand = true;
+        delete_button.clicked.connect (() => {
+            delete_selected ();
+        });
 
         var grid = new Gtk.Grid ();
         grid.hexpand = true;
diff --git a/src/world.ui b/src/world.ui
index f9972f5..cecd2ce 100644
--- a/src/world.ui
+++ b/src/world.ui
@@ -1,6 +1,45 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkGrid" id="empty_panel">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="halign">center</property>
+    <property name="valign">center</property>
+    <property name="row_spacing">6</property>
+    <child>
+      <object class="GtkImage" id="image1">
+        <property name="visible">True</property>
+        <property name="sensitive">False</property>
+        <property name="can_focus">False</property>
+        <property name="icon_name">document-open-recent-symbolic</property>
+        <property name="icon-size">6</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="GtkLabel" id="label1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Select &lt;b&gt;New&lt;/b&gt; to add a world 
clock</property>
+        <property name="use_markup">True</property>
+        <style>
+          <class name="dim-label"/>
+        </style>
+      </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="location_dialog_content">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -9,7 +48,7 @@
     <property name="border_width">5</property>
     <property name="row_spacing">6</property>
     <child>
-      <object class="GtkLabel" id="label1">
+      <object class="GtkLabel" id="label2">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="xalign">0</property>
@@ -22,9 +61,6 @@
         <property name="height">1</property>
       </packing>
     </child>
-    <child>
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkGrid" id="standalone_content">
     <property name="visible">True</property>
@@ -57,7 +93,6 @@
           <object class="GtkLabel" id="time_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes"></property>
             <style>
               <class name="clocks-time-label"/>
             </style>
@@ -73,7 +108,6 @@
           <object class="GtkLabel" id="day_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes"></property>
             <style>
               <class name="clocks-secondary-time-label"/>
             </style>
@@ -104,7 +138,7 @@
           <class name="clocks-secondary-time-label"/>
         </style>
         <child>
-          <object class="GtkLabel" id="label2">
+          <object class="GtkLabel" id="label3">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">Sunrise</property>
@@ -120,7 +154,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="label3">
+          <object class="GtkLabel" id="label4">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">Sunset</property>
@@ -152,7 +186,6 @@
           <object class="GtkLabel" id="sunset_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes"></property>
           </object>
           <packing>
             <property name="left_attach">1</property>
diff --git a/src/world.vala b/src/world.vala
index 31aa58d..2d29a3b 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -273,9 +273,14 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
             }
         });
 
-        content_view = new ContentView (icon_view, "document-open-recent-symbolic", _("Select <b>New</b> to 
add a world clock"));
+        var builder = Utils.load_ui ("world.ui");
+        var empty_view = builder.get_object ("empty_panel") as Gtk.Widget;
+        content_view = new ContentView (empty_view, icon_view);
         add (content_view);
 
+        content_view.delete_selected.connect (() => {
+        });
+
         standalone = new StandalonePanel ();
         add (standalone);
 


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