Introduce and use midori_view_save_speed_dial_config

This commit is contained in:
Paweł Forysiuk 2011-10-07 21:07:21 +02:00 committed by Christian Dywan
parent b5aad2d176
commit 76a9bc38ff
3 changed files with 25 additions and 24 deletions

View file

@ -1123,11 +1123,8 @@ midori_browser_add_speed_dial (MidoriBrowser* browser)
if ((img = midori_view_get_snapshot (MIDORI_VIEW (view), 240, 160))) if ((img = midori_view_get_snapshot (MIDORI_VIEW (view), 240, 160)))
{ {
gint i;
GKeyFile* key_file; GKeyFile* key_file;
gchar* dial_id = g_strdup_printf ("Dial %s", slot_id + 1); 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* file_path = sokoke_build_thumbnail_path (uri);
gchar* thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (), gchar* thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (),
PACKAGE_NAME, "thumbnails", NULL); PACKAGE_NAME, "thumbnails", NULL);
@ -1140,19 +1137,12 @@ midori_browser_add_speed_dial (MidoriBrowser* browser)
katze_mkdir_with_parents (thumb_dir, 0700); katze_mkdir_with_parents (thumb_dir, 0700);
gdk_pixbuf_save (img, file_path, "png", NULL, "compression", "7", NULL); 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_object_unref (img);
g_free (file_path); g_free (file_path);
g_free (thumb_dir); g_free (thumb_dir);
g_free (config_file);
g_free (dial_id); g_free (dial_id);
} }
g_free (uri); g_free (uri);

View file

@ -5365,8 +5365,7 @@ thumb_view_load_status_cb (MidoriView* thumb_view,
gchar* thumb_dir; gchar* thumb_dir;
gchar* thumb_uri; gchar* thumb_uri;
MidoriBrowser* browser; MidoriBrowser* browser;
gint i; GKeyFile* key_file;
GtkWidget* tab;
if (midori_view_get_load_status (thumb_view) != MIDORI_LOAD_FINISHED) if (midori_view_get_load_status (thumb_view) != MIDORI_LOAD_FINISHED)
return; return;
@ -5399,10 +5398,8 @@ thumb_view_load_status_cb (MidoriView* thumb_view,
#endif #endif
browser = midori_browser_get_for_widget (GTK_WIDGET (view)); browser = midori_browser_get_for_widget (GTK_WIDGET (view));
i = 0; g_object_get (browser, "speed-dial", &key_file, NULL);
while ((tab = midori_browser_get_nth_tab (browser, i++))) midori_view_save_speed_dial_config (view, key_file);
if (midori_view_is_blank (MIDORI_VIEW (tab)))
midori_view_reload (MIDORI_VIEW (tab), FALSE);
} }
/** /**
@ -5468,13 +5465,10 @@ midori_view_speed_dial_save (MidoriView* view,
const gchar* message) const gchar* message)
{ {
gchar* action; gchar* action;
gchar* config_file;
GKeyFile* key_file; GKeyFile* key_file;
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view)); MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
gchar* msg = g_strdup (message + 16); gchar* msg = g_strdup (message + 16);
gchar** parts = g_strsplit (msg, " ", 4); gchar** parts = g_strsplit (msg, " ", 4);
gint i;
GtkWidget* tab;
g_object_get (browser, "speed-dial", &key_file, NULL); g_object_get (browser, "speed-dial", &key_file, NULL);
action = parts[0]; action = parts[0];
@ -5548,16 +5542,29 @@ midori_view_speed_dial_save (MidoriView* view,
g_free (dial_id); 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); config_file = g_build_filename (sokoke_set_config_dir (NULL), "speeddial", NULL);
sokoke_key_file_save_to_file (key_file, config_file, 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)); katze_assign (speeddial_markup, prepare_speed_dial_html (view));
i = 0;
while ((tab = midori_browser_get_nth_tab (browser, i++))) while ((tab = midori_browser_get_nth_tab (browser, i++)))
if (midori_view_is_blank (MIDORI_VIEW (tab))) if (midori_view_is_blank (MIDORI_VIEW (tab)))
midori_view_reload (MIDORI_VIEW (tab), FALSE); midori_view_reload (MIDORI_VIEW (tab), FALSE);
g_free (msg);
g_free (action);
g_free (config_file);
} }

View file

@ -248,6 +248,10 @@ midori_view_add_info_bar (MidoriView* view,
const gchar* first_button_text, const gchar* first_button_text,
...); ...);
void
midori_view_save_speed_dial_config (MidoriView* view,
GKeyFile* key_file);
G_END_DECLS G_END_DECLS
#endif /* __MIDORI_VIEW_H__ */ #endif /* __MIDORI_VIEW_H__ */