Kaydet (Commit) 9f8c5103 authored tarafından Enrico Tröger's avatar Enrico Tröger

Add document_compare_by_tab_order() and document_compare_by_tab_order_reverse() to the plugin API.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5727 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 0b2d16a4
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:
......
......@@ -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 \
......
......@@ -3043,3 +3043,61 @@ gint document_compare_by_display_name(gconstpointer a, gconstpointer b)
}
/** 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;
}
......@@ -261,4 +261,8 @@ void document_apply_indent_settings(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);
#endif
......@@ -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 @@ typedef struct DocumentFuncs
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;
......
......@@ -112,7 +112,9 @@ static DocumentFuncs doc_funcs = {
&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 = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment