Merge lp:~indicator-applet-developers/evolution-indicator/blacklist-support into lp:evolution-indicator

Proposed by Neil J. Patel
Status: Merged
Merged at revision: not available
Proposed branch: lp:~indicator-applet-developers/evolution-indicator/blacklist-support
Merge into: lp:evolution-indicator
Diff against target: None lines
To merge this branch: bzr merge lp:~indicator-applet-developers/evolution-indicator/blacklist-support
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+11887@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Creates/removes the blacklist file when appropriate.

Revision history for this message
Ted Gould (ted) wrote :

On Wed, 2009-09-16 at 14:40 +0000, Neil J. Patel wrote:
> Creates/removes the blacklist file when appropriate.

You probably need to create USER_BLACKLIST_DIR as it won't always exist.
I don't think that build_filename will do that.

53. By Neil J. Patel

modified:
  src/evolution-indicator.c
    - Create directory before writing to it as per teds comments

Revision history for this message
David Barth (dbarth) wrote :

blacklist management should really be something done by the indicator-messages itself then.

Revision history for this message
Neil J. Patel (njpatel) wrote :

> On Wed, 2009-09-16 at 14:40 +0000, Neil J. Patel wrote:
> > Creates/removes the blacklist file when appropriate.
>
> You probably need to create USER_BLACKLIST_DIR as it won't always exist.
> I don't think that build_filename will do that.

Nice catch, I added support for that in rev 53. It seems to work fine when I remove any of the directories in the ~/.config/indicators/messages/applications-blacklist chain.

Revision history for this message
Ted Gould (ted) wrote :

On Wed, 2009-09-16 at 15:53 +0000, David Barth wrote:
> blacklist management should really be something done by the
> indicator-messages itself then.

We've discussed making a utility to do it so there'd be something like:

  $ indicator-messages-blacklist-add /path/to/my/desktopfile.desktop

and

  $ indicator-messages-blacklist-remove /path/to/my/desktopfile.desktop

But no one (including myself) has come down definitively on either side
of that. The script would be very short.

Revision history for this message
Ted Gould (ted) wrote :

On Wed, 2009-09-16 at 15:55 +0000, Neil J. Patel wrote:
> Nice catch, I added support for that in rev 53. It seems to
> work fine when I remove any of the directories in the
> ~/.config/indicators/messages/applications-blacklist chain.

Looks good.

  review approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/evolution-indicator.c'
2--- src/evolution-indicator.c 2009-09-10 16:44:38 +0000
3+++ src/evolution-indicator.c 2009-09-16 14:27:22 +0000
4@@ -63,6 +63,9 @@
5
6 #define UNREAD_DATA "unread"
7
8+#define USER_BLACKLIST_DIR "indicators/messages/applications-blacklist"
9+#define USER_BLACKLIST_FILENAME "evolution"
10+
11 static EShell *evo_shell = NULL;
12 static GStaticMutex mlock = G_STATIC_MUTEX_INIT;
13 static GConfClient *client = NULL;
14@@ -98,6 +101,9 @@
15
16 static void show_evolution (gpointer arg0, gpointer arg1);
17
18+static void show_evolution_in_indicator_applet (void);
19+static void hide_evolution_in_indicator_applet (void);
20+
21 typedef struct {
22 gchar *url;
23 gchar *name;
24@@ -395,9 +401,17 @@
25 value = entry->value;
26
27 show_count = gconf_value_get_bool (value);
28-
29- show_count ? indicate_server_show (server)
30- : indicate_server_hide (server);
31+
32+ if (show_count)
33+ {
34+ indicate_server_show (server);
35+ show_evolution_in_indicator_applet ();
36+ }
37+ else
38+ {
39+ indicate_server_hide (server);
40+ hide_evolution_in_indicator_applet ();
41+ }
42
43 g_debug ("EI: Messages in panel %s",
44 show_count ? "true" : "false");
45@@ -684,7 +698,13 @@
46 if (show_count)
47 {
48 indicate_server_show (server);
49+ show_evolution_in_indicator_applet ();
50 }
51+ else
52+ {
53+ indicate_server_hide (server);
54+ hide_evolution_in_indicator_applet ();
55+ }
56 }
57 else
58 {
59@@ -705,6 +725,9 @@
60 indicate_server_hide (server);
61 g_object_unref (server);
62 server = NULL;
63+
64+ /* Remove evolution from indicator menu */
65+ hide_evolution_in_indicator_applet ();
66
67 g_debug ("EI: Disabled");
68 }
69@@ -983,3 +1006,73 @@
70 }
71
72
73+/*
74+ *
75+ * SHOW/HIDE EVOLUTION IN INDICATOR APPLET
76+ *
77+ */
78+
79+static void
80+show_evolution_in_indicator_applet (void)
81+{
82+ gchar *bpath;
83+
84+ bpath = g_build_filename (g_get_user_config_dir (),
85+ USER_BLACKLIST_DIR,
86+ USER_BLACKLIST_FILENAME,
87+ NULL);
88+
89+ if (g_file_test (bpath, G_FILE_TEST_EXISTS))
90+ {
91+ GFile *bfile;
92+
93+ bfile = g_file_new_for_path (bpath);
94+
95+ if (bfile)
96+ {
97+ GError *error = NULL;
98+
99+ g_file_delete (bfile, NULL, &error);
100+
101+ if (error)
102+ {
103+ g_warning ("Unable to remove blacklist file: %s", error->message);
104+ g_error_free (error);
105+ }
106+
107+ g_object_unref (bfile);
108+ }
109+ }
110+
111+ g_free (bpath);
112+}
113+
114+static void
115+hide_evolution_in_indicator_applet (void)
116+{
117+ gchar *bpath;
118+ GError *error = NULL;
119+
120+ bpath = g_build_filename (g_get_user_config_dir (),
121+ USER_BLACKLIST_DIR,
122+ USER_BLACKLIST_FILENAME,
123+ NULL);
124+
125+ if (g_file_set_contents (bpath,
126+ EVOLUTION_DESKTOP_FILE,
127+ -1,
128+ &error))
129+ {
130+ g_debug ("Successfully wrote blacklist file to %s", bpath);
131+ }
132+ else
133+ {
134+ g_debug ("Unable to write blacklist file to %s: %s",
135+ bpath,
136+ error ? error->message : "Unknown");
137+ if (error)
138+ g_error_free (error);
139+ }
140+
141+ g_free (bpath);
142+}

Subscribers

People subscribed via source and target branches