[gedit] Made document 'shortname' writable
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gedit] Made document 'shortname' writable
- Date: Sun, 14 Feb 2010 22:08:19 +0000 (UTC)
commit faefe07b7352026c1c450d9858d3f0bd7ac8714b
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Tue Feb 9 23:53:05 2010 +0100
Made document 'shortname' writable
gedit/gedit-document.c | 31 +++++++++++++++++++++++++++----
gedit/gedit-document.h | 4 ++++
gedit/gedit-tab.c | 15 +++++++++++++++
3 files changed, 46 insertions(+), 4 deletions(-)
---
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index 415944b..43cb3f4 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -103,6 +103,7 @@ struct _GeditDocumentPrivate
{
gchar *uri;
gint untitled_number;
+ gchar *short_name;
GFileInfo *metadata_info;
@@ -371,6 +372,10 @@ gedit_document_set_property (GObject *object,
gedit_document_set_newline_type (doc,
g_value_get_enum (value));
break;
+ case PROP_SHORTNAME:
+ gedit_document_set_short_name_for_display (doc,
+ g_value_get_string (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -423,7 +428,7 @@ gedit_document_class_init (GeditDocumentClass *klass)
object_class->dispose = gedit_document_dispose;
object_class->finalize = gedit_document_finalize;
object_class->get_property = gedit_document_get_property;
- object_class->set_property = gedit_document_set_property;
+ object_class->set_property = gedit_document_set_property;
buf_class->mark_set = gedit_document_mark_set;
buf_class->changed = gedit_document_changed;
@@ -444,7 +449,7 @@ gedit_document_class_init (GeditDocumentClass *klass)
"Short Name",
"The document's short name",
NULL,
- G_PARAM_READABLE |
+ G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_CONTENT_TYPE,
@@ -980,7 +985,11 @@ set_uri (GeditDocument *doc,
#endif
g_object_notify (G_OBJECT (doc), "uri");
- g_object_notify (G_OBJECT (doc), "shortname");
+
+ if (doc->priv->short_name == NULL)
+ {
+ g_object_notify (G_OBJECT (doc), "shortname");
+ }
}
GFile *
@@ -1026,13 +1035,27 @@ gedit_document_get_short_name_for_display (GeditDocument *doc)
{
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), g_strdup (""));
- if (doc->priv->uri == NULL)
+ if (doc->priv->short_name != NULL)
+ return g_strdup (doc->priv->short_name);
+ else if (doc->priv->uri == NULL)
return g_strdup_printf (_("Unsaved Document %d"),
doc->priv->untitled_number);
else
return gedit_utils_basename_for_display (doc->priv->uri);
}
+void
+gedit_document_set_short_name_for_display (GeditDocument *doc,
+ const gchar *short_name)
+{
+ g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
+
+ g_free (doc->priv->short_name);
+ doc->priv->short_name = g_strdup (short_name);
+
+ g_object_notify (G_OBJECT (doc), "shortname");
+}
+
gchar *
gedit_document_get_content_type (GeditDocument *doc)
{
diff --git a/gedit/gedit-document.h b/gedit/gedit-document.h
index b316393..3cb6893 100644
--- a/gedit/gedit-document.h
+++ b/gedit/gedit-document.h
@@ -187,6 +187,10 @@ gchar *gedit_document_get_uri_for_display
gchar *gedit_document_get_short_name_for_display
(GeditDocument *doc);
+void gedit_document_set_short_name_for_display
+ (GeditDocument *doc,
+ const gchar *name);
+
gchar *gedit_document_get_content_type
(GeditDocument *doc);
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index 87d6c8c..af396fe 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -421,6 +421,17 @@ document_uri_notify_handler (GeditDocument *document,
g_object_notify (G_OBJECT (tab), "name");
}
+static void
+document_shortname_notify_handler (GeditDocument *document,
+ GParamSpec *pspec,
+ GeditTab *tab)
+{
+ gedit_debug (DEBUG_TAB);
+
+ /* Notify the change in the shortname */
+ g_object_notify (G_OBJECT (tab), "name");
+}
+
static void
document_modified_changed (GtkTextBuffer *document,
GeditTab *tab)
@@ -1575,6 +1586,10 @@ gedit_tab_init (GeditTab *tab)
G_CALLBACK (document_uri_notify_handler),
tab);
g_signal_connect (doc,
+ "notify::shortname",
+ G_CALLBACK (document_shortname_notify_handler),
+ tab);
+ g_signal_connect (doc,
"modified_changed",
G_CALLBACK (document_modified_changed),
tab);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]