[Xfce4-commits] <xfce4-indicator-plugin:master> Fixed missing placeholder label (regression)
Andrzej
noreply at xfce.org
Thu Apr 4 17:44:14 CEST 2013
Updating branch refs/heads/master
to c40c282be0037c4de230fc7178c786a5fbab3689 (commit)
from 2cb73e6d4175c5d693e91cc5357ac4564912e18f (commit)
commit c40c282be0037c4de230fc7178c786a5fbab3689
Author: Andrzej <ndrwrdck at gmail.com>
Date: Sun Apr 29 02:33:43 2012 +0900
Fixed missing placeholder label (regression)
also, use an ellipsis mode for labels in the deskbar mode.
panel-plugin/indicator-button.c | 23 ++++++++++++++++++++---
panel-plugin/indicator.c | 17 ++++++++++++++---
2 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/panel-plugin/indicator-button.c b/panel-plugin/indicator-button.c
index ac0f432..97e26d3 100644
--- a/panel-plugin/indicator-button.c
+++ b/panel-plugin/indicator-button.c
@@ -131,30 +131,47 @@ static void
xfce_indicator_button_update_layout (XfceIndicatorButton *button)
{
GtkRequisition label_size;
+ gfloat align_x;
g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button));
g_return_if_fail (XFCE_IS_INDICATOR_BOX (button->buttonbox));
+ if (button->label != NULL)
+ gtk_label_set_ellipsize (GTK_LABEL (button->label), PANGO_ELLIPSIZE_NONE);
+
+ /* deskbar mode? */
if (button->label != NULL &&
xfce_indicator_box_get_panel_orientation (button->buttonbox) == GTK_ORIENTATION_VERTICAL &&
xfce_indicator_box_get_indicator_orientation (button->buttonbox) == GTK_ORIENTATION_HORIZONTAL)
{
gtk_widget_size_request (button->label, &label_size);
+ /* check if icon and label fit side by side */
if (!xfce_indicator_box_get_align_left (button->buttonbox)
|| (button->icon != NULL
&& label_size.width >
xfce_indicator_box_get_panel_size (button->buttonbox)
- xfce_indicator_box_get_indicator_size (button->buttonbox)))
{
- gtk_alignment_set (GTK_ALIGNMENT (button->align_box), 0.5, 0.5, 0.0, 0.0);
+ align_x = 0.5;
gtk_orientable_set_orientation (GTK_ORIENTABLE (button->box), GTK_ORIENTATION_VERTICAL);
}
else
{
- gtk_alignment_set (GTK_ALIGNMENT (button->align_box), 0.0, 0.5, 0.0, 0.0);
+ align_x = 0.0;
gtk_orientable_set_orientation (GTK_ORIENTABLE (button->box), GTK_ORIENTATION_HORIZONTAL);
}
+
+ /* check if label alone fits in the panel */
+ if (label_size.width > xfce_indicator_box_get_panel_size (button->buttonbox) - 6)
+ {
+ gtk_alignment_set (GTK_ALIGNMENT (button->align_box), align_x, 0.5, 1.0, 0.0);
+ gtk_label_set_ellipsize (GTK_LABEL (button->label), PANGO_ELLIPSIZE_END);
+ }
+ else
+ {
+ gtk_alignment_set (GTK_ALIGNMENT (button->align_box), align_x, 0.5, 0.0, 0.0);
+ }
}
else
{
@@ -482,7 +499,7 @@ xfce_indicator_button_button_press (GtkWidget *widget,
{
XfceIndicatorButton *button = XFCE_INDICATOR_BUTTON (widget);
- if( event->button == 1) /* left click only */
+ if(event->button == 1 && button->menu != NULL) /* left click only */
{
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),TRUE);
gtk_menu_popup (button->menu, NULL, NULL,
diff --git a/panel-plugin/indicator.c b/panel-plugin/indicator.c
index f152a02..88f4d42 100644
--- a/panel-plugin/indicator.c
+++ b/panel-plugin/indicator.c
@@ -276,6 +276,7 @@ indicator_construct (XfcePanelPlugin *plugin)
IndicatorPlugin *indicator = XFCE_INDICATOR_PLUGIN (plugin);
GtkRcStyle *style;
gint indicators_loaded = 0;
+ GtkWidget *label;
xfce_panel_plugin_menu_show_configure (plugin);
@@ -321,10 +322,11 @@ indicator_construct (XfcePanelPlugin *plugin)
if (indicators_loaded == 0) {
/* A label to allow for click through */
indicator->item = xfce_indicator_button_new(NULL, NULL, XFCE_INDICATOR_BOX (indicator->buttonbox));
- xfce_indicator_button_set_label(XFCE_INDICATOR_BUTTON(indicator->item),
- GTK_LABEL (gtk_label_new(_("No Indicators"))));
+ label = gtk_label_new ( _("No Indicators"));
+ xfce_indicator_button_set_label (XFCE_INDICATOR_BUTTON (indicator->item), GTK_LABEL (label));
gtk_container_add (GTK_CONTAINER (indicator->buttonbox), indicator->item);
- gtk_widget_show(indicator->item);
+ gtk_widget_show (label);
+ gtk_widget_show (indicator->item);
}
}
@@ -335,6 +337,15 @@ entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_d
XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (user_data);
IndicatorPlugin *indicator = XFCE_INDICATOR_PLUGIN (plugin);
GtkWidget * button = xfce_indicator_button_new (io, entry, XFCE_INDICATOR_BOX (indicator->buttonbox));
+
+ /* remove placeholder item when there are real entries to be added */
+ if (indicator->item != NULL)
+ {
+ xfce_indicator_button_disconnect_signals (XFCE_INDICATOR_BUTTON (indicator->item));
+ gtk_widget_destroy (GTK_WIDGET (indicator->item));
+ indicator->item = NULL;
+ }
+
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");
More information about the Xfce4-commits
mailing list