Remove data_ptr argument to foreach_[s]list() macros, as using

node->data is enough sometimes; this makes the macro a bit more
efficient too.
Add foreach_[s]list() macros to the plugin API docs.



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3862 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2009-06-12 15:32:35 +00:00
parent 6dc41e053e
commit f56cad490e
8 changed files with 32 additions and 23 deletions

View File

@ -4,6 +4,12 @@
Fix type definitions being parsed as functions. Fix type definitions being parsed as functions.
* src/editor.c: * src/editor.c:
Don't autocomplete in unterminated strings as well. Don't autocomplete in unterminated strings as well.
* src/templates.c, src/utils.h, src/dialogs.c, src/plugindata.h,
src/filetypes.c, src/ui_utils.c, plugins/saveactions.c:
Remove data_ptr argument to foreach_[s]list() macros, as using
node->data is enough sometimes; this makes the macro a bit more
efficient too.
Add foreach_[s]list() macros to the plugin API docs.
2009-06-11 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2009-06-11 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -42,7 +42,7 @@ GeanyData *geany_data;
GeanyFunctions *geany_functions; GeanyFunctions *geany_functions;
PLUGIN_VERSION_CHECK(98) PLUGIN_VERSION_CHECK(GEANY_API_VERSION)
PLUGIN_SET_INFO(_("Save Actions"), _("This plugin provides different actions related to saving of files."), PLUGIN_SET_INFO(_("Save Actions"), _("This plugin provides different actions related to saving of files."),
VERSION, _("The Geany developer team")) VERSION, _("The Geany developer team"))
@ -604,7 +604,6 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
GtkWidget *combo; GtkWidget *combo;
guint i; guint i;
GSList *node; GSList *node;
GeanyFiletype *ft;
notebook_vbox = gtk_vbox_new(FALSE, 2); notebook_vbox = gtk_vbox_new(FALSE, 2);
inner_vbox = gtk_vbox_new(FALSE, 5); inner_vbox = gtk_vbox_new(FALSE, 5);
@ -627,8 +626,10 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
pref_widgets.instantsave_ft_combo = combo = gtk_combo_box_new_text(); pref_widgets.instantsave_ft_combo = combo = gtk_combo_box_new_text();
i = 0; i = 0;
foreach_slist(ft, node, geany->filetypes_by_title) foreach_slist(node, geany->filetypes_by_title)
{ {
GeanyFiletype *ft = node->data;
gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ft->name); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ft->name);
if (utils_str_equal(ft->name, instantsave_default_ft)) if (utils_str_equal(ft->name, instantsave_default_ft))

View File

@ -135,7 +135,6 @@ static void create_open_file_dialog(void)
GtkWidget *viewbtn; GtkWidget *viewbtn;
guint i; guint i;
gchar *encoding_string; gchar *encoding_string;
GeanyFiletype *ft;
GSList *node; GSList *node;
ui_widgets.open_filesel = gtk_file_chooser_dialog_new(_("Open File"), GTK_WINDOW(main_widgets.window), ui_widgets.open_filesel = gtk_file_chooser_dialog_new(_("Open File"), GTK_WINDOW(main_widgets.window),
@ -174,8 +173,10 @@ static void create_open_file_dialog(void)
/* now create meta filter "All Source" */ /* now create meta filter "All Source" */
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(ui_widgets.open_filesel), gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(ui_widgets.open_filesel),
filetypes_create_file_filter_all_source()); filetypes_create_file_filter_all_source());
foreach_slist(ft, node, filetypes_by_title) foreach_slist(node, filetypes_by_title)
{ {
GeanyFiletype *ft = node->data;
if (G_UNLIKELY(ft->id == GEANY_FILETYPES_NONE)) if (G_UNLIKELY(ft->id == GEANY_FILETYPES_NONE))
continue; continue;
gtk_combo_box_append_text(GTK_COMBO_BOX(filetype_combo), ft->title); gtk_combo_box_append_text(GTK_COMBO_BOX(filetype_combo), ft->title);

View File

@ -1492,10 +1492,11 @@ GeanyFiletype *filetypes_index(gint idx)
void filetypes_foreach_named(GFunc callback, gpointer user_data) void filetypes_foreach_named(GFunc callback, gpointer user_data)
{ {
GSList *node; GSList *node;
GeanyFiletype *ft;
foreach_slist(ft, node, filetypes_by_title) foreach_slist(node, filetypes_by_title)
{ {
GeanyFiletype *ft = node->data;
if (G_LIKELY(ft->id != GEANY_FILETYPES_NONE)) if (G_LIKELY(ft->id != GEANY_FILETYPES_NONE))
callback(ft, user_data); callback(ft, user_data);
} }

View File

@ -45,7 +45,7 @@
enum { enum {
/** The Application Programming Interface (API) version, incremented /** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */ * whenever any plugin data types are modified or appended to. */
GEANY_API_VERSION = 141, GEANY_API_VERSION = 142,
/** The Application Binary Interface (ABI) version, incremented whenever /** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */ * existing fields in the plugin data types have to be changed or reordered. */

View File

@ -362,16 +362,15 @@ on_new_with_template (GtkMenuItem *menuitem,
/* template items for the new file menu */ /* template items for the new file menu */
static void create_new_menu_items(void) static void create_new_menu_items(void)
{ {
GeanyFiletype *ft;
GSList *node; GSList *node;
foreach_slist(ft, node, filetypes_by_title) foreach_slist(node, filetypes_by_title)
{ {
filetype_id ft_id = ft->id; GeanyFiletype *ft = node->data;
GtkWidget *tmp_menu, *tmp_button; GtkWidget *tmp_menu, *tmp_button;
const gchar *label = ft->title; const gchar *label = ft->title;
if (ft_templates[ft_id] == NULL) if (ft_templates[ft->id] == NULL)
continue; continue;
tmp_menu = gtk_menu_item_new_with_label(label); tmp_menu = gtk_menu_item_new_with_label(label);

View File

@ -2056,14 +2056,13 @@ void ui_menu_sort_by_label(GtkMenu *menu)
{ {
GList *list = gtk_container_get_children(GTK_CONTAINER(menu)); GList *list = gtk_container_get_children(GTK_CONTAINER(menu));
GList *node; GList *node;
GtkWidget *child;
gint pos; gint pos;
list = g_list_sort(list, compare_menu_item_labels); list = g_list_sort(list, compare_menu_item_labels);
pos = 0; pos = 0;
foreach_list(child, node, list) foreach_list(node, list)
{ {
gtk_menu_reorder_child(menu, child, pos); gtk_menu_reorder_child(menu, node->data, pos);
pos++; pos++;
} }
g_list_free(list); g_list_free(list);

View File

@ -57,15 +57,17 @@
for (ptr = ptr_array->pdata, item = *ptr; \ for (ptr = ptr_array->pdata, item = *ptr; \
ptr < &ptr_array->pdata[ptr_array->len]; ++ptr, item = *ptr) ptr < &ptr_array->pdata[ptr_array->len]; ++ptr, item = *ptr)
/* @param node should be a (GSList*), needed for implementation. */ /** Iterates all the nodes in @a list.
#define foreach_slist(data_ptr, node, list) \ * @param node should be a (GList*).
for (node = list, data_ptr = node ? node->data : NULL; node != NULL; \ * @param list List to traverse. */
node = g_slist_next(node), data_ptr = node ? node->data : NULL) #define foreach_list(node, list) \
for (node = list; node != NULL; node = node->next)
/* @param node should be a (GList*), needed for implementation. */ /** Iterates all the nodes in @a list.
#define foreach_list(data_ptr, node, list) \ * @param node should be a (GSList*).
for (node = list, data_ptr = node ? node->data : NULL; node != NULL; \ * @param list List to traverse. */
node = g_list_next(node), data_ptr = node ? node->data : NULL) #define foreach_slist(node, list) \
foreach_list(node, list)
void utils_open_browser(const gchar *uri); void utils_open_browser(const gchar *uri);