[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 267/473: Add support for running other types of elements.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:57:17 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 3bc137caf38f0c16019fe9a3a87c1f10a6d8d1c2
Author: Graeme Gott <graeme at gottcode.org>
Date:   Thu Nov 21 17:35:10 2013 -0500

    Add support for running other types of elements.
---
 panel-plugin/element.h     |   10 +++++++++-
 panel-plugin/launcher.h    |    5 -----
 panel-plugin/list-page.cpp |    2 ++
 panel-plugin/page.cpp      |   24 ++++++++++++++----------
 panel-plugin/page.h        |    2 +-
 5 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/panel-plugin/element.h b/panel-plugin/element.h
index 13c36c2..a64fc8a 100644
--- a/panel-plugin/element.h
+++ b/panel-plugin/element.h
@@ -18,7 +18,7 @@
 #ifndef WHISKERMENU_ELEMENT_H
 #define WHISKERMENU_ELEMENT_H
 
-#include <glib.h>
+#include <gdk/gdk.h>
 
 namespace WhiskerMenu
 {
@@ -52,6 +52,10 @@ public:
 		return m_text;
 	}
 
+	virtual void run(GdkScreen*) const
+	{
+	}
+
 	static bool less_than(const Element* lhs, const Element* rhs)
 	{
 		return g_strcmp0(lhs->m_sort_key, rhs->m_sort_key) < 0;
@@ -81,6 +85,10 @@ protected:
 	}
 
 private:
+	Element(const Element&);
+	Element& operator=(const Element&);
+
+private:
 	gchar* m_icon;
 	gchar* m_text;
 	gchar* m_sort_key;
diff --git a/panel-plugin/launcher.h b/panel-plugin/launcher.h
index 606fd96..3310eca 100644
--- a/panel-plugin/launcher.h
+++ b/panel-plugin/launcher.h
@@ -23,7 +23,6 @@
 #include <string>
 
 #include <garcon/garcon.h>
-#include <gdk/gdk.h>
 
 namespace WhiskerMenu
 {
@@ -65,10 +64,6 @@ public:
 	int search(const Query& query) const;
 
 private:
-	Launcher(const Launcher& launcher);
-	Launcher& operator=(const Launcher& launcher);
-
-private:
 	GarconMenuItem* m_item;
 	const gchar* m_display_name;
 	std::string m_search_name;
diff --git a/panel-plugin/list-page.cpp b/panel-plugin/list-page.cpp
index d6ecb3f..04d9fea 100644
--- a/panel-plugin/list-page.cpp
+++ b/panel-plugin/list-page.cpp
@@ -154,6 +154,7 @@ void ListPage::on_row_changed(GtkTreeModel* model, GtkTreePath* path, GtkTreeIte
 
 	Launcher* launcher;
 	gtk_tree_model_get(model, iter, LauncherView::COLUMN_LAUNCHER, &launcher, -1);
+	g_assert(launcher->get_type() == Launcher::Type);
 	if (launcher)
 	{
 		m_desktop_ids[pos] = launcher->get_desktop_id();
@@ -170,6 +171,7 @@ void ListPage::on_row_inserted(GtkTreeModel* model, GtkTreePath* path, GtkTreeIt
 	std::string desktop_id;
 	Launcher* launcher;
 	gtk_tree_model_get(model, iter, LauncherView::COLUMN_LAUNCHER, &launcher, -1);
+	g_assert(launcher->get_type() == Launcher::Type);
 	if (launcher)
 	{
 		desktop_id = launcher->get_desktop_id();
diff --git a/panel-plugin/page.cpp b/panel-plugin/page.cpp
index a1d68f6..bb4b728 100644
--- a/panel-plugin/page.cpp
+++ b/panel-plugin/page.cpp
@@ -38,7 +38,7 @@ Page::Page(Window* window) :
 	m_view = new LauncherView;
 	g_signal_connect_slot(m_view->get_widget(), "button-press-event", &Page::view_button_press_event, this);
 	g_signal_connect_slot(m_view->get_widget(), "popup-menu", &Page::view_popup_menu_event, this);
-	g_signal_connect_slot(m_view->get_widget(), "row-activated", &Page::launcher_activated, this);
+	g_signal_connect_slot(m_view->get_widget(), "row-activated", &Page::item_activated, this);
 	g_signal_connect_swapped(m_view->get_widget(), "start-interactive-search", G_CALLBACK(gtk_widget_grab_focus), m_window->get_search_entry());
 
 	// Add scrolling to view
@@ -93,7 +93,7 @@ Launcher* Page::get_selected_launcher() const
 		gtk_tree_model_get_iter(model, &iter, m_selected_path);
 		gtk_tree_model_get(model, &iter, LauncherView::COLUMN_LAUNCHER, &launcher, -1);
 	}
-	return launcher;
+	return (launcher->get_type() == Launcher::Type) ? launcher : NULL;
 }
 
 //-----------------------------------------------------------------------------
@@ -105,31 +105,35 @@ bool Page::remember_launcher(Launcher*)
 
 //-----------------------------------------------------------------------------
 
-void Page::launcher_activated(GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn*)
+void Page::item_activated(GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn*)
 {
 	GtkTreeIter iter;
 	GtkTreeModel* model = gtk_tree_view_get_model(view);
 	gtk_tree_model_get_iter(model, &iter, path);
 
-	// Find launcher
-	Launcher* launcher = NULL;
-	gtk_tree_model_get(model, &iter, LauncherView::COLUMN_LAUNCHER, &launcher, -1);
-	if (!launcher)
+	// Find element
+	Element* element = NULL;
+	gtk_tree_model_get(model, &iter, LauncherView::COLUMN_LAUNCHER, &element, -1);
+	if (!element)
 	{
 		return;
 	}
 
 	// Add to recent
-	if (remember_launcher(launcher))
+	if (element->get_type() == Launcher::Type)
 	{
-		m_window->get_recent()->add(launcher);
+		Launcher* launcher = static_cast<Launcher*>(element);
+		if (remember_launcher(launcher))
+		{
+			m_window->get_recent()->add(launcher);
+		}
 	}
 
 	// Hide window
 	m_window->hide();
 
 	// Execute app
-	launcher->run(gtk_widget_get_screen(GTK_WIDGET(view)));
+	element->run(gtk_widget_get_screen(GTK_WIDGET(view)));
 }
 
 //-----------------------------------------------------------------------------
diff --git a/panel-plugin/page.h b/panel-plugin/page.h
index d398d7e..6195104 100644
--- a/panel-plugin/page.h
+++ b/panel-plugin/page.h
@@ -53,7 +53,7 @@ protected:
 
 private:
 	virtual bool remember_launcher(Launcher* launcher);
-	void launcher_activated(GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn*);
+	void item_activated(GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn*);
 	gboolean view_button_press_event(GtkWidget* view, GdkEventButton* event);
 	gboolean view_popup_menu_event(GtkWidget* view);
 	void on_unmap();

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


More information about the Xfce4-commits mailing list