Revision: 3862 http://geany.svn.sourceforge.net/geany/?rev=3862&view=rev Author: ntrel Date: 2009-06-12 15:32:35 +0000 (Fri, 12 Jun 2009)
Log Message: ----------- 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.
Modified Paths: -------------- trunk/ChangeLog trunk/plugins/saveactions.c trunk/src/dialogs.c trunk/src/filetypes.c trunk/src/plugindata.h trunk/src/templates.c trunk/src/ui_utils.c trunk/src/utils.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-06-12 15:22:32 UTC (rev 3861) +++ trunk/ChangeLog 2009-06-12 15:32:35 UTC (rev 3862) @@ -4,6 +4,12 @@ Fix type definitions being parsed as functions. * src/editor.c: 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>
Modified: trunk/plugins/saveactions.c =================================================================== --- trunk/plugins/saveactions.c 2009-06-12 15:22:32 UTC (rev 3861) +++ trunk/plugins/saveactions.c 2009-06-12 15:32:35 UTC (rev 3862) @@ -42,7 +42,7 @@ 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."), VERSION, _("The Geany developer team")) @@ -604,7 +604,6 @@ GtkWidget *combo; guint i; GSList *node; - GeanyFiletype *ft;
notebook_vbox = gtk_vbox_new(FALSE, 2); inner_vbox = gtk_vbox_new(FALSE, 5); @@ -627,8 +626,10 @@
pref_widgets.instantsave_ft_combo = combo = gtk_combo_box_new_text(); 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);
if (utils_str_equal(ft->name, instantsave_default_ft))
Modified: trunk/src/dialogs.c =================================================================== --- trunk/src/dialogs.c 2009-06-12 15:22:32 UTC (rev 3861) +++ trunk/src/dialogs.c 2009-06-12 15:32:35 UTC (rev 3862) @@ -135,7 +135,6 @@ GtkWidget *viewbtn; guint i; gchar *encoding_string; - GeanyFiletype *ft; GSList *node;
ui_widgets.open_filesel = gtk_file_chooser_dialog_new(_("Open File"), GTK_WINDOW(main_widgets.window), @@ -174,8 +173,10 @@ /* now create meta filter "All Source" */ gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(ui_widgets.open_filesel), 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)) continue; gtk_combo_box_append_text(GTK_COMBO_BOX(filetype_combo), ft->title);
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2009-06-12 15:22:32 UTC (rev 3861) +++ trunk/src/filetypes.c 2009-06-12 15:32:35 UTC (rev 3862) @@ -1492,10 +1492,11 @@ void filetypes_foreach_named(GFunc callback, gpointer user_data) { 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)) callback(ft, user_data); }
Modified: trunk/src/plugindata.h =================================================================== --- trunk/src/plugindata.h 2009-06-12 15:22:32 UTC (rev 3861) +++ trunk/src/plugindata.h 2009-06-12 15:32:35 UTC (rev 3862) @@ -45,7 +45,7 @@ enum { /** The Application Programming Interface (API) version, incremented * 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 * existing fields in the plugin data types have to be changed or reordered. */
Modified: trunk/src/templates.c =================================================================== --- trunk/src/templates.c 2009-06-12 15:22:32 UTC (rev 3861) +++ trunk/src/templates.c 2009-06-12 15:32:35 UTC (rev 3862) @@ -362,16 +362,15 @@ /* template items for the new file menu */ static void create_new_menu_items(void) { - GeanyFiletype *ft; 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; const gchar *label = ft->title;
- if (ft_templates[ft_id] == NULL) + if (ft_templates[ft->id] == NULL) continue;
tmp_menu = gtk_menu_item_new_with_label(label);
Modified: trunk/src/ui_utils.c =================================================================== --- trunk/src/ui_utils.c 2009-06-12 15:22:32 UTC (rev 3861) +++ trunk/src/ui_utils.c 2009-06-12 15:32:35 UTC (rev 3862) @@ -2056,14 +2056,13 @@ { GList *list = gtk_container_get_children(GTK_CONTAINER(menu)); GList *node; - GtkWidget *child; gint pos;
list = g_list_sort(list, compare_menu_item_labels); 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++; } g_list_free(list);
Modified: trunk/src/utils.h =================================================================== --- trunk/src/utils.h 2009-06-12 15:22:32 UTC (rev 3861) +++ trunk/src/utils.h 2009-06-12 15:32:35 UTC (rev 3862) @@ -57,15 +57,17 @@ for (ptr = ptr_array->pdata, item = *ptr; \ ptr < &ptr_array->pdata[ptr_array->len]; ++ptr, item = *ptr)
-/* @param node should be a (GSList*), needed for implementation. */ -#define foreach_slist(data_ptr, node, list) \ - for (node = list, data_ptr = node ? node->data : NULL; node != NULL; \ - node = g_slist_next(node), data_ptr = node ? node->data : NULL) +/** Iterates all the nodes in @a list. + * @param node should be a (GList*). + * @param list List to traverse. */ +#define foreach_list(node, list) \ + for (node = list; node != NULL; node = node->next)
-/* @param node should be a (GList*), needed for implementation. */ -#define foreach_list(data_ptr, node, list) \ - for (node = list, data_ptr = node ? node->data : NULL; node != NULL; \ - node = g_list_next(node), data_ptr = node ? node->data : NULL) +/** Iterates all the nodes in @a list. + * @param node should be a (GSList*). + * @param list List to traverse. */ +#define foreach_slist(node, list) \ + foreach_list(node, list)
void utils_open_browser(const gchar *uri);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.