[gedit] Disconnect handlers for modeline on tab removed



commit 3df829e0b2d9f209c959999b0bbd600a80461605
Author: Jesse van den Kieboom <jesse icecrew nl>
Date:   Sat May 23 16:18:01 2009 +0200

    Disconnect handlers for modeline on tab removed
    
    This should solve the issue where modelines will be doubly active (and not properly
    deactivated) when moving tabs from one window to another.
---
 plugins/modelines/gedit-modeline-plugin.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/plugins/modelines/gedit-modeline-plugin.c b/plugins/modelines/gedit-modeline-plugin.c
index dd5603d..1fb03d1 100644
--- a/plugins/modelines/gedit-modeline-plugin.c
+++ b/plugins/modelines/gedit-modeline-plugin.c
@@ -37,6 +37,7 @@
 typedef struct
 {
 	gulong tab_added_handler_id;
+	gulong tab_removed_handler_id;
 } WindowData;
 
 typedef struct
@@ -170,6 +171,14 @@ on_window_tab_added (GeditWindow *window,
 }
 
 static void
+on_window_tab_removed (GeditWindow *window,
+		       GeditTab *tab,
+		       gpointer user_data)
+{
+	disconnect_handlers (gedit_tab_get_view (tab));
+}
+
+static void
 gedit_modeline_plugin_activate (GeditPlugin *plugin,
 				GeditWindow *window)
 {
@@ -188,10 +197,15 @@ gedit_modeline_plugin_activate (GeditPlugin *plugin,
 	g_list_free (views);
 
 	wdata = g_slice_new (WindowData);
+
 	wdata->tab_added_handler_id =
 		g_signal_connect (window, "tab-added",
 				  G_CALLBACK (on_window_tab_added), NULL);
 
+	wdata->tab_removed_handler_id =
+		g_signal_connect (window, "tab-removed",
+				  G_CALLBACK (on_window_tab_removed), NULL);
+
 	g_object_set_data_full (G_OBJECT (window), WINDOW_DATA_KEY,
 				wdata, (GDestroyNotify) window_data_free);
 }



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