Skip to content

Commit 3f351d5

Browse files
braikarlukefromdc
authored andcommitted
button-widget: wide panels, more suitable resize limits on Widgets and arrows
Set better limits to the size taken by all BUTTON_WIDGETs when the panel is wide. For a wide panel (example vertical panel 100px wide) a widget would, before, take a space of 100x100 (for max hardcoded icon size 48px) Now if panel width exceeds 50px, the widgets' height stays at 50 and does not grow in height anymore. Same behaviour applies on wide horizontal panels. The GTK_ARROW also resizes properly for wide panel on BUTTON_WIDGETs with property "has_arrow"
1 parent e4fc17c commit 3f351d5

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

mate-panel/button-widget.c

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -303,35 +303,40 @@ calc_arrow (PanelOrientation orientation,
303303
gdouble *size)
304304
{
305305
GtkArrowType retval = GTK_ARROW_UP;
306-
double scale;
307306

308-
scale = (orientation & PANEL_HORIZONTAL_MASK ? button_height : button_width) / 48.0;
309-
310-
*size = 12 * scale;
307+
if (orientation & PANEL_HORIZONTAL_MASK) {
308+
if (button_width > 50)
309+
button_width = 50;
310+
} else {
311+
if (button_height > 50)
312+
button_height = 50;
313+
}
314+
315+
*size = (orientation & PANEL_HORIZONTAL_MASK ? button_width : button_height) / 2;
311316
*angle = 0;
312317

313318
switch (orientation) {
314319
case PANEL_ORIENTATION_TOP:
315-
*x = scale * 3;
316-
*y = scale * (48 - 13);
320+
*x = (button_width - (*size)) / 2;
321+
*y = button_height * .99 - (*size) / (3/2); // 3/2 is the approximate ratio of GTK arrows
317322
*angle = G_PI;
318323
retval = GTK_ARROW_DOWN;
319324
break;
320325
case PANEL_ORIENTATION_BOTTOM:
321-
*x = scale * (48 - 13);
322-
*y = scale * 1;
326+
*x = (button_width - (*size)) / 2;
327+
*y = button_height * .01;
323328
*angle = 0;
324329
retval = GTK_ARROW_UP;
325330
break;
326331
case PANEL_ORIENTATION_LEFT:
327-
*x = scale * (48 - 13);
328-
*y = scale * 3;
332+
*x = button_width * .99 - (*size) / (3/2); // 3/2 is the approximate ratio of GTK arrows
333+
*y = (button_height - (*size)) / 2;
329334
*angle = G_PI / 2;
330335
retval = GTK_ARROW_RIGHT;
331336
break;
332337
case PANEL_ORIENTATION_RIGHT:
333-
*x = scale * 1;
334-
*y = scale * 3;
338+
*x = button_width * .01;
339+
*y = (button_height - (*size)) / 2;
335340
*angle = 3 * (G_PI / 2);
336341
retval = GTK_ARROW_LEFT;
337342
break;
@@ -446,9 +451,14 @@ button_widget_get_preferred_width (GtkWidget *widget,
446451

447452
parent = gtk_widget_get_parent (widget);
448453

449-
if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK)
454+
if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK){
450455
size = gtk_widget_get_allocated_height (parent);
451-
else
456+
457+
/* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48*/
458+
if ( size > 50 )
459+
size = 50;
460+
461+
} else
452462
size = gtk_widget_get_allocated_width (parent);
453463

454464
*minimal_width = *natural_width = size;
@@ -467,8 +477,14 @@ button_widget_get_preferred_height (GtkWidget *widget,
467477

468478
if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK)
469479
size = gtk_widget_get_allocated_height (parent);
470-
else
480+
else {
471481
size = gtk_widget_get_allocated_width (parent);
482+
483+
/* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48*/
484+
if ( size > 50 )
485+
size = 50;
486+
487+
}
472488

473489
*minimal_height = *natural_height = size;
474490
}
@@ -480,6 +496,17 @@ button_widget_size_allocate (GtkWidget *widget,
480496
ButtonWidget *button_widget = BUTTON_WIDGET (widget);
481497
int size;
482498

499+
/* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48?*/
500+
if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK) {
501+
if ( allocation->height > 50 ) {
502+
allocation->width = 50;
503+
}
504+
} else {
505+
if ( allocation->width > 50 ) {
506+
allocation->height = 50;
507+
}
508+
}
509+
483510
GTK_WIDGET_CLASS (button_widget_parent_class)->size_allocate (widget, allocation);
484511

485512
if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK)

0 commit comments

Comments
 (0)