Enhance Web Settings greatly with new properties.

A lot of new properties are added, which are going to
be the basis of the coming configuration replacement.

Also a little cleanup is done in a few places.
This commit is contained in:
Christian Dywan 2008-04-13 11:29:21 +02:00
parent 39bf592772
commit e91d077a84
7 changed files with 720 additions and 57 deletions

View file

@ -152,7 +152,7 @@ katze_throbber_class_init (KatzeThrobberClass* class)
"Pixbuf", "Pixbuf",
_("A GdkPixbuf containing animation frames"), _("A GdkPixbuf containing animation frames"),
GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF,
flags)); G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_ANIMATED, PROP_ANIMATED,
@ -179,7 +179,7 @@ katze_throbber_class_init (KatzeThrobberClass* class)
"Static Pixbuf", "Static Pixbuf",
_("A GdkPixbuf to be used as the static image"), _("A GdkPixbuf to be used as the static image"),
GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF,
flags)); G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_STATIC_STOCK_ID, PROP_STATIC_STOCK_ID,
@ -205,7 +205,7 @@ katze_throbber_init (KatzeThrobber *throbber)
} }
static void static void
katze_throbber_dispose (GObject *object) katze_throbber_dispose (GObject* object)
{ {
KatzeThrobber* throbber = KATZE_THROBBER (object); KatzeThrobber* throbber = KATZE_THROBBER (object);
KatzeThrobberPrivate* priv = throbber->priv; KatzeThrobberPrivate* priv = throbber->priv;
@ -217,7 +217,7 @@ katze_throbber_dispose (GObject *object)
} }
static void static void
katze_throbber_destroy (GtkObject *object) katze_throbber_destroy (GtkObject* object)
{ {
KatzeThrobber* throbber = KATZE_THROBBER (object); KatzeThrobber* throbber = KATZE_THROBBER (object);
KatzeThrobberPrivate* priv = throbber->priv; KatzeThrobberPrivate* priv = throbber->priv;

View file

@ -13,7 +13,7 @@
#define __KATZE_THROBBER_H__ #define __KATZE_THROBBER_H__
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gtk/gtkmisc.h> #include <gtk/gtk.h>
#include "katze-utils.h" #include "katze-utils.h"

View file

@ -719,7 +719,7 @@ katze_xbel_folder_from_data (KatzeXbelItem* folder,
if((doc = xmlParseMemory (data, strlen (data))) == NULL) if((doc = xmlParseMemory (data, strlen (data))) == NULL)
{ {
// No valid xml or broken encoding // No valid xml or broken encoding
*error = g_error_new (KATZE_XBEL_ERROR, KATZE_XBEL_ERROR_READ, *error = g_error_new_literal (KATZE_XBEL_ERROR, KATZE_XBEL_ERROR_READ,
_("Malformed document.")); _("Malformed document."));
return FALSE; return FALSE;
} }
@ -727,7 +727,7 @@ katze_xbel_folder_from_data (KatzeXbelItem* folder,
{ {
// Parsing failed // Parsing failed
xmlFreeDoc(doc); xmlFreeDoc(doc);
*error = g_error_new (KATZE_XBEL_ERROR, KATZE_XBEL_ERROR_READ, *error = g_error_new_literal (KATZE_XBEL_ERROR, KATZE_XBEL_ERROR_READ,
_("Malformed document.")); _("Malformed document."));
return FALSE; return FALSE;
} }
@ -755,7 +755,7 @@ katze_xbel_folder_from_file (KatzeXbelItem* folder,
if (!g_file_test (file, G_FILE_TEST_EXISTS)) if (!g_file_test (file, G_FILE_TEST_EXISTS))
{ {
// File doesn't exist // File doesn't exist
*error = g_error_new (G_FILE_ERROR, G_FILE_ERROR_NOENT, *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_NOENT,
_("File not found.")); _("File not found."));
return FALSE; return FALSE;
} }
@ -763,7 +763,7 @@ katze_xbel_folder_from_file (KatzeXbelItem* folder,
if ((doc = xmlParseFile (file)) == NULL) if ((doc = xmlParseFile (file)) == NULL)
{ {
// No valid xml or broken encoding // No valid xml or broken encoding
*error = g_error_new (KATZE_XBEL_ERROR, KATZE_XBEL_ERROR_READ, *error = g_error_new_literal (KATZE_XBEL_ERROR, KATZE_XBEL_ERROR_READ,
_("Malformed document.")); _("Malformed document."));
return FALSE; return FALSE;
} }
@ -771,7 +771,7 @@ katze_xbel_folder_from_file (KatzeXbelItem* folder,
{ {
// Parsing failed // Parsing failed
xmlFreeDoc (doc); xmlFreeDoc (doc);
*error = g_error_new (KATZE_XBEL_ERROR, KATZE_XBEL_ERROR_READ, *error = g_error_new_literal (KATZE_XBEL_ERROR, KATZE_XBEL_ERROR_READ,
_("Malformed document.")); _("Malformed document."));
return FALSE; return FALSE;
} }
@ -800,7 +800,7 @@ katze_xbel_folder_from_data_dirs (KatzeXbelItem* folder,
g_return_val_if_fail (file, FALSE); g_return_val_if_fail (file, FALSE);
// FIXME: Essentially unimplemented // FIXME: Essentially unimplemented
*error = g_error_new (KATZE_XBEL_ERROR, KATZE_XBEL_ERROR_READ, *error = g_error_new_literal (KATZE_XBEL_ERROR, KATZE_XBEL_ERROR_READ,
_("Malformed document.")); _("Malformed document."));
return FALSE; return FALSE;
} }
@ -946,9 +946,9 @@ katze_xbel_folder_to_file (KatzeXbelItem* folder,
if (!(data = katze_xbel_folder_to_data (folder, NULL, error))) if (!(data = katze_xbel_folder_to_data (folder, NULL, error)))
return FALSE; return FALSE;
FILE* fp; FILE* fp;
if(!(fp = fopen (file, "w"))) if (!(fp = fopen (file, "w")))
{ {
*error = g_error_new (G_FILE_ERROR, G_FILE_ERROR_ACCES, *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_ACCES,
_("Writing failed.")); _("Writing failed."));
return FALSE; return FALSE;
} }

View file

@ -321,8 +321,8 @@ int main(int argc, char** argv)
"enable-scripts", config->enableScripts, "enable-scripts", config->enableScripts,
"enable-plugins", config->enablePlugins, "enable-plugins", config->enablePlugins,
"tab-label-size", config->tabSize, "tab-label-size", config->tabSize,
"close-button", config->tabClose, "close-buttons-on-tabs", config->tabClose,
"middle-click-goto", config->middleClickGoto, "middle-click-opens-selection", config->middleClickGoto,
NULL); NULL);
webSettings = settings; webSettings = settings;

View file

@ -9,18 +9,48 @@
See the file COPYING for the full license text. See the file COPYING for the full license text.
*/ */
#include "midori-webview.h" #include "midori-websettings.h"
#include "sokoke.h" #include "sokoke.h"
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <string.h>
G_DEFINE_TYPE (MidoriWebSettings, midori_web_settings, WEBKIT_TYPE_WEB_SETTINGS) G_DEFINE_TYPE (MidoriWebSettings, midori_web_settings, WEBKIT_TYPE_WEB_SETTINGS)
struct _MidoriWebSettingsPrivate struct _MidoriWebSettingsPrivate
{ {
MidoriStartup load_on_startup;
gchar* homepage;
gchar* download_folder;
gboolean show_download_notification;
gchar* location_entry_search;
MidoriPreferredEncoding preferred_encoding;
MidoriToolbarStyle toolbar_style;
gboolean small_toolbar;
gboolean show_web_search;
gboolean show_new_tab;
gboolean show_trash;
gint tab_label_size; gint tab_label_size;
gboolean close_button; gboolean close_buttons_on_tabs;
gboolean middle_click_goto; MidoriNewPage open_new_pages_in;
gboolean middle_click_opens_selection;
gboolean open_tabs_in_the_background;
gboolean open_popups_in_tabs;
MidoriAcceptCookies accept_cookies;
gboolean original_cookies_only;
gint maximum_cookie_age;
gboolean remember_last_visited_pages;
gint maximum_history_age;
gboolean remember_last_form_inputs;
gboolean remember_last_downloaded_files;
gchar* http_proxy;
gint cache_size;
}; };
#define MIDORI_WEB_SETTINGS_GET_PRIVATE(obj) \ #define MIDORI_WEB_SETTINGS_GET_PRIVATE(obj) \
@ -31,11 +61,129 @@ enum
{ {
PROP_0, PROP_0,
PROP_LOAD_ON_STARTUP,
PROP_HOMEPAGE,
PROP_DOWNLOAD_FOLDER,
PROP_SHOW_DOWNLOAD_NOTIFICATION,
PROP_LOCATION_ENTRY_SEARCH,
PROP_PREFERRED_ENCODING,
PROP_TOOLBAR_STYLE,
PROP_SMALL_TOOLBAR,
PROP_SHOW_NEW_TAB,
PROP_SHOW_WEB_SEARCH,
PROP_SHOW_TRASH,
PROP_TAB_LABEL_SIZE, PROP_TAB_LABEL_SIZE,
PROP_CLOSE_BUTTON, PROP_CLOSE_BUTTONS_ON_TABS,
PROP_MIDDLE_CLICK_GOTO PROP_OPEN_NEW_PAGES_IN,
PROP_MIDDLE_CLICK_OPENS_SELECTION,
PROP_OPEN_TABS_IN_THE_BACKGROUND,
PROP_OPEN_POPUPS_IN_TABS,
PROP_ACCEPT_COOKIES,
PROP_ORIGINAL_COOKIES_ONLY,
PROP_MAXIMUM_COOKIE_AGE,
PROP_REMEMBER_LAST_VISITED_PAGES,
PROP_MAXIMUM_HISTORY_AGE,
PROP_REMEMBER_LAST_FORM_INPUTS,
PROP_REMEMBER_LAST_DOWNLOADED_FILES,
PROP_HTTP_PROXY,
PROP_CACHE_SIZE
}; };
GType
midori_startup_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GEnumValue values[] = {
{ MIDORI_STARTUP_BLANK, "MIDORI_STARTUP_BLANK", "Blank" },
{ MIDORI_STARTUP_HOMEPAGE, "MIDORI_STARTUP_HOMEPAGE", "Homepage" },
{ MIDORI_STARTUP_LAST_OPEN_PAGES, "MIDORI_STARTUP_LAST_OPEN_PAGES", "Last open pages" },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriStartup", values);
}
return type;
}
GType
midori_preferred_encoding_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GEnumValue values[] = {
{ MIDORI_ENCODING_CHINESE, "MIDORI_ENCODING_CHINESE", "Chinese (BIG5)" },
{ MIDORI_ENCODING_JAPANESE, "MIDORI_ENCODING_JAPANESE", "Japanese (SHIFT_JIS)" },
{ MIDORI_ENCODING_RUSSIAN, "MIDORI_ENCODING_RUSSIAN", "Russian (KOI8-R)" },
{ MIDORI_ENCODING_UNICODE, "MIDORI_ENCODING_UNICODE", "Unicode (UTF-8)" },
{ MIDORI_ENCODING_WESTERN, "MIDORI_ENCODING_WESTERN", "Western (ISO-8859-1)" },
{ MIDORI_ENCODING_WESTERN, "MIDORI_ENCODING_CUSTOM", "Custom..." },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriPreferredEncoding", values);
}
return type;
}
GType
midori_new_page_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GEnumValue values[] = {
{ MIDORI_NEW_PAGE_TAB, "MIDORI_NEW_PAGE_TAB", "New tab" },
{ MIDORI_NEW_PAGE_WINDOW, "MIDORI_NEW_PAGE_WINDOW", "New window" },
{ MIDORI_NEW_PAGE_CURRENT, "MIDORI_NEW_PAGE_CURRENT", "Current tab" },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriNewPage", values);
}
return type;
}
GType
midori_toolbar_style_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GEnumValue values[] = {
{ MIDORI_TOOLBAR_DEFAULT, "MIDORI_TOOLBAR_DEFAULT", "Default" },
{ MIDORI_TOOLBAR_ICONS, "MIDORI_TOOLBAR_ICONS", "Icons" },
{ MIDORI_TOOLBAR_TEXT, "MIDORI_TOOLBAR_TEXT", "Text" },
{ MIDORI_TOOLBAR_BOTH, "MIDORI_TOOLBAR_BOTH", "Both" },
{ MIDORI_TOOLBAR_BOTH_HORIZ, "MIDORI_TOOLBAR_BOTH_HORIZ", "Both horizontal" },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriToolbarStyle", values);
}
return type;
}
GType
midori_accept_cookies_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GEnumValue values[] = {
{ MIDORI_ACCEPT_COOKIES_ALL, "MIDORI_ACCEPT_COOKIES_ALL", "All cookies" },
{ MIDORI_ACCEPT_COOKIES_SESSION, "MIDORI_ACCEPT_COOKIES_SESSION", "Session cookies" },
{ MIDORI_ACCEPT_COOKIES_NONE, "MIDORI_ACCEPT_COOKIES_NONE", "None" },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriAcceptCookies", values);
}
return type;
}
static void static void
midori_web_settings_finalize (GObject* object); midori_web_settings_finalize (GObject* object);
@ -61,42 +209,289 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
GParamFlags flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT; GParamFlags flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
g_object_class_install_property (gobject_class,
PROP_LOAD_ON_STARTUP,
g_param_spec_enum (
"load-on-startup",
_("Load on Startup"),
_("What to load on startup"),
MIDORI_TYPE_STARTUP,
MIDORI_STARTUP_HOMEPAGE,
flags));
g_object_class_install_property (gobject_class,
PROP_HOMEPAGE,
g_param_spec_string (
"homepage",
_("Homepage"),
_("The homepage"),
"http://www.google.com",
flags));
g_object_class_install_property (gobject_class,
PROP_DOWNLOAD_FOLDER,
g_param_spec_string (
"download-folder",
_("Download Folder"),
_("The folder downloaded files are saved to"),
g_get_home_dir (),
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_SHOW_DOWNLOAD_NOTIFICATION,
g_param_spec_boolean (
"show-download-notification",
_("Show Download Notification"),
_("Show a notification window for finished downloads"),
TRUE,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_LOCATION_ENTRY_SEARCH,
g_param_spec_string (
"location-entry-search",
_("Location entry Search"),
_("The search to perform inside the location entry"),
"http://www.google.com/search/?q=%s",
flags));
g_object_class_install_property (gobject_class,
PROP_PREFERRED_ENCODING,
g_param_spec_enum (
"preferred-encoding",
_("Preferred Encoding"),
_("The preferred character encoding"),
MIDORI_TYPE_PREFERRED_ENCODING,
MIDORI_ENCODING_WESTERN,
flags));
g_object_class_install_property (gobject_class,
PROP_TOOLBAR_STYLE,
g_param_spec_enum (
"toolbar-style",
_("Toolbar Style"),
_("The style of the toolbar"),
MIDORI_TYPE_TOOLBAR_STYLE,
MIDORI_TOOLBAR_DEFAULT,
flags));
g_object_class_install_property (gobject_class,
PROP_SMALL_TOOLBAR,
g_param_spec_boolean (
"small-toolbar",
_("Small toolbar"),
_("Use small toolbar icons"),
FALSE,
flags));
g_object_class_install_property (gobject_class,
PROP_SHOW_NEW_TAB,
g_param_spec_boolean (
"show-new-tab",
_("Show New Tab"),
_("Show the New Tab button in the toolbar"),
TRUE,
flags));
g_object_class_install_property (gobject_class,
PROP_SHOW_WEB_SEARCH,
g_param_spec_boolean (
"show-web-search",
_("Show Web search"),
_("Show the Web search entry in the toolbar"),
TRUE,
flags));
g_object_class_install_property (gobject_class,
PROP_SHOW_TRASH,
g_param_spec_boolean (
"show-trash",
_("Show Trash"),
_("Show the Trash button in the toolbar"),
TRUE,
flags));
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_TAB_LABEL_SIZE, PROP_TAB_LABEL_SIZE,
g_param_spec_int ( g_param_spec_int (
"tab-label-size", "tab-label-size",
"Tab Label Size", _("Tab Label Size"),
_("The desired tab label size"), _("The desired tab label size"),
0, G_MAXINT, 10, 0, G_MAXINT, 10,
flags)); flags));
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_CLOSE_BUTTON, PROP_CLOSE_BUTTONS_ON_TABS,
g_param_spec_boolean ( g_param_spec_boolean (
"close-button", "close-buttons-on-tabs",
"Close Button", _("Close Buttons on Tabs"),
_("Whether tabs have close buttons"), _("Whether tabs have close buttons"),
FALSE, FALSE,
flags)); flags));
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_MIDDLE_CLICK_GOTO, PROP_OPEN_NEW_PAGES_IN,
g_param_spec_enum (
"open-new-pages-in",
_("Open new pages in"),
_("Where to open new pages"),
MIDORI_TYPE_NEW_PAGE,
MIDORI_NEW_PAGE_TAB,
flags));
g_object_class_install_property (gobject_class,
PROP_MIDDLE_CLICK_OPENS_SELECTION,
g_param_spec_boolean ( g_param_spec_boolean (
"middle-click-goto", "middle-click-opens-selection",
"Middle Click Goto", _("Middle click opens Selection"),
_("Load an URL from the selection via middle click"), _("Load an URL from the selection via middle click"),
FALSE, FALSE,
flags)); flags));
g_object_class_install_property (gobject_class,
PROP_OPEN_TABS_IN_THE_BACKGROUND,
g_param_spec_boolean (
"open-tabs-in-the-background",
_("Open tabs in the background"),
_("Whether to open new tabs in the background"),
FALSE,
flags));
g_object_class_install_property (gobject_class,
PROP_OPEN_POPUPS_IN_TABS,
g_param_spec_boolean (
"open-popups-in-tabs",
_("Open popups in tabs"),
_("Whether to open popup windows in tabs"),
TRUE,
flags));
g_object_class_install_property (gobject_class,
PROP_ACCEPT_COOKIES,
g_param_spec_enum (
"accept-cookies",
_("Accept cookies"),
_("What type of cookies to accept"),
MIDORI_TYPE_ACCEPT_COOKIES,
MIDORI_ACCEPT_COOKIES_ALL,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_ORIGINAL_COOKIES_ONLY,
g_param_spec_boolean (
"original-cookies-only",
_("Original cookies only"),
_("Accept cookies from the original website only"),
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_MAXIMUM_COOKIE_AGE,
g_param_spec_int (
"maximum-cookie-age",
_("Maximum cookie age"),
_("The maximum number of days to save cookies for"),
0, G_MAXINT, 30,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_REMEMBER_LAST_VISITED_PAGES,
g_param_spec_boolean (
"remember-last-visited-pages",
_("Remember last visited pages"),
_("Whether the last visited pages are saved"),
TRUE,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_MAXIMUM_HISTORY_AGE,
g_param_spec_int (
"maximum-history-age",
_("Maximum history age"),
_("The maximum number of days to save the history for"),
0, G_MAXINT, 30,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_REMEMBER_LAST_FORM_INPUTS,
g_param_spec_boolean (
"remember-last-form-inputs",
_("Remember last form inputs"),
_("Whether the last form inputs are saved"),
TRUE,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_REMEMBER_LAST_DOWNLOADED_FILES,
g_param_spec_boolean (
"remember-last-downloaded-files",
_("Remember last downloaded files"),
_("Whether the last downloaded files are saved"),
TRUE,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_HTTP_PROXY,
g_param_spec_string (
"http-proxy",
_("HTTP Proxy"),
_("The proxy used for HTTP connections"),
g_getenv ("http_proxy"),
flags));
g_object_class_install_property (gobject_class,
PROP_CACHE_SIZE,
g_param_spec_int (
"cache-size",
_("Cache size"),
_("The allowed size of the cache"),
0, G_MAXINT, 100,
G_PARAM_READABLE));
g_type_class_add_private (class, sizeof (MidoriWebSettingsPrivate)); g_type_class_add_private (class, sizeof (MidoriWebSettingsPrivate));
} }
static void
notify_default_encoding_cb (GObject* object, GParamSpec* pspec)
{
MidoriWebSettings* web_settings = MIDORI_WEB_SETTINGS (object);
MidoriWebSettingsPrivate* priv = web_settings->priv;
const gchar* string;
g_object_get (object, "default-encoding", &string, NULL);
const gchar* encoding = string ? string : "";
if (!strcmp (encoding, "BIG5"))
priv->preferred_encoding = MIDORI_ENCODING_CHINESE;
else if (!strcmp (encoding, "SHIFT_JIS"))
priv->preferred_encoding = MIDORI_ENCODING_JAPANESE;
else if (!strcmp (encoding, "KOI8-R"))
priv->preferred_encoding = MIDORI_ENCODING_RUSSIAN;
else if (!strcmp (encoding, "UTF-8"))
priv->preferred_encoding = MIDORI_ENCODING_UNICODE;
else if (!strcmp (encoding, "ISO-8859-1"))
priv->preferred_encoding = MIDORI_ENCODING_WESTERN;
else
priv->preferred_encoding = MIDORI_ENCODING_CUSTOM;
g_object_notify (object, "preferred-encoding");
}
static void static void
midori_web_settings_init (MidoriWebSettings* web_settings) midori_web_settings_init (MidoriWebSettings* web_settings)
{ {
web_settings->priv = MIDORI_WEB_SETTINGS_GET_PRIVATE (web_settings); web_settings->priv = MIDORI_WEB_SETTINGS_GET_PRIVATE (web_settings);
g_signal_connect (web_settings, "notify::default-encoding",
G_CALLBACK (notify_default_encoding_cb), NULL);
} }
static void static void
@ -116,14 +511,109 @@ midori_web_settings_set_property (GObject* object,
switch (prop_id) switch (prop_id)
{ {
case PROP_LOAD_ON_STARTUP:
priv->load_on_startup = g_value_get_enum (value);
break;
case PROP_HOMEPAGE:
katze_assign (priv->homepage, g_value_dup_string (value));
break;
case PROP_DOWNLOAD_FOLDER:
katze_assign (priv->download_folder, g_value_dup_string (value));
break;
case PROP_SHOW_DOWNLOAD_NOTIFICATION:
priv->show_download_notification = g_value_get_boolean (value);
break;
case PROP_LOCATION_ENTRY_SEARCH:
katze_assign (priv->location_entry_search, g_value_dup_string (value));
break;
case PROP_PREFERRED_ENCODING:
priv->preferred_encoding = g_value_get_enum (value);
switch (priv->preferred_encoding)
{
case MIDORI_ENCODING_CHINESE:
g_object_set (object, "default-encoding", "BIG5", NULL);
break;
case MIDORI_ENCODING_JAPANESE:
g_object_set (object, "default-encoding", "SHIFT_JIS", NULL);
break;
case MIDORI_ENCODING_RUSSIAN:
g_object_set (object, "default-encoding", "KOI8-R", NULL);
break;
case MIDORI_ENCODING_UNICODE:
g_object_set (object, "default-encoding", "UTF-8", NULL);
break;
case MIDORI_ENCODING_WESTERN:
g_object_set (object, "default-encoding", "ISO-8859-1", NULL);
break;
case MIDORI_ENCODING_CUSTOM:
g_object_set (object, "default-encoding", "", NULL);
}
break;
case PROP_TOOLBAR_STYLE:
priv->toolbar_style = g_value_get_enum (value);
break;
case PROP_SMALL_TOOLBAR:
priv->small_toolbar = g_value_get_boolean (value);
break;
case PROP_SHOW_NEW_TAB:
priv->show_new_tab = g_value_get_boolean (value);
break;
case PROP_SHOW_WEB_SEARCH:
priv->show_web_search = g_value_get_boolean (value);
break;
case PROP_SHOW_TRASH:
priv->show_trash = g_value_get_boolean (value);
break;
case PROP_TAB_LABEL_SIZE: case PROP_TAB_LABEL_SIZE:
priv->tab_label_size = g_value_get_int (value); priv->tab_label_size = g_value_get_int (value);
break; break;
case PROP_CLOSE_BUTTON: case PROP_CLOSE_BUTTONS_ON_TABS:
priv->close_button = g_value_get_boolean (value); priv->close_buttons_on_tabs = g_value_get_boolean (value);
break; break;
case PROP_MIDDLE_CLICK_GOTO: case PROP_OPEN_NEW_PAGES_IN:
priv->middle_click_goto = g_value_get_boolean (value); priv->open_new_pages_in = g_value_get_enum (value);
break;
case PROP_MIDDLE_CLICK_OPENS_SELECTION:
priv->middle_click_opens_selection = g_value_get_boolean (value);
break;
case PROP_OPEN_TABS_IN_THE_BACKGROUND:
priv->open_tabs_in_the_background = g_value_get_boolean (value);
break;
case PROP_OPEN_POPUPS_IN_TABS:
priv->open_popups_in_tabs = g_value_get_boolean (value);
break;
case PROP_ACCEPT_COOKIES:
priv->accept_cookies = g_value_get_enum (value);
break;
case PROP_ORIGINAL_COOKIES_ONLY:
priv->original_cookies_only = g_value_get_boolean (value);
break;
case PROP_MAXIMUM_COOKIE_AGE:
priv->maximum_cookie_age = g_value_get_int (value);
break;
case PROP_REMEMBER_LAST_VISITED_PAGES:
priv->remember_last_visited_pages = g_value_get_boolean (value);
break;
case PROP_MAXIMUM_HISTORY_AGE:
priv->maximum_history_age = g_value_get_int (value);
break;
case PROP_REMEMBER_LAST_FORM_INPUTS:
priv->remember_last_form_inputs = g_value_get_boolean (value);
break;
case PROP_REMEMBER_LAST_DOWNLOADED_FILES:
priv->remember_last_downloaded_files = g_value_get_boolean (value);
break;
case PROP_HTTP_PROXY:
katze_assign (priv->http_proxy, g_value_dup_string (value));
g_setenv ("http_proxy", priv->http_proxy ? priv->http_proxy : "", TRUE);
break;
case PROP_CACHE_SIZE:
priv->cache_size = g_value_get_int (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -142,14 +632,88 @@ midori_web_settings_get_property (GObject* object,
switch (prop_id) switch (prop_id)
{ {
case PROP_LOAD_ON_STARTUP:
g_value_set_enum (value, priv->load_on_startup);
break;
case PROP_HOMEPAGE:
g_value_set_string (value, priv->homepage);
break;
case PROP_DOWNLOAD_FOLDER:
g_value_set_string (value, priv->download_folder);
break;
case PROP_SHOW_DOWNLOAD_NOTIFICATION:
g_value_set_boolean (value, priv->show_download_notification);
break;
case PROP_LOCATION_ENTRY_SEARCH:
g_value_set_string (value, priv->location_entry_search);
break;
case PROP_PREFERRED_ENCODING:
g_value_set_enum (value, priv->preferred_encoding);
break;
case PROP_TOOLBAR_STYLE:
g_value_set_enum (value, priv->toolbar_style);
break;
case PROP_SMALL_TOOLBAR:
g_value_set_boolean (value, priv->small_toolbar);
break;
case PROP_SHOW_NEW_TAB:
g_value_set_boolean (value, priv->show_new_tab);
break;
case PROP_SHOW_WEB_SEARCH:
g_value_set_boolean (value, priv->show_web_search);
break;
case PROP_SHOW_TRASH:
g_value_set_boolean (value, priv->show_trash);
break;
case PROP_TAB_LABEL_SIZE: case PROP_TAB_LABEL_SIZE:
g_value_set_int (value, priv->tab_label_size); g_value_set_int (value, priv->tab_label_size);
break; break;
case PROP_CLOSE_BUTTON: case PROP_CLOSE_BUTTONS_ON_TABS:
g_value_set_boolean (value, priv->close_button); g_value_set_boolean (value, priv->close_buttons_on_tabs);
break; break;
case PROP_MIDDLE_CLICK_GOTO: case PROP_OPEN_NEW_PAGES_IN:
g_value_set_boolean (value, priv->middle_click_goto); g_value_set_enum (value, priv->open_new_pages_in);
break;
case PROP_MIDDLE_CLICK_OPENS_SELECTION:
g_value_set_boolean (value, priv->middle_click_opens_selection);
break;
case PROP_OPEN_TABS_IN_THE_BACKGROUND:
g_value_set_boolean (value, priv->open_tabs_in_the_background);
break;
case PROP_OPEN_POPUPS_IN_TABS:
g_value_set_boolean (value, priv->open_popups_in_tabs);
break;
case PROP_ACCEPT_COOKIES:
g_value_set_enum (value, priv->accept_cookies);
break;
case PROP_ORIGINAL_COOKIES_ONLY:
g_value_set_boolean (value, priv->original_cookies_only);
break;
case PROP_MAXIMUM_COOKIE_AGE:
g_value_set_int (value, priv->maximum_cookie_age);
break;
case PROP_REMEMBER_LAST_VISITED_PAGES:
g_value_set_boolean (value, priv->remember_last_visited_pages);
break;
case PROP_MAXIMUM_HISTORY_AGE:
g_value_set_int (value, priv->maximum_history_age);
break;
case PROP_REMEMBER_LAST_FORM_INPUTS:
g_value_set_boolean (value, priv->remember_last_form_inputs);
break;
case PROP_REMEMBER_LAST_DOWNLOADED_FILES:
g_value_set_boolean (value, priv->remember_last_downloaded_files);
break;
case PROP_HTTP_PROXY:
g_value_set_string (value, priv->http_proxy);
break;
case PROP_CACHE_SIZE:
g_value_set_int (value, priv->cache_size);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -190,11 +754,40 @@ midori_web_settings_copy (MidoriWebSettings* web_settings)
MidoriWebSettingsPrivate* priv = web_settings->priv; MidoriWebSettingsPrivate* priv = web_settings->priv;
MidoriWebSettings* copy; MidoriWebSettings* copy;
copy = MIDORI_WEB_SETTINGS (webkit_web_settings_copy (WEBKIT_WEB_SETTINGS (web_settings))); copy = MIDORI_WEB_SETTINGS (webkit_web_settings_copy (
WEBKIT_WEB_SETTINGS (web_settings)));
g_object_set (copy, g_object_set (copy,
"load-on-startup", priv->load_on_startup,
"homepage", priv->homepage,
"download-folder", priv->download_folder,
"show-download-notification", priv->show_download_notification,
"location-entry-search", priv->location_entry_search,
"preferred-encoding", priv->preferred_encoding,
"toolbar-style", priv->toolbar_style,
"small-toolbar", priv->small_toolbar,
"show-web-search", priv->show_web_search,
"show-new-tab", priv->show_new_tab,
"show-trash", priv->show_trash,
"tab-label-size", priv->tab_label_size, "tab-label-size", priv->tab_label_size,
"close-button", priv->close_button, "close-buttons-on-tabs", priv->close_buttons_on_tabs,
"middle-click-goto", priv->middle_click_goto, "open-new-pages-in", priv->open_new_pages_in,
"middle-click-opens-selection", priv->middle_click_opens_selection,
"open-tabs-in-the-background", priv->open_tabs_in_the_background,
"open-popups-in-tabs", priv->open_popups_in_tabs,
"accept-cookies", priv->accept_cookies,
"original-cookies-only", priv->original_cookies_only,
"maximum-cookie-age", priv->maximum_cookie_age,
"remember-last-visited-pages", priv->remember_last_visited_pages,
"maximum-history-age", priv->maximum_history_age,
"remember-last-form-inputs", priv->remember_last_form_inputs,
"remember-last-downloaded-files", priv->remember_last_downloaded_files,
"http-proxy", priv->http_proxy,
"cache-size", priv->cache_size,
NULL); NULL);
return copy; return copy;

View file

@ -42,6 +42,76 @@ struct _MidoriWebSettings
MidoriWebSettingsPrivate* priv; MidoriWebSettingsPrivate* priv;
}; };
typedef enum
{
MIDORI_STARTUP_BLANK,
MIDORI_STARTUP_HOMEPAGE,
MIDORI_STARTUP_LAST_OPEN_PAGES
} MidoriStartup;
GType
midori_startup_get_type (void) G_GNUC_CONST;
#define MIDORI_TYPE_STARTUP \
(midori_startup_get_type ())
typedef enum
{
MIDORI_ENCODING_CHINESE,
MIDORI_ENCODING_JAPANESE,
MIDORI_ENCODING_RUSSIAN,
MIDORI_ENCODING_UNICODE,
MIDORI_ENCODING_WESTERN,
MIDORI_ENCODING_CUSTOM
} MidoriPreferredEncoding;
GType
midori_preferred_encoding_get_type (void) G_GNUC_CONST;
#define MIDORI_TYPE_PREFERRED_ENCODING \
(midori_preferred_encoding_get_type ())
typedef enum
{
MIDORI_NEW_PAGE_TAB,
MIDORI_NEW_PAGE_WINDOW,
MIDORI_NEW_PAGE_CURRENT
} MidoriNewPage;
GType
midori_new_page_get_type (void) G_GNUC_CONST;
#define MIDORI_TYPE_NEW_PAGE \
(midori_new_page_get_type ())
typedef enum
{
MIDORI_TOOLBAR_DEFAULT,
MIDORI_TOOLBAR_ICONS,
MIDORI_TOOLBAR_TEXT,
MIDORI_TOOLBAR_BOTH,
MIDORI_TOOLBAR_BOTH_HORIZ
} MidoriToolbarStyle;
GType
midori_toolbar_style_get_type (void) G_GNUC_CONST;
#define MIDORI_TYPE_TOOLBAR_STYLE \
(midori_toolbar_style_get_type ())
typedef enum
{
MIDORI_ACCEPT_COOKIES_ALL,
MIDORI_ACCEPT_COOKIES_SESSION,
MIDORI_ACCEPT_COOKIES_NONE
} MidoriAcceptCookies;
GType
midori_accept_cookies_get_type (void) G_GNUC_CONST;
#define MIDORI_TYPE_ACCEPT_COOKIES \
(midori_accept_cookies_get_type ())
struct _MidoriWebSettingsClass struct _MidoriWebSettingsClass
{ {
WebKitWebSettingsClass parent_class; WebKitWebSettingsClass parent_class;

View file

@ -543,8 +543,8 @@ _midori_web_view_update_settings (MidoriWebView* web_view)
g_object_get (G_OBJECT (priv->settings), g_object_get (G_OBJECT (priv->settings),
"tab-label-size", &priv->tab_label_size, "tab-label-size", &priv->tab_label_size,
"close-button", &priv->close_button, "close-buttons-on-tabs", &priv->close_button,
"middle-click-goto", &priv->middle_click_goto, "middle-click-opens-selection", &priv->middle_click_goto,
NULL); NULL);
} }
@ -565,13 +565,13 @@ midori_web_view_settings_notify (MidoriWebSettings* web_settings,
priv->tab_label_size = g_value_get_int (&value); priv->tab_label_size = g_value_get_int (&value);
_midori_web_view_update_tab_label_size (web_view); _midori_web_view_update_tab_label_size (web_view);
} }
else if (name == g_intern_string ("close-button")) else if (name == g_intern_string ("close-buttons-on-tabs"))
{ {
priv->close_button = g_value_get_boolean (&value); priv->close_button = g_value_get_boolean (&value);
if (priv->tab_close) if (priv->tab_close)
sokoke_widget_set_visible (priv->tab_close, priv->close_button); sokoke_widget_set_visible (priv->tab_close, priv->close_button);
} }
else if (name == g_intern_string ("middle-click-goto")) else if (name == g_intern_string ("middle-click-opens-selection"))
priv->middle_click_goto = g_value_get_boolean (&value); priv->middle_click_goto = g_value_get_boolean (&value);
else if (!g_object_class_find_property (G_OBJECT_GET_CLASS (web_settings), else if (!g_object_class_find_property (G_OBJECT_GET_CLASS (web_settings),
name)) name))