[gnome-builder] editor: place minimap above floating bar



commit 4867d5546f8cfe48a7caa287d80b7fb355beb456
Author: Christian Hergert <christian hergert me>
Date:   Sun Apr 26 13:31:01 2015 -0700

    editor: place minimap above floating bar
    
    This adds a new container to help us manage the layout. The minimap will
    be displayed above the floating bar, but not cover the source view.

 data/ui/gb-editor-frame.ui           |  217 +++++++++++++++++----------------
 src/editor/gb-editor-frame.c         |    2 +
 src/editor/gb-editor-map-bin.c       |  154 ++++++++++++++++++++++++
 src/editor/gb-editor-map-bin.h       |   32 +++++
 src/gnome-builder.mk                 |    2 +
 src/nautilus/nautilus-floating-bar.c |    2 +
 6 files changed, 304 insertions(+), 105 deletions(-)
---
diff --git a/data/ui/gb-editor-frame.ui b/data/ui/gb-editor-frame.ui
index 79301f6..91a9a73 100644
--- a/data/ui/gb-editor-frame.ui
+++ b/data/ui/gb-editor-frame.ui
@@ -3,104 +3,110 @@
   <!-- interface-requires gtk+ 3.15 -->
   <template class="GbEditorFrame" parent="GtkBin">
     <child>
-      <object class="GtkBox">
-        <property name="orientation">horizontal</property>
+      <object class="GtkOverlay">
+        <property name="expand">true</property>
         <property name="visible">true</property>
-        <child>
-          <object class="GtkOverlay">
-            <property name="expand">true</property>
+        <child type="overlay">
+          <object class="NautilusFloatingBar" id="floating_bar">
+            <property name="halign">end</property>
+            <property name="primary_label"></property>
+            <property name="valign">end</property>
             <property name="visible">true</property>
-            <child type="overlay">
-              <object class="NautilusFloatingBar" id="floating_bar">
-                <property name="halign">end</property>
-                <property name="primary_label"></property>
-                <property name="valign">end</property>
+            <child>
+              <object class="GtkLabel" id="overwrite_label">
+                <!-- translators: OVR indicates we are in overwite mode -->
+                <property name="label" translatable="yes">OVR</property>
+                <property name="margin-start">12</property>
+                <property name="visible">false</property>
+              </object>
+              <packing>
+                <property name="pack-type">start</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="mode_name_label">
+                <property name="margin-start">12</property>
+                <property name="margin-end">3</property>
                 <property name="visible">true</property>
-                <child>
-                  <object class="GtkLabel" id="overwrite_label">
-                    <!-- translators: OVR indicates we are in overwite mode -->
-                    <property name="label" translatable="yes">OVR</property>
-                    <property name="margin-start">12</property>
-                    <property name="visible">false</property>
-                  </object>
-                  <packing>
-                    <property name="pack-type">start</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="mode_name_label">
-                    <property name="margin-start">12</property>
-                    <property name="margin-end">3</property>
-                    <property name="visible">true</property>
-                  </object>
-                  <packing>
-                    <property name="pack-type">start</property>
-                    <property name="position">2</property>
-                  </packing>
-                </child>
               </object>
+              <packing>
+                <property name="pack-type">start</property>
+                <property name="position">2</property>
+              </packing>
             </child>
-            <child type="overlay">
-              <object class="GtkRevealer" id="search_revealer">
-                <property name="halign">end</property>
-                <property name="valign">start</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox">
+            <property name="orientation">horizontal</property>
+            <property name="visible">true</property>
+            <child>
+              <object class="GtkOverlay">
+                <property name="expand">true</property>
                 <property name="visible">true</property>
-                <property name="width-request">300</property>
-                <child>
-                  <object class="GtkFrame">
+                <child type="overlay">
+                  <object class="GtkRevealer" id="search_revealer">
+                    <property name="halign">end</property>
+                    <property name="valign">start</property>
                     <property name="visible">true</property>
-                    <property name="margin-end">12</property>
-                    <style>
-                      <class name="gb-search-slider"/>
-                    </style>
+                    <property name="width-request">300</property>
                     <child>
-                      <object class="GtkBox">
-                        <property name="orientation">horizontal</property>
+                      <object class="GtkFrame">
                         <property name="visible">true</property>
+                        <property name="margin-end">12</property>
                         <style>
-                          <class name="linked"/>
+                          <class name="gb-search-slider"/>
                         </style>
                         <child>
-                          <object class="GdTaggedEntry" id="search_entry">
-                            <property name="visible">true</property>
-                            <property name="tag-close-visible">false</property>
-                            <property name="can-focus">true</property>
-                            <property name="width-request">260</property>
-                            <property name="primary-icon-activatable">true</property>
-                            <property name="primary-icon-sensitive">true</property>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkButton">
-                            <property name="action-name">frame.previous-search-result</property>
-                            <property name="can-focus">false</property>
+                          <object class="GtkBox">
+                            <property name="orientation">horizontal</property>
                             <property name="visible">true</property>
                             <style>
-                              <class name="image-button"/>
+                              <class name="linked"/>
                             </style>
                             <child>
-                              <object class="GtkImage">
-                                <property name="icon-name">go-up-symbolic</property>
-                                <property name="icon-size">1</property>
+                              <object class="GdTaggedEntry" id="search_entry">
                                 <property name="visible">true</property>
+                                <property name="tag-close-visible">false</property>
+                                <property name="can-focus">true</property>
+                                <property name="width-request">260</property>
+                                <property name="primary-icon-activatable">true</property>
+                                <property name="primary-icon-sensitive">true</property>
                               </object>
                             </child>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkButton">
-                            <property name="action-name">frame.next-search-result</property>
-                            <property name="can-focus">false</property>
-                            <property name="visible">true</property>
-                            <style>
-                              <class name="image-button"/>
-                            </style>
                             <child>
-                              <object class="GtkImage">
-                                <property name="icon-name">go-down-symbolic</property>
-                                <property name="icon-size">1</property>
+                              <object class="GtkButton">
+                                <property name="action-name">frame.previous-search-result</property>
+                                <property name="can-focus">false</property>
                                 <property name="visible">true</property>
+                                <style>
+                                  <class name="image-button"/>
+                                </style>
+                                <child>
+                                  <object class="GtkImage">
+                                    <property name="icon-name">go-up-symbolic</property>
+                                    <property name="icon-size">1</property>
+                                    <property name="visible">true</property>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkButton">
+                                <property name="action-name">frame.next-search-result</property>
+                                <property name="can-focus">false</property>
+                                <property name="visible">true</property>
+                                <style>
+                                  <class name="image-button"/>
+                                </style>
+                                <child>
+                                  <object class="GtkImage">
+                                    <property name="icon-name">go-down-symbolic</property>
+                                    <property name="icon-size">1</property>
+                                    <property name="visible">true</property>
+                                  </object>
+                                </child>
                               </object>
                             </child>
                           </object>
@@ -109,42 +115,43 @@
                     </child>
                   </object>
                 </child>
-              </object>
-            </child>
-            <child>
-              <object class="GtkScrolledWindow" id="scrolled_window">
-                <property name="expand">true</property>
-                <property name="visible">true</property>
                 <child>
-                  <object class="IdeSourceView" id="source_view">
-                    <property name="auto-indent">true</property>
-                    <property name="enable-word-completion">true</property>
-                    <property name="highlight-current-line">true</property>
-                    <property name="insert-matching-brace">true</property>
-                    <property name="overwrite-braces">true</property>
-                    <property name="scroll-offset">0</property>
-                    <property name="show-grid-lines">true</property>
-                    <property name="show-line-changes">true</property>
-                    <property name="show-line-numbers">true</property>
-                    <property name="show-right-margin">true</property>
-                    <property name="show-search-bubbles">true</property>
-                    <property name="smart-backspace">true</property>
-                    <property name="snippet-completion">true</property>
+                  <object class="GtkScrolledWindow" id="scrolled_window">
+                    <property name="expand">true</property>
                     <property name="visible">true</property>
-                    <child internal-child="completion">
-                      <object class="GtkSourceCompletion">
-                        <property name="show-headers">false</property>
+                    <child>
+                      <object class="IdeSourceView" id="source_view">
+                        <property name="auto-indent">true</property>
+                        <property name="enable-word-completion">true</property>
+                        <property name="highlight-current-line">true</property>
+                        <property name="insert-matching-brace">true</property>
+                        <property name="overwrite-braces">true</property>
+                        <property name="scroll-offset">0</property>
+                        <property name="show-grid-lines">true</property>
+                        <property name="show-line-changes">true</property>
+                        <property name="show-line-numbers">true</property>
+                        <property name="show-right-margin">true</property>
+                        <property name="show-search-bubbles">true</property>
+                        <property name="smart-backspace">true</property>
+                        <property name="snippet-completion">true</property>
+                        <property name="visible">true</property>
+                        <child internal-child="completion">
+                          <object class="GtkSourceCompletion">
+                            <property name="show-headers">false</property>
+                          </object>
+                        </child>
                       </object>
                     </child>
                   </object>
                 </child>
               </object>
             </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkBox" id="source_map_container">
-            <property name="visible">true</property>
+            <child>
+              <object class="GbEditorMapBin" id="source_map_container">
+                <property name="floating-bar">floating_bar</property>
+                <property name="visible">true</property>
+              </object>
+            </child>
           </object>
         </child>
       </object>
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index 7c7b07c..79645a6 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -24,6 +24,7 @@
 #include "gb-editor-frame.h"
 #include "gb-editor-frame-actions.h"
 #include "gb-editor-frame-private.h"
+#include "gb-editor-map-bin.h"
 #include "gb-string.h"
 #include "gb-view-stack.h"
 #include "gb-widget.h"
@@ -684,6 +685,7 @@ gb_editor_frame_class_init (GbEditorFrameClass *klass)
   GB_WIDGET_CLASS_BIND (klass, GbEditorFrame, source_view);
 
   g_type_ensure (NAUTILUS_TYPE_FLOATING_BAR);
+  g_type_ensure (GB_TYPE_EDITOR_MAP_BIN);
   g_type_ensure (GD_TYPE_TAGGED_ENTRY);
 }
 
diff --git a/src/editor/gb-editor-map-bin.c b/src/editor/gb-editor-map-bin.c
new file mode 100644
index 0000000..b6215f2
--- /dev/null
+++ b/src/editor/gb-editor-map-bin.c
@@ -0,0 +1,154 @@
+/* gb-editor-map-bin.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n.h>
+#include <ide.h>
+
+#include "gb-editor-map-bin.h"
+
+struct _GbEditorMapBin
+{
+  GtkBin     parent_instance;
+  gint       cached_height;
+  gulong     size_allocate_handler;
+  GtkWidget *floating_bar;
+};
+
+G_DEFINE_TYPE (GbEditorMapBin, gb_editor_map_bin, GTK_TYPE_BIN)
+
+enum {
+  PROP_0,
+  PROP_FLOATING_BAR,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+static void
+gb_editor_map_bin__floating_bar_size_allocate (GbEditorMapBin *self,
+                                               GtkAllocation  *alloc,
+                                               GtkWidget      *floating_bar)
+{
+  g_assert (GB_IS_EDITOR_MAP_BIN (self));
+  g_assert (alloc != NULL);
+  g_assert (GTK_IS_WIDGET (floating_bar));
+
+  if (self->cached_height != alloc->height)
+    {
+      self->cached_height = alloc->height;
+      gtk_widget_queue_resize (GTK_WIDGET (self));
+    }
+}
+
+static void
+gb_editor_map_bin_set_floating_bar (GbEditorMapBin *self,
+                                    GtkWidget      *floating_bar)
+{
+  g_return_if_fail (GB_IS_EDITOR_MAP_BIN (self));
+
+  if (floating_bar != self->floating_bar)
+    {
+      if (self->floating_bar)
+        {
+          ide_clear_signal_handler (self->floating_bar, &self->size_allocate_handler);
+          ide_clear_weak_pointer (&self->floating_bar);
+        }
+
+      if (floating_bar)
+        {
+          ide_set_weak_pointer (&self->floating_bar, floating_bar);
+          g_signal_connect_object (self->floating_bar,
+                                   "size-allocate",
+                                   G_CALLBACK (gb_editor_map_bin__floating_bar_size_allocate),
+                                   self,
+                                   G_CONNECT_SWAPPED);
+        }
+
+      gtk_widget_queue_resize (GTK_WIDGET (self));
+    }
+
+  if (ide_set_weak_pointer (&self->floating_bar, floating_bar))
+    gtk_widget_queue_resize (GTK_WIDGET (self));
+}
+
+static void
+gb_editor_map_bin_size_allocate (GtkWidget     *widget,
+                                 GtkAllocation *alloc)
+{
+  GbEditorMapBin *self = (GbEditorMapBin *)widget;
+
+  alloc->height -= self->cached_height;
+
+  GTK_WIDGET_CLASS (gb_editor_map_bin_parent_class)->size_allocate (widget, alloc);
+}
+
+static void
+gb_editor_map_bin_finalize (GObject *object)
+{
+  GbEditorMapBin *self = (GbEditorMapBin *)object;
+
+  ide_clear_signal_handler (self->floating_bar, &self->size_allocate_handler);
+  ide_clear_weak_pointer (&self->floating_bar);
+
+  G_OBJECT_CLASS (gb_editor_map_bin_parent_class)->finalize (object);
+}
+
+static void
+gb_editor_map_bin_set_property (GObject      *object,
+                                guint         prop_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+  GbEditorMapBin *self = GB_EDITOR_MAP_BIN (object);
+
+  switch (prop_id)
+    {
+    case PROP_FLOATING_BAR:
+      gb_editor_map_bin_set_floating_bar (self, g_value_get_object (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_editor_map_bin_class_init (GbEditorMapBinClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  object_class->finalize = gb_editor_map_bin_finalize;
+  object_class->set_property = gb_editor_map_bin_set_property;
+
+  widget_class->size_allocate = gb_editor_map_bin_size_allocate;
+
+  gParamSpecs [PROP_FLOATING_BAR] =
+    g_param_spec_object ("floating-bar",
+                         "Floating Bar",
+                         "The floating bar to use for relative allocation size.",
+                         GTK_TYPE_WIDGET,
+                         (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_FLOATING_BAR,
+                                   gParamSpecs [PROP_FLOATING_BAR]);
+}
+
+static void
+gb_editor_map_bin_init (GbEditorMapBin *self)
+{
+}
diff --git a/src/editor/gb-editor-map-bin.h b/src/editor/gb-editor-map-bin.h
new file mode 100644
index 0000000..c4f1306
--- /dev/null
+++ b/src/editor/gb-editor-map-bin.h
@@ -0,0 +1,32 @@
+/* gb-editor-map-bin.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GB_EDITOR_MAP_BIN_H
+#define GB_EDITOR_MAP_BIN_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_EDITOR_MAP_BIN (gb_editor_map_bin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbEditorMapBin, gb_editor_map_bin, GB, EDITOR_MAP_BIN, GtkBin)
+
+G_END_DECLS
+
+#endif /* GB_EDITOR_MAP_BIN_H */
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 7316c89..15427b1 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -52,6 +52,8 @@ libgnome_builder_la_SOURCES = \
        src/editor/gb-editor-frame-actions.c \
        src/editor/gb-editor-frame-actions.h \
        src/editor/gb-editor-frame-private.h \
+       src/editor/gb-editor-map-bin.c \
+       src/editor/gb-editor-map-bin.h \
        src/editor/gb-editor-settings-widget.c \
        src/editor/gb-editor-settings-widget.h \
        src/editor/gb-editor-tweak-widget.c \
diff --git a/src/nautilus/nautilus-floating-bar.c b/src/nautilus/nautilus-floating-bar.c
index d1f30b8..2aee9c6 100644
--- a/src/nautilus/nautilus-floating-bar.c
+++ b/src/nautilus/nautilus-floating-bar.c
@@ -151,6 +151,7 @@ overlay_enter_notify_cb (GtkWidget        *parent,
                         GdkEventCrossing *event,
                         gpointer          user_data)
 {
+#if 0
        GtkWidget *widget = user_data;
 
        if (event->window != gtk_widget_get_window (widget)) {
@@ -168,6 +169,7 @@ overlay_enter_notify_cb (GtkWidget        *parent,
        }
 
        gtk_widget_queue_resize (widget);
+#endif
 
        return FALSE;
 }


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