[gnome-builder] editor: bind GtkSourceFile:location to tab title label.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: bind GtkSourceFile:location to tab title label.
- Date: Tue, 9 Sep 2014 01:53:39 +0000 (UTC)
commit a3f10a3b52357e2c6018073f3641c5e2fbb482b4
Author: Christian Hergert <christian hergert me>
Date: Mon Sep 8 18:53:34 2014 -0700
editor: bind GtkSourceFile:location to tab title label.
src/editor/gb-editor-tab.c | 36 ++++++++++++++++++++++++++++++------
1 files changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index 985143a..7bff92f 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -101,12 +101,6 @@ struct _GbEditorTabPrivate
GtkSourceFile *file;
/*
- * If we are an unsaved document,
- * track our unsaved file number.
- */
- guint unsaved_number;
-
- /*
* Animation for save progress.
*/
GbAnimation *save_animation;
@@ -1327,6 +1321,32 @@ on_source_view_push_snippet (GbSourceView *source_view,
}
}
+static gboolean
+transform_file_to_title (GBinding *binding,
+ const GValue *src_value,
+ GValue *dst_value,
+ gpointer user_data)
+{
+ GbEditorTab *tab = user_data;
+ gchar *title;
+ GFile *file;
+
+ g_return_val_if_fail (GB_IS_EDITOR_TAB (tab), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS (src_value, G_TYPE_FILE), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS (dst_value, G_TYPE_STRING), FALSE);
+
+ file = g_value_get_object (src_value);
+
+ if (file)
+ title = g_file_get_basename (file);
+ else
+ title = g_strdup (_("Unsaved File"));
+
+ g_value_take_string (dst_value, title);
+
+ return TRUE;
+}
+
static void
gb_editor_tab_constructed (GObject *object)
{
@@ -1417,6 +1437,10 @@ gb_editor_tab_constructed (GObject *object)
priv->source_view, "show-shadow",
G_BINDING_SYNC_CREATE);
+ g_object_bind_property_full (priv->file, "location", tab, "title",
+ G_BINDING_SYNC_CREATE, transform_file_to_title,
+ NULL, tab, NULL);
+
#if 1
{
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]