Port to GWeather4
In preparation for the GTK4 port. This is just a cheap port, I'll implement proper entry completion after porting to GTK4.
This commit is contained in:
@@ -65,7 +65,7 @@
|
|||||||
{
|
{
|
||||||
"type" : "git",
|
"type" : "git",
|
||||||
"url" : "https://gitlab.gnome.org/GNOME/libgweather.git",
|
"url" : "https://gitlab.gnome.org/GNOME/libgweather.git",
|
||||||
"tag" : "40.0"
|
"branch" : "main"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -168,7 +168,7 @@ libhandy_dep = dependency('libhandy-1', version: '>= 1.5.0')
|
|||||||
glib_dep = dependency('glib-2.0', version: '>= 2.67.5')
|
glib_dep = dependency('glib-2.0', version: '>= 2.67.5')
|
||||||
gtk_dep = dependency('gtk+-3.0', version: '>= 3.22.20')
|
gtk_dep = dependency('gtk+-3.0', version: '>= 3.22.20')
|
||||||
gio_dep = dependency('gio-2.0', version: '>= 2.58.0')
|
gio_dep = dependency('gio-2.0', version: '>= 2.58.0')
|
||||||
gweather_dep = dependency('gweather-3.0', version: '>= 40.0')
|
gweather_dep = dependency('gweather4')
|
||||||
geoclue_dep = dependency('libgeoclue-2.0', version: '>=2.4')
|
geoclue_dep = dependency('libgeoclue-2.0', version: '>=2.4')
|
||||||
geocode_dep = dependency('geocode-glib-1.0', version: '>=3.23')
|
geocode_dep = dependency('geocode-glib-1.0', version: '>=3.23')
|
||||||
m_dep = cc.find_library('m')
|
m_dep = cc.find_library('m')
|
||||||
|
|||||||
@@ -33,12 +33,14 @@ struct _GcalWeatherSettings
|
|||||||
GtkSwitch *weather_auto_location_switch;
|
GtkSwitch *weather_auto_location_switch;
|
||||||
GtkWidget *weather_location_entry;
|
GtkWidget *weather_location_entry;
|
||||||
|
|
||||||
|
GWeatherLocation *location;
|
||||||
|
|
||||||
GcalContext *context;
|
GcalContext *context;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void on_weather_location_searchbox_changed_cb (GWeatherLocationEntry *entry,
|
static void on_weather_location_searchbox_changed_cb (GtkEntry *entry,
|
||||||
GcalWeatherSettings *self);
|
GcalWeatherSettings *self);
|
||||||
|
|
||||||
static void on_show_weather_changed_cb (GtkSwitch *wswitch,
|
static void on_show_weather_changed_cb (GtkSwitch *wswitch,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
@@ -111,7 +113,9 @@ load_weather_settings (GcalWeatherSettings *self)
|
|||||||
world = gweather_location_get_world ();
|
world = gweather_location_get_world ();
|
||||||
weather_location = location ? gweather_location_deserialize (world, location) : NULL;
|
weather_location = location ? gweather_location_deserialize (world, location) : NULL;
|
||||||
|
|
||||||
gweather_location_entry_set_location (GWEATHER_LOCATION_ENTRY (self->weather_location_entry), weather_location);
|
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) : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (self->show_weather_switch, on_show_weather_changed_cb, self);
|
g_signal_handlers_unblock_by_func (self->show_weather_switch, on_show_weather_changed_cb, self);
|
||||||
@@ -124,7 +128,6 @@ load_weather_settings (GcalWeatherSettings *self)
|
|||||||
static void
|
static void
|
||||||
save_weather_settings (GcalWeatherSettings *self)
|
save_weather_settings (GcalWeatherSettings *self)
|
||||||
{
|
{
|
||||||
g_autoptr (GWeatherLocation) location = NULL;
|
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
GVariant *value;
|
GVariant *value;
|
||||||
GVariant *vlocation;
|
GVariant *vlocation;
|
||||||
@@ -135,8 +138,7 @@ save_weather_settings (GcalWeatherSettings *self)
|
|||||||
if (!self->context)
|
if (!self->context)
|
||||||
GCAL_RETURN ();
|
GCAL_RETURN ();
|
||||||
|
|
||||||
location = gweather_location_entry_get_location (GWEATHER_LOCATION_ENTRY (self->weather_location_entry));
|
vlocation = self->location ? gweather_location_serialize (self->location) : NULL;
|
||||||
vlocation = location ? gweather_location_serialize (location) : NULL;
|
|
||||||
|
|
||||||
settings = gcal_context_get_settings (self->context);
|
settings = gcal_context_get_settings (self->context);
|
||||||
value = g_variant_new ("(bbsmv)",
|
value = g_variant_new ("(bbsmv)",
|
||||||
@@ -170,17 +172,13 @@ update_menu_weather_sensitivity (GcalWeatherSettings *self)
|
|||||||
static GWeatherLocation*
|
static GWeatherLocation*
|
||||||
get_checked_fixed_location (GcalWeatherSettings *self)
|
get_checked_fixed_location (GcalWeatherSettings *self)
|
||||||
{
|
{
|
||||||
g_autoptr (GWeatherLocation) location = NULL;
|
|
||||||
|
|
||||||
location = gweather_location_entry_get_location (GWEATHER_LOCATION_ENTRY (self->weather_location_entry));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: This check feels shabby. However, I couldn't find a better
|
* NOTE: This check feels shabby. However, I couldn't find a better
|
||||||
* one without iterating the model. has-custom-text does not work
|
* one without iterating the model. has-custom-text does not work
|
||||||
* properly. Lets go with it for now.
|
* properly. Lets go with it for now.
|
||||||
*/
|
*/
|
||||||
if (location && gweather_location_get_name (location))
|
if (self->location && gweather_location_get_name (self->location))
|
||||||
return g_steal_pointer (&location);
|
return g_object_ref (self->location);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -243,8 +241,8 @@ on_weather_auto_location_changed_cb (GtkSwitch *lswitch,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_weather_location_searchbox_changed_cb (GWeatherLocationEntry *entry,
|
on_weather_location_searchbox_changed_cb (GtkEntry *entry,
|
||||||
GcalWeatherSettings *self)
|
GcalWeatherSettings *self)
|
||||||
{
|
{
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GWeatherLocation *location;
|
GWeatherLocation *location;
|
||||||
@@ -264,7 +262,7 @@ on_weather_location_searchbox_changed_cb (GWeatherLocationEntry *entry,
|
|||||||
{
|
{
|
||||||
gtk_style_context_remove_class (context, "error");
|
gtk_style_context_remove_class (context, "error");
|
||||||
manage_weather_service (self);
|
manage_weather_service (self);
|
||||||
gweather_location_unref (location);
|
g_object_unref (location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,6 +276,7 @@ gcal_weather_settings_finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
GcalWeatherSettings *self = (GcalWeatherSettings *)object;
|
GcalWeatherSettings *self = (GcalWeatherSettings *)object;
|
||||||
|
|
||||||
|
g_clear_object (&self->location);
|
||||||
g_clear_object (&self->context);
|
g_clear_object (&self->context);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gcal_weather_settings_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gcal_weather_settings_parent_class)->finalize (object);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GWeatherLocationEntry" id="weather_location_entry">
|
<object class="GtkEntry" id="weather_location_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="primary_icon_name">edit-find-symbolic</property>
|
<property name="primary_icon_name">edit-find-symbolic</property>
|
||||||
|
|||||||
@@ -665,7 +665,7 @@ static void
|
|||||||
update_gclue_location (GcalWeatherService *self,
|
update_gclue_location (GcalWeatherService *self,
|
||||||
GClueLocation *location)
|
GClueLocation *location)
|
||||||
{
|
{
|
||||||
GWeatherLocation *wlocation = NULL; /* owned */
|
g_autoptr (GWeatherLocation) wlocation = NULL; /* owned */
|
||||||
|
|
||||||
if (location)
|
if (location)
|
||||||
{
|
{
|
||||||
@@ -682,8 +682,6 @@ update_gclue_location (GcalWeatherService *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_location (self, wlocation);
|
update_location (self, wlocation);
|
||||||
|
|
||||||
g_clear_pointer (&wlocation, gweather_location_unref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,7 @@
|
|||||||
#define GCAL_WEATHER_SERVICE_H
|
#define GCAL_WEATHER_SERVICE_H
|
||||||
|
|
||||||
#include <libgweather/gweather.h>
|
#include <libgweather/gweather.h>
|
||||||
#include <glib-object.h>
|
#include <gtk/gtk.h>
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "gcal-weather-info.h"
|
#include "gcal-weather-info.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user