gnome-terminal r2785 - trunk/src



Author: chpe
Date: Thu May 29 19:54:05 2008
New Revision: 2785
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=2785&view=rev

Log:
Split terminal_app_new_terminal into the case of new terminal and the case of just moving an existing terminal between windows. Simplify and refacor terminal_app_new_window/tab.


Modified:
   trunk/src/terminal-app.c
   trunk/src/terminal-app.h
   trunk/src/terminal-screen.c
   trunk/src/terminal-window.c
   trunk/src/terminal.c

Modified: trunk/src/terminal-app.c
==============================================================================
--- trunk/src/terminal-app.c	(original)
+++ trunk/src/terminal-app.c	Thu May 29 19:54:05 2008
@@ -266,91 +266,6 @@
   g_free (gconf_dir);
 }
 
-static GdkScreen*
-find_screen_by_display_name (const char *display_name,
-                             int         screen_number)
-{
-  GdkScreen *screen;
-  
-  /* --screen=screen_number overrides --display */
-  
-  screen = NULL;
-  
-  if (display_name == NULL)
-    {
-      if (screen_number >= 0)
-        screen = gdk_display_get_screen (gdk_display_get_default (), screen_number);
-
-      if (screen == NULL)
-        screen = gdk_screen_get_default ();
-
-      g_object_ref (G_OBJECT (screen));
-    }
-  else
-    {
-      GSList *displays;
-      GSList *tmp;
-      const char *period;
-      GdkDisplay *display;
-        
-      period = strrchr (display_name, '.');
-      if (period)
-        {
-          gulong n;
-          char *end;
-          
-          errno = 0;
-          end = NULL;
-          n = g_ascii_strtoull (period + 1, &end, 0);
-          if (errno == 0 && (period + 1) != end)
-            screen_number = n;
-        }
-      
-      displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
-
-      display = NULL;
-      tmp = displays;
-      while (tmp != NULL)
-        {
-          const char *this_name;
-
-          display = tmp->data;
-          this_name = gdk_display_get_name (display);
-          
-          /* compare without the screen number part */
-          if (strncmp (this_name, display_name, period - display_name) == 0)
-            break;
-
-          tmp = tmp->next;
-        }
-      
-      g_slist_free (displays);
-
-      if (display == NULL)
-        display = gdk_display_open (display_name); /* FIXME we never close displays */
-      
-      if (display != NULL)
-        {
-          if (screen_number >= 0)
-            screen = gdk_display_get_screen (display, screen_number);
-          
-          if (screen == NULL)
-            screen = gdk_display_get_default_screen (display);
-
-          if (screen)
-            g_object_ref (G_OBJECT (screen));
-        }
-    }
-
-  if (screen == NULL)
-    {
-      screen = gdk_screen_get_default ();
-      g_object_ref (G_OBJECT (screen));
-    }
-  
-  return screen;
-}
-
 static void
 terminal_app_profile_cell_data_func (GtkTreeViewColumn *tree_column,
                                      GtkCellRenderer *cell,
@@ -1688,12 +1603,9 @@
 
 TerminalWindow *
 terminal_app_new_window (TerminalApp *app,
-                         const char *role,
-                         const char *startup_id,
-                         const char *display_name,
-                         int screen_number)
+                         GdkScreen *screen,
+                         const char *geometry)
 {
-  GdkScreen *gdk_screen;
   TerminalWindow *window;
   
   window = terminal_window_new ();
@@ -1702,133 +1614,62 @@
   g_signal_connect (window, "destroy",
                     G_CALLBACK (terminal_window_destroyed), app);
 
-  gdk_screen = find_screen_by_display_name (display_name, screen_number);
-  if (gdk_screen != NULL)
+  if (screen)
+    gtk_window_set_screen (GTK_WINDOW (window), screen);
+
+  if (geometry)
     {
-      gtk_window_set_screen (GTK_WINDOW (window), gdk_screen);
-      g_object_unref (G_OBJECT (gdk_screen));
+      if (!gtk_window_parse_geometry (GTK_WINDOW (window), geometry))
+        g_printerr (_("Invalid geometry string \"%s\"\n"), geometry);
     }
 
-  if (startup_id != NULL)
-    terminal_window_set_startup_id (window, startup_id);
-  
-  if (role == NULL)
-    terminal_util_set_unique_role (GTK_WINDOW (window), "gnome-terminal");
-  else
-    gtk_window_set_role (GTK_WINDOW (window), role);
-
   return window;
 }
 
-void
+TerminalScreen *
 terminal_app_new_terminal (TerminalApp     *app,
-                           TerminalProfile *profile,
                            TerminalWindow  *window,
-                           TerminalScreen  *screen,
-                           gboolean         force_menubar_state,
-                           gboolean         forced_menubar_state,
-                           gboolean         start_fullscreen,
+                           TerminalProfile *profile,
                            char           **override_command,
-                           const char      *geometry,
                            const char      *title,
                            const char      *working_dir,
-                           const char      *role,
-                           double           zoom,
-                           const char      *startup_id,
-                           const char      *display_name,
-                           int              screen_number)
+                           double           zoom)
 {
-  gboolean window_created;
-  gboolean screen_created;
-  
-  g_return_if_fail (profile);
+  TerminalScreen *screen;
 
-  window_created = FALSE;
-  if (window == NULL)
-    {
-      window = terminal_app_new_window (app, role, startup_id, display_name, screen_number);
-      window_created = TRUE;
-    }
-
-  if (force_menubar_state)
-    {
-      terminal_window_set_menubar_visible (window, forced_menubar_state);
-    }
+  g_return_val_if_fail (TERMINAL_IS_APP (app), NULL);
+  g_return_val_if_fail (TERMINAL_IS_WINDOW (window), NULL);
+  g_return_val_if_fail (TERMINAL_IS_PROFILE (profile), NULL);
 
-  screen_created = FALSE;
-  if (screen == NULL)
-    {  
-      screen_created = TRUE;
-      screen = terminal_screen_new ();
-      
-      terminal_screen_set_profile (screen, profile);
-    
-      if (title)
-        {
-          terminal_screen_set_title (screen, title);
-          terminal_screen_set_dynamic_title (screen, title, FALSE);
-          terminal_screen_set_dynamic_icon_title (screen, title, FALSE);
-        }
+  screen = terminal_screen_new ();
 
-      if (working_dir)
-        terminal_screen_set_working_dir (screen, working_dir);
-      
-      if (override_command)    
-        terminal_screen_set_override_command (screen, override_command);
-    
-      terminal_screen_set_font_scale (screen, zoom);
-      terminal_screen_set_font (screen);
-    
-      terminal_window_add_screen (window, screen, -1);
+  terminal_screen_set_profile (screen, profile);
 
-      terminal_window_switch_screen (window, screen);
-      gtk_widget_grab_focus (GTK_WIDGET (screen));
-    }
-  else
+  if (title)
     {
-      GtkWidget *source_toplevel;
+      terminal_screen_set_title (screen, title);
+      terminal_screen_set_dynamic_title (screen, title, FALSE);
+      terminal_screen_set_dynamic_icon_title (screen, title, FALSE);
+    }
 
-      source_toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen));
-      if (GTK_WIDGET_TOPLEVEL (source_toplevel) &&
-          TERMINAL_IS_WINDOW (source_toplevel))
-        {
-          TerminalWindow *source_window = TERMINAL_WINDOW (source_toplevel);
+  if (working_dir)
+    terminal_screen_set_working_dir (screen, working_dir);
 
-          g_object_ref_sink (screen);
-          terminal_window_remove_screen (source_window, screen);
-          terminal_window_add_screen (window, screen, -1);
-          g_object_unref (screen);
+  if (override_command)
+    terminal_screen_set_override_command (screen, override_command);
 
-          terminal_window_switch_screen (window, screen);
-          gtk_widget_grab_focus (GTK_WIDGET (screen));
-        }
-    }
+  terminal_screen_set_font_scale (screen, zoom);
+  terminal_screen_set_font (screen);
 
-  if (geometry)
-    {
-      if (!gtk_window_parse_geometry (GTK_WINDOW (window),
-                                      geometry))
-        g_printerr (_("Invalid geometry string \"%s\"\n"),
-                    geometry);
-    }
-
-  if (start_fullscreen)
-    {
-      gtk_window_fullscreen (GTK_WINDOW (window));
-    }
+  terminal_window_add_screen (window, screen, -1);
+  terminal_window_switch_screen (window, screen);
+  gtk_widget_grab_focus (GTK_WIDGET (screen));
 
-  /* don't present on new tab, or we can accidentally make the
-   * terminal jump workspaces.
-   * http://bugzilla.gnome.org/show_bug.cgi?id=78253
-   */
-  if (window_created)
-    gtk_window_present (GTK_WINDOW (window));
+  terminal_screen_launch_child (screen);
 
-  if (screen_created)
-    terminal_screen_launch_child (screen);
+  return screen;
 }
 
-
 void
 terminal_app_edit_profile (TerminalApp     *app,
                            TerminalProfile *profile,
@@ -1919,27 +1760,19 @@
 }
 
 TerminalProfile*
-terminal_app_get_profile_for_new_term (TerminalApp *app,
-                                       TerminalProfile *current)
+terminal_app_get_profile_for_new_term (TerminalApp *app)
 {
-  GList *list;
-  TerminalProfile *profile;
+  GHashTableIter iter;
+  TerminalProfile *profile = NULL;
 
   g_return_val_if_fail (TERMINAL_IS_APP (app), NULL);
 
-  if (current)
-    return current;
-  
   if (app->default_profile)
     return app->default_profile;	
 
-  list = terminal_app_get_profile_list (app);
-  if (list)
-    profile = list->data;
-  else
-    profile = NULL;
+  g_hash_table_iter_init (&iter, app->profiles);
+  if (g_hash_table_iter_next (&iter, NULL, (gpointer*) &profile))
+    return profile;
 
-  g_list_free (list);
-
-  return profile;
+  return NULL;
 }

Modified: trunk/src/terminal-app.h
==============================================================================
--- trunk/src/terminal-app.h	(original)
+++ trunk/src/terminal-app.h	Thu May 29 19:54:05 2008
@@ -67,27 +67,16 @@
                                GtkWindow       *transient_parent);
 
 TerminalWindow * terminal_app_new_window   (TerminalApp *app,
-                                            const char *role,
-                                            const char *startup_id,
-                                            const char *display_name,
-                                            int screen_number);
-
-void terminal_app_new_terminal (TerminalApp     *app,
-                                TerminalProfile *profile,
-                                TerminalWindow  *window,
-                                TerminalScreen  *screen,
-                                gboolean         force_menubar_state,
-                                gboolean         forced_menubar_state,
-                                gboolean         start_fullscreen,
-                                char           **override_command,
-                                const char      *geometry,
-                                const char      *title,
-                                const char      *working_dir,
-                                const char      *role,
-                                double           zoom,
-                                const char      *startup_id,
-                                const char      *display_name,
-                                int              screen_number);
+                                            GdkScreen *screen,
+                                            const char *geometry);
+
+TerminalScreen *terminal_app_new_terminal (TerminalApp     *app,
+                                           TerminalWindow  *window,
+                                           TerminalProfile *profile,
+                                           char           **override_command,
+                                           const char      *title,
+                                           const char      *working_dir,
+                                           double           zoom);
 
 TerminalWindow *terminal_app_get_current_window (TerminalApp *app);
 
@@ -116,8 +105,7 @@
 TerminalProfile* terminal_app_get_default_profile (TerminalApp *app);
 
 /* never returns NULL if any profiles exist, one is always supposed to */
-TerminalProfile* terminal_app_get_profile_for_new_term (TerminalApp *app,
-                                                        TerminalProfile *current);
+TerminalProfile* terminal_app_get_profile_for_new_term (TerminalApp *app);
 
 G_END_DECLS
 

Modified: trunk/src/terminal-screen.c
==============================================================================
--- trunk/src/terminal-screen.c	(original)
+++ trunk/src/terminal-screen.c	Thu May 29 19:54:05 2008
@@ -990,13 +990,9 @@
 {
   TerminalProfile *new_profile;
 
-  /* Revert to the new term profile if any */
-  new_profile = terminal_app_get_profile_for_new_term (terminal_app_get (), NULL);
-
-  if (new_profile)
-    terminal_screen_set_profile (screen, new_profile);
-  else
-    g_assert_not_reached (); /* FIXME ? */
+  new_profile = terminal_app_get_profile_for_new_term (terminal_app_get ());
+  g_assert (new_profile);
+  terminal_screen_set_profile (screen, new_profile);
 }
 
 void
@@ -1982,6 +1978,7 @@
 
     case TARGET_TAB:
       {
+        GtkWidget *container;
         TerminalScreen *moving_screen;
         TerminalWindow *source_window;
         TerminalWindow *dest_window;
@@ -1989,9 +1986,15 @@
         GtkWidget *dest_notebook;
         gint page_num;
 
-        moving_screen = *(TerminalScreen**) selection_data->data;
+        /* FIXMEchpe same-app only!? */
+        container = *(GtkWidget**) selection_data->data;
+        if (!GTK_IS_WIDGET (container))
+          return;
 
+        moving_screen = terminal_screen_container_get_screen (container);
         g_return_if_fail (TERMINAL_IS_SCREEN (moving_screen));
+        if (!TERMINAL_IS_SCREEN (moving_screen))
+          return;
 
         source_window = moving_screen->priv->window;
         source_notebook = terminal_window_get_notebook (source_window);
@@ -2000,9 +2003,9 @@
         page_num = gtk_notebook_page_num (GTK_NOTEBOOK (dest_notebook), 
                                           GTK_WIDGET (screen));
 
-        g_object_ref (G_OBJECT (moving_screen));
+        g_object_ref_sink (moving_screen);
         terminal_window_add_screen (dest_window, moving_screen, page_num);
-        g_object_unref (G_OBJECT (moving_screen));
+        g_object_unref (moving_screen);
 
         gtk_drag_finish (context, TRUE, TRUE, time);
       }

Modified: trunk/src/terminal-window.c
==============================================================================
--- trunk/src/terminal-window.c	(original)
+++ trunk/src/terminal-window.c	Thu May 29 19:54:05 2008
@@ -111,14 +111,9 @@
                                               guint            page_num,
                                               TerminalWindow  *window);
 
-static void new_window                    (TerminalWindow  *window,
-                                           TerminalScreen  *screen,
-                                           TerminalProfile *profile);
-
 /* Menu action callbacks */
 static void terminal_menu_activate_callback (GtkAction *action,
                                            TerminalWindow *window);
-
 static void file_new_window_callback          (GtkAction *action,
                                                TerminalWindow *window);
 static void file_new_tab_callback             (GtkAction *action,
@@ -167,7 +162,6 @@
                                                TerminalWindow *window);
 static void tabs_detach_tab_callback          (GtkAction *action,
                                                TerminalWindow *window);
-
 static void help_contents_callback        (GtkAction *action,
                                            TerminalWindow *window);
 static void help_about_callback           (GtkAction *action,
@@ -848,25 +842,23 @@
 {
   TerminalScreen *screen;
   TerminalWindow *source_window;
-  TerminalWindow *dest_window;
-  TerminalWindowPrivate *dest_priv;
-  double zoom;
+  TerminalWindow *new_window;
+  TerminalWindowPrivate *new_priv;
 
   screen = terminal_screen_container_get_screen (container);
   source_window = TERMINAL_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (source_notebook)));
-
   g_return_val_if_fail (TERMINAL_IS_WINDOW (source_window), NULL);
 
-  zoom = terminal_screen_get_font_scale (screen);
-
-  dest_window = terminal_app_new_window (terminal_app_get (), NULL, NULL, NULL, -1);
-  dest_priv = dest_window->priv;
-  dest_priv->present_on_insert = TRUE;
+  new_window = terminal_app_new_window (terminal_app_get (),
+                                        gtk_widget_get_screen (GTK_WIDGET (source_window)),
+                                        NULL /* FIXME? */);
+  new_priv = new_window->priv;
+  new_priv->present_on_insert = TRUE;
 
   update_tab_visibility (source_window, -1);
-  update_tab_visibility (dest_window, +1);
+  update_tab_visibility (new_window, +1);
 
-  return GTK_NOTEBOOK (dest_priv->notebook);
+  return GTK_NOTEBOOK (new_priv->notebook);
 }
 
 static void
@@ -1101,6 +1093,7 @@
 screen_close_cb (TerminalScreen *screen,
                  TerminalWindow *window)
 {
+  g_print ("window %p screen-close %p\n", window, screen);
   terminal_window_remove_screen (window, screen);
 }
 
@@ -1464,6 +1457,8 @@
   window_group = gtk_window_group_new ();
   gtk_window_group_add_window (window_group, GTK_WINDOW (window));
   g_object_unref (window_group);
+
+  terminal_util_set_unique_role (GTK_WINDOW (window), "gnome-terminal");
 }
 
 static void
@@ -2155,7 +2150,7 @@
 
   if (priv->present_on_insert)
     {
-      gtk_window_present (GTK_WINDOW (window));
+      gtk_window_present_with_time (GTK_WINDOW (window), gtk_get_current_event_time ());
       priv->present_on_insert = FALSE;
     }
 
@@ -2312,55 +2307,38 @@
 file_new_window_callback (GtkAction *action,
                           TerminalWindow *window)
 {
+  TerminalWindowPrivate *priv = window->priv;
+  TerminalApp *app;
+  TerminalWindow *new_window;
   TerminalProfile *profile;
+  char *geometry;
+  int width, height;
+
+  app = terminal_app_get ();
 
   profile = g_object_get_data (G_OBJECT (action), PROFILE_DATA_KEY);
   if (!profile)
-    profile = terminal_app_get_default_profile (terminal_app_get ());
+    profile = terminal_app_get_default_profile (app);
   if (!profile)
     return;
 
   if (_terminal_profile_get_forgotten (profile))
     return;
 
-  new_window (window, NULL, profile);
-}
-
-static void
-new_window (TerminalWindow *window,
-            TerminalScreen *screen,
-            TerminalProfile *profile)
-{
-  TerminalWindowPrivate *priv = window->priv;
-  char *display_name, *geometry;
-  const char *dir;
+  /* FIXMEchpe: this seems wrong if tabs are shown in the window */
+  terminal_screen_get_size (priv->active_screen, &width, &height);
+  geometry = g_strdup_printf ("%dx%d", width, height);
 
-  display_name = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (window)));
-
-  dir = terminal_screen_get_working_dir (priv->active_screen);
-
-  if (screen)
-    {
-      int width, height;
-
-      terminal_screen_get_size (screen, &width, &height);
-      geometry = g_strdup_printf("%dx%d", width, height);
-    }
-  else
-    {
-      geometry = NULL;
-    }
+  new_window = terminal_app_new_window (app, gtk_widget_get_screen (GTK_WIDGET (window)),
+                                        geometry);
+  g_free (geometry);
 
-  terminal_app_new_terminal (terminal_app_get (),
-                             profile,
-                             NULL,
-                             screen,
-                             FALSE, FALSE, FALSE,
-                             NULL, geometry, NULL, dir, NULL, 1.0,
-                             NULL, display_name, -1);
+  terminal_app_new_terminal (app, new_window, profile,
+                             NULL, NULL,
+                             terminal_screen_get_working_dir (priv->active_screen),
+                             1.0);
 
-  g_free (geometry);
-  g_free (display_name);
+  gtk_window_present_with_time (GTK_WINDOW (new_window), gtk_get_current_event_time ());
 }
 
 static void
@@ -2369,7 +2347,6 @@
 {
   TerminalWindowPrivate *priv = window->priv;
   TerminalProfile *profile;
-  const char *dir;
 
   profile = g_object_get_data (G_OBJECT (action), PROFILE_DATA_KEY);
   if (!profile)
@@ -2380,15 +2357,10 @@
   if (_terminal_profile_get_forgotten (profile))
     return;
       
-  dir = terminal_screen_get_working_dir (priv->active_screen);
-
-  terminal_app_new_terminal (terminal_app_get (),
-                             profile,
-                             window,
-                             NULL,
-                             FALSE, FALSE, FALSE,
-                             NULL, NULL, NULL, dir, NULL, 1.0,
-                             NULL, NULL, -1);
+  terminal_app_new_terminal (terminal_app_get (), window, profile,
+                             NULL, NULL,
+                             terminal_screen_get_working_dir (priv->active_screen),
+                             1.0);
 }
 
 static void
@@ -2813,18 +2785,30 @@
                           TerminalWindow *window)
 {
   TerminalWindowPrivate *priv = window->priv;
-  GtkNotebook *notebook = GTK_NOTEBOOK (priv->notebook);
-  TerminalProfile *profile;
-  gint page_num;
-  GtkWidget *page;
+  TerminalApp *app;
+  TerminalWindow *new_window;
   TerminalScreen *screen;
+  char *geometry;
+  int width, height;
 
-  page_num = gtk_notebook_get_current_page (notebook);
-  page = gtk_notebook_get_nth_page (notebook, page_num);
+  app = terminal_app_get ();
 
-  screen = terminal_screen_container_get_screen (page);
-  profile = terminal_screen_get_profile (screen);
-  new_window (window, screen, profile);
+  screen = priv->active_screen;
+
+  /* FIXMEchpe: this seems wrong if tabs are shown in the window */
+  terminal_screen_get_size (screen, &width, &height);
+  geometry = g_strdup_printf ("%dx%d", width, height);
+
+  new_window = terminal_app_new_window (app, gtk_widget_get_screen (GTK_WIDGET (window)),
+                                        geometry);
+  g_free (geometry);
+
+  g_object_ref_sink (screen);
+  terminal_window_remove_screen (window, screen);
+  terminal_window_add_screen (new_window, screen, -1);
+  g_object_unref (screen);
+
+  gtk_window_present_with_time (GTK_WINDOW (new_window), gtk_get_current_event_time ());
 }
 
 static void

Modified: trunk/src/terminal.c
==============================================================================
--- trunk/src/terminal.c	(original)
+++ trunk/src/terminal.c	Thu May 29 19:54:05 2008
@@ -863,6 +863,65 @@
     }
 }
 
+static GdkScreen*
+find_screen_by_display_name (const char *display_name,
+                             int         screen_number)
+{
+  GdkDisplay *display = NULL;
+  GdkScreen *screen;
+  
+  /* --screen=screen_number overrides --display */
+  
+  screen = NULL;
+  
+  if (display_name == NULL)
+    display = gdk_display_get_default ();
+  else
+    {
+      GSList *displays, *l;
+      const char *period;
+        
+      period = strrchr (display_name, '.');
+      if (period)
+        {
+          gulong n;
+          char *end;
+          
+          errno = 0;
+          end = NULL;
+          n = g_ascii_strtoull (period + 1, &end, 0);
+          if (errno == 0 && (period + 1) != end)
+            screen_number = n;
+        }
+      
+      displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
+      for (l = displays; l != NULL; l = l->next)
+        {
+          GdkDisplay *disp = l->data;
+
+          /* compare without the screen number part */
+          if (strncmp (gdk_display_get_name (disp), display_name, period - display_name) == 0)
+            {
+              display = disp;
+              break;
+            }
+        }
+      g_slist_free (displays);
+
+      if (display == NULL)
+        display = gdk_display_open (display_name); /* FIXME we never close displays */
+    }
+
+  if (display == NULL)
+    return NULL;
+  if (screen_number >= 0)
+    screen = gdk_display_get_screen (display, screen_number);
+  if (screen == NULL)
+    screen = gdk_display_get_default_screen (display);
+
+  return screen;
+}
+
 static void
 option_parsing_results_apply_directory_defaults (OptionParsingResults *results)
 {
@@ -894,20 +953,42 @@
                            OptionParsingResults *results)
 {
   GList *lw;
+  GdkScreen *screen;
+
+  screen = find_screen_by_display_name (results->display_name,
+                                        results->screen_number);
 
   for (lw = results->initial_windows;  lw != NULL; lw = lw->next)
     {
       InitialWindow *iw = lw->data;
-      TerminalWindow *current_window = NULL;
-      TerminalScreen *active_screen = NULL;
+      TerminalWindow *window;
       GList *lt;
 
       g_assert (iw->tabs);
 
+      /* Create & setup new window */
+      window = terminal_app_new_window (app, screen, iw->geometry);
+
+      if (results->startup_id)
+        terminal_window_set_startup_id (window, results->startup_id);
+
+      if (iw->role)
+        gtk_window_set_role (GTK_WINDOW (window), iw->role);
+      else
+        terminal_util_set_unique_role (GTK_WINDOW (window), "gnome-terminal");
+
+      if (iw->force_menubar_state)
+        terminal_window_set_menubar_visible (window, iw->menubar_state);
+
+      if (iw->start_fullscreen)
+        gtk_window_fullscreen (GTK_WINDOW (window));
+
+      /* Now add the tabs */
       for (lt = iw->tabs; lt != NULL; lt = lt->next)
         {
           InitialTab *it = lt->data;
           TerminalProfile *profile = NULL;
+          TerminalScreen *screen;
 
           if (it->profile)
             {
@@ -915,74 +996,25 @@
                 profile = terminal_app_get_profile_by_name (app, it->profile);
               else                
                 profile = terminal_app_get_profile_by_visible_name (app, it->profile);
+
+              if (profile == NULL)
+                g_printerr (_("No such profile \"%s\", using default profile\n"), it->profile);
             }
-          else if (it->profile == NULL)
-            {
-              profile = terminal_app_get_profile_for_new_term (app, NULL);
-            }
-          
           if (profile == NULL)
-            {
-              if (it->profile)
-                g_printerr (_("No such profile \"%s\", using default profile\n"),
-                            it->profile);
-              profile = terminal_app_get_profile_for_new_term (app, NULL);
-            }
-          
+            profile = terminal_app_get_profile_for_new_term (app);
           g_assert (profile);
 
-          if (lt == iw->tabs)
-            {
-              terminal_app_new_terminal (terminal_app_get (),
-                                         profile,
-                                         NULL,
-                                         NULL,
-                                         iw->force_menubar_state,
-                                         iw->menubar_state,
-                                         iw->start_fullscreen,
-                                         it->exec_argv,
-                                         iw->geometry,
-                                         it->title,
-                                         it->working_dir,
-                                         iw->role,
-                                         it->zoom_set ?
-                                         it->zoom : 1.0,
-                                         results->startup_id,
-                                         results->display_name,
-                                         results->screen_number);
-
-              current_window = terminal_app_get_current_window (terminal_app_get ());
-            }
-          else
-            {
-              terminal_app_new_terminal (terminal_app_get (),
-                                         profile,
-                                         current_window,
-                                         NULL,
-                                         FALSE, FALSE,
-                                         FALSE/*not fullscreen*/,
-                                         it->exec_argv,
-                                         NULL,
-                                         it->title,
-                                         it->working_dir,
-                                         NULL,
-                                         it->zoom_set ?
-                                         it->zoom : 1.0,
-                                         NULL, NULL, -1);
-            }
+          screen = terminal_app_new_terminal (app, window, profile,
+                                              it->exec_argv,
+                                              it->title,
+                                              it->working_dir,
+                                              it->zoom_set ? it->zoom : 1.0);
           
           if (it->active)
-            {
-              /* TerminalWindow's interface does not expose the list of TerminalScreens,
-               * so we use the fact that terminal_app_new_terminal() sets the new terminal
-               * to be the active one. Not nice.
-               */
-              active_screen = terminal_window_get_active (current_window);
-             }
+            terminal_window_switch_screen (window, screen);
         }
-      
-      if (active_screen)
-        terminal_window_switch_screen (current_window, active_screen);
+
+      gtk_window_present (GTK_WINDOW (window));
     }
 }
 



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