[Xfce4-commits] <garcon:jannis/global-monitoring> Squashme

Jannis Pohlmann noreply at xfce.org
Sun Sep 5 14:50:34 CEST 2010


Updating branch refs/heads/jannis/global-monitoring
         to f184e60d6561668180bcff62ff2f96a24cdc40d0 (commit)
       from 25864bee17ba4394e2db8c91ff38d91e8f063971 (commit)

commit f184e60d6561668180bcff62ff2f96a24cdc40d0
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Mon Aug 30 15:29:35 2010 +0200

    Squashme

 garcon/garcon-menu.c |   54 ++++++++++++++++++++++++++++++++++---------------
 1 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/garcon/garcon-menu.c b/garcon/garcon-menu.c
index 930c938..ef162b9 100644
--- a/garcon/garcon-menu.c
+++ b/garcon/garcon-menu.c
@@ -2150,7 +2150,7 @@ garcon_menu_find_file_item (GarconMenu *menu,
 
 
 static void
-garcon_menu_update_item_file (GarconMenu  *menu,
+garcon_menu_update_file_item (GarconMenu  *menu,
                               const gchar *desktop_id,
                               GFile       *file)
 {
@@ -2586,7 +2586,6 @@ garcon_menu_app_dir_changed (GarconMenu       *menu,
   GList          *menus = NULL;
   GList          *lp;
   gchar          *desktop_id;
-  gchar          *uri;
 
   g_return_if_fail (GARCON_IS_MENU (menu));
 
@@ -2647,7 +2646,18 @@ garcon_menu_app_dir_changed (GarconMenu       *menu,
               /* determine the desktop ID for this file */
               if (garcon_menu_collect_file (menu, file, NULL, NULL, &desktop_id))
                 {
-                  garcon_menu_update_file_item (menu, desktop_id, file);
+                  if (garcon_menu_collect_file (menu, NULL, desktop_id, &replacement_file, NULL))
+                    {
+                      if (g_file_equal (file, replacement_file))
+                        {
+                          /* TODO we need to handle the app dir priority here */
+                          garcon_menu_update_file_item (menu, desktop_id, file);
+                        }
+                      else
+                        {
+                          g_debug ("ignoring the changed file as it is overriden");
+                        }
+                    }
                   g_free (desktop_id);
                 }
             }
@@ -2662,19 +2672,29 @@ garcon_menu_app_dir_changed (GarconMenu       *menu,
                garcon_menu_element_get_name (GARCON_MENU_ELEMENT (menu)),
                g_file_get_path (file), event_type);
 
-      /* TODO
-       * 1) the new file is a directory
-       *    - collect files from the newly created directory
-       *    - add files to the correct menus (make sure to emit
-       *      'item-added' signals)
-       *    - monitor the newly created directory
-       * 2) the new file is a regular file
-       *    - remove items with the same desktop id
-       *    - load it into a GarconMenuItem
-       *    - find the correct menu(s) for it
-       *    - add it to those menus (make sure to emit 'item-added'
-       *      signals)
-       */
+      /* 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)
+        {
+          /* TODO
+           * the new file is a directory
+           *   - collect files from the newly created directory
+           *   - add files to the correct menus (make sure to emit
+           *    'item-added' signals)
+           *   - monitor the newly created directory */
+        }
+      else 
+        {
+          /* TODO
+           * the new file is a regular file
+           *   - remove items with the same desktop id and lower app dir priority
+           *   - load it into a GarconMenuItem
+           *   - find the correct menu(s) for it
+           *   - add it to those menus (make sure to emit 'item-added'
+           *     signals)
+           */
+        }
     }
   else if (event_type == G_FILE_MONITOR_EVENT_DELETED)
     {
@@ -2736,7 +2756,7 @@ garcon_menu_app_dir_changed (GarconMenu       *menu,
               /* determine the next-priority desktop file with the same desktop ID */
               if (garcon_menu_collect_file (menu, NULL, desktop_id, &replacement_file, NULL))
                 {
-                  garcon_menu_update_item_file (menu, desktop_id, file);
+                  garcon_menu_update_file_item (menu, desktop_id, file);
                   g_object_unref (replacement_file);
                 }
 



More information about the Xfce4-commits mailing list