Panel plugins have a fixed size in trunk

mmassonnet at mmassonnet at
Fri Oct 5 07:19:37 CEST 2007

On Tue, Oct 02, 2007 at 05:44:20PM -0700, Brian J. Tarricone wrote:
Yo Brian,

> mmassonnet at wrote:
> > 	    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);
> This is really only sorta correct.  A better solution is to ensure that 
> the widgets inside the plugin will only need as much space as the panel 
> will allow, by using the size reported by the panel to calculate the 
> sizes of stuff inside the plugin.

Right, better set the correct size for the widgets!  But if you look
closer to this special case, the progress bar will just fit the max
height with -1, and even if you want to set a height it will always
expand to the maximum height, hence the useless here :)  But as said
better set the correct size of your widgets, and after that you can just
call gtk_widget_set_request_size with (-1, -1) to unset the damm locked
width/height on orientation movement of the XfcePanelPlugin.

What I see is that when the plugin undergoes a orientation movement,
then it is stuck in a square and you have to either set the correct size
for the XfcePanelPlugin (over complexity IMHO), or unset its size so the
width set on the other widgets will take relative place inside it.

If that could be fixed in the panel code itself it would just be nice:
lock the height if orientation is horizontal, or lock the width if
orientation is vertical.  Not sure at all what the code says tho :s

> For example, if you have an image in your plugin, you should calculate 
> the image size based on the plugin size minus any borders, padding, 
> x/ythickness, etc., and the sizes of any other widgets (say a text 
> label) that sit above/below (horizonal panel) or to the left/right 
> (vertical panel) of the image.  Forcing widgets to a particular size 
> will just hide sizing bugs.
> (Of course, there are probably some instances where you'd want to 
> explicitly set the size of the widget, perhaps when doing some custom 
> drawing.)

Calculate the image size is correct, this is the code I have in the
notes plugin (it comes from the early Xfce 4.2 version):

  size = size - 2 - (2 * MAX (plugin->button->style->xthickness,

- size originates to the panel size
- 2 is the wished padding inside the button (understand top+bottom or
  right+left for a 1 pixel border inside the button)
- 2 * (x|y)thickness removes the border all around the button

> 	-b


More information about the Xfce4-dev mailing list