diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-01-31 03:03:19 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-04-08 23:05:26 +0800 |
commit | 72797decc12602b181f69dba7c54df7a0d1b9326 (patch) | |
tree | ecd1314c92bc26b59647b351b2d47e446f4ed21d /widgets/table | |
parent | 3ba0b61f9f447b01c3a83bfb78ee33a45d413700 (diff) | |
download | gsoc2013-evolution-72797decc12602b181f69dba7c54df7a0d1b9326.tar.gz gsoc2013-evolution-72797decc12602b181f69dba7c54df7a0d1b9326.tar.zst gsoc2013-evolution-72797decc12602b181f69dba7c54df7a0d1b9326.zip |
Giant leap towards GSEAL compliance.
Diffstat (limited to 'widgets/table')
22 files changed, 886 insertions, 495 deletions
diff --git a/widgets/table/e-cell-combo.c b/widgets/table/e-cell-combo.c index 31e6c29b99..47e1a87eac 100644 --- a/widgets/table/e-cell-combo.c +++ b/widgets/table/e-cell-combo.c @@ -126,6 +126,7 @@ e_cell_combo_init (ECellCombo *ecc) AtkObject *a11y; GtkListStore *store; GtkTreeSelection *selection; + GtkScrolledWindow *scrolled_window; /* We create one popup window for the ECell, since there will only ever be one popup in use at a time. */ @@ -140,11 +141,17 @@ e_cell_combo_init (ECellCombo *ecc) gtk_widget_show (frame); ecc->popup_scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ecc->popup_scrolled_window), + scrolled_window = GTK_SCROLLED_WINDOW (ecc->popup_scrolled_window); + + gtk_scrolled_window_set_policy (scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (ecc->popup_scrolled_window)->hscrollbar, GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (ecc->popup_scrolled_window)->vscrollbar, GTK_CAN_FOCUS); + GTK_WIDGET_UNSET_FLAGS ( + gtk_scrolled_window_get_hscrollbar (scrolled_window), + GTK_CAN_FOCUS); + GTK_WIDGET_UNSET_FLAGS ( + gtk_scrolled_window_get_vscrollbar (scrolled_window), + GTK_CAN_FOCUS); gtk_container_add (GTK_CONTAINER (frame), ecc->popup_scrolled_window); gtk_widget_show (ecc->popup_scrolled_window); @@ -330,24 +337,33 @@ e_cell_combo_select_matching_item (ECellCombo *ecc) static void e_cell_combo_show_popup (ECellCombo *ecc, gint row, gint view_col) { + GdkWindow *window; + GtkAllocation allocation; gint x, y, width, height, old_width, old_height; + gtk_widget_get_allocation (ecc->popup_window, &allocation); + /* This code is practically copied from GtkCombo. */ - old_width = ecc->popup_window->allocation.width; - old_height = ecc->popup_window->allocation.height; + old_width = allocation.width; + old_height = allocation.height; e_cell_combo_get_popup_pos (ecc, row, view_col, &x, &y, &height, &width); /* workaround for gtk_scrolled_window_size_allocate bug */ if (old_width != width || old_height != height) { - gtk_widget_hide (GTK_SCROLLED_WINDOW (ecc->popup_scrolled_window)->hscrollbar); - gtk_widget_hide (GTK_SCROLLED_WINDOW (ecc->popup_scrolled_window)->vscrollbar); + gtk_widget_hide ( + gtk_scrolled_window_get_hscrollbar ( + GTK_SCROLLED_WINDOW (ecc->popup_scrolled_window))); + gtk_widget_hide ( + gtk_scrolled_window_get_vscrollbar ( + GTK_SCROLLED_WINDOW (ecc->popup_scrolled_window))); } gtk_window_move (GTK_WINDOW (ecc->popup_window), x, y); gtk_widget_set_size_request (ecc->popup_window, width, height); gtk_widget_realize (ecc->popup_window); - gdk_window_resize (ecc->popup_window->window, width, height); + window = gtk_widget_get_window (ecc->popup_window); + gdk_window_resize (window, width, height); gtk_widget_show (ecc->popup_window); e_cell_popup_set_shown (E_CELL_POPUP (ecc), TRUE); @@ -367,8 +383,15 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc, ECellPopup *ecp = E_CELL_POPUP (ecc); ETableItem *eti = E_TABLE_ITEM (ecp->popup_cell_view->cell_view.e_table_item_view); GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (eti)->canvas); + GtkWidget *widget; + GtkWidget *popwin_child; + GtkWidget *popup_child; + GtkStyle *popwin_style; + GtkStyle *popup_style; + GdkWindow *window; GtkBin *popwin; GtkScrolledWindow *popup; + GtkRequisition requisition; GtkRequisition list_requisition; gboolean show_vscroll = FALSE, show_hscroll = FALSE; gint avail_height, avail_width, min_height, work_height, screen_width; @@ -380,7 +403,8 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc, popup = GTK_SCROLLED_WINDOW (ecc->popup_scrolled_window); popwin = GTK_BIN (ecc->popup_window); - gdk_window_get_origin (canvas->window, x, y); + window = gtk_widget_get_window (canvas); + gdk_window_get_origin (window, x, y); x1 = e_table_header_col_diff (eti->header, 0, view_col + 1); y1 = e_table_item_row_diff (eti, 0, row + 1); @@ -402,10 +426,16 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc, *x += x1; /* The ETable positions don't include the grid lines, I think, so we add 1. */ *y += y1 + 1 - - (gint)((GnomeCanvas *)canvas)->layout.vadjustment->value + - (gint)gtk_adjustment_get_value ( + gtk_layout_get_vadjustment ( + &((GnomeCanvas *)canvas)->layout)) + ((GnomeCanvas *)canvas)->zoom_yofs; - scrollbar_width = popup->vscrollbar->requisition.width + widget = gtk_scrolled_window_get_vscrollbar (popup); + gtk_widget_get_child_requisition (widget, &requisition); + + scrollbar_width = + requisition.width + GTK_SCROLLED_WINDOW_CLASS (GTK_OBJECT_GET_CLASS (popup))->scrollbar_spacing; avail_height = gdk_screen_height () - *y; @@ -415,19 +445,27 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc, screen_width = gdk_screen_width (); avail_width = screen_width - scrollbar_width; + widget = gtk_scrolled_window_get_vscrollbar (popup); + gtk_widget_get_child_requisition (widget, &requisition); + gtk_widget_size_request (ecc->popup_tree_view, &list_requisition); - min_height = MIN (list_requisition.height, - popup->vscrollbar->requisition.height); + 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; + popwin_child = gtk_bin_get_child (popwin); + popwin_style = gtk_widget_get_style (popwin_child); + + popup_child = gtk_bin_get_child (GTK_BIN (popup)); + popup_style = gtk_widget_get_style (popup_child); + /* Calculate the desired width. */ *width = list_requisition.width - + 2 * popwin->child->style->xthickness - + 2 * GTK_CONTAINER (popwin->child)->border_width - + 2 * GTK_CONTAINER (popup)->border_width - + 2 * GTK_CONTAINER (GTK_BIN (popup)->child)->border_width - + 2 * GTK_BIN (popup)->child->style->xthickness; + + 2 * popwin_style->xthickness + + 2 * gtk_container_get_border_width (GTK_CONTAINER (popwin_child)) + + 2 * gtk_container_get_border_width (GTK_CONTAINER (popup)) + + 2 * gtk_container_get_border_width (GTK_CONTAINER (popup_child)) + + 2 * popup_style->xthickness; /* Use at least the same width as the column. */ if (*width < column_width) @@ -441,15 +479,19 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc, } /* Calculate all the borders etc. that we need to add to the height. */ - work_height = (2 * popwin->child->style->ythickness - + 2 * GTK_CONTAINER (popwin->child)->border_width - + 2 * GTK_CONTAINER (popup)->border_width - + 2 * GTK_CONTAINER (GTK_BIN (popup)->child)->border_width - + 2 * GTK_BIN (popup)->child->style->xthickness); + work_height = (2 * popwin_style->ythickness + + 2 * gtk_container_get_border_width (GTK_CONTAINER (popwin_child)) + + 2 * gtk_container_get_border_width (GTK_CONTAINER (popup)) + + 2 * gtk_container_get_border_width (GTK_CONTAINER (popup_child)) + + 2 * popup_style->xthickness); + + widget = gtk_scrolled_window_get_hscrollbar (popup); + gtk_widget_get_child_requisition (widget, &requisition); /* Add on the height of the horizontal scrollbar if we need it. */ if (show_hscroll) - work_height += popup->hscrollbar->requisition.height + + work_height += + requisition.height + GTK_SCROLLED_WINDOW_CLASS (GTK_OBJECT_GET_CLASS (popup))->scrollbar_spacing; /* Check if it fits in the available height. */ @@ -494,11 +536,7 @@ e_cell_combo_selection_changed (GtkTreeSelection *selection, ECellCombo *ecc) GtkTreeIter iter; GtkTreeModel *model; -#if GTK_CHECK_VERSION(2,19,7) if (!gtk_widget_get_realized (ecc->popup_window) || !gtk_tree_selection_get_selected (selection, &model, &iter)) -#else - if (!GTK_WIDGET_REALIZED (ecc->popup_window) || !gtk_tree_selection_get_selected (selection, &model, &iter)) -#endif return; e_cell_combo_update_cell (ecc); @@ -526,7 +564,7 @@ e_cell_combo_button_press (GtkWidget *popup_window, presses outside the application will be reported to this window, which is why we hide the popup in this case. */ while (event_widget) { - event_widget = event_widget->parent; + event_widget = gtk_widget_get_parent (event_widget); if (event_widget == ecc->popup_tree_view) return FALSE; } @@ -564,7 +602,7 @@ e_cell_combo_button_release (GtkWidget *popup_window, /* See if the button was released in the list (or its children). */ while (event_widget && event_widget != ecc->popup_tree_view) - event_widget = event_widget->parent; + event_widget = gtk_widget_get_parent (event_widget); /* If it wasn't, then we just ignore the event. */ if (event_widget != ecc->popup_tree_view) @@ -601,11 +639,7 @@ e_cell_combo_key_press (GtkWidget *popup_window, && event->keyval != GDK_3270_Enter) return FALSE; -#if GTK_CHECK_VERSION(2,19,7) if (event->keyval == GDK_Escape && (!ecc->popup_window||!gtk_widget_get_visible (ecc->popup_window))) -#else - if (event->keyval == GDK_Escape && (!ecc->popup_window||!GTK_WIDGET_VISIBLE (ecc->popup_window))) -#endif return FALSE; gtk_grab_remove (ecc->popup_window); diff --git a/widgets/table/e-cell-date-edit.c b/widgets/table/e-cell-date-edit.c index 692614ff14..cab6c816ee 100644 --- a/widgets/table/e-cell-date-edit.c +++ b/widgets/table/e-cell-date-edit.c @@ -383,32 +383,16 @@ e_cell_date_edit_get_property (GObject *object, switch (property_id) { case PROP_SHOW_TIME: -#if GTK_CHECK_VERSION(2,19,7) g_value_set_boolean (value, gtk_widget_get_visible (ecde->time_entry)); -#else - g_value_set_boolean (value, GTK_WIDGET_VISIBLE (ecde->time_entry)); -#endif return; case PROP_SHOW_NOW_BUTTON: -#if GTK_CHECK_VERSION(2,19,7) g_value_set_boolean (value, gtk_widget_get_visible (ecde->now_button)); -#else - g_value_set_boolean (value, GTK_WIDGET_VISIBLE (ecde->now_button)); -#endif return; case PROP_SHOW_TODAY_BUTTON: -#if GTK_CHECK_VERSION(2,19,7) g_value_set_boolean (value, gtk_widget_get_visible (ecde->today_button)); -#else - g_value_set_boolean (value, GTK_WIDGET_VISIBLE (ecde->today_button)); -#endif return; case PROP_ALLOW_NO_DATE_SET: -#if GTK_CHECK_VERSION(2,19,7) g_value_set_boolean (value, gtk_widget_get_visible (ecde->none_button)); -#else - g_value_set_boolean (value, GTK_WIDGET_VISIBLE (ecde->none_button)); -#endif return; case PROP_USE_24_HOUR_FORMAT: g_value_set_boolean (value, ecde->use_24_hour_format); @@ -503,6 +487,7 @@ e_cell_date_edit_do_popup (ECellPopup *ecp, gint view_col) { ECellDateEdit *ecde = E_CELL_DATE_EDIT (ecp); + GdkWindow *window; e_cell_date_edit_show_popup (ecde, row, view_col); e_cell_date_edit_set_popup_values (ecde); @@ -511,7 +496,8 @@ e_cell_date_edit_do_popup (ECellPopup *ecp, /* Set the focus to the first widget. */ gtk_widget_grab_focus (ecde->time_entry); - gdk_window_focus (ecde->popup_window->window, GDK_CURRENT_TIME); + window = gtk_widget_get_window (ecde->popup_window); + gdk_window_focus (window, GDK_CURRENT_TIME); return TRUE; } @@ -627,6 +613,7 @@ e_cell_date_edit_show_popup (ECellDateEdit *ecde, gint row, gint view_col) { + GdkWindow *window; gint x, y, width, height; if (ecde->need_time_list_rebuild) @@ -636,10 +623,11 @@ e_cell_date_edit_show_popup (ECellDateEdit *ecde, e_cell_date_edit_get_popup_pos (ecde, row, view_col, &x, &y, &height, &width); + window = gtk_widget_get_window (ecde->popup_window); gtk_window_move (GTK_WINDOW (ecde->popup_window), x, y); gtk_widget_set_size_request (ecde->popup_window, width, height); gtk_widget_realize (ecde->popup_window); - gdk_window_resize (ecde->popup_window->window, width, height); + gdk_window_resize (window, width, height); gtk_widget_show (ecde->popup_window); e_cell_popup_set_shown (E_CELL_POPUP (ecde), TRUE); @@ -659,10 +647,15 @@ e_cell_date_edit_get_popup_pos (ECellDateEdit *ecde, ETableItem *eti = E_TABLE_ITEM (ecp->popup_cell_view->cell_view.e_table_item_view); GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (eti)->canvas); GtkRequisition popup_requisition; + GtkAdjustment *adjustment; + GtkLayout *layout; + GdkWindow *window; gint avail_height, screen_width, column_width, row_height; gdouble x1, y1, wx, wy; + gint value; - gdk_window_get_origin (canvas->window, x, y); + window = gtk_widget_get_window (canvas); + gdk_window_get_origin (window, x, y); x1 = e_table_header_col_diff (eti->header, 0, view_col + 1); y1 = e_table_item_row_diff (eti, 0, row + 1); @@ -684,9 +677,10 @@ e_cell_date_edit_get_popup_pos (ECellDateEdit *ecde, *x += x1; /* The ETable positions don't include the grid lines, I think, so we add 1. */ - *y += y1 + 1 - - (gint)((GnomeCanvas *)canvas)->layout.vadjustment->value - + ((GnomeCanvas *)canvas)->zoom_yofs; + layout = &GNOME_CANVAS (canvas)->layout; + adjustment = gtk_layout_get_vadjustment (layout); + value = (gint) gtk_adjustment_get_value (adjustment); + *y += y1 + 1 - value + ((GnomeCanvas *)canvas)->zoom_yofs; avail_height = gdk_screen_height () - *y; diff --git a/widgets/table/e-cell-popup.c b/widgets/table/e-cell-popup.c index 6deb4c46a9..32de41ecb4 100644 --- a/widgets/table/e-cell-popup.c +++ b/widgets/table/e-cell-popup.c @@ -277,6 +277,8 @@ ecp_draw (ECellView *ecv, GdkDrawable *drawable, ecp->popup_arrow_shown = show_popup_arrow; if (show_popup_arrow) { + GtkStyle *style; + e_cell_draw (ecp_view->child_view, drawable, model_col, view_col, row, flags, x1, y1, x2 - E_CELL_POPUP_ARROW_WIDTH, y2); @@ -291,11 +293,13 @@ ecp_draw (ECellView *ecv, GdkDrawable *drawable, else shadow = GTK_SHADOW_OUT; - gtk_paint_box (canvas->style, drawable, + style = gtk_widget_get_style (canvas); + + gtk_paint_box (style, drawable, GTK_STATE_NORMAL, shadow, &rect, canvas, "ecellpopup", rect.x, rect.y, rect.width, rect.height); - gtk_paint_arrow (canvas->style, drawable, + gtk_paint_arrow (style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE, &rect, canvas, NULL, GTK_ARROW_DOWN, TRUE, diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c index b501c47c10..ba246316bb 100644 --- a/widgets/table/e-cell-text.c +++ b/widgets/table/e-cell-text.c @@ -274,6 +274,7 @@ ect_queue_redraw (ECellTextView *text_view, gint view_col, gint view_row) static void ect_stop_editing (ECellTextView *text_view, gboolean commit) { + GdkWindow *window; CellEdit *edit = text_view->edit; gint row, view_col, model_col; gchar *old_text, *text; @@ -281,6 +282,8 @@ ect_stop_editing (ECellTextView *text_view, gboolean commit) if (!edit) return; + window = gtk_widget_get_window (GTK_WIDGET (text_view->canvas)); + row = edit->row; view_col = edit->view_col; model_col = edit->model_col; @@ -290,7 +293,7 @@ ect_stop_editing (ECellTextView *text_view, gboolean commit) if (edit->tep) g_object_unref (edit->tep); if (!edit->default_cursor_shown) { - gdk_window_set_cursor (GTK_WIDGET(text_view->canvas)->window, NULL); + gdk_window_set_cursor (window, NULL); edit->default_cursor_shown = TRUE; } if (edit->timeout_id) { @@ -389,8 +392,10 @@ static void ect_realize (ECellView *ecell_view) { ECellTextView *text_view = (ECellTextView *) ecell_view; + GdkWindow *window; - text_view->gc = gdk_gc_new (GTK_WIDGET (text_view->canvas)->window); + window = gtk_widget_get_window (GTK_WIDGET (text_view->canvas)); + text_view->gc = gdk_gc_new (window); text_view->i_cursor = gdk_cursor_new (GDK_XTERM); @@ -730,21 +735,20 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, GdkColor *foreground; GtkWidget *canvas = GTK_WIDGET (text_view->canvas); GdkRectangle clip_rect; + GtkStyle *style; gint x_origin, y_origin, vspacing; + style = gtk_widget_get_style (canvas); + selected = flags & E_CELL_SELECTED; if (selected) { -#if GTK_CHECK_VERSION(2,19,7) if (gtk_widget_has_focus (canvas)) -#else - if (GTK_WIDGET_HAS_FOCUS (canvas)) -#endif - foreground = &canvas->style->fg [GTK_STATE_SELECTED]; + foreground = &style->fg[GTK_STATE_SELECTED]; else - foreground = &canvas->style->fg [GTK_STATE_ACTIVE]; + foreground = &style->fg[GTK_STATE_ACTIVE]; } else { - foreground = &canvas->style->text [GTK_STATE_NORMAL]; + foreground = &style->text[GTK_STATE_NORMAL]; if (ect->color_column != -1) { gchar *color_spec; @@ -805,11 +809,11 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, end_index = edit->selection_start ^ edit->selection_end ^ start_index; if (edit->has_selection) { - selection_gc = canvas->style->base_gc [GTK_STATE_SELECTED]; - text_gc = canvas->style->text_gc[GTK_STATE_SELECTED]; + selection_gc = style->base_gc[GTK_STATE_SELECTED]; + text_gc = style->text_gc[GTK_STATE_SELECTED]; } else { - selection_gc = canvas->style->base_gc [GTK_STATE_ACTIVE]; - text_gc = canvas->style->text_gc[GTK_STATE_ACTIVE]; + selection_gc = style->base_gc [GTK_STATE_ACTIVE]; + text_gc = style->text_gc[GTK_STATE_ACTIVE]; } gdk_gc_set_clip_rectangle (selection_gc, &clip_rect); @@ -1126,7 +1130,10 @@ ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col #endif if (edit_display) { if (edit->default_cursor_shown) { - gdk_window_set_cursor (canvas->window, text_view->i_cursor); + GdkWindow *window; + + window = gtk_widget_get_window (canvas); + gdk_window_set_cursor (window, text_view->i_cursor); edit->default_cursor_shown = FALSE; } } @@ -1137,7 +1144,10 @@ ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col #endif if (edit_display) { if (!edit->default_cursor_shown) { - gdk_window_set_cursor (canvas->window, NULL); + GdkWindow *window; + + window = gtk_widget_get_window (canvas); + gdk_window_set_cursor (window, NULL); edit->default_cursor_shown = TRUE; } } @@ -1334,6 +1344,7 @@ ect_print (ECellView *ecell_view, GtkPrintContext *context, ECellText *ect = E_CELL_TEXT(ecell_view->ecell); ECellTextView *ectView = (ECellTextView *)ecell_view; GtkWidget *canvas = GTK_WIDGET(ectView->canvas); + GtkStyle *style; PangoDirection dir; gboolean strikeout, underline; cairo_t *cr; @@ -1355,12 +1366,14 @@ ect_print (ECellView *ecell_view, GtkPrintContext *context, cairo_rectangle (cr, 2, 2, width + 2, height + 2); cairo_clip(cr); + style = gtk_widget_get_style (canvas); pango_context = gtk_widget_get_pango_context (canvas); - font_metrics = pango_context_get_metrics (pango_context, - canvas->style->font_desc, pango_context_get_language(pango_context)); - ty = (gdouble)(text_height - - pango_font_metrics_get_ascent (font_metrics) - - pango_font_metrics_get_descent (font_metrics)) / 2.0 /(gdouble)PANGO_SCALE; + font_metrics = pango_context_get_metrics ( + pango_context, style->font_desc, + pango_context_get_language(pango_context)); + ty = (gdouble)(text_height - + pango_font_metrics_get_ascent (font_metrics) - + pango_font_metrics_get_descent (font_metrics)) / 2.0 /(gdouble)PANGO_SCALE; strikeout = ect->strikeout_column >= 0 && row >= 0 && e_table_model_value_at (ecell_view->e_table_model, ect->strikeout_column, row); diff --git a/widgets/table/e-cell-toggle.c b/widgets/table/e-cell-toggle.c index 5f7cc66321..08a9d8dcc3 100644 --- a/widgets/table/e-cell-toggle.c +++ b/widgets/table/e-cell-toggle.c @@ -173,8 +173,10 @@ static void cell_toggle_realize (ECellView *ecell_view) { ECellToggleView *toggle_view = (ECellToggleView *) ecell_view; + GdkWindow *window; - toggle_view->gc = gdk_gc_new (GTK_WIDGET (toggle_view->canvas)->window); + window = gtk_widget_get_window (GTK_WIDGET (toggle_view->canvas)); + toggle_view->gc = gdk_gc_new (window); } static void diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c index 8a8017e2e7..b5506af13b 100644 --- a/widgets/table/e-cell-tree.c +++ b/widgets/table/e-cell-tree.c @@ -169,11 +169,13 @@ static void ect_realize (ECellView *ecell_view) { ECellTreeView *tree_view = (ECellTreeView *) ecell_view; + GdkWindow *window; /* realize our subcell view */ e_cell_realize (tree_view->subcell_view); - tree_view->gc = gdk_gc_new (GTK_WIDGET (tree_view->canvas)->window); + window = gtk_widget_get_window (GTK_WIDGET (tree_view->canvas)); + tree_view->gc = gdk_gc_new (window); gdk_gc_set_line_attributes (tree_view->gc, 1, GDK_LINE_ON_OFF_DASH, @@ -229,11 +231,19 @@ draw_retro_expander (ECellTreeView *ectv, GdkDrawable *drawable, gboolean expand static void draw_expander (ECellTreeView *ectv, GdkDrawable *drawable, GtkExpanderStyle expander_style, GtkStateType state, GdkRectangle *rect) { - GtkWidget *tree = GTK_WIDGET (ectv->canvas)->parent; + GtkStyle *style; + GtkWidget *tree; gint exp_size; + + tree = gtk_widget_get_parent (GTK_WIDGET (ectv->canvas)); + style = gtk_widget_get_style (tree); + gtk_widget_style_get (tree, "expander_size", &exp_size, NULL); - gtk_paint_expander (tree->style, drawable, state, rect, tree, "treeview", rect->x + rect->width - exp_size / 2, rect->y + rect->height / 2, expander_style); + gtk_paint_expander ( + style, drawable, state, rect, tree, "treeview", + rect->x + rect->width - exp_size / 2, + rect->y + rect->height / 2, expander_style); } /* @@ -250,12 +260,16 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, ETreePath node; GdkRectangle rect, *clip_rect = NULL; GtkWidget *canvas = GTK_WIDGET (tree_view->canvas); - GdkGC *fg_gc = canvas->style->fg_gc[GTK_STATE_ACTIVE]; + GtkStyle *style; + GdkGC *fg_gc; GdkColor *foreground; gboolean selected; gint offset, subcell_offset; + style = gtk_widget_get_style (canvas); + fg_gc = style->fg_gc[GTK_STATE_ACTIVE]; + selected = flags & E_CELL_SELECTED; /* only draw the tree effects if we're the active sort */ @@ -263,7 +277,9 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, GdkPixbuf *node_image; gint node_image_width = 0, node_image_height = 0; ETreePath parent_node; - ETree *tree = E_TREE (canvas->parent); + ETree *tree; + + tree = E_TREE (gtk_widget_get_parent (canvas)); gtk_widget_style_get (GTK_WIDGET (tree), "retro_look", &tree_view->retro_look, @@ -295,9 +311,9 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, clip_rect = ▭ if (selected) { - foreground = &canvas->style->text [GTK_STATE_SELECTED]; + foreground = &style->text [GTK_STATE_SELECTED]; } else { - foreground = &canvas->style->text [GTK_STATE_NORMAL]; + foreground = &style->text [GTK_STATE_NORMAL]; } gdk_gc_set_foreground (tree_view->gc, foreground); @@ -445,6 +461,8 @@ typedef struct { static gboolean animate_expander (gpointer data) { + GtkLayout *layout; + GdkWindow *window; animate_closure_t *closure = (animate_closure_t *) data; if (closure->finish) { @@ -454,9 +472,14 @@ animate_expander (gpointer data) return FALSE; } - draw_expander (closure->ectv, GTK_LAYOUT (closure->ectv->canvas)->bin_window, - closure->expanded ? GTK_EXPANDER_SEMI_COLLAPSED : GTK_EXPANDER_SEMI_EXPANDED, - GTK_STATE_NORMAL, &closure->area); + layout = GTK_LAYOUT (closure->ectv->canvas); + window = gtk_layout_get_bin_window (layout); + + draw_expander ( + closure->ectv, window, closure->expanded ? + GTK_EXPANDER_SEMI_COLLAPSED : + GTK_EXPANDER_SEMI_EXPANDED, + GTK_STATE_NORMAL, &closure->area); closure->finish = TRUE; return TRUE; @@ -468,6 +491,8 @@ animate_expander (gpointer data) static gint ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col, gint row, ECellFlags flags, ECellActions *actions) { + GtkLayout *layout; + GdkWindow *window; ECellTreeView *tree_view = (ECellTreeView *) ecell_view; ETreeModel *tree_model = e_cell_tree_get_tree_model (ecell_view->e_table_model, row); ETreeTableAdapter *etta = e_cell_tree_get_tree_table_adapter(ecell_view->e_table_model, row); @@ -475,6 +500,9 @@ ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col gint offset = offset_of_node (ecell_view->e_table_model, row); gint result; + layout = GTK_LAYOUT (tree_view->canvas); + window = gtk_layout_get_bin_window (layout); + switch (event->type) { case GDK_BUTTON_PRESS: @@ -497,9 +525,11 @@ ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col if (hgt != area.height) /* Composite cells */ area.height += hgt; - draw_expander (tree_view, GTK_LAYOUT (tree_view->canvas)->bin_window, - expanded ? GTK_EXPANDER_SEMI_EXPANDED : GTK_EXPANDER_SEMI_COLLAPSED, - GTK_STATE_NORMAL, &area); + draw_expander ( + tree_view, window, expanded ? + GTK_EXPANDER_SEMI_EXPANDED : + GTK_EXPANDER_SEMI_COLLAPSED, + GTK_STATE_NORMAL, &area); closure->ectv = tree_view; closure->etta = etta; closure->node = node; @@ -526,9 +556,11 @@ ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col e_table_item_get_cell_geometry (tree_view->cell_view.e_table_item_view, &tmp_row, &view_col, &area.x, &area.y, NULL, &area.height); area.width = offset - 2; - draw_expander (tree_view, GTK_LAYOUT (tree_view->canvas)->bin_window, - e_tree_table_adapter_node_is_expanded (etta, node) ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, - in_expander ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL, &area); + draw_expander ( + tree_view, window, + e_tree_table_adapter_node_is_expanded (etta, node) ? + GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, + in_expander ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL, &area); tree_view->prelit = in_expander; return TRUE; } @@ -544,9 +576,11 @@ ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col e_table_item_get_cell_geometry (tree_view->cell_view.e_table_item_view, &tmp_row, &view_col, &area.x, &area.y, NULL, &area.height); area.width = offset - 2; - draw_expander (tree_view, GTK_LAYOUT (tree_view->canvas)->bin_window, - e_tree_table_adapter_node_is_expanded (etta, node) ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, - GTK_STATE_NORMAL, &area); + draw_expander ( + tree_view, window, + e_tree_table_adapter_node_is_expanded (etta, node) ? + GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, + GTK_STATE_NORMAL, &area); tree_view->prelit = FALSE; } return TRUE; diff --git a/widgets/table/e-table-click-to-add.c b/widgets/table/e-table-click-to-add.c index deebd7939c..e50d0f4274 100644 --- a/widgets/table/e-table-click-to-add.c +++ b/widgets/table/e-table-click-to-add.c @@ -73,21 +73,24 @@ etcta_cursor_change (GtkObject *object, gint row, gint col, ETableClickToAdd *et static void etcta_style_set (ETableClickToAdd *etcta, GtkStyle *previous_style) { - GtkWidget *widget = GTK_WIDGET(GNOME_CANVAS_ITEM(etcta)->canvas); + GtkWidget *widget; + GtkStyle *style; - if (etcta->rect) { - gnome_canvas_item_set (etcta->rect, - "outline_color_gdk", &widget->style->fg[GTK_STATE_NORMAL], - "fill_color_gdk", &widget->style->bg[GTK_STATE_NORMAL], - NULL ); + widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etcta)->canvas); + style = gtk_widget_get_style (widget); - } + if (etcta->rect) + gnome_canvas_item_set ( + etcta->rect, + "outline_color_gdk", &style->fg[GTK_STATE_NORMAL], + "fill_color_gdk", &style->bg[GTK_STATE_NORMAL], + NULL); if (etcta->text) - gnome_canvas_item_set (etcta->text, - "fill_color_gdk", &widget->style->text[GTK_STATE_NORMAL], - NULL); - + gnome_canvas_item_set ( + etcta->text, + "fill_color_gdk", &style->text[GTK_STATE_NORMAL], + NULL); } static void @@ -237,28 +240,34 @@ etcta_set_property (GObject *object, static void create_rect_and_text (ETableClickToAdd *etcta) { - GtkWidget *widget = GTK_WIDGET (GNOME_CANVAS_ITEM(etcta)->canvas); + GtkWidget *widget; + GtkStyle *style; + + widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etcta)->canvas); + style = gtk_widget_get_style (widget); if (!etcta->rect) - etcta->rect = gnome_canvas_item_new(GNOME_CANVAS_GROUP(etcta), - gnome_canvas_rect_get_type(), - "x1", (gdouble) 0, - "y1", (gdouble) 0, - "x2", (gdouble) etcta->width - 1, - "y2", (gdouble) etcta->height - 1, - "outline_color_gdk", &widget->style->fg[GTK_STATE_NORMAL], - "fill_color_gdk", &widget->style->bg[GTK_STATE_NORMAL], - NULL); + etcta->rect = gnome_canvas_item_new ( + GNOME_CANVAS_GROUP (etcta), + gnome_canvas_rect_get_type (), + "x1", (gdouble) 0, + "y1", (gdouble) 0, + "x2", (gdouble) etcta->width - 1, + "y2", (gdouble) etcta->height - 1, + "outline_color_gdk", &style->fg[GTK_STATE_NORMAL], + "fill_color_gdk", &style->bg[GTK_STATE_NORMAL], + NULL); if (!etcta->text) - etcta->text = gnome_canvas_item_new(GNOME_CANVAS_GROUP(etcta), - e_text_get_type(), - "text", etcta->message ? etcta->message : "", - "anchor", GTK_ANCHOR_NW, - "width", etcta->width - 4, - "draw_background", FALSE, - "fill_color_gdk", &widget->style->text[GTK_STATE_NORMAL], - NULL); + etcta->text = gnome_canvas_item_new ( + GNOME_CANVAS_GROUP (etcta), + e_text_get_type (), + "text", etcta->message ? etcta->message : "", + "anchor", GTK_ANCHOR_NW, + "width", etcta->width - 4, + "draw_background", FALSE, + "fill_color_gdk", &style->text[GTK_STATE_NORMAL], + NULL); } static void diff --git a/widgets/table/e-table-config.c b/widgets/table/e-table-config.c index 23046c717a..736473a81c 100644 --- a/widgets/table/e-table-config.c +++ b/widgets/table/e-table-config.c @@ -549,18 +549,27 @@ do_sort_and_group_config_dialog (ETableConfig *config, gboolean is_sort) static void do_fields_config_dialog (ETableConfig *config) { + GtkDialog *dialog; + GtkWidget *widget; gint response, running = 1; + dialog = GTK_DIALOG (config->dialog_show_fields); + gtk_widget_ensure_style (config->dialog_show_fields); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (config->dialog_show_fields)->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (config->dialog_show_fields)->action_area), 12); + + widget = gtk_dialog_get_content_area (dialog); + gtk_container_set_border_width (GTK_CONTAINER (widget), 0); + + widget = gtk_dialog_get_action_area (dialog); + gtk_container_set_border_width (GTK_CONTAINER (widget), 12); config->temp_state = e_table_state_duplicate (config->state); setup_fields (config); - gtk_window_set_transient_for (GTK_WINDOW (config->dialog_show_fields), - GTK_WINDOW (config->dialog_toplevel)); + gtk_window_set_transient_for ( + GTK_WINDOW (config->dialog_show_fields), + GTK_WINDOW (config->dialog_toplevel)); do { response = gtk_dialog_run (GTK_DIALOG(config->dialog_show_fields)); @@ -759,6 +768,7 @@ sort_combo_changed (GtkComboBox *combo_box, ETableConfigSortWidgets *sort) ETableConfig *config = sort->e_table_config; ETableSortInfo *sort_info = config->temp_state->sort_info; ETableConfigSortWidgets *base = &config->sort[0]; + GtkToggleButton *toggle_button; gint idx = sort - base; gchar *s; @@ -775,8 +785,9 @@ sort_combo_changed (GtkComboBox *combo_box, ETableConfigSortWidgets *sort) return; } - c.ascending = GTK_TOGGLE_BUTTON ( - config->sort [idx].radio_ascending)->active; + toggle_button = GTK_TOGGLE_BUTTON ( + config->sort[idx].radio_ascending); + c.ascending = gtk_toggle_button_get_active (toggle_button); c.column = col; e_table_sort_info_sorting_set_nth (sort_info, idx, c); @@ -799,7 +810,7 @@ sort_ascending_toggled (GtkToggleButton *t, ETableConfigSortWidgets *sort) ETableSortColumn c; c = e_table_sort_info_sorting_get_nth (si, idx); - c.ascending = t->active; + c.ascending = gtk_toggle_button_get_active (t); e_table_sort_info_sorting_set_nth (si, idx, c); } @@ -877,6 +888,7 @@ group_combo_changed (GtkComboBox *combo_box, ETableConfigSortWidgets *group) s = configure_combo_box_get_active (combo_box); if (s != NULL) { + GtkToggleButton *toggle_button; ETableSortColumn c; gint col; @@ -887,8 +899,9 @@ group_combo_changed (GtkComboBox *combo_box, ETableConfigSortWidgets *group) return; } - c.ascending = GTK_TOGGLE_BUTTON ( - config->group [idx].radio_ascending)->active; + toggle_button = GTK_TOGGLE_BUTTON ( + config->group[idx].radio_ascending); + c.ascending = gtk_toggle_button_get_active (toggle_button); c.column = col; e_table_sort_info_grouping_set_nth (sort_info, idx, c); @@ -911,7 +924,7 @@ group_ascending_toggled (GtkToggleButton *t, ETableConfigSortWidgets *group) ETableSortColumn c; c = e_table_sort_info_grouping_get_nth (si, idx); - c.ascending = t->active; + c.ascending = gtk_toggle_button_get_active (t); e_table_sort_info_grouping_set_nth (si, idx, c); } @@ -1324,15 +1337,23 @@ e_table_config_new (const gchar *header, GtkWindow *parent_window) { ETableConfig *config = g_object_new (E_TABLE_CONFIG_TYPE, NULL); + GtkDialog *dialog; + GtkWidget *widget; if (e_table_config_construct (config, header, spec, state, parent_window) == NULL) { g_object_unref (config); return NULL; } + dialog = GTK_DIALOG (config->dialog_toplevel); + gtk_widget_ensure_style (config->dialog_toplevel); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (config->dialog_toplevel)->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (config->dialog_toplevel)->action_area), 12); + + widget = gtk_dialog_get_content_area (dialog); + gtk_container_set_border_width (GTK_CONTAINER (widget), 0); + + widget = gtk_dialog_get_action_area (dialog); + gtk_container_set_border_width (GTK_CONTAINER (widget), 12); gtk_dialog_set_response_sensitive (GTK_DIALOG (config->dialog_toplevel), GTK_RESPONSE_APPLY, FALSE); @@ -1350,6 +1371,9 @@ e_table_config_new (const gchar *header, void e_table_config_raise (ETableConfig *config) { - gdk_window_raise (GTK_WIDGET (config->dialog_toplevel)->window); + GdkWindow *window; + + window = gtk_widget_get_window (GTK_WIDGET (config->dialog_toplevel)); + gdk_window_raise (window); } diff --git a/widgets/table/e-table-field-chooser-dialog.c b/widgets/table/e-table-field-chooser-dialog.c index 9641f6c58e..c05506d953 100644 --- a/widgets/table/e-table-field-chooser-dialog.c +++ b/widgets/table/e-table-field-chooser-dialog.c @@ -85,17 +85,20 @@ e_table_field_chooser_dialog_class_init (ETableFieldChooserDialogClass *klass) static void e_table_field_chooser_dialog_init (ETableFieldChooserDialog *e_table_field_chooser_dialog) { + GtkDialog *dialog; + GtkWidget *content_area; GtkWidget *widget; + dialog = GTK_DIALOG (e_table_field_chooser_dialog); + e_table_field_chooser_dialog->etfc = NULL; e_table_field_chooser_dialog->dnd_code = g_strdup(""); e_table_field_chooser_dialog->full_header = NULL; e_table_field_chooser_dialog->header = NULL; - gtk_dialog_add_button(GTK_DIALOG(e_table_field_chooser_dialog), - GTK_STOCK_CLOSE, GTK_RESPONSE_OK); + gtk_dialog_add_button (dialog, GTK_STOCK_CLOSE, GTK_RESPONSE_OK); - gtk_window_set_resizable(GTK_WINDOW(e_table_field_chooser_dialog), TRUE); + gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE); widget = e_table_field_chooser_new(); e_table_field_chooser_dialog->etfc = E_TABLE_FIELD_CHOOSER(widget); @@ -106,12 +109,12 @@ e_table_field_chooser_dialog_init (ETableFieldChooserDialog *e_table_field_choos "header", e_table_field_chooser_dialog->header, NULL); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(e_table_field_chooser_dialog)->vbox), - widget, TRUE, TRUE, 0); + content_area = gtk_dialog_get_content_area (dialog); + gtk_box_pack_start (GTK_BOX (content_area), widget, TRUE, TRUE, 0); - gtk_widget_show(GTK_WIDGET(widget)); + gtk_widget_show (GTK_WIDGET(widget)); - gtk_window_set_title (GTK_WINDOW (e_table_field_chooser_dialog), _("Add a Column")); + gtk_window_set_title (GTK_WINDOW (dialog), _("Add a Column")); } GtkWidget* diff --git a/widgets/table/e-table-field-chooser-item.c b/widgets/table/e-table-field-chooser-item.c index 69c0b58249..a04e4f3742 100644 --- a/widgets/table/e-table-field-chooser-item.c +++ b/widgets/table/e-table-field-chooser-item.c @@ -214,12 +214,14 @@ etfci_update (GnomeCanvasItem *item, gdouble *affine, ArtSVP *clip_path, gint fl static void etfci_font_load (ETableFieldChooserItem *etfci) { + GtkWidget *widget; GtkStyle *style; if (etfci->font_desc) pango_font_description_free (etfci->font_desc); - style = GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas)->style; + widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas); + style = gtk_widget_get_style (widget); etfci->font_desc = pango_font_description_copy (style->font_desc); } @@ -462,7 +464,7 @@ etfci_draw (GnomeCanvasItem *item, GdkDrawable *drawable, gint x, gint y, gint w rows = e_table_header_count (etfci->combined_header); - style = GTK_WIDGET (canvas)->style; + style = gtk_widget_get_style (GTK_WIDGET (canvas)); state = gtk_widget_get_state (GTK_WIDGET (canvas)); y1 = y2 = 0; @@ -519,6 +521,8 @@ etfci_start_drag (ETableFieldChooserItem *etfci, GdkEvent *event, gdouble x, gdo GtkWidget *widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas); GtkTargetList *list; GdkDragContext *context; + GdkWindow *window; + GtkStyle *style; GtkStateType state; ETableCol *ecol; GdkPixmap *pixmap; @@ -551,24 +555,26 @@ etfci_start_drag (ETableFieldChooserItem *etfci, GdkEvent *event, gdouble x, gdo g_free(etfci_drag_types[0].target); button_height = e_table_header_compute_height (ecol, widget); - pixmap = gdk_pixmap_new (widget->window, etfci->width, button_height, -1); + window = gtk_widget_get_window (widget); + pixmap = gdk_pixmap_new (window, etfci->width, button_height, -1); + style = gtk_widget_get_style (widget); state = gtk_widget_get_state (widget); - e_table_header_draw_button (pixmap, ecol, - widget->style, state, - widget, - 0, 0, - etfci->width, button_height, - etfci->width, button_height, - E_TABLE_COL_ARROW_NONE); - - gtk_drag_set_icon_pixmap (context, - gdk_drawable_get_colormap (GDK_DRAWABLE (widget->window)), - pixmap, - NULL, - etfci->width / 2, - button_height / 2); + e_table_header_draw_button ( + pixmap, ecol, style, + state, widget, 0, 0, + etfci->width, button_height, + etfci->width, button_height, + E_TABLE_COL_ARROW_NONE); + + gtk_drag_set_icon_pixmap ( + context, + gdk_drawable_get_colormap (GDK_DRAWABLE (window)), + pixmap, NULL, + etfci->width / 2, + button_height / 2); + g_object_unref (pixmap); etfci->maybe_drag = FALSE; } diff --git a/widgets/table/e-table-field-chooser.c b/widgets/table/e-table-field-chooser.c index 2e73bafcfc..e56293b111 100644 --- a/widgets/table/e-table-field-chooser.c +++ b/widgets/table/e-table-field-chooser.c @@ -94,9 +94,9 @@ ensure_nonzero_step_increments (ETableFieldChooser *etfc) so use 16 pixels which should be OK */ if (va) - va->step_increment = 16.0; + gtk_adjustment_set_step_increment (va, 16.0); if (ha) - ha->step_increment = 16.0; + gtk_adjustment_set_step_increment (ha, 16.0); } static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, ETableFieldChooser *etfc) diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c index e99270bd4b..72f2323acd 100644 --- a/widgets/table/e-table-group-container.c +++ b/widgets/table/e-table-group-container.c @@ -146,6 +146,7 @@ e_table_group_container_construct (GnomeCanvasGroup *parent, ETableGroupContaine { ETableCol *col; ETableSortColumn column = e_table_sort_info_grouping_get_nth(sort_info, n); + GtkWidget *widget; GtkStyle *style; col = e_table_header_get_column_by_col_idx(full_header, column.column); @@ -160,7 +161,8 @@ e_table_group_container_construct (GnomeCanvasGroup *parent, ETableGroupContaine etgc->n = n; etgc->ascending = column.ascending; - style = GTK_WIDGET (GNOME_CANVAS_ITEM (etgc)->canvas)->style; + widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etgc)->canvas); + style = gtk_widget_get_style (widget); etgc->font_desc = pango_font_description_copy (style->font_desc); etgc->open = TRUE; diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c index 57e0e42a82..133a368754 100644 --- a/widgets/table/e-table-header-item.c +++ b/widgets/table/e-table-header-item.c @@ -498,6 +498,9 @@ make_shaped_window_from_xpm (const gchar **xpm) static void ethi_add_drop_marker (ETableHeaderItem *ethi, gint col, gboolean recreate) { + GnomeCanvas *canvas; + GtkAdjustment *adjustment; + GdkWindow *window; gint rx, ry; gint x; @@ -515,14 +518,15 @@ ethi_add_drop_marker (ETableHeaderItem *ethi, gint col, gboolean recreate) arrow_down = make_shaped_window_from_xpm (arrow_down_xpm); } - gdk_window_get_origin ( - GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas)->window, - &rx, &ry); + canvas = GNOME_CANVAS_ITEM (ethi)->canvas; + window = gtk_widget_get_window (GTK_WIDGET (canvas)); + gdk_window_get_origin (window, &rx, &ry); - rx -= gtk_layout_get_hadjustment ( - GTK_LAYOUT (GNOME_CANVAS_ITEM (ethi)->canvas))->value; - ry -= gtk_layout_get_vadjustment ( - GTK_LAYOUT (GNOME_CANVAS_ITEM (ethi)->canvas))->value; + adjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (canvas)); + rx -= gtk_adjustment_get_value (adjustment); + + adjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (canvas)); + ry -= gtk_adjustment_get_value (adjustment); gtk_window_move ( GTK_WINDOW (arrow_down), @@ -645,7 +649,13 @@ scroll_timeout (gpointer data) { ETableHeaderItem *ethi = data; gint dx = 0; - GtkAdjustment *h, *v; + GtkLayout *layout; + GtkAdjustment *adjustment; + gdouble hadjustment_value; + gdouble vadjustment_value; + gdouble page_size; + gdouble lower; + gdouble upper; gdouble value; if (ethi->scroll_direction & ET_SCROLL_RIGHT) @@ -653,20 +663,35 @@ scroll_timeout (gpointer data) if (ethi->scroll_direction & ET_SCROLL_LEFT) dx -= 20; - h = GTK_LAYOUT(GNOME_CANVAS_ITEM (ethi)->canvas)->hadjustment; - v = GTK_LAYOUT(GNOME_CANVAS_ITEM (ethi)->canvas)->vadjustment; + layout = GTK_LAYOUT (GNOME_CANVAS_ITEM (ethi)->canvas); + + adjustment = gtk_layout_get_hadjustment (layout); + hadjustment_value = gtk_adjustment_get_value (adjustment); + + adjustment = gtk_layout_get_vadjustment (layout); + vadjustment_value = gtk_adjustment_get_value (adjustment); + + value = hadjustment_value; + + adjustment = gtk_layout_get_hadjustment (layout); + page_size = gtk_adjustment_get_page_size (adjustment); + lower = gtk_adjustment_get_lower (adjustment); + upper = gtk_adjustment_get_upper (adjustment); - value = h->value; + gtk_adjustment_set_value ( + adjustment, CLAMP ( + hadjustment_value + dx, lower, upper - page_size)); - gtk_adjustment_set_value(h, CLAMP(h->value + dx, h->lower, h->upper - h->page_size)); + hadjustment_value = gtk_adjustment_get_value (adjustment); - if (h->value != value) - do_drag_motion(ethi, - ethi->last_drop_context, - ethi->last_drop_x + h->value, - ethi->last_drop_y + v->value, - ethi->last_drop_time, - TRUE); + if (hadjustment_value != value) + do_drag_motion( + ethi, + ethi->last_drop_context, + ethi->last_drop_x + hadjustment_value, + ethi->last_drop_y + vadjustment_value, + ethi->last_drop_time, + TRUE); return TRUE; } @@ -723,6 +748,10 @@ ethi_drag_motion (GtkWidget *widget, guint time, ETableHeaderItem *ethi) { + GtkAllocation allocation; + GtkAdjustment *adjustment; + gdouble hadjustment_value; + gdouble vadjustment_value; gchar *droptype, *headertype; guint direction = 0; @@ -739,9 +768,11 @@ ethi_drag_motion (GtkWidget *widget, g_free (headertype); + gtk_widget_get_allocation (widget, &allocation); + if (x < 20) direction |= ET_SCROLL_LEFT; - if (x > widget->allocation.width - 20) + if (x > allocation.width - 20) direction |= ET_SCROLL_RIGHT; ethi->last_drop_x = x; @@ -750,12 +781,17 @@ ethi_drag_motion (GtkWidget *widget, ethi->last_drop_context = context; context_connect (ethi, context); - do_drag_motion (ethi, - context, - x + GTK_LAYOUT(widget)->hadjustment->value, - y + GTK_LAYOUT(widget)->vadjustment->value, - time, - FALSE); + adjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (widget)); + hadjustment_value = gtk_adjustment_get_value (adjustment); + + adjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (widget)); + vadjustment_value = gtk_adjustment_get_value (adjustment); + + do_drag_motion ( + ethi, context, + x + hadjustment_value, + y + vadjustment_value, + time, FALSE); if (direction != 0) scroll_on (ethi, direction); @@ -781,20 +817,23 @@ ethi_drag_data_received (GtkWidget *canvas, GdkDragContext *drag_context, gint x, gint y, - GtkSelectionData *data, + GtkSelectionData *selection_data, guint info, guint time, ETableHeaderItem *ethi) { + const guchar *data; gint found = FALSE; gint count; gint column; gint drop_col; gint i; - if (data->data) { + data = gtk_selection_data_get_data (selection_data); + + if (data != NULL) { count = e_table_header_count(ethi->eth); - column = atoi((gchar *)data->data); + column = atoi((gchar *)data); drop_col = ethi->drop_col; ethi->drop_col = -1; @@ -891,6 +930,7 @@ static void ethi_realize (GnomeCanvasItem *item) { ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); + GtkStyle *style; GtkTargetEntry ethi_drop_types [] = { { (gchar *) TARGET_ETABLE_COL_TYPE, 0, TARGET_ETABLE_COL_HEADER }, }; @@ -898,8 +938,10 @@ ethi_realize (GnomeCanvasItem *item) if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)-> realize) (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->realize)(item); + style = gtk_widget_get_style (GTK_WIDGET (item->canvas)); + if (!ethi->font_desc) - ethi_font_set (ethi, GTK_WIDGET (item->canvas)->style->font_desc); + ethi_font_set (ethi, style->font_desc); /* * Now, configure DnD @@ -972,6 +1014,11 @@ ethi_draw (GnomeCanvasItem *item, gint x1, x2; gint col; GHashTable *arrows = g_hash_table_new (NULL, NULL); + GtkStateType state; + GtkStyle *style; + + state = gtk_widget_get_state (GTK_WIDGET (canvas)); + style = gtk_widget_get_style (GTK_WIDGET (canvas)); if (ethi->sort_info) { gint length = e_table_sort_info_grouping_get_count(ethi->sort_info); @@ -1018,15 +1065,13 @@ ethi_draw (GnomeCanvasItem *item, state = gtk_widget_get_state (GTK_WIDGET (canvas)); - e_table_header_draw_button (drawable, ecol, - GTK_WIDGET (canvas)->style, - state, - GTK_WIDGET (canvas), - x1 - x, -y, - width, height, - x2 - x1, ethi->height, - (ETableColArrow) g_hash_table_lookup ( - arrows, GINT_TO_POINTER (ecol->col_idx))); + e_table_header_draw_button ( + drawable, ecol, + style, state, GTK_WIDGET (canvas), + x1 - x, -y, width, height, + x2 - x1, ethi->height, + (ETableColArrow) g_hash_table_lookup ( + arrows, GINT_TO_POINTER (ecol->col_idx))); } g_hash_table_destroy (arrows); @@ -1088,12 +1133,16 @@ is_pointer_on_division (ETableHeaderItem *ethi, static void set_cursor (ETableHeaderItem *ethi, gint pos) { - gint col; - GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas); + GnomeCanvas *canvas; + GdkWindow *window; gboolean resizable = FALSE; + gint col; + + canvas = GNOME_CANVAS_ITEM (ethi)->canvas; + window = gtk_widget_get_window (GTK_WIDGET (canvas)); /* We might be invoked before we are realized */ - if (!canvas->window) + if (window == NULL) return; if (is_pointer_on_division (ethi, pos, NULL, &col)) { @@ -1119,9 +1168,9 @@ set_cursor (ETableHeaderItem *ethi, gint pos) } if (resizable) - gdk_window_set_cursor (canvas->window, ethi->resize_cursor); + gdk_window_set_cursor (window, ethi->resize_cursor); else - gdk_window_set_cursor (canvas->window, NULL); + gdk_window_set_cursor (window, NULL); } static void @@ -1157,17 +1206,24 @@ ethi_start_drag (ETableHeaderItem *ethi, GdkEvent *event) GtkWidget *widget = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas); GtkTargetList *list; GdkDragContext *context; - GtkStateType state; ETableCol *ecol; gint col_width; GdkPixmap *pixmap; gint group_indent = 0; GHashTable *arrows = g_hash_table_new (NULL, NULL); + GtkStateType state; + GtkStyle *style; + GdkWindow *window; GtkTargetEntry ethi_drag_types [] = { { (gchar *) TARGET_ETABLE_COL_TYPE, 0, TARGET_ETABLE_COL_HEADER }, }; + widget = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas); + window = gtk_widget_get_window (widget); + state = gtk_widget_get_state (widget); + style = gtk_widget_get_style (widget); + ethi->drag_col = ethi_find_col_by_x (ethi, event->motion.x); if (ethi->drag_col == -1) @@ -1212,23 +1268,21 @@ ethi_start_drag (ETableHeaderItem *ethi, GdkEvent *event) ecol = e_table_header_get_column (ethi->eth, ethi->drag_col); col_width = ecol->width; - pixmap = gdk_pixmap_new (widget->window, col_width, ethi->height, -1); + pixmap = gdk_pixmap_new (window, col_width, ethi->height, -1); state = gtk_widget_get_state (widget); e_table_header_draw_button ( pixmap, ecol, - widget->style, - state, - widget, - 0, 0, + style, state, + widget, 0, 0, col_width, ethi->height, col_width, ethi->height, (ETableColArrow) g_hash_table_lookup ( arrows, GINT_TO_POINTER (ecol->col_idx))); gtk_drag_set_icon_pixmap ( context, - gdk_drawable_get_colormap (GDK_DRAWABLE (widget->window)), + gdk_drawable_get_colormap (GDK_DRAWABLE (window)), pixmap, NULL, col_width / 2, @@ -1754,6 +1808,7 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e) { ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); GnomeCanvas *canvas = item->canvas; + GdkWindow *window; const gboolean resizing = ETHI_RESIZING (ethi); gint x, y, start, col; gint was_maybe_drag = 0; @@ -1765,7 +1820,8 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e) break; case GDK_LEAVE_NOTIFY: - gdk_window_set_cursor (GTK_WIDGET (canvas)->window, NULL); + window = gtk_widget_get_window (GTK_WIDGET (canvas)); + gdk_window_set_cursor (window, NULL); break; case GDK_MOTION_NOTIFY: diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index f2a3c1a826..ecb906d093 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -349,12 +349,12 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, gtk_container_add (GTK_CONTAINER (window), button); gtk_widget_ensure_style (window); gtk_widget_ensure_style (button); - g_label = GTK_BIN(button)->child; + g_label = gtk_bin_get_child (GTK_BIN (button)); g_object_add_weak_pointer (G_OBJECT (g_label), &g_label); gtk_widget_ensure_style (g_label); } - gc = GTK_WIDGET (g_label)->style->fg_gc[state]; + gc = gtk_widget_get_style (GTK_WIDGET (g_label))->fg_gc[state]; gdk_gc_set_clip_rectangle (gc, NULL); diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c index 3c0fa33bb0..b2c27590c7 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -245,22 +245,22 @@ inline static GdkColor * eti_get_cell_background_color (ETableItem *eti, gint row, gint col, gboolean selected, gboolean *allocatedp) { ECellView *ecell_view = eti->cell_views [col]; - GtkWidget *canvas = GTK_WIDGET(GNOME_CANVAS_ITEM(eti)->canvas); + GtkWidget *canvas; GdkColor *background, bg; + GtkStyle *style; gchar *color_spec = NULL; gboolean allocated = FALSE; + canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (eti)->canvas); + style = gtk_widget_get_style (canvas); + if (selected) { -#if GTK_CHECK_VERSION(2,19,7) if (gtk_widget_has_focus (canvas)) -#else - if (GTK_WIDGET_HAS_FOCUS(canvas)) -#endif - background = &canvas->style->bg [GTK_STATE_SELECTED]; + background = &style->bg [GTK_STATE_SELECTED]; else - background = &canvas->style->bg [GTK_STATE_ACTIVE]; + background = &style->bg [GTK_STATE_ACTIVE]; } else { - background = &canvas->style->base [GTK_STATE_NORMAL]; + background = &style->base [GTK_STATE_NORMAL]; } color_spec = e_cell_get_bg_color (ecell_view, row); @@ -268,7 +268,7 @@ eti_get_cell_background_color (ETableItem *eti, gint row, gint col, gboolean sel if (color_spec != NULL) { if (gdk_color_parse (color_spec, &bg)) { background = gdk_color_copy (&bg); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (canvas)), background, + gdk_colormap_alloc_color (gtk_widget_get_colormap (canvas), background, FALSE, TRUE); allocated = TRUE; } @@ -283,7 +283,7 @@ eti_get_cell_background_color (ETableItem *eti, gint row, gint col, gboolean sel allocated = TRUE; } e_hsv_tweak (background, 0.0f, 0.0f, -0.07f); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (canvas)), background, + gdk_colormap_alloc_color (gtk_widget_get_colormap (canvas), background, FALSE, TRUE); } } @@ -296,23 +296,23 @@ eti_get_cell_background_color (ETableItem *eti, gint row, gint col, gboolean sel inline static GdkColor * eti_get_cell_foreground_color (ETableItem *eti, gint row, gint col, gboolean selected, gboolean *allocated) { - GtkWidget *canvas = GTK_WIDGET(GNOME_CANVAS_ITEM(eti)->canvas); + GtkWidget *canvas; GdkColor *foreground; + GtkStyle *style; + + canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (eti)->canvas); + style = gtk_widget_get_style (canvas); if (allocated) *allocated = FALSE; if (selected) { -#if GTK_CHECK_VERSION(2,19,7) if (gtk_widget_has_focus (canvas)) -#else - if (GTK_WIDGET_HAS_FOCUS (canvas)) -#endif - foreground = &canvas->style->fg [GTK_STATE_SELECTED]; + foreground = &style->fg [GTK_STATE_SELECTED]; else - foreground = &canvas->style->fg [GTK_STATE_ACTIVE]; + foreground = &style->fg [GTK_STATE_ACTIVE]; } else { - foreground = &canvas->style->text [GTK_STATE_NORMAL]; + foreground = &style->text [GTK_STATE_NORMAL]; } return foreground; @@ -1631,8 +1631,9 @@ static void eti_realize (GnomeCanvasItem *item) { ETableItem *eti = E_TABLE_ITEM (item); - GtkWidget *canvas_widget = GTK_WIDGET (item->canvas); GdkWindow *window; + GtkWidget *widget; + GtkStyle *style; if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize) (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize)(item); @@ -1642,15 +1643,17 @@ eti_realize (GnomeCanvasItem *item) /* * Gdk Resource allocation */ - window = canvas_widget->window; + widget = GTK_WIDGET (item->canvas); + style = gtk_widget_get_style (widget); + window = gtk_widget_get_window (widget); eti->fill_gc = gdk_gc_new (window); eti->grid_gc = gdk_gc_new (window); - gdk_gc_set_foreground (eti->grid_gc, &canvas_widget->style->dark [GTK_STATE_NORMAL]); + gdk_gc_set_foreground (eti->grid_gc, &style->dark [GTK_STATE_NORMAL]); eti->focus_gc = gdk_gc_new (window); - gdk_gc_set_foreground (eti->focus_gc, &canvas_widget->style->bg [GTK_STATE_NORMAL]); - gdk_gc_set_background (eti->focus_gc, &canvas_widget->style->fg [GTK_STATE_NORMAL]); + gdk_gc_set_foreground (eti->focus_gc, &style->bg [GTK_STATE_NORMAL]); + gdk_gc_set_background (eti->focus_gc, &style->fg [GTK_STATE_NORMAL]); eti->stipple = gdk_bitmap_create_from_data (NULL, gray50_bits, gray50_width, gray50_height); gdk_gc_set_ts_origin (eti->focus_gc, 0, 0); gdk_gc_set_stipple (eti->focus_gc, eti->stipple); @@ -1933,11 +1936,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, gint x, gint y, gint wid gdk_color_free (background); flags = col_selected ? E_CELL_SELECTED : 0; -#if GTK_CHECK_VERSION(2,19,7) flags |= gtk_widget_has_focus (canvas) ? E_CELL_FOCUSED : 0; -#else - flags |= GTK_WIDGET_HAS_FOCUS(canvas) ? E_CELL_FOCUSED : 0; -#endif flags |= cursor ? E_CELL_CURSOR : 0; switch (ecol->justification) { diff --git a/widgets/table/e-table-utils.c b/widgets/table/e-table-utils.c index 89affd357d..f3bce34487 100644 --- a/widgets/table/e-table-utils.c +++ b/widgets/table/e-table-utils.c @@ -36,6 +36,7 @@ ETableHeader * e_table_state_to_header (GtkWidget *widget, ETableHeader *full_header, ETableState *state) { ETableHeader *nh; + GtkStyle *style; const gint max_cols = e_table_header_count (full_header); gint column; GValue *val = g_new0 (GValue, 1); @@ -44,9 +45,11 @@ e_table_state_to_header (GtkWidget *widget, ETableHeader *full_header, ETableSta g_return_val_if_fail (full_header, NULL); g_return_val_if_fail (state, NULL); + style = gtk_widget_get_style (widget); + nh = e_table_header_new (); g_value_init (val, G_TYPE_DOUBLE); - g_value_set_double (val, e_table_header_width_extras (widget->style)); + g_value_set_double (val, e_table_header_width_extras (style)); g_object_set_property (G_OBJECT(nh), "width_extras", val); g_free (val); diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 5c35eb26e6..ce2253bc66 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -509,11 +509,9 @@ et_finalize (GObject *object) static void e_table_init (ETable *e_table) { - GtkTable *gtk_table = GTK_TABLE (e_table); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET (e_table), GTK_CAN_FOCUS); - gtk_table->homogeneous = FALSE; + gtk_table_set_homogeneous (GTK_TABLE (e_table), FALSE); e_table->sort_info = NULL; e_table->group_info_change_id = 0; @@ -582,7 +580,7 @@ et_focus (GtkWidget *container, GtkDirectionType direction) e_table = E_TABLE (container); - if (GTK_CONTAINER (container)->focus_child) { + if (gtk_container_get_focus_child (GTK_CONTAINER (container))) { gtk_container_set_focus_child (GTK_CONTAINER (container), NULL); return FALSE; } @@ -615,14 +613,18 @@ set_header_canvas_width (ETable *e_table) static void header_canvas_size_allocate (GtkWidget *widget, GtkAllocation *alloc, ETable *e_table) { + GtkAllocation allocation; + set_header_canvas_width (e_table); + gtk_widget_get_allocation ( + GTK_WIDGET (e_table->header_canvas), &allocation); + /* When the header item is created ->height == 0, as the font is only created when everything is realized. So we set the usize here as well, so that the size of the header is correct */ - if (GTK_WIDGET (e_table->header_canvas)->allocation.height != - E_TABLE_HEADER_ITEM (e_table->header_item)->height) + if (allocation.height != E_TABLE_HEADER_ITEM (e_table->header_item)->height) g_object_set ( e_table->header_canvas, "height-request", E_TABLE_HEADER_ITEM (e_table->header_item)->height, @@ -688,14 +690,16 @@ table_canvas_reflow_idle (ETable *e_table) { gdouble height, width; gdouble oldheight, oldwidth; - GtkAllocation *alloc = &(GTK_WIDGET (e_table->table_canvas)->allocation); + GtkAllocation allocation; - g_object_get (e_table->canvas_vbox, - "height", &height, - "width", &width, - NULL); - height = MAX ((gint)height, alloc->height); - width = MAX((gint)width, alloc->width); + gtk_widget_get_allocation ( + GTK_WIDGET (e_table->table_canvas), &allocation); + + g_object_get ( + e_table->canvas_vbox, + "height", &height, "width", &width, NULL); + height = MAX ((gint)height, allocation.height); + width = MAX((gint)width, allocation.width); /* I have no idea why this needs to be -1, but it works. */ gnome_canvas_get_scroll_region (GNOME_CANVAS (e_table->table_canvas), NULL, NULL, &oldwidth, &oldheight); @@ -805,14 +809,24 @@ group_key_press (ETableGroup *etg, gint row, gint col, GdkEvent *event, ETable * gboolean return_val = FALSE; GdkEventKey *key = (GdkEventKey *) event; gint y, row_local, col_local; - GtkAdjustment *vadj; + GtkAdjustment *adjustment; + GtkLayout *layout; + gdouble page_size; + gdouble upper; + gdouble value; + + layout = GTK_LAYOUT (et->table_canvas); + adjustment = gtk_layout_get_vadjustment (layout); switch (key->keyval) { case GDK_Page_Down: case GDK_KP_Page_Down: - vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas)); - y = CLAMP(vadj->value + (2 * vadj->page_size - 50), 0, vadj->upper); - y -= vadj->value; + page_size = gtk_adjustment_get_page_size (adjustment); + upper = gtk_adjustment_get_value (adjustment); + value = gtk_adjustment_get_value (adjustment); + + y = CLAMP (value + (2 * page_size - 50), 0, upper); + y -= value; e_table_get_cell_at (et, 30, y, &row_local, &col_local); if (row_local == -1) @@ -825,9 +839,12 @@ group_key_press (ETableGroup *etg, gint row, gint col, GdkEvent *event, ETable * break; case GDK_Page_Up: case GDK_KP_Page_Up: - vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas)); - y = CLAMP(vadj->value - (vadj->page_size - 50), 0, vadj->upper); - y -= vadj->value; + page_size = gtk_adjustment_get_page_size (adjustment); + upper = gtk_adjustment_get_upper (adjustment); + value = gtk_adjustment_get_value (adjustment); + + y = CLAMP (value - (page_size - 50), 0, upper); + y -= value; e_table_get_cell_at (et, 30, y, &row_local, &col_local); if (row_local == -1) @@ -1029,9 +1046,15 @@ changed_idle (gpointer data) static void et_canvas_realize (GtkWidget *canvas, ETable *e_table) { + GtkWidget *widget; + GtkStyle *style; + + widget = GTK_WIDGET (e_table->table_canvas); + style = gtk_widget_get_style (widget); + gnome_canvas_item_set( e_table->white_item, - "fill_color_gdk", >K_WIDGET(e_table->table_canvas)->style->base[GTK_STATE_NORMAL], + "fill_color_gdk", &style->base[GTK_STATE_NORMAL], NULL); CHECK_HORIZONTAL(e_table); @@ -1052,11 +1075,7 @@ et_eti_leave_edit (ETable *et) { GnomeCanvas *canvas = et->table_canvas; -#if GTK_CHECK_VERSION(2,19,7) if (gtk_widget_has_focus (GTK_WIDGET (canvas))) { -#else - if (GTK_WIDGET_HAS_FOCUS(canvas)) { -#endif GnomeCanvasItem *item = GNOME_CANVAS(canvas)->focused_item; if (E_IS_TABLE_ITEM(item)) { @@ -1208,6 +1227,9 @@ static void e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *header, ETableModel *model) { + GtkWidget *widget; + GtkStyle *style; + e_table->table_canvas = GNOME_CANVAS (e_canvas_new ()); g_signal_connect ( G_OBJECT (e_table->table_canvas), "size_allocate", @@ -1247,12 +1269,15 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h g_signal_connect (G_OBJECT(e_table->table_canvas), "reflow", G_CALLBACK (table_canvas_reflow), e_table); - gtk_widget_show (GTK_WIDGET (e_table->table_canvas)); + widget = GTK_WIDGET (e_table->table_canvas); + style = gtk_widget_get_style (widget); + + gtk_widget_show (widget); e_table->white_item = gnome_canvas_item_new( gnome_canvas_root(e_table->table_canvas), e_canvas_background_get_type(), - "fill_color_gdk", >K_WIDGET(e_table->table_canvas)->style->base[GTK_STATE_NORMAL], + "fill_color_gdk", &style->base[GTK_STATE_NORMAL], NULL); g_signal_connect (G_OBJECT (e_table->white_item), "event", @@ -1321,12 +1346,19 @@ e_table_fill_table (ETable *e_table, ETableModel *model) void e_table_set_state_object(ETable *e_table, ETableState *state) { - GValue *val = g_new0 (GValue, 1); + GValue *val; + GtkWidget *widget; + GtkAllocation allocation; + + val = g_new0 (GValue, 1); g_value_init (val, G_TYPE_DOUBLE); connect_header (e_table, state); - g_value_set_double (val, (gdouble) (GTK_WIDGET(e_table->table_canvas)->allocation.width)); + widget = GTK_WIDGET (e_table->table_canvas); + gtk_widget_get_allocation (widget, &allocation); + + g_value_set_double (val, (gdouble) allocation.width); g_object_set_property (G_OBJECT (e_table->header), "width", val); g_free (val); @@ -1528,7 +1560,11 @@ et_real_construct (ETable *e_table, ETableModel *etm, ETableExtras *ete, { gint row = 0; gint col_count, i; - GValue *val = g_new0 (GValue, 1); + GValue *val; + GtkLayout *layout; + GtkAdjustment *adjustment; + + val = g_new0 (GValue, 1); g_value_init (val, G_TYPE_OBJECT); if (ete) @@ -1607,15 +1643,16 @@ et_real_construct (ETable *e_table, ETableModel *etm, ETableExtras *ete, e_table_setup_table (e_table, e_table->full_header, e_table->header, etm); e_table_fill_table (e_table, etm); - gtk_layout_get_vadjustment (GTK_LAYOUT (e_table->table_canvas))->step_increment = 20; - gtk_adjustment_changed(gtk_layout_get_vadjustment (GTK_LAYOUT (e_table->table_canvas))); - gtk_layout_get_hadjustment (GTK_LAYOUT (e_table->table_canvas))->step_increment = 20; - gtk_adjustment_changed(gtk_layout_get_hadjustment (GTK_LAYOUT (e_table->table_canvas))); + layout = GTK_LAYOUT (e_table->table_canvas); + + adjustment = gtk_layout_get_vadjustment (layout); + gtk_adjustment_set_step_increment (adjustment, 20); + + adjustment = gtk_layout_get_hadjustment (layout); + gtk_adjustment_set_step_increment (adjustment, 20); if (!specification->no_headers) { - /* - * The header - */ + /* The header */ gtk_table_attach (GTK_TABLE (e_table), GTK_WIDGET (e_table->header_canvas), 0, 1, 0 + row, 1 + row, GTK_FILL | GTK_EXPAND, @@ -2237,25 +2274,22 @@ set_scroll_adjustments (ETable *table, GtkAdjustment *hadjustment, GtkAdjustment *vadjustment) { - if (vadjustment != NULL) { - vadjustment->step_increment = 20; - gtk_adjustment_changed(vadjustment); - } - if (hadjustment != NULL) { - hadjustment->step_increment = 20; - gtk_adjustment_changed(hadjustment); - } + if (vadjustment != NULL) + gtk_adjustment_set_step_increment (vadjustment, 20); + + if (hadjustment != NULL) + gtk_adjustment_set_step_increment (hadjustment, 20); if (table->table_canvas != NULL) { - gtk_layout_set_hadjustment (GTK_LAYOUT(table->table_canvas), - hadjustment); - gtk_layout_set_vadjustment (GTK_LAYOUT(table->table_canvas), - vadjustment); + gtk_layout_set_hadjustment ( + GTK_LAYOUT(table->table_canvas), hadjustment); + gtk_layout_set_vadjustment ( + GTK_LAYOUT(table->table_canvas), vadjustment); } if (table->header_canvas != NULL) - gtk_layout_set_hadjustment (GTK_LAYOUT(table->header_canvas), - hadjustment); + gtk_layout_set_hadjustment ( + GTK_LAYOUT(table->header_canvas), hadjustment); } /** @@ -2384,7 +2418,9 @@ e_table_get_cell_at (ETable *table, gint x, gint y, gint *row_return, gint *col_return) { - g_return_if_fail (table != NULL); + GtkAdjustment *adjustment; + GtkLayout *layout; + g_return_if_fail (E_IS_TABLE (table)); g_return_if_fail (row_return != NULL); g_return_if_fail (col_return != NULL); @@ -2392,9 +2428,16 @@ e_table_get_cell_at (ETable *table, /* FIXME it would be nice if it could handle a NULL row_return or * col_return gracefully. */ - x += GTK_LAYOUT(table->table_canvas)->hadjustment->value; - y += GTK_LAYOUT(table->table_canvas)->vadjustment->value; - e_table_group_compute_location(table->group, &x, &y, row_return, col_return); + layout = GTK_LAYOUT (table->table_canvas); + + adjustment = gtk_layout_get_hadjustment (layout); + x += gtk_adjustment_get_value (adjustment); + + adjustment = gtk_layout_get_vadjustment (layout); + y += gtk_adjustment_get_value (adjustment); + + e_table_group_compute_location ( + table->group, &x, &y, row_return, col_return); } /** @@ -2416,18 +2459,35 @@ e_table_get_cell_geometry (ETable *table, gint *x_return, gint *y_return, gint *width_return, gint *height_return) { - g_return_if_fail (table != NULL); + GtkAdjustment *adjustment; + GtkAllocation allocation; + GtkLayout *layout; + g_return_if_fail (E_IS_TABLE (table)); - e_table_group_get_cell_geometry(table->group, &row, &col, x_return, y_return, width_return, height_return); + layout = GTK_LAYOUT (table->table_canvas); + + e_table_group_get_cell_geometry ( + table->group, &row, &col, x_return, y_return, + width_return, height_return); + + if (x_return && table->table_canvas) { + adjustment = gtk_layout_get_hadjustment (layout); + (*x_return) -= gtk_adjustment_get_value (adjustment); + } - if (x_return && table->table_canvas) - (*x_return) -= GTK_LAYOUT(table->table_canvas)->hadjustment->value; if (y_return) { - if (table->table_canvas) - (*y_return) -= GTK_LAYOUT(table->table_canvas)->vadjustment->value; - if (table->header_canvas) - (*y_return) += GTK_WIDGET(table->header_canvas)->allocation.height; + if (table->table_canvas) { + adjustment = gtk_layout_get_vadjustment (layout); + (*y_return) -= gtk_adjustment_get_value (adjustment); + } + + if (table->header_canvas) { + gtk_widget_get_allocation ( + GTK_WIDGET (table->header_canvas), + &allocation); + (*y_return) += allocation.height; + } } } @@ -2578,30 +2638,39 @@ e_table_drag_highlight (ETable *table, gint row, gint col) { - g_return_if_fail(table != NULL); - g_return_if_fail(E_IS_TABLE(table)); + GtkAdjustment *adjustment; + GtkAllocation allocation; + GtkLayout *layout; + GtkStyle *style; + + g_return_if_fail (E_IS_TABLE (table)); + + layout = GTK_LAYOUT (table->table_canvas); + style = gtk_widget_get_style (GTK_WIDGET (table)); + gtk_widget_get_allocation (GTK_WIDGET (layout), &allocation); if (row != -1) { gint x, y, width, height; if (col == -1) { e_table_get_cell_geometry (table, row, 0, &x, &y, &width, &height); x = 0; - width = GTK_WIDGET (table->table_canvas)->allocation.width; + width = allocation.width; } else { e_table_get_cell_geometry (table, row, col, &x, &y, &width, &height); - x += GTK_LAYOUT(table->table_canvas)->hadjustment->value; + adjustment = gtk_layout_get_hadjustment (layout); + x += gtk_adjustment_get_value (adjustment); } - y += GTK_LAYOUT(table->table_canvas)->vadjustment->value; + + adjustment = gtk_layout_get_vadjustment (layout); + y += gtk_adjustment_get_value (adjustment); if (table->drop_highlight == NULL) { - table->drop_highlight = - gnome_canvas_item_new (gnome_canvas_root (table->table_canvas), - gnome_canvas_rect_get_type (), - "fill_color", NULL, - /* "outline_color", "black", - "width_pixels", 1,*/ - "outline_color_gdk", &(GTK_WIDGET (table)->style->fg[GTK_STATE_NORMAL]), - NULL); + table->drop_highlight = gnome_canvas_item_new ( + gnome_canvas_root (table->table_canvas), + gnome_canvas_rect_get_type (), + "fill_color", NULL, + "outline_color_gdk", &style->fg[GTK_STATE_NORMAL], + NULL); } gnome_canvas_item_set (table->drop_highlight, "x1", (gdouble) x, @@ -2901,8 +2970,15 @@ scroll_timeout (gpointer data) { ETable *et = data; gint dx = 0, dy = 0; - GtkAdjustment *h, *v; - gdouble hvalue, vvalue; + GtkAdjustment *adjustment; + GtkLayout *layout; + gdouble old_h_value; + gdouble new_h_value; + gdouble old_v_value; + gdouble new_v_value; + gdouble page_size; + gdouble lower; + gdouble upper; if (et->scroll_direction & ET_SCROLL_DOWN) dy += 20; @@ -2914,22 +2990,37 @@ scroll_timeout (gpointer data) if (et->scroll_direction & ET_SCROLL_LEFT) dx -= 20; - h = GTK_LAYOUT(et->table_canvas)->hadjustment; - v = GTK_LAYOUT(et->table_canvas)->vadjustment; + layout = GTK_LAYOUT (et->table_canvas); + + adjustment = gtk_layout_get_hadjustment (layout); - hvalue = h->value; - vvalue = v->value; + lower = gtk_adjustment_get_lower (adjustment); + upper = gtk_adjustment_get_upper (adjustment); + page_size = gtk_adjustment_get_page_size (adjustment); - gtk_adjustment_set_value(h, CLAMP(h->value + dx, h->lower, h->upper - h->page_size)); - gtk_adjustment_set_value(v, CLAMP(v->value + dy, v->lower, v->upper - v->page_size)); + old_h_value = gtk_adjustment_get_value (adjustment); + new_h_value = CLAMP (old_h_value + dx, lower, upper - page_size); - if (h->value != hvalue || - v->value != vvalue) - do_drag_motion(et, - et->last_drop_context, - et->last_drop_x, - et->last_drop_y, - et->last_drop_time); + gtk_adjustment_set_value (adjustment, new_h_value); + + adjustment = gtk_layout_get_vadjustment (layout); + + lower = gtk_adjustment_get_lower (adjustment); + upper = gtk_adjustment_get_upper (adjustment); + page_size = gtk_adjustment_get_page_size (adjustment); + + old_v_value = gtk_adjustment_get_value (adjustment); + new_v_value = CLAMP (old_v_value + dy, lower, upper - page_size); + + gtk_adjustment_set_value (adjustment, new_v_value); + + if (new_h_value != old_h_value || new_v_value != old_v_value) + do_drag_motion ( + et, + et->last_drop_context, + et->last_drop_x, + et->last_drop_y, + et->last_drop_time); return TRUE; } @@ -3001,28 +3092,27 @@ et_drag_motion(GtkWidget *widget, guint time, ETable *et) { + GtkAllocation allocation; gboolean ret_val; guint direction = 0; + gtk_widget_get_allocation (widget, &allocation); + et->last_drop_x = x; et->last_drop_y = y; et->last_drop_time = time; et->last_drop_context = context; context_connect (et, context); - ret_val = do_drag_motion (et, - context, - x, - y, - time); + ret_val = do_drag_motion (et, context, x, y, time); if (y < 20) direction |= ET_SCROLL_UP; - if (y > widget->allocation.height - 20) + if (y > allocation.height - 20) direction |= ET_SCROLL_DOWN; if (x < 20) direction |= ET_SCROLL_LEFT; - if (x > widget->allocation.width - 20) + if (x > allocation.width - 20) direction |= ET_SCROLL_RIGHT; if (direction != 0) diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index c093255518..3f7ab111fa 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -538,11 +538,9 @@ et_search_accept (ETableSearch *search, ETree *et) static void e_tree_init (ETree *e_tree) { - GtkTable *gtk_table = GTK_TABLE (e_tree); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET (e_tree), GTK_CAN_FOCUS); - gtk_table->homogeneous = FALSE; + gtk_table_set_homogeneous (GTK_TABLE (e_tree), FALSE); e_tree->priv = g_new(ETreePriv, 1); @@ -656,7 +654,7 @@ et_focus (GtkWidget *container, GtkDirectionType direction) e_tree = E_TREE (container); - if (GTK_CONTAINER (container)->focus_child) { + if (gtk_container_get_focus_child (GTK_CONTAINER (container))) { gtk_container_set_focus_child (GTK_CONTAINER (container), NULL); return FALSE; } @@ -689,16 +687,21 @@ set_header_canvas_width (ETree *e_tree) static void header_canvas_size_allocate (GtkWidget *widget, GtkAllocation *alloc, ETree *e_tree) { + GtkAllocation allocation; + set_header_canvas_width (e_tree); + widget = GTK_WIDGET (e_tree->priv->header_canvas); + gtk_widget_get_allocation (widget, &allocation); + /* When the header item is created ->height == 0, as the font is only created when everything is realized. So we set the usize here as well, so that the size of the header is correct */ - if (GTK_WIDGET (e_tree->priv->header_canvas)->allocation.height != - E_TABLE_HEADER_ITEM (e_tree->priv->header_item)->height) - gtk_widget_set_size_request (GTK_WIDGET (e_tree->priv->header_canvas), -1, - E_TABLE_HEADER_ITEM (e_tree->priv->header_item)->height); + if (allocation.height != E_TABLE_HEADER_ITEM (e_tree->priv->header_item)->height) + gtk_widget_set_size_request ( + widget, -1, + E_TABLE_HEADER_ITEM (e_tree->priv->header_item)->height); } static void @@ -737,23 +740,39 @@ static void scroll_to_cursor (ETree *e_tree) { ETreePath path; - GtkAdjustment *adj; + GtkAdjustment *adjustment; + GtkLayout *layout; gint x, y, w, h; + gdouble page_size; + gdouble lower; + gdouble upper; + gdouble value; path = e_tree_get_cursor (e_tree); - adj = GTK_LAYOUT (e_tree->priv->table_canvas)->vadjustment; x = y = w = h = 0; + if (path) { gint row = e_tree_row_of_node(e_tree, path); gint col = 0; if (row >= 0) - e_table_item_get_cell_geometry (E_TABLE_ITEM (e_tree->priv->item), - &row, &col, &x, &y, &w, &h); + e_table_item_get_cell_geometry ( + E_TABLE_ITEM (e_tree->priv->item), + &row, &col, &x, &y, &w, &h); } - if (y < adj->value || y + h > adj->value + adj->page_size) - gtk_adjustment_set_value(adj, CLAMP(y - adj->page_size / 2, adj->lower, adj->upper - adj->page_size)); + layout = GTK_LAYOUT (e_tree->priv->table_canvas); + adjustment = gtk_layout_get_vadjustment (layout); + + page_size = gtk_adjustment_get_page_size (adjustment); + lower = gtk_adjustment_get_lower (adjustment); + upper = gtk_adjustment_get_upper (adjustment); + value = gtk_adjustment_get_value (adjustment); + + if (y < value || y + h > value + page_size) { + value = CLAMP (y - page_size / 2, lower, upper - page_size); + gtk_adjustment_set_value (adjustment, value); + } } static gboolean @@ -761,24 +780,32 @@ tree_canvas_reflow_idle (ETree *e_tree) { gdouble height, width; gdouble oldheight, oldwidth; - GtkAllocation *alloc = &(GTK_WIDGET (e_tree->priv->table_canvas)->allocation); + GtkAllocation allocation; + GtkWidget *widget; + + widget = GTK_WIDGET (e_tree->priv->table_canvas); + gtk_widget_get_allocation (widget, &allocation); + + g_object_get ( + e_tree->priv->item, + "height", &height, "width", &width, NULL); + + height = MAX ((gint)height, allocation.height); + width = MAX((gint)width, allocation.width); - g_object_get (e_tree->priv->item, - "height", &height, - "width", &width, - NULL); - height = MAX ((gint)height, alloc->height); - width = MAX((gint)width, alloc->width); /* I have no idea why this needs to be -1, but it works. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (e_tree->priv->table_canvas), - NULL, NULL, &oldwidth, &oldheight); + gnome_canvas_get_scroll_region ( + GNOME_CANVAS (e_tree->priv->table_canvas), + NULL, NULL, &oldwidth, &oldheight); if (oldwidth != width - 1 || oldheight != height - 1) { - gnome_canvas_set_scroll_region (GNOME_CANVAS (e_tree->priv->table_canvas), - 0, 0, width - 1, height - 1); + gnome_canvas_set_scroll_region ( + GNOME_CANVAS (e_tree->priv->table_canvas), + 0, 0, width - 1, height - 1); set_header_canvas_width (e_tree); } + e_tree->priv->reflow_idle_id = 0; if (e_tree->priv->show_cursor_after_reflow) { @@ -881,14 +908,24 @@ item_key_press (ETableItem *eti, gint row, gint col, GdkEvent *event, ETree *et) GdkEventKey *key = (GdkEventKey *) event; ETreePath path; gint y, row_local, col_local; - GtkAdjustment *vadj; + GtkAdjustment *adjustment; + GtkLayout *layout; + gdouble page_size; + gdouble upper; + gdouble value; + + layout = GTK_LAYOUT (et->priv->table_canvas); + adjustment = gtk_layout_get_vadjustment (layout); + + page_size = gtk_adjustment_get_page_size (adjustment); + upper = gtk_adjustment_get_upper (adjustment); + value = gtk_adjustment_get_value (adjustment); switch (key->keyval) { case GDK_Page_Down: case GDK_KP_Page_Down: - vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas)); - y = CLAMP(vadj->value + (2 * vadj->page_size - 50), 0, vadj->upper); - y -= vadj->value; + y = CLAMP (value + (2 * page_size - 50), 0, upper); + y -= value; e_tree_get_cell_at (et, 30, y, &row_local, &col_local); if (row_local == -1) @@ -902,9 +939,8 @@ item_key_press (ETableItem *eti, gint row, gint col, GdkEvent *event, ETree *et) break; case GDK_Page_Up: case GDK_KP_Page_Up: - vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas)); - y = CLAMP(vadj->value - (vadj->page_size - 50), 0, vadj->upper); - y -= vadj->value; + y = CLAMP (value - (page_size - 50), 0, upper); + y -= value; e_tree_get_cell_at (et, 30, y, &row_local, &col_local); if (row_local == -1) @@ -1029,9 +1065,13 @@ et_build_item (ETree *et) static void et_canvas_style_set (GtkWidget *widget, GtkStyle *prev_style) { + GtkStyle *style; + + style = gtk_widget_get_style (widget); + gnome_canvas_item_set( E_TREE(widget)->priv->white_item, - "fill_color_gdk", &widget->style->base[GTK_STATE_NORMAL], + "fill_color_gdk", &style->base[GTK_STATE_NORMAL], NULL); } @@ -1053,11 +1093,7 @@ et_canvas_root_event (GnomeCanvasItem *root, GdkEvent *event, ETree *e_tree) case GDK_2BUTTON_PRESS: case GDK_BUTTON_RELEASE: if (event->button.button != 4 && event->button.button != 5) { -#if GTK_CHECK_VERSION(2,19,7) if (gtk_widget_has_focus (GTK_WIDGET (root->canvas))) { -#else - if (GTK_WIDGET_HAS_FOCUS(root->canvas)) { -#endif GnomeCanvasItem *item = GNOME_CANVAS(root->canvas)->focused_item; if (E_IS_TABLE_ITEM(item)) { @@ -1102,6 +1138,9 @@ table_canvas_focus_event_cb (GtkWidget *widget, GdkEventFocus *event, gpointer d static void e_tree_setup_table (ETree *e_tree) { + GtkWidget *widget; + GtkStyle *style; + e_tree->priv->table_canvas = GNOME_CANVAS (e_canvas_new ()); g_signal_connect ( e_tree->priv->table_canvas, "size_allocate", @@ -1141,16 +1180,20 @@ e_tree_setup_table (ETree *e_tree) g_signal_connect (e_tree->priv->table_canvas, "reflow", G_CALLBACK (tree_canvas_reflow), e_tree); - gtk_widget_show (GTK_WIDGET (e_tree->priv->table_canvas)); + widget = GTK_WIDGET (e_tree->priv->table_canvas); + style = gtk_widget_get_style (widget); + + gtk_widget_show (widget); - e_tree->priv->white_item = gnome_canvas_item_new( - gnome_canvas_root(e_tree->priv->table_canvas), + e_tree->priv->white_item = gnome_canvas_item_new ( + gnome_canvas_root (e_tree->priv->table_canvas), e_canvas_background_get_type(), - "fill_color_gdk", >K_WIDGET(e_tree->priv->table_canvas)->style->base[GTK_STATE_NORMAL], + "fill_color_gdk", &style->base[GTK_STATE_NORMAL], NULL); - g_signal_connect (e_tree->priv->white_item, "event", - G_CALLBACK (white_item_event), e_tree); + g_signal_connect ( + e_tree->priv->white_item, "event", + G_CALLBACK (white_item_event), e_tree); g_signal_connect ( gnome_canvas_root (e_tree->priv->table_canvas), "event", G_CALLBACK(et_canvas_root_event), e_tree); @@ -1182,12 +1225,19 @@ e_tree_set_search_column (ETree *e_tree, gint col) void e_tree_set_state_object(ETree *e_tree, ETableState *state) { - GValue *val = g_new0 (GValue, 1); + GValue *val; + GtkAllocation allocation; + GtkWidget *widget; + + val = g_new0 (GValue, 1); g_value_init (val, G_TYPE_DOUBLE); connect_header (e_tree, state); - g_value_set_double (val, (gdouble) (GTK_WIDGET(e_tree->priv->table_canvas)->allocation.width)); + widget = GTK_WIDGET (e_tree->priv->table_canvas); + gtk_widget_get_allocation (widget, &allocation); + + g_value_set_double (val, (gdouble) allocation.width); g_object_set_property (G_OBJECT (e_tree->priv->header), "width", val); g_free (val); @@ -1424,6 +1474,8 @@ static gboolean et_real_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, ETableSpecification *specification, ETableState *state) { + GtkAdjustment *adjustment; + GtkLayout *layout; gint row = 0; if (ete) @@ -1475,10 +1527,13 @@ et_real_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, } e_tree_setup_table (e_tree); - gtk_layout_get_vadjustment (GTK_LAYOUT (e_tree->priv->table_canvas))->step_increment = 20; - gtk_adjustment_changed(gtk_layout_get_vadjustment (GTK_LAYOUT (e_tree->priv->table_canvas))); - gtk_layout_get_hadjustment (GTK_LAYOUT (e_tree->priv->table_canvas))->step_increment = 20; - gtk_adjustment_changed(gtk_layout_get_hadjustment (GTK_LAYOUT (e_tree->priv->table_canvas))); + layout = GTK_LAYOUT (e_tree->priv->table_canvas); + + adjustment = gtk_layout_get_vadjustment (layout); + gtk_adjustment_set_step_increment (adjustment, 20); + + adjustment = gtk_layout_get_hadjustment (layout); + gtk_adjustment_set_step_increment (adjustment, 20); if (!specification->no_headers) { /* @@ -1930,24 +1985,24 @@ set_scroll_adjustments (ETree *tree, GtkAdjustment *hadjustment, GtkAdjustment *vadjustment) { - if (vadjustment != NULL) { - vadjustment->step_increment = 20; - gtk_adjustment_changed(vadjustment); - } - if (hadjustment != NULL) { - hadjustment->step_increment = 20; - gtk_adjustment_changed(hadjustment); - } + GtkLayout *layout; + + layout = GTK_LAYOUT (tree->priv->table_canvas); + + if (vadjustment != NULL) + gtk_adjustment_set_step_increment (vadjustment, 20); + + if (hadjustment != NULL) + gtk_adjustment_set_step_increment (hadjustment, 20); if (tree->priv) { - gtk_layout_set_hadjustment (GTK_LAYOUT(tree->priv->table_canvas), - hadjustment); - gtk_layout_set_vadjustment (GTK_LAYOUT(tree->priv->table_canvas), - vadjustment); + gtk_layout_set_hadjustment (layout, hadjustment); + gtk_layout_set_vadjustment (layout, vadjustment); if (tree->priv->header_canvas != NULL) - gtk_layout_set_hadjustment (GTK_LAYOUT(tree->priv->header_canvas), - hadjustment); + gtk_layout_set_hadjustment ( + GTK_LAYOUT(tree->priv->header_canvas), + hadjustment); } } @@ -2383,37 +2438,48 @@ e_tree_drag_highlight (ETree *tree, gint row, gint col) { - g_return_if_fail(tree != NULL); + GtkAdjustment *adjustment; + GtkAllocation allocation; + GtkLayout *layout; + GtkStyle *style; + g_return_if_fail(E_IS_TREE(tree)); + layout = GTK_LAYOUT (tree->priv->table_canvas); + style = gtk_widget_get_style (GTK_WIDGET (tree)); + gtk_widget_get_allocation (GTK_WIDGET (layout), &allocation); + if (row != -1) { gint x, y, width, height; if (col == -1) { e_tree_get_cell_geometry (tree, row, 0, &x, &y, &width, &height); x = 0; - width = GTK_WIDGET (tree->priv->table_canvas)->allocation.width; + width = allocation.width; } else { e_tree_get_cell_geometry (tree, row, col, &x, &y, &width, &height); - x += GTK_LAYOUT(tree->priv->table_canvas)->hadjustment->value; + adjustment = gtk_layout_get_hadjustment (layout); + x += gtk_adjustment_get_value (adjustment); } - y += GTK_LAYOUT(tree->priv->table_canvas)->vadjustment->value; + + adjustment = gtk_layout_get_vadjustment (layout); + y += gtk_adjustment_get_value (adjustment); if (tree->priv->drop_highlight == NULL) { - tree->priv->drop_highlight = - gnome_canvas_item_new (gnome_canvas_root (tree->priv->table_canvas), - gnome_canvas_rect_get_type (), - "fill_color", NULL, - /* "outline_color", "black", - "width_pixels", 1,*/ - "outline_color_gdk", &(GTK_WIDGET (tree)->style->fg[GTK_STATE_NORMAL]), - NULL); + tree->priv->drop_highlight = gnome_canvas_item_new ( + gnome_canvas_root (tree->priv->table_canvas), + gnome_canvas_rect_get_type (), + "fill_color", NULL, + "outline_color_gdk", &style->fg[GTK_STATE_NORMAL], + NULL); } - gnome_canvas_item_set (tree->priv->drop_highlight, - "x1", (gdouble) x, - "x2", (gdouble) x + width - 1, - "y1", (gdouble) y, - "y2", (gdouble) y + height - 1, - NULL); + + gnome_canvas_item_set ( + tree->priv->drop_highlight, + "x1", (gdouble) x, + "x2", (gdouble) x + width - 1, + "y1", (gdouble) y, + "y2", (gdouble) y + height - 1, + NULL); } else { gtk_object_destroy (GTK_OBJECT (tree->priv->drop_highlight)); tree->priv->drop_highlight = NULL; @@ -2617,7 +2683,9 @@ e_tree_get_cell_at (ETree *tree, gint x, gint y, gint *row_return, gint *col_return) { - g_return_if_fail (tree != NULL); + GtkAdjustment *adjustment; + GtkLayout *layout; + g_return_if_fail (E_IS_TREE (tree)); g_return_if_fail (row_return != NULL); g_return_if_fail (col_return != NULL); @@ -2630,9 +2698,17 @@ e_tree_get_cell_at (ETree *tree, if (col_return) *col_return = -1; - x += GTK_LAYOUT(tree->priv->table_canvas)->hadjustment->value; - y += GTK_LAYOUT(tree->priv->table_canvas)->vadjustment->value; - e_table_item_compute_location(E_TABLE_ITEM(tree->priv->item), &x, &y, row_return, col_return); + layout = GTK_LAYOUT (tree->priv->table_canvas); + + adjustment = gtk_layout_get_hadjustment (layout); + x += gtk_adjustment_get_value (adjustment); + + adjustment = gtk_layout_get_vadjustment (layout); + y += gtk_adjustment_get_value (adjustment); + + e_table_item_compute_location ( + E_TABLE_ITEM (tree->priv->item), + &x, &y, row_return, col_return); } /** @@ -2653,7 +2729,9 @@ e_tree_get_cell_geometry (ETree *tree, gint *x_return, gint *y_return, gint *width_return, gint *height_return) { - g_return_if_fail (tree != NULL); + GtkAdjustment *adjustment; + GtkLayout *layout; + g_return_if_fail (E_IS_TREE (tree)); g_return_if_fail (row >= 0); g_return_if_fail (col >= 0); @@ -2661,12 +2739,22 @@ e_tree_get_cell_geometry (ETree *tree, /* FIXME it would be nice if it could handle a NULL row_return or * col_return gracefully. */ - e_table_item_get_cell_geometry(E_TABLE_ITEM(tree->priv->item), &row, &col, x_return, y_return, width_return, height_return); + e_table_item_get_cell_geometry ( + E_TABLE_ITEM (tree->priv->item), + &row, &col, x_return, y_return, + width_return, height_return); + + layout = GTK_LAYOUT (tree->priv->table_canvas); + + if (x_return) { + adjustment = gtk_layout_get_hadjustment (layout); + (*x_return) -= gtk_adjustment_get_value (adjustment); + } - if (x_return) - (*x_return) -= GTK_LAYOUT(tree->priv->table_canvas)->hadjustment->value; - if (y_return) - (*y_return) -= GTK_LAYOUT(tree->priv->table_canvas)->vadjustment->value; + if (y_return) { + adjustment = gtk_layout_get_vadjustment (layout); + (*y_return) -= gtk_adjustment_get_value (adjustment); + } } static void @@ -2777,8 +2865,15 @@ scroll_timeout (gpointer data) { ETree *et = data; gint dx = 0, dy = 0; - GtkAdjustment *v, *h; - gdouble vvalue, hvalue; + GtkAdjustment *adjustment; + GtkLayout *layout; + gdouble old_h_value; + gdouble new_h_value; + gdouble old_v_value; + gdouble new_v_value; + gdouble page_size; + gdouble lower; + gdouble upper; if (et->priv->scroll_direction & ET_SCROLL_DOWN) dy += 20; @@ -2790,22 +2885,37 @@ scroll_timeout (gpointer data) if (et->priv->scroll_direction & ET_SCROLL_LEFT) dx -= 20; - h = GTK_LAYOUT(et->priv->table_canvas)->hadjustment; - v = GTK_LAYOUT(et->priv->table_canvas)->vadjustment; + layout = GTK_LAYOUT (et->priv->table_canvas); + + adjustment = gtk_layout_get_hadjustment (layout); + + page_size = gtk_adjustment_get_page_size (adjustment); + lower = gtk_adjustment_get_lower (adjustment); + upper = gtk_adjustment_get_upper (adjustment); - hvalue = h->value; - vvalue = v->value; + old_h_value = gtk_adjustment_get_value (adjustment); + new_h_value = CLAMP (old_h_value + dx, lower, upper - page_size); - gtk_adjustment_set_value(h, CLAMP(h->value + dx, h->lower, h->upper - h->page_size)); - gtk_adjustment_set_value(v, CLAMP(v->value + dy, v->lower, v->upper - v->page_size)); + gtk_adjustment_set_value (adjustment, new_h_value); - if (h->value != hvalue || - v->value != vvalue) - do_drag_motion(et, - et->priv->last_drop_context, - et->priv->last_drop_x, - et->priv->last_drop_y, - et->priv->last_drop_time); + adjustment = gtk_layout_get_vadjustment (layout); + + page_size = gtk_adjustment_get_page_size (adjustment); + lower = gtk_adjustment_get_lower (adjustment); + upper = gtk_adjustment_get_upper (adjustment); + + old_v_value = gtk_adjustment_get_value (adjustment); + new_v_value = CLAMP (old_v_value + dy, lower, upper - page_size); + + gtk_adjustment_set_value (adjustment, new_v_value); + + if (new_h_value != old_h_value || new_v_value != old_v_value) + do_drag_motion ( + et, + et->priv->last_drop_context, + et->priv->last_drop_x, + et->priv->last_drop_y, + et->priv->last_drop_time); return TRUE; } @@ -2969,6 +3079,7 @@ et_drag_motion(GtkWidget *widget, guint time, ETree *et) { + GtkAllocation allocation; gint ret_val; guint direction = 0; @@ -2987,19 +3098,17 @@ et_drag_motion(GtkWidget *widget, hover_on (et, x, y); } - ret_val = do_drag_motion (et, - context, - x, - y, - time); + ret_val = do_drag_motion (et, context, x, y, time); + + gtk_widget_get_allocation (widget, &allocation); if (y < 20) direction |= ET_SCROLL_UP; - if (y > widget->allocation.height - 20) + if (y > allocation.height - 20) direction |= ET_SCROLL_DOWN; if (x < 20) direction |= ET_SCROLL_LEFT; - if (x > widget->allocation.width - 20) + if (x > allocation.width - 20) direction |= ET_SCROLL_RIGHT; if (direction != 0) @@ -3453,6 +3562,9 @@ tree_size_allocate (GtkWidget *widget, GtkAllocation *alloc, ETree *tree) void e_tree_set_info_message (ETree *tree, const gchar *info_message) { + GtkAllocation allocation; + GtkWidget *widget; + g_return_if_fail (tree != NULL); g_return_if_fail (tree->priv != NULL); @@ -3466,18 +3578,22 @@ e_tree_set_info_message (ETree *tree, const gchar *info_message) return; } + widget = GTK_WIDGET (tree->priv->table_canvas); + gtk_widget_get_allocation (widget, &allocation); + if (!tree->priv->info_text) { - tree->priv->info_text = gnome_canvas_item_new (GNOME_CANVAS_GROUP (gnome_canvas_root (tree->priv->table_canvas)), - e_text_get_type (), - "anchor", GTK_ANCHOR_NW, - "line_wrap", TRUE, - "clip", TRUE, - "justification", GTK_JUSTIFY_LEFT, - "text", info_message, - "draw_background", FALSE, - "width", (gdouble) GTK_WIDGET (tree->priv->table_canvas)->allocation.width - 60.0, - "clip_width", (gdouble) GTK_WIDGET (tree->priv->table_canvas)->allocation.width - 60.0, - NULL); + tree->priv->info_text = gnome_canvas_item_new ( + GNOME_CANVAS_GROUP (gnome_canvas_root (tree->priv->table_canvas)), + e_text_get_type (), + "anchor", GTK_ANCHOR_NW, + "line_wrap", TRUE, + "clip", TRUE, + "justification", GTK_JUSTIFY_LEFT, + "text", info_message, + "draw_background", FALSE, + "width", (gdouble) allocation.width - 60.0, + "clip_width", (gdouble) allocation.width - 60.0, + NULL); e_canvas_item_move_absolute (tree->priv->info_text, 30, 30); diff --git a/widgets/table/gal-a11y-e-cell-popup.c b/widgets/table/gal-a11y-e-cell-popup.c index 33dcf733a5..921ae8e4d5 100644 --- a/widgets/table/gal-a11y-e-cell-popup.c +++ b/widgets/table/gal-a11y-e-cell-popup.c @@ -133,9 +133,12 @@ popup_cell_action (GalA11yECell *cell) { gint finished; GdkEvent event; + GtkLayout *layout; + + layout = GTK_LAYOUT (GNOME_CANVAS_ITEM (cell->item)->canvas); event.key.type = GDK_KEY_PRESS; - event.key.window = GTK_LAYOUT(GNOME_CANVAS_ITEM(cell->item)->canvas)->bin_window;; + event.key.window = gtk_layout_get_bin_window (layout); event.key.send_event = TRUE; event.key.time = GDK_CURRENT_TIME; event.key.state = GDK_MOD1_MASK; diff --git a/widgets/table/gal-a11y-e-cell-toggle.c b/widgets/table/gal-a11y-e-cell-toggle.c index 25d59496a7..54b1b3586c 100644 --- a/widgets/table/gal-a11y-e-cell-toggle.c +++ b/widgets/table/gal-a11y-e-cell-toggle.c @@ -90,6 +90,7 @@ static void toggle_cell_action (GalA11yECell *cell) { gint finished; + GtkLayout *layout; GdkEventButton event; gint x, y, width, height; gint row, col; @@ -97,14 +98,16 @@ toggle_cell_action (GalA11yECell *cell) row = cell->row; col = cell->view_col; - e_table_item_get_cell_geometry (cell->item, &row, &col, - &x, &y, &width, &height); + layout = GTK_LAYOUT (GNOME_CANVAS_ITEM (cell->item)->canvas); + + e_table_item_get_cell_geometry ( + cell->item, &row, &col, &x, &y, &width, &height); event.x = x + width / 2 + (gint)(GNOME_CANVAS_ITEM (cell->item)->x1); event.y = y + height / 2 + (gint)(GNOME_CANVAS_ITEM (cell->item)->y1); event.type = GDK_BUTTON_PRESS; - event.window = GTK_LAYOUT(GNOME_CANVAS_ITEM(cell->item)->canvas)->bin_window; + event.window = gtk_layout_get_bin_window (layout); event.button = 1; event.send_event = TRUE; event.time = GDK_CURRENT_TIME; diff --git a/widgets/table/gal-a11y-e-table-click-to-add.c b/widgets/table/gal-a11y-e-table-click-to-add.c index 8d788a458b..ebec8681ae 100644 --- a/widgets/table/gal-a11y-e-table-click-to-add.c +++ b/widgets/table/gal-a11y-e-table-click-to-add.c @@ -72,26 +72,30 @@ etcta_action_get_name (AtkAction *action, gint i) static gboolean idle_do_action (gpointer data) { - GdkEventButton event; + GtkLayout *layout; + GdkEventButton event; ETableClickToAdd * etcta; - gint finished; + gint finished; g_return_val_if_fail ( data!= NULL, FALSE); - etcta = E_TABLE_CLICK_TO_ADD (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (data))); + etcta = E_TABLE_CLICK_TO_ADD ( + atk_gobject_accessible_get_object ( + ATK_GOBJECT_ACCESSIBLE (data))); g_return_val_if_fail (etcta, FALSE); + layout = GTK_LAYOUT (GNOME_CANVAS_ITEM (etcta)->canvas); + event.x = 0; event.y = 0; - - event.type = GDK_BUTTON_PRESS; - event.window = GTK_LAYOUT(GNOME_CANVAS_ITEM(etcta)->canvas)->bin_window; - event.button = 1; - event.send_event = TRUE; - event.time = GDK_CURRENT_TIME; - event.axes = NULL; - - g_signal_emit_by_name (etcta, "event", &event, &finished); + event.type = GDK_BUTTON_PRESS; + event.window = gtk_layout_get_bin_window (layout); + event.button = 1; + event.send_event = TRUE; + event.time = GDK_CURRENT_TIME; + event.axes = NULL; + + g_signal_emit_by_name (etcta, "event", &event, &finished); return FALSE; } diff --git a/widgets/table/gal-a11y-e-table.c b/widgets/table/gal-a11y-e-table.c index 37e5b892d2..6134b2d297 100644 --- a/widgets/table/gal-a11y-e-table.c +++ b/widgets/table/gal-a11y-e-table.c @@ -90,11 +90,7 @@ init_child_item (GalA11yETable *a11y) return FALSE; table = E_TABLE (GTK_ACCESSIBLE (a11y)->widget); -#if GTK_CHECK_VERSION(2,19,7) if (table && gtk_widget_get_mapped (GTK_WIDGET (table)) && table->group && E_IS_TABLE_GROUP_CONTAINER(table->group)) { -#else - if (table && GTK_WIDGET_MAPPED (GTK_WIDGET (table)) && table->group && E_IS_TABLE_GROUP_CONTAINER(table->group)) { -#endif ETableGroupContainer *etgc = (ETableGroupContainer *)table->group; GList *list; @@ -288,11 +284,7 @@ gal_a11y_e_table_new (GObject *widget) GTK_ACCESSIBLE (a11y)->widget = GTK_WIDGET (widget); /* we need to init all the children for multiple table items */ -#if GTK_CHECK_VERSION(2,19,7) if (table && gtk_widget_get_mapped (GTK_WIDGET (table)) && table->group && E_IS_TABLE_GROUP_CONTAINER (table->group)) { -#else - if (table && GTK_WIDGET_MAPPED (GTK_WIDGET (table)) && table->group && E_IS_TABLE_GROUP_CONTAINER (table->group)) { -#endif /* Ref it here so that it is still valid in the idle function */ /* It will be unrefed in the idle function */ g_object_ref (a11y); |