← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~jjardon/indicator-datetime/optimizations into lp:indicator-datetime

 

Javier Jardón has proposed merging lp:~jjardon/indicator-datetime/optimizations into lp:indicator-datetime.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)

For more details, see:
https://code.launchpad.net/~jjardon/indicator-datetime/optimizations/+merge/74210
-- 
https://code.launchpad.net/~jjardon/indicator-datetime/optimizations/+merge/74210
Your team ayatana-commits is subscribed to branch lp:indicator-datetime.
=== modified file 'src/indicator-datetime.c'
--- src/indicator-datetime.c	2011-08-25 14:46:51 +0000
+++ src/indicator-datetime.c	2011-09-06 12:59:13 +0000
@@ -138,9 +138,6 @@
 #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 @@
 	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 @@
 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 @@
 
 	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 @@
 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 @@
 	/* 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 @@
 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 @@
 	/* 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);

=== modified file 'src/timezone-completion.c'
--- src/timezone-completion.c	2011-06-29 13:10:25 +0000
+++ src/timezone-completion.c	2011-09-06 12:59:13 +0000
@@ -35,7 +35,6 @@
 
 /* static guint signals[LAST_SIGNAL] = { }; */
 
-typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate;
 struct _TimezoneCompletionPrivate
 {
   GtkTreeModel * initial_model;
@@ -48,8 +47,6 @@
   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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
   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)

=== modified file 'src/timezone-completion.h'
--- src/timezone-completion.h	2011-02-23 18:28:53 +0000
+++ src/timezone-completion.h	2011-09-06 12:59:13 +0000
@@ -34,17 +34,20 @@
 #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;
+typedef struct _TimezoneCompletion             TimezoneCompletion;
+typedef struct _TimezoneCompletionPrivate      TimezoneCompletionPrivate;
+typedef struct _TimezoneCompletionClass        TimezoneCompletionClass;
+
+struct _TimezoneCompletion {
+  GtkEntryCompletion parent;
+
+  TimezoneCompletionPrivate *priv;
+};
 
 struct _TimezoneCompletionClass {
   GtkEntryCompletionClass parent_class;
 };
 
-struct _TimezoneCompletion {
-  GtkEntryCompletion parent;
-};
-
 #define TIMEZONE_COMPLETION_ZONE      0
 #define TIMEZONE_COMPLETION_NAME      1
 #define TIMEZONE_COMPLETION_ADMIN1    2
@@ -53,7 +56,7 @@
 #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);
 


Follow ups