[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 17/28: Replace slot templates with macros.

noreply at xfce.org noreply at xfce.org
Sat Aug 20 18:33:13 CEST 2016


This is an automated email from the git hooks/post-receive script.

gottcode pushed a commit to annotated tag v1.0.1
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 18899ea73f6e769a27f1fb0618959a03596d59c5
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sun Jun 23 08:40:28 2013 -0400

    Replace slot templates with macros.
---
 src/applications_page.cpp    |  11 +++--
 src/applications_page.hpp    |   7 ++-
 src/configuration_dialog.cpp |   9 ++--
 src/configuration_dialog.hpp |  10 +++--
 src/list_page.cpp            |   7 ++-
 src/list_page.hpp            |   7 +--
 src/menu.cpp                 |  29 ++++++------
 src/menu.hpp                 |  30 +++++++------
 src/page.cpp                 |  19 ++++----
 src/page.hpp                 |  23 +++++-----
 src/panel_plugin.cpp         |  13 +++---
 src/panel_plugin.hpp         |  14 +++---
 src/resizer_widget.cpp       |  10 ++---
 src/resizer_widget.hpp       |  10 +++--
 src/search_page.cpp          |   5 +--
 src/search_page.hpp          |   7 ++-
 src/slot.hpp                 | 103 +++++++++++++------------------------------
 17 files changed, 141 insertions(+), 173 deletions(-)

diff --git a/src/applications_page.cpp b/src/applications_page.cpp
index ac01311..b3f2bf1 100644
--- a/src/applications_page.cpp
+++ b/src/applications_page.cpp
@@ -21,7 +21,6 @@
 #include "launcher_view.hpp"
 #include "menu.hpp"
 #include "section_button.hpp"
-#include "slot.hpp"
 
 #include <algorithm>
 #include <map>
@@ -126,7 +125,7 @@ void ApplicationsPage::reload_applications()
 	g_object_ref(m_garcon_menu);
 	if (garcon_menu_load(m_garcon_menu, nullptr, nullptr))
 	{
-		g_signal_connect_slot(m_garcon_menu, "reload-required", &ApplicationsPage::reload_applications, this);
+		g_signal_connect_swapped(m_garcon_menu, "reload-required", SLOT_CALLBACK(ApplicationsPage::reload_applications), this);
 		load_menu(m_garcon_menu);
 	}
 
@@ -257,7 +256,7 @@ void ApplicationsPage::load_menu(GarconMenu* menu)
 	}
 
 	// Listen for menu changes
-	g_signal_connect_slot(menu, "directory-changed", &ApplicationsPage::reload_applications, this);
+	g_signal_connect_swapped(menu, "directory-changed", SLOT_CALLBACK(ApplicationsPage::reload_applications), this);
 }
 
 //-----------------------------------------------------------------------------
@@ -285,7 +284,7 @@ void ApplicationsPage::load_menu_item(const gchar* desktop_id, GarconMenuItem* m
 	}
 
 	// Listen for menu changes
-	g_signal_connect_slot(menu_item, "changed", &ApplicationsPage::reload_applications, page);
+	g_signal_connect_swapped(menu_item, "changed", SLOT_CALLBACK(ApplicationsPage::reload_applications), page);
 }
 
 //-----------------------------------------------------------------------------
@@ -296,7 +295,7 @@ void ApplicationsPage::reload_categories()
 
 	// Add button for all applications
 	GtkRadioButton* all_button = new_section_button("applications-other", _("All"));
-	g_signal_connect_slot(all_button, "toggled", &ApplicationsPage::apply_filter, this);
+	g_signal_connect(all_button, "toggled", SLOT_CALLBACK(ApplicationsPage::apply_filter), this);
 	m_category_buttons.emplace(all_button, nullptr);
 	category_buttons.push_back(all_button);
 
@@ -313,7 +312,7 @@ void ApplicationsPage::reload_categories()
 	for (const auto& i : sorted_categories)
 	{
 		GtkRadioButton* category_button = new_section_button(i.second->get_icon(), i.second->get_text());
-		g_signal_connect_slot(category_button, "toggled", &ApplicationsPage::apply_filter, this);
+		g_signal_connect(category_button, "toggled", SLOT_CALLBACK(ApplicationsPage::apply_filter), this);
 		m_category_buttons.emplace(category_button, i.second);
 		category_buttons.push_back(category_button);
 	}
diff --git a/src/applications_page.hpp b/src/applications_page.hpp
index d47d716..990799d 100644
--- a/src/applications_page.hpp
+++ b/src/applications_page.hpp
@@ -18,6 +18,7 @@
 #define WHISKERMENU_APPLICATIONS_PAGE_HPP
 
 #include "filter_page.hpp"
+#include "slot.hpp"
 
 #include <string>
 #include <unordered_map>
@@ -61,10 +62,12 @@ public:
 	ApplicationsPage(Menu* menu);
 	~ApplicationsPage();
 
-	void reload_applications();
+	SLOT_0(void, ApplicationsPage, reload_applications);
+
+private:
+	SLOT_1(void, ApplicationsPage, apply_filter, GtkToggleButton*);
 
 private:
-	void apply_filter(GtkToggleButton* togglebutton);
 	bool on_filter(GtkTreeModel* model, GtkTreeIter* iter);
 	void clear_applications();
 	void load_menu(GarconMenu* menu);
diff --git a/src/configuration_dialog.cpp b/src/configuration_dialog.cpp
index f23efbe..e1293fd 100644
--- a/src/configuration_dialog.cpp
+++ b/src/configuration_dialog.cpp
@@ -18,7 +18,6 @@
 
 #include "launcher.hpp"
 #include "panel_plugin.hpp"
-#include "slot.hpp"
 
 extern "C"
 {
@@ -52,7 +51,7 @@ ConfigurationDialog::ConfigurationDialog(PanelPlugin* plugin) :
 	m_window = xfce_titled_dialog_new_with_buttons(_("Whisker Menu"), window, GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, nullptr);
 	gtk_window_set_icon_name(GTK_WINDOW(m_window), GTK_STOCK_PROPERTIES);
 	gtk_window_set_position(GTK_WINDOW(m_window), GTK_WIN_POS_CENTER);
-	g_signal_connect_slot(m_window, "response", &ConfigurationDialog::response, this);
+	g_signal_connect(m_window, "response", SLOT_CALLBACK(ConfigurationDialog::response), this);
 	g_signal_connect_swapped(m_window, "destroy", G_CALLBACK(whiskermenu_config_dialog_delete), this);
 
 	// Fetch contents box
@@ -71,13 +70,13 @@ ConfigurationDialog::ConfigurationDialog(PanelPlugin* plugin) :
 	m_show_names = gtk_check_button_new_with_mnemonic(_("Show applications by _name"));
 	gtk_box_pack_start(appearance_vbox, m_show_names, true, true, 0);
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_names), Launcher::get_show_name());
-	g_signal_connect_slot(m_show_names, "toggled", &ConfigurationDialog::toggle_show_name, this);
+	g_signal_connect(m_show_names, "toggled", SLOT_CALLBACK(ConfigurationDialog::toggle_show_name), this);
 
 	// Add option to hide descriptions
 	m_show_descriptions = gtk_check_button_new_with_mnemonic(_("Show application _descriptions"));
 	gtk_box_pack_start(appearance_vbox, m_show_descriptions, true, true, 0);
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_descriptions), Launcher::get_show_description());
-	g_signal_connect_slot(m_show_descriptions, "toggled", &ConfigurationDialog::toggle_show_description, this);
+	g_signal_connect(m_show_descriptions, "toggled", SLOT_CALLBACK(ConfigurationDialog::toggle_show_description), this);
 
 	// Add icon selector
 	GtkBox* hbox = GTK_BOX(gtk_hbox_new(false, 2));
@@ -91,7 +90,7 @@ ConfigurationDialog::ConfigurationDialog(PanelPlugin* plugin) :
 	m_icon_button = gtk_button_new();
 	gtk_box_pack_start(hbox, m_icon_button, false, false, 0);
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_icon_button);
-	g_signal_connect_slot(m_icon_button, "clicked", &ConfigurationDialog::choose_icon, this);
+	g_signal_connect_swapped(m_icon_button, "clicked", SLOT_CALLBACK(ConfigurationDialog::choose_icon), this);
 
 	m_icon = xfce_panel_image_new_from_source(m_plugin->get_button_icon_name().c_str());
 	xfce_panel_image_set_size(XFCE_PANEL_IMAGE(m_icon), 48);
diff --git a/src/configuration_dialog.hpp b/src/configuration_dialog.hpp
index 003dc6b..f35e69e 100644
--- a/src/configuration_dialog.hpp
+++ b/src/configuration_dialog.hpp
@@ -17,6 +17,8 @@
 #ifndef WHISKERMENU_CONFIGURATION_DIALOG_HPP
 #define WHISKERMENU_CONFIGURATION_DIALOG_HPP
 
+#include "slot.hpp"
+
 extern "C"
 {
 #include <gtk/gtk.h>
@@ -34,10 +36,10 @@ public:
 	~ConfigurationDialog();
 
 private:
-	void choose_icon();
-	void toggle_show_name(GtkToggleButton*);
-	void toggle_show_description(GtkToggleButton*);
-	void response(GtkDialog* dialog, gint response_id);
+	SLOT_0(void, ConfigurationDialog, choose_icon);
+	SLOT_1(void, ConfigurationDialog, toggle_show_name, GtkToggleButton*);
+	SLOT_1(void, ConfigurationDialog, toggle_show_description, GtkToggleButton*);
+	SLOT_2(void, ConfigurationDialog, response, GtkDialog*, gint);
 
 private:
 	PanelPlugin* m_plugin;
diff --git a/src/list_page.cpp b/src/list_page.cpp
index 177d38e..5cea9c1 100644
--- a/src/list_page.cpp
+++ b/src/list_page.cpp
@@ -19,7 +19,6 @@
 #include "launcher.hpp"
 #include "launcher_model.hpp"
 #include "launcher_view.hpp"
-#include "slot.hpp"
 
 #include <algorithm>
 
@@ -117,9 +116,9 @@ void ListPage::set_menu_items(std::unordered_map<std::string, Launcher*> items)
 
 	// Replace treeview contents
 	get_view()->set_model(model.get_model());
-	g_signal_connect_slot(get_view()->get_model(), "row-changed", &ListPage::on_row_changed, this);
-	g_signal_connect_slot(get_view()->get_model(), "row-inserted", &ListPage::on_row_inserted, this);
-	g_signal_connect_slot(get_view()->get_model(), "row-deleted", &ListPage::on_row_deleted, this);
+	g_signal_connect(get_view()->get_model(), "row-changed", SLOT_CALLBACK(ListPage::on_row_changed), this);
+	g_signal_connect(get_view()->get_model(), "row-inserted", SLOT_CALLBACK(ListPage::on_row_inserted), this);
+	g_signal_connect(get_view()->get_model(), "row-deleted", SLOT_CALLBACK(ListPage::on_row_deleted), this);
 }
 
 //-----------------------------------------------------------------------------
diff --git a/src/list_page.hpp b/src/list_page.hpp
index 7ff4544..28be059 100644
--- a/src/list_page.hpp
+++ b/src/list_page.hpp
@@ -18,6 +18,7 @@
 #define WHISKERMENU_LIST_PAGE_HPP
 
 #include "page.hpp"
+#include "slot.hpp"
 
 #include <string>
 #include <unordered_map>
@@ -53,9 +54,9 @@ public:
 	void unset_menu_items();
 
 private:
-	void on_row_changed(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter);
-	void on_row_inserted(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter);
-	void on_row_deleted(GtkTreeModel* model, GtkTreePath* path);
+	SLOT_3(void, ListPage, on_row_changed, GtkTreeModel*, GtkTreePath*, GtkTreeIter*);
+	SLOT_3(void, ListPage, on_row_inserted, GtkTreeModel*, GtkTreePath*, GtkTreeIter*);
+	SLOT_2(void, ListPage, on_row_deleted, GtkTreeModel*, GtkTreePath*);
 
 private:
 	const gchar* m_key;
diff --git a/src/menu.cpp b/src/menu.cpp
index 5170389..0d3dde4 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -24,7 +24,6 @@
 #include "resizer_widget.hpp"
 #include "search_page.hpp"
 #include "section_button.hpp"
-#include "slot.hpp"
 
 extern "C"
 {
@@ -65,12 +64,12 @@ Menu::Menu(XfceRc* settings) :
 	gtk_window_set_skip_pager_hint(m_window, true);
 	gtk_window_stick(m_window);
 	gtk_widget_add_events(GTK_WIDGET(m_window), GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_STRUCTURE_MASK);
-	g_signal_connect_slot(m_window, "enter-notify-event", &Menu::on_enter_notify_event, this);
-	g_signal_connect_slot(m_window, "leave-notify-event", &Menu::on_leave_notify_event, this);
-	g_signal_connect_slot(m_window, "button-press-event", &Menu::on_button_press_event, this);
-	g_signal_connect_slot(m_window, "key-press-event", &Menu::on_key_press_event, this);
-	g_signal_connect_slot(m_window, "map-event", &Menu::on_map_event, this);
-	g_signal_connect_slot(m_window, "configure-event", &Menu::on_configure_event, this);
+	g_signal_connect(m_window, "enter-notify-event", SLOT_CALLBACK(Menu::on_enter_notify_event), this);
+	g_signal_connect(m_window, "leave-notify-event", SLOT_CALLBACK(Menu::on_leave_notify_event), this);
+	g_signal_connect(m_window, "button-press-event", SLOT_CALLBACK(Menu::on_button_press_event), this);
+	g_signal_connect(m_window, "key-press-event", SLOT_CALLBACK(Menu::on_key_press_event), this);
+	g_signal_connect(m_window, "map-event", SLOT_CALLBACK(Menu::on_map_event), this);
+	g_signal_connect(m_window, "configure-event", SLOT_CALLBACK(Menu::on_configure_event), this);
 
 	// Create the border of the window
 	GtkWidget* frame = gtk_frame_new(nullptr);
@@ -91,13 +90,13 @@ Menu::Menu(XfceRc* settings) :
 
 	// Create action buttons
 	m_settings_button = new_action_button("preferences-desktop", _("All Settings"));
-	g_signal_connect_slot(m_settings_button, "clicked", &Menu::launch_settings_manager, this);
+	g_signal_connect_swapped(m_settings_button, "clicked", SLOT_CALLBACK(Menu::launch_settings_manager), this);
 
 	m_lock_screen_button = new_action_button("system-lock-screen", _("Lock Screen"));
-	g_signal_connect_slot(m_lock_screen_button, "clicked", &Menu::lock_screen, this);
+	g_signal_connect_swapped(m_lock_screen_button, "clicked", SLOT_CALLBACK(Menu::lock_screen), this);
 
 	m_log_out_button = new_action_button("system-log-out", _("Log Out"));
-	g_signal_connect_slot(m_log_out_button, "clicked", &Menu::log_out, this);
+	g_signal_connect_swapped(m_log_out_button, "clicked", SLOT_CALLBACK(Menu::log_out), this);
 
 	m_resizer = new ResizerWidget(m_window);
 
@@ -105,20 +104,20 @@ Menu::Menu(XfceRc* settings) :
 	m_search_entry = GTK_ENTRY(gtk_entry_new());
 	gtk_entry_set_icon_from_stock(m_search_entry, GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_FIND);
 	gtk_entry_set_icon_activatable(m_search_entry, GTK_ENTRY_ICON_SECONDARY, false);
-	g_signal_connect_slot(m_search_entry, "changed", &Menu::search, this);
+	g_signal_connect_swapped(m_search_entry, "changed", SLOT_CALLBACK(Menu::search), this);
 
 	// Create favorites
 	m_favorites = new FavoritesPage(settings, this);
 
 	m_favorites_button = new_section_button("user-bookmarks", _("Favorites"));
-	g_signal_connect_slot(m_favorites_button, "toggled", &Menu::favorites_toggled, this);
+	g_signal_connect_swapped(m_favorites_button, "toggled", SLOT_CALLBACK(Menu::favorites_toggled), this);
 
 	// Create recent
 	m_recent = new RecentPage(settings, this);
 
 	m_recent_button = new_section_button("document-open-recent", _("Recently Used"));
 	gtk_radio_button_set_group(m_recent_button, gtk_radio_button_get_group(m_favorites_button));
-	g_signal_connect_slot(m_recent_button, "toggled", &Menu::recent_toggled, this);
+	g_signal_connect_swapped(m_recent_button, "toggled", SLOT_CALLBACK(Menu::recent_toggled), this);
 
 	// Create applications
 	m_applications = new ApplicationsPage(this);
@@ -390,7 +389,7 @@ void Menu::set_categories(std::vector<GtkRadioButton*> categories)
 	{
 		gtk_radio_button_set_group(i, gtk_radio_button_get_group(m_recent_button));
 		gtk_box_pack_start(m_sidebar_box, GTK_WIDGET(i), false, false, 0);
-		g_signal_connect_slot(i, "toggled", &Menu::category_toggled, this);
+		g_signal_connect_swapped(i, "toggled", SLOT_CALLBACK(Menu::category_toggled), this);
 	}
 	gtk_widget_show_all(GTK_WIDGET(m_sidebar_box));
 
@@ -407,7 +406,7 @@ void Menu::set_items(std::unordered_map<std::string, Launcher*> items)
 
 	// Handle switching to favorites are added
 	GtkTreeModel* favorites_model = m_favorites->get_view()->get_model();
-	g_signal_connect_slot(favorites_model, "row-inserted", &Menu::show_favorites, this);
+	g_signal_connect_swapped(favorites_model, "row-inserted", SLOT_CALLBACK(Menu::show_favorites), this);
 }
 
 //-----------------------------------------------------------------------------
diff --git a/src/menu.hpp b/src/menu.hpp
index 5a13f8b..6fc00ad 100644
--- a/src/menu.hpp
+++ b/src/menu.hpp
@@ -17,6 +17,8 @@
 #ifndef WHISKERMENU_MENU_HPP
 #define WHISKERMENU_MENU_HPP
 
+#include "slot.hpp"
+
 #include <string>
 #include <unordered_map>
 #include <vector>
@@ -76,20 +78,20 @@ public:
 	void unset_items();
 
 private:
-	gboolean on_enter_notify_event(GtkWidget*, GdkEventCrossing* event);
-	gboolean on_leave_notify_event(GtkWidget*, GdkEventCrossing* event);
-	gboolean on_button_press_event(GtkWidget*, GdkEventButton* event);
-	gboolean on_key_press_event(GtkWidget* widget, GdkEventKey* event);
-	gboolean on_map_event(GtkWidget* widget, GdkEventAny* event);
-	gboolean on_configure_event(GtkWidget* widget, GdkEventConfigure* event);
-	void favorites_toggled();
-	void recent_toggled();
-	void category_toggled();
-	void show_favorites();
-	void search();
-	void launch_settings_manager();
-	void lock_screen();
-	void log_out();
+	SLOT_2(gboolean, Menu, on_enter_notify_event, GtkWidget*, GdkEventCrossing*);
+	SLOT_2(gboolean, Menu, on_leave_notify_event, GtkWidget*, GdkEventCrossing*);
+	SLOT_2(gboolean, Menu, on_button_press_event, GtkWidget*, GdkEventButton*);
+	SLOT_2(gboolean, Menu, on_key_press_event, GtkWidget*, GdkEventKey*);
+	SLOT_2(gboolean, Menu, on_map_event, GtkWidget*, GdkEventAny*);
+	SLOT_2(gboolean, Menu, on_configure_event, GtkWidget*, GdkEventConfigure*);
+	SLOT_0(void, Menu, favorites_toggled);
+	SLOT_0(void, Menu, recent_toggled);
+	SLOT_0(void, Menu, category_toggled);
+	SLOT_0(void, Menu, show_favorites);
+	SLOT_0(void, Menu, search);
+	SLOT_0(void, Menu, launch_settings_manager);
+	SLOT_0(void, Menu, lock_screen);
+	SLOT_0(void, Menu, log_out);
 
 private:
 	GtkWindow* m_window;
diff --git a/src/page.cpp b/src/page.cpp
index 2d76ab0..a3a093e 100644
--- a/src/page.cpp
+++ b/src/page.cpp
@@ -22,7 +22,6 @@
 #include "launcher_view.hpp"
 #include "menu.hpp"
 #include "recent_page.hpp"
-#include "slot.hpp"
 
 extern "C"
 {
@@ -39,9 +38,9 @@ Page::Page(Menu* menu) :
 {
 	// Create view
 	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(m_view->get_widget(), "button-press-event", SLOT_CALLBACK(Page::view_button_press_event), this);
+	g_signal_connect(m_view->get_widget(), "popup-menu", SLOT_CALLBACK(Page::view_popup_menu_event), this);
+	g_signal_connect(m_view->get_widget(), "row-activated", SLOT_CALLBACK(Page::launcher_activated), this);
 	g_signal_connect_swapped(m_view->get_widget(), "start-interactive-search", G_CALLBACK(gtk_widget_grab_focus), m_menu->get_search_entry());
 
 	// Add scrolling to view
@@ -49,7 +48,7 @@ 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_slot(m_widget, "unmap", &Page::on_unmap, this);
+	g_signal_connect_swapped(m_widget, "unmap", SLOT_CALLBACK(Page::on_unmap), this);
 	g_object_ref_sink(m_widget);
 }
 
@@ -160,7 +159,7 @@ void Page::create_context_menu(GtkTreeIter* iter, GdkEventButton* event)
 
 	// Create context menu
 	GtkWidget* menu = gtk_menu_new();
-	g_signal_connect_slot(menu, "selection-done", &Page::destroy_context_menu, this);
+	g_signal_connect(menu, "selection-done", SLOT_CALLBACK(Page::destroy_context_menu), this);
 
 	// Add menu items
 	GtkWidget* menuitem = nullptr;
@@ -168,22 +167,22 @@ void Page::create_context_menu(GtkTreeIter* iter, GdkEventButton* event)
 	if (!m_menu->get_favorites()->contains(get_selected_launcher()))
 	{
 		menuitem = gtk_menu_item_new_with_label(_("Add to Favorites"));
-		g_signal_connect_slot(menuitem, "activate", &Page::add_selected_to_favorites, this);
+		g_signal_connect_swapped(menuitem, "activate", SLOT_CALLBACK(Page::add_selected_to_favorites), this);
 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 	}
 	else
 	{
 		menuitem = gtk_menu_item_new_with_label(_("Remove From Favorites"));
-		g_signal_connect_slot(menuitem, "activate", &Page::remove_selected_from_favorites, this);
+		g_signal_connect_swapped(menuitem, "activate", SLOT_CALLBACK(Page::remove_selected_from_favorites), this);
 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 	}
 
 	menuitem = gtk_menu_item_new_with_label(_("Add to Desktop"));
-	g_signal_connect_slot(menuitem, "activate", &Page::add_selected_to_desktop, this);
+	g_signal_connect_swapped(menuitem, "activate", SLOT_CALLBACK(Page::add_selected_to_desktop), this);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 
 	menuitem = gtk_menu_item_new_with_label(_("Add to Panel"));
-	g_signal_connect_slot(menuitem, "activate", &Page::add_selected_to_panel, this);
+	g_signal_connect_swapped(menuitem, "activate", SLOT_CALLBACK(Page::add_selected_to_panel), this);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 
 	gtk_widget_show_all(menu);
diff --git a/src/page.hpp b/src/page.hpp
index d29d2b3..17d2561 100644
--- a/src/page.hpp
+++ b/src/page.hpp
@@ -17,6 +17,8 @@
 #ifndef WHISKERMENU_PAGE_HPP
 #define WHISKERMENU_PAGE_HPP
 
+#include "slot.hpp"
+
 extern "C"
 {
 #include <gtk/gtk.h>
@@ -53,19 +55,20 @@ protected:
 	}
 
 private:
-	Launcher* get_selected_launcher() const;
+	SLOT_3(void, Page, launcher_activated, GtkTreeView*, GtkTreePath*, GtkTreeViewColumn*);
+	SLOT_2(gboolean, Page, view_button_press_event, GtkWidget*, GdkEventButton*);
+	SLOT_1(gboolean, Page, view_popup_menu_event, GtkWidget*);
+	SLOT_0(void, Page, on_unmap);
+	SLOT_1(void, Page, destroy_context_menu, GtkMenuShell*);
+	SLOT_0(void, Page, add_selected_to_desktop);
+	SLOT_0(void, Page, add_selected_to_panel);
+	SLOT_0(void, Page, add_selected_to_favorites);
+	SLOT_0(void, Page, remove_selected_from_favorites);
 
-	void launcher_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();
+private:
+	Launcher* get_selected_launcher() const;
 	void create_context_menu(GtkTreeIter* iter, GdkEventButton* event);
-	void destroy_context_menu(GtkMenuShell* menu);
 	static void position_context_menu(GtkMenu*, gint* x, gint* y, gboolean* push_in, Page* page);
-	void add_selected_to_desktop();
-	void add_selected_to_panel();
-	void add_selected_to_favorites();
-	void remove_selected_from_favorites();
 
 private:
 	Menu* m_menu;
diff --git a/src/panel_plugin.cpp b/src/panel_plugin.cpp
index b90f720..885cf7e 100644
--- a/src/panel_plugin.cpp
+++ b/src/panel_plugin.cpp
@@ -20,7 +20,6 @@
 #include "configuration_dialog.hpp"
 #include "launcher.hpp"
 #include "menu.hpp"
-#include "slot.hpp"
 
 using namespace WhiskerMenu;
 
@@ -63,8 +62,8 @@ PanelPlugin::PanelPlugin(XfcePanelPlugin* plugin) :
 	{
 		m_menu = new Menu(nullptr);
 	}
-	g_signal_connect_slot(m_menu->get_widget(), "map", &PanelPlugin::menu_shown, this);
-	g_signal_connect_slot(m_menu->get_widget(), "unmap", &PanelPlugin::menu_hidden, this);
+	g_signal_connect_swapped(m_menu->get_widget(), "map", SLOT_CALLBACK(PanelPlugin::menu_shown), this);
+	g_signal_connect_swapped(m_menu->get_widget(), "unmap", SLOT_CALLBACK(PanelPlugin::menu_hidden), this);
 
 	// Create toggle button
 	m_button = xfce_create_panel_toggle_button();
@@ -73,7 +72,7 @@ PanelPlugin::PanelPlugin(XfcePanelPlugin* plugin) :
 	xfce_panel_image_set_size(m_button_icon, -1);
 	gtk_container_add(GTK_CONTAINER(m_button), GTK_WIDGET(m_button_icon));
 	gtk_widget_show_all(m_button);
-	g_signal_connect_slot(m_button, "button-press-event", &PanelPlugin::button_clicked, this);
+	g_signal_connect(m_button, "button-press-event", SLOT_CALLBACK(PanelPlugin::button_clicked), this);
 
 	// Add plugin to panel
 	gtk_container_add(GTK_CONTAINER(plugin), m_button);
@@ -81,9 +80,9 @@ PanelPlugin::PanelPlugin(XfcePanelPlugin* plugin) :
 
 	// Connect plugin signals to functions
 	g_signal_connect(plugin, "free-data", G_CALLBACK(whiskermenu_free), this);
-	g_signal_connect_slot(plugin, "configure-plugin", &PanelPlugin::configure, this);
-	g_signal_connect_slot(plugin, "save", &PanelPlugin::save, this);
-	g_signal_connect_slot(plugin, "size-changed", &PanelPlugin::size_changed, this);
+	g_signal_connect_swapped(plugin, "configure-plugin", SLOT_CALLBACK(PanelPlugin::configure), this);
+	g_signal_connect_swapped(plugin, "save", SLOT_CALLBACK(PanelPlugin::save), this);
+	g_signal_connect(plugin, "size-changed", SLOT_CALLBACK(PanelPlugin::size_changed), this);
 	xfce_panel_plugin_menu_show_configure(plugin);
 }
 
diff --git a/src/panel_plugin.hpp b/src/panel_plugin.hpp
index 1ab78ad..4ba3efb 100644
--- a/src/panel_plugin.hpp
+++ b/src/panel_plugin.hpp
@@ -17,6 +17,8 @@
 #ifndef WHISKERMENU_PANEL_PLUGIN_HPP
 #define WHISKERMENU_PANEL_PLUGIN_HPP
 
+#include "slot.hpp"
+
 #include <string>
 
 extern "C"
@@ -51,12 +53,12 @@ public:
 	void set_configure_enabled(bool enabled);
 
 private:
-	gboolean button_clicked(GtkWidget*, GdkEventButton* event);
-	void menu_hidden();
-	void menu_shown();
-	void configure();
-	void save();
-	gboolean size_changed(XfcePanelPlugin*, gint size);
+	SLOT_2(gboolean, PanelPlugin, button_clicked, GtkWidget*, GdkEventButton*);
+	SLOT_0(void, PanelPlugin, menu_hidden);
+	SLOT_0(void, PanelPlugin, menu_shown);
+	SLOT_0(void, PanelPlugin, configure);
+	SLOT_0(void, PanelPlugin, save);
+	SLOT_2(gboolean, PanelPlugin, size_changed, XfcePanelPlugin*, gint);
 
 private:
 	XfcePanelPlugin* m_plugin;
diff --git a/src/resizer_widget.cpp b/src/resizer_widget.cpp
index 6f06355..2370f5b 100644
--- a/src/resizer_widget.cpp
+++ b/src/resizer_widget.cpp
@@ -16,8 +16,6 @@
 
 #include "resizer_widget.hpp"
 
-#include "slot.hpp"
-
 using namespace WhiskerMenu;
 
 //-----------------------------------------------------------------------------
@@ -33,10 +31,10 @@ ResizerWidget::ResizerWidget(GtkWindow* window) :
 	gtk_widget_add_events(m_drawing, GDK_BUTTON_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
 	gtk_container_add(GTK_CONTAINER(m_alignment), m_drawing);
 
-	g_signal_connect_slot(m_drawing, "button-press-event", &ResizerWidget::on_button_press_event, this);
-	g_signal_connect_slot(m_drawing, "enter-notify-event", &ResizerWidget::on_enter_notify_event, this);
-	g_signal_connect_slot(m_drawing, "leave-notify-event", &ResizerWidget::on_leave_notify_event, this);
-	g_signal_connect_slot(m_drawing, "expose-event", &ResizerWidget::on_expose_event, this);
+	g_signal_connect(m_drawing, "button-press-event", SLOT_CALLBACK(ResizerWidget::on_button_press_event), this);
+	g_signal_connect(m_drawing, "enter-notify-event", SLOT_CALLBACK(ResizerWidget::on_enter_notify_event), this);
+	g_signal_connect(m_drawing, "leave-notify-event", SLOT_CALLBACK(ResizerWidget::on_leave_notify_event), this);
+	g_signal_connect(m_drawing, "expose-event", SLOT_CALLBACK(ResizerWidget::on_expose_event), this);
 
 	set_corner(TopRight);
 }
diff --git a/src/resizer_widget.hpp b/src/resizer_widget.hpp
index 2f7a26f..730f458 100644
--- a/src/resizer_widget.hpp
+++ b/src/resizer_widget.hpp
@@ -17,6 +17,8 @@
 #ifndef WHISKERMENU_RESIZER_WIDGET_HPP
 #define WHISKERMENU_RESIZER_WIDGET_HPP
 
+#include "slot.hpp"
+
 #include <vector>
 
 extern "C"
@@ -48,10 +50,10 @@ public:
 	void set_corner(Corner corner);
 
 private:
-	gboolean on_button_press_event(GtkWidget* widget, GdkEventButton* event);
-	gboolean on_enter_notify_event(GtkWidget* widget, GdkEventCrossing* event);
-	gboolean on_leave_notify_event(GtkWidget* widget, GdkEventCrossing* event);
-	gboolean on_expose_event(GtkWidget* widget, GdkEventExpose* event);
+	SLOT_2(gboolean, ResizerWidget, on_button_press_event, GtkWidget*, GdkEventButton*);
+	SLOT_2(gboolean, ResizerWidget, on_enter_notify_event, GtkWidget*, GdkEventCrossing*);
+	SLOT_2(gboolean, ResizerWidget, on_leave_notify_event, GtkWidget*, GdkEventCrossing*);
+	SLOT_2(gboolean, ResizerWidget, on_expose_event, GtkWidget*, GdkEventExpose*);
 
 private:
 	GtkWindow* m_window;
diff --git a/src/search_page.cpp b/src/search_page.cpp
index c00f7b9..5d26e6d 100644
--- a/src/search_page.cpp
+++ b/src/search_page.cpp
@@ -20,7 +20,6 @@
 #include "launcher_model.hpp"
 #include "launcher_view.hpp"
 #include "menu.hpp"
-#include "slot.hpp"
 
 extern "C"
 {
@@ -37,8 +36,8 @@ SearchPage::SearchPage(Menu* menu) :
 {
 	get_view()->set_selection_mode(GTK_SELECTION_BROWSE);
 
-	g_signal_connect_slot(menu->get_search_entry(), "icon-release", &SearchPage::clear_search, this);
-	g_signal_connect_slot(menu->get_search_entry(), "key-press-event", &SearchPage::search_entry_key_press, this);
+	g_signal_connect(menu->get_search_entry(), "icon-release", SLOT_CALLBACK(SearchPage::clear_search), this);
+	g_signal_connect(menu->get_search_entry(), "key-press-event", SLOT_CALLBACK(SearchPage::search_entry_key_press), this);
 }
 
 //-----------------------------------------------------------------------------
diff --git a/src/search_page.hpp b/src/search_page.hpp
index 4500321..c654977 100644
--- a/src/search_page.hpp
+++ b/src/search_page.hpp
@@ -18,6 +18,7 @@
 #define WHISKERMENU_SEARCH_PAGE_HPP
 
 #include "filter_page.hpp"
+#include "slot.hpp"
 
 #include <string>
 
@@ -37,9 +38,11 @@ public:
 	void unset_menu_items();
 
 private:
+	SLOT_3(void, SearchPage, clear_search, GtkEntry*, GtkEntryIconPosition, GdkEvent*);
+	SLOT_2(gboolean, SearchPage, search_entry_key_press, GtkWidget*, GdkEventKey*);
+
+private:
 	bool on_filter(GtkTreeModel* model, GtkTreeIter* iter);
-	void clear_search(GtkEntry* entry, GtkEntryIconPosition icon_pos, GdkEvent*);
-	gboolean search_entry_key_press(GtkWidget* widget, GdkEventKey* event);
 
 private:
 	std::string m_filter_string;
diff --git a/src/slot.hpp b/src/slot.hpp
index 25e8cf0..4ce34fc 100644
--- a/src/slot.hpp
+++ b/src/slot.hpp
@@ -22,77 +22,36 @@ extern "C"
 #include <glib-object.h>
 }
 
-namespace WhiskerMenu
-{
-
-// Member functions without parameters
-template <typename T, typename R>
-struct Slot0
-{
-	T* instance;
-	R (T::*member)();
-};
-
-template <typename T, typename R>
-R invoke_slot0(Slot0<T,R>* slot)
-{
-	return (slot->instance->*slot->member)();
-}
-
-template <typename T, typename R>
-void delete_slot0(Slot0<T,R>* slot)
-{
-	delete slot;
-	slot = nullptr;
-}
-
-template<typename T, typename R>
-gulong g_signal_connect_slot(gpointer signal_obj, const gchar* detailed_signal, R (T::*member)(), T* instance)
-{
-	return g_signal_connect_closure(signal_obj, detailed_signal,
-		g_cclosure_new_swap
-		(
-			(GCallback)&invoke_slot0<T,R>,
-			new Slot0<T,R>{instance, member},
-			(GClosureNotify)&delete_slot0<T,R>
-		),
-		false);
-}
-
-// Member functions with parameters
-template <typename T, typename R, typename... Args>
-struct SlotArgs
-{
-	T* instance;
-	R (T::*member)(Args...);
-};
-
-template <typename T, typename R, typename... Args>
-R invoke_slot_args(Args... args, SlotArgs<T,R,Args...>* slot)
-{
-	return (slot->instance->*slot->member)(args...);
-}
-
-template <typename T, typename R, typename... Args>
-void delete_slot_args(SlotArgs<T,R,Args...>* slot)
-{
-	delete slot;
-	slot = nullptr;
-}
-
-template<typename T, typename R, typename... Args>
-gulong g_signal_connect_slot(gpointer signal_obj, const gchar* detailed_signal, R (T::*member)(Args...), T* instance)
-{
-	return g_signal_connect_closure(signal_obj, detailed_signal,
-		g_cclosure_new
-		(
-			(GCallback)&invoke_slot_args<T,R,Args...>,
-			new SlotArgs<T,R,Args...>{instance, member},
-			(GClosureNotify)&delete_slot_args<T,R,Args...>
-		),
-		false);
-}
-
-}
+#define SLOT_CALLBACK(klassmember) G_CALLBACK(klassmember ## _slot)
+
+#define SLOT_0(R, klass, member) \
+	static R member ## _slot(klass* obj) \
+		{ return obj->member(); } \
+	R member()
+
+#define SLOT_1(R, klass, member, T1) \
+	static R member ## _slot(T1 arg1, klass* obj) \
+		{ return obj->member(arg1); } \
+	R member(T1)
+
+#define SLOT_2(R, klass, member, T1, T2) \
+	static R member ## _slot(T1 arg1, T2 arg2, klass* obj) \
+		{ return obj->member(arg1, arg2); } \
+	R member(T1, T2)
+
+#define SLOT_3(R, klass, member, T1, T2, T3) \
+	static R member ## _slot(T1 arg1, T2 arg2, T3 arg3, klass* obj) \
+		{ return obj->member(arg1, arg2, arg3); } \
+	R member(T1, T2, T3)
+
+#define SLOT_4(R, klass, member, T1, T2, T3, T4) \
+	static R member ## _slot(T1 arg1, T2 arg2, T3 arg3, T4 arg4, klass* obj) \
+		{ return obj->member(arg1, arg2, arg3, arg4); } \
+	R member(T1, T2, T3, T4)
+
+#define SLOT_5(R, klass, member, T1, T2, T3, T4, T5) \
+	static R member ## _slot(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, klass* obj) \
+		{ return obj->member(arg1, arg2, arg3, arg4, arg5); } \
+	R member(T1, T2, T3, T4, T5)
 
 #endif // WHISKERMENU_SLOT_HPP

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


More information about the Xfce4-commits mailing list