Merge lp:~jjardon/indicator-datetime/optimizations into lp:indicator-datetime/0.3

Proposed by Javier Jardón
Status: Merged
Approved by: Ted Gould
Approved revision: 130
Merged at revision: 130
Proposed branch: lp:~jjardon/indicator-datetime/optimizations
Merge into: lp:indicator-datetime/0.3
Diff against target: 223 lines (+35/-30)
3 files modified
src/indicator-datetime.c (+12/-12)
src/timezone-completion.c (+13/-11)
src/timezone-completion.h (+10/-7)
To merge this branch: bzr merge lp:~jjardon/indicator-datetime/optimizations
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+74210@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/indicator-datetime.c'
--- src/indicator-datetime.c 2011-08-25 14:46:51 +0000
+++ src/indicator-datetime.c 2011-09-06 13:01:30 +0000
@@ -138,9 +138,6 @@
138#define PROP_SHOW_WEEK_NUMBERS_S "show-week-numbers"138#define PROP_SHOW_WEEK_NUMBERS_S "show-week-numbers"
139#define PROP_SHOW_CALENDAR_S "show-calendar"139#define PROP_SHOW_CALENDAR_S "show-calendar"
140140
141#define INDICATOR_DATETIME_GET_PRIVATE(o) \
142(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_DATETIME_TYPE, IndicatorDatetimePrivate))
143
144enum {141enum {
145 STRFTIME_MASK_NONE = 0, /* Hours or minutes as we always test those */142 STRFTIME_MASK_NONE = 0, /* Hours or minutes as we always test those */
146 STRFTIME_MASK_SECONDS = 1 << 0, /* Seconds count */143 STRFTIME_MASK_SECONDS = 1 << 0, /* Seconds count */
@@ -153,7 +150,7 @@
153 STRFTIME_MASK_ALL = (STRFTIME_MASK_SECONDS | STRFTIME_MASK_AMPM | STRFTIME_MASK_WEEK | STRFTIME_MASK_DAY | STRFTIME_MASK_MONTH | STRFTIME_MASK_YEAR)150 STRFTIME_MASK_ALL = (STRFTIME_MASK_SECONDS | STRFTIME_MASK_AMPM | STRFTIME_MASK_WEEK | STRFTIME_MASK_DAY | STRFTIME_MASK_MONTH | STRFTIME_MASK_YEAR)
154};151};
155152
156GType indicator_datetime_get_type (void);153GType indicator_datetime_get_type (void) G_GNUC_CONST;
157154
158static void indicator_datetime_class_init (IndicatorDatetimeClass *klass);155static void indicator_datetime_class_init (IndicatorDatetimeClass *klass);
159static void indicator_datetime_init (IndicatorDatetime *self);156static void indicator_datetime_init (IndicatorDatetime *self);
@@ -291,7 +288,9 @@
291static void288static void
292indicator_datetime_init (IndicatorDatetime *self)289indicator_datetime_init (IndicatorDatetime *self)
293{290{
294 self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);291 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
292 INDICATOR_DATETIME_TYPE,
293 IndicatorDatetimePrivate);
295294
296 self->priv->label = NULL;295 self->priv->label = NULL;
297 self->priv->timer = 0;296 self->priv->timer = 0;
@@ -400,11 +399,10 @@
400399
401 IndicatorDatetime * self = INDICATOR_DATETIME(user_data);400 IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
402 g_return_if_fail(self != NULL);401 g_return_if_fail(self != NULL);
402 IndicatorDatetimePrivate * priv = self->priv;
403403
404 GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);404 GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
405405
406 IndicatorDatetimePrivate * priv = INDICATOR_DATETIME_GET_PRIVATE(self);
407
408 if (priv->service_proxy_cancel != NULL) {406 if (priv->service_proxy_cancel != NULL) {
409 g_object_unref(priv->service_proxy_cancel);407 g_object_unref(priv->service_proxy_cancel);
410 priv->service_proxy_cancel = NULL;408 priv->service_proxy_cancel = NULL;
@@ -537,7 +535,8 @@
537static void535static void
538timezone_update_all_labels (IndicatorDatetime * self)536timezone_update_all_labels (IndicatorDatetime * self)
539{537{
540 IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self);538 IndicatorDatetimePrivate *priv = self->priv;
539
541 g_list_foreach(priv->timezone_items, (GFunc)timezone_update_labels, NULL);540 g_list_foreach(priv->timezone_items, (GFunc)timezone_update_labels, NULL);
542}541}
543542
@@ -1386,8 +1385,7 @@
1386 /* Note: not checking parent, it's reasonable for it to be NULL */1385 /* Note: not checking parent, it's reasonable for it to be NULL */
13871386
1388 IndicatorDatetime *self = INDICATOR_DATETIME(user_data);1387 IndicatorDatetime *self = INDICATOR_DATETIME(user_data);
1389 self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);1388
1390
1391 IdoCalendarMenuItem *ido = IDO_CALENDAR_MENU_ITEM (ido_calendar_menu_item_new ());1389 IdoCalendarMenuItem *ido = IDO_CALENDAR_MENU_ITEM (ido_calendar_menu_item_new ());
1392 self->priv->ido_calendar = ido;1390 self->priv->ido_calendar = ido;
1393 1391
@@ -1431,7 +1429,9 @@
1431static void1429static void
1432timezone_destroyed_cb (indicator_item_t * mi_data, DbusmenuMenuitem * dbusitem)1430timezone_destroyed_cb (indicator_item_t * mi_data, DbusmenuMenuitem * dbusitem)
1433{1431{
1434 IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(mi_data->self);1432 IndicatorDatetime *self = INDICATOR_DATETIME (mi_data->self);
1433 IndicatorDatetimePrivate *priv = self->priv;
1434
1435 priv->timezone_items = g_list_remove(priv->timezone_items, mi_data);1435 priv->timezone_items = g_list_remove(priv->timezone_items, mi_data);
1436 g_signal_handlers_disconnect_by_func(G_OBJECT(mi_data->gmi), G_CALLBACK(timezone_toggled_cb), dbusitem);1436 g_signal_handlers_disconnect_by_func(G_OBJECT(mi_data->gmi), G_CALLBACK(timezone_toggled_cb), dbusitem);
1437 g_free(mi_data);1437 g_free(mi_data);
@@ -1449,7 +1449,7 @@
1449 /* Note: not checking parent, it's reasonable for it to be NULL */1449 /* Note: not checking parent, it's reasonable for it to be NULL */
14501450
1451 IndicatorDatetime * self = INDICATOR_DATETIME(user_data);1451 IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
1452 IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self);1452 IndicatorDatetimePrivate *priv = self->priv;
14531453
1454 // Menu item with a radio button and a right aligned time1454 // Menu item with a radio button and a right aligned time
1455 indicator_item_t * mi_data = g_new0(indicator_item_t, 1);1455 indicator_item_t * mi_data = g_new0(indicator_item_t, 1);
14561456
=== modified file 'src/timezone-completion.c'
--- src/timezone-completion.c 2011-06-29 13:10:25 +0000
+++ src/timezone-completion.c 2011-09-06 13:01:30 +0000
@@ -35,7 +35,6 @@
3535
36/* static guint signals[LAST_SIGNAL] = { }; */36/* static guint signals[LAST_SIGNAL] = { }; */
3737
38typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate;
39struct _TimezoneCompletionPrivate38struct _TimezoneCompletionPrivate
40{39{
41 GtkTreeModel * initial_model;40 GtkTreeModel * initial_model;
@@ -48,8 +47,6 @@
48 GHashTable * request_table;47 GHashTable * request_table;
49};48};
5049
51#define TIMEZONE_COMPLETION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionPrivate))
52
53#define GEONAME_URL "http://geoname-lookup.ubuntu.com/?query=%s&release=%s&lang=%s"50#define GEONAME_URL "http://geoname-lookup.ubuntu.com/?query=%s&release=%s&lang=%s"
5451
55/* Prototypes */52/* Prototypes */
@@ -71,7 +68,7 @@
71static void68static void
72save_and_use_model (TimezoneCompletion * completion, GtkTreeModel * model)69save_and_use_model (TimezoneCompletion * completion, GtkTreeModel * model)
73{70{
74 TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion);71 TimezoneCompletionPrivate * priv = completion->priv;
7572
76 g_hash_table_insert (priv->request_table, g_strdup (priv->request_text), g_object_ref_sink (model));73 g_hash_table_insert (priv->request_table, g_strdup (priv->request_text), g_object_ref_sink (model));
7774
@@ -129,7 +126,7 @@
129json_parse_ready (GObject *object, GAsyncResult *res, gpointer user_data)126json_parse_ready (GObject *object, GAsyncResult *res, gpointer user_data)
130{127{
131 TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data);128 TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data);
132 TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion);129 TimezoneCompletionPrivate * priv = completion->priv;
133 GError * error = NULL;130 GError * error = NULL;
134 const gchar * prev_name = NULL;131 const gchar * prev_name = NULL;
135 const gchar * prev_admin1 = NULL;132 const gchar * prev_admin1 = NULL;
@@ -257,7 +254,7 @@
257geonames_data_ready (GObject *object, GAsyncResult *res, gpointer user_data)254geonames_data_ready (GObject *object, GAsyncResult *res, gpointer user_data)
258{255{
259 TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data);256 TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data);
260 TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);257 TimezoneCompletionPrivate * priv = completion->priv;
261 GError * error = NULL;258 GError * error = NULL;
262 GFileInputStream * stream;259 GFileInputStream * stream;
263260
@@ -335,7 +332,7 @@
335static gboolean332static gboolean
336request_zones (TimezoneCompletion * completion)333request_zones (TimezoneCompletion * completion)
337{334{
338 TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);335 TimezoneCompletionPrivate * priv = completion->priv;
339336
340 priv->queued_request = 0;337 priv->queued_request = 0;
341338
@@ -373,7 +370,7 @@
373static void370static void
374entry_changed (GtkEntry * entry, TimezoneCompletion * completion)371entry_changed (GtkEntry * entry, TimezoneCompletion * completion)
375{372{
376 TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);373 TimezoneCompletionPrivate * priv = completion->priv;
377374
378 if (priv->queued_request) {375 if (priv->queued_request) {
379 g_source_remove (priv->queued_request);376 g_source_remove (priv->queued_request);
@@ -484,7 +481,7 @@
484void481void
485timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry)482timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry)
486{483{
487 TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);484 TimezoneCompletionPrivate * priv = completion->priv;
488485
489 if (priv->queued_request) {486 if (priv->queued_request) {
490 g_source_remove (priv->queued_request);487 g_source_remove (priv->queued_request);
@@ -604,7 +601,12 @@
604static void601static void
605timezone_completion_init (TimezoneCompletion * self)602timezone_completion_init (TimezoneCompletion * self)
606{603{
607 TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (self);604 TimezoneCompletionPrivate *priv;
605
606 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
607 TIMEZONE_COMPLETION_TYPE,
608 TimezoneCompletionPrivate);
609 priv = self->priv;
608610
609 priv->initial_model = GTK_TREE_MODEL (get_initial_model ());611 priv->initial_model = GTK_TREE_MODEL (get_initial_model ());
610612
@@ -630,7 +632,7 @@
630 G_OBJECT_CLASS (timezone_completion_parent_class)->dispose (object);632 G_OBJECT_CLASS (timezone_completion_parent_class)->dispose (object);
631633
632 TimezoneCompletion * completion = TIMEZONE_COMPLETION (object);634 TimezoneCompletion * completion = TIMEZONE_COMPLETION (object);
633 TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);635 TimezoneCompletionPrivate * priv = completion->priv;
634636
635 if (priv->changed_id) {637 if (priv->changed_id) {
636 if (priv->entry)638 if (priv->entry)
637639
=== modified file 'src/timezone-completion.h'
--- src/timezone-completion.h 2011-02-23 18:28:53 +0000
+++ src/timezone-completion.h 2011-09-06 13:01:30 +0000
@@ -34,17 +34,20 @@
34#define IS_TIMEZONE_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TIMEZONE_COMPLETION_TYPE))34#define IS_TIMEZONE_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TIMEZONE_COMPLETION_TYPE))
35#define TIMEZONE_COMPLETION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionClass))35#define TIMEZONE_COMPLETION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionClass))
3636
37typedef struct _TimezoneCompletion TimezoneCompletion;37typedef struct _TimezoneCompletion TimezoneCompletion;
38typedef struct _TimezoneCompletionClass TimezoneCompletionClass;38typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate;
39typedef struct _TimezoneCompletionClass TimezoneCompletionClass;
40
41struct _TimezoneCompletion {
42 GtkEntryCompletion parent;
43
44 TimezoneCompletionPrivate *priv;
45};
3946
40struct _TimezoneCompletionClass {47struct _TimezoneCompletionClass {
41 GtkEntryCompletionClass parent_class;48 GtkEntryCompletionClass parent_class;
42};49};
4350
44struct _TimezoneCompletion {
45 GtkEntryCompletion parent;
46};
47
48#define TIMEZONE_COMPLETION_ZONE 051#define TIMEZONE_COMPLETION_ZONE 0
49#define TIMEZONE_COMPLETION_NAME 152#define TIMEZONE_COMPLETION_NAME 1
50#define TIMEZONE_COMPLETION_ADMIN1 253#define TIMEZONE_COMPLETION_ADMIN1 2
@@ -53,7 +56,7 @@
53#define TIMEZONE_COMPLETION_LATITUDE 556#define TIMEZONE_COMPLETION_LATITUDE 5
54#define TIMEZONE_COMPLETION_LAST 657#define TIMEZONE_COMPLETION_LAST 6
5558
56GType timezone_completion_get_type (void);59GType timezone_completion_get_type (void) G_GNUC_CONST;
57TimezoneCompletion * timezone_completion_new ();60TimezoneCompletion * timezone_completion_new ();
58void timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry);61void timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry);
5962

Subscribers

People subscribed via source and target branches