diff --git a/extensions/adblock.c b/extensions/adblock.c index 46a244a0..12a68e5e 100644 --- a/extensions/adblock.c +++ b/extensions/adblock.c @@ -1367,7 +1367,6 @@ adblock_activate_cb (MidoriExtension* extension, #endif KatzeArray* browsers; MidoriBrowser* browser; - guint i; #if !HAVE_WEBKIT_RESOURCE_REQUEST SoupSession* session = webkit_get_default_session (); @@ -1391,8 +1390,7 @@ adblock_activate_cb (MidoriExtension* extension, adblock_reload_rules (extension, FALSE); browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) adblock_app_add_browser_cb (app, browser, extension); g_signal_connect (app, "add-browser", G_CALLBACK (adblock_app_add_browser_cb), extension); diff --git a/extensions/addons.c b/extensions/addons.c index 4eff71cf..3c62c39a 100644 --- a/extensions/addons.c +++ b/extensions/addons.c @@ -1447,13 +1447,12 @@ addons_deactivate_cb (MidoriExtension* extension, KatzeArray* browsers; MidoriBrowser* browser; GSource* source; - guint i = 0; addons_disable_monitors (extension); addons_save_settings (NULL, extension); browsers = katze_object_get_object (app, "browsers"); - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) addons_browser_destroy (browser, extension); source = g_object_get_data (G_OBJECT (extension), "monitor-timer"); @@ -1556,7 +1555,6 @@ addons_activate_cb (MidoriExtension* extension, { KatzeArray* browsers; MidoriBrowser* browser; - guint i; browsers = katze_object_get_object (app, "browsers"); addons_update_elements (extension, ADDONS_USER_STYLES); @@ -1564,8 +1562,7 @@ addons_activate_cb (MidoriExtension* extension, addons_update_elements (extension, ADDONS_USER_SCRIPTS); addons_monitor_directories (extension, ADDONS_USER_SCRIPTS); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) addons_app_add_browser_cb (app, browser, extension); g_object_unref (browsers); diff --git a/extensions/colorful-tabs.c b/extensions/colorful-tabs.c index d9c108ef..5979f4e6 100644 --- a/extensions/colorful-tabs.c +++ b/extensions/colorful-tabs.c @@ -185,11 +185,9 @@ colorful_tabs_activate_cb (MidoriExtension* extension, { KatzeArray* browsers; MidoriBrowser* browser; - guint i; browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) colorful_tabs_app_add_browser_cb (app, browser, extension); g_signal_connect (app, "add-browser", G_CALLBACK (colorful_tabs_app_add_browser_cb), extension); diff --git a/extensions/cookie-manager/cookie-manager.c b/extensions/cookie-manager/cookie-manager.c index dc256722..70a4f7aa 100644 --- a/extensions/cookie-manager/cookie-manager.c +++ b/extensions/cookie-manager/cookie-manager.c @@ -315,7 +315,6 @@ CookieManager *cookie_manager_new(MidoriExtension *extension, MidoriApp *app) { CookieManager *cm; CookieManagerPrivate *priv; - guint i; KatzeArray *browsers; MidoriBrowser *browser; @@ -327,8 +326,7 @@ CookieManager *cookie_manager_new(MidoriExtension *extension, MidoriApp *app) /* add the cookie manager panel page to existing browsers */ browsers = katze_object_get_object(app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item(browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) cookie_manager_app_add_browser_cb(app, browser, cm); g_object_unref(browsers); diff --git a/extensions/copy-tabs.c b/extensions/copy-tabs.c index 2734ec54..60fe2dbc 100644 --- a/extensions/copy-tabs.c +++ b/extensions/copy-tabs.c @@ -80,11 +80,9 @@ copy_tabs_activate_cb (MidoriExtension* extension, { KatzeArray* browsers; MidoriBrowser* browser; - guint i; browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) copy_tabs_app_add_browser_cb (app, browser, extension); g_object_unref (browsers); g_signal_connect (app, "add-browser", diff --git a/extensions/feed-panel/feed-panel.c b/extensions/feed-panel/feed-panel.c index 26fbb261..2241ad70 100644 --- a/extensions/feed-panel/feed-panel.c +++ b/extensions/feed-panel/feed-panel.c @@ -271,7 +271,6 @@ feed_panel_disconnect_feed (FeedPanel* panel, KatzeArray* feed) { KatzeItem* item; - guint i; g_return_if_fail (KATZE_IS_ARRAY (feed)); @@ -282,8 +281,7 @@ feed_panel_disconnect_feed (FeedPanel* panel, g_signal_handlers_disconnect_by_func (feed, feed_panel_move_item_cb, panel); - i = 0; - while ((item = katze_array_get_nth_item (feed, i++))) + KATZE_ARRAY_FOREACH_ITEM (item, feed) { if (KATZE_IS_ARRAY (item)) feed_panel_disconnect_feed (panel, KATZE_ARRAY (item)); diff --git a/extensions/feed-panel/main.c b/extensions/feed-panel/main.c index 2e46c784..14c4f826 100644 --- a/extensions/feed-panel/main.c +++ b/extensions/feed-panel/main.c @@ -157,18 +157,18 @@ feed_save_items (MidoriExtension* extension, { KatzeItem* item; gchar** sfeeds; - gint i; - gint n; + gint i, n; g_return_if_fail (KATZE_IS_ARRAY (feed)); n = katze_array_get_length (feed); sfeeds = g_new (gchar*, n + 1); - for (i = 0; i < n; i++) + i = 0; + KATZE_ARRAY_FOREACH_ITEM (item, feed) { - item = katze_array_get_nth_item (feed, i); sfeeds[i] = (gchar*) katze_item_get_uri (KATZE_ITEM (item)); + i++; } sfeeds[n] = NULL; @@ -498,11 +498,9 @@ feed_activate_cb (MidoriExtension* extension, { KatzeArray* browsers; MidoriBrowser* browser; - guint i; browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) feed_app_add_browser_cb (app, browser, extension); g_object_unref (browsers); diff --git a/extensions/formhistory.c b/extensions/formhistory.c index 446e534b..44958a3f 100644 --- a/extensions/formhistory.c +++ b/extensions/formhistory.c @@ -425,7 +425,6 @@ formhistory_activate_cb (MidoriExtension* extension, char* errmsg = NULL, *errmsg2 = NULL; KatzeArray* browsers; MidoriBrowser* browser; - guint i; global_keys = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, @@ -464,8 +463,7 @@ formhistory_activate_cb (MidoriExtension* extension, } browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) formhistory_app_add_browser_cb (app, browser, extension); g_signal_connect (app, "add-browser", G_CALLBACK (formhistory_app_add_browser_cb), extension); diff --git a/extensions/mouse-gestures.c b/extensions/mouse-gestures.c index c3c93bf0..9a7d738a 100644 --- a/extensions/mouse-gestures.c +++ b/extensions/mouse-gestures.c @@ -281,14 +281,12 @@ mouse_gestures_activate_cb (MidoriExtension* extension, { KatzeArray* browsers; MidoriBrowser* browser; - guint i; gesture = mouse_gesture_new (); gesture->button = midori_extension_get_integer (extension, "button"); browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) mouse_gestures_app_add_browser_cb (app, browser, extension); g_signal_connect (app, "add-browser", G_CALLBACK (mouse_gestures_app_add_browser_cb), extension); diff --git a/extensions/page-holder.c b/extensions/page-holder.c index 9c6f0f14..b3374421 100644 --- a/extensions/page-holder.c +++ b/extensions/page-holder.c @@ -139,11 +139,9 @@ page_holder_activate_cb (MidoriExtension* extension, { KatzeArray* browsers; MidoriBrowser* browser; - guint i; browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) page_holder_app_add_browser_cb (app, browser, extension); g_object_unref (browsers); g_signal_connect (app, "add-browser", diff --git a/extensions/shortcuts.c b/extensions/shortcuts.c index 3ff55788..12671fa3 100644 --- a/extensions/shortcuts.c +++ b/extensions/shortcuts.c @@ -297,11 +297,9 @@ shortcuts_activate_cb (MidoriExtension* extension, { KatzeArray* browsers; MidoriBrowser* browser; - guint i; browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) shortcuts_app_add_browser_cb (app, browser, extension); g_signal_connect (app, "add-browser", G_CALLBACK (shortcuts_app_add_browser_cb), extension); diff --git a/extensions/status-clock.c b/extensions/status-clock.c index c30f1cf0..68bf1f2c 100644 --- a/extensions/status-clock.c +++ b/extensions/status-clock.c @@ -131,10 +131,9 @@ clock_deactivate_cb (MidoriExtension* extension, KatzeArray* browsers; MidoriBrowser* browser; GtkWidget* label; - guint i = 0; browsers = katze_object_get_object (app, "browsers"); - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) { clock_browser_destroy_cb (browser, NULL); label = g_object_get_data (G_OBJECT (browser), "clock-label"); @@ -155,10 +154,9 @@ clock_activate_cb (MidoriExtension* extension, { KatzeArray* browsers; MidoriBrowser* browser; - guint i = 0; browsers = katze_object_get_object (app, "browsers"); - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) clock_app_add_browser_cb (app, browser, extension); g_signal_connect (app, "add-browser", G_CALLBACK (clock_app_add_browser_cb), extension); diff --git a/extensions/statusbar-features.c b/extensions/statusbar-features.c index 58b99fa4..9a6b0665 100644 --- a/extensions/statusbar-features.c +++ b/extensions/statusbar-features.c @@ -131,11 +131,9 @@ statusbar_features_activate_cb (MidoriExtension* extension, { KatzeArray* browsers; MidoriBrowser* browser; - guint i; browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) statusbar_features_app_add_browser_cb (app, browser, extension); g_signal_connect (app, "add-browser", G_CALLBACK (statusbar_features_app_add_browser_cb), extension); diff --git a/extensions/tab-panel.c b/extensions/tab-panel.c index beabcda5..a358818a 100644 --- a/extensions/tab-panel.c +++ b/extensions/tab-panel.c @@ -590,11 +590,9 @@ tab_panel_activate_cb (MidoriExtension* extension, { KatzeArray* browsers; MidoriBrowser* browser; - guint i; browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) tab_panel_app_add_browser_cb (app, browser, extension); g_object_unref (browsers); g_signal_connect (app, "add-browser", diff --git a/extensions/tabs-minimized.c b/extensions/tabs-minimized.c index 993625ed..f5130ee3 100644 --- a/extensions/tabs-minimized.c +++ b/extensions/tabs-minimized.c @@ -61,11 +61,9 @@ tabs_minimized_activate_cb (MidoriExtension* extension, { KatzeArray* browsers; MidoriBrowser* browser; - guint i; browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) tabs_minimized_app_add_browser_cb (app, browser, extension); g_object_unref (browsers); g_signal_connect (app, "add-browser", diff --git a/extensions/toolbar-editor.c b/extensions/toolbar-editor.c index b8b0e005..d5f1ea85 100644 --- a/extensions/toolbar-editor.c +++ b/extensions/toolbar-editor.c @@ -592,11 +592,9 @@ static void tb_editor_activate_cb(MidoriExtension *extension, MidoriApp *app) { KatzeArray *browsers; MidoriBrowser *browser; - guint i; browsers = katze_object_get_object(app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item(browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) tb_editor_app_add_browser_cb(app, browser, extension); g_signal_connect(app, "add-browser", G_CALLBACK(tb_editor_app_add_browser_cb), extension); g_object_unref(browsers); diff --git a/extensions/web-cache.c b/extensions/web-cache.c index 33c34299..884e083a 100644 --- a/extensions/web-cache.c +++ b/extensions/web-cache.c @@ -438,7 +438,6 @@ web_cache_activate_cb (MidoriExtension* extension, const gchar* cache_path = midori_extension_get_string (extension, "path"); KatzeArray* browsers; MidoriBrowser* browser; - guint i; SoupSession* session = webkit_get_default_session (); katze_mkdir_with_parents (cache_path, 0700); @@ -446,8 +445,7 @@ web_cache_activate_cb (MidoriExtension* extension, G_CALLBACK (web_cache_session_request_queued_cb), extension); browsers = katze_object_get_object (app, "browsers"); - i = 0; - while ((browser = katze_array_get_nth_item (browsers, i++))) + KATZE_ARRAY_FOREACH_ITEM (browser, browsers) web_cache_app_add_browser_cb (app, browser, extension); g_signal_connect (app, "add-browser", G_CALLBACK (web_cache_app_add_browser_cb), extension); diff --git a/katze/katze-array.c b/katze/katze-array.c index 44b77501..9cf0cbaa 100644 --- a/katze/katze-array.c +++ b/katze/katze-array.c @@ -479,6 +479,12 @@ katze_array_get_items (KatzeArray* array) return g_list_copy (array->items); } +GList* +katze_array_peek_items (KatzeArray* array) +{ + return array->items; +} + /** * katze_array_clear: * @array: a #KatzeArray diff --git a/katze/katze-array.h b/katze/katze-array.h index 17d203d8..f54f66ba 100644 --- a/katze/katze-array.h +++ b/katze/katze-array.h @@ -80,6 +80,17 @@ katze_array_move_item (KatzeArray* array, GList* katze_array_get_items (KatzeArray* array); +GList* +katze_array_peek_items (KatzeArray* array); + +GList* kalistglobal; +#define KATZE_ARRAY_FOREACH_ITEM(kaitem, kaarray) \ + for (kalistglobal = katze_array_peek_items (kaarray), \ + kaitem = kalistglobal ? kalistglobal->data : NULL; \ + kalistglobal != NULL; \ + kalistglobal = g_list_next (kalistglobal), \ + kaitem = kalistglobal ? kalistglobal->data : NULL) + void katze_array_clear (KatzeArray* array); diff --git a/katze/katze-utils.c b/katze/katze-utils.c index b43869d6..cde82348 100644 --- a/katze/katze-utils.c +++ b/katze/katze-utils.c @@ -1136,9 +1136,8 @@ katze_bookmark_populate_tree_view (KatzeArray* array, KatzeItem* child; GtkTreeIter iter; GtkTreeIter root_iter; - guint i = 0; - while ((child = katze_array_get_nth_item (KATZE_ARRAY (array), i))) + KATZE_ARRAY_FOREACH_ITEM (child, array) { if (KATZE_ITEM_IS_BOOKMARK (child)) { @@ -1155,7 +1154,6 @@ katze_bookmark_populate_tree_view (KatzeArray* array, gtk_tree_store_insert_with_values (model, &iter, &root_iter, 0, 0, NULL, -1); } - i++; } } diff --git a/midori/main.c b/midori/main.c index 5f9cd151..5f464f18 100644 --- a/midori/main.c +++ b/midori/main.c @@ -244,8 +244,7 @@ settings_save_to_file (MidoriWebSettings* settings, if (extensions) { - i = 0; - while ((extension = katze_array_get_nth_item (extensions, i++))) + KATZE_ARRAY_FOREACH_ITEM (extension, extensions) if (midori_extension_is_active (extension)) g_key_file_set_boolean (key_file, "extensions", g_object_get_data (G_OBJECT (extension), "filename"), TRUE); @@ -315,7 +314,7 @@ search_engines_save_to_file (KatzeArray* search_engines, GError** error) { GKeyFile* key_file; - guint i, j, n_properties; + guint j, n_properties; KatzeItem* item; const gchar* name; GParamSpec** pspecs; @@ -326,8 +325,7 @@ search_engines_save_to_file (KatzeArray* search_engines, key_file = g_key_file_new (); pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (search_engines), &n_properties); - i = 0; - while ((item = katze_array_get_nth_item (search_engines, i++))) + KATZE_ARRAY_FOREACH_ITEM (item, search_engines) { name = katze_item_get_name (item); for (j = 0; j < n_properties; j++) @@ -508,8 +506,7 @@ static void midori_session_add_delay (KatzeArray* session) { KatzeItem* item; - gint i = 0; - while ((item = katze_array_get_nth_item (session, i++))) + KATZE_ARRAY_FOREACH_ITEM (item, session) katze_item_set_meta_integer (item, "delay", 1); } @@ -1196,9 +1193,8 @@ midori_browser_action_last_session_activate_cb (GtkAction* action, GError* error = NULL; if (midori_array_from_file (old_session, config_file, "xbel", &error)) { - guint i = 0; KatzeItem* item; - while ((item = katze_array_get_nth_item (old_session, i++))) + KATZE_ARRAY_FOREACH_ITEM (item, old_session) midori_browser_add_item (browser, item); } else @@ -1223,7 +1219,6 @@ midori_load_session (gpointer data) gchar* config_file; KatzeArray* session; KatzeItem* item; - guint i; gint64 current; MidoriStartup load_on_startup; gchar** command = g_object_get_data (G_OBJECT (app), "execute-command"); @@ -1277,8 +1272,7 @@ midori_load_session (gpointer data) midori_session_add_delay (_session); session = midori_browser_get_proxy_array (browser); - i = 0; - while ((item = katze_array_get_nth_item (_session, i++))) + KATZE_ARRAY_FOREACH_ITEM (item, _session) { g_object_set_data (G_OBJECT (item), "midori-view-append", (void*)1); midori_browser_add_item (browser, item); @@ -2056,8 +2050,7 @@ main (int argc, G_CALLBACK (midori_search_engines_modify_cb), search_engines); if (!katze_array_is_empty (search_engines)) { - i = 0; - while ((item = katze_array_get_nth_item (search_engines, i++))) + KATZE_ARRAY_FOREACH_ITEM (item, search_engines) g_signal_connect_after (item, "notify", G_CALLBACK (midori_search_engines_modify_cb), search_engines); } diff --git a/midori/midori-array.c b/midori/midori-array.c index e8ca484b..25c68d01 100644 --- a/midori/midori-array.c +++ b/midori/midori-array.c @@ -589,7 +589,6 @@ string_append_item (GString* string, metadata = katze_item_metadata_to_xbel (item); if (KATZE_IS_ARRAY (item)) { - guint i = 0; KatzeItem* _item; KatzeArray* array = KATZE_ARRAY (item); @@ -597,7 +596,7 @@ string_append_item (GString* string, /* FIXME: " folded=\"no\" */ string_append_xml_element (string, "title", katze_item_get_name (item)); string_append_xml_element (string, "desc", katze_item_get_text (item)); - while ((_item = katze_array_get_nth_item (array, i++))) + KATZE_ARRAY_FOREACH_ITEM (_item, array) string_append_item (string, _item); g_string_append (string, metadata); g_string_append (string, "\n"); @@ -679,7 +678,6 @@ katze_array_to_xbel (KatzeArray* array, GError** error) { gchar* metadata = katze_item_metadata_to_xbel (KATZE_ITEM (array)); - guint i; KatzeItem* item; GString* markup = g_string_new ( @@ -693,8 +691,7 @@ katze_array_to_xbel (KatzeArray* array, string_append_xml_element (markup, "title", katze_item_get_name (KATZE_ITEM (array))); string_append_xml_element (markup, "desc", katze_item_get_text (KATZE_ITEM (array))); g_string_append (markup, metadata); - i = 0; - while ((item = katze_array_get_nth_item (array, i++))) + KATZE_ARRAY_FOREACH_ITEM (item, array) string_append_item (markup, item); g_string_append (markup, "\n"); diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 05c9b336..dfa00700 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -3764,16 +3764,14 @@ midori_browser_bookmark_open_in_tab_activate_cb (GtkWidget* menuitem, if (KATZE_IS_ARRAY (item)) { KatzeItem* child; - guint i = 0; - while ((child = katze_array_get_nth_item (KATZE_ARRAY (item), i))) + KATZE_ARRAY_FOREACH_ITEM (child, KATZE_ARRAY (item)) { if ((uri = katze_item_get_uri (child)) && *uri) { n = midori_browser_add_item (browser, child); midori_browser_set_current_page_smartly (browser, n); } - i++; } } else @@ -4016,8 +4014,7 @@ _action_bookmarks_import_activate (GtkAction* action, db = g_object_get_data (G_OBJECT (browser->bookmarks), "db"); sqlcmd = "SELECT title from bookmarks where uri=''"; bookmarkdirs = katze_array_from_sqlite (db, sqlcmd); - i = 0; - while ((item = katze_array_get_nth_item (bookmarkdirs, i++))) + KATZE_ARRAY_FOREACH_ITEM (item, bookmarkdirs) { const gchar* name = katze_item_get_name (item); gtk_combo_box_append_text (combobox_folder, name); @@ -6145,16 +6142,13 @@ _midori_browser_update_settings (MidoriBrowser* browser) if (browser->search_engines) { - guint i; - item = katze_array_get_nth_item (browser->search_engines, last_web_search); if (item) midori_search_action_set_current_item (MIDORI_SEARCH_ACTION ( _action_by_name (browser, "Search")), item); - i = 0; - while ((item = katze_array_get_nth_item (browser->search_engines, i++))) + KATZE_ARRAY_FOREACH_ITEM (item, browser->search_engines) if (!g_strcmp0 (katze_item_get_uri (item), browser->location_entry_search)) { midori_search_action_set_default_item (MIDORI_SEARCH_ACTION ( @@ -6330,7 +6324,6 @@ midori_bookmarkbar_populate (MidoriBrowser* browser) const gchar* sqlcmd; KatzeArray* array; KatzeItem* item; - gint i = 0; midori_bookmarkbar_clear (browser->bookmarkbar); @@ -6353,7 +6346,7 @@ midori_bookmarkbar_populate (MidoriBrowser* browser) return; } - while ((item = katze_array_get_nth_item (KATZE_ARRAY (array), i))) + KATZE_ARRAY_FOREACH_ITEM (item, array) { if (KATZE_ITEM_IS_BOOKMARK (item)) midori_bookmarkbar_insert_item (browser->bookmarkbar, item); @@ -6369,7 +6362,6 @@ midori_bookmarkbar_populate (MidoriBrowser* browser) midori_bookmarkbar_insert_item (browser->bookmarkbar, KATZE_ITEM (subfolder)); g_free (subsqlcmd); } - i++; } _action_set_sensitive (browser, "BookmarkAdd", TRUE); _action_set_sensitive (browser, "BookmarkFolderAdd", TRUE); @@ -6476,8 +6468,6 @@ midori_browser_set_property (GObject* object, break; case PROP_SEARCH_ENGINES: { - guint i; - /* FIXME: Disconnect handlers */ katze_object_assign (browser->search_engines, g_value_dup_object (value)); if (katze_object_get_boolean (browser->settings, @@ -6498,8 +6488,7 @@ midori_browser_set_property (GObject* object, midori_search_action_set_current_item (MIDORI_SEARCH_ACTION ( _action_by_name (browser, "Search")), item); - i = 0; - while ((item = katze_array_get_nth_item (browser->search_engines, i++))) + KATZE_ARRAY_FOREACH_ITEM (item, browser->search_engines) if (!g_strcmp0 (katze_item_get_uri (item), browser->location_entry_search)) { midori_search_action_set_default_item (MIDORI_SEARCH_ACTION ( diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 0e54d31e..cecda90e 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -486,9 +486,9 @@ midori_location_action_popup_timeout_cb (gpointer data) if (action->search_engines) { - gint i = 0; KatzeItem* item; - while ((item = katze_array_get_nth_item (action->search_engines, i))) + i = 0; + KATZE_ARRAY_FOREACH_ITEM (item, action->search_engines) { gchar* uri; gchar* title; diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c index f49fd14b..6c4da389 100644 --- a/midori/midori-searchaction.c +++ b/midori/midori-searchaction.c @@ -436,7 +436,6 @@ midori_search_action_icon_released_cb (GtkWidget* entry, { KatzeArray* search_engines; GtkWidget* menu; - guint i; GtkWidget* menuitem; KatzeItem* item; GdkPixbuf* icon; @@ -447,10 +446,9 @@ midori_search_action_icon_released_cb (GtkWidget* entry, search_engines = MIDORI_SEARCH_ACTION (action)->search_engines; menu = gtk_menu_new (); - i = 0; - if ((item = katze_array_get_nth_item (search_engines, i))) + if (!katze_array_is_empty (search_engines)) { - do + KATZE_ARRAY_FOREACH_ITEM (item, search_engines) { const gchar* icon_name; @@ -477,7 +475,6 @@ midori_search_action_icon_released_cb (GtkWidget* entry, G_CALLBACK (midori_search_action_engine_activate_cb), action); gtk_widget_show (menuitem); } - while ((item = katze_array_get_nth_item (search_engines, ++i))); } else { @@ -1304,7 +1301,7 @@ midori_search_action_get_dialog (MidoriSearchAction* search_action) gtk_box_pack_start (GTK_BOX (hbox), scrolled, TRUE, TRUE, 5); i = 0; if (search_action->search_engines) - while ((item = katze_array_get_nth_item (search_action->search_engines, i))) + KATZE_ARRAY_FOREACH_ITEM (item, search_action->search_engines) gtk_list_store_insert_with_values (GTK_LIST_STORE (liststore), NULL, i++, 0, item, -1); g_object_unref (liststore); diff --git a/midori/midori-view.c b/midori/midori-view.c index a4db75da..4ecd00dd 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -2226,7 +2226,7 @@ midori_view_populate_popup (MidoriView* view, gtk_menu_shell_insert (menu_shell, menuitem, 1); search_engines = katze_object_get_object (window, "search-engines"); - while ((item = katze_array_get_nth_item (search_engines, i++))) + KATZE_ARRAY_FOREACH_ITEM (item, search_engines) { GdkPixbuf* pixbuf; const gchar* icon_name; @@ -2246,11 +2246,12 @@ midori_view_populate_popup (MidoriView* view, gtk_image_menu_item_set_always_show_image ( GTK_IMAGE_MENU_ITEM (menuitem), TRUE); #endif - gtk_menu_shell_insert (GTK_MENU_SHELL (sub_menu), menuitem, i - 1); + gtk_menu_shell_insert (GTK_MENU_SHELL (sub_menu), menuitem, i); g_object_set_data (G_OBJECT (menuitem), "search", (gchar*)katze_item_get_uri (item)); g_signal_connect (menuitem, "activate", G_CALLBACK (midori_web_view_menu_search_web_activate_cb), view); + i++; } g_object_unref (search_engines); } diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c index 339c9d4e..b843e4f8 100644 --- a/panels/midori-bookmarks.c +++ b/panels/midori-bookmarks.c @@ -131,13 +131,12 @@ midori_bookmarks_export_array_db (sqlite3* db, KatzeArray* root_array; KatzeArray* subarray; KatzeItem* item; - int i = 0; sqlcmd = g_strdup_printf ("SELECT * FROM bookmarks where folder='%s'", folder); root_array = katze_array_from_sqlite (db, sqlcmd); g_free (sqlcmd); - while ((item = katze_array_get_nth_item (KATZE_ARRAY (root_array), i++))) + KATZE_ARRAY_FOREACH_ITEM (item, root_array) { if (KATZE_ITEM_IS_FOLDER (item)) { @@ -156,17 +155,12 @@ midori_bookmarks_import_array_db (sqlite3* db, KatzeArray* array, const gchar* folder) { - GList* list = NULL; - GList* bookmarks; + KatzeItem* item; - bookmarks = katze_array_get_items ((KatzeArray*)array); - for (list = bookmarks; list != NULL; list = g_list_next (list)) + KATZE_ARRAY_FOREACH_ITEM (item, array) { - KatzeItem* item; - - if (KATZE_IS_ARRAY (list->data)) - midori_bookmarks_import_array_db (db, list->data, folder); - item = (KatzeItem*) list->data; + if (KATZE_IS_ARRAY (item)) + midori_bookmarks_import_array_db (db, KATZE_ARRAY (item), folder); midori_bookmarks_insert_item_db (db, item, folder); } } @@ -660,11 +654,10 @@ midori_bookmarks_open_in_tab_activate_cb (GtkWidget* menuitem, { KatzeItem* child; KatzeArray* array; - guint i = 0; array = midori_bookmarks_read_from_db (bookmarks, katze_item_get_name (item), NULL); g_return_if_fail (KATZE_IS_ARRAY (array)); - while ((child = katze_array_get_nth_item (KATZE_ARRAY (array), i))) + KATZE_ARRAY_FOREACH_ITEM (child, array) { if ((uri = katze_item_get_uri (child)) && *uri) { @@ -674,7 +667,6 @@ midori_bookmarks_open_in_tab_activate_cb (GtkWidget* menuitem, n = midori_browser_add_item (browser, child); midori_browser_set_current_page_smartly (browser, n); } - i++; } } else if ((uri = katze_item_get_uri (item)) && *uri) diff --git a/panels/midori-extensions.c b/panels/midori-extensions.c index f1702ea3..847ff0c3 100644 --- a/panels/midori-extensions.c +++ b/panels/midori-extensions.c @@ -167,7 +167,6 @@ midori_extensions_set_property (GObject* object, { KatzeArray* array; MidoriExtension* extension; - guint i; /* FIXME: Handle NULL and subsequent assignments */ extensions->app = g_value_get_object (value); @@ -175,8 +174,7 @@ midori_extensions_set_property (GObject* object, g_signal_connect (array, "add-item", G_CALLBACK (midori_extensions_add_item_cb), extensions); - i = 0; - while ((extension = katze_array_get_nth_item (array, i++))) + KATZE_ARRAY_FOREACH_ITEM (extension, array) midori_extensions_add_item_cb (array, extension, extensions); /* Hide if there are no extensions at all */ @@ -379,10 +377,9 @@ midori_extensions_finalize (GObject* object) { MidoriExtensions* extensions = MIDORI_EXTENSIONS (object); KatzeArray* array = katze_object_get_object (extensions->app, "extensions"); - guint i = 0; MidoriExtension* extension; - while ((extension = katze_array_get_nth_item (array, i++))) + KATZE_ARRAY_FOREACH_ITEM (extension, array) { g_signal_handlers_disconnect_by_func (extension, midori_extensions_extension_activate_cb, extensions); diff --git a/panels/midori-history.c b/panels/midori-history.c index 0ccf7950..2186721c 100644 --- a/panels/midori-history.c +++ b/panels/midori-history.c @@ -668,7 +668,6 @@ midori_history_open_in_tab_activate_cb (GtkWidget* menuitem, gchar* sqlcmd; KatzeItem* child; KatzeArray* array; - guint i = 0; db = g_object_get_data (G_OBJECT (history->array), "db"); sqlcmd = g_strdup_printf ("SELECT uri, title, date, day " @@ -677,7 +676,7 @@ midori_history_open_in_tab_activate_cb (GtkWidget* menuitem, (int)katze_item_get_added (item)); array = katze_array_from_sqlite (db, sqlcmd); g_free (sqlcmd); - while ((child = katze_array_get_nth_item (KATZE_ARRAY (array), i++))) + KATZE_ARRAY_FOREACH_ITEM (child, KATZE_ARRAY (array)) { if ((uri = katze_item_get_uri (child)) && *uri) {