summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaximiliano Sandoval R <msandova@gnome.org>2021-10-11 00:29:43 +0200
committerDavid King <amigadave@amigadave.com>2022-03-28 17:11:49 +0100
commitc71055611a45bd83a69f386ebd6ffafed370f6dd (patch)
treeb6e5fbe940c6a0915d232da9195b492375af9cbc
parent01bf4423f6dee07f9a7efcd8ba42410e78ccc7f2 (diff)
downloadgnome-logs-c71055611a45bd83a69f386ebd6ffafed370f6dd.tar.gz
window: Use set_key_capture_widget in entry bar
-rw-r--r--data/gl-window.ui2
-rw-r--r--src/gl-eventviewlist.c39
-rw-r--r--src/gl-eventviewlist.h3
-rw-r--r--src/gl-window.c23
4 files changed, 16 insertions, 51 deletions
diff --git a/data/gl-window.ui b/data/gl-window.ui
index dd3e3fa..297eb88 100644
--- a/data/gl-window.ui
+++ b/data/gl-window.ui
@@ -3,8 +3,6 @@
<template class="GlWindow" parent="AdwApplicationWindow">
<property name="default-width">1200</property>
<property name="default-height">600</property>
- <!-- TODO -->
- <!-- <signal name="key-press-event" handler="on_gl_window_key_press_event"/> -->
<child>
<object class="GtkBox" id="event_box">
<property name="orientation">vertical</property>
diff --git a/src/gl-eventviewlist.c b/src/gl-eventviewlist.c
index 0369756..7cd30da 100644
--- a/src/gl-eventviewlist.c
+++ b/src/gl-eventviewlist.c
@@ -414,29 +414,6 @@ gl_event_view_list_get_boot_ids (GlEventViewList *view)
return gl_journal_model_get_boot_ids (priv->journal_model);
}
-gboolean
-gl_event_view_list_handle_search_event (GlEventViewList *view,
- GAction *action,
- GdkEvent *event)
-{
- GlEventViewListPrivate *priv;
-
- priv = gl_event_view_list_get_instance_private (view);
-
- if (g_action_get_enabled (action))
- {
- if (gtk_search_bar_handle_event (GTK_SEARCH_BAR (priv->event_search),
- event) == GDK_EVENT_STOP)
- {
- g_action_change_state (action, g_variant_new_boolean (TRUE));
-
- return GDK_EVENT_STOP;
- }
- }
-
- return GDK_EVENT_PROPAGATE;
-}
-
void
gl_event_view_list_set_search_mode (GlEventViewList *view,
gboolean state)
@@ -1018,12 +995,28 @@ gl_event_view_list_finalize (GObject *object)
}
static void
+gl_event_view_list_realize (GtkWidget *widget)
+{
+ GlEventViewList *view = GL_EVENT_VIEW_LIST (widget);
+ GlEventViewListPrivate *priv = gl_event_view_list_get_instance_private (view);
+ GtkRoot *root;
+
+ GTK_WIDGET_CLASS (gl_event_view_list_parent_class)->realize (widget);
+
+ root = gtk_widget_get_root (widget);
+
+ gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (priv->event_search),
+ GTK_WIDGET (root));
+}
+
+static void
gl_event_view_list_class_init (GlEventViewListClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gobject_class->finalize = gl_event_view_list_finalize;
+ widget_class->realize = gl_event_view_list_realize;
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Logs/gl-eventviewlist.ui");
diff --git a/src/gl-eventviewlist.h b/src/gl-eventviewlist.h
index e0ad0c8..53bfdab 100644
--- a/src/gl-eventviewlist.h
+++ b/src/gl-eventviewlist.h
@@ -32,9 +32,6 @@ G_DECLARE_FINAL_TYPE (GlEventViewList, gl_event_view_list, GL, EVENT_VIEW_LIST,
GtkWidget * gl_event_view_list_new (void);
GlRowEntry *gl_event_view_list_get_detail_entry (GlEventViewList *view);
-gboolean gl_event_view_list_handle_search_event (GlEventViewList *view,
- GAction *action,
- GdkEvent *event);
void gl_event_view_list_set_search_mode (GlEventViewList *view, gboolean state);
void gl_event_view_list_set_sort_order (GlEventViewList *view, GlSortOrder sort_order);
void gl_event_view_list_view_boot (GlEventViewList *view, const gchar *match);
diff --git a/src/gl-window.c b/src/gl-window.c
index 8bbbbd4..3227bc8 100644
--- a/src/gl-window.c
+++ b/src/gl-window.c
@@ -256,27 +256,6 @@ on_category_list_changed (GlCategoryList *list,
g_free (current_boot);
}
-static gboolean
-on_gl_window_key_press_event (GlWindow *window,
- GdkEvent *event,
- gpointer user_data)
-{
- GlWindowPrivate *priv;
- GlEventViewList *event_list;
- GAction *action;
-
- priv = gl_window_get_instance_private (window);
- action = g_action_map_lookup_action (G_ACTION_MAP (window), "search");
- event_list = GL_EVENT_VIEW_LIST (priv->event_list);
-
- if (gl_event_view_list_handle_search_event (event_list, action, event) == GDK_EVENT_STOP)
- {
- return GDK_EVENT_STOP;
- }
-
- return GDK_EVENT_PROPAGATE;
-}
-
static void
on_help_button_clicked (GlWindow *window,
gint response_id,
@@ -356,8 +335,6 @@ gl_window_class_init (GlWindowClass *klass)
info_bar);
gtk_widget_class_bind_template_callback (widget_class,
- on_gl_window_key_press_event);
- gtk_widget_class_bind_template_callback (widget_class,
on_help_button_clicked);
gtk_widget_class_bind_template_callback (widget_class,
on_ignore_button_clicked);