[latexila] DocumentTab: remove add_message()



commit 4f13ea2d53fa6d8e2341d377c0fe8c2cd0413185
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Jun 24 05:14:50 2017 +0200

    DocumentTab: remove add_message()
    
    Now that tepl_tab_add_info_bar() exists, add_message() is no longer
    really useful.

 src/document.vala     |   27 ++++++++++++++++++---------
 src/document_tab.vala |   17 ++++-------------
 src/main_window.vala  |   10 ++++++++--
 3 files changed, 30 insertions(+), 24 deletions(-)
---
diff --git a/src/document.vala b/src/document.vala
index 3ebfb7f..486b09b 100644
--- a/src/document.vala
+++ b/src/document.vala
@@ -123,7 +123,10 @@ public class Document : Tepl.Buffer
             {
                 string primary_msg = _("Impossible to load the file '%s'.")
                     .printf (location.get_parse_name ());
-                tab.add_message (primary_msg, e.message, MessageType.ERROR);
+                Tepl.InfoBar infobar = new Tepl.InfoBar.simple (MessageType.ERROR,
+                    primary_msg, e.message);
+                tab.add_info_bar (infobar);
+                infobar.show ();
             }
         }
     }
@@ -204,10 +207,14 @@ public class Document : Tepl.Buffer
                     .printf (location.get_parse_name ());
                 string secondary_msg =
                     _("If you save it, all the external changes could be lost. Save it anyway?");
-                Tepl.InfoBar infobar = tab.add_message (primary_msg, secondary_msg,
-                    MessageType.WARNING);
+
+                Tepl.InfoBar infobar = new Tepl.InfoBar.simple (MessageType.WARNING,
+                    primary_msg, secondary_msg);
                 infobar.add_button (_("_Save Anyway"), ResponseType.YES);
                 infobar.add_button (_("_Don't Save"), ResponseType.CANCEL);
+                tab.add_info_bar (infobar);
+                infobar.show ();
+
                 infobar.response.connect ((response_id) =>
                 {
                     if (response_id == ResponseType.YES)
@@ -222,9 +229,11 @@ public class Document : Tepl.Buffer
                 if (tab != null)
                 {
                     string primary_msg = _("Impossible to save the file.");
-                    Tepl.InfoBar infobar = tab.add_message (primary_msg, e.message,
-                        MessageType.ERROR);
+                    Tepl.InfoBar infobar = new Tepl.InfoBar.simple (MessageType.ERROR,
+                        primary_msg, e.message);
                     infobar.add_close_button ();
+                    tab.add_info_bar (infobar);
+                    infobar.show ();
                 }
             }
         }
@@ -515,13 +524,13 @@ public class Document : Tepl.Buffer
         if (tab == null)
             return true;
 
-        Tepl.InfoBar infobar = tab.add_message (
+        Tepl.InfoBar infobar = new Tepl.InfoBar.simple (MessageType.WARNING,
             _("The file has a temporary location. The data can be lost after rebooting your computer."),
-            _("Do you want to save the file in a safer place?"),
-            MessageType.WARNING);
-
+            _("Do you want to save the file in a safer place?"));
         infobar.add_button (_("Save _As"), ResponseType.YES);
         infobar.add_button (_("Cancel"), ResponseType.NO);
+        tab.add_info_bar (infobar);
+        infobar.show ();
 
         infobar.response.connect ((response_id) =>
         {
diff --git a/src/document_tab.vala b/src/document_tab.vala
index 3bf481e..542e7ca 100644
--- a/src/document_tab.vala
+++ b/src/document_tab.vala
@@ -192,17 +192,6 @@ public class DocumentTab : Tepl.Tab
         });
     }
 
-    public Tepl.InfoBar add_message (string primary_msg, string secondary_msg,
-        MessageType msg_type)
-    {
-        Tepl.InfoBar infobar = new Tepl.InfoBar.simple (msg_type, primary_msg,
-            secondary_msg);
-        add_info_bar (infobar);
-        infobar.show ();
-
-        return infobar;
-    }
-
     private void update_label_text ()
     {
         label_text = Utils.str_middle_truncate (
@@ -278,10 +267,12 @@ public class DocumentTab : Tepl.Tab
             else
                 secondary_msg = _("Do you want to reload the file?");
 
-            Tepl.InfoBar infobar = add_message (primary_msg, secondary_msg,
-                MessageType.WARNING);
+            Tepl.InfoBar infobar = new Tepl.InfoBar.simple (MessageType.WARNING,
+                primary_msg, secondary_msg);
             infobar.add_button (_("_Reload"), ResponseType.OK);
             infobar.add_button (_("_Cancel"), ResponseType.CANCEL);
+            add_info_bar (infobar);
+            infobar.show ();
 
             infobar.response.connect ((response_id) =>
             {
diff --git a/src/main_window.vala b/src/main_window.vala
index cf73810..0261d4f 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -647,14 +647,19 @@ public class MainWindow : ApplicationWindow
                 /* the document is already opened in another window */
                 DocumentTab tab = create_tab_from_location (location, jump_to);
                 tab.document.readonly = true;
+
                 string primary_msg =
                     _("This file (%s) is already opened in another LaTeXila window.")
                     .printf (location.get_parse_name ());
                 string secondary_msg = _("LaTeXila opened this instance of the file in a non-editable way. 
Do you want to edit it anyway?");
-                InfoBar infobar = tab.add_message (primary_msg, secondary_msg,
-                    MessageType.WARNING);
+
+                InfoBar infobar = new Tepl.InfoBar.simple (MessageType.WARNING,
+                    primary_msg, secondary_msg);
                 infobar.add_button (_("Edit Anyway"), ResponseType.YES);
                 infobar.add_button (_("Don't Edit"), ResponseType.NO);
+                tab.add_info_bar (infobar);
+                infobar.show ();
+
                 infobar.response.connect ((response_id) =>
                 {
                     if (response_id == ResponseType.YES)
@@ -662,6 +667,7 @@ public class MainWindow : ApplicationWindow
                     infobar.destroy ();
                     tab.document_view.grab_focus ();
                 });
+
                 return tab;
             }
         }


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