From: Vladimir Nadvornik Date: Tue, 31 Jul 2012 22:17:18 +0000 (+0200) Subject: use accessor functions X-Git-Tag: v1.2~168 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=dc0a8b78729966b1e85f5a385bd258ba63e20bb7 use accessor functions gtk3 does not allow direct use of data structures, use accessor functions instead --- diff --git a/src/bar.c b/src/bar.c index 70827092..a26b8fa0 100644 --- a/src/bar.c +++ b/src/bar.c @@ -284,9 +284,9 @@ static void bar_menu_popup(GtkWidget *widget) else { expander = widget; - bar = widget->parent; + bar = gtk_widget_get_parent(widget); while (bar && !g_object_get_data(G_OBJECT(bar), "bar_data")) - bar = bar->parent; + bar = gtk_widget_get_parent(bar); if (!bar) return; } @@ -496,7 +496,7 @@ void bar_update_expander(GtkWidget *pane) if (!pd) return; - expander = pane->parent; + expander = gtk_widget_get_parent(pane); gtk_expander_set_expanded(GTK_EXPANDER(expander), pd->expanded); } diff --git a/src/bar_exif.c b/src/bar_exif.c index 7c029994..e07a4917 100644 --- a/src/bar_exif.c +++ b/src/bar_exif.c @@ -350,7 +350,7 @@ static void bar_pane_exif_entry_dnd_get(GtkWidget *entry, GdkDragContext *contex switch (info) { case TARGET_APP_EXIF_ENTRY: - gtk_selection_data_set(selection_data, selection_data->target, + gtk_selection_data_set(selection_data, gtk_selection_data_get_target(selection_data), 8, (gpointer) &entry, sizeof(entry)); break; @@ -378,14 +378,14 @@ static void bar_pane_exif_dnd_receive(GtkWidget *pane, GdkDragContext *context, switch (info) { case TARGET_APP_EXIF_ENTRY: - new_entry = *(gpointer *)selection_data->data; + new_entry = *(gpointer *)gtk_selection_data_get_data(selection_data); - if (new_entry->parent && new_entry->parent != ped->vbox) bar_pane_exif_reparent_entry(new_entry, pane); + if (gtk_widget_get_parent(new_entry) && gtk_widget_get_parent(new_entry) != ped->vbox) bar_pane_exif_reparent_entry(new_entry, pane); break; default: /* FIXME: this needs a check for valid exif keys */ - new_entry = bar_pane_exif_add_entry(ped, (gchar *)selection_data->data, NULL, TRUE, FALSE); + new_entry = bar_pane_exif_add_entry(ped, (gchar *)gtk_selection_data_get_data(selection_data), NULL, TRUE, FALSE); break; } @@ -396,17 +396,20 @@ static void bar_pane_exif_dnd_receive(GtkWidget *pane, GdkDragContext *context, { gint nx, ny; GtkWidget *entry = work->data; + GtkAllocation allocation; work = work->next; if (entry == new_entry) continue; + gtk_widget_get_allocation(entry, &allocation); + #if GTK_CHECK_VERSION(2,20,0) if (gtk_widget_is_drawable(entry) && #else if (GTK_WIDGET_DRAWABLE(entry) && #endif gtk_widget_translate_coordinates(pane, entry, x, y, &nx, &ny) && - ny < entry->allocation.height / 2) break; + ny < allocation.height / 2) break; pos++; } g_list_free(list); @@ -488,13 +491,13 @@ static void bar_pane_exif_edit_ok_cb(GenericDialog *gd, gpointer data) if (ee) { const gchar *title; - GtkWidget *pane = cdd->widget->parent; + GtkWidget *pane = gtk_widget_get_parent(cdd->widget); while (pane) { ped = g_object_get_data(G_OBJECT(pane), "pane_data"); if (ped) break; - pane = pane->parent; + pane = gtk_widget_get_parent(pane); } if (!pane) return; diff --git a/src/bar_histogram.c b/src/bar_histogram.c index d19aa733..a0659a8b 100644 --- a/src/bar_histogram.c +++ b/src/bar_histogram.c @@ -156,17 +156,11 @@ static gboolean bar_pane_histogram_expose_event_cb(GtkWidget *widget, GdkEventEx if (!phd->pixbuf) return TRUE; - gdk_draw_pixbuf(widget->window, -#if GTK_CHECK_VERSION(2,20,0) - widget->style->fg_gc[gtk_widget_get_state(widget)], -#else - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], -#endif - phd->pixbuf, - 0, 0, - 0, 0, - -1, -1, - GDK_RGB_DITHER_NORMAL, 0, 0); + cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget)); + gdk_cairo_set_source_pixbuf (cr, phd->pixbuf, 0, 0); + cairo_paint (cr); + cairo_destroy (cr); + return TRUE; } diff --git a/src/bar_keywords.c b/src/bar_keywords.c index bdbc8e03..9a849bce 100644 --- a/src/bar_keywords.c +++ b/src/bar_keywords.c @@ -490,7 +490,7 @@ static void bar_pane_keywords_dnd_get(GtkWidget *tree_view, GdkDragContext *cont case TARGET_APP_KEYWORD_PATH: { GList *path = keyword_tree_get_path(keyword_tree, &child_iter); - gtk_selection_data_set(selection_data, selection_data->target, + gtk_selection_data_set(selection_data, gtk_selection_data_get_target(selection_data), 8, (gpointer) &path, sizeof(path)); break; } @@ -611,13 +611,13 @@ static void bar_pane_keywords_dnd_receive(GtkWidget *tree_view, GdkDragContext * { case TARGET_APP_KEYWORD_PATH: { - GList *path = *(gpointer *)selection_data->data; + GList *path = *(gpointer *)gtk_selection_data_get_data(selection_data); src_valid = keyword_tree_get_iter(keyword_tree, &src_kw_iter, path); string_list_free(path); break; } default: - new_keywords = string_to_keywords_list((gchar *)selection_data->data); + new_keywords = string_to_keywords_list((gchar *)gtk_selection_data_get_data(selection_data)); break; } diff --git a/src/bar_sort.c b/src/bar_sort.c index 59987bd7..16eb85e6 100644 --- a/src/bar_sort.c +++ b/src/bar_sort.c @@ -599,12 +599,12 @@ static GtkWidget *bar_sort_new(LayoutWindow *lw, SortActionType action, gtk_box_pack_start(GTK_BOX(sd->vbox), label, FALSE, FALSE, 0); gtk_widget_show(label); - combo = gtk_combo_box_new_text(); + combo = gtk_combo_box_text_new(); gtk_box_pack_start(GTK_BOX(sd->vbox), combo, FALSE, FALSE, 0); gtk_widget_show(combo); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Folders")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Collections")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Folders")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Collections")); g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(bar_sort_mode_cb), sd); diff --git a/src/cache_maint.c b/src/cache_maint.c index 0816b71e..0da0a0b5 100644 --- a/src/cache_maint.c +++ b/src/cache_maint.c @@ -338,7 +338,7 @@ void cache_maintain_home(gboolean metadata, gboolean clear, GtkWidget *parent) gtk_widget_show(hbox); cm->entry = gtk_entry_new(); - GTK_WIDGET_UNSET_FLAGS(cm->entry, GTK_CAN_FOCUS); + gtk_widget_set_can_focus(cm->entry, FALSE); gtk_editable_set_editable(GTK_EDITABLE(cm->entry), FALSE); gtk_box_pack_start(GTK_BOX(hbox), cm->entry, TRUE, TRUE, 0); gtk_widget_show(cm->entry); @@ -910,7 +910,7 @@ static void cache_manager_render_dialog(GtkWidget *widget, const gchar *path) hbox = pref_box_new(cd->gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); cd->progress = gtk_entry_new(); - GTK_WIDGET_UNSET_FLAGS(cd->progress, GTK_CAN_FOCUS); + gtk_widget_set_can_focus(cd->progress, FALSE); gtk_editable_set_editable(GTK_EDITABLE(cd->progress), FALSE); gtk_entry_set_text(GTK_ENTRY(cd->progress), _("click start to begin")); gtk_box_pack_start(GTK_BOX(hbox), cd->progress, TRUE, TRUE, 0); diff --git a/src/cellrenderericon.c b/src/cellrenderericon.c index 00f4ede8..2538aea0 100644 --- a/src/cellrenderericon.c +++ b/src/cellrenderericon.c @@ -126,8 +126,7 @@ static void gqv_cell_renderer_icon_init(GQvCellRendererIcon *cellicon) { GTK_CELL_RENDERER(cellicon)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE; - GTK_CELL_RENDERER(cellicon)->xpad = 2; - GTK_CELL_RENDERER(cellicon)->ypad = 2; + gtk_cell_renderer_set_padding(GTK_CELL_RENDERER(cellicon), 2, 2); } static void @@ -553,6 +552,11 @@ gqv_cell_renderer_icon_get_size(GtkCellRenderer *cell, GQvCellRendererIcon *cellicon = (GQvCellRendererIcon *) cell; gint calc_width; gint calc_height; + gint xpad, ypad; + gint xalign, yalign; + + gtk_cell_renderer_get_padding(cell, &xpad, &ypad); + gtk_cell_renderer_get_alignment(cell, &xalign, &yalign); if (cellicon->fixed_width > 0) { @@ -591,8 +595,8 @@ gqv_cell_renderer_icon_get_size(GtkCellRenderer *cell, calc_width = MAX(calc_width, TOGGLE_SPACING * cellicon->num_marks); } - calc_width += (gint)cell->xpad * 2; - calc_height += (gint)cell->ypad * 2; + calc_width += xpad * 2; + calc_height += ypad * 2; if (x_offset) *x_offset = 0; if (y_offset) *y_offset = 0; @@ -601,13 +605,13 @@ gqv_cell_renderer_icon_get_size(GtkCellRenderer *cell, { if (x_offset) { - *x_offset = (cell->xalign * (cell_area->width - calc_width - 2 * cell->xpad)); - *x_offset = MAX(*x_offset, 0) + cell->xpad; + *x_offset = (xalign * (cell_area->width - calc_width - 2 * xpad)); + *x_offset = MAX(*x_offset, 0) + xpad; } if (y_offset) { - *y_offset = (cell->yalign * (cell_area->height - calc_height - 2 * cell->ypad)); - *y_offset = MAX(*y_offset, 0) + cell->ypad; + *y_offset = (yalign * (cell_area->height - calc_height - 2 * ypad)); + *y_offset = MAX(*y_offset, 0) + ypad; } } @@ -630,20 +634,24 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, const gchar *text; GdkRectangle cell_rect; GtkStateType state; + gint xpad, ypad; + pixbuf = cellicon->pixbuf; text = cellicon->text; if (!pixbuf && !text) return; + gtk_cell_renderer_get_padding(cell, &xpad, &ypad); + gqv_cell_renderer_icon_get_size(cell, widget, cell_area, &cell_rect.x, &cell_rect.y, &cell_rect.width, &cell_rect.height); - cell_rect.x += cell->xpad; - cell_rect.y += cell->ypad; - cell_rect.width -= cell->xpad * 2; - cell_rect.height -= cell->ypad * 2; + cell_rect.x += xpad; + cell_rect.y += ypad; + cell_rect.width -= xpad * 2; + cell_rect.height -= ypad * 2; if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED) { @@ -680,7 +688,7 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, if (cellicon->fixed_height > 0) { - pix_rect.y = cell_area->y + cell->ypad + (cellicon->fixed_height - pix_rect.height) / 2; + pix_rect.y = cell_area->y + ypad + (cellicon->fixed_height - pix_rect.height) / 2; } else { @@ -717,8 +725,8 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, pix_rect.width = text_rect.width; pix_rect.height = text_rect.height; - pix_rect.x = cell_area->x + cell->xpad + (cell_rect.width - text_rect.width + 1) / 2; - pix_rect.y = cell_area->y + cell->ypad + (cell_rect.height - text_rect.height); + pix_rect.x = cell_area->x + xpad + (cell_rect.width - text_rect.width + 1) / 2; + pix_rect.y = cell_area->y + ypad + (cell_rect.height - text_rect.height); if (cellicon->show_marks) { @@ -747,8 +755,8 @@ gqv_cell_renderer_icon_render(GtkCellRenderer *cell, pix_rect.width = TOGGLE_SPACING * cellicon->num_marks; pix_rect.height = TOGGLE_SPACING; - pix_rect.x = cell_area->x + cell->xpad + (cell_rect.width - pix_rect.width + 1) / 2 + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2; - pix_rect.y = cell_area->y + cell->ypad + (cell_rect.height - pix_rect.height) + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2; + pix_rect.x = cell_area->x + xpad + (cell_rect.width - pix_rect.width + 1) / 2 + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2; + pix_rect.y = cell_area->y + ypad + (cell_rect.height - pix_rect.height) + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2; if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) && gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect)) @@ -800,22 +808,25 @@ gqv_cell_renderer_icon_activate(GtkCellRenderer *cell, GdkRectangle rect; GdkRectangle cell_rect; gint i; + gint xpad, ypad; + + gtk_cell_renderer_get_padding(cell, &xpad, &ypad); gqv_cell_renderer_icon_get_size(cell, widget, cell_area, &cell_rect.x, &cell_rect.y, &cell_rect.width, &cell_rect.height); - cell_rect.x += cell->xpad; - cell_rect.y += cell->ypad; - cell_rect.width -= cell->xpad * 2; - cell_rect.height -= cell->ypad * 2; + cell_rect.x += xpad; + cell_rect.y += ypad; + cell_rect.width -= xpad * 2; + cell_rect.height -= ypad * 2; rect.width = TOGGLE_WIDTH; rect.height = TOGGLE_WIDTH; - rect.y = cell_area->y + cell->ypad + (cell_rect.height - TOGGLE_SPACING) + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2; + rect.y = cell_area->y + ypad + (cell_rect.height - TOGGLE_SPACING) + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2; for (i = 0; i < cellicon->num_marks; i++) { - rect.x = cell_area->x + cell->xpad + (cell_rect.width - TOGGLE_SPACING * cellicon->num_marks + 1) / 2 + i * TOGGLE_SPACING; + rect.x = cell_area->x + xpad + (cell_rect.width - TOGGLE_SPACING * cellicon->num_marks + 1) / 2 + i * TOGGLE_SPACING; if (bevent->x >= rect.x && bevent->x < rect.x + rect.width && bevent->y >= rect.y && bevent->y < rect.y + rect.height) diff --git a/src/collect-table.c b/src/collect-table.c index fb326bee..e54db835 100644 --- a/src/collect-table.c +++ b/src/collect-table.c @@ -244,10 +244,12 @@ static void collection_table_update_extras(CollectTable *ct, gboolean loading, g static void collection_table_toggle_filenames(CollectTable *ct) { + GtkAllocation allocation; ct->show_text = !ct->show_text; options->show_icon_names = ct->show_text; - collection_table_populate_at_new_size(ct, ct->listview->allocation.width, ct->listview->allocation.height, TRUE); + gtk_widget_get_allocation(ct->listview, &allocation); + collection_table_populate_at_new_size(ct, allocation.width, allocation.height, TRUE); } static gint collection_table_get_icon_width(CollectTable *ct) @@ -520,7 +522,7 @@ static void tip_show(CollectTable *ct) if (ct->tip_window) return; - gdk_window_get_pointer(ct->listview->window, &x, &y, NULL); + gdk_window_get_pointer(gtk_widget_get_window(ct->listview), &x, &y, NULL); ct->tip_info = collection_table_find_data_by_coord(ct, x, y, NULL); if (!ct->tip_info) return; @@ -1103,7 +1105,7 @@ static gint page_height(CollectTable *ct) gint ret; adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(ct->listview)); - page_size = (gint)adj->page_increment; + page_size = (gint)gtk_adjustment_get_page_increment(adj); row_height = options->thumbnails.max_height + THUMB_BORDER_PADDING * 2; if (ct->show_text) row_height += options->thumbnails.max_height / 3; @@ -1267,7 +1269,7 @@ static CollectInfo *collection_table_insert_find(CollectTable *ct, CollectInfo * store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); - if (!use_coord) gdk_window_get_pointer(ct->listview->window, &x, &y, NULL); + if (!use_coord) gdk_window_get_pointer(gtk_widget_get_window(ct->listview), &x, &y, NULL); if (source) { @@ -1395,7 +1397,7 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info, gdk_pixbuf_render_pixmap_and_mask(pb, &pixmap, &mask, 128); g_object_unref(pb); - gdk_drawable_get_size(pixmap, &w, &h); + gdk_pixmap_get_size(pixmap, &w, &h); attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; @@ -1417,7 +1419,8 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info, gint x, y; gint w, h; - gdk_drawable_get_size(ct->marker_window, &w, &h); + w = gdk_window_get_width(ct->marker_window); + h = gdk_window_get_height(ct->marker_window); if (!after) { @@ -1472,9 +1475,10 @@ static gboolean collection_table_auto_scroll_idle_cb(gpointer data) if (!ct->drop_idle_id) return FALSE; - window = ct->listview->window; + window = gtk_widget_get_window(ct->listview); gdk_window_get_pointer(window, &x, &y, NULL); - gdk_drawable_get_size(window, &w, &h); + w = gdk_window_get_width(window); + h = gdk_window_get_height(window); if (x >= 0 && x < w && y >= 0 && y < h) { collection_table_motion_update(ct, x, y, TRUE); @@ -2174,8 +2178,7 @@ static void collection_table_dnd_get(GtkWidget *widget, GdkDragContext *context, break; } - gtk_selection_data_set(selection_data, selection_data->target, - 8, (guchar *)uri_text, total); + gtk_selection_data_set_text(selection_data, uri_text, total); g_free(uri_text); } @@ -2192,7 +2195,7 @@ static void collection_table_dnd_receive(GtkWidget *widget, GdkDragContext *cont CollectInfo *drop_info; GList *work; - DEBUG_1("%s", selection_data->data); + DEBUG_1("%s", gtk_selection_data_get_data(selection_data)); collection_table_scroll(ct, FALSE); collection_table_insert_marker(ct, NULL, FALSE); @@ -2202,7 +2205,7 @@ static void collection_table_dnd_receive(GtkWidget *widget, GdkDragContext *cont switch (info) { case TARGET_APP_COLLECTION_MEMBER: - source = collection_from_dnd_data((gchar *)selection_data->data, &list, &info_list); + source = collection_from_dnd_data((gchar *)gtk_selection_data_get_data(selection_data), &list, &info_list); if (source) { if (source == ct->cd) @@ -2226,7 +2229,7 @@ static void collection_table_dnd_receive(GtkWidget *widget, GdkDragContext *cont else { /* it is a move/copy across collections */ - if (context->action == GDK_ACTION_MOVE) + if (gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE) { collection_remove_by_info_list(source, info_list); } @@ -2235,7 +2238,7 @@ static void collection_table_dnd_receive(GtkWidget *widget, GdkDragContext *cont } break; case TARGET_URI_LIST: - list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); + list = uri_filelist_from_text((gchar *)gtk_selection_data_get_data(selection_data), TRUE); work = list; while (work) { diff --git a/src/collect.c b/src/collect.c index 71ff8c1e..3a1b3566 100644 --- a/src/collect.c +++ b/src/collect.c @@ -979,12 +979,15 @@ static gboolean collection_window_keypress(GtkWidget *widget, GdkEventKey *event static void collection_window_get_geometry(CollectWindow *cw) { CollectionData *cd; + GdkWindow *window; if (!cw) return; cd = cw->cd; - gdk_window_get_position(cw->window->window, &cd->window_x, &cd->window_y); - gdk_drawable_get_size(cw->window->window, &cd->window_w, &cd->window_h); + window = gtk_widget_get_window(cw->window); + gdk_window_get_position(window, &cd->window_x, &cd->window_y); + cd->window_w = gdk_window_get_width(window); + cd->window_h = gdk_window_get_height(window); cd->window_read = TRUE; } diff --git a/src/desktop_file.c b/src/desktop_file.c index d49025cc..842e28b2 100644 --- a/src/desktop_file.c +++ b/src/desktop_file.c @@ -217,7 +217,7 @@ static void editor_window_new(const gchar *src_path, const gchar *desktop_name) ew->save_button = pref_button_new(NULL, GTK_STOCK_SAVE, NULL, FALSE, G_CALLBACK(editor_window_save_cb), ew); gtk_container_add(GTK_CONTAINER(button_hbox), ew->save_button); - GTK_WIDGET_SET_FLAGS(ew->save_button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(ew->save_button, TRUE); gtk_widget_set_sensitive(ew->save_button, FALSE); gtk_widget_show(ew->save_button); ct_button = ew->save_button; @@ -225,7 +225,7 @@ static void editor_window_new(const gchar *src_path, const gchar *desktop_name) button = pref_button_new(NULL, GTK_STOCK_CLOSE, NULL, FALSE, G_CALLBACK(editor_window_close_cb), ew); gtk_container_add(GTK_CONTAINER(button_hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_show(button); if (!generic_dialog_get_alternative_button_order(ew->window)) @@ -472,13 +472,13 @@ static void editor_list_window_create(void) button = pref_button_new(NULL, GTK_STOCK_NEW, NULL, FALSE, G_CALLBACK(editor_list_window_new_cb), ewl); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_show(button); button = pref_button_new(NULL, GTK_STOCK_EDIT, NULL, FALSE, G_CALLBACK(editor_list_window_edit_cb), ewl); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_set_sensitive(button, FALSE); gtk_widget_show(button); ewl->edit_button = button; @@ -486,7 +486,7 @@ static void editor_list_window_create(void) button = pref_button_new(NULL, GTK_STOCK_DELETE, NULL, FALSE, G_CALLBACK(editor_list_window_delete_cb), ewl); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_set_sensitive(button, FALSE); gtk_widget_show(button); ewl->delete_button = button; @@ -494,7 +494,7 @@ static void editor_list_window_create(void) button = pref_button_new(NULL, GTK_STOCK_CLOSE, NULL, FALSE, G_CALLBACK(editor_list_window_close_cb), ewl); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_show(button); scrolled = gtk_scrolled_window_new(NULL, NULL); diff --git a/src/dnd.c b/src/dnd.c index 6464a195..c50addb2 100644 --- a/src/dnd.c +++ b/src/dnd.c @@ -99,8 +99,6 @@ static void pixbuf_draw_rect(GdkPixbuf *pixbuf, gint x, gint y, gint w, gint h, void dnd_set_drag_icon(GtkWidget *widget, GdkDragContext *context, GdkPixbuf *pixbuf, gint items) { - GdkPixmap *pixmap; - GdkBitmap *mask; GdkPixbuf *dest; gint w, h; gint sw, sh; @@ -151,21 +149,17 @@ void dnd_set_drag_icon(GtkWidget *widget, GdkDragContext *context, GdkPixbuf *pi pixbuf_draw_rect(dest, x, y, lw, lh, 128); } - gdk_pixbuf_render_pixmap_and_mask(dest, &pixmap, &mask, 128); - g_object_unref(dest); - if (layout) { - gdk_draw_layout(pixmap, widget->style->black_gc, x+1, y+1, layout); - gdk_draw_layout(pixmap, widget->style->white_gc, x, y, layout); + pixbuf_draw_layout(dest, layout, NULL, x+1, y+1, 0, 0, 0, 255); + pixbuf_draw_layout(dest, layout, NULL, x, y, 255, 255, 255, 255); g_object_unref(G_OBJECT(layout)); } - gtk_drag_set_icon_pixmap(context, gtk_widget_get_colormap(widget), pixmap, mask, -8, -6); + gtk_drag_set_icon_pixbuf(context, dest, -8, -6); - g_object_unref(pixmap); - if (mask) g_object_unref(mask); + g_object_unref(dest); } static void dnd_set_drag_label_end_cb(GtkWidget *widget, GdkDragContext *context, gpointer data) diff --git a/src/dupe.c b/src/dupe.c index a0b01fd8..de5192ae 100644 --- a/src/dupe.c +++ b/src/dupe.c @@ -217,7 +217,7 @@ static void widget_set_cursor(GtkWidget *widget, gint icon) { GdkCursor *cursor; - if (!widget->window) return; + if (!gtk_widget_get_window(widget)) return; if (icon == -1) { @@ -228,7 +228,7 @@ static void widget_set_cursor(GtkWidget *widget, gint icon) cursor = gdk_cursor_new(icon); } - gdk_window_set_cursor(widget->window, cursor); + gdk_window_set_cursor(gtk_widget_get_window(widget), cursor); if (cursor) gdk_cursor_unref(cursor); } @@ -2581,7 +2581,7 @@ static void dupe_second_set_toggle_cb(GtkWidget *widget, gpointer data) { DupeWindow *dw = data; - dw->second_set = GTK_TOGGLE_BUTTON(widget)->active; + dw->second_set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); if (dw->second_set) { @@ -2797,7 +2797,7 @@ static void dupe_window_show_thumb_cb(GtkWidget *widget, gpointer data) { DupeWindow *dw = data; - dw->show_thumbs = GTK_TOGGLE_BUTTON(widget)->active; + dw->show_thumbs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); if (dw->show_thumbs) { @@ -3412,8 +3412,7 @@ static void dupe_dnd_data_set(GtkWidget *widget, GdkDragContext *context, break; } - if (uri_text) gtk_selection_data_set(selection_data, selection_data->target, - 8, (guchar *)uri_text, length); + if (uri_text) gtk_selection_data_set_text(selection_data, uri_text, length); g_free(uri_text); } @@ -3435,10 +3434,10 @@ static void dupe_dnd_data_get(GtkWidget *widget, GdkDragContext *context, switch (info) { case TARGET_APP_COLLECTION_MEMBER: - collection_from_dnd_data((gchar *)selection_data->data, &list, NULL); + collection_from_dnd_data((gchar *)gtk_selection_data_get_data(selection_data), &list, NULL); break; case TARGET_URI_LIST: - list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); + list = uri_filelist_from_text((gchar *)gtk_selection_data_get_data(selection_data), TRUE); work = list; while (work) { diff --git a/src/fullscreen.c b/src/fullscreen.c index 48d91d54..8a66da75 100644 --- a/src/fullscreen.c +++ b/src/fullscreen.c @@ -37,36 +37,28 @@ enum { static void clear_mouse_cursor(GtkWidget *widget, gint state) { - if (!widget->window) return; + GdkWindow *window = gtk_widget_get_window(widget); + if (!window) return; if (state & FULLSCREEN_CURSOR_BUSY) { GdkCursor *cursor; cursor = gdk_cursor_new(GDK_WATCH); - gdk_window_set_cursor(widget->window, cursor); + gdk_window_set_cursor(window, cursor); gdk_cursor_unref(cursor); } else if (state & FULLSCREEN_CURSOR_NORMAL) { - gdk_window_set_cursor(widget->window, NULL); + gdk_window_set_cursor(window, NULL); } else { GdkCursor *cursor; - GdkPixmap *p; - - p = gdk_bitmap_create_from_data(widget->window, "\0\0\0", 1, 1); - - cursor = gdk_cursor_new_from_pixmap(p, p, - &widget->style->fg[GTK_STATE_ACTIVE], - &widget->style->bg[GTK_STATE_ACTIVE], - 0, 0); - - gdk_window_set_cursor(widget->window, cursor); - + + cursor = gdk_cursor_new(GDK_BLANK_CURSOR); + gdk_window_set_cursor(window, cursor); gdk_cursor_unref(cursor); - g_object_unref(p); } } @@ -510,13 +502,13 @@ void fullscreen_prefs_get_geometry(gint screen, GtkWidget *widget, gint *x, gint if (height) *height = sd->height; if (dest_screen) *dest_screen = screen; - if (same_region) *same_region = (!widget || !widget->window || + if (same_region) *same_region = (!widget || !gtk_widget_get_window(widget) || (screen == gtk_widget_get_screen(widget) && (sd->number%100 == 0 || - sd->number%100 == gdk_screen_get_monitor_at_window(screen, widget->window)+1))); + sd->number%100 == gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(widget))+1))); } - else if (screen != 1 || !widget || !widget->window) + else if (screen != 1 || !widget || !gtk_widget_get_window(widget)) { GdkScreen *screen; @@ -544,7 +536,7 @@ void fullscreen_prefs_get_geometry(gint screen, GtkWidget *widget, gint *x, gint GdkRectangle rect; screen = gtk_widget_get_screen(widget); - monitor = gdk_screen_get_monitor_at_window(screen, widget->window); + monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(widget)); gdk_screen_get_monitor_geometry(screen, monitor, &rect); @@ -566,10 +558,10 @@ gint fullscreen_prefs_find_screen_for_widget(GtkWidget *widget) gint monitor; gint n; - if (!widget || !widget->window) return 0; + if (!widget || !gtk_widget_get_window(widget)) return 0; screen = gtk_widget_get_screen(widget); - monitor = gdk_screen_get_monitor_at_window(screen, widget->window); + monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(widget)); n = (gdk_screen_get_number(screen)+1) * 100 + monitor + 1; diff --git a/src/image.c b/src/image.c index 6d56b8b9..a29668f2 100644 --- a/src/image.c +++ b/src/image.c @@ -892,21 +892,24 @@ static void image_focus_paint(ImageWindow *imd, gboolean has_focus, GdkRectangle GtkWidget *widget; widget = imd->widget; - if (!widget->window) return; + if (!gtk_widget_get_window(widget)) return; + + GtkAllocation allocation; + gtk_widget_get_allocation(widget, &allocation); if (has_focus) { - gtk_paint_focus(widget->style, widget->window, GTK_STATE_ACTIVE, + gtk_paint_focus(gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_ACTIVE, area, widget, "image_window", - widget->allocation.x, widget->allocation.y, - widget->allocation.width - 1, widget->allocation.height - 1); + allocation.x, allocation.y, + allocation.width - 1, allocation.height - 1); } else { - gtk_paint_shadow(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, + gtk_paint_shadow(gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL, GTK_SHADOW_IN, area, widget, "image_window", - widget->allocation.x, widget->allocation.y, - widget->allocation.width - 1, widget->allocation.height - 1); + allocation.x, allocation.y, + allocation.width - 1, allocation.height - 1); } } @@ -926,7 +929,7 @@ static gboolean image_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, gpoin { ImageWindow *imd = data; - GTK_WIDGET_SET_FLAGS(imd->widget, GTK_HAS_FOCUS); + gtk_widget_grab_focus(imd->widget); image_focus_paint(imd, TRUE, NULL); if (imd->func_focus_in) @@ -941,7 +944,7 @@ static gboolean image_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, gpoi { ImageWindow *imd = data; - GTK_WIDGET_UNSET_FLAGS(imd->widget, GTK_HAS_FOCUS); +// GTK_WIDGET_UNSET_FLAGS(imd->widget, GTK_HAS_FOCUS); image_focus_paint(imd, FALSE, NULL); return TRUE; @@ -1770,15 +1773,18 @@ static void image_destroy_cb(GtkObject *widget, gpointer data) gboolean selectable_frame_expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) { - gtk_paint_flat_box(widget->style, - widget->window, - widget->state, - (GTK_FRAME(widget))->shadow_type, + GtkAllocation allocation; + gtk_widget_get_allocation(widget, &allocation); + + gtk_paint_flat_box(gtk_widget_get_style(widget), + gtk_widget_get_window(widget), + gtk_widget_get_state(widget), + gtk_frame_get_shadow_type(GTK_FRAME(widget)), NULL, widget, NULL, - widget->allocation.x + 3, widget->allocation.y + 3, - widget->allocation.width - 6, widget->allocation.height - 6); + allocation.x + 3, allocation.y + 3, + allocation.width - 6, allocation.height - 6); return FALSE; @@ -1812,7 +1818,7 @@ void image_set_frame(ImageWindow *imd, gboolean frame) g_signal_connect(G_OBJECT(imd->frame), "expose_event", G_CALLBACK(selectable_frame_expose_cb), NULL); - GTK_WIDGET_SET_FLAGS(imd->frame, GTK_CAN_FOCUS); + gtk_widget_set_can_focus(imd->frame, TRUE); g_signal_connect(G_OBJECT(imd->frame), "focus_in_event", G_CALLBACK(image_focus_in_cb), imd); g_signal_connect(G_OBJECT(imd->frame), "focus_out_event", diff --git a/src/img-view.c b/src/img-view.c index 715d4141..fef76765 100644 --- a/src/img-view.c +++ b/src/img-view.c @@ -322,7 +322,7 @@ static void view_window_menu_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolean *p ImageWindow *imd; imd = view_window_active_image(vw); - gdk_window_get_origin(imd->pr->window, x, y); + gdk_window_get_origin(gtk_widget_get_window(imd->pr), x, y); popup_menu_position_clamp(menu, x, y, 0); } @@ -1487,7 +1487,7 @@ static void view_window_get_dnd_data(GtkWidget *widget, GdkDragContext *context, { GList *work; - list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); + list = uri_filelist_from_text((gchar *)gtk_selection_data_get_data(selection_data), TRUE); work = list; while (work) @@ -1510,7 +1510,7 @@ static void view_window_get_dnd_data(GtkWidget *widget, GdkDragContext *context, } else { - source = collection_from_dnd_data((gchar *)selection_data->data, &list, &info_list); + source = collection_from_dnd_data((gchar *)gtk_selection_data_get_data(selection_data), &list, &info_list); } if (list) @@ -1576,14 +1576,13 @@ static void view_window_set_dnd_data(GtkWidget *widget, GdkDragContext *context, g_list_free(list); if (text) { - gtk_selection_data_set(selection_data, selection_data->target, - 8, (guchar *)text, len); + gtk_selection_data_set_text(selection_data, text, len); g_free(text); } } else { - gtk_selection_data_set(selection_data, selection_data->target, + gtk_selection_data_set(selection_data, gtk_selection_data_get_target(selection_data), 8, NULL, 0); } } diff --git a/src/layout.c b/src/layout.c index b822295f..6abbb5a7 100644 --- a/src/layout.c +++ b/src/layout.c @@ -284,7 +284,7 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw) gtk_box_pack_start(GTK_BOX(box), tabcomp, FALSE, FALSE, 0); gtk_widget_show(tabcomp); - g_signal_connect(G_OBJECT(lw->path_entry->parent), "changed", + g_signal_connect(G_OBJECT(gtk_widget_get_parent(lw->path_entry)), "changed", G_CALLBACK(layout_path_entry_changed_cb), lw); lw->vd = vd_new(lw->options.dir_view_type, lw->dir_fd); @@ -1008,7 +1008,7 @@ void layout_sort_set(LayoutWindow *lw, SortType type, gboolean ascend) lw->sort_method = type; lw->sort_ascend = ascend; - if (lw->info_sort) gtk_label_set_text(GTK_LABEL(GTK_BIN(lw->info_sort)->child), + if (lw->info_sort) gtk_label_set_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(lw->info_sort))), sort_type_get_text(type)); layout_list_sync_sort(lw); } @@ -1025,10 +1025,13 @@ gboolean layout_sort_get(LayoutWindow *lw, SortType *type, gboolean *ascend) gboolean layout_geometry_get(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h) { + GdkWindow *window; if (!layout_valid(&lw)) return FALSE; - - gdk_window_get_root_origin(lw->window->window, x, y); - gdk_drawable_get_size(lw->window->window, w, h); + + window = gtk_widget_get_window(lw->window); + gdk_window_get_root_origin(window, x, y); + *w = gdk_window_get_width(window); + *h = gdk_window_get_height(window); return TRUE; } @@ -1037,18 +1040,18 @@ gboolean layout_geometry_get_dividers(LayoutWindow *lw, gint *h, gint *v) { if (!layout_valid(&lw)) return FALSE; - if (lw->h_pane && GTK_PANED(lw->h_pane)->child1->allocation.x >= 0) + if (lw->h_pane && gtk_paned_get_child1(GTK_PANED(lw->h_pane))->allocation.x >= 0) { - *h = GTK_PANED(lw->h_pane)->child1->allocation.width; + *h = gtk_paned_get_child1(GTK_PANED(lw->h_pane))->allocation.width; } else if (h != &lw->options.main_window.hdivider_pos) { *h = lw->options.main_window.hdivider_pos; } - if (lw->v_pane && GTK_PANED(lw->v_pane)->child1->allocation.x >= 0) + if (lw->v_pane && gtk_paned_get_child1(GTK_PANED(lw->v_pane))->allocation.x >= 0) { - *v = GTK_PANED(lw->v_pane)->child1->allocation.height; + *v = gtk_paned_get_child1(GTK_PANED(lw->v_pane))->allocation.height; } else if (v != &lw->options.main_window.vdivider_pos) { @@ -1142,6 +1145,7 @@ static void layout_location_compute(LayoutLocation l1, LayoutLocation l2, gboolean layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h, gint *divider_pos) { + GdkWindow *window; if (!layout_valid(&lw)) return FALSE; #if GTK_CHECK_VERSION(2,20,0) @@ -1157,16 +1161,18 @@ gboolean layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, return FALSE; } - gdk_window_get_root_origin(lw->tools->window, x, y); - gdk_drawable_get_size(lw->tools->window, w, h); + window = gtk_widget_get_window(lw->window); + gdk_window_get_root_origin(window, x, y); + *w = gdk_window_get_width(window); + *h = gdk_window_get_height(window); if (GTK_IS_VPANED(lw->tools_pane)) { - *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.height; + *divider_pos = gtk_paned_get_child1(GTK_PANED(lw->tools_pane))->allocation.height; } else { - *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.width; + *divider_pos = gtk_paned_get_child1(GTK_PANED(lw->tools_pane))->allocation.width; } return TRUE; @@ -1272,7 +1278,7 @@ static void layout_tools_setup(LayoutWindow *lw, GtkWidget *tools, GtkWidget *fi { layout_tools_geometry_sync(lw); /* dump the contents */ - gtk_widget_destroy(GTK_BIN(lw->tools)->child); + gtk_widget_destroy(gtk_bin_get_child(GTK_BIN(lw->tools))); } layout_actions_add_window(lw, lw->tools); @@ -1401,8 +1407,8 @@ void layout_split_change(LayoutWindow *lw, ImageSplitMode mode) if (lw->split_images[i]) { gtk_widget_hide(lw->split_images[i]->widget); - if (lw->split_images[i]->widget->parent != lw->utility_paned) - gtk_container_remove(GTK_CONTAINER(lw->split_images[i]->widget->parent), lw->split_images[i]->widget); + if (gtk_widget_get_parent(lw->split_images[i]->widget) != lw->utility_paned) + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(lw->split_images[i]->widget)), lw->split_images[i]->widget); } } gtk_container_remove(GTK_CONTAINER(lw->utility_paned), lw->split_image_widget); @@ -1561,10 +1567,10 @@ void layout_style_set(LayoutWindow *lw, gint style, const gchar *order) /* preserve utility_box (image + sidebars), menu_bar and toolbars to be reused later in layout_grid_setup */ /* lw->image is preserved together with lw->utility_box */ - if (lw->utility_box) gtk_container_remove(GTK_CONTAINER(lw->utility_box->parent), lw->utility_box); - if (lw->menu_bar) gtk_container_remove(GTK_CONTAINER(lw->menu_bar->parent), lw->menu_bar); + if (lw->utility_box) gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(lw->utility_box)), lw->utility_box); + if (lw->menu_bar) gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(lw->menu_bar)), lw->menu_bar); for (i = 0; i < TOOLBAR_COUNT; i++) - if (lw->toolbar[i]) gtk_container_remove(GTK_CONTAINER(lw->toolbar[i]->parent), lw->toolbar[i]); + if (lw->toolbar[i]) gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(lw->toolbar[i])), lw->toolbar[i]); /* clear it all */ @@ -1894,7 +1900,7 @@ void layout_show_config_window(LayoutWindow *lw) button = pref_button_new(NULL, GTK_STOCK_OK, NULL, FALSE, G_CALLBACK(layout_config_ok_cb), lc); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_grab_default(button); gtk_widget_show(button); @@ -1909,13 +1915,13 @@ void layout_show_config_window(LayoutWindow *lw) button = pref_button_new(NULL, GTK_STOCK_APPLY, NULL, FALSE, G_CALLBACK(layout_config_apply_cb), lc); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_show(button); button = pref_button_new(NULL, GTK_STOCK_CANCEL, NULL, FALSE, G_CALLBACK(layout_config_close_cb), lc); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_show(button); if (!generic_dialog_get_alternative_button_order(lc->configwindow)) diff --git a/src/layout_config.c b/src/layout_config.c index 7dc087ef..c51b8715 100644 --- a/src/layout_config.c +++ b/src/layout_config.c @@ -222,7 +222,7 @@ static void layout_config_table_button(GtkWidget *table, LayoutLocation l, const button = gtk_button_new_with_label(text); gtk_widget_set_sensitive(button, FALSE); - GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); + gtk_widget_set_can_focus(button, FALSE); gtk_table_attach_defaults(GTK_TABLE(table), button, x1, x2, y1, y2); gtk_widget_show(button); } diff --git a/src/layout_image.c b/src/layout_image.c index 6a814649..cf5c515c 100644 --- a/src/layout_image.c +++ b/src/layout_image.c @@ -614,13 +614,13 @@ static void layout_image_dnd_receive(GtkWidget *widget, GdkDragContext *context, if (info == TARGET_URI_LIST) { - list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); + list = uri_filelist_from_text((gchar *)gtk_selection_data_get_data(selection_data), TRUE); source = NULL; info_list = NULL; } else { - source = collection_from_dnd_data((gchar *)selection_data->data, &list, &info_list); + source = collection_from_dnd_data((gchar *)gtk_selection_data_get_data(selection_data), &list, &info_list); } if (list) @@ -712,14 +712,13 @@ static void layout_image_dnd_get(GtkWidget *widget, GdkDragContext *context, g_list_free(list); if (text) { - gtk_selection_data_set(selection_data, selection_data->target, - 8, (guchar *)text, len); + gtk_selection_data_set_text(selection_data, text, len); g_free(text); } } else { - gtk_selection_data_set(selection_data, selection_data->target, + gtk_selection_data_set(selection_data, gtk_selection_data_get_target(selection_data), 8, NULL, 0); } } @@ -727,7 +726,7 @@ static void layout_image_dnd_get(GtkWidget *widget, GdkDragContext *context, static void layout_image_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) { LayoutWindow *lw = data; - if (context->action == GDK_ACTION_MOVE) + if (gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE) { FileData *fd; gint row; diff --git a/src/logwindow.c b/src/logwindow.c index 9c9aa4ee..b2260b30 100644 --- a/src/logwindow.c +++ b/src/logwindow.c @@ -127,7 +127,7 @@ static void log_window_init(LogWindow *logwin) memcpy(&logwin->colors[i], &logwin->colors[LOG_NORMAL], sizeof(GdkColor)); } - colormap = gdk_drawable_get_colormap(logwin->window->window); + colormap = gdk_drawable_get_colormap(gtk_widget_get_window(logwin->window)); gdk_colormap_alloc_colors(colormap, logwin->colors, LOG_COUNT, FALSE, TRUE, success); for (i = LOG_NORMAL; i < LOG_COUNT; i++) diff --git a/src/main.c b/src/main.c index 34a97912..b01b07e1 100644 --- a/src/main.c +++ b/src/main.c @@ -747,7 +747,7 @@ gint main(gint argc, gchar *argv[]) init_exec_time(); /* setup locale, i18n */ - gtk_set_locale(); + setlocale(LC_ALL, ""); #ifdef ENABLE_NLS bindtextdomain(PACKAGE, GQ_LOCALEDIR); diff --git a/src/menu.c b/src/menu.c index 3896ba45..e586218e 100644 --- a/src/menu.c +++ b/src/menu.c @@ -54,9 +54,9 @@ static GtkWidget *add_menu_item(GtkWidget *menu, gchar *label, GtkAccelGroup *ac gpointer submenu_item_get_data(GtkWidget *menu) { - if (!menu->parent || !GTK_IS_MENU(menu->parent)) return NULL; + if (!gtk_widget_get_parent(menu) || !GTK_IS_MENU(gtk_widget_get_parent(menu))) return NULL; - return g_object_get_data(G_OBJECT(menu->parent), "submenu_data"); + return g_object_get_data(G_OBJECT(gtk_widget_get_parent(menu)), "submenu_data"); } /* diff --git a/src/pan-view.c b/src/pan-view.c index e52a598a..6e7edff8 100644 --- a/src/pan-view.c +++ b/src/pan-view.c @@ -1193,7 +1193,7 @@ static void pan_window_menu_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolean *pu { PanWindow *pw = data; - gdk_window_get_origin(pw->imd->pr->window, x, y); + gdk_window_get_origin(gtk_widget_get_window(pw->imd->pr), x, y); popup_menu_position_clamp(menu, x, y, 0); } @@ -2199,12 +2199,12 @@ static void pan_window_image_scroll_notify_cb(PixbufRenderer *pr, gpointer data) pixbuf_renderer_get_image_size(pr, &width, &height); adj = gtk_range_get_adjustment(GTK_RANGE(pw->scrollbar_h)); - adj->page_size = (gdouble)rect.width; - adj->page_increment = adj->page_size / 2.0; - adj->step_increment = 48.0 / pr->scale; - adj->lower = 0.0; - adj->upper = MAX((gdouble)width, 1.0); - adj->value = (gdouble)rect.x; + gtk_adjustment_set_page_size(adj, rect.width); + gtk_adjustment_set_page_increment(adj, gtk_adjustment_get_page_size(adj) / 2.0); + gtk_adjustment_set_step_increment(adj, 48.0 / pr->scale); + gtk_adjustment_set_lower(adj, 0.0); + gtk_adjustment_set_upper(adj, MAX((gdouble)width, 1.0)); + gtk_adjustment_set_value(adj, (gdouble)rect.x); pref_signal_block_data(pw->scrollbar_h, pw); gtk_adjustment_changed(adj); @@ -2212,12 +2212,12 @@ static void pan_window_image_scroll_notify_cb(PixbufRenderer *pr, gpointer data) pref_signal_unblock_data(pw->scrollbar_h, pw); adj = gtk_range_get_adjustment(GTK_RANGE(pw->scrollbar_v)); - adj->page_size = (gdouble)rect.height; - adj->page_increment = adj->page_size / 2.0; - adj->step_increment = 48.0 / pr->scale; - adj->lower = 0.0; - adj->upper = MAX((gdouble)height, 1.0); - adj->value = (gdouble)rect.y; + gtk_adjustment_set_page_size(adj, rect.height); + gtk_adjustment_set_page_increment(adj, gtk_adjustment_get_page_size(adj) / 2.0); + gtk_adjustment_set_step_increment(adj, 48.0 / pr->scale); + gtk_adjustment_set_lower(adj, 0.0); + gtk_adjustment_set_upper(adj, MAX((gdouble)height, 1.0)); + gtk_adjustment_set_value(adj, (gdouble)rect.y); pref_signal_block_data(pw->scrollbar_v, pw); gtk_adjustment_changed(adj); @@ -2406,17 +2406,17 @@ static void pan_window_new_real(FileData *dir_fd) pref_label_new(box, _("Location:")); combo = tab_completion_new_with_history(&pw->path_entry, dir_fd->path, "pan_view_path", -1, pan_window_entry_activate_cb, pw); - g_signal_connect(G_OBJECT(pw->path_entry->parent), "changed", + g_signal_connect(G_OBJECT(gtk_widget_get_parent(pw->path_entry)), "changed", G_CALLBACK(pan_window_entry_change_cb), pw); gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0); gtk_widget_show(combo); - combo = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Timeline")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Calendar")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Folders")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Folders (flower)")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Grid")); + combo = gtk_combo_box_text_new(); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Timeline")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Calendar")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Folders")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Folders (flower)")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Grid")); gtk_combo_box_set_active(GTK_COMBO_BOX(combo), pw->layout); g_signal_connect(G_OBJECT(combo), "changed", @@ -2424,17 +2424,17 @@ static void pan_window_new_real(FileData *dir_fd) gtk_box_pack_start(GTK_BOX(box), combo, FALSE, FALSE, 0); gtk_widget_show(combo); - combo = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Dots")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("No Images")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Small Thumbnails")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Normal Thumbnails")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Large Thumbnails")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("1:10 (10%)")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("1:4 (25%)")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("1:3 (33%)")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("1:2 (50%)")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("1:1 (100%)")); + combo = gtk_combo_box_text_new(); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Dots")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("No Images")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Small Thumbnails")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Normal Thumbnails")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Large Thumbnails")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("1:10 (10%)")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("1:4 (25%)")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("1:3 (33%)")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("1:2 (50%)")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("1:1 (100%)")); gtk_combo_box_set_active(GTK_COMBO_BOX(combo), pw->size); g_signal_connect(G_OBJECT(combo), "changed", @@ -2933,7 +2933,7 @@ static void pan_window_get_dnd_data(GtkWidget *widget, GdkDragContext *context, { GList *list; - list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); + list = uri_filelist_from_text((gchar *)gtk_selection_data_get_data(selection_data), TRUE); if (list && isdir(((FileData *)list->data)->path)) { FileData *fd = list->data; @@ -2975,14 +2975,13 @@ static void pan_window_set_dnd_data(GtkWidget *widget, GdkDragContext *context, g_list_free(list); if (text) { - gtk_selection_data_set(selection_data, selection_data->target, - 8, (guchar *)text, len); + gtk_selection_data_set_text(selection_data, text, len); g_free(text); } } else { - gtk_selection_data_set(selection_data, selection_data->target, + gtk_selection_data_set(selection_data, gtk_selection_data_get_target(selection_data), 8, NULL, 0); } } diff --git a/src/pixbuf-renderer.c b/src/pixbuf-renderer.c index c2703852..0dc6deb4 100644 --- a/src/pixbuf-renderer.c +++ b/src/pixbuf-renderer.c @@ -611,7 +611,7 @@ static gboolean pixbuf_renderer_expose(GtkWidget *widget, GdkEventExpose *event) if (!GTK_WIDGET_NO_WINDOW(widget)) #endif { - if (event->window != widget->window) + if (event->window != gtk_widget_get_window(widget)) { GdkRectangle area; @@ -643,7 +643,7 @@ static void widget_set_cursor(GtkWidget *widget, gint icon) { GdkCursor *cursor; - if (!widget->window) return; + if (!gtk_widget_get_window(widget)) return; if (icon == -1) { @@ -654,7 +654,7 @@ static void widget_set_cursor(GtkWidget *widget, gint icon) cursor = gdk_cursor_new(icon); } - gdk_window_set_cursor(widget->window, cursor); + gdk_window_set_cursor(gtk_widget_get_window(widget), cursor); if (cursor) gdk_cursor_unref(cursor); } @@ -686,10 +686,10 @@ static gboolean pr_parent_window_sizable(PixbufRenderer *pr) if (!pr->parent_window) return FALSE; if (!pr->window_fit) return FALSE; - if (!GTK_WIDGET(pr)->window) return FALSE; + if (!gtk_widget_get_window(GTK_WIDGET(pr))) return FALSE; - if (!pr->parent_window->window) return FALSE; - state = gdk_window_get_state(pr->parent_window->window); + if (!gtk_widget_get_window(pr->parent_window)) return FALSE; + state = gdk_window_get_state(gtk_widget_get_window(pr->parent_window)); if (state & GDK_WINDOW_STATE_MAXIMIZED) return FALSE; return TRUE; @@ -700,6 +700,8 @@ static gboolean pr_parent_window_resize(PixbufRenderer *pr, gint w, gint h) GtkWidget *widget; GtkWidget *parent; gint ww, wh; + GtkAllocation widget_allocation; + GtkAllocation parent_allocation; if (!pr_parent_window_sizable(pr)) return FALSE; @@ -715,13 +717,17 @@ static gboolean pr_parent_window_resize(PixbufRenderer *pr, gint w, gint h) widget = GTK_WIDGET(pr); parent = GTK_WIDGET(pr->parent_window); - w += (parent->allocation.width - widget->allocation.width); - h += (parent->allocation.height - widget->allocation.height); + gtk_widget_get_allocation(widget, &widget_allocation); + gtk_widget_get_allocation(parent, &parent_allocation); - gdk_drawable_get_size(parent->window, &ww, &wh); + w += (parent_allocation.width - widget_allocation.width); + h += (parent_allocation.height - widget_allocation.height); + + ww = gdk_window_get_width(gtk_widget_get_window(parent)); + wh = gdk_window_get_height(gtk_widget_get_window(parent)); if (w == ww && h == wh) return FALSE; - gdk_window_resize(parent->window, w, h); + gdk_window_resize(gtk_widget_get_window(parent), w, h); return TRUE; } @@ -2137,7 +2143,7 @@ static gboolean pr_mouse_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpo pr->drag_last_x = bevent->x; pr->drag_last_y = bevent->y; pr->drag_moved = 0; - gdk_pointer_grab(widget->window, FALSE, + gdk_pointer_grab(gtk_widget_get_window(widget), FALSE, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); gtk_grab_add(widget); @@ -2449,7 +2455,7 @@ static void pr_set_pixbuf(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom, P if (GTK_WIDGET_REALIZED(box)) #endif { - gdk_window_clear(box->window); + gdk_window_clear(gtk_widget_get_window(box)); pr->renderer->overlay_draw(pr->renderer, 0, 0, pr->viewport_width, pr->viewport_height); if (pr->renderer2) pr->renderer2->overlay_draw(pr->renderer2, 0, 0, pr->viewport_width, pr->viewport_height); } diff --git a/src/pixbuf_util.c b/src/pixbuf_util.c index 2c7378e1..c1681725 100644 --- a/src/pixbuf_util.c +++ b/src/pixbuf_util.c @@ -780,32 +780,36 @@ void pixbuf_draw_layout(GdkPixbuf *pixbuf, PangoLayout *layout, GtkWidget *widge gint x, gint y, guint8 r, guint8 g, guint8 b, guint8 a) { - GdkPixmap *pixmap; GdkPixbuf *buffer; gint w, h; GdkGC *gc; gint sx, sy; gint dw, dh; - - if (!widget || !widget->window) return; + cairo_surface_t *source; + cairo_t *cr; pango_layout_get_pixel_size(layout, &w, &h); if (w < 1 || h < 1) return; - pixmap = gdk_pixmap_new(widget->window, w, h, -1); - - gc = gdk_gc_new(widget->window); - gdk_gc_copy(gc, widget->style->black_gc); - gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, w, h); - gdk_gc_copy(gc, widget->style->white_gc); - gdk_draw_layout(pixmap, gc, 0, 0, layout); - g_object_unref(gc); - - buffer = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, w, h); - gdk_pixbuf_get_from_drawable(buffer, pixmap, - gdk_drawable_get_colormap(widget->window), - 0, 0, 0, 0, w, h); - g_object_unref(pixmap); + source = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + + cr = cairo_create (source); + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_rectangle (cr, 0, 0, w, h); + cairo_fill (cr); + cairo_set_source_rgb(cr, 1, 1, 1); + pango_cairo_show_layout (cr, layout); + cairo_destroy (cr); + + buffer = gdk_pixbuf_new_from_data (cairo_image_surface_get_data (source), + GDK_COLORSPACE_RGB, + cairo_image_surface_get_format (source) == CAIRO_FORMAT_ARGB32, + 8, + cairo_image_surface_get_width (source), + cairo_image_surface_get_height (source), + cairo_image_surface_get_stride (source), + NULL, + NULL); sx = 0; sy = 0; @@ -834,6 +838,7 @@ void pixbuf_draw_layout(GdkPixbuf *pixbuf, PangoLayout *layout, GtkWidget *widge r, g, b, a); g_object_unref(buffer); + cairo_surface_destroy(source); } /* diff --git a/src/preferences.c b/src/preferences.c index 4f3e21ab..1ab7fd75 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -125,13 +125,13 @@ static GtkWidget *sidecar_ext_entry; static void zoom_mode_cb(GtkWidget *widget, gpointer data) { - if (GTK_TOGGLE_BUTTON (widget)->active) + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) c_options->image.zoom_mode = GPOINTER_TO_INT(data); } static void scroll_reset_cb(GtkWidget *widget, gpointer data) { - if (GTK_TOGGLE_BUTTON (widget)->active) + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) c_options->image.scroll_reset_method = GPOINTER_TO_INT(data); } @@ -433,15 +433,15 @@ static void add_quality_menu(GtkWidget *table, gint column, gint row, const gcha pref_table_label(table, column, row, text, 0.0); - combo = gtk_combo_box_new_text(); + combo = gtk_combo_box_text_new(); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Nearest (worst, but fastest)")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Nearest (worst, but fastest)")); if (option == GDK_INTERP_NEAREST) current = 0; - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Tiles")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Tiles")); if (option == GDK_INTERP_TILES) current = 1; - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Bilinear")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Bilinear")); if (option == GDK_INTERP_BILINEAR) current = 2; - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Hyper (best, but slowest)")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Hyper (best, but slowest)")); if (option == GDK_INTERP_HYPER) current = 3; gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current); @@ -511,7 +511,7 @@ static void add_thumb_size_menu(GtkWidget *table, gint column, gint row, gchar * pref_table_label(table, column, row, text, 0.0); - combo = gtk_combo_box_new_text(); + combo = gtk_combo_box_text_new(); current = -1; for (i = 0; (guint) i < sizeof(thumb_size_list) / sizeof(ThumbSize); i++) @@ -523,7 +523,7 @@ static void add_thumb_size_menu(GtkWidget *table, gint column, gint row, gchar * h = thumb_size_list[i].h; buf = g_strdup_printf("%d x %d", w, h); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), buf); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), buf); g_free(buf); if (w == options->thumbnails.max_width && h == options->thumbnails.max_height) current = i; @@ -534,7 +534,7 @@ static void add_thumb_size_menu(GtkWidget *table, gint column, gint row, gchar * gchar *buf; buf = g_strdup_printf("%s %d x %d", _("Custom"), options->thumbnails.max_width, options->thumbnails.max_height); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), buf); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), buf); g_free(buf); current = i; @@ -596,27 +596,27 @@ static void add_stereo_mode_menu(GtkWidget *table, gint column, gint row, const pref_table_label(table, column, row, text, 0.0); - combo = gtk_combo_box_new_text(); + combo = gtk_combo_box_text_new(); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Single image")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Single image")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Anaglyph Red-Cyan")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Anaglyph Red-Cyan")); if (option & PR_STEREO_ANAGLYPH_RC) current = 1; - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Anaglyph Gray Red-Cyan")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Anaglyph Gray Red-Cyan")); if (option & PR_STEREO_ANAGLYPH_GRAY) current = 2; - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Anaglyph Dubois")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Anaglyph Dubois")); if (option & PR_STEREO_ANAGLYPH_DB) current = 3; - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Side by Side")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Side by Side Half size")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Side by Side")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Side by Side Half size")); if (option & PR_STEREO_HORIZ) { current = 4; if (option & PR_STEREO_HALF) current = 5; } - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Top - Bottom")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Top - Bottom Half size")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Top - Bottom")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Top - Bottom Half size")); if (option & PR_STEREO_VERT) { current = 6; @@ -625,7 +625,7 @@ static void add_stereo_mode_menu(GtkWidget *table, gint column, gint row, const if (add_fixed) { - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Fixed position")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Fixed position")); if (option & PR_STEREO_FIXED) current = 8; } @@ -903,7 +903,7 @@ static void safe_delete_clear_cb(GtkWidget *widget, gpointer data) _("This will remove the trash contents.")); generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, safe_delete_clear_ok_cb, TRUE); entry = gtk_entry_new(); - GTK_WIDGET_UNSET_FLAGS(entry, GTK_CAN_FOCUS); + gtk_widget_set_can_focus(entry, FALSE); gtk_editable_set_editable(GTK_EDITABLE(entry), FALSE); if (options->file_ops.safe_delete_path) gtk_entry_set_text(GTK_ENTRY(entry), options->file_ops.safe_delete_path); gtk_box_pack_start(GTK_BOX(gd->vbox), entry, FALSE, FALSE, 0); @@ -2184,7 +2184,7 @@ static void config_window_create(void) button = pref_button_new(NULL, GTK_STOCK_OK, NULL, FALSE, G_CALLBACK(config_window_ok_cb), NULL); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_grab_default(button); gtk_widget_show(button); @@ -2193,19 +2193,19 @@ static void config_window_create(void) button = pref_button_new(NULL, GTK_STOCK_SAVE, NULL, FALSE, G_CALLBACK(config_window_save_cb), NULL); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_show(button); button = pref_button_new(NULL, GTK_STOCK_APPLY, NULL, FALSE, G_CALLBACK(config_window_apply_cb), NULL); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_show(button); button = pref_button_new(NULL, GTK_STOCK_CANCEL, NULL, FALSE, G_CALLBACK(config_window_close_cb), NULL); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_show(button); if (!generic_dialog_get_alternative_button_order(configwindow)) @@ -2333,13 +2333,13 @@ void show_about_window(void) button = pref_button_new(NULL, NULL, _("Credits..."), FALSE, G_CALLBACK(about_credits_cb), NULL); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_show(button); button = pref_button_new(NULL, GTK_STOCK_CLOSE, NULL, FALSE, G_CALLBACK(about_window_close), NULL); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_grab_default(button); gtk_widget_show(button); diff --git a/src/print.c b/src/print.c index e228bdd1..d8e721fd 100644 --- a/src/print.c +++ b/src/print.c @@ -2668,11 +2668,11 @@ static GtkWidget *print_combo_menu(const gchar *text[], gint count, gint preferr GtkWidget *combo; gint i; - combo = gtk_combo_box_new_text(); + combo = gtk_combo_box_text_new(); for (i = 0 ; i < count; i++) { - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _(text[i])); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _(text[i])); } if (preferred >= 0 && preferred < count) @@ -2700,12 +2700,12 @@ static GtkWidget *print_paper_menu(GtkWidget *table, gint column, gint row, pref_table_label(table, column, row, (_("Format:")), 1.0); - combo = gtk_combo_box_new_text(); + combo = gtk_combo_box_text_new(); i = 0; while (print_paper_sizes[i].description) { - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _(print_paper_sizes[i].description)); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _(print_paper_sizes[i].description)); i++; } @@ -2981,7 +2981,7 @@ static void print_custom_entry_set(PrintWindow *pw, GtkWidget *combo) work = work->next; buf = g_strdup_printf(PRINT_LPR_CUSTOM, name); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), buf); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), buf); g_free(buf); } string_list_free(list); diff --git a/src/search.c b/src/search.c index 932d07c2..e019148b 100644 --- a/src/search.c +++ b/src/search.c @@ -1394,8 +1394,7 @@ static void search_dnd_data_set(GtkWidget *widget, GdkDragContext *context, break; } - if (uri_text) gtk_selection_data_set(selection_data, selection_data->target, - 8, (guchar *)uri_text, length); + if (uri_text) gtk_selection_data_set_text(selection_data, uri_text, length); g_free(uri_text); } diff --git a/src/ui_bookmark.c b/src/ui_bookmark.c index 623b2f98..3a0e5eb8 100644 --- a/src/ui_bookmark.c +++ b/src/ui_bookmark.c @@ -383,9 +383,11 @@ static void bookmark_menu_remove_cb(GtkWidget *widget, gpointer data) static void bookmark_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gint *pushed_in, gpointer data) { GtkWidget *button = data; + GtkAllocation allocation; - gdk_window_get_origin(button->window, x, y); - *y += button->allocation.y + button->allocation.height; + gtk_widget_set_allocation(button, &allocation); + gdk_window_get_origin(gtk_widget_get_window(button), x, y); + *y += allocation.y + allocation.height; } static void bookmark_menu_popup(BookMarkData *bm, GtkWidget *button, @@ -472,7 +474,7 @@ static void bookmark_drag_set_data(GtkWidget *button, gint length = 0; GList *list = NULL; - if (context->dest_window == bm->widget->window) return; +// if (context->dest_window == bm->widget->window) return; b = g_object_get_data(G_OBJECT(button), "bookbuttondata"); if (!b) return; @@ -493,8 +495,7 @@ static void bookmark_drag_set_data(GtkWidget *button, if (!uri_text) return; - gtk_selection_data_set(selection_data, selection_data->target, - 8, (guchar *)uri_text, length); + gtk_selection_data_set_text(selection_data, uri_text, length); g_free(uri_text); } @@ -503,17 +504,20 @@ static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpoi GdkPixbuf *pixbuf; GdkModifierType mask; gint x, y; + GtkAllocation allocation; + + gtk_widget_get_allocation(button, &allocation); pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, - button->allocation.width, button->allocation.height); - gdk_pixbuf_get_from_drawable(pixbuf, button->window, NULL, - button->allocation.x, button->allocation.y, - 0, 0, button->allocation.width, button->allocation.height); + allocation.width, allocation.height); + gdk_pixbuf_get_from_drawable(pixbuf, gtk_widget_get_window(button), NULL, + allocation.x, allocation.y, + 0, 0, allocation.width, allocation.height); - gdk_window_get_pointer(button->window, &x, &y, &mask); + gdk_window_get_pointer(gtk_widget_get_window(button), &x, &y, &mask); gtk_drag_set_icon_pixbuf(context, pixbuf, - x - button->allocation.x, y - button->allocation.y); + x - allocation.x, y - allocation.y); g_object_unref(pixbuf); } @@ -688,7 +692,7 @@ static void bookmark_dnd_get_data(GtkWidget *widget, { case TARGET_URI_LIST: case TARGET_X_URL: - list = uri_list_from_text((gchar *)selection_data->data, FALSE); + list = uri_list_from_text((gchar *)gtk_selection_data_get_data(selection_data), FALSE); break; } @@ -871,13 +875,13 @@ GtkWidget *history_combo_new(GtkWidget **entry, const gchar *text, hc->history_key = g_strdup(history_key); hc->history_levels = max_levels; - hc->combo = gtk_combo_box_entry_new_text(); + hc->combo = gtk_combo_box_text_new_with_entry(); #if 0 gtk_combo_set_case_sensitive(GTK_COMBO(hc->combo), TRUE); gtk_combo_set_use_arrows(GTK_COMBO(hc->combo), FALSE); #endif - hc->entry = GTK_BIN(hc->combo)->child; + hc->entry = gtk_bin_get_child(GTK_BIN(hc->combo)); g_object_set_data(G_OBJECT(hc->combo), "history_combo_data", hc); g_object_set_data(G_OBJECT(hc->entry), "history_combo_data", hc); @@ -887,7 +891,7 @@ GtkWidget *history_combo_new(GtkWidget **entry, const gchar *text, work = history_list_get_by_key(hc->history_key); while (work) { - gtk_combo_box_append_text(GTK_COMBO_BOX(hc->combo), (gchar *)work->data); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(hc->combo), (gchar *)work->data); work = work->next; n++; } @@ -944,7 +948,7 @@ void history_combo_append_history(GtkWidget *widget, const gchar *text) work = history_list_get_by_key(hc->history_key); while (work) { - gtk_combo_box_append_text(GTK_COMBO_BOX(hc->combo), (gchar *)work->data); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(hc->combo), (gchar *)work->data); work = work->next; } } diff --git a/src/ui_fileops.c b/src/ui_fileops.c index b5b6c348..9b9a4f9b 100644 --- a/src/ui_fileops.c +++ b/src/ui_fileops.c @@ -77,12 +77,12 @@ static void encoding_dialog(const gchar *path) const gchar *bf; /* check that gtk is initialized (loop is level > 0) */ - if (gtk_main_level() == 0) - { +// if (gtk_main_level() == 0) +// { /* gtk not initialized */ - gtk_init_add(encoding_dialog_delay, g_strdup(path)); - return; - } +// gtk_init_add(encoding_dialog_delay, g_strdup(path)); +// return; +// } if (warned_user) return; warned_user = TRUE; diff --git a/src/ui_help.c b/src/ui_help.c index dc834fca..e67ffd71 100644 --- a/src/ui_help.c +++ b/src/ui_help.c @@ -167,7 +167,7 @@ void help_window_set_key(GtkWidget *window, const gchar *key) text = g_object_get_data(G_OBJECT(window), "text_widget"); if (!text) return; - gdk_window_raise(window->window); + gdk_window_raise(gtk_widget_get_window(window)); if (key) help_window_scroll(text, key); } @@ -181,7 +181,7 @@ void help_window_set_file(GtkWidget *window, const gchar *path, const gchar *key text = g_object_get_data(G_OBJECT(window), "text_widget"); if (!text) return; - gdk_window_raise(window->window); + gdk_window_raise(gtk_widget_get_window(window)); help_window_load_text(text, path); help_window_scroll(text, key); @@ -249,7 +249,7 @@ GtkWidget *help_window_new(const gchar *title, g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(help_window_close), window); gtk_container_add(GTK_CONTAINER(hbox), button); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); gtk_widget_grab_default(button); gtk_widget_show(button); diff --git a/src/ui_menu.c b/src/ui_menu.c index 580e15e8..0219978f 100644 --- a/src/ui_menu.c +++ b/src/ui_menu.c @@ -162,9 +162,11 @@ gboolean popup_menu_position_clamp(GtkMenu *menu, gint *x, gint *y, gint height) gboolean adjusted = FALSE; gint w, h; gint xw, xh; + GtkRequisition requisition; - w = GTK_WIDGET(menu)->requisition.width; - h = GTK_WIDGET(menu)->requisition.height; + gtk_widget_get_requisition(GTK_WIDGET(menu), &requisition); + w = requisition.width; + h = requisition.height; xw = gdk_screen_width(); xh = gdk_screen_height(); diff --git a/src/ui_misc.c b/src/ui_misc.c index 4ff9c760..fcc35ce9 100644 --- a/src/ui_misc.c +++ b/src/ui_misc.c @@ -65,9 +65,14 @@ GtkWidget *pref_group_new(GtkWidget *parent_box, gboolean fill, vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); /* add additional spacing if necessary */ - if (GTK_IS_VBOX(parent_box) && GTK_BOX(parent_box)->children != NULL) + if (GTK_IS_VBOX(parent_box)) { - pref_spacer(vbox, PREF_PAD_GROUP - PREF_PAD_GAP); + GList *list = gtk_container_get_children(GTK_CONTAINER(parent_box)); + if (list) + { + pref_spacer(vbox, PREF_PAD_GROUP - PREF_PAD_GAP); + } + g_list_free(list); } gtk_box_pack_start(GTK_BOX(parent_box), vbox, fill, fill, 0); @@ -928,12 +933,15 @@ static gboolean date_selection_popup_press_cb(GtkWidget *widget, GdkEventButton gint x, y; gint w, h; gint xr, yr; + GdkWindow *window; xr = (gint)event->x_root; yr = (gint)event->y_root; - gdk_window_get_origin(ds->window->window, &x, &y); - gdk_drawable_get_size(ds->window->window, &w, &h); + window = gtk_widget_get_window(ds->window); + gdk_window_get_origin(window, &x, &y); + w = gdk_window_get_width(window); + h = gdk_window_get_height(window); if (xr < x || yr < y || xr > x + w || yr > y + h) { @@ -995,6 +1003,8 @@ static void date_selection_popup(DateSelection *ds) gint x, y; gint wx, wy; gint day, month, year; + GtkAllocation button_allocation; + GtkAllocation window_allocation; if (ds->window) return; @@ -1020,14 +1030,17 @@ static void date_selection_popup(DateSelection *ds) gtk_widget_realize(ds->window); - gdk_window_get_origin(ds->button->window, &wx, &wy); + gdk_window_get_origin(gtk_widget_get_window(ds->button), &wx, &wy); - x = wx + ds->button->allocation.x + ds->button->allocation.width - ds->window->allocation.width; - y = wy + ds->button->allocation.y + ds->button->allocation.height; + gtk_widget_get_allocation(ds->button, &button_allocation); + gtk_widget_get_allocation(ds->window, &window_allocation); + + x = wx + button_allocation.x + button_allocation.width - window_allocation.width; + y = wy + button_allocation.y + button_allocation.height; - if (y + ds->window->allocation.height > gdk_screen_height()) + if (y + window_allocation.height > gdk_screen_height()) { - y = wy + ds->button->allocation.y - ds->window->allocation.height; + y = wy + button_allocation.y - window_allocation.height; } if (x < 0) x = 0; if (y < 0) y = 0; @@ -1036,10 +1049,10 @@ static void date_selection_popup(DateSelection *ds) gtk_widget_show(ds->window); gtk_widget_grab_focus(ds->calendar); - gdk_pointer_grab(ds->window->window, TRUE, + gdk_pointer_grab(gtk_widget_get_window(ds->window), TRUE, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK, NULL, NULL, GDK_CURRENT_TIME); - gdk_keyboard_grab(ds->window->window, TRUE, GDK_CURRENT_TIME); + gdk_keyboard_grab(gtk_widget_get_window(ds->window), TRUE, GDK_CURRENT_TIME); gtk_grab_add(ds->window); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ds->button), TRUE); @@ -1058,15 +1071,19 @@ static void date_selection_button_cb(GtkWidget *widget, gpointer data) static void button_size_allocate_cb(GtkWidget *button, GtkAllocation *allocation, gpointer data) { GtkWidget *spin = data; + GtkRequisition spin_requisition; + gtk_widget_get_requisition(spin, &spin_requisition); - if (allocation->height > spin->requisition.height) + if (allocation->height > spin_requisition.height) { GtkAllocation button_allocation; + GtkAllocation spin_allocation; - button_allocation = button->allocation; - button_allocation.height = spin->requisition.height; - button_allocation.y = spin->allocation.y + - (spin->allocation.height - spin->requisition.height) / 2; + gtk_widget_get_allocation(button, &button_allocation); + gtk_widget_get_allocation(spin, &spin_allocation); + button_allocation.height = spin_requisition.height; + button_allocation.y = spin_allocation.y + + (spin_allocation.height - spin_requisition.height) / 2; gtk_widget_size_allocate(button, &button_allocation); } } @@ -1232,6 +1249,7 @@ static gboolean sizer_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpoin SizerData *sd = data; gint x, y; gint w, h; + GtkAllocation parent_allocation; if (!sd->in_drag) return FALSE; @@ -1264,20 +1282,27 @@ static gboolean sizer_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpoin if (sd->bounding_widget) { - w = CLAMP(w, sd->sizer->allocation.width, sd->bounding_widget->allocation.width); - h = CLAMP(h, sd->sizer->allocation.height, sd->bounding_widget->allocation.height); + GtkAllocation sizer_allocation; + GtkAllocation bounding_allocation; + gtk_widget_get_allocation(sd->sizer, &sizer_allocation); + gtk_widget_get_allocation(sd->bounding_widget, &bounding_allocation); + w = CLAMP(w, sizer_allocation.width, bounding_allocation.width); + h = CLAMP(h, sizer_allocation.height, bounding_allocation.height); } else { - if (w < sd->sizer->allocation.width) w = sd->sizer->allocation.width; - if (h < sd->sizer->allocation.height) h = sd->sizer->allocation.height; + GtkAllocation sizer_allocation; + gtk_widget_get_allocation(sd->sizer, &sizer_allocation); + if (w < sizer_allocation.width) w = sizer_allocation.width; + if (h < sizer_allocation.height) h = sizer_allocation.height; } if (sd->hsize_max >= 0) w = MIN(w, sd->hsize_max); if (sd->vsize_max >= 0) h = MIN(h, sd->vsize_max); - if (w == sd->parent->allocation.width) w = -1; - if (h == sd->parent->allocation.height) h = -1; + gtk_widget_get_allocation(sd->parent, &parent_allocation); + if (w == parent_allocation.width) w = -1; + if (h == parent_allocation.height) h = -1; if (w > 0 || h > 0) gtk_widget_set_size_request(sd->parent, w, h); @@ -1287,6 +1312,7 @@ static gboolean sizer_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpoin static gboolean sizer_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) { SizerData *sd = data; + GtkAllocation parent_allocation; if (bevent->button != MOUSE_BUTTON_LEFT) return FALSE; @@ -1294,10 +1320,11 @@ static gboolean sizer_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpoint sd->press_x = bevent->x_root; sd->press_y = bevent->y_root; - sd->press_width = sd->parent->allocation.width; - sd->press_height = sd->parent->allocation.height; + gtk_widget_get_allocation(sd->parent, &parent_allocation); + sd->press_width = parent_allocation.width; + sd->press_height = parent_allocation.height; - gdk_pointer_grab(sd->sizer->window, FALSE, + gdk_pointer_grab(gtk_widget_get_window(sd->sizer), FALSE, GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); gtk_grab_add(sd->sizer); @@ -1328,9 +1355,12 @@ static gboolean sizer_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpoi static void sizer_set_prelight(SizerData *sd, gboolean prelit) { + GtkAllocation sizer_allocation; + gtk_widget_get_allocation(sd->sizer, &sizer_allocation); + sd->handle_prelit = prelit; gtk_widget_queue_draw_area(sd->sizer, 0, 0, - sd->sizer->allocation.width, sd->sizer->allocation.height); + sizer_allocation.width, sizer_allocation.height); } static gboolean sizer_enter_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data) @@ -1355,6 +1385,7 @@ static gboolean sizer_expose_cb(GtkWidget *widget, GdkEventExpose *event, gpoint GdkRectangle clip; GtkOrientation orientation; GtkStateType state; + GtkAllocation allocation; gdk_region_get_clipbox(event->region, &clip); @@ -1373,13 +1404,14 @@ static gboolean sizer_expose_cb(GtkWidget *widget, GdkEventExpose *event, gpoint } else { - state = widget->state; + state = gtk_widget_get_state(widget); } - gtk_paint_handle(widget->style, widget->window, state, + gtk_widget_get_allocation(widget, &allocation); + gtk_paint_handle(gtk_widget_get_style(widget), gtk_widget_get_window(widget), state, GTK_SHADOW_NONE, &clip, widget, "paned", 0, 0, - widget->allocation.width, widget->allocation.height, + allocation.width, allocation.height, orientation); return TRUE; @@ -1400,11 +1432,11 @@ static void sizer_realize_cb(GtkWidget *widget, gpointer data) n = (n != 0) ? GDK_FLEUR : GDK_SB_H_DOUBLE_ARROW; } - if (n != 0 && widget->window) + if (n != 0 && gtk_widget_get_window(widget)) { GdkCursor *cursor; cursor = gdk_cursor_new(n); - gdk_window_set_cursor(widget->window, cursor); + gdk_window_set_cursor(gtk_widget_get_window(widget), cursor); gdk_cursor_unref(cursor); } } diff --git a/src/ui_pathsel.c b/src/ui_pathsel.c index 3b27ad38..fd8d2f3c 100644 --- a/src/ui_pathsel.c +++ b/src/ui_pathsel.c @@ -360,8 +360,7 @@ static void dest_dnd_set_data(GtkWidget *view, if (!uri_text) return; - gtk_selection_data_set(selection_data, selection_data->target, - 8, (guchar *)uri_text, length); + gtk_selection_data_set_text(selection_data, uri_text, length); g_free(uri_text); } @@ -905,7 +904,7 @@ static void dest_filter_list_sync(Dest_Data *dd) if (!dd->filter_list || !dd->filter_combo) return; - entry = GTK_BIN(dd->filter_combo)->child; + entry = gtk_bin_get_child(GTK_BIN(dd->filter_combo)); old_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry))); store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(dd->filter_combo))); @@ -972,7 +971,7 @@ static void dest_filter_add(Dest_Data *dd, const gchar *filter, const gchar *des } dd->filter_text_list = uig_list_insert_link(dd->filter_text_list, g_list_last(dd->filter_text_list), buf); - if (set) gtk_entry_set_text(GTK_ENTRY(GTK_BIN(dd->filter_combo)->child), filter); + if (set) gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dd->filter_combo))), filter); dest_filter_list_sync(dd); } @@ -994,7 +993,7 @@ static void dest_filter_changed_cb(GtkEditable *editable, gpointer data) const gchar *buf; gchar *path; - entry = GTK_BIN(dd->filter_combo)->child; + entry = gtk_bin_get_child(GTK_BIN(dd->filter_combo)); buf = gtk_entry_get_text(GTK_ENTRY(entry)); g_free(dd->filter); @@ -1144,8 +1143,7 @@ GtkWidget *path_selection_new_with_files(GtkWidget *entry, const gchar *path, store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); - dd->filter_combo = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(store), - FILTER_COLUMN_FILTER); + dd->filter_combo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store)); g_object_unref(store); gtk_cell_layout_clear(GTK_CELL_LAYOUT(dd->filter_combo)); renderer = gtk_cell_renderer_text_new(); @@ -1208,7 +1206,7 @@ GtkWidget *path_selection_new_with_files(GtkWidget *entry, const gchar *path, dest_filter_clear(dd); dest_filter_add(dd, filter, filter_desc, TRUE); - dd->filter = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(dd->filter_combo)->child))); + dd->filter = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dd->filter_combo))))); } if (path && path[0] == G_DIR_SEPARATOR && isdir(path)) @@ -1235,7 +1233,7 @@ GtkWidget *path_selection_new_with_files(GtkWidget *entry, const gchar *path, if (dd->filter_combo) { - g_signal_connect(G_OBJECT(GTK_BIN(dd->filter_combo)->child), "changed", + g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(dd->filter_combo))), "changed", G_CALLBACK(dest_filter_changed_cb), dd); } g_signal_connect(G_OBJECT(dd->entry), "changed", diff --git a/src/ui_tabcomp.c b/src/ui_tabcomp.c index a8734fc4..5764e07c 100644 --- a/src/ui_tabcomp.c +++ b/src/ui_tabcomp.c @@ -300,11 +300,13 @@ static void tab_completion_popup_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolea GdkScreen *screen; gint monitor_num; GdkRectangle monitor; + GtkRequisition requisition; + GtkAllocation allocation; - gdk_window_get_origin(td->entry->window, x, y); + gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(td->entry)), x, y); screen = gtk_widget_get_screen(GTK_WIDGET(menu)); - monitor_num = gdk_screen_get_monitor_at_window(screen, td->entry->window); + monitor_num = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(GTK_WIDGET(td->entry))); gdk_screen_get_monitor_geometry(screen, monitor_num, &monitor); gtk_widget_size_request(GTK_WIDGET(menu), &req); @@ -317,7 +319,10 @@ static void tab_completion_popup_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolea *x += strong_pos.x / PANGO_SCALE + xoffset; - height = MIN(td->entry->requisition.height, td->entry->allocation.height); + gtk_widget_get_requisition(td->entry, &requisition); + gtk_widget_get_allocation(td->entry, &allocation); + + height = MIN(requisition.height, allocation.height); if (req.height > monitor.y + monitor.height - *y - height && *y - monitor.y > monitor.y + monitor.height - *y) @@ -668,15 +673,17 @@ static void tab_completion_button_pressed(GtkWidget *widget, gpointer data) static void tab_completion_button_size_allocate(GtkWidget *button, GtkAllocation *allocation, gpointer data) { GtkWidget *parent = data; + GtkAllocation parent_allocation; + gtk_widget_get_allocation(parent, &parent_allocation); - if (allocation->height > parent->allocation.height) + if (allocation->height > parent_allocation.height) { GtkAllocation button_allocation; - button_allocation = button->allocation; - button_allocation.height = parent->allocation.height; - button_allocation.y = parent->allocation.y + - (parent->allocation.height - parent->allocation.height) / 2; + gtk_widget_get_allocation(button, &button_allocation); + button_allocation.height = parent_allocation.height; + button_allocation.y = parent_allocation.y + + (parent_allocation.height - parent_allocation.height) / 2; gtk_widget_size_allocate(button, &button_allocation); } } @@ -688,7 +695,7 @@ static GtkWidget *tab_completion_create_complete_button(GtkWidget *entry, GtkWid GdkPixbuf *pixbuf; button = gtk_button_new(); - GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); + gtk_widget_set_can_focus(button, FALSE); g_signal_connect(G_OBJECT(button), "size_allocate", G_CALLBACK(tab_completion_button_size_allocate), parent); g_signal_connect(G_OBJECT(button), "clicked", @@ -724,11 +731,11 @@ GtkWidget *tab_completion_new_with_history(GtkWidget **entry, const gchar *text, box = gtk_hbox_new(FALSE, 0); - combo = gtk_combo_box_entry_new_text(); + combo = gtk_combo_box_text_new_with_entry(); gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0); gtk_widget_show(combo); - combo_entry = GTK_BIN(combo)->child; + combo_entry = gtk_bin_get_child(GTK_BIN(combo)); #if 0 gtk_combo_set_case_sensitive(GTK_COMBO(combo), TRUE); gtk_combo_set_use_arrows(GTK_COMBO(combo), FALSE); @@ -753,7 +760,7 @@ GtkWidget *tab_completion_new_with_history(GtkWidget **entry, const gchar *text, work = history_list_get_by_key(history_key); while (work) { - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), (gchar *)work->data); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), (gchar *)work->data); work = work->next; n++; } @@ -810,7 +817,7 @@ void tab_completion_append_to_history(GtkWidget *entry, const gchar *path) work = history_list_get_by_key(td->history_key); while (work) { - gtk_combo_box_append_text(GTK_COMBO_BOX(td->combo), (gchar *)work->data); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(td->combo), (gchar *)work->data); work = work->next; n++; } diff --git a/src/ui_tree_edit.c b/src/ui_tree_edit.c index 1f3f8ce0..03147d0d 100644 --- a/src/ui_tree_edit.c +++ b/src/ui_tree_edit.c @@ -74,6 +74,7 @@ static gboolean tree_edit_click_end_cb(GtkWidget *widget, GdkEventButton *event, static gboolean tree_edit_click_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) { TreeEditData *ted = data; + GdkWindow *window = gtk_widget_get_window(ted->window); gint x, y; gint w, h; @@ -83,8 +84,9 @@ static gboolean tree_edit_click_cb(GtkWidget *widget, GdkEventButton *event, gpo xr = (gint)event->x_root; yr = (gint)event->y_root; - gdk_window_get_origin(ted->window->window, &x, &y); - gdk_drawable_get_size(ted->window->window, &w, &h); + gdk_window_get_origin(window, &x, &y); + w = gdk_window_get_width(window); + h = gdk_window_get_height(window); if (xr < x || yr < y || xr > x + w || yr > y + h) { @@ -164,12 +166,12 @@ static gboolean tree_edit_by_path_idle_cb(gpointer data) /* explicitely set the focus flag for the entry, for some reason on popup windows this * is not set, and causes no edit cursor to appear ( popups not allowed focus? ) */ - GTK_WIDGET_SET_FLAGS(ted->entry, GTK_HAS_FOCUS); + gtk_widget_grab_focus(ted->entry); gtk_grab_add(ted->window); - gdk_pointer_grab(ted->window->window, TRUE, + gdk_pointer_grab(gtk_widget_get_window(ted->window), TRUE, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK, NULL, NULL, GDK_CURRENT_TIME); - gdk_keyboard_grab(ted->window->window, TRUE, GDK_CURRENT_TIME); + gdk_keyboard_grab(gtk_widget_get_window(ted->window), TRUE, GDK_CURRENT_TIME); return FALSE; } @@ -185,7 +187,7 @@ gboolean tree_edit_by_path(GtkTreeView *tree, GtkTreePath *tpath, gint column, c if (!edit_func) return FALSE; #if GTK_CHECK_VERSION(2,20,0) - if (!gtk_widget_get_visible(tree)) return FALSE; + if (!gtk_widget_get_visible(GTK_WIDGET(tree))) return FALSE; #else if (!GTK_WIDGET_VISIBLE(tree)) return FALSE; #endif @@ -278,11 +280,13 @@ gboolean tree_view_get_cell_origin(GtkTreeView *widget, GtkTreePath *tpath, gint #else gtk_tree_view_tree_to_widget_coords(widget, 0, 0, &x_offset, &y_offset); #endif - gdk_window_get_origin(GTK_WIDGET(widget)->window, &x_origin, &y_origin); + gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(widget)), &x_origin, &y_origin); if (gtk_tree_view_get_headers_visible(widget)) { - header_size = tv_column->button->allocation.height; + GtkAllocation allocation; + gtk_widget_get_allocation(tv_column->button, &allocation); + header_size = allocation.height; } else { @@ -337,9 +341,12 @@ void tree_view_get_cell_clamped(GtkTreeView *widget, GtkTreePath *tpath, gint co gint wx, wy, ww, wh; GdkWindow *window; - window = GTK_WIDGET(widget)->window; + window = gtk_widget_get_window(GTK_WIDGET(widget)); gdk_window_get_origin(window, &wx, &wy); - gdk_drawable_get_size(window, &ww, &wh); + + ww = gdk_window_get_width(window); + wh = gdk_window_get_height(window); + if (!tree_view_get_cell_origin(widget, tpath, column, text_cell_only, x, y, width, height)) { *x = wx; @@ -617,9 +624,10 @@ static gboolean widget_auto_scroll_cb(gpointer data) sd->max_step = MIN(sd->region_size, sd->max_step + 2); } - window = sd->widget->window; + window = gtk_widget_get_window(sd->widget); gdk_window_get_pointer(window, &x, &y, NULL); - gdk_drawable_get_size(window, &w, &h); + w = gdk_window_get_width(window); + h = gdk_window_get_height(window); if (x < 0 || x >= w || y < 0 || y >= h) { @@ -649,7 +657,7 @@ static gboolean widget_auto_scroll_cb(gpointer data) { amt = CLAMP(amt, 0 - sd->max_step, sd->max_step); - if (sd->adj->value != CLAMP(sd->adj->value + amt, sd->adj->lower, sd->adj->upper - sd->adj->page_size)) + if (gtk_adjustment_get_value(sd->adj) != CLAMP(gtk_adjustment_get_value(sd->adj) + amt, gtk_adjustment_get_lower(sd->adj), gtk_adjustment_get_upper(sd->adj) - gtk_adjustment_get_page_size(sd->adj))) { /* only notify when scrolling is needed */ if (sd->notify_func && !sd->notify_func(sd->widget, x, y, sd->notify_data)) @@ -660,7 +668,7 @@ static gboolean widget_auto_scroll_cb(gpointer data) } gtk_adjustment_set_value(sd->adj, - CLAMP(sd->adj->value + amt, sd->adj->lower, sd->adj->upper - sd->adj->page_size)); + CLAMP(gtk_adjustment_get_value(sd->adj) + amt, gtk_adjustment_get_lower(sd->adj), gtk_adjustment_get_upper(sd->adj) - gtk_adjustment_get_page_size(sd->adj))); } } diff --git a/src/ui_utildlg.c b/src/ui_utildlg.c index 785b8dfc..285bae33 100644 --- a/src/ui_utildlg.c +++ b/src/ui_utildlg.c @@ -150,7 +150,7 @@ GtkWidget *generic_dialog_add_button(GenericDialog *gd, const gchar *stock_id, c button = pref_button_new(NULL, stock_id, text, FALSE, G_CALLBACK(generic_dialog_click_cb), gd); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(button, TRUE); g_object_set_data(G_OBJECT(button), "dialog_function", func_cb); gtk_container_add(GTK_CONTAINER(gd->hbox), button); diff --git a/src/view_dir.c b/src/view_dir.c index 47be07de..b11142ee 100644 --- a/src/view_dir.c +++ b/src/view_dir.c @@ -744,8 +744,7 @@ static void vd_dnd_get(GtkWidget *widget, GdkDragContext *context, } if (uritext) { - gtk_selection_data_set(selection_data, selection_data->target, - 8, (guchar *)uritext, length); + gtk_selection_data_set_text(selection_data, uritext, length); g_free(uritext); } } @@ -764,7 +763,7 @@ static void vd_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data vd_color_set(vd, vd->click_fd, FALSE); - if (vd->type == DIRVIEW_LIST && context->action == GDK_ACTION_MOVE) + if (vd->type == DIRVIEW_LIST && gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE) { vd_refresh(vd); } @@ -797,7 +796,7 @@ static void vd_dnd_drop_receive(GtkWidget *widget, gint active; gboolean done = FALSE; - list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); + list = uri_filelist_from_text((gchar *)gtk_selection_data_get_data(selection_data), TRUE); if (!list) return; active = access_file(fd->path, W_OK | X_OK); @@ -806,13 +805,13 @@ static void vd_dnd_drop_receive(GtkWidget *widget, if (active) { - if (context->actions == GDK_ACTION_COPY) + if (gdk_drag_context_get_actions(context) == GDK_ACTION_COPY) { file_util_copy_simple(list, fd->path, vd->widget); done = TRUE; list = NULL; } - else if (context->actions == GDK_ACTION_MOVE) + else if (gdk_drag_context_get_actions(context) == GDK_ACTION_MOVE) { file_util_move_simple(list, fd->path, vd->widget); done = TRUE; @@ -872,9 +871,10 @@ static gboolean vd_auto_scroll_idle_cb(gpointer data) gint x, y; gint w, h; - window = vd->view->window; + window = gtk_widget_get_window(vd->view); gdk_window_get_pointer(window, &x, &y, NULL); - gdk_drawable_get_size(window, &w, &h); + w = gdk_window_get_width(window); + h = gdk_window_get_height(window); if (x >= 0 && x < w && y >= 0 && y < h) { vd_dnd_drop_update(vd, x, y); @@ -911,7 +911,7 @@ static gboolean vd_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context, } else { - gdk_drag_status(context, context->suggested_action, time); + gdk_drag_status(context, gdk_drag_context_get_suggested_action(context), time); } vd_dnd_drop_update(vd, x, y); diff --git a/src/view_dir_tree.c b/src/view_dir_tree.c index 45a470a3..7409bc8e 100644 --- a/src/view_dir_tree.c +++ b/src/view_dir_tree.c @@ -53,10 +53,10 @@ static void set_cursor(GtkWidget *widget, GdkCursorType cursor_type) { GdkCursor *cursor = NULL; - if (!widget || !widget->window) return; + if (!widget || !gtk_widget_get_window(widget)) return; if (cursor_type > -1) cursor = gdk_cursor_new(cursor_type); - gdk_window_set_cursor(widget->window, cursor); + gdk_window_set_cursor(gtk_widget_get_window(widget), cursor); if (cursor) gdk_cursor_unref(cursor); gdk_flush(); } diff --git a/src/view_file_icon.c b/src/view_file_icon.c index 4c24647f..1dd6787b 100644 --- a/src/view_file_icon.c +++ b/src/view_file_icon.c @@ -267,10 +267,12 @@ static void vficon_send_layout_select(ViewFile *vf, IconData *id) static void vficon_toggle_filenames(ViewFile *vf) { + GtkAllocation allocation; VFICON(vf)->show_text = !VFICON(vf)->show_text; options->show_icon_names = VFICON(vf)->show_text; - vficon_populate_at_new_size(vf, vf->listview->allocation.width, vf->listview->allocation.height, TRUE); + gtk_widget_get_allocation(vf->listview, &allocation); + vficon_populate_at_new_size(vf, allocation.width, allocation.height, TRUE); } static gint vficon_get_icon_width(ViewFile *vf) @@ -460,7 +462,7 @@ static gboolean tip_schedule_cb(gpointer data) #else if (GTK_WIDGET_SENSITIVE(window) && #endif - GTK_WINDOW(window)->has_focus) + gtk_window_has_toplevel_focus(GTK_WINDOW(window))) { tip_show(vf); } @@ -560,8 +562,7 @@ static void vficon_dnd_get(GtkWidget *widget, GdkDragContext *context, DEBUG_1("%s", uri_text); - gtk_selection_data_set(selection_data, selection_data->target, - 8, (guchar *)uri_text, total); + gtk_selection_data_set_text(selection_data, uri_text, total); g_free(uri_text); } @@ -577,7 +578,7 @@ static void vficon_drag_data_received(GtkWidget *entry_widget, GdkDragContext *c if (id && id->fd) { /* Add keywords to file */ FileData *fd = id->fd; - gchar *str = g_strndup((gchar *)selection->data, selection->length); + gchar *str = gtk_selection_data_get_text(selection); GList *kw_list = string_to_keywords_list(str); metadata_append_list(fd, KEYWORD_KEY, kw_list); @@ -618,7 +619,7 @@ static void vficon_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer vficon_selection_remove(vf, VFICON(vf)->click_id, SELECTION_PRELIGHT, NULL); - if (context->action == GDK_ACTION_MOVE) + if (gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE) { vf_refresh(vf); } @@ -696,7 +697,9 @@ static void vficon_selection_remove(ViewFile *vf, IconData *id, SelectionType ma void vficon_marks_set(ViewFile *vf, gint enable) { - vficon_populate_at_new_size(vf, vf->listview->allocation.width, vf->listview->allocation.height, TRUE); + GtkAllocation allocation; + gtk_widget_get_allocation(vf->listview, &allocation); + vficon_populate_at_new_size(vf, allocation.width, allocation.height, TRUE); } /* @@ -1251,7 +1254,7 @@ static gint page_height(ViewFile *vf) gint ret; adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vf->listview)); - page_size = (gint)adj->page_increment; + page_size = (gint)gtk_adjustment_get_page_increment(adj); row_height = options->thumbnails.max_height + THUMB_BORDER_PADDING * 2; if (VFICON(vf)->show_text) row_height += options->thumbnails.max_height / 3; diff --git a/src/view_file_list.c b/src/view_file_list.c index db88839c..de69b4d4 100644 --- a/src/view_file_list.c +++ b/src/view_file_list.c @@ -274,8 +274,7 @@ static void vflist_dnd_get(GtkWidget *widget, GdkDragContext *context, DEBUG_1("%s", uri_text); - gtk_selection_data_set(selection_data, selection_data->target, - 8, (guchar *)uri_text, total); + gtk_selection_data_set_text(selection_data, uri_text, total); g_free(uri_text); } @@ -305,7 +304,7 @@ static void vflist_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer vflist_color_set(vf, VFLIST(vf)->click_fd, FALSE); - if (context->action == GDK_ACTION_MOVE) + if (gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE) { vf_refresh(vf); } @@ -322,7 +321,7 @@ static void vflist_drag_data_received(GtkWidget *entry_widget, GdkDragContext *c if (fd) { /* Add keywords to file */ - gchar *str = g_strndup((gchar *)selection->data, selection->length); + gchar *str = gtk_selection_data_get_text(selection); GList *kw_list = string_to_keywords_list(str); metadata_append_list(fd, KEYWORD_KEY, kw_list); diff --git a/src/window.c b/src/window.c index fb20ce8f..9dbf2fe5 100644 --- a/src/window.c +++ b/src/window.c @@ -69,9 +69,9 @@ gboolean window_maximized(GtkWidget *window) { GdkWindowState state; - if (!window || !window->window) return FALSE; + if (!window || !gtk_widget_get_window(window)) return FALSE; - state = gdk_window_get_state(window->window); + state = gdk_window_get_state(gtk_widget_get_window(window)); return !!(state & GDK_WINDOW_STATE_MAXIMIZED); }