[gnome-builder] view-stack: allow focusing the view stack by clicking on the header
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] view-stack: allow focusing the view stack by clicking on the header
- Date: Thu, 17 Sep 2015 03:31:06 +0000 (UTC)
commit 4780ff45e648e6dce12653d02162e366ec5d805b
Author: Christian Hergert <christian hergert me>
Date: Wed Sep 16 20:30:59 2015 -0700
view-stack: allow focusing the view stack by clicking on the header
data/theme/Adwaita-shared.css | 20 ++--
data/ui/gb-view-stack.ui | 315 +++++++++++++++++++------------------
src/views/gb-view-stack-private.h | 1 +
src/views/gb-view-stack.c | 27 +++-
4 files changed, 198 insertions(+), 165 deletions(-)
---
diff --git a/data/theme/Adwaita-shared.css b/data/theme/Adwaita-shared.css
index 0ee0605..1e018b8 100644
--- a/data/theme/Adwaita-shared.css
+++ b/data/theme/Adwaita-shared.css
@@ -38,8 +38,8 @@ GbViewStack GtkBox.header.notebook {
GbViewStack:not(.focused) GtkBox.header.notebook {
background-color: shade (@theme_bg_color, 0.95);
}
-GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkBox.horizontal > .button,
-GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkBox.horizontal > GtkStack > GtkBox >
.button {
+GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkEventBox > GtkBox.horizontal >
.button,
+GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkEventBox > GtkBox.horizontal >
GtkStack > GtkBox > .button {
background-image: none;
border-bottom: 1px solid transparent;
border-radius: 0px;
@@ -49,7 +49,7 @@ GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkBox.horiz
opacity: 0.55;
padding: 3px 8px 4px;
}
-GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkBox.horizontal > GtkBox.navigation >
.button {
+GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkEventBox > GtkBox.horizontal >
GtkBox.navigation > .button {
background-image: none;
border-bottom: 1px solid transparent;
border-radius: 0px;
@@ -70,25 +70,25 @@ GbWorkspacePane > GtkBox.vertical > GtkBox.notebook.header > GtkStackSwitcher >
padding: 3px 0px 3px;
}
GbWorkspacePane > GtkBox.vertical > GtkBox.horizontal.notebook.header > GtkStackSwitcher .button:checked,
-GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkBox.horizontal > .button:checked {
+GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkEventBox > GtkBox.horizontal >
.button:checked {
box-shadow: 0px 2px 0px @theme_fg_color;
color: @theme_fg_color;
}
GbWorkspacePane > GtkBox.vertical > GtkBox.notebook.header.horizontal > GtkStackSwitcher > .button:hover,
-GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkBox.horizontal > GtkBox.navigation >
.button:hover,
-GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkBox.horizontal > .button:hover,
-GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkBox.horizontal > GtkStack > GtkBox >
.button:hover {
+GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkEventBox > GtkBox.horizontal >
GtkBox.navigation > .button:hover,
+GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkEventBox > GtkBox.horizontal >
.button:hover,
+GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkEventBox > GtkBox.horizontal >
GtkStack > GtkBox > .button:hover {
border: 1px solid transparent;
box-shadow: 0px 2px 0px mix(@theme_fg_color, @theme_bg_color, 0.25);
}
-GbViewStack > GtkBox.vertical > GtkBox.header.notebook > GtkBox.horizontal > GtkBox.navigation > .button {
+GbViewStack > GtkBox.vertical > GtkBox.header.notebook > GtkEventBox > GtkBox.horizontal > GtkBox.navigation
.button {
padding-left: 4px;
padding-right: 4px;
}
-GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkBox.horizontal >
GtkMenuButton.document-button {
+GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkEventBox > GtkBox.horizontal >
GtkMenuButton.document-button {
padding: 0px;
}
-GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkBox.horizontal >
GtkMenuButton.document-button > GtkBox > GtkArrow {
+GbViewStack > GtkBox.vertical > GtkBox.header.notebook.horizontal > GtkEventBox > GtkBox.horizontal >
GtkMenuButton.document-button > GtkBox > GtkArrow {
opacity: 0.35;
padding-right: 0px;
margin-right: 0px;
diff --git a/data/ui/gb-view-stack.ui b/data/ui/gb-view-stack.ui
index 6837650..d4cd430 100644
--- a/data/ui/gb-view-stack.ui
+++ b/data/ui/gb-view-stack.ui
@@ -15,205 +15,212 @@
<class name="header"/>
</style>
<child>
- <object class="GtkBox">
- <property name="orientation">horizontal</property>
- <property name="hexpand">true</property>
+ <object class="GtkEventBox" id="header_event_box">
+ <property name="above-child">false</property>
+ <property name="visible-window">false</property>
<property name="visible">true</property>
- <property name="margin-bottom">3</property>
- <property name="margin-end">7</property>
- <property name="margin-start">6</property>
- <property name="margin-top">3</property>
- <child>
- <object class="GtkMenuButton" id="views_button">
- <property name="visible">true</property>
- <property name="focus-on-click">false</property>
- <property name="popover">views_popover</property>
- <property name="sensitive">false</property>
- <style>
- <class name="image-button"/>
- <class name="flat"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="visible">true</property>
- <property name="icon-name">view-list-symbolic</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="pack-type">start</property>
- </packing>
- </child>
- <child>
- <object class="GtkSeparator">
- <property name="margin-start">3</property>
- <property name="margin-end">3</property>
- <property name="margin-top">4</property>
- <property name="margin-bottom">4</property>
- <property name="orientation">vertical</property>
- <property name="visible">true</property>
- </object>
- </child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
+ <property name="hexpand">true</property>
<property name="visible">true</property>
- <style>
- <class name="navigation"/>
- </style>
+ <property name="margin-bottom">3</property>
+ <property name="margin-end">7</property>
+ <property name="margin-start">6</property>
+ <property name="margin-top">3</property>
<child>
- <object class="GtkButton" id="go_backward">
+ <object class="GtkMenuButton" id="views_button">
<property name="visible">true</property>
- <property name="action-name">view-stack.go-backward</property>
<property name="focus-on-click">false</property>
+ <property name="popover">views_popover</property>
+ <property name="sensitive">false</property>
<style>
- <class name="flat"/>
<class name="image-button"/>
+ <class name="flat"/>
</style>
<child>
<object class="GtkImage">
- <property name="icon-name">go-previous-symbolic</property>
<property name="visible">true</property>
+ <property name="icon-name">view-list-symbolic</property>
</object>
</child>
</object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
</child>
<child>
- <object class="GtkButton" id="go_forward">
+ <object class="GtkSeparator">
+ <property name="margin-start">3</property>
+ <property name="margin-end">3</property>
+ <property name="margin-top">4</property>
+ <property name="margin-bottom">4</property>
+ <property name="orientation">vertical</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
<property name="visible">true</property>
- <property name="action-name">view-stack.go-forward</property>
- <property name="focus-on-click">false</property>
<style>
- <class name="flat"/>
- <class name="image-button"/>
+ <class name="navigation"/>
</style>
<child>
- <object class="GtkImage">
- <property name="icon-name">go-next-symbolic</property>
+ <object class="GtkButton" id="go_backward">
<property name="visible">true</property>
+ <property name="action-name">view-stack.go-backward</property>
+ <property name="focus-on-click">false</property>
+ <style>
+ <class name="flat"/>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">go-previous-symbolic</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="go_forward">
+ <property name="visible">true</property>
+ <property name="action-name">view-stack.go-forward</property>
+ <property name="focus-on-click">false</property>
+ <style>
+ <class name="flat"/>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">go-next-symbolic</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
</object>
</child>
</object>
</child>
- </object>
- </child>
- <child>
- <object class="GtkSeparator">
- <property name="margin-start">3</property>
- <property name="margin-end">3</property>
- <property name="margin-top">4</property>
- <property name="margin-bottom">4</property>
- <property name="orientation">vertical</property>
- <property name="visible">true</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuButton" id="document_button">
- <property name="focus-on-click">false</property>
- <property name="hexpand">false</property>
- <property name="popover">popover</property>
- <!-- Sensitive is not being respected,
- likely due to popover being set. -->
- <property name="sensitive">false</property>
- <property name="visible">true</property>
- <style>
- <class name="flat"/>
- <class name="text-button"/>
- <class name="document-button"/>
- </style>
<child>
- <object class="GtkBox">
- <property name="spacing">6</property>
+ <object class="GtkSeparator">
+ <property name="margin-start">3</property>
+ <property name="margin-end">3</property>
+ <property name="margin-top">4</property>
+ <property name="margin-bottom">4</property>
+ <property name="orientation">vertical</property>
<property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="document_button">
+ <property name="focus-on-click">false</property>
+ <property name="hexpand">false</property>
+ <property name="popover">popover</property>
+ <!-- Sensitive is not being respected,
+ likely due to popover being set. -->
+ <property name="sensitive">false</property>
+ <property name="visible">true</property>
+ <style>
+ <class name="flat"/>
+ <class name="text-button"/>
+ <class name="document-button"/>
+ </style>
<child>
- <object class="GtkLabel" id="title_label">
- <property name="hexpand">false</property>
+ <object class="GtkBox">
+ <property name="spacing">6</property>
<property name="visible">true</property>
- <property name="ellipsize">start</property>
- <property name="valign">baseline</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="modified_label">
- <property name="halign">fill</property>
- <property name="hexpand">true</property>
- <property name="xalign">1.0</property>
- <property name="label">•</property>
- <property name="valign">baseline</property>
- <property name="visible">false</property>
+ <child>
+ <object class="GtkLabel" id="title_label">
+ <property name="hexpand">false</property>
+ <property name="visible">true</property>
+ <property name="ellipsize">start</property>
+ <property name="valign">baseline</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="modified_label">
+ <property name="halign">fill</property>
+ <property name="hexpand">true</property>
+ <property name="xalign">1.0</property>
+ <property name="label">•</property>
+ <property name="valign">baseline</property>
+ <property name="visible">false</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkArrow">
+ <property name="arrow-type">down</property>
+ <property name="margin-top">2</property>
+ <property name="valign">baseline</property>
+ <property name="visible">true</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="pack-type">end</property>
- <property name="position">1</property>
- </packing>
</child>
+ </object>
+ <packing>
+ <property name="padding">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="close_button">
+ <property name="action-name">view-stack.close</property>
+ <property name="visible">true</property>
+ <property name="focus-on-click">false</property>
+ <style>
+ <class name="image-button"/>
+ <class name="flat"/>
+ <class name="small-button"/>
+ </style>
<child>
- <object class="GtkArrow">
- <property name="arrow-type">down</property>
- <property name="margin-top">2</property>
- <property name="valign">baseline</property>
+ <object class="GtkImage">
<property name="visible">true</property>
+ <property name="icon-name">window-close-symbolic</property>
</object>
- <packing>
- <property name="pack-type">end</property>
- <property name="position">0</property>
- </packing>
</child>
</object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
</child>
- </object>
- <packing>
- <property name="padding">6</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="close_button">
- <property name="action-name">view-stack.close</property>
- <property name="visible">true</property>
- <property name="focus-on-click">false</property>
- <style>
- <class name="image-button"/>
- <class name="flat"/>
- <class name="small-button"/>
- </style>
<child>
- <object class="GtkImage">
+ <object class="GtkSeparator">
+ <property name="margin-start">3</property>
+ <property name="margin-end">3</property>
+ <property name="margin-top">4</property>
+ <property name="margin-bottom">4</property>
+ <property name="orientation">vertical</property>
<property name="visible">true</property>
- <property name="icon-name">window-close-symbolic</property>
</object>
+ <packing>
+ <!--
+ this padding is to make things line up with header bar.
+ unfortunately, this was annoying to get right with css.
+ feel free to come fix it.
+ -->
+ <property name="padding">1</property>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkStack" id="controls_stack">
+ <property name="homogeneous">false</property>
+ <property name="visible">true</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- <child>
- <object class="GtkSeparator">
- <property name="margin-start">3</property>
- <property name="margin-end">3</property>
- <property name="margin-top">4</property>
- <property name="margin-bottom">4</property>
- <property name="orientation">vertical</property>
- <property name="visible">true</property>
- </object>
- <packing>
- <!--
- this padding is to make things line up with header bar.
- unfortunately, this was annoying to get right with css.
- feel free to come fix it.
- -->
- <property name="padding">1</property>
- <property name="pack-type">end</property>
- </packing>
- </child>
- <child>
- <object class="GtkStack" id="controls_stack">
- <property name="homogeneous">false</property>
- <property name="visible">true</property>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
</child>
</object>
</child>
diff --git a/src/views/gb-view-stack-private.h b/src/views/gb-view-stack-private.h
index 6ca3d82..6a478bc 100644
--- a/src/views/gb-view-stack-private.h
+++ b/src/views/gb-view-stack-private.h
@@ -44,6 +44,7 @@ struct _GbViewStack
GtkMenuButton *document_button;
GtkButton *go_backward;
GtkButton *go_forward;
+ GtkEventBox *header_event_box;
GtkLabel *modified_label;
GtkStack *stack;
GtkLabel *title_label;
diff --git a/src/views/gb-view-stack.c b/src/views/gb-view-stack.c
index 7637a78..25579a9 100644
--- a/src/views/gb-view-stack.c
+++ b/src/views/gb-view-stack.c
@@ -414,8 +414,26 @@ gb_view_stack_swipe (GbViewStack *self,
else if (velocity_x > 0)
gb_widget_activate_action (GTK_WIDGET (self), "view-stack", "next-view", NULL);
}
+}
+
+static gboolean
+gb_view_stack__header__button_press (GbViewStack *self,
+ GdkEventButton *button,
+ GtkEventBox *event_box)
+{
+ g_assert (GB_IS_VIEW_STACK (self));
+ g_assert (button != NULL);
+ g_assert (GTK_IS_EVENT_BOX (event_box));
+
+ g_print ("button press\n");
- g_print ("SWIPE: %lf %lf\n", velocity_x, velocity_y);
+ if (button->button == GDK_BUTTON_PRIMARY)
+ {
+ gtk_widget_grab_focus (GTK_WIDGET (self));
+ return GDK_EVENT_STOP;
+ }
+
+ return GDK_EVENT_PROPAGATE;
}
static void
@@ -441,6 +459,12 @@ gb_view_stack_constructed (GObject *object)
self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->header_event_box,
+ "button-press-event",
+ G_CALLBACK (gb_view_stack__header__button_press),
+ self,
+ G_CONNECT_SWAPPED);
+
gb_view_stack_actions_init (self);
}
@@ -560,6 +584,7 @@ gb_view_stack_class_init (GbViewStackClass *klass)
GB_WIDGET_CLASS_BIND (klass, GbViewStack, document_button);
GB_WIDGET_CLASS_BIND (klass, GbViewStack, go_backward);
GB_WIDGET_CLASS_BIND (klass, GbViewStack, go_forward);
+ GB_WIDGET_CLASS_BIND (klass, GbViewStack, header_event_box);
GB_WIDGET_CLASS_BIND (klass, GbViewStack, modified_label);
GB_WIDGET_CLASS_BIND (klass, GbViewStack, stack);
GB_WIDGET_CLASS_BIND (klass, GbViewStack, title_label);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]