[gnome-panel] menus: don't hardcode application menu file
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] menus: don't hardcode application menu file
- Date: Mon, 27 Oct 2014 16:22:55 +0000 (UTC)
commit ac02b880213d744fc5087b2c5a0acd02f222805f
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Oct 16 20:24:59 2014 +0300
menus: don't hardcode application menu file
Use XDG_MENU_PREFIX to generate correct applications menu file and
use it.
gnome-panel/menu.c | 11 +++++++++++
gnome-panel/menu.h | 1 +
gnome-panel/panel-addto.c | 9 +++++++--
gnome-panel/panel-menu-bar.c | 6 +++++-
gnome-panel/panel-menu-button.c | 16 ++++++++++++++++
gnome-panel/panel-run-dialog.c | 5 ++++-
6 files changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/gnome-panel/menu.c b/gnome-panel/menu.c
index f338516..9c5b67b 100644
--- a/gnome-panel/menu.c
+++ b/gnome-panel/menu.c
@@ -1385,8 +1385,11 @@ GtkWidget *
create_main_menu (PanelWidget *panel)
{
GtkWidget *main_menu;
+ gchar *applications_menu;
+ applications_menu = get_applications_menu ();
main_menu = create_applications_menu ("gnome-applications.menu", NULL, TRUE);
+ g_free (applications_menu);
g_object_set_data (G_OBJECT (main_menu), "menu_panel", panel);
/* FIXME need to update the panel on parent_set */
@@ -1487,3 +1490,11 @@ panel_load_menu_image_deferred (GtkWidget *image_menu_item,
image_menu_items = g_slist_prepend (image_menu_items, image);
}
+
+gchar *
+get_applications_menu (void)
+{
+ const gchar *xdg_menu_prefx = g_getenv ("XDG_MENU_PREFIX");
+ return g_strdup_printf ("%sapplications.menu",
+ xdg_menu_prefx ? xdg_menu_prefx : "gnome-");
+}
diff --git a/gnome-panel/menu.h b/gnome-panel/menu.h
index ec1bc77..aaf22c6 100644
--- a/gnome-panel/menu.h
+++ b/gnome-panel/menu.h
@@ -67,6 +67,7 @@ GtkWidget *add_menu_separator (GtkWidget *menu);
gboolean menu_dummy_button_press_event (GtkWidget *menuitem,
GdkEventButton *event);
+gchar *get_applications_menu (void);
G_END_DECLS
diff --git a/gnome-panel/panel-addto.c b/gnome-panel/panel-addto.c
index e5a6945..ef4006e 100644
--- a/gnome-panel/panel-addto.c
+++ b/gnome-panel/panel-addto.c
@@ -30,6 +30,7 @@
#include <libpanel-util/panel-glib.h>
#include "launcher.h"
+#include "menu.h"
#include "panel.h"
#include "panel-applets-manager.h"
#include "panel-applet-frame.h"
@@ -653,6 +654,7 @@ panel_addto_make_application_model (PanelAddtoDialog *dialog)
GtkTreeStore *store;
GMenuTree *tree;
GMenuTreeDirectory *root;
+ gchar *applications_menu;
if (dialog->filter_application_model != NULL)
return;
@@ -663,7 +665,8 @@ panel_addto_make_application_model (PanelAddtoDialog *dialog)
G_TYPE_POINTER,
G_TYPE_STRING);
- tree = gmenu_tree_new ("gnome-applications.menu", GMENU_TREE_FLAGS_SORT_DISPLAY_NAME);
+ applications_menu = get_applications_menu ();
+ tree = gmenu_tree_new (applications_menu, GMENU_TREE_FLAGS_SORT_DISPLAY_NAME);
if (!gmenu_tree_load_sync (tree, NULL)) {
g_object_unref (tree);
@@ -672,13 +675,15 @@ panel_addto_make_application_model (PanelAddtoDialog *dialog)
if (tree != NULL && (root = gmenu_tree_get_root_directory (tree))) {
panel_addto_make_application_list (&dialog->application_list,
- root, "gnome-applications.menu",
+ root, applications_menu,
PANEL_ADDTO_MENU_SHOW_ALL);
panel_addto_populate_application_model (store, NULL, dialog->application_list);
gmenu_tree_item_unref (root);
}
+ g_free (applications_menu);
+
if (tree != NULL)
g_object_unref (tree);
diff --git a/gnome-panel/panel-menu-bar.c b/gnome-panel/panel-menu-bar.c
index 8c736ea..3aeb43a 100644
--- a/gnome-panel/panel-menu-bar.c
+++ b/gnome-panel/panel-menu-bar.c
@@ -110,11 +110,15 @@ panel_menu_bar_setup_tooltip (PanelMenuBar *menubar)
static void
panel_menu_bar_init (PanelMenuBar *menubar)
{
+ gchar *applications_menu;
+
menubar->priv = PANEL_MENU_BAR_GET_PRIVATE (menubar);
menubar->priv->info = NULL;
- menubar->priv->applications_menu = create_applications_menu ("gnome-applications.menu", NULL, TRUE);
+ applications_menu = get_applications_menu ();
+ menubar->priv->applications_menu = create_applications_menu (applications_menu, NULL, TRUE);
+ g_free (applications_menu);
menubar->priv->applications_item = panel_image_menu_item_new2 ();
gtk_menu_item_set_label (GTK_MENU_ITEM (menubar->priv->applications_item),
diff --git a/gnome-panel/panel-menu-button.c b/gnome-panel/panel-menu-button.c
index 22c4f3a..01f7519 100644
--- a/gnome-panel/panel-menu-button.c
+++ b/gnome-panel/panel-menu-button.c
@@ -93,12 +93,24 @@ static void panel_menu_button_set_icon (PanelMenuButton *button);
static AtkObject *panel_menu_button_get_accessible (GtkWidget *widget);
+static void
+fix_application_menu_name (void)
+{
+ static gboolean updated = FALSE;
+ if (!updated) {
+ root_items [0].filename = get_applications_menu ();
+ updated = TRUE;
+ }
+}
+
static const char *
panel_menu_path_root_to_filename (MenuPathRoot path_root)
{
const char *retval;
int i;
+ fix_application_menu_name ();
+
retval = NULL;
for (i = 0; i < G_N_ELEMENTS (root_items); i++) {
@@ -117,6 +129,8 @@ panel_menu_filename_to_scheme (const char *filename)
const char *retval;
int i;
+ fix_application_menu_name ();
+
retval = NULL;
if (!filename)
@@ -140,6 +154,8 @@ panel_menu_scheme_to_path_root (const char *scheme)
MenuPathRoot retval;
int i;
+ fix_application_menu_name ();
+
retval = LAST_MENU;
if (!scheme)
diff --git a/gnome-panel/panel-run-dialog.c b/gnome-panel/panel-run-dialog.c
index 8beb907..e76a067 100644
--- a/gnome-panel/panel-run-dialog.c
+++ b/gnome-panel/panel-run-dialog.c
@@ -913,8 +913,11 @@ get_all_applications (void)
GMenuTree *tree;
GMenuTreeDirectory *root;
GSList *retval;
+ gchar *applications_menu;
- tree = gmenu_tree_new ("gnome-applications.menu", GMENU_TREE_FLAGS_SORT_DISPLAY_NAME);
+ applications_menu = get_applications_menu ();
+ tree = gmenu_tree_new (applications_menu, GMENU_TREE_FLAGS_SORT_DISPLAY_NAME);
+ g_free (applications_menu);
if (!gmenu_tree_load_sync (tree, NULL))
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]