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.
* 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>

View File

@ -42,7 +42,7 @@ GeanyData *geany_data;
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 *plugin_configure(GtkDialog *dialog)
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 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
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))

View File

@ -135,7 +135,6 @@ static void create_open_file_dialog(void)
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 @@ static void create_open_file_dialog(void)
/* 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);

View File

@ -1492,10 +1492,11 @@ GeanyFiletype *filetypes_index(gint idx)
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);
}

View File

@ -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. */

View File

@ -362,16 +362,15 @@ on_new_with_template (GtkMenuItem *menuitem,
/* 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);

View File

@ -2056,14 +2056,13 @@ void ui_menu_sort_by_label(GtkMenu *menu)
{
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);

View File

@ -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);