/*
* Claws Mail -- A GTK+ based, lightweight, and fast e-mail client
- * Copyright(C) 1999-2013 the Claws Mail Team
+ * Copyright(C) 1999-2014 the Claws Mail Team
* == Fancy Plugin ==
- * This file Copyright (C) 2009-2013 Salvatore De Paolis
+ * This file Copyright (C) 2009-2014 Salvatore De Paolis
* <iwkse@claws-mail.org> and the Claws Mail Team
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "version.h"
#include "claws.h"
#include "plugin.h"
-
-
#include "gtkutils.h"
#include "utils.h"
#include "prefs.h"
#include "prefswindow.h"
#include "combobox.h"
#include "addressbook.h"
+#include "filesel.h"
#include "fancy_prefs.h"
#endif
GtkWidget *proxy_checkbox;
GtkWidget *proxy_str;
+ GtkWidget *stylesheet;
};
static PrefParam param[] = {
NULL, NULL, NULL},
{"proxy_server", "http://SERVERNAME:PORT", &fancy_prefs.proxy_str, P_STRING,
NULL, NULL, NULL},
+ {"stylesheet", "", &fancy_prefs.stylesheet, P_STRING, NULL, NULL, NULL},
{0,0,0,0}
};
static FancyPrefsPage fancy_prefs_page;
+static void fancy_prefs_stylesheet_browse_cb (GtkWidget *widget, gpointer data);
+static void fancy_prefs_stylesheet_edit_cb (GtkWidget *widget, gpointer data);
+
static void create_fancy_prefs_page (PrefsPage *page, GtkWindow *window, gpointer data);
static void destroy_fancy_prefs_page (PrefsPage *page);
static void save_fancy_prefs_page (PrefsPage *page);
GtkWidget *enable_scripts;
GtkWidget *enable_plugins;
GtkWidget *enable_java;
+ GtkWidget *stylesheet_label;
+ GtkWidget *stylesheet;
+ GtkWidget *stylesheet_browse_button;
+ GtkWidget *stylesheet_edit_button;
vbox = gtk_vbox_new(FALSE, 3);
gtk_container_set_border_width(GTK_CONTAINER(vbox), VBOX_BORDER);
combobox_select_by_data(GTK_COMBO_BOX(optmenu_open_external),
fancy_prefs.open_external);
+
+ GtkWidget *hbox_css = gtk_hbox_new(FALSE, 8);
+ gtk_widget_show(hbox_css);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox_css, FALSE, FALSE, 0);
+
+ CLAWS_SET_TIP(hbox_css, _("The CSS in this file will be applied to all HTML parts"));
+
+ stylesheet_label = gtk_label_new(_("Stylesheet:"));
+ gtk_widget_show(stylesheet_label);
+ gtk_box_pack_start(GTK_BOX(hbox_css), stylesheet_label, FALSE, FALSE, 0);
+
+ stylesheet = gtk_entry_new();
+ gtk_widget_show(stylesheet);
+ gtk_box_pack_start(GTK_BOX(hbox_css), stylesheet, TRUE, TRUE, 0);
+
+ stylesheet_browse_button = gtkut_get_browse_file_btn(_("Bro_wse"));
+ gtk_widget_show(stylesheet_browse_button);
+ gtk_box_pack_start(GTK_BOX(hbox_css), stylesheet_browse_button, FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(stylesheet_browse_button), "clicked",
+ G_CALLBACK(fancy_prefs_stylesheet_browse_cb), stylesheet);
+
+ stylesheet_edit_button = gtk_button_new_from_stock(GTK_STOCK_EDIT);
+ gtk_widget_show (stylesheet_edit_button);
+ gtk_box_pack_start(GTK_BOX(hbox_css), stylesheet_edit_button, FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(stylesheet_edit_button), "clicked",
+ G_CALLBACK(fancy_prefs_stylesheet_edit_cb), stylesheet);
+ pref_set_entry_from_pref(GTK_ENTRY(stylesheet), fancy_prefs.stylesheet);
+
#ifdef HAVE_LIBSOUP_GNOME
prefs_page->gnome_proxy_checkbox = gnome_proxy_checkbox;
prefs_page->enable_plugins = enable_plugins;
prefs_page->enable_java = enable_java;
prefs_page->open_external = optmenu_open_external;
+ prefs_page->stylesheet = stylesheet;
prefs_page->page.widget = vbox;
g_signal_connect(G_OBJECT(prefs_page->enable_remote_content), "toggled",
remote_content_set_labels_cb(NULL, prefs_page);
}
+static void fancy_prefs_stylesheet_browse_cb(GtkWidget *widget, gpointer data)
+{
+ gchar *filename;
+ gchar *utf8_filename;
+ GtkEntry *dest = GTK_ENTRY(data);
+
+ filename = filesel_select_file_open(_("Select stylesheet"), NULL);
+ if (!filename) return;
+
+ utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
+ if (!utf8_filename) {
+ g_warning("fancy_prefs_stylesheet_browse_cb(): failed to convert character set.");
+ utf8_filename = g_strdup(filename);
+ }
+ gtk_entry_set_text(GTK_ENTRY(dest), utf8_filename);
+ g_free(utf8_filename);
+}
+
+static void fancy_prefs_stylesheet_edit_cb(GtkWidget *widget, gpointer data)
+{
+ const gchar *stylesheet = gtk_entry_get_text(GTK_ENTRY(data));
+ if (!is_file_exist(stylesheet))
+ str_write_to_file(stylesheet, "");
+ open_txt_editor(stylesheet, prefs_common_get_ext_editor_cmd());
+}
+
static void prefs_set_proxy_entry_sens(GtkWidget *button, GtkEntry *entry_str) {
gtk_widget_set_sensitive(GTK_WIDGET(entry_str),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
fancy_prefs.enable_proxy = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON(prefs_page->proxy_checkbox));
fancy_prefs.proxy_str = pref_get_pref_from_entry(GTK_ENTRY(prefs_page->proxy_str));
+ fancy_prefs.stylesheet = pref_get_pref_from_entry(GTK_ENTRY(prefs_page->stylesheet));
save_fancy_prefs(page);
}
/*
* Claws Mail -- A GTK+ based, lightweight, and fast e-mail client
* == Fancy Plugin ==
- * Copyright(C) 1999-2013 the Claws Mail Team
- * This file Copyright (C) 2009-2013 Salvatore De Paolis
+ * Copyright(C) 1999-2014 the Claws Mail Team
+ * This file Copyright (C) 2009-2014 Salvatore De Paolis
* <iwkse@claws-mail.org> and the Claws Mail Team
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
"enable-plugins", viewer->override_prefs_plugins,
"enable-java-applet", viewer->override_prefs_java,
"enable-dns-prefetching", viewer->override_prefs_remote_content,
+ "user-stylesheet-uri", viewer->override_stylesheet,
#ifdef G_OS_WIN32
"default-font-family", "Arial",
"cursive-font-family", "Comic Sans MS",
"sans-serif-font-family", "Arial",
"serif-font-family", "Times New Roman",
#endif
- NULL);
+ NULL);
webkit_web_view_set_settings(viewer->view, viewer->settings);
}
static void fancy_set_defaults(FancyViewer *viewer)
{
+ gchar *user_stylesheet = g_strconcat("file://", fancy_prefs.stylesheet, NULL);
+
viewer->override_prefs_remote_content = fancy_prefs.enable_remote_content;
viewer->override_prefs_external = fancy_prefs.open_external;
viewer->override_prefs_images = fancy_prefs.enable_images;
viewer->override_prefs_scripts = fancy_prefs.enable_scripts;
viewer->override_prefs_plugins = fancy_prefs.enable_plugins;
viewer->override_prefs_java = fancy_prefs.enable_java;
+ viewer->override_stylesheet = user_stylesheet;
g_signal_handlers_block_by_func(G_OBJECT(viewer->enable_images),
fancy_auto_load_images_activated, viewer);
fancy_open_external_activated, viewer);
fancy_apply_prefs(viewer);
+ g_free(user_stylesheet);
}
static void fancy_load_uri(FancyViewer *viewer, const gchar *uri)