SF.net SVN: geany:[5727] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Apr 17 13:40:05 UTC 2011


Revision: 5727
          http://geany.svn.sourceforge.net/geany/?rev=5727&view=rev
Author:   eht16
Date:     2011-04-17 13:40:04 +0000 (Sun, 17 Apr 2011)

Log Message:
-----------
Add document_compare_by_tab_order() and document_compare_by_tab_order_reverse() to the plugin API.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/plugins/geanyfunctions.h
    trunk/src/document.c
    trunk/src/document.h
    trunk/src/plugindata.h
    trunk/src/plugins.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2011-04-15 16:59:15 UTC (rev 5726)
+++ trunk/ChangeLog	2011-04-17 13:40:04 UTC (rev 5727)
@@ -1,3 +1,11 @@
+2011-04-17  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
+ * src/plugindata.h, src/document.c, src/plugins.c, src/document.h,
+   plugins/geanyfunctions.h:
+   Add document_compare_by_tab_order() and
+   document_compare_by_tab_order_reverse() to the plugin API.
+
+
 2011-04-15  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * src/utils.c, src/utils.h, src/editor.c:

Modified: trunk/plugins/geanyfunctions.h
===================================================================
--- trunk/plugins/geanyfunctions.h	2011-04-15 16:59:15 UTC (rev 5726)
+++ trunk/plugins/geanyfunctions.h	2011-04-17 13:40:04 UTC (rev 5727)
@@ -74,6 +74,10 @@
 	geany_functions->p_document->document_get_notebook_page
 #define document_compare_by_display_name \
 	geany_functions->p_document->document_compare_by_display_name
+#define document_compare_by_tab_order \
+	geany_functions->p_document->document_compare_by_tab_order
+#define document_compare_by_tab_order_reverse \
+	geany_functions->p_document->document_compare_by_tab_order_reverse
 #define editor_get_indent_prefs \
 	geany_functions->p_editor->editor_get_indent_prefs
 #define editor_create_widget \

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2011-04-15 16:59:15 UTC (rev 5726)
+++ trunk/src/document.c	2011-04-17 13:40:04 UTC (rev 5727)
@@ -3043,3 +3043,61 @@
 }
 
 
+/** Compares documents by their tab order.
+ * This matches @c GCompareFunc for use with e.g. @c g_ptr_array_sort().
+ *
+ * @param a @c GeanyDocument**.
+ * @param b @c GeanyDocument**.
+ * @warning The arguments take the address of each document pointer.
+ * @return Negative value if a < b; zero if a = b; positive value if a > b.
+ *
+ * @since 0.21 (GEANY_API_VERSION 209)
+ */
+gint document_compare_by_tab_order(gconstpointer a, gconstpointer b)
+{
+	GeanyDocument *doc_a = *((GeanyDocument**) a);
+	GeanyDocument *doc_b = *((GeanyDocument**) b);
+	gint notebook_position_doc_a;
+	gint notebook_position_doc_b;
+
+	notebook_position_doc_a = document_get_notebook_page(doc_a);
+	notebook_position_doc_b = document_get_notebook_page(doc_b);
+
+	if (notebook_position_doc_a < notebook_position_doc_b)
+		return -1;
+	if (notebook_position_doc_a > notebook_position_doc_b)
+		return 1;
+	/* equality */
+	return 0;
+}
+
+
+/** Compares documents by their tab order, in reverse order.
+ * This matches @c GCompareFunc for use with e.g. @c g_ptr_array_sort().
+ *
+ * @param a @c GeanyDocument**.
+ * @param b @c GeanyDocument**.
+ * @warning The arguments take the address of each document pointer.
+ * @return Negative value if a < b; zero if a = b; positive value if a > b.
+ *
+ * @since 0.21 (GEANY_API_VERSION 209)
+ */
+gint document_compare_by_tab_order_reverse(gconstpointer a, gconstpointer b)
+{
+	GeanyDocument *doc_a = *((GeanyDocument**) a);
+	GeanyDocument *doc_b = *((GeanyDocument**) b);
+	gint notebook_position_doc_a;
+	gint notebook_position_doc_b;
+
+	notebook_position_doc_a = document_get_notebook_page(doc_a);
+	notebook_position_doc_b = document_get_notebook_page(doc_b);
+
+	if (notebook_position_doc_a < notebook_position_doc_b)
+		return 1;
+	if (notebook_position_doc_a > notebook_position_doc_b)
+		return -1;
+	/* equality */
+	return 0;
+}
+
+

Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h	2011-04-15 16:59:15 UTC (rev 5726)
+++ trunk/src/document.h	2011-04-17 13:40:04 UTC (rev 5727)
@@ -261,4 +261,8 @@
 
 gint document_compare_by_display_name(gconstpointer a, gconstpointer b);
 
+gint document_compare_by_tab_order(gconstpointer a, gconstpointer b);
+
+gint document_compare_by_tab_order_reverse(gconstpointer a, gconstpointer b);
+
 #endif

Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h	2011-04-15 16:59:15 UTC (rev 5726)
+++ trunk/src/plugindata.h	2011-04-17 13:40:04 UTC (rev 5727)
@@ -54,7 +54,7 @@
  * @warning You should not test for values below 200 as previously
  * @c GEANY_API_VERSION was defined as an enum value, not a macro.
  */
-#define GEANY_API_VERSION 208
+#define GEANY_API_VERSION 209
 
 /** The Application Binary Interface (ABI) version, incremented whenever
  * existing fields in the plugin data types have to be changed or reordered.
@@ -311,6 +311,8 @@
 	gchar*		(*document_get_basename_for_display) (struct GeanyDocument *doc, gint length);
 	gint		(*document_get_notebook_page) (struct GeanyDocument *doc);
 	gint		(*document_compare_by_display_name) (gconstpointer a, gconstpointer b);
+	gint		(*document_compare_by_tab_order) (gconstpointer a, gconstpointer b);
+	gint		(*document_compare_by_tab_order_reverse) (gconstpointer a, gconstpointer b);
 }
 DocumentFuncs;
 

Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c	2011-04-15 16:59:15 UTC (rev 5726)
+++ trunk/src/plugins.c	2011-04-17 13:40:04 UTC (rev 5727)
@@ -112,7 +112,9 @@
 	&document_get_status_color,
 	&document_get_basename_for_display,
 	&document_get_notebook_page,
-	&document_compare_by_display_name
+	&document_compare_by_display_name,
+	&document_compare_by_tab_order,
+	&document_compare_by_tab_order_reverse
 };
 
 static EditorFuncs editor_funcs = {


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