From: Paweł Forysiuk Date: Fri, 7 Oct 2011 19:07:21 +0000 (+0200) Subject: Introduce and use midori_view_save_speed_dial_config X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76a9bc38ff872d4825cbb5777e4a758362d2ff0c;p=midori Introduce and use midori_view_save_speed_dial_config --- diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 8f96d3ba..2005c9c4 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -1123,11 +1123,8 @@ midori_browser_add_speed_dial (MidoriBrowser* browser) if ((img = midori_view_get_snapshot (MIDORI_VIEW (view), 240, 160))) { - gint i; GKeyFile* key_file; gchar* dial_id = g_strdup_printf ("Dial %s", slot_id + 1); - gchar* config_file = g_build_filename (sokoke_set_config_dir (NULL), - "speeddial", NULL); gchar* file_path = sokoke_build_thumbnail_path (uri); gchar* thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (), PACKAGE_NAME, "thumbnails", NULL); @@ -1140,19 +1137,12 @@ midori_browser_add_speed_dial (MidoriBrowser* browser) katze_mkdir_with_parents (thumb_dir, 0700); gdk_pixbuf_save (img, file_path, "png", NULL, "compression", "7", NULL); - sokoke_key_file_save_to_file (key_file, config_file, NULL); - - i = 0; - while ((view = gtk_notebook_get_nth_page (GTK_NOTEBOOK ( - browser->notebook), i++))) - if (midori_view_is_blank (MIDORI_VIEW (view))) - midori_view_reload (MIDORI_VIEW (view), FALSE); + midori_view_save_speed_dial_config (MIDORI_VIEW (view), key_file); g_object_unref (img); g_free (file_path); g_free (thumb_dir); - g_free (config_file); g_free (dial_id); } g_free (uri); diff --git a/midori/midori-view.c b/midori/midori-view.c index 7b54c4a8..0e9aac34 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -5365,8 +5365,7 @@ thumb_view_load_status_cb (MidoriView* thumb_view, gchar* thumb_dir; gchar* thumb_uri; MidoriBrowser* browser; - gint i; - GtkWidget* tab; + GKeyFile* key_file; if (midori_view_get_load_status (thumb_view) != MIDORI_LOAD_FINISHED) return; @@ -5399,10 +5398,8 @@ thumb_view_load_status_cb (MidoriView* thumb_view, #endif browser = midori_browser_get_for_widget (GTK_WIDGET (view)); - i = 0; - while ((tab = midori_browser_get_nth_tab (browser, i++))) - if (midori_view_is_blank (MIDORI_VIEW (tab))) - midori_view_reload (MIDORI_VIEW (tab), FALSE); + g_object_get (browser, "speed-dial", &key_file, NULL); + midori_view_save_speed_dial_config (view, key_file); } /** @@ -5468,13 +5465,10 @@ midori_view_speed_dial_save (MidoriView* view, const gchar* message) { gchar* action; - gchar* config_file; GKeyFile* key_file; MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view)); gchar* msg = g_strdup (message + 16); gchar** parts = g_strsplit (msg, " ", 4); - gint i; - GtkWidget* tab; g_object_get (browser, "speed-dial", &key_file, NULL); action = parts[0]; @@ -5548,16 +5542,29 @@ midori_view_speed_dial_save (MidoriView* view, g_free (dial_id); } + midori_view_save_speed_dial_config (view, key_file); + + g_free (msg); + g_free (action); +} + +void +midori_view_save_speed_dial_config (MidoriView* view, + GKeyFile* key_file) +{ + gchar* config_file; + guint i = 0; + MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view)); + GtkWidget* tab; + config_file = g_build_filename (sokoke_set_config_dir (NULL), "speeddial", NULL); sokoke_key_file_save_to_file (key_file, config_file, NULL); + g_free (config_file); + katze_assign (speeddial_markup, prepare_speed_dial_html (view)); - i = 0; while ((tab = midori_browser_get_nth_tab (browser, i++))) if (midori_view_is_blank (MIDORI_VIEW (tab))) midori_view_reload (MIDORI_VIEW (tab), FALSE); - g_free (msg); - g_free (action); - g_free (config_file); } diff --git a/midori/midori-view.h b/midori/midori-view.h index 9b8123d3..b0246e34 100644 --- a/midori/midori-view.h +++ b/midori/midori-view.h @@ -248,6 +248,10 @@ midori_view_add_info_bar (MidoriView* view, const gchar* first_button_text, ...); +void +midori_view_save_speed_dial_config (MidoriView* view, + GKeyFile* key_file); + G_END_DECLS #endif /* __MIDORI_VIEW_H__ */