summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbraikar <[email protected]>2018-08-20 05:58:16 +0200
committerlukefromdc <[email protected]>2018-10-20 13:35:24 -0400
commit3f351d5c959b81792ed5a20845bb871a66b2f87c (patch)
treedb52ed8029de408e3c23424283b874da08f45a8c
parente4fc17cf8c76f84a95e21779b5384136f1a2b756 (diff)
downloadmate-panel-3f351d5c959b81792ed5a20845bb871a66b2f87c.tar.bz2
mate-panel-3f351d5c959b81792ed5a20845bb871a66b2f87c.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)