summaryrefslogtreecommitdiff
path: root/gtk/gtkplug.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-06-08 18:09:34 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-06-08 18:09:34 +0000
commit74e7da214f1ee9b98304145813814d4f73a97a15 (patch)
treefc3dd7f61cea4cabf3fc5dc44dc8fbd9ca691b30 /gtk/gtkplug.c
parent72ef055bde913c993d4a38964542b1d1c4470e1b (diff)
downloadgtk+-74e7da214f1ee9b98304145813814d4f73a97a15.tar.gz
geez, don't call g_list funcs on GSList
2001-06-08 Havoc Pennington <hp@redhat.com> * gtk/gtktextbuffer.c (gtk_text_buffer_remove_all_tags): geez, don't call g_list funcs on GSList * gtk/gtkwidget.c (gtk_widget_child_focus): replaces gtk_container_focus(), since some widgets have focusable locations which are not other widgets. These widgets should not have to be containers just to manage the focus. For example, GtkHSV is currently a container for no good reason. Also, this cleans up the "if (is_container && is_sensitive && is_drawable) container_focus ()" mess in widget implementations. * gtk/gtkcontainer.c (gtk_container_focus): deprecate this function, and have it just call gtk_widget_child_focus(). * gtk/gtkhsv.c: derive from widget not container Throughout: fix to reflect GtkContainer::focus change
Diffstat (limited to 'gtk/gtkplug.c')
-rw-r--r--gtk/gtkplug.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index 78d9d5128f..1f7319b390 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -43,7 +43,7 @@ static void gtk_plug_forward_key_press (GtkPlug *plug,
GdkEventKey *event);
static void gtk_plug_set_focus (GtkWindow *window,
GtkWidget *focus);
-static gboolean gtk_plug_focus (GtkContainer *container,
+static gboolean gtk_plug_focus (GtkWidget *widget,
GtkDirectionType direction);
static void gtk_plug_accel_entries_changed (GtkWindow *window);
static GdkFilterReturn gtk_plug_filter_func (GdkXEvent *gdk_xevent,
@@ -94,7 +94,6 @@ static void
gtk_plug_class_init (GtkPlugClass *class)
{
GtkWidgetClass *widget_class = (GtkWidgetClass *)class;
- GtkContainerClass *container_class = (GtkContainerClass *)class;
GtkWindowClass *window_class = (GtkWindowClass *)class;
parent_class = gtk_type_class (GTK_TYPE_WINDOW);
@@ -103,7 +102,7 @@ gtk_plug_class_init (GtkPlugClass *class)
widget_class->unrealize = gtk_plug_unrealize;
widget_class->key_press_event = gtk_plug_key_press_event;
- container_class->focus = gtk_plug_focus;
+ widget_class->focus = gtk_plug_focus;
window_class->set_focus = gtk_plug_set_focus;
#if 0
@@ -441,12 +440,13 @@ gtk_plug_accel_entries_changed (GtkWindow *window)
#endif
static gboolean
-gtk_plug_focus (GtkContainer *container,
+gtk_plug_focus (GtkWidget *widget,
GtkDirectionType direction)
{
- GtkBin *bin = GTK_BIN (container);
- GtkPlug *plug = GTK_PLUG (container);
- GtkWindow *window = GTK_WINDOW (container);
+ GtkBin *bin = GTK_BIN (widget);
+ GtkPlug *plug = GTK_PLUG (widget);
+ GtkWindow *window = GTK_WINDOW (widget);
+ GtkContainer *container = GTK_CONTAINER (widget);
GtkWidget *old_focus_child = container->focus_child;
GtkWidget *parent;
@@ -454,10 +454,7 @@ gtk_plug_focus (GtkContainer *container,
*/
if (old_focus_child)
{
- if (GTK_IS_CONTAINER (old_focus_child) &&
- GTK_WIDGET_DRAWABLE (old_focus_child) &&
- GTK_WIDGET_IS_SENSITIVE (old_focus_child) &&
- gtk_container_focus (GTK_CONTAINER (old_focus_child), direction))
+ if (gtk_widget_child_focus (old_focus_child, direction))
return TRUE;
if (window->focus_widget)
@@ -513,20 +510,9 @@ gtk_plug_focus (GtkContainer *container,
else
{
/* Try to focus the first widget in the window */
- if (GTK_WIDGET_DRAWABLE (bin->child) &&
- GTK_WIDGET_IS_SENSITIVE (bin->child))
- {
- if (GTK_IS_CONTAINER (bin->child))
- {
- if (gtk_container_focus (GTK_CONTAINER (bin->child), direction))
- return TRUE;
- }
- else if (GTK_WIDGET_CAN_FOCUS (bin->child))
- {
- gtk_widget_grab_focus (bin->child);
- return TRUE;
- }
- }
+
+ if (gtk_widget_child_focus (bin->child, direction))
+ return TRUE;
}
return FALSE;
@@ -582,7 +568,7 @@ focus_first_last (GtkPlug *plug,
gtk_window_set_focus (GTK_WINDOW (plug), NULL);
}
- gtk_container_focus (GTK_CONTAINER (plug), direction);
+ gtk_widget_child_focus (GTK_WIDGET (plug), direction);
}
static void