Author: jannis Date: 2008-08-31 18:53:12 +0000 (Sun, 31 Aug 2008) New Revision: 27630
Modified: libxfce4menu/trunk/ChangeLog libxfce4menu/trunk/libxfce4menu/xfce-menu-item.c libxfce4menu/trunk/libxfce4menu/xfce-menu-item.h Log: * libxfce4menu/xfce-menu-item.{c,h}: Add xfce_menu_item_only_show_in_environment() function which checks whether the current environment is present in the OnlyShowIn key of a menu item. This should close bug #3741. Modified: libxfce4menu/trunk/ChangeLog =================================================================== --- libxfce4menu/trunk/ChangeLog 2008-08-31 18:33:06 UTC (rev 27629) +++ libxfce4menu/trunk/ChangeLog 2008-08-31 18:53:12 UTC (rev 27630) @@ -1,5 +1,12 @@ 2008-08-31 Jannis Pohlmann <[EMAIL PROTECTED]> + * libxfce4menu/xfce-menu-item.{c,h}: Add + xfce_menu_item_only_show_in_environment() function which checks + whether the current environment is present in the OnlyShowIn key of + a menu item. This should close bug #3741. + +2008-08-31 Jannis Pohlmann <[EMAIL PROTECTED]> + * autogen.sh: Don't print errors when trying to detect the revision of a git svn repository. Modified: libxfce4menu/trunk/libxfce4menu/xfce-menu-item.c =================================================================== --- libxfce4menu/trunk/libxfce4menu/xfce-menu-item.c 2008-08-31 18:33:06 UTC (rev 27629) +++ libxfce4menu/trunk/libxfce4menu/xfce-menu-item.c 2008-08-31 18:53:12 UTC (rev 27630) @@ -1093,7 +1093,7 @@ if (G_UNLIKELY (env == NULL)) return TRUE; - /* Check if we have a OnlyShowIn OR a NotShowIn list (only one of them will be + /* Check if we have an OnlyShowIn OR a NotShowIn list (only one of them will be * there, according to the desktop entry specification) */ if (G_UNLIKELY (item->priv->only_show_in != NULL)) { @@ -1129,6 +1129,38 @@ +gboolean +xfce_menu_item_only_show_in_environment (XfceMenuItem *item) +{ + const gchar *env; + gboolean show = FALSE; + int i; + + g_return_val_if_fail (XFCE_IS_MENU_ITEM (item), FALSE); + + /* Determine current environment */ + env = xfce_menu_get_environment (); + + /* If no environment has been set, the contents of OnlyShowIn don't matter */ + if (G_LIKELY (env == NULL)) + return FALSE; + + /* Check if we have an OnlyShowIn list */ + if (G_UNLIKELY (item->priv->only_show_in != NULL)) + { + for (i = 0; i < g_strv_length (item->priv->only_show_in); ++i) + if (G_UNLIKELY (g_utf8_collate (item->priv->only_show_in[i], env) == 0)) + { + show = TRUE; + break; + } + } + + return show; +} + + + void xfce_menu_item_ref (XfceMenuItem *item) { Modified: libxfce4menu/trunk/libxfce4menu/xfce-menu-item.h =================================================================== --- libxfce4menu/trunk/libxfce4menu/xfce-menu-item.h 2008-08-31 18:33:06 UTC (rev 27629) +++ libxfce4menu/trunk/libxfce4menu/xfce-menu-item.h 2008-08-31 18:53:12 UTC (rev 27630) @@ -89,6 +89,7 @@ gboolean xfce_menu_item_has_category (XfceMenuItem *item, const gchar *category); gboolean xfce_menu_item_show_in_environment (XfceMenuItem *item); +gboolean xfce_menu_item_only_show_in_environment (XfceMenuItem *item); void xfce_menu_item_ref (XfceMenuItem *item); void xfce_menu_item_unref (XfceMenuItem *item); gint xfce_menu_item_get_allocated (XfceMenuItem *item); _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits