Author: jannis
Date: 2006-10-04 17:35:30 +0000 (Wed, 04 Oct 2006)
New Revision: 23283

Modified:
   libfrap/trunk/libfrap/menu/ChangeLog
   libfrap/trunk/libfrap/menu/frap-menu-item.c
   libfrap/trunk/libfrap/menu/frap-menu.c
   libfrap/trunk/libfrap/menu/tests/test-display-root-menu.c
Log:
        * frap-menu-item.c: Revert parts of the previous commit because of 
          useless checks.
        * frap-menu.c: Remove <Deleted /> menus and add notes for other 

Modified: libfrap/trunk/libfrap/menu/ChangeLog
===================================================================
--- libfrap/trunk/libfrap/menu/ChangeLog        2006-10-04 17:05:57 UTC (rev 
23282)
+++ libfrap/trunk/libfrap/menu/ChangeLog        2006-10-04 17:35:30 UTC (rev 
23283)
@@ -1,5 +1,12 @@
 2006-10-04     Jannis Pohlmann <[EMAIL PROTECTED]>
 
+       * frap-menu-item.c: Revert parts of the previous commit because of 
+         useless checks.
+       * frap-menu.c: Remove <Deleted /> menus and add notes for other 
+          merge actions to be implemented.
+
+2006-10-04     Jannis Pohlmann <[EMAIL PROTECTED]>
+
        * frap-menu-item.c: Make property assignment more clean.
 
 2006-10-04     Jannis Pohlmann <[EMAIL PROTECTED]>

Modified: libfrap/trunk/libfrap/menu/frap-menu-item.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-item.c 2006-10-04 17:05:57 UTC (rev 
23282)
+++ libfrap/trunk/libfrap/menu/frap-menu-item.c 2006-10-04 17:35:30 UTC (rev 
23283)
@@ -288,11 +288,11 @@
 frap_menu_item_init (FrapMenuItem *item)
 {
   item->priv = FRAP_MENU_ITEM_GET_PRIVATE (item);
-  item->priv->icon_name = NULL;
-  item->priv->name = NULL;
-  item->priv->command = NULL;
   item->priv->desktop_id = NULL;
+  item->priv->name = NULL;
   item->priv->filename = NULL;
+  item->priv->command = NULL;
+  item->priv->icon_name = NULL;
   item->priv->categories = NULL;
 }
 
@@ -558,8 +558,7 @@
     }
 
   /* Assign the new desktop_id */
-  if (G_LIKELY (desktop_id != NULL))
-    item->priv->desktop_id = g_strdup (desktop_id);
+  item->priv->desktop_id = g_strdup (desktop_id);
 
   /* Notify listeners */
   g_object_notify (G_OBJECT (item), "desktop_id");
@@ -596,8 +595,7 @@
     }
 
   /* Assign the new filename */
-  if (G_LIKELY (filename != NULL))
-    item->priv->filename = g_strdup (filename);
+  item->priv->filename = g_strdup (filename);
 
   /* Notify listeners */
   g_object_notify (G_OBJECT (item), "filename");
@@ -665,8 +663,7 @@
     }
 
   /* Assign new command */
-  if (G_LIKELY (command != NULL))
-    item->priv->command = g_strdup (command);
+  item->priv->command = g_strdup (command);
 
   /* Notify listeners */
   g_object_notify (G_OBJECT (item), "command");
@@ -700,8 +697,7 @@
     }
 
   /* Assign new name */
-  if (G_LIKELY (name != NULL))
-    item->priv->name = g_strdup (name);
+  item->priv->name = g_strdup (name);
 
   /* Notify listeners */
   g_object_notify (G_OBJECT (item), "name");
@@ -735,8 +731,7 @@
     }
 
   /* Assign new icon name */
-  if (G_LIKELY (icon_name != NULL))
-    item->priv->icon_name = g_strdup (icon_name);
+  item->priv->icon_name = g_strdup (icon_name);
 
   /* Notify listeners */
   g_object_notify (G_OBJECT (item), "icon_name");

Modified: libfrap/trunk/libfrap/menu/frap-menu.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu.c      2006-10-04 17:05:57 UTC (rev 
23282)
+++ libfrap/trunk/libfrap/menu/frap-menu.c      2006-10-04 17:35:30 UTC (rev 
23283)
@@ -206,6 +206,7 @@
 static void               frap_menu_resolve_items_from_path       (FrapMenu    
          *menu,
                                                                    const gchar 
          *path,
                                                                    const gchar 
          *id_prefix);
+static void               frap_menu_resolve_deleted               (FrapMenu    
          *menu);
 
 
 
@@ -902,8 +903,17 @@
   g_list_free (menu_context.menu_stack);
   g_list_free (menu_context.rule_stack);
 
-  /* Resolve internals, merge menus (TODO) and determine included/excluded 
menu items */
+#if 0 
+  /* TODO (wrapping all this into another method might make sense, especially 
+   * because stuff needs to be re-run after merging. */
+  frap_menu_consolidate_child_menus (menu);
+#endif
   frap_menu_resolve_directory (menu);
+#if 0
+  /* TODO */
+  frap_menu_resolve_move (menu);
+#endif
+  frap_menu_resolve_deleted (menu);
   frap_menu_resolve_items (menu);
 }
 
@@ -1776,6 +1786,36 @@
 
 
 
+static void
+frap_menu_resolve_deleted (FrapMenu *menu)
+{
+  GSList *iter;
+
+  g_return_if_fail (FRAP_IS_MENU (menu));
+
+  /* Note: There's a limitation here. If the root menu has a <Deleted /> we
+   * can't just free the pointer here. Therefor we just check child menus. */
+
+  for (iter = menu->priv->submenus; iter != NULL; iter = g_slist_next (iter))
+    {
+      FrapMenu *submenu = iter->data;
+
+      /* Remove submenu if it is deleted, otherwise check submenus of the
+       * submenu. */
+      if (G_UNLIKELY (submenu->priv->deleted))
+        {
+          /* Remove submenu from the list ... */
+          menu->priv->submenus = g_slist_remove_link (menu->priv->submenus, 
iter);
+
+          /* ... and destroy it */
+          g_object_unref (G_OBJECT (submenu));
+        }
+      else
+        frap_menu_resolve_deleted (submenu);
+    }
+}
+
+
 static GSList*
 frap_menu_get_rules (FrapMenu *menu)
 {
@@ -1804,3 +1844,4 @@
 
   return menu->priv->pool;
 }
+

Modified: libfrap/trunk/libfrap/menu/tests/test-display-root-menu.c
===================================================================
--- libfrap/trunk/libfrap/menu/tests/test-display-root-menu.c   2006-10-04 
17:05:57 UTC (rev 23282)
+++ libfrap/trunk/libfrap/menu/tests/test-display-root-menu.c   2006-10-04 
17:35:30 UTC (rev 23283)
@@ -67,8 +67,8 @@
 GdkPixbuf*
 create_icon_for_item (FrapMenuItem *item)
 {
+  GdkPixbuf    *pixbuf = NULL;
   GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
-  GdkPixbuf    *pixbuf = NULL;
   const gchar  *icon_name = frap_menu_item_get_icon_name (item);
   const gchar  *item_name = frap_menu_item_get_name (item);
 
@@ -125,7 +125,7 @@
     {
       GdkPixbuf *old = pixbuf;
       pixbuf = gdk_pixbuf_scale_simple (old, ICON_SIZE, ICON_SIZE, 
GDK_INTERP_BILINEAR);
-      gdk_pixbuf_unref (old);
+      g_object_unref (G_OBJECT (old));
     }
 
   /* Print icon name if icon could not be loaded */
@@ -141,10 +141,10 @@
 execute_command_for_item (GtkWidget    *widget,
                           FrapMenuItem *item)
 {
+  GError      *error = NULL;
   const gchar *command = frap_menu_item_get_command (item);
   gboolean     terminal = frap_menu_item_requires_terminal (item);
   gboolean     startup_notification = 
frap_menu_item_supports_startup_notification (item);
-  GError      *error = NULL;
 
   /* Abort if no command was defined for this item */
   if (G_UNLIKELY (command == NULL))
@@ -201,9 +201,9 @@
   GtkWidget         *image;
   GSList            *iter;
   GSList            *menus;
-  GtkIconTheme      *icon_theme = gtk_icon_theme_get_default ();
   const gchar       *icon_name;
   GdkPixbuf         *pixbuf;
+  GtkIconTheme      *icon_theme = gtk_icon_theme_get_default ();
 
   /* Create sorted copy of the submenu list */
   menus = g_slist_sort (g_slist_copy (frap_menu_get_menus (menu)), 
(GCompareFunc) compare_menus);

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to