[gnome-panel] menu: move get_applications_menu to utils file



commit 5de566dc8bb88820f934a26668fb768ba1088f7b
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Sep 15 17:04:32 2018 +0300

    menu: move get_applications_menu to utils file

 modules/menu/gp-menu-bar-applet.c    | 14 +-------------
 modules/menu/gp-menu-button-applet.c | 16 ++--------------
 modules/menu/gp-menu-utils.c         | 12 ++++++++++++
 modules/menu/gp-menu-utils.h         | 18 ++++++++++--------
 4 files changed, 25 insertions(+), 35 deletions(-)
---
diff --git a/modules/menu/gp-menu-bar-applet.c b/modules/menu/gp-menu-bar-applet.c
index f0377fd10..5346a28e0 100644
--- a/modules/menu/gp-menu-bar-applet.c
+++ b/modules/menu/gp-menu-bar-applet.c
@@ -78,18 +78,6 @@ button_press_event_cb (GtkWidget      *widget,
   return TRUE;
 }
 
-static gchar *
-get_applications_menu (void)
-{
-  const gchar *xdg_menu_prefx;
-
-  xdg_menu_prefx = g_getenv ("XDG_MENU_PREFIX");
-  if (!xdg_menu_prefx || *xdg_menu_prefx == '\0')
-    return g_strdup ("gnome-applications.menu");
-
-  return g_strdup_printf ("%sapplications.menu", xdg_menu_prefx);
-}
-
 static gchar *
 get_settings_menu (void)
 {
@@ -136,7 +124,7 @@ append_applications_item (GpMenuBarApplet *applet)
   tooltip = _("Browse and run installed applications");
   gtk_widget_set_tooltip_text (applet->applications_item, tooltip);
 
-  menu = get_applications_menu ();
+  menu = gp_menu_utils_get_applications_menu ();
 
   applet->applications_menu = gp_menu_new (GP_APPLET (applet), menu, TRUE);
   g_free (menu);
diff --git a/modules/menu/gp-menu-button-applet.c b/modules/menu/gp-menu-button-applet.c
index 276a30d67..12714f2af 100644
--- a/modules/menu/gp-menu-button-applet.c
+++ b/modules/menu/gp-menu-button-applet.c
@@ -232,18 +232,6 @@ split_menu_uri (const gchar  *menu_uri,
   return g_strdup (p);
 }
 
-static gchar *
-get_applications_menu (void)
-{
-  const gchar *xdg_menu_prefx;
-
-  xdg_menu_prefx = g_getenv ("XDG_MENU_PREFIX");
-  if (!xdg_menu_prefx || *xdg_menu_prefx == '\0')
-    return g_strdup ("gnome-applications.menu");
-
-  return g_strdup_printf ("%sapplications.menu", xdg_menu_prefx);
-}
-
 static void
 menu_icon_size_cb (GpApplet   *applet,
                    GParamSpec *pspec,
@@ -334,7 +322,7 @@ validate_scheme (const gchar  *scheme,
 {
   if (g_strcmp0 (scheme, "applications") == 0)
     {
-      *menu_file = get_applications_menu ();
+      *menu_file = gp_menu_utils_get_applications_menu ();
       return TRUE;
     }
   else if (g_strcmp0 (scheme, "gnomecc") == 0)
@@ -390,7 +378,7 @@ update_menu (GpMenuButtonApplet *menu_button)
     {
       gchar *menu_file;
 
-      menu_file = get_applications_menu ();
+      menu_file = gp_menu_utils_get_applications_menu ();
       priv->menu = gp_menu_new (GP_APPLET (menu_button), menu_file, TRUE);
       g_free (menu_file);
 
diff --git a/modules/menu/gp-menu-utils.c b/modules/menu/gp-menu-utils.c
index ef21778e8..a83e7f0cb 100644
--- a/modules/menu/gp-menu-utils.c
+++ b/modules/menu/gp-menu-utils.c
@@ -477,6 +477,18 @@ gp_menu_utils_get_user_name (void)
   return user_name;
 }
 
+gchar *
+gp_menu_utils_get_applications_menu (void)
+{
+  const gchar *xdg_menu_prefx;
+
+  xdg_menu_prefx = g_getenv ("XDG_MENU_PREFIX");
+  if (!xdg_menu_prefx || *xdg_menu_prefx == '\0')
+    return g_strdup ("gnome-applications.menu");
+
+  return g_strdup_printf ("%sapplications.menu", xdg_menu_prefx);
+}
+
 void
 append_separator_if_needed (GtkMenu *menu)
 {
diff --git a/modules/menu/gp-menu-utils.h b/modules/menu/gp-menu-utils.h
index 2fd03cd3c..1b40558a7 100644
--- a/modules/menu/gp-menu-utils.h
+++ b/modules/menu/gp-menu-utils.h
@@ -26,20 +26,22 @@ G_BEGIN_DECLS
 typedef void (* GpAppendMenuItemsFunc) (GtkMenu  *menu,
                                         gpointer  user_data);
 
-void   gp_menu_utils_app_info_launch    (GDesktopAppInfo *app_info);
+void   gp_menu_utils_app_info_launch       (GDesktopAppInfo *app_info);
 
-void   gp_menu_utils_launch_uri         (const gchar     *uri);
+void   gp_menu_utils_launch_uri            (const gchar     *uri);
 
-GIcon *gp_menu_utils_get_icon_for_file  (GFile           *file);
+GIcon *gp_menu_utils_get_icon_for_file     (GFile           *file);
 
-gchar *gp_menu_utils_get_label_for_file (GFile           *file);
+gchar *gp_menu_utils_get_label_for_file    (GFile           *file);
 
-void   gp_menu_utils_show_error_dialog  (const gchar     *message,
-                                         GError          *error);
+void   gp_menu_utils_show_error_dialog     (const gchar     *message,
+                                            GError          *error);
 
-gchar *gp_menu_utils_get_user_name      (void);
+gchar *gp_menu_utils_get_user_name         (void);
 
-void   append_separator_if_needed       (GtkMenu         *menu);
+gchar *gp_menu_utils_get_applications_menu (void);
+
+void   append_separator_if_needed          (GtkMenu         *menu);
 
 G_END_DECLS
 


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