From 6589911b919b7ab44556c1966c5ab5befcd46688 Mon Sep 17 00:00:00 2001 From: Wu Xiaotian Date: Sat, 20 Jul 2019 15:15:41 +0800 Subject: hide menu and toolbutton when view is only one --- src/caja-view-as-action.c | 5 +++++ src/caja-window.c | 29 +++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/caja-view-as-action.c b/src/caja-view-as-action.c index 115dfedd..4c1a7d4b 100644 --- a/src/caja-view-as-action.c +++ b/src/caja-view-as-action.c @@ -158,6 +158,11 @@ view_as_changed_callback (CajaWindow *window, } gtk_combo_box_set_active (combo_box, selected_index); + if (g_list_length (window->details->short_list_viewers) == 1) { + gtk_widget_hide(GTK_WIDGET(combo_box)); + } else { + gtk_widget_show(GTK_WIDGET(combo_box)); + } } diff --git a/src/caja-window.c b/src/caja-window.c index c9dc3f71..9710bb6f 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -1330,7 +1330,6 @@ static void load_view_as_menu (CajaWindow *window) { GList *node; - int index; guint merge_id; if (window->details->short_list_merge_id != 0) @@ -1364,19 +1363,21 @@ load_view_as_menu (CajaWindow *window) G_GNUC_END_IGNORE_DEPRECATIONS; window->details->view_as_radio_action = NULL; - /* Add a menu item for each view in the preferred list for this location. */ - /* Start on 1, because extra_viewer gets index 0 */ - for (node = window->details->short_list_viewers, index = 1; - node != NULL; - node = node->next, ++index) - { - /* Menu item in View menu. */ - /* TODO */ - add_view_as_menu_item (window, - CAJA_MENU_PATH_SHORT_LIST_PLACEHOLDER, - node->data, - index, - merge_id); + if (g_list_length (window->details->short_list_viewers) > 1) { + int index; + /* Add a menu item for each view in the preferred list for this location. */ + /* Start on 1, because extra_viewer gets index 0 */ + for (node = window->details->short_list_viewers, index = 1; + node != NULL; + node = node->next, ++index) + { + /* Menu item in View menu. */ + add_view_as_menu_item (window, + CAJA_MENU_PATH_SHORT_LIST_PLACEHOLDER, + node->data, + index, + merge_id); + } } gtk_ui_manager_insert_action_group (window->details->ui_manager, window->details->view_as_action_group, -- cgit v1.2.1