From e8ee0ba15dbd56bba3a7710ef22aa8bdac008dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= Date: Mon, 11 Aug 2014 17:40:02 +0300 Subject: [PATCH 1/2] Revert "calendar-window: Port 'size-request' signal" This reverts commit 7f9470c42ba1264667e8b4f916b3f157c6cd1e54. --- applets/clock/calendar-window.c | 49 +++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/applets/clock/calendar-window.c b/applets/clock/calendar-window.c index 14d88dd..f4f2b74 100644 --- a/applets/clock/calendar-window.c +++ b/applets/clock/calendar-window.c @@ -1269,34 +1269,55 @@ calendar_month_selected (GtkCalendar *calendar, handle_tasks_changed (calwin); } +typedef struct +{ + GtkWidget *calendar; + GtkWidget *tree; +} ConstraintData; + static void -setup_list_size_constraint (GtkWidget *widget, - GtkWidget *calendar, - GtkWidget *tree) +constrain_list_size (GtkWidget *widget, + GtkRequisition *requisition, + ConstraintData *constraint) { - GtkRequisition req; + GtkRequisition req; GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; - int screen_h; - int max_height; - int req_height; + int screen_h; + int max_height; - /* constrain width to the calendar width */ - gtk_widget_get_preferred_size (calendar, &req, NULL); + /* constrain width to the calendar width */ + gtk_widget_get_preferred_size (constraint->calendar, &req, NULL); + requisition->width = MIN (requisition->width, req.width); screen_h = gdk_screen_get_height (gtk_widget_get_screen (widget)); /* constrain height to be the tree height up to a max */ - max_height = (screen_h - req.height) / 3; - gtk_widget_get_preferred_size (tree, &req, NULL); + max_height = (screen_h - req.height) / 3; + gtk_widget_get_preferred_size (constraint->tree, &req, NULL); state = gtk_widget_get_state_flags (widget); context = gtk_widget_get_style_context (widget); gtk_style_context_get_padding (context, state, &padding); - req_height = MIN (req.height, max_height); - req_height += padding.top + padding.bottom; - gtk_widget_set_size_request (widget, req.width, req_height); + requisition->height = MIN (req.height, max_height); + requisition->height += padding.top + padding.bottom; +} + +static void +setup_list_size_constraint (GtkWidget *widget, + GtkWidget *calendar, + GtkWidget *tree) +{ + ConstraintData *constraint; + + constraint = g_new0 (ConstraintData, 1); + constraint->calendar = calendar; + constraint->tree = tree; + + g_signal_connect_data (widget, "size-request", + G_CALLBACK (constrain_list_size), constraint, + (GClosureNotify) g_free, 0); } #endif /* HAVE_LIBECAL */ -- 2.1.0.rc1