diff options
author | Rodrigo Moya <rodrigo@gnome-db.org> | 2010-12-10 20:15:27 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:41:26 +0800 |
commit | b5aba428f4d7daca78a6b079e1766d9fba5a8bc3 (patch) | |
tree | c8cd9400a62f2cf2b3ba84bd6e6b01774f2b3085 /widgets | |
parent | cd633936b1f2f2e8c678dfb4e3e38ba9713e41a4 (diff) | |
download | gsoc2013-evolution-b5aba428f4d7daca78a6b079e1766d9fba5a8bc3.tar gsoc2013-evolution-b5aba428f4d7daca78a6b079e1766d9fba5a8bc3.tar.gz gsoc2013-evolution-b5aba428f4d7daca78a6b079e1766d9fba5a8bc3.tar.bz2 gsoc2013-evolution-b5aba428f4d7daca78a6b079e1766d9fba5a8bc3.tar.lz gsoc2013-evolution-b5aba428f4d7daca78a6b079e1766d9fba5a8bc3.tar.xz gsoc2013-evolution-b5aba428f4d7daca78a6b079e1766d9fba5a8bc3.tar.zst gsoc2013-evolution-b5aba428f4d7daca78a6b079e1766d9fba5a8bc3.zip |
Adapt size_request vfuncs to latest gtk+-3.0 API.
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/e-calendar.c | 44 | ||||
-rw-r--r-- | widgets/misc/e-map.c | 26 | ||||
-rw-r--r-- | widgets/misc/e-menu-tool-button.c | 27 | ||||
-rw-r--r-- | widgets/table/e-table.c | 20 |
4 files changed, 84 insertions, 33 deletions
diff --git a/widgets/misc/e-calendar.c b/widgets/misc/e-calendar.c index d835ba89ae..c21a6a4547 100644 --- a/widgets/misc/e-calendar.c +++ b/widgets/misc/e-calendar.c @@ -69,8 +69,12 @@ static void e_calendar_dispose (GObject *object); static void e_calendar_realize (GtkWidget *widget); static void e_calendar_style_set (GtkWidget *widget, GtkStyle *previous_style); -static void e_calendar_size_request (GtkWidget *widget, - GtkRequisition *requisition); +static void e_calendar_get_preferred_width (GtkWidget *widget, + gint *minimal_width, + gint *natural_width); +static void e_calendar_get_preferred_height (GtkWidget *widget, + gint *minimal_height, + gint *natural_height); static void e_calendar_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static gint e_calendar_drag_motion (GtkWidget *widget, @@ -115,7 +119,8 @@ e_calendar_class_init (ECalendarClass *class) widget_class->realize = e_calendar_realize; widget_class->style_set = e_calendar_style_set; - widget_class->size_request = e_calendar_size_request; + widget_class->get_preferred_width = e_calendar_get_preferred_width; + widget_class->get_preferred_height = e_calendar_get_preferred_height; widget_class->size_allocate = e_calendar_size_allocate; widget_class->drag_motion = e_calendar_drag_motion; widget_class->drag_leave = e_calendar_drag_leave; @@ -281,26 +286,37 @@ e_calendar_style_set (GtkWidget *widget, } static void -e_calendar_size_request (GtkWidget *widget, - GtkRequisition *requisition) +e_calendar_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural) { ECalendar *cal; GtkStyle *style; - gint col_width, row_height, width, height; + gint col_width; cal = E_CALENDAR (widget); style = gtk_widget_get_style (GTK_WIDGET (cal)); - g_object_get ((cal->calitem), - "row_height", &row_height, - "column_width", &col_width, - NULL); + g_object_get ((cal->calitem), "column_width", &col_width, NULL); - height = row_height * cal->min_rows; - width = col_width * cal->min_cols; + *minimum = *natural = col_width * cal->min_cols + style->xthickness * 2; +} + +static void +e_calendar_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + ECalendar *cal; + GtkStyle *style; + gint row_height; + + cal = E_CALENDAR (widget); + style = gtk_widget_get_style (GTK_WIDGET (cal)); + + g_object_get ((cal->calitem), "row_height", &row_height, NULL); - requisition->width = width + style->xthickness * 2; - requisition->height = height + style->ythickness * 2; + *minimum = *natural = row_height * cal->min_rows + style->ythickness * 2; } static void diff --git a/widgets/misc/e-map.c b/widgets/misc/e-map.c index 89ca22b76a..842d396c7e 100644 --- a/widgets/misc/e-map.c +++ b/widgets/misc/e-map.c @@ -388,20 +388,35 @@ e_map_unrealize (GtkWidget *widget) } static void -e_map_size_request (GtkWidget *widget, GtkRequisition *requisition) +e_map_get_preferred_width (GtkWidget *widget, gint *minimum, gint *natural) { EMap *map; g_return_if_fail (widget != NULL); g_return_if_fail (E_IS_MAP (widget)); - g_return_if_fail (requisition != NULL); map = E_MAP (widget); /* TODO: Put real sizes here. */ - requisition->width = gdk_pixbuf_get_width (map->priv->map_pixbuf); - requisition->height = gdk_pixbuf_get_height (map->priv->map_pixbuf); + *minimum = *natural = gdk_pixbuf_get_width (map->priv->map_pixbuf); +} + +static void +e_map_get_preferred_height (GtkWidget *widget, gint *minimum, gint *natural) +{ + EMap *view; + EMapPrivate *priv; + + g_return_if_fail (widget != NULL); + g_return_if_fail (E_IS_MAP (widget)); + + view = E_MAP (widget); + priv = view->priv; + + /* TODO: Put real sizes here. */ + + *minimum = *natural = gdk_pixbuf_get_height (priv->map_pixbuf); } static void @@ -621,7 +636,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->button_press_event = e_map_button_press; widget_class->button_release_event = e_map_button_release; diff --git a/widgets/misc/e-menu-tool-button.c b/widgets/misc/e-menu-tool-button.c index 612ed801f2..628fdea55d 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; diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index d21137ef04..6a4d276e1b 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -226,13 +226,20 @@ current_search_col (ETable *et) } static void -et_size_request (GtkWidget *widget, GtkRequisition *request) +et_get_preferred_width (GtkWidget *widget, gint *minimum, gint *natural) { ETable *et = E_TABLE (widget); - if (GTK_WIDGET_CLASS (e_table_parent_class)->size_request) - GTK_WIDGET_CLASS (e_table_parent_class)->size_request (widget, request); - if (et->horizontal_resize) - request->width = MAX (request->width, et->header_width); + GTK_WIDGET_CLASS (e_table_parent_class)->get_preferred_width (widget, minimum, natural); + if (et->horizontal_resize) { + *minimum = MAX (*minimum, et->header_width); + *natural = MAX (*natural, et->header_width); + } +} + +static void +et_get_preferred_height (GtkWidget *widget, gint *minimum, gint *natural) +{ + GTK_WIDGET_CLASS (e_table_parent_class)->get_preferred_height (widget, minimum, natural); } static void @@ -3239,7 +3246,8 @@ e_table_class_init (ETableClass *class) widget_class->grab_focus = et_grab_focus; widget_class->unrealize = et_unrealize; - widget_class->size_request = et_size_request; + widget_class->get_preferred_width = et_get_preferred_width; + widget_class->get_preferred_height = et_get_preferred_height; widget_class->focus = et_focus; |