[gnome-builder/tweak] editor: start on editor tweak widget



commit 3c9b51eea72c3ffaf36bec27898d0ffe0f60a721
Author: Christian Hergert <christian hergert me>
Date:   Tue Dec 16 17:52:35 2014 -0800

    editor: start on editor tweak widget
    
    This will be handy for quick changes to the spacing/highlight/etc

 src/editor/gb-editor-tweak-widget.c        |  105 +++++++++++++++++++++++++++
 src/editor/gb-editor-tweak-widget.h        |   56 ++++++++++++++
 src/editor/gb-editor-view.c                |    2 +
 src/gnome-builder.mk                       |    2 +
 src/resources/css/builder.Adwaita.css      |    5 ++
 src/resources/gnome-builder.gresource.xml  |    1 +
 src/resources/ui/gb-editor-tweak-widget.ui |  108 ++++++++++++++++++++++++++++
 src/resources/ui/gb-editor-view.ui         |   19 +++++-
 8 files changed, 297 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-editor-tweak-widget.c b/src/editor/gb-editor-tweak-widget.c
new file mode 100644
index 0000000..cf6163b
--- /dev/null
+++ b/src/editor/gb-editor-tweak-widget.c
@@ -0,0 +1,105 @@
+/* gb-editor-tweak-widget.c
+ *
+ * Copyright (C) 2014 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/>.
+ */
+
+#define G_LOG_DOMAIN "editor-tweak"
+
+#include <glib/gi18n.h>
+
+#include "gb-editor-tweak-widget.h"
+#include "gb-widget.h"
+
+struct _GbEditorTweakWidgetPrivate
+{
+  GtkSearchEntry *entry;
+  GtkListBox     *list_box;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbEditorTweakWidget, gb_editor_tweak_widget,
+                            GTK_TYPE_BIN)
+
+enum {
+  PROP_0,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+GtkWidget *
+gb_editor_tweak_widget_new (void)
+{
+  return g_object_new (GB_TYPE_EDITOR_TWEAK_WIDGET, NULL);
+}
+
+static void
+gb_editor_tweak_widget_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (gb_editor_tweak_widget_parent_class)->finalize (object);
+}
+
+static void
+gb_editor_tweak_widget_get_property (GObject    *object,
+                                     guint       prop_id,
+                                     GValue     *value,
+                                     GParamSpec *pspec)
+{
+  GbEditorTweakWidget *self = GB_EDITOR_TWEAK_WIDGET (object);
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_editor_tweak_widget_set_property (GObject      *object,
+                                     guint         prop_id,
+                                     const GValue *value,
+                                     GParamSpec   *pspec)
+{
+  GbEditorTweakWidget *self = GB_EDITOR_TWEAK_WIDGET (object);
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_editor_tweak_widget_class_init (GbEditorTweakWidgetClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  object_class->finalize = gb_editor_tweak_widget_finalize;
+  object_class->get_property = gb_editor_tweak_widget_get_property;
+  object_class->set_property = gb_editor_tweak_widget_set_property;
+
+  GB_WIDGET_CLASS_TEMPLATE (widget_class, "gb-editor-tweak-widget.ui");
+  GB_WIDGET_CLASS_BIND (widget_class, GbEditorTweakWidget, entry);
+  GB_WIDGET_CLASS_BIND (widget_class, GbEditorTweakWidget, list_box);
+}
+
+static void
+gb_editor_tweak_widget_init (GbEditorTweakWidget *self)
+{
+  self->priv = gb_editor_tweak_widget_get_instance_private (self);
+
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/editor/gb-editor-tweak-widget.h b/src/editor/gb-editor-tweak-widget.h
new file mode 100644
index 0000000..d1f1bf4
--- /dev/null
+++ b/src/editor/gb-editor-tweak-widget.h
@@ -0,0 +1,56 @@
+/* gb-editor-tweak-widget.h
+ *
+ * Copyright (C) 2014 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_TWEAK_WIDGET_H
+#define GB_EDITOR_TWEAK_WIDGET_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_EDITOR_TWEAK_WIDGET            (gb_editor_tweak_widget_get_type())
+#define GB_EDITOR_TWEAK_WIDGET(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GB_TYPE_EDITOR_TWEAK_WIDGET, GbEditorTweakWidget))
+#define GB_EDITOR_TWEAK_WIDGET_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GB_TYPE_EDITOR_TWEAK_WIDGET, GbEditorTweakWidget const))
+#define GB_EDITOR_TWEAK_WIDGET_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  
GB_TYPE_EDITOR_TWEAK_WIDGET, GbEditorTweakWidgetClass))
+#define GB_IS_EDITOR_TWEAK_WIDGET(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GB_TYPE_EDITOR_TWEAK_WIDGET))
+#define GB_IS_EDITOR_TWEAK_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  
GB_TYPE_EDITOR_TWEAK_WIDGET))
+#define GB_EDITOR_TWEAK_WIDGET_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  
GB_TYPE_EDITOR_TWEAK_WIDGET, GbEditorTweakWidgetClass))
+
+typedef struct _GbEditorTweakWidget        GbEditorTweakWidget;
+typedef struct _GbEditorTweakWidgetClass   GbEditorTweakWidgetClass;
+typedef struct _GbEditorTweakWidgetPrivate GbEditorTweakWidgetPrivate;
+
+struct _GbEditorTweakWidget
+{
+  GtkBin parent;
+
+  /*< private >*/
+  GbEditorTweakWidgetPrivate *priv;
+};
+
+struct _GbEditorTweakWidgetClass
+{
+  GtkBinClass parent;
+};
+
+GType      gb_editor_tweak_widget_get_type (void);
+GtkWidget *gb_editor_tweak_widget_new      (void);
+
+G_END_DECLS
+
+#endif /* GB_EDITOR_TWEAK_WIDGET_H */
diff --git a/src/editor/gb-editor-view.c b/src/editor/gb-editor-view.c
index cbff5c3..447e977 100644
--- a/src/editor/gb-editor-view.c
+++ b/src/editor/gb-editor-view.c
@@ -23,6 +23,7 @@
 #include "gb-animation.h"
 #include "gb-editor-frame.h"
 #include "gb-editor-frame-private.h"
+#include "gb-editor-tweak-widget.h"
 #include "gb-editor-view.h"
 #include "gb-glib.h"
 #include "gb-html-document.h"
@@ -594,6 +595,7 @@ gb_editor_view_class_init (GbEditorViewClass *klass)
   GB_WIDGET_CLASS_BIND (widget_class, GbEditorView, error_close_button);
 
   g_type_ensure (GB_TYPE_EDITOR_FRAME);
+  g_type_ensure (GB_TYPE_EDITOR_TWEAK_WIDGET);
 }
 
 static void
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 46f12b8..d0f7a29 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -78,6 +78,8 @@ libgnome_builder_la_SOURCES = \
        src/editor/gb-editor-navigation-item.h \
        src/editor/gb-editor-settings-widget.c \
        src/editor/gb-editor-settings-widget.h \
+       src/editor/gb-editor-tweak-widget.c \
+       src/editor/gb-editor-tweak-widget.h \
        src/editor/gb-editor-view.c \
        src/editor/gb-editor-view.h \
        src/editor/gb-editor-workspace.c \
diff --git a/src/resources/css/builder.Adwaita.css b/src/resources/css/builder.Adwaita.css
index d4fbea7..0c999ca 100644
--- a/src/resources/css/builder.Adwaita.css
+++ b/src/resources/css/builder.Adwaita.css
@@ -227,3 +227,8 @@ GbCreditsWidget GtkLabel {
 GbSourceStyleSchemeWidget GtkSourceView {
     font-family: Monospace;
 }
+
+
+GbEditorTweakWidget GtkScrolledWindow {
+    border-top: none;
+}
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 85fe5af..71ff8ca 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -26,6 +26,7 @@
     <file>ui/gb-document-menu-button.ui</file>
     <file>ui/gb-editor-settings-widget.ui</file>
     <file>ui/gb-editor-frame.ui</file>
+    <file>ui/gb-editor-tweak-widget.ui</file>
     <file>ui/gb-editor-view.ui</file>
     <file>ui/gb-editor-workspace.ui</file>
     <file>ui/gb-git-search-result.ui</file>
diff --git a/src/resources/ui/gb-editor-tweak-widget.ui b/src/resources/ui/gb-editor-tweak-widget.ui
new file mode 100644
index 0000000..56bf87e
--- /dev/null
+++ b/src/resources/ui/gb-editor-tweak-widget.ui
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.8 -->
+  <template class="GbEditorTweakWidget" parent="GtkBin">
+    <property name="width_request">250</property>
+    <property name="height_request">400</property>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">true</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">3</property>
+        <child>
+          <object class="GtkModelButton">
+            <property name="visible">true</property>
+            <property name="action_name">editor-view.detect_indent</property>
+            <property name="label" translatable="yes">Auto detect tab width</property>
+            <property name="xalign">0.0</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkSeparator">
+            <property name="visible">true</property>
+            <property name="orientation">horizontal</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkModelButton">
+            <property name="visible">true</property>
+            <property name="action_name">editor-view.tab_width</property>
+            <property name="action_target">2</property>
+            <property name="label" translatable="yes">2</property>
+            <property name="xalign">0.0</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkModelButton">
+            <property name="visible">true</property>
+            <property name="action_name">editor-view.tab_width</property>
+            <property name="action_target">3</property>
+            <property name="label" translatable="yes">3</property>
+            <property name="xalign">0.0</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkModelButton">
+            <property name="visible">true</property>
+            <property name="action_name">editor-view.tab_width</property>
+            <property name="action_target">4</property>
+            <property name="label" translatable="yes">4</property>
+            <property name="xalign">0.0</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkModelButton">
+            <property name="visible">true</property>
+            <property name="action_name">editor-view.tab_width</property>
+            <property name="action_target">8</property>
+            <property name="label" translatable="yes">8</property>
+            <property name="xalign">0.0</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkSeparator">
+            <property name="visible">true</property>
+            <property name="margin_top">3</property>
+            <property name="margin_bottom">3</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkModelButton">
+            <property name="visible">true</property>
+            <property name="margin_bottom">12</property>
+            <property name="label" translatable="yes">Tabs instead of spaces</property>
+            <property name="action_name">editor-view.tabs_instead_of_spaces</property>
+            <property name="xalign">0.0</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">true</property>
+            <property name="orientation">vertical</property>
+            <style>
+              <class name="linked"/>
+            </style>
+            <child>
+              <object class="GtkSearchEntry" id="entry">
+                <property name="visible">true</property>
+                <property name="placeholder_text" translatable="yes">Search highlight modeā€¦</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkScrolledWindow">
+                <property name="visible">true</property>
+                <property name="expand">true</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkListBox" id="list_box">
+                    <property name="visible">true</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/resources/ui/gb-editor-view.ui b/src/resources/ui/gb-editor-view.ui
index 3261bbf..c982a54 100644
--- a/src/resources/ui/gb-editor-view.ui
+++ b/src/resources/ui/gb-editor-view.ui
@@ -9,11 +9,20 @@
           <class name="linked"/>
         </style>
         <child>
+          <object class="GtkMenuButton" id="tweak_button">
+            <property name="visible">true</property>
+            <property name="popover">tweak_popover</property>
+            <style>
+              <class name="text-button"/>
+              <class name="tab-control-first"/>
+            </style>
+          </object>
+        </child>
+        <child>
           <object class="GtkToggleButton" id="split_button">
             <property name="visible">true</property>
             <style>
               <class name="image-button"/>
-              <class name="tab-control-first"/>
               <class name="tab-control-last"/>
             </style>
             <child>
@@ -212,4 +221,12 @@
       </object>
     </child>
   </template>
+  <object class="GtkPopoverMenu" id="tweak_popover">
+    <child>
+      <object class="GbEditorTweakWidget" id="tweak_widget">
+        <property name="visible">true</property>
+        <property name="margin">10</property>
+      </object>
+    </child>
+  </object>
 </interface>


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