From 33e07dab3aafaf7219b3284a95ad4f16755d677d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Aug 2009 14:01:38 -0500 Subject: Turning blacklist dir changes into events --- src/messages-service.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/messages-service.c') diff --git a/src/messages-service.c b/src/messages-service.c index b153eda..4e03c26 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -53,7 +53,7 @@ static gboolean build_launcher (gpointer data); static gboolean build_launchers (gpointer data); static gboolean blacklist_init (gpointer data); static gboolean blacklist_add (gpointer data); -static void blacklist_remove (const gchar * definition_file); +static gboolean blacklist_remove (gpointer data); static void blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); static void app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); @@ -258,17 +258,18 @@ blacklist_add (gpointer udata) } } - blacklist_remove(NULL); return FALSE; } /* Remove a black list item based on the definition file and uneclipse those launchers blocked by it. */ -static void -blacklist_remove (const gchar * definition_file) +static gboolean +blacklist_remove (gpointer data) { + gchar * definition_file = (gchar *)data; + g_debug("Removing: %s", definition_file); - return; + return FALSE; } /* Check to see if a particular desktop file is @@ -294,6 +295,23 @@ blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, { g_debug("Blacklist directory changed!"); + switch (event_type) { + case G_FILE_MONITOR_EVENT_DELETED: { + gchar * path = g_file_get_path(file); + g_debug("\tDelete: %s", path); + g_idle_add(blacklist_remove, path); + break; + } + case G_FILE_MONITOR_EVENT_CREATED: { + gchar * path = g_file_get_path(file); + g_debug("\tCreate: %s", path); + g_idle_add(blacklist_add, path); + break; + } + default: + break; + } + return; } -- cgit v1.2.3