gnome-menus r896 - in trunk: . libmenu



Author: vuntz
Date: Sun May 18 14:59:20 2008
New Revision: 896
URL: http://svn.gnome.org/viewvc/gnome-menus?rev=896&view=rev

Log:
2008-05-18  Vincent Untz  <vuntz gnome org>

	Fix the values of <DefaultLayout> (ie, show_empty, inline,
	inline_limit, etc.) not being inherited by submenus when the
	<DefaultLayout> node is after the <Menu> node in the .menu file.
	Can also fix other issues when there are multiple <DefaultLayout> nodes
	mixed with the <Menu> nodes.

	* libmenu/gmenu-tree.c: (gmenu_tree_directory_new): do not set the
	default layout values from the parent here since we might not have
	the values of the parent yet. So just set to the default values.
	(set_default_layout_values): new, set the default layout values of a
	menu based on its parent, and then iterate on the children to do the
	same
	(process_layout): after having iterated over all the nodes, we'll have
	found <DefaultLayout> if there's one and so we can make the submenus
	inherit it


Modified:
   trunk/ChangeLog
   trunk/libmenu/gmenu-tree.c

Modified: trunk/libmenu/gmenu-tree.c
==============================================================================
--- trunk/libmenu/gmenu-tree.c	(original)
+++ trunk/libmenu/gmenu-tree.c	Sun May 18 14:59:20 2008
@@ -1247,19 +1247,12 @@
   retval->only_unallocated    = FALSE;
   retval->is_nodisplay        = FALSE;
 
-  if (parent != NULL)
-    {
-      retval->default_layout_values = parent->default_layout_values;
-    }
-  else
-    {
-      retval->default_layout_values.mask          = MENU_LAYOUT_VALUES_NONE;
-      retval->default_layout_values.show_empty    = FALSE;
-      retval->default_layout_values.inline_menus  = FALSE;
-      retval->default_layout_values.inline_limit  = 4;
-      retval->default_layout_values.inline_header = FALSE;
-      retval->default_layout_values.inline_alias  = FALSE;
-    }
+  retval->default_layout_values.mask          = MENU_LAYOUT_VALUES_NONE;
+  retval->default_layout_values.show_empty    = FALSE;
+  retval->default_layout_values.inline_menus  = FALSE;
+  retval->default_layout_values.inline_limit  = 4;
+  retval->default_layout_values.inline_header = FALSE;
+  retval->default_layout_values.inline_alias  = FALSE;
 
   return retval;
 }
@@ -3121,6 +3114,32 @@
                                            desktop_entry_get_no_display (desktop_entry)));
 }
 
+static void
+set_default_layout_values (GMenuTreeDirectory *parent,
+                           GMenuTreeDirectory *child)
+{
+  GSList *tmp;
+
+  /* if the child has a defined default layout, we don't want to override its
+   * values, and if the parent doesn't have a defined default layout, then
+   * everybody already uses the default values */
+  if (parent->default_layout_info == NULL ||
+      child->default_layout_info != NULL)
+    return;
+
+  child->default_layout_values = parent->default_layout_values;
+
+  tmp = child->subdirs;
+  while (tmp != NULL)
+    {
+      GMenuTreeDirectory *subdir = tmp->data;
+
+      set_default_layout_values (child, subdir);
+
+      tmp = tmp->next;
+   }
+}
+
 static GMenuTreeDirectory *
 process_layout (GMenuTree          *tree,
                 GMenuTreeDirectory *parent,
@@ -3378,6 +3397,16 @@
       desktop_entry_set_unref (excluded_set);
     }
 
+  tmp = directory->subdirs;
+  while (tmp != NULL)
+    {
+      GMenuTreeDirectory *subdir = tmp->data;
+
+      set_default_layout_values (directory, subdir);
+
+      tmp = tmp->next;
+   }
+
   tmp = directory->entries;
   while (tmp != NULL)
     {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]