diff options
author | Ted Gould <ted@canonical.com> | 2009-08-20 21:24:31 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-08-20 21:24:31 -0500 |
commit | 79f4b7e53cc1a26d37de1daf98fdcb9a6f803aa8 (patch) | |
tree | d624d3cb4ebc87b90ec34085b55e4e6390661c3e /src/messages-service.c | |
parent | acdf23dfc7c9be7b7a6b953fc2f02202e3905807 (diff) | |
download | ayatana-indicator-messages-79f4b7e53cc1a26d37de1daf98fdcb9a6f803aa8.tar.gz ayatana-indicator-messages-79f4b7e53cc1a26d37de1daf98fdcb9a6f803aa8.tar.bz2 ayatana-indicator-messages-79f4b7e53cc1a26d37de1daf98fdcb9a6f803aa8.zip |
Basic code to monitor the directories
Diffstat (limited to 'src/messages-service.c')
-rw-r--r-- | src/messages-service.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/messages-service.c b/src/messages-service.c index 8b9b5cb..b153eda 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -24,6 +24,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <pango/pango-utils.h> #include <dbus/dbus-glib-bindings.h> #include <libindicate/listener.h> +#include <gio/gio.h> #include <libdbusmenu-glib/server.h> @@ -53,6 +54,8 @@ 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 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); /* @@ -164,6 +167,7 @@ launcherList_sort (gconstpointer a, gconstpointer b) */ static GHashTable * blacklist = NULL; +static GFileMonitor * blacklistdirmon = NULL; /* Initialize the black list and start to setup handlers for it. */ @@ -180,6 +184,12 @@ blacklist_init (gpointer data) return FALSE; } + GFile * filedir = g_file_new_for_path(blacklistdir); + blacklistdirmon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL); + if (blacklistdirmon != NULL) { + g_signal_connect(G_OBJECT(blacklistdirmon), "changed", G_CALLBACK(blacklist_dir_changed), NULL); + } + GError * error = NULL; GDir * dir = g_dir_open(blacklistdir, 0, &error); if (dir == NULL) { @@ -277,6 +287,16 @@ blacklist_check (const gchar * desktop_file) return FALSE; } +/* A callback everytime the blacklist directory changes + in some way. It needs to handle that. */ +static void +blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data) +{ + g_debug("Blacklist directory changed!"); + + return; +} + /* * More code */ @@ -659,6 +679,14 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, return; } +static void +app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data) +{ + gchar * directory = (gchar *)user_data; + g_debug("Application directory changed: %s", directory); + return; +} + /* Check to see if a new desktop file causes any of the launchers to be eclipsed by a running process */ @@ -762,6 +790,12 @@ build_launchers (gpointer data) return FALSE; } + GFile * filedir = g_file_new_for_path(directory); + GFileMonitor * dirmon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL); + if (dirmon != NULL) { + g_signal_connect(G_OBJECT(dirmon), "changed", G_CALLBACK(app_dir_changed), directory); + } + GError * error = NULL; GDir * dir = g_dir_open(directory, 0, &error); if (dir == NULL) { |