[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 109/473: Fix focus selection not properly reset when switching categories.
noreply at xfce.org
noreply at xfce.org
Mon Feb 16 23:54: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 22ca7de7757f9593522c7bc0db07340afd69f602
Author: Graeme Gott <graeme at gottcode.org>
Date: Sun Jul 14 19:59:23 2013 -0400
Fix focus selection not properly reset when switching categories.
---
src/launcher_view.cpp | 3 +--
src/menu.cpp | 8 ++++++++
src/page.cpp | 34 +++++++++++++++++-----------------
src/page.hpp | 7 ++-----
4 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/src/launcher_view.cpp b/src/launcher_view.cpp
index 2692092..86610ae 100644
--- a/src/launcher_view.cpp
+++ b/src/launcher_view.cpp
@@ -102,8 +102,7 @@ void LauncherView::scroll_to_path(GtkTreePath* path)
void LauncherView::select_path(GtkTreePath* path)
{
- GtkTreeSelection* selection = gtk_tree_view_get_selection(m_view);
- gtk_tree_selection_select_path(selection, path);
+ gtk_tree_view_set_cursor(m_view, path, NULL, false);
}
//-----------------------------------------------------------------------------
diff --git a/src/menu.cpp b/src/menu.cpp
index 5d6ea2f..d167fe4 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -600,6 +600,8 @@ bool Menu::on_key_press_event_after(GtkWidget* widget, GdkEventKey* event)
bool Menu::on_map_event()
{
+ m_favorites->reset_selection();
+
gtk_window_set_keep_above(m_window, true);
// Track mouse clicks outside of menu
@@ -635,27 +637,33 @@ bool Menu::on_configure_event(GdkEventConfigure* event)
void Menu::favorites_toggled()
{
+ m_favorites->reset_selection();
gtk_widget_hide(m_recent->get_widget());
gtk_widget_hide(m_applications->get_widget());
gtk_widget_show_all(m_favorites->get_widget());
+ gtk_widget_grab_focus(GTK_WIDGET(m_search_entry));
}
//-----------------------------------------------------------------------------
void Menu::recent_toggled()
{
+ m_recent->reset_selection();
gtk_widget_hide(m_favorites->get_widget());
gtk_widget_hide(m_applications->get_widget());
gtk_widget_show_all(m_recent->get_widget());
+ gtk_widget_grab_focus(GTK_WIDGET(m_search_entry));
}
//-----------------------------------------------------------------------------
void Menu::category_toggled()
{
+ m_applications->reset_selection();
gtk_widget_hide(m_favorites->get_widget());
gtk_widget_hide(m_recent->get_widget());
gtk_widget_show_all(m_applications->get_widget());
+ gtk_widget_grab_focus(GTK_WIDGET(m_search_entry));
}
//-----------------------------------------------------------------------------
diff --git a/src/page.cpp b/src/page.cpp
index 76d0c93..25400b8 100644
--- a/src/page.cpp
+++ b/src/page.cpp
@@ -48,7 +48,6 @@ Page::Page(Menu* menu) :
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(m_widget), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(m_widget), GTK_SHADOW_ETCHED_IN);
gtk_container_add(GTK_CONTAINER(m_widget), m_view->get_widget());
- g_signal_connect(m_widget, "unmap", G_CALLBACK(Page::on_unmap_slot), this);
g_object_ref_sink(m_widget);
}
@@ -67,6 +66,23 @@ Page::~Page()
//-----------------------------------------------------------------------------
+void Page::reset_selection()
+{
+ // Clear selection and scroll to top
+ GtkTreeModel* model = m_view->get_model();
+ GtkTreeIter iter;
+ if (gtk_tree_model_get_iter_first(model, &iter))
+ {
+ GtkTreePath* path = gtk_tree_model_get_path(model, &iter);
+ get_view()->scroll_to_path(path);
+ get_view()->select_path(path);
+ get_view()->unselect_all();
+ gtk_tree_path_free(path);
+ }
+}
+
+//-----------------------------------------------------------------------------
+
Launcher* Page::get_selected_launcher() const
{
Launcher* launcher = NULL;
@@ -140,22 +156,6 @@ bool Page::view_popup_menu_event(GtkWidget* view)
//-----------------------------------------------------------------------------
-void Page::on_unmap()
-{
- // Clear selection and scroll to top
- GtkTreeModel* model = m_view->get_model();
- GtkTreeIter iter;
- if (gtk_tree_model_get_iter_first(model, &iter))
- {
- GtkTreePath* path = gtk_tree_model_get_path(model, &iter);
- get_view()->scroll_to_path(path);
- get_view()->unselect_all();
- gtk_tree_path_free(path);
- }
-}
-
-//-----------------------------------------------------------------------------
-
void Page::create_context_menu(GtkTreeIter* iter, GdkEventButton* event)
{
m_selected_path = gtk_tree_model_get_path(m_view->get_model(), iter);
diff --git a/src/page.hpp b/src/page.hpp
index 93297ec..e9c6de0 100644
--- a/src/page.hpp
+++ b/src/page.hpp
@@ -46,6 +46,8 @@ public:
return m_view;
}
+ void reset_selection();
+
protected:
Menu* get_menu() const
{
@@ -90,11 +92,6 @@ private:
return obj->view_popup_menu_event(view);
}
- static void on_unmap_slot(GtkWidget*, Page* obj)
- {
- obj->on_unmap();
- }
-
static void destroy_context_menu_slot(GtkMenuShell* menu, Page* obj)
{
obj->destroy_context_menu(menu);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list