[gedit] Remove tab-added and tab-removed signals.



commit 3a0948e9423605dc59a60f44f38e20c15ebdbce8
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sun May 23 22:55:02 2010 +0200

    Remove tab-added and tab-removed signals.
    
    Now we use the page-added and page-removed signals added in GtkNotebook
    sometime ago.

 gedit/gedit-notebook.c |   59 ++++++++---------------------------------------
 gedit/gedit-notebook.h |    4 ---
 gedit/gedit-window.c   |   39 +++++++++++++++++--------------
 3 files changed, 31 insertions(+), 71 deletions(-)
---
diff --git a/gedit/gedit-notebook.c b/gedit/gedit-notebook.c
index fcee52a..b6f5676 100644
--- a/gedit/gedit-notebook.c
+++ b/gedit/gedit-notebook.c
@@ -49,10 +49,6 @@
 #include "gedit-marshal.h"
 #include "gedit-window.h"
 
-#ifdef BUILD_SPINNER
-#include "gedit-spinner.h"
-#endif
-
 #include "gseal-gtk-compat.h"
 
 #define AFTER_ALL_TABS -1
@@ -75,8 +71,6 @@ struct _GeditNotebookPrivate
 
 G_DEFINE_TYPE(GeditNotebook, gedit_notebook, GTK_TYPE_NOTEBOOK)
 
-static void gedit_notebook_finalize (GObject *object);
-
 static gboolean gedit_notebook_change_current_page (GtkNotebook   *notebook,
 						    gint           offset);
 
@@ -91,8 +85,6 @@ static GdkCursor *cursor = NULL;
 /* Signals */
 enum
 {
-	TAB_ADDED,
-	TAB_REMOVED,
 	TABS_REORDERED,
 	TAB_DETACHED,
 	TAB_CLOSE_REQUEST,
@@ -102,6 +94,16 @@ enum
 static guint signals[LAST_SIGNAL] = { 0 };
 
 static void
+gedit_notebook_finalize (GObject *object)
+{
+	GeditNotebook *notebook = GEDIT_NOTEBOOK (object);
+
+	g_list_free (notebook->priv->focused_pages);
+
+	G_OBJECT_CLASS (gedit_notebook_parent_class)->finalize (object);
+}
+
+static void
 gedit_notebook_destroy (GtkObject *object)
 {
 	GeditNotebook *notebook = GEDIT_NOTEBOOK (object);
@@ -154,26 +156,6 @@ gedit_notebook_class_init (GeditNotebookClass *klass)
 	
 	notebook_class->change_current_page = gedit_notebook_change_current_page;
 
-	signals[TAB_ADDED] =
-		g_signal_new ("tab_added",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (GeditNotebookClass, tab_added),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__OBJECT,
-			      G_TYPE_NONE,
-			      1,
-			      GEDIT_TYPE_TAB);
-	signals[TAB_REMOVED] =
-		g_signal_new ("tab_removed",
-			      G_OBJECT_CLASS_TYPE (object_class),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (GeditNotebookClass, tab_removed),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__OBJECT,
-			      G_TYPE_NONE,
-			      1,
-			      GEDIT_TYPE_TAB);
 	signals[TAB_DETACHED] =
 		g_signal_new ("tab_detached",
 			      G_OBJECT_CLASS_TYPE (object_class),
@@ -750,16 +732,6 @@ gedit_notebook_init (GeditNotebook *notebook)
                                 NULL);
 }
 
-static void
-gedit_notebook_finalize (GObject *object)
-{
-	GeditNotebook *notebook = GEDIT_NOTEBOOK (object);
-
-	g_list_free (notebook->priv->focused_pages);
-
-	G_OBJECT_CLASS (gedit_notebook_parent_class)->finalize (object);
-}
-
 /*
  * We need to override this because when we don't show the tabs, like in
  * fullscreen we need to have wrap around too
@@ -901,8 +873,6 @@ gedit_notebook_add_tab (GeditNotebook *nb,
 				  position);
 	update_tabs_visibility (nb, TRUE);
 
-	g_signal_emit (G_OBJECT (nb), signals[TAB_ADDED], 0, tab);
-
 	/* The signal handler may have reordered the tabs */
 	position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), 
 					  GTK_WIDGET (tab));
@@ -955,18 +925,9 @@ remove_tab (GeditTab      *tab,
 
 	position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
 
-	/* we ref the tab so that it's still alive while the tabs_removed
-	 * signal is processed.
-	 */
-	g_object_ref (tab);
-
 	remove_tab_label (nb, tab);
 	gtk_notebook_remove_page (GTK_NOTEBOOK (nb), position);
 	update_tabs_visibility (nb, FALSE);
-
-	g_signal_emit (G_OBJECT (nb), signals[TAB_REMOVED], 0, tab);
-
-	g_object_unref (tab);
 }
 
 /**
diff --git a/gedit/gedit-notebook.h b/gedit/gedit-notebook.h
index cf17d1f..fa7d41b 100644
--- a/gedit/gedit-notebook.h
+++ b/gedit/gedit-notebook.h
@@ -81,10 +81,6 @@ struct _GeditNotebookClass
         GtkNotebookClass parent_class;
 
 	/* Signals */
-	void	 (* tab_added)		(GeditNotebook *notebook,
-					 GeditTab      *tab);
-	void	 (* tab_removed)	(GeditNotebook *notebook,
-					 GeditTab      *tab);
 	void	 (* tab_detached)	(GeditNotebook *notebook,
 					 GeditTab      *tab);
 	void	 (* tabs_reordered)	(GeditNotebook *notebook);
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index dfbc6fd..cbfe3a4 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -3405,9 +3405,10 @@ update_sensitivity_according_to_open_tabs (GeditWindow *window)
 }
 
 static void
-notebook_tab_added (GeditNotebook *notebook,
-		    GeditTab      *tab,
-		    GeditWindow   *window)
+notebook_page_added (GtkNotebook *notebook,
+		     GtkWidget   *child,
+		     guint        page_num,
+		     GeditWindow *window)
 {
 	GeditView *view;
 	GeditDocument *doc;
@@ -3420,19 +3421,19 @@ notebook_tab_added (GeditNotebook *notebook,
 
 	update_sensitivity_according_to_open_tabs (window);
 
-	view = gedit_tab_get_view (tab);
-	doc = gedit_tab_get_document (tab);
+	view = gedit_tab_get_view (GEDIT_TAB (child));
+	doc = gedit_tab_get_document (GEDIT_TAB (child));
 
 	/* IMPORTANT: remember to disconnect the signal in notebook_tab_removed
 	 * if a new signal is connected here */
 
-	g_signal_connect (tab, 
+	g_signal_connect (child,
 			 "notify::name",
-			  G_CALLBACK (sync_name), 
+			  G_CALLBACK (sync_name),
 			  window);
-	g_signal_connect (tab, 
+	g_signal_connect (child, 
 			 "notify::state",
-			  G_CALLBACK (sync_state), 
+			  G_CALLBACK (sync_state),
 			  window);
 
 	g_signal_connect (doc,
@@ -3485,14 +3486,16 @@ notebook_tab_added (GeditNotebook *notebook,
 
 	update_window_state (window);
 
-	g_signal_emit (G_OBJECT (window), signals[TAB_ADDED], 0, tab);
+	g_signal_emit (G_OBJECT (window), signals[TAB_ADDED], 0, child);
 }
 
 static void
-notebook_tab_removed (GeditNotebook *notebook,
-		      GeditTab      *tab,
-		      GeditWindow   *window)
+notebook_page_removed (GtkNotebook *notebook,
+		       GtkWidget   *child,
+		       guint        page_num,
+		       GeditWindow *window)
 {
+	GeditTab *tab = GEDIT_TAB (child);
 	GeditView     *view;
 	GeditDocument *doc;
 
@@ -3602,7 +3605,7 @@ notebook_tab_removed (GeditNotebook *notebook,
 
 	update_window_state (window);
 
-	g_signal_emit (G_OBJECT (window), signals[TAB_REMOVED], 0, tab);	
+	g_signal_emit (G_OBJECT (window), signals[TAB_REMOVED], 0, tab);
 }
 
 static void
@@ -4069,12 +4072,12 @@ connect_notebook_signals (GeditWindow *window,
 			  G_CALLBACK (notebook_switch_page),
 			  window);
 	g_signal_connect (notebook,
-			  "tab-added",
-			  G_CALLBACK (notebook_tab_added),
+			  "page-added",
+			  G_CALLBACK (notebook_page_added),
 			  window);
 	g_signal_connect (notebook,
-			  "tab-removed",
-			  G_CALLBACK (notebook_tab_removed),
+			  "page-removed",
+			  G_CALLBACK (notebook_page_removed),
 			  window);
 	g_signal_connect (notebook,
 			  "tabs-reordered",



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