Author: jannis
Date: 2006-09-26 15:28:07 +0000 (Tue, 26 Sep 2006)
New Revision: 23213

Added:
   libfrap/trunk/libfrap/menu/frap-menu-or-rules.c
   libfrap/trunk/libfrap/menu/frap-menu-or-rules.h
   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
Modified:
   libfrap/trunk/libfrap/menu/ChangeLog
   libfrap/trunk/libfrap/menu/Makefile.am
   libfrap/trunk/libfrap/menu/frap-menu.c
Log:
        * Makefile.am, frap-menu-rules.{c.h}: FrapMenuRulesIface interface 
added.
          This interface will be used for the <And>, <Or> and <Not> elements.
          It provides virtual methods to add filename and category rules as
          well as FrapMenuRules objects (as the mentioned elements may be
          nested). It also provides a virtual method for matching menu items
          (essentially, desktop entries) against these rules.
        * Makefile.am, frap-menu-standard-rules.{c,h}: Implemented a base
          class for all rule sets (<And>, <Or>, <Not>). It implements the add
          methods of FrapMenuRulesIface. The responsibility of implementing the
          match method is forwarded to subclasses of FrapMenuStandardRules.
        * Makefile.am, frap-menu-or-rules.{c,h}: This first implementation of
          the FrapMenuRulesIface will be used for matching items against <Or>,
          <Include> and <Exclude> elements. The match method is not implemented
          yet, though.

Modified: libfrap/trunk/libfrap/menu/ChangeLog
===================================================================
--- libfrap/trunk/libfrap/menu/ChangeLog        2006-09-26 12:46:32 UTC (rev 
23212)
+++ libfrap/trunk/libfrap/menu/ChangeLog        2006-09-26 15:28:07 UTC (rev 
23213)
@@ -1,3 +1,20 @@
+2006-09-26     Jannis Pohlmann <[EMAIL PROTECTED]>
+
+       * Makefile.am, frap-menu-rules.{c.h}: FrapMenuRulesIface interface 
added.
+         This interface will be used for the <And>, <Or> and <Not> elements.
+         It provides virtual methods to add filename and category rules as
+         well as FrapMenuRules objects (as the mentioned elements may be
+         nested). It also provides a virtual method for matching menu items
+         (essentially, desktop entries) against these rules.
+       * Makefile.am, frap-menu-standard-rules.{c,h}: Implemented a base
+         class for all rule sets (<And>, <Or>, <Not>). It implements the add
+         methods of FrapMenuRulesIface. The responsibility of implementing the
+         match method is forwarded to subclasses of FrapMenuStandardRules.
+       * Makefile.am, frap-menu-or-rules.{c,h}: This first implementation of
+         the FrapMenuRulesIface will be used for matching items against <Or>,
+         <Include> and <Exclude> elements. The match method is not implemented
+         yet, though.
+
 2006-07-28     Jannis Pohlmann <[EMAIL PROTECTED]>
 
        * Import as libfrapmenu into the newly created libfrap development

Modified: libfrap/trunk/libfrap/menu/Makefile.am
===================================================================
--- libfrap/trunk/libfrap/menu/Makefile.am      2006-09-26 12:46:32 UTC (rev 
23212)
+++ libfrap/trunk/libfrap/menu/Makefile.am      2006-09-26 15:28:07 UTC (rev 
23213)
@@ -4,12 +4,18 @@
 
 libfrapmenu_la_SOURCES =                                               \
        frap-menu.c                                                     \
-       frap-menu-directory.c
+       frap-menu-directory.c                                           \
+       frap-menu-rules.c                                               \
+       frap-menu-standard-rules.c                                      \
+       frap-menu-or-rules.c                                            
 
 noinst_HEADERS =                                                       \
        libfrapmenu.h                                                   \
        frap-menu.h                                                     \
-       frap-menu-directory.h                                           
+       frap-menu-directory.h                                           \
+       frap-menu-rules.h                                               \
+       frap-menu-standard-rules.h                                      \
+       frap-menu-or-rules.h                                            
 
 INCLUDES =                                                             \
        $(GLIB_CFLAGS)                                                  \

Added: libfrap/trunk/libfrap/menu/frap-menu-or-rules.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-or-rules.c                             
(rev 0)
+++ libfrap/trunk/libfrap/menu/frap-menu-or-rules.c     2006-09-26 15:28:07 UTC 
(rev 23213)
@@ -0,0 +1,124 @@
+/* $Id$ */
+/* vi:set expandtab sw=2 sts=2: */
+/*-
+ * Copyright (c) 2006 Jannis Pohlmann <[EMAIL PROTECTED]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <frap-menu-standard-rules.h>
+#include <frap-menu-or-rules.h>
+
+
+
+static void     frap_menu_or_rules_class_init     (FrapMenuOrRulesClass  
*klass);
+static void     frap_menu_or_rules_init           (FrapMenuOrRules       
*rules);
+static void     frap_menu_or_rules_finalize       (GObject               
*object);
+static gboolean frap_menu_or_rules_match          (FrapMenuStandardRules 
*rules,
+                                                   const gchar           
*item);
+
+
+
+struct _FrapMenuOrRulesClass
+{
+  FrapMenuStandardRulesClass __parent__;
+};
+
+struct _FrapMenuOrRules
+{
+  FrapMenuStandardRules __parent__;
+};
+
+
+
+static GObjectClass *frap_menu_or_rules_parent_class = NULL;
+
+
+
+GType
+frap_menu_or_rules_get_type (void)
+{
+  static GType type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (type == G_TYPE_INVALID))
+    {
+      static const GTypeInfo info =
+      {
+        sizeof (FrapMenuOrRulesClass),
+        NULL,
+        NULL,
+        (GClassInitFunc) frap_menu_or_rules_class_init,
+        NULL,
+        NULL,
+        sizeof (FrapMenuOrRules),
+        0,
+        (GInstanceInitFunc) frap_menu_or_rules_init,
+        NULL,
+      };
+
+      type = g_type_register_static (G_TYPE_OBJECT, "FrapMenuOrRules", &info, 
0);
+    }
+
+  return type;
+}
+
+
+
+static void
+frap_menu_or_rules_class_init (FrapMenuOrRulesClass *klass)
+{
+  GObjectClass *gobject_class;
+  FrapMenuStandardRulesClass *std_rules_class;
+
+  frap_menu_or_rules_parent_class = g_type_class_peek_parent (klass);
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = frap_menu_or_rules_finalize;
+
+  std_rules_class = FRAP_MENU_STANDARD_RULES_CLASS (klass);
+  std_rules_class->match = frap_menu_or_rules_match;
+}
+
+
+
+static void
+frap_menu_or_rules_init (FrapMenuOrRules *rules)
+{
+}
+
+
+
+static void
+frap_menu_or_rules_finalize (GObject *object)
+{
+  FrapMenuOrRules *rules = FRAP_MENU_OR_RULES (object);
+
+  (*G_OBJECT_CLASS (frap_menu_or_rules_parent_class)->finalize) (object); 
+}
+
+
+
+static gboolean
+frap_menu_or_rules_match (FrapMenuStandardRules *rules,
+                          const gchar           *item)
+{
+  /* TODO */
+  return TRUE;
+}

Added: libfrap/trunk/libfrap/menu/frap-menu-or-rules.h
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-or-rules.h                             
(rev 0)
+++ libfrap/trunk/libfrap/menu/frap-menu-or-rules.h     2006-09-26 15:28:07 UTC 
(rev 23213)
@@ -0,0 +1,45 @@
+/* $Id$ */
+/* vi:set expandtab sw=2 sts=2: */
+/*-
+ * Copyright (c) 2006 Jannis Pohlmann <[EMAIL PROTECTED]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(LIBFRAPMENU_INSIDE_LIBFRAPMENU_H) && 
!defined(LIBFRAPMENU_COMPILATION)
+#error "Only <libfrapmenu/libfrapmenu.h> can be included directly. This file 
may disappear or change contents."
+#endif
+
+#ifndef __FRAP_MENU_OR_RULES_H__
+#define __FRAP_MENU_OR_RULES_H__
+
+#include <glib-object.h>
+
+typedef struct _FrapMenuOrRules        FrapMenuOrRules;
+typedef struct _FrapMenuOrRulesClass   FrapMenuOrRulesClass;
+
+#define FRAP_TYPE_MENU_OR_RULES             (frap_menu_or_rules_get_type ())
+#define FRAP_MENU_OR_RULES(obj)             (G_TYPE_CHECK_INSTANCE_CAST 
((obj), FRAP_TYPE_MENU_OR_RULES, FrapMenuOrRules))
+#define FRAP_MENU_OR_RULES_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), 
FRAP_TYPE_MENU_OR_RULES, FrapMenuOrRulesClass))
+#define FRAP_IS_MENU_OR_RULES(obj)          (G_TYPE_CHECK_INSTANCE_TYPE 
((obj), FRAP_TYPE_MENU_OR_RULES))
+#define FRAP_IS_MENU_OR_RULES_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((obj), 
FRAP_TYPE_MENU_OR_RULES))
+#define FRAP_MENU_OR_RULES_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), 
FRAP_TYPE_MENU_OR_RULES, FrapMenuOrRulesClass))
+
+GType frap_menu_or_rules_get_type      (void) G_GNUC_CONST;
+
+G_END_DECLS;
+
+#endif /* !__FRAP_MENU_OR_RULES_H__ */

Added: libfrap/trunk/libfrap/menu/frap-menu-rules.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-rules.c                                
(rev 0)
+++ libfrap/trunk/libfrap/menu/frap-menu-rules.c        2006-09-26 15:28:07 UTC 
(rev 23213)
@@ -0,0 +1,105 @@
+/* $Id$ */
+/* vi:set expandtab sw=2 sts=2: */
+/*-
+ * Copyright (c) 2006 Jannis Pohlmann <[EMAIL PROTECTED]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <frap-menu-rules.h>
+
+
+
+static void frap_menu_rules_class_init (gpointer klass);
+
+
+
+GType
+frap_menu_rules_get_type (void)
+{
+  static GType type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (type == G_TYPE_INVALID))
+    {
+      static const GTypeInfo info =
+      {
+        sizeof (FrapMenuRulesIface),
+        NULL,
+        NULL,
+        (GClassInitFunc) frap_menu_rules_class_init,
+        NULL,
+        NULL,
+        0,
+        0,
+        NULL,
+      };
+
+      type = g_type_register_static (G_TYPE_INTERFACE, "FrapMenuRules", &info, 
0);
+    }
+  
+  return type;
+}
+
+
+
+static void
+frap_menu_rules_class_init (gpointer klass)
+{
+}
+
+
+
+gboolean
+frap_menu_rules_match (FrapMenuRules *rules,
+                       const gchar   *name)
+{
+  g_return_val_if_fail (FRAP_IS_MENU_RULES (rules), FALSE);
+  return (*FRAP_MENU_RULES_GET_IFACE (rules)->match) (rules, name);
+}
+
+
+
+void
+frap_menu_rules_add_rules (FrapMenuRules *rules,
+                           FrapMenuRules *additional_rules)
+{
+  g_return_if_fail (FRAP_IS_MENU_RULES (rules));
+  g_return_if_fail (FRAP_IS_MENU_RULES (additional_rules));
+  (*FRAP_MENU_RULES_GET_IFACE (rules)->add_rules) (rules, additional_rules);
+}
+
+
+
+void
+frap_menu_rules_add_filename (FrapMenuRules *rules,
+                              const gchar   *filename)
+{
+  g_return_if_fail (FRAP_IS_MENU_RULES (rules));
+  (*FRAP_MENU_RULES_GET_IFACE (rules)->add_filename) (rules, filename);
+}
+
+
+void
+frap_menu_rules_add_category (FrapMenuRules *rules,
+                              const gchar   *category)
+{
+  g_return_if_fail (FRAP_IS_MENU_RULES (rules));
+  (*FRAP_MENU_RULES_GET_IFACE (rules)->add_category) (rules, category);
+}

Added: libfrap/trunk/libfrap/menu/frap-menu-rules.h
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-rules.h                                
(rev 0)
+++ libfrap/trunk/libfrap/menu/frap-menu-rules.h        2006-09-26 15:28:07 UTC 
(rev 23213)
@@ -0,0 +1,63 @@
+/* $Id$ */
+/* vi:set expandtab sw=2 sts=2: */
+/*-
+ * Copyright (c) 2006 Jannis Pohlmann <[EMAIL PROTECTED]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(LIBFRAPMENU_INSIDE_LIBFRAPMENU_H) && 
!defined(LIBFRAPMENU_COMPILATION)
+#error "Only <libfrapmenu/libfrapmenu.h> can be included directly. This file 
may disappear or change contents."
+#endif
+
+#ifndef __FRAP_MENU_RULES_H__
+#define __FRAP_MENU_RULES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS;
+
+typedef struct _FrapMenuRules      FrapMenuRules;
+typedef struct _FrapMenuRulesIface FrapMenuRulesIface;
+
+#define FRAP_TYPE_MENU_RULES           (frap_menu_rules_get_type ())
+#define FRAP_MENU_RULES(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
FRAP_TYPE_MENU_RULES, FrapMenuRules))
+#define FRAP_IS_MENU_RULES(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
FRAP_TYPE_MENU_RULES))
+#define FRAP_MENU_RULES_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), 
FRAP_TYPE_MENU_RULES, FrapMenuRulesIface))
+
+struct _FrapMenuRulesIface
+{
+  GTypeInterface __parent__;
+
+  /* Virtual methods */
+  gboolean  (*match)             (FrapMenuRules *rules, 
+                                  const gchar   *name);
+  void      (*add_rules)         (FrapMenuRules *rules, 
+                                  FrapMenuRules *additional_rules);
+  void      (*add_filename)      (FrapMenuRules *rules, 
+                                  const gchar   *filename);
+  void      (*add_category)      (FrapMenuRules *rules, const gchar *category);
+
+};
+
+GType    frap_menu_rules_get_type    (void) G_GNUC_CONST;
+
+gboolean frap_menu__rules_match_item (FrapMenuRules *rules,
+                                      const gchar   *name);
+
+G_END_DECLS;
+
+#endif /* !__FRAP_MENU_RULES_H__ */

Added: libfrap/trunk/libfrap/menu/frap-menu-standard-rules.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-standard-rules.c                       
        (rev 0)
+++ libfrap/trunk/libfrap/menu/frap-menu-standard-rules.c       2006-09-26 
15:28:07 UTC (rev 23213)
@@ -0,0 +1,195 @@
+/* $Id$ */
+/* vi:set expandtab sw=2 sts=2: */
+/*-
+ * Copyright (c) 2006 Jannis Pohlmann <[EMAIL PROTECTED]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <frap-menu-rules.h>
+#include <frap-menu-standard-rules.h>
+
+
+
+static void     frap_menu_standard_rules_class_init     
(FrapMenuStandardRulesClass *klass);
+static void     frap_menu_standard_rules_rules_init     (FrapMenuRulesIface    
     *iface);
+static void     frap_menu_standard_rules_init           (FrapMenuStandardRules 
     *rules);
+static void     frap_menu_standard_rules_finalize       (GObject               
     *object);
+static gboolean frap_menu_standard_rules_match          (FrapMenuRules         
     *rules,
+                                                         const gchar           
     *item);
+static void     frap_menu_standard_rules_add_rules      (FrapMenuRules         
     *rules,
+                                                         FrapMenuRules         
     *additional_rules);
+static void     frap_menu_standard_rules_add_filename   (FrapMenuRules         
     *rules,
+                                                         const gchar           
     *filename);
+static void     frap_menu_standard_rules_add_category   (FrapMenuRules         
     *rules,
+                                                         const gchar           
     *category);
+
+
+static GObjectClass *frap_menu_standard_rules_parent_class = NULL;
+
+
+
+GType
+frap_menu_standard_rules_get_type (void)
+{
+  static GType type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (type == G_TYPE_INVALID))
+    {
+      static const GTypeInfo info =
+      {
+        sizeof (FrapMenuStandardRulesClass),
+        NULL,
+        NULL,
+        (GClassInitFunc) frap_menu_standard_rules_class_init,
+        NULL,
+        NULL,
+        sizeof (FrapMenuStandardRules),
+        0,
+        (GInstanceInitFunc) frap_menu_standard_rules_init,
+        NULL,
+      };
+
+      static const GInterfaceInfo rules_info = 
+      {
+        (GInterfaceInitFunc) frap_menu_standard_rules_rules_init,
+        NULL,
+        NULL,
+      };
+
+      type = g_type_register_static (G_TYPE_OBJECT, "FrapMenuStandardRules", 
&info, G_TYPE_FLAG_ABSTRACT);
+      g_type_add_interface_static (type, FRAP_TYPE_MENU_RULES, &rules_info);
+    }
+
+  return type;
+}
+
+
+
+static void
+frap_menu_standard_rules_class_init (FrapMenuStandardRulesClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  frap_menu_standard_rules_parent_class = g_type_class_peek_parent (klass);
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = frap_menu_standard_rules_finalize;
+}
+
+
+
+static void
+frap_menu_standard_rules_rules_init (FrapMenuRulesIface *iface)
+{
+  iface->add_rules = frap_menu_standard_rules_add_rules;
+  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;
+}
+  
+
+
+static void
+frap_menu_standard_rules_init (FrapMenuStandardRules *rules)
+{
+  rules->rules = NULL;
+  rules->filenames = NULL;
+  rules->categories = NULL; 
+}
+
+
+
+static void
+frap_menu_standard_rules_finalize (GObject *object)
+{
+  FrapMenuStandardRules *rules = FRAP_MENU_STANDARD_RULES (object);
+
+  g_list_foreach (rules->rules, (GFunc) g_object_unref, NULL);
+  g_list_free (rules->rules);
+
+  g_list_foreach (rules->filenames, (GFunc) g_free, NULL);
+  g_list_free (rules->filenames);
+
+  g_list_foreach (rules->categories, (GFunc) g_free, NULL);
+  g_list_free (rules->categories);
+
+  (*G_OBJECT_CLASS (frap_menu_standard_rules_parent_class)->finalize) 
(object); 
+}
+
+
+
+static void
+frap_menu_standard_rules_add_rules (FrapMenuRules *rules,
+                                    FrapMenuRules *additional_rules)
+{
+  g_return_if_fail (FRAP_IS_MENU_RULES (rules));
+  g_return_if_fail (FRAP_IS_MENU_RULES (additional_rules));
+
+  FrapMenuStandardRules *std_rules = FRAP_MENU_STANDARD_RULES (rules);
+
+  /* Remove floating reference (if any) and request a normal one */
+  g_object_ref_sink (G_OBJECT (additional_rules));
+
+  /* Append rules to the list */
+  std_rules->rules = g_list_append (std_rules->rules, additional_rules);
+}
+
+
+
+static void
+frap_menu_standard_rules_add_filename (FrapMenuRules *rules,
+                                       const gchar   *filename)
+{
+  g_return_if_fail (FRAP_IS_MENU_RULES (rules));
+  g_return_if_fail (filename != NULL);
+
+  FrapMenuStandardRules *std_rules = FRAP_MENU_STANDARD_RULES (rules);
+
+  /* Append filename to the list */
+  std_rules->filenames = g_list_append (std_rules->filenames, g_strdup 
(filename));
+}
+
+
+
+static void
+frap_menu_standard_rules_add_category (FrapMenuRules *rules,
+                                       const gchar   *category)
+{
+  g_return_if_fail (FRAP_IS_MENU_RULES (rules));
+  g_return_if_fail (category != NULL);
+
+  FrapMenuStandardRules *std_rules = FRAP_MENU_STANDARD_RULES (rules);
+
+  /* Append category to the list (if not yet included) */
+  std_rules->categories = g_list_append (std_rules->categories, g_strdup 
(category));
+}
+
+
+static gboolean
+frap_menu_standard_rules_match (FrapMenuRules *rules,
+                                const gchar   *item)
+{
+  g_return_val_if_fail (FRAP_IS_MENU_RULES (rules), FALSE);
+
+  FrapMenuStandardRules *std_rules = FRAP_MENU_STANDARD_RULES (rules);
+
+  return (*FRAP_MENU_STANDARD_RULES_GET_CLASS (std_rules)->match) (std_rules, 
item);
+}

Added: libfrap/trunk/libfrap/menu/frap-menu-standard-rules.h
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu-standard-rules.h                       
        (rev 0)
+++ libfrap/trunk/libfrap/menu/frap-menu-standard-rules.h       2006-09-26 
15:28:07 UTC (rev 23213)
@@ -0,0 +1,62 @@
+/* $Id$ */
+/* vi:set expandtab sw=2 sts=2: */
+/*-
+ * Copyright (c) 2006 Jannis Pohlmann <[EMAIL PROTECTED]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FSTANDARD A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(LIBFRAPMENU_INSIDE_LIBFRAPMENU_H) && 
!defined(LIBFRAPMENU_COMPILATION)
+#error "Only <libfrapmenu/libfrapmenu.h> can be included directly. This file 
may disappear or change contents."
+#endif
+
+#ifndef __FRAP_MENU_STANDARD_RULES_H__
+#define __FRAP_MENU_STANDARD_RULES_H__
+
+#include <glib-object.h>
+
+typedef struct _FrapMenuStandardRules        FrapMenuStandardRules;
+typedef struct _FrapMenuStandardRulesClass   FrapMenuStandardRulesClass;
+
+#define FRAP_TYPE_MENU_STANDARD_RULES             (frap_menu_or_rules_get_type 
())
+#define FRAP_MENU_STANDARD_RULES(obj)             (G_TYPE_CHECK_INSTANCE_CAST 
((obj), FRAP_TYPE_MENU_STANDARD_RULES, FrapMenuStandardRules))
+#define FRAP_MENU_STANDARD_RULES_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST 
((klass), FRAP_TYPE_MENU_STANDARD_RULES, FrapMenuStandardRulesClass))
+#define FRAP_IS_MENU_STANDARD_RULES(obj)          (G_TYPE_CHECK_INSTANCE_TYPE 
((obj), FRAP_TYPE_MENU_STANDARD_RULES))
+#define FRAP_IS_MENU_STANDARD_RULES_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE 
((obj), FRAP_TYPE_MENU_STANDARD_RULES))
+#define FRAP_MENU_STANDARD_RULES_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS 
((obj), FRAP_TYPE_MENU_STANDARD_RULES, FrapMenuStandardRulesClass))
+
+struct _FrapMenuStandardRulesClass
+{
+  GObjectClass __parent__;
+
+  gboolean (*match) (FrapMenuStandardRules *rules, 
+                     const gchar           *item);
+};
+
+struct _FrapMenuStandardRules
+{
+  GObject __parent__;
+
+  GList *rules;
+  GList *filenames;
+  GList *categories;
+};
+
+GType frap_menu_standard_rules_get_type      (void) G_GNUC_CONST;
+
+G_END_DECLS;
+
+#endif /* !__FRAP_MENU_STANDARD_RULES_H__ */

Modified: libfrap/trunk/libfrap/menu/frap-menu.c
===================================================================
--- libfrap/trunk/libfrap/menu/frap-menu.c      2006-09-26 12:46:32 UTC (rev 
23212)
+++ libfrap/trunk/libfrap/menu/frap-menu.c      2006-09-26 15:28:07 UTC (rev 
23213)
@@ -27,6 +27,7 @@
 
 #include <libxfce4util/libxfce4util.h>
 
+#include <frap-menu-standard-rules.h>
 #include <frap-menu-directory.h>
 #include <frap-menu.h>
 
@@ -279,7 +280,7 @@
 {
   GObjectClass *gobject_class;
 
-  g_type_class_add_private (klass, sizeof(FrapMenuPrivate));
+  g_type_class_add_private (klass, sizeof (FrapMenuPrivate));
 
   /* Determine the parent type class */
   frap_menu_parent_class = g_type_class_peek_parent (klass);

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

Reply via email to