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 b8ec31d4a028136eae64978979819347a68b0522
Author: Graeme Gott <[email protected]>
Date:   Tue Dec 24 14:38:50 2019 -0500

    Select items when hovering icon view.
---
 panel-plugin/launcher-icon-view.cpp | 48 +++++++++++++++++++++++++++++++++++++
 panel-plugin/launcher-icon-view.h   |  6 +++++
 2 files changed, 54 insertions(+)

diff --git a/panel-plugin/launcher-icon-view.cpp 
b/panel-plugin/launcher-icon-view.cpp
index 4e451cc..80554c7 100644
--- a/panel-plugin/launcher-icon-view.cpp
+++ b/panel-plugin/launcher-icon-view.cpp
@@ -54,6 +54,12 @@ LauncherIconView::LauncherIconView() :
        gtk_icon_view_set_selection_mode(m_view, GTK_SELECTION_SINGLE);
 
        g_object_ref_sink(m_view);
+
+       // Handle hover selection
+       gtk_widget_add_events(GTK_WIDGET(m_view), GDK_SCROLL_MASK);
+       g_signal_connect_slot(m_view, "leave-notify-event", 
&LauncherIconView::on_leave_notify_event, this);
+       g_signal_connect_slot(m_view, "motion-notify-event", 
&LauncherIconView::on_motion_notify_event, this);
+       g_signal_connect_slot(m_view, "scroll-event", 
&LauncherIconView::on_scroll_event, this);
 }
 
 //-----------------------------------------------------------------------------
@@ -275,3 +281,45 @@ void LauncherIconView::reload_icon_size()
 }
 
 //-----------------------------------------------------------------------------
+
+gboolean LauncherIconView::on_leave_notify_event(GtkWidget*, GdkEvent*)
+{
+       clear_selection();
+       return false;
+}
+
+//-----------------------------------------------------------------------------
+
+gboolean LauncherIconView::on_motion_notify_event(GtkWidget*, GdkEvent* event)
+{
+       GdkEventMotion* motion_event = reinterpret_cast<GdkEventMotion*>(event);
+       select_path_at_pos(motion_event->x, motion_event->y);
+       return false;
+}
+
+//-----------------------------------------------------------------------------
+
+gboolean LauncherIconView::on_scroll_event(GtkWidget*, GdkEvent* event)
+{
+       GdkEventScroll* scroll_event = reinterpret_cast<GdkEventScroll*>(event);
+       select_path_at_pos(scroll_event->x, scroll_event->y);
+       return false;
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::select_path_at_pos(int x, int y)
+{
+       GtkTreePath* path = get_path_at_pos(x, y);
+       if (!path)
+       {
+               clear_selection();
+       }
+       else if (!gtk_icon_view_path_is_selected(m_view, path))
+       {
+               select_path(path);
+       }
+       gtk_tree_path_free(path);
+}
+
+//-----------------------------------------------------------------------------
diff --git a/panel-plugin/launcher-icon-view.h 
b/panel-plugin/launcher-icon-view.h
index b810000..40a6a62 100644
--- a/panel-plugin/launcher-icon-view.h
+++ b/panel-plugin/launcher-icon-view.h
@@ -62,6 +62,12 @@ public:
        void reload_icon_size();
 
 private:
+       gboolean on_leave_notify_event(GtkWidget*, GdkEvent*);
+       gboolean on_motion_notify_event(GtkWidget*, GdkEvent* event);
+       gboolean on_scroll_event(GtkWidget*, GdkEvent* event);
+       void select_path_at_pos(int x, int y);
+
+private:
        GtkIconView* m_view;
        GtkCellRenderer* m_icon_renderer;
        int m_icon_size;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
Xfce4-commits mailing list
[email protected]
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to