[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 469/473: Expand subcategories when activated. Closes #81

noreply at xfce.org noreply at xfce.org
Tue Feb 17 00:00: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 60a9705c34124a2e3766831ab71b49b991d20e53
Author: Graeme Gott <graeme at gottcode.org>
Date:   Tue Mar 25 11:56:44 2014 -0400

    Expand subcategories when activated. Closes #81
---
 panel-plugin/launcher-view.cpp |   36 ++++++++++++++++++++++++++++++++++++
 panel-plugin/launcher-view.h   |    3 +++
 2 files changed, 39 insertions(+)

diff --git a/panel-plugin/launcher-view.cpp b/panel-plugin/launcher-view.cpp
index dbcb035..4f2d7b5 100644
--- a/panel-plugin/launcher-view.cpp
+++ b/panel-plugin/launcher-view.cpp
@@ -47,6 +47,7 @@ LauncherView::LauncherView(Window* window) :
 	m_pressed_launcher(NULL),
 	m_drag_enabled(true),
 	m_launcher_dragged(false),
+	m_row_activated(false),
 	m_reorderable(false)
 {
 	// Create the view
@@ -76,6 +77,9 @@ LauncherView::LauncherView(Window* window) :
 	g_signal_connect_slot(m_view, "button-release-event", &LauncherView::on_button_release_event, this);
 	g_signal_connect_slot(m_view, "drag-data-get", &LauncherView::on_drag_data_get, this);
 	g_signal_connect_slot(m_view, "drag-end", &LauncherView::on_drag_end, this);
+	g_signal_connect_slot(m_view, "row-activated", &LauncherView::on_row_activated, this);
+	g_signal_connect_slot<GtkTreeView*,GtkTreeIter*,GtkTreePath*>(m_view, "test-collapse-row", &LauncherView::test_row_toggle, this);
+	g_signal_connect_slot<GtkTreeView*,GtkTreeIter*,GtkTreePath*>(m_view, "test-expand-row", &LauncherView::test_row_toggle, this);
 	set_reorderable(false);
 }
 
@@ -284,6 +288,8 @@ gboolean LauncherView::on_key_release_event(GtkWidget*, GdkEvent* event)
 
 gboolean LauncherView::on_button_press_event(GtkWidget*, GdkEvent* event)
 {
+	m_row_activated = false;
+
 	GdkEventButton* button_event = reinterpret_cast<GdkEventButton*>(event);
 	if (button_event->button != 1)
 	{
@@ -366,3 +372,33 @@ void LauncherView::on_drag_end(GtkWidget*, GdkDragContext*)
 }
 
 //-----------------------------------------------------------------------------
+
+void LauncherView::on_row_activated(GtkTreeView* tree_view, GtkTreePath* path, GtkTreeViewColumn*)
+{
+	if (m_pressed_launcher)
+	{
+		return;
+	}
+
+	m_row_activated = true;
+
+	if (gtk_tree_view_row_expanded(tree_view, path))
+	{
+		gtk_tree_view_collapse_row(tree_view, path);
+	}
+	else
+	{
+		gtk_tree_view_expand_row(tree_view, path, false);
+	}
+}
+
+//-----------------------------------------------------------------------------
+
+gboolean LauncherView::test_row_toggle()
+{
+	bool allow = !m_row_activated;
+	m_row_activated = false;
+	return allow;
+}
+
+//-----------------------------------------------------------------------------
diff --git a/panel-plugin/launcher-view.h b/panel-plugin/launcher-view.h
index e5f2030..c4763e5 100644
--- a/panel-plugin/launcher-view.h
+++ b/panel-plugin/launcher-view.h
@@ -76,6 +76,8 @@ private:
 	gboolean on_button_release_event(GtkWidget*, GdkEvent* event);
 	void on_drag_data_get(GtkWidget*, GdkDragContext*, GtkSelectionData* data, guint info, guint);
 	void on_drag_end(GtkWidget*, GdkDragContext*);
+	void on_row_activated(GtkTreeView* tree_view, GtkTreePath* path, GtkTreeViewColumn* column);
+	gboolean test_row_toggle();
 
 private:
 	Window* m_window;
@@ -88,6 +90,7 @@ private:
 	Launcher* m_pressed_launcher;
 	bool m_drag_enabled;
 	bool m_launcher_dragged;
+	bool m_row_activated;
 	bool m_reorderable;
 };
 

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


More information about the Xfce4-commits mailing list