1998-01-20 21:40:38 +00:00
|
|
|
/* gtkcombo - combo widget for gtk+
|
|
|
|
* Copyright 1997 Paolo Molaro
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
1998-04-13 02:02:47 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
1998-01-20 21:40:38 +00:00
|
|
|
*/
|
|
|
|
|
1999-02-24 07:37:18 +00:00
|
|
|
/*
|
|
|
|
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "gtkarrow.h"
|
|
|
|
#include "gtklabel.h"
|
|
|
|
#include "gtklist.h"
|
|
|
|
#include "gtkentry.h"
|
1998-03-24 05:27:00 +00:00
|
|
|
#include "gtkeventbox.h"
|
1998-01-20 21:40:38 +00:00
|
|
|
#include "gtkbutton.h"
|
|
|
|
#include "gtklistitem.h"
|
|
|
|
#include "gtkscrolledwindow.h"
|
|
|
|
#include "gtkmain.h"
|
|
|
|
#include "gtksignal.h"
|
|
|
|
#include "gtkwindow.h"
|
|
|
|
#include "gdk/gdkkeysyms.h"
|
|
|
|
#include "gtkcombo.h"
|
1998-03-13 17:45:16 +00:00
|
|
|
#include "gtkframe.h"
|
1998-01-20 21:40:38 +00:00
|
|
|
|
1998-02-02 14:11:24 +00:00
|
|
|
const gchar *gtk_combo_string_key = "gtk-combo-string-value";
|
1998-01-20 21:40:38 +00:00
|
|
|
|
1998-05-02 04:20:55 +00:00
|
|
|
#define COMBO_LIST_MAX_HEIGHT (400)
|
|
|
|
#define EMPTY_LIST_HEIGHT (15)
|
1998-01-20 21:40:38 +00:00
|
|
|
|
|
|
|
static void gtk_combo_class_init (GtkComboClass *klass);
|
|
|
|
static void gtk_combo_init (GtkCombo *combo);
|
|
|
|
static void gtk_combo_destroy (GtkObject *combo);
|
|
|
|
static GtkListItem *gtk_combo_find (GtkCombo *combo);
|
|
|
|
static gchar * gtk_combo_func (GtkListItem *li);
|
|
|
|
static gint gtk_combo_focus_idle (GtkCombo *combo);
|
|
|
|
static gint gtk_combo_entry_focus_out (GtkEntry *entry,
|
|
|
|
GdkEventFocus *event,
|
|
|
|
GtkCombo *combo);
|
|
|
|
static void gtk_combo_get_pos (GtkCombo *combo,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *height,
|
|
|
|
gint *width);
|
1998-04-30 15:18:19 +00:00
|
|
|
static void gtk_combo_popup_list (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);
|
1998-01-20 21:40:38 +00:00
|
|
|
static void gtk_combo_update_entry (GtkList *list,
|
|
|
|
GtkCombo *combo);
|
|
|
|
static void gtk_combo_update_list (GtkEntry *entry,
|
|
|
|
GtkCombo *combo);
|
|
|
|
static gint gtk_combo_button_press (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GtkCombo *combo);
|
1998-04-30 15:18:19 +00:00
|
|
|
static gint gtk_combo_button_release (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GtkCombo *combo);
|
1998-05-01 19:39:27 +00:00
|
|
|
static gint gtk_combo_list_enter (GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event,
|
|
|
|
GtkCombo *combo);
|
1998-01-20 21:40:38 +00:00
|
|
|
static gint gtk_combo_list_key_press (GtkWidget *widget,
|
|
|
|
GdkEventKey *event,
|
|
|
|
GtkCombo *combo);
|
|
|
|
static gint gtk_combo_entry_key_press (GtkEntry *widget,
|
|
|
|
GdkEventKey *event,
|
|
|
|
GtkCombo *combo);
|
|
|
|
static void gtk_combo_item_destroy (GtkObject *object);
|
1998-03-13 17:45:16 +00:00
|
|
|
static void gtk_combo_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation);
|
1998-01-20 21:40:38 +00:00
|
|
|
|
|
|
|
static GtkHBoxClass *parent_class = NULL;
|
|
|
|
|
1998-03-17 19:03:52 +00:00
|
|
|
static void
|
1998-01-20 21:40:38 +00:00
|
|
|
gtk_combo_class_init (GtkComboClass * klass)
|
|
|
|
{
|
|
|
|
GtkObjectClass *oclass;
|
1998-03-13 17:45:16 +00:00
|
|
|
GtkWidgetClass *widget_class;
|
1998-01-20 21:40:38 +00:00
|
|
|
|
|
|
|
parent_class = gtk_type_class (gtk_hbox_get_type ());
|
|
|
|
oclass = (GtkObjectClass *) klass;
|
1998-03-13 17:45:16 +00:00
|
|
|
widget_class = (GtkWidgetClass *) klass;
|
1998-01-20 21:40:38 +00:00
|
|
|
|
|
|
|
oclass->destroy = gtk_combo_destroy;
|
1998-03-13 17:45:16 +00:00
|
|
|
|
|
|
|
widget_class->size_allocate = gtk_combo_size_allocate;
|
1998-01-20 21:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_destroy (GtkObject * combo)
|
|
|
|
{
|
1998-02-02 14:11:24 +00:00
|
|
|
gtk_widget_destroy (GTK_COMBO (combo)->popwin);
|
|
|
|
gtk_widget_unref (GTK_COMBO (combo)->popwin);
|
1998-01-20 21:40:38 +00:00
|
|
|
|
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
(*GTK_OBJECT_CLASS (parent_class)->destroy) (combo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gtk_combo_entry_key_press (GtkEntry * entry, GdkEventKey * event, GtkCombo * combo)
|
|
|
|
{
|
|
|
|
GList *li;
|
1998-05-01 13:16:49 +00:00
|
|
|
|
1998-05-19 10:17:31 +00:00
|
|
|
/* completion */
|
1998-10-14 09:07:18 +00:00
|
|
|
if ((event->keyval == GDK_Tab) && (event->state & GDK_MOD1_MASK))
|
1998-06-09 23:18:11 +00:00
|
|
|
{
|
1998-05-19 10:17:31 +00:00
|
|
|
GCompletion * cmpl;
|
|
|
|
gchar* prefix;
|
|
|
|
gchar* nprefix = NULL;
|
1998-06-09 23:18:11 +00:00
|
|
|
gint pos;
|
1998-10-14 09:07:18 +00:00
|
|
|
|
1999-01-21 00:37:48 +00:00
|
|
|
if ( !GTK_LIST (combo->list)->children )
|
1998-10-14 09:07:18 +00:00
|
|
|
return FALSE;
|
1998-05-19 10:17:31 +00:00
|
|
|
|
|
|
|
gtk_signal_emit_stop_by_name (GTK_OBJECT (entry), "key_press_event");
|
1999-01-21 00:37:48 +00:00
|
|
|
|
|
|
|
cmpl = g_completion_new ((GCompletionFunc)gtk_combo_func);
|
|
|
|
g_completion_add_items (cmpl, GTK_LIST (combo->list)->children);
|
|
|
|
|
|
|
|
pos = GTK_EDITABLE (entry)->current_pos;
|
|
|
|
prefix = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, pos);
|
|
|
|
|
1998-05-19 10:17:31 +00:00
|
|
|
g_completion_complete(cmpl, prefix, &nprefix);
|
1999-01-21 00:37:48 +00:00
|
|
|
|
|
|
|
if (nprefix && strlen (nprefix) > strlen (prefix))
|
1998-06-09 23:18:11 +00:00
|
|
|
{
|
1999-01-21 00:37:48 +00:00
|
|
|
gtk_editable_insert_text (GTK_EDITABLE (entry), nprefix + pos,
|
|
|
|
strlen (nprefix) - strlen (prefix), &pos);
|
|
|
|
GTK_EDITABLE (entry)->current_pos = pos;
|
1998-05-19 10:17:31 +00:00
|
|
|
}
|
1999-01-21 00:37:48 +00:00
|
|
|
|
|
|
|
if (nprefix)
|
|
|
|
g_free (nprefix);
|
|
|
|
g_free (prefix);
|
|
|
|
g_completion_free (cmpl);
|
|
|
|
|
1998-05-19 10:17:31 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
1999-01-21 00:37:48 +00:00
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
if (!combo->use_arrows || !GTK_LIST (combo->list)->children)
|
|
|
|
return FALSE;
|
1999-01-21 00:37:48 +00:00
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
li = g_list_find (GTK_LIST (combo->list)->children, gtk_combo_find (combo));
|
|
|
|
|
1998-02-19 20:22:51 +00:00
|
|
|
if ((event->keyval == GDK_Up)
|
|
|
|
|| (event->keyval == GDK_KP_Up)
|
|
|
|
|| ((event->state & GDK_MOD1_MASK) && ((event->keyval == 'p') || (event->keyval == 'P'))))
|
1998-01-20 21:40:38 +00:00
|
|
|
{
|
|
|
|
if (li)
|
|
|
|
li = li->prev;
|
|
|
|
if (!li && combo->use_arrows_always)
|
|
|
|
{
|
|
|
|
li = g_list_last (GTK_LIST (combo->list)->children);
|
|
|
|
}
|
|
|
|
if (li)
|
|
|
|
{
|
|
|
|
gtk_list_select_child (GTK_LIST (combo->list), GTK_WIDGET (li->data));
|
|
|
|
gtk_signal_emit_stop_by_name (GTK_OBJECT (entry), "key_press_event");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
1998-02-19 20:22:51 +00:00
|
|
|
else if ((event->keyval == GDK_Down)
|
|
|
|
|| (event->keyval == GDK_KP_Down)
|
|
|
|
|| ((event->state & GDK_MOD1_MASK) && ((event->keyval == 'n') || (event->keyval == 'N'))))
|
1998-01-20 21:40:38 +00:00
|
|
|
{
|
|
|
|
if (li)
|
|
|
|
li = li->next;
|
|
|
|
if (!li && combo->use_arrows_always)
|
|
|
|
{
|
|
|
|
li = GTK_LIST (combo->list)->children;
|
|
|
|
}
|
|
|
|
if (li)
|
|
|
|
{
|
|
|
|
gtk_list_select_child (GTK_LIST (combo->list), GTK_WIDGET (li->data));
|
|
|
|
gtk_signal_emit_stop_by_name (GTK_OBJECT (entry), "key_press_event");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkListItem *
|
|
|
|
gtk_combo_find (GtkCombo * combo)
|
|
|
|
{
|
|
|
|
gchar *text;
|
|
|
|
gchar *ltext;
|
|
|
|
GList *clist;
|
|
|
|
int (*string_compare) (const char *, const char *);
|
|
|
|
|
|
|
|
if (combo->case_sensitive)
|
|
|
|
string_compare = strcmp;
|
|
|
|
else
|
1998-03-02 23:16:39 +00:00
|
|
|
string_compare = g_strcasecmp;
|
1998-01-20 21:40:38 +00:00
|
|
|
|
|
|
|
text = gtk_entry_get_text (GTK_ENTRY (combo->entry));
|
|
|
|
clist = GTK_LIST (combo->list)->children;
|
|
|
|
|
|
|
|
while (clist && clist->data)
|
|
|
|
{
|
|
|
|
ltext = gtk_combo_func (GTK_LIST_ITEM (clist->data));
|
|
|
|
if (!ltext)
|
|
|
|
continue;
|
|
|
|
if (!(*string_compare) (ltext, text))
|
|
|
|
return (GtkListItem *) clist->data;
|
|
|
|
clist = clist->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gtk_combo_func (GtkListItem * li)
|
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
gchar *ltext = NULL;
|
|
|
|
|
|
|
|
ltext = (gchar *) gtk_object_get_data (GTK_OBJECT (li), gtk_combo_string_key);
|
|
|
|
if (!ltext)
|
|
|
|
{
|
|
|
|
label = GTK_BIN (li)->child;
|
|
|
|
if (!label || !GTK_IS_LABEL (label))
|
|
|
|
return NULL;
|
|
|
|
gtk_label_get (GTK_LABEL (label), <ext);
|
|
|
|
}
|
|
|
|
return ltext;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_combo_focus_idle (GtkCombo * combo)
|
|
|
|
{
|
|
|
|
if (combo)
|
1998-12-15 07:32:11 +00:00
|
|
|
{
|
1998-12-16 20:09:30 +00:00
|
|
|
GDK_THREADS_ENTER ();
|
1998-12-15 07:32:11 +00:00
|
|
|
gtk_widget_grab_focus (combo->entry);
|
1998-12-16 20:09:30 +00:00
|
|
|
GDK_THREADS_LEAVE ();
|
1998-12-15 07:32:11 +00:00
|
|
|
}
|
1998-01-20 21:40:38 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_combo_entry_focus_out (GtkEntry * entry, GdkEventFocus * event, GtkCombo * combo)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (combo->value_in_list && !gtk_combo_find (combo))
|
|
|
|
{
|
|
|
|
/* gdk_beep(); *//* this can be annoying */
|
|
|
|
if (combo->ok_if_empty && !strcmp (gtk_entry_get_text (entry), ""))
|
|
|
|
return FALSE;
|
|
|
|
#ifdef TEST
|
|
|
|
printf ("INVALID ENTRY: `%s'\n", gtk_entry_get_text (entry));
|
|
|
|
#endif
|
|
|
|
gtk_grab_add (GTK_WIDGET (combo));
|
|
|
|
/* this is needed because if we call gtk_widget_grab_focus()
|
|
|
|
it isn't guaranteed it's the *last* call before the main-loop,
|
|
|
|
so the focus can be lost anyway...
|
|
|
|
the signal_emit_stop doesn't seem to work either...
|
|
|
|
*/
|
|
|
|
gtk_idle_add ((GtkFunction) gtk_combo_focus_idle, combo);
|
1998-05-02 04:20:55 +00:00
|
|
|
/*gtk_signal_emit_stop_by_name (GTK_OBJECT (entry), "focus_out_event"); */
|
1998-01-20 21:40:38 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_get_pos (GtkCombo * combo, gint * x, gint * y, gint * height, gint * width)
|
|
|
|
{
|
1998-03-13 17:45:16 +00:00
|
|
|
GtkBin *popwin;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkScrolledWindow *popup;
|
1998-05-02 04:20:55 +00:00
|
|
|
|
1998-03-13 17:45:16 +00:00
|
|
|
gint real_height;
|
|
|
|
GtkRequisition list_requisition;
|
|
|
|
gboolean show_hscroll = FALSE;
|
|
|
|
gboolean show_vscroll = FALSE;
|
|
|
|
gint avail_height;
|
|
|
|
gint min_height;
|
|
|
|
gint alloc_width;
|
|
|
|
gint work_height;
|
|
|
|
gint old_height;
|
|
|
|
gint old_width;
|
1998-05-02 04:20:55 +00:00
|
|
|
|
1998-03-13 17:45:16 +00:00
|
|
|
widget = GTK_WIDGET(combo);
|
|
|
|
popup = GTK_SCROLLED_WINDOW (combo->popup);
|
|
|
|
popwin = GTK_BIN (combo->popwin);
|
1998-05-02 04:20:55 +00:00
|
|
|
|
1998-03-13 17:45:16 +00:00
|
|
|
gdk_window_get_origin (combo->entry->window, x, y);
|
|
|
|
real_height = MIN (combo->entry->requisition.height,
|
|
|
|
combo->entry->allocation.height);
|
|
|
|
*y += real_height;
|
|
|
|
avail_height = gdk_screen_height () - *y;
|
1998-05-02 04:20:55 +00:00
|
|
|
|
1998-03-13 17:45:16 +00:00
|
|
|
gtk_widget_size_request (combo->list, &list_requisition);
|
|
|
|
min_height = MIN (list_requisition.height,
|
|
|
|
popup->vscrollbar->requisition.height);
|
1998-05-02 04:20:55 +00:00
|
|
|
if (!GTK_LIST (combo->list)->children)
|
|
|
|
list_requisition.height += EMPTY_LIST_HEIGHT;
|
|
|
|
|
|
|
|
alloc_width = (widget->allocation.width -
|
|
|
|
2 * popwin->child->style->klass->xthickness -
|
|
|
|
2 * GTK_CONTAINER (popwin->child)->border_width -
|
|
|
|
2 * GTK_CONTAINER (combo->popup)->border_width -
|
1998-11-28 07:42:37 +00:00
|
|
|
2 * GTK_CONTAINER (GTK_BIN (popup)->child)->border_width -
|
|
|
|
2 * GTK_BIN (popup)->child->style->klass->xthickness);
|
1998-05-02 04:20:55 +00:00
|
|
|
|
|
|
|
work_height = (2 * popwin->child->style->klass->ythickness +
|
|
|
|
2 * GTK_CONTAINER (popwin->child)->border_width +
|
|
|
|
2 * GTK_CONTAINER (combo->popup)->border_width +
|
1998-11-28 07:42:37 +00:00
|
|
|
2 * GTK_CONTAINER (GTK_BIN (popup)->child)->border_width +
|
|
|
|
2 * GTK_BIN (popup)->child->style->klass->xthickness);
|
1998-05-02 04:20:55 +00:00
|
|
|
|
1998-03-13 17:45:16 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
old_width = alloc_width;
|
|
|
|
old_height = work_height;
|
1998-05-02 04:20:55 +00:00
|
|
|
|
1998-03-13 17:45:16 +00:00
|
|
|
if (!show_hscroll &&
|
|
|
|
alloc_width < list_requisition.width)
|
|
|
|
{
|
|
|
|
work_height += popup->hscrollbar->requisition.height +
|
|
|
|
GTK_SCROLLED_WINDOW_CLASS
|
|
|
|
(GTK_OBJECT (combo->popup)->klass)->scrollbar_spacing;
|
|
|
|
show_hscroll = TRUE;
|
|
|
|
}
|
|
|
|
if (!show_vscroll &&
|
|
|
|
work_height + list_requisition.height > avail_height)
|
|
|
|
{
|
|
|
|
if (work_height + min_height > avail_height &&
|
|
|
|
*y - real_height > avail_height)
|
|
|
|
{
|
1998-05-02 04:20:55 +00:00
|
|
|
*y -= (work_height + list_requisition.height + real_height);
|
1998-03-13 17:45:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
alloc_width -=
|
|
|
|
popup->vscrollbar->requisition.width +
|
|
|
|
GTK_SCROLLED_WINDOW_CLASS
|
|
|
|
(GTK_OBJECT (combo->popup)->klass)->scrollbar_spacing;
|
|
|
|
show_vscroll = TRUE;
|
|
|
|
}
|
|
|
|
} while (old_width != alloc_width || old_height != work_height);
|
1998-05-02 04:20:55 +00:00
|
|
|
|
1998-03-13 17:45:16 +00:00
|
|
|
*width = widget->allocation.width;
|
|
|
|
if (show_vscroll)
|
1998-05-02 04:20:55 +00:00
|
|
|
*height = avail_height;
|
1998-03-13 17:45:16 +00:00
|
|
|
else
|
|
|
|
*height = work_height + list_requisition.height;
|
|
|
|
|
|
|
|
if (*x < 0)
|
|
|
|
*x = 0;
|
1998-01-20 21:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-04-30 15:18:19 +00:00
|
|
|
gtk_combo_popup_list (GtkCombo * combo)
|
1998-01-20 21:40:38 +00:00
|
|
|
{
|
|
|
|
gint height, width, x, y;
|
1998-03-13 17:45:16 +00:00
|
|
|
gint old_width, old_height;
|
1998-01-20 21:40:38 +00:00
|
|
|
|
1998-03-13 17:45:16 +00:00
|
|
|
old_width = combo->popwin->allocation.width;
|
|
|
|
old_height = combo->popwin->allocation.height;
|
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
gtk_combo_get_pos (combo, &x, &y, &height, &width);
|
|
|
|
|
1998-03-13 17:45:16 +00:00
|
|
|
/* workaround for gtk_scrolled_window_size_allocate bug */
|
|
|
|
if (old_width != width || old_height != height)
|
|
|
|
{
|
|
|
|
gtk_widget_hide (GTK_SCROLLED_WINDOW (combo->popup)->hscrollbar);
|
|
|
|
gtk_widget_hide (GTK_SCROLLED_WINDOW (combo->popup)->vscrollbar);
|
|
|
|
}
|
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
gtk_widget_set_uposition (combo->popwin, x, y);
|
|
|
|
gtk_widget_set_usize (combo->popwin, width, height);
|
|
|
|
gtk_widget_realize (combo->popwin);
|
|
|
|
gdk_window_resize (combo->popwin->window, width, height);
|
|
|
|
gtk_widget_show (combo->popwin);
|
1998-03-13 17:45:16 +00:00
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
gtk_widget_grab_focus (combo->popwin);
|
1998-04-30 15:18:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_activate (GtkWidget *widget,
|
|
|
|
GtkCombo *combo)
|
|
|
|
{
|
|
|
|
gtk_combo_popup_list (combo);
|
|
|
|
|
1998-05-02 04:20:55 +00:00
|
|
|
if (!GTK_WIDGET_HAS_FOCUS (combo->entry))
|
|
|
|
gtk_widget_grab_focus (combo->entry);
|
Few fixes for column resize. Store resize column in clist->drag_pos.
Fri Jul 31 20:45:07 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (gtk_clist_button_press) (gtk_clist_motion)
(gtk_clist_button_release) (new_column_width): Few fixes for
column resize. Store resize column in clist->drag_pos.
Thu Jul 31 15:18:36 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h
* gtk/gtkctree.c
* gtk/testgtk.c : New typedef GtkCTreeNode, changed all GList *node
to GtkCTreeNode *node.
* gtk/gtklist.h : added extended selection mode and auto scrolling.
(struct _GtkList): removed unneeded variables timer, button,
selection_start_pos, selection_end_pos, scroll_direction, have_grab.
Added new variables undo_selection, undo_unselection, last_focus_child,
undo_focus_child, htimer, vtimer, anchor, drag_pos, anchor_state,
drag_selection, add_mode.
New functions :
(gtk_list_extend_selection), (gtk_list_start_selection),
(gtk_list_end_selection), (gtk_list_select_all),
(gtk_list_unselect_all), (gtk_list_scroll_horizontal),
(gtk_list_scroll_vertical), (gtk_list_toggle_add_mode),
(gtk_list_toggle_focus_row), (gtk_list_toggle_row),
(gtk_list_undo_selection), (gtk_list_end_drag_selection)
* gtk/gtklist.c :
(gtk_list_enter_notify): removed, because auto scrolling now works
with gtk_list_motion_notify
New functions, needed for auto scrolling :
(gtk_list_motion_notify) (gtk_list_move_focus_child)
New functions for extended selection support :
(gtk_list_set_anchor), (gtk_list_fake_unselect_all),
(gtk_list_fake_toggle_row), (gtk_list_update_extended_selection),
(gtk_list_focus_lost)
(gtk_list_set_focus_child): modified gtk_container_set_focus_child
function to support auto scrolling, and avoid out-of-sync errors in
case auf GTK_SELECTION_BROWSE
(gtk_list_focus): modified gtk_container_focus function to avoid out
off sync errors in case auf GTK_SELECTION_EXTENDED
* gtk/gtklistitem.h
* gtk/gtklistitem.c :
New signal functions for key binding support :
(toggle_focus_row), (select_all), (list_item), (unselect_all)
(list_item), (undo_selection), (start_selection), (end_selection)
(extend_selection), (scroll_horizontal), (scroll_vertical),
(toggle_add_mode)
(gtk_list_item_realize): added GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK
(gtk_list_item_draw_focus): modify gc if parent has add_mode set.
* gtk/gtkcombo.c :
(gtk_combo_popup_button_press): grab pointer for combo->list
(gtk_combo_button_release): ungrab only if combo->popwin HAS_GRAB
(gtk_combo_list_key_press): take care of which child HAS_GRAB
(gtk_comb_init): don't connect combo->button with button_release_event
1998-07-31 20:48:06 +00:00
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
gtk_grab_add (combo->popwin);
|
|
|
|
gdk_pointer_grab (combo->popwin->window, TRUE,
|
1998-03-24 05:27:00 +00:00
|
|
|
GDK_BUTTON_PRESS_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK |
|
|
|
|
GDK_POINTER_MOTION_MASK,
|
|
|
|
NULL, NULL, GDK_CURRENT_TIME);
|
1998-01-20 21:40:38 +00:00
|
|
|
}
|
|
|
|
|
1998-04-30 15:18:19 +00:00
|
|
|
static void
|
|
|
|
gtk_combo_popup_button_press (GtkWidget *button,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GtkCombo *combo)
|
1998-01-20 21:40:38 +00:00
|
|
|
{
|
1998-05-02 04:20:55 +00:00
|
|
|
if (!GTK_WIDGET_HAS_FOCUS (combo->entry))
|
|
|
|
gtk_widget_grab_focus (combo->entry);
|
1998-04-30 15:18:19 +00:00
|
|
|
if (!combo->current_button && (event->button == 1))
|
|
|
|
gtk_combo_popup_list (combo);
|
|
|
|
|
|
|
|
combo->current_button = event->button;
|
Few fixes for column resize. Store resize column in clist->drag_pos.
Fri Jul 31 20:45:07 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (gtk_clist_button_press) (gtk_clist_motion)
(gtk_clist_button_release) (new_column_width): Few fixes for
column resize. Store resize column in clist->drag_pos.
Thu Jul 31 15:18:36 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h
* gtk/gtkctree.c
* gtk/testgtk.c : New typedef GtkCTreeNode, changed all GList *node
to GtkCTreeNode *node.
* gtk/gtklist.h : added extended selection mode and auto scrolling.
(struct _GtkList): removed unneeded variables timer, button,
selection_start_pos, selection_end_pos, scroll_direction, have_grab.
Added new variables undo_selection, undo_unselection, last_focus_child,
undo_focus_child, htimer, vtimer, anchor, drag_pos, anchor_state,
drag_selection, add_mode.
New functions :
(gtk_list_extend_selection), (gtk_list_start_selection),
(gtk_list_end_selection), (gtk_list_select_all),
(gtk_list_unselect_all), (gtk_list_scroll_horizontal),
(gtk_list_scroll_vertical), (gtk_list_toggle_add_mode),
(gtk_list_toggle_focus_row), (gtk_list_toggle_row),
(gtk_list_undo_selection), (gtk_list_end_drag_selection)
* gtk/gtklist.c :
(gtk_list_enter_notify): removed, because auto scrolling now works
with gtk_list_motion_notify
New functions, needed for auto scrolling :
(gtk_list_motion_notify) (gtk_list_move_focus_child)
New functions for extended selection support :
(gtk_list_set_anchor), (gtk_list_fake_unselect_all),
(gtk_list_fake_toggle_row), (gtk_list_update_extended_selection),
(gtk_list_focus_lost)
(gtk_list_set_focus_child): modified gtk_container_set_focus_child
function to support auto scrolling, and avoid out-of-sync errors in
case auf GTK_SELECTION_BROWSE
(gtk_list_focus): modified gtk_container_focus function to avoid out
off sync errors in case auf GTK_SELECTION_EXTENDED
* gtk/gtklistitem.h
* gtk/gtklistitem.c :
New signal functions for key binding support :
(toggle_focus_row), (select_all), (list_item), (unselect_all)
(list_item), (undo_selection), (start_selection), (end_selection)
(extend_selection), (scroll_horizontal), (scroll_vertical),
(toggle_add_mode)
(gtk_list_item_realize): added GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK
(gtk_list_item_draw_focus): modify gc if parent has add_mode set.
* gtk/gtkcombo.c :
(gtk_combo_popup_button_press): grab pointer for combo->list
(gtk_combo_button_release): ungrab only if combo->popwin HAS_GRAB
(gtk_combo_list_key_press): take care of which child HAS_GRAB
(gtk_comb_init): don't connect combo->button with button_release_event
1998-07-31 20:48:06 +00:00
|
|
|
|
|
|
|
GTK_LIST (combo->list)->drag_selection = TRUE;
|
|
|
|
gdk_pointer_grab (combo->list->window, TRUE,
|
|
|
|
GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON1_MOTION_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK,
|
|
|
|
NULL, NULL, event->time);
|
|
|
|
gtk_grab_add (combo->list);
|
1998-01-20 21:40:38 +00:00
|
|
|
}
|
1998-04-30 15:18:19 +00:00
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_update_entry (GtkList * list, GtkCombo * combo)
|
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
gtk_grab_remove (GTK_WIDGET (combo));
|
|
|
|
gtk_signal_handler_block (GTK_OBJECT (list), combo->list_change_id);
|
|
|
|
if (list->selection)
|
|
|
|
{
|
|
|
|
text = gtk_combo_func (GTK_LIST_ITEM (list->selection->data));
|
|
|
|
if (!text)
|
|
|
|
text = "";
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (combo->entry), text);
|
|
|
|
}
|
|
|
|
gtk_signal_handler_unblock (GTK_OBJECT (list), combo->list_change_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_update_list (GtkEntry * entry, GtkCombo * combo)
|
|
|
|
{
|
|
|
|
GtkList *list = GTK_LIST (combo->list);
|
|
|
|
GList *slist = list->selection;
|
|
|
|
GtkListItem *li;
|
|
|
|
|
|
|
|
gtk_grab_remove (GTK_WIDGET (combo));
|
|
|
|
|
|
|
|
gtk_signal_handler_block (GTK_OBJECT (entry), combo->entry_change_id);
|
|
|
|
if (slist && slist->data)
|
|
|
|
gtk_list_unselect_child (list, GTK_WIDGET (slist->data));
|
|
|
|
li = gtk_combo_find (combo);
|
|
|
|
if (li)
|
|
|
|
gtk_list_select_child (list, GTK_WIDGET (li));
|
|
|
|
gtk_signal_handler_unblock (GTK_OBJECT (entry), combo->entry_change_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_combo_button_press (GtkWidget * widget, GdkEvent * event, GtkCombo * combo)
|
|
|
|
{
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
|
|
child = gtk_get_event_widget (event);
|
|
|
|
|
|
|
|
/* We don't ask for button press events on the grab widget, so
|
|
|
|
* if an event is reported directly to the grab widget, it must
|
|
|
|
* be on a window outside the application (and thus we remove
|
|
|
|
* the popup window). Otherwise, we check if the widget is a child
|
|
|
|
* of the grab widget, and only remove the popup window if it
|
|
|
|
* is not.
|
|
|
|
*/
|
|
|
|
if (child != widget)
|
|
|
|
{
|
|
|
|
while (child)
|
|
|
|
{
|
|
|
|
if (child == widget)
|
|
|
|
return FALSE;
|
|
|
|
child = child->parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_hide (combo->popwin);
|
|
|
|
gtk_grab_remove (combo->popwin);
|
1998-04-30 15:18:19 +00:00
|
|
|
gdk_pointer_ungrab (event->button.time);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_combo_button_release (GtkWidget * widget, GdkEvent * event, GtkCombo * combo)
|
|
|
|
{
|
|
|
|
GtkWidget *child;
|
1998-05-01 19:39:27 +00:00
|
|
|
|
1998-04-30 15:18:19 +00:00
|
|
|
if ((combo->current_button != 0) && (event->button.button == 1))
|
|
|
|
{
|
1998-05-01 19:39:27 +00:00
|
|
|
/* This was the initial button press */
|
|
|
|
|
1998-04-30 15:18:19 +00:00
|
|
|
GdkEventCrossing tmp_event;
|
|
|
|
|
|
|
|
combo->current_button = 0;
|
|
|
|
|
1998-05-01 19:39:27 +00:00
|
|
|
if (widget != combo->button)
|
|
|
|
gtk_widget_event (combo->button, event);
|
1998-04-30 15:18:19 +00:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
{
|
1998-05-01 19:39:27 +00:00
|
|
|
/* The user has clicked inside the popwin and released */
|
1998-05-01 04:23:59 +00:00
|
|
|
|
Few fixes for column resize. Store resize column in clist->drag_pos.
Fri Jul 31 20:45:07 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (gtk_clist_button_press) (gtk_clist_motion)
(gtk_clist_button_release) (new_column_width): Few fixes for
column resize. Store resize column in clist->drag_pos.
Thu Jul 31 15:18:36 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h
* gtk/gtkctree.c
* gtk/testgtk.c : New typedef GtkCTreeNode, changed all GList *node
to GtkCTreeNode *node.
* gtk/gtklist.h : added extended selection mode and auto scrolling.
(struct _GtkList): removed unneeded variables timer, button,
selection_start_pos, selection_end_pos, scroll_direction, have_grab.
Added new variables undo_selection, undo_unselection, last_focus_child,
undo_focus_child, htimer, vtimer, anchor, drag_pos, anchor_state,
drag_selection, add_mode.
New functions :
(gtk_list_extend_selection), (gtk_list_start_selection),
(gtk_list_end_selection), (gtk_list_select_all),
(gtk_list_unselect_all), (gtk_list_scroll_horizontal),
(gtk_list_scroll_vertical), (gtk_list_toggle_add_mode),
(gtk_list_toggle_focus_row), (gtk_list_toggle_row),
(gtk_list_undo_selection), (gtk_list_end_drag_selection)
* gtk/gtklist.c :
(gtk_list_enter_notify): removed, because auto scrolling now works
with gtk_list_motion_notify
New functions, needed for auto scrolling :
(gtk_list_motion_notify) (gtk_list_move_focus_child)
New functions for extended selection support :
(gtk_list_set_anchor), (gtk_list_fake_unselect_all),
(gtk_list_fake_toggle_row), (gtk_list_update_extended_selection),
(gtk_list_focus_lost)
(gtk_list_set_focus_child): modified gtk_container_set_focus_child
function to support auto scrolling, and avoid out-of-sync errors in
case auf GTK_SELECTION_BROWSE
(gtk_list_focus): modified gtk_container_focus function to avoid out
off sync errors in case auf GTK_SELECTION_EXTENDED
* gtk/gtklistitem.h
* gtk/gtklistitem.c :
New signal functions for key binding support :
(toggle_focus_row), (select_all), (list_item), (unselect_all)
(list_item), (undo_selection), (start_selection), (end_selection)
(extend_selection), (scroll_horizontal), (scroll_vertical),
(toggle_add_mode)
(gtk_list_item_realize): added GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK
(gtk_list_item_draw_focus): modify gc if parent has add_mode set.
* gtk/gtkcombo.c :
(gtk_combo_popup_button_press): grab pointer for combo->list
(gtk_combo_button_release): ungrab only if combo->popwin HAS_GRAB
(gtk_combo_list_key_press): take care of which child HAS_GRAB
(gtk_comb_init): don't connect combo->button with button_release_event
1998-07-31 20:48:06 +00:00
|
|
|
if (GTK_WIDGET_HAS_GRAB (combo->popwin))
|
|
|
|
{
|
|
|
|
gtk_grab_remove (combo->popwin);
|
|
|
|
gdk_pointer_ungrab (event->button.time);
|
|
|
|
}
|
1998-04-30 15:18:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_hide (combo->popwin);
|
1998-01-20 21:40:38 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-05-01 19:39:27 +00:00
|
|
|
static gint
|
|
|
|
gtk_combo_list_enter (GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event,
|
|
|
|
GtkCombo *combo)
|
|
|
|
{
|
|
|
|
GtkWidget *event_widget;
|
|
|
|
|
|
|
|
event_widget = gtk_get_event_widget ((GdkEvent*) event);
|
|
|
|
|
|
|
|
if ((event_widget == combo->list) &&
|
|
|
|
(combo->current_button != 0) &&
|
|
|
|
(!GTK_WIDGET_HAS_GRAB (combo->list)))
|
|
|
|
{
|
|
|
|
GdkEvent tmp_event;
|
|
|
|
gint x, y;
|
|
|
|
GdkModifierType mask;
|
|
|
|
|
|
|
|
gtk_grab_remove (combo->popwin);
|
|
|
|
|
|
|
|
/* Transfer the grab over to the list by synthesizing
|
|
|
|
* a button press event
|
|
|
|
*/
|
|
|
|
gdk_window_get_pointer (combo->list->window, &x, &y, &mask);
|
|
|
|
|
|
|
|
tmp_event.button.type = GDK_BUTTON_PRESS;
|
|
|
|
tmp_event.button.window = combo->list->window;
|
|
|
|
tmp_event.button.send_event = TRUE;
|
|
|
|
tmp_event.button.time = GDK_CURRENT_TIME; /* bad */
|
|
|
|
tmp_event.button.x = x;
|
|
|
|
tmp_event.button.y = y;
|
|
|
|
/* We leave all the XInput fields unfilled here, in the expectation
|
|
|
|
* that GtkList doesn't care.
|
|
|
|
*/
|
|
|
|
tmp_event.button.button = combo->current_button;
|
|
|
|
tmp_event.button.state = mask;
|
|
|
|
|
|
|
|
gtk_widget_event (combo->list, &tmp_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
static int
|
|
|
|
gtk_combo_list_key_press (GtkWidget * widget, GdkEventKey * event, GtkCombo * combo)
|
|
|
|
{
|
|
|
|
if (event->keyval == GDK_Escape)
|
|
|
|
{
|
Few fixes for column resize. Store resize column in clist->drag_pos.
Fri Jul 31 20:45:07 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (gtk_clist_button_press) (gtk_clist_motion)
(gtk_clist_button_release) (new_column_width): Few fixes for
column resize. Store resize column in clist->drag_pos.
Thu Jul 31 15:18:36 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h
* gtk/gtkctree.c
* gtk/testgtk.c : New typedef GtkCTreeNode, changed all GList *node
to GtkCTreeNode *node.
* gtk/gtklist.h : added extended selection mode and auto scrolling.
(struct _GtkList): removed unneeded variables timer, button,
selection_start_pos, selection_end_pos, scroll_direction, have_grab.
Added new variables undo_selection, undo_unselection, last_focus_child,
undo_focus_child, htimer, vtimer, anchor, drag_pos, anchor_state,
drag_selection, add_mode.
New functions :
(gtk_list_extend_selection), (gtk_list_start_selection),
(gtk_list_end_selection), (gtk_list_select_all),
(gtk_list_unselect_all), (gtk_list_scroll_horizontal),
(gtk_list_scroll_vertical), (gtk_list_toggle_add_mode),
(gtk_list_toggle_focus_row), (gtk_list_toggle_row),
(gtk_list_undo_selection), (gtk_list_end_drag_selection)
* gtk/gtklist.c :
(gtk_list_enter_notify): removed, because auto scrolling now works
with gtk_list_motion_notify
New functions, needed for auto scrolling :
(gtk_list_motion_notify) (gtk_list_move_focus_child)
New functions for extended selection support :
(gtk_list_set_anchor), (gtk_list_fake_unselect_all),
(gtk_list_fake_toggle_row), (gtk_list_update_extended_selection),
(gtk_list_focus_lost)
(gtk_list_set_focus_child): modified gtk_container_set_focus_child
function to support auto scrolling, and avoid out-of-sync errors in
case auf GTK_SELECTION_BROWSE
(gtk_list_focus): modified gtk_container_focus function to avoid out
off sync errors in case auf GTK_SELECTION_EXTENDED
* gtk/gtklistitem.h
* gtk/gtklistitem.c :
New signal functions for key binding support :
(toggle_focus_row), (select_all), (list_item), (unselect_all)
(list_item), (undo_selection), (start_selection), (end_selection)
(extend_selection), (scroll_horizontal), (scroll_vertical),
(toggle_add_mode)
(gtk_list_item_realize): added GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK
(gtk_list_item_draw_focus): modify gc if parent has add_mode set.
* gtk/gtkcombo.c :
(gtk_combo_popup_button_press): grab pointer for combo->list
(gtk_combo_button_release): ungrab only if combo->popwin HAS_GRAB
(gtk_combo_list_key_press): take care of which child HAS_GRAB
(gtk_comb_init): don't connect combo->button with button_release_event
1998-07-31 20:48:06 +00:00
|
|
|
if (GTK_WIDGET_HAS_GRAB (combo->popwin))
|
|
|
|
{
|
|
|
|
gtk_grab_remove (combo->popwin);
|
|
|
|
gdk_pointer_ungrab (GDK_CURRENT_TIME);
|
|
|
|
}
|
|
|
|
else if (GTK_WIDGET_HAS_GRAB (combo->list))
|
|
|
|
gtk_list_end_drag_selection (GTK_LIST (combo->list));
|
1998-01-20 21:40:38 +00:00
|
|
|
gtk_widget_hide (combo->popwin);
|
Few fixes for column resize. Store resize column in clist->drag_pos.
Fri Jul 31 20:45:07 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (gtk_clist_button_press) (gtk_clist_motion)
(gtk_clist_button_release) (new_column_width): Few fixes for
column resize. Store resize column in clist->drag_pos.
Thu Jul 31 15:18:36 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h
* gtk/gtkctree.c
* gtk/testgtk.c : New typedef GtkCTreeNode, changed all GList *node
to GtkCTreeNode *node.
* gtk/gtklist.h : added extended selection mode and auto scrolling.
(struct _GtkList): removed unneeded variables timer, button,
selection_start_pos, selection_end_pos, scroll_direction, have_grab.
Added new variables undo_selection, undo_unselection, last_focus_child,
undo_focus_child, htimer, vtimer, anchor, drag_pos, anchor_state,
drag_selection, add_mode.
New functions :
(gtk_list_extend_selection), (gtk_list_start_selection),
(gtk_list_end_selection), (gtk_list_select_all),
(gtk_list_unselect_all), (gtk_list_scroll_horizontal),
(gtk_list_scroll_vertical), (gtk_list_toggle_add_mode),
(gtk_list_toggle_focus_row), (gtk_list_toggle_row),
(gtk_list_undo_selection), (gtk_list_end_drag_selection)
* gtk/gtklist.c :
(gtk_list_enter_notify): removed, because auto scrolling now works
with gtk_list_motion_notify
New functions, needed for auto scrolling :
(gtk_list_motion_notify) (gtk_list_move_focus_child)
New functions for extended selection support :
(gtk_list_set_anchor), (gtk_list_fake_unselect_all),
(gtk_list_fake_toggle_row), (gtk_list_update_extended_selection),
(gtk_list_focus_lost)
(gtk_list_set_focus_child): modified gtk_container_set_focus_child
function to support auto scrolling, and avoid out-of-sync errors in
case auf GTK_SELECTION_BROWSE
(gtk_list_focus): modified gtk_container_focus function to avoid out
off sync errors in case auf GTK_SELECTION_EXTENDED
* gtk/gtklistitem.h
* gtk/gtklistitem.c :
New signal functions for key binding support :
(toggle_focus_row), (select_all), (list_item), (unselect_all)
(list_item), (undo_selection), (start_selection), (end_selection)
(extend_selection), (scroll_horizontal), (scroll_vertical),
(toggle_add_mode)
(gtk_list_item_realize): added GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK
(gtk_list_item_draw_focus): modify gc if parent has add_mode set.
* gtk/gtkcombo.c :
(gtk_combo_popup_button_press): grab pointer for combo->list
(gtk_combo_button_release): ungrab only if combo->popwin HAS_GRAB
(gtk_combo_list_key_press): take care of which child HAS_GRAB
(gtk_comb_init): don't connect combo->button with button_release_event
1998-07-31 20:48:06 +00:00
|
|
|
if (GTK_WIDGET_HAS_GRAB (combo->button))
|
|
|
|
{
|
|
|
|
combo->current_button = 0;
|
|
|
|
GTK_BUTTON (combo->button)->in_button = FALSE;
|
1998-08-02 22:18:20 +00:00
|
|
|
gtk_button_released (GTK_BUTTON (combo->button));
|
Few fixes for column resize. Store resize column in clist->drag_pos.
Fri Jul 31 20:45:07 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (gtk_clist_button_press) (gtk_clist_motion)
(gtk_clist_button_release) (new_column_width): Few fixes for
column resize. Store resize column in clist->drag_pos.
Thu Jul 31 15:18:36 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h
* gtk/gtkctree.c
* gtk/testgtk.c : New typedef GtkCTreeNode, changed all GList *node
to GtkCTreeNode *node.
* gtk/gtklist.h : added extended selection mode and auto scrolling.
(struct _GtkList): removed unneeded variables timer, button,
selection_start_pos, selection_end_pos, scroll_direction, have_grab.
Added new variables undo_selection, undo_unselection, last_focus_child,
undo_focus_child, htimer, vtimer, anchor, drag_pos, anchor_state,
drag_selection, add_mode.
New functions :
(gtk_list_extend_selection), (gtk_list_start_selection),
(gtk_list_end_selection), (gtk_list_select_all),
(gtk_list_unselect_all), (gtk_list_scroll_horizontal),
(gtk_list_scroll_vertical), (gtk_list_toggle_add_mode),
(gtk_list_toggle_focus_row), (gtk_list_toggle_row),
(gtk_list_undo_selection), (gtk_list_end_drag_selection)
* gtk/gtklist.c :
(gtk_list_enter_notify): removed, because auto scrolling now works
with gtk_list_motion_notify
New functions, needed for auto scrolling :
(gtk_list_motion_notify) (gtk_list_move_focus_child)
New functions for extended selection support :
(gtk_list_set_anchor), (gtk_list_fake_unselect_all),
(gtk_list_fake_toggle_row), (gtk_list_update_extended_selection),
(gtk_list_focus_lost)
(gtk_list_set_focus_child): modified gtk_container_set_focus_child
function to support auto scrolling, and avoid out-of-sync errors in
case auf GTK_SELECTION_BROWSE
(gtk_list_focus): modified gtk_container_focus function to avoid out
off sync errors in case auf GTK_SELECTION_EXTENDED
* gtk/gtklistitem.h
* gtk/gtklistitem.c :
New signal functions for key binding support :
(toggle_focus_row), (select_all), (list_item), (unselect_all)
(list_item), (undo_selection), (start_selection), (end_selection)
(extend_selection), (scroll_horizontal), (scroll_vertical),
(toggle_add_mode)
(gtk_list_item_realize): added GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK
(gtk_list_item_draw_focus): modify gc if parent has add_mode set.
* gtk/gtkcombo.c :
(gtk_combo_popup_button_press): grab pointer for combo->list
(gtk_combo_button_release): ungrab only if combo->popwin HAS_GRAB
(gtk_combo_list_key_press): take care of which child HAS_GRAB
(gtk_comb_init): don't connect combo->button with button_release_event
1998-07-31 20:48:06 +00:00
|
|
|
gtk_grab_remove (combo->button);
|
|
|
|
}
|
1998-01-20 21:40:38 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1998-03-17 19:03:52 +00:00
|
|
|
static void
|
1998-01-20 21:40:38 +00:00
|
|
|
gtk_combo_init (GtkCombo * combo)
|
|
|
|
{
|
|
|
|
GtkWidget *arrow;
|
1998-03-13 17:45:16 +00:00
|
|
|
GtkWidget *frame;
|
1998-03-24 05:27:00 +00:00
|
|
|
GtkWidget *event_box;
|
|
|
|
GdkCursor *cursor;
|
1998-01-20 21:40:38 +00:00
|
|
|
|
|
|
|
combo->case_sensitive = 0;
|
|
|
|
combo->value_in_list = 0;
|
|
|
|
combo->ok_if_empty = 1;
|
|
|
|
combo->use_arrows = 1;
|
|
|
|
combo->use_arrows_always = 0;
|
|
|
|
combo->entry = gtk_entry_new ();
|
|
|
|
combo->button = gtk_button_new ();
|
1998-04-30 15:18:19 +00:00
|
|
|
combo->current_button = 0;
|
1998-01-20 21:40:38 +00:00
|
|
|
arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
|
|
|
|
gtk_widget_show (arrow);
|
|
|
|
gtk_container_add (GTK_CONTAINER (combo->button), arrow);
|
|
|
|
gtk_box_pack_start (GTK_BOX (combo), combo->entry, TRUE, TRUE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (combo), combo->button, FALSE, FALSE, 0);
|
1998-05-01 13:16:49 +00:00
|
|
|
GTK_WIDGET_UNSET_FLAGS (combo->button, GTK_CAN_FOCUS);
|
1998-01-20 21:40:38 +00:00
|
|
|
gtk_widget_show (combo->entry);
|
|
|
|
gtk_widget_show (combo->button);
|
|
|
|
combo->entry_change_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "changed",
|
|
|
|
(GtkSignalFunc) gtk_combo_update_list, combo);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (combo->entry), "key_press_event",
|
|
|
|
(GtkSignalFunc) gtk_combo_entry_key_press, combo);
|
|
|
|
gtk_signal_connect_after (GTK_OBJECT (combo->entry), "focus_out_event",
|
|
|
|
(GtkSignalFunc) gtk_combo_entry_focus_out, combo);
|
1998-03-21 09:45:03 +00:00
|
|
|
combo->activate_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "activate",
|
1998-04-30 15:18:19 +00:00
|
|
|
(GtkSignalFunc) gtk_combo_activate, combo);
|
|
|
|
gtk_signal_connect_after (GTK_OBJECT (combo->button), "button_press_event",
|
|
|
|
(GtkSignalFunc) gtk_combo_popup_button_press, combo);
|
Few fixes for column resize. Store resize column in clist->drag_pos.
Fri Jul 31 20:45:07 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (gtk_clist_button_press) (gtk_clist_motion)
(gtk_clist_button_release) (new_column_width): Few fixes for
column resize. Store resize column in clist->drag_pos.
Thu Jul 31 15:18:36 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h
* gtk/gtkctree.c
* gtk/testgtk.c : New typedef GtkCTreeNode, changed all GList *node
to GtkCTreeNode *node.
* gtk/gtklist.h : added extended selection mode and auto scrolling.
(struct _GtkList): removed unneeded variables timer, button,
selection_start_pos, selection_end_pos, scroll_direction, have_grab.
Added new variables undo_selection, undo_unselection, last_focus_child,
undo_focus_child, htimer, vtimer, anchor, drag_pos, anchor_state,
drag_selection, add_mode.
New functions :
(gtk_list_extend_selection), (gtk_list_start_selection),
(gtk_list_end_selection), (gtk_list_select_all),
(gtk_list_unselect_all), (gtk_list_scroll_horizontal),
(gtk_list_scroll_vertical), (gtk_list_toggle_add_mode),
(gtk_list_toggle_focus_row), (gtk_list_toggle_row),
(gtk_list_undo_selection), (gtk_list_end_drag_selection)
* gtk/gtklist.c :
(gtk_list_enter_notify): removed, because auto scrolling now works
with gtk_list_motion_notify
New functions, needed for auto scrolling :
(gtk_list_motion_notify) (gtk_list_move_focus_child)
New functions for extended selection support :
(gtk_list_set_anchor), (gtk_list_fake_unselect_all),
(gtk_list_fake_toggle_row), (gtk_list_update_extended_selection),
(gtk_list_focus_lost)
(gtk_list_set_focus_child): modified gtk_container_set_focus_child
function to support auto scrolling, and avoid out-of-sync errors in
case auf GTK_SELECTION_BROWSE
(gtk_list_focus): modified gtk_container_focus function to avoid out
off sync errors in case auf GTK_SELECTION_EXTENDED
* gtk/gtklistitem.h
* gtk/gtklistitem.c :
New signal functions for key binding support :
(toggle_focus_row), (select_all), (list_item), (unselect_all)
(list_item), (undo_selection), (start_selection), (end_selection)
(extend_selection), (scroll_horizontal), (scroll_vertical),
(toggle_add_mode)
(gtk_list_item_realize): added GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK
(gtk_list_item_draw_focus): modify gc if parent has add_mode set.
* gtk/gtkcombo.c :
(gtk_combo_popup_button_press): grab pointer for combo->list
(gtk_combo_button_release): ungrab only if combo->popwin HAS_GRAB
(gtk_combo_list_key_press): take care of which child HAS_GRAB
(gtk_comb_init): don't connect combo->button with button_release_event
1998-07-31 20:48:06 +00:00
|
|
|
/*gtk_signal_connect_after (GTK_OBJECT (combo->button), "button_release_event",
|
|
|
|
(GtkSignalFunc) gtk_combo_button_release, combo);*/
|
1998-04-30 15:18:19 +00:00
|
|
|
gtk_signal_connect (GTK_OBJECT (combo->button), "leave_notify_event",
|
|
|
|
(GtkSignalFunc) gtk_combo_popup_button_leave, combo);
|
1998-01-20 21:40:38 +00:00
|
|
|
/*gtk_signal_connect(GTK_OBJECT(combo->button), "clicked",
|
|
|
|
(GtkSignalFunc)prelight_bug, combo); */
|
|
|
|
|
|
|
|
combo->popwin = gtk_window_new (GTK_WINDOW_POPUP);
|
1998-02-02 14:11:24 +00:00
|
|
|
gtk_widget_ref (combo->popwin);
|
1998-01-20 21:40:38 +00:00
|
|
|
gtk_window_set_policy (GTK_WINDOW (combo->popwin), 1, 1, 0);
|
1998-03-24 05:27:00 +00:00
|
|
|
|
|
|
|
gtk_widget_set_events (combo->popwin, GDK_KEY_PRESS_MASK);
|
|
|
|
|
|
|
|
event_box = gtk_event_box_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER (combo->popwin), event_box);
|
|
|
|
gtk_widget_show (event_box);
|
|
|
|
|
|
|
|
gtk_widget_realize (event_box);
|
|
|
|
cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW);
|
|
|
|
gdk_window_set_cursor (event_box->window, cursor);
|
|
|
|
gdk_cursor_destroy (cursor);
|
1998-03-13 17:45:16 +00:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
1998-03-24 05:27:00 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (event_box), frame);
|
1998-03-13 17:45:16 +00:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
combo->popup = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (combo->popup),
|
1998-05-01 13:16:49 +00:00
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (combo->popup)->hscrollbar, GTK_CAN_FOCUS);
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (combo->popup)->vscrollbar, GTK_CAN_FOCUS);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), combo->popup);
|
|
|
|
gtk_widget_show (combo->popup);
|
1998-03-24 05:27:00 +00:00
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
combo->list = gtk_list_new ();
|
1998-05-01 19:39:27 +00:00
|
|
|
/* We'll use enter notify events to figure out when to transfer
|
|
|
|
* the grab to the list
|
|
|
|
*/
|
|
|
|
gtk_widget_set_events (combo->list, GDK_ENTER_NOTIFY_MASK);
|
|
|
|
|
1998-01-21 00:34:27 +00:00
|
|
|
gtk_list_set_selection_mode(GTK_LIST(combo->list), GTK_SELECTION_BROWSE);
|
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode.
Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org>
* gtk/gtkprogress.c: added args ::show_text, ::text_xalign,
::text_yalign, ::activity_mode.
* gtk/gtkprogressbar.c: added construct arg ::adjustment. added args
::bar_style, ::orientation, ::discrete_blocks, ::activity_step,
::activity_blocks.
(gtk_progress_bar_new):
(gtk_progress_bar_new_with_adjustment): use gtk_widget_new().
(gtk_progress_bar_construct): deprecated.
* gtk/gtkvscrollbar.c:
(gtk_vscrollbar_draw_step_back):
(gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for
gtk_paint_arrow, to be consistent with hscrollbar.
* gtk/gtktext.c
added construct args ::hadjustment, ::vadjustment.
added args ::line_wrap, ::word_wrap.
(gtk_text_class_init): added scroll_adjustments signal.
(gtk_text_new): use gtk_widget_new.
(gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments,
so we don't screw the reference counts and don't leave signals connected.
(gtk_text_destroy): disconnect adjustments signals.
(gtk_text_finalize): unref adjustments.
* gtk/gtkctree.c: added construct args ::n_columns and ::tree_column.
added args ::indent, ::spacing, ::show_stub, ::reorderable,
::use_drag_icons, ::line_style and ::expander_style.
(gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is
deprecated now.
* gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag.
* gtk/gtkclist.c:
removed ::vadjustment and ::hadjustment args, introduced
::scroll_adjustments signal.
added ::shadow_type, ::selection_mode and ::row_height args.
added n_columns construct arg.
(gtk_clist_construct): call gtk_object_constructed().
(gtk_clist_set_row_height): if height is passed as 0,
revert to automatic height calculation.
(gtk_clist_destroy): before unrefing the adjustments, disconnect our
signal handlers.
Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct
like gtk_object_new.
(gtk_widget_destroy): assert that we only destroy constructed widgets.
* gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY
to identify args that may only be used for construction.
GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction
time.
* gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct
at the end if the object is not fully constructed.
(gtk_object_newv): likewise.
(gtk_object_destroy): assert that we only destroy constructed objects.
(gtk_object_init): setup GTK_CONSTRUCTED from the
objects real klass.
(gtk_object_default_construct): new function to complete default
construction of an object by applying missing construtor args with
default values of 0, 0.0 or NULL.
(gtk_object_constructed): new function to mark an object as being
constructed (used from within constructors).
* gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer
so it is immediatedly available for the caller.
* gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to
the object initilizer (GtkObjectInitFunc takes a second arg now, the
real klass), and asure that object initializers may temporarily alter
the class pointer.
Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org>
* gtk/testgtk.c: change all occourances of gtk_container_add (
scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...)
for widget!=(clist, ctree, text, viewport).
* gtk/gtkcombo.c:
(gtk_combo_init): use gtk_scrolled_window_add_with_viewport()
to add children to the scrolled window.
* gtk/gtkscrolledwindow.h:
* gtk/gtkscrolledwindow.c:
changed scrolled_window->viewport to scrolled_window->child, and use
gtk_widget_scroll_adjustements() to set the scroll adjustments for the
widget, we do not create an additional viewport anymore.
added ::hadjustment and ::vadjustment constructor args.
(gtk_scrolled_window_new): use gtk_widget_new() to create the widget.
(gtk_scrolled_window_set_hadjustment):
(gtk_scrolled_window_set_vadjustment): new functions that superceed
gtk_scrolled_window_construct.
(gtk_scrolled_window_construct): deprecated this function.
* gtk/gtkhscrollbar.c:
* gtk/gtkvscrollbar.c:
* gtk/gtkhscale.c:
* gtk/gtkvscale.c:
support a constructor arg "::adjustment", and use gtk_widget_new() for
the widget creation.
* gtk/gtkrange.c: added ::update_policy arg.
(gtk_range_set_adjustment): if adjustment is passed in as NULL, create
a default adjustment so this function can be used for derived widgets
that depend on the adjustment's existance.
(gtk_range_destroy): disconnect the adjustment signal, so we don't
get called after we got destroyed, we don't destroy the adjustment
in here, because it might have been provided from another widget.
* gtk/gtkviewport.c: introduced ::scroll_adjustments signal.
(gtk_viewport_destroy): same as gtk_range_destroy.
* gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy.
* gtk/gtkwidget.h:
* gtk/gtkwidget.c: changed gtk_widget_activate() to return a
gboolean, indicating whether this widget supports activation.
added gtk_widget_scroll_adjustements() to set the scrolling
adjustments of a widget.
Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org>
* gtk/gtkoptionmenu.c:
(gtk_option_menu_remove_contents):
(gtk_option_menu_update_contents): removed
gtk_container_[un]block_resize() pairs.
* gtk/gtknotebook.h:
* gtk/gtknotebook.c: removed the tab_border field, since it shouldn't
be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a
wrtie-only argument.
* *.c: made deprecated functions issue a message:
gtk_clist_set_border, gtk_container_block_resize,
gtk_container_unblock_resize, gtk_container_need_resize,
gtk_object_class_add_user_signal, gtk_spin_button_construct,
gtk_scrolled_window_construct.
removed non-functional functions:
gtk_container_disable_resize, gtk_container_enable_resize,
gtk_clist_set_policy.
Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org>
* gtk/gtkbox.c (gtk_box_init):
* gtk/gtkdrawingarea.c (gtk_drawing_area_init):
* gtk/gtkeventbox.c (gtk_event_box_init):
* gtk/gtkfixed.c (gtk_fixed_init):
* gtk/gtkframe.c (gtk_frame_init):
* gtk/gtkhandlebox.c (gtk_handle_box_init):
* gtk/gtkpacker.c (gtk_packer_init):
* gtk/gtkmisc.c (gtk_misc_init):
* gtk/gtkpreview.c (gtk_preview_init):
* gtk/gtkprogress.c (gtk_progress_init):
* gtk/gtkprogressbar.c (gtk_progress_bar_init):
* gtk/gtkseparator.c (gtk_separator_init):
* gtk/gtktable.c (gtk_table_init):
* gtk/gtkviewport.c (gtk_viewport_init):
* gtk/gtkalignment.c (gtk_alignment_init):
removed setting of the GTK_BASIC flag.
* gtk/gtkwidget.h:
* gtk/gtkwidget.c:
removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic.
* miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
|
|
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (combo->popup), combo->list);
|
1998-05-01 13:16:49 +00:00
|
|
|
gtk_container_set_focus_vadjustment (GTK_CONTAINER (combo->list),
|
|
|
|
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (combo->popup)));
|
Few fixes for column resize. Store resize column in clist->drag_pos.
Fri Jul 31 20:45:07 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (gtk_clist_button_press) (gtk_clist_motion)
(gtk_clist_button_release) (new_column_width): Few fixes for
column resize. Store resize column in clist->drag_pos.
Thu Jul 31 15:18:36 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h
* gtk/gtkctree.c
* gtk/testgtk.c : New typedef GtkCTreeNode, changed all GList *node
to GtkCTreeNode *node.
* gtk/gtklist.h : added extended selection mode and auto scrolling.
(struct _GtkList): removed unneeded variables timer, button,
selection_start_pos, selection_end_pos, scroll_direction, have_grab.
Added new variables undo_selection, undo_unselection, last_focus_child,
undo_focus_child, htimer, vtimer, anchor, drag_pos, anchor_state,
drag_selection, add_mode.
New functions :
(gtk_list_extend_selection), (gtk_list_start_selection),
(gtk_list_end_selection), (gtk_list_select_all),
(gtk_list_unselect_all), (gtk_list_scroll_horizontal),
(gtk_list_scroll_vertical), (gtk_list_toggle_add_mode),
(gtk_list_toggle_focus_row), (gtk_list_toggle_row),
(gtk_list_undo_selection), (gtk_list_end_drag_selection)
* gtk/gtklist.c :
(gtk_list_enter_notify): removed, because auto scrolling now works
with gtk_list_motion_notify
New functions, needed for auto scrolling :
(gtk_list_motion_notify) (gtk_list_move_focus_child)
New functions for extended selection support :
(gtk_list_set_anchor), (gtk_list_fake_unselect_all),
(gtk_list_fake_toggle_row), (gtk_list_update_extended_selection),
(gtk_list_focus_lost)
(gtk_list_set_focus_child): modified gtk_container_set_focus_child
function to support auto scrolling, and avoid out-of-sync errors in
case auf GTK_SELECTION_BROWSE
(gtk_list_focus): modified gtk_container_focus function to avoid out
off sync errors in case auf GTK_SELECTION_EXTENDED
* gtk/gtklistitem.h
* gtk/gtklistitem.c :
New signal functions for key binding support :
(toggle_focus_row), (select_all), (list_item), (unselect_all)
(list_item), (undo_selection), (start_selection), (end_selection)
(extend_selection), (scroll_horizontal), (scroll_vertical),
(toggle_add_mode)
(gtk_list_item_realize): added GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK
(gtk_list_item_draw_focus): modify gc if parent has add_mode set.
* gtk/gtkcombo.c :
(gtk_combo_popup_button_press): grab pointer for combo->list
(gtk_combo_button_release): ungrab only if combo->popwin HAS_GRAB
(gtk_combo_list_key_press): take care of which child HAS_GRAB
(gtk_comb_init): don't connect combo->button with button_release_event
1998-07-31 20:48:06 +00:00
|
|
|
gtk_container_set_focus_hadjustment (GTK_CONTAINER (combo->list),
|
|
|
|
gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (combo->popup)));
|
1998-01-20 21:40:38 +00:00
|
|
|
gtk_widget_show (combo->list);
|
1998-03-24 05:27:00 +00:00
|
|
|
|
1998-01-20 21:40:38 +00:00
|
|
|
combo->list_change_id = gtk_signal_connect (GTK_OBJECT (combo->list), "selection_changed",
|
|
|
|
(GtkSignalFunc) gtk_combo_update_entry, combo);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (combo->popwin), "key_press_event",
|
|
|
|
(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);
|
1998-05-01 19:39:27 +00:00
|
|
|
|
Few fixes for column resize. Store resize column in clist->drag_pos.
Fri Jul 31 20:45:07 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (gtk_clist_button_press) (gtk_clist_motion)
(gtk_clist_button_release) (new_column_width): Few fixes for
column resize. Store resize column in clist->drag_pos.
Thu Jul 31 15:18:36 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h
* gtk/gtkctree.c
* gtk/testgtk.c : New typedef GtkCTreeNode, changed all GList *node
to GtkCTreeNode *node.
* gtk/gtklist.h : added extended selection mode and auto scrolling.
(struct _GtkList): removed unneeded variables timer, button,
selection_start_pos, selection_end_pos, scroll_direction, have_grab.
Added new variables undo_selection, undo_unselection, last_focus_child,
undo_focus_child, htimer, vtimer, anchor, drag_pos, anchor_state,
drag_selection, add_mode.
New functions :
(gtk_list_extend_selection), (gtk_list_start_selection),
(gtk_list_end_selection), (gtk_list_select_all),
(gtk_list_unselect_all), (gtk_list_scroll_horizontal),
(gtk_list_scroll_vertical), (gtk_list_toggle_add_mode),
(gtk_list_toggle_focus_row), (gtk_list_toggle_row),
(gtk_list_undo_selection), (gtk_list_end_drag_selection)
* gtk/gtklist.c :
(gtk_list_enter_notify): removed, because auto scrolling now works
with gtk_list_motion_notify
New functions, needed for auto scrolling :
(gtk_list_motion_notify) (gtk_list_move_focus_child)
New functions for extended selection support :
(gtk_list_set_anchor), (gtk_list_fake_unselect_all),
(gtk_list_fake_toggle_row), (gtk_list_update_extended_selection),
(gtk_list_focus_lost)
(gtk_list_set_focus_child): modified gtk_container_set_focus_child
function to support auto scrolling, and avoid out-of-sync errors in
case auf GTK_SELECTION_BROWSE
(gtk_list_focus): modified gtk_container_focus function to avoid out
off sync errors in case auf GTK_SELECTION_EXTENDED
* gtk/gtklistitem.h
* gtk/gtklistitem.c :
New signal functions for key binding support :
(toggle_focus_row), (select_all), (list_item), (unselect_all)
(list_item), (undo_selection), (start_selection), (end_selection)
(extend_selection), (scroll_horizontal), (scroll_vertical),
(toggle_add_mode)
(gtk_list_item_realize): added GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK
(gtk_list_item_draw_focus): modify gc if parent has add_mode set.
* gtk/gtkcombo.c :
(gtk_combo_popup_button_press): grab pointer for combo->list
(gtk_combo_button_release): ungrab only if combo->popwin HAS_GRAB
(gtk_combo_list_key_press): take care of which child HAS_GRAB
(gtk_comb_init): don't connect combo->button with button_release_event
1998-07-31 20:48:06 +00:00
|
|
|
gtk_signal_connect_after (GTK_OBJECT (combo->list), "button_release_event",
|
|
|
|
GTK_SIGNAL_FUNC (gtk_combo_button_release), combo);
|
1998-05-01 19:39:27 +00:00
|
|
|
/* We connect here on the button, because we'll have a grab on it
|
|
|
|
* when the event occurs. But we are actually interested in enters
|
|
|
|
* for the combo->list.
|
|
|
|
*/
|
|
|
|
gtk_signal_connect (GTK_OBJECT (combo->button), "enter_notify_event",
|
|
|
|
GTK_SIGNAL_FUNC (gtk_combo_list_enter), combo);
|
1998-01-20 21:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
guint
|
1998-05-03 22:41:32 +00:00
|
|
|
gtk_combo_get_type (void)
|
1998-01-20 21:40:38 +00:00
|
|
|
{
|
|
|
|
static guint combo_type = 0;
|
|
|
|
|
|
|
|
if (!combo_type)
|
|
|
|
{
|
1998-11-30 19:07:15 +00:00
|
|
|
static const GtkTypeInfo combo_info =
|
1998-01-20 21:40:38 +00:00
|
|
|
{
|
|
|
|
"GtkCombo",
|
|
|
|
sizeof (GtkCombo),
|
|
|
|
sizeof (GtkComboClass),
|
|
|
|
(GtkClassInitFunc) gtk_combo_class_init,
|
|
|
|
(GtkObjectInitFunc) gtk_combo_init,
|
1998-07-04 15:31:30 +00:00
|
|
|
/* reserved_1 */ NULL,
|
|
|
|
/* reserved_2 */ NULL,
|
1998-06-28 07:46:10 +00:00
|
|
|
(GtkClassInitFunc) NULL,
|
1998-01-20 21:40:38 +00:00
|
|
|
};
|
|
|
|
combo_type = gtk_type_unique (gtk_hbox_get_type (), &combo_info);
|
|
|
|
}
|
|
|
|
return combo_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
1998-05-03 22:41:32 +00:00
|
|
|
gtk_combo_new (void)
|
1998-01-20 21:40:38 +00:00
|
|
|
{
|
|
|
|
return GTK_WIDGET (gtk_type_new (gtk_combo_get_type ()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_combo_set_value_in_list (GtkCombo * combo, gint val, gint ok_if_empty)
|
|
|
|
{
|
|
|
|
g_return_if_fail (combo != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_COMBO (combo));
|
|
|
|
|
|
|
|
combo->value_in_list = val;
|
|
|
|
combo->ok_if_empty = ok_if_empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_combo_set_case_sensitive (GtkCombo * combo, gint val)
|
|
|
|
{
|
|
|
|
g_return_if_fail (combo != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_COMBO (combo));
|
|
|
|
|
|
|
|
combo->case_sensitive = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_combo_set_use_arrows (GtkCombo * combo, gint val)
|
|
|
|
{
|
|
|
|
g_return_if_fail (combo != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_COMBO (combo));
|
|
|
|
|
|
|
|
combo->use_arrows = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_combo_set_use_arrows_always (GtkCombo * combo, gint val)
|
|
|
|
{
|
|
|
|
g_return_if_fail (combo != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_COMBO (combo));
|
|
|
|
|
|
|
|
combo->use_arrows_always = val;
|
|
|
|
combo->use_arrows = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_combo_set_popdown_strings (GtkCombo * combo, GList * strings)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
GtkWidget *li;
|
|
|
|
|
|
|
|
g_return_if_fail (combo != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_COMBO (combo));
|
|
|
|
g_return_if_fail (strings != NULL);
|
|
|
|
|
|
|
|
gtk_list_clear_items (GTK_LIST (combo->list), 0, -1);
|
|
|
|
list = strings;
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
li = gtk_list_item_new_with_label ((gchar *) list->data);
|
|
|
|
gtk_widget_show (li);
|
|
|
|
gtk_container_add (GTK_CONTAINER (combo->list), li);
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_item_destroy (GtkObject * object)
|
|
|
|
{
|
|
|
|
gchar *key;
|
|
|
|
|
|
|
|
key = gtk_object_get_data (object, gtk_combo_string_key);
|
|
|
|
if (key)
|
|
|
|
g_free (key);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_combo_set_item_string (GtkCombo * combo, GtkItem * item, const gchar * item_value)
|
|
|
|
{
|
|
|
|
gchar *val;
|
|
|
|
gint connected = 0;
|
|
|
|
|
|
|
|
g_return_if_fail (combo != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_COMBO (combo));
|
|
|
|
g_return_if_fail (item != NULL);
|
|
|
|
|
|
|
|
val = gtk_object_get_data (GTK_OBJECT (item), gtk_combo_string_key);
|
|
|
|
if (val)
|
|
|
|
{
|
|
|
|
g_free (val);
|
|
|
|
connected = 1;
|
|
|
|
}
|
|
|
|
if (item_value)
|
|
|
|
{
|
|
|
|
val = g_strdup(item_value);
|
|
|
|
gtk_object_set_data (GTK_OBJECT (item), gtk_combo_string_key, val);
|
|
|
|
if (!connected)
|
|
|
|
gtk_signal_connect (GTK_OBJECT (item), "destroy",
|
|
|
|
(GtkSignalFunc) gtk_combo_item_destroy, val);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_object_set_data (GTK_OBJECT (item), gtk_combo_string_key, NULL);
|
|
|
|
if (connected)
|
|
|
|
gtk_signal_disconnect_by_data(GTK_OBJECT (item), val);
|
|
|
|
}
|
|
|
|
}
|
1998-03-13 17:45:16 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_combo_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
|
|
|
GtkCombo *combo;
|
|
|
|
|
|
|
|
g_return_if_fail (widget != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_COMBO (widget));
|
|
|
|
g_return_if_fail (allocation != NULL);
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
|
|
|
|
|
|
|
|
combo = GTK_COMBO (widget);
|
|
|
|
|
|
|
|
if (combo->entry->allocation.height > combo->entry->requisition.height)
|
|
|
|
{
|
|
|
|
GtkAllocation button_allocation;
|
|
|
|
|
|
|
|
button_allocation = combo->button->allocation;
|
|
|
|
button_allocation.height = combo->entry->requisition.height;
|
|
|
|
button_allocation.y = combo->entry->allocation.y +
|
|
|
|
(combo->entry->allocation.height - combo->entry->requisition.height)
|
|
|
|
/ 2;
|
|
|
|
gtk_widget_size_allocate (combo->button, &button_allocation);
|
|
|
|
}
|
|
|
|
}
|
1998-03-21 09:45:03 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
gtk_combo_disable_activate (GtkCombo* combo)
|
|
|
|
{
|
|
|
|
g_return_if_fail (combo != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_COMBO (combo));
|
|
|
|
|
|
|
|
if ( combo->activate_id ) {
|
1998-03-29 02:44:43 +00:00
|
|
|
gtk_signal_disconnect(GTK_OBJECT(combo->entry), combo->activate_id);
|
1998-03-21 09:45:03 +00:00
|
|
|
combo->activate_id = 0;
|
|
|
|
}
|
|
|
|
}
|