gnome-terminal r2767 - trunk/src



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

Log:
Add close-screen signal to TerminalScreen and use that instead of directly calling a method on the TerminalWindow from inside TerminalScreen.


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

Modified: trunk/src/terminal-screen.c
==============================================================================
--- trunk/src/terminal-screen.c	(original)
+++ trunk/src/terminal-screen.c	Thu May 29 19:52:18 2008
@@ -74,6 +74,7 @@
 {
   PROFILE_SET,
   SHOW_POPUP_MENU,
+  CLOSE_SCREEN,
   LAST_SIGNAL
 };
 
@@ -438,7 +439,7 @@
   widget_class->screen_changed = terminal_screen_screen_changed;
 
   signals[PROFILE_SET] =
-    g_signal_new (I_("profile_set"),
+    g_signal_new (I_("profile-set"),
                   G_OBJECT_CLASS_TYPE (object_class),
                   G_SIGNAL_RUN_LAST,
                   G_STRUCT_OFFSET (TerminalScreenClass, profile_set),
@@ -458,6 +459,16 @@
                   1,
                   G_TYPE_POINTER);
 
+  signals[CLOSE_SCREEN] =
+    g_signal_new (I_("close-screen"),
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (TerminalScreenClass, close_screen),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE,
+                  0);
+  
   g_object_class_install_property
     (object_class,
      PROP_ICON_TITLE,
@@ -1361,17 +1372,6 @@
   g_strfreev (env);
 }
 
-void
-terminal_screen_close (TerminalScreen *screen)
-{
-  TerminalScreenPrivate *priv = screen->priv;
-  
-  g_return_if_fail (priv->window);
-
-  terminal_window_remove_screen (priv->window, screen);
-  /* screen should be finalized here, do not touch it past this point */
-}
-
 static TerminalScreenPopupInfo *
 terminal_screen_popup_info_new (TerminalScreen *screen)
 {
@@ -1748,7 +1748,7 @@
   switch (action)
     {
     case TERMINAL_EXIT_CLOSE:
-      terminal_screen_close (screen);
+      g_signal_emit (screen, signals[CLOSE_SCREEN], 0);
       break;
     case TERMINAL_EXIT_RESTART:
       terminal_screen_launch_child (screen);

Modified: trunk/src/terminal-screen.h
==============================================================================
--- trunk/src/terminal-screen.h	(original)
+++ trunk/src/terminal-screen.h	Thu May 29 19:52:18 2008
@@ -62,6 +62,7 @@
                                TerminalProfile *old_profile);
   void (* show_popup_menu)    (TerminalScreen *screen,
                                TerminalScreenPopupInfo *info);
+  void (* close_screen)       (TerminalScreen *screen);
 };
 
 GType terminal_screen_get_type (void) G_GNUC_CONST;
@@ -88,8 +89,6 @@
 const char* terminal_screen_get_icon_title     (TerminalScreen *screen);
 gboolean    terminal_screen_get_icon_title_set (TerminalScreen *screen);
 
-void terminal_screen_close (TerminalScreen *screen);
-
 void terminal_screen_edit_title (TerminalScreen *screen,
                                  GtkWindow      *transient_parent);
 

Modified: trunk/src/terminal-window.c
==============================================================================
--- trunk/src/terminal-window.c	(original)
+++ trunk/src/terminal-window.c	Thu May 29 19:52:18 2008
@@ -1071,6 +1071,13 @@
                                   terminal_screen_popup_info_ref (info));
 }
 
+static void
+screen_close_cb (TerminalScreen *screen,
+                 TerminalWindow *window)
+{
+  terminal_window_remove_screen (window, screen);
+}
+
 /*****************************************/
 
 
@@ -1688,7 +1695,7 @@
 }
 
 static GtkWidget *
-construct_tab_label (TerminalWindow *window, TerminalScreen *screen, GtkWidget *screen_container)
+construct_tab_label (TerminalScreen *screen, GtkWidget *screen_container)
 {
   GtkWidget *hbox, *label, *close_button, *image;
 
@@ -1753,7 +1760,7 @@
 
   update_tab_visibility (window, +1);
 
-  tab_label = construct_tab_label (window, screen, screen_container);
+  tab_label = construct_tab_label (screen, screen_container);
 
   gtk_notebook_insert_page (GTK_NOTEBOOK (priv->notebook),
                             screen_container,
@@ -2063,6 +2070,9 @@
   g_signal_connect (screen, "show-popup-menu",
                     G_CALLBACK (screen_show_popup_menu_callback), window);
 
+  g_signal_connect (screen, "close-screen",
+                    G_CALLBACK (screen_close_cb), window);
+
   update_notebook (window);
 
   update_tab_visibility (window, 0);
@@ -2137,6 +2147,10 @@
                                         G_CALLBACK (screen_show_popup_menu_callback),
                                         window);
 
+  g_signal_handlers_disconnect_by_func (screen,
+                                        G_CALLBACK (screen_close_cb),
+                                        window);
+
   /* FIXMEchpe this should have been done by the parent-set handler already! */
   terminal_screen_set_window (screen, NULL);
   priv->terms--;
@@ -2373,8 +2387,10 @@
 {
   TerminalWindowPrivate *priv = window->priv;
   
-  if (priv->active_term)
-    terminal_screen_close (priv->active_term);
+  if (!priv->active_term)
+    return;
+
+  terminal_window_remove_screen (window, priv->active_term);
 }
 
 static void



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