[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 164/473: Add option to not include favorites in recently used.
noreply at xfce.org
noreply at xfce.org
Mon Feb 16 23:55:34 CET 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 0a01dcb26e746c638c0ff90fc8ff1c543284ab6d
Author: Graeme Gott <graeme at gottcode.org>
Date: Fri Sep 20 05:43:59 2013 -0400
Add option to not include favorites in recently used.
---
src/configuration_dialog.cpp | 14 ++++++++++++++
src/configuration_dialog.hpp | 7 +++++++
src/favorites_page.cpp | 23 +++++++++++++++++++++++
src/favorites_page.hpp | 4 ++++
src/page.cpp | 12 +++++++++++-
src/page.hpp | 1 +
src/panel_plugin.cpp | 3 +++
7 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/src/configuration_dialog.cpp b/src/configuration_dialog.cpp
index c45e445..9c3da54 100644
--- a/src/configuration_dialog.cpp
+++ b/src/configuration_dialog.cpp
@@ -17,6 +17,7 @@
#include "configuration_dialog.hpp"
#include "applications_page.hpp"
+#include "favorites_page.hpp"
#include "icon_size.hpp"
#include "launcher.hpp"
#include "launcher_view.hpp"
@@ -196,6 +197,12 @@ ConfigurationDialog::ConfigurationDialog(PanelPlugin* plugin) :
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_load_hierarchy), ApplicationsPage::get_load_hierarchy());
g_signal_connect(m_load_hierarchy, "toggled", G_CALLBACK(ConfigurationDialog::toggle_load_hierarchy_slot), this);
+ // Add option to remember favorites
+ m_remember_favorites = gtk_check_button_new_with_mnemonic(_("Include _favorites in recently used"));
+ gtk_box_pack_start(behavior_vbox, m_remember_favorites, true, true, 0);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_remember_favorites), FavoritesPage::get_remember_favorites());
+ g_signal_connect(m_remember_favorites, "toggled", G_CALLBACK(ConfigurationDialog::toggle_remember_favorites_slot), this);
+
// Show GTK window
gtk_widget_show_all(m_window);
@@ -300,6 +307,13 @@ void ConfigurationDialog::toggle_load_hierarchy(GtkToggleButton* button)
//-----------------------------------------------------------------------------
+void ConfigurationDialog::toggle_remember_favorites(GtkToggleButton* button)
+{
+ FavoritesPage::set_remember_favorites(gtk_toggle_button_get_active(button));
+}
+
+//-----------------------------------------------------------------------------
+
void ConfigurationDialog::response(int response_id)
{
if ((m_plugin->get_button_style() == PanelPlugin::ShowText) && m_plugin->get_button_title().empty())
diff --git a/src/configuration_dialog.hpp b/src/configuration_dialog.hpp
index 86f5d72..775c313 100644
--- a/src/configuration_dialog.hpp
+++ b/src/configuration_dialog.hpp
@@ -48,6 +48,7 @@ private:
void toggle_show_name(GtkToggleButton* button);
void toggle_show_description(GtkToggleButton* button);
void toggle_load_hierarchy(GtkToggleButton* button);
+ void toggle_remember_favorites(GtkToggleButton* button);
void response(int response_id);
private:
@@ -64,6 +65,7 @@ private:
GtkWidget* m_show_descriptions;
GtkWidget* m_hover_switch_category;
GtkWidget* m_load_hierarchy;
+ GtkWidget* m_remember_favorites;
private:
@@ -112,6 +114,11 @@ private:
obj->toggle_load_hierarchy(button);
}
+ static void toggle_remember_favorites_slot(GtkToggleButton* button, ConfigurationDialog* obj)
+ {
+ obj->toggle_remember_favorites(button);
+ }
+
static void response_slot(GtkDialog*, gint response_id, ConfigurationDialog* obj)
{
obj->response(response_id);
diff --git a/src/favorites_page.cpp b/src/favorites_page.cpp
index c8ed504..43ddc75 100644
--- a/src/favorites_page.cpp
+++ b/src/favorites_page.cpp
@@ -28,6 +28,8 @@ using namespace WhiskerMenu;
//-----------------------------------------------------------------------------
+static bool f_remember_favorites = true;
+
static const std::string default_favorites[4] =
{
"exo-terminal-emulator.desktop",
@@ -65,6 +67,20 @@ void FavoritesPage::add(Launcher* launcher)
//-----------------------------------------------------------------------------
+bool FavoritesPage::get_remember_favorites()
+{
+ return f_remember_favorites;
+}
+
+//-----------------------------------------------------------------------------
+
+void FavoritesPage::set_remember_favorites(bool remember)
+{
+ f_remember_favorites = remember;
+}
+
+//-----------------------------------------------------------------------------
+
void FavoritesPage::extend_context_menu(GtkWidget* menu)
{
GtkWidget* menuitem = gtk_separator_menu_item_new();
@@ -85,6 +101,13 @@ void FavoritesPage::extend_context_menu(GtkWidget* menu)
//-----------------------------------------------------------------------------
+bool FavoritesPage::remember_launcher(Launcher* launcher)
+{
+ return f_remember_favorites ? true : !contains(launcher);
+}
+
+//-----------------------------------------------------------------------------
+
void FavoritesPage::sort(std::vector<Launcher*>& items) const
{
const std::vector<std::string>& desktop_ids = get_desktop_ids();
diff --git a/src/favorites_page.hpp b/src/favorites_page.hpp
index 230d371..6122b6e 100644
--- a/src/favorites_page.hpp
+++ b/src/favorites_page.hpp
@@ -31,8 +31,12 @@ public:
void add(Launcher* launcher);
+ static bool get_remember_favorites();
+ static void set_remember_favorites(bool remember);
+
private:
void extend_context_menu(GtkWidget* menu);
+ bool remember_launcher(Launcher* launcher);
void sort(std::vector<Launcher*>& items) const;
void sort_ascending();
void sort_descending();
diff --git a/src/page.cpp b/src/page.cpp
index 48283b9..7fbc169 100644
--- a/src/page.cpp
+++ b/src/page.cpp
@@ -100,6 +100,13 @@ Launcher* Page::get_selected_launcher() const
//-----------------------------------------------------------------------------
+bool Page::remember_launcher(Launcher*)
+{
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+
void Page::launcher_activated(GtkTreeView* view, GtkTreePath* path)
{
GtkTreeIter iter;
@@ -115,7 +122,10 @@ void Page::launcher_activated(GtkTreeView* view, GtkTreePath* path)
}
// Add to recent
- m_menu->get_recent()->add(launcher);
+ if (remember_launcher(launcher))
+ {
+ m_menu->get_recent()->add(launcher);
+ }
// Hide window
m_menu->hide();
diff --git a/src/page.hpp b/src/page.hpp
index e9c6de0..cb04fc1 100644
--- a/src/page.hpp
+++ b/src/page.hpp
@@ -55,6 +55,7 @@ protected:
}
private:
+ virtual bool remember_launcher(Launcher* launcher);
void launcher_activated(GtkTreeView* view, GtkTreePath* path);
bool view_button_press_event(GtkWidget* view, GdkEventButton* event);
bool view_popup_menu_event(GtkWidget* view);
diff --git a/src/panel_plugin.cpp b/src/panel_plugin.cpp
index 9f1a3ca..fb6a5bb 100644
--- a/src/panel_plugin.cpp
+++ b/src/panel_plugin.cpp
@@ -18,6 +18,7 @@
#include "applications_page.hpp"
#include "configuration_dialog.hpp"
+#include "favorites_page.hpp"
#include "icon_size.hpp"
#include "launcher.hpp"
#include "launcher_view.hpp"
@@ -67,6 +68,7 @@ PanelPlugin::PanelPlugin(XfcePanelPlugin* plugin) :
SectionButton::set_icon_size(xfce_rc_read_int_entry(settings, "category-icon-size", SectionButton::get_icon_size()));
LauncherView::set_icon_size(xfce_rc_read_int_entry(settings, "item-icon-size", LauncherView::get_icon_size()));
ApplicationsPage::set_load_hierarchy(xfce_rc_read_bool_entry(settings, "load-hierarchy", ApplicationsPage::get_load_hierarchy()));
+ FavoritesPage::set_remember_favorites(xfce_rc_read_bool_entry(settings, "favorites-in-recent", FavoritesPage::get_remember_favorites()));
m_menu = new Menu(settings);
xfce_rc_close(settings);
@@ -312,6 +314,7 @@ void PanelPlugin::save()
xfce_rc_write_int_entry(settings, "category-icon-size", SectionButton::get_icon_size());
xfce_rc_write_int_entry(settings, "item-icon-size", LauncherView::get_icon_size());
xfce_rc_write_bool_entry(settings, "load-hierarchy", ApplicationsPage::get_load_hierarchy());
+ xfce_rc_write_bool_entry(settings, "favorites-in-recent", FavoritesPage::get_remember_favorites());
m_menu->save(settings);
xfce_rc_close(settings);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list