[gnome-calendar/wip/flb/weather-forecast: 26/50] window: Improve weather setting sensitivity



commit 90cdef24edbfb3c9ffbecda02c6e742c52b82b4f
Author: Florian Brosch <flo brosch gmail com>
Date:   Sun Oct 15 21:58:57 2017 +0200

    window: Improve weather setting sensitivity

 data/ui/menus.ui  |    2 +-
 src/gcal-window.c |   15 ++++++++++-----
 2 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/data/ui/menus.ui b/data/ui/menus.ui
index d5ed908..a41d49f 100644
--- a/data/ui/menus.ui
+++ b/data/ui/menus.ui
@@ -125,7 +125,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkBox">
+              <object class="GtkBox" id="auto-location-box">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="spacing">5</property> <!-- TODO: check HIG for right value -->
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 7d4eeab..696ae55 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -178,10 +178,11 @@ struct _GcalWindow
   gint                 open_edit_dialog_timeout_id;
 
   /* weather management */
-  GcalWeatherService    *weather_service; /* owned */
-  GtkSwitch             *weather;         /* unowned */
-  GtkSwitch             *auto_location;   /* unowned */
-  GWeatherLocationEntry *location_entry;  /* unowned */
+  GcalWeatherService    *weather_service;   /* owned */
+  GtkSwitch             *weather;           /* unowned */
+  GtkSwitch             *auto_location;     /* unowned */
+  GtkBox                *auto_location_box; /* unowned */
+  GWeatherLocationEntry *location_entry;    /* unowned */
   WeatherSigs            weather_cb_ids[5];
 
   /* temp to keep event_creation */
@@ -1719,6 +1720,7 @@ gcal_window_init (GcalWindow *self)
   /* Weather menu: */
   self->weather_service = NULL;
   self->weather = GTK_SWITCH(gtk_builder_get_object (builder, "show-weather-switch"));
+  self->auto_location_box = GTK_BOX (gtk_builder_get_object (builder, "auto-location-box"));
   self->auto_location = GTK_SWITCH(gtk_builder_get_object (builder, "auto-location-switch"));
   self->location_entry = GWEATHER_LOCATION_ENTRY (gtk_builder_get_object (builder, 
"fixed-weather-location"));
   location_completion = gtk_entry_get_completion (GTK_ENTRY (self->location_entry));
@@ -1999,7 +2001,7 @@ update_menu_weather_sensitivity (GcalWindow *self)
   weather_enabled = gtk_switch_get_active (self->weather);
   autoloc_enabled = gtk_switch_get_active (self->auto_location);
 
-  gtk_widget_set_sensitive (GTK_WIDGET (self->auto_location), weather_enabled);
+  gtk_widget_set_sensitive (GTK_WIDGET (self->auto_location_box), weather_enabled);
   gtk_widget_set_sensitive (GTK_WIDGET (self->location_entry), weather_enabled && !autoloc_enabled);
 }
 
@@ -2096,6 +2098,9 @@ load_weather_settings (GcalWindow *self)
   gtk_switch_set_active (self->auto_location, auto_location);
   if (location == NULL)
     {
+      GtkStyleContext *context; /* unowned */
+
+      context = gtk_widget_get_style_context (GTK_WIDGET (self->location_entry));
       gtk_entry_set_text (GTK_ENTRY (self->location_entry), location_name);
       gtk_style_context_add_class (context, "error");
     }


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