This is an automated email from the git hooks/post-receive script. g o t t c o d e p u s h e d a c o m m i t t o b r a n c h m a s t e r in repository panel-plugins/xfce4-whiskermenu-plugin.
commit 0b767f6391b7d5ad59c79aff19ba66d34c0de44a Author: Graeme Gott <gra...@gottcode.org> Date: Mon Dec 23 16:33:07 2019 -0500 Add option to show as icons. (bug #15675) --- panel-plugin/configuration-dialog.cpp | 51 ++++++++++++++++++++++++++++++----- panel-plugin/configuration-dialog.h | 4 ++- panel-plugin/page.cpp | 35 +++++++++++++++++++++--- panel-plugin/page.h | 1 + panel-plugin/settings.cpp | 3 +++ panel-plugin/settings.h | 3 ++- panel-plugin/window.cpp | 6 +++++ 7 files changed, 91 insertions(+), 12 deletions(-) diff --git a/panel-plugin/configuration-dialog.cpp b/panel-plugin/configuration-dialog.cpp index 37445b5..97d8334 100644 --- a/panel-plugin/configuration-dialog.cpp +++ b/panel-plugin/configuration-dialog.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2015, 2016, 2017, 2018 Graeme Gott <gra...@gottcode.org> + * Copyright (C) 2013, 2015, 2016, 2017, 2018, 2019 Graeme Gott <gra...@gottcode.org> * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -231,6 +231,12 @@ void ConfigurationDialog::toggle_show_description(GtkToggleButton* button) wm_settings->launcher_show_description = gtk_toggle_button_get_active(button); wm_settings->set_modified(); m_plugin->reload(); + + const bool active = wm_settings->launcher_show_description; + if (active) + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_as_icons), false); + } } //----------------------------------------------------------------------------- @@ -248,6 +254,29 @@ void ConfigurationDialog::toggle_show_hierarchy(GtkToggleButton* button) wm_settings->load_hierarchy = gtk_toggle_button_get_active(button); wm_settings->set_modified(); m_plugin->reload(); + + const bool active = wm_settings->load_hierarchy; + if (active) + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_as_icons), false); + } +} + +//----------------------------------------------------------------------------- + +void ConfigurationDialog::toggle_show_as_icons(GtkToggleButton *button) +{ + wm_settings->view_as_icons = gtk_toggle_button_get_active(button); + wm_settings->set_modified(); + + const bool active = wm_settings->view_as_icons; + gtk_widget_set_sensitive(GTK_WIDGET(m_show_descriptions), !active); + gtk_widget_set_sensitive(GTK_WIDGET(m_show_hierarchy), !active); + if (active) + { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_descriptions), false); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_hierarchy), false); + } } //----------------------------------------------------------------------------- @@ -629,6 +658,7 @@ GtkWidget* ConfigurationDialog::init_appearance_tab() m_show_descriptions = gtk_check_button_new_with_mnemonic(_("Show application _descriptions")); gtk_grid_attach(menu_table, m_show_descriptions, 0, 2, 2, 1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_descriptions), wm_settings->launcher_show_description); + gtk_widget_set_sensitive(m_show_descriptions, !wm_settings->view_as_icons); g_signal_connect_slot(m_show_descriptions, "toggled", &ConfigurationDialog::toggle_show_description, this); // Add option to hide tooltips @@ -641,12 +671,19 @@ GtkWidget* ConfigurationDialog::init_appearance_tab() m_show_hierarchy = gtk_check_button_new_with_mnemonic(_("Show menu hie_rarchy")); gtk_grid_attach(menu_table, m_show_hierarchy, 0, 4, 2, 1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_hierarchy), wm_settings->load_hierarchy); + gtk_widget_set_sensitive(m_show_hierarchy, !wm_settings->view_as_icons); g_signal_connect_slot(m_show_hierarchy, "toggled", &ConfigurationDialog::toggle_show_hierarchy, this); + // Add option to show as icons + m_show_as_icons = gtk_check_button_new_with_mnemonic(_("Show as _icons")); + gtk_grid_attach(menu_table, m_show_as_icons, 0, 5, 2, 1); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_as_icons), wm_settings->view_as_icons); + g_signal_connect_slot(m_show_as_icons, "toggled", &ConfigurationDialog::toggle_show_as_icons, this); + // Add item icon size selector label = gtk_label_new_with_mnemonic(_("Ite_m icon size:")); gtk_widget_set_halign(label, GTK_ALIGN_START); - gtk_grid_attach(menu_table, label, 0, 5, 1, 1); + gtk_grid_attach(menu_table, label, 0, 6, 1, 1); m_item_icon_size = gtk_combo_box_text_new(); std::vector<std::string> icon_sizes = IconSize::get_strings(); @@ -655,14 +692,14 @@ GtkWidget* ConfigurationDialog::init_appearance_tab() gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(m_item_icon_size), i->c_str()); } gtk_combo_box_set_active(GTK_COMBO_BOX(m_item_icon_size), wm_settings->launcher_icon_size + 1); - gtk_grid_attach(menu_table, m_item_icon_size, 1, 5, 1, 1); + gtk_grid_attach(menu_table, m_item_icon_size, 1, 6, 1, 1); gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_item_icon_size); g_signal_connect_slot(m_item_icon_size, "changed", &ConfigurationDialog::item_icon_size_changed, this); // Add category icon size selector label = gtk_label_new_with_mnemonic(_("Categ_ory icon size:")); gtk_widget_set_halign(label, GTK_ALIGN_START); - gtk_grid_attach(menu_table, label, 0, 6, 1, 1); + gtk_grid_attach(menu_table, label, 0, 7, 1, 1); m_category_icon_size = gtk_combo_box_text_new(); for (std::vector<std::string>::const_iterator i = icon_sizes.begin(), end = icon_sizes.end(); i != end; ++i) @@ -670,18 +707,18 @@ GtkWidget* ConfigurationDialog::init_appearance_tab() gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(m_category_icon_size), i->c_str()); } gtk_combo_box_set_active(GTK_COMBO_BOX(m_category_icon_size), wm_settings->category_icon_size + 1); - gtk_grid_attach(menu_table, m_category_icon_size, 1, 6, 1, 1); + gtk_grid_attach(menu_table, m_category_icon_size, 1, 7, 1, 1); gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_category_icon_size); g_signal_connect_slot(m_category_icon_size, "changed", &ConfigurationDialog::category_icon_size_changed, this); // Add option to control background opacity label = gtk_label_new_with_mnemonic(_("Background opacit_y:")); gtk_widget_set_halign(label, GTK_ALIGN_START); - gtk_grid_attach(menu_table, label, 0, 7, 1, 1); + gtk_grid_attach(menu_table, label, 0, 8, 1, 1); m_background_opacity = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0.0, 100.0, 1.0); gtk_widget_set_hexpand(GTK_WIDGET(m_background_opacity), true); - gtk_grid_attach(menu_table, m_background_opacity, 1, 7, 1, 1); + gtk_grid_attach(menu_table, m_background_opacity, 1, 8, 1, 1); gtk_scale_set_value_pos(GTK_SCALE(m_background_opacity), GTK_POS_RIGHT); gtk_range_set_value(GTK_RANGE(m_background_opacity), wm_settings->menu_opacity); g_signal_connect_slot(m_background_opacity, "value-changed", &ConfigurationDialog::background_opacity_changed, this); diff --git a/panel-plugin/configuration-dialog.h b/panel-plugin/configuration-dialog.h index afafa7d..c6a9793 100644 --- a/panel-plugin/configuration-dialog.h +++ b/panel-plugin/configuration-dialog.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2015, 2016, 2018 Graeme Gott <gra...@gottcode.org> + * Copyright (C) 2013, 2015, 2016, 2018, 2019 Graeme Gott <gra...@gottcode.org> * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,6 +46,7 @@ private: void toggle_show_description(GtkToggleButton* button); void toggle_show_tooltip(GtkToggleButton* button); void toggle_show_hierarchy(GtkToggleButton* button); + void toggle_show_as_icons(GtkToggleButton* button); void toggle_position_search_alternate(GtkToggleButton* button); void toggle_position_commands_alternate(GtkToggleButton* button); void toggle_position_categories_alternate(GtkToggleButton* button); @@ -92,6 +93,7 @@ private: GtkWidget* m_show_descriptions; GtkWidget* m_show_tooltips; GtkWidget* m_show_hierarchy; + GtkWidget* m_show_as_icons; GtkWidget* m_position_search_alternate; GtkWidget* m_position_commands_alternate; GtkWidget* m_position_categories_alternate; diff --git a/panel-plugin/page.cpp b/panel-plugin/page.cpp index 732d901..ef59fca 100644 --- a/panel-plugin/page.cpp +++ b/panel-plugin/page.cpp @@ -22,6 +22,7 @@ #include "launcher-icon-view.h" #include "launcher-tree-view.h" #include "recent-page.h" +#include "settings.h" #include "slot.h" #include "window.h" @@ -80,6 +81,26 @@ void Page::reset_selection() //----------------------------------------------------------------------------- +void Page::update_view() +{ + if ((dynamic_cast<LauncherIconView*>(m_view) != 0) == wm_settings->view_as_icons) + { + return; + } + + LauncherView* view = m_view; + create_view(); + m_view->set_model(view->get_model()); + delete view; + + gtk_container_add(GTK_CONTAINER(m_widget), m_view->get_widget()); + gtk_widget_show_all(m_widget); + + view_created(); +} + +//----------------------------------------------------------------------------- + void Page::set_reorderable(bool reorderable) { m_reorderable = reorderable; @@ -120,9 +141,17 @@ void Page::set_reorderable(bool reorderable) void Page::create_view() { - m_view = new LauncherTreeView(); - g_signal_connect(m_view->get_widget(), "row-activated", G_CALLBACK(&Page::row_activated_slot), this); - g_signal_connect_swapped(m_view->get_widget(), "start-interactive-search", G_CALLBACK(gtk_widget_grab_focus), m_window->get_search_entry()); + if (wm_settings->view_as_icons) + { + m_view = new LauncherIconView(); + g_signal_connect(m_view->get_widget(), "item-activated", G_CALLBACK(&Page::item_activated_slot), this); + } + else + { + m_view = new LauncherTreeView(); + g_signal_connect(m_view->get_widget(), "row-activated", G_CALLBACK(&Page::row_activated_slot), this); + g_signal_connect_swapped(m_view->get_widget(), "start-interactive-search", G_CALLBACK(gtk_widget_grab_focus), m_window->get_search_entry()); + } g_signal_connect_slot(m_view->get_widget(), "button-press-event", &Page::view_button_press_event, this); g_signal_connect_slot(m_view->get_widget(), "button-release-event", &Page::view_button_release_event, this); g_signal_connect_slot(m_view->get_widget(), "drag-data-get", &Page::view_drag_data_get, this); diff --git a/panel-plugin/page.h b/panel-plugin/page.h index 27c90da..d00d3b3 100644 --- a/panel-plugin/page.h +++ b/panel-plugin/page.h @@ -45,6 +45,7 @@ public: } void reset_selection(); + void update_view(); protected: Window* get_window() const diff --git a/panel-plugin/settings.cpp b/panel-plugin/settings.cpp index 18479de..2f1dde4 100644 --- a/panel-plugin/settings.cpp +++ b/panel-plugin/settings.cpp @@ -103,6 +103,7 @@ Settings::Settings() : category_icon_size(IconSize::Smaller), load_hierarchy(false), + view_as_icons(false), recent_items_max(10), favorites_in_recent(true), @@ -239,6 +240,7 @@ void Settings::load(char* file) category_show_name = xfce_rc_read_bool_entry(rc, "category-show-name", category_show_name) || (category_icon_size == -1); load_hierarchy = xfce_rc_read_bool_entry(rc, "load-hierarchy", load_hierarchy); + view_as_icons = xfce_rc_read_bool_entry(rc, "view-as-icons", view_as_icons) && !launcher_show_description && !load_hierarchy; recent_items_max = std::max(0, xfce_rc_read_int_entry(rc, "recent-items-max", recent_items_max)); favorites_in_recent = xfce_rc_read_bool_entry(rc, "favorites-in-recent", favorites_in_recent); @@ -340,6 +342,7 @@ void Settings::save(char* file) xfce_rc_write_int_entry(rc, "category-icon-size", category_icon_size); xfce_rc_write_bool_entry(rc, "load-hierarchy", load_hierarchy); + xfce_rc_write_bool_entry(rc, "view-as-icons", view_as_icons); xfce_rc_write_int_entry(rc, "recent-items-max", recent_items_max); xfce_rc_write_bool_entry(rc, "favorites-in-recent", favorites_in_recent); diff --git a/panel-plugin/settings.h b/panel-plugin/settings.h index 678f642..c77cf72 100644 --- a/panel-plugin/settings.h +++ b/panel-plugin/settings.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2014, 2016, 2018 Graeme Gott <gra...@gottcode.org> + * Copyright (C) 2013, 2014, 2016, 2018, 2019 Graeme Gott <gra...@gottcode.org> * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,6 +75,7 @@ public: IconSize category_icon_size; bool load_hierarchy; + bool view_as_icons; unsigned int recent_items_max; bool favorites_in_recent; diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp index d7fe6c8..23b16ee 100644 --- a/panel-plugin/window.cpp +++ b/panel-plugin/window.cpp @@ -311,6 +311,12 @@ void WhiskerMenu::Window::hide() void WhiskerMenu::Window::show(const Position position) { + // Handle switching view types + m_search_results->update_view(); + m_favorites->update_view(); + m_recent->update_view(); + m_applications->update_view(); + // Handle showing tooltips if (wm_settings->launcher_show_tooltip) { -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits