[gnome-builder/wip/chergert/layout] editor: stub out properties editor widget



commit 205814d6b2a2b8a77ee2aff34e6f53814223f6bf
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jul 6 00:48:28 2017 -0700

    editor: stub out properties editor widget

 libide/editor/ide-editor-properties.c  |  131 ++++++++++++++++++++++++++++++++
 libide/editor/ide-editor-properties.h  |   35 +++++++++
 libide/editor/ide-editor-properties.ui |   11 +++
 libide/libide.gresource.xml            |    1 +
 libide/meson.build                     |    2 +
 5 files changed, 180 insertions(+), 0 deletions(-)
---
diff --git a/libide/editor/ide-editor-properties.c b/libide/editor/ide-editor-properties.c
new file mode 100644
index 0000000..b7ab461
--- /dev/null
+++ b/libide/editor/ide-editor-properties.c
@@ -0,0 +1,131 @@
+/* ide-editor-properties.c
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * 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 "ide-editor-properties"
+
+#include <dazzle.h>
+
+#include "editor/ide-editor-properties.h"
+
+/**
+ * SECTION:ide-editor-properties
+ * @title: IdeEditorProperties
+ * @short_description: property editor for IdeEditorView
+ *
+ * This widget is a property editor to tweak settings of an #IdeEditorView.
+ * It should be used in a transient panel when the user needs to tweak the
+ * settings of a view.
+ *
+ * Since: 3.26
+ */
+
+struct _IdeEditorProperties
+{
+  GtkBin parent_instance;
+};
+
+enum {
+  PROP_0,
+  PROP_VIEW,
+  N_PROPS
+};
+
+G_DEFINE_TYPE (IdeEditorProperties, ide_editor_properties, GTK_TYPE_BIN)
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+ide_editor_properties_set_property (GObject      *object,
+                                    guint         prop_id,
+                                    const GValue *value,
+                                    GParamSpec   *pspec)
+{
+  IdeEditorProperties *self = IDE_EDITOR_PROPERTIES (object);
+
+  switch (prop_id)
+    {
+    case PROP_VIEW:
+      ide_editor_properties_set_view (self, g_value_get_object (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+ide_editor_properties_class_init (IdeEditorPropertiesClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  object_class->set_property = ide_editor_properties_set_property;
+
+  properties [PROP_VIEW] =
+    g_param_spec_object ("view",
+                         "View",
+                         "The editor view to modify",
+                         IDE_TYPE_EDITOR_VIEW,
+                         (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, N_PROPS, properties);
+
+  gtk_widget_class_set_template_from_resource (widget_class,
+                                               "/org/gnome/builder/ui/ide-editor-properties.ui");
+}
+
+static void
+ide_editor_properties_init (IdeEditorProperties *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+/**
+ * ide_editor_properties_new:
+ *
+ * Creates a new #IdeEditorProperties.
+ *
+ * Returns: (transfer full): A #IdeEditorProperties
+ *
+ * Since: 3.26
+ */
+GtkWidget *
+ide_editor_properties_new (void)
+{
+  return g_object_new (IDE_TYPE_EDITOR_PROPERTIES, NULL);
+}
+
+/**
+ * ide_editor_properties_set_view:
+ * @self: an #IdeEditorProperties
+ * @view: (nullable): an #IdeEditorView
+ *
+ * Sets the view to be edited by the property editor.
+ *
+ * Since: 3.26
+ */
+void
+ide_editor_properties_set_view (IdeEditorProperties *self,
+                                IdeEditorView       *view)
+{
+  g_return_if_fail (IDE_IS_EDITOR_VIEW (self));
+
+  dzl_gtk_widget_mux_action_groups (GTK_WIDGET (self),
+                                    view ? GTK_WIDGET (view) : NULL,
+                                    "IDE_EDITOR_PROPERTY_ACTIONS");
+}
diff --git a/libide/editor/ide-editor-properties.h b/libide/editor/ide-editor-properties.h
new file mode 100644
index 0000000..50a9b10
--- /dev/null
+++ b/libide/editor/ide-editor-properties.h
@@ -0,0 +1,35 @@
+/* ide-editor-properties.h
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * 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/>.
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "editor/ide-editor-view.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_EDITOR_PROPERTIES (ide_editor_properties_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeEditorProperties, ide_editor_properties, IDE, EDITOR_PROPERTIES, GtkBin)
+
+GtkWidget *ide_editor_properties_new      (void);
+void       ide_editor_properties_set_view (IdeEditorProperties *self,
+                                           IdeEditorView       *view);
+
+G_END_DECLS
diff --git a/libide/editor/ide-editor-properties.ui b/libide/editor/ide-editor-properties.ui
new file mode 100644
index 0000000..126b510
--- /dev/null
+++ b/libide/editor/ide-editor-properties.ui
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="IdeEditorProperties" parent="GtkBin">
+    <child>
+      <object class="GtkBox">
+        <property name="orientation">vertical</property>
+        <property name="visible">true</property>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/libide/libide.gresource.xml b/libide/libide.gresource.xml
index 5e17350..26a1472 100644
--- a/libide/libide.gresource.xml
+++ b/libide/libide.gresource.xml
@@ -55,6 +55,7 @@
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-layout-stack-header.ui">layout/ide-layout-stack-header.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-layout-stack.ui">layout/ide-layout-stack.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-editor-perspective.ui">editor/ide-editor-perspective.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-editor-properties.ui">editor/ide-editor-properties.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-editor-layout-stack-controls.ui">editor/ide-editor-layout-stack-controls.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-editor-search-bar.ui">editor/ide-editor-search-bar.ui</file>
     <file compressed="true" preprocess="xml-stripblanks" 
alias="ide-editor-sidebar.ui">editor/ide-editor-sidebar.ui</file>
diff --git a/libide/meson.build b/libide/meson.build
index 891d332..918b17b 100644
--- a/libide/meson.build
+++ b/libide/meson.build
@@ -474,6 +474,8 @@ libide_sources = libide_generated_headers + libide_public_sources + [
   'editor/ide-editor-print-operation.c',
   'editor/ide-editor-print-operation.h',
   'editor/ide-editor-private.h',
+  'editor/ide-editor-properties.c',
+  'editor/ide-editor-properties.h',
   'editor/ide-editor-search-bar.c',
   'editor/ide-editor-search-bar.h',
   'editor/ide-editor-view-actions.c',


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