SF.net SVN: geany: [2505] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sat Apr 19 08:14:00 UTC 2008


Revision: 2505
          http://geany.svn.sourceforge.net/geany/?rev=2505&view=rev
Author:   eht16
Date:     2008-04-19 01:14:00 -0700 (Sat, 19 Apr 2008)

Log Message:
-----------
Clean related navigation queue items when closing a document.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c
    trunk/src/navqueue.c
    trunk/src/navqueue.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-04-19 07:56:56 UTC (rev 2504)
+++ trunk/ChangeLog	2008-04-19 08:14:00 UTC (rev 2505)
@@ -2,6 +2,8 @@
 
  * tagmanager/js.c:
    Make property tags be recognised in the symbol list.
+ * src/document.c, src/navqueue.c, src/navqueue.h:
+   Clean related navigation queue items when closing a document.
 
 
 2008-04-18  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2008-04-19 07:56:56 UTC (rev 2504)
+++ trunk/src/document.c	2008-04-19 08:14:00 UTC (rev 2505)
@@ -71,6 +71,7 @@
 #include "callbacks.h"
 #include "geanyobject.h"
 #include "highlighting.h"
+#include "navqueue.h"
 #include "win32.h"
 
 
@@ -535,6 +536,7 @@
 		}
 		notebook_remove_page(page_num);
 		treeviews_remove_document(idx);
+		navqueue_remove_file(doc_list[idx].file_name);
 		msgwin_status_add(_("File %s closed."), DOC_FILENAME(idx));
 		g_free(doc_list[idx].encoding);
 		g_free(doc_list[idx].saved_encoding.encoding);

Modified: trunk/src/navqueue.c
===================================================================
--- trunk/src/navqueue.c	2008-04-19 07:56:56 UTC (rev 2504)
+++ trunk/src/navqueue.c	2008-04-19 08:14:00 UTC (rev 2505)
@@ -38,7 +38,7 @@
 /* for the navigation history queue */
 typedef struct
 {
-	gchar *file;	/* this is the tagmanager filename, not document::file_name */
+	gchar *file;	/* This is the document's filename, in UTF-8 */
 	gint pos;
 } filepos;
 
@@ -106,16 +106,16 @@
 }
 
 
-static void add_new_position(gchar *tm_filename, gint pos)
+static void add_new_position(gchar *utf8_filename, gint pos)
 {
 	filepos *npos;
 	guint i;
 
-	if (queue_pos_matches(nav_queue_pos, tm_filename, pos))
+	if (queue_pos_matches(nav_queue_pos, utf8_filename, pos))
 		return;	/* prevent duplicates */
 
 	npos = g_new0(filepos, 1);
-	npos->file = tm_filename;
+	npos->file = utf8_filename;
 	npos->pos = pos;
 
 	/* if we've jumped to a new position from inside the queue rather than going forward */
@@ -216,3 +216,29 @@
 	adjust_buttons();
 }
 
+
+static gint find_by_filename(gconstpointer a, gconstpointer b)
+{
+	if (utils_str_equal(((const filepos*)a)->file, (const gchar*) b))
+		return 0;
+	else
+		return 1;
+}
+
+
+/* Remove all elements with the given filename */
+void navqueue_remove_file(const gchar *filename)
+{
+	GList *match;
+
+	if (filename == NULL)
+		return;
+
+	while ((match = g_queue_find_custom(navigation_queue, filename, find_by_filename)))
+	{
+		g_free(match->data);
+		g_queue_delete_link(navigation_queue, match);
+	}
+
+	adjust_buttons();
+}

Modified: trunk/src/navqueue.h
===================================================================
--- trunk/src/navqueue.h	2008-04-19 07:56:56 UTC (rev 2504)
+++ trunk/src/navqueue.h	2008-04-19 08:14:00 UTC (rev 2505)
@@ -36,7 +36,9 @@
 
 void navqueue_free(void);
 
+void navqueue_remove_file(const gchar *filename);
 
+
 gboolean navqueue_goto_line(gint old_idx, gint new_idx, gint line);
 
 void navqueue_go_back(void);


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