[gnome-calendar/gbsneto/gtk4: 6/10] weather-settings: Port to GTK4
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/gbsneto/gtk4: 6/10] weather-settings: Port to GTK4
- Date: Thu, 3 Feb 2022 05:38:02 +0000 (UTC)
commit 9d7876ed5edb30871831604da62e92fac9bec33e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Jan 26 13:16:19 2022 -0300
weather-settings: Port to GTK4
src/gui/gcal-weather-settings.c | 23 +++++++++--------------
src/gui/gcal-weather-settings.ui | 31 ++++---------------------------
2 files changed, 13 insertions(+), 41 deletions(-)
---
diff --git a/src/gui/gcal-weather-settings.c b/src/gui/gcal-weather-settings.c
index 391e4733..edfb88f2 100644
--- a/src/gui/gcal-weather-settings.c
+++ b/src/gui/gcal-weather-settings.c
@@ -31,7 +31,7 @@ struct _GcalWeatherSettings
GtkSwitch *show_weather_switch;
GtkSwitch *weather_auto_location_switch;
- GtkWidget *weather_location_entry;
+ GtkEditable *weather_location_entry;
GWeatherLocation *location;
@@ -99,11 +99,8 @@ load_weather_settings (GcalWeatherSettings *self)
if (!location && !auto_location)
{
- GtkStyleContext *context;
-
- context = gtk_widget_get_style_context (GTK_WIDGET (self->weather_location_entry));
- gtk_entry_set_text (GTK_ENTRY (self->weather_location_entry), location_name);
- gtk_style_context_add_class (context, "error");
+ gtk_editable_set_text (self->weather_location_entry, location_name);
+ gtk_widget_add_css_class (GTK_WIDGET (self->weather_location_entry), "error");
}
else
{
@@ -114,8 +111,8 @@ load_weather_settings (GcalWeatherSettings *self)
weather_location = location ? gweather_location_deserialize (world, location) : NULL;
self->location = weather_location ? g_object_ref (weather_location) : NULL;
- gtk_entry_set_text (GTK_ENTRY (self->weather_location_entry),
- self->location ? gweather_location_get_name (self->location) : "");
+ gtk_editable_set_text (self->weather_location_entry,
+ self->location ? gweather_location_get_name (self->location) : "");
}
g_signal_handlers_unblock_by_func (self->show_weather_switch, on_show_weather_changed_cb, self);
@@ -144,7 +141,7 @@ save_weather_settings (GcalWeatherSettings *self)
value = g_variant_new ("(bbsmv)",
gtk_switch_get_active (self->show_weather_switch),
gtk_switch_get_active (self->weather_auto_location_switch),
- gtk_entry_get_text (GTK_ENTRY (self->weather_location_entry)),
+ gtk_editable_get_text (self->weather_location_entry),
vlocation);
res = g_settings_set_value (settings, "weather-settings", value);
@@ -201,7 +198,7 @@ manage_weather_service (GcalWeatherSettings *self)
location = get_checked_fixed_location (self);
if (!location)
- g_warning ("Unknown location '%s' selected", gtk_entry_get_text (GTK_ENTRY
(self->weather_location_entry)));
+ g_warning ("Unknown location '%s' selected", gtk_editable_get_text
(self->weather_location_entry));
}
gcal_weather_service_run (weather_service, location);
@@ -244,23 +241,21 @@ static void
on_weather_location_searchbox_changed_cb (GtkEntry *entry,
GcalWeatherSettings *self)
{
- GtkStyleContext *context;
GWeatherLocation *location;
gboolean auto_location;
save_weather_settings (self);
- context = gtk_widget_get_style_context (self->weather_location_entry);
auto_location = gtk_switch_get_active (self->weather_auto_location_switch);
location = get_checked_fixed_location (self);
if (!location && !auto_location)
{
- gtk_style_context_add_class (context, "error");
+ gtk_widget_add_css_class (GTK_WIDGET (self->weather_location_entry), "error");
}
else
{
- gtk_style_context_remove_class (context, "error");
+ gtk_widget_remove_css_class (GTK_WIDGET (self->weather_location_entry), "error");
manage_weather_service (self);
g_object_unref (location);
}
diff --git a/src/gui/gcal-weather-settings.ui b/src/gui/gcal-weather-settings.ui
index f84ef43c..5d4e4333 100644
--- a/src/gui/gcal-weather-settings.ui
+++ b/src/gui/gcal-weather-settings.ui
@@ -1,30 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <requires lib="gtk+" version="3.14"/>
<template class="GcalWeatherSettings" parent="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="orientation">vertical</property>
- <property name="margin">12</property>
+ <property name="margin-top">12</property>
+ <property name="margin-bottom">12</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
<property name="spacing">6</property>
- <child>
- <object class="GtkModelButton">
- <property name="text" translatable="yes">_Weather</property>
- <property name="menu-name">main</property>
- <property name="inverted">True</property>
- <property name="centered">True</property>
- <property name="visible">True</property>
- </object>
- </child>
<child>
<object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="spacing">18</property>
<child>
<object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="xalign">0.0</property>
<property name="label" translatable="yes">Show Weather</property>
@@ -32,8 +19,6 @@
</child>
<child>
<object class="GtkSwitch" id="show_weather_switch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
<signal name="notify::active" handler="on_show_weather_changed_cb" object="GcalWeatherSettings"
swapped="no" />
</object>
</child>
@@ -41,13 +26,9 @@
</child>
<child>
<object class="GtkBox" id="weather_auto_location_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="spacing">18</property>
<child>
<object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="xalign">0.0</property>
<property name="label" translatable="yes">Automatic Location</property>
@@ -55,8 +36,6 @@
</child>
<child>
<object class="GtkSwitch" id="weather_auto_location_switch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
<signal name="notify::active" handler="on_weather_auto_location_changed_cb"
object="GcalWeatherSettings" swapped="no" />
</object>
</child>
@@ -64,8 +43,6 @@
</child>
<child>
<object class="GtkEntry" id="weather_location_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]