summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbraikar <[email protected]>2018-08-20 05:58:16 +0200
committerraveit65 <[email protected]>2019-01-28 17:14:33 +0100
commitd491abcac81b278c73cb8dce9b260b59ce4b176e (patch)
treec149c350220c173a606f47f6c337683d5ee02f80
parent0a10e4b82ec4869386f088cd2a8ecaacfbbf011c (diff)
downloadmate-panel-d491abcac81b278c73cb8dce9b260b59ce4b176e.tar.bz2
mate-panel-d491abcac81b278c73cb8dce9b260b59ce4b176e.tar.xz
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"
-rw-r--r--mate-panel/button-widget.c57
1 files changed, 42 insertions, 15 deletions
diff --git a/mate-panel/button-widget.c b/mate-panel/button-widget.c
index 796e3179..02f69fb0 100644
--- a/mate-panel/button-widget.c
+++ b/mate-panel/button-widget.c
@@ -303,35 +303,40 @@ calc_arrow (PanelOrientation orientation,
gdouble *size)
{
GtkArrowType retval = GTK_ARROW_UP;
- double scale;
- scale = (orientation & PANEL_HORIZONTAL_MASK ? button_height : button_width) / 48.0;
-
- *size = 12 * scale;
+ if (orientation & PANEL_HORIZONTAL_MASK) {
+ if (button_width > 50)
+ button_width = 50;
+ } else {
+ if (button_height > 50)
+ button_height = 50;
+ }
+
+ *size = (orientation & PANEL_HORIZONTAL_MASK ? button_width : button_height) / 2;
*angle = 0;
switch (orientation) {
case PANEL_ORIENTATION_TOP:
- *x = scale * 3;
- *y = scale * (48 - 13);
+ *x = (button_width - (*size)) / 2;
+ *y = button_height * .99 - (*size) / (3/2); // 3/2 is the approximate ratio of GTK arrows
*angle = G_PI;
retval = GTK_ARROW_DOWN;
break;
case PANEL_ORIENTATION_BOTTOM:
- *x = scale * (48 - 13);
- *y = scale * 1;
+ *x = (button_width - (*size)) / 2;
+ *y = button_height * .01;
*angle = 0;
retval = GTK_ARROW_UP;
break;
case PANEL_ORIENTATION_LEFT:
- *x = scale * (48 - 13);
- *y = scale * 3;
+ *x = button_width * .99 - (*size) / (3/2); // 3/2 is the approximate ratio of GTK arrows
+ *y = (button_height - (*size)) / 2;
*angle = G_PI / 2;
retval = GTK_ARROW_RIGHT;
break;
case PANEL_ORIENTATION_RIGHT:
- *x = scale * 1;
- *y = scale * 3;
+ *x = button_width * .01;
+ *y = (button_height - (*size)) / 2;
*angle = 3 * (G_PI / 2);
retval = GTK_ARROW_LEFT;
break;
@@ -446,9 +451,14 @@ button_widget_get_preferred_width (GtkWidget *widget,
parent = gtk_widget_get_parent (widget);
- if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK)
+ if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK){
size = gtk_widget_get_allocated_height (parent);
- else
+
+ /* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48*/
+ if ( size > 50 )
+ size = 50;
+
+ } else
size = gtk_widget_get_allocated_width (parent);
*minimal_width = *natural_width = size;
@@ -467,8 +477,14 @@ button_widget_get_preferred_height (GtkWidget *widget,
if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK)
size = gtk_widget_get_allocated_height (parent);
- else
+ else {
size = gtk_widget_get_allocated_width (parent);
+
+ /* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48*/
+ if ( size > 50 )
+ size = 50;
+
+ }
*minimal_height = *natural_height = size;
}
@@ -480,6 +496,17 @@ button_widget_size_allocate (GtkWidget *widget,
ButtonWidget *button_widget = BUTTON_WIDGET (widget);
int size;
+ /* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48?*/
+ if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK) {
+ if ( allocation->height > 50 ) {
+ allocation->width = 50;
+ }
+ } else {
+ if ( allocation->width > 50 ) {
+ allocation->height = 50;
+ }
+ }
+
GTK_WIDGET_CLASS (button_widget_parent_class)->size_allocate (widget, allocation);
if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK)