Merge lp:~larsu/evolution-indicator/messaging-menu-fixes into lp:evolution-indicator
- messaging-menu-fixes
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~larsu/evolution-indicator/messaging-menu-fixes |
Merge into: | lp:evolution-indicator |
Diff against target: |
993 lines (+172/-550) 3 files modified
configure.ac (+1/-1) src/evolution-indicator.c (+169/-548) src/org-freedesktop-evolution-indicator.eplug.xml (+2/-1) |
To merge this branch: | bzr merge lp:~larsu/evolution-indicator/messaging-menu-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mathieu Trudel-Lapierre | Approve | ||
Review via email: mp+153957@code.launchpad.net |
This proposal has been superseded by a proposal from 2013-03-21.
Commit message
Description of the change
A couple of minor fixes to lp:~twolife/evolution-indicator/eds-3.6_messaging-menu that I found while testing.
- 93. By Lars Karlitski
-
update_accounts: fix indentation and use consistent code style
- 94. By Lars Karlitski
-
update_accounts: recreate accounts list from scratch
This function is only ever called when the global 'accounts' list is NULL,
there's no need to check for existing accounts. - 95. By Lars Karlitski
-
update_accounts: move name and url fetching into separate function
Also removes some unnecessary string allocations and a memory leak.
- 96. By Lars Karlitski
-
update_accounts: fix memory leak
- 97. By Lars Karlitski
-
Use evolution's uids instead of self-assembled urls as message source identifiers
This simplifies the code and fixes a bug: all POP accounts got the url "pop:",
making them show up as the same entry in the messaging menu. - 98. By Lars Karlitski
-
Remove n_accounts global variable
It gets in the way of the next patch.
- 99. By Lars Karlitski
-
Update the list of accounts on-the-fly
We don't need any information about sources until new messages arrive. Create
the account objects then, instead of listening to "source-added" and
"source-removed" signals. - 100. By Lars Karlitski
-
Use GMutex instead of the deprecated GStaticMutex
- 101. By Lars Karlitski
-
e_plugin_
get_configure_ widget: return NULL instead of an empty widget To get rid of warnings about deprecated gtk functions.
- 102. By Lars Karlitski
-
Declare update_
unity_launcher_ count before first use - 103. By Lars Karlitski
-
Use new-style GtkBox constructors
Unmerged revisions
- 103. By Lars Karlitski
-
Use new-style GtkBox constructors
- 102. By Lars Karlitski
-
Declare update_
unity_launcher_ count before first use - 101. By Lars Karlitski
-
e_plugin_
get_configure_ widget: return NULL instead of an empty widget To get rid of warnings about deprecated gtk functions.
- 100. By Lars Karlitski
-
Use GMutex instead of the deprecated GStaticMutex
- 99. By Lars Karlitski
-
Update the list of accounts on-the-fly
We don't need any information about sources until new messages arrive. Create
the account objects then, instead of listening to "source-added" and
"source-removed" signals. - 98. By Lars Karlitski
-
Remove n_accounts global variable
It gets in the way of the next patch.
- 97. By Lars Karlitski
-
Use evolution's uids instead of self-assembled urls as message source identifiers
This simplifies the code and fixes a bug: all POP accounts got the url "pop:",
making them show up as the same entry in the messaging menu. - 96. By Lars Karlitski
-
update_accounts: fix memory leak
- 95. By Lars Karlitski
-
update_accounts: move name and url fetching into separate function
Also removes some unnecessary string allocations and a memory leak.
- 94. By Lars Karlitski
-
update_accounts: recreate accounts list from scratch
This function is only ever called when the global 'accounts' list is NULL,
there's no need to check for existing accounts.
Preview Diff
1 | === modified file 'configure.ac' | |||
2 | --- configure.ac 2012-05-25 21:05:11 +0000 | |||
3 | +++ configure.ac 2013-03-21 23:26:20 +0000 | |||
4 | @@ -70,7 +70,6 @@ | |||
5 | 70 | AC_SUBST(GCC_FLAGS) | 70 | AC_SUBST(GCC_FLAGS) |
6 | 71 | 71 | ||
7 | 72 | PKG_CHECK_MODULES(DEPS, | 72 | PKG_CHECK_MODULES(DEPS, |
8 | 73 | indicate-0.7 >= 0.6.90 | ||
9 | 74 | $EVOLUTION_PLUGIN | 73 | $EVOLUTION_PLUGIN |
10 | 75 | dbus-1 | 74 | dbus-1 |
11 | 76 | dbus-glib-1 | 75 | dbus-glib-1 |
12 | @@ -81,6 +80,7 @@ | |||
13 | 81 | libebackend-1.2 | 80 | libebackend-1.2 |
14 | 82 | libsoup-2.4 | 81 | libsoup-2.4 |
15 | 83 | gconf-2.0 | 82 | gconf-2.0 |
16 | 83 | messaging-menu | ||
17 | 84 | ) | 84 | ) |
18 | 85 | AC_SUBST(DEPS_CFLAGS) | 85 | AC_SUBST(DEPS_CFLAGS) |
19 | 86 | AC_SUBST(DEPS_LIBS) | 86 | AC_SUBST(DEPS_LIBS) |
20 | 87 | 87 | ||
21 | === modified file 'src/evolution-indicator.c' | |||
22 | --- src/evolution-indicator.c 2012-05-25 21:05:11 +0000 | |||
23 | +++ src/evolution-indicator.c 2013-03-21 23:26:20 +0000 | |||
24 | @@ -28,6 +28,7 @@ | |||
25 | 28 | #include <glib/gprintf.h> | 28 | #include <glib/gprintf.h> |
26 | 29 | 29 | ||
27 | 30 | #include <gconf/gconf.h> | 30 | #include <gconf/gconf.h> |
28 | 31 | #include <gconf/gconf-client.h> | ||
29 | 31 | 32 | ||
30 | 32 | #include <canberra.h> | 33 | #include <canberra.h> |
31 | 33 | #include <libnotify/notify.h> | 34 | #include <libnotify/notify.h> |
32 | @@ -44,9 +45,7 @@ | |||
33 | 44 | 45 | ||
34 | 45 | #include <camel/camel.h> | 46 | #include <camel/camel.h> |
35 | 46 | 47 | ||
39 | 47 | #include <libindicate/server.h> | 48 | #include <messaging-menu.h> |
37 | 48 | #include <libindicate/indicator.h> | ||
38 | 49 | #include <libindicate/indicator-messages.h> | ||
40 | 50 | 49 | ||
41 | 51 | #include <unity.h> | 50 | #include <unity.h> |
42 | 52 | 51 | ||
43 | @@ -58,22 +57,15 @@ | |||
44 | 58 | #define SHOW_BUBBLE CONF_DIR"/show_bubble" | 57 | #define SHOW_BUBBLE CONF_DIR"/show_bubble" |
45 | 59 | #define SHOW_NEW_IN_PANEL CONF_DIR"/show_new_messages_in_panel" | 58 | #define SHOW_NEW_IN_PANEL CONF_DIR"/show_new_messages_in_panel" |
46 | 60 | 59 | ||
47 | 61 | #define ACCOUNT_DIR "/apps/evolution/mail" | ||
48 | 62 | #define ACCOUNTS ACCOUNT_DIR"/accounts" | ||
49 | 63 | |||
50 | 64 | #define EVOLUTION_DESKTOP_FILE "/usr/share/applications/evolution.desktop" | 60 | #define EVOLUTION_DESKTOP_FILE "/usr/share/applications/evolution.desktop" |
51 | 65 | 61 | ||
52 | 66 | #define UNREAD_DATA "unread" | 62 | #define UNREAD_DATA "unread" |
53 | 67 | 63 | ||
58 | 68 | #define USER_BLACKLIST_DIR "indicators/messages/applications-blacklist" | 64 | static GMutex mlock; |
55 | 69 | #define USER_BLACKLIST_FILENAME "evolution" | ||
56 | 70 | |||
57 | 71 | static GStaticMutex mlock = G_STATIC_MUTEX_INIT; | ||
59 | 72 | static GConfClient *client = NULL; | 65 | static GConfClient *client = NULL; |
60 | 73 | 66 | ||
64 | 74 | static IndicateServer *server = NULL; | 67 | static MessagingMenuApp *mmapp = NULL; |
65 | 75 | static GSList *indicators = NULL; | 68 | static GSList *accounts = NULL; |
63 | 76 | static gint n_accounts = 0; | ||
66 | 77 | 69 | ||
67 | 78 | static UnityLauncherEntry *launcher = NULL; | 70 | static UnityLauncherEntry *launcher = NULL; |
68 | 79 | 71 | ||
69 | @@ -91,50 +83,25 @@ | |||
70 | 91 | static guint play_sound_id = 0; | 83 | static guint play_sound_id = 0; |
71 | 92 | static guint show_bubble_id = 0; | 84 | static guint show_bubble_id = 0; |
72 | 93 | static guint show_count_id = 0; | 85 | static guint show_count_id = 0; |
73 | 94 | static guint accounts_id = 0; | ||
74 | 95 | 86 | ||
75 | 96 | static gint message_count = 0; | 87 | static gint message_count = 0; |
76 | 97 | 88 | ||
77 | 98 | void org_gnome_mail_new_notify (EPlugin *ep, EMEventTargetFolder *t); | 89 | void org_gnome_mail_new_notify (EPlugin *ep, EMEventTargetFolder *t); |
78 | 99 | void org_gnome_mail_read_notify (EPlugin *ep, EMEventTargetMessage *t); | 90 | void org_gnome_mail_read_notify (EPlugin *ep, EMEventTargetMessage *t); |
79 | 91 | void update_unity_launcher_count (); | ||
80 | 100 | 92 | ||
81 | 101 | int e_plugin_lib_enable (EPlugin *ep, int enable); | 93 | int e_plugin_lib_enable (EPlugin *ep, int enable); |
82 | 102 | GtkWidget * e_plugin_lib_get_configure_widget (EPlugin *ep); | 94 | GtkWidget * e_plugin_lib_get_configure_widget (EPlugin *ep); |
83 | 103 | 95 | ||
88 | 104 | static void show_evolution (gpointer arg0, guint timestamp, gpointer arg1); | 96 | static void show_evolution (MessagingMenuApp *mmapp, const gchar *uid, gpointer user_data); |
85 | 105 | |||
86 | 106 | static void show_evolution_in_indicator_applet (void); | ||
87 | 107 | static void hide_evolution_in_indicator_applet (void); | ||
89 | 108 | 97 | ||
90 | 109 | typedef struct { | 98 | typedef struct { |
119 | 110 | gchar *url; | 99 | gchar *name; |
120 | 111 | gchar *name; | 100 | gchar *uid; |
121 | 112 | gchar *parent; | 101 | gint n_count; |
122 | 113 | gchar *last_parent; | 102 | } MessagingMailAccount; |
123 | 114 | 103 | MessagingMailAccount * find_account_for_uid(GSList*, const gchar*); | |
124 | 115 | gint reap_type; | 104 | static MessagingMailAccount * ensure_account_for_uid(const gchar*); |
97 | 116 | |||
98 | 117 | gboolean enabled; | ||
99 | 118 | |||
100 | 119 | } ParserData; | ||
101 | 120 | |||
102 | 121 | enum { | ||
103 | 122 | REAP_NONE = 0, | ||
104 | 123 | REAP_URL, | ||
105 | 124 | REAP_NAME | ||
106 | 125 | }; | ||
107 | 126 | |||
108 | 127 | static GtkWidget * | ||
109 | 128 | get_cfg_widget (void) | ||
110 | 129 | { | ||
111 | 130 | GtkWidget *vbox; | ||
112 | 131 | |||
113 | 132 | vbox = gtk_vbox_new (FALSE, 6); | ||
114 | 133 | |||
115 | 134 | gtk_widget_show (vbox); | ||
116 | 135 | |||
117 | 136 | return vbox; | ||
118 | 137 | } | ||
125 | 138 | 105 | ||
126 | 139 | static gboolean | 106 | static gboolean |
127 | 140 | evolution_is_focused (void) | 107 | evolution_is_focused (void) |
128 | @@ -195,95 +162,57 @@ | |||
129 | 195 | return FALSE; | 162 | return FALSE; |
130 | 196 | } | 163 | } |
131 | 197 | 164 | ||
132 | 198 | static gint | ||
133 | 199 | get_indicator_unread_count (IndicateIndicator *indicator) | ||
134 | 200 | { | ||
135 | 201 | return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (indicator), | ||
136 | 202 | UNREAD_DATA)); | ||
137 | 203 | } | ||
138 | 204 | |||
139 | 205 | static void | ||
140 | 206 | set_indicator_unread_count (IndicateIndicator *indicator, gint count) | ||
141 | 207 | { | ||
142 | 208 | gchar *count_str; | ||
143 | 209 | |||
144 | 210 | count_str = g_strdup_printf ("%d", count); | ||
145 | 211 | indicate_indicator_set_property (indicator, | ||
146 | 212 | INDICATE_INDICATOR_MESSAGES_PROP_COUNT, | ||
147 | 213 | count_str); | ||
148 | 214 | g_object_set_data (G_OBJECT (indicator), | ||
149 | 215 | UNREAD_DATA, | ||
150 | 216 | GINT_TO_POINTER (count)); | ||
151 | 217 | |||
152 | 218 | g_free (count_str); | ||
153 | 219 | } | ||
154 | 220 | |||
155 | 221 | void | 165 | void |
156 | 222 | org_gnome_mail_new_notify (EPlugin *ep, EMEventTargetFolder *t) | 166 | org_gnome_mail_new_notify (EPlugin *ep, EMEventTargetFolder *t) |
157 | 223 | { | 167 | { |
160 | 224 | gchar *url; | 168 | MessagingMailAccount *account; |
161 | 225 | CamelURL *service_url; | 169 | const gchar *uid; |
162 | 226 | 170 | ||
163 | 227 | g_return_if_fail (t != NULL); | 171 | g_return_if_fail (t != NULL); |
164 | 228 | 172 | ||
168 | 229 | service_url = camel_service_new_camel_url (CAMEL_SERVICE (t->store)); | 173 | uid = camel_service_get_uid (CAMEL_SERVICE (t->store)); |
166 | 230 | url = camel_url_to_string (service_url, 0); | ||
167 | 231 | camel_url_free (service_url); | ||
169 | 232 | 174 | ||
170 | 233 | if (!t->new) | 175 | if (!t->new) |
172 | 234 | return; | 176 | return; |
173 | 235 | 177 | ||
174 | 236 | if (only_inbox && !(t->is_inbox)) | 178 | if (only_inbox && !(t->is_inbox)) |
175 | 237 | { | 179 | { |
177 | 238 | g_debug ("EI: %s is not an inbox", url); | 180 | g_debug ("EI: %s is not an inbox", t->folder_name); |
178 | 239 | return; | 181 | return; |
179 | 240 | } | 182 | } |
180 | 241 | 183 | ||
181 | 242 | if (evolution_is_focused ()) | 184 | if (evolution_is_focused ()) |
183 | 243 | { | 185 | { |
184 | 244 | g_debug ("EI: Evolution is focused"); | 186 | g_debug ("EI: Evolution is focused"); |
185 | 245 | return; | 187 | return; |
186 | 246 | } | 188 | } |
187 | 247 | 189 | ||
206 | 248 | g_static_mutex_lock (&mlock); | 190 | g_mutex_lock (&mlock); |
207 | 249 | 191 | ||
208 | 250 | g_debug ("EI:mail_new_notify: %s", url); | 192 | g_debug ("EI:mail_new_notify: %s/%s", uid, t->folder_name); |
209 | 251 | 193 | ||
210 | 252 | message_count += t->new; | 194 | account = ensure_account_for_uid (uid); |
211 | 253 | 195 | if(account) { | |
212 | 254 | if (show_count) | 196 | account->n_count += t->new; |
213 | 255 | { | 197 | message_count += t->new; |
214 | 256 | IndicateIndicator *indicator = NULL; | 198 | |
215 | 257 | GSList *i; | 199 | if (show_count) |
216 | 258 | 200 | { | |
217 | 259 | for (i = indicators; i; i = i->next) | 201 | if (messaging_menu_app_has_source(MESSAGING_MENU_APP (mmapp), uid)) |
200 | 260 | { | ||
201 | 261 | IndicateIndicator *indi = i->data; | ||
202 | 262 | |||
203 | 263 | if (g_strstr_len (url, | ||
204 | 264 | -1, | ||
205 | 265 | indicate_indicator_get_property (indi, "url"))) | ||
218 | 266 | { | 202 | { |
229 | 267 | indicator = indi; | 203 | messaging_menu_app_set_source_count (MESSAGING_MENU_APP (mmapp), uid, account->n_count); |
230 | 268 | break; | 204 | } |
231 | 269 | } | 205 | else { |
232 | 270 | } | 206 | gchar *name = account->name; |
233 | 271 | if (indicator) | 207 | messaging_menu_app_append_source_with_count (MESSAGING_MENU_APP (mmapp), uid, NULL, name, account->n_count); |
234 | 272 | { | 208 | } |
235 | 273 | gint count; | 209 | messaging_menu_app_draw_attention (MESSAGING_MENU_APP (mmapp), uid); |
236 | 274 | 210 | } | |
227 | 275 | count = get_indicator_unread_count (indicator); | ||
228 | 276 | set_indicator_unread_count (indicator, count + t->new); | ||
237 | 277 | 211 | ||
247 | 278 | indicate_indicator_set_property (indicator, | 212 | } |
248 | 279 | INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, | 213 | else { |
249 | 280 | "true"); | 214 | g_warning ("EI: Unable to find account that matches %s", uid); |
250 | 281 | } | 215 | } |
242 | 282 | else | ||
243 | 283 | { | ||
244 | 284 | g_warning ("EI: Unable to find account that matches %s", url); | ||
245 | 285 | } | ||
246 | 286 | } | ||
251 | 287 | 216 | ||
252 | 288 | update_unity_launcher_count (); | 217 | update_unity_launcher_count (); |
253 | 289 | 218 | ||
254 | @@ -340,59 +269,47 @@ | |||
255 | 340 | g_warning ("EI: Unable to play sound: %s\n", ca_strerror (ret)); | 269 | g_warning ("EI: Unable to play sound: %s\n", ca_strerror (ret)); |
256 | 341 | } | 270 | } |
257 | 342 | 271 | ||
259 | 343 | g_static_mutex_unlock (&mlock); | 272 | g_mutex_unlock (&mlock); |
260 | 344 | } | 273 | } |
261 | 345 | 274 | ||
262 | 346 | void | 275 | void |
263 | 347 | org_gnome_mail_read_notify (EPlugin *ep, EMEventTargetMessage *t) | 276 | org_gnome_mail_read_notify (EPlugin *ep, EMEventTargetMessage *t) |
264 | 348 | { | 277 | { |
265 | 278 | MessagingMailAccount *account; | ||
266 | 279 | const gchar *uid; | ||
267 | 280 | |||
268 | 349 | g_return_if_fail (t != NULL); | 281 | g_return_if_fail (t != NULL); |
269 | 350 | 282 | ||
271 | 351 | GSList *i; | 283 | uid = camel_service_get_uid (CAMEL_SERVICE (camel_folder_get_parent_store (t->folder))); |
272 | 352 | 284 | ||
274 | 353 | g_static_mutex_lock (&mlock); | 285 | g_mutex_lock (&mlock); |
275 | 354 | 286 | ||
276 | 355 | g_debug ("EI: mail_read_notify"); | 287 | g_debug ("EI: mail_read_notify"); |
277 | 356 | 288 | ||
292 | 357 | for (i = indicators; i; i = i->next) | 289 | account = ensure_account_for_uid (uid); |
293 | 358 | { | 290 | if(account) |
294 | 359 | IndicateIndicator *indicator = i->data; | 291 | { |
295 | 360 | 292 | messaging_menu_app_remove_source (MESSAGING_MENU_APP (mmapp), uid); | |
296 | 361 | set_indicator_unread_count (indicator, 0); | 293 | message_count -= account->n_count; |
297 | 362 | indicate_indicator_set_property (indicator, | 294 | account->n_count = 0; |
298 | 363 | INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, | 295 | g_debug ("EI: Setting %s to 0 unread messages", uid); |
299 | 364 | "false"); | 296 | } |
300 | 365 | 297 | else { | |
301 | 366 | g_debug ("EI: Setting %s to 0 unread messages", | 298 | g_warning ("EI: Unable to find account that matches %s", uid); |
302 | 367 | indicate_indicator_get_property (indicator, "name")); | 299 | } |
289 | 368 | |||
290 | 369 | } | ||
291 | 370 | message_count = 0; | ||
303 | 371 | 300 | ||
304 | 372 | update_unity_launcher_count (); | 301 | update_unity_launcher_count (); |
305 | 373 | 302 | ||
307 | 374 | g_static_mutex_unlock (&mlock); | 303 | g_mutex_unlock (&mlock); |
308 | 375 | } | 304 | } |
309 | 376 | 305 | ||
310 | 377 | void | 306 | void |
311 | 378 | update_unity_launcher_count () | 307 | update_unity_launcher_count () |
312 | 379 | { | 308 | { |
313 | 380 | GSList *i; | ||
314 | 381 | int count = 0; | ||
315 | 382 | |||
316 | 383 | g_debug ("EI: update_unity_launcher_count"); | 309 | g_debug ("EI: update_unity_launcher_count"); |
317 | 384 | 310 | ||
329 | 385 | for (i = indicators; i; i = i->next) | 311 | unity_launcher_entry_set_count (launcher, message_count); |
330 | 386 | { | 312 | if (message_count > 0) |
320 | 387 | IndicateIndicator *indicator = i->data; | ||
321 | 388 | |||
322 | 389 | count = count + get_indicator_unread_count (indicator); | ||
323 | 390 | |||
324 | 391 | g_debug ("EI: Setting count to %d unread messages", count); | ||
325 | 392 | |||
326 | 393 | } | ||
327 | 394 | unity_launcher_entry_set_count (launcher, count); | ||
328 | 395 | if (count > 0) | ||
331 | 396 | { | 313 | { |
332 | 397 | unity_launcher_entry_set_count_visible (launcher, TRUE); | 314 | unity_launcher_entry_set_count_visible (launcher, TRUE); |
333 | 398 | } else { | 315 | } else { |
334 | @@ -444,17 +361,11 @@ | |||
335 | 444 | value = entry->value; | 361 | value = entry->value; |
336 | 445 | 362 | ||
337 | 446 | show_count = gconf_value_get_bool (value); | 363 | show_count = gconf_value_get_bool (value); |
339 | 447 | 364 | ||
340 | 448 | if (show_count) | 365 | if (show_count) |
345 | 449 | { | 366 | messaging_menu_app_register (mmapp); |
342 | 450 | indicate_server_show (server); | ||
343 | 451 | show_evolution_in_indicator_applet (); | ||
344 | 452 | } | ||
346 | 453 | else | 367 | else |
351 | 454 | { | 368 | messaging_menu_app_unregister (mmapp); |
348 | 455 | indicate_server_hide (server); | ||
349 | 456 | hide_evolution_in_indicator_applet (); | ||
350 | 457 | } | ||
352 | 458 | 369 | ||
353 | 459 | g_debug ("EI: Messages in panel %s", | 370 | g_debug ("EI: Messages in panel %s", |
354 | 460 | show_count ? "true" : "false"); | 371 | show_count ? "true" : "false"); |
355 | @@ -475,246 +386,103 @@ | |||
356 | 475 | g_debug ("EI: Show Bubbles %s", show_bubble ? "true" : "false"); | 386 | g_debug ("EI: Show Bubbles %s", show_bubble ? "true" : "false"); |
357 | 476 | } | 387 | } |
358 | 477 | 388 | ||
361 | 478 | static IndicateIndicator * | 389 | MessagingMailAccount * |
362 | 479 | find_indicator_for_url (GSList *indicator_list, const gchar *url) | 390 | find_account_for_uid (GSList *accounts_list, const gchar *uid) |
363 | 480 | { | 391 | { |
364 | 481 | GSList *i; | 392 | GSList *i; |
365 | 482 | 393 | ||
367 | 483 | for (i = indicator_list; i; i = i->next) | 394 | for (i = accounts_list; i; i = i->next) |
368 | 484 | { | 395 | { |
370 | 485 | IndicateIndicator *indicator = i->data; | 396 | MessagingMailAccount *a = i->data; |
371 | 486 | 397 | ||
373 | 487 | if (g_strcmp0 (indicate_indicator_get_property (indicator, "url"), url) | 398 | if (g_strcmp0 (a->uid, uid) |
374 | 488 | == 0) | 399 | == 0) |
376 | 489 | return indicator; | 400 | return a; |
377 | 490 | } | 401 | } |
378 | 491 | return NULL; | 402 | return NULL; |
379 | 492 | } | 403 | } |
380 | 493 | 404 | ||
383 | 494 | static IndicateIndicator * | 405 | void |
384 | 495 | create_indicator (const gchar *url, const gchar *name) | 406 | unref_account(MessagingMailAccount *m) |
385 | 496 | { | 407 | { |
405 | 497 | IndicateIndicator *indicator; | 408 | g_free(m->name); |
406 | 498 | 409 | g_free(m->uid); | |
407 | 499 | indicator = indicate_indicator_new (); | 410 | g_free(m); |
389 | 500 | indicate_indicator_set_property (indicator, | ||
390 | 501 | INDICATE_INDICATOR_MESSAGES_PROP_NAME, | ||
391 | 502 | name); | ||
392 | 503 | indicate_indicator_set_property (indicator, | ||
393 | 504 | "url", | ||
394 | 505 | url); | ||
395 | 506 | set_indicator_unread_count (indicator, 0); | ||
396 | 507 | indicate_indicator_show (indicator); | ||
397 | 508 | |||
398 | 509 | /* FIXME: I need to find a way to show a mailbox individually */ | ||
399 | 510 | g_signal_connect (indicator, "user-display", | ||
400 | 511 | G_CALLBACK (show_evolution), NULL); | ||
401 | 512 | |||
402 | 513 | g_debug ("EI: New Indicator: %s %s", name, url); | ||
403 | 514 | |||
404 | 515 | return indicator; | ||
408 | 516 | } | 411 | } |
409 | 517 | 412 | ||
417 | 518 | static void | 413 | static ESource * |
418 | 519 | start_element_handler (GMarkupParseContext *context, | 414 | mail_source_from_uid (const gchar *uid) |
412 | 520 | const gchar *element_name, | ||
413 | 521 | const gchar **attribute_names, | ||
414 | 522 | const gchar **attribute_values, | ||
415 | 523 | gpointer user_data, | ||
416 | 524 | GError **error) | ||
419 | 525 | { | 415 | { |
427 | 526 | ParserData *data = (ParserData *)user_data; | 416 | ESourceRegistry *registry; |
428 | 527 | 417 | GError *error = NULL; | |
429 | 528 | if (g_strcmp0 (element_name, "account") == 0) | 418 | GList *sources; |
430 | 529 | { | 419 | GList *it; |
431 | 530 | gint i = 0; | 420 | ESource *source = NULL; |
432 | 531 | 421 | ||
433 | 532 | while (attribute_names[i] != NULL) | 422 | registry = e_source_registry_new_sync (NULL, &error); |
434 | 423 | if (!registry) | ||
435 | 424 | { | ||
436 | 425 | g_warning ("Failed to get access to source registry: %s\n", error->message); | ||
437 | 426 | g_error_free (error); | ||
438 | 427 | return NULL; | ||
439 | 428 | } | ||
440 | 429 | |||
441 | 430 | sources = e_source_registry_list_sources (registry, E_SOURCE_EXTENSION_MAIL_ACCOUNT); | ||
442 | 431 | for (it = sources; it; it = it->next) | ||
443 | 432 | { | ||
444 | 433 | if (g_str_equal (uid, e_source_get_uid (it->data))) | ||
445 | 533 | { | 434 | { |
456 | 534 | if (g_strcmp0 (attribute_names[i], "name") == 0) | 435 | source = g_object_ref (it->data); |
457 | 535 | { | 436 | break; |
448 | 536 | data->name = g_strdup (attribute_values[i]); | ||
449 | 537 | } | ||
450 | 538 | else if (g_strcmp0 (attribute_names[i], "enabled") == 0) | ||
451 | 539 | { | ||
452 | 540 | if (g_strcmp0 (attribute_values[i], "false") == 0) | ||
453 | 541 | data->enabled = FALSE; | ||
454 | 542 | } | ||
455 | 543 | i++; | ||
458 | 544 | } | 437 | } |
459 | 545 | } | 438 | } |
541 | 546 | else if (g_strcmp0 (element_name, "url") == 0) | 439 | |
542 | 547 | data->reap_type = REAP_URL; | 440 | g_list_free_full (sources, g_object_unref); |
543 | 548 | else | 441 | g_object_unref (registry); |
544 | 549 | data->reap_type = REAP_NONE; | 442 | return source; |
545 | 550 | 443 | } | |
546 | 551 | if (data->last_parent) | 444 | |
547 | 552 | g_free (data->last_parent); | 445 | static MessagingMailAccount * |
548 | 553 | 446 | ensure_account_for_uid (const gchar *uid) | |
549 | 554 | data->last_parent = data->parent; | 447 | { |
550 | 555 | data->parent = g_strdup (element_name); | 448 | MessagingMailAccount *account; |
551 | 556 | } | 449 | ESource *source; |
552 | 557 | 450 | ||
553 | 558 | static void | 451 | if ((account = find_account_for_uid (accounts, uid))) |
554 | 559 | text_handler (GMarkupParseContext *context, | 452 | return account; |
555 | 560 | const gchar *text, | 453 | |
556 | 561 | gsize text_len, | 454 | if ((source = mail_source_from_uid (uid))) |
557 | 562 | gpointer user_data, | 455 | { |
558 | 563 | GError **error) | 456 | if (e_source_get_removable(source) && e_source_get_enabled(source)) |
478 | 564 | { | ||
479 | 565 | ParserData *data = (ParserData *)user_data; | ||
480 | 566 | |||
481 | 567 | if (!data->url | ||
482 | 568 | && data->reap_type == REAP_URL | ||
483 | 569 | && g_strcmp0(data->last_parent, "source") == 0) | ||
484 | 570 | { | ||
485 | 571 | gchar **tokens; | ||
486 | 572 | |||
487 | 573 | tokens = g_strsplit (text, ";", 2); | ||
488 | 574 | |||
489 | 575 | data->url = g_strdup (tokens[0]); | ||
490 | 576 | |||
491 | 577 | /* Accounts with no configured way to receive mail will not have a URL */ | ||
492 | 578 | if (!data->url) | ||
493 | 579 | data->enabled = FALSE; | ||
494 | 580 | |||
495 | 581 | g_strfreev (tokens); | ||
496 | 582 | } | ||
497 | 583 | } | ||
498 | 584 | |||
499 | 585 | static void | ||
500 | 586 | update_accounts (void) | ||
501 | 587 | { | ||
502 | 588 | GSList *accounts; | ||
503 | 589 | GError *error = NULL; | ||
504 | 590 | gint i = 1; | ||
505 | 591 | GTimeVal timeval = { 0 }; | ||
506 | 592 | |||
507 | 593 | g_get_current_time (&timeval); | ||
508 | 594 | accounts = gconf_client_get_list (client, | ||
509 | 595 | ACCOUNTS, | ||
510 | 596 | GCONF_VALUE_STRING, | ||
511 | 597 | &error); | ||
512 | 598 | if (accounts == NULL || error) | ||
513 | 599 | { | ||
514 | 600 | g_warning ("EI: Unable to determine number of accounts, " | ||
515 | 601 | "defaulting to '1' (%s)", | ||
516 | 602 | error ? error->message : "unknown"); | ||
517 | 603 | if (error) | ||
518 | 604 | g_error_free (error); | ||
519 | 605 | |||
520 | 606 | /* We could have this as 0 too, as it won't effect anything. It just | ||
521 | 607 | * seems to make more sense to have it default at 1 | ||
522 | 608 | */ | ||
523 | 609 | n_accounts = 1; | ||
524 | 610 | } | ||
525 | 611 | else | ||
526 | 612 | { | ||
527 | 613 | GSList *old_list; | ||
528 | 614 | GSList *a; | ||
529 | 615 | static GMarkupParser parser = { | ||
530 | 616 | start_element_handler, | ||
531 | 617 | NULL, | ||
532 | 618 | text_handler, | ||
533 | 619 | NULL, | ||
534 | 620 | NULL | ||
535 | 621 | }; | ||
536 | 622 | |||
537 | 623 | old_list = indicators; | ||
538 | 624 | indicators = NULL; | ||
539 | 625 | |||
540 | 626 | for (a = accounts; a; a = a->next) | ||
559 | 627 | { | 457 | { |
579 | 628 | gchar *account_info = a->data; | 458 | ESourceExtension *extension; |
580 | 629 | GMarkupParseContext *context; | 459 | const gchar *protocol; |
581 | 630 | ParserData data = { NULL, NULL, NULL, NULL, 0, TRUE }; | 460 | |
582 | 631 | IndicateIndicator *indicator; | 461 | extension = e_source_get_extension (source, E_SOURCE_EXTENSION_MAIL_ACCOUNT); |
583 | 632 | 462 | protocol = e_source_backend_get_backend_name (E_SOURCE_BACKEND (extension)); | |
584 | 633 | /* Parse account XML to get some useful details about the account */ | 463 | |
585 | 634 | context = g_markup_parse_context_new (&parser, 0, &data, NULL); | 464 | account = g_new(MessagingMailAccount, 1); |
586 | 635 | g_markup_parse_context_parse (context, | 465 | account->uid = g_strdup (uid); |
587 | 636 | account_info, | 466 | account->n_count = 0; |
588 | 637 | strlen (account_info), | 467 | |
589 | 638 | NULL); | 468 | if (g_str_has_prefix (protocol, "pop")) |
590 | 639 | 469 | account->name = g_strdup (g_dgettext (EVO_I18N_DOMAIN, "Inbox")); | |
572 | 640 | /* Check to see account already exists and, if not, create it */ | ||
573 | 641 | indicator = find_indicator_for_url (indicators, data.url); | ||
574 | 642 | if (indicator) | ||
575 | 643 | { | ||
576 | 644 | old_list = g_slist_remove (old_list, indicator); | ||
577 | 645 | indicators = g_slist_append (indicators, indicator); | ||
578 | 646 | } | ||
591 | 647 | else | 470 | else |
628 | 648 | { | 471 | account->name = e_source_dup_display_name (source); |
629 | 649 | if (data.url && g_str_has_prefix (data.url, "pop:")) | 472 | |
630 | 650 | { | 473 | accounts = g_slist_append (accounts, account); |
631 | 651 | indicator = create_indicator ("pop:", | 474 | g_debug ("EI: New account: %s (%s)", account->name, account->uid); |
596 | 652 | g_dgettext (EVO_I18N_DOMAIN, | ||
597 | 653 | "Inbox")); | ||
598 | 654 | } | ||
599 | 655 | else | ||
600 | 656 | { | ||
601 | 657 | indicator = create_indicator (data.url, data.name); | ||
602 | 658 | } | ||
603 | 659 | indicators = g_slist_append (indicators, indicator); | ||
604 | 660 | |||
605 | 661 | g_debug ("EI: New account: %s (%s)", data.name, data.url); | ||
606 | 662 | } | ||
607 | 663 | |||
608 | 664 | if (!data.enabled) | ||
609 | 665 | indicate_indicator_hide (indicator); | ||
610 | 666 | |||
611 | 667 | /* Fake a time */ | ||
612 | 668 | g_time_val_add (&timeval, -1000000 * 60 * i); | ||
613 | 669 | indicate_indicator_set_property_time (indicator, | ||
614 | 670 | INDICATE_INDICATOR_MESSAGES_PROP_TIME, | ||
615 | 671 | &timeval); | ||
616 | 672 | |||
617 | 673 | i++; | ||
618 | 674 | |||
619 | 675 | /* Clean up */ | ||
620 | 676 | g_free (data.url); | ||
621 | 677 | g_free (data.name); | ||
622 | 678 | g_free (data.parent); | ||
623 | 679 | g_free (data.last_parent); | ||
624 | 680 | data.reap_type = REAP_NONE; | ||
625 | 681 | data.enabled = TRUE; | ||
626 | 682 | |||
627 | 683 | g_markup_parse_context_free (context); | ||
632 | 684 | } | 475 | } |
633 | 685 | 476 | ||
639 | 686 | g_slist_foreach (old_list, (GFunc)g_object_unref, NULL); | 477 | g_object_unref (source); |
635 | 687 | g_slist_free (old_list); | ||
636 | 688 | |||
637 | 689 | n_accounts = g_slist_length (accounts); | ||
638 | 690 | g_slist_free (accounts); | ||
640 | 691 | } | 478 | } |
641 | 692 | 479 | ||
652 | 693 | g_debug ("EI: Number of email accounts: %d", n_accounts); | 480 | return account; |
643 | 694 | } | ||
644 | 695 | |||
645 | 696 | static void | ||
646 | 697 | on_accounts_changed (GConfClient *gclient, | ||
647 | 698 | guint id, | ||
648 | 699 | GConfEntry *entry, | ||
649 | 700 | gpointer data) | ||
650 | 701 | { | ||
651 | 702 | update_accounts (); | ||
653 | 703 | } | 481 | } |
654 | 704 | 482 | ||
655 | 705 | #define EVO_CONTACTS_CMD "evolution -c contacts" | 483 | #define EVO_CONTACTS_CMD "evolution -c contacts" |
656 | 706 | #define EVO_COMPOSE_CMD "evolution mailto:" | 484 | #define EVO_COMPOSE_CMD "evolution mailto:" |
657 | 707 | 485 | ||
658 | 708 | static void | ||
659 | 709 | command_item_activate (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) | ||
660 | 710 | { | ||
661 | 711 | gchar * command = (gchar *)user_data; | ||
662 | 712 | if (!g_spawn_command_line_async(command, NULL)) { | ||
663 | 713 | g_warning("EI: Unable to execute command '%s'", command); | ||
664 | 714 | } | ||
665 | 715 | return; | ||
666 | 716 | } | ||
667 | 717 | |||
668 | 718 | int | 486 | int |
669 | 719 | e_plugin_lib_enable (EPlugin *ep, int enable) | 487 | e_plugin_lib_enable (EPlugin *ep, int enable) |
670 | 720 | { | 488 | { |
671 | @@ -748,27 +516,10 @@ | |||
672 | 748 | } | 516 | } |
673 | 749 | } | 517 | } |
674 | 750 | 518 | ||
696 | 751 | server = indicate_server_ref_default (); | 519 | if (mmapp == NULL) |
697 | 752 | indicate_server_set_type (server, "message"); | 520 | mmapp = messaging_menu_app_new ("evolution.desktop"); |
698 | 753 | indicate_server_set_desktop_file (server, EVOLUTION_DESKTOP_FILE); | 521 | |
699 | 754 | g_signal_connect (server, "server-display", | 522 | g_signal_connect (mmapp, "activate-source", G_CALLBACK (show_evolution), NULL); |
679 | 755 | G_CALLBACK (show_evolution), NULL); | ||
680 | 756 | |||
681 | 757 | DbusmenuServer * menu_server = dbusmenu_server_new("/messaging/commands"); | ||
682 | 758 | DbusmenuMenuitem * root = dbusmenu_menuitem_new(); | ||
683 | 759 | |||
684 | 760 | DbusmenuMenuitem * mi = dbusmenu_menuitem_new(); | ||
685 | 761 | dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Compose New Message")); | ||
686 | 762 | g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(command_item_activate), EVO_COMPOSE_CMD); | ||
687 | 763 | dbusmenu_menuitem_child_append(root, mi); | ||
688 | 764 | |||
689 | 765 | mi = dbusmenu_menuitem_new(); | ||
690 | 766 | dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Contacts")); | ||
691 | 767 | g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(command_item_activate), EVO_CONTACTS_CMD); | ||
692 | 768 | dbusmenu_menuitem_child_append(root, mi); | ||
693 | 769 | |||
694 | 770 | dbusmenu_server_set_root(menu_server, root); | ||
695 | 771 | indicate_server_set_menu(server, menu_server); | ||
700 | 772 | 523 | ||
701 | 773 | launcher = unity_launcher_entry_get_for_desktop_file (EVOLUTION_DESKTOP_FILE); | 524 | launcher = unity_launcher_entry_get_for_desktop_file (EVOLUTION_DESKTOP_FILE); |
702 | 774 | 525 | ||
703 | @@ -797,22 +548,10 @@ | |||
704 | 797 | show_count_id = gconf_client_notify_add (client, SHOW_NEW_IN_PANEL, | 548 | show_count_id = gconf_client_notify_add (client, SHOW_NEW_IN_PANEL, |
705 | 798 | show_new_in_panel_changed, NULL, NULL, NULL); | 549 | show_new_in_panel_changed, NULL, NULL, NULL); |
706 | 799 | 550 | ||
707 | 800 | gconf_client_add_dir (client, ACCOUNT_DIR,GCONF_CLIENT_PRELOAD_NONE, NULL); | ||
708 | 801 | update_accounts (); | ||
709 | 802 | accounts_id = gconf_client_notify_add (client, ACCOUNTS, | ||
710 | 803 | on_accounts_changed, NULL, | ||
711 | 804 | NULL, NULL); | ||
712 | 805 | |||
713 | 806 | if (show_count) | 551 | if (show_count) |
718 | 807 | { | 552 | messaging_menu_app_register (mmapp); |
715 | 808 | indicate_server_show (server); | ||
716 | 809 | show_evolution_in_indicator_applet (); | ||
717 | 810 | } | ||
719 | 811 | else | 553 | else |
724 | 812 | { | 554 | messaging_menu_app_unregister (mmapp); |
721 | 813 | indicate_server_hide (server); | ||
722 | 814 | hide_evolution_in_indicator_applet (); | ||
723 | 815 | } | ||
725 | 816 | } | 555 | } |
726 | 817 | else | 556 | else |
727 | 818 | { | 557 | { |
728 | @@ -820,35 +559,28 @@ | |||
729 | 820 | gconf_client_notify_remove (client, play_sound_id); | 559 | gconf_client_notify_remove (client, play_sound_id); |
730 | 821 | gconf_client_notify_remove (client, show_bubble_id); | 560 | gconf_client_notify_remove (client, show_bubble_id); |
731 | 822 | gconf_client_notify_remove (client, show_count_id); | 561 | gconf_client_notify_remove (client, show_count_id); |
732 | 823 | gconf_client_notify_remove (client, accounts_id); | ||
733 | 824 | 562 | ||
734 | 825 | g_object_unref (client); | 563 | g_object_unref (client); |
735 | 826 | client = NULL; | 564 | client = NULL; |
737 | 827 | 565 | ||
738 | 828 | /* Free indicators */ | 566 | /* Free indicators */ |
751 | 829 | g_slist_foreach (indicators, (GFunc)g_object_unref, NULL); | 567 | g_slist_foreach (accounts, (GFunc)unref_account, NULL); |
752 | 830 | g_slist_free (indicators); | 568 | g_slist_free (accounts); |
753 | 831 | indicators = NULL; | 569 | accounts = NULL; |
754 | 832 | 570 | ||
755 | 833 | /* Free server */ | 571 | messaging_menu_app_unregister (mmapp); |
756 | 834 | indicate_server_hide (server); | 572 | |
745 | 835 | g_object_unref (server); | ||
746 | 836 | server = NULL; | ||
747 | 837 | |||
748 | 838 | /* Remove evolution from indicator menu */ | ||
749 | 839 | hide_evolution_in_indicator_applet (); | ||
750 | 840 | |||
757 | 841 | g_debug ("EI: Disabled"); | 573 | g_debug ("EI: Disabled"); |
758 | 842 | } | 574 | } |
759 | 843 | 575 | ||
761 | 844 | return 0; | 576 | return 0; |
762 | 845 | } | 577 | } |
763 | 846 | 578 | ||
764 | 847 | GtkWidget * | 579 | GtkWidget * |
765 | 848 | e_plugin_lib_get_configure_widget (EPlugin *ep) | 580 | e_plugin_lib_get_configure_widget (EPlugin *ep) |
766 | 849 | { | 581 | { |
767 | 850 | g_debug ("EI: Get Configure Widget"); | 582 | g_debug ("EI: Get Configure Widget"); |
769 | 851 | return get_cfg_widget (); | 583 | return NULL; |
770 | 852 | } | 584 | } |
771 | 853 | 585 | ||
772 | 854 | static void | 586 | static void |
773 | @@ -911,7 +643,7 @@ | |||
774 | 911 | 643 | ||
775 | 912 | gtk_box_reorder_child (GTK_BOX (gtk_widget_get_parent (frame)), frame, 0); | 644 | gtk_box_reorder_child (GTK_BOX (gtk_widget_get_parent (frame)), frame, 0); |
776 | 913 | 645 | ||
778 | 914 | box = gtk_hbox_new (FALSE, 0); | 646 | box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); |
779 | 915 | gtk_frame_set_label_widget (GTK_FRAME (frame), box); | 647 | gtk_frame_set_label_widget (GTK_FRAME (frame), box); |
780 | 916 | gtk_widget_show (frame); | 648 | gtk_widget_show (frame); |
781 | 917 | 649 | ||
782 | @@ -925,12 +657,12 @@ | |||
783 | 925 | #if GTK_CHECK_VERSION(2, 91, 0) | 657 | #if GTK_CHECK_VERSION(2, 91, 0) |
784 | 926 | combo = gtk_combo_box_text_new (); | 658 | combo = gtk_combo_box_text_new (); |
785 | 927 | gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), | 659 | gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), |
787 | 928 | n_accounts > 1 ? _("any Inbox") : _("Inbox")); | 660 | g_slist_length (accounts) > 1 ? _("any Inbox") : _("Inbox")); |
788 | 929 | gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("any Folder")); | 661 | gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("any Folder")); |
789 | 930 | #else | 662 | #else |
790 | 931 | combo = gtk_combo_box_new_text (); | 663 | combo = gtk_combo_box_new_text (); |
791 | 932 | gtk_combo_box_append_text (GTK_COMBO_BOX (combo), | 664 | gtk_combo_box_append_text (GTK_COMBO_BOX (combo), |
793 | 933 | n_accounts > 1 ? _("any Inbox") : _("Inbox")); | 665 | g_slist_length (accounts) > 1 ? _("any Inbox") : _("Inbox")); |
794 | 934 | gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("any Folder")); | 666 | gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("any Folder")); |
795 | 935 | #endif | 667 | #endif |
796 | 936 | gtk_combo_box_set_active (GTK_COMBO_BOX (combo), | 668 | gtk_combo_box_set_active (GTK_COMBO_BOX (combo), |
797 | @@ -965,7 +697,7 @@ | |||
798 | 965 | g_debug ("EI: Woops, couldn't find the GtkFrame in the widget hierarchy"); | 697 | g_debug ("EI: Woops, couldn't find the GtkFrame in the widget hierarchy"); |
799 | 966 | } | 698 | } |
800 | 967 | 699 | ||
802 | 968 | vbox = gtk_vbox_new (FALSE, 8); | 700 | vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8); |
803 | 969 | gtk_table_attach((GtkTable *)data->parent, vbox, 0, 1, 0, 1, 0, 0, 0, 0); | 701 | gtk_table_attach((GtkTable *)data->parent, vbox, 0, 1, 0, 1, 0, 0, 0, 0); |
804 | 970 | 702 | ||
805 | 971 | check = gtk_check_button_new_with_mnemonic (_("Pla_y a sound")); | 703 | check = gtk_check_button_new_with_mnemonic (_("Pla_y a sound")); |
806 | @@ -995,7 +727,7 @@ | |||
807 | 995 | */ | 727 | */ |
808 | 996 | 728 | ||
809 | 997 | static void | 729 | static void |
811 | 998 | show_evolution (gpointer arg0, guint timestamp, gpointer arg1) | 730 | show_evolution (MessagingMenuApp *mmapp, const gchar *uid, gpointer user_data) |
812 | 999 | { | 731 | { |
813 | 1000 | #define MAIL_ICON "evolution-mail" | 732 | #define MAIL_ICON "evolution-mail" |
814 | 1001 | EShell *shell = e_shell_get_default (); | 733 | EShell *shell = e_shell_get_default (); |
815 | @@ -1004,7 +736,7 @@ | |||
816 | 1004 | 736 | ||
817 | 1005 | if (shell) | 737 | if (shell) |
818 | 1006 | { | 738 | { |
820 | 1007 | GSList *i; | 739 | MessagingMailAccount *account; |
821 | 1008 | EShellWindow *shell_window; | 740 | EShellWindow *shell_window; |
822 | 1009 | EShellView *shell_view; | 741 | EShellView *shell_view; |
823 | 1010 | GtkAction *action; | 742 | GtkAction *action; |
824 | @@ -1014,7 +746,7 @@ | |||
825 | 1014 | shell_window = E_SHELL_WINDOW (e_shell_get_active_window (shell)); | 746 | shell_window = E_SHELL_WINDOW (e_shell_get_active_window (shell)); |
826 | 1015 | if (!evolution_is_focused ()) | 747 | if (!evolution_is_focused ()) |
827 | 1016 | { | 748 | { |
829 | 1017 | gtk_window_present_with_time (GTK_WINDOW (shell_window), timestamp); | 749 | gtk_window_present (GTK_WINDOW (shell_window)); |
830 | 1018 | } | 750 | } |
831 | 1019 | 751 | ||
832 | 1020 | /* Switch to the mail view. */ | 752 | /* Switch to the mail view. */ |
833 | @@ -1023,20 +755,19 @@ | |||
834 | 1023 | gtk_action_activate (action); | 755 | gtk_action_activate (action); |
835 | 1024 | 756 | ||
836 | 1025 | /* Setup the indicators */ | 757 | /* Setup the indicators */ |
838 | 1026 | for (i = indicators; i; i = i->next) | 758 | account = ensure_account_for_uid (uid); |
839 | 759 | if(account) | ||
840 | 1027 | { | 760 | { |
853 | 1028 | IndicateIndicator *indicator = i->data; | 761 | gchar *uid = account->uid; |
854 | 1029 | 762 | ||
855 | 1030 | set_indicator_unread_count (indicator, 0); | 763 | message_count -= account->n_count; |
856 | 1031 | indicate_indicator_set_property (indicator, | 764 | account->n_count = 0; |
857 | 1032 | INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, | 765 | g_debug ("EI: Setting %s to 0 unread messages", uid); |
858 | 1033 | "false"); | 766 | } |
859 | 1034 | 767 | else { | |
860 | 1035 | g_debug ("EI: Setting %s to 0 unread messages", | 768 | g_warning ("EI: Unable to find account that matches %s", uid); |
861 | 1036 | indicate_indicator_get_property (indicator, "name")); | 769 | } |
862 | 1037 | 770 | ||
851 | 1038 | } | ||
852 | 1039 | message_count = 0; | ||
863 | 1040 | update_unity_launcher_count (); | 771 | update_unity_launcher_count (); |
864 | 1041 | } | 772 | } |
865 | 1042 | else | 773 | else |
866 | @@ -1045,113 +776,3 @@ | |||
867 | 1045 | return; | 776 | return; |
868 | 1046 | } | 777 | } |
869 | 1047 | } | 778 | } |
870 | 1048 | |||
871 | 1049 | |||
872 | 1050 | /* | ||
873 | 1051 | * | ||
874 | 1052 | * SHOW/HIDE EVOLUTION IN INDICATOR APPLET | ||
875 | 1053 | * | ||
876 | 1054 | */ | ||
877 | 1055 | |||
878 | 1056 | static void | ||
879 | 1057 | show_evolution_in_indicator_applet (void) | ||
880 | 1058 | { | ||
881 | 1059 | gchar *bpath; | ||
882 | 1060 | |||
883 | 1061 | bpath = g_build_filename (g_get_user_config_dir (), | ||
884 | 1062 | USER_BLACKLIST_DIR, | ||
885 | 1063 | USER_BLACKLIST_FILENAME, | ||
886 | 1064 | NULL); | ||
887 | 1065 | |||
888 | 1066 | if (g_file_test (bpath, G_FILE_TEST_EXISTS)) | ||
889 | 1067 | { | ||
890 | 1068 | GFile *bfile; | ||
891 | 1069 | |||
892 | 1070 | bfile = g_file_new_for_path (bpath); | ||
893 | 1071 | |||
894 | 1072 | if (bfile) | ||
895 | 1073 | { | ||
896 | 1074 | GError *error = NULL; | ||
897 | 1075 | |||
898 | 1076 | g_file_delete (bfile, NULL, &error); | ||
899 | 1077 | |||
900 | 1078 | if (error) | ||
901 | 1079 | { | ||
902 | 1080 | g_warning ("EI: Unable to remove blacklist file: %s", error->message); | ||
903 | 1081 | g_error_free (error); | ||
904 | 1082 | } | ||
905 | 1083 | |||
906 | 1084 | g_object_unref (bfile); | ||
907 | 1085 | } | ||
908 | 1086 | } | ||
909 | 1087 | |||
910 | 1088 | g_free (bpath); | ||
911 | 1089 | } | ||
912 | 1090 | |||
913 | 1091 | static void | ||
914 | 1092 | hide_evolution_in_indicator_applet (void) | ||
915 | 1093 | { | ||
916 | 1094 | gchar *bdir; | ||
917 | 1095 | gchar *bpath; | ||
918 | 1096 | GError *error = NULL; | ||
919 | 1097 | |||
920 | 1098 | bdir = g_build_filename (g_get_user_config_dir (), | ||
921 | 1099 | USER_BLACKLIST_DIR, | ||
922 | 1100 | NULL); | ||
923 | 1101 | if (!g_file_test (bdir, G_FILE_TEST_IS_DIR)) | ||
924 | 1102 | { | ||
925 | 1103 | GFile *dirfile; | ||
926 | 1104 | |||
927 | 1105 | dirfile = g_file_new_for_path (bdir); | ||
928 | 1106 | if (dirfile) | ||
929 | 1107 | { | ||
930 | 1108 | g_file_make_directory_with_parents (dirfile, | ||
931 | 1109 | NULL, | ||
932 | 1110 | &error); | ||
933 | 1111 | if (error) | ||
934 | 1112 | { | ||
935 | 1113 | g_warning ("EI: Unable to create blacklist directory: %s", | ||
936 | 1114 | error->message); | ||
937 | 1115 | g_error_free (error); | ||
938 | 1116 | g_object_unref (dirfile); | ||
939 | 1117 | g_free (bdir); | ||
940 | 1118 | g_free (bpath); | ||
941 | 1119 | return; | ||
942 | 1120 | } | ||
943 | 1121 | } | ||
944 | 1122 | else | ||
945 | 1123 | { | ||
946 | 1124 | g_warning ("EI: Unable to create blacklist directory: Unable to create " | ||
947 | 1125 | "GFile for path %s", bdir); | ||
948 | 1126 | g_free (bdir); | ||
949 | 1127 | g_free (bpath); | ||
950 | 1128 | return; | ||
951 | 1129 | } | ||
952 | 1130 | |||
953 | 1131 | g_object_unref (dirfile); | ||
954 | 1132 | } | ||
955 | 1133 | g_free (bdir); | ||
956 | 1134 | |||
957 | 1135 | bpath = g_build_filename (g_get_user_config_dir (), | ||
958 | 1136 | USER_BLACKLIST_DIR, | ||
959 | 1137 | USER_BLACKLIST_FILENAME, | ||
960 | 1138 | NULL); | ||
961 | 1139 | |||
962 | 1140 | if (g_file_set_contents (bpath, | ||
963 | 1141 | EVOLUTION_DESKTOP_FILE, | ||
964 | 1142 | -1, | ||
965 | 1143 | &error)) | ||
966 | 1144 | { | ||
967 | 1145 | g_debug ("EI: Successfully wrote blacklist file to %s", bpath); | ||
968 | 1146 | } | ||
969 | 1147 | else | ||
970 | 1148 | { | ||
971 | 1149 | g_debug ("EI: Unable to write blacklist file to %s: %s", | ||
972 | 1150 | bpath, | ||
973 | 1151 | error ? error->message : "Unknown"); | ||
974 | 1152 | if (error) | ||
975 | 1153 | g_error_free (error); | ||
976 | 1154 | } | ||
977 | 1155 | |||
978 | 1156 | g_free (bpath); | ||
979 | 1157 | } | ||
980 | 1158 | 779 | ||
981 | === modified file 'src/org-freedesktop-evolution-indicator.eplug.xml' | |||
982 | --- src/org-freedesktop-evolution-indicator.eplug.xml 2011-07-10 13:45:32 +0000 | |||
983 | +++ src/org-freedesktop-evolution-indicator.eplug.xml 2013-03-21 23:26:20 +0000 | |||
984 | @@ -5,7 +5,8 @@ | |||
985 | 5 | location="@PLUGINDIR@/liborg-freedesktop-evolution-indicator.so" | 5 | location="@PLUGINDIR@/liborg-freedesktop-evolution-indicator.so" |
986 | 6 | id="org.freedesktop.evolution_indicator" | 6 | id="org.freedesktop.evolution_indicator" |
987 | 7 | domain="@GETTEXT_PACKAGE@" | 7 | domain="@GETTEXT_PACKAGE@" |
989 | 8 | _name="Evolution Indicator"> | 8 | _name="Evolution Indicator" |
990 | 9 | load-on-startup="true"> | ||
991 | 9 | 10 | ||
992 | 10 | <_description>Shows new mail count in a message indicator.</_description> | 11 | <_description>Shows new mail count in a message indicator.</_description> |
993 | 11 | <author name="Neil Jagdish Patel" email="neil.patel@canonical.com"/> | 12 | <author name="Neil Jagdish Patel" email="neil.patel@canonical.com"/> |
Seems to me like this would be a perpetuating a regression that we have since evo switched to a source registry: accounts won't be updated when added/removed or changed.
Consider adding the necesary code to watch the source registry signals described at https:/ /developer. gnome.org/ libedataserver/ stable/ ESourceRegistry .html#ESourceRe gistry. signals in place of your TODO at line 688.
Otherwise, looks good :) Since the code itself looks fine and we already have the above regression, I'm approving the merge.