Author: jannis
Date: 2007-01-14 14:47:00 +0000 (Sun, 14 Jan 2007)
New Revision: 24444

Modified:
   libfrap/trunk/libfrap/menu/ChangeLog
   libfrap/trunk/libfrap/menu/Makefile.am
   libfrap/trunk/libfrap/menu/STATUS
   libfrap/trunk/libfrap/menu/frap-menu-and-rules.c
   libfrap/trunk/libfrap/menu/frap-menu-not-rules.c
   libfrap/trunk/libfrap/menu/frap-menu-or-rules.c
   libfrap/trunk/libfrap/menu/frap-menu-rules.c
   libfrap/trunk/libfrap/menu/frap-menu-rules.h
   libfrap/trunk/libfrap/menu/frap-menu-standard-rules.c
   libfrap/trunk/libfrap/menu/frap-menu-standard-rules.h
   libfrap/trunk/libfrap/menu/frap-menu.c
   libfrap/trunk/libfrap/menu/frap-menu.h
   libfrap/trunk/libfrap/menu/tests/test-display-root-menu.c
   libfrap/trunk/libfrap/menu/tests/test-root-menu.c
Log:
        * frap-menu.{c,h}, frap-menu-rules.h, frap-menu-standard-rules.h,
        frap-menu-{standard,or,and,not}-rules.{c}, tests/test-root-menu.c,
        tests/test-display-root-menu.c, Makefile.am, STATUS: Incorporate Benny's
        patch which he wrote for the xfce4-appbrowser mockup. This patch
        includes a lot of changes:
          - Adds <All> support to all include/exclude rules
          - Makes parsing include/exclude rules more sane if markup is malformed
          - Adds kde-applications.menu and gnome-applications.menu to the list
            of root menu files to search
          - Adds GError support to menu loading functions
          - Fixes <DirectoryDir> elements accidently being skipped
          - Fixes use of g_access usage
        And some other small fixes. Huge thanks to Benny for this.

Modified: libfrap/trunk/libfrap/menu/ChangeLog
===================================================================
--- libfrap/trunk/libfrap/menu/ChangeLog        2007-01-14 14:14:02 UTC (rev 
24443)
+++ libfrap/trunk/libfrap/menu/ChangeLog        2007-01-14 14:47:00 UTC (rev 
24444)
@@ -1,3 +1,21 @@
+2007-01-14     Jannis Pohlmann <[EMAIL PROTECTED]>
+
+       * frap-menu.{c,h}, frap-menu-rules.h, frap-menu-standard-rules.h,
+       frap-menu-{standard,or,and,not}-rules.{c}, tests/test-root-menu.c,
+       tests/test-display-root-menu.c, Makefile.am, STATUS: Incorporate Benny's
+       patch which he wrote for the xfce4-appbrowser mockup. This patch
+       includes a lot of changes:
+
+         - Adds <All> support to all include/exclude rules
+         - Makes parsing include/exclude rules more sane if markup is malformed
+         - Adds kde-applications.menu and gnome-applications.menu to the list
+           of root menu files to search
+         - Adds GError support to menu loading functions
+         - Fixes <DirectoryDir> elements accidently being skipped
+         - Fixes use of g_access usage
+
+       And some other small fixes. Huge thanks to Benny for this.
+
 2007-01-11     Jannis Pohlmann <[EMAIL PROTECTED]>
 
        * frap-menu-item.{c,h}: Remove "allocated" property and replace it

Modified: libfrap/trunk/libfrap/menu/Makefile.am
===================================================================
--- libfrap/trunk/libfrap/menu/Makefile.am      2007-01-14 14:14:02 UTC (rev 
24443)
+++ libfrap/trunk/libfrap/menu/Makefile.am      2007-01-14 14:47:00 UTC (rev 
24444)
@@ -1,10 +1,16 @@
 # $Id$ 
 
+INCLUDES =                                                             \
+       -DG_LOG_DOMAIN=\"FrapMenu\"                                     \
+       -DLIBFRAPMENU_COMPILATION                                       \
+       $(PLATFORM_CFLAGS)
+
 SUBDIRS =                                                              \
        tests                                                           \
        tdb
 
-noinst_LTLIBRARIES = libfrapmenu.la
+noinst_LTLIBRARIES =                                                   \
+       libfrapmenu.la
 
 libfrapmenu_la_SOURCES =                                               \
        frap-menu.c                                                     \
@@ -36,15 +42,17 @@
        frap-menu-move.h                                                \
        frap-menu-item.h                                                
 
-INCLUDES =                                                             \
+libfrapmenu_la_CFLAGS =                                                \
        $(GLIB_CFLAGS)                                                  \
        $(GTHREAD_CFLAGS)                                               \
        $(LIBXFCE4UTIL_CFLAGS)                                          \
-       $(PLATFORM_CFLAGS)                                              \
-       -DLIBFRAPMENU_COMPILATION                                       \
-       -DG_LOG_DOMAIN=\"FrapMenu\"
+       $(PLATFORM_CFLAGS)                                              
+
+libfrapmenu_la_LDFLAGS =                                               \
+       -no-undefined                                                   \
+       $(PLATFORM_LDFLAGS)
        
-LIBS =                                                                         
\
+libfrapmenu_la_LIBADD =                                                \
        $(GLIB_LIBS)                                                    \
        $(GTHREAD_LIBS)                                                 \
        $(LIBXFCE4UTIL_LIBS)                                            \

Modified: libfrap/trunk/libfrap/menu/STATUS
===================================================================
--- libfrap/trunk/libfrap/menu/STATUS   2007-01-14 14:14:02 UTC (rev 24443)
+++ libfrap/trunk/libfrap/menu/STATUS   2007-01-14 14:47:00 UTC (rev 24444)
@@ -48,7 +48,7 @@
 
   [x] <Category>
 
-  [ ] <All>
+  [x] <All>
 
   [x] <And>
 

Modified: libfrap/trunk/libfrap/menu/frap-menu-and-rules.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-and-rules.c    2007-01-14 14:14:02 UTC 
(rev 24443)
+++ libfrap/trunk/libfrap/menu/frap-menu-and-rules.c    2007-01-14 14:47:00 UTC 
(rev 24444)
@@ -111,8 +111,6 @@
 static void
 frap_menu_and_rules_finalize (GObject *object)
 {
-  FrapMenuAndRules *rules = FRAP_MENU_AND_RULES (object);
-
   (*G_OBJECT_CLASS (frap_menu_and_rules_parent_class)->finalize) (object); 
 }
 
@@ -135,6 +133,10 @@
   g_return_val_if_fail (FRAP_IS_MENU_STANDARD_RULES (rules), FALSE);
   g_return_val_if_fail (FRAP_IS_MENU_ITEM (item), FALSE);
 
+  /* Check if all elements should be included */
+  if (rules->all)
+    return TRUE;
+
   /* Compare desktop id's */
   for (iter = rules->filenames; iter != NULL; iter = g_list_next (iter))
     {

Modified: libfrap/trunk/libfrap/menu/frap-menu-not-rules.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-not-rules.c    2007-01-14 14:14:02 UTC 
(rev 24443)
+++ libfrap/trunk/libfrap/menu/frap-menu-not-rules.c    2007-01-14 14:47:00 UTC 
(rev 24444)
@@ -136,6 +136,9 @@
   g_return_val_if_fail (FRAP_IS_MENU_STANDARD_RULES (rules), FALSE);
   g_return_val_if_fail (FRAP_IS_MENU_ITEM (item), FALSE);
 
+  if (rules->all)
+    return FALSE;
+
   /* Compare desktop id's */
   for (iter = rules->filenames; iter != NULL; iter = g_list_next (iter))
     {

Modified: libfrap/trunk/libfrap/menu/frap-menu-or-rules.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-or-rules.c     2007-01-14 14:14:02 UTC 
(rev 24443)
+++ libfrap/trunk/libfrap/menu/frap-menu-or-rules.c     2007-01-14 14:47:00 UTC 
(rev 24444)
@@ -135,6 +135,9 @@
   g_return_val_if_fail (FRAP_IS_MENU_STANDARD_RULES (rules), FALSE);
   g_return_val_if_fail (FRAP_IS_MENU_ITEM (item), FALSE);
 
+  if (rules->all)
+    return TRUE;
+
   /* Compare desktop id's */
   for (iter = rules->filenames; iter != NULL; iter = g_list_next (iter))
     {

Modified: libfrap/trunk/libfrap/menu/frap-menu-rules.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-rules.c        2007-01-14 14:14:02 UTC 
(rev 24443)
+++ libfrap/trunk/libfrap/menu/frap-menu-rules.c        2007-01-14 14:47:00 UTC 
(rev 24444)
@@ -89,6 +89,14 @@
 
 
 
+void frap_menu_rules_add_all (FrapMenuRules *rules)
+{
+  g_return_if_fail (FRAP_IS_MENU_RULES (rules));
+  (*FRAP_MENU_RULES_GET_IFACE (rules)->add_all) (rules);
+}
+
+
+
 void
 frap_menu_rules_add_filename (FrapMenuRules *rules,
                               const gchar   *filename)

Modified: libfrap/trunk/libfrap/menu/frap-menu-rules.h
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-rules.h        2007-01-14 14:14:02 UTC 
(rev 24443)
+++ libfrap/trunk/libfrap/menu/frap-menu-rules.h        2007-01-14 14:47:00 UTC 
(rev 24444)
@@ -47,6 +47,7 @@
                                   FrapMenuItem  *item);
   void      (*add_rules)         (FrapMenuRules *rules, 
                                   FrapMenuRules *additional_rules);
+  void      (*add_all)           (FrapMenuRules *rules);
   void      (*add_filename)      (FrapMenuRules *rules, 
                                   const gchar   *filename);
   void      (*add_category)      (FrapMenuRules *rules, 
@@ -58,6 +59,7 @@
 
 gboolean frap_menu_rules_match        (FrapMenuRules *rules,
                                        FrapMenuItem  *item);
+void     frap_menu_rules_add_all      (FrapMenuRules *rules);
 void     frap_menu_rules_add_rules    (FrapMenuRules *rules,
                                        FrapMenuRules *additional_rules);
 void     frap_menu_rules_add_filename (FrapMenuRules *rules,

Modified: libfrap/trunk/libfrap/menu/frap-menu-standard-rules.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-standard-rules.c       2007-01-14 
14:14:02 UTC (rev 24443)
+++ libfrap/trunk/libfrap/menu/frap-menu-standard-rules.c       2007-01-14 
14:47:00 UTC (rev 24444)
@@ -58,6 +58,7 @@
                                                          FrapMenuItem          
     *item);
 static void     frap_menu_standard_rules_add_rules      (FrapMenuRules         
     *rules,
                                                          FrapMenuRules         
     *additional_rules);
+static void     frap_menu_standard_rules_add_all        (FrapMenuRules         
     *rules);
 static void     frap_menu_standard_rules_add_filename   (FrapMenuRules         
     *rules,
                                                          const gchar           
     *filename);
 static void     frap_menu_standard_rules_add_category   (FrapMenuRules         
     *rules,
@@ -144,6 +145,7 @@
 frap_menu_standard_rules_rules_init (FrapMenuRulesIface *iface)
 {
   iface->add_rules = frap_menu_standard_rules_add_rules;
+  iface->add_all = frap_menu_standard_rules_add_all;
   iface->add_filename = frap_menu_standard_rules_add_filename;
   iface->add_category = frap_menu_standard_rules_add_category;
   iface->match = frap_menu_standard_rules_match;
@@ -154,6 +156,7 @@
 static void
 frap_menu_standard_rules_init (FrapMenuStandardRules *rules)
 {
+  rules->all = FALSE;
   rules->rules = NULL;
   rules->filenames = NULL;
   rules->categories = NULL; 
@@ -248,6 +251,18 @@
 
 
 static void
+frap_menu_standard_rules_add_all (FrapMenuRules *rules)
+{
+  FrapMenuStandardRules *std_rules = FRAP_MENU_STANDARD_RULES (rules);
+
+  g_return_if_fail (FRAP_IS_MENU_RULES (rules));
+
+  std_rules->all = TRUE;
+}
+
+
+
+static void
 frap_menu_standard_rules_add_filename (FrapMenuRules *rules,
                                        const gchar   *filename)
 {

Modified: libfrap/trunk/libfrap/menu/frap-menu-standard-rules.h
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-standard-rules.h       2007-01-14 
14:14:02 UTC (rev 24443)
+++ libfrap/trunk/libfrap/menu/frap-menu-standard-rules.h       2007-01-14 
14:47:00 UTC (rev 24444)
@@ -59,6 +59,9 @@
   /* Category rules */
   GList   *categories;
 
+  /* All rule */
+  guint    all : 1;
+
   /* Whether this rules object is treated as an include or exclude element */
   gboolean include;
 };

Modified: libfrap/trunk/libfrap/menu/frap-menu.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu.c      2007-01-14 14:14:02 UTC (rev 
24443)
+++ libfrap/trunk/libfrap/menu/frap-menu.c      2007-01-14 14:47:00 UTC (rev 
24444)
@@ -23,7 +23,9 @@
 #include <config.h>
 #endif
 
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 
 #include <libxfce4util/libxfce4util.h>
 
@@ -41,6 +43,25 @@
 
 
 
+/* Use g_access() on win32 */
+#if defined(G_OS_WIN32)
+#include <glib/gstdio.h>
+#else
+#define g_access(filename, mode) (access ((filename), (mode)))
+#endif
+
+
+
+/* Possible root menu files */
+static const gchar FRAP_MENU_ROOT_SPECS[][30] = 
+{
+  "menus/applications.menu",
+  "menus/gnome-applications.menu",
+  "menus/kde-applications.menu",
+};
+
+
+
 static gint frap_menu_ref_count = 0;
 
 
@@ -171,19 +192,20 @@
 
 
 
-static void               frap_menu_class_init                             
(FrapMenuClass       *klass);
-static void               frap_menu_instance_init                          
(FrapMenu            *menu);
-static void               frap_menu_finalize                               
(GObject             *object);
-static void               frap_menu_get_property                           
(GObject             *object,
-                                                                            
guint                prop_id,
-                                                                            
GValue              *value,
-                                                                            
GParamSpec          *pspec);
-static void               frap_menu_set_property                           
(GObject             *object,
-                                                                            
guint                prop_id,
-                                                                            
const GValue        *value,
-                                                                            
GParamSpec          *pspec);
+static void               frap_menu_class_init                             
(FrapMenuClass         *klass);
+static void               frap_menu_instance_init                          
(FrapMenu              *menu);
+static void               frap_menu_finalize                               
(GObject               *object);
+static void               frap_menu_get_property                           
(GObject               *object,
+                                                                            
guint                  prop_id,
+                                                                            
GValue                *value,
+                                                                            
GParamSpec            *pspec);
+static void               frap_menu_set_property                           
(GObject               *object,
+                                                                            
guint                  prop_id,
+                                                                            
const GValue          *value,
+                                                                            
GParamSpec            *pspec);
 
-static void               frap_menu_load                                   
(FrapMenu              *menu);
+static gboolean           frap_menu_load                                   
(FrapMenu              *menu,
+                                                                            
GError               **error);
 static void               frap_menu_start_element                          
(GMarkupParseContext   *context,
                                                                             
const gchar           *element_name,
                                                                             
const gchar          **attribute_names,
@@ -584,6 +606,7 @@
 
 /**
  * frap_menu_get_root:
+ * @error : Return location for errors or %NULL.
  *
  * Returns a pointer to the system root menu. If the root menu is not in memory
  * already, it is loaded from disk, which may take some time as it involves
@@ -596,12 +619,15 @@
  *               unref'd later.
  **/
 FrapMenu*
-frap_menu_get_root (void)
+frap_menu_get_root (GError **error)
 {
   static FrapMenu *root_menu = NULL;
+  gchar           *filename;
+  guint            n;
 
   if (G_UNLIKELY (root_menu == NULL))
     {
+#if 0
       /* Generate the location string of the root menu file */
       gchar *filename = g_build_path (G_DIR_SEPARATOR_S, "menus", 
"applications.menu", NULL);
 
@@ -623,6 +649,33 @@
       
       /* Free filename */
       g_free (filename);
+#endif
+      /* Search for a usable root menu file */
+      for (n = 0; n < G_N_ELEMENTS (FRAP_MENU_ROOT_SPECS) && root_menu == 
NULL; ++n)
+        {
+          /* Search for the root menu file */
+          filename = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, 
FRAP_MENU_ROOT_SPECS[n]);
+          if (G_UNLIKELY (filename == NULL))
+            continue;
+
+          /* Try to load the root menu from this file */
+          root_menu = frap_menu_new (filename, NULL);
+          if (G_LIKELY (root_menu != NULL))
+            {
+              /* Add weak pointer on the menu */
+              g_object_add_weak_pointer (G_OBJECT (root_menu), (gpointer) 
&root_menu);
+            }
+
+          /* Free filename string */
+          g_free (filename);
+        }
+
+      /* Check if we failed to load the root menu */
+      if (G_UNLIKELY (root_menu == NULL))
+        {
+          /* Let the caller know there was no suitable file */
+          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Failed to 
locate the application root menu"));
+        }
     }
   else
     g_object_ref (G_OBJECT (root_menu));
@@ -635,6 +688,7 @@
 /**
  * frap_menu_new:
  * @filename : filename containing the menu structure you want to load.
+ * @error    : return location for errors or %NULL.
  *
  * Parses a file and returns the menu structure found in this file. This
  * may involve parsing and merging of a lot of other files. So if you call this
@@ -645,18 +699,21 @@
  * Return value: Menu structure found in @filename.
  **/
 FrapMenu*
-frap_menu_new (const gchar *filename)
+frap_menu_new (const gchar *filename, GError **error)
 {
   FrapMenu *menu;
 
   g_return_val_if_fail (g_path_is_absolute (filename), NULL);
-  g_return_val_if_fail (g_file_test (filename, G_FILE_TEST_EXISTS), NULL);
 
   /* Create new menu */
   menu = g_object_new (FRAP_TYPE_MENU, "filename", filename, NULL);
 
-  /* Load menu structure */
-  frap_menu_load (menu);
+  /* Try to load the menu structure */
+  if (!frap_menu_load (menu, error))
+    {
+      g_object_unref (G_OBJECT (menu));
+      return NULL;
+    }
 
   return menu;
 }
@@ -950,11 +1007,9 @@
 
 
 
-static void
-frap_menu_load (FrapMenu *menu)
+static gboolean
+frap_menu_load (FrapMenu *menu, GError **error)
 {
-  GError *error = NULL;
-
   /* Parser structure (connect handlers etc.) */
   GMarkupParseContext *context;
   GMarkupParser parser = {
@@ -972,31 +1027,23 @@
   GIOStatus status;
   GIOChannel *stream;
 
-  g_return_if_fail (FRAP_IS_MENU (menu));
-  g_return_if_fail (menu->priv->filename != NULL);
+  g_return_val_if_fail (FRAP_IS_MENU (menu), FALSE);
+  g_return_val_if_fail (menu->priv->filename != NULL, FALSE);
 
   /* Try to open the menu file */
-  stream = g_io_channel_new_file (menu->priv->filename, "r", &error);
+  stream = g_io_channel_new_file (menu->priv->filename, "r", error);
 
   if (G_UNLIKELY (stream == NULL))
-    {
-      g_critical ("Failed to open menu file %s: %s", menu->priv->filename, 
error->message);
-      g_error_free (error);
-      return;
-    }
+    return FALSE;
 
   /* Try to read the menu file */
-  status = g_io_channel_read_to_end (stream, &contents, &contents_length, 
&error);
+  status = g_io_channel_read_to_end (stream, &contents, &contents_length, 
error);
   
   /* Free IO handle */
   g_io_channel_unref (stream);
 
   if (G_UNLIKELY (status != G_IO_STATUS_NORMAL))
-    {
-      g_critical ("Failed to read menu file %s: %s", menu->priv->filename, 
error->message);
-      g_error_free (error);
-      return;
-    }
+    return FALSE;
 
   /* Define menu parse context */
   menu_context.root_menu = menu;
@@ -1010,10 +1057,10 @@
   context = g_markup_parse_context_new (&parser, 0, &menu_context, NULL);
 
   /* Try to parse the menu file */
-  if (!g_markup_parse_context_parse (context, contents, contents_length, 
&error) || !g_markup_parse_context_end_parse (context, &error))
+  if (!g_markup_parse_context_parse (context, contents, contents_length, 
error) || !g_markup_parse_context_end_parse (context, error))
     {
-      g_critical ("Failed to parse menu file %s: %s", menu->priv->filename, 
error->message);
-      g_error_free (error);
+      g_markup_parse_context_free (context);
+      return FALSE;
     }
   
   /* Free file contents */
@@ -1036,6 +1083,8 @@
 
   frap_menu_resolve_items (menu, FALSE);
   frap_menu_resolve_items (menu, TRUE);
+  
+  return TRUE;
 }
 
 
@@ -1159,8 +1208,12 @@
       /* Fetch current rule from stack */
       current_rule = FRAP_MENU_RULES (g_list_first 
(menu_context->rule_stack)->data);
 
-      if (g_utf8_collate (element_name, "Filename") == 0)
+      if (g_utf8_collate (element_name, "All") == 0)
         {
+          frap_menu_rules_add_all (current_rule);
+        }
+      else if (g_utf8_collate (element_name, "Filename") == 0)
+        {
           menu_context->node_type = FRAP_MENU_PARSE_NODE_TYPE_FILENAME;
         }
       else if (g_utf8_collate (element_name, "Category") == 0)
@@ -1316,7 +1369,7 @@
 {
   FrapMenuParseContext *menu_context = (FrapMenuParseContext *)user_data;
   FrapMenu             *current_menu = g_list_first 
(menu_context->menu_stack)->data;
-  FrapMenuRules        *current_rule;
+  FrapMenuRules        *current_rule = NULL;
 
   /* Generate NULL-terminated string */
   gchar *content = g_strndup (text, text_len);
@@ -1335,6 +1388,10 @@
       frap_menu_parse_info_add_directory_name (current_menu->priv->parse_info, 
content);
       break;
 
+    case FRAP_MENU_PARSE_NODE_TYPE_DIRECTORY_DIR:
+      frap_menu_add_directory_dir (current_menu, content);
+      break;
+
     case FRAP_MENU_PARSE_NODE_TYPE_APP_DIR:
       frap_menu_add_app_dir (current_menu, content);
       break;
@@ -1344,11 +1401,13 @@
       break;
 
     case FRAP_MENU_PARSE_NODE_TYPE_FILENAME:
-      frap_menu_rules_add_filename (current_rule, content);
+      if (G_LIKELY (current_rule != NULL))
+        frap_menu_rules_add_filename (current_rule, content);
       break;
 
     case FRAP_MENU_PARSE_NODE_TYPE_CATEGORY:
-      frap_menu_rules_add_category (current_rule, content);
+      if (G_LIKELY (current_rule != NULL))
+        frap_menu_rules_add_category (current_rule, content);
       break;
 
     case FRAP_MENU_PARSE_NODE_TYPE_OLD:

Modified: libfrap/trunk/libfrap/menu/frap-menu.h
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu.h      2007-01-14 14:14:02 UTC (rev 
24443)
+++ libfrap/trunk/libfrap/menu/frap-menu.h      2007-01-14 14:47:00 UTC (rev 
24444)
@@ -46,9 +46,10 @@
 
 GType              frap_menu_get_type              (void) G_GNUC_CONST;
 
-FrapMenu          *frap_menu_get_root              (void) G_GNUC_CONST;
+FrapMenu          *frap_menu_get_root              (GError           **error) 
G_GNUC_CONST;
 
-FrapMenu          *frap_menu_new                   (const gchar *filename);
+FrapMenu          *frap_menu_new                   (const gchar       
*filename,
+                                                    GError           **error) 
G_GNUC_MALLOC;
 
 const gchar       *frap_menu_get_filename          (FrapMenu          *menu);
 void               frap_menu_set_filename          (FrapMenu          *menu,

Modified: libfrap/trunk/libfrap/menu/tests/test-display-root-menu.c
===================================================================
--- libfrap/trunk/libfrap/menu/tests/test-display-root-menu.c   2007-01-14 
14:14:02 UTC (rev 24443)
+++ libfrap/trunk/libfrap/menu/tests/test-display-root-menu.c   2007-01-14 
14:47:00 UTC (rev 24444)
@@ -320,6 +320,9 @@
 int main(int    argc,
          char **argv)
 {
+  GError *error     = NULL;
+  gint    exit_code = EXIT_SUCCESS;
+
   /* Initialize GTK */
   gtk_init (&argc, &argv);
 
@@ -329,25 +332,33 @@
   if (g_strv_length (argv) > 1)
     {
       /* Load menu from special filename */
-      root = frap_menu_new (argv[1]);
+      root = frap_menu_new (argv[1], &error);
     }
   else
     {
       /* Get a reference to the root menu */
-      root = frap_menu_get_root ();
+      root = frap_menu_get_root (&error);
     }
 
-  /* Create the main window */
-  create_main_window ();
+  if (G_LIKELY (root != NULL))
+    {
+      /* Create the main window */
+      create_main_window ();
 
-  /* Enter main loop */
-  gtk_main ();
+      /* Enter main loop */
+      gtk_main ();
 
-  /* Destroy the root menu */
-  g_object_unref (root);
+      /* Destroy the root menu */
+      g_object_unref (root);
+    }
+  else
+    {
+      g_error (error->message);
+      exit_code = EXIT_FAILURE;
+    }
 
   /* Shut down the menu library */
   frap_menu_shutdown ();
 
-  return EXIT_SUCCESS;
+  return exit_code;
 }

Modified: libfrap/trunk/libfrap/menu/tests/test-root-menu.c
===================================================================
--- libfrap/trunk/libfrap/menu/tests/test-root-menu.c   2007-01-14 14:14:02 UTC 
(rev 24443)
+++ libfrap/trunk/libfrap/menu/tests/test-root-menu.c   2007-01-14 14:47:00 UTC 
(rev 24444)
@@ -32,13 +32,14 @@
 int main (int    argc,
           char **argv)
 {
+  GError   *error = NULL;
   FrapMenu *root;
 
   /* Initialize FrapMenu */
   frap_menu_init ();
 
   /* Get system root menu */
-  root = frap_menu_get_root ();
+  root = frap_menu_get_root (&error);
 
   /* Unref root menu */
   g_object_unref (root);

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to