mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 22:41:43 +00:00
gtkfilechooserentry: Use GtkEntry key controller for focus-out handling
Expose the GtkEntry key controller in private API, so we don't have to create yet another one just to handle focus-out.
This commit is contained in:
parent
e08e15ba51
commit
aaf1e4995c
@ -9580,3 +9580,11 @@ set_enable_emoji_completion (GtkEntry *entry,
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_ENABLE_EMOJI_COMPLETION]);
|
||||
}
|
||||
|
||||
GtkEventController *
|
||||
gtk_entry_get_key_controller (GtkEntry *entry)
|
||||
{
|
||||
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
|
||||
|
||||
return priv->key_controller;
|
||||
}
|
||||
|
@ -97,6 +97,7 @@ void gtk_entry_set_positions (GtkEntry *entry,
|
||||
int current_pos,
|
||||
int selection_bound);
|
||||
|
||||
GtkEventController * gtk_entry_get_key_controller (GtkEntry *entry);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "gtkcelllayout.h"
|
||||
#include "gtkcellrenderertext.h"
|
||||
#include "gtkentry.h"
|
||||
#include "gtkentryprivate.h"
|
||||
#include "gtkfilesystemmodel.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkmain.h"
|
||||
@ -86,8 +86,6 @@ static void gtk_file_chooser_entry_dispose (GObject *object)
|
||||
static void gtk_file_chooser_entry_grab_focus (GtkWidget *widget);
|
||||
static gboolean gtk_file_chooser_entry_tab_handler (GtkWidget *widget,
|
||||
GdkEvent *event);
|
||||
static gboolean gtk_file_chooser_entry_event (GtkWidget *widget,
|
||||
GdkEvent *event);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
static gint insert_text_callback (GtkFileChooserEntry *widget,
|
||||
@ -169,7 +167,6 @@ _gtk_file_chooser_entry_class_init (GtkFileChooserEntryClass *class)
|
||||
gobject_class->dispatch_properties_changed = gtk_file_chooser_entry_dispatch_properties_changed;
|
||||
|
||||
widget_class->grab_focus = gtk_file_chooser_entry_grab_focus;
|
||||
widget_class->event = gtk_file_chooser_entry_event;
|
||||
|
||||
signals[HIDE_ENTRY] =
|
||||
g_signal_new (I_("hide-entry"),
|
||||
@ -258,6 +255,13 @@ match_func (GtkEntryCompletion *compl,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
chooser_entry_focus_out (GtkEventControllerKey *key_controller,
|
||||
GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
set_complete_on_load (chooser_entry, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
@ -298,6 +302,10 @@ _gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry)
|
||||
g_signal_connect (chooser_entry, "event",
|
||||
G_CALLBACK (gtk_file_chooser_entry_tab_handler), NULL);
|
||||
|
||||
g_signal_connect (gtk_entry_get_key_controller (GTK_ENTRY (chooser_entry)),
|
||||
"focus-out", G_CALLBACK (chooser_entry_focus_out),
|
||||
chooser_entry);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
g_signal_connect (chooser_entry, "insert-text",
|
||||
G_CALLBACK (insert_text_callback), NULL);
|
||||
@ -543,27 +551,6 @@ gtk_file_chooser_entry_tab_handler (GtkWidget *widget,
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_file_chooser_entry_event (GtkWidget *widget,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (widget);
|
||||
|
||||
if (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE)
|
||||
{
|
||||
gboolean focus_in;
|
||||
|
||||
gdk_event_get_focus_in (event, &focus_in);
|
||||
|
||||
if (!focus_in)
|
||||
set_complete_on_load (chooser_entry, FALSE);
|
||||
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
static void
|
||||
update_inline_completion (GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user