Merge lp:~jjardon/indicator-datetime/optimizations into lp:indicator-datetime/0.3
- optimizations
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
Review via email: mp+74210@code.launchpad.net |
Commit message
Description of the change
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
1 | === modified file 'src/indicator-datetime.c' | |||
2 | --- src/indicator-datetime.c 2011-08-25 14:46:51 +0000 | |||
3 | +++ src/indicator-datetime.c 2011-09-06 13:01:30 +0000 | |||
4 | @@ -138,9 +138,6 @@ | |||
5 | 138 | #define PROP_SHOW_WEEK_NUMBERS_S "show-week-numbers" | 138 | #define PROP_SHOW_WEEK_NUMBERS_S "show-week-numbers" |
6 | 139 | #define PROP_SHOW_CALENDAR_S "show-calendar" | 139 | #define PROP_SHOW_CALENDAR_S "show-calendar" |
7 | 140 | 140 | ||
8 | 141 | #define INDICATOR_DATETIME_GET_PRIVATE(o) \ | ||
9 | 142 | (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_DATETIME_TYPE, IndicatorDatetimePrivate)) | ||
10 | 143 | |||
11 | 144 | enum { | 141 | enum { |
12 | 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 */ |
13 | 146 | STRFTIME_MASK_SECONDS = 1 << 0, /* Seconds count */ | 143 | STRFTIME_MASK_SECONDS = 1 << 0, /* Seconds count */ |
14 | @@ -153,7 +150,7 @@ | |||
15 | 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) |
16 | 154 | }; | 151 | }; |
17 | 155 | 152 | ||
19 | 156 | GType indicator_datetime_get_type (void); | 153 | GType indicator_datetime_get_type (void) G_GNUC_CONST; |
20 | 157 | 154 | ||
21 | 158 | static void indicator_datetime_class_init (IndicatorDatetimeClass *klass); | 155 | static void indicator_datetime_class_init (IndicatorDatetimeClass *klass); |
22 | 159 | static void indicator_datetime_init (IndicatorDatetime *self); | 156 | static void indicator_datetime_init (IndicatorDatetime *self); |
23 | @@ -291,7 +288,9 @@ | |||
24 | 291 | static void | 288 | static void |
25 | 292 | indicator_datetime_init (IndicatorDatetime *self) | 289 | indicator_datetime_init (IndicatorDatetime *self) |
26 | 293 | { | 290 | { |
28 | 294 | self->priv = INDICATOR_DATETIME_GET_PRIVATE(self); | 291 | self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, |
29 | 292 | INDICATOR_DATETIME_TYPE, | ||
30 | 293 | IndicatorDatetimePrivate); | ||
31 | 295 | 294 | ||
32 | 296 | self->priv->label = NULL; | 295 | self->priv->label = NULL; |
33 | 297 | self->priv->timer = 0; | 296 | self->priv->timer = 0; |
34 | @@ -400,11 +399,10 @@ | |||
35 | 400 | 399 | ||
36 | 401 | IndicatorDatetime * self = INDICATOR_DATETIME(user_data); | 400 | IndicatorDatetime * self = INDICATOR_DATETIME(user_data); |
37 | 402 | g_return_if_fail(self != NULL); | 401 | g_return_if_fail(self != NULL); |
38 | 402 | IndicatorDatetimePrivate * priv = self->priv; | ||
39 | 403 | 403 | ||
40 | 404 | GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); | 404 | GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); |
41 | 405 | 405 | ||
42 | 406 | IndicatorDatetimePrivate * priv = INDICATOR_DATETIME_GET_PRIVATE(self); | ||
43 | 407 | |||
44 | 408 | if (priv->service_proxy_cancel != NULL) { | 406 | if (priv->service_proxy_cancel != NULL) { |
45 | 409 | g_object_unref(priv->service_proxy_cancel); | 407 | g_object_unref(priv->service_proxy_cancel); |
46 | 410 | priv->service_proxy_cancel = NULL; | 408 | priv->service_proxy_cancel = NULL; |
47 | @@ -537,7 +535,8 @@ | |||
48 | 537 | static void | 535 | static void |
49 | 538 | timezone_update_all_labels (IndicatorDatetime * self) | 536 | timezone_update_all_labels (IndicatorDatetime * self) |
50 | 539 | { | 537 | { |
52 | 540 | IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self); | 538 | IndicatorDatetimePrivate *priv = self->priv; |
53 | 539 | |||
54 | 541 | g_list_foreach(priv->timezone_items, (GFunc)timezone_update_labels, NULL); | 540 | g_list_foreach(priv->timezone_items, (GFunc)timezone_update_labels, NULL); |
55 | 542 | } | 541 | } |
56 | 543 | 542 | ||
57 | @@ -1386,8 +1385,7 @@ | |||
58 | 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 */ |
59 | 1387 | 1386 | ||
60 | 1388 | IndicatorDatetime *self = INDICATOR_DATETIME(user_data); | 1387 | IndicatorDatetime *self = INDICATOR_DATETIME(user_data); |
63 | 1389 | self->priv = INDICATOR_DATETIME_GET_PRIVATE(self); | 1388 | |
62 | 1390 | |||
64 | 1391 | IdoCalendarMenuItem *ido = IDO_CALENDAR_MENU_ITEM (ido_calendar_menu_item_new ()); | 1389 | IdoCalendarMenuItem *ido = IDO_CALENDAR_MENU_ITEM (ido_calendar_menu_item_new ()); |
65 | 1392 | self->priv->ido_calendar = ido; | 1390 | self->priv->ido_calendar = ido; |
66 | 1393 | 1391 | ||
67 | @@ -1431,7 +1429,9 @@ | |||
68 | 1431 | static void | 1429 | static void |
69 | 1432 | timezone_destroyed_cb (indicator_item_t * mi_data, DbusmenuMenuitem * dbusitem) | 1430 | timezone_destroyed_cb (indicator_item_t * mi_data, DbusmenuMenuitem * dbusitem) |
70 | 1433 | { | 1431 | { |
72 | 1434 | IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(mi_data->self); | 1432 | IndicatorDatetime *self = INDICATOR_DATETIME (mi_data->self); |
73 | 1433 | IndicatorDatetimePrivate *priv = self->priv; | ||
74 | 1434 | |||
75 | 1435 | priv->timezone_items = g_list_remove(priv->timezone_items, mi_data); | 1435 | priv->timezone_items = g_list_remove(priv->timezone_items, mi_data); |
76 | 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); |
77 | 1437 | g_free(mi_data); | 1437 | g_free(mi_data); |
78 | @@ -1449,7 +1449,7 @@ | |||
79 | 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 */ |
80 | 1450 | 1450 | ||
81 | 1451 | IndicatorDatetime * self = INDICATOR_DATETIME(user_data); | 1451 | IndicatorDatetime * self = INDICATOR_DATETIME(user_data); |
83 | 1452 | IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self); | 1452 | IndicatorDatetimePrivate *priv = self->priv; |
84 | 1453 | 1453 | ||
85 | 1454 | // Menu item with a radio button and a right aligned time | 1454 | // Menu item with a radio button and a right aligned time |
86 | 1455 | indicator_item_t * mi_data = g_new0(indicator_item_t, 1); | 1455 | indicator_item_t * mi_data = g_new0(indicator_item_t, 1); |
87 | 1456 | 1456 | ||
88 | === modified file 'src/timezone-completion.c' | |||
89 | --- src/timezone-completion.c 2011-06-29 13:10:25 +0000 | |||
90 | +++ src/timezone-completion.c 2011-09-06 13:01:30 +0000 | |||
91 | @@ -35,7 +35,6 @@ | |||
92 | 35 | 35 | ||
93 | 36 | /* static guint signals[LAST_SIGNAL] = { }; */ | 36 | /* static guint signals[LAST_SIGNAL] = { }; */ |
94 | 37 | 37 | ||
95 | 38 | typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate; | ||
96 | 39 | struct _TimezoneCompletionPrivate | 38 | struct _TimezoneCompletionPrivate |
97 | 40 | { | 39 | { |
98 | 41 | GtkTreeModel * initial_model; | 40 | GtkTreeModel * initial_model; |
99 | @@ -48,8 +47,6 @@ | |||
100 | 48 | GHashTable * request_table; | 47 | GHashTable * request_table; |
101 | 49 | }; | 48 | }; |
102 | 50 | 49 | ||
103 | 51 | #define TIMEZONE_COMPLETION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionPrivate)) | ||
104 | 52 | |||
105 | 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" |
106 | 54 | 51 | ||
107 | 55 | /* Prototypes */ | 52 | /* Prototypes */ |
108 | @@ -71,7 +68,7 @@ | |||
109 | 71 | static void | 68 | static void |
110 | 72 | save_and_use_model (TimezoneCompletion * completion, GtkTreeModel * model) | 69 | save_and_use_model (TimezoneCompletion * completion, GtkTreeModel * model) |
111 | 73 | { | 70 | { |
113 | 74 | TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion); | 71 | TimezoneCompletionPrivate * priv = completion->priv; |
114 | 75 | 72 | ||
115 | 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)); |
116 | 77 | 74 | ||
117 | @@ -129,7 +126,7 @@ | |||
118 | 129 | json_parse_ready (GObject *object, GAsyncResult *res, gpointer user_data) | 126 | json_parse_ready (GObject *object, GAsyncResult *res, gpointer user_data) |
119 | 130 | { | 127 | { |
120 | 131 | TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data); | 128 | TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data); |
122 | 132 | TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion); | 129 | TimezoneCompletionPrivate * priv = completion->priv; |
123 | 133 | GError * error = NULL; | 130 | GError * error = NULL; |
124 | 134 | const gchar * prev_name = NULL; | 131 | const gchar * prev_name = NULL; |
125 | 135 | const gchar * prev_admin1 = NULL; | 132 | const gchar * prev_admin1 = NULL; |
126 | @@ -257,7 +254,7 @@ | |||
127 | 257 | geonames_data_ready (GObject *object, GAsyncResult *res, gpointer user_data) | 254 | geonames_data_ready (GObject *object, GAsyncResult *res, gpointer user_data) |
128 | 258 | { | 255 | { |
129 | 259 | TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data); | 256 | TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data); |
131 | 260 | TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion); | 257 | TimezoneCompletionPrivate * priv = completion->priv; |
132 | 261 | GError * error = NULL; | 258 | GError * error = NULL; |
133 | 262 | GFileInputStream * stream; | 259 | GFileInputStream * stream; |
134 | 263 | 260 | ||
135 | @@ -335,7 +332,7 @@ | |||
136 | 335 | static gboolean | 332 | static gboolean |
137 | 336 | request_zones (TimezoneCompletion * completion) | 333 | request_zones (TimezoneCompletion * completion) |
138 | 337 | { | 334 | { |
140 | 338 | TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion); | 335 | TimezoneCompletionPrivate * priv = completion->priv; |
141 | 339 | 336 | ||
142 | 340 | priv->queued_request = 0; | 337 | priv->queued_request = 0; |
143 | 341 | 338 | ||
144 | @@ -373,7 +370,7 @@ | |||
145 | 373 | static void | 370 | static void |
146 | 374 | entry_changed (GtkEntry * entry, TimezoneCompletion * completion) | 371 | entry_changed (GtkEntry * entry, TimezoneCompletion * completion) |
147 | 375 | { | 372 | { |
149 | 376 | TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion); | 373 | TimezoneCompletionPrivate * priv = completion->priv; |
150 | 377 | 374 | ||
151 | 378 | if (priv->queued_request) { | 375 | if (priv->queued_request) { |
152 | 379 | g_source_remove (priv->queued_request); | 376 | g_source_remove (priv->queued_request); |
153 | @@ -484,7 +481,7 @@ | |||
154 | 484 | void | 481 | void |
155 | 485 | timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry) | 482 | timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry) |
156 | 486 | { | 483 | { |
158 | 487 | TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion); | 484 | TimezoneCompletionPrivate * priv = completion->priv; |
159 | 488 | 485 | ||
160 | 489 | if (priv->queued_request) { | 486 | if (priv->queued_request) { |
161 | 490 | g_source_remove (priv->queued_request); | 487 | g_source_remove (priv->queued_request); |
162 | @@ -604,7 +601,12 @@ | |||
163 | 604 | static void | 601 | static void |
164 | 605 | timezone_completion_init (TimezoneCompletion * self) | 602 | timezone_completion_init (TimezoneCompletion * self) |
165 | 606 | { | 603 | { |
167 | 607 | TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (self); | 604 | TimezoneCompletionPrivate *priv; |
168 | 605 | |||
169 | 606 | self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, | ||
170 | 607 | TIMEZONE_COMPLETION_TYPE, | ||
171 | 608 | TimezoneCompletionPrivate); | ||
172 | 609 | priv = self->priv; | ||
173 | 608 | 610 | ||
174 | 609 | priv->initial_model = GTK_TREE_MODEL (get_initial_model ()); | 611 | priv->initial_model = GTK_TREE_MODEL (get_initial_model ()); |
175 | 610 | 612 | ||
176 | @@ -630,7 +632,7 @@ | |||
177 | 630 | G_OBJECT_CLASS (timezone_completion_parent_class)->dispose (object); | 632 | G_OBJECT_CLASS (timezone_completion_parent_class)->dispose (object); |
178 | 631 | 633 | ||
179 | 632 | TimezoneCompletion * completion = TIMEZONE_COMPLETION (object); | 634 | TimezoneCompletion * completion = TIMEZONE_COMPLETION (object); |
181 | 633 | TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion); | 635 | TimezoneCompletionPrivate * priv = completion->priv; |
182 | 634 | 636 | ||
183 | 635 | if (priv->changed_id) { | 637 | if (priv->changed_id) { |
184 | 636 | if (priv->entry) | 638 | if (priv->entry) |
185 | 637 | 639 | ||
186 | === modified file 'src/timezone-completion.h' | |||
187 | --- src/timezone-completion.h 2011-02-23 18:28:53 +0000 | |||
188 | +++ src/timezone-completion.h 2011-09-06 13:01:30 +0000 | |||
189 | @@ -34,17 +34,20 @@ | |||
190 | 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)) |
191 | 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)) |
192 | 36 | 36 | ||
195 | 37 | typedef struct _TimezoneCompletion TimezoneCompletion; | 37 | typedef struct _TimezoneCompletion TimezoneCompletion; |
196 | 38 | typedef struct _TimezoneCompletionClass TimezoneCompletionClass; | 38 | typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate; |
197 | 39 | typedef struct _TimezoneCompletionClass TimezoneCompletionClass; | ||
198 | 40 | |||
199 | 41 | struct _TimezoneCompletion { | ||
200 | 42 | GtkEntryCompletion parent; | ||
201 | 43 | |||
202 | 44 | TimezoneCompletionPrivate *priv; | ||
203 | 45 | }; | ||
204 | 39 | 46 | ||
205 | 40 | struct _TimezoneCompletionClass { | 47 | struct _TimezoneCompletionClass { |
206 | 41 | GtkEntryCompletionClass parent_class; | 48 | GtkEntryCompletionClass parent_class; |
207 | 42 | }; | 49 | }; |
208 | 43 | 50 | ||
209 | 44 | struct _TimezoneCompletion { | ||
210 | 45 | GtkEntryCompletion parent; | ||
211 | 46 | }; | ||
212 | 47 | |||
213 | 48 | #define TIMEZONE_COMPLETION_ZONE 0 | 51 | #define TIMEZONE_COMPLETION_ZONE 0 |
214 | 49 | #define TIMEZONE_COMPLETION_NAME 1 | 52 | #define TIMEZONE_COMPLETION_NAME 1 |
215 | 50 | #define TIMEZONE_COMPLETION_ADMIN1 2 | 53 | #define TIMEZONE_COMPLETION_ADMIN1 2 |
216 | @@ -53,7 +56,7 @@ | |||
217 | 53 | #define TIMEZONE_COMPLETION_LATITUDE 5 | 56 | #define TIMEZONE_COMPLETION_LATITUDE 5 |
218 | 54 | #define TIMEZONE_COMPLETION_LAST 6 | 57 | #define TIMEZONE_COMPLETION_LAST 6 |
219 | 55 | 58 | ||
221 | 56 | GType timezone_completion_get_type (void); | 59 | GType timezone_completion_get_type (void) G_GNUC_CONST; |
222 | 57 | TimezoneCompletion * timezone_completion_new (); | 60 | TimezoneCompletion * timezone_completion_new (); |
223 | 58 | void timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry); | 61 | void timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry); |
224 | 59 | 62 |