[gnome-panel/wip/muktupavels/gweather-4] clock: rename GWeatherTimezoneMenu to ClockTimezoneMenu
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/muktupavels/gweather-4] clock: rename GWeatherTimezoneMenu to ClockTimezoneMenu
- Date: Mon, 28 Feb 2022 10:53:22 +0000 (UTC)
commit 45f80c3fdb612cf4efbd2116551be3f04de3f2dc
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Feb 27 22:51:19 2022 +0200
clock: rename GWeatherTimezoneMenu to ClockTimezoneMenu
And make sure it builds.
modules/clock/Makefile.am | 2 +
...ather-timezone-menu.c => clock-timezone-menu.c} | 77 ++++++++++------------
modules/clock/clock-timezone-menu.h | 54 +++++++++++++++
modules/clock/gweather-timezone-menu.h | 59 -----------------
4 files changed, 91 insertions(+), 101 deletions(-)
---
diff --git a/modules/clock/Makefile.am b/modules/clock/Makefile.am
index 6a2b4c4c1..3cf01499a 100644
--- a/modules/clock/Makefile.am
+++ b/modules/clock/Makefile.am
@@ -35,6 +35,8 @@ org_gnome_gnome_panel_clock_la_SOURCES = \
clock-module.c \
clock-sunpos.c \
clock-sunpos.h \
+ clock-timezone-menu.c \
+ clock-timezone-menu.h \
clock-utils.c \
clock-utils.h \
set-timezone.c \
diff --git a/modules/clock/gweather-timezone-menu.c b/modules/clock/clock-timezone-menu.c
similarity index 84%
rename from modules/clock/gweather-timezone-menu.c
rename to modules/clock/clock-timezone-menu.c
index c4559bbac..bf2d2f430 100644
--- a/modules/clock/gweather-timezone-menu.c
+++ b/modules/clock/clock-timezone-menu.c
@@ -18,23 +18,13 @@
* <https://www.gnu.org/licenses/>.
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "gweather-timezone-menu.h"
-#include "gweather-private.h"
+#include "config.h"
+#include "clock-timezone-menu.h"
+#include <glib/gi18n-lib.h>
#include <string.h>
-/**
- * SECTION:gweathertimezonemenu
- * @Title: GWeatherTimezoneMenu
- *
- * A #GtkComboBox subclass for choosing a #GWeatherTimezone
- */
-
-G_DEFINE_TYPE (GWeatherTimezoneMenu, gweather_timezone_menu, GTK_TYPE_COMBO_BOX)
+G_DEFINE_TYPE (ClockTimezoneMenu, clock_timezone_menu, GTK_TYPE_COMBO_BOX)
enum {
PROP_0,
@@ -59,7 +49,7 @@ static void is_sensitive (GtkCellLayout *cell_layout, GtkCellRenderer *cell,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data);
static void
-gweather_timezone_menu_init (GWeatherTimezoneMenu *menu)
+clock_timezone_menu_init (ClockTimezoneMenu *menu)
{
GtkCellRenderer *renderer;
@@ -78,16 +68,16 @@ gweather_timezone_menu_init (GWeatherTimezoneMenu *menu)
static void
finalize (GObject *object)
{
- GWeatherTimezoneMenu *menu = GWEATHER_TIMEZONE_MENU (object);
+ ClockTimezoneMenu *menu = CLOCK_TIMEZONE_MENU (object);
if (menu->zone)
gweather_timezone_unref (menu->zone);
- G_OBJECT_CLASS (gweather_timezone_menu_parent_class)->finalize (object);
+ G_OBJECT_CLASS (clock_timezone_menu_parent_class)->finalize (object);
}
static void
-gweather_timezone_menu_class_init (GWeatherTimezoneMenuClass *timezone_menu_class)
+clock_timezone_menu_class_init (ClockTimezoneMenuClass *timezone_menu_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (timezone_menu_class);
GtkComboBoxClass *combo_class = GTK_COMBO_BOX_CLASS (timezone_menu_class);
@@ -130,8 +120,8 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_TZID:
- gweather_timezone_menu_set_tzid (GWEATHER_TIMEZONE_MENU (object),
- g_value_get_string (value));
+ clock_timezone_menu_set_tzid (CLOCK_TIMEZONE_MENU (object),
+ g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -143,11 +133,11 @@ static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
- GWeatherTimezoneMenu *menu = GWEATHER_TIMEZONE_MENU (object);
+ ClockTimezoneMenu *menu = CLOCK_TIMEZONE_MENU (object);
switch (prop_id) {
case PROP_TZID:
- g_value_set_string (value, gweather_timezone_menu_get_tzid (menu));
+ g_value_set_string (value, clock_timezone_menu_get_tzid (menu));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -163,7 +153,7 @@ enum {
static void
changed (GtkComboBox *combo)
{
- GWeatherTimezoneMenu *menu = GWEATHER_TIMEZONE_MENU (combo);
+ ClockTimezoneMenu *menu = CLOCK_TIMEZONE_MENU (combo);
GtkTreeIter iter;
if (menu->zone)
@@ -232,11 +222,12 @@ insert_locations (GtkTreeStore *store, GWeatherLocation *loc)
int i;
if (gweather_location_get_level (loc) < GWEATHER_LOCATION_COUNTRY) {
- GWeatherLocation **children;
+ GWeatherLocation *child;
- children = gweather_location_get_children (loc);
- for (i = 0; children[i]; i++)
- insert_locations (store, children[i]);
+ child = NULL;
+ while ((child = gweather_location_next_child (loc, child)) != NULL) {
+ insert_locations (store, child);
+ }
} else {
GWeatherTimezone **zones;
GtkTreeIter iter;
@@ -262,13 +253,14 @@ insert_locations (GtkTreeStore *store, GWeatherLocation *loc)
static GtkTreeModel *
gweather_timezone_model_new (GWeatherLocation *top)
{
- g_autoptr(GWeatherLocation) world = NULL;
+ GWeatherLocation *world;
GtkTreeStore *store;
GtkTreeModel *model;
GtkTreeIter iter;
char *unknown;
GWeatherTimezone *utc;
+ world = NULL;
store = gtk_tree_store_new (2, G_TYPE_STRING, GWEATHER_TYPE_TIMEZONE);
model = GTK_TREE_MODEL (store);
@@ -295,6 +287,8 @@ gweather_timezone_model_new (GWeatherLocation *top)
insert_locations (store, top);
+ g_clear_pointer (&world, gweather_location_unref);
+
return model;
}
@@ -324,10 +318,10 @@ is_sensitive (GtkCellLayout *cell_layout, GtkCellRenderer *cell,
}
/**
- * gweather_timezone_menu_new:
+ * clock_timezone_menu_new:
* @top: the top-level location for the menu.
*
- * Creates a new #GWeatherTimezoneMenu.
+ * Creates a new #ClockTimezoneMenu.
*
* @top will normally be the location returned from
* gweather_location_get_world(), but you can create a menu that
@@ -336,9 +330,9 @@ is_sensitive (GtkCellLayout *cell_layout, GtkCellRenderer *cell,
* Return value: the new #GWeatherTimezoneMenu
**/
GtkWidget *
-gweather_timezone_menu_new (GWeatherLocation *top)
+clock_timezone_menu_new (GWeatherLocation *top)
{
- return g_object_new (GWEATHER_TYPE_TIMEZONE_MENU,
+ return g_object_new (CLOCK_TYPE_TIMEZONE_MENU,
"top", top,
NULL);
}
@@ -373,20 +367,20 @@ check_tzid (GtkTreeModel *model, GtkTreePath *path,
}
/**
- * gweather_timezone_menu_set_tzid:
- * @menu: a #GWeatherTimezoneMenu
+ * clock_timezone_menu_set_tzid:
+ * @menu: a #ClockTimezoneMenu
* @tzid: (allow-none): a tzdata id (eg, "America/New_York")
*
* Sets @menu to the given @tzid. If @tzid is %NULL, sets @menu to
* "Unknown".
**/
void
-gweather_timezone_menu_set_tzid (GWeatherTimezoneMenu *menu,
- const char *tzid)
+clock_timezone_menu_set_tzid (ClockTimezoneMenu *menu,
+ const char *tzid)
{
SetTimezoneData tzd;
- g_return_if_fail (GWEATHER_IS_TIMEZONE_MENU (menu));
+ g_return_if_fail (CLOCK_IS_TIMEZONE_MENU (menu));
if (!tzid) {
gtk_combo_box_set_active (GTK_COMBO_BOX (menu), 0);
@@ -400,8 +394,8 @@ gweather_timezone_menu_set_tzid (GWeatherTimezoneMenu *menu,
}
/**
- * gweather_timezone_menu_get_tzid:
- * @menu: a #GWeatherTimezoneMenu
+ * clock_timezone_menu_get_tzid:
+ * @menu: a #ClockTimezoneMenu
*
* Gets @menu's timezone id.
*
@@ -409,12 +403,11 @@ gweather_timezone_menu_set_tzid (GWeatherTimezoneMenu *menu,
* is selected.
**/
const char *
-gweather_timezone_menu_get_tzid (GWeatherTimezoneMenu *menu)
+clock_timezone_menu_get_tzid (ClockTimezoneMenu *menu)
{
- g_return_val_if_fail (GWEATHER_IS_TIMEZONE_MENU (menu), NULL);
+ g_return_val_if_fail (CLOCK_IS_TIMEZONE_MENU (menu), NULL);
if (!menu->zone)
return NULL;
return gweather_timezone_get_tzid (menu->zone);
}
-
diff --git a/modules/clock/clock-timezone-menu.h b/modules/clock/clock-timezone-menu.h
new file mode 100644
index 000000000..68fb3def6
--- /dev/null
+++ b/modules/clock/clock-timezone-menu.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* timezone-menu.h - Timezone-selecting menu
+ *
+ * Copyright 2008, Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see
+ * <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef CLOCK_TIMEZONE_MENU_H
+#define CLOCK_TIMEZONE_MENU_H
+
+#include <gtk/gtk.h>
+#include <libgweather/gweather.h>
+
+typedef struct _ClockTimezoneMenu ClockTimezoneMenu;
+typedef struct _ClockTimezoneMenuClass ClockTimezoneMenuClass;
+
+#define CLOCK_TYPE_TIMEZONE_MENU (clock_timezone_menu_get_type ())
+#define CLOCK_TIMEZONE_MENU(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), CLOCK_TYPE_TIMEZONE_MENU,
ClockTimezoneMenu))
+#define CLOCK_TIMEZONE_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLOCK_TYPE_TIMEZONE_MENU,
ClockTimezoneMenuClass))
+#define CLOCK_IS_TIMEZONE_MENU(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), CLOCK_TYPE_TIMEZONE_MENU))
+#define CLOCK_IS_TIMEZONE_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLOCK_TYPE_TIMEZONE_MENU))
+#define CLOCK_TIMEZONE_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLOCK_TYPE_TIMEZONE_MENU,
ClockTimezoneMenuClass))
+
+struct _ClockTimezoneMenu {
+ GtkComboBox parent;
+
+ /*< private >*/
+ GWeatherTimezone *zone;
+};
+
+struct _ClockTimezoneMenuClass {
+ GtkComboBoxClass parent_class;
+};
+
+GType clock_timezone_menu_get_type (void);
+GtkWidget *clock_timezone_menu_new (GWeatherLocation *top);
+void clock_timezone_menu_set_tzid (ClockTimezoneMenu *menu,
+ const char *tzid);
+const char *clock_timezone_menu_get_tzid (ClockTimezoneMenu *menu);
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]