Panel plugins have a fixed size in trunk

mmassonnet at gmail.com mmassonnet at gmail.com
Tue Oct 2 23:54:46 CEST 2007


On Mon, Sep 10, 2007 at 02:16:47PM +0200, Nick Schermer wrote:

Hey Nick,

> >From now on the plugin size is fixed in trunk. This means the plugin
> cannot increase the panel size anymore and will be cutoff when it is
> bigger.
> 
> I know some developers are not going to like this, but really, you
> have to live with it. The reason is easy: some plugins use the panel
> size to, for example, calculate the icon size. If an other plugin
> increases the real size of the panel, this technique becomes useless.
> Using the allocated size might result in loops (ask Samuel ^_^), so
> this is the best solution for (almost) everyone.

Well, annoying sure, but now we have a one-way to do it.  It just lacks
documentation, where this mail might help.

I figured the annoyance with the fsguard plugin.  I added some features
to fsguard which I will commit this week, and maybe I'll go ahead to fix
other plugins like the systemload...

A common plugin bug will be the next: if you move the plugin to a panel
which has a different orientation or you change the orientation of the
current panel, then the plugin will be boxed inside a square (or the
like).

The correction is simple, set a size request of (-1, -1) to the
XfcePanelPlugin in the “size-changed” callback like that:

	static gboolean
	panel_plugin_set_size (XfcePanelPlugin *panel_plugin,
	                       int size,
	                       gpointer user_data)
	  {
[...]
	    /* A button */
	    gtk_widget_set_size_request (user_data->button, size, size);
[...]
	    /* A progress bar */
	    GtkOrientation orientation =
	      xfce_panel_plugin_get_orientation (user_data->plugin);

	    if (orientation == GTK_ORIENTATION_HORIZONTAL)
	      gtk_widget_set_size_request (GTK_WIDGET(user_data->progress_bar),
	              BORDER, -1); /* Usually BORDER is defined to 8 */
	    else
	      gtk_widget_set_size_request (GTK_WIDGET(user_data->progress_bar),
	              -1, BORDER);
[...]
	    /* The panel plugin */
	    gtk_widget_set_size_request (GTK_WIDGET (panel_plugin), -1, -1);
[...]
	  }

Also, the fsguard plugin didn't use the XfceHVBox widget, which is
really convenient (avoids you to reparent each of your widgets)... many
other plugins might not use it.

An example for the “orientation-changed” callback:

	static void
	panel_plugin_set_orientation (XfcePanelPlugin *panel_plugin,
	                              GtkOrientation orientation,
     	                              gpointer user_data)
	  {
[...]
	    xfce_hvbox_set_orientation (XFCE_HVBOX (user_data->box), orientation);
[...]
	    gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR(user_data->progress_bar),
                    orientation == GTK_ORIENTATION_HORIZONTAL ?
                    GTK_PROGRESS_BOTTOM_TO_TOP : GTK_PROGRESS_LEFT_TO_RIGHT);
[...]
	  }


> Greets,
> Nick and Jasper

Greetz ;)
Mike
PS: the orientation-changed signal is always followed by the
size-changed signal.
PS2: if you steal the thread for another discussion, don't forget to
append [OT] in the really first place, or open a new thread.



More information about the Xfce4-dev mailing list