From a6d296b998729abc78e634844cc4a3aeda7d0327 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 12 Jan 2010 17:54:29 -0500 Subject: Baby steps toward GSEAL compliance. --- widgets/misc/e-attachment-button.c | 23 +-- widgets/misc/e-calendar-item.c | 36 +++-- widgets/misc/e-calendar.c | 6 +- widgets/misc/e-canvas-background.c | 11 +- widgets/misc/e-canvas-utils.c | 40 ++++- widgets/misc/e-canvas.c | 18 ++- widgets/misc/e-cell-renderer-combo.c | 12 +- widgets/misc/e-combo-cell-editable.c | 19 ++- widgets/misc/e-dateedit.c | 107 ++++++++----- widgets/misc/e-map.c | 293 ++++++++++++++++++++++------------- widgets/misc/e-map.h | 11 +- widgets/misc/e-menu-tool-button.c | 2 +- widgets/misc/e-paned.c | 12 +- widgets/misc/e-send-options.c | 16 +- widgets/misc/e-spinner.c | 22 ++- widgets/misc/ea-calendar-item.c | 2 +- 16 files changed, 397 insertions(+), 233 deletions(-) (limited to 'widgets/misc') diff --git a/widgets/misc/e-attachment-button.c b/widgets/misc/e-attachment-button.c index adf40d4df4..192344068b 100644 --- a/widgets/misc/e-attachment-button.c +++ b/widgets/misc/e-attachment-button.c @@ -81,6 +81,7 @@ attachment_button_menu_position (GtkMenu *menu, { GtkRequisition menu_requisition; GtkTextDirection direction; + GtkAllocation allocation; GdkRectangle monitor; GdkScreen *screen; GdkWindow *window; @@ -99,24 +100,28 @@ attachment_button_menu_position (GtkMenu *menu, monitor_num = 0; gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); + gtk_widget_get_allocation (widget, &allocation); + gdk_window_get_origin (window, x, y); - *x += widget->allocation.x; - *y += widget->allocation.y; + *x += allocation.x; + *y += allocation.y; direction = gtk_widget_get_direction (widget); if (direction == GTK_TEXT_DIR_LTR) - *x += MAX (widget->allocation.width - menu_requisition.width, 0); - else if (menu_requisition.width > widget->allocation.width) - *x -= menu_requisition.width - widget->allocation.width; + *x += MAX (allocation.width - menu_requisition.width, 0); + else if (menu_requisition.width > allocation.width) + *x -= menu_requisition.width - allocation.width; + + gtk_widget_get_allocation (toggle_button, &allocation); - if ((*y + toggle_button->allocation.height + + if ((*y + allocation.height + menu_requisition.height) <= monitor.y + monitor.height) - *y += toggle_button->allocation.height; + *y += allocation.height; else if ((*y - menu_requisition.height) >= monitor.y) *y -= menu_requisition.height; else if (monitor.y + monitor.height - - (*y + toggle_button->allocation.height) > *y) - *y += toggle_button->allocation.height; + (*y + allocation.height) > *y) + *y += allocation.height; else *y -= menu_requisition.height; diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c index 742dd763a8..6f54327033 100644 --- a/widgets/misc/e-calendar-item.c +++ b/widgets/misc/e-calendar-item.c @@ -898,7 +898,7 @@ e_calendar_item_update (GnomeCanvasItem *item, item_class->update (item, affine, clip_path, flags); calitem = E_CALENDAR_ITEM (item); - style = GTK_WIDGET (item->canvas)->style; + style = gtk_widget_get_style (GTK_WIDGET (item->canvas)); xthickness = style->xthickness; ythickness = style->ythickness; @@ -1037,7 +1037,7 @@ e_calendar_item_draw (GnomeCanvasItem *canvas_item, x, y, width, height); #endif calitem = E_CALENDAR_ITEM (canvas_item); - style = GTK_WIDGET (canvas_item->canvas)->style; + style = gtk_widget_get_style (GTK_WIDGET (canvas_item->canvas)); /* Set up Pango prerequisites */ font_desc = calitem->font_desc; @@ -1172,7 +1172,7 @@ e_calendar_item_draw_month (ECalendarItem *calitem, #endif item = GNOME_CANVAS_ITEM (calitem); widget = GTK_WIDGET (item->canvas); - style = widget->style; + style = gtk_widget_get_style (widget); cr = gdk_cairo_create (drawable); @@ -1419,7 +1419,7 @@ e_calendar_item_draw_day_numbers (ECalendarItem *calitem, item = GNOME_CANVAS_ITEM (calitem); widget = GTK_WIDGET (item->canvas); - style = widget->style; + style = gtk_widget_get_style (widget); cr = gdk_cairo_create (drawable); @@ -1952,7 +1952,7 @@ e_calendar_item_recalc_sizes (ECalendarItem *calitem) PangoLayout *layout; canvas_item = GNOME_CANVAS_ITEM (calitem); - style = GTK_WIDGET (canvas_item->canvas)->style; + style = gtk_widget_get_style (GTK_WIDGET (canvas_item->canvas)); if (!style) return; @@ -2062,7 +2062,7 @@ e_calendar_item_get_day_style (ECalendarItem *calitem, GtkStyle *style; widget = GTK_WIDGET (GNOME_CANVAS_ITEM (calitem)->canvas); - style = widget->style; + style = gtk_widget_get_style (widget); *bg_color = NULL; *fg_color = NULL; @@ -2075,7 +2075,7 @@ e_calendar_item_get_day_style (ECalendarItem *calitem, *box_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX]; if (prev_or_next_month) - *fg_color = &style->mid[GTK_WIDGET_STATE (widget)]; + *fg_color = &style->mid[gtk_widget_get_state (widget)]; if (selected) { if (has_focus) { @@ -2400,7 +2400,7 @@ e_calendar_item_convert_position_to_day (ECalendarItem *calitem, item = GNOME_CANVAS_ITEM (calitem); widget = GTK_WIDGET (item->canvas); - style = widget->style; + style = gtk_widget_get_style (widget); font_desc = calitem->font_desc; if (!font_desc) @@ -3181,21 +3181,24 @@ e_calendar_item_set_selection_if_emission (ECalendarItem *calitem, void e_calendar_item_style_set (GtkWidget *widget, ECalendarItem *calitem) { + GtkStyle *style; GdkColor *color; - color = &widget->style->bg[GTK_STATE_SELECTED]; + style = gtk_widget_get_style (widget); + + color = &style->bg[GTK_STATE_SELECTED]; calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX] = *color; - color = &widget->style->base[GTK_STATE_NORMAL]; + color = &style->base[GTK_STATE_NORMAL]; calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_FG] = *color; - color = &widget->style->bg[GTK_STATE_SELECTED]; + color = &style->bg[GTK_STATE_SELECTED]; calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG_FOCUSED] = *color; - color = &widget->style->fg[GTK_STATE_INSENSITIVE]; + color = &style->fg[GTK_STATE_INSENSITIVE]; calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG] = *color; - color = &widget->style->fg[GTK_STATE_INSENSITIVE]; + color = &style->fg[GTK_STATE_INSENSITIVE]; calitem->colors[E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG] = *color; } @@ -3376,13 +3379,16 @@ static void e_calendar_item_on_menu_item_activate (GtkWidget *menuitem, ECalendarItem *calitem) { + GtkWidget *parent; gint year, month_offset, month; gpointer data; - data = g_object_get_data (G_OBJECT (menuitem->parent), "year"); + parent = gtk_widget_get_parent (menuitem); + data = g_object_get_data (G_OBJECT (parent), "year"); year = GPOINTER_TO_INT (data); - data = g_object_get_data (G_OBJECT (menuitem->parent), "month_offset"); + parent = gtk_widget_get_parent (menuitem); + data = g_object_get_data (G_OBJECT (parent), "month_offset"); month_offset = GPOINTER_TO_INT (data); data = g_object_get_data (G_OBJECT (menuitem), "month"); diff --git a/widgets/misc/e-calendar.c b/widgets/misc/e-calendar.c index 44e4568656..384d4ce664 100644 --- a/widgets/misc/e-calendar.c +++ b/widgets/misc/e-calendar.c @@ -308,6 +308,7 @@ e_calendar_size_allocate (GtkWidget *widget, { ECalendar *cal; GtkStyle *style; + GtkAllocation old_allocation; PangoFontDescription *font_desc; PangoContext *pango_context; PangoFontMetrics *font_metrics; @@ -330,8 +331,9 @@ e_calendar_size_allocate (GtkWidget *widget, /* Set the scroll region to its allocated size, if changed. */ gnome_canvas_get_scroll_region (GNOME_CANVAS (cal), NULL, NULL, &old_x2, &old_y2); - new_x2 = widget->allocation.width - 1; - new_y2 = widget->allocation.height - 1; + gtk_widget_get_allocation (widget, &old_allocation); + new_x2 = old_allocation.width - 1; + new_y2 = old_allocation.height - 1; if (old_x2 != new_x2 || old_y2 != new_y2) gnome_canvas_set_scroll_region (GNOME_CANVAS (cal), 0, 0, new_x2, new_y2); diff --git a/widgets/misc/e-canvas-background.c b/widgets/misc/e-canvas-background.c index 898fe0628a..f9879c2614 100644 --- a/widgets/misc/e-canvas-background.c +++ b/widgets/misc/e-canvas-background.c @@ -337,11 +337,14 @@ static void ecb_realize (GnomeCanvasItem *item) { ECanvasBackground *ecb = E_CANVAS_BACKGROUND (item); + GdkWindow *bin_window; if (GNOME_CANVAS_ITEM_CLASS (ecb_parent_class)->realize) GNOME_CANVAS_ITEM_CLASS (ecb_parent_class)->realize (item); - ecb->priv->gc = gdk_gc_new (item->canvas->layout.bin_window); + bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (item->canvas)); + + ecb->priv->gc = gdk_gc_new (bin_window); get_color (ecb); if (!item->canvas->aa) gdk_gc_set_foreground (ecb->priv->gc, &ecb->priv->color); @@ -430,11 +433,13 @@ ecb_style_set (ECanvasBackground *ecb, GtkStyle *previous_style) { GnomeCanvasItem *item = GNOME_CANVAS_ITEM (ecb); + GtkStyle *style; + + style = gtk_widget_get_style (GTK_WIDGET (item->canvas)); if (GTK_WIDGET_REALIZED (item->canvas)) { gdk_gc_set_foreground ( - ecb->priv->gc, >K_WIDGET(item->canvas)-> - style->base[GTK_STATE_NORMAL]); + ecb->priv->gc, &style->base[GTK_STATE_NORMAL]); gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (ecb)); } } diff --git a/widgets/misc/e-canvas-utils.c b/widgets/misc/e-canvas-utils.c index e69bb9c980..9e097b02bd 100644 --- a/widgets/misc/e-canvas-utils.c +++ b/widgets/misc/e-canvas-utils.c @@ -68,19 +68,31 @@ e_canvas_show_area (GnomeCanvas *canvas, double x1, double y1, double x2, double { GtkAdjustment *h, *v; gint dx = 0, dy = 0; + gdouble page_size; + gdouble lower; + gdouble upper; + gdouble value; g_return_if_fail (canvas != NULL); g_return_if_fail (GNOME_IS_CANVAS (canvas)); h = gtk_layout_get_hadjustment(GTK_LAYOUT(canvas)); - dx = compute_offset(x1, x2, h->value, h->value + h->page_size); + page_size = gtk_adjustment_get_page_size (h); + lower = gtk_adjustment_get_lower (h); + upper = gtk_adjustment_get_upper (h); + value = gtk_adjustment_get_value (h); + dx = compute_offset(x1, x2, value, value + page_size); if (dx) - gtk_adjustment_set_value(h, CLAMP(h->value + dx, h->lower, h->upper - h->page_size)); + gtk_adjustment_set_value(h, CLAMP(value + dx, lower, upper - page_size)); v = gtk_layout_get_vadjustment(GTK_LAYOUT(canvas)); - dy = compute_offset(y1, y2, v->value, v->value + v->page_size); + page_size = gtk_adjustment_get_page_size (v); + lower = gtk_adjustment_get_lower (v); + upper = gtk_adjustment_get_upper (v); + value = gtk_adjustment_get_value (v); + dy = compute_offset(y1, y2, value, value + page_size); if (dy) - gtk_adjustment_set_value(v, CLAMP(v->value + dy, v->lower, v->upper - v->page_size)); + gtk_adjustment_set_value(v, CLAMP(value + dy, lower, upper - page_size)); } void @@ -100,18 +112,30 @@ e_canvas_area_shown (GnomeCanvas *canvas, double x1, double y1, double x2, doubl { GtkAdjustment *h, *v; gint dx = 0, dy = 0; + gdouble page_size; + gdouble lower; + gdouble upper; + gdouble value; g_return_val_if_fail (canvas != NULL, FALSE); g_return_val_if_fail (GNOME_IS_CANVAS (canvas), FALSE); h = gtk_layout_get_hadjustment(GTK_LAYOUT(canvas)); - dx = compute_offset(x1, x2, h->value, h->value + h->page_size); - if (CLAMP(h->value + dx, h->lower, h->upper - h->page_size) - h->value != 0) + page_size = gtk_adjustment_get_page_size (h); + lower = gtk_adjustment_get_lower (h); + upper = gtk_adjustment_get_upper (h); + value = gtk_adjustment_get_value (h); + dx = compute_offset(x1, x2, value, value + page_size); + if (CLAMP(value + dx, lower, upper - page_size) - value != 0) return FALSE; v = gtk_layout_get_vadjustment(GTK_LAYOUT(canvas)); - dy = compute_offset(y1, y2, v->value, v->value + v->page_size); - if (CLAMP(v->value + dy, v->lower, v->upper - v->page_size) - v->value != 0) + page_size = gtk_adjustment_get_page_size (v); + lower = gtk_adjustment_get_lower (v); + upper = gtk_adjustment_get_upper (v); + value = gtk_adjustment_get_value (v); + dy = compute_offset(y1, y2, value, value + page_size); + if (CLAMP(value + dy, lower, upper - page_size) - value != 0) return FALSE; return TRUE; } diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c index 5f719fed80..f1b7713f43 100644 --- a/widgets/misc/e-canvas.c +++ b/widgets/misc/e-canvas.c @@ -458,6 +458,7 @@ static gint e_canvas_button (GtkWidget *widget, GdkEventButton *event) { GnomeCanvas *canvas; + GdkWindow *bin_window; gint mask; gint retval; @@ -468,6 +469,7 @@ e_canvas_button (GtkWidget *widget, GdkEventButton *event) retval = FALSE; canvas = GNOME_CANVAS (widget); + bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (canvas)); d(g_print ("button %d, event type %d, grabbed=%p, current=%p\n", event->button, @@ -477,7 +479,7 @@ e_canvas_button (GtkWidget *widget, GdkEventButton *event) /* dispatch normally regardless of the event's window if an item has has a pointer grab in effect */ - if (!canvas->grabbed_item && event->window != canvas->layout.bin_window) + if (!canvas->grabbed_item && event->window != bin_window) return retval; switch (event->button) { @@ -557,17 +559,20 @@ void e_canvas_item_grab_focus (GnomeCanvasItem *item, gboolean widget_too) { GnomeCanvasItem *focused_item; + GdkWindow *bin_window; GdkEvent ev; g_return_if_fail (item != NULL); g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); g_return_if_fail (gtk_widget_get_can_focus (GTK_WIDGET (item->canvas))); + bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (item->canvas)); + focused_item = item->canvas->focused_item; if (focused_item) { ev.focus_change.type = GDK_FOCUS_CHANGE; - ev.focus_change.window = GTK_LAYOUT (item->canvas)->bin_window; + ev.focus_change.window = bin_window; ev.focus_change.send_event = FALSE; ev.focus_change.in = FALSE; @@ -582,7 +587,7 @@ e_canvas_item_grab_focus (GnomeCanvasItem *item, gboolean widget_too) if (item) { ev.focus_change.type = GDK_FOCUS_CHANGE; - ev.focus_change.window = GTK_LAYOUT (item->canvas)->bin_window; + ev.focus_change.window = bin_window; ev.focus_change.send_event = FALSE; ev.focus_change.in = TRUE; @@ -665,13 +670,16 @@ static void e_canvas_realize (GtkWidget *widget) { ECanvas *ecanvas = E_CANVAS (widget); + GdkWindow *window; if (GTK_WIDGET_CLASS (e_canvas_parent_class)->realize) (* GTK_WIDGET_CLASS (e_canvas_parent_class)->realize) (widget); - gdk_window_set_back_pixmap (GTK_LAYOUT (widget)->bin_window, NULL, FALSE); + window = gtk_layout_get_bin_window (GTK_LAYOUT (widget)); + gdk_window_set_back_pixmap (window, NULL, FALSE); - gtk_im_context_set_client_window (ecanvas->im_context, widget->window); + window = gtk_widget_get_window (widget); + gtk_im_context_set_client_window (ecanvas->im_context, window); } static void diff --git a/widgets/misc/e-cell-renderer-combo.c b/widgets/misc/e-cell-renderer-combo.c index ab03c73f2b..96079032fe 100644 --- a/widgets/misc/e-cell-renderer-combo.c +++ b/widgets/misc/e-cell-renderer-combo.c @@ -62,15 +62,23 @@ ecrc_start_editing (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, c ECellRendererCombo *combo_cell = E_CELL_RENDERER_COMBO (cell); GtkCellRendererText *text_cell = GTK_CELL_RENDERER_TEXT (cell); EComboCellEditable *editable; + gboolean is_editable; + gchar *text; - if (!text_cell->editable) + g_object_get (text_cell, "editable", &is_editable, NULL); + + if (!is_editable) return NULL; + g_object_get (text_cell, "text", &text, NULL); + editable = E_COMBO_CELL_EDITABLE (e_combo_cell_editable_new ()); - e_combo_cell_editable_set_text (editable, text_cell->text); + e_combo_cell_editable_set_text (editable, text); e_combo_cell_editable_set_list (editable, combo_cell->priv->list); gtk_widget_show (GTK_WIDGET (editable)); + g_free (text); + g_signal_connect (editable, "editing-done", G_CALLBACK (ecrc_editing_done), combo_cell); combo_cell->priv->editable = g_object_ref (editable); diff --git a/widgets/misc/e-combo-cell-editable.c b/widgets/misc/e-combo-cell-editable.c index 3d3c777986..98cd0b17c5 100644 --- a/widgets/misc/e-combo-cell-editable.c +++ b/widgets/misc/e-combo-cell-editable.c @@ -73,14 +73,16 @@ static gboolean popup_button_press_cb (GtkWidget *widget, GdkEventButton *event, EComboCellEditable *ecce) { GtkAllocation alloc; + GdkWindow *window; gdouble rel_x, rel_y; gint win_x, win_y; if (event->button != 1) return FALSE; - gdk_window_get_root_origin (widget->window, &win_x, &win_y); - alloc = ecce->priv->popup->allocation; + window = gtk_widget_get_window (widget); + gdk_window_get_root_origin (window, &win_x, &win_y); + gtk_widget_get_allocation (ecce->priv->popup, &alloc); rel_x = event->x_root - win_x - alloc.x; rel_y = event->y_root - win_y - alloc.y; @@ -217,6 +219,7 @@ show_popup (EComboCellEditable *ecce) { gint row; GtkAllocation alloc; + GdkWindow *window; gint x, y; if (!ecce->priv->list) @@ -227,14 +230,18 @@ show_popup (EComboCellEditable *ecce) set_cursor (ecce->priv->tree_view, row); gtk_editable_select_region (GTK_EDITABLE (ecce->priv->entry), 0, 0); - gdk_window_get_origin (GTK_WIDGET (ecce)->window, &x, &y); - alloc = GTK_WIDGET (ecce)->allocation; + + window = gtk_widget_get_window (GTK_WIDGET (ecce)); + gtk_widget_get_allocation (GTK_WIDGET (ecce), &alloc); + gdk_window_get_origin (window, &x, &y); position_popup (ecce, x, y + alloc.height, alloc.height); - gtk_grab_add (GTK_WIDGET (ecce->priv->popup)); + gtk_grab_add (ecce->priv->popup); gtk_widget_grab_focus (GTK_WIDGET (ecce->priv->tree_view)); - grab_popup (GTK_WIDGET (ecce->priv->popup)->window); + + window = gtk_widget_get_window (ecce->priv->popup); + grab_popup (window); } static void diff --git a/widgets/misc/e-dateedit.c b/widgets/misc/e-dateedit.c index a16bcefaf8..acc4cb353d 100644 --- a/widgets/misc/e-dateedit.c +++ b/widgets/misc/e-dateedit.c @@ -532,6 +532,7 @@ create_children (EDateEdit *dedit) ECalendar *calendar; GtkWidget *frame, *arrow; GtkWidget *vbox, *bbox; + GtkWidget *child; AtkObject *a11y; GtkListStore *time_store; GList *cells; @@ -590,11 +591,13 @@ create_children (EDateEdit *dedit) GTK_TREE_MODEL (time_store), 0); g_object_unref (time_store); + child = gtk_bin_get_child (GTK_BIN (priv->time_combo)); + /* We need to make sure labels are right-aligned, since we want * digits to line up, and with a nonproportional font, the width * of a space != width of a digit. Technically, only 12-hour * format needs this, but we do it always, for consistency. */ - g_object_set (GTK_BIN (priv->time_combo)->child, "xalign", 1.0, NULL); + g_object_set (child, "xalign", 1.0, NULL); cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (priv->time_combo)); if (cells) { g_object_set (GTK_CELL_RENDERER (cells->data), "xalign", 1.0, NULL); @@ -609,22 +612,18 @@ create_children (EDateEdit *dedit) atk_object_set_description (a11y, _("Drop-down combination box to select time")); atk_object_set_name (a11y, _("Time")); - g_signal_connect (GTK_BIN (priv->time_combo)->child, - "key_press_event", - G_CALLBACK (on_time_entry_key_press), - dedit); - g_signal_connect (GTK_BIN (priv->time_combo)->child, - "key_release_event", - G_CALLBACK (on_time_entry_key_release), - dedit); - g_signal_connect_after (GTK_BIN (priv->time_combo)->child, - "focus_out_event", - G_CALLBACK (on_time_entry_focus_out), - dedit); - g_signal_connect_after (priv->time_combo, - "changed", - G_CALLBACK (on_date_edit_time_selected), - dedit); + g_signal_connect ( + child, "key_press_event", + G_CALLBACK (on_time_entry_key_press), dedit); + g_signal_connect ( + child, "key_release_event", + G_CALLBACK (on_time_entry_key_release), dedit); + g_signal_connect_after ( + child, "focus_out_event", + G_CALLBACK (on_time_entry_focus_out), dedit); + g_signal_connect_after ( + priv->time_combo, "changed", + G_CALLBACK (on_date_edit_time_selected), dedit); if (priv->show_time || priv->make_time_insensitive) gtk_widget_show (priv->time_combo); @@ -719,15 +718,17 @@ static void e_date_edit_grab_focus (GtkWidget *widget) { EDateEdit *dedit; + GtkWidget *child; g_return_if_fail (E_IS_DATE_EDIT (widget)); dedit = E_DATE_EDIT (widget); + child = gtk_bin_get_child (GTK_BIN (dedit->priv->time_combo)); if (dedit->priv->show_date) gtk_widget_grab_focus (dedit->priv->date_entry); else - gtk_widget_grab_focus (GTK_BIN (dedit->priv->time_combo)->child); + gtk_widget_grab_focus (child); } /** @@ -1359,6 +1360,7 @@ e_date_edit_show_date_popup (EDateEdit *dedit) { EDateEditPrivate *priv; ECalendar *calendar; + GdkWindow *window; struct tm mtm; const gchar *date_text; GDate selected_day; @@ -1386,17 +1388,20 @@ e_date_edit_show_date_popup (EDateEdit *dedit) emissions. */ calendar->calitem->selection_changed = FALSE; - position_date_popup (dedit); + position_date_popup (dedit); gtk_widget_show (priv->cal_popup); gtk_widget_grab_focus (priv->cal_popup); gtk_grab_add (priv->cal_popup); - gdk_pointer_grab (priv->cal_popup->window, TRUE, - (GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_POINTER_MOTION_MASK), - NULL, NULL, GDK_CURRENT_TIME); - gdk_keyboard_grab (priv->cal_popup->window, TRUE, GDK_CURRENT_TIME); - gdk_window_focus (priv->cal_popup->window, GDK_CURRENT_TIME); + + window = gtk_widget_get_window (priv->cal_popup); + gdk_pointer_grab ( + window, TRUE, + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK, + NULL, NULL, GDK_CURRENT_TIME); + gdk_keyboard_grab (window, TRUE, GDK_CURRENT_TIME); + gdk_window_focus (window, GDK_CURRENT_TIME); } /* This positions the date popup below and to the left of the arrow button, @@ -1407,6 +1412,8 @@ position_date_popup (EDateEdit *dedit) gint x, y; gint win_x, win_y; gint bwidth, bheight; + GtkWidget *toplevel; + GdkWindow *window; GtkRequisition cal_req, button_req; gint screen_width, screen_height; @@ -1423,9 +1430,9 @@ position_date_popup (EDateEdit *dedit) gtk_widget_get_toplevel (dedit->priv->date_button), bwidth - cal_req.width, bheight, &x, &y); - gdk_window_get_origin ( - gtk_widget_get_toplevel (dedit->priv->date_button)->window, - &win_x, &win_y); + toplevel = gtk_widget_get_toplevel (dedit->priv->date_button); + window = gtk_widget_get_window (toplevel); + gdk_window_get_origin (window, &win_x, &win_y); x += win_x; y += win_y; @@ -1503,8 +1510,12 @@ on_date_popup_key_press (GtkWidget *widget, GdkEventKey *event, EDateEdit *dedit) { + GdkWindow *window; + + window = gtk_widget_get_window (dedit->priv->cal_popup); + if (event->keyval != GDK_Escape) { - gdk_keyboard_grab (dedit->priv->cal_popup->window, TRUE, GDK_CURRENT_TIME); + gdk_keyboard_grab (window, TRUE, GDK_CURRENT_TIME); return FALSE; } @@ -1541,7 +1552,7 @@ on_date_popup_button_press (GtkWidget *widget, while (child) { if (child == widget) return FALSE; - child = child->parent; + child = gtk_widget_get_parent (child); } } @@ -1700,12 +1711,16 @@ static void on_date_edit_time_selected (GtkComboBox *combo, EDateEdit *dedit) { + GtkWidget *child; + + child = gtk_bin_get_child (GTK_BIN (combo)); + /* We only want to emit signals when an item is selected explicitly, not when it is selected by the silly combo update thing. */ if (gtk_combo_box_get_active (combo) == -1) return; - if (!GTK_WIDGET_MAPPED (GTK_BIN (combo)->child)) + if (!GTK_WIDGET_MAPPED (child)) return; e_date_edit_check_time_changed (dedit); @@ -1740,6 +1755,10 @@ on_time_entry_key_press (GtkWidget *widget, GdkEventKey *event, EDateEdit *dedit) { + GtkWidget *child; + + child = gtk_bin_get_child (GTK_BIN (dedit->priv->time_combo)); + /* I'd like to use Alt+Up/Down for popping up the list, like Win32, but the combo steals any Up/Down keys, so we use Alt+Return. */ #if 0 @@ -1748,9 +1767,8 @@ on_time_entry_key_press (GtkWidget *widget, #else if (event->state & GDK_MOD1_MASK && event->keyval == GDK_Return) { #endif - g_signal_stop_emission_by_name (widget, - "key_press_event"); - g_signal_emit_by_name (GTK_BIN (dedit->priv->time_combo)->child, "activate", 0); + g_signal_stop_emission_by_name (widget, "key_press_event"); + g_signal_emit_by_name (child, "activate", 0); return TRUE; } @@ -1946,14 +1964,17 @@ static void e_date_edit_update_time_entry (EDateEdit *dedit) { EDateEditPrivate *priv; + GtkWidget *child; gchar buffer[40]; struct tm tmp_tm = { 0 }; priv = dedit->priv; + child = gtk_bin_get_child (GTK_BIN (priv->time_combo)); + if (priv->time_set_to_none || !priv->time_is_valid) { gtk_combo_box_set_active (GTK_COMBO_BOX (priv->time_combo), -1); - gtk_entry_set_text (GTK_ENTRY (GTK_BIN (priv->time_combo)->child), ""); + gtk_entry_set_text (GTK_ENTRY (child), ""); } else { GtkTreeModel *model; GtkTreeIter iter; @@ -1982,8 +2003,7 @@ e_date_edit_update_time_entry (EDateEdit *dedit) if (!priv->use_24_hour_format && buffer[0] == '0') buffer[0] = ' '; - gtk_entry_set_text (GTK_ENTRY (GTK_BIN (priv->time_combo)->child), - buffer); + gtk_entry_set_text (GTK_ENTRY (child), buffer); /* truncate left spaces */ b = buffer; @@ -2046,10 +2066,13 @@ e_date_edit_update_time_combo_state (EDateEdit *dedit) } if (clear_entry) { + GtkWidget *child; + /* Only clear it if it isn't empty already. */ - text = gtk_entry_get_text (GTK_ENTRY (GTK_BIN (priv->time_combo)->child)); + child = gtk_bin_get_child (GTK_BIN (priv->time_combo)); + text = gtk_entry_get_text (GTK_ENTRY (child)); if (text[0]) - gtk_entry_set_text (GTK_ENTRY (GTK_BIN (priv->time_combo)->child), ""); + gtk_entry_set_text (GTK_ENTRY (child), ""); } gtk_widget_set_sensitive (priv->time_combo, sensitive); @@ -2114,6 +2137,7 @@ static void e_date_edit_check_time_changed (EDateEdit *dedit) { EDateEditPrivate *priv; + GtkWidget *child; const gchar *time_text; struct tm tmp_tm; gboolean none = FALSE, valid = TRUE, time_changed; @@ -2123,7 +2147,8 @@ e_date_edit_check_time_changed (EDateEdit *dedit) tmp_tm.tm_hour = 0; tmp_tm.tm_min = 0; - time_text = gtk_entry_get_text (GTK_ENTRY (GTK_BIN (priv->time_combo)->child)); + child = gtk_bin_get_child (GTK_BIN (priv->time_combo)); + time_text = gtk_entry_get_text (GTK_ENTRY (child)); if (field_set_to_none (time_text)) none = TRUE; else if (!e_date_edit_parse_time (dedit, time_text, &tmp_tm)) diff --git a/widgets/misc/e-map.c b/widgets/misc/e-map.c index 26640cf121..3169c97c78 100644 --- a/widgets/misc/e-map.c +++ b/widgets/misc/e-map.c @@ -55,8 +55,7 @@ EMapZoomState; /* Private part of the EMap structure */ -typedef struct -{ +struct _EMapPrivate { /* Pointer to map image */ GdkPixbuf *map_pixbuf, *map_render_pixbuf; @@ -76,8 +75,7 @@ typedef struct /* Dots */ GPtrArray *points; -} -EMapPrivate; +}; /* Internal prototypes */ @@ -293,7 +291,10 @@ e_map_unmap (GtkWidget *widget) static void e_map_realize (GtkWidget *widget) { + GtkAllocation allocation; GdkWindowAttr attr; + GdkWindow *window; + GtkStyle *style; gint attr_mask; g_return_if_fail (widget != NULL); @@ -301,11 +302,13 @@ e_map_realize (GtkWidget *widget) GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + gtk_widget_get_allocation (widget, &allocation); + attr.window_type = GDK_WINDOW_CHILD; - attr.x = widget->allocation.x; - attr.y = widget->allocation.y; - attr.width = widget->allocation.width; - attr.height = widget->allocation.height; + attr.x = allocation.x; + attr.y = allocation.y; + attr.width = allocation.width; + attr.height = allocation.height; attr.wclass = GDK_INPUT_OUTPUT; attr.visual = gdk_rgb_get_visual (); attr.colormap = gdk_rgb_get_colormap (); @@ -315,12 +318,16 @@ e_map_realize (GtkWidget *widget) attr_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attr, attr_mask); - gdk_window_set_user_data (widget->window, widget); + window = gdk_window_new ( + gtk_widget_get_parent_window (widget), &attr, attr_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, widget); - widget->style = gtk_style_attach (widget->style, widget->window); + style = gtk_widget_get_style (widget); + style = gtk_style_attach (style, window); + gtk_widget_set_style (widget, style); - gdk_window_set_back_pixmap (widget->window, NULL, FALSE); + gdk_window_set_back_pixmap (window, NULL, FALSE); update_render_pixbuf (E_MAP (widget), GDK_INTERP_BILINEAR, TRUE); } @@ -373,11 +380,16 @@ e_map_size_allocate (GtkWidget *widget, GtkAllocation *allocation) /* Resize the window */ - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); - if (GTK_WIDGET_REALIZED (widget)) - { - gdk_window_move_resize (widget->window, allocation->x, allocation->y, allocation->width, allocation->height); + if (GTK_WIDGET_REALIZED (widget)) { + GdkWindow *window; + + window = gtk_widget_get_window (widget); + + gdk_window_move_resize ( + window, allocation->x, allocation->y, + allocation->width, allocation->height); area.x = 0; area.y = 0; @@ -558,18 +570,25 @@ e_map_key_press (GtkWidget *widget, GdkEventKey *event) if (do_scroll) { + gint page_size; + gint upper; gint x, y; - x = CLAMP (priv->xofs + xofs, 0, priv->hadj->upper - priv->hadj->page_size); - y = CLAMP (priv->yofs + yofs, 0, priv->vadj->upper - priv->vadj->page_size); + page_size = gtk_adjustment_get_page_size (priv->hadj); + upper = gtk_adjustment_get_upper (priv->hadj); + x = CLAMP (priv->xofs + xofs, 0, upper - page_size); + + page_size = gtk_adjustment_get_page_size (priv->vadj); + upper = gtk_adjustment_get_upper (priv->vadj); + y = CLAMP (priv->yofs + yofs, 0, upper - page_size); scroll_to (view, x, y); g_signal_handlers_block_matched (priv->hadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); g_signal_handlers_block_matched (priv->vadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); - priv->hadj->value = x; - priv->vadj->value = y; + gtk_adjustment_set_value (priv->hadj, x); + gtk_adjustment_set_value (priv->vadj, y); g_signal_emit_by_name (priv->hadj, "value_changed"); g_signal_emit_by_name (priv->vadj, "value_changed"); @@ -830,15 +849,17 @@ gboolean e_map_point_is_in_view (EMap *map, EMapPoint *point) { EMapPrivate *priv; + GtkAllocation allocation; double x, y; priv = map->priv; if (!priv->map_render_pixbuf) return FALSE; e_map_world_to_window (map, point->longitude, point->latitude, &x, &y); + gtk_widget_get_allocation (GTK_WIDGET (map), &allocation); - if (x >= 0 && x < GTK_WIDGET (map)->allocation.width && - y >= 0 && y < GTK_WIDGET (map)->allocation.height) + if (x >= 0 && x < allocation.width && + y >= 0 && y < allocation.height) return TRUE; return FALSE; @@ -882,11 +903,14 @@ static void repaint_visible (EMap *map) { GdkRectangle area; + GtkAllocation allocation; + + gtk_widget_get_allocation (GTK_WIDGET (map), &allocation); area.x = 0; area.y = 0; - area.width = GTK_WIDGET (map)->allocation.width; - area.height = GTK_WIDGET (map)->allocation.height; + area.width = allocation.width; + area.height = allocation.height; request_paint_area (map, &area); } @@ -918,36 +942,39 @@ load_map_background (EMap *view, gchar *name) } static void -update_render_pixbuf (EMap *map, GdkInterpType interp, gboolean render_overlays) +update_render_pixbuf (EMap *map, + GdkInterpType interp, + gboolean render_overlays) { EMapPrivate *priv; EMapPoint *point; + GtkAllocation allocation; gint width, height, orig_width, orig_height; double zoom; gint i; - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (map))) return; + if (!GTK_WIDGET_REALIZED (map)) + return; + + gtk_widget_get_allocation (GTK_WIDGET (map), &allocation); /* Set up value shortcuts */ priv = map->priv; - width = GTK_WIDGET (map)->allocation.width; - height = GTK_WIDGET (map)->allocation.height; + width = allocation.width; + height = allocation.height; orig_width = gdk_pixbuf_get_width (priv->map_pixbuf); orig_height = gdk_pixbuf_get_height (priv->map_pixbuf); /* Compute scaled width and height based on the extreme dimension */ if ((double) width / orig_width > (double) height / orig_height) - { zoom = (double) width / (double) orig_width; - } else - { zoom = (double) height / (double) orig_height; - } - if (priv->zoom_state == E_MAP_ZOOMED_IN) zoom *= 2.0; + if (priv->zoom_state == E_MAP_ZOOMED_IN) + zoom *= 2.0; height = (orig_height * zoom) + 0.5; width = (orig_width * zoom) + 0.5; @@ -1014,12 +1041,22 @@ request_paint_area (EMap *view, GdkRectangle *area) if (gdk_pixbuf_get_colorspace (priv->map_render_pixbuf) == GDK_COLORSPACE_RGB && !gdk_pixbuf_get_has_alpha (priv->map_render_pixbuf) && gdk_pixbuf_get_bits_per_sample (priv->map_render_pixbuf) == 8) { + GtkStyle *style; + GdkWindow *window; guchar *pixels; gint rowstride; + style = gtk_widget_get_style (GTK_WIDGET (view)); + window = gtk_widget_get_window (GTK_WIDGET (view)); + rowstride = gdk_pixbuf_get_rowstride (priv->map_render_pixbuf); - pixels = gdk_pixbuf_get_pixels (priv->map_render_pixbuf) + (area->y + priv->yofs) * rowstride + 3 * (area->x + priv->xofs); - gdk_draw_rgb_image_dithalign (GTK_WIDGET (view)->window, GTK_WIDGET (view)->style->black_gc, area->x, area->y, width, height, GDK_RGB_DITHER_NORMAL, pixels, rowstride, 0, 0); + pixels = gdk_pixbuf_get_pixels (priv->map_render_pixbuf) + + (area->y + priv->yofs) * rowstride + 3 * + (area->x + priv->xofs); + gdk_draw_rgb_image_dithalign ( + window, style->black_gc, area->x, area->y, + width, height, GDK_RGB_DITHER_NORMAL, pixels, + rowstride, 0, 0); return; } @@ -1112,23 +1149,22 @@ static void center_at (EMap *map, gint x, gint y, gboolean scroll) { EMapPrivate *priv; - gint pb_width, pb_height, - view_width, view_height; + GtkAllocation allocation; + gint pb_width, pb_height; priv = map->priv; pb_width = E_MAP_GET_WIDTH (map); pb_height = E_MAP_GET_HEIGHT (map); - view_width = GTK_WIDGET (map)->allocation.width; - view_height = GTK_WIDGET (map)->allocation.height; + gtk_widget_get_allocation (GTK_WIDGET (map), &allocation); - x = CLAMP (x - (view_width / 2), 0, pb_width - view_width); - y = CLAMP (y - (view_height / 2), 0, pb_height - view_height); + x = CLAMP (x - (allocation.width / 2), 0, pb_width - allocation.width); + y = CLAMP (y - (allocation.height / 2), 0, pb_height - allocation.height); - if (scroll) scroll_to (map, x, y); - else - { + if (scroll) + scroll_to (map, x, y); + else { priv->xofs = x; priv->yofs = y; } @@ -1138,8 +1174,8 @@ static void smooth_center_at (EMap *map, gint x, gint y) { EMapPrivate *priv; - gint pb_width, pb_height, - view_width, view_height; + GtkAllocation allocation; + gint pb_width, pb_height; gint dx, dy; priv = map->priv; @@ -1147,15 +1183,15 @@ smooth_center_at (EMap *map, gint x, gint y) pb_width = E_MAP_GET_WIDTH (map); pb_height = E_MAP_GET_HEIGHT (map); - view_width = GTK_WIDGET (map)->allocation.width; - view_height = GTK_WIDGET (map)->allocation.height; + gtk_widget_get_allocation (GTK_WIDGET (map), &allocation); - x = CLAMP (x - (view_width / 2), 0, pb_width - view_width); - y = CLAMP (y - (view_height / 2), 0, pb_height - view_height); + x = CLAMP (x - (allocation.width / 2), 0, pb_width - allocation.width); + y = CLAMP (y - (allocation.height / 2), 0, pb_height - allocation.height); for (;;) { - if (priv->xofs == x && priv->yofs == y) break; + if (priv->xofs == x && priv->yofs == y) + break; dx = (x < priv->xofs) ? -1 : (x > priv->xofs) ? 1 : 0; dy = (y < priv->yofs) ? -1 : (y > priv->yofs) ? 1 : 0; @@ -1172,8 +1208,8 @@ scroll_to (EMap *view, gint x, gint y) EMapPrivate *priv; gint xofs, yofs; GdkWindow *window; + GtkAllocation allocation; GdkGC *gc; - gint width, height; gint src_x, src_y; gint dest_x, dest_y; #if 0 /* see comment below */ @@ -1187,30 +1223,31 @@ scroll_to (EMap *view, gint x, gint y) xofs = x - priv->xofs; yofs = y - priv->yofs; - if (xofs == 0 && yofs == 0) return; + if (xofs == 0 && yofs == 0) + return; priv->xofs = x; priv->yofs = y; - if (!GTK_WIDGET_DRAWABLE (view)) return; + if (!GTK_WIDGET_DRAWABLE (view)) + return; - width = GTK_WIDGET (view)->allocation.width; - height = GTK_WIDGET (view)->allocation.height; + gtk_widget_get_allocation (GTK_WIDGET (view), &allocation); - if (abs (xofs) >= width || abs (yofs) >= height) + if (abs (xofs) >= allocation.width || abs (yofs) >= allocation.height) { GdkRectangle area; area.x = 0; area.y = 0; - area.width = width; - area.height = height; + area.width = allocation.width; + area.height = allocation.height; request_paint_area (view, &area); return; } - window = GTK_WIDGET (view)->window; + window = gtk_widget_get_window (GTK_WIDGET (view)); /* Copy the window area */ @@ -1222,7 +1259,12 @@ scroll_to (EMap *view, gint x, gint y) gc = gdk_gc_new (window); gdk_gc_set_exposures (gc, TRUE); - gdk_draw_drawable (GDK_DRAWABLE (window), gc, GDK_DRAWABLE (window), src_x, src_y, dest_x, dest_y, width - abs (xofs), height - abs (yofs)); + gdk_draw_drawable ( + GDK_DRAWABLE (window), + gc, GDK_DRAWABLE (window), + src_x, src_y, dest_x, dest_y, + allocation.width - abs (xofs), + allocation.height - abs (yofs)); g_object_unref (gc); @@ -1232,10 +1274,10 @@ scroll_to (EMap *view, gint x, gint y) { GdkRectangle r; - r.x = xofs < 0 ? 0 : width - xofs; + r.x = xofs < 0 ? 0 : allocation.width - xofs; r.y = 0; r.width = abs (xofs); - r.height = height; + r.height = allocation.height; request_paint_area (view, &r); } @@ -1245,8 +1287,8 @@ scroll_to (EMap *view, gint x, gint y) GdkRectangle r; r.x = 0; - r.y = yofs < 0 ? 0 : height - yofs; - r.width = width; + r.y = yofs < 0 ? 0 : allocation.height - yofs; + r.width = allocation.width; r.height = abs (yofs); request_paint_area (view, &r); @@ -1493,6 +1535,7 @@ blowup_window_area (GdkWindow *window, gint area_x, gint area_y, gint target_x, static void zoom_in_smooth (EMap *map) { + GtkAllocation allocation; GdkRectangle area; EMapPrivate *priv; GdkWindow *window; @@ -1502,13 +1545,15 @@ zoom_in_smooth (EMap *map) g_return_if_fail (map); g_return_if_fail (GTK_WIDGET_REALIZED (GTK_WIDGET (map))); + gtk_widget_get_allocation (GTK_WIDGET (map), &allocation); + area.x = 0; area.y = 0; - area.width = GTK_WIDGET (map)->allocation.width; - area.height = GTK_WIDGET (map)->allocation.height; + area.width = allocation.width; + area.height = allocation.height; priv = map->priv; - window = GTK_WIDGET (map)->window; + window = gtk_widget_get_window (GTK_WIDGET (map)); width = gdk_pixbuf_get_width (priv->map_render_pixbuf); height = gdk_pixbuf_get_height (priv->map_render_pixbuf); @@ -1549,24 +1594,33 @@ zoom_in_smooth (EMap *map) static void zoom_in (EMap *map) { + GtkAllocation allocation; GdkRectangle area; EMapPrivate *priv; double x, y; priv = map->priv; + gtk_widget_get_allocation (GTK_WIDGET (map), &allocation); + area.x = 0; area.y = 0; - area.width = GTK_WIDGET (map)->allocation.width; - area.height = GTK_WIDGET (map)->allocation.height; + area.width = allocation.width; + area.height = allocation.height; priv->zoom_state = E_MAP_ZOOMED_IN; update_render_pixbuf (map, GDK_INTERP_BILINEAR, TRUE); - e_map_world_to_window (map, priv->zoom_target_long, priv->zoom_target_lat, &x, &y); - priv->xofs = CLAMP (priv->xofs + x - area.width / 2.0, 0, E_MAP_GET_WIDTH (map) - area.width); - priv->yofs = CLAMP (priv->yofs + y - area.height / 2.0, 0, E_MAP_GET_HEIGHT (map) - area.height); + e_map_world_to_window ( + map, priv->zoom_target_long, + priv->zoom_target_lat, &x, &y); + priv->xofs = CLAMP ( + priv->xofs + x - area.width / 2.0, + 0, E_MAP_GET_WIDTH (map) - area.width); + priv->yofs = CLAMP ( + priv->yofs + y - area.height / 2.0, + 0, E_MAP_GET_HEIGHT (map) - area.height); request_paint_area (map, &area); } @@ -1574,6 +1628,7 @@ zoom_in (EMap *map) static void zoom_out (EMap *map) { + GtkAllocation allocation; GdkRectangle area; EMapPrivate *priv; double longitude, latitude; @@ -1581,15 +1636,18 @@ zoom_out (EMap *map) priv = map->priv; + gtk_widget_get_allocation (GTK_WIDGET (map), &allocation); + area.x = 0; area.y = 0; - area.width = GTK_WIDGET (map)->allocation.width; - area.height = GTK_WIDGET (map)->allocation.height; + area.width = allocation.width; + area.height = allocation.height; /* Must be done before update_render_pixbuf() */ - e_map_window_to_world (map, area.width / 2, area.height / 2, - &longitude, &latitude); + e_map_window_to_world ( + map, area.width / 2, area.height / 2, + &longitude, &latitude); priv->zoom_state = E_MAP_ZOOMED_OUT; update_render_pixbuf (map, GDK_INTERP_BILINEAR, TRUE); @@ -1632,65 +1690,78 @@ static void adjustment_changed_cb (GtkAdjustment *adj, gpointer data) { EMap *view; - EMapPrivate *priv; + gint hadj_value; + gint vadj_value; view = E_MAP (data); - priv = view->priv; - scroll_to (view, priv->hadj->value, priv->vadj->value); + hadj_value = gtk_adjustment_get_value (view->priv->hadj); + vadj_value = gtk_adjustment_get_value (view->priv->vadj); + + scroll_to (view, hadj_value, vadj_value); } static void set_scroll_area (EMap *view) { EMapPrivate *priv; + GtkAllocation allocation; + gint upper, page_size; priv = view->priv; if (!GTK_WIDGET_REALIZED (GTK_WIDGET (view))) return; if (!priv->hadj || !priv->vadj) return; + g_object_freeze_notify (G_OBJECT (priv->hadj)); + g_object_freeze_notify (G_OBJECT (priv->vadj)); + + gtk_widget_get_allocation (GTK_WIDGET (view), &allocation); + /* Set scroll increments */ - priv->hadj->page_size = GTK_WIDGET (view)->allocation.width; - priv->hadj->page_increment = GTK_WIDGET (view)->allocation.width / 2; - priv->hadj->step_increment = SCROLL_STEP_SIZE; + gtk_adjustment_set_page_size (priv->hadj, allocation.width); + gtk_adjustment_set_page_increment (priv->hadj, allocation.width / 2); + gtk_adjustment_set_step_increment (priv->hadj, SCROLL_STEP_SIZE); - priv->vadj->page_size = GTK_WIDGET (view)->allocation.height; - priv->vadj->page_increment = GTK_WIDGET (view)->allocation.height / 2; - priv->vadj->step_increment = SCROLL_STEP_SIZE; + gtk_adjustment_set_page_size (priv->vadj, allocation.height); + gtk_adjustment_set_page_increment (priv->vadj, allocation.height / 2); + gtk_adjustment_set_step_increment (priv->vadj, SCROLL_STEP_SIZE); /* Set scroll bounds and new offsets */ - priv->hadj->lower = 0; - if (priv->map_render_pixbuf) - priv->hadj->upper = gdk_pixbuf_get_width (priv->map_render_pixbuf); - - priv->vadj->lower = 0; - if (priv->map_render_pixbuf) - priv->vadj->upper = gdk_pixbuf_get_height (priv->map_render_pixbuf); + gtk_adjustment_set_lower (priv->hadj, 0); + if (priv->map_render_pixbuf) { + gint width = gdk_pixbuf_get_width (priv->map_render_pixbuf); + gtk_adjustment_set_upper (priv->hadj, width); + } - g_signal_emit_by_name (priv->hadj, "changed"); - g_signal_emit_by_name (priv->vadj, "changed"); + gtk_adjustment_set_lower (priv->vadj, 0); + if (priv->map_render_pixbuf) { + gint height = gdk_pixbuf_get_height (priv->map_render_pixbuf); + gtk_adjustment_set_upper (priv->vadj, height); + } - priv->xofs = CLAMP (priv->xofs, 0, priv->hadj->upper - priv->hadj->page_size); - priv->yofs = CLAMP (priv->yofs, 0, priv->vadj->upper - priv->vadj->page_size); + g_object_thaw_notify (G_OBJECT (priv->hadj)); + g_object_thaw_notify (G_OBJECT (priv->vadj)); - if (priv->hadj->value != priv->xofs) - { - priv->hadj->value = priv->xofs; + upper = gtk_adjustment_get_upper (priv->hadj); + page_size = gtk_adjustment_get_page_size (priv->hadj); + priv->xofs = CLAMP (priv->xofs, 0, upper - page_size); - g_signal_handlers_block_matched (priv->hadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); - g_signal_emit_by_name (priv->hadj, "value_changed"); - g_signal_handlers_unblock_matched (priv->hadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); - } + upper = gtk_adjustment_get_upper (priv->vadj); + page_size = gtk_adjustment_get_page_size (priv->vadj); + priv->yofs = CLAMP (priv->yofs, 0, upper - page_size); - if (priv->vadj->value != priv->yofs) - { - priv->vadj->value = priv->yofs; + g_signal_handlers_block_matched ( + priv->hadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); + gtk_adjustment_set_value (priv->hadj, priv->xofs); + g_signal_handlers_unblock_matched ( + priv->hadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); - g_signal_handlers_block_matched (priv->vadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); - g_signal_emit_by_name (priv->vadj, "value_changed"); - g_signal_handlers_unblock_matched (priv->vadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); - } + g_signal_handlers_block_matched ( + priv->vadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); + gtk_adjustment_set_value (priv->vadj, priv->yofs); + g_signal_handlers_unblock_matched ( + priv->vadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); } diff --git a/widgets/misc/e-map.h b/widgets/misc/e-map.h index 6c0e44e93b..b3d7997401 100644 --- a/widgets/misc/e-map.h +++ b/widgets/misc/e-map.h @@ -34,18 +34,15 @@ typedef struct _EMap EMap; typedef struct _EMapClass EMapClass; +typedef struct _EMapPrivate EMapPrivate; typedef struct _EMapPoint EMapPoint; -struct _EMap -{ +struct _EMap { GtkWidget widget; - - /* Private data */ - gpointer priv; + EMapPrivate *priv; }; -struct _EMapClass -{ +struct _EMapClass { GtkWidgetClass parent_class; /* Notification signals */ diff --git a/widgets/misc/e-menu-tool-button.c b/widgets/misc/e-menu-tool-button.c index fcf73d6c4e..0d9599c2f4 100644 --- a/widgets/misc/e-menu-tool-button.c +++ b/widgets/misc/e-menu-tool-button.c @@ -50,7 +50,7 @@ menu_tool_button_get_first_menu_item (GtkMenuToolButton *menu_tool_button) if (!GTK_IS_MENU (menu)) return NULL; - /* XXX GTK+ 2.12 provides no accessor function. */ + /* XXX GTK+ 2.18 provides no accessor function. */ children = GTK_MENU_SHELL (menu)->children; if (children == NULL) return NULL; diff --git a/widgets/misc/e-paned.c b/widgets/misc/e-paned.c index 83f9614e74..2b4701b9ff 100644 --- a/widgets/misc/e-paned.c +++ b/widgets/misc/e-paned.c @@ -93,7 +93,7 @@ paned_notify_orientation_cb (EPaned *paned) static void paned_notify_position_cb (EPaned *paned) { - GtkAllocation *allocation; + GtkAllocation allocation; GtkOrientable *orientable; GtkOrientation orientation; gdouble proportion; @@ -106,20 +106,20 @@ paned_notify_position_cb (EPaned *paned) orientable = GTK_ORIENTABLE (paned); orientation = gtk_orientable_get_orientation (orientable); - allocation = >K_WIDGET (paned)->allocation; + gtk_widget_get_allocation (GTK_WIDGET (paned), &allocation); position = gtk_paned_get_position (GTK_PANED (paned)); g_object_freeze_notify (G_OBJECT (paned)); if (orientation == GTK_ORIENTATION_HORIZONTAL) { - position = MAX (0, allocation->width - position); - proportion = (gdouble) position / allocation->width; + position = MAX (0, allocation.width - position); + proportion = (gdouble) position / allocation.width; paned->priv->hposition = position; g_object_notify (G_OBJECT (paned), "hposition"); } else { - position = MAX (0, allocation->height - position); - proportion = (gdouble) position / allocation->height; + position = MAX (0, allocation.height - position); + proportion = (gdouble) position / allocation.height; paned->priv->vposition = position; g_object_notify (G_OBJECT (paned), "vposition"); diff --git a/widgets/misc/e-send-options.c b/widgets/misc/e-send-options.c index c134bfba6e..4f2ad8a9a4 100644 --- a/widgets/misc/e-send-options.c +++ b/widgets/misc/e-send-options.c @@ -260,7 +260,7 @@ sensitize_widgets (ESendOptionsDialog *sod) } static void -expiration_toggled_cb (GtkWidget *toggle, gpointer data) +expiration_toggled_cb (GtkToggleButton *toggle, gpointer data) { gboolean active; ESendOptionsDialog *sod; @@ -269,13 +269,13 @@ expiration_toggled_cb (GtkWidget *toggle, gpointer data) sod = data; priv = sod->priv; - active = GTK_TOGGLE_BUTTON (toggle)->active; + active = gtk_toggle_button_get_active (toggle); gtk_widget_set_sensitive (priv->expire_after, active); } static void -reply_request_toggled_cb (GtkWidget *toggle, gpointer data) +reply_request_toggled_cb (GtkToggleButton *toggle, gpointer data) { gboolean active; ESendOptionsDialog *sod; @@ -283,7 +283,7 @@ reply_request_toggled_cb (GtkWidget *toggle, gpointer data) sod = data; priv = sod->priv; - active = GTK_TOGGLE_BUTTON (toggle)->active; + active = gtk_toggle_button_get_active (toggle); gtk_widget_set_sensitive (priv->reply_convenient, active); gtk_widget_set_sensitive (priv->reply_within, active); @@ -292,7 +292,7 @@ reply_request_toggled_cb (GtkWidget *toggle, gpointer data) } static void -delay_delivery_toggled_cb (GtkWidget *toggle, gpointer data) +delay_delivery_toggled_cb (GtkToggleButton *toggle, gpointer data) { gboolean active; ESendOptionsDialog *sod; @@ -300,13 +300,13 @@ delay_delivery_toggled_cb (GtkWidget *toggle, gpointer data) sod = data; priv = sod->priv; - active = GTK_TOGGLE_BUTTON (toggle)->active; + active = gtk_toggle_button_get_active (toggle); gtk_widget_set_sensitive (priv->delay_until, active); } static void -sent_item_toggled_cb (GtkWidget *toggle, gpointer data) +sent_item_toggled_cb (GtkToggleButton *toggle, gpointer data) { gboolean active; ESendOptionsDialog *sod; @@ -314,7 +314,7 @@ sent_item_toggled_cb (GtkWidget *toggle, gpointer data) sod = data; priv = sod->priv; - active = GTK_TOGGLE_BUTTON (toggle)->active; + active = gtk_toggle_button_get_active (toggle); gtk_widget_set_sensitive (priv->delivered, active); gtk_widget_set_sensitive (priv->delivered_opened, active); diff --git a/widgets/misc/e-spinner.c b/widgets/misc/e-spinner.c index 3e7b732def..c95f26b0a7 100644 --- a/widgets/misc/e-spinner.c +++ b/widgets/misc/e-spinner.c @@ -640,7 +640,9 @@ e_spinner_expose (GtkWidget *widget, ESpinner *spinner = E_SPINNER (widget); ESpinnerDetails *details = spinner->details; ESpinnerImages *images; + GtkAllocation allocation; GdkPixbuf *pixbuf; + GdkWindow *window; GdkGC *gc; gint x_offset, y_offset, width, height; GdkRectangle pix_area, dest; @@ -675,12 +677,14 @@ e_spinner_expose (GtkWidget *widget, width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); + gtk_widget_get_allocation (widget, &allocation); + /* Compute the offsets for the image centered on our allocation */ - x_offset = (widget->allocation.width - width) / 2; - y_offset = (widget->allocation.height - height) / 2; + x_offset = (allocation.width - width) / 2; + y_offset = (allocation.height - height) / 2; - pix_area.x = x_offset + widget->allocation.x; - pix_area.y = y_offset + widget->allocation.y; + pix_area.x = x_offset + allocation.x; + pix_area.y = y_offset + allocation.y; pix_area.width = width; pix_area.height = height; @@ -689,10 +693,12 @@ e_spinner_expose (GtkWidget *widget, return FALSE; } - gc = gdk_gc_new (widget->window); - gdk_draw_pixbuf (widget->window, gc, pixbuf, - dest.x - x_offset - widget->allocation.x, - dest.y - y_offset - widget->allocation.y, + window = gtk_widget_get_window (widget); + + gc = gdk_gc_new (window); + gdk_draw_pixbuf (window, gc, pixbuf, + dest.x - x_offset - allocation.x, + dest.y - y_offset - allocation.y, dest.x, dest.y, dest.width, dest.height, GDK_RGB_DITHER_MAX, 0, 0); diff --git a/widgets/misc/ea-calendar-item.c b/widgets/misc/ea-calendar-item.c index 82c118bf82..17188ed66c 100644 --- a/widgets/misc/ea-calendar-item.c +++ b/widgets/misc/ea-calendar-item.c @@ -1166,7 +1166,7 @@ e_calendar_item_get_day_extents (ECalendarItem *calitem, item = GNOME_CANVAS_ITEM (calitem); widget = GTK_WIDGET (item->canvas); - style = widget->style; + style = gtk_widget_get_style (widget); /* Set up Pango prerequisites */ font_desc = calitem->font_desc; -- cgit v1.2.3