[gnome-latex: 175/205] Set window title with the filename of current doc



commit a7dad08aab03e9f0cf7d0c7e4ce2f5c45d9694c3
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date:   Wed Jan 20 22:25:53 2010 +0100

    Set window title with the filename of current doc
    
    It takes the text label of the document tab.

 TODO            |  1 -
 src/callbacks.c | 22 ++++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/TODO b/TODO
index 2251e6f..3b56c55 100644
--- a/TODO
+++ b/TODO
@@ -14,7 +14,6 @@ TODO LaTeXila
 - Auto-completion of LaTeX commands
 
 - Some various improvements:
-       - Change the title of the window with the filename of the current document
        - Make a copy of a file before saving it for the first time (with a name like "file~")
        - Autosave files every X minutes
        - Symbols: most recently used
diff --git a/src/callbacks.c b/src/callbacks.c
index 608bb9d..3ae3635 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -45,6 +45,7 @@ static void save_as_dialog (void);
 static void file_save (void);
 static gboolean close_all (void);
 static void set_title (void);
+static void set_window_title (void);
 static void set_undo_redo_sensitivity (void);
 static void update_cursor_position_statusbar (void);
 static void find (gboolean backward);
@@ -146,6 +147,7 @@ cb_close (void)
                latexila.active_doc = NULL;
 
        set_undo_redo_sensitivity ();
+       set_window_title ();
 }
 
 void
@@ -168,6 +170,7 @@ cb_close_tab (GtkWidget *widget, GtkWidget *child)
 
                set_undo_redo_sensitivity ();
                update_cursor_position_statusbar ();
+               set_window_title ();
        }
 
        // the document to close is not the current document
@@ -1005,6 +1008,7 @@ cb_page_change (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num,
        latexila.active_doc = g_list_nth_data (latexila.all_docs, page_num);
        set_undo_redo_sensitivity ();
        update_cursor_position_statusbar ();
+       set_window_title ();
 }
 
 void
@@ -1290,6 +1294,7 @@ create_document_in_new_tab (const gchar *path, const gchar *text,
        
        set_undo_redo_sensitivity ();
        update_cursor_position_statusbar ();
+       set_window_title ();
 }
 
 
@@ -1520,6 +1525,23 @@ set_title (void)
        gtk_label_set_text (GTK_LABEL (latexila.active_doc->title), title);
 
        g_free (title);
+
+       set_window_title ();
+}
+
+static void
+set_window_title (void)
+{
+       if (latexila.active_doc == NULL)
+       {
+               gtk_window_set_title (latexila.main_window, "LaTeXila");
+               return;
+       }
+
+       const gchar *title = gtk_label_get_text (GTK_LABEL (latexila.active_doc->title));
+       gchar *window_title = g_strdup_printf ("%s - LaTeXila", title);
+       gtk_window_set_title (latexila.main_window, window_title);
+       g_free (window_title);
 }
 
 static void


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