[Xfce4-commits] <xfce4-dict:master> Adapting the plugin to panel version 4.9+

Enrico Tröger noreply at xfce.org
Sat Mar 3 17:08:01 CET 2012


Updating branch refs/heads/master
         to 336b0b9a3001bf75803a042b080f3eb845bfff5a (commit)
       from 133ce7045b9ec45421a397fe9ac17eb3e288d21d (commit)

commit 336b0b9a3001bf75803a042b080f3eb845bfff5a
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Fri Feb 24 15:33:33 2012 +0900

    Adapting the plugin to panel version 4.9+
    
    Signed-off-by: Enrico Tröger <enrico.troeger at uvena.de>

 panel-plugin/xfce4-dict-plugin.c |   83 +++++++++++++++++++++++--------------
 1 files changed, 51 insertions(+), 32 deletions(-)

diff --git a/panel-plugin/xfce4-dict-plugin.c b/panel-plugin/xfce4-dict-plugin.c
index 332f6ca..c52a449 100644
--- a/panel-plugin/xfce4-dict-plugin.c
+++ b/panel-plugin/xfce4-dict-plugin.c
@@ -51,6 +51,7 @@ typedef struct
 
 	GtkWidget *panel_button;
 	GtkWidget *panel_button_image;
+	GtkWidget *box;
 } DictPanelData;
 
 
@@ -81,28 +82,49 @@ static GdkPixbuf *dict_plugin_load_and_scale(const guint8 *data, gint dstw, gint
 
 static gboolean dict_plugin_panel_set_size(XfcePanelPlugin *plugin, gint wsize, DictPanelData *dpd)
 {
-	gint width;
-	gint height = wsize;
-	gint size = wsize - 2 - (2 * MAX(dpd->panel_button->style->xthickness,
+	gint size;
+	gint bsize = wsize;
+
+#if defined (LIBXFCE4PANEL_CHECK_VERSION) && LIBXFCE4PANEL_CHECK_VERSION (4,9,0)
+	bsize /= xfce_panel_plugin_get_nrows(plugin);
+#endif
+
+	size = bsize - 2 - (2 * MAX(dpd->panel_button->style->xthickness,
 									 dpd->panel_button->style->ythickness));
 
 	dpd->dd->icon = dict_plugin_load_and_scale(dict_gui_get_icon_data(), size, -1);
 
 	gtk_image_set_from_pixbuf(GTK_IMAGE(dpd->panel_button_image), dpd->dd->icon);
 
+#if defined (LIBXFCE4PANEL_CHECK_VERSION) && LIBXFCE4PANEL_CHECK_VERSION (4,9,0)
+	if (dpd->dd->show_panel_entry &&
+		xfce_panel_plugin_get_mode(dpd->plugin) != XFCE_PANEL_PLUGIN_MODE_VERTICAL)
+	{
+		xfce_panel_plugin_set_small (plugin, FALSE);
+		if (xfce_panel_plugin_get_mode(dpd->plugin) == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL)
+			gtk_widget_set_size_request(dpd->dd->panel_entry, dpd->dd->panel_entry_size, -1);
+		else
+			gtk_widget_set_size_request(dpd->dd->panel_entry, -1, -1);
+		gtk_orientable_set_orientation(GTK_ORIENTABLE(dpd->box), xfce_panel_plugin_get_orientation(dpd->plugin));
+		gtk_widget_show(dpd->dd->panel_entry);
+	}
+	else
+	{
+		gtk_widget_hide(dpd->dd->panel_entry);
+		xfce_panel_plugin_set_small (plugin, TRUE);
+	}
+#else
 	if (dpd->dd->show_panel_entry &&
 		xfce_panel_plugin_get_orientation(plugin) == GTK_ORIENTATION_HORIZONTAL)
 	{
-		width = size + dpd->dd->panel_entry_size;
+		gtk_widget_show(dpd->dd->panel_entry);
 		gtk_widget_set_size_request(dpd->dd->panel_entry, dpd->dd->panel_entry_size, -1);
 	}
 	else
-		width = size;
-
-	if (xfce_panel_plugin_get_orientation(plugin) == GTK_ORIENTATION_VERTICAL)
-		height -= 4; /* reduce some of the height because it creates too much space otherwise */
+		gtk_widget_hide(dpd->dd->panel_entry);
+#endif
 
-	gtk_widget_set_size_request(dpd->panel_button, wsize, height);
+	gtk_widget_set_size_request(dpd->panel_button, bsize, bsize);
 
 	return TRUE;
 }
@@ -254,14 +276,20 @@ static void dict_plugin_free_data(XfcePanelPlugin *plugin, DictPanelData *dpd)
 }
 
 
+#if defined (LIBXFCE4PANEL_CHECK_VERSION) && LIBXFCE4PANEL_CHECK_VERSION (4,9,0)
+static void dict_plugin_panel_change_mode(XfcePanelPlugin *plugin,
+												 XfcePanelPluginMode mode, DictPanelData *dpd)
+{
+	dict_plugin_panel_set_size(plugin, xfce_panel_plugin_get_size(plugin), dpd);
+}
+
+#else
 static void dict_plugin_panel_change_orientation(XfcePanelPlugin *plugin,
 												 GtkOrientation orientation, DictPanelData *dpd)
 {
-	if (! dpd->dd->show_panel_entry || orientation == GTK_ORIENTATION_VERTICAL)
-		gtk_widget_hide(dpd->dd->panel_entry);
-	else
-		gtk_widget_show(dpd->dd->panel_entry);
+	dict_plugin_panel_set_size(plugin, xfce_panel_plugin_get_size(plugin), dpd);
 }
+#endif
 
 
 static void dict_plugin_style_set(XfcePanelPlugin *plugin, gpointer unused, DictPanelData *dpd)
@@ -278,14 +306,6 @@ static void dict_plugin_write_rc_file(XfcePanelPlugin *plugin, DictPanelData *dp
 
 static void dict_plugin_panel_save_settings(DictPanelData *dpd)
 {
-	if (dpd->dd->show_panel_entry &&
-		xfce_panel_plugin_get_orientation(dpd->plugin) == GTK_ORIENTATION_HORIZONTAL)
-	{
-		gtk_widget_show(dpd->dd->panel_entry);
-	}
-	else
-		gtk_widget_hide(dpd->dd->panel_entry);
-
 	dict_plugin_panel_set_size(dpd->plugin, xfce_panel_plugin_get_size(dpd->plugin), dpd);
 }
 
@@ -395,7 +415,6 @@ static void dict_plugin_drag_data_received(GtkWidget *widget, GdkDragContext *dr
 static void dict_plugin_construct(XfcePanelPlugin *plugin)
 {
 	DictPanelData *dpd = g_new0(DictPanelData, 1);
-	GtkWidget *hbox;
 
 	xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
 
@@ -425,7 +444,11 @@ static void dict_plugin_construct(XfcePanelPlugin *plugin)
 	g_signal_connect(dpd->dd->close_button, "clicked", G_CALLBACK(dict_plugin_close_button_clicked), dpd);
 	g_signal_connect(plugin, "free-data", G_CALLBACK(dict_plugin_free_data), dpd);
 	g_signal_connect(plugin, "size-changed", G_CALLBACK(dict_plugin_panel_set_size), dpd);
+#if defined (LIBXFCE4PANEL_CHECK_VERSION) && LIBXFCE4PANEL_CHECK_VERSION (4,9,0)
+	g_signal_connect(plugin, "mode-changed", G_CALLBACK (dict_plugin_panel_change_mode), dpd);
+#else
 	g_signal_connect(plugin, "orientation-changed", G_CALLBACK(dict_plugin_panel_change_orientation), dpd);
+#endif
 	g_signal_connect(plugin, "style-set", G_CALLBACK(dict_plugin_style_set), dpd);
 	g_signal_connect(plugin, "save", G_CALLBACK(dict_plugin_write_rc_file), dpd);
 	g_signal_connect(plugin, "configure-plugin", G_CALLBACK(dict_plugin_properties_dialog), dpd);
@@ -447,18 +470,14 @@ static void dict_plugin_construct(XfcePanelPlugin *plugin)
 	g_signal_connect(dpd->dd->panel_entry, "button-press-event", G_CALLBACK(entry_buttonpress_cb), dpd);
 	g_signal_connect(dpd->dd->panel_entry, "changed", G_CALLBACK(entry_changed_cb), dpd);
 
-	if (dpd->dd->show_panel_entry &&
-		xfce_panel_plugin_get_orientation(dpd->plugin) == GTK_ORIENTATION_HORIZONTAL)
-	{
-		gtk_widget_show(dpd->dd->panel_entry);
-	}
+	dpd->box = gtk_hbox_new(FALSE, 3);
+	gtk_widget_show(dpd->box);
 
-	hbox = gtk_hbox_new(FALSE, 3);
-	gtk_widget_show(hbox);
+	gtk_box_pack_start(GTK_BOX(dpd->box), dpd->panel_button, FALSE, FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(dpd->box), dpd->dd->panel_entry, FALSE, FALSE, 0);
+	gtk_container_add(GTK_CONTAINER(plugin), dpd->box);
 
-	gtk_box_pack_start(GTK_BOX(hbox), dpd->panel_button, FALSE, FALSE, 0);
-	gtk_box_pack_start(GTK_BOX(hbox), dpd->dd->panel_entry, FALSE, FALSE, 0);
-	gtk_container_add(GTK_CONTAINER(plugin), hbox);
+	dict_plugin_panel_set_size(dpd->plugin, xfce_panel_plugin_get_size(dpd->plugin), dpd);
 
 	xfce_panel_plugin_add_action_widget(plugin, dpd->panel_button);
 	dict_plugin_set_selection(dpd);


More information about the Xfce4-commits mailing list