[gnome-builder] style: style sidebar header similar to view-stacks
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] style: style sidebar header similar to view-stacks
- Date: Mon, 13 Apr 2015 23:44:12 +0000 (UTC)
commit 1124d22289ee62e4fe477dedec05358fe4f8c7c4
Author: Christian Hergert <christian hergert me>
Date: Mon Apr 13 16:42:02 2015 -0700
style: style sidebar header similar to view-stacks
This helps simplify the focus to the eye as the view stacks will lose
focus highlight now when we are focused in the project tree. additionally,
the project tree will lose focus highlight when we select the view
stacks.
Overall, this makes things feel like "columns".
data/theme/Adwaita-shared.css | 3 ++-
data/ui/gb-editor-workspace.ui | 3 ++-
src/editor/gb-editor-workspace-private.h | 1 +
src/editor/gb-editor-workspace.c | 28 ++++++++++++++++++++++++++++
src/views/gb-view-grid.c | 2 ++
5 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/data/theme/Adwaita-shared.css b/data/theme/Adwaita-shared.css
index bbf6639..e13e661 100644
--- a/data/theme/Adwaita-shared.css
+++ b/data/theme/Adwaita-shared.css
@@ -124,7 +124,8 @@ GbDocumentStack .button {
GbViewStack GtkBox.header.notebook {
border-bottom: 1px solid @borders;
}
-GbViewStack:not(.focused) GtkBox.header.notebook {
+GbViewStack:not(.focused) GtkBox.header.notebook,
+#project_sidebar_header:not(.focused) {
background-color: shade (@theme_bg_color, 0.95);
}
GbEditorWorkspace > GtkPaned > GtkBox > GtkBox.header.notebook {
diff --git a/data/ui/gb-editor-workspace.ui b/data/ui/gb-editor-workspace.ui
index 34180bb..9bef3dc 100644
--- a/data/ui/gb-editor-workspace.ui
+++ b/data/ui/gb-editor-workspace.ui
@@ -13,7 +13,8 @@
<property name="orientation">vertical</property>
<property name="visible">false</property>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="project_sidebar_header">
+ <property name="name">project_sidebar_header</property>
<property name="orientation">horizontal</property>
<property name="visible">true</property>
<style>
diff --git a/src/editor/gb-editor-workspace-private.h b/src/editor/gb-editor-workspace-private.h
index 8abee09..43259e8 100644
--- a/src/editor/gb-editor-workspace-private.h
+++ b/src/editor/gb-editor-workspace-private.h
@@ -33,6 +33,7 @@ struct _GbEditorWorkspace
GtkPaned *project_paned;
GtkBox *project_sidebar;
+ GtkBox *project_sidebar_header;
GtkMenuButton *project_button;
GtkSpinner *project_spinner;
GbProjectTree *project_tree;
diff --git a/src/editor/gb-editor-workspace.c b/src/editor/gb-editor-workspace.c
index 04b18fb..17f1f4c 100644
--- a/src/editor/gb-editor-workspace.c
+++ b/src/editor/gb-editor-workspace.c
@@ -149,6 +149,27 @@ gb_editor_workspace_context_changed (GtkWidget *workspace,
}
static void
+gb_editor_workspace__project_tree_notify_has_focus (GbEditorWorkspace *self,
+ GParamSpec *pspec,
+ GbProjectTree *project_tree)
+{
+ GtkStyleContext *style_context;
+ gboolean has_focus;
+
+ g_assert (GB_IS_EDITOR_WORKSPACE (self));
+ g_assert (GB_IS_PROJECT_TREE (project_tree));
+
+ has_focus = gtk_widget_has_focus (GTK_WIDGET (project_tree));
+
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (self->project_sidebar_header));
+
+ if (has_focus)
+ gtk_style_context_add_class (style_context, "focused");
+ else
+ gtk_style_context_remove_class (style_context, "focused");
+}
+
+static void
gb_editor_workspace_grab_focus (GtkWidget *widget)
{
GbEditorWorkspace *self = (GbEditorWorkspace *)widget;
@@ -167,6 +188,12 @@ gb_editor_workspace_constructed (GObject *object)
G_OBJECT_CLASS (gb_editor_workspace_parent_class)->constructed (object);
+ g_signal_connect_object (self->project_tree,
+ "notify::has-focus",
+ G_CALLBACK (gb_editor_workspace__project_tree_notify_has_focus),
+ self,
+ G_CONNECT_SWAPPED);
+
gb_editor_workspace_actions_init (self);
IDE_EXIT;
@@ -254,6 +281,7 @@ gb_editor_workspace_class_init (GbEditorWorkspaceClass *klass)
GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_button);
GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_paned);
GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_sidebar);
+ GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_sidebar_header);
GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_spinner);
GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_tree);
GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, view_grid);
diff --git a/src/views/gb-view-grid.c b/src/views/gb-view-grid.c
index 3656508..732df81 100644
--- a/src/views/gb-view-grid.c
+++ b/src/views/gb-view-grid.c
@@ -668,6 +668,8 @@ gb_view_grid_toplevel_set_focus (GtkWidget *toplevel,
{
g_return_if_fail (GB_IS_VIEW_GRID (self));
+ gb_view_grid_set_focus (self, NULL);
+
if (focus && gtk_widget_is_ancestor (focus, GTK_WIDGET (self)))
{
GtkWidget *parent = focus;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]