Commit 8850ce81 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Allow the user to use the popup list like a menu.

Thu Apr 30 11:18:00 1998  Owen Taylor  <otaylor@gtk.org>

	* gtk/gtkcombo.[ch]: Allow the user to use the popup list
	like a menu.

	* gtk/gtkmenuitem.c gtk/gtkitem.c: Moved enter/leave handlers
	to gtkitem.c so dragging can also work in lists.

	* gtk/gtklist.[ch]: Track child enter events and use
	those to allow dragging the selection.

Thu Apr 30 11:16:06 1998  Owen Taylor  <otaylor@gtk.org>

	* gtk/gtktext.c: Try enabling background pixmaps for editable text
	widgets.  There is a bit of flashing, but not too bad. If you
	don't want the flashing, you can always not set a background
	pixmap.

Wed Apr 29 15:46:13 1998  Owen Taylor  <otaylor@gtk.org>

	* gtk/gtktext.c: Fixed a bug where the drawn level
	was being messed up when the text was scrolled
	during a deletion.
parent 32e8dc45
Thu Apr 30 11:18:00 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkcombo.[ch]: Allow the user to use the popup list
like a menu.
* gtk/gtkmenuitem.c gtk/gtkitem.c: Moved enter/leave handlers
to gtkitem.c so dragging can also work in lists.
* gtk/gtklist.[ch]: Track child enter events and use
those to allow dragging the selection.
Thu Apr 30 11:16:06 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Try enabling background pixmaps for editable text
widgets. There is a bit of flashing, but not too bad. If you
don't want the flashing, you can always not set a background
pixmap.
Wed Apr 29 15:46:13 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Fixed a bug where the drawn level
was being messed up when the text was scrolled
during a deletion.
1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx> 1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Random debugging fixed this * gdk/gdk.c (gdk_event_translate): Random debugging fixed this
......
Thu Apr 30 11:18:00 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkcombo.[ch]: Allow the user to use the popup list
like a menu.
* gtk/gtkmenuitem.c gtk/gtkitem.c: Moved enter/leave handlers
to gtkitem.c so dragging can also work in lists.
* gtk/gtklist.[ch]: Track child enter events and use
those to allow dragging the selection.
Thu Apr 30 11:16:06 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Try enabling background pixmaps for editable text
widgets. There is a bit of flashing, but not too bad. If you
don't want the flashing, you can always not set a background
pixmap.
Wed Apr 29 15:46:13 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Fixed a bug where the drawn level
was being messed up when the text was scrolled
during a deletion.
1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx> 1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Random debugging fixed this * gdk/gdk.c (gdk_event_translate): Random debugging fixed this
......
Thu Apr 30 11:18:00 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkcombo.[ch]: Allow the user to use the popup list
like a menu.
* gtk/gtkmenuitem.c gtk/gtkitem.c: Moved enter/leave handlers
to gtkitem.c so dragging can also work in lists.
* gtk/gtklist.[ch]: Track child enter events and use
those to allow dragging the selection.
Thu Apr 30 11:16:06 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Try enabling background pixmaps for editable text
widgets. There is a bit of flashing, but not too bad. If you
don't want the flashing, you can always not set a background
pixmap.
Wed Apr 29 15:46:13 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Fixed a bug where the drawn level
was being messed up when the text was scrolled
during a deletion.
1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx> 1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Random debugging fixed this * gdk/gdk.c (gdk_event_translate): Random debugging fixed this
......
Thu Apr 30 11:18:00 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkcombo.[ch]: Allow the user to use the popup list
like a menu.
* gtk/gtkmenuitem.c gtk/gtkitem.c: Moved enter/leave handlers
to gtkitem.c so dragging can also work in lists.
* gtk/gtklist.[ch]: Track child enter events and use
those to allow dragging the selection.
Thu Apr 30 11:16:06 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Try enabling background pixmaps for editable text
widgets. There is a bit of flashing, but not too bad. If you
don't want the flashing, you can always not set a background
pixmap.
Wed Apr 29 15:46:13 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Fixed a bug where the drawn level
was being messed up when the text was scrolled
during a deletion.
1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx> 1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Random debugging fixed this * gdk/gdk.c (gdk_event_translate): Random debugging fixed this
......
Thu Apr 30 11:18:00 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkcombo.[ch]: Allow the user to use the popup list
like a menu.
* gtk/gtkmenuitem.c gtk/gtkitem.c: Moved enter/leave handlers
to gtkitem.c so dragging can also work in lists.
* gtk/gtklist.[ch]: Track child enter events and use
those to allow dragging the selection.
Thu Apr 30 11:16:06 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Try enabling background pixmaps for editable text
widgets. There is a bit of flashing, but not too bad. If you
don't want the flashing, you can always not set a background
pixmap.
Wed Apr 29 15:46:13 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Fixed a bug where the drawn level
was being messed up when the text was scrolled
during a deletion.
1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx> 1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Random debugging fixed this * gdk/gdk.c (gdk_event_translate): Random debugging fixed this
......
Thu Apr 30 11:18:00 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkcombo.[ch]: Allow the user to use the popup list
like a menu.
* gtk/gtkmenuitem.c gtk/gtkitem.c: Moved enter/leave handlers
to gtkitem.c so dragging can also work in lists.
* gtk/gtklist.[ch]: Track child enter events and use
those to allow dragging the selection.
Thu Apr 30 11:16:06 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Try enabling background pixmaps for editable text
widgets. There is a bit of flashing, but not too bad. If you
don't want the flashing, you can always not set a background
pixmap.
Wed Apr 29 15:46:13 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Fixed a bug where the drawn level
was being messed up when the text was scrolled
during a deletion.
1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx> 1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Random debugging fixed this * gdk/gdk.c (gdk_event_translate): Random debugging fixed this
......
Thu Apr 30 11:18:00 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkcombo.[ch]: Allow the user to use the popup list
like a menu.
* gtk/gtkmenuitem.c gtk/gtkitem.c: Moved enter/leave handlers
to gtkitem.c so dragging can also work in lists.
* gtk/gtklist.[ch]: Track child enter events and use
those to allow dragging the selection.
Thu Apr 30 11:16:06 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Try enabling background pixmaps for editable text
widgets. There is a bit of flashing, but not too bad. If you
don't want the flashing, you can always not set a background
pixmap.
Wed Apr 29 15:46:13 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktext.c: Fixed a bug where the drawn level
was being messed up when the text was scrolled
during a deletion.
1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx> 1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdk/gdk.c (gdk_event_translate): Random debugging fixed this * gdk/gdk.c (gdk_event_translate): Random debugging fixed this
......
...@@ -52,8 +52,15 @@ static void gtk_combo_get_pos (GtkCombo *combo, ...@@ -52,8 +52,15 @@ static void gtk_combo_get_pos (GtkCombo *combo,
gint *y, gint *y,
gint *height, gint *height,
gint *width); gint *width);
static void gtk_combo_popup_list (GtkButton *button, static void gtk_combo_popup_list (GtkCombo *combo);
GtkCombo *combo); static void gtk_combo_activate (GtkWidget *widget,
GtkCombo *combo);
static void gtk_combo_popup_button_press (GtkWidget *button,
GdkEventButton *event,
GtkCombo *combo);
static void gtk_combo_popup_button_leave (GtkWidget *button,
GdkEventCrossing *event,
GtkCombo *combo);
static void gtk_combo_update_entry (GtkList *list, static void gtk_combo_update_entry (GtkList *list,
GtkCombo *combo); GtkCombo *combo);
static void gtk_combo_update_list (GtkEntry *entry, static void gtk_combo_update_list (GtkEntry *entry,
...@@ -61,6 +68,9 @@ static void gtk_combo_update_list (GtkEntry *entry, ...@@ -61,6 +68,9 @@ static void gtk_combo_update_list (GtkEntry *entry,
static gint gtk_combo_button_press (GtkWidget *widget, static gint gtk_combo_button_press (GtkWidget *widget,
GdkEvent *event, GdkEvent *event,
GtkCombo *combo); GtkCombo *combo);
static gint gtk_combo_button_release (GtkWidget *widget,
GdkEvent *event,
GtkCombo *combo);
static gint gtk_combo_list_key_press (GtkWidget *widget, static gint gtk_combo_list_key_press (GtkWidget *widget,
GdkEventKey *event, GdkEventKey *event,
GtkCombo *combo); GtkCombo *combo);
...@@ -315,7 +325,7 @@ gtk_combo_get_pos (GtkCombo * combo, gint * x, gint * y, gint * height, gint * w ...@@ -315,7 +325,7 @@ gtk_combo_get_pos (GtkCombo * combo, gint * x, gint * y, gint * height, gint * w
} }
static void static void
gtk_combo_popup_list (GtkButton * button, GtkCombo * combo) gtk_combo_popup_list (GtkCombo * combo)
{ {
gint height, width, x, y; gint height, width, x, y;
gint old_width, old_height; gint old_width, old_height;
...@@ -342,6 +352,14 @@ gtk_combo_popup_list (GtkButton * button, GtkCombo * combo) ...@@ -342,6 +352,14 @@ gtk_combo_popup_list (GtkButton * button, GtkCombo * combo)
gtk_widget_show (combo->popwin); gtk_widget_show (combo->popwin);
gtk_widget_grab_focus (combo->popwin); gtk_widget_grab_focus (combo->popwin);
}
static void
gtk_combo_activate (GtkWidget *widget,
GtkCombo *combo)
{
gtk_combo_popup_list (combo);
gtk_grab_add (combo->popwin); gtk_grab_add (combo->popwin);
gdk_pointer_grab (combo->popwin->window, TRUE, gdk_pointer_grab (combo->popwin->window, TRUE,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_PRESS_MASK |
...@@ -350,15 +368,28 @@ gtk_combo_popup_list (GtkButton * button, GtkCombo * combo) ...@@ -350,15 +368,28 @@ gtk_combo_popup_list (GtkButton * button, GtkCombo * combo)
NULL, NULL, GDK_CURRENT_TIME); NULL, NULL, GDK_CURRENT_TIME);
} }
#if 0 static void
static void gtk_combo_popup_button_press (GtkWidget *button,
prelight_bug (GtkButton * b, GtkCombo * combo) GdkEventButton *event,
GtkCombo *combo)
{ {
/* avoid prelight state... */ if (!combo->current_button && (event->button == 1))
gtk_widget_set_state (combo->button, GTK_STATE_NORMAL); gtk_combo_popup_list (combo);
gtk_widget_event (combo->list, (GdkEvent *)event);
combo->current_button = event->button;
} }
#endif
static void
gtk_combo_popup_button_leave (GtkWidget *button,
GdkEventCrossing *event,
GtkCombo *combo)
{
if (combo->current_button)
gtk_signal_emit_stop_by_name (GTK_OBJECT (button), "leave_notify_event");
}
static void static void
gtk_combo_update_entry (GtkList * list, GtkCombo * combo) gtk_combo_update_entry (GtkList * list, GtkCombo * combo)
...@@ -374,9 +405,6 @@ gtk_combo_update_entry (GtkList * list, GtkCombo * combo) ...@@ -374,9 +405,6 @@ gtk_combo_update_entry (GtkList * list, GtkCombo * combo)
text = ""; text = "";
gtk_entry_set_text (GTK_ENTRY (combo->entry), text); gtk_entry_set_text (GTK_ENTRY (combo->entry), text);
} }
gtk_widget_hide (combo->popwin);
gtk_grab_remove (combo->popwin);
gdk_pointer_ungrab (GDK_CURRENT_TIME);
gtk_signal_handler_unblock (GTK_OBJECT (list), combo->list_change_id); gtk_signal_handler_unblock (GTK_OBJECT (list), combo->list_change_id);
} }
...@@ -424,7 +452,59 @@ gtk_combo_button_press (GtkWidget * widget, GdkEvent * event, GtkCombo * combo) ...@@ -424,7 +452,59 @@ gtk_combo_button_press (GtkWidget * widget, GdkEvent * event, GtkCombo * combo)
gtk_widget_hide (combo->popwin); gtk_widget_hide (combo->popwin);
gtk_grab_remove (combo->popwin); gtk_grab_remove (combo->popwin);
gdk_pointer_ungrab (GDK_CURRENT_TIME); gdk_pointer_ungrab (event->button.time);
return TRUE;
}
static gint
gtk_combo_button_release (GtkWidget * widget, GdkEvent * event, GtkCombo * combo)
{
GtkWidget *child;
if ((combo->current_button != 0) && (event->button.button == 1))
{
GdkEventCrossing tmp_event;
combo->current_button = 0;
gtk_widget_event (combo->button, event);
/* Un-pre-hightlight */
tmp_event.type = GDK_LEAVE_NOTIFY;
tmp_event.window = combo->button->window;
tmp_event.send_event = TRUE;
tmp_event.subwindow = NULL;
tmp_event.detail = GDK_NOTIFY_ANCESTOR;
gtk_widget_event (combo->button, (GdkEvent *)&tmp_event);
/* Check to see if we released inside the button */
child = gtk_get_event_widget ((GdkEvent*) event);
while (child && child != (combo->button))
child = child->parent;
if (child == combo->button)
{
gtk_grab_add (combo->popwin);
gdk_pointer_grab (combo->popwin->window, TRUE,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK,
NULL, NULL, GDK_CURRENT_TIME);
return FALSE;
}
}
else
{
gtk_grab_remove (combo->popwin);
gdk_pointer_ungrab (event->button.time);
}
gtk_widget_hide (combo->popwin);
return TRUE; return TRUE;
} }
...@@ -457,6 +537,7 @@ gtk_combo_init (GtkCombo * combo) ...@@ -457,6 +537,7 @@ gtk_combo_init (GtkCombo * combo)
combo->use_arrows_always = 0; combo->use_arrows_always = 0;
combo->entry = gtk_entry_new (); combo->entry = gtk_entry_new ();
combo->button = gtk_button_new (); combo->button = gtk_button_new ();
combo->current_button = 0;
arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT); arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
gtk_widget_show (arrow); gtk_widget_show (arrow);
gtk_container_add (GTK_CONTAINER (combo->button), arrow); gtk_container_add (GTK_CONTAINER (combo->button), arrow);
...@@ -471,9 +552,11 @@ gtk_combo_init (GtkCombo * combo) ...@@ -471,9 +552,11 @@ gtk_combo_init (GtkCombo * combo)
gtk_signal_connect_after (GTK_OBJECT (combo->entry), "focus_out_event", gtk_signal_connect_after (GTK_OBJECT (combo->entry), "focus_out_event",
(GtkSignalFunc) gtk_combo_entry_focus_out, combo); (GtkSignalFunc) gtk_combo_entry_focus_out, combo);
combo->activate_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "activate", combo->activate_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "activate",
(GtkSignalFunc) gtk_combo_popup_list, combo); (GtkSignalFunc) gtk_combo_activate, combo);
gtk_signal_connect (GTK_OBJECT (combo->button), "clicked", gtk_signal_connect_after (GTK_OBJECT (combo->button), "button_press_event",
(GtkSignalFunc) gtk_combo_popup_list, combo); (GtkSignalFunc) gtk_combo_popup_button_press, combo);
gtk_signal_connect (GTK_OBJECT (combo->button), "leave_notify_event",
(GtkSignalFunc) gtk_combo_popup_button_leave, combo);
/*gtk_signal_connect(GTK_OBJECT(combo->button), "clicked", /*gtk_signal_connect(GTK_OBJECT(combo->button), "clicked",
(GtkSignalFunc)prelight_bug, combo); */ (GtkSignalFunc)prelight_bug, combo); */
...@@ -514,7 +597,8 @@ gtk_combo_init (GtkCombo * combo) ...@@ -514,7 +597,8 @@ gtk_combo_init (GtkCombo * combo)
(GtkSignalFunc) gtk_combo_list_key_press, combo); (GtkSignalFunc) gtk_combo_list_key_press, combo);
gtk_signal_connect (GTK_OBJECT (combo->popwin), "button_press_event", gtk_signal_connect (GTK_OBJECT (combo->popwin), "button_press_event",
GTK_SIGNAL_FUNC (gtk_combo_button_press), combo); GTK_SIGNAL_FUNC (gtk_combo_button_press), combo);
gtk_signal_connect (GTK_OBJECT (combo->popwin), "button_release_event",
GTK_SIGNAL_FUNC (gtk_combo_button_release), combo);
} }
guint guint
......
...@@ -53,6 +53,7 @@ struct _GtkCombo { ...@@ -53,6 +53,7 @@ struct _GtkCombo {
guint use_arrows:1; guint use_arrows:1;
guint use_arrows_always:1; guint use_arrows_always:1;
guint16 current_button;
guint activate_id; guint activate_id;
}; };
......
...@@ -28,11 +28,15 @@ enum { ...@@ -28,11 +28,15 @@ enum {
}; };
static void gtk_item_class_init (GtkItemClass *klass); static void gtk_item_class_init (GtkItemClass *klass);
static void gtk_item_init (GtkItem *item); static void gtk_item_init (GtkItem *item);
static void gtk_item_map (GtkWidget *widget); static void gtk_item_map (GtkWidget *widget);
static void gtk_item_unmap (GtkWidget *widget); static void gtk_item_unmap (GtkWidget *widget);
static void gtk_item_realize (GtkWidget *widget); static void gtk_item_realize (GtkWidget *widget);
static gint gtk_item_enter (GtkWidget *widget,
GdkEventCrossing *event);
static gint gtk_item_leave (GtkWidget *widget,
GdkEventCrossing *event);
static guint item_signals[LAST_SIGNAL] = { 0 }; static guint item_signals[LAST_SIGNAL] = { 0 };
...@@ -99,6 +103,8 @@ gtk_item_class_init (GtkItemClass *class) ...@@ -99,6 +103,8 @@ gtk_item_class_init (GtkItemClass *class)
widget_class->map = gtk_item_map; widget_class->map = gtk_item_map;
widget_class->unmap = gtk_item_unmap; widget_class->unmap = gtk_item_unmap;
widget_class->realize = gtk_item_realize; widget_class->realize = gtk_item_realize;
widget_class->enter_notify_event = gtk_item_enter;
widget_class->leave_notify_event = gtk_item_leave;
class->select = NULL; class->select = NULL;
class->deselect = NULL; class->deselect = NULL;
...@@ -192,3 +198,26 @@ gtk_item_realize (GtkWidget *widget) ...@@ -192,3 +198,26 @@ gtk_item_realize (GtkWidget *widget)
widget->style = gtk_style_attach (widget->style, widget->window); widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
} }
static gint
gtk_item_enter (GtkWidget *widget,
GdkEventCrossing *event)
{
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
return gtk_widget_event (widget->parent, (GdkEvent*) event);
}
static gint
gtk_item_leave (GtkWidget *widget,
GdkEventCrossing *event)
{
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
return gtk_widget_event (widget->parent, (GdkEvent*) event);
}
...@@ -45,8 +45,8 @@ static void gtk_list_draw (GtkWidget *widget, ...@@ -45,8 +45,8 @@ static void gtk_list_draw (GtkWidget *widget,
GdkRectangle *area); GdkRectangle *area);
static gint gtk_list_expose (GtkWidget *widget, static gint gtk_list_expose (GtkWidget *widget,
GdkEventExpose *event); GdkEventExpose *event);
static gint gtk_list_motion_notify (GtkWidget *widget, static gint gtk_list_enter_notify (GtkWidget *widget,
GdkEventMotion *event); GdkEventCrossing *event);
static gint gtk_list_button_press (GtkWidget *widget, static gint gtk_list_button_press (GtkWidget *widget,
GdkEventButton *event); GdkEventButton *event);
static gint gtk_list_button_release (GtkWidget *widget, static gint gtk_list_button_release (GtkWidget *widget,
...@@ -148,9 +148,9 @@ gtk_list_class_init (GtkListClass *class) ...@@ -148,9 +148,9 @@ gtk_list_class_init (GtkListClass *class)
widget_class->realize = gtk_list_realize; widget_class->realize = gtk_list_realize;
widget_class->draw = gtk_list_draw; widget_class->draw = gtk_list_draw;
widget_class->expose_event = gtk_list_expose; widget_class->expose_event = gtk_list_expose;
widget_class->motion_notify_event = gtk_list_motion_notify;
widget_class->button_press_event = gtk_list_button_press; widget_class->button_press_event = gtk_list_button_press;
widget_class->button_release_event = gtk_list_button_release; widget_class->button_release_event = gtk_list_button_release;
widget_class->enter_notify_event = gtk_list_enter_notify;
widget_class->size_request = gtk_list_size_request; widget_class->size_request = gtk_list_size_request;
widget_class->size_allocate = gtk_list_size_allocate; widget_class->size_allocate = gtk_list_size_allocate;
...@@ -173,7 +173,7 @@ gtk_list_init (GtkList *list) ...@@ -173,7 +173,7 @@ gtk_list_init (GtkList *list)
list->selection_end_pos = 0; list->selection_end_pos = 0;
list->selection_mode = GTK_SELECTION_SINGLE; list->selection_mode = GTK_SELECTION_SINGLE;
list->scroll_direction = 0; list->scroll_direction = 0;
list->have_grab = FALSE; list->button = 0;
} }
GtkWidget* GtkWidget*
...@@ -673,14 +673,27 @@ gtk_list_expose (GtkWidget *widget, ...@@ -673,14 +673,27 @@ gtk_list_expose (GtkWidget *widget,
} }
static gint static gint
gtk_list_motion_notify (GtkWidget *widget, gtk_list_enter_notify (GtkWidget *widget,
GdkEventMotion *event) GdkEventCrossing *event)
{ {
GtkList *list;
GtkWidget *item;
g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_LIST (widget), FALSE); g_return_val_if_fail (GTK_IS_LIST (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE); g_return_val_if_fail (event != NULL, FALSE);
/* g_print ("gtk_list_motion_notify\n"); */ list = GTK_LIST (widget);
item = gtk_get_event_widget ((GdkEvent*) event);
if (!list->button)
return FALSE;
while (item && !GTK_IS_LIST_ITEM (item))
item = item->parent;
if (item && (item->parent == widget))
gtk_list_select_child (list, item);
return FALSE; return FALSE;
} }
...@@ -698,14 +711,22 @@ gtk_list_button_press (GtkWidget *widget, ...@@ -698,14 +711,22 @@ gtk_list_button_press (GtkWidget *widget,
list = GTK_LIST (widget); list = GTK_LIST (widget);
item = gtk_get_event_widget ((GdkEvent*) event); item = gtk_get_event_widget ((GdkEvent*) event);
if (list->button && (list->button != event->button))
return FALSE;
list->button = event->button;
while (item && !GTK_IS_LIST_ITEM (item)) while (item && !GTK_IS_LIST_ITEM (item))
item = item->parent; item = item->parent;
if (!item || (item->parent != widget)) if (item && (item->parent == widget))
return FALSE; gtk_list_select_child (list, item);