Merge lp:~larsu/evolution-indicator/messaging-menu-fixes into lp:evolution-indicator

Proposed by Lars Karlitski on 2013-03-21
Status: Needs review
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
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre 2013-03-21 Pending
Review via email: mp+154833@code.launchpad.net

This proposal supersedes a proposal from 2013-03-18.

Description of the change

A couple of minor fixes to lp:~twolife/evolution-indicator/eds-3.6_messaging-menu that I found while testing.

To post a comment you must log in.
Mathieu Trudel-Lapierre (cyphermox) wrote : Posted in a previous version of this proposal

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#ESourceRegistry.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.

review: Approve
Lars Karlitski (larsu) wrote :

A couple of more fixes, please see the individual commits. (Sorry for munging everything together like this)

Mathieu, thanks for the pointer. Turns out we don't even need to listen to source changes, because we're only interested in sources that have new emails. r99 adds sources whenever a new mail event arrives.

Mathieu Trudel-Lapierre (cyphermox) wrote :

Does this still need to get merged?

Lars Karlitski (larsu) wrote :

If nobody cared this long then probably not?

Sebastien Bacher (seb128) wrote :

Unsure, but it looks like that or at least part got included in the package, the vcs might be outdated compared to what is in Ubuntu.

Unmerged revisions

103. By Lars Karlitski on 2013-03-21

Use new-style GtkBox constructors

102. By Lars Karlitski on 2013-03-21

Declare update_unity_launcher_count before first use

101. By Lars Karlitski on 2013-03-21

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 on 2013-03-21

Use GMutex instead of the deprecated GStaticMutex

99. By Lars Karlitski on 2013-03-21

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 on 2013-03-21

Remove n_accounts global variable

It gets in the way of the next patch.

97. By Lars Karlitski on 2013-03-21

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 on 2013-03-21

update_accounts: fix memory leak

95. By Lars Karlitski on 2013-03-21

update_accounts: move name and url fetching into separate function

Also removes some unnecessary string allocations and a memory leak.

94. By Lars Karlitski on 2013-03-21

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

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

Subscribers

People subscribed via source and target branches