summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis@xfce.org>2010-09-05 21:39:11 +0200
committerJannis Pohlmann <jannis@xfce.org>2010-09-05 21:39:11 +0200
commit2d3750233542f9252fd0802e3438896d759f9fd3 (patch)
treeee9873e2240f0e9f189bd3c06bcaca7aeaa22a47
parent2be335a2c9332d9b2c9f649245a764afb7140257 (diff)
downloadgarcon-jannis/basic-monitoring.tar.gz
Properly react on delete events. They are not included in CHANGES_DONE.jannis/basic-monitoring
Too bad, here we have our first exception. Delete events don't seem to be included in the events closed by G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT.
-rw-r--r--garcon/garcon-menu.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/garcon/garcon-menu.c b/garcon/garcon-menu.c
index 4f40c2e..85c8ffc 100644
--- a/garcon/garcon-menu.c
+++ b/garcon/garcon-menu.c
@@ -2185,6 +2185,42 @@ garcon_menu_app_dir_changed (GarconMenu *menu,
g_free (path);
}
}
+ else if (event_type == G_FILE_MONITOR_EVENT_DELETED)
+ {
+ /* query the type of the changed file */
+ file_type = g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL);
+
+ if (file_type == G_FILE_TYPE_DIRECTORY)
+ {
+ /* an existing app dir (or a subdirectory) has been deleted. we
+ * could remove all the items that are in use and reside inside
+ * this root directory. but for now... enforce a menu reload! */
+ g_signal_emit (menu, menu_signals[RELOAD_REQUIRED], 0);
+ }
+ else
+ {
+ /* a regular file was deleted, try to find the corresponding menu item */
+ item = garcon_menu_find_file_item (menu, file);
+ if (item != NULL)
+ {
+ /* remove the item from the desktop item cache so we are forced
+ * to reload it from disk the next time */
+ garcon_menu_item_cache_invalidate_file (menu->priv->cache, file);
+
+ /* ok, so a .desktop file was removed. of course we don't know
+ * yet whether there is a replacement in another app dir
+ * with lower priority. we could try to find out but for now
+ * it's easier to simply enforce a menu reload */
+ g_signal_emit (menu, menu_signals[RELOAD_REQUIRED], 0);
+ }
+ else
+ {
+ /* the deleted file hasn't been in use anyway, so removing it
+ * doesn't change anything. so we have nothing to do for a
+ * change, no f****ing menu reload! */
+ }
+ }
+ }
}