Merge lp:~larsu/indicator-messages/fix-blacklist into lp:indicator-messages/0.3

Proposed by Lars Karlitski
Status: Merged
Approved by: Ted Gould
Approved revision: 253
Merged at revision: 259
Proposed branch: lp:~larsu/indicator-messages/fix-blacklist
Merge into: lp:indicator-messages/0.3
Diff against target: 99 lines (+22/-23)
1 file modified
src/messages-service.c (+22/-23)
To merge this branch: bzr merge lp:~larsu/indicator-messages/fix-blacklist
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+94424@code.launchpad.net

Description of the change

The blacklist hash map used desktop file contents as keys, but checked for file paths when checking whether an etnry should be hidden. This patch makes it use the link target, which should be something in /usr/share/applications in the majority of cases.

I'm not sure about this approach though. Maybe someone with more insight into i-messages can tell me whether this makes sense at all.

Also, hidden menuitems are still visible for me (only the label is gone). A bug in libindicator?

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

I think that instead of using the symlink targets we should probably use basename's to match the desktop file names. I think that some people might have done a copy of the desktop files instead of linking them, while I think linking would be better, I don't think we can use that alone.

review: Needs Fixing
Revision history for this message
Lars Karlitski (larsu) wrote :

To be honest, I think this whole approach is kind of clunky and error-prone. Can't we just use a gsetting for that (like unity-panel-service does for the system tray whitelist)? This would make the i-messages code a lot cleaner and also make it easier for users to edit the blacklist.

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

On Fri, 2012-03-09 at 10:22 +0000, Lars Uebernickel wrote:
> To be honest, I think this whole approach is kind of clunky and
> error-prone.. Can't we just use a gsetting for that (like
> unity-panel-service does for the system tray whitelist)? This would
> make the i-messages code a lot cleaner and also make it easier for
> users to edit the blacklist.

The problem with using lists in GSettings is that it's impossible to
upgrade them. If a user ever sets that list, the default is
unreachable. By using directories we get this "merging" feature for
free. It's on the slate to make it into DConf at some point, but we
haven't budgeted the time for that yet.

Also, when this code was written GSettings didn't exist :-)

I think if we use the directory listing like this "list of keys" we're
almost doing the same thing, although not as cleanly for sure.

253. By Lars Karlitski

Use basename of the desktop file as key in the blacklist hash table

This is superior to using symlinks, as this also allows copying the desktop
files into the blacklist directory. Copying is the default when dragging and
dropping an application into that folder.

Revision history for this message
Lars Karlitski (larsu) wrote :

Pushed a fix that uses basenames instead of symlink targets.

By the way, applications that are running are always displayed, even if they are in the blacklist. Is that correct or also a bug? (Or did I introduce this with my patch?)

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

Nope, that's been there. I kinda feel if the application is putting itself there, you either need to disable that in the app, but it's not our responsibility to not show it. Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/messages-service.c'
--- src/messages-service.c 2012-03-08 16:05:30 +0000
+++ src/messages-service.c 2012-03-14 18:01:19 +0000
@@ -327,20 +327,8 @@
327blacklist_add (gpointer udata)327blacklist_add (gpointer udata)
328{328{
329 gchar * definition_file = (gchar *)udata;329 gchar * definition_file = (gchar *)udata;
330 /* Dump the file */330
331 gchar * desktop;331 blacklist_add_core(definition_file, definition_file);
332 g_file_get_contents(definition_file, &desktop, NULL, NULL);
333 if (desktop == NULL) {
334 g_warning("Couldn't get data out of: %s", definition_file);
335 return FALSE;
336 }
337
338 /* Clean up the data */
339 gchar * trimdesktop = pango_trim_string(desktop);
340 g_free(desktop);
341
342 blacklist_add_core(trimdesktop, definition_file);
343 g_free(trimdesktop);
344332
345 return FALSE;333 return FALSE;
346}334}
@@ -352,8 +340,10 @@
352static void340static void
353blacklist_add_core (gchar * desktop, gchar * definition)341blacklist_add_core (gchar * desktop, gchar * definition)
354{342{
343 gchar *basename = g_path_get_basename(desktop);
344
355 /* Check for conflicts */345 /* Check for conflicts */
356 gpointer data = g_hash_table_lookup(blacklist, desktop);346 gpointer data = g_hash_table_lookup(blacklist, basename);
357 if (data != NULL) {347 if (data != NULL) {
358 gchar * oldfile = (gchar *)data;348 gchar * oldfile = (gchar *)data;
359 if (!g_strcmp0(oldfile, definition)) {349 if (!g_strcmp0(oldfile, definition)) {
@@ -362,27 +352,31 @@
362 g_warning("Already have desktop file '%s' in blacklist file '%s' not adding from '%s'", desktop, oldfile, definition);352 g_warning("Already have desktop file '%s' in blacklist file '%s' not adding from '%s'", desktop, oldfile, definition);
363 }353 }
364354
355 g_free(basename);
365 return;356 return;
366 }357 }
367358
368 /* Actually blacklist this thing */359 /* Actually blacklist this thing */
369 g_hash_table_insert(blacklist, g_strdup(desktop), g_strdup(definition));360 g_hash_table_insert(blacklist, g_strdup(basename), g_strdup(definition));
370 g_debug("Adding Blacklist item '%s' for desktop '%s'", definition, desktop);361 g_debug("Adding Blacklist item '%s' for desktop '%s'", definition, desktop);
371362
372 /* Go through and eclipse folks */363 /* Go through and eclipse folks */
373 GList * launcher;364 GList * launcher;
374 for (launcher = launcherList; launcher != NULL; launcher = launcher->next) {365 for (launcher = launcherList; launcher != NULL; launcher = launcher->next) {
375 launcherList_t * item = (launcherList_t *)launcher->data;366 launcherList_t * item = (launcherList_t *)launcher->data;
376 if (!g_strcmp0(desktop, launcher_menu_item_get_desktop(item->menuitem))) {367 gchar * item_basename = g_path_get_basename(launcher_menu_item_get_desktop(item->menuitem));
368 if (!g_strcmp0(basename, item_basename)) {
377 launcher_menu_item_set_eclipsed(item->menuitem, TRUE);369 launcher_menu_item_set_eclipsed(item->menuitem, TRUE);
378 dbusmenu_menuitem_property_set_bool(item->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);370 dbusmenu_menuitem_property_set_bool(item->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
379 }371 }
372 g_free(item_basename);
380 }373 }
381374
382 check_hidden();375 check_hidden();
383 /* Shouldn't need a resort here as hiding shouldn't cause things to376 /* Shouldn't need a resort here as hiding shouldn't cause things to
384 move other than this item disappearing. */377 move other than this item disappearing. */
385378
379 g_free(basename);
386 return;380 return;
387}381}
388382
@@ -444,15 +438,20 @@
444static gboolean438static gboolean
445blacklist_check (const gchar * desktop_file)439blacklist_check (const gchar * desktop_file)
446{440{
447 g_debug("Checking blacklist for: %s", desktop_file);441 gchar *basename = g_path_get_basename(desktop_file);
448 if (blacklist == NULL) return FALSE;442 gboolean found;
449443
450 if (g_hash_table_lookup(blacklist, desktop_file)) {444 g_debug("Checking blacklist for: %s", basename);
445
446 if (blacklist && g_hash_table_lookup(blacklist, basename)) {
451 g_debug("\tFound!");447 g_debug("\tFound!");
452 return TRUE;448 found = TRUE;
453 }449 }
450 else
451 found = FALSE;
454452
455 return FALSE;453 g_free(basename);
454 return found;
456}455}
457456
458/* A callback everytime the blacklist directory changes457/* A callback everytime the blacklist directory changes

Subscribers

People subscribed via source and target branches