[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 02/02: Only show recent button when recent items are tracked.

noreply at xfce.org noreply at xfce.org
Fri Oct 9 21:13:25 CEST 2015


This is an automated email from the git hooks/post-receive script.

gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 020fda40e840d53360ad8621f272f8d02995d820
Author: Graeme Gott <graeme at gottcode.org>
Date:   Fri Oct 9 11:35:31 2015 -0400

    Only show recent button when recent items are tracked.
---
 panel-plugin/configuration-dialog.cpp |    9 ++++++++-
 panel-plugin/recent-page.cpp          |    4 ++--
 panel-plugin/settings.cpp             |    4 ++--
 panel-plugin/window.cpp               |    3 +++
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/panel-plugin/configuration-dialog.cpp b/panel-plugin/configuration-dialog.cpp
index fb90f22..71a4700 100644
--- a/panel-plugin/configuration-dialog.cpp
+++ b/panel-plugin/configuration-dialog.cpp
@@ -250,6 +250,12 @@ void ConfigurationDialog::recent_items_max_changed(GtkSpinButton* button)
 {
 	wm_settings->recent_items_max = gtk_spin_button_get_value_as_int(button);
 	wm_settings->set_modified();
+	const bool active = wm_settings->recent_items_max;
+	gtk_widget_set_sensitive(GTK_WIDGET(m_display_recent), active);
+	if (!active)
+	{
+		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_display_recent), false);
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -683,7 +689,7 @@ GtkWidget* ConfigurationDialog::init_behavior_tab()
 	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
 	gtk_table_attach(recent_table, label, 0, 1, 0, 1, GTK_FILL, GtkAttachOptions(GTK_EXPAND | GTK_FILL), 0, 0);
 
-	m_recent_items_max = gtk_spin_button_new_with_range(5, 100, 1);
+	m_recent_items_max = gtk_spin_button_new_with_range(0, 100, 1);
 	gtk_table_attach_defaults(recent_table, m_recent_items_max, 1, 2, 0, 1);
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_recent_items_max);
 	gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_recent_items_max), wm_settings->recent_items_max);
@@ -699,6 +705,7 @@ GtkWidget* ConfigurationDialog::init_behavior_tab()
 	m_display_recent = gtk_check_button_new_with_mnemonic(_("Display by _default"));
 	gtk_table_attach_defaults(recent_table, m_display_recent, 0, 2, 2, 3);
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_display_recent), wm_settings->display_recent);
+	gtk_widget_set_sensitive(GTK_WIDGET(m_display_recent), wm_settings->recent_items_max);
 	g_signal_connect_slot(m_display_recent, "toggled", &ConfigurationDialog::toggle_display_recent, this);
 
 	return page;
diff --git a/panel-plugin/recent-page.cpp b/panel-plugin/recent-page.cpp
index eb9b7b9..d9be893 100644
--- a/panel-plugin/recent-page.cpp
+++ b/panel-plugin/recent-page.cpp
@@ -54,7 +54,7 @@ RecentPage::~RecentPage()
 
 void RecentPage::add(Launcher* launcher)
 {
-	if (!launcher)
+	if (!wm_settings->recent_items_max || !launcher)
 	{
 		return;
 	}
@@ -109,7 +109,7 @@ void RecentPage::enforce_item_count()
 	}
 
 	GtkListStore* store = GTK_LIST_STORE(get_view()->get_model());
-	for (size_t i = wm_settings->recent.size() - 1, end = wm_settings->recent_items_max; i >= end; --i)
+	for (ssize_t i = wm_settings->recent.size() - 1, end = wm_settings->recent_items_max; i >= end; --i)
 	{
 		Launcher* launcher = get_window()->get_applications()->get_application(wm_settings->recent[i]);
 		if (launcher)
diff --git a/panel-plugin/settings.cpp b/panel-plugin/settings.cpp
index efa9682..7c790be 100644
--- a/panel-plugin/settings.cpp
+++ b/panel-plugin/settings.cpp
@@ -180,9 +180,9 @@ void Settings::load(char* file)
 
 	load_hierarchy = xfce_rc_read_bool_entry(rc, "load-hierarchy", load_hierarchy);
 
-	recent_items_max = std::max(5, xfce_rc_read_int_entry(rc, "recent-items-max", recent_items_max));
+	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);
-	display_recent = xfce_rc_read_bool_entry(rc, "display-recent-default", display_recent);
+	display_recent = xfce_rc_read_bool_entry(rc, "display-recent-default", display_recent) && recent_items_max;
 
 	position_search_alternate = xfce_rc_read_bool_entry(rc, "position-search-alternate", position_search_alternate);
 	position_commands_alternate = xfce_rc_read_bool_entry(rc, "position-commands-alternate", position_commands_alternate) && position_search_alternate;
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index 7608668..491b934 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -561,6 +561,9 @@ void WhiskerMenu::Window::show(GtkWidget* parent, bool horizontal)
 		}
 	}
 
+	// Make sure recent button is only visible when tracked
+	gtk_widget_set_visible(GTK_WIDGET(m_recent_button->get_button()), wm_settings->recent_items_max);
+
 	// Show window
 	gtk_widget_show(GTK_WIDGET(m_window));
 	gtk_window_move(m_window, m_geometry.x, m_geometry.y);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list