From 5dbbc209182cf5ee36a7f7266b6acd4a1ce4b4cc Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Wed, 13 Nov 2019 16:33:29 +1300 Subject: [PATCH] shell: Show the submenu icon hint for the applications panel The panel swarms details/devices/privacy show this icon. Since the applications panel is not made from sub-panels, this doesn't show. For consistency this shows the icon so the transition isn't as jarring for the user. Add a flat into the panel .desktop file to enable this - other panels might require this in the future --- .../gnome-applications-panel.desktop.in.in | 1 + shell/cc-panel-list.c | 18 ++++++++++++++---- shell/cc-panel-list.h | 3 ++- shell/cc-shell-model.c | 5 ++++- shell/cc-shell-model.h | 1 + shell/cc-window.c | 5 ++++- 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/panels/applications/gnome-applications-panel.desktop.in.in b/panels/applications/gnome-applications-panel.desktop.in.in index b848078f4..82284e39c 100644 --- a/panels/applications/gnome-applications-panel.desktop.in.in +++ b/panels/applications/gnome-applications-panel.desktop.in.in @@ -13,3 +13,4 @@ Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;X-GNOME-Acc OnlyShowIn=GNOME;Unity; # Translators: Search terms to find the Privacy panel. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon! Keywords=application;flatpak;permission;setting; +X-GNOME-ControlCenter-HasSidebar=true diff --git a/shell/cc-panel-list.c b/shell/cc-panel-list.c index bf4f32077..254c4327c 100644 --- a/shell/cc-panel-list.c +++ b/shell/cc-panel-list.c @@ -295,7 +295,8 @@ row_data_new (CcPanelCategory category, const gchar *description, const GStrv keywords, const gchar *icon, - CcPanelVisibility visibility) + CcPanelVisibility visibility, + gboolean has_sidebar) { GtkWidget *label, *grid, *image; RowData *data; @@ -343,6 +344,14 @@ row_data_new (CcPanelCategory category, gtk_label_set_max_width_chars (GTK_LABEL (label), 25); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + if (has_sidebar) + { + image = gtk_image_new_from_icon_name ("go-next-symbolic", GTK_ICON_SIZE_BUTTON); + gtk_style_context_add_class (gtk_widget_get_style_context (image), "sidebar-icon"); + gtk_grid_attach (GTK_GRID (grid), image, 2, 0, 1, 1); + gtk_widget_show (image); + } + gtk_style_context_add_class (gtk_widget_get_style_context (label), "dim-label"); gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1); @@ -1017,7 +1026,8 @@ cc_panel_list_add_panel (CcPanelList *self, const gchar *description, const GStrv keywords, const gchar *icon, - CcPanelVisibility visibility) + CcPanelVisibility visibility, + gboolean has_sidebar) { GtkWidget *listbox; RowData *data, *search_data; @@ -1025,14 +1035,14 @@ cc_panel_list_add_panel (CcPanelList *self, g_return_if_fail (CC_IS_PANEL_LIST (self)); /* Add the panel to the proper listbox */ - data = row_data_new (category, id, title, description, keywords, icon, visibility); + data = row_data_new (category, id, title, description, keywords, icon, visibility, has_sidebar); gtk_widget_set_visible (data->row, visibility == CC_PANEL_VISIBLE); listbox = get_listbox_from_category (self, category); gtk_container_add (GTK_CONTAINER (listbox), data->row); /* And add to the search listbox too */ - search_data = row_data_new (category, id, title, description, keywords, icon, visibility); + search_data = row_data_new (category, id, title, description, keywords, icon, visibility, has_sidebar); gtk_widget_set_visible (search_data->row, visibility != CC_PANEL_HIDDEN); gtk_container_add (GTK_CONTAINER (self->search_listbox), search_data->row); diff --git a/shell/cc-panel-list.h b/shell/cc-panel-list.h index dd8cfe0b1..d07554ae7 100644 --- a/shell/cc-panel-list.h +++ b/shell/cc-panel-list.h @@ -61,7 +61,8 @@ void cc_panel_list_add_panel (CcPanelList const gchar *description, const GStrv keywords, const gchar *icon, - CcPanelVisibility visibility); + CcPanelVisibility visibility, + gboolean has_sidebar); void cc_panel_list_set_active_panel (CcPanelList *self, const gchar *id); diff --git a/shell/cc-shell-model.c b/shell/cc-shell-model.c index ff3aef312..6252b3f70 100644 --- a/shell/cc-shell-model.c +++ b/shell/cc-shell-model.c @@ -219,7 +219,7 @@ static void cc_shell_model_init (CcShellModel *self) { GType types[] = {G_TYPE_STRING, G_TYPE_STRING, G_TYPE_APP_INFO, G_TYPE_STRING, G_TYPE_UINT, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_ICON, G_TYPE_STRV, G_TYPE_UINT }; + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_ICON, G_TYPE_STRV, G_TYPE_UINT, G_TYPE_BOOLEAN }; gtk_list_store_set_column_types (GTK_LIST_STORE (self), N_COLS, types); @@ -286,11 +286,13 @@ cc_shell_model_add_item (CcShellModel *model, g_auto(GStrv) keywords = NULL; g_autofree gchar *casefolded_name = NULL; g_autofree gchar *casefolded_description = NULL; + gboolean has_sidebar; casefolded_name = cc_util_normalize_casefold_and_unaccent (name); casefolded_description = cc_util_normalize_casefold_and_unaccent (comment); keywords = get_casefolded_keywords (appinfo); icon = symbolicize_g_icon (g_app_info_get_icon (appinfo)); + has_sidebar = g_desktop_app_info_get_boolean (G_DESKTOP_APP_INFO (appinfo), "X-GNOME-ControlCenter-HasSidebar"); gtk_list_store_insert_with_values (GTK_LIST_STORE (model), NULL, 0, COL_NAME, name, @@ -303,6 +305,7 @@ cc_shell_model_add_item (CcShellModel *model, COL_GICON, icon, COL_KEYWORDS, keywords, COL_VISIBILITY, CC_PANEL_VISIBLE, + COL_HAS_SIDEBAR, has_sidebar, -1); } diff --git a/shell/cc-shell-model.h b/shell/cc-shell-model.h index 9b3eaf6ad..763803e4a 100644 --- a/shell/cc-shell-model.h +++ b/shell/cc-shell-model.h @@ -54,6 +54,7 @@ enum COL_GICON, COL_KEYWORDS, COL_VISIBILITY, + COL_HAS_SIDEBAR, N_COLS }; diff --git a/shell/cc-window.c b/shell/cc-window.c index 78042c1a6..7bdcaebe3 100644 --- a/shell/cc-window.c +++ b/shell/cc-window.c @@ -351,6 +351,7 @@ setup_model (CcWindow *self) g_autofree gchar *id = NULL; g_auto(GStrv) keywords = NULL; CcPanelVisibility visibility; + gboolean has_sidebar; const gchar *icon_name = NULL; gtk_tree_model_get (model, &iter, @@ -361,6 +362,7 @@ setup_model (CcWindow *self) COL_NAME, &name, COL_KEYWORDS, &keywords, COL_VISIBILITY, &visibility, + COL_HAS_SIDEBAR, &has_sidebar, -1); if (G_IS_THEMED_ICON (icon)) @@ -373,7 +375,8 @@ setup_model (CcWindow *self) description, keywords, icon_name, - visibility); + visibility, + has_sidebar); valid = gtk_tree_model_iter_next (model, &iter); } -- GitLab