Author: jannis
Date: 2008-01-02 15:50:33 +0000 (Wed, 02 Jan 2008)
New Revision: 26527

Modified:
   libxfce4menu/trunk/ChangeLog
   libxfce4menu/trunk/libxfce4menu/xfce-menu-item.c
   libxfce4menu/trunk/libxfce4menu/xfce-menu-item.h
   libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.c
   libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.h
   libxfce4menu/trunk/libxfce4menu/xfce-menu.c
   libxfce4menu/trunk/tests/test-display-menu.c
Log:
        * libxfce4menu/xfce-menu-item.{c,h}: Add support for the Comment field
          via xfce_menu_item_get_comment().
        * libxfce4menu/xfce-menu-monitor.{c,h}: Add support for defining what
          kind of files/directories are monitored (XfceMenuMonitorFlags,
          xfce_menu_monitor_set_flags(), xfce_menu_monitor_get_flags(),
          xfce_menu_monitor_has_flags()).
        * libxfce4menu/xfce-menu.c: Check monitor flags before adding
          files/directories to the monitoring system.
        * tests/test-display-menu.c: Center window on screen.

Modified: libxfce4menu/trunk/ChangeLog
===================================================================
--- libxfce4menu/trunk/ChangeLog        2008-01-02 15:41:28 UTC (rev 26526)
+++ libxfce4menu/trunk/ChangeLog        2008-01-02 15:50:33 UTC (rev 26527)
@@ -1,4 +1,20 @@
+2008-01-02     Jannis Pohlmann <[EMAIL PROTECTED]>
+
+       * libxfce4menu/xfce-menu-item.{c,h}: Add support for the Comment field
+         via xfce_menu_item_get_comment().
+
+2007-12-29     Jannis Pohlmann <[EMAIL PROTECTED]>
+
+       * libxfce4menu/xfce-menu-monitor.{c,h}: Add support for defining what
+         kind of files/directories are monitored (XfceMenuMonitorFlags,
+         xfce_menu_monitor_set_flags(), xfce_menu_monitor_get_flags(),
+         xfce_menu_monitor_has_flags()).
+       * libxfce4menu/xfce-menu.c: Check monitor flags before adding
+         files/directories to the monitoring system.
+       * tests/test-display-menu.c: Center window on screen.
+
 2007-12-27     Jannis Pohlmann <[EMAIL PROTECTED]>
+
        * libxfce4menu/xfce-menu-monitor.c: Use the KEY, not the VALUE pointer
          to remove items from the shared handle hash table. In this case, use
          the directory string instead of the shared handle. This should fix

Modified: libxfce4menu/trunk/libxfce4menu/xfce-menu-item.c
===================================================================
--- libxfce4menu/trunk/libxfce4menu/xfce-menu-item.c    2008-01-02 15:41:28 UTC 
(rev 26526)
+++ libxfce4menu/trunk/libxfce4menu/xfce-menu-item.c    2008-01-02 15:50:33 UTC 
(rev 26527)
@@ -47,6 +47,7 @@
   PROP_STARTUP_NOTIFICATION,
   PROP_NAME,
   PROP_GENERIC_NAME,
+  PROP_COMMENT,
   PROP_ICON_NAME,
   PROP_COMMAND,
   PROP_TRY_EXEC,
@@ -103,6 +104,9 @@
   /* Generic name of the menu item */
   gchar    *generic_name;
 
+  /* Comment/description of the item */
+  gchar    *comment;
+
   /* Command to be executed when the menu item is clicked */
   gchar    *command;
 
@@ -286,6 +290,20 @@
                                                         G_PARAM_READWRITE));
 
   /**
+   * XfceMenuItem:comment:
+   *
+   * Comment/description for the application. To be displayed e.g. in tooltips 
of
+   * GtkMenuItems.
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_COMMENT,
+                                   g_param_spec_string ("comment",
+                                                        "Comment",
+                                                        "Comment/description 
for the application",
+                                                        NULL,
+                                                        G_PARAM_READWRITE));
+
+  /**
    * XfceMenuItem:command:
    *
    * Command to be executed when the menu item is clicked.
@@ -356,6 +374,7 @@
   item->priv->desktop_id = NULL;
   item->priv->name = NULL;
   item->priv->generic_name = NULL;
+  item->priv->comment = NULL;
   item->priv->filename = NULL;
   item->priv->command = NULL;
   item->priv->try_exec = NULL;
@@ -377,6 +396,7 @@
   g_free (item->priv->desktop_id);
   g_free (item->priv->name);
   g_free (item->priv->generic_name);
+  g_free (item->priv->comment);
   g_free (item->priv->filename);
   g_free (item->priv->command);
   g_free (item->priv->try_exec);
@@ -413,6 +433,10 @@
       g_value_set_string (value, xfce_menu_item_get_filename (item));
       break;
 
+    case PROP_COMMENT:
+      g_value_set_string (value, xfce_menu_item_get_comment (item));
+      break;
+
     case PROP_REQUIRES_TERMINAL:
     case PROP_NO_DISPLAY:
     case PROP_STARTUP_NOTIFICATION:
@@ -473,6 +497,10 @@
       xfce_menu_item_set_generic_name (item, g_value_get_string (value));
       break;
 
+    case PROP_COMMENT:
+      xfce_menu_item_set_comment (item, g_value_get_string (value));
+      break;
+
     case PROP_COMMAND:
       xfce_menu_item_set_command (item, g_value_get_string (value));
       break;
@@ -505,6 +533,7 @@
   const gchar  *path;
   const gchar  *name;
   const gchar  *generic_name;
+  const gchar  *comment;
   const gchar  *exec;
   const gchar  *try_exec;
   const gchar  *icon;
@@ -537,6 +566,7 @@
   /* Parse name, exec command and icon name */
   name = xfce_rc_read_entry (rc, "Name", NULL);
   generic_name = xfce_rc_read_entry (rc, "GenericName", NULL);
+  comment = xfce_rc_read_entry (rc, "Comment", NULL);
   exec = xfce_rc_read_entry (rc, "Exec", NULL);
   try_exec = xfce_rc_read_entry (rc, "TryExec", NULL);
   icon = xfce_rc_read_entry (rc, "Icon", NULL);
@@ -557,6 +587,7 @@
                            "try-exec", try_exec,
                            "name", name, 
                            "generic-name", generic_name,
+                           "comment", comment,
                            "icon-name", icon, 
                            "requires-terminal", terminal, 
                            "no-display", no_display, 
@@ -837,6 +868,40 @@
 
 
 const gchar*
+xfce_menu_item_get_comment (XfceMenuItem *item)
+{
+  g_return_val_if_fail (XFCE_IS_MENU_ITEM (item), NULL);
+  return item->priv->comment;
+}
+
+
+
+void
+xfce_menu_item_set_comment (XfceMenuItem *item,
+                                 const gchar  *comment)
+{
+  g_return_if_fail (XFCE_IS_MENU_ITEM (item));
+
+  if (G_UNLIKELY (item->priv->comment != NULL))
+    {
+      /* Abort if old and new comment are equal */
+      if (G_UNLIKELY (g_utf8_collate (item->priv->comment, comment) == 0))
+        return;
+
+      /* Otherwise free old comment */
+      g_free (item->priv->comment);
+    }
+
+  /* Assign new comment */
+  item->priv->comment = g_strdup (comment);
+
+  /* Notify listeners */
+  g_object_notify (G_OBJECT (item), "comment");
+}
+
+
+
+const gchar*
 xfce_menu_item_get_icon_name (XfceMenuItem *item)
 {
   g_return_val_if_fail (XFCE_IS_MENU_ITEM (item), NULL);

Modified: libxfce4menu/trunk/libxfce4menu/xfce-menu-item.h
===================================================================
--- libxfce4menu/trunk/libxfce4menu/xfce-menu-item.h    2008-01-02 15:41:28 UTC 
(rev 26526)
+++ libxfce4menu/trunk/libxfce4menu/xfce-menu-item.h    2008-01-02 15:50:33 UTC 
(rev 26527)
@@ -65,6 +65,9 @@
 const gchar  *xfce_menu_item_get_generic_name                  (XfceMenuItem 
*item);
 void          xfce_menu_item_set_generic_name                  (XfceMenuItem 
*item,
                                                                 const gchar  
*generic_name);
+const gchar  *xfce_menu_item_get_comment                       (XfceMenuItem 
*item);
+void          xfce_menu_item_set_comment                       (XfceMenuItem 
*item,
+                                                                const gchar  
*comment);
 const gchar  *xfce_menu_item_get_icon_name                     (XfceMenuItem 
*item);
 void          xfce_menu_item_set_icon_name                     (XfceMenuItem 
*item,
                                                                 const gchar  
*icon_name);

Modified: libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.c
===================================================================
--- libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.c 2008-01-02 15:41:28 UTC 
(rev 26526)
+++ libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.c 2008-01-02 15:50:33 UTC 
(rev 26527)
@@ -37,6 +37,9 @@
   NULL,
 };
 
+/* Monitor flags */
+static XfceMenuMonitorFlags xfce_menu_monitor_flags;
+
 /* User data as provided by the client */
 static gpointer xfce_menu_monitor_user_data = NULL;
 
@@ -62,6 +65,7 @@
   /* Initialize hash tables */
   xfce_menu_monitor_item_handles = g_hash_table_new (NULL, NULL);
   xfce_menu_monitor_shared_handles = g_hash_table_new_full (g_str_hash, 
g_str_equal, g_free, g_free);
+  xfce_menu_monitor_flags = 
XFCE_MENU_MONITOR_DIRECTORIES|XFCE_MENU_MONITOR_MENU_FILES|XFCE_MENU_MONITOR_DIRECTORY_FILES|XFCE_MENU_MONITOR_DESKTOP_FILES;
 }
 
 
@@ -330,3 +334,27 @@
         }
     }
 }
+
+
+
+void 
+xfce_menu_monitor_set_flags (XfceMenuMonitorFlags flags)
+{
+  xfce_menu_monitor_flags = flags;
+}
+
+
+
+XfceMenuMonitorFlags 
+xfce_menu_monitor_get_flags (void)
+{
+  return xfce_menu_monitor_flags;
+}
+
+
+
+gboolean
+xfce_menu_monitor_has_flags (XfceMenuMonitorFlags flags)
+{
+  return (xfce_menu_monitor_flags & flags) != 0;
+}

Modified: libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.h
===================================================================
--- libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.h 2008-01-02 15:41:28 UTC 
(rev 26526)
+++ libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.h 2008-01-02 15:50:33 UTC 
(rev 26527)
@@ -32,22 +32,33 @@
 
 G_BEGIN_DECLS;
 
+typedef enum
+{
+  XFCE_MENU_MONITOR_DIRECTORIES     = 1 << 0,
+  XFCE_MENU_MONITOR_MENU_FILES      = 1 << 1,
+  XFCE_MENU_MONITOR_DIRECTORY_FILES = 1 << 2,
+  XFCE_MENU_MONITOR_DESKTOP_FILES   = 1 << 3
+} XfceMenuMonitorFlags;
+
 typedef struct _XfceMenuMonitorVTable XfceMenuMonitorVTable;
 
-void     xfce_menu_monitor_set_vtable       (XfceMenuMonitorVTable *vtable, 
-                                             gpointer               user_data);
-gpointer xfce_menu_monitor_add_item         (XfceMenu              *menu,
-                                             XfceMenuItem          *item);
-void     xfce_menu_monitor_remove_item      (XfceMenu              *menu,
-                                             XfceMenuItem          *item);
-gpointer xfce_menu_monitor_add_directory    (XfceMenu              *menu,
-                                             const gchar           *directory);
-void     xfce_menu_monitor_remove_directory (XfceMenu              *menu,
-                                             const gchar           *directory);
-gpointer xfce_menu_monitor_add_file         (XfceMenu              *menu,
-                                             const gchar           *filename);
-void     xfce_menu_monitor_remove_file      (XfceMenu              *menu,
-                                             const gchar           *filename);
+void                 xfce_menu_monitor_set_vtable       (XfceMenuMonitorVTable 
*vtable, 
+                                                         gpointer              
 user_data);
+gpointer             xfce_menu_monitor_add_item         (XfceMenu              
*menu,
+                                                         XfceMenuItem          
*item);
+void                 xfce_menu_monitor_remove_item      (XfceMenu              
*menu,
+                                                         XfceMenuItem          
*item);
+gpointer             xfce_menu_monitor_add_directory    (XfceMenu              
*menu,
+                                                         const gchar           
*directory);
+void                 xfce_menu_monitor_remove_directory (XfceMenu              
*menu,
+                                                         const gchar           
*directory);
+gpointer             xfce_menu_monitor_add_file         (XfceMenu              
*menu,
+                                                         const gchar           
*filename);
+void                 xfce_menu_monitor_remove_file      (XfceMenu              
*menu,
+                                                         const gchar           
*filename);
+void                 xfce_menu_monitor_set_flags        (XfceMenuMonitorFlags  
 flags);
+XfceMenuMonitorFlags xfce_menu_monitor_get_flags        (void);
+gboolean             xfce_menu_monitor_has_flags        (XfceMenuMonitorFlags  
 flags);
 
 /**
  * XfceMenuMonitorVTable:

Modified: libxfce4menu/trunk/libxfce4menu/xfce-menu.c
===================================================================
--- libxfce4menu/trunk/libxfce4menu/xfce-menu.c 2008-01-02 15:41:28 UTC (rev 
26526)
+++ libxfce4menu/trunk/libxfce4menu/xfce-menu.c 2008-01-02 15:50:33 UTC (rev 
26527)
@@ -3155,18 +3155,21 @@
   g_return_if_fail (XFCE_IS_MENU (menu));
 
   /* Monitor the menu file */
-  xfce_menu_monitor_add_file (menu, menu->priv->filename);
+  if (G_LIKELY (xfce_menu_monitor_has_flags (XFCE_MENU_MONITOR_MENU_FILES)))
+    xfce_menu_monitor_add_file (menu, menu->priv->filename);
 
   /* Monitor the menu directory file */
-  if (XFCE_IS_MENU_DIRECTORY (menu->priv->directory))
+  if (G_LIKELY (XFCE_IS_MENU_DIRECTORY (menu->priv->directory) && 
xfce_menu_monitor_has_flags (XFCE_MENU_MONITOR_DIRECTORY_FILES)))
     xfce_menu_monitor_add_file (menu, xfce_menu_directory_get_filename 
(menu->priv->directory));
 
   /* Monitor the application directories */
-  for (iter = menu->priv->app_dirs; iter != NULL; iter = g_slist_next (iter))
-    xfce_menu_monitor_add_directory (menu, (const gchar *)iter->data);
+  if (G_LIKELY (xfce_menu_monitor_has_flags (XFCE_MENU_MONITOR_DIRECTORIES)))
+    for (iter = menu->priv->app_dirs; iter != NULL; iter = g_slist_next (iter))
+      xfce_menu_monitor_add_directory (menu, (const gchar *)iter->data);
 
   /* Monitor items in the menu pool */
-  xfce_menu_item_pool_foreach (menu->priv->pool, (GHFunc) item_monitor_start, 
menu);
+  if (G_LIKELY (xfce_menu_monitor_has_flags (XFCE_MENU_MONITOR_DESKTOP_FILES)))
+    xfce_menu_item_pool_foreach (menu->priv->pool, (GHFunc) 
item_monitor_start, menu);
 
   /* Monitor items in submenus */
   for (iter = menu->priv->submenus; iter != NULL; iter = g_slist_next (iter))

Modified: libxfce4menu/trunk/tests/test-display-menu.c
===================================================================
--- libxfce4menu/trunk/tests/test-display-menu.c        2008-01-02 15:41:28 UTC 
(rev 26526)
+++ libxfce4menu/trunk/tests/test-display-menu.c        2008-01-02 15:50:33 UTC 
(rev 26527)
@@ -351,6 +351,7 @@
   /* Create main window */
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (GTK_WINDOW (window), _("XfceMenu: Display Menu Test"));
+  gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
   gtk_container_set_border_width (GTK_CONTAINER (window), 12);
   gtk_widget_show (window);
 

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

Reply via email to