[evince] shell: Mark the document title when modified



commit 22d4a034ed9142ef47ea535630827ecd8235f075
Author: Casey Jao <casey jao gmail com>
Date:   Fri Oct 2 10:55:39 2020 -0400

    shell: Mark the document title when modified
    
    Append a middle dot (•) to the document title to provide a cue the user
    when the document has been modified and need to be saved.

 shell/ev-window.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
---
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 4b47a014..96e63c12 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -313,6 +313,9 @@ static void ev_window_load_job_cb                   (EvJob            *job,
                                                         gpointer          data);
 static void     ev_window_reload_document               (EvWindow         *window,
                                                         EvLinkDest *dest);
+static void    ev_window_document_modified_cb          (EvDocument *document,
+                                                         GParamSpec *pspec,
+                                                         EvWindow   *ev_window);
 static void     ev_window_reload_job_cb                 (EvJob            *job,
                                                         EvWindow         *window);
 static void     ev_window_save_job_cb                   (EvJob            *save,
@@ -1775,6 +1778,8 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document)
                ev_window_run_presentation (ev_window);
        }
 
+       g_signal_connect (document, "notify::modified", G_CALLBACK (ev_window_document_modified_cb), 
ev_window);
+
        if (priv->setup_document_idle > 0)
                g_source_remove (priv->setup_document_idle);
 
@@ -5362,6 +5367,32 @@ ev_window_document_changed_cb (EvDocumentModel *model,
                                ev_document_model_get_document (model));
 }
 
+static void
+ev_window_document_modified_cb (EvDocument *document,
+                                GParamSpec *pspec,
+                                EvWindow   *ev_window)
+{
+       GtkHeaderBar *toolbar = GTK_HEADER_BAR (ev_window_get_toolbar (ev_window));
+       const gchar *title = gtk_header_bar_get_title (toolbar);
+       gchar *new_title;
+
+       if (!((EV_IS_DOCUMENT_FORMS (document) &&
+           ev_document_forms_document_is_modified (EV_DOCUMENT_FORMS (document))) ||
+           (EV_IS_DOCUMENT_ANNOTATIONS (document) &&
+           ev_document_annotations_document_is_modified (EV_DOCUMENT_ANNOTATIONS (document)))))
+               return;
+
+       if (gtk_widget_get_direction (GTK_WIDGET (ev_window)) == GTK_TEXT_DIR_RTL)
+               new_title = g_strconcat ("• ", title, NULL);
+       else
+               new_title = g_strconcat (title, " •", NULL);
+
+       if (new_title) {
+               gtk_header_bar_set_title (toolbar, new_title);
+               g_free (new_title);
+       }
+}
+
 static void
 ev_window_sizing_mode_changed_cb (EvDocumentModel *model,
                                  GParamSpec      *pspec,


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