diff options
-rw-r--r-- | src/indicator-datetime.c | 24 | ||||
-rw-r--r-- | src/timezone-completion.c | 24 | ||||
-rw-r--r-- | src/timezone-completion.h | 17 |
3 files changed, 35 insertions, 30 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 59bcaf3..a9c8469 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -138,9 +138,6 @@ struct _indicator_item_t { #define PROP_SHOW_WEEK_NUMBERS_S "show-week-numbers" #define PROP_SHOW_CALENDAR_S "show-calendar" -#define INDICATOR_DATETIME_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_DATETIME_TYPE, IndicatorDatetimePrivate)) - enum { STRFTIME_MASK_NONE = 0, /* Hours or minutes as we always test those */ STRFTIME_MASK_SECONDS = 1 << 0, /* Seconds count */ @@ -153,7 +150,7 @@ enum { STRFTIME_MASK_ALL = (STRFTIME_MASK_SECONDS | STRFTIME_MASK_AMPM | STRFTIME_MASK_WEEK | STRFTIME_MASK_DAY | STRFTIME_MASK_MONTH | STRFTIME_MASK_YEAR) }; -GType indicator_datetime_get_type (void); +GType indicator_datetime_get_type (void) G_GNUC_CONST; static void indicator_datetime_class_init (IndicatorDatetimeClass *klass); static void indicator_datetime_init (IndicatorDatetime *self); @@ -291,7 +288,9 @@ menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointe static void indicator_datetime_init (IndicatorDatetime *self) { - self->priv = INDICATOR_DATETIME_GET_PRIVATE(self); + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + INDICATOR_DATETIME_TYPE, + IndicatorDatetimePrivate); self->priv->label = NULL; self->priv->timer = 0; @@ -400,11 +399,10 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) IndicatorDatetime * self = INDICATOR_DATETIME(user_data); g_return_if_fail(self != NULL); + IndicatorDatetimePrivate * priv = self->priv; GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); - IndicatorDatetimePrivate * priv = INDICATOR_DATETIME_GET_PRIVATE(self); - if (priv->service_proxy_cancel != NULL) { g_object_unref(priv->service_proxy_cancel); priv->service_proxy_cancel = NULL; @@ -537,7 +535,8 @@ bind_enum_get (GValue * value, GVariant * variant, gpointer user_data) static void timezone_update_all_labels (IndicatorDatetime * self) { - IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self); + IndicatorDatetimePrivate *priv = self->priv; + g_list_foreach(priv->timezone_items, (GFunc)timezone_update_labels, NULL); } @@ -1386,8 +1385,7 @@ new_calendar_item (DbusmenuMenuitem * newitem, /* Note: not checking parent, it's reasonable for it to be NULL */ IndicatorDatetime *self = INDICATOR_DATETIME(user_data); - self->priv = INDICATOR_DATETIME_GET_PRIVATE(self); - + IdoCalendarMenuItem *ido = IDO_CALENDAR_MENU_ITEM (ido_calendar_menu_item_new ()); self->priv->ido_calendar = ido; @@ -1431,7 +1429,9 @@ timezone_toggled_cb (GtkCheckMenuItem *checkmenuitem, DbusmenuMenuitem * dbusite static void timezone_destroyed_cb (indicator_item_t * mi_data, DbusmenuMenuitem * dbusitem) { - IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(mi_data->self); + IndicatorDatetime *self = INDICATOR_DATETIME (mi_data->self); + IndicatorDatetimePrivate *priv = self->priv; + priv->timezone_items = g_list_remove(priv->timezone_items, mi_data); g_signal_handlers_disconnect_by_func(G_OBJECT(mi_data->gmi), G_CALLBACK(timezone_toggled_cb), dbusitem); g_free(mi_data); @@ -1449,7 +1449,7 @@ new_timezone_item(DbusmenuMenuitem * newitem, /* Note: not checking parent, it's reasonable for it to be NULL */ IndicatorDatetime * self = INDICATOR_DATETIME(user_data); - IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self); + IndicatorDatetimePrivate *priv = self->priv; // Menu item with a radio button and a right aligned time indicator_item_t * mi_data = g_new0(indicator_item_t, 1); diff --git a/src/timezone-completion.c b/src/timezone-completion.c index d190035..f223bf4 100644 --- a/src/timezone-completion.c +++ b/src/timezone-completion.c @@ -35,7 +35,6 @@ enum { /* static guint signals[LAST_SIGNAL] = { }; */ -typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate; struct _TimezoneCompletionPrivate { GtkTreeModel * initial_model; @@ -48,8 +47,6 @@ struct _TimezoneCompletionPrivate GHashTable * request_table; }; -#define TIMEZONE_COMPLETION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionPrivate)) - #define GEONAME_URL "http://geoname-lookup.ubuntu.com/?query=%s&release=%s&lang=%s" /* Prototypes */ @@ -71,7 +68,7 @@ match_func (GtkEntryCompletion *completion, const gchar *key, static void save_and_use_model (TimezoneCompletion * completion, GtkTreeModel * model) { - TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion); + TimezoneCompletionPrivate * priv = completion->priv; g_hash_table_insert (priv->request_table, g_strdup (priv->request_text), g_object_ref_sink (model)); @@ -129,7 +126,7 @@ static void json_parse_ready (GObject *object, GAsyncResult *res, gpointer user_data) { TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data); - TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion); + TimezoneCompletionPrivate * priv = completion->priv; GError * error = NULL; const gchar * prev_name = NULL; const gchar * prev_admin1 = NULL; @@ -257,7 +254,7 @@ static void geonames_data_ready (GObject *object, GAsyncResult *res, gpointer user_data) { TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data); - TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion); + TimezoneCompletionPrivate * priv = completion->priv; GError * error = NULL; GFileInputStream * stream; @@ -335,7 +332,7 @@ get_version (void) static gboolean request_zones (TimezoneCompletion * completion) { - TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion); + TimezoneCompletionPrivate * priv = completion->priv; priv->queued_request = 0; @@ -373,7 +370,7 @@ request_zones (TimezoneCompletion * completion) static void entry_changed (GtkEntry * entry, TimezoneCompletion * completion) { - TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion); + TimezoneCompletionPrivate * priv = completion->priv; if (priv->queued_request) { g_source_remove (priv->queued_request); @@ -484,7 +481,7 @@ entry_keypress (GtkEntry * entry, GdkEventKey *event, TimezoneCompletion * comp void timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry) { - TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion); + TimezoneCompletionPrivate * priv = completion->priv; if (priv->queued_request) { g_source_remove (priv->queued_request); @@ -604,7 +601,12 @@ timezone_completion_class_init (TimezoneCompletionClass *klass) static void timezone_completion_init (TimezoneCompletion * self) { - TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (self); + TimezoneCompletionPrivate *priv; + + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + TIMEZONE_COMPLETION_TYPE, + TimezoneCompletionPrivate); + priv = self->priv; priv->initial_model = GTK_TREE_MODEL (get_initial_model ()); @@ -630,7 +632,7 @@ timezone_completion_dispose (GObject * object) G_OBJECT_CLASS (timezone_completion_parent_class)->dispose (object); TimezoneCompletion * completion = TIMEZONE_COMPLETION (object); - TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion); + TimezoneCompletionPrivate * priv = completion->priv; if (priv->changed_id) { if (priv->entry) diff --git a/src/timezone-completion.h b/src/timezone-completion.h index fdfb234..1592d79 100644 --- a/src/timezone-completion.h +++ b/src/timezone-completion.h @@ -34,15 +34,18 @@ G_BEGIN_DECLS #define IS_TIMEZONE_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TIMEZONE_COMPLETION_TYPE)) #define TIMEZONE_COMPLETION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionClass)) -typedef struct _TimezoneCompletion TimezoneCompletion; -typedef struct _TimezoneCompletionClass TimezoneCompletionClass; - -struct _TimezoneCompletionClass { - GtkEntryCompletionClass parent_class; -}; +typedef struct _TimezoneCompletion TimezoneCompletion; +typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate; +typedef struct _TimezoneCompletionClass TimezoneCompletionClass; struct _TimezoneCompletion { GtkEntryCompletion parent; + + TimezoneCompletionPrivate *priv; +}; + +struct _TimezoneCompletionClass { + GtkEntryCompletionClass parent_class; }; #define TIMEZONE_COMPLETION_ZONE 0 @@ -53,7 +56,7 @@ struct _TimezoneCompletion { #define TIMEZONE_COMPLETION_LATITUDE 5 #define TIMEZONE_COMPLETION_LAST 6 -GType timezone_completion_get_type (void); +GType timezone_completion_get_type (void) G_GNUC_CONST; TimezoneCompletion * timezone_completion_new (); void timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry); |