[libdazzle] suggestions: track entry focus in popover
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] suggestions: track entry focus in popover
- Date: Sun, 27 Jan 2019 20:38:24 +0000 (UTC)
commit 180bbc6b72a39bf233b6673ec4f21b6563687dbb
Author: Christian Hergert <chergert redhat com>
Date: Sun Jan 27 12:36:37 2019 -0800
suggestions: track entry focus in popover
src/suggestions/dzl-suggestion-entry.c | 21 +++++++++++++++++++++
src/suggestions/dzl-suggestion-popover.c | 12 ++++++++++++
src/suggestions/dzl-suggestion-private.h | 2 ++
3 files changed, 35 insertions(+)
---
diff --git a/src/suggestions/dzl-suggestion-entry.c b/src/suggestions/dzl-suggestion-entry.c
index 4fb8382..fa268fa 100644
--- a/src/suggestions/dzl-suggestion-entry.c
+++ b/src/suggestions/dzl-suggestion-entry.c
@@ -139,15 +139,35 @@ dzl_suggestion_entry_hide_suggestions (DzlSuggestionEntry *self)
DZL_EXIT;
}
+static gboolean
+dzl_suggestion_entry_focus_in_event (GtkWidget *widget,
+ GdkEventFocus *event)
+{
+ DzlSuggestionEntry *self = (DzlSuggestionEntry *)widget;
+ DzlSuggestionEntryPrivate *priv = dzl_suggestion_entry_get_instance_private (self);
+
+ g_assert (DZL_IS_SUGGESTION_ENTRY (self));
+ g_assert (event != NULL);
+
+ if (priv->popover)
+ _dzl_suggestion_popover_set_focused (priv->popover, TRUE);
+
+ return GTK_WIDGET_CLASS (dzl_suggestion_entry_parent_class)->focus_in_event (widget, event);
+}
+
static gboolean
dzl_suggestion_entry_focus_out_event (GtkWidget *widget,
GdkEventFocus *event)
{
DzlSuggestionEntry *self = (DzlSuggestionEntry *)widget;
+ DzlSuggestionEntryPrivate *priv = dzl_suggestion_entry_get_instance_private (self);
g_assert (DZL_IS_SUGGESTION_ENTRY (self));
g_assert (event != NULL);
+ if (priv->popover)
+ _dzl_suggestion_popover_set_focused (priv->popover, FALSE);
+
g_signal_emit (self, signals [HIDE_SUGGESTIONS], 0);
return GTK_WIDGET_CLASS (dzl_suggestion_entry_parent_class)->focus_out_event (widget, event);
@@ -479,6 +499,7 @@ dzl_suggestion_entry_class_init (DzlSuggestionEntryClass *klass)
object_class->set_property = dzl_suggestion_entry_set_property;
widget_class->destroy = dzl_suggestion_entry_destroy;
+ widget_class->focus_in_event = dzl_suggestion_entry_focus_in_event;
widget_class->focus_out_event = dzl_suggestion_entry_focus_out_event;
widget_class->hierarchy_changed = dzl_suggestion_entry_hierarchy_changed;
widget_class->key_press_event = dzl_suggestion_entry_key_press_event;
diff --git a/src/suggestions/dzl-suggestion-popover.c b/src/suggestions/dzl-suggestion-popover.c
index a2b92f2..f88989b 100644
--- a/src/suggestions/dzl-suggestion-popover.c
+++ b/src/suggestions/dzl-suggestion-popover.c
@@ -65,6 +65,7 @@ struct _DzlSuggestionPopover
PangoEllipsizeMode title_ellipsize;
guint popup_requested : 1;
+ guint entry_focused : 1;
};
enum {
@@ -1143,3 +1144,14 @@ _dzl_suggestion_popover_set_click_mode (DzlSuggestionPopover *self,
gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (self->list_box), single_click);
}
+
+void
+_dzl_suggestion_popover_set_focused (DzlSuggestionPopover *self,
+ gboolean entry_focused)
+{
+ g_return_if_fail (DZL_IS_SUGGESTION_POPOVER (self));
+
+ self->entry_focused = !!entry_focused;
+ if (!entry_focused)
+ self->popup_requested = FALSE;
+}
diff --git a/src/suggestions/dzl-suggestion-private.h b/src/suggestions/dzl-suggestion-private.h
index 19f73df..2f076c9 100644
--- a/src/suggestions/dzl-suggestion-private.h
+++ b/src/suggestions/dzl-suggestion-private.h
@@ -26,6 +26,8 @@
void _dzl_suggestion_entry_reposition (DzlSuggestionEntry *entry,
DzlSuggestionPopover *popover);
+void _dzl_suggestion_popover_set_focused (DzlSuggestionPopover *self,
+ gboolean entry_focused);
void _dzl_suggestion_popover_set_max_height (DzlSuggestionPopover *popover,
gint max_height);
void _dzl_suggestion_popover_adjust_margin (DzlSuggestionPopover *popover,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]