From d8c1dd043186652397e10b527cb4566014a61d8b Mon Sep 17 00:00:00 2001 From: Andrzej Date: Wed, 14 Mar 2012 02:30:20 +0900 Subject: [PATCH 1/2] Compatibility fix for panel 4.9+ Mainly handling button orientation. At the moment, the buttons are still laid out in a single row/column. Created a new class (XfceIndicatorButton) for better control over the button label and icon, and storing other parameters (indicator object, io entry, menu, layout options etc). --- panel-plugin/Makefile.am | 2 + panel-plugin/indicator-button.c | 334 +++++++++++++++++++++++++++++++++++++++ panel-plugin/indicator-button.h | 88 ++++++++++ panel-plugin/indicator.c | 127 +++++++++++++--- 4 files changed, 532 insertions(+), 19 deletions(-) create mode 100644 panel-plugin/indicator-button.c create mode 100644 panel-plugin/indicator-button.h diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am index 8cbe4f5..de8c63a 100644 --- a/panel-plugin/Makefile.am +++ b/panel-plugin/Makefile.am @@ -14,6 +14,8 @@ plugindir = \ $(libexecdir)/xfce4/panel-plugins xfce4_indicator_plugin_SOURCES = \ + indicator-button.c \ + indicator-button.h \ indicator.c \ indicator.h diff --git a/panel-plugin/indicator-button.c b/panel-plugin/indicator-button.c new file mode 100644 index 0000000..78bbee3 --- /dev/null +++ b/panel-plugin/indicator-button.c @@ -0,0 +1,334 @@ +/* Copyright (c) 2012 Andrzej + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include + +#include "indicator-button.h" + +static void xfce_indicator_button_finalize (GObject *object); + + +G_DEFINE_TYPE (XfceIndicatorButton, xfce_indicator_button, GTK_TYPE_TOGGLE_BUTTON) + +static void +xfce_indicator_button_class_init (XfceIndicatorButtonClass *klass) +{ + GObjectClass *gobject_class; + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = xfce_indicator_button_finalize; +} + + + +static void +xfce_indicator_button_init (XfceIndicatorButton *button) +{ + GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (button), GTK_CAN_DEFAULT | GTK_CAN_FOCUS); + gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); + gtk_button_set_use_underline (GTK_BUTTON (button),TRUE); + gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); + gtk_widget_set_name (GTK_WIDGET (button), "indicator-button"); + + button->io = NULL; + button->entry = NULL; + button->menu = NULL; + + button->label = NULL; + button->icon = NULL; + button->size = -1; + button->panel_size = -1; + button->panel_orientation = GTK_ORIENTATION_HORIZONTAL; + button->orientation = GTK_ORIENTATION_HORIZONTAL; + + + button->outer_box = xfce_hvbox_new (GTK_ORIENTATION_VERTICAL, FALSE, 1); + gtk_container_add (GTK_CONTAINER (button), button->outer_box); + gtk_widget_show (button->outer_box); + + button->box = xfce_hvbox_new (button->orientation, FALSE, 1); + gtk_box_pack_start (GTK_BOX (button->outer_box), button->box, TRUE, FALSE, 0); + gtk_widget_show (button->box); +} + + + +static void +xfce_indicator_button_finalize (GObject *object) +{ + XfceIndicatorButton *button = XFCE_INDICATOR_BUTTON (object); + + if (button->label != NULL) + { + g_object_unref (G_OBJECT (button->label)); + button->label = NULL; + } + if (button->icon != NULL) + { + g_object_unref (G_OBJECT (button->icon)); + button->icon = NULL; + } + if (button->io != NULL) + { + g_object_unref (G_OBJECT (button->io)); + button->io = NULL; + } + if (button->entry != NULL) + { + g_object_unref (G_OBJECT (button->entry)); + button->entry = NULL; + } + if (button->menu != NULL) + { + g_object_unref (G_OBJECT (button->menu)); + button->menu = NULL; + } + + G_OBJECT_CLASS (xfce_indicator_button_parent_class)->finalize (object); +} + + + +static void +xfce_indicator_button_check_label_size (XfceIndicatorButton *button) +{ + GtkRequisition label_size; + gint width, border_thickness; + GtkStyle *style; + + g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button)); + + if (button->panel_orientation == GTK_ORIENTATION_VERTICAL && + button->orientation == GTK_ORIENTATION_HORIZONTAL && + button->icon != NULL && + button->label != NULL) + { + gtk_widget_size_request (button->label, &label_size); + + width = gdk_pixbuf_get_width (gtk_image_get_pixbuf (button->icon)); + style = gtk_widget_get_style (GTK_WIDGET (button)); + border_thickness = 2 * MAX (style->xthickness, style->ythickness) + 2; + + if (label_size.width > button->panel_size - width - border_thickness) + gtk_orientable_set_orientation (GTK_ORIENTABLE (button->box), GTK_ORIENTATION_VERTICAL); + else + gtk_orientable_set_orientation (GTK_ORIENTABLE (button->box), GTK_ORIENTATION_HORIZONTAL); + } +} + + + +void +xfce_indicator_button_set_label (XfceIndicatorButton *button, + GtkLabel *label) +{ + g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button)); + g_return_if_fail (GTK_IS_LABEL (label)); + + if (button->label != GTK_WIDGET (label)) + { + if (button->label != NULL) + { + gtk_container_remove (GTK_CONTAINER (button->box), button->label); + g_object_unref (G_OBJECT (button->label)); + } + + button->label = GTK_WIDGET (label); + g_object_ref (G_OBJECT (button->label)); + gtk_box_pack_end (GTK_BOX (button->box), button->label, TRUE, FALSE, 1); + } + xfce_indicator_button_check_label_size (button); +} + + + +void +xfce_indicator_button_set_image (XfceIndicatorButton *button, + GtkImage *image) +{ + g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button)); + g_return_if_fail (GTK_IS_IMAGE (image)); + + if (button->icon != GTK_WIDGET (image)) + { + if (button->icon != NULL) + { + gtk_container_remove (GTK_CONTAINER (button->box), button->icon); + g_object_unref (G_OBJECT (button->icon)); + } + + button->icon = GTK_WIDGET (image); + g_object_ref (G_OBJECT (button->icon)); + gtk_box_pack_start (GTK_BOX (button->box), button->icon, TRUE, FALSE, 1); + } + xfce_indicator_button_check_label_size (button); +} + + + +void +xfce_indicator_button_set_menu (XfceIndicatorButton *button, + GtkMenu *menu) +{ + g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button)); + g_return_if_fail (GTK_IS_MENU (menu)); + + if (button->menu != menu) + { + if (button->menu != NULL) + g_object_unref (G_OBJECT (button->menu)); + button->menu = menu; + g_object_ref (G_OBJECT (button->menu)); + gtk_menu_attach_to_widget(menu, GTK_WIDGET (button), NULL); + } +} + + + +GtkWidget * +xfce_indicator_button_get_label (XfceIndicatorButton *button) +{ + g_return_val_if_fail (XFCE_IS_INDICATOR_BUTTON (button), NULL); + + return button->label; +} + + + +GtkWidget * +xfce_indicator_button_get_image (XfceIndicatorButton *button) +{ + g_return_val_if_fail (XFCE_IS_INDICATOR_BUTTON (button), NULL); + + return button->icon; +} + + + +IndicatorObjectEntry * +xfce_indicator_button_get_entry (XfceIndicatorButton *button) +{ + g_return_val_if_fail (XFCE_IS_INDICATOR_BUTTON (button), NULL); + + return button->entry; +} + + + +IndicatorObject * +xfce_indicator_button_get_io (XfceIndicatorButton *button) +{ + g_return_val_if_fail (XFCE_IS_INDICATOR_BUTTON (button), NULL); + + return button->io; +} + + + +GtkMenu * +xfce_indicator_button_get_menu (XfceIndicatorButton *button) +{ + g_return_val_if_fail (XFCE_IS_INDICATOR_BUTTON (button), NULL); + + return button->menu; +} + + + +void +xfce_indicator_button_set_orientation (XfceIndicatorButton *button, + GtkOrientation orientation) +{ + g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button)); + + button->orientation = orientation; + + gtk_orientable_set_orientation (GTK_ORIENTABLE (button->box), orientation); + + if (button->label != NULL) + gtk_label_set_angle (GTK_LABEL (button->label), + (orientation == GTK_ORIENTATION_VERTICAL) ? -90 : 0); + xfce_indicator_button_check_label_size (button); +} + + + +void +xfce_indicator_button_set_panel_orientation (XfceIndicatorButton *button, + GtkOrientation orientation) +{ + g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button)); + + button->panel_orientation = orientation; + + gtk_orientable_set_orientation + (GTK_ORIENTABLE (button->outer_box), + (orientation == GTK_ORIENTATION_HORIZONTAL) ? + GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL); + xfce_indicator_button_check_label_size (button); +} + + + +void +xfce_indicator_button_set_panel_size (XfceIndicatorButton *button, + gint size) +{ + g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button)); + + button->panel_size = size; + xfce_indicator_button_check_label_size (button); +} + + + +void +xfce_indicator_button_set_size (XfceIndicatorButton *button, + gint size) +{ + g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button)); + + button->size = size; + + size -= (2 + 2 * MAX (GTK_WIDGET (button)->style->xthickness, + GTK_WIDGET (button)->style->ythickness)); + if (button->icon != NULL) + { + gtk_widget_set_size_request (button->icon, size, size); + xfce_indicator_button_check_label_size (button); + } +} + + + +GtkWidget * +xfce_indicator_button_new (IndicatorObject *io, + IndicatorObjectEntry *entry) +{ + XfceIndicatorButton *button = g_object_new (XFCE_TYPE_INDICATOR_BUTTON, NULL); + button->io = io; + button->entry = entry; + g_object_ref (G_OBJECT (button->io)); + g_object_ref (G_OBJECT (button->entry)); + return GTK_WIDGET (button); +} + + + diff --git a/panel-plugin/indicator-button.h b/panel-plugin/indicator-button.h new file mode 100644 index 0000000..bf4a169 --- /dev/null +++ b/panel-plugin/indicator-button.h @@ -0,0 +1,88 @@ +/* Copyright (c) 2012 Andrzej + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __INDICATOR_BUTTON_H__ +#define __INDICATOR_BUTTON_H__ + +G_BEGIN_DECLS + +GType xfce_indicator_button_get_type (void); + +#define XFCE_TYPE_INDICATOR_BUTTON (xfce_indicator_button_get_type()) +#define XFCE_INDICATOR_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XFCE_TYPE_INDICATOR_BUTTON, XfceIndicatorButton)) +#define XFCE_INDICATOR_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XFCE_TYPE_INDICATOR_BUTTON, XfceIndicatorButtonClass)) +#define XFCE_IS_INDICATOR_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XFCE_TYPE_INDICATOR_BUTTON)) +#define XFCE_IS_INDICATOR_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), XFCE_TYPE_INDICATOR_BUTTON)) +#define XFCE_INDICATOR_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XFCE_TYPE_INDICATOR_BUTTON, XfceIndicatorButtonClass)) + +typedef struct _XfceIndicatorButton XfceIndicatorButton; +typedef struct _XfceIndicatorButtonClass XfceIndicatorButtonClass; + +struct _XfceIndicatorButton +{ + GtkToggleButton __parent__; + + IndicatorObject *io; + IndicatorObjectEntry *entry; + GtkMenu *menu; + + GtkWidget *outer_box; + GtkWidget *box; + GtkWidget *label; + GtkWidget *icon; + + gint panel_size; + gint size; + + GtkOrientation panel_orientation; + GtkOrientation orientation; +}; + +struct _XfceIndicatorButtonClass +{ + GtkToggleButtonClass __parent__; +}; + +void xfce_indicator_button_set_label (XfceIndicatorButton *button, GtkLabel *label); + +void xfce_indicator_button_set_image (XfceIndicatorButton *button, GtkImage *image); + +void xfce_indicator_button_set_menu (XfceIndicatorButton *button, GtkMenu *menu); + +GtkWidget *xfce_indicator_button_get_label (XfceIndicatorButton *button); + +GtkWidget *xfce_indicator_button_get_image (XfceIndicatorButton *button); + +IndicatorObjectEntry *xfce_indicator_button_get_entry (XfceIndicatorButton *button); + +IndicatorObject *xfce_indicator_button_get_io (XfceIndicatorButton *button); + +GtkMenu *xfce_indicator_button_get_menu (XfceIndicatorButton *button); + +void xfce_indicator_button_set_orientation (XfceIndicatorButton *button, GtkOrientation orientation); + +void xfce_indicator_button_set_panel_orientation (XfceIndicatorButton *button, GtkOrientation orientation); + +void xfce_indicator_button_set_panel_size (XfceIndicatorButton *button, gint size); + +void xfce_indicator_button_set_size (XfceIndicatorButton *button, gint size); + +GtkWidget *xfce_indicator_button_new (IndicatorObject *io, IndicatorObjectEntry *entry); + +G_END_DECLS + +#endif /* !__INDICATOR_BUTTON_H__ */ diff --git a/panel-plugin/indicator.c b/panel-plugin/indicator.c index a116170..ecba16c 100644 --- a/panel-plugin/indicator.c +++ b/panel-plugin/indicator.c @@ -28,6 +28,7 @@ #include #include "indicator.h" +#include "indicator-button.h" #define DEFAULT_EXCLUDED_MODULES NULL @@ -38,6 +39,18 @@ indicator_construct (XfcePanelPlugin *plugin); static gboolean load_module (const gchar * name, IndicatorPlugin * indicator); +static gboolean +indicator_size_changed (XfcePanelPlugin *plugin, gint size, IndicatorPlugin *indicator); + +#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0) +static void +indicator_mode_changed (XfcePanelPlugin *plugin, XfcePanelPluginMode mode, IndicatorPlugin *indicator); +#else +static void +indicator_orientation_changed (XfcePanelPlugin *plugin, GtkOrientation orientation, IndicatorPlugin *indicator); +#endif + + /* register the plugin */ XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (indicator_construct); @@ -76,6 +89,7 @@ indicator_save (XfcePanelPlugin *plugin, } #endif + static void indicator_read (IndicatorPlugin *indicator) { @@ -178,8 +192,9 @@ indicator_new (XfcePanelPlugin *plugin) if (indicators_loaded == 0) { /* A label to allow for click through */ - indicator->item = xfce_create_panel_button(); - gtk_button_set_label(GTK_BUTTON(indicator->item), _("No Indicators")); + indicator->item = xfce_indicator_button_new(NULL, NULL); + xfce_indicator_button_set_label(XFCE_INDICATOR_BUTTON(indicator->item), + GTK_LABEL (gtk_label_new(_("No Indicators")))); gtk_container_add (GTK_CONTAINER (plugin), indicator->item); gtk_widget_show(indicator->item); /* show the panel's right-click menu on this menu */ @@ -216,17 +231,52 @@ indicator_free (XfcePanelPlugin *plugin, +#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0) +static void +indicator_mode_changed (XfcePanelPlugin *plugin, + XfcePanelPluginMode mode, + IndicatorPlugin *indicator) +{ + GList *buttons; + GList *button; + GtkOrientation orientation; + GtkOrientation panel_orientation = xfce_panel_plugin_get_orientation (plugin); + + gtk_orientable_set_orientation (GTK_ORIENTABLE(indicator->buttonbox), panel_orientation); + + orientation = (mode == XFCE_PANEL_PLUGIN_MODE_VERTICAL) ? + GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL; + + buttons = gtk_container_get_children (GTK_CONTAINER (indicator->buttonbox)); + for (button = buttons; button != NULL; button = g_list_next (button)) + { + xfce_indicator_button_set_panel_orientation (XFCE_INDICATOR_BUTTON (button->data), + panel_orientation); + xfce_indicator_button_set_orientation (XFCE_INDICATOR_BUTTON (button->data), + orientation); + } + indicator_size_changed (plugin, xfce_panel_plugin_get_size (plugin), indicator); +} + +#else static void indicator_orientation_changed (XfcePanelPlugin *plugin, GtkOrientation orientation, IndicatorPlugin *indicator) { - gint sizex=-1, sizey=-1; + GList *buttons; + GList *button; + gtk_orientable_set_orientation (GTK_ORIENTABLE(indicator->buttonbox), orientation); - gtk_widget_get_size_request (GTK_WIDGET (plugin), &sizex, &sizey); - gtk_widget_set_size_request (GTK_WIDGET (plugin), sizey, sizex); -} + buttons = gtk_container_get_children (GTK_CONTAINER (indicator->buttonbox)); + for (button = buttons; button != NULL; button = g_list_next (button)) + xfce_indicator_button_set_panel_orientation (XFCE_INDICATOR_BUTTON (button->data), + orientation); + + indicator_size_changed (plugin, xfce_panel_plugin_get_size (plugin), indicator); +} +#endif static gboolean @@ -235,6 +285,11 @@ indicator_size_changed (XfcePanelPlugin *plugin, IndicatorPlugin *indicator) { GtkOrientation orientation; + GList *buttons; + GList *button; +#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + gint row_size = size / xfce_panel_plugin_get_nrows (plugin); +#endif /* get the orientation of the plugin */ orientation = xfce_panel_plugin_get_orientation (plugin); @@ -245,9 +300,21 @@ indicator_size_changed (XfcePanelPlugin *plugin, else gtk_widget_set_size_request (GTK_WIDGET (plugin), size, -1); + + buttons = gtk_container_get_children (GTK_CONTAINER (indicator->buttonbox)); + for (button = buttons; button != NULL; button = g_list_next (button)) + { +#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + //xfce_indicator_button_set_size (XFCE_INDICATOR_BUTTON (button->data), row_size); +#endif + xfce_indicator_button_set_panel_size (XFCE_INDICATOR_BUTTON (button->data), size); + } + return TRUE; } + + static gboolean on_button_press (GtkWidget *widget, GdkEventButton *event, IndicatorPlugin *indicator) { @@ -256,7 +323,7 @@ on_button_press (GtkWidget *widget, GdkEventButton *event, IndicatorPlugin *indi if( event->button == 1) /* left click only */ { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),TRUE); - gtk_menu_popup (GTK_MENU(g_object_get_data (G_OBJECT(widget),"menu")), NULL, NULL, + gtk_menu_popup (xfce_indicator_button_get_menu (XFCE_INDICATOR_BUTTON(widget)), NULL, NULL, xfce_panel_plugin_position_menu, indicator->plugin, 1, gtk_get_current_event_time ()); @@ -276,9 +343,12 @@ menu_deactivate (GtkMenu *menu, } static void -on_label_changed (GtkLabel *label, GParamSpec *pspec, GtkButton *button) +on_label_changed (GtkLabel *label, GParamSpec *pspec, XfceIndicatorButton *button) { - gtk_button_set_label (button, gtk_label_get_label (label)); + g_return_if_fail (GTK_IS_LABEL (label)); + g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button)); + + xfce_indicator_button_set_label (button, label); } static void @@ -299,16 +369,23 @@ indicator_construct (XfcePanelPlugin *plugin) g_signal_connect (G_OBJECT (plugin), "size-changed", G_CALLBACK (indicator_size_changed), indicator); +#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + g_signal_connect (G_OBJECT (plugin), "mode-changed", + G_CALLBACK (indicator_mode_changed), indicator); + indicator_mode_changed (plugin, xfce_panel_plugin_get_mode (plugin), indicator); +#else g_signal_connect (G_OBJECT (plugin), "orientation-changed", G_CALLBACK (indicator_orientation_changed), indicator); + indicator_orientation_changed (plugin, xfce_panel_plugin_get_orientation (plugin), indicator); +#endif } static gboolean entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, IndicatorPlugin *indicator) { - IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), "indicator-custom-object-data"); - IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), "indicator-custom-entry-data"); + IndicatorObject *io = xfce_indicator_button_get_io (XFCE_INDICATOR_BUTTON (menuitem)); + IndicatorObjectEntry *entry = xfce_indicator_button_get_entry (XFCE_INDICATOR_BUTTON (menuitem)); g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE); g_return_val_if_fail(indicator != NULL, FALSE); @@ -322,23 +399,23 @@ entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, IndicatorPlugin *ind static void entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data) { - GtkWidget * button = gtk_toggle_button_new(); + XfcePanelPlugin *plugin = ((IndicatorPlugin *) user_data)->plugin; + GtkWidget * button = xfce_indicator_button_new (io, entry); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_button_set_use_underline(GTK_BUTTON (button),TRUE); gtk_widget_set_name(GTK_WIDGET (button), "indicator-button"); if (entry->image != NULL) - gtk_button_set_image(GTK_BUTTON(button), GTK_WIDGET(entry->image)); + xfce_indicator_button_set_image(XFCE_INDICATOR_BUTTON(button), entry->image); if (entry->label != NULL) { - gtk_button_set_label(GTK_BUTTON(button), gtk_label_get_label (entry->label)); + xfce_indicator_button_set_label(XFCE_INDICATOR_BUTTON(button), entry->label); g_signal_connect(G_OBJECT(entry->label), "notify::label", G_CALLBACK(on_label_changed), button); } if (entry->menu != NULL) { - g_object_set_data(G_OBJECT(button), "menu", entry->menu); - gtk_menu_attach_to_widget(entry->menu, button, NULL); + xfce_indicator_button_set_menu (XFCE_INDICATOR_BUTTON(button), entry->menu); g_signal_connect(G_OBJECT(entry->menu), "deactivate", G_CALLBACK(menu_deactivate),NULL); } @@ -348,15 +425,27 @@ entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_d user_data); gtk_box_pack_start(GTK_BOX(((IndicatorPlugin *)user_data)->buttonbox), button, TRUE, TRUE, 0); gtk_widget_show(button); - g_object_set_data(G_OBJECT(button), "indicator-custom-object-data", io); - g_object_set_data(G_OBJECT(button), "indicator-custom-entry-data", entry); + + xfce_indicator_button_set_panel_size (XFCE_INDICATOR_BUTTON (button), + xfce_panel_plugin_get_size (plugin)); + xfce_indicator_button_set_panel_orientation (XFCE_INDICATOR_BUTTON (button), + xfce_panel_plugin_get_orientation (plugin)); +#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + xfce_indicator_button_set_orientation + (XFCE_INDICATOR_BUTTON (button), + (xfce_panel_plugin_get_mode (plugin) == XFCE_PANEL_PLUGIN_MODE_VERTICAL) ? + GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL); +#else + xfce_indicator_button_set_orientation (XFCE_INDICATOR_BUTTON (button), + GTK_ORIENTATION_HORIZONTAL); +#endif } static void entry_removed_cb (GtkWidget * widget, gpointer userdata) { - gpointer data = g_object_get_data(G_OBJECT(widget), "indicator-custom-entry-data"); + gpointer data = (gpointer) xfce_indicator_button_get_entry (XFCE_INDICATOR_BUTTON (widget)); if (data != userdata) return; -- 1.7.5.4 From d2f9feb9f01718216a036c9b9fda9f91c1ce03f7 Mon Sep 17 00:00:00 2001 From: Andrzej Date: Wed, 14 Mar 2012 17:09:00 +0900 Subject: [PATCH 2/2] Fixed layout regression in 4.8 --- panel-plugin/indicator.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/panel-plugin/indicator.c b/panel-plugin/indicator.c index ecba16c..6618049 100644 --- a/panel-plugin/indicator.c +++ b/panel-plugin/indicator.c @@ -271,8 +271,12 @@ indicator_orientation_changed (XfcePanelPlugin *plugin, buttons = gtk_container_get_children (GTK_CONTAINER (indicator->buttonbox)); for (button = buttons; button != NULL; button = g_list_next (button)) - xfce_indicator_button_set_panel_orientation (XFCE_INDICATOR_BUTTON (button->data), - orientation); + { + xfce_indicator_button_set_panel_orientation (XFCE_INDICATOR_BUTTON (button->data), + orientation); + xfce_indicator_button_set_orientation (XFCE_INDICATOR_BUTTON (button->data), + GTK_ORIENTATION_HORIZONTAL); + } indicator_size_changed (plugin, xfce_panel_plugin_get_size (plugin), indicator); } -- 1.7.5.4