[tepl] File loading: add jump_to param to tepl_application_window_open_file()



commit 4735f7d863ac90f240cc94ebcc68986b30ea8874
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Oct 11 17:58:39 2017 +0200

    File loading: add jump_to param to tepl_application_window_open_file()

 tepl/tepl-application-window.c |    8 +++++---
 tepl/tepl-application-window.h |    3 ++-
 tepl/tepl-application.c        |    9 +++++----
 3 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/tepl/tepl-application-window.c b/tepl/tepl-application-window.c
index 8fc3ed5..5da8120 100644
--- a/tepl/tepl-application-window.c
+++ b/tepl/tepl-application-window.c
@@ -1217,10 +1217,11 @@ tepl_application_window_set_handle_title (TeplApplicationWindow *tepl_window,
  * tepl_application_window_open_file:
  * @tepl_window: a #TeplApplicationWindow.
  * @location: a #GFile.
+ * @jump_to: whether to set the tab where the file is loaded as the active tab.
  *
  * Opens a file in @tepl_window. If the active tab is untouched (see
  * tepl_buffer_is_untouched()), then the file is loaded in that tab. Otherwise a
- * new tab is created and becomes the new active tab.
+ * new tab is created.
  *
  * This function is asynchronous, the file loading is done with the
  * tepl_tab_load_file() function. There is no way to know when the file loading
@@ -1230,7 +1231,8 @@ tepl_application_window_set_handle_title (TeplApplicationWindow *tepl_window,
  */
 void
 tepl_application_window_open_file (TeplApplicationWindow *tepl_window,
-                                  GFile                 *location)
+                                  GFile                 *location,
+                                  gboolean               jump_to)
 {
        TeplTab *tab;
        TeplBuffer *buffer;
@@ -1250,7 +1252,7 @@ tepl_application_window_open_file (TeplApplicationWindow *tepl_window,
                tab = tepl_abstract_factory_create_tab (factory);
                gtk_widget_show (GTK_WIDGET (tab));
 
-               tepl_tab_group_append_tab (TEPL_TAB_GROUP (tepl_window), tab, TRUE);
+               tepl_tab_group_append_tab (TEPL_TAB_GROUP (tepl_window), tab, jump_to);
        }
 
        tepl_tab_load_file (tab, location);
diff --git a/tepl/tepl-application-window.h b/tepl/tepl-application-window.h
index 147f5d1..76e4280 100644
--- a/tepl/tepl-application-window.h
+++ b/tepl/tepl-application-window.h
@@ -70,7 +70,8 @@ void                  tepl_application_window_set_handle_title                
(TeplApplicationWindow *tepl_wi
                                                                                 gboolean               
handle_title);
 
 void                   tepl_application_window_open_file                       (TeplApplicationWindow 
*tepl_window,
-                                                                                GFile                 
*location);
+                                                                                GFile                 
*location,
+                                                                                gboolean               
jump_to);
 
 G_END_DECLS
 
diff --git a/tepl/tepl-application.c b/tepl/tepl-application.c
index 332f780..00f47be 100644
--- a/tepl/tepl-application.c
+++ b/tepl/tepl-application.c
@@ -426,7 +426,7 @@ open_cb (GApplication     *g_app,
 {
        GtkApplicationWindow *main_window;
        TeplApplicationWindow *tepl_window;
-       gint i;
+       gint file_num;
 
        if (n_files < 1)
        {
@@ -457,11 +457,12 @@ open_cb (GApplication     *g_app,
         * 4. Load the files one by one. Needs an async/finish API to load one
         *    file.
         */
-       for (i = 0; i < n_files; i++)
+       for (file_num = 0; file_num < n_files; file_num++)
        {
-               GFile *cur_file = files[i];
+               GFile *cur_file = files[file_num];
+               gboolean jump_to = file_num == 0;
 
-               tepl_application_window_open_file (tepl_window, cur_file);
+               tepl_application_window_open_file (tepl_window, cur_file, jump_to);
        }
 }
 


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