X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=unix%2Fgtkcols.c;h=e70400dea10838bc8ea4dac51d5bf573f1ea66fe;hb=12e019bafc75cb441e965c63e15dfceeaf71ca1e;hp=d4c936795ff54c1e16c4971c95eaaf2a8e8dc626;hpb=df85003ea56581734754d7404fa08e4081f9dd34;p=PuTTY.git diff --git a/unix/gtkcols.c b/unix/gtkcols.c index d4c93679..e70400de 100644 --- a/unix/gtkcols.c +++ b/unix/gtkcols.c @@ -3,18 +3,23 @@ */ #include "gtkcols.h" +#include static void columns_init(Columns *cols); static void columns_class_init(ColumnsClass *klass); static void columns_map(GtkWidget *widget); static void columns_unmap(GtkWidget *widget); +#if !GTK_CHECK_VERSION(2,0,0) static void columns_draw(GtkWidget *widget, GdkRectangle *area); static gint columns_expose(GtkWidget *widget, GdkEventExpose *event); +#endif static void columns_base_add(GtkContainer *container, GtkWidget *widget); static void columns_remove(GtkContainer *container, GtkWidget *widget); static void columns_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); +#if !GTK_CHECK_VERSION(2,0,0) static gint columns_focus(GtkContainer *container, GtkDirectionType dir); +#endif static GtkType columns_child_type(GtkContainer *container); static void columns_size_request(GtkWidget *widget, GtkRequisition *req); static void columns_size_allocate(GtkWidget *widget, GtkAllocation *alloc); @@ -43,8 +48,10 @@ GtkType columns_get_type(void) return columns_type; } +#if !GTK_CHECK_VERSION(2,0,0) static gint (*columns_inherited_focus)(GtkContainer *container, GtkDirectionType direction); +#endif static void columns_class_init(ColumnsClass *klass) { @@ -65,8 +72,10 @@ static void columns_class_init(ColumnsClass *klass) widget_class->map = columns_map; widget_class->unmap = columns_unmap; +#if !GTK_CHECK_VERSION(2,0,0) widget_class->draw = columns_draw; widget_class->expose_event = columns_expose; +#endif widget_class->size_request = columns_size_request; widget_class->size_allocate = columns_size_allocate; @@ -74,10 +83,12 @@ static void columns_class_init(ColumnsClass *klass) container_class->remove = columns_remove; container_class->forall = columns_forall; container_class->child_type = columns_child_type; +#if !GTK_CHECK_VERSION(2,0,0) /* Save the previous value of this method. */ if (!columns_inherited_focus) columns_inherited_focus = container_class->focus; container_class->focus = columns_focus; +#endif } static void columns_init(Columns *cols) @@ -135,6 +146,7 @@ static void columns_unmap(GtkWidget *widget) gtk_widget_unmap(child->widget); } } +#if !GTK_CHECK_VERSION(2,0,0) static void columns_draw(GtkWidget *widget, GdkRectangle *area) { Columns *cols; @@ -186,6 +198,7 @@ static gint columns_expose(GtkWidget *widget, GdkEventExpose *event) } return FALSE; } +#endif static void columns_base_add(GtkContainer *container, GtkWidget *widget) { @@ -241,6 +254,9 @@ static void columns_remove(GtkContainer *container, GtkWidget *widget) cols->taborder = g_list_remove_link(cols->taborder, children); g_list_free(children); +#if GTK_CHECK_VERSION(2,0,0) + gtk_container_set_focus_chain(container, cols->taborder); +#endif break; } } @@ -250,7 +266,7 @@ static void columns_forall(GtkContainer *container, gboolean include_internals, { Columns *cols; ColumnsChild *child; - GList *children; + GList *children, *next; g_return_if_fail(container != NULL); g_return_if_fail(IS_COLUMNS(container)); @@ -260,9 +276,19 @@ static void columns_forall(GtkContainer *container, gboolean include_internals, for (children = cols->children; children && (child = children->data); - children = children->next) + children = next) { + /* + * We can't wait until after the callback to assign + * `children = children->next', because the callback might + * be gtk_widget_destroy, which would remove the link + * `children' from the list! So instead we must get our + * hands on the value of the `next' pointer _before_ the + * callback. + */ + next = children->next; if (child->widget) callback(child->widget, callback_data); + } } static GtkType columns_child_type(GtkContainer *container) @@ -322,6 +348,10 @@ void columns_add(Columns *cols, GtkWidget *child, gtk_widget_set_parent(child, GTK_WIDGET(cols)); +#if GTK_CHECK_VERSION(2,0,0) + gtk_container_set_focus_chain(GTK_CONTAINER(cols), cols->taborder); +#endif + if (GTK_WIDGET_REALIZED(cols)) gtk_widget_realize(child); @@ -372,10 +402,14 @@ void columns_taborder_last(Columns *cols, GtkWidget *widget) cols->taborder = g_list_remove_link(cols->taborder, children); g_list_free(children); cols->taborder = g_list_append(cols->taborder, widget); +#if GTK_CHECK_VERSION(2,0,0) + gtk_container_set_focus_chain(GTK_CONTAINER(cols), cols->taborder); +#endif break; } } +#if !GTK_CHECK_VERSION(2,0,0) /* * Override GtkContainer's focus movement so the user can * explicitly specify the tab order. @@ -439,6 +473,7 @@ static gint columns_focus(GtkContainer *container, GtkDirectionType dir) } else return columns_inherited_focus(container, dir); } +#endif /* * Now here comes the interesting bit. The actual layout part is