[gnome-builder/wip/glade] wip: stub out glade plugin



commit c344ba2229be3171be7638833e46865d0597df98
Author: Christian Hergert <christian hergert me>
Date:   Sat Jun 20 14:28:07 2015 -0700

    wip: stub out glade plugin
    
    Doesn't do anything yet, just playing around with restyling existing
    glade components via ui monkey patching.

 configure.ac                         |    3 +
 data/theme/Adwaita-shared.css        |   11 +++
 plugins/Makefile.am                  |    1 +
 plugins/glade/Makefile.am            |   47 ++++++++++++
 plugins/glade/gb-glade-addin.c       |  135 +++++++++++++++++++++++++++++++++
 plugins/glade/gb-glade-addin.h       |   32 ++++++++
 plugins/glade/gb-glade-panel.c       |  137 ++++++++++++++++++++++++++++++++++
 plugins/glade/gb-glade-panel.h       |   32 ++++++++
 plugins/glade/gb-glade-panel.ui      |   35 +++++++++
 plugins/glade/gb-glade.gresource.xml |    6 ++
 plugins/glade/glade.plugin           |    8 ++
 11 files changed, 447 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d32441d..e96eded 100644
--- a/configure.ac
+++ b/configure.ac
@@ -139,6 +139,7 @@ dnl Check for Required Packages
 dnl ***********************************************************************
 m4_define([gtk_required_version], [3.17.1])
 m4_define([glib_required_version], [2.45.1])
+m4_define([glade_required_version], [3.19.0])
 m4_define([gtksourceview_required_version], [3.17.2])
 m4_define([ggit_required_version], [0.22.9])
 m4_define([gjs_required_version], [1.42.0])
@@ -154,6 +155,7 @@ PKG_CHECK_MODULES(BUILDER,  [gtk+-3.0 >= gtk_required_version
                              libdevhelp-3.0 >= devhelp_required_version
                              libgit2-glib-1.0 >= ggit_required_version
                              libpeas-1.0 >= peas_required_version
+                             gladeui-2.0 >= glade_required_version
                             vte-2.91 >= vte_required_version])
 PKG_CHECK_MODULES(EGG,      [glib-2.0 >= glib_required_version
                              gtk+-3.0 >= gtk_required_version])
@@ -387,6 +389,7 @@ AC_CONFIG_FILES([
        plugins/devhelp/Makefile
        plugins/device-manager/Makefile
        plugins/file-search/Makefile
+       plugins/glade/Makefile
        plugins/symbol-tree/Makefile
        plugins/sysmon/Makefile
        plugins/terminal/Makefile
diff --git a/data/theme/Adwaita-shared.css b/data/theme/Adwaita-shared.css
index 4f03d50..f067c79 100644
--- a/data/theme/Adwaita-shared.css
+++ b/data/theme/Adwaita-shared.css
@@ -83,3 +83,14 @@ SymbolTree GtkSearchEntry {
   border-top: none;
   border-radius: 0px;
 }
+
+
+/*
+ * Glade panel styling.
+ */
+GbGladePanel GladeInspector GtkEntry {
+  border-left: none;
+  border-right: none;
+  border-top: none;
+  border-radius: 0px;
+}
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 370d79d..28e56b8 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -3,6 +3,7 @@ SUBDIRS = \
        devhelp \
        device-manager \
        file-search \
+       glade \
        symbol-tree \
        sysmon \
        terminal \
diff --git a/plugins/glade/Makefile.am b/plugins/glade/Makefile.am
new file mode 100644
index 0000000..87a7195
--- /dev/null
+++ b/plugins/glade/Makefile.am
@@ -0,0 +1,47 @@
+DISTCLEANFILES =
+BUILT_SOURCES =
+CLEANFILES =
+EXTRA_DIST = $(plugin_DATA)
+
+plugindir = $(libdir)/gnome-builder/plugins
+plugin_LTLIBRARIES = libglade.la
+plugin_DATA = glade.plugin
+
+libglade_la_SOURCES = \
+       gb-glade-addin.c \
+       gb-glade-addin.h \
+       gb-glade-panel.c \
+       gb-glade-panel.h \
+       $(NULL)
+
+nodist_libglade_la_SOURCES = \
+       gb-glade-resources.c \
+       gb-glade-resources.h
+
+# XXX: temporary, since we need to extract lots of src/ into plugins
+libglade_la_CFLAGS = \
+       $(BUILDER_CFLAGS) \
+       -I$(top_srcdir)/src \
+       -I$(top_srcdir)/src/documents \
+       -I$(top_srcdir)/src/editor \
+       -I$(top_srcdir)/src/views \
+       -I$(top_srcdir)/src/workbench \
+       -I$(top_srcdir)/src/workspace \
+       -I$(top_srcdir)/libide \
+       -I$(top_srcdir)/contrib/egg \
+       $(NULL)
+
+libglade_la_LDFLAGS = \
+       $(OPTIMIZE_LDFLAGS) \
+       -avoid-version \
+       -module \
+       $(NULL)
+
+glib_resources_c = gb-glade-resources.c
+glib_resources_h = gb-glade-resources.h
+glib_resources_xml = gb-glade.gresource.xml
+glib_resources_namespace = gb_glade
+include $(top_srcdir)/build/autotools/Makefile.am.gresources
+
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/glade/gb-glade-addin.c b/plugins/glade/gb-glade-addin.c
new file mode 100644
index 0000000..fa32272
--- /dev/null
+++ b/plugins/glade/gb-glade-addin.c
@@ -0,0 +1,135 @@
+/* gb-glade-addin.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 <libpeas/peas.h>
+
+#include "gb-glade-addin.h"
+#include "gb-glade-panel.h"
+#include "gb-workbench-addin.h"
+#include "gb-workspace.h"
+
+struct _GbGladeAddin
+{
+  GObject       parent_instnace;
+
+  GbWorkbench  *workbench;
+  GbGladePanel *panel;
+};
+
+static void workbench_addin_iface_init (GbWorkbenchAddinInterface *iface);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (GbGladeAddin, gb_glade_addin, G_TYPE_OBJECT, 0,
+                                G_IMPLEMENT_INTERFACE_DYNAMIC (GB_TYPE_WORKBENCH_ADDIN,
+                                                               workbench_addin_iface_init))
+
+enum {
+  PROP_0,
+  PROP_WORKBENCH,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+static void
+gb_glade_addin_load (GbWorkbenchAddin *addin)
+{
+  GbGladeAddin *self = (GbGladeAddin *)addin;
+  GtkWidget *workspace;
+  GtkWidget *pane;
+
+  g_assert (GB_IS_GLADE_ADDIN (self));
+
+  workspace = gb_workbench_get_workspace (self->workbench);
+  pane = gb_workspace_get_right_pane (GB_WORKSPACE (workspace));
+
+  self->panel = g_object_new (GB_TYPE_GLADE_PANEL,
+                              "visible", TRUE,
+                              NULL);
+  gb_workspace_pane_add_page (GB_WORKSPACE_PANE (pane), GTK_WIDGET (self->panel),
+                              _("Glade"), "glade-symbolic");
+}
+
+static void
+gb_glade_addin_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (gb_glade_addin_parent_class)->finalize (object);
+}
+
+static void
+gb_glade_addin_set_property (GObject      *object,
+                             guint         prop_id,
+                             const GValue *value,
+                             GParamSpec   *pspec)
+{
+  GbGladeAddin *self = (GbGladeAddin *)object;
+
+  switch (prop_id)
+    {
+    case PROP_WORKBENCH:
+      ide_set_weak_pointer (&self->workbench, g_value_get_object (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_glade_addin_class_finalize (GbGladeAddinClass *klass)
+{
+}
+
+static void
+gb_glade_addin_class_init (GbGladeAddinClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gb_glade_addin_finalize;
+  object_class->set_property = gb_glade_addin_set_property;
+
+  gParamSpecs [PROP_WORKBENCH] =
+    g_param_spec_object ("workbench",
+                         _("Workbench"),
+                         _("Workbench"),
+                         GB_TYPE_WORKBENCH,
+                         (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, LAST_PROP, gParamSpecs);
+}
+
+static void
+gb_glade_addin_init (GbGladeAddin *self)
+{
+}
+
+static void
+workbench_addin_iface_init (GbWorkbenchAddinInterface *iface)
+{
+  iface->load = gb_glade_addin_load;
+}
+
+void
+peas_register_types (PeasObjectModule *module)
+{
+  gb_glade_addin_register_type (G_TYPE_MODULE (module));
+
+  peas_object_module_register_extension_type (module,
+                                              GB_TYPE_WORKBENCH_ADDIN,
+                                              GB_TYPE_GLADE_ADDIN);
+}
diff --git a/plugins/glade/gb-glade-addin.h b/plugins/glade/gb-glade-addin.h
new file mode 100644
index 0000000..5cf4fb1
--- /dev/null
+++ b/plugins/glade/gb-glade-addin.h
@@ -0,0 +1,32 @@
+/* gb-glade-addin.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_GLADE_ADDIN_H
+#define GB_GLADE_ADDIN_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_GLADE_ADDIN (gb_glade_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbGladeAddin, gb_glade_addin, GB, GLADE_ADDIN, GObject)
+
+G_END_DECLS
+
+#endif /* GB_GLADE_ADDIN_H */
diff --git a/plugins/glade/gb-glade-panel.c b/plugins/glade/gb-glade-panel.c
new file mode 100644
index 0000000..854c419
--- /dev/null
+++ b/plugins/glade/gb-glade-panel.c
@@ -0,0 +1,137 @@
+/* gb-glade-panel.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 <gladeui/glade.h>
+#include <ide.h>
+
+#include "gb-glade-panel.h"
+
+struct _GbGladePanel
+{
+  GtkBox          parent_instance;
+
+  GladeEditor    *editor;
+  GladeInspector *inspector;
+};
+
+G_DEFINE_TYPE (GbGladePanel, gb_glade_panel, GTK_TYPE_BOX)
+
+enum {
+  PROP_0,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+static void
+fixup_inspector_styling (GtkWidget *widget,
+                         gpointer   user_data)
+{
+  if (GTK_IS_ENTRY (widget))
+    {
+      GtkWidget *parent;
+
+      parent = gtk_widget_get_parent (widget);
+      gtk_container_child_set (GTK_CONTAINER (parent), widget, "padding", 0, NULL);
+
+      g_object_set (widget,
+                    "primary-icon-name", "edit-find-symbolic",
+                    "placeholder-text", NULL,
+                    "secondary-icon-name", NULL,
+                    NULL);
+    }
+  else if (GTK_IS_SCROLLED_WINDOW (widget))
+    {
+      gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_NONE);
+    }
+}
+
+static void
+fixup_editor_styling (GtkWidget *widget,
+                      gpointer   user_data)
+{
+  if (GTK_IS_NOTEBOOK (widget))
+    {
+      gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
+    }
+}
+
+static void
+gb_glade_panel_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (gb_glade_panel_parent_class)->finalize (object);
+}
+
+static void
+gb_glade_panel_get_property (GObject    *object,
+                             guint       prop_id,
+                             GValue     *value,
+                             GParamSpec *pspec)
+{
+  GbGladePanel *self = GB_GLADE_PANEL (object);
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_glade_panel_set_property (GObject      *object,
+                             guint         prop_id,
+                             const GValue *value,
+                             GParamSpec   *pspec)
+{
+  GbGladePanel *self = GB_GLADE_PANEL (object);
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_glade_panel_class_init (GbGladePanelClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  object_class->finalize = gb_glade_panel_finalize;
+  object_class->get_property = gb_glade_panel_get_property;
+  object_class->set_property = gb_glade_panel_set_property;
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/plugins/glade/gb-glade-panel.ui");
+  gtk_widget_class_bind_template_child (widget_class, GbGladePanel, editor);
+  gtk_widget_class_bind_template_child (widget_class, GbGladePanel, inspector);
+}
+
+static void
+gb_glade_panel_init (GbGladePanel *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+
+  gtk_container_foreach (GTK_CONTAINER (self->editor),
+                         fixup_editor_styling,
+                         NULL);
+  gtk_container_foreach (GTK_CONTAINER (self->inspector),
+                         fixup_inspector_styling,
+                         NULL);
+}
diff --git a/plugins/glade/gb-glade-panel.h b/plugins/glade/gb-glade-panel.h
new file mode 100644
index 0000000..a47aa45
--- /dev/null
+++ b/plugins/glade/gb-glade-panel.h
@@ -0,0 +1,32 @@
+/* gb-glade-panel.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_GLADE_PANEL_H
+#define GB_GLADE_PANEL_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_GLADE_PANEL (gb_glade_panel_get_type())
+
+G_DECLARE_FINAL_TYPE (GbGladePanel, gb_glade_panel, GB, GLADE_PANEL, GtkBox)
+
+G_END_DECLS
+
+#endif /* GB_GLADE_PANEL_H */
diff --git a/plugins/glade/gb-glade-panel.ui b/plugins/glade/gb-glade-panel.ui
new file mode 100644
index 0000000..23f50e7
--- /dev/null
+++ b/plugins/glade/gb-glade-panel.ui
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.16 -->
+  <template class="GbGladePanel" parent="GtkBox">
+    <property name="vexpand">true</property>
+    <property name="visible">true</property>
+    <property name="orientation">vertical</property>
+    <child>
+      <object class="GtkPaned">
+        <property name="orientation">vertical</property>
+        <property name="visible">true</property>
+        <child>
+          <object class="GladeInspector" id="inspector">
+            <property name="visible">true</property>
+            <property name="vexpand">true</property>
+          </object>
+          <packing>
+            <property name="resize">true</property>
+            <property name="shrink">false</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladeEditor" id="editor">
+            <property name="visible">true</property>
+            <property name="vexpand">true</property>
+          </object>
+          <packing>
+            <property name="resize">true</property>
+            <property name="shrink">false</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/plugins/glade/gb-glade.gresource.xml b/plugins/glade/gb-glade.gresource.xml
new file mode 100644
index 0000000..1358d39
--- /dev/null
+++ b/plugins/glade/gb-glade.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/builder/plugins/glade">
+    <file>gb-glade-panel.ui</file>
+  </gresource>
+</gresources>
diff --git a/plugins/glade/glade.plugin b/plugins/glade/glade.plugin
new file mode 100644
index 0000000..bbd72ec
--- /dev/null
+++ b/plugins/glade/glade.plugin
@@ -0,0 +1,8 @@
+[Plugin]
+Module=glade
+Name=Glade
+Description=Provides integration with the Glade UI designer.
+Authors=Christian Hergert <christian hergert me>
+Copyright=Copyright © 2015 Christian Hergert
+Builtin=true
+Hidden=true


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