[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 03/05: Make interface for SectionButton more clear.

noreply at xfce.org noreply at xfce.org
Sat Jan 18 15:11:11 CET 2020


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

g   o   t   t   c   o   d   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 1d308c4614f95e6dd73998b196d82793947b1288
Author: Graeme Gott <graeme at gottcode.org>
Date:   Thu Jan 16 15:28:42 2020 -0500

    Make interface for SectionButton more clear.
---
 panel-plugin/applications-page.cpp |  6 +++---
 panel-plugin/section-button.h      | 15 +++++----------
 panel-plugin/window.cpp            | 24 +++++++++++++-----------
 3 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/panel-plugin/applications-page.cpp b/panel-plugin/applications-page.cpp
index 3648d02..1dca32c 100644
--- a/panel-plugin/applications-page.cpp
+++ b/panel-plugin/applications-page.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2015, 2016, 2017, 2018 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015, 2016, 2017, 2018, 2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -136,7 +136,7 @@ void ApplicationsPage::apply_filter(GtkToggleButton* togglebutton)
 	Category* category = NULL;
 	for (std::vector<Category*>::const_iterator i = m_categories.begin(), end = m_categories.end(); i != end; ++i)
 	{
-		if (GTK_TOGGLE_BUTTON((*i)->get_button()->get_button()) == togglebutton)
+		if (GTK_TOGGLE_BUTTON((*i)->get_button()->get_widget()) == togglebutton)
 		{
 			category = *i;
 			break;
@@ -328,7 +328,7 @@ void ApplicationsPage::load_contents()
 	for (std::vector<Category*>::const_iterator i = m_categories.begin(), end = m_categories.end(); i != end; ++i)
 	{
 		SectionButton* category_button = (*i)->get_button();
-		g_signal_connect_slot(category_button->get_button(), "toggled", &ApplicationsPage::apply_filter, this);
+		g_signal_connect_slot(category_button->get_widget(), "toggled", &ApplicationsPage::apply_filter, this);
 		category_buttons.push_back(category_button);
 	}
 
diff --git a/panel-plugin/section-button.h b/panel-plugin/section-button.h
index 8b48b20..5faccb9 100644
--- a/panel-plugin/section-button.h
+++ b/panel-plugin/section-button.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2016, 2017 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2016, 2017, 2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -29,9 +29,9 @@ public:
 	SectionButton(GIcon* icon, const gchar* text);
 	~SectionButton();
 
-	GtkRadioButton* get_button() const
+	GtkWidget* get_widget() const
 	{
-		return m_button;
+		return GTK_WIDGET(m_button);
 	}
 
 	bool get_active() const
@@ -44,14 +44,9 @@ public:
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_button), active);
 	}
 
-	GSList* get_group() const
+	void join_group(SectionButton* button)
 	{
-		return gtk_radio_button_get_group(m_button);
-	}
-
-	void set_group(GSList* group)
-	{
-		gtk_radio_button_set_group(m_button, group);
+		gtk_radio_button_join_group(m_button, button->m_button);
 	}
 
 	void reload_icon_size();
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index a38344d..5379bd2 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -158,7 +158,7 @@ WhiskerMenu::Window::Window(Plugin* plugin) :
 	GIcon* icon = g_themed_icon_new("user-bookmarks");
 	m_favorites_button = new SectionButton(icon, _("Favorites"));
 	g_object_unref(icon);
-	g_signal_connect_slot<GtkToggleButton*>(m_favorites_button->get_button(), "toggled", &Window::favorites_toggled, this);
+	g_signal_connect_slot<GtkToggleButton*>(m_favorites_button->get_widget(), "toggled", &Window::favorites_toggled, this);
 
 	// Create recent
 	m_recent = new RecentPage(this);
@@ -166,8 +166,8 @@ WhiskerMenu::Window::Window(Plugin* plugin) :
 	icon = g_themed_icon_new("document-open-recent");
 	m_recent_button = new SectionButton(icon, _("Recently Used"));
 	g_object_unref(icon);
-	m_recent_button->set_group(m_favorites_button->get_group());
-	g_signal_connect_slot<GtkToggleButton*>(m_recent_button->get_button(), "toggled", &Window::recent_toggled, this);
+	m_recent_button->join_group(m_favorites_button);
+	g_signal_connect_slot<GtkToggleButton*>(m_recent_button->get_widget(), "toggled", &Window::recent_toggled, this);
 
 	// Create applications
 	m_applications = new ApplicationsPage(this);
@@ -230,8 +230,8 @@ WhiskerMenu::Window::Window(Plugin* plugin) :
 
 	// Create box for packing sidebar
 	m_sidebar_buttons = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
-	gtk_box_pack_start(m_sidebar_buttons, GTK_WIDGET(m_favorites_button->get_button()), false, false, 0);
-	gtk_box_pack_start(m_sidebar_buttons, GTK_WIDGET(m_recent_button->get_button()), false, false, 0);
+	gtk_box_pack_start(m_sidebar_buttons, m_favorites_button->get_widget(), false, false, 0);
+	gtk_box_pack_start(m_sidebar_buttons, m_recent_button->get_widget(), false, false, 0);
 	gtk_box_pack_start(m_sidebar_buttons, gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), false, false, 4);
 
 	m_sidebar = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL));
@@ -659,7 +659,7 @@ void WhiskerMenu::Window::show(const Position position)
 	}
 
 	// Make sure recent button is only visible when tracked
-	gtk_widget_set_visible(GTK_WIDGET(m_recent_button->get_button()), wm_settings->recent_items_max);
+	gtk_widget_set_visible(m_recent_button->get_widget(), wm_settings->recent_items_max);
 
 	// Show window
 	gtk_widget_show(GTK_WIDGET(m_window));
@@ -693,17 +693,19 @@ void WhiskerMenu::Window::on_context_menu_destroyed()
 
 void WhiskerMenu::Window::set_categories(const std::vector<SectionButton*>& categories)
 {
+	SectionButton* button = m_recent_button;
 	for (std::vector<SectionButton*>::const_iterator i = categories.begin(), end = categories.end(); i != end; ++i)
 	{
-		(*i)->set_group(m_recent_button->get_group());
-		gtk_box_pack_start(m_sidebar_buttons, GTK_WIDGET((*i)->get_button()), false, false, 0);
-		g_signal_connect_slot<GtkToggleButton*>((*i)->get_button(), "toggled", &Window::category_toggled, this);
+		(*i)->join_group(button);
+		button = *i;
+		gtk_box_pack_start(m_sidebar_buttons, button->get_widget(), false, false, 0);
+		g_signal_connect_slot<GtkToggleButton*>(button->get_widget(), "toggled", &Window::category_toggled, this);
 	}
 
 	// Position "All Applications" above divider
 	if (!categories.empty())
 	{
-		gtk_box_reorder_child(m_sidebar_buttons, GTK_WIDGET(categories[0]->get_button()), 2);
+		gtk_box_reorder_child(m_sidebar_buttons, categories.front()->get_widget(), 2);
 	}
 
 	show_default_page();
@@ -847,7 +849,7 @@ gboolean WhiskerMenu::Window::on_key_press_event(GtkWidget* widget, GdkEvent* ev
 	{
 		if (GTK_IS_TREE_VIEW(view) && ((widget == view) || (gtk_window_get_focus(m_window) == view)))
 		{
-			gtk_widget_grab_focus(GTK_WIDGET(m_favorites_button->get_button()));
+			gtk_widget_grab_focus(m_favorites_button->get_widget());
 			page->reset_selection();
 		}
 	}

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


More information about the Xfce4-commits mailing list