[gnome-builder] document: use modified instead of can-save.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] document: use modified instead of can-save.
- Date: Thu, 11 Dec 2014 00:08:31 +0000 (UTC)
commit 747ebb1cdfae105161e322e529930431cdccaf35
Author: Christian Hergert <christian hergert me>
Date: Sun Dec 7 02:39:45 2014 -0800
document: use modified instead of can-save.
src/documents/gb-document.c | 48 ++++++++++++++++++++++++++++++---------
src/editor/gb-editor-document.c | 30 +++++++++++++++++++-----
2 files changed, 61 insertions(+), 17 deletions(-)
---
diff --git a/src/documents/gb-document.c b/src/documents/gb-document.c
index 0528a42..ac646eb 100644
--- a/src/documents/gb-document.c
+++ b/src/documents/gb-document.c
@@ -19,24 +19,31 @@
#include <glib/gi18n.h>
#include "gb-document.h"
+#include "gb-document-view.h"
G_DEFINE_INTERFACE (GbDocument, gb_document, G_TYPE_OBJECT)
enum {
PROP_0,
- PROP_CAN_SAVE,
+ PROP_MODIFIED,
PROP_TITLE,
LAST_PROP
};
+enum {
+ CREATE_VIEW,
+ LAST_SIGNAL
+};
+
static GParamSpec *gParamSpecs [LAST_PROP];
+static guint gSignals [LAST_SIGNAL];
gboolean
-gb_document_get_can_save (GbDocument *document)
+gb_document_get_modified (GbDocument *document)
{
g_return_val_if_fail (GB_IS_DOCUMENT (document), FALSE);
- return GB_DOCUMENT_GET_INTERFACE (document)->get_can_save (document);
+ return GB_DOCUMENT_GET_INTERFACE (document)->get_modified (document);
}
const gchar *
@@ -47,24 +54,32 @@ gb_document_get_title (GbDocument *document)
return GB_DOCUMENT_GET_INTERFACE (document)->get_title (document);
}
-GbTab *
-gb_document_create_tab (GbDocument *document)
+GtkWidget *
+gb_document_create_view (GbDocument *document)
{
+ GtkWidget *ret = NULL;
+
g_return_val_if_fail (GB_IS_DOCUMENT (document), NULL);
- return GB_DOCUMENT_GET_INTERFACE (document)->create_tab (document);
+ g_signal_emit (document, gSignals [CREATE_VIEW], 0, &ret);
+
+ if (!ret)
+ g_warning ("%s failed to implement create_view() signal",
+ g_type_name (G_TYPE_FROM_INSTANCE (document)));
+
+ return ret;
}
static void
gb_document_default_init (GbDocumentInterface *iface)
{
- gParamSpecs [PROP_CAN_SAVE] =
- g_param_spec_boolean ("can-save",
- _("Can Save"),
- _("If the document can be saved."),
+ gParamSpecs [PROP_MODIFIED] =
+ g_param_spec_boolean ("modified",
+ _("Modified"),
+ _("If the document has been modified from disk."),
FALSE,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_interface_install_property (iface, gParamSpecs [PROP_CAN_SAVE]);
+ g_object_interface_install_property (iface, gParamSpecs [PROP_MODIFIED]);
gParamSpecs [PROP_TITLE] =
g_param_spec_string ("title",
@@ -73,4 +88,15 @@ gb_document_default_init (GbDocumentInterface *iface)
NULL,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface, gParamSpecs [PROP_TITLE]);
+
+ gSignals [CREATE_VIEW] =
+ g_signal_new ("create-view",
+ GB_TYPE_DOCUMENT,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GbDocumentInterface, create_view),
+ g_signal_accumulator_first_wins,
+ NULL,
+ g_cclosure_marshal_generic,
+ GB_TYPE_DOCUMENT_VIEW,
+ 0);
}
diff --git a/src/editor/gb-editor-document.c b/src/editor/gb-editor-document.c
index 672dc94..d1268f6 100644
--- a/src/editor/gb-editor-document.c
+++ b/src/editor/gb-editor-document.c
@@ -25,6 +25,7 @@
#include "gb-doc-seq.h"
#include "gb-editor-document.h"
#include "gb-editor-file-marks.h"
+#include "gb-editor-view.h"
#include "gb-log.h"
#include "gca-structs.h"
@@ -41,9 +42,9 @@ struct _GbEditorDocumentPrivate
enum {
PROP_0,
- PROP_CAN_SAVE,
PROP_CHANGE_MONITOR,
PROP_FILE,
+ PROP_MODIFIED,
PROP_STYLE_SCHEME_NAME,
PROP_TITLE,
PROP_TRIM_TRAILING_WHITESPACE,
@@ -729,7 +730,7 @@ gb_editor_document_modified_changed (GtkTextBuffer *buffer)
}
gboolean
-gb_editor_document_get_can_save (GbDocument *document)
+gb_editor_document_get_modified (GbDocument *document)
{
g_return_val_if_fail (GB_IS_EDITOR_DOCUMENT (document), FALSE);
@@ -744,6 +745,21 @@ gb_editor_document_get_title (GbDocument *document)
return GB_EDITOR_DOCUMENT (document)->priv->title;
}
+static GtkWidget *
+gb_editor_document_create_view (GbDocument *document)
+{
+ GbEditorView *view;
+
+ g_return_val_if_fail (GB_IS_EDITOR_DOCUMENT (document), NULL);
+
+ view = g_object_new (GB_TYPE_EDITOR_VIEW,
+ "document", document,
+ "visible", TRUE,
+ NULL);
+
+ return GTK_WIDGET (view);
+}
+
static void
gb_editor_document_finalize (GObject *object)
{
@@ -754,6 +770,7 @@ gb_editor_document_finalize (GObject *object)
g_clear_object (&priv->file);
g_clear_object (&priv->change_monitor);
g_clear_object (&priv->code_assistant);
+ g_clear_pointer (&priv->title, g_free);
G_OBJECT_CLASS(gb_editor_document_parent_class)->finalize (object);
@@ -770,9 +787,9 @@ gb_editor_document_get_property (GObject *object,
switch (prop_id)
{
- case PROP_CAN_SAVE:
+ case PROP_MODIFIED:
g_value_set_boolean (value,
- gb_editor_document_get_can_save (GB_DOCUMENT (self)));
+ gb_editor_document_get_modified (GB_DOCUMENT (self)));
break;
case PROP_CHANGE_MONITOR:
@@ -837,7 +854,7 @@ gb_editor_document_class_init (GbEditorDocumentClass *klass)
text_buffer_class->changed = gb_editor_document_changed;
text_buffer_class->modified_changed = gb_editor_document_modified_changed;
- g_object_class_override_property (object_class, PROP_CAN_SAVE, "can-save");
+ g_object_class_override_property (object_class, PROP_MODIFIED, "modified");
g_object_class_override_property (object_class, PROP_TITLE, "title");
gParamSpecs [PROP_CHANGE_MONITOR] =
@@ -919,6 +936,7 @@ gb_editor_document_init (GbEditorDocument *document)
static void
gb_editor_document_init_document (GbDocumentInterface *iface)
{
- iface->get_can_save = gb_editor_document_get_can_save;
+ iface->get_modified = gb_editor_document_get_modified;
iface->get_title = gb_editor_document_get_title;
+ iface->create_view = gb_editor_document_create_view;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]