1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-26 09:42:25 +00:00

GTK 3 prep: use accessor functions for object data fields.

We now build cleanly in GTK2 with -DGSEAL_ENABLE.
This commit is contained in:
Simon Tatham 2015-08-08 15:53:43 +01:00
parent 8ee12773d8
commit 0a3e593959
6 changed files with 229 additions and 138 deletions

View File

@ -167,9 +167,9 @@ static gint expose_area(GtkWidget *widget, GdkEventExpose *event,
{ {
struct drawing_area_ctx *ctx = (struct drawing_area_ctx *)data; struct drawing_area_ctx *ctx = (struct drawing_area_ctx *)data;
GdkGC *gc = gdk_gc_new(ctx->area->window); GdkGC *gc = gdk_gc_new(gtk_widget_get_window(ctx->area));
gdk_gc_set_foreground(gc, &ctx->cols[ctx->current]); gdk_gc_set_foreground(gc, &ctx->cols[ctx->current]);
gdk_draw_rectangle(widget->window, gc, TRUE, gdk_draw_rectangle(gtk_widget_get_window(widget), gc, TRUE,
0, 0, ctx->width, ctx->height); 0, 0, ctx->width, ctx->height);
gdk_gc_unref(gc); gdk_gc_unref(gc);
return TRUE; return TRUE;
@ -177,7 +177,8 @@ static gint expose_area(GtkWidget *widget, GdkEventExpose *event,
static int try_grab_keyboard(struct askpass_ctx *ctx) static int try_grab_keyboard(struct askpass_ctx *ctx)
{ {
int ret = gdk_keyboard_grab(ctx->dialog->window, FALSE, GDK_CURRENT_TIME); int ret = gdk_keyboard_grab(gtk_widget_get_window(ctx->dialog),
FALSE, GDK_CURRENT_TIME);
return ret == GDK_GRAB_SUCCESS; return ret == GDK_GRAB_SUCCESS;
} }
@ -302,7 +303,8 @@ static const char *gtk_askpass_setup(struct askpass_ctx *ctx,
gtk_signal_connect(GTK_OBJECT(ctx->promptlabel), "key_release_event", gtk_signal_connect(GTK_OBJECT(ctx->promptlabel), "key_release_event",
GTK_SIGNAL_FUNC(key_event), ctx); GTK_SIGNAL_FUNC(key_event), ctx);
#if GTK_CHECK_VERSION(2,0,0) #if GTK_CHECK_VERSION(2,0,0)
gtk_im_context_set_client_window(ctx->imc, ctx->dialog->window); gtk_im_context_set_client_window(ctx->imc,
gtk_widget_get_window(ctx->dialog));
#endif #endif
gtk_widget_show(ctx->promptlabel); gtk_widget_show(ctx->promptlabel);

View File

@ -4,6 +4,7 @@
#include "gtkcols.h" #include "gtkcols.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gtkcompat.h"
static void columns_init(Columns *cols); static void columns_init(Columns *cols);
static void columns_class_init(ColumnsClass *klass); static void columns_class_init(ColumnsClass *klass);
@ -120,7 +121,7 @@ static void columns_class_init(ColumnsClass *klass)
static void columns_init(Columns *cols) static void columns_init(Columns *cols)
{ {
GTK_WIDGET_SET_FLAGS(cols, GTK_NO_WINDOW); gtk_widget_set_has_window(GTK_WIDGET(cols), FALSE);
cols->children = NULL; cols->children = NULL;
cols->spacing = 0; cols->spacing = 0;
@ -141,14 +142,14 @@ static void columns_map(GtkWidget *widget)
g_return_if_fail(IS_COLUMNS(widget)); g_return_if_fail(IS_COLUMNS(widget));
cols = COLUMNS(widget); cols = COLUMNS(widget);
GTK_WIDGET_SET_FLAGS(cols, GTK_MAPPED); gtk_widget_set_mapped(GTK_WIDGET(cols), TRUE);
for (children = cols->children; for (children = cols->children;
children && (child = children->data); children && (child = children->data);
children = children->next) { children = children->next) {
if (child->widget && if (child->widget &&
GTK_WIDGET_VISIBLE(child->widget) && gtk_widget_get_visible(child->widget) &&
!GTK_WIDGET_MAPPED(child->widget)) !gtk_widget_get_mapped(child->widget))
gtk_widget_map(child->widget); gtk_widget_map(child->widget);
} }
} }
@ -162,14 +163,14 @@ static void columns_unmap(GtkWidget *widget)
g_return_if_fail(IS_COLUMNS(widget)); g_return_if_fail(IS_COLUMNS(widget));
cols = COLUMNS(widget); cols = COLUMNS(widget);
GTK_WIDGET_UNSET_FLAGS(cols, GTK_MAPPED); gtk_widget_set_mapped(GTK_WIDGET(cols), FALSE);
for (children = cols->children; for (children = cols->children;
children && (child = children->data); children && (child = children->data);
children = children->next) { children = children->next) {
if (child->widget && if (child->widget &&
GTK_WIDGET_VISIBLE(child->widget) && gtk_widget_get_visible(child->widget) &&
GTK_WIDGET_MAPPED(child->widget)) gtk_widget_get_mapped(child->widget))
gtk_widget_unmap(child->widget); gtk_widget_unmap(child->widget);
} }
} }
@ -263,7 +264,7 @@ static void columns_remove(GtkContainer *container, GtkWidget *widget)
if (child->widget != widget) if (child->widget != widget)
continue; continue;
was_visible = GTK_WIDGET_VISIBLE(widget); was_visible = gtk_widget_get_visible(widget);
gtk_widget_unparent(widget); gtk_widget_unparent(widget);
cols->children = g_list_remove_link(cols->children, children); cols->children = g_list_remove_link(cols->children, children);
g_list_free(children); g_list_free(children);
@ -367,7 +368,7 @@ void columns_add(Columns *cols, GtkWidget *child,
g_return_if_fail(cols != NULL); g_return_if_fail(cols != NULL);
g_return_if_fail(IS_COLUMNS(cols)); g_return_if_fail(IS_COLUMNS(cols));
g_return_if_fail(child != NULL); g_return_if_fail(child != NULL);
g_return_if_fail(child->parent == NULL); g_return_if_fail(gtk_widget_get_parent(child) == NULL);
childdata = g_new(ColumnsChild, 1); childdata = g_new(ColumnsChild, 1);
childdata->widget = child; childdata->widget = child;
@ -384,11 +385,12 @@ void columns_add(Columns *cols, GtkWidget *child,
gtk_container_set_focus_chain(GTK_CONTAINER(cols), cols->taborder); gtk_container_set_focus_chain(GTK_CONTAINER(cols), cols->taborder);
#endif #endif
if (GTK_WIDGET_REALIZED(cols)) if (gtk_widget_get_realized(GTK_WIDGET(cols)))
gtk_widget_realize(child); gtk_widget_realize(child);
if (GTK_WIDGET_VISIBLE(cols) && GTK_WIDGET_VISIBLE(child)) { if (gtk_widget_get_visible(GTK_WIDGET(cols)) &&
if (GTK_WIDGET_MAPPED(cols)) gtk_widget_get_visible(child)) {
if (gtk_widget_get_mapped(GTK_WIDGET(cols)))
gtk_widget_map(child); gtk_widget_map(child);
gtk_widget_queue_resize(child); gtk_widget_queue_resize(child);
} }
@ -410,7 +412,7 @@ void columns_force_left_align(Columns *cols, GtkWidget *widget)
continue; continue;
child->force_left = TRUE; child->force_left = TRUE;
if (GTK_WIDGET_VISIBLE(widget)) if (gtk_widget_get_visible(widget))
gtk_widget_queue_resize(GTK_WIDGET(cols)); gtk_widget_queue_resize(GTK_WIDGET(cols));
break; break;
} }
@ -565,7 +567,7 @@ static void columns_size_request(GtkWidget *widget, GtkRequisition *req)
} }
/* Only take visible widgets into account. */ /* Only take visible widgets into account. */
if (!GTK_WIDGET_VISIBLE(child->widget)) if (!gtk_widget_get_visible(child->widget))
continue; continue;
gtk_widget_size_request(child->widget, &creq); gtk_widget_size_request(child->widget, &creq);
@ -634,8 +636,8 @@ static void columns_size_request(GtkWidget *widget, GtkRequisition *req)
} }
} }
req->width += 2*GTK_CONTAINER(cols)->border_width; req->width += 2*gtk_container_get_border_width(GTK_CONTAINER(cols));
req->height += 2*GTK_CONTAINER(cols)->border_width; req->height += 2*gtk_container_get_border_width(GTK_CONTAINER(cols));
g_free(colypos); g_free(colypos);
} }
@ -654,8 +656,8 @@ static void columns_size_allocate(GtkWidget *widget, GtkAllocation *alloc)
g_return_if_fail(alloc != NULL); g_return_if_fail(alloc != NULL);
cols = COLUMNS(widget); cols = COLUMNS(widget);
widget->allocation = *alloc; gtk_widget_set_allocation(widget, alloc);
border = GTK_CONTAINER(cols)->border_width; border = gtk_container_get_border_width(GTK_CONTAINER(cols));
ncols = 1; ncols = 1;
percentages = onecol; percentages = onecol;
@ -701,7 +703,7 @@ static void columns_size_allocate(GtkWidget *widget, GtkAllocation *alloc)
} }
/* Only take visible widgets into account. */ /* Only take visible widgets into account. */
if (!GTK_WIDGET_VISIBLE(child->widget)) if (!gtk_widget_get_visible(child->widget))
continue; continue;
gtk_widget_get_child_requisition(child->widget, &creq); gtk_widget_get_child_requisition(child->widget, &creq);

View File

@ -9,14 +9,56 @@
#include <ctype.h> #include <ctype.h>
#include <X11/X.h> #include <X11/X.h>
/* Helper macro used in definitions below. Note that although it
* *expands* w and flag twice, it does not *evaluate* them twice
* because the evaluations are in exclusive branches of ?:. So it's
* a side-effect-safe macro. */
#define gtk1_widget_set_unset_flag(w, flag, b) \
((b) ? GTK_WIDGET_SET_FLAGS(w, flag) : GTK_WIDGET_UNSET_FLAGS(w, flag))
#define G_CALLBACK(x) GTK_SIGNAL_FUNC(x) #define G_CALLBACK(x) GTK_SIGNAL_FUNC(x)
#define G_OBJECT(x) GTK_OBJECT(x) #define G_OBJECT(x) GTK_OBJECT(x)
#define g_ascii_isspace(x) (isspace((unsigned char)(x))) #define g_ascii_isspace(x) (isspace((unsigned char)(x)))
#define g_signal_connect gtk_signal_connect #define g_signal_connect gtk_signal_connect
#define g_object_set_data gtk_object_set_data
#define GDK_GRAB_SUCCESS GrabSuccess #define GDK_GRAB_SUCCESS GrabSuccess
#define gtk_widget_set_size_request gtk_widget_set_usize
#define gtk_dialog_get_content_area(dlg) ((dlg)->vbox) #define gtk_dialog_get_content_area(dlg) ((dlg)->vbox)
#define gtk_dialog_get_action_area(dlg) ((dlg)->action_area) #define gtk_dialog_get_action_area(dlg) ((dlg)->action_area)
#define gtk_widget_set_size_request gtk_widget_set_usize #define gtk_dialog_set_can_default(dlg) ((dlg)->action_area)
#define gtk_widget_get_window(w) ((w)->window)
#define gtk_widget_get_parent(w) ((w)->parent)
#define gtk_widget_set_allocation(w, a) ((w)->allocation = *(a))
#define gtk_container_get_border_width(c) ((c)->border_width)
#define gtk_bin_get_child(b) ((b)->child)
#define gtk_color_selection_dialog_get_color_selection(cs) ((cs)->colorsel)
#define gtk_selection_data_get_target(sd) ((sd)->target)
#define gtk_selection_data_get_data_type(sd) ((sd)->type)
#define gtk_selection_data_get_data(sd) ((sd)->data)
#define gtk_selection_data_get_length(sd) ((sd)->length)
#define gtk_selection_data_get_format(sd) ((sd)->format)
#define gtk_adjustment_set_lower(a, val) ((a)->lower = (val))
#define gtk_adjustment_set_upper(a, val) ((a)->upper = (val))
#define gtk_adjustment_set_page_size(a, val) ((a)->page_size = (val))
#define gtk_adjustment_set_page_increment(a, val) ((a)->page_increment = (val))
#define gtk_adjustment_set_step_increment(a, val) ((a)->step_increment = (val))
#define gtk_adjustment_get_value(a) ((a)->value)
#define gdk_visual_get_depth(v) ((v)->depth)
#define gtk_widget_set_has_window(w, b) \
gtk1_widget_set_unset_flag(w, GTK_NO_WINDOW, !(b))
#define gtk_widget_set_mapped(w, b) \
gtk1_widget_set_unset_flag(w, GTK_MAPPED, (b))
#define gtk_widget_set_can_default(w, b) \
gtk1_widget_set_unset_flag(w, GTK_CAN_DEFAULT, (b))
#define gtk_widget_get_visible(w) GTK_WIDGET_VISIBLE(w)
#define gtk_widget_get_mapped(w) GTK_WIDGET_MAPPED(w)
#define gtk_widget_get_realized(w) GTK_WIDGET_REALIZED(w)
#define gtk_widget_get_state(w) GTK_WIDGET_STATE(w)
#endif #endif

View File

@ -14,6 +14,8 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include "gtkcompat.h"
#include "gtkcols.h" #include "gtkcols.h"
#include "gtkfont.h" #include "gtkfont.h"
@ -221,7 +223,7 @@ static struct uctrl *dlg_find_bywidget(struct dlgparam *dp, GtkWidget *w)
ret = find234(dp->bywidget, w, uctrl_cmp_bywidget_find); ret = find234(dp->bywidget, w, uctrl_cmp_bywidget_find);
if (ret) if (ret)
return ret; return ret;
w = w->parent; w = gtk_widget_get_parent(w);
} while (w); } while (w);
return ret; return ret;
} }
@ -1035,8 +1037,8 @@ static void set_transient_window_pos(GtkWidget *parent, GtkWidget *child)
gtk_window_set_position(GTK_WINDOW(child), GTK_WIN_POS_NONE); gtk_window_set_position(GTK_WINDOW(child), GTK_WIN_POS_NONE);
gtk_widget_size_request(GTK_WIDGET(child), &req); gtk_widget_size_request(GTK_WIDGET(child), &req);
gdk_window_get_origin(GTK_WIDGET(parent)->window, &x, &y); gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(parent)), &x, &y);
gdk_window_get_size(GTK_WIDGET(parent)->window, &w, &h); gdk_window_get_size(gtk_widget_get_window(GTK_WIDGET(parent)), &w, &h);
/* /*
* One corner of the transient will be offset inwards, by 1/4 * One corner of the transient will be offset inwards, by 1/4
@ -1067,17 +1069,17 @@ void dlg_error_msg(void *dlg, const char *msg)
gtk_misc_set_alignment(GTK_MISC(text), 0.0, 0.0); gtk_misc_set_alignment(GTK_MISC(text), 0.0, 0.0);
hbox = gtk_hbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), text, FALSE, FALSE, 20); gtk_box_pack_start(GTK_BOX(hbox), text, FALSE, FALSE, 20);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(window))),
hbox, FALSE, FALSE, 20); hbox, FALSE, FALSE, 20);
gtk_widget_show(text); gtk_widget_show(text);
gtk_widget_show(hbox); gtk_widget_show(hbox);
gtk_window_set_title(GTK_WINDOW(window), "Error"); gtk_window_set_title(GTK_WINDOW(window), "Error");
gtk_label_set_line_wrap(GTK_LABEL(text), TRUE); gtk_label_set_line_wrap(GTK_LABEL(text), TRUE);
ok = gtk_button_new_with_label("OK"); ok = gtk_button_new_with_label("OK");
gtk_box_pack_end(GTK_BOX(GTK_DIALOG(window)->action_area), gtk_box_pack_end(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(window))),
ok, FALSE, FALSE, 0); ok, FALSE, FALSE, 0);
gtk_widget_show(ok); gtk_widget_show(ok);
GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT); gtk_widget_set_can_default(ok, TRUE);
gtk_window_set_default(GTK_WINDOW(window), ok); gtk_window_set_default(GTK_WINDOW(window), ok);
gtk_signal_connect(GTK_OBJECT(ok), "clicked", gtk_signal_connect(GTK_OBJECT(ok), "clicked",
GTK_SIGNAL_FUNC(errmsg_button_clicked), window); GTK_SIGNAL_FUNC(errmsg_button_clicked), window);
@ -1127,38 +1129,50 @@ void dlg_coloursel_start(union control *ctrl, void *dlg, int r, int g, int b)
struct dlgparam *dp = (struct dlgparam *)dlg; struct dlgparam *dp = (struct dlgparam *)dlg;
struct uctrl *uc = dlg_find_byctrl(dp, ctrl); struct uctrl *uc = dlg_find_byctrl(dp, ctrl);
gdouble cvals[4]; gdouble cvals[4];
GtkWidget *okbutton, *cancelbutton;
GtkWidget *coloursel = GtkWidget *coloursel =
gtk_color_selection_dialog_new("Select a colour"); gtk_color_selection_dialog_new("Select a colour");
GtkColorSelectionDialog *ccs = GTK_COLOR_SELECTION_DIALOG(coloursel); GtkColorSelectionDialog *ccs = GTK_COLOR_SELECTION_DIALOG(coloursel);
GtkColorSelection *cs = GTK_COLOR_SELECTION
(gtk_color_selection_dialog_get_color_selection(ccs));
dp->coloursel_result.ok = FALSE; dp->coloursel_result.ok = FALSE;
gtk_window_set_modal(GTK_WINDOW(coloursel), TRUE); gtk_window_set_modal(GTK_WINDOW(coloursel), TRUE);
#if GTK_CHECK_VERSION(2,0,0) #if GTK_CHECK_VERSION(2,0,0)
gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(ccs->colorsel), FALSE); gtk_color_selection_set_has_opacity_control(cs, FALSE);
#else #else
gtk_color_selection_set_opacity(GTK_COLOR_SELECTION(ccs->colorsel), FALSE); gtk_color_selection_set_opacity(cs, FALSE);
#endif #endif
cvals[0] = r / 255.0; cvals[0] = r / 255.0;
cvals[1] = g / 255.0; cvals[1] = g / 255.0;
cvals[2] = b / 255.0; cvals[2] = b / 255.0;
cvals[3] = 1.0; /* fully opaque! */ cvals[3] = 1.0; /* fully opaque! */
gtk_color_selection_set_color(GTK_COLOR_SELECTION(ccs->colorsel), cvals); gtk_color_selection_set_color(cs, cvals);
gtk_object_set_data(GTK_OBJECT(ccs->ok_button), "user-data", #if GTK_CHECK_VERSION(2,0,0)
g_object_get(G_OBJECT(ccs),
"ok-button", &okbutton,
"cancel-button", &cancelbutton,
(const char *)NULL);
#else
okbutton = ccs->ok_button;
cancelbutton = ccs->cancel_button;
#endif
g_object_set_data(G_OBJECT(okbutton), "user-data",
(gpointer)coloursel); (gpointer)coloursel);
gtk_object_set_data(GTK_OBJECT(ccs->cancel_button), "user-data", g_object_set_data(G_OBJECT(cancelbutton), "user-data",
(gpointer)coloursel); (gpointer)coloursel);
gtk_object_set_data(GTK_OBJECT(coloursel), "user-data", (gpointer)uc); gtk_object_set_data(GTK_OBJECT(coloursel), "user-data", (gpointer)uc);
gtk_signal_connect(GTK_OBJECT(ccs->ok_button), "clicked", gtk_signal_connect(GTK_OBJECT(okbutton), "clicked",
GTK_SIGNAL_FUNC(coloursel_ok), (gpointer)dp); GTK_SIGNAL_FUNC(coloursel_ok), (gpointer)dp);
gtk_signal_connect(GTK_OBJECT(ccs->cancel_button), "clicked", gtk_signal_connect(GTK_OBJECT(cancelbutton), "clicked",
GTK_SIGNAL_FUNC(coloursel_cancel), (gpointer)dp); GTK_SIGNAL_FUNC(coloursel_cancel), (gpointer)dp);
gtk_signal_connect_object(GTK_OBJECT(ccs->ok_button), "clicked", gtk_signal_connect_object(GTK_OBJECT(okbutton), "clicked",
GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_SIGNAL_FUNC(gtk_widget_destroy),
(gpointer)coloursel); (gpointer)coloursel);
gtk_signal_connect_object(GTK_OBJECT(ccs->cancel_button), "clicked", gtk_signal_connect_object(GTK_OBJECT(cancelbutton), "clicked",
GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_SIGNAL_FUNC(gtk_widget_destroy),
(gpointer)coloursel); (gpointer)coloursel);
gtk_widget_show(coloursel); gtk_widget_show(coloursel);
@ -1227,10 +1241,11 @@ static gboolean editbox_key(GtkWidget *widget, GdkEventKey *event,
* Return in an edit box will now activate the default button * Return in an edit box will now activate the default button
* in the dialog just like it will everywhere else. * in the dialog just like it will everywhere else.
*/ */
if (event->keyval == GDK_Return && widget->parent != NULL) { GtkWidget *parent = gtk_widget_get_parent(widget);
if (event->keyval == GDK_Return && parent != NULL) {
gboolean return_val; gboolean return_val;
gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "key_press_event"); gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "key_press_event");
gtk_signal_emit_by_name(GTK_OBJECT(widget->parent), "key_press_event", gtk_signal_emit_by_name(GTK_OBJECT(parent), "key_press_event",
event, &return_val); event, &return_val);
return return_val; return return_val;
} }
@ -1585,10 +1600,11 @@ static void coloursel_ok(GtkButton *button, gpointer data)
struct dlgparam *dp = (struct dlgparam *)data; struct dlgparam *dp = (struct dlgparam *)data;
gpointer coloursel = gtk_object_get_data(GTK_OBJECT(button), "user-data"); gpointer coloursel = gtk_object_get_data(GTK_OBJECT(button), "user-data");
struct uctrl *uc = gtk_object_get_data(GTK_OBJECT(coloursel), "user-data"); struct uctrl *uc = gtk_object_get_data(GTK_OBJECT(coloursel), "user-data");
GtkColorSelection *cs = GTK_COLOR_SELECTION
(gtk_color_selection_dialog_get_color_selection
(GTK_COLOR_SELECTION_DIALOG(coloursel)));
gdouble cvals[4]; gdouble cvals[4];
gtk_color_selection_get_color gtk_color_selection_get_color(cs, cvals);
(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(coloursel)->colorsel),
cvals);
dp->coloursel_result.r = (int) (255 * cvals[0]); dp->coloursel_result.r = (int) (255 * cvals[0]);
dp->coloursel_result.g = (int) (255 * cvals[1]); dp->coloursel_result.g = (int) (255 * cvals[1]);
dp->coloursel_result.b = (int) (255 * cvals[2]); dp->coloursel_result.b = (int) (255 * cvals[2]);
@ -1821,7 +1837,7 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
case CTRL_BUTTON: case CTRL_BUTTON:
w = gtk_button_new_with_label(ctrl->generic.label); w = gtk_button_new_with_label(ctrl->generic.label);
if (win) { if (win) {
GTK_WIDGET_SET_FLAGS(w, GTK_CAN_DEFAULT); gtk_widget_set_can_default(w, TRUE);
if (ctrl->button.isdefault) if (ctrl->button.isdefault)
gtk_window_set_default(win, w); gtk_window_set_default(win, w);
if (ctrl->button.iscancel) if (ctrl->button.iscancel)
@ -1831,8 +1847,8 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
GTK_SIGNAL_FUNC(button_clicked), dp); GTK_SIGNAL_FUNC(button_clicked), dp);
gtk_signal_connect(GTK_OBJECT(w), "focus_in_event", gtk_signal_connect(GTK_OBJECT(w), "focus_in_event",
GTK_SIGNAL_FUNC(widget_focus), dp); GTK_SIGNAL_FUNC(widget_focus), dp);
shortcut_add(scs, GTK_BIN(w)->child, ctrl->button.shortcut, shortcut_add(scs, gtk_bin_get_child(GTK_BIN(w)),
SHORTCUT_UCTRL, uc); ctrl->button.shortcut, SHORTCUT_UCTRL, uc);
break; break;
case CTRL_CHECKBOX: case CTRL_CHECKBOX:
w = gtk_check_button_new_with_label(ctrl->generic.label); w = gtk_check_button_new_with_label(ctrl->generic.label);
@ -1840,8 +1856,8 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
GTK_SIGNAL_FUNC(button_toggled), dp); GTK_SIGNAL_FUNC(button_toggled), dp);
gtk_signal_connect(GTK_OBJECT(w), "focus_in_event", gtk_signal_connect(GTK_OBJECT(w), "focus_in_event",
GTK_SIGNAL_FUNC(widget_focus), dp); GTK_SIGNAL_FUNC(widget_focus), dp);
shortcut_add(scs, GTK_BIN(w)->child, ctrl->checkbox.shortcut, shortcut_add(scs, gtk_bin_get_child(GTK_BIN(w)),
SHORTCUT_UCTRL, uc); ctrl->checkbox.shortcut, SHORTCUT_UCTRL, uc);
left = TRUE; left = TRUE;
break; break;
case CTRL_RADIO: case CTRL_RADIO:
@ -1896,7 +1912,7 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
gtk_signal_connect(GTK_OBJECT(b), "focus_in_event", gtk_signal_connect(GTK_OBJECT(b), "focus_in_event",
GTK_SIGNAL_FUNC(widget_focus), dp); GTK_SIGNAL_FUNC(widget_focus), dp);
if (ctrl->radio.shortcuts) { if (ctrl->radio.shortcuts) {
shortcut_add(scs, GTK_BIN(b)->child, shortcut_add(scs, gtk_bin_get_child(GTK_BIN(b)),
ctrl->radio.shortcuts[i], ctrl->radio.shortcuts[i],
SHORTCUT_UCTRL, uc); SHORTCUT_UCTRL, uc);
} }
@ -2786,11 +2802,13 @@ void set_dialog_action_area(GtkDialog *dlg, GtkWidget *w)
gtk_alignment_set_padding(GTK_ALIGNMENT(align), 8, 8, 8, 8); gtk_alignment_set_padding(GTK_ALIGNMENT(align), 8, 8, 8, 8);
#endif #endif
gtk_widget_show(align); gtk_widget_show(align);
gtk_box_pack_end(GTK_BOX(dlg->vbox), align, FALSE, TRUE, 0); gtk_box_pack_end(GTK_BOX(gtk_dialog_get_content_area(dlg)),
align, FALSE, TRUE, 0);
w = gtk_hseparator_new(); w = gtk_hseparator_new();
gtk_box_pack_end(GTK_BOX(dlg->vbox), w, FALSE, TRUE, 0); gtk_box_pack_end(GTK_BOX(gtk_dialog_get_content_area(dlg)),
w, FALSE, TRUE, 0);
gtk_widget_show(w); gtk_widget_show(w);
gtk_widget_hide(dlg->action_area); gtk_widget_hide(gtk_dialog_get_action_area(dlg));
gtk_dialog_set_has_separator(dlg, FALSE); gtk_dialog_set_has_separator(dlg, FALSE);
#endif #endif
} }
@ -2835,7 +2853,9 @@ int do_config_box(const char *title, Conf *conf, int midsession,
gtk_window_set_title(GTK_WINDOW(window), title); gtk_window_set_title(GTK_WINDOW(window), title);
hbox = gtk_hbox_new(FALSE, 4); hbox = gtk_hbox_new(FALSE, 4);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), hbox, TRUE, TRUE, 0); gtk_box_pack_start
(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(window))),
hbox, TRUE, TRUE, 0);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 10); gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
gtk_widget_show(hbox); gtk_widget_show(hbox);
vbox = gtk_vbox_new(FALSE, 4); vbox = gtk_vbox_new(FALSE, 4);
@ -3207,7 +3227,8 @@ int messagebox(GtkWidget *parentwin, const char *title, const char *msg,
w1 = layout_ctrls(&dp, &scs, s1, GTK_WINDOW(window)); w1 = layout_ctrls(&dp, &scs, s1, GTK_WINDOW(window));
gtk_container_set_border_width(GTK_CONTAINER(w1), 10); gtk_container_set_border_width(GTK_CONTAINER(w1), 10);
gtk_widget_set_usize(w1, minwid+20, -1); gtk_widget_set_usize(w1, minwid+20, -1);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), gtk_box_pack_start
(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(window))),
w1, TRUE, TRUE, 0); w1, TRUE, TRUE, 0);
gtk_widget_show(w1); gtk_widget_show(w1);
@ -3463,34 +3484,37 @@ void about_box(void *window)
sfree(title); sfree(title);
w = gtk_button_new_with_label("Close"); w = gtk_button_new_with_label("Close");
GTK_WIDGET_SET_FLAGS(w, GTK_CAN_DEFAULT); gtk_widget_set_can_default(w, TRUE);
gtk_window_set_default(GTK_WINDOW(aboutbox), w); gtk_window_set_default(GTK_WINDOW(aboutbox), w);
gtk_box_pack_end(GTK_BOX(GTK_DIALOG(aboutbox)->action_area), gtk_box_pack_end(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(aboutbox))),
w, FALSE, FALSE, 0); w, FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(w), "clicked", gtk_signal_connect(GTK_OBJECT(w), "clicked",
GTK_SIGNAL_FUNC(about_close_clicked), NULL); GTK_SIGNAL_FUNC(about_close_clicked), NULL);
gtk_widget_show(w); gtk_widget_show(w);
w = gtk_button_new_with_label("View Licence"); w = gtk_button_new_with_label("View Licence");
GTK_WIDGET_SET_FLAGS(w, GTK_CAN_DEFAULT); gtk_widget_set_can_default(w, TRUE);
gtk_box_pack_end(GTK_BOX(GTK_DIALOG(aboutbox)->action_area), gtk_box_pack_end(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(aboutbox))),
w, FALSE, FALSE, 0); w, FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(w), "clicked", gtk_signal_connect(GTK_OBJECT(w), "clicked",
GTK_SIGNAL_FUNC(licence_clicked), NULL); GTK_SIGNAL_FUNC(licence_clicked), NULL);
gtk_widget_show(w); gtk_widget_show(w);
w = gtk_label_new(appname); w = gtk_label_new(appname);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(aboutbox)->vbox), gtk_box_pack_start
(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(aboutbox))),
w, FALSE, FALSE, 0); w, FALSE, FALSE, 0);
gtk_widget_show(w); gtk_widget_show(w);
w = gtk_label_new(ver); w = gtk_label_new(ver);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(aboutbox)->vbox), gtk_box_pack_start
(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(aboutbox))),
w, FALSE, FALSE, 5); w, FALSE, FALSE, 5);
gtk_widget_show(w); gtk_widget_show(w);
w = gtk_label_new("Copyright 1997-2015 Simon Tatham. All rights reserved"); w = gtk_label_new("Copyright 1997-2015 Simon Tatham. All rights reserved");
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(aboutbox)->vbox), gtk_box_pack_start
(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(aboutbox))),
w, FALSE, FALSE, 5); w, FALSE, FALSE, 5);
gtk_widget_show(w); gtk_widget_show(w);
@ -3595,7 +3619,7 @@ void eventlog_selection_get(GtkWidget *widget, GtkSelectionData *seldata,
{ {
struct eventlog_stuff *es = (struct eventlog_stuff *)data; struct eventlog_stuff *es = (struct eventlog_stuff *)data;
gtk_selection_data_set(seldata, seldata->target, 8, gtk_selection_data_set(seldata, gtk_selection_data_get_target(seldata), 8,
(unsigned char *)es->seldata, es->sellen); (unsigned char *)es->seldata, es->sellen);
} }
@ -3680,7 +3704,8 @@ void showeventlog(void *estuff, void *parentwin)
string_width("LINE OF TEXT GIVING WIDTH OF EVENT LOG" string_width("LINE OF TEXT GIVING WIDTH OF EVENT LOG"
" IS QUITE LONG 'COS SSH LOG ENTRIES" " IS QUITE LONG 'COS SSH LOG ENTRIES"
" ARE WIDE"), -1); " ARE WIDE"), -1);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), gtk_box_pack_start
(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(window))),
w1, TRUE, TRUE, 0); w1, TRUE, TRUE, 0);
gtk_widget_show(w1); gtk_widget_show(w1);

View File

@ -2045,7 +2045,8 @@ static void unifontsel_draw_preview_text(unifontsel_internal *fs)
42, FALSE, FALSE, font->width); 42, FALSE, FALSE, font->width);
} }
gdk_gc_unref(gc); gdk_gc_unref(gc);
gdk_window_invalidate_rect(fs->preview_area->window, NULL, FALSE); gdk_window_invalidate_rect(gtk_widget_get_window(fs->preview_area),
NULL, FALSE);
} }
if (font) if (font)
info->fontclass->destroy(font); info->fontclass->destroy(font);
@ -2478,8 +2479,9 @@ static gint unifontsel_expose_area(GtkWidget *widget, GdkEventExpose *event,
unifontsel_internal *fs = (unifontsel_internal *)data; unifontsel_internal *fs = (unifontsel_internal *)data;
if (fs->preview_pixmap) { if (fs->preview_pixmap) {
gdk_draw_pixmap(widget->window, gdk_draw_pixmap(gtk_widget_get_window(widget),
widget->style->fg_gc[GTK_WIDGET_STATE(widget)], (gtk_widget_get_style(widget)->fg_gc
[gtk_widget_get_state(widget)]),
fs->preview_pixmap, fs->preview_pixmap,
event->area.x, event->area.y, event->area.x, event->area.y,
event->area.x, event->area.y, event->area.x, event->area.y,
@ -2507,14 +2509,15 @@ static gint unifontsel_configure_area(GtkWidget *widget,
nx = (x > ox ? x : ox); nx = (x > ox ? x : ox);
ny = (y > oy ? y : oy); ny = (y > oy ? y : oy);
fs->preview_pixmap = gdk_pixmap_new(widget->window, nx, ny, -1); fs->preview_pixmap = gdk_pixmap_new(gtk_widget_get_window(widget),
nx, ny, -1);
fs->preview_width = nx; fs->preview_width = nx;
fs->preview_height = ny; fs->preview_height = ny;
unifontsel_draw_preview_text(fs); unifontsel_draw_preview_text(fs);
} }
gdk_window_invalidate_rect(widget->window, NULL, FALSE); gdk_window_invalidate_rect(gtk_widget_get_window(widget), NULL, FALSE);
return TRUE; return TRUE;
} }
@ -2584,7 +2587,8 @@ unifontsel *unifontsel_new(const char *wintitle)
#else #else
w = table; w = table;
#endif #endif
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fs->u.window)->vbox), gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area
(GTK_DIALOG(fs->u.window))),
w, TRUE, TRUE, 0); w, TRUE, TRUE, 0);
label = gtk_label_new_with_mnemonic("_Font:"); label = gtk_label_new_with_mnemonic("_Font:");

View File

@ -37,6 +37,7 @@
#include "putty.h" #include "putty.h"
#include "terminal.h" #include "terminal.h"
#include "gtkcompat.h"
#include "gtkfont.h" #include "gtkfont.h"
#define CAT2(x,y) x ## y #define CAT2(x,y) x ## y
@ -316,7 +317,7 @@ void move_window(void *frontend, int x, int y)
#if GTK_CHECK_VERSION(2,0,0) #if GTK_CHECK_VERSION(2,0,0)
gtk_window_move(GTK_WINDOW(inst->window), x, y); gtk_window_move(GTK_WINDOW(inst->window), x, y);
#else #else
gdk_window_move(inst->window->window, x, y); gdk_window_move(gtk_widget_get_window(inst->window), x, y);
#endif #endif
} }
@ -328,9 +329,9 @@ void set_zorder(void *frontend, int top)
{ {
struct gui_data *inst = (struct gui_data *)frontend; struct gui_data *inst = (struct gui_data *)frontend;
if (top) if (top)
gdk_window_raise(inst->window->window); gdk_window_raise(gtk_widget_get_window(inst->window));
else else
gdk_window_lower(inst->window->window); gdk_window_lower(gtk_widget_get_window(inst->window));
} }
/* /*
@ -366,7 +367,7 @@ void set_zoomed(void *frontend, int zoomed)
int is_iconic(void *frontend) int is_iconic(void *frontend)
{ {
struct gui_data *inst = (struct gui_data *)frontend; struct gui_data *inst = (struct gui_data *)frontend;
return !gdk_window_is_viewable(inst->window->window); return !gdk_window_is_viewable(gtk_widget_get_window(inst->window));
} }
/* /*
@ -383,7 +384,7 @@ void get_window_pos(void *frontend, int *x, int *y)
#if GTK_CHECK_VERSION(2,0,0) #if GTK_CHECK_VERSION(2,0,0)
gtk_window_get_position(GTK_WINDOW(inst->window), x, y); gtk_window_get_position(GTK_WINDOW(inst->window), x, y);
#else #else
gdk_window_get_position(inst->window->window, x, y); gdk_window_get_position(gtk_widget_get_window(inst->window), x, y);
#endif #endif
} }
@ -401,7 +402,7 @@ void get_window_pixels(void *frontend, int *x, int *y)
#if GTK_CHECK_VERSION(2,0,0) #if GTK_CHECK_VERSION(2,0,0)
gtk_window_get_size(GTK_WINDOW(inst->window), x, y); gtk_window_get_size(GTK_WINDOW(inst->window), x, y);
#else #else
gdk_window_get_size(inst->window->window, x, y); gdk_window_get_size(gtk_widget_get_window(inst->window), x, y);
#endif #endif
} }
@ -429,17 +430,21 @@ static void update_mouseptr(struct gui_data *inst)
switch (inst->busy_status) { switch (inst->busy_status) {
case BUSY_NOT: case BUSY_NOT:
if (!inst->mouseptr_visible) { if (!inst->mouseptr_visible) {
gdk_window_set_cursor(inst->area->window, inst->blankcursor); gdk_window_set_cursor(gtk_widget_get_window(inst->area),
inst->blankcursor);
} else if (send_raw_mouse) { } else if (send_raw_mouse) {
gdk_window_set_cursor(inst->area->window, inst->rawcursor); gdk_window_set_cursor(gtk_widget_get_window(inst->area),
inst->rawcursor);
} else { } else {
gdk_window_set_cursor(inst->area->window, inst->textcursor); gdk_window_set_cursor(gtk_widget_get_window(inst->area),
inst->textcursor);
} }
break; break;
case BUSY_WAITING: /* XXX can we do better? */ case BUSY_WAITING: /* XXX can we do better? */
case BUSY_CPU: case BUSY_CPU:
/* We always display these cursors. */ /* We always display these cursors. */
gdk_window_set_cursor(inst->area->window, inst->waitcursor); gdk_window_set_cursor(gtk_widget_get_window(inst->area),
inst->waitcursor);
break; break;
default: default:
assert(0); assert(0);
@ -456,7 +461,7 @@ static void show_mouseptr(struct gui_data *inst, int show)
void draw_backing_rect(struct gui_data *inst) void draw_backing_rect(struct gui_data *inst)
{ {
GdkGC *gc = gdk_gc_new(inst->area->window); GdkGC *gc = gdk_gc_new(gtk_widget_get_window(inst->area));
gdk_gc_set_foreground(gc, &inst->cols[258]); /* default background */ gdk_gc_set_foreground(gc, &inst->cols[258]); /* default background */
gdk_draw_rectangle(inst->pixmap, gc, 1, 0, 0, gdk_draw_rectangle(inst->pixmap, gc, 1, 0, 0,
inst->width * inst->font_width + 2*inst->window_border, inst->width * inst->font_width + 2*inst->window_border,
@ -488,7 +493,7 @@ gint configure_area(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
inst->pixmap = NULL; inst->pixmap = NULL;
} }
inst->pixmap = gdk_pixmap_new(widget->window, inst->pixmap = gdk_pixmap_new(gtk_widget_get_window(widget),
(w * inst->font_width + 2*inst->window_border), (w * inst->font_width + 2*inst->window_border),
(h * inst->font_height + 2*inst->window_border), -1); (h * inst->font_height + 2*inst->window_border), -1);
@ -502,7 +507,7 @@ gint configure_area(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
term_invalidate(inst->term); term_invalidate(inst->term);
#if GTK_CHECK_VERSION(2,0,0) #if GTK_CHECK_VERSION(2,0,0)
gtk_im_context_set_client_window(inst->imc, widget->window); gtk_im_context_set_client_window(inst->imc, gtk_widget_get_window(widget));
#endif #endif
return TRUE; return TRUE;
@ -517,8 +522,9 @@ gint expose_area(GtkWidget *widget, GdkEventExpose *event, gpointer data)
* back to do the actual painting. * back to do the actual painting.
*/ */
if (inst->pixmap) { if (inst->pixmap) {
gdk_draw_pixmap(widget->window, gdk_draw_pixmap(gtk_widget_get_window(widget),
widget->style->fg_gc[GTK_WIDGET_STATE(widget)], (gtk_widget_get_style(widget)->fg_gc
[gtk_widget_get_state(widget)]),
inst->pixmap, inst->pixmap,
event->area.x, event->area.y, event->area.x, event->area.y,
event->area.x, event->area.y, event->area.x, event->area.y,
@ -1650,7 +1656,7 @@ void request_resize(void *frontend, int w, int h)
* above. * above.
*/ */
gtk_container_dequeue_resize_handler(GTK_CONTAINER(inst->window)); gtk_container_dequeue_resize_handler(GTK_CONTAINER(inst->window));
gdk_window_resize(inst->window->window, gdk_window_resize(gtk_widget_get_window(inst->window),
area_x + offset_x, area_y + offset_y); area_x + offset_x, area_y + offset_y);
#endif #endif
} }
@ -1673,10 +1679,12 @@ static void real_palette_set(struct gui_data *inst, int n, int r, int g, int b)
void set_window_background(struct gui_data *inst) void set_window_background(struct gui_data *inst)
{ {
if (inst->area && inst->area->window) if (inst->area && gtk_widget_get_window(inst->area))
gdk_window_set_background(inst->area->window, &inst->cols[258]); gdk_window_set_background(gtk_widget_get_window(inst->area),
if (inst->window && inst->window->window) &inst->cols[258]);
gdk_window_set_background(inst->window->window, &inst->cols[258]); if (inst->window && gtk_widget_get_window(inst->window))
gdk_window_set_background(gtk_widget_get_window(inst->window),
&inst->cols[258]);
} }
void palette_set(void *frontend, int n, int r, int g, int b) void palette_set(void *frontend, int n, int r, int g, int b)
@ -1753,7 +1761,7 @@ void palette_reset(void *frontend)
/* Since Default Background may have changed, ensure that space /* Since Default Background may have changed, ensure that space
* between text area and window border is refreshed. */ * between text area and window border is refreshed. */
set_window_background(inst); set_window_background(inst);
if (inst->area && inst->area->window) { if (inst->area && gtk_widget_get_window(inst->area)) {
draw_backing_rect(inst); draw_backing_rect(inst);
gtk_widget_queue_draw(inst->area); gtk_widget_queue_draw(inst->area);
} }
@ -1901,16 +1909,17 @@ void selection_get(GtkWidget *widget, GtkSelectionData *seldata,
guint info, guint time_stamp, gpointer data) guint info, guint time_stamp, gpointer data)
{ {
struct gui_data *inst = (struct gui_data *)data; struct gui_data *inst = (struct gui_data *)data;
if (seldata->target == utf8_string_atom) GdkAtom target = gtk_selection_data_get_target(seldata);
gtk_selection_data_set(seldata, seldata->target, 8, if (target == utf8_string_atom)
gtk_selection_data_set(seldata, target, 8,
(unsigned char *)inst->pasteout_data_utf8, (unsigned char *)inst->pasteout_data_utf8,
inst->pasteout_data_utf8_len); inst->pasteout_data_utf8_len);
else if (seldata->target == compound_text_atom) else if (target == compound_text_atom)
gtk_selection_data_set(seldata, seldata->target, 8, gtk_selection_data_set(seldata, target, 8,
(unsigned char *)inst->pasteout_data_ctext, (unsigned char *)inst->pasteout_data_ctext,
inst->pasteout_data_ctext_len); inst->pasteout_data_ctext_len);
else else
gtk_selection_data_set(seldata, seldata->target, 8, gtk_selection_data_set(seldata, target, 8,
(unsigned char *)inst->pasteout_data, (unsigned char *)inst->pasteout_data,
inst->pasteout_data_len); inst->pasteout_data_len);
} }
@ -1980,8 +1989,13 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
int free_list_required = 0; int free_list_required = 0;
int free_required = 0; int free_required = 0;
int charset; int charset;
GdkAtom seldata_target = gtk_selection_data_get_target(seldata);
GdkAtom seldata_type = gtk_selection_data_get_data_type(seldata);
const guchar *seldata_data = gtk_selection_data_get_data(seldata);
gint seldata_length = gtk_selection_data_get_length(seldata);
gint seldata_format = gtk_selection_data_get_format(seldata);
if (seldata->target == utf8_string_atom && seldata->length <= 0) { if (seldata_target == utf8_string_atom && seldata_length <= 0) {
/* /*
* Failed to get a UTF-8 selection string. Try compound * Failed to get a UTF-8 selection string. Try compound
* text next. * text next.
@ -1992,7 +2006,7 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
return; return;
} }
if (seldata->target == compound_text_atom && seldata->length <= 0) { if (seldata_target == compound_text_atom && seldata_length <= 0) {
/* /*
* Failed to get UTF-8 or compound text. Try an ordinary * Failed to get UTF-8 or compound text. Try an ordinary
* string. * string.
@ -2007,16 +2021,16 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
* If we have data, but it's not of a type we can deal with, * If we have data, but it's not of a type we can deal with,
* we have to ignore the data. * we have to ignore the data.
*/ */
if (seldata->length > 0 && if (seldata_length > 0 &&
seldata->type != GDK_SELECTION_TYPE_STRING && seldata_type != GDK_SELECTION_TYPE_STRING &&
seldata->type != compound_text_atom && seldata_type != compound_text_atom &&
seldata->type != utf8_string_atom) seldata_type != utf8_string_atom)
return; return;
/* /*
* If we have no data, try looking in a cut buffer. * If we have no data, try looking in a cut buffer.
*/ */
if (seldata->length <= 0) { if (seldata_length <= 0) {
text = retrieve_cutbuffer(&length); text = retrieve_cutbuffer(&length);
if (length == 0) if (length == 0)
return; return;
@ -2028,11 +2042,11 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
/* /*
* Convert COMPOUND_TEXT into UTF-8. * Convert COMPOUND_TEXT into UTF-8.
*/ */
if (seldata->type == compound_text_atom) { if (seldata_type == compound_text_atom) {
tp.value = seldata->data; tp.value = (unsigned char *)seldata_data;
tp.encoding = (Atom) seldata->type; tp.encoding = (Atom) seldata_type;
tp.format = seldata->format; tp.format = seldata_format;
tp.nitems = seldata->length; tp.nitems = seldata_length;
ret = Xutf8TextPropertyToTextList(GDK_DISPLAY(), &tp, ret = Xutf8TextPropertyToTextList(GDK_DISPLAY(), &tp,
&list, &count); &list, &count);
if (ret != 0 || count != 1) { if (ret != 0 || count != 1) {
@ -2049,9 +2063,9 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
charset = CS_UTF8; charset = CS_UTF8;
free_list_required = 1; free_list_required = 1;
} else { } else {
text = (char *)seldata->data; text = (char *)seldata_data;
length = seldata->length; length = seldata_length;
charset = (seldata->type == utf8_string_atom ? charset = (seldata_type == utf8_string_atom ?
CS_UTF8 : inst->ucsdata.line_codepage); CS_UTF8 : inst->ucsdata.line_codepage);
} }
} }
@ -2092,7 +2106,8 @@ static void set_window_titles(struct gui_data *inst)
*/ */
gtk_window_set_title(GTK_WINDOW(inst->window), inst->wintitle); gtk_window_set_title(GTK_WINDOW(inst->window), inst->wintitle);
if (!conf_get_int(inst->conf, CONF_win_name_always)) if (!conf_get_int(inst->conf, CONF_win_name_always))
gdk_window_set_icon_name(inst->window->window, inst->icontitle); gdk_window_set_icon_name(gtk_widget_get_window(inst->window),
inst->icontitle);
} }
void set_title(void *frontend, char *title) void set_title(void *frontend, char *title)
@ -2126,12 +2141,12 @@ void set_sbar(void *frontend, int total, int start, int page)
struct gui_data *inst = (struct gui_data *)frontend; struct gui_data *inst = (struct gui_data *)frontend;
if (!conf_get_int(inst->conf, CONF_scrollbar)) if (!conf_get_int(inst->conf, CONF_scrollbar))
return; return;
inst->sbar_adjust->lower = 0; gtk_adjustment_set_lower(inst->sbar_adjust, 0);
inst->sbar_adjust->upper = total; gtk_adjustment_set_upper(inst->sbar_adjust, total);
inst->sbar_adjust->value = start; gtk_adjustment_set_value(inst->sbar_adjust, start);
inst->sbar_adjust->page_size = page; gtk_adjustment_set_page_size(inst->sbar_adjust, page);
inst->sbar_adjust->step_increment = 1; gtk_adjustment_set_step_increment(inst->sbar_adjust, 1);
inst->sbar_adjust->page_increment = page/2; gtk_adjustment_set_page_increment(inst->sbar_adjust, page/2);
inst->ignore_sbar = TRUE; inst->ignore_sbar = TRUE;
gtk_adjustment_changed(inst->sbar_adjust); gtk_adjustment_changed(inst->sbar_adjust);
inst->ignore_sbar = FALSE; inst->ignore_sbar = FALSE;
@ -2144,7 +2159,7 @@ void scrollbar_moved(GtkAdjustment *adj, gpointer data)
if (!conf_get_int(inst->conf, CONF_scrollbar)) if (!conf_get_int(inst->conf, CONF_scrollbar))
return; return;
if (!inst->ignore_sbar) if (!inst->ignore_sbar)
term_scroll(inst->term, 1, (int)adj->value); term_scroll(inst->term, 1, (int)gtk_adjustment_get_value(adj));
} }
void sys_cursor(void *frontend, int x, int y) void sys_cursor(void *frontend, int x, int y)
@ -2183,12 +2198,12 @@ Context get_ctx(void *frontend)
struct gui_data *inst = (struct gui_data *)frontend; struct gui_data *inst = (struct gui_data *)frontend;
struct draw_ctx *dctx; struct draw_ctx *dctx;
if (!inst->area->window) if (!gtk_widget_get_window(inst->area))
return NULL; return NULL;
dctx = snew(struct draw_ctx); dctx = snew(struct draw_ctx);
dctx->inst = inst; dctx->inst = inst;
dctx->gc = gdk_gc_new(inst->area->window); dctx->gc = gdk_gc_new(gtk_widget_get_window(inst->area));
return dctx; return dctx;
} }
@ -2215,7 +2230,8 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
GdkGC *gc = dctx->gc; GdkGC *gc = dctx->gc;
int ncombining, combining; int ncombining, combining;
int nfg, nbg, t, fontid, shadow, rlen, widefactor, bold; int nfg, nbg, t, fontid, shadow, rlen, widefactor, bold;
int monochrome = gtk_widget_get_visual(inst->area)->depth == 1; int monochrome =
gdk_visual_get_depth(gtk_widget_get_visual(inst->area)) == 1;
if (attr & TATTR_COMBINING) { if (attr & TATTR_COMBINING) {
ncombining = len; ncombining = len;
@ -2384,7 +2400,7 @@ void do_text(Context ctx, int x, int y, wchar_t *text, int len,
len *= 2; len *= 2;
} }
gdk_draw_pixmap(inst->area->window, gc, inst->pixmap, gdk_draw_pixmap(gtk_widget_get_window(inst->area), gc, inst->pixmap,
x*inst->font_width+inst->window_border, x*inst->font_width+inst->window_border,
y*inst->font_height+inst->window_border, y*inst->font_height+inst->window_border,
x*inst->font_width+inst->window_border, x*inst->font_width+inst->window_border,
@ -2491,7 +2507,7 @@ void do_cursor(Context ctx, int x, int y, wchar_t *text, int len,
} /* else no cursor (e.g., blinked off) */ } /* else no cursor (e.g., blinked off) */
} }
gdk_draw_pixmap(inst->area->window, gc, inst->pixmap, gdk_draw_pixmap(gtk_widget_get_window(inst->area), gc, inst->pixmap,
x*inst->font_width+inst->window_border, x*inst->font_width+inst->window_border,
y*inst->font_height+inst->window_border, y*inst->font_height+inst->window_border,
x*inst->font_width+inst->window_border, x*inst->font_width+inst->window_border,
@ -2635,7 +2651,7 @@ char *get_x_display(void *frontend)
long get_windowid(void *frontend) long get_windowid(void *frontend)
{ {
struct gui_data *inst = (struct gui_data *)frontend; struct gui_data *inst = (struct gui_data *)frontend;
return (long)GDK_WINDOW_XWINDOW(inst->area->window); return (long)GDK_WINDOW_XWINDOW(gtk_widget_get_window(inst->area));
} }
static void help(FILE *fp) { static void help(FILE *fp) {
@ -3511,9 +3527,9 @@ void set_window_icon(GtkWidget *window, const char *const *const *icon,
return; return;
gtk_widget_realize(window); gtk_widget_realize(window);
iconpm = gdk_pixmap_create_from_xpm_d(window->window, &iconmask, iconpm = gdk_pixmap_create_from_xpm_d(gtk_widget_get_window(window),
NULL, (gchar **)icon[0]); &iconmask, NULL, (gchar **)icon[0]);
gdk_window_set_icon(window->window, NULL, iconpm, iconmask); gdk_window_set_icon(gtk_widget_get_window(window), NULL, iconpm, iconmask);
#if GTK_CHECK_VERSION(2,0,0) #if GTK_CHECK_VERSION(2,0,0)
iconlist = NULL; iconlist = NULL;
@ -3523,7 +3539,7 @@ void set_window_icon(GtkWidget *window, const char *const *const *icon,
gdk_pixbuf_new_from_xpm_data((const gchar **) gdk_pixbuf_new_from_xpm_data((const gchar **)
icon[n])); icon[n]));
} }
gdk_window_set_icon_list(window->window, iconlist); gdk_window_set_icon_list(gtk_widget_get_window(window), iconlist);
#endif #endif
} }