[gnome-builder/wip/commands2] commands: wire up command bar



commit 5b98e148bd932005180db212e17e8f7e5be4b257
Author: Christian Hergert <christian hergert me>
Date:   Fri Oct 10 14:10:11 2014 -0700

    commands: wire up command bar

 src/resources/css/builder.Adwaita.css     |   37 +++++++++++++
 src/resources/gnome-builder.gresource.xml |    2 +
 src/resources/keybindings/default.ini     |    1 +
 src/resources/ui/gb-command-bar-item.ui   |   62 ++++++++++++++++++++++
 src/resources/ui/gb-command-bar.ui        |   64 +++++++++++++++++++++++
 src/resources/ui/gb-workbench.ui          |   80 +++++++++++++++++------------
 src/workbench/gb-workbench.c              |   26 +++++++++-
 7 files changed, 238 insertions(+), 34 deletions(-)
---
diff --git a/src/resources/css/builder.Adwaita.css b/src/resources/css/builder.Adwaita.css
index 9910e7f..97d7ffd 100644
--- a/src/resources/css/builder.Adwaita.css
+++ b/src/resources/css/builder.Adwaita.css
@@ -139,3 +139,40 @@ GtkStackSwitcher.gb-workspace-switcher > GtkRadioButton:active {
     padding: 10px;
 }
 
+
+/*
+ * Command bar styling.
+ */
+.gb-command-bar-frame {
+    background-color: shade (@theme_base_color, 0.8);
+    padding: 6px 6px 8px 6px;
+    border-color: shade (@theme_base_color, 0.6);
+    border-radius: 3px 3px 0 0;
+    border-width: 1px 1px 0 1px;
+    border-style: solid;
+}
+GtkEntry.gb-command-bar {
+    padding: 6px;
+    font-family: Monospace;
+}
+GtkLabel.gb-command-bar-placeholder {
+    font-size: 1.2em;
+    font-weight: bold;
+    color: shade (@theme_base_color, 0.5);
+}
+GbCommandBarItem .gb-command-bar-item-command {
+    font-size: 1.1em;
+    font-family: Monospace;
+}
+GbCommandBarItem .gb-command-bar-item-result {
+    font-size: 1.1em;
+    font-family: Monospace;
+}
+GbCommandBarItem .gb-command-bar-item-equal {
+    font-size: 1.2em;
+    font-weight: bold;
+    color: shade (@theme_base_color, 0.5);
+    padding-left: 12px;
+    padding-right: 12px;
+    font-family: Monospace;
+}
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 15a2508..dfc84c5 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -17,6 +17,8 @@
     <file>snippets/c.snippets</file>
     <file>snippets/chdr.snippets</file>
 
+    <file>ui/gb-command-bar.ui</file>
+    <file>ui/gb-command-bar-item.ui</file>
     <file>ui/gb-devhelp-tab.ui</file>
     <file>ui/gb-editor-tab.ui</file>
     <file>ui/gb-preferences-window.ui</file>
diff --git a/src/resources/keybindings/default.ini b/src/resources/keybindings/default.ini
index 8387112..3fbd798 100644
--- a/src/resources/keybindings/default.ini
+++ b/src/resources/keybindings/default.ini
@@ -7,6 +7,7 @@ workspace1 = <Control>1
 workspace2 = <Control>2
 go-forward = <Control>I
 go-backward = <Control>O
+show-command-bar = <Control>space
 
 [workbench]
 close-tab = <Control>W
diff --git a/src/resources/ui/gb-command-bar-item.ui b/src/resources/ui/gb-command-bar-item.ui
new file mode 100644
index 0000000..caa72b4
--- /dev/null
+++ b/src/resources/ui/gb-command-bar-item.ui
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.8 -->
+  <template class="GbCommandBarItem" parent="GtkBin">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="border_width">6</property>
+    <child>
+      <object class="GtkBox" id="box">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="vexpand">False</property>
+        <property name="spacing">6</property>
+        <child>
+          <object class="GtkSpinner" id="spinner">
+            <property name="visible">False</property>
+            <property name="can_focus">False</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel" id="command_text">
+            <property name="visible">True</property>
+            <property name="xalign">0.0</property>
+            <property name="valign">baseline</property>
+            <property name="hexpand">True</property>
+            <property name="can_focus">False</property>
+            <property name="selectable">True</property>
+            <style>
+              <class name="gb-command-bar-item-command"/>
+            </style>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel" id="equal_label">
+            <property name="visible">True</property>
+            <property name="hexpand">False</property>
+            <property name="valign">baseline</property>
+            <property name="can_focus">False</property>
+            <property name="label">=</property>
+            <property name="selectable">False</property>
+            <style>
+              <class name="gb-command-bar-item-equal"/>
+            </style>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel" id="result_text">
+            <property name="visible">True</property>
+            <property name="xalign">0.0</property>
+            <property name="valign">baseline</property>
+            <property name="hexpand">False</property>
+            <property name="can_focus">False</property>
+            <property name="selectable">True</property>
+            <style>
+              <class name="gb-command-bar-item-result"/>
+            </style>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/resources/ui/gb-command-bar.ui b/src/resources/ui/gb-command-bar.ui
new file mode 100644
index 0000000..b1c341b
--- /dev/null
+++ b/src/resources/ui/gb-command-bar.ui
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.8 -->
+  <template class="GbCommandBar" parent="GtkRevealer">
+    <property name="visible">True</property>
+    <property name="reveal-child">False</property>
+    <property name="can-focus">True</property>
+    <child>
+      <object class="GtkFrame" id="frame">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <property name="vexpand">True</property>
+        <style>
+          <class name="gb-command-bar-frame"/>
+        </style>
+        <child>
+          <object class="GtkBox" id="vbox1">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkScrolledWindow" id="scroller">
+                <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+                <property name="visible">True</property>
+                <property name="expand">True</property>
+                <property name="height_request">300</property>
+                <child>
+                  <object class="GtkListBox" id="list_box">
+                    <property name="visible">True</property>
+                    <property name="expand">True</property>
+                    <property name="selection_mode">GTK_SELECTION_NONE</property>
+                  </object>
+                  <style>
+                    <class name="view"/>
+                  </style>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkSeparator" id="hsep1">
+                <property name="orientation">horizontal</property>
+                <property name="visible">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkEntry" id="entry">
+                <property name="visible">True</property>
+                <property name="expand">False</property>
+                <property name="valign">end</property>
+                <property name="has_frame">False</property>
+                <style>
+                  <class name="gb-command-bar"/>
+                </style>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+  <object class="GtkSizeGroup" id="result_size_group">
+    <property name="mode">GTK_SIZE_GROUP_HORIZONTAL</property>
+  </object>
+</interface>
diff --git a/src/resources/ui/gb-workbench.ui b/src/resources/ui/gb-workbench.ui
index 242cbad..f2d008c 100644
--- a/src/resources/ui/gb-workbench.ui
+++ b/src/resources/ui/gb-workbench.ui
@@ -119,52 +119,66 @@
       </object>
     </child>
     <child>
-      <object class="GtkBox" id="main_hbox">
-        <property name="orientation">horizontal</property>
+      <object class="GtkOverlay" id="main_overlay">
         <property name="visible">True</property>
-        <child>
-          <object class="GtkStackSwitcher" id="switcher">
+        <child type="overlay">
+          <object class="GbCommandBar" id="command_bar">
+            <property name="width-request">500</property>
+            <property name="transition-type">GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP</property>
+            <property name="halign">center</property>
+            <property name="valign">end</property>
             <property name="visible">True</property>
-            <property name="stack">stack</property>
-            <property name="orientation">vertical</property>
-            <property name="border_width">4</property>
-            <property name="spacing">4</property>
-            <style>
-              <class name="gb-workspace-switcher"/>
-            </style>
           </object>
         </child>
         <child>
-          <object class="GtkSeparator" id="sidebar_separator">
-            <property name="visible">True</property>
-            <property name="orientation">vertical</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkStack" id="stack">
+          <object class="GtkBox" id="main_hbox">
+            <property name="orientation">horizontal</property>
             <property name="visible">True</property>
-            <property name="transition_type">GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN</property>
             <child>
-              <object class="GbEditorWorkspace" id="editor">
-                <property name="name">editor</property>
+              <object class="GtkStackSwitcher" id="switcher">
+                <property name="visible">True</property>
+                <property name="stack">stack</property>
+                <property name="orientation">vertical</property>
+                <property name="border_width">4</property>
+                <property name="spacing">4</property>
+                <style>
+                  <class name="gb-workspace-switcher"/>
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkSeparator" id="sidebar_separator">
                 <property name="visible">True</property>
+                <property name="orientation">vertical</property>
               </object>
-              <packing>
-                <property name="icon_name">text-editor-symbolic</property>
-                <property name="name">editor</property>
-                <property name="title" translatable="yes">Editor</property>
-              </packing>
             </child>
             <child>
-              <object class="GbDevhelpWorkspace" id="devhelp">
-                <property name="name">devhelp</property>
+              <object class="GtkStack" id="stack">
                 <property name="visible">True</property>
+                <property name="transition_type">GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN</property>
+                <child>
+                  <object class="GbEditorWorkspace" id="editor">
+                    <property name="name">editor</property>
+                    <property name="visible">True</property>
+                  </object>
+                  <packing>
+                    <property name="icon_name">text-editor-symbolic</property>
+                    <property name="name">editor</property>
+                    <property name="title" translatable="yes">Editor</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GbDevhelpWorkspace" id="devhelp">
+                    <property name="name">devhelp</property>
+                    <property name="visible">True</property>
+                  </object>
+                  <packing>
+                    <property name="name">devhelp</property>
+                    <property name="icon_name">help-browser-symbolic</property>
+                    <property name="title" translatable="yes">Documentation</property>
+                  </packing>
+                </child>
               </object>
-              <packing>
-                <property name="name">devhelp</property>
-                <property name="icon_name">help-browser-symbolic</property>
-                <property name="title" translatable="yes">Documentation</property>
-              </packing>
             </child>
           </object>
         </child>
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index 46db7c0..5429dff 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -20,6 +20,7 @@
 
 #include <glib/gi18n.h>
 
+#include "gb-command-bar.h"
 #include "gb-command-gaction-provider.h"
 #include "gb-command-manager.h"
 #include "gb-command-vim-provider.h"
@@ -40,6 +41,7 @@ struct _GbWorkbenchPrivate
   GbNavigationList       *navigation_list;
 
   GbWorkspace            *active_workspace;
+  GbCommandBar           *command_bar;
   GbWorkspace            *devhelp;
   GbWorkspace            *editor;
   GtkMenuButton          *add_button;
@@ -289,6 +291,24 @@ gb_workbench_navigation_changed (GbWorkbench      *workbench,
 }
 
 static void
+on_show_command_bar_activate (GSimpleAction *action,
+                              GVariant      *parameters,
+                              gpointer       user_data)
+{
+  GbWorkbenchPrivate *priv;
+  GbWorkbench *workbench = user_data;
+
+  g_return_if_fail (GB_IS_WORKBENCH (workbench));
+
+  priv = workbench->priv;
+
+  if (gtk_revealer_get_reveal_child (GTK_REVEALER (priv->command_bar)))
+    gb_command_bar_hide (priv->command_bar);
+  else
+    gb_command_bar_show (priv->command_bar);
+}
+
+static void
 gb_workbench_constructed (GObject *object)
 {
   static const GActionEntry actions[] = {
@@ -296,6 +316,7 @@ gb_workbench_constructed (GObject *object)
     { "workspace2", on_workspace2_activate },
     { "go-backward", on_go_backward_activate },
     { "go-forward", on_go_forward_activate },
+    { "show-command-bar", on_show_command_bar_activate },
   };
   GbWorkbenchPrivate *priv;
   GbWorkbench *workbench = (GbWorkbench *)object;
@@ -452,6 +473,8 @@ gb_workbench_class_init (GbWorkbenchClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
                                                 devhelp);
   gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
+                                                command_bar);
+  gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
                                                 editor);
   gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
                                                 add_button);
@@ -472,8 +495,9 @@ gb_workbench_class_init (GbWorkbenchClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
                                                 stack);
 
-  g_type_ensure (GB_TYPE_EDITOR_WORKSPACE);
+  g_type_ensure (GB_TYPE_COMMAND_BAR);
   g_type_ensure (GB_TYPE_DEVHELP_WORKSPACE);
+  g_type_ensure (GB_TYPE_EDITOR_WORKSPACE);
   g_type_ensure (GEDIT_TYPE_MENU_STACK_SWITCHER);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]