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
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 #define PROP_SHOW_WEEK_NUMBERS_S "show-week-numbers"
6 #define PROP_SHOW_CALENDAR_S "show-calendar"
7
8-#define INDICATOR_DATETIME_GET_PRIVATE(o) \
9-(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_DATETIME_TYPE, IndicatorDatetimePrivate))
10-
11 enum {
12 STRFTIME_MASK_NONE = 0, /* Hours or minutes as we always test those */
13 STRFTIME_MASK_SECONDS = 1 << 0, /* Seconds count */
14@@ -153,7 +150,7 @@
15 STRFTIME_MASK_ALL = (STRFTIME_MASK_SECONDS | STRFTIME_MASK_AMPM | STRFTIME_MASK_WEEK | STRFTIME_MASK_DAY | STRFTIME_MASK_MONTH | STRFTIME_MASK_YEAR)
16 };
17
18-GType indicator_datetime_get_type (void);
19+GType indicator_datetime_get_type (void) G_GNUC_CONST;
20
21 static void indicator_datetime_class_init (IndicatorDatetimeClass *klass);
22 static void indicator_datetime_init (IndicatorDatetime *self);
23@@ -291,7 +288,9 @@
24 static void
25 indicator_datetime_init (IndicatorDatetime *self)
26 {
27- self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);
28+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
29+ INDICATOR_DATETIME_TYPE,
30+ IndicatorDatetimePrivate);
31
32 self->priv->label = NULL;
33 self->priv->timer = 0;
34@@ -400,11 +399,10 @@
35
36 IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
37 g_return_if_fail(self != NULL);
38+ IndicatorDatetimePrivate * priv = self->priv;
39
40 GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
41
42- IndicatorDatetimePrivate * priv = INDICATOR_DATETIME_GET_PRIVATE(self);
43-
44 if (priv->service_proxy_cancel != NULL) {
45 g_object_unref(priv->service_proxy_cancel);
46 priv->service_proxy_cancel = NULL;
47@@ -537,7 +535,8 @@
48 static void
49 timezone_update_all_labels (IndicatorDatetime * self)
50 {
51- IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self);
52+ IndicatorDatetimePrivate *priv = self->priv;
53+
54 g_list_foreach(priv->timezone_items, (GFunc)timezone_update_labels, NULL);
55 }
56
57@@ -1386,8 +1385,7 @@
58 /* Note: not checking parent, it's reasonable for it to be NULL */
59
60 IndicatorDatetime *self = INDICATOR_DATETIME(user_data);
61- self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);
62-
63+
64 IdoCalendarMenuItem *ido = IDO_CALENDAR_MENU_ITEM (ido_calendar_menu_item_new ());
65 self->priv->ido_calendar = ido;
66
67@@ -1431,7 +1429,9 @@
68 static void
69 timezone_destroyed_cb (indicator_item_t * mi_data, DbusmenuMenuitem * dbusitem)
70 {
71- IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(mi_data->self);
72+ IndicatorDatetime *self = INDICATOR_DATETIME (mi_data->self);
73+ IndicatorDatetimePrivate *priv = self->priv;
74+
75 priv->timezone_items = g_list_remove(priv->timezone_items, mi_data);
76 g_signal_handlers_disconnect_by_func(G_OBJECT(mi_data->gmi), G_CALLBACK(timezone_toggled_cb), dbusitem);
77 g_free(mi_data);
78@@ -1449,7 +1449,7 @@
79 /* Note: not checking parent, it's reasonable for it to be NULL */
80
81 IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
82- IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self);
83+ IndicatorDatetimePrivate *priv = self->priv;
84
85 // Menu item with a radio button and a right aligned time
86 indicator_item_t * mi_data = g_new0(indicator_item_t, 1);
87
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
93 /* static guint signals[LAST_SIGNAL] = { }; */
94
95-typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate;
96 struct _TimezoneCompletionPrivate
97 {
98 GtkTreeModel * initial_model;
99@@ -48,8 +47,6 @@
100 GHashTable * request_table;
101 };
102
103-#define TIMEZONE_COMPLETION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionPrivate))
104-
105 #define GEONAME_URL "http://geoname-lookup.ubuntu.com/?query=%s&release=%s&lang=%s"
106
107 /* Prototypes */
108@@ -71,7 +68,7 @@
109 static void
110 save_and_use_model (TimezoneCompletion * completion, GtkTreeModel * model)
111 {
112- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion);
113+ TimezoneCompletionPrivate * priv = completion->priv;
114
115 g_hash_table_insert (priv->request_table, g_strdup (priv->request_text), g_object_ref_sink (model));
116
117@@ -129,7 +126,7 @@
118 json_parse_ready (GObject *object, GAsyncResult *res, gpointer user_data)
119 {
120 TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data);
121- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion);
122+ TimezoneCompletionPrivate * priv = completion->priv;
123 GError * error = NULL;
124 const gchar * prev_name = NULL;
125 const gchar * prev_admin1 = NULL;
126@@ -257,7 +254,7 @@
127 geonames_data_ready (GObject *object, GAsyncResult *res, gpointer user_data)
128 {
129 TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data);
130- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
131+ TimezoneCompletionPrivate * priv = completion->priv;
132 GError * error = NULL;
133 GFileInputStream * stream;
134
135@@ -335,7 +332,7 @@
136 static gboolean
137 request_zones (TimezoneCompletion * completion)
138 {
139- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
140+ TimezoneCompletionPrivate * priv = completion->priv;
141
142 priv->queued_request = 0;
143
144@@ -373,7 +370,7 @@
145 static void
146 entry_changed (GtkEntry * entry, TimezoneCompletion * completion)
147 {
148- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
149+ TimezoneCompletionPrivate * priv = completion->priv;
150
151 if (priv->queued_request) {
152 g_source_remove (priv->queued_request);
153@@ -484,7 +481,7 @@
154 void
155 timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry)
156 {
157- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
158+ TimezoneCompletionPrivate * priv = completion->priv;
159
160 if (priv->queued_request) {
161 g_source_remove (priv->queued_request);
162@@ -604,7 +601,12 @@
163 static void
164 timezone_completion_init (TimezoneCompletion * self)
165 {
166- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (self);
167+ TimezoneCompletionPrivate *priv;
168+
169+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
170+ TIMEZONE_COMPLETION_TYPE,
171+ TimezoneCompletionPrivate);
172+ priv = self->priv;
173
174 priv->initial_model = GTK_TREE_MODEL (get_initial_model ());
175
176@@ -630,7 +632,7 @@
177 G_OBJECT_CLASS (timezone_completion_parent_class)->dispose (object);
178
179 TimezoneCompletion * completion = TIMEZONE_COMPLETION (object);
180- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
181+ TimezoneCompletionPrivate * priv = completion->priv;
182
183 if (priv->changed_id) {
184 if (priv->entry)
185
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 #define IS_TIMEZONE_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TIMEZONE_COMPLETION_TYPE))
191 #define TIMEZONE_COMPLETION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionClass))
192
193-typedef struct _TimezoneCompletion TimezoneCompletion;
194-typedef struct _TimezoneCompletionClass TimezoneCompletionClass;
195+typedef struct _TimezoneCompletion TimezoneCompletion;
196+typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate;
197+typedef struct _TimezoneCompletionClass TimezoneCompletionClass;
198+
199+struct _TimezoneCompletion {
200+ GtkEntryCompletion parent;
201+
202+ TimezoneCompletionPrivate *priv;
203+};
204
205 struct _TimezoneCompletionClass {
206 GtkEntryCompletionClass parent_class;
207 };
208
209-struct _TimezoneCompletion {
210- GtkEntryCompletion parent;
211-};
212-
213 #define TIMEZONE_COMPLETION_ZONE 0
214 #define TIMEZONE_COMPLETION_NAME 1
215 #define TIMEZONE_COMPLETION_ADMIN1 2
216@@ -53,7 +56,7 @@
217 #define TIMEZONE_COMPLETION_LATITUDE 5
218 #define TIMEZONE_COMPLETION_LAST 6
219
220-GType timezone_completion_get_type (void);
221+GType timezone_completion_get_type (void) G_GNUC_CONST;
222 TimezoneCompletion * timezone_completion_new ();
223 void timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry);
224

Subscribers

People subscribed via source and target branches