mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
gtk: Drop gtk_search_[entry|bar]_handle_event()
This is now unused, and unrecommended.
This commit is contained in:
parent
edccf89020
commit
b842bf7bf5
@ -2493,7 +2493,6 @@ gtk_search_bar_get_search_mode
|
||||
gtk_search_bar_set_search_mode
|
||||
gtk_search_bar_get_show_close_button
|
||||
gtk_search_bar_set_show_close_button
|
||||
gtk_search_bar_handle_event
|
||||
gtk_search_bar_set_key_capture_widget
|
||||
gtk_search_bar_get_key_capture_widget
|
||||
<SUBSECTION Standard>
|
||||
@ -2512,7 +2511,6 @@ gtk_search_bar_get_type
|
||||
<TITLE>GtkSearchEntry</TITLE>
|
||||
GtkSearchEntry
|
||||
gtk_search_entry_new
|
||||
gtk_search_entry_handle_event
|
||||
gtk_search_entry_set_key_capture_widget
|
||||
gtk_search_entry_get_key_capture_widget
|
||||
<SUBSECTION Standard>
|
||||
|
@ -121,124 +121,6 @@ preedit_changed_cb (GtkEntry *entry,
|
||||
*preedit_changed = TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_search_bar_handle_event_for_entry (GtkSearchBar *bar,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);
|
||||
gboolean handled;
|
||||
gboolean preedit_changed;
|
||||
guint preedit_change_id;
|
||||
gboolean res;
|
||||
char *old_text, *new_text;
|
||||
guint keyval, state;
|
||||
|
||||
gdk_event_get_keyval (event, &keyval);
|
||||
gdk_event_get_state (event, &state);
|
||||
|
||||
if (gtk_search_entry_is_keynav (keyval, state) ||
|
||||
keyval == GDK_KEY_space ||
|
||||
keyval == GDK_KEY_Menu)
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
||||
if (!gtk_widget_get_realized (priv->entry))
|
||||
gtk_widget_realize (priv->entry);
|
||||
|
||||
handled = GDK_EVENT_PROPAGATE;
|
||||
preedit_changed = FALSE;
|
||||
preedit_change_id = g_signal_connect (priv->entry, "preedit-changed",
|
||||
G_CALLBACK (preedit_changed_cb), &preedit_changed);
|
||||
|
||||
old_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (priv->entry)));
|
||||
res = gtk_widget_event (priv->entry, event);
|
||||
new_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (priv->entry)));
|
||||
|
||||
g_signal_handler_disconnect (priv->entry, preedit_change_id);
|
||||
|
||||
if ((res && g_strcmp0 (new_text, old_text) != 0) || preedit_changed)
|
||||
handled = GDK_EVENT_STOP;
|
||||
|
||||
g_free (old_text);
|
||||
g_free (new_text);
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_search_bar_handle_event:
|
||||
* @bar: a #GtkSearchBar
|
||||
* @event: a #GdkEvent containing key press events
|
||||
*
|
||||
* This function should be called when the top-level
|
||||
* window which contains the search bar received a key event.
|
||||
*
|
||||
* If the key event is handled by the search bar, the bar will
|
||||
* be shown, the entry populated with the entered text and %GDK_EVENT_STOP
|
||||
* will be returned. The caller should ensure that events are
|
||||
* not propagated further.
|
||||
*
|
||||
* If no entry has been connected to the search bar, using
|
||||
* gtk_search_bar_connect_entry(), this function will return
|
||||
* immediately with a warning.
|
||||
*
|
||||
* ## Showing the search bar on key presses
|
||||
*
|
||||
* |[<!-- language="C" -->
|
||||
* static gboolean
|
||||
* on_key_press_event (GtkWidget *widget,
|
||||
* GdkEvent *event,
|
||||
* gpointer user_data)
|
||||
* {
|
||||
* GtkSearchBar *bar = GTK_SEARCH_BAR (user_data);
|
||||
* return gtk_search_bar_handle_event (bar, event);
|
||||
* }
|
||||
*
|
||||
* static void
|
||||
* create_toplevel (void)
|
||||
* {
|
||||
* GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
* GtkWindow *search_bar = gtk_search_bar_new ();
|
||||
*
|
||||
* // Add more widgets to the window...
|
||||
*
|
||||
* g_signal_connect (window,
|
||||
* "key-press-event",
|
||||
* G_CALLBACK (on_key_press_event),
|
||||
* search_bar);
|
||||
* }
|
||||
* ]|
|
||||
*
|
||||
* Returns: %GDK_EVENT_STOP if the key press event resulted
|
||||
* in text being entered in the search entry (and revealing
|
||||
* the search bar if necessary), %GDK_EVENT_PROPAGATE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
gtk_search_bar_handle_event (GtkSearchBar *bar,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);
|
||||
gboolean handled;
|
||||
|
||||
if (priv->reveal_child)
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
||||
if (priv->entry == NULL)
|
||||
{
|
||||
g_warning ("The search bar does not have an entry connected to it. Call gtk_search_bar_connect_entry() to connect one.");
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
if (GTK_IS_SEARCH_ENTRY (priv->entry))
|
||||
handled = gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->entry), event);
|
||||
else
|
||||
handled = gtk_search_bar_handle_event_for_entry (bar, event);
|
||||
|
||||
if (handled == GDK_EVENT_STOP)
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), TRUE);
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
static void
|
||||
reveal_child_changed_cb (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
|
@ -92,10 +92,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_search_bar_set_show_close_button (GtkSearchBar *bar,
|
||||
gboolean visible);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_search_bar_handle_event (GtkSearchBar *bar,
|
||||
GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_search_bar_set_key_capture_widget (GtkSearchBar *bar,
|
||||
GtkWidget *widget);
|
||||
|
@ -614,54 +614,6 @@ gtk_search_entry_is_keynav (guint keyval,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_search_entry_handle_event:
|
||||
* @entry: a #GtkSearchEntry
|
||||
* @event: a key event
|
||||
*
|
||||
* This function should be called when the top-level window
|
||||
* which contains the search entry received a key event. If
|
||||
* the entry is part of a #GtkSearchBar, it is preferable
|
||||
* to call gtk_search_bar_handle_event() instead, which will
|
||||
* reveal the entry in addition to passing the event to this
|
||||
* function.
|
||||
*
|
||||
* If the key event is handled by the search entry and starts
|
||||
* or continues a search, %GDK_EVENT_STOP will be returned.
|
||||
* The caller should ensure that the entry is shown in this
|
||||
* case, and not propagate the event further.
|
||||
*
|
||||
* Returns: %GDK_EVENT_STOP if the key press event resulted
|
||||
* in a search beginning or continuing, %GDK_EVENT_PROPAGATE
|
||||
* otherwise.
|
||||
*/
|
||||
gboolean
|
||||
gtk_search_entry_handle_event (GtkSearchEntry *entry,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
gboolean handled;
|
||||
guint keyval, state;
|
||||
|
||||
if (!gtk_widget_get_realized (GTK_WIDGET (entry)))
|
||||
gtk_widget_realize (GTK_WIDGET (entry));
|
||||
|
||||
gdk_event_get_keyval (event, &keyval);
|
||||
gdk_event_get_state (event, &state);
|
||||
|
||||
if (gtk_search_entry_is_keynav (keyval, state) ||
|
||||
keyval == GDK_KEY_space ||
|
||||
keyval == GDK_KEY_Menu)
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
||||
priv->content_changed = FALSE;
|
||||
priv->search_stopped = FALSE;
|
||||
|
||||
handled = gtk_widget_event (GTK_WIDGET (entry), event);
|
||||
|
||||
return handled && priv->content_changed && !priv->search_stopped ? GDK_EVENT_STOP : GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
capture_widget_key_handled (GtkEventControllerKey *controller,
|
||||
guint keyval,
|
||||
|
@ -68,10 +68,6 @@ GType gtk_search_entry_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget* gtk_search_entry_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_search_entry_handle_event (GtkSearchEntry *entry,
|
||||
GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_search_entry_set_key_capture_widget (GtkSearchEntry *entry,
|
||||
GtkWidget *widget);
|
||||
|
Loading…
Reference in New Issue
Block a user