SF.net SVN: geany: [2689] branches/document-pointer

eht16 at users.sourceforge.net eht16 at xxxxx
Thu Jun 12 20:45:44 UTC 2008


Revision: 2689
          http://geany.svn.sourceforge.net/geany/?rev=2689&view=rev
Author:   eht16
Date:     2008-06-12 13:45:18 -0700 (Thu, 12 Jun 2008)

Log Message:
-----------
Remove temporary navqueues_ and msgwins_ functions and adjust depending code.

Modified Paths:
--------------
    branches/document-pointer/ChangeLog
    branches/document-pointer/src/msgwindow.c
    branches/document-pointer/src/msgwindow.h
    branches/document-pointer/src/navqueue.c
    branches/document-pointer/src/navqueue.h
    branches/document-pointer/src/plugins.c
    branches/document-pointer/src/search.c
    branches/document-pointer/src/symbols.c
    branches/document-pointer/src/treeviews.c

Modified: branches/document-pointer/ChangeLog
===================================================================
--- branches/document-pointer/ChangeLog	2008-06-12 20:09:57 UTC (rev 2688)
+++ branches/document-pointer/ChangeLog	2008-06-12 20:45:18 UTC (rev 2689)
@@ -10,6 +10,10 @@
    Make NavQueueFuncs and MsgWinFuncs use a GeanyDocument* instead of an
    integer index.
    Adjust plugins to work with these changes.
+ * src/navqueue.c, src/navqueue.h, src/treeviews.c, src/msgwindow.c,
+   src/msgwindow.h, src/search.c, src/plugins.c, src/symbols.c:
+   Remove temporary navqueues_ and msgwins_ functions and adjust
+   depending code.
 
 
 2008-06-12  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: branches/document-pointer/src/msgwindow.c
===================================================================
--- branches/document-pointer/src/msgwindow.c	2008-06-12 20:09:57 UTC (rev 2688)
+++ branches/document-pointer/src/msgwindow.c	2008-06-12 20:45:18 UTC (rev 2689)
@@ -278,7 +278,7 @@
  *  @param format Printf()-style format string.
  *  @param ... Arguments for the @c format string.
  **/
-void msgwins_msg_add_fmt(gint msg_color, gint line, GeanyDocument *doc, const gchar *format, ...)
+void msgwin_msg_add_fmt(gint msg_color, gint line, GeanyDocument *doc, const gchar *format, ...)
 {
 	gchar string[512];
 	va_list args;
@@ -287,12 +287,12 @@
 	g_vsnprintf(string, 512, format, args);
 	va_end(args);
 
-	msgwins_msg_add(msg_color, line, doc, string);
+	msgwin_msg_add(msg_color, line, doc, string);
 }
 
 
 /* adds string to the msg treeview */
-void msgwins_msg_add(gint msg_color, gint line, GeanyDocument *doc, const gchar *string)
+void msgwin_msg_add(gint msg_color, gint line, GeanyDocument *doc, const gchar *string)
 {
 	GtkTreeIter iter;
 	const GdkColor *color = get_color(msg_color);
@@ -317,28 +317,6 @@
 }
 
 
-/* temporary compatibility functions */
-void msgwin_msg_add_fmt(gint msg_color, gint line, gint idx, const gchar *format, ...)
-{
-	gchar string[512];
-	va_list args;
-
-	va_start(args, format);
-	g_vsnprintf(string, 512, format, args);
-	va_end(args);
-
-	msgwins_msg_add(msg_color, line, documents[idx], string);
-}
-
-
-void msgwin_msg_add(gint msg_color, gint line, gint idx, const gchar *string)
-{
-	if (! DOC_IDX_VALID(idx))
-		return;
-	msgwins_msg_add(msg_color, line, documents[idx], string);
-}
-
-
 /**
  *  Log a status message *without* setting the status bar.
  *  (Use ui_set_statusbar() to display text on the statusbar)
@@ -523,7 +501,6 @@
 	gchar *string;
 	gboolean ret = FALSE;
 	GdkColor *color;
-	gint old_idx = document_get_cur_idx();
 
 	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_compiler));
 	if (gtk_tree_selection_get_selected(selection, &model, &iter))
@@ -541,7 +518,6 @@
 		if (string != NULL)
 		{
 			gint line;
-			gint idx;
 			gchar *filename, *dir;
 			GtkTreePath *path;
 
@@ -556,18 +532,20 @@
 			if (filename != NULL && line > -1)
 			{
 				gchar *utf8_filename = utils_get_utf8_from_locale(filename);
-				idx = document_find_by_filename(utf8_filename);
+				GeanyDocument *doc = documents_find_by_filename(utf8_filename);
+				GeanyDocument *old_doc = document_get_current();
+
 				g_free(utf8_filename);
 
-				if (idx < 0)	/* file not already open */
-					idx = document_open_file(filename, FALSE, NULL, NULL);
+				if (doc == NULL)	/* file not already open */
+					doc = documents_open_file(filename, FALSE, NULL, NULL);
 
-				if (DOC_IDX_VALID(idx))
+				if (doc != NULL)
 				{
-					if (! documents[idx]->changed)	/* if modified, line may be wrong */
-						editor_set_indicator_on_line(idx, line - 1);
+					if (! doc->changed)	/* if modified, line may be wrong */
+						editor_set_indicator_on_line(DOC_IDX(doc), line - 1);
 
-					ret = navqueue_goto_line(old_idx, idx, line);
+					ret = navqueue_goto_line(old_doc, doc, line);
 				}
 			}
 			g_free(filename);
@@ -823,14 +801,15 @@
 	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_msg));
 	if (gtk_tree_selection_get_selected(selection, &model, &iter))
 	{
-		gint idx, line, old_idx = document_get_cur_idx();
+		gint line;
 		gchar *string;
+		GeanyDocument *doc;
+		GeanyDocument *old_doc = document_get_current();
 
-		gtk_tree_model_get(model, &iter, 0, &line, 1, &idx, 3, &string, -1);
-		if (line >= 0 && idx >= 0)
+		gtk_tree_model_get(model, &iter, 0, &line, 1, &doc, 3, &string, -1);
+		if (line >= 0 && doc != NULL)
 		{
-			if (DOC_IDX_VALID(idx))
-				ret = navqueue_goto_line(old_idx, idx, line);
+			ret = navqueue_goto_line(old_doc, doc, line);
 		}
 		else if (line < 0 && string != NULL)
 		{
@@ -839,9 +818,9 @@
 			if (filename != NULL && line > -1)
 			{
 				/* use document_open_file to find an already open file, or open it in place */
-				idx = document_open_file(filename, FALSE, NULL, NULL);
-				if (DOC_IDX_VALID(idx))
-					ret = navqueue_goto_line(old_idx, idx, line);
+				doc = documents_open_file(filename, FALSE, NULL, NULL);
+				if (doc != NULL)
+					ret = navqueue_goto_line(old_doc, doc, line);
 			}
 			g_free(filename);
 		}

Modified: branches/document-pointer/src/msgwindow.h
===================================================================
--- branches/document-pointer/src/msgwindow.h	2008-06-12 20:09:57 UTC (rev 2688)
+++ branches/document-pointer/src/msgwindow.h	2008-06-12 20:45:18 UTC (rev 2689)
@@ -84,16 +84,11 @@
 
 void msgwin_clear_tab(gint tabnum);
 
-void msgwins_msg_add_fmt(gint msg_color, gint line, GeanyDocument *doc, const gchar *format, ...)
+void msgwin_msg_add_fmt(gint msg_color, gint line, GeanyDocument *doc, const gchar *format, ...)
 			G_GNUC_PRINTF (4, 5);
 
-void msgwins_msg_add(gint msg_color, gint line, GeanyDocument *doc, const gchar *string);
+void msgwin_msg_add(gint msg_color, gint line, GeanyDocument *doc, const gchar *string);
 
-/* temporary compatibility functions */
-void msgwin_msg_add_fmt(gint msg_color, gint line, gint idx, const gchar *format, ...) G_GNUC_PRINTF (4, 5);
-
-void msgwin_msg_add(gint msg_color, gint line, gint idx, const gchar *string);
-
 void msgwin_compiler_add_fmt(gint msg_color, const gchar *format, ...) G_GNUC_PRINTF (2, 3);
 
 void msgwin_compiler_add(gint msg_color, const gchar *msg);

Modified: branches/document-pointer/src/navqueue.c
===================================================================
--- branches/document-pointer/src/navqueue.c	2008-06-12 20:09:57 UTC (rev 2688)
+++ branches/document-pointer/src/navqueue.c	2008-06-12 20:45:18 UTC (rev 2689)
@@ -144,7 +144,7 @@
  *
  *  @return @a TRUE if the cursor has changed the position to @a line or @a FALSE otherwise.
  **/
-gboolean navqueues_goto_line(GeanyDocument *old_doc, GeanyDocument *new_doc, gint line)
+gboolean navqueue_goto_line(GeanyDocument *old_doc, GeanyDocument *new_doc, gint line)
 {
 	gint pos;
 
@@ -171,13 +171,6 @@
 }
 
 
-/* temporary compatibility function */
-gboolean navqueue_goto_line(gint old_idx, gint new_idx, gint line)
-{
-	return navqueues_goto_line(documents[old_idx], documents[new_idx],	line);
-}
-
-
 static gboolean goto_file_pos(const gchar *file, gint pos)
 {
 	gint file_idx = document_find_by_filename(file);

Modified: branches/document-pointer/src/navqueue.h
===================================================================
--- branches/document-pointer/src/navqueue.h	2008-06-12 20:09:57 UTC (rev 2688)
+++ branches/document-pointer/src/navqueue.h	2008-06-12 20:45:18 UTC (rev 2689)
@@ -39,11 +39,8 @@
 void navqueue_remove_file(const gchar *filename);
 
 
-gboolean navqueues_goto_line(GeanyDocument *old_doc, GeanyDocument *new_doc, gint line);
+gboolean navqueue_goto_line(GeanyDocument *old_doc, GeanyDocument *new_doc, gint line);
 
-/* temporary compatibility function */
-gboolean navqueue_goto_line(gint old_idx, gint new_idx, gint line);
-
 void navqueue_go_back(void);
 
 void navqueue_go_forward(void);

Modified: branches/document-pointer/src/plugins.c
===================================================================
--- branches/document-pointer/src/plugins.c	2008-06-12 20:09:57 UTC (rev 2688)
+++ branches/document-pointer/src/plugins.c	2008-06-12 20:45:18 UTC (rev 2689)
@@ -194,7 +194,7 @@
 static MsgWinFuncs msgwin_funcs = {
 	&msgwin_status_add,
 	&msgwin_compiler_add_fmt,
-	&msgwins_msg_add_fmt,
+	&msgwin_msg_add_fmt,
 	&msgwin_clear_tab,
 	&msgwin_switch_tab
 };
@@ -234,7 +234,7 @@
 };
 
 static NavQueueFuncs navqueue_funcs = {
-	&navqueues_goto_line
+	&navqueue_goto_line
 };
 
 static GeanyFunctions geany_functions = {

Modified: branches/document-pointer/src/search.c
===================================================================
--- branches/document-pointer/src/search.c	2008-06-12 20:09:57 UTC (rev 2688)
+++ branches/document-pointer/src/search.c	2008-06-12 20:45:18 UTC (rev 2689)
@@ -1237,7 +1237,7 @@
 		str = g_strdup_printf(_("%s %s -- %s (in directory: %s)"),
 			tool_prefs.grep_cmd, opts, search_text, dir);
 		utf8_str = utils_get_utf8_from_locale(str);
-		msgwin_msg_add(COLOR_BLUE, -1, -1, utf8_str);
+		msgwin_msg_add(COLOR_BLUE, -1, NULL, utf8_str);
 		utils_free_pointers(str, utf8_str, NULL);
 		ret = TRUE;
 	}
@@ -1296,7 +1296,7 @@
 
 		while (g_io_channel_read_line(source, &msg, NULL, NULL, NULL) && msg)
 		{
-			msgwin_msg_add(COLOR_BLACK, -1, -1, g_strstrip(msg));
+			msgwin_msg_add(COLOR_BLACK, -1, NULL, g_strstrip(msg));
 			g_free(msg);
 		}
 	}
@@ -1309,6 +1309,7 @@
 
 static void search_close_pid(GPid child_pid, gint status, gpointer user_data)
 {
+	/* TODO: port this also to Windows API */
 #ifdef G_OS_UNIX
 	const gchar *msg = _("Search failed.");
 	gint color = COLOR_DARK_RED;
@@ -1322,7 +1323,7 @@
 				gint count = gtk_tree_model_iter_n_children(
 					GTK_TREE_MODEL(msgwindow.store_msg), NULL) - 1;
 
-				msgwin_msg_add_fmt(COLOR_BLUE, -1, -1,
+				msgwin_msg_add_fmt(COLOR_BLUE, -1, NULL,
 					ngettext("Search completed with %d matches.",
 							 "Search completed with %d matches.", count),
 					count);
@@ -1336,7 +1337,7 @@
 				msg = _("No matches found.");
 				color = COLOR_BLUE;
 			default:
-				msgwin_msg_add(color, -1, -1, msg);
+				msgwin_msg_add(color, -1, NULL, msg);
 				ui_set_statusbar(FALSE, "%s", msg);
 				break;
 		}
@@ -1375,7 +1376,7 @@
 		count++;
 		line = sci_get_line_from_position(documents[idx]->sci, pos);
 		buffer = sci_get_line(documents[idx]->sci, line);
-		msgwin_msg_add_fmt(COLOR_BLACK, line + 1, idx,
+		msgwin_msg_add_fmt(COLOR_BLACK, line + 1, documents[idx],
 			"%s:%d : %s", short_file_name, line + 1, g_strstrip(buffer));
 		g_free(buffer);
 
@@ -1415,7 +1416,7 @@
 	if (! found) /* no matches were found */
 	{
 		ui_set_statusbar(FALSE, _("No matches found for \"%s\"."), search_text);
-		msgwin_msg_add_fmt(COLOR_BLUE, -1, -1, _("No matches found for \"%s\"."), search_text);
+		msgwin_msg_add_fmt(COLOR_BLUE, -1, NULL, _("No matches found for \"%s\"."), search_text);
 	}
 	else
 	{
@@ -1424,7 +1425,7 @@
 		ui_set_statusbar(FALSE, ngettext(
 			"Found %d matches for \"%s\".", "Found %d matches for \"%s\".", count),
 			count, search_text);
-		msgwin_msg_add_fmt(COLOR_BLUE, -1, -1, ngettext(
+		msgwin_msg_add_fmt(COLOR_BLUE, -1, NULL, ngettext(
 			"Found %d matches for \"%s\".", "Found %d matches for \"%s\".", count),
 			count, search_text);
 	}

Modified: branches/document-pointer/src/symbols.c
===================================================================
--- branches/document-pointer/src/symbols.c	2008-06-12 20:09:57 UTC (rev 2688)
+++ branches/document-pointer/src/symbols.c	2008-06-12 20:45:18 UTC (rev 2689)
@@ -1206,7 +1206,7 @@
 			new_idx = document_open_file(tmtag->atts.entry.file->work_object.file_name, FALSE, NULL, NULL);
 		}
 
-		if (navqueue_goto_line(old_idx, new_idx, tmtag->atts.entry.line))
+		if (navqueue_goto_line(documents[old_idx], documents[new_idx], tmtag->atts.entry.line))
 			return TRUE;
 	}
 	/* if we are here, there was no match and we are beeping ;-) */

Modified: branches/document-pointer/src/treeviews.c
===================================================================
--- branches/document-pointer/src/treeviews.c	2008-06-12 20:09:57 UTC (rev 2688)
+++ branches/document-pointer/src/treeviews.c	2008-06-12 20:45:18 UTC (rev 2689)
@@ -649,9 +649,9 @@
 		gtk_tree_model_get(model, &iter, SYMBOLS_COLUMN_LINE, &line, -1);
 		if (line > 0)
 		{
-			gint idx = document_get_cur_idx();
+			GeanyDocument *doc = document_get_current();
 
-			navqueue_goto_line(idx, idx, line);
+			navqueue_goto_line(doc, doc, line);
 		}
 	}
 	return FALSE;


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