[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 169/473: Add option to display recently used by default. Closes #30.
noreply at xfce.org
noreply at xfce.org
Mon Feb 16 23:55:39 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 0c0fd174f25e8c5eb98b38207339bffd90cffa36
Author: Graeme Gott <graeme at gottcode.org>
Date: Wed Oct 9 05:47:29 2013 -0400
Add option to display recently used by default. Closes #30.
---
src/configuration_dialog.cpp | 14 +++++++++
src/configuration_dialog.hpp | 7 +++++
src/menu.cpp | 68 +++++++++++++++++++++++++++++++++++++-----
src/menu.hpp | 7 +++++
src/panel_plugin.cpp | 2 ++
5 files changed, 90 insertions(+), 8 deletions(-)
diff --git a/src/configuration_dialog.cpp b/src/configuration_dialog.cpp
index f6dd478..1250765 100644
--- a/src/configuration_dialog.cpp
+++ b/src/configuration_dialog.cpp
@@ -185,6 +185,14 @@ void ConfigurationDialog::toggle_remember_favorites(GtkToggleButton* button)
//-----------------------------------------------------------------------------
+void ConfigurationDialog::toggle_display_recent(GtkToggleButton* button)
+{
+ Menu::set_display_recent(gtk_toggle_button_get_active(button));
+ m_plugin->reload();
+}
+
+//-----------------------------------------------------------------------------
+
void ConfigurationDialog::settings_command_changed()
{
const gchar* text = gtk_entry_get_text(GTK_ENTRY(m_settings_command));
@@ -384,6 +392,12 @@ GtkWidget* ConfigurationDialog::init_behavior_tab()
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);
+ // Add option to display recently used
+ m_display_recent = gtk_check_button_new_with_mnemonic(_("Display recently _used by default"));
+ gtk_box_pack_start(behavior_vbox, m_display_recent, true, true, 0);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_display_recent), Menu::get_display_recent());
+ g_signal_connect(m_display_recent, "toggled", G_CALLBACK(ConfigurationDialog::toggle_display_recent_slot), this);
+
return page;
}
diff --git a/src/configuration_dialog.hpp b/src/configuration_dialog.hpp
index ed189d4..ccbcee5 100644
--- a/src/configuration_dialog.hpp
+++ b/src/configuration_dialog.hpp
@@ -49,6 +49,7 @@ private:
void toggle_show_description(GtkToggleButton* button);
void toggle_load_hierarchy(GtkToggleButton* button);
void toggle_remember_favorites(GtkToggleButton* button);
+ void toggle_display_recent(GtkToggleButton* button);
void settings_command_changed();
void lockscreen_command_changed();
void logout_command_changed();
@@ -73,6 +74,7 @@ private:
GtkWidget* m_hover_switch_category;
GtkWidget* m_load_hierarchy;
GtkWidget* m_remember_favorites;
+ GtkWidget* m_display_recent;
GtkWidget* m_settings_command;
GtkWidget* m_lockscreen_command;
GtkWidget* m_logout_command;
@@ -129,6 +131,11 @@ private:
obj->toggle_remember_favorites(button);
}
+ static void toggle_display_recent_slot(GtkToggleButton* button, ConfigurationDialog* obj)
+ {
+ obj->toggle_display_recent(button);
+ }
+
static void response_slot(GtkDialog*, gint response_id, ConfigurationDialog* obj)
{
obj->response(response_id);
diff --git a/src/menu.cpp b/src/menu.cpp
index 863e9ea..eabcc5a 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -52,6 +52,7 @@ static GtkButton* new_action_button(const gchar* icon, const gchar* text)
std::string Menu::m_settings_command = "xfce4-settings-manager";
std::string Menu::m_lockscreen_command = "xflock4";
std::string Menu::m_logout_command = "xfce4-session-logout";
+bool Menu::m_display_recent = false;
//-----------------------------------------------------------------------------
@@ -138,6 +139,18 @@ Menu::Menu(XfceRc* settings) :
// Create search results
m_search_results = new SearchPage(this);
+ // Handle default page
+ if (!m_display_recent)
+ {
+ m_default_button = m_favorites_button;
+ m_default_page = m_favorites;
+ }
+ else
+ {
+ m_default_button = m_recent_button;
+ m_default_page = m_recent;
+ }
+
// Create box for packing children
m_vbox = GTK_BOX(gtk_vbox_new(false, 6));
gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(m_vbox));
@@ -189,10 +202,11 @@ Menu::Menu(XfceRc* settings) :
// Show widgets
gtk_widget_show_all(GTK_WIDGET(m_vbox));
+ gtk_widget_hide(m_favorites->get_widget());
gtk_widget_hide(m_recent->get_widget());
gtk_widget_hide(m_applications->get_widget());
gtk_widget_hide(m_search_results->get_widget());
- m_favorites_button->set_active(true);
+ m_default_button->set_active(true);
gtk_widget_show(frame);
// Resize to last known size
@@ -228,11 +242,23 @@ void Menu::hide()
// Hide window
gtk_widget_hide(GTK_WIDGET(m_window));
- // Reset mouse cursor by forcing favorites to hide
- gtk_widget_hide(m_favorites->get_widget());
+ // Update default page
+ if (m_display_recent && (m_default_page == m_favorites))
+ {
+ m_default_button = m_recent_button;
+ m_default_page = m_recent;
+ }
+ else if (!m_display_recent && (m_default_page == m_recent))
+ {
+ m_default_button = m_favorites_button;
+ m_default_page = m_favorites;
+ }
- // Switch back to favorites
- show_favorites();
+ // Reset mouse cursor by forcing default page to hide
+ gtk_widget_hide(m_default_page->get_widget());
+
+ // Switch back to default page
+ show_default_page();
}
//-----------------------------------------------------------------------------
@@ -251,8 +277,8 @@ void Menu::show(GtkWidget* parent, bool horizontal)
// Make sure applications list is current; does nothing unless list has changed
m_applications->load_applications();
- // Reset mouse cursor by forcing favorites to hide
- gtk_widget_show(m_favorites->get_widget());
+ // Reset mouse cursor by forcing default page to hide
+ gtk_widget_show(m_default_page->get_widget());
GdkScreen* screen = NULL;
int parent_x = 0, parent_y = 0, parent_w = 0, parent_h = 0;
@@ -452,7 +478,7 @@ void Menu::set_categories(const std::vector<SectionButton*>& categories)
}
gtk_widget_show_all(GTK_WIDGET(m_sidebar_box));
- show_favorites();
+ show_default_page();
}
//-----------------------------------------------------------------------------
@@ -531,6 +557,13 @@ std::string Menu::get_logout_command()
//-----------------------------------------------------------------------------
+bool Menu::get_display_recent()
+{
+ return m_display_recent;
+}
+
+//-----------------------------------------------------------------------------
+
void Menu::set_settings_command(const std::string& command)
{
m_settings_command = command;
@@ -552,6 +585,13 @@ void Menu::set_logout_command(const std::string& command)
//-----------------------------------------------------------------------------
+void Menu::set_display_recent(bool display)
+{
+ m_display_recent = display;
+}
+
+//-----------------------------------------------------------------------------
+
bool Menu::on_leave_notify_event(GdkEventCrossing* event)
{
if ( (event->detail == GDK_NOTIFY_INFERIOR)
@@ -740,6 +780,18 @@ void Menu::show_favorites()
//-----------------------------------------------------------------------------
+void Menu::show_default_page()
+{
+ // Switch to favorites panel
+ m_default_button->set_active(true);
+
+ // Clear search entry
+ gtk_entry_set_text(m_search_entry, "");
+ gtk_widget_grab_focus(GTK_WIDGET(m_search_entry));
+}
+
+//-----------------------------------------------------------------------------
+
void Menu::search()
{
// Fetch search string
diff --git a/src/menu.hpp b/src/menu.hpp
index 4742c7b..9b501dd 100644
--- a/src/menu.hpp
+++ b/src/menu.hpp
@@ -33,6 +33,7 @@ namespace WhiskerMenu
class ApplicationsPage;
class FavoritesPage;
class Launcher;
+class Page;
class ResizerWidget;
class RecentPage;
class SearchPage;
@@ -85,9 +86,11 @@ public:
static std::string get_settings_command();
static std::string get_lockscreen_command();
static std::string get_logout_command();
+ static bool get_display_recent();
static void set_settings_command(const std::string& command);
static void set_lockscreen_command(const std::string& command);
static void set_logout_command(const std::string& command);
+ static void set_display_recent(bool display);
private:
bool on_enter_notify_event(GdkEventCrossing* event);
@@ -102,6 +105,7 @@ private:
void recent_toggled();
void category_toggled();
void show_favorites();
+ void show_default_page();
void search();
void launch_settings_manager();
void lock_screen();
@@ -128,10 +132,12 @@ private:
FavoritesPage* m_favorites;
RecentPage* m_recent;
ApplicationsPage* m_applications;
+ Page* m_default_page;
GtkScrolledWindow* m_sidebar;
SectionButton* m_favorites_button;
SectionButton* m_recent_button;
+ SectionButton* m_default_button;
GdkRectangle m_geometry;
bool m_layout_left;
@@ -141,6 +147,7 @@ private:
static std::string m_settings_command;
static std::string m_lockscreen_command;
static std::string m_logout_command;
+ static bool m_display_recent;
private:
diff --git a/src/panel_plugin.cpp b/src/panel_plugin.cpp
index cbd0b2a..909684a 100644
--- a/src/panel_plugin.cpp
+++ b/src/panel_plugin.cpp
@@ -69,6 +69,7 @@ PanelPlugin::PanelPlugin(XfcePanelPlugin* plugin) :
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()));
+ Menu::set_display_recent(xfce_rc_read_bool_entry(settings, "display-recent-default", Menu::get_display_recent()));
Menu::set_settings_command(xfce_rc_read_entry(settings, "command-settings", Menu::get_settings_command().c_str()));
Menu::set_lockscreen_command(xfce_rc_read_entry(settings, "command-lockscreen", Menu::get_lockscreen_command().c_str()));
Menu::set_logout_command(xfce_rc_read_entry(settings, "command-logout", Menu::get_logout_command().c_str()));
@@ -318,6 +319,7 @@ void PanelPlugin::save()
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());
+ xfce_rc_write_bool_entry(settings, "display-recent-default", Menu::get_display_recent());
xfce_rc_write_entry(settings, "command-settings", Menu::get_settings_command().c_str());
xfce_rc_write_entry(settings, "command-lockscreen", Menu::get_lockscreen_command().c_str());
xfce_rc_write_entry(settings, "command-logout", Menu::get_logout_command().c_str());
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list