aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-08-08 04:20:37 +0800
committerChris Lahey <clahey@src.gnome.org>2000-08-08 04:20:37 +0800
commit5b1da3b4397606654c31fd221215b25faee93770 (patch)
tree208b770be1dc3b68825074202efbc5051aabaaa9 /widgets/misc
parent12f903a3b0bc7bbed7bf3aa862dd56d852ed03f0 (diff)
downloadgsoc2013-evolution-5b1da3b4397606654c31fd221215b25faee93770.tar
gsoc2013-evolution-5b1da3b4397606654c31fd221215b25faee93770.tar.gz
gsoc2013-evolution-5b1da3b4397606654c31fd221215b25faee93770.tar.bz2
gsoc2013-evolution-5b1da3b4397606654c31fd221215b25faee93770.tar.lz
gsoc2013-evolution-5b1da3b4397606654c31fd221215b25faee93770.tar.xz
gsoc2013-evolution-5b1da3b4397606654c31fd221215b25faee93770.tar.zst
gsoc2013-evolution-5b1da3b4397606654c31fd221215b25faee93770.zip
Added e_container_change_tab_order.
2000-08-07 Christopher James Lahey <clahey@helixcode.com> * e-gui-utils.c, e-gui-utils.c: Added e_container_change_tab_order. svn path=/trunk/; revision=4580
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/e-gui-utils.c81
-rw-r--r--widgets/misc/e-gui-utils.h3
2 files changed, 83 insertions, 1 deletions
diff --git a/widgets/misc/e-gui-utils.c b/widgets/misc/e-gui-utils.c
index 5d53c64d35..2e31eb101b 100644
--- a/widgets/misc/e-gui-utils.c
+++ b/widgets/misc/e-gui-utils.c
@@ -136,3 +136,84 @@ e_container_foreach_leaf(GtkContainer *container,
callback_closure.closure = closure;
gtk_container_foreach(container, (GtkCallback) e_container_foreach_leaf_callback, &callback_closure);
}
+
+static void
+e_container_change_tab_order_destroy_notify(gpointer data)
+{
+ GList *list = data;
+ g_list_foreach(list, (GFunc) gtk_object_unref, NULL);
+ g_list_free(list);
+}
+
+
+static gint
+e_container_change_tab_order_callback(GtkContainer *container,
+ GtkDirectionType direction,
+ GList *children)
+{
+ GtkWidget *focus_child;
+ GtkWidget *child;
+
+ if (direction != GTK_DIR_TAB_FORWARD &&
+ direction != GTK_DIR_TAB_BACKWARD)
+ return FALSE;
+
+ focus_child = container->focus_child;
+
+ if (direction == GTK_DIR_TAB_BACKWARD) {
+ children = g_list_last(children);
+ }
+
+ while (children) {
+ child = children->data;
+ if (direction == GTK_DIR_TAB_FORWARD)
+ children = children->next;
+ else
+ children = children->prev;
+
+ if (!child)
+ continue;
+
+ if (focus_child) {
+ if (focus_child == child) {
+ focus_child = NULL;
+
+ if (GTK_WIDGET_DRAWABLE (child) &&
+ GTK_IS_CONTAINER (child) &&
+ !GTK_WIDGET_HAS_FOCUS (child))
+ if (gtk_container_focus (GTK_CONTAINER (child), direction)) {
+ gtk_signal_emit_stop_by_name(GTK_OBJECT(container), "focus");
+ return TRUE;
+ }
+ }
+ }
+ else if (GTK_WIDGET_DRAWABLE (child)) {
+ if (GTK_IS_CONTAINER (child)) {
+ if (gtk_container_focus (GTK_CONTAINER (child), direction)) {
+ gtk_signal_emit_stop_by_name(GTK_OBJECT(container), "focus");
+ return TRUE;
+ }
+ }
+ else if (GTK_WIDGET_CAN_FOCUS (child)) {
+ gtk_widget_grab_focus (child);
+ gtk_signal_emit_stop_by_name(GTK_OBJECT(container), "focus");
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+gint
+e_container_change_tab_order(GtkContainer *container, GList *widgets)
+{
+ GList *list;
+ list = g_list_copy(widgets);
+ g_list_foreach(list, (GFunc) gtk_object_ref, NULL);
+ return gtk_signal_connect_full(GTK_OBJECT(container), "focus",
+ GTK_SIGNAL_FUNC(e_container_change_tab_order_callback),
+ NULL, list,
+ e_container_change_tab_order_destroy_notify,
+ FALSE, FALSE);
+}
diff --git a/widgets/misc/e-gui-utils.h b/widgets/misc/e-gui-utils.h
index c1958879aa..1d47a7b514 100644
--- a/widgets/misc/e-gui-utils.h
+++ b/widgets/misc/e-gui-utils.h
@@ -13,6 +13,7 @@ GtkWidget *e_create_image_widget (gchar *name, gchar *string1, gchar *string
void e_container_foreach_leaf (GtkContainer *container,
GtkCallback callback,
gpointer closure);
-
+gint e_container_change_tab_order (GtkContainer *container,
+ GList *widgets);
#endif /* E_GUI_UTILS_H */