[evolution/wip/gsettings] Fudge gtk_widget_get_preferred_size() for gtk2.



commit 2485ba3936c9fdd4e185393d49c34dae7ba1f49d
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Jan 13 10:54:58 2011 -0500

    Fudge gtk_widget_get_preferred_size() for gtk2.
    
    Easy enough to fake gtk_widget_get_preferred_size() in gtk2 using
    gtk_widget_size_request().  Reduces diff noise with gtk3 branch.

 addressbook/gui/contact-editor/e-contact-editor.c |    4 ++--
 calendar/gui/e-calendar-view.c                    |    2 +-
 calendar/gui/e-meeting-time-sel.c                 |    7 +++++--
 e-util/gtk-compat.h                               |    5 +++++
 plugins/mark-all-read/mark-all-read.c             |    5 ++++-
 shell/e-shell-content.c                           |   13 ++++++++-----
 shell/e-shell-sidebar.c                           |    9 ++++++---
 shell/e-shell-switcher.c                          |    9 ++++++---
 widgets/misc/e-attachment-button.c                |    5 ++++-
 widgets/misc/e-cell-renderer-combo.c              |    5 ++++-
 widgets/misc/e-combo-cell-editable.c              |    2 +-
 widgets/misc/e-dateedit.c                         |    8 ++++----
 widgets/table/e-cell-combo.c                      |    2 +-
 widgets/table/e-cell-date-edit.c                  |    2 +-
 14 files changed, 52 insertions(+), 26 deletions(-)
---
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index d071e9b..4ca2dd6 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -2706,8 +2706,8 @@ init_all (EContactEditor *editor)
 
 	/* with so many scrolled windows, we need to
 	   do some manual sizing */
-	gtk_widget_size_request (
-		e_builder_get_widget (editor->builder, "vbox-size-leader"), &tab_req);
+	gtk_widget_get_preferred_size (
+		e_builder_get_widget (editor->builder, "vbox-size-leader"), &tab_req, NULL);
 	gtk_widget_set_size_request (
 		e_builder_get_widget (editor->builder, "scrolledwindow-size-leader"),
 		tab_req.width, tab_req.height + 8);
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 13ea437..868b411 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -1740,7 +1740,7 @@ e_calendar_view_move_tip (GtkWidget *widget, gint x, gint y)
 
 	screen = gtk_widget_get_screen (widget);
 
-	gtk_widget_size_request (widget, &requisition);
+	gtk_widget_get_preferred_size (widget, &requisition, NULL);
 	w = requisition.width;
 	h = requisition.height;
 
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index 4b2ccfc..8b6f36d 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -46,6 +46,9 @@
 #include "e-meeting-list-view.h"
 #include "e-meeting-time-sel-item.h"
 
+/* backward-compatibility cruft */
+#include "e-util/gtk-compat.h"
+
 #define E_MEETING_TIME_SELECTOR_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), E_TYPE_MEETING_TIME_SELECTOR, EMeetingTimeSelectorPrivate))
@@ -1741,7 +1744,7 @@ e_meeting_time_selector_options_menu_position_callback (GtkMenu *menu,
 	*y += allocation.y + allocation.height - 2;
 
 	/* Now make sure we are on the screen. */
-	gtk_widget_size_request (mts->options_menu, &menu_requisition);
+	gtk_widget_get_preferred_size (mts->options_menu, &menu_requisition, NULL);
 	max_x = MAX (0, gdk_screen_width () - menu_requisition.width);
 	max_y = MAX (0, gdk_screen_height () - menu_requisition.height);
 	*x = CLAMP (*x, 0, max_x);
@@ -1794,7 +1797,7 @@ e_meeting_time_selector_autopick_menu_position_callback (GtkMenu *menu,
 	*y += allocation.y + allocation.height - 2;
 
 	/* Now make sure we are on the screen. */
-	gtk_widget_size_request (mts->autopick_menu, &menu_requisition);
+	gtk_widget_get_preferred_size (mts->autopick_menu, &menu_requisition, NULL);
 	max_x = MAX (0, gdk_screen_width () - menu_requisition.width);
 	max_y = MAX (0, gdk_screen_height () - menu_requisition.height);
 	*x = CLAMP (*x, 0, max_x);
diff --git a/e-util/gtk-compat.h b/e-util/gtk-compat.h
index bbee371..f67a9e2 100644
--- a/e-util/gtk-compat.h
+++ b/e-util/gtk-compat.h
@@ -5,6 +5,11 @@
 
 /* Provide a GTK+ compatibility layer. */
 
+#if !GTK_CHECK_VERSION (2,91,0)  /* approximately  */
+#define gtk_widget_get_preferred_size(widget, minimum_size, natural_size) \
+	(gtk_widget_size_request ((widget), ((minimum_size))))
+#endif
+
 #if !GTK_CHECK_VERSION (2,23,0)
 #define gtk_combo_box_text_new			gtk_combo_box_new_text
 #define gtk_combo_box_text_append_text		gtk_combo_box_append_text
diff --git a/plugins/mark-all-read/mark-all-read.c b/plugins/mark-all-read/mark-all-read.c
index 62b8102..6e527d6 100644
--- a/plugins/mark-all-read/mark-all-read.c
+++ b/plugins/mark-all-read/mark-all-read.c
@@ -38,6 +38,9 @@
 #include <shell/e-shell-view.h>
 #include <shell/e-shell-window.h>
 
+/* backward-compatibility cruft */
+#include "e-util/gtk-compat.h"
+
 #define PRIMARY_TEXT \
 	N_("Also mark messages in subfolders?")
 #define SECONDARY_TEXT \
@@ -79,7 +82,7 @@ box_mapped_cb (GtkWidget *box,
 	/* In order to get decent line wrapping we need to wait until the
 	 * box containing the buttons is mapped, and then resize the label
 	 * to the same width as the box. */
-	gtk_widget_size_request (box, &requisition);
+	gtk_widget_get_preferred_size (box, &requisition, NULL);
 	gtk_widget_set_size_request (label, requisition.width, -1);
 }
 
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
index 62cfdd4..a97c095 100644
--- a/shell/e-shell-content.c
+++ b/shell/e-shell-content.c
@@ -44,6 +44,9 @@
 #include "e-shell-view.h"
 #include "e-shell-window-actions.h"
 
+/* backward-compatibility cruft */
+#include "e-util/gtk-compat.h"
+
 #define E_SHELL_CONTENT_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), E_TYPE_SHELL_CONTENT, EShellContentPrivate))
@@ -226,16 +229,16 @@ shell_content_size_request (GtkWidget *widget,
 	requisition->height = 0;
 
 	child = gtk_bin_get_child (GTK_BIN (widget));
-	gtk_widget_size_request (child, requisition);
+	gtk_widget_get_preferred_size (child, requisition, NULL);
 
-	gtk_widget_size_request (priv->alert_bar, &child_requisition);
+	gtk_widget_get_preferred_size (priv->alert_bar, &child_requisition, NULL);
 	requisition->width = MAX (requisition->width, child_requisition.width);
 	requisition->height += child_requisition.height;
 
 	if (priv->searchbar == NULL)
 		return;
 
-	gtk_widget_size_request (priv->searchbar, &child_requisition);
+	gtk_widget_get_preferred_size (priv->searchbar, &child_requisition, NULL);
 	requisition->width = MAX (requisition->width, child_requisition.width);
 	requisition->height += child_requisition.height;
 }
@@ -267,7 +270,7 @@ shell_content_size_allocate (GtkWidget *widget,
 	child_allocation.y += child_requisition.height;
 
 	if (gtk_widget_get_visible (child))
-		gtk_widget_size_request (child, &child_requisition);
+		gtk_widget_get_preferred_size (child, &child_requisition, NULL);
 	else
 		child_requisition.height = 0;
 
@@ -282,7 +285,7 @@ shell_content_size_allocate (GtkWidget *widget,
 	child_allocation.y += child_requisition.height;
 
 	if (child != NULL)
-		gtk_widget_size_request (child, &child_requisition);
+		gtk_widget_get_preferred_size (child, &child_requisition, NULL);
 	else
 		child_requisition.height = 0;
 
diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c
index a7cb28e..e460d30 100644
--- a/shell/e-shell-sidebar.c
+++ b/shell/e-shell-sidebar.c
@@ -31,6 +31,9 @@
 #include <e-util/e-unicode.h>
 #include <shell/e-shell-view.h>
 
+/* backward-compatibility cruft */
+#include "e-util/gtk-compat.h"
+
 #define E_SHELL_SIDEBAR_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), E_TYPE_SHELL_SIDEBAR, EShellSidebarPrivate))
@@ -233,10 +236,10 @@ shell_sidebar_size_request (GtkWidget *widget,
 	requisition->height = 0;
 
 	child = gtk_bin_get_child (GTK_BIN (widget));
-	gtk_widget_size_request (child, requisition);
+	gtk_widget_get_preferred_size (child, requisition, NULL);
 
 	child = priv->event_box;
-	gtk_widget_size_request (child, &child_requisition);
+	gtk_widget_get_preferred_size (child, &child_requisition, NULL);
 	requisition->width = MAX (requisition->width, child_requisition.width);
 	requisition->height += child_requisition.height;
 }
@@ -255,7 +258,7 @@ shell_sidebar_size_allocate (GtkWidget *widget,
 	gtk_widget_set_allocation (widget, allocation);
 
 	child = priv->event_box;
-	gtk_widget_size_request (child, &child_requisition);
+	gtk_widget_get_preferred_size (child, &child_requisition, NULL);
 
 	child_allocation.x = allocation->x;
 	child_allocation.y = allocation->y;
diff --git a/shell/e-shell-switcher.c b/shell/e-shell-switcher.c
index fec943c..6dbcc86 100644
--- a/shell/e-shell-switcher.c
+++ b/shell/e-shell-switcher.c
@@ -30,6 +30,9 @@
 #include <glib/gi18n.h>
 #include <e-util/e-extensible.h>
 
+/* backward-compatibility cruft */
+#include "e-util/gtk-compat.h"
+
 #define E_SHELL_SWITCHER_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), E_TYPE_SHELL_SWITCHER, EShellSwitcherPrivate))
@@ -100,7 +103,7 @@ shell_switcher_layout_actions (EShellSwitcher *switcher)
 		GtkWidget *widget = p->data;
 		GtkRequisition requisition;
 
-		gtk_widget_size_request (widget, &requisition);
+		gtk_widget_get_preferred_size (widget, &requisition, NULL);
 		max_height = MAX (max_height, requisition.height);
 		max_width = MAX (max_width, requisition.width);
 	}
@@ -261,7 +264,7 @@ shell_switcher_size_request (GtkWidget *widget,
 
 	child = gtk_bin_get_child (GTK_BIN (widget));
 	if (child != NULL)
-		gtk_widget_size_request (child, requisition);
+		gtk_widget_get_preferred_size (child, requisition, NULL);
 
 	if (!priv->toolbar_visible)
 		return;
@@ -270,7 +273,7 @@ shell_switcher_size_request (GtkWidget *widget,
 		GtkWidget *widget = iter->data;
 		GtkRequisition child_requisition;
 
-		gtk_widget_size_request (widget, &child_requisition);
+		gtk_widget_get_preferred_size (widget, &child_requisition, NULL);
 
 		child_requisition.width += H_PADDING;
 		child_requisition.height += V_PADDING;
diff --git a/widgets/misc/e-attachment-button.c b/widgets/misc/e-attachment-button.c
index 77bab88..19af142 100644
--- a/widgets/misc/e-attachment-button.c
+++ b/widgets/misc/e-attachment-button.c
@@ -23,6 +23,9 @@
 
 #include "e-attachment-button.h"
 
+/* backward-compatibility cruft */
+#include "e-util/gtk-compat.h"
+
 #define E_ATTACHMENT_BUTTON_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), E_TYPE_ATTACHMENT_BUTTON, EAttachmentButtonPrivate))
@@ -93,7 +96,7 @@ attachment_button_menu_position (GtkMenu *menu,
 
 	widget = GTK_WIDGET (button);
 	toggle_button = button->priv->toggle_button;
-	gtk_widget_size_request (GTK_WIDGET (menu), &menu_requisition);
+	gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_requisition, NULL);
 
 	window = gtk_widget_get_parent_window (widget);
 	screen = gtk_widget_get_screen (GTK_WIDGET (menu));
diff --git a/widgets/misc/e-cell-renderer-combo.c b/widgets/misc/e-cell-renderer-combo.c
index a2b65b2..03156f1 100644
--- a/widgets/misc/e-cell-renderer-combo.c
+++ b/widgets/misc/e-cell-renderer-combo.c
@@ -27,6 +27,9 @@
 #include "e-combo-cell-editable.h"
 #include "e-cell-renderer-combo.h"
 
+/* backward-compatibility cruft */
+#include "e-util/gtk-compat.h"
+
 enum {
 	PROP_0,
 	PROP_LIST
@@ -102,7 +105,7 @@ ecrc_get_size (GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *cell_area
 
 	btn = gtk_button_new ();
 	gtk_container_add (GTK_CONTAINER (btn), gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE));
-	gtk_widget_size_request (btn, &req);
+	gtk_widget_get_preferred_size (btn, &req, NULL);
 	*width += req.width;
 	gtk_widget_destroy (btn);
 }
diff --git a/widgets/misc/e-combo-cell-editable.c b/widgets/misc/e-combo-cell-editable.c
index aa51463..613fc7b 100644
--- a/widgets/misc/e-combo-cell-editable.c
+++ b/widgets/misc/e-combo-cell-editable.c
@@ -215,7 +215,7 @@ position_popup (EComboCellEditable *ecce, gint x, gint y, gint offset)
 	GtkRequisition req;
 
 	gtk_widget_realize (ecce->priv->popup);
-	gtk_widget_size_request (ecce->priv->popup, &req);
+	gtk_widget_get_preferred_size (ecce->priv->popup, &req, NULL);
 
 	if (req.height > gdk_screen_height () - y) {
 		y -= (offset + req.height);
diff --git a/widgets/misc/e-dateedit.c b/widgets/misc/e-dateedit.c
index d0b9b7e..098825a 100644
--- a/widgets/misc/e-dateedit.c
+++ b/widgets/misc/e-dateedit.c
@@ -1411,12 +1411,12 @@ position_date_popup		(EDateEdit	*dedit)
 	GtkRequisition cal_req, button_req;
 	gint screen_width, screen_height;
 
-	gtk_widget_size_request (dedit->priv->cal_popup, &cal_req);
+	gtk_widget_get_preferred_size (dedit->priv->cal_popup, &cal_req, NULL);
 
-	gtk_widget_size_request (dedit->priv->date_button, &button_req);
+	gtk_widget_get_preferred_size (dedit->priv->date_button, &button_req, NULL);
 	bwidth = button_req.width;
-	gtk_widget_size_request (
-		gtk_widget_get_parent (dedit->priv->date_button), &button_req);
+	gtk_widget_get_preferred_size (
+		gtk_widget_get_parent (dedit->priv->date_button), &button_req, NULL);
 	bheight = button_req.height;
 
 	gtk_widget_translate_coordinates (
diff --git a/widgets/table/e-cell-combo.c b/widgets/table/e-cell-combo.c
index d4ba4f3..6e1eb5c 100644
--- a/widgets/table/e-cell-combo.c
+++ b/widgets/table/e-cell-combo.c
@@ -447,7 +447,7 @@ e_cell_combo_get_popup_pos		(ECellCombo	*ecc,
 	widget = gtk_scrolled_window_get_vscrollbar (popup);
 	gtk_widget_get_child_requisition (widget, &requisition);
 
-	gtk_widget_size_request (ecc->popup_tree_view, &list_requisition);
+	gtk_widget_get_preferred_size (ecc->popup_tree_view, &list_requisition, NULL);
 	min_height = MIN (list_requisition.height, requisition.height);
 	if (!gtk_tree_model_iter_n_children (gtk_tree_view_get_model (GTK_TREE_VIEW (ecc->popup_tree_view)), NULL))
 		list_requisition.height += E_CELL_COMBO_LIST_EMPTY_HEIGHT;
diff --git a/widgets/table/e-cell-date-edit.c b/widgets/table/e-cell-date-edit.c
index 73a5d94..005f7a6 100644
--- a/widgets/table/e-cell-date-edit.c
+++ b/widgets/table/e-cell-date-edit.c
@@ -688,7 +688,7 @@ e_cell_date_edit_get_popup_pos		(ECellDateEdit	*ecde,
 	   the vertical scrollbar in case we need to show that. */
 	screen_width = gdk_screen_width ();
 
-	gtk_widget_size_request (ecde->popup_window, &popup_requisition);
+	gtk_widget_get_preferred_size (ecde->popup_window, &popup_requisition, NULL);
 
 	/* Calculate the desired width. */
 	*width = popup_requisition.width;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]