#endif
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
#if !HAVE_WEBKIT_RESOURCE_REQUEST
SoupSession* session = webkit_get_default_session ();
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);
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");
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
browsers = katze_object_get_object (app, "browsers");
addons_update_elements (extension, ADDONS_USER_STYLES);
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);
{
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);
{
CookieManager *cm;
CookieManagerPrivate *priv;
- guint i;
KatzeArray *browsers;
MidoriBrowser *browser;
/* 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);
{
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",
KatzeArray* feed)
{
KatzeItem* item;
- guint i;
g_return_if_fail (KATZE_IS_ARRAY (feed));
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));
{
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;
{
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);
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,
}
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);
{
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);
{
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",
{
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);
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");
{
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);
{
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);
{
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",
{
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",
{
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);
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);
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);
return g_list_copy (array->items);
}
+GList*
+katze_array_peek_items (KatzeArray* array)
+{
+ return array->items;
+}
+
/**
* katze_array_clear:
* @array: a #KatzeArray
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);
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))
{
gtk_tree_store_insert_with_values (model, &iter, &root_iter,
0, 0, NULL, -1);
}
- i++;
}
}
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);
GError** error)
{
GKeyFile* key_file;
- guint i, j, n_properties;
+ guint j, n_properties;
KatzeItem* item;
const gchar* name;
GParamSpec** pspecs;
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++)
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);
}
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
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");
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);
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);
}
metadata = katze_item_metadata_to_xbel (item);
if (KATZE_IS_ARRAY (item))
{
- guint i = 0;
KatzeItem* _item;
KatzeArray* array = KATZE_ARRAY (item);
/* 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, "</folder>\n");
GError** error)
{
gchar* metadata = katze_item_metadata_to_xbel (KATZE_ITEM (array));
- guint i;
KatzeItem* item;
GString* markup = g_string_new (
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, "</xbel>\n");
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
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);
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 (
const gchar* sqlcmd;
KatzeArray* array;
KatzeItem* item;
- gint i = 0;
midori_bookmarkbar_clear (browser->bookmarkbar);
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);
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);
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,
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 (
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;
{
KatzeArray* search_engines;
GtkWidget* menu;
- guint i;
GtkWidget* menuitem;
KatzeItem* item;
GdkPixbuf* icon;
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;
G_CALLBACK (midori_search_action_engine_activate_cb), action);
gtk_widget_show (menuitem);
}
- while ((item = katze_array_get_nth_item (search_engines, ++i)));
}
else
{
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);
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;
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);
}
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))
{
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);
}
}
{
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)
{
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)
{
KatzeArray* array;
MidoriExtension* extension;
- guint i;
/* FIXME: Handle NULL and subsequent assignments */
extensions->app = g_value_get_object (value);
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 */
{
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);
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 "
(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)
{