SF.net SVN: geany:[5632] trunk

colombanw at users.sourceforge.net colombanw at xxxxx
Sun Mar 27 00:18:05 UTC 2011


Revision: 5632
          http://geany.svn.sourceforge.net/geany/?rev=5632&view=rev
Author:   colombanw
Date:     2011-03-27 00:18:05 +0000 (Sun, 27 Mar 2011)

Log Message:
-----------
Enable code folding in splitview window (closes #3097780)

Based on a patch by Matthew Brush, thanks!

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/plugins/splitwindow.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2011-03-26 17:25:24 UTC (rev 5631)
+++ trunk/ChangeLog	2011-03-27 00:18:05 UTC (rev 5632)
@@ -11,6 +11,9 @@
    src/project.c:
    Add possibility to detect the indentation width from the file content
    (not supported if indentation type is tabs only).
+ * plugins/splitwindow.c:
+   Enable code folding in splitview window (based on a patch by Matthew
+   Brush, thanks! - closes #3097780).
 
 
 2011-03-25  Colomban Wendling  <colomban(at)geany(dot)org>

Modified: trunk/plugins/splitwindow.c
===================================================================
--- trunk/plugins/splitwindow.c	2011-03-26 17:25:24 UTC (rev 5631)
+++ trunk/plugins/splitwindow.c	2011-03-27 00:18:05 UTC (rev 5632)
@@ -73,10 +73,11 @@
 	ScintillaObject	*sci;		/* new editor widget */
 	GtkWidget		*vbox;
 	GtkWidget		*name_label;
+	gint 			handler_id;
 }
 EditWindow;
 
-static EditWindow edit_window = {NULL, NULL, NULL, NULL};
+static EditWindow edit_window = {NULL, NULL, NULL, NULL, 0 };
 
 
 static void on_unsplit(GtkMenuItem *menuitem, gpointer user_data);
@@ -103,6 +104,25 @@
 }
 
 
+static void on_sci_notify (ScintillaObject *sci, gint param, SCNotification *notif, gpointer data)
+{
+	gint line;
+
+	switch (notif->nmhdr.code)
+	{
+		case SCN_MARGINCLICK:
+			if (notif->margin == 2)
+			{
+				line = sci_get_line_from_position(sci, notif->position);
+				scintilla_send_message(sci, SCI_TOGGLEFOLD, line, 0);
+			}
+			break;
+
+		default: break;
+	}
+}
+
+
 static void sync_to_current(ScintillaObject *sci, ScintillaObject *current)
 {
 	gpointer sdoc;
@@ -119,7 +139,6 @@
 	/* override some defaults */
 	set_line_numbers(sci, geany->editor_prefs->show_linenumber_margin);
 	scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 1, 0 ); /* hide marker margin (no commands) */
-	scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 2, 0 ); /* hide fold margin (no toggle callback) */
 }
 
 
@@ -127,6 +146,12 @@
 {
 	editwin->editor = editor;
 
+	if (editwin->handler_id > 0 && editwin->sci != NULL)
+	{
+		g_signal_handler_disconnect(editwin->sci, editwin->handler_id);
+		editwin->handler_id = 0;
+	}
+
 	/* first destroy any widget, otherwise its signals will have an
 	 * invalid document as user_data */
 	if (editwin->sci != NULL)
@@ -138,6 +163,12 @@
 
 	sync_to_current(editwin->sci, editor->sci);
 
+	if (geany->editor_prefs->folding)
+		editwin->handler_id = g_signal_connect(editwin->sci, "sci-notify",
+				G_CALLBACK(on_sci_notify), NULL);
+	else
+		scintilla_send_message(editwin->sci, SCI_SETMARGINWIDTHN, 2, 0);
+
 	gtk_label_set_text(GTK_LABEL(editwin->name_label), DOC_FILENAME(editor->document));
 }
 
@@ -332,6 +363,12 @@
 	gtk_widget_reparent(notebook,
 		ui_lookup_widget(geany->main_widgets->window, "vbox1"));
 
+	if (edit_window.sci != NULL && edit_window.handler_id > 0)
+	{
+		g_signal_handler_disconnect(edit_window.sci, edit_window.handler_id);
+		edit_window.handler_id = 0;
+	}
+
 	gtk_widget_destroy(pane);
 	edit_window.editor = NULL;
 	edit_window.sci = NULL;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list