[gnome-builder/document-manager] devhelp: start on devhelp view for new style documents
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/document-manager] devhelp: start on devhelp view for new style documents
- Date: Tue, 9 Dec 2014 23:24:05 +0000 (UTC)
commit aee9b80982f4aedccb2050d61afabeebee5dcf84
Author: Christian Hergert <christian hergert me>
Date: Tue Dec 9 15:23:48 2014 -0800
devhelp: start on devhelp view for new style documents
src/devhelp/gb-devhelp-document.c | 149 +++++++++++++++++++++++++++++++++++
src/devhelp/gb-devhelp-document.h | 58 ++++++++++++++
src/devhelp/gb-devhelp-view.c | 145 ++++++++++++++++++++++++++++++++++
src/devhelp/gb-devhelp-view.h | 57 +++++++++++++
src/gnome-builder.mk | 4 +
src/resources/ui/gb-devhelp-view.ui | 19 +++++
6 files changed, 432 insertions(+), 0 deletions(-)
---
diff --git a/src/devhelp/gb-devhelp-document.c b/src/devhelp/gb-devhelp-document.c
new file mode 100644
index 0000000..d18027a
--- /dev/null
+++ b/src/devhelp/gb-devhelp-document.c
@@ -0,0 +1,149 @@
+/* gb-devhelp-document.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 "devhelp-document"
+
+#include <glib/gi18n.h>
+
+#include "gb-devhelp-document.h"
+
+struct _GbDevhelpDocumentPrivate
+{
+ gchar *title;
+};
+
+static void gb_document_init (GbDocumentInterface *iface);
+
+G_DEFINE_TYPE_EXTENDED (GbDevhelpDocument,
+ gb_devhelp_document,
+ G_TYPE_OBJECT,
+ 0,
+ G_ADD_PRIVATE (GbDevhelpDocument)
+ G_IMPLEMENT_INTERFACE (GB_TYPE_DOCUMENT,
+ gb_document_init))
+
+enum {
+ PROP_0,
+ PROP_MODIFIED,
+ PROP_TITLE,
+ LAST_PROP
+};
+
+GbDevhelpDocument *
+gb_devhelp_document_new (void)
+{
+ return g_object_new (GB_TYPE_DEVHELP_DOCUMENT, NULL);
+}
+
+const gchar *
+gb_devhelp_document_get_title (GbDocument *document)
+{
+ GbDevhelpDocument *self = (GbDevhelpDocument *)document;
+
+ g_return_val_if_fail (GB_IS_DEVHELP_DOCUMENT (self), NULL);
+
+ if (self->priv->title)
+ return self->priv->title;
+
+ return _("Documentation");
+}
+
+gboolean
+gb_devhelp_document_get_modified (GbDocument *document)
+{
+ g_return_val_if_fail (GB_IS_DEVHELP_DOCUMENT (document), FALSE);
+
+ return FALSE;
+}
+
+static void
+gb_devhelp_document_finalize (GObject *object)
+{
+ GbDevhelpDocumentPrivate *priv = GB_DEVHELP_DOCUMENT (object)->priv;
+
+ g_clear_pointer (&priv->title, g_free);
+
+ G_OBJECT_CLASS (gb_devhelp_document_parent_class)->finalize (object);
+}
+
+static void
+gb_devhelp_document_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbDevhelpDocument *self = GB_DEVHELP_DOCUMENT (object);
+
+ switch (prop_id)
+ {
+ case PROP_MODIFIED:
+ g_value_set_boolean (value,
+ gb_devhelp_document_get_modified (GB_DOCUMENT (self)));
+ break;
+
+ case PROP_TITLE:
+ g_value_set_string (value,
+ gb_devhelp_document_get_title (GB_DOCUMENT (self)));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_devhelp_document_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+#if 0
+ GbDevhelpDocument *self = GB_DEVHELP_DOCUMENT (object);
+#endif
+
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_devhelp_document_class_init (GbDevhelpDocumentClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gb_devhelp_document_finalize;
+ object_class->get_property = gb_devhelp_document_get_property;
+ object_class->set_property = gb_devhelp_document_set_property;
+
+ g_object_class_override_property (object_class, PROP_TITLE, "title");
+ g_object_class_override_property (object_class, PROP_MODIFIED, "modified");
+}
+
+static void
+gb_devhelp_document_init (GbDevhelpDocument *self)
+{
+ self->priv = gb_devhelp_document_get_instance_private (self);
+}
+
+static void
+gb_document_init (GbDocumentInterface *iface)
+{
+ iface->get_title = gb_devhelp_document_get_title;
+}
diff --git a/src/devhelp/gb-devhelp-document.h b/src/devhelp/gb-devhelp-document.h
new file mode 100644
index 0000000..0ab0610
--- /dev/null
+++ b/src/devhelp/gb-devhelp-document.h
@@ -0,0 +1,58 @@
+/* gb-devhelp-document.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_DEVHELP_DOCUMENT_H
+#define GB_DEVHELP_DOCUMENT_H
+
+#include "gb-document.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_DEVHELP_DOCUMENT (gb_devhelp_document_get_type())
+#define GB_DEVHELP_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_DEVHELP_DOCUMENT,
GbDevhelpDocument))
+#define GB_DEVHELP_DOCUMENT_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_DEVHELP_DOCUMENT,
GbDevhelpDocument const))
+#define GB_DEVHELP_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GB_TYPE_DEVHELP_DOCUMENT,
GbDevhelpDocumentClass))
+#define GB_IS_DEVHELP_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GB_TYPE_DEVHELP_DOCUMENT))
+#define GB_IS_DEVHELP_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GB_TYPE_DEVHELP_DOCUMENT))
+#define GB_DEVHELP_DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GB_TYPE_DEVHELP_DOCUMENT,
GbDevhelpDocumentClass))
+
+typedef struct _GbDevhelpDocument GbDevhelpDocument;
+typedef struct _GbDevhelpDocumentClass GbDevhelpDocumentClass;
+typedef struct _GbDevhelpDocumentPrivate GbDevhelpDocumentPrivate;
+
+struct _GbDevhelpDocument
+{
+ GObject parent;
+
+ /*< private >*/
+ GbDevhelpDocumentPrivate *priv;
+};
+
+struct _GbDevhelpDocumentClass
+{
+ GObjectClass parent;
+};
+
+GType gb_devhelp_document_get_type (void);
+GbDevhelpDocument *gb_devhelp_document_new (void);
+void gb_devhelp_document_set_search (GbDevhelpDocument *document,
+ const gchar *search);
+
+G_END_DECLS
+
+#endif /* GB_DEVHELP_DOCUMENT_H */
diff --git a/src/devhelp/gb-devhelp-view.c b/src/devhelp/gb-devhelp-view.c
new file mode 100644
index 0000000..56cfad2
--- /dev/null
+++ b/src/devhelp/gb-devhelp-view.c
@@ -0,0 +1,145 @@
+/* gb-devhelp-view.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 "devhelp-view"
+
+#include <glib/gi18n.h>
+#include <webkit2/webkit2.h>
+
+#include "gb-devhelp-view.h"
+
+struct _GbDevhelpViewPrivate
+{
+ GbDevhelpDocument *document;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbDevhelpView, gb_devhelp_view,
+ GB_TYPE_DOCUMENT_VIEW)
+
+enum {
+ PROP_0,
+ PROP_DOCUMENT,
+ LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+GbDocumentView *
+gb_devhelp_view_new (GbDevhelpDocument *document)
+{
+ return g_object_new (GB_TYPE_DEVHELP_VIEW,
+ "document", document,
+ NULL);
+}
+
+static GbDocument *
+gb_devhelp_view_get_document (GbDocumentView *view)
+{
+ g_return_val_if_fail (GB_IS_DEVHELP_VIEW (view), NULL);
+
+ return GB_DOCUMENT (GB_DEVHELP_VIEW (view)->priv->document);
+}
+
+static void
+gb_devhelp_view_set_document (GbDevhelpView *view,
+ GbDevhelpDocument *document)
+{
+ g_return_if_fail (GB_IS_DEVHELP_VIEW (view));
+}
+
+static void
+gb_devhelp_view_finalize (GObject *object)
+{
+ GbDevhelpViewPrivate *priv = GB_DEVHELP_VIEW (object)->priv;
+
+ g_clear_object (&priv->document);
+
+ G_OBJECT_CLASS (gb_devhelp_view_parent_class)->finalize (object);
+}
+
+static void
+gb_devhelp_view_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbDevhelpView *self = GB_DEVHELP_VIEW (object);
+
+ switch (prop_id)
+ {
+ case PROP_DOCUMENT:
+ g_value_set_object (value, self->priv->document);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_devhelp_view_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbDevhelpView *self = GB_DEVHELP_VIEW (object);
+
+ switch (prop_id)
+ {
+ case PROP_DOCUMENT:
+ gb_devhelp_view_set_document (self, g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_devhelp_view_class_init (GbDevhelpViewClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GbDocumentViewClass *view_class = GB_DOCUMENT_VIEW_CLASS (klass);
+
+ object_class->finalize = gb_devhelp_view_finalize;
+ object_class->get_property = gb_devhelp_view_get_property;
+ object_class->set_property = gb_devhelp_view_set_property;
+
+ view_class->get_document = gb_devhelp_view_get_document;
+
+ gParamSpecs [PROP_DOCUMENT] =
+ g_param_spec_object ("document",
+ _("Document"),
+ _("The document for the devhelp view."),
+ GB_TYPE_DEVHELP_DOCUMENT,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_DOCUMENT,
+ gParamSpecs [PROP_DOCUMENT]);
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/builder/ui/gb-devhelp-view.ui");
+}
+
+static void
+gb_devhelp_view_init (GbDevhelpView *self)
+{
+ self->priv = gb_devhelp_view_get_instance_private (self);
+
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/devhelp/gb-devhelp-view.h b/src/devhelp/gb-devhelp-view.h
new file mode 100644
index 0000000..4714ea2
--- /dev/null
+++ b/src/devhelp/gb-devhelp-view.h
@@ -0,0 +1,57 @@
+/* gb-devhelp-view.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_DEVHELP_VIEW_H
+#define GB_DEVHELP_VIEW_H
+
+#include "gb-devhelp-document.h"
+#include "gb-document-view.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_DEVHELP_VIEW (gb_devhelp_view_get_type())
+#define GB_DEVHELP_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_DEVHELP_VIEW,
GbDevhelpView))
+#define GB_DEVHELP_VIEW_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_DEVHELP_VIEW,
GbDevhelpView const))
+#define GB_DEVHELP_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GB_TYPE_DEVHELP_VIEW,
GbDevhelpViewClass))
+#define GB_IS_DEVHELP_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GB_TYPE_DEVHELP_VIEW))
+#define GB_IS_DEVHELP_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GB_TYPE_DEVHELP_VIEW))
+#define GB_DEVHELP_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GB_TYPE_DEVHELP_VIEW,
GbDevhelpViewClass))
+
+typedef struct _GbDevhelpView GbDevhelpView;
+typedef struct _GbDevhelpViewClass GbDevhelpViewClass;
+typedef struct _GbDevhelpViewPrivate GbDevhelpViewPrivate;
+
+struct _GbDevhelpView
+{
+ GbDocumentView parent;
+
+ /*< private >*/
+ GbDevhelpViewPrivate *priv;
+};
+
+struct _GbDevhelpViewClass
+{
+ GbDocumentViewClass parent;
+};
+
+GType gb_devhelp_view_get_type (void);
+GbDocumentView *gb_devhelp_view_new (GbDevhelpDocument *document);
+
+G_END_DECLS
+
+#endif /* GB_DEVHELP_VIEW_H */
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 1499a15..f92d9e5 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -41,6 +41,10 @@ libgnome_builder_la_SOURCES = \
src/commands/gb-command-vim.h \
src/credits/gb-credits-widget.c \
src/credits/gb-credits-widget.h \
+ src/devhelp/gb-devhelp-document.c \
+ src/devhelp/gb-devhelp-document.h \
+ src/devhelp/gb-devhelp-view.c \
+ src/devhelp/gb-devhelp-view.h \
src/devhelp/gb-devhelp-tab.c \
src/devhelp/gb-devhelp-tab.h \
src/documents/gb-document.c \
diff --git a/src/resources/ui/gb-devhelp-view.ui b/src/resources/ui/gb-devhelp-view.ui
new file mode 100644
index 0000000..90ed6e7
--- /dev/null
+++ b/src/resources/ui/gb-devhelp-view.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.14 -->
+ <template class="GbDevhelpView" parent="GbDocumentView">
+ <child internal-child="controls">
+ <object class="GtkBox">
+ <property name="visible">true</property>
+ <style>
+ <class name="linked"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="WebKitWebView" id="web_view">
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]