[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 78/473: Fix panel button size issues.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:54:08 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 0818c4a57cf24d840a9f40433487e6a2ea4e18a0
Author: Graeme Gott <graeme at gottcode.org>
Date:   Wed Jul 10 07:05:32 2013 -0400

    Fix panel button size issues.
---
 src/configuration_dialog.cpp |    3 ++-
 src/panel_plugin.cpp         |   40 ++++++++++++++++++++++++++++++++++++----
 2 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/src/configuration_dialog.cpp b/src/configuration_dialog.cpp
index a7a61ef..5bfa6f4 100644
--- a/src/configuration_dialog.cpp
+++ b/src/configuration_dialog.cpp
@@ -173,7 +173,8 @@ void ConfigurationDialog::choose_icon()
 
 void ConfigurationDialog::title_changed(GtkEditable*)
 {
-	m_plugin->set_button_title(gtk_entry_get_text(GTK_ENTRY(m_title)));
+	const gchar* text = gtk_entry_get_text(GTK_ENTRY(m_title));
+	m_plugin->set_button_title(text ? text : "");
 }
 
 //-----------------------------------------------------------------------------
diff --git a/src/panel_plugin.cpp b/src/panel_plugin.cpp
index 8cf8855..4194a66 100644
--- a/src/panel_plugin.cpp
+++ b/src/panel_plugin.cpp
@@ -135,6 +135,7 @@ void PanelPlugin::set_button_title(const std::string& title)
 {
 	m_button_title = title;
 	gtk_label_set_label(m_button_label, m_button_title.c_str());
+	size_changed(m_plugin, xfce_panel_plugin_get_size(m_plugin));
 }
 
 //-----------------------------------------------------------------------------
@@ -150,6 +151,7 @@ void PanelPlugin::set_button_title_visible(bool visible)
 	{
 		gtk_widget_hide(GTK_WIDGET(m_button_label));
 	}
+	size_changed(m_plugin, xfce_panel_plugin_get_size(m_plugin));
 }
 
 //-----------------------------------------------------------------------------
@@ -158,6 +160,7 @@ void PanelPlugin::set_button_icon_name(const std::string& icon)
 {
 	m_button_icon_name = icon;
 	xfce_panel_image_set_from_source(m_button_icon, icon.c_str());
+	size_changed(m_plugin, xfce_panel_plugin_get_size(m_plugin));
 }
 
 //-----------------------------------------------------------------------------
@@ -273,14 +276,43 @@ gboolean PanelPlugin::size_changed(XfcePanelPlugin*, gint size)
 
 	GtkOrientation orientation = xfce_panel_plugin_get_orientation(m_plugin);
 
-	xfce_panel_image_set_size(m_button_icon, -1);
-	if (orientation == GTK_ORIENTATION_HORIZONTAL)
+	// Make icon expand to fill button if title is not visible
+	gtk_box_set_child_packing(GTK_BOX(m_button_box), GTK_WIDGET(m_button_icon),
+			!m_button_title_visible,
+			!m_button_title_visible,
+			0, GTK_PACK_START);
+
+	if (!m_button_title_visible)
 	{
-		gtk_widget_set_size_request(GTK_WIDGET(m_button_icon), row_size, size);
+		xfce_panel_image_set_size(m_button_icon, -1);
+		if (orientation == GTK_ORIENTATION_HORIZONTAL)
+		{
+			gtk_widget_set_size_request(GTK_WIDGET(m_plugin), row_size, size);
+		}
+		else
+		{
+			gtk_widget_set_size_request(GTK_WIDGET(m_plugin), size, row_size);
+		}
 	}
 	else
 	{
-		gtk_widget_set_size_request(GTK_WIDGET(m_button_icon), size, row_size);
+		GtkStyle* style = gtk_widget_get_style(m_button);
+		gint border = (2 * std::max(style->xthickness, style->ythickness)) + 2;
+		xfce_panel_image_set_size(m_button_icon, row_size - border);
+		gtk_widget_set_size_request(GTK_WIDGET(m_plugin), -1, -1);
+
+#if (LIBXFCE4PANEL_CHECK_VERSION(4,10,0))
+		// Put title next to icon if panel is wide enough
+		if (xfce_panel_plugin_get_mode(m_plugin) == XFCE_PANEL_PLUGIN_MODE_DESKBAR)
+		{
+			GtkRequisition label_size;
+			gtk_widget_size_request(GTK_WIDGET(m_button_label), &label_size);
+			if (label_size.width <= (size - row_size))
+			{
+				orientation = GTK_ORIENTATION_HORIZONTAL;
+			}
+		}
+#endif
 	}
 
 	gtk_orientable_set_orientation(GTK_ORIENTABLE(m_button_box), orientation);

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


More information about the Xfce4-commits mailing list