Implement and use KATZE_ARRAY_FOREACH_ITEM
Iterating an array by a GList is considerably faster than continuously retrieving items, however it is also a lot more complicated. So the new macro takes care of that and uses a new semi-private function to avoid copying the list. Note that the macro can't be nested, which basically isn't useful in practise anyway.
This commit is contained in:
parent
db2c204b08
commit
40dc38fd21
29 changed files with 72 additions and 127 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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, "</folder>\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, "</xbel>\n");
|
||||
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
bookmarks = katze_array_get_items ((KatzeArray*)array);
|
||||
for (list = bookmarks; list != NULL; list = g_list_next (list))
|
||||
{
|
||||
KatzeItem* item;
|
||||
|
||||
if (KATZE_IS_ARRAY (list->data))
|
||||
midori_bookmarks_import_array_db (db, list->data, folder);
|
||||
item = (KatzeItem*) list->data;
|
||||
KATZE_ARRAY_FOREACH_ITEM (item, array)
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue