[gnome-builder/wip/libide-merge: 21/35] focus highlight color
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide-merge: 21/35] focus highlight color
- Date: Thu, 19 Mar 2015 08:56:19 +0000 (UTC)
commit 232cc234ffc07f95916a4ea1445d1fca2fd75ba7
Author: Christian Hergert <christian hergert me>
Date: Wed Mar 18 22:45:38 2015 -0700
focus highlight color
src/resources/css/builder.Adwaita.css | 4 ++
src/views/gb-view-grid.c | 25 +++++++++++++-
src/views/gb-view-stack.c | 61 ---------------------------------
3 files changed, 28 insertions(+), 62 deletions(-)
---
diff --git a/src/resources/css/builder.Adwaita.css b/src/resources/css/builder.Adwaita.css
index 98bc405..aefadab 100644
--- a/src/resources/css/builder.Adwaita.css
+++ b/src/resources/css/builder.Adwaita.css
@@ -214,3 +214,7 @@ GbDocumentStack .button {
GbViewStack GtkBox.header.notebook {
border-bottom: 1px solid @borders;
}
+
+GbViewStack:not(.focused) GtkBox.header.notebook {
+ background-color: shade (@theme_bg_color, 0.95);
+}
diff --git a/src/views/gb-view-grid.c b/src/views/gb-view-grid.c
index 4857f40..fc659d5 100644
--- a/src/views/gb-view-grid.c
+++ b/src/views/gb-view-grid.c
@@ -625,6 +625,29 @@ gb_view_grid_grab_focus (GtkWidget *widget)
}
static void
+gb_view_grid_set_focus (GbViewGrid *self,
+ GbViewStack *stack)
+{
+ if (self->last_focus)
+ {
+ GtkStyleContext *style_context;
+
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (self->last_focus));
+ gtk_style_context_remove_class (style_context, "focused");
+ ide_clear_weak_pointer (&self->last_focus);
+ }
+
+ if (stack != NULL)
+ {
+ GtkStyleContext *style_context;
+
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (stack));
+ gtk_style_context_add_class (style_context, "focused");
+ ide_set_weak_pointer (&self->last_focus, stack);
+ }
+}
+
+static void
gb_view_grid_toplevel_set_focus (GtkWidget *toplevel,
GtkWidget *focus,
GbViewGrid *self)
@@ -639,7 +662,7 @@ gb_view_grid_toplevel_set_focus (GtkWidget *toplevel,
parent = gtk_widget_get_parent (parent);
if (GB_IS_VIEW_STACK (parent))
- ide_set_weak_pointer (&self->last_focus, GB_VIEW_STACK (parent));
+ gb_view_grid_set_focus (self, GB_VIEW_STACK (parent));
}
}
diff --git a/src/views/gb-view-stack.c b/src/views/gb-view-stack.c
index 8508ad7..3e70b9d 100644
--- a/src/views/gb-view-stack.c
+++ b/src/views/gb-view-stack.c
@@ -118,63 +118,6 @@ gb_view_stack__notify_visible_child (GbViewStack *self,
}
static void
-gb_view_stack__set_focus (GbViewStack *self,
- GtkWidget *focus_widget,
- GtkWindow *toplevel)
-{
- g_assert (GB_IS_VIEW_STACK (self));
- g_assert (!focus_widget || GTK_IS_WIDGET (focus_widget));
- g_assert (!toplevel || GTK_IS_WIDGET (toplevel));
-
- self->focused = focus_widget && gtk_widget_is_ancestor (GTK_WIDGET (self), focus_widget);
-}
-
-static void
-gb_view_stack_hierarchy_changed (GtkWidget *widget,
- GtkWidget *previous_toplevel)
-{
- GbViewStack *self = (GbViewStack *)widget;
- GtkWidget *toplevel;
-
- g_assert (GB_IS_VIEW_STACK (self));
- g_assert (!previous_toplevel || GTK_IS_WIDGET (previous_toplevel));
-
- if (GTK_IS_WINDOW (previous_toplevel))
- g_signal_handlers_disconnect_by_func (previous_toplevel,
- G_CALLBACK (gb_view_stack__set_focus),
- self);
-
- toplevel = gtk_widget_get_toplevel (widget);
- if (GTK_IS_WINDOW (toplevel))
- g_signal_connect_object (toplevel,
- "set-focus",
- G_CALLBACK (gb_view_stack__set_focus),
- self,
- G_CONNECT_SWAPPED);
-}
-
-static gboolean
-gb_view_stack_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- GbViewStack *self = (GbViewStack *)widget;
- GtkStyleContext *style_context;
- gboolean ret;
-
- g_assert (GB_IS_VIEW_STACK (self));
- g_assert (cr);
-
- style_context = gtk_widget_get_style_context (widget);
- gtk_style_context_save (style_context);
- if (self->focused)
- gtk_style_context_add_class (style_context, "focused");
- ret = GTK_WIDGET_CLASS (gb_view_stack_parent_class)->draw (widget, cr);
- gtk_style_context_restore (style_context);
-
- return ret;
-}
-
-static void
gb_view_stack_constructed (GObject *object)
{
GbViewStack *self = (GbViewStack *)object;
@@ -238,7 +181,6 @@ static void
gb_view_stack_class_init (GbViewStackClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
object_class->constructed = gb_view_stack_constructed;
@@ -246,9 +188,6 @@ gb_view_stack_class_init (GbViewStackClass *klass)
object_class->get_property = gb_view_stack_get_property;
object_class->set_property = gb_view_stack_set_property;
- widget_class->draw = gb_view_stack_draw;
- widget_class->hierarchy_changed = gb_view_stack_hierarchy_changed;
-
container_class->add = gb_view_stack_add;
container_class->remove = gb_view_stack_real_remove;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]