Implement "Clear private data when quitting Midori" check button
This commit is contained in:
parent
37b715e571
commit
74757bdc9e
3 changed files with 70 additions and 12 deletions
|
@ -1413,6 +1413,20 @@ midori_web_app_browser_notify_load_status_cb (MidoriBrowser* browser,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
midori_remove_config_file (gint clear_prefs,
|
||||
gint flag,
|
||||
const gchar* filename)
|
||||
{
|
||||
if ((clear_prefs & flag) == flag)
|
||||
{
|
||||
gchar* config_file = build_config_filename (filename);
|
||||
if (is_writable (config_file))
|
||||
g_unlink (config_file);
|
||||
g_free (config_file);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char** argv)
|
||||
|
@ -1468,6 +1482,7 @@ main (int argc,
|
|||
#if HAVE_HILDON
|
||||
osso_context_t* osso_context;
|
||||
#endif
|
||||
gint clear_prefs = MIDORI_CLEAR_NONE;
|
||||
|
||||
#if ENABLE_NLS
|
||||
setlocale (LC_ALL, "");
|
||||
|
@ -1925,12 +1940,35 @@ main (int argc,
|
|||
osso_deinitialize (osso_context);
|
||||
#endif
|
||||
|
||||
#if HAVE_SQLITE
|
||||
settings = katze_object_get_object (app, "settings");
|
||||
#if HAVE_SQLITE
|
||||
g_object_get (settings, "maximum-history-age", &max_history_age, NULL);
|
||||
g_object_unref (settings);
|
||||
midori_history_terminate (db, max_history_age);
|
||||
#endif
|
||||
|
||||
/* Clear data on quit, according to the Clear private data dialog */
|
||||
g_object_get (settings, "clear-private-data", &clear_prefs, NULL);
|
||||
#if HAVE_SQLITE
|
||||
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_HISTORY, "history.db");
|
||||
#endif
|
||||
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_COOKIES, "cookies.txt");
|
||||
if ((clear_prefs & MIDORI_CLEAR_FLASH_COOKIES) == MIDORI_CLEAR_FLASH_COOKIES)
|
||||
{
|
||||
gchar* cache = g_build_filename (g_get_home_dir (), ".macromedia",
|
||||
"Flash_Player", NULL);
|
||||
sokoke_remove_path (cache, TRUE);
|
||||
g_free (cache);
|
||||
}
|
||||
if ((clear_prefs & MIDORI_CLEAR_WEBSITE_ICONS) == MIDORI_CLEAR_WEBSITE_ICONS)
|
||||
{
|
||||
gchar* cache = g_build_filename (g_get_user_cache_dir (),
|
||||
PACKAGE_NAME, "icons", NULL);
|
||||
sokoke_remove_path (cache, TRUE);
|
||||
g_free (cache);
|
||||
}
|
||||
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_TRASH, "tabtrash.xbel");
|
||||
|
||||
g_object_unref (settings);
|
||||
g_object_unref (app);
|
||||
g_free (config_file);
|
||||
return 0;
|
||||
|
|
|
@ -138,16 +138,6 @@ enum
|
|||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MIDORI_CLEAR_NONE = 0,
|
||||
MIDORI_CLEAR_HISTORY = 1,
|
||||
MIDORI_CLEAR_COOKIES = 2,
|
||||
MIDORI_CLEAR_FLASH_COOKIES = 4,
|
||||
MIDORI_CLEAR_WEBSITE_ICONS = 8,
|
||||
MIDORI_CLEAR_TRASH = 16
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL];
|
||||
|
||||
static void
|
||||
|
@ -3723,6 +3713,16 @@ midori_browser_clear_private_data_response_cb (GtkWidget* dialog,
|
|||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
midori_browser_clear_on_quit_toggled_cb (GtkToggleButton* button,
|
||||
MidoriWebSettings* settings)
|
||||
{
|
||||
gint clear_prefs = MIDORI_CLEAR_NONE;
|
||||
g_object_get (settings, "clear-private-data", &clear_prefs, NULL);
|
||||
clear_prefs ^= MIDORI_CLEAR_ON_QUIT;
|
||||
g_object_set (settings, "clear-private-data", clear_prefs, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_action_clear_private_data_activate (GtkAction* action,
|
||||
MidoriBrowser* browser)
|
||||
|
@ -3802,6 +3802,15 @@ _action_clear_private_data_activate (GtkAction* action,
|
|||
gtk_container_add (GTK_CONTAINER (alignment), vbox);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
|
||||
button = gtk_check_button_new_with_mnemonic (_("Clear private data when _quitting Midori"));
|
||||
if ((clear_prefs & MIDORI_CLEAR_ON_QUIT) == MIDORI_CLEAR_ON_QUIT)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
g_signal_connect (button, "toggled",
|
||||
G_CALLBACK (midori_browser_clear_on_quit_toggled_cb), browser->settings);
|
||||
alignment = gtk_alignment_new (0, 0, 1, 1);
|
||||
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 2, 0);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), button);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), alignment, FALSE, FALSE, 0);
|
||||
gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
|
|
|
@ -34,6 +34,17 @@ G_BEGIN_DECLS
|
|||
typedef struct _MidoriWebSettings MidoriWebSettings;
|
||||
typedef struct _MidoriWebSettingsClass MidoriWebSettingsClass;
|
||||
|
||||
enum
|
||||
{
|
||||
MIDORI_CLEAR_NONE = 0,
|
||||
MIDORI_CLEAR_HISTORY = 1,
|
||||
MIDORI_CLEAR_COOKIES = 2,
|
||||
MIDORI_CLEAR_FLASH_COOKIES = 4,
|
||||
MIDORI_CLEAR_WEBSITE_ICONS = 8,
|
||||
MIDORI_CLEAR_TRASH = 16,
|
||||
MIDORI_CLEAR_ON_QUIT = 32,
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MIDORI_WINDOW_NORMAL,
|
||||
|
|
Loading…
Reference in a new issue