[gnome-clocks/bilelmoussaoui/adaptive-headerbar: 5/5] Panels: add an icon name per panel



commit 9ff92baed04c438a95c60177b49031a580bfa8ec
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Thu Sep 26 14:41:56 2019 +0200

    Panels: add an icon name per panel

 src/alarm.vala       |  2 ++
 src/application.vala |  3 +++
 src/clock.vala       | 18 +++++++++++++++++-
 src/stopwatch.vala   |  2 ++
 src/timer.vala       |  2 ++
 src/window.vala      |  9 +++------
 src/world.vala       |  2 ++
 7 files changed, 31 insertions(+), 7 deletions(-)
---
diff --git a/src/alarm.vala b/src/alarm.vala
index 001ebc0..8fddf74 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -578,6 +578,7 @@ private class RingingPanel : Gtk.Grid {
 [GtkTemplate (ui = "/org/gnome/clocks/ui/alarm.ui")]
 public class Face : Gtk.Stack, Clocks.Clock {
     public string label { get; construct set; }
+    public string icon_name { get; construct set; }
     public HeaderBar header_bar { get; construct set; }
     public PanelId panel_id { get; construct set; }
 
@@ -593,6 +594,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
 
     public Face (HeaderBar header_bar) {
         Object (label: _("Alarm"),
+                icon_name: "alarm-symbolic",
                 header_bar: header_bar,
                 panel_id: PanelId.ALARM);
 
diff --git a/src/application.vala b/src/application.vala
index 0292426..1668901 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -119,6 +119,9 @@ public class Application : Gtk.Application {
 
         Utils.load_main_css ();
 
+        var theme = Gtk.IconTheme.get_default ();
+        theme.add_resource_path("/org/gnome/clocks/icons");
+
         var settings = Gtk.Settings.get_default ();
         settings.notify["gtk-theme-name"].connect(() => {
             update_theme (settings);
diff --git a/src/clock.vala b/src/clock.vala
index 2fb963f..50c6d1a 100644
--- a/src/clock.vala
+++ b/src/clock.vala
@@ -22,13 +22,29 @@ public enum PanelId {
     WORLD,
     ALARM,
     STOPWATCH,
-    TIMER,
+    TIMER;
+
+    public string to_string() {
+        switch (this) {
+            case WORLD:
+                return "world";
+            case ALARM:
+                return "alarm";
+            case STOPWATCH:
+                return "stopwatch";
+            case TIMER:
+                return "timer";
+            default:
+                assert_not_reached();
+        }
+    }
 }
 
 public const int N_PANELS = 4;
 
 public interface Clock : GLib.Object {
     public abstract string label { get; protected construct set; }
+    public abstract string icon_name { get; protected construct set; }
     public abstract HeaderBar header_bar { get; protected construct set; }
     public abstract PanelId panel_id { get; protected construct set; }
 
diff --git a/src/stopwatch.vala b/src/stopwatch.vala
index 38a7a2a..fca93bb 100644
--- a/src/stopwatch.vala
+++ b/src/stopwatch.vala
@@ -113,6 +113,7 @@ public class Face : Gtk.Box, Clocks.Clock {
     }
 
     public string label { get; construct set; }
+    public string icon_name { get; construct set; }
     public HeaderBar header_bar { get; construct set; }
     public PanelId panel_id { get; construct set; }
 
@@ -137,6 +138,7 @@ public class Face : Gtk.Box, Clocks.Clock {
 
     public Face (HeaderBar header_bar) {
         Object (label: _("Stopwatch"),
+                icon_name: "stopwatch-symbolic",
                 header_bar: header_bar,
                 panel_id: PanelId.STOPWATCH);
 
diff --git a/src/timer.vala b/src/timer.vala
index 5846479..e80c3b3 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -72,6 +72,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
     }
 
     public string label { get; construct set; }
+    public string icon_name { get; construct set; }
     public HeaderBar header_bar { get; construct set; }
     public PanelId panel_id { get; construct set; }
 
@@ -113,6 +114,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
 
     public Face (HeaderBar header_bar) {
         Object (label: _("Timer"),
+                icon_name: "timer-symbolic",
                 header_bar: header_bar,
                 panel_id: PanelId.TIMER,
                 transition_type: Gtk.StackTransitionType.CROSSFADE);
diff --git a/src/window.vala b/src/window.vala
index 56b21df..bae6a67 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -78,14 +78,11 @@ public class Window : Gtk.ApplicationWindow {
         var stopwatch = (Stopwatch.Face)panels[PanelId.STOPWATCH];
         var timer = (Timer.Face)panels[PanelId.TIMER];
 
-        foreach (var clock in panels) {
-            stack.add_titled (clock, ((Clock)clock).label, ((Clock)clock).label);
-            ((Clock)clock).request_header_bar_update.connect (() => {
-                update_header_bar ();
-            });
+       foreach (var panel in panels) {
+            stack.add_titled (panel, ((Clock)panel).label, ((Clock)panel).label);
+            stack.child_set_property(panel, "icon-name", ((Clock)panel).icon_name);
         }
 
-
         var stack_id = stack.notify["visible-child"].connect (() => {
             var help_overlay = get_help_overlay ();
             help_overlay.view_name = Type.from_instance(stack.visible_child).name();
diff --git a/src/world.vala b/src/world.vala
index 219b99a..1f76a74 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -339,6 +339,7 @@ private class LocationDialog : Gtk.Dialog {
 [GtkTemplate (ui = "/org/gnome/clocks/ui/world.ui")]
 public class Face : Gtk.Stack, Clocks.Clock {
     public string label { get; construct set; }
+    public string icon_name { get; construct set; }
     public HeaderBar header_bar { get; construct set; }
     public PanelId panel_id { get; construct set; }
 
@@ -365,6 +366,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
     public Face (HeaderBar header_bar) {
         Object (label: _("World"),
                 header_bar: header_bar,
+                icon_name: "globe-symbolic",
                 panel_id: PanelId.WORLD,
                 transition_type: Gtk.StackTransitionType.CROSSFADE);
 


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