*/
#include "gtkcols.h"
+#include <gtk/gtk.h>
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);
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)
{
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;
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)
gtk_widget_unmap(child->widget);
}
}
+#if !GTK_CHECK_VERSION(2,0,0)
static void columns_draw(GtkWidget *widget, GdkRectangle *area)
{
Columns *cols;
}
return FALSE;
}
+#endif
static void columns_base_add(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;
}
}
{
Columns *cols;
ColumnsChild *child;
- GList *children;
+ GList *children, *next;
g_return_if_fail(container != NULL);
g_return_if_fail(IS_COLUMNS(container));
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)
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);
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.
} else
return columns_inherited_focus(container, dir);
}
+#endif
/*
* Now here comes the interesting bit. The actual layout part is