X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/881da16842e210236b12a040a19bf480de3a5a92..f160b7b8908cac4a7ca37b49928b7855fe0a11fe:/unix/gtkcols.c diff --git a/unix/gtkcols.c b/unix/gtkcols.c index c0a0ed8d..8cb5d14f 100644 --- a/unix/gtkcols.c +++ b/unix/gtkcols.c @@ -3,24 +3,30 @@ */ #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); static GtkContainerClass *parent_class = NULL; +#if !GTK_CHECK_VERSION(2,0,0) GtkType columns_get_type(void) { static GtkType columns_type = 0; @@ -42,31 +48,61 @@ GtkType columns_get_type(void) return columns_type; } +#else +GType columns_get_type(void) +{ + static GType columns_type = 0; + + if (!columns_type) { + static const GTypeInfo columns_info = { + sizeof(ColumnsClass), + NULL, + NULL, + (GClassInitFunc) columns_class_init, + NULL, + NULL, + sizeof(Columns), + 0, + (GInstanceInitFunc)columns_init, + }; + + columns_type = g_type_register_static(GTK_TYPE_CONTAINER, "Columns", + &columns_info, 0); + } + + return columns_type; +} +#endif +#if !GTK_CHECK_VERSION(2,0,0) static gint (*columns_inherited_focus)(GtkContainer *container, GtkDirectionType direction); +#endif static void columns_class_init(ColumnsClass *klass) { - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - object_class = (GtkObjectClass *)klass; - widget_class = (GtkWidgetClass *)klass; - container_class = (GtkContainerClass *)klass; - +#if !GTK_CHECK_VERSION(2,0,0) + /* GtkObjectClass *object_class = (GtkObjectClass *)klass; */ + GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; + GtkContainerClass *container_class = (GtkContainerClass *)klass; +#else + /* GObjectClass *object_class = G_OBJECT_CLASS(klass); */ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + GtkContainerClass *container_class = GTK_CONTAINER_CLASS(klass); +#endif + +#if !GTK_CHECK_VERSION(2,0,0) parent_class = gtk_type_class(GTK_TYPE_CONTAINER); - - /* - * FIXME: do we have to do all this faffing with set_arg, - * get_arg and child_arg_type? Ick. - */ +#else + parent_class = g_type_class_peek_parent(klass); +#endif 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 +110,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 +173,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 +225,7 @@ static gint columns_expose(GtkWidget *widget, GdkEventExpose *event) } return FALSE; } +#endif static void columns_base_add(GtkContainer *container, GtkWidget *widget) { @@ -241,6 +281,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; } } @@ -284,7 +327,12 @@ GtkWidget *columns_new(gint spacing) { Columns *cols; +#if !GTK_CHECK_VERSION(2,0,0) cols = gtk_type_new(columns_get_type()); +#else + cols = g_object_new(TYPE_COLUMNS, NULL); +#endif + cols->spacing = spacing; return GTK_WIDGET(cols); @@ -332,6 +380,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); @@ -382,10 +434,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. @@ -449,6 +505,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