Add sections to the all apps view
Separate out the main app view into different sections based on the categories in the desktop file. The configuration is done via gmenu and the desktop menu specification, we set XDG_MENU_PREFIX="gs-" on startup, so that gmenu reads gs-applications.menu, which we install. There is no support for "submenus" - only the menus directly under Applications will be displayed as categories. https://bugzilla.gnome.org/show_bug.cgi?id=614131
This commit is contained in:
@ -149,6 +149,7 @@ gnome_shell_plugin_class_init (GnomeShellPluginClass *klass)
|
||||
static void
|
||||
gnome_shell_plugin_init (GnomeShellPlugin *shell_plugin)
|
||||
{
|
||||
g_setenv ("XDG_MENU_PREFIX", "gs-", TRUE);
|
||||
meta_prefs_override_preference_location ("/apps/metacity/general/button_layout",
|
||||
"/desktop/gnome/shell/windows/button_layout");
|
||||
}
|
||||
|
@ -156,6 +156,7 @@ def start_shell(perf_output=None):
|
||||
env = dict(os.environ)
|
||||
env.update({'GNOME_SHELL_JS' : '@GJS_JS_DIR@:@GJS_JS_NATIVE_DIR@:' + js_dir,
|
||||
'PATH' : '@MUTTER_BIN_DIR@:' + os.environ.get('PATH', ''),
|
||||
'XDG_CONFIG_DIRS' : '@sysconfdir@/xdg:' + os.environ.get('XDG_CONFIG_DIRS', ''),
|
||||
'GNOME_DISABLE_CRASH_DIALOG' : '1'})
|
||||
|
||||
if running_from_source_tree:
|
||||
|
@ -1109,10 +1109,84 @@ shell_app_info_get_icon (ShellAppInfo *info)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GSList *
|
||||
shell_app_info_get_categories (ShellAppInfo *info)
|
||||
/**
|
||||
* shell_app_system_get_sections:
|
||||
*
|
||||
* return names of sections in applications menu.
|
||||
*
|
||||
* Returns: (element-type utf8) (transfer full): List of Names
|
||||
*/
|
||||
GList *
|
||||
shell_app_system_get_sections (ShellAppSystem *system)
|
||||
{
|
||||
return NULL; /* TODO */
|
||||
GList *res = NULL;
|
||||
GSList *i, *contents;
|
||||
GMenuTreeDirectory *root;
|
||||
|
||||
root = gmenu_tree_get_root_directory (system->priv->apps_tree);
|
||||
|
||||
if (G_UNLIKELY (!root))
|
||||
g_error ("applications.menu not found.");
|
||||
|
||||
contents = gmenu_tree_directory_get_contents (root);
|
||||
|
||||
for (i = contents; i; i = i->next)
|
||||
{
|
||||
GMenuTreeItem *item = i->data;
|
||||
if (gmenu_tree_item_get_type (item) == GMENU_TREE_ITEM_DIRECTORY)
|
||||
{
|
||||
char *name = g_strdup (gmenu_tree_directory_get_name ((GMenuTreeDirectory*)item));
|
||||
|
||||
g_assert (name);
|
||||
|
||||
res = g_list_append (res, name);
|
||||
}
|
||||
gmenu_tree_item_unref (item);
|
||||
}
|
||||
|
||||
g_slist_free (contents);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_app_info_get_section:
|
||||
*
|
||||
* return name of section, that contain this application.
|
||||
* Returns: (transfer full): section name
|
||||
*/
|
||||
char *
|
||||
shell_app_info_get_section (ShellAppInfo *info)
|
||||
{
|
||||
char *name;
|
||||
GMenuTreeDirectory *dir, *parent;
|
||||
|
||||
if (info->type != SHELL_APP_INFO_TYPE_ENTRY)
|
||||
return NULL;
|
||||
|
||||
dir = gmenu_tree_item_get_parent ((GMenuTreeItem*)info->entry);
|
||||
if (!dir)
|
||||
return NULL;
|
||||
|
||||
parent = gmenu_tree_item_get_parent ((GMenuTreeItem*)dir);
|
||||
if (!parent)
|
||||
return NULL;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
GMenuTreeDirectory *pparent = gmenu_tree_item_get_parent ((GMenuTreeItem*)parent);
|
||||
if (!pparent)
|
||||
break;
|
||||
gmenu_tree_item_unref ((GMenuTreeItem*)dir);
|
||||
dir = parent;
|
||||
parent = pparent;
|
||||
}
|
||||
|
||||
name = g_strdup (gmenu_tree_directory_get_name (dir));
|
||||
|
||||
gmenu_tree_item_unref ((GMenuTreeItem*)dir);
|
||||
gmenu_tree_item_unref ((GMenuTreeItem*)parent);
|
||||
return name;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -52,7 +52,7 @@ char *shell_app_info_get_executable (ShellAppInfo *info);
|
||||
char *shell_app_info_get_desktop_file_path (ShellAppInfo *info);
|
||||
GIcon *shell_app_info_get_icon (ShellAppInfo *info);
|
||||
ClutterActor *shell_app_info_create_icon_texture (ShellAppInfo *info, float size);
|
||||
GSList *shell_app_info_get_categories (ShellAppInfo *info);
|
||||
char *shell_app_info_get_section (ShellAppInfo *info);
|
||||
gboolean shell_app_info_get_is_nodisplay (ShellAppInfo *info);
|
||||
gboolean shell_app_info_is_transient (ShellAppInfo *info);
|
||||
|
||||
@ -69,6 +69,7 @@ gboolean shell_app_info_launch (ShellAppInfo *info,
|
||||
|
||||
ShellAppInfo *shell_app_system_load_from_desktop_file (ShellAppSystem *system, const char *filename, GError **error);
|
||||
|
||||
GList *shell_app_system_get_sections (ShellAppSystem *system);
|
||||
ShellApp *shell_app_system_get_app (ShellAppSystem *system, const char *id);
|
||||
ShellApp *shell_app_system_get_app_for_path (ShellAppSystem *system, const char *desktop_path);
|
||||
ShellApp *shell_app_system_get_app_for_window (ShellAppSystem *self, MetaWindow *window);
|
||||
|
Reference in New Issue
Block a user