[gnome-builder/wip/chergert/headerbar] omnibar: add support for omnibar:active state flag
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/headerbar] omnibar: add support for omnibar:active state flag
- Date: Sun, 26 Jun 2016 23:37:21 +0000 (UTC)
commit 4a6c4e4fd5930bb4fc406c0f55c51827fab9d918
Author: Christian Hergert <chergert redhat com>
Date: Sun Jun 26 16:37:14 2016 -0700
omnibar: add support for omnibar:active state flag
data/theme/Adwaita-shared.css | 3 ++-
libide/workbench/ide-omni-bar.c | 29 +++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/data/theme/Adwaita-shared.css b/data/theme/Adwaita-shared.css
index 78abae7..b64a9d9 100644
--- a/data/theme/Adwaita-shared.css
+++ b/data/theme/Adwaita-shared.css
@@ -151,7 +151,8 @@ omnibar entry {
background-color: @theme_bg_color;
color: alpha(@theme_fg_color, 0.8);
}
-omnibar:hover entry {
+omnibar:hover entry,
+omnibar:active entry {
background-color: mix(@theme_bg_color, @content_view_bg, 0.9);
color: @theme_fg_color;
}
diff --git a/libide/workbench/ide-omni-bar.c b/libide/workbench/ide-omni-bar.c
index 0000533..a9ef27a 100644
--- a/libide/workbench/ide-omni-bar.c
+++ b/libide/workbench/ide-omni-bar.c
@@ -476,13 +476,36 @@ multipress_pressed_cb (GtkGestureMultiPress *gesture,
gdouble y,
IdeOmniBar *self)
{
+ GtkStyleContext *style_context;
+ GtkStateFlags state_flags;
+
g_assert (IDE_IS_OMNI_BAR (self));
gtk_widget_show (GTK_WIDGET (self->popover));
+
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (self));
+ state_flags = gtk_style_context_get_state (style_context);
+ gtk_style_context_set_state (style_context, state_flags | GTK_STATE_FLAG_ACTIVE);
+
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
}
static void
+ide_omni_bar_popover_closed (IdeOmniBar *self,
+ GtkPopover *popover)
+{
+ GtkStyleContext *style_context;
+ GtkStateFlags state_flags;
+
+ g_assert (IDE_IS_OMNI_BAR (self));
+ g_assert (GTK_IS_POPOVER (popover));
+
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (self));
+ state_flags = gtk_style_context_get_state (style_context);
+ gtk_style_context_set_state (style_context, state_flags & ~GTK_STATE_FLAG_ACTIVE);
+}
+
+static void
ide_omni_bar_finalize (GObject *object)
{
IdeOmniBar *self = (IdeOmniBar *)object;
@@ -556,6 +579,12 @@ ide_omni_bar_init (IdeOmniBar *self)
self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->popover,
+ "closed",
+ G_CALLBACK (ide_omni_bar_popover_closed),
+ self,
+ G_CONNECT_SWAPPED);
+
self->gesture = gtk_gesture_multi_press_new (GTK_WIDGET (self->event_box));
g_signal_connect (self->gesture, "pressed", G_CALLBACK (multipress_pressed_cb), self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]