mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-02 17:00:19 +00:00
file chooser widget: Stop using ::key-press-event
Use a generic ::event handler instead.
This commit is contained in:
parent
576dcf65b3
commit
c78166e190
@ -456,8 +456,8 @@ static void gtk_file_chooser_widget_hierarchy_changed (GtkWidget *w
|
|||||||
static void gtk_file_chooser_widget_style_updated (GtkWidget *widget);
|
static void gtk_file_chooser_widget_style_updated (GtkWidget *widget);
|
||||||
static void gtk_file_chooser_widget_display_changed (GtkWidget *widget,
|
static void gtk_file_chooser_widget_display_changed (GtkWidget *widget,
|
||||||
GdkDisplay *previous_display);
|
GdkDisplay *previous_display);
|
||||||
static gboolean gtk_file_chooser_widget_key_press_event (GtkWidget *widget,
|
static gboolean gtk_file_chooser_widget_event (GtkWidget *widget,
|
||||||
GdkEventKey *event);
|
GdkEvent *event);
|
||||||
|
|
||||||
static gboolean gtk_file_chooser_widget_set_current_folder (GtkFileChooser *chooser,
|
static gboolean gtk_file_chooser_widget_set_current_folder (GtkFileChooser *chooser,
|
||||||
GFile *folder,
|
GFile *folder,
|
||||||
@ -1382,15 +1382,18 @@ key_press_cb (GtkEventController *controller,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_file_chooser_widget_key_press_event (GtkWidget *widget,
|
gtk_file_chooser_widget_event (GtkWidget *widget,
|
||||||
GdkEventKey *event)
|
GdkEvent *event)
|
||||||
{
|
{
|
||||||
GtkFileChooserWidget *impl = (GtkFileChooserWidget *) widget;
|
GtkFileChooserWidget *impl = (GtkFileChooserWidget *) widget;
|
||||||
GtkFileChooserWidgetPrivate *priv = impl->priv;
|
GtkFileChooserWidgetPrivate *priv = impl->priv;
|
||||||
guint keyval, state;
|
guint keyval, state;
|
||||||
|
|
||||||
gdk_event_get_keyval ((GdkEvent *)event, &keyval);
|
if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
|
||||||
gdk_event_get_state ((GdkEvent *)event, &state);
|
return GDK_EVENT_PROPAGATE;
|
||||||
|
|
||||||
|
gdk_event_get_keyval (event, &keyval);
|
||||||
|
gdk_event_get_state (event, &state);
|
||||||
|
|
||||||
if (should_trigger_location_entry (impl, keyval, state))
|
if (should_trigger_location_entry (impl, keyval, state))
|
||||||
{
|
{
|
||||||
@ -1399,22 +1402,22 @@ gtk_file_chooser_widget_key_press_event (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
const char *string;
|
const char *string;
|
||||||
|
|
||||||
gdk_event_get_string ((GdkEvent *)event, &string);
|
gdk_event_get_string (event, &string);
|
||||||
location_popup_handler (impl, string);
|
location_popup_handler (impl, string);
|
||||||
return TRUE;
|
return GDK_EVENT_STOP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->search_entry), (GdkEvent *)event))
|
else if (gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->search_entry), event))
|
||||||
{
|
{
|
||||||
if (priv->operation_mode != OPERATION_MODE_SEARCH)
|
if (priv->operation_mode != OPERATION_MODE_SEARCH)
|
||||||
operation_mode_set (impl, OPERATION_MODE_SEARCH);
|
operation_mode_set (impl, OPERATION_MODE_SEARCH);
|
||||||
return TRUE;
|
return GDK_EVENT_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->key_press_event (widget, event))
|
if (GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->event (widget, event))
|
||||||
return TRUE;
|
return GDK_EVENT_STOP;
|
||||||
|
|
||||||
return FALSE;
|
return GDK_EVENT_PROPAGATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback used from gtk_tree_selection_selected_foreach(); adds a bookmark for
|
/* Callback used from gtk_tree_selection_selected_foreach(); adds a bookmark for
|
||||||
@ -2537,14 +2540,17 @@ location_entry_create (GtkFileChooserWidget *impl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
external_entry_key_press (GtkWidget *entry,
|
external_entry_event (GtkWidget *entry,
|
||||||
GdkEventKey *event,
|
GdkEvent *event,
|
||||||
GtkFileChooserWidget *impl)
|
GtkFileChooserWidget *impl)
|
||||||
{
|
{
|
||||||
/* Since the entry is not a descendent of the file chooser widget
|
/* Since the entry is not a descendent of the file chooser widget
|
||||||
* in this case, we need to manually make our bindings apply.
|
* in this case, we need to manually make our bindings apply.
|
||||||
*/
|
*/
|
||||||
return gtk_bindings_activate_event (G_OBJECT (impl), event);
|
if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
|
||||||
|
return GDK_EVENT_PROPAGATE;
|
||||||
|
|
||||||
|
return gtk_bindings_activate_event (G_OBJECT (impl), (GdkEventKey *)event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Creates the widgets specific to Save mode */
|
/* Creates the widgets specific to Save mode */
|
||||||
@ -2569,8 +2575,8 @@ save_widgets_create (GtkFileChooserWidget *impl)
|
|||||||
priv->location_entry = priv->external_entry;
|
priv->location_entry = priv->external_entry;
|
||||||
location_entry_setup (impl);
|
location_entry_setup (impl);
|
||||||
|
|
||||||
g_signal_connect_after (priv->external_entry, "key-press-event",
|
g_signal_connect_after (priv->external_entry, "event",
|
||||||
G_CALLBACK (external_entry_key_press), impl);
|
G_CALLBACK (external_entry_event), impl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2611,7 +2617,7 @@ save_widgets_destroy (GtkFileChooserWidget *impl)
|
|||||||
|
|
||||||
if (priv->external_entry && priv->external_entry == priv->location_entry)
|
if (priv->external_entry && priv->external_entry == priv->location_entry)
|
||||||
{
|
{
|
||||||
g_signal_handlers_disconnect_by_func (priv->external_entry, external_entry_key_press, impl);
|
g_signal_handlers_disconnect_by_func (priv->external_entry, external_entry_event, impl);
|
||||||
|
|
||||||
location_entry_disconnect (impl);
|
location_entry_disconnect (impl);
|
||||||
priv->location_entry = NULL;
|
priv->location_entry = NULL;
|
||||||
@ -7980,7 +7986,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
|
|||||||
widget_class->hierarchy_changed = gtk_file_chooser_widget_hierarchy_changed;
|
widget_class->hierarchy_changed = gtk_file_chooser_widget_hierarchy_changed;
|
||||||
widget_class->style_updated = gtk_file_chooser_widget_style_updated;
|
widget_class->style_updated = gtk_file_chooser_widget_style_updated;
|
||||||
widget_class->display_changed = gtk_file_chooser_widget_display_changed;
|
widget_class->display_changed = gtk_file_chooser_widget_display_changed;
|
||||||
widget_class->key_press_event = gtk_file_chooser_widget_key_press_event;
|
widget_class->event = gtk_file_chooser_widget_event;
|
||||||
widget_class->measure = gtk_file_chooser_widget_measure;
|
widget_class->measure = gtk_file_chooser_widget_measure;
|
||||||
widget_class->size_allocate = gtk_file_chooser_widget_size_allocate;
|
widget_class->size_allocate = gtk_file_chooser_widget_size_allocate;
|
||||||
widget_class->snapshot = gtk_file_chooser_widget_snapshot;
|
widget_class->snapshot = gtk_file_chooser_widget_snapshot;
|
||||||
|
Loading…
Reference in New Issue
Block a user