summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2021-05-24 13:50:47 +0200
committerraveit65 <[email protected]>2022-01-23 13:55:39 +0100
commitb27da42b92d559c5d2933824b2d448cf0fa5bdf6 (patch)
tree2afa0edfab99dcb6c2aa6b776c60fd81c4a9124a
parent42e01cf4992c552bc7924bb8fd0087832e85e8c1 (diff)
downloadmate-panel-b27da42b92d559c5d2933824b2d448cf0fa5bdf6.tar.bz2
mate-panel-b27da42b92d559c5d2933824b2d448cf0fa5bdf6.tar.xz
widget: calculate correct applet sizefix-for-libwnck3-4.0
gtk_widget_get_preferred_size will not return correct size for applets that use height-for-width or width-for-height size request mode. With width-for-height mode gtk_widget_get_preferred_size first will get minimum height and then will get minimum width for calculated height while we really want minimum width for actual panel size if expand_minor is TRUE. origin commit: https://gitlab.gnome.org/GNOME/gnome-panel/-/commit/dc11001
-rw-r--r--mate-panel/panel-widget.c58
1 files changed, 43 insertions, 15 deletions
diff --git a/mate-panel/panel-widget.c b/mate-panel/panel-widget.c
index 7a828021..0daf051f 100644
--- a/mate-panel/panel-widget.c
+++ b/mate-panel/panel-widget.c
@@ -1356,6 +1356,46 @@ queue_resize_on_all_applets(PanelWidget *panel)
}
static void
+get_preferred_size (PanelWidget *self,
+ AppletData *ad,
+ GtkRequisition *minimum_size)
+{
+ if (self->orient == GTK_ORIENTATION_HORIZONTAL) {
+ if (ad->expand_minor)
+ minimum_size->height = self->sz;
+ else
+ gtk_widget_get_preferred_height (ad->applet,
+ &minimum_size->height,
+ NULL);
+
+ gtk_widget_get_preferred_width_for_height (ad->applet,
+ minimum_size->height,
+ &minimum_size->width,
+ NULL);
+ g_print ("[%s] height - %d, width - %d\n",
+ gtk_widget_get_name (gtk_bin_get_child (GTK_BIN (ad->applet))),
+ minimum_size->height,
+ minimum_size->width);
+ }
+ else if (self->orient == GTK_ORIENTATION_VERTICAL) {
+ if (ad->expand_minor)
+ minimum_size->width = self->sz;
+ else
+ gtk_widget_get_preferred_width (ad->applet,
+ &minimum_size->width,
+ NULL);
+
+ gtk_widget_get_preferred_height_for_width (ad->applet,
+ minimum_size->width,
+ &minimum_size->height,
+ NULL);
+ }
+ else {
+ g_assert_not_reached ();
+ }
+}
+
+static void
panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
PanelWidget *panel;
@@ -1399,16 +1439,13 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
AppletData *ad = list->data;
GtkAllocation challoc;
GtkRequisition chreq;
- gtk_widget_get_preferred_size (ad->applet, &chreq, NULL);
+ get_preferred_size (panel, ad, &chreq);
ad->constrained = i;
challoc.width = chreq.width;
challoc.height = chreq.height;
if(panel->orient == GTK_ORIENTATION_HORIZONTAL) {
- if (ad->expand_minor)
- challoc.height = allocation->height;
-
if (ad->expand_major && ad->size_hints) {
int width = panel->applets_using_hint[applet_using_hint_index].size;
applet_using_hint_index++;
@@ -1419,9 +1456,6 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
challoc.x = ltr ? ad->constrained : panel->size - ad->constrained - challoc.width;
challoc.y = allocation->height / 2 - challoc.height / 2;
} else {
- if (ad->expand_minor)
- challoc.width = allocation->width;
-
if (ad->expand_major && ad->size_hints) {
int height = panel->applets_using_hint[applet_using_hint_index].size;
applet_using_hint_index++;
@@ -1450,7 +1484,7 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
AppletData *ad = list->data;
GtkRequisition chreq;
- gtk_widget_get_preferred_size (ad->applet, &chreq, NULL);
+ get_preferred_size (panel, ad, &chreq);
if (!ad->expand_major || !ad->size_hints) {
if(panel->orient == GTK_ORIENTATION_HORIZONTAL)
@@ -1519,22 +1553,16 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
AppletData *ad = list->data;
GtkAllocation challoc;
GtkRequisition chreq;
- gtk_widget_get_preferred_size (ad->applet, &chreq, NULL);
+ get_preferred_size (panel, ad, &chreq);
challoc.width = chreq.width;
challoc.height = chreq.height;
if(panel->orient == GTK_ORIENTATION_HORIZONTAL) {
challoc.width = ad->cells;
- if (ad->expand_minor) {
- challoc.height = allocation->height;
- }
challoc.x = ltr ? ad->constrained : panel->size - ad->constrained - challoc.width;
challoc.y = allocation->height / 2 - challoc.height / 2;
} else {
challoc.height = ad->cells;
- if (ad->expand_minor) {
- challoc.width = allocation->width;
- }
challoc.x = allocation->width / 2 - challoc.width / 2;
challoc.y = ad->constrained;
}