small combo box UI patch
- From: <nuke bayside net>
- To: gtk-list redhat com
- Subject: small combo box UI patch
- Date: Fri, 15 May 1998 02:22:47 -0400 (EDT)
this is kinda flaky, and most likely buggy too.. but It Works For Me(tm).
i think this is veryuseful thing for comboboxes (apply it and see what
i mean)
if anyone knows of a better way to do this, please clue me in.
--------------------------->8 cut here 8<-------------------------
--- gtkcombo.c Fri May 15 01:57:53 1998
+++ gtkcombo-new.c Fri May 15 01:54:35 1998
@@ -61,6 +61,9 @@
static gint gtk_combo_button_press (GtkWidget *widget,
GdkEvent *event,
GtkCombo *combo);
+static gint gtk_combo_button_release (GtkWidget *widget,
+ GdkEvent *event,
+ GtkCombo *combo);
static gint gtk_combo_list_key_press (GtkWidget *widget,
GdkEventKey *event,
GtkCombo *combo);
@@ -374,8 +377,6 @@
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);
}
@@ -429,6 +430,34 @@
return TRUE;
}
+static gint
+gtk_combo_button_release (GtkWidget * widget, GdkEvent * event, GtkCombo * combo)
+{
+ GtkWidget *child;
+ gint i;
+
+ child = gtk_get_event_widget (event);
+
+ if (child != widget)
+ {
+ for (i=0;child;i++)
+ {
+ /* If the child has 6 parents, we can safely assume it's
+ * the listitem, in which case the pop window can be closed.
+ */
+ if ((child==widget) && (i==6))
+ {
+ gtk_widget_hide (combo->popwin);
+ gtk_grab_remove (combo->popwin);
+ return TRUE;
+ }
+ child = child->parent;
+ }
+ }
+
+ return FALSE;
+}
+
static int
gtk_combo_list_key_press (GtkWidget * widget, GdkEventKey * event, GtkCombo * combo)
{
@@ -514,6 +544,8 @@
(GtkSignalFunc) gtk_combo_list_key_press, combo);
gtk_signal_connect (GTK_OBJECT (combo->popwin), "button_press_event",
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);
}
--------------------------->8 cut here 8<-------------------------
_ _ __ __ _ _ _
| / |/ /_ __/ /_____ | Nuke Skyjumper |
| / / // / '_/ -_) | "Master of the Farce" |
|_ /_/|_/\_,_/_/\_\\__/ _|_ nuke@bayside.net _|
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]