[evolution/gtk3] Replace size_request vfunc with get_preferred_height/width
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gtk3] Replace size_request vfunc with get_preferred_height/width
- Date: Fri, 10 Dec 2010 12:35:26 +0000 (UTC)
commit 6f609d80594e3e294483e5d539239d85c99b87f2
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Fri Dec 10 13:34:10 2010 +0100
Replace size_request vfunc with get_preferred_height/width
widgets/misc/e-map.c | 27 ++++++++++++++++++++++++++-
widgets/misc/e-menu-tool-button.c | 27 +++++++++++++++++++--------
2 files changed, 45 insertions(+), 9 deletions(-)
---
diff --git a/widgets/misc/e-map.c b/widgets/misc/e-map.c
index b18b608..58200e8 100644
--- a/widgets/misc/e-map.c
+++ b/widgets/misc/e-map.c
@@ -464,6 +464,30 @@ e_map_size_request (GtkWidget *widget, GtkRequisition *requisition)
}
static void
+e_map_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ GtkRequisition requisition;
+
+ e_map_size_request (widget, &requisition);
+
+ *minimal_height = *natural_height = requisition.height;
+}
+
+static void
+e_map_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ GtkRequisition requisition;
+
+ e_map_size_request (widget, &requisition);
+
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void
e_map_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
EMap *map;
@@ -609,7 +633,8 @@ e_map_class_init (EMapClass *class)
widget_class = GTK_WIDGET_CLASS (class);
widget_class->realize = e_map_realize;
widget_class->unrealize = e_map_unrealize;
- widget_class->size_request = e_map_size_request;
+ widget_class->get_preferred_height = e_map_get_preferred_height;
+ widget_class->get_preferred_width = e_map_get_preferred_width;
widget_class->size_allocate = e_map_size_allocate;
widget_class->draw = e_map_draw;
widget_class->button_press_event = e_map_button_press;
diff --git a/widgets/misc/e-menu-tool-button.c b/widgets/misc/e-menu-tool-button.c
index 612ed80..628fdea 100644
--- a/widgets/misc/e-menu-tool-button.c
+++ b/widgets/misc/e-menu-tool-button.c
@@ -100,14 +100,23 @@ menu_tool_button_update_button (GtkToolButton *tool_button)
}
static void
-menu_tool_button_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+menu_tool_button_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
{
- gint minimum_width;
+ GTK_WIDGET_CLASS (e_menu_tool_button_parent_class)->
+ get_preferred_height (widget, minimal_height, natural_height);
+}
+
+static void
+menu_tool_button_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ gint minimum_width, min_height, nat_height;
- /* Chain up to parent's size_request() method. */
GTK_WIDGET_CLASS (e_menu_tool_button_parent_class)->
- size_request (widget, requisition);
+ get_preferred_width (widget, minimal_width, natural_width);
/* XXX This is a hack. This widget is only used for the New
* button in the main window toolbar. The New button is
@@ -117,8 +126,9 @@ menu_tool_button_size_request (GtkWidget *widget,
*
* We can't go hard-coding a width, but we -can- use a
* heuristic based on the toolbar button height. */
- minimum_width = requisition->height * 2;
- requisition->width = MAX (minimum_width, requisition->width);
+ menu_tool_button_get_preferred_height (widget, &min_height, &nat_height);
+ minimum_width = min_height * 2;
+ *minimal_width = *natural_width = MAX (minimum_width, *minimal_width);
}
static void
@@ -141,7 +151,8 @@ e_menu_tool_button_class_init (EMenuToolButtonClass *class)
GtkToolButtonClass *tool_button_class;
widget_class = GTK_WIDGET_CLASS (class);
- widget_class->size_request = menu_tool_button_size_request;
+ widget_class->get_preferred_height = menu_tool_button_get_preferred_height;
+ widget_class->get_preferred_width = menu_tool_button_get_preferred_width;
tool_button_class = GTK_TOOL_BUTTON_CLASS (class);
tool_button_class->clicked = menu_tool_button_clicked;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]