Switch configuration to MidoriWebSettings.

Switch configuration logic from a custom structure to
fully rely on MidoriWebSettings. This includes revamping
the preferences dialog. The old logic is not yet
replaced completely, this will follow soon, thus several
settings will have no effect right now.
This commit is contained in:
Christian Dywan 2008-04-13 21:51:43 +02:00
parent a9eb81a016
commit cdde1293ab
10 changed files with 399 additions and 778 deletions

View file

@ -4,6 +4,7 @@ midori.desktop.in
src/conf.c src/conf.c
src/helpers.c src/helpers.c
src/main.c src/main.c
src/midori-console.c
src/midori-browser.c src/midori-browser.c
src/midori-panel.c src/midori-panel.c
src/midori-trash.c src/midori-trash.c

View file

@ -34,58 +34,6 @@ gboolean config_from_file(CConfig* config, const gchar* filename, GError** error
{ {
GKeyFile* keyFile = g_key_file_new(); GKeyFile* keyFile = g_key_file_new();
g_key_file_load_from_file(keyFile, filename, G_KEY_FILE_KEEP_COMMENTS, error); g_key_file_load_from_file(keyFile, filename, G_KEY_FILE_KEEP_COMMENTS, error);
/*g_key_file_load_from_data_dirs(keyFile, sFilename, NULL
, G_KEY_FILE_KEEP_COMMENTS, error);*/
#define GET_INT(var, key, default) \
var = sokoke_key_file_get_integer_default( \
keyFile, "browser", key, default, NULL)
#define GET_STR(var, key, default) \
var = sokoke_key_file_get_string_default( \
keyFile, "browser", key, default, NULL)
GET_INT(config->startup, "Startup", CONFIG_STARTUP_HOMEPAGE);
GET_STR(config->homepage, "Homepage", "http://www.google.com");
GET_STR(config->locationSearch, "LocationSearch", "http://www.google.com/search?q=%s");
GET_INT(config->toolbarNavigation, "ToolbarNavigation", TRUE);
GET_INT(config->toolbarBookmarks, "ToolbarBookmarks", FALSE);
GET_INT(config->toolbarStatus, "ToolbarStatus", TRUE);
//GET_INT(config->toolbarTransfer, "ToolbarTransfer", FALSE);
GET_INT(config->toolbarStyle, "ToolbarStyle", CONFIG_TOOLBAR_DEFAULT);
GET_INT(config->toolbarSmall, "ToolbarSmall", FALSE);
GET_INT(config->toolbarWebSearch, "ToolbarWebSearch", TRUE);
GET_INT(config->toolbarNewTab, "ToolbarNewTab", TRUE);
GET_INT(config->toolbarClosedTabs, "ToolbarClosedTabs", TRUE);
GET_INT(config->panelShow, "PanelShow", FALSE);
GET_INT(config->panelActive, "PanelActive", 0);
GET_STR(config->panelPageholder, "PanelPageholder", "http://www.google.com");
GET_INT(config->tabSize, "TabSize", 10);
GET_INT(config->tabClose, "TabClose", TRUE);
GET_INT(config->newPages, "NewPages", CONFIG_NEWPAGES_TAB_NEW);
GET_INT(config->openTabsInTheBackground, "OpenTabsInTheBackground", FALSE);
GET_INT(config->openPopupsInTabs, "OpenPopupsInTabs", FALSE);
GET_INT(config->middleClickGoto, "MiddleClickGoto", FALSE);
#undef GET_INT
#undef GET_STR
#define GET_INT(var, key, default) \
var = sokoke_key_file_get_integer_default( \
keyFile, "content", key, default, NULL)
#define GET_STR(var, key, default) \
var = sokoke_key_file_get_string_default( \
keyFile, "content", key, default, NULL)
GET_STR(config->defaultFontFamily, "DefaultFontFamily", "Sans");
GET_INT(config->defaultFontSize, "DefaultFontSize", 10);
GET_INT(config->minimumFontSize, "MinimumFontSize", 5);
GET_STR(config->defaultEncoding, "DefaultEncoding", "UTF-8");
GET_INT(config->autoLoadImages, "AutoLoadImages", TRUE);
GET_INT(config->autoShrinkImages, "AutoShrinkImages", TRUE);
GET_INT(config->printBackgrounds, "PrintBackgrounds", FALSE);
GET_INT(config->resizableTextAreas, "ResizableTextAreas", FALSE);
GET_INT(config->userStylesheet, "UserStylesheet", FALSE);
GET_STR(config->userStylesheetUri, "UserStylesheetUri", "");
GET_INT(config->enableScripts, "EnableScripts", TRUE);
GET_INT(config->enablePlugins, "EnablePlugins", TRUE);
#undef GET_INT
#undef GET_STR
#define GET_INT(var, key, default) \ #define GET_INT(var, key, default) \
var = sokoke_key_file_get_integer_default( \ var = sokoke_key_file_get_integer_default( \
@ -109,41 +57,6 @@ gboolean config_to_file(CConfig* config, const gchar* filename, GError** error)
{ {
GKeyFile* keyFile = g_key_file_new(); GKeyFile* keyFile = g_key_file_new();
g_key_file_set_integer(keyFile, "browser", "Startup", config->startup);
g_key_file_set_string (keyFile, "browser", "Homepage", config->homepage);
g_key_file_set_string (keyFile, "browser", "LocationSearch", config->locationSearch);
g_key_file_set_integer(keyFile, "browser", "ToolbarNavigation", config->toolbarNavigation);
g_key_file_set_integer(keyFile, "browser", "ToolbarBookmarks", config->toolbarBookmarks);
//g_key_file_set_integer(keyFile, "browser", "ToolbarTransfers", config->toolbarTransfers);
g_key_file_set_integer(keyFile, "browser", "ToolbarStatus", config->toolbarStatus);
g_key_file_set_integer(keyFile, "browser", "ToolbarStyle", config->toolbarStyle);
g_key_file_set_integer(keyFile, "browser", "ToolbarSmall", config->toolbarSmall);
g_key_file_set_integer(keyFile, "browser", "ToolbarWebSearch", config->toolbarWebSearch);
g_key_file_set_integer(keyFile, "browser", "ToolbarNewTab", config->toolbarNewTab);
g_key_file_set_integer(keyFile, "browser", "ToolbarClosedTabs", config->toolbarClosedTabs);
g_key_file_set_integer(keyFile, "browser", "PanelShow", config->panelShow);
g_key_file_set_integer(keyFile, "browser", "PanelActive", config->panelActive);
g_key_file_set_string (keyFile, "browser", "PanelPageholder", config->panelPageholder);
g_key_file_set_integer(keyFile, "browser", "TabSize", config->tabSize);
g_key_file_set_integer(keyFile, "browser", "TabClose", config->tabClose);
g_key_file_set_integer(keyFile, "browser", "NewPages", config->newPages);
g_key_file_set_integer(keyFile, "browser", "OpenTabsInTheBackground", config->openTabsInTheBackground);
g_key_file_set_integer(keyFile, "browser", "OpenPopupsInTabs", config->openPopupsInTabs);
g_key_file_set_integer(keyFile, "browser", "MiddleClickGoto", config->middleClickGoto);
g_key_file_set_string (keyFile, "content", "DefaultFontFamily", config->defaultFontFamily);
g_key_file_set_integer(keyFile, "content", "DefaultFontSize", config->defaultFontSize);
g_key_file_set_integer(keyFile, "content", "MinimumFontSize", config->minimumFontSize);
g_key_file_set_string (keyFile, "content", "DefaultEncoding", config->defaultEncoding);
g_key_file_set_integer(keyFile, "content", "AutoLoadImages", config->autoLoadImages);
g_key_file_set_integer(keyFile, "content", "AutoShrinkImages", config->autoShrinkImages);
g_key_file_set_integer(keyFile, "content", "PrintBackgrounds", config->printBackgrounds);
g_key_file_set_integer(keyFile, "content", "ResizableTextAreas", config->resizableTextAreas);
g_key_file_set_integer(keyFile, "content", "UserStylesheet", config->userStylesheet);
g_key_file_set_string (keyFile, "content", "UserStylesheetUri", config->userStylesheetUri);
g_key_file_set_integer(keyFile, "content", "EnableScripts", config->enableScripts);
g_key_file_set_integer(keyFile, "content", "EnablePlugins", config->enablePlugins);
g_key_file_set_integer(keyFile, "session", "RememberWinSize", config->rememberWinSize); g_key_file_set_integer(keyFile, "session", "RememberWinSize", config->rememberWinSize);
g_key_file_set_integer(keyFile, "session", "WinWidth", config->winWidth); g_key_file_set_integer(keyFile, "session", "WinWidth", config->winWidth);
g_key_file_set_integer(keyFile, "session", "WinHeight", config->winHeight); g_key_file_set_integer(keyFile, "session", "WinHeight", config->winHeight);

View file

@ -133,17 +133,141 @@ locale_init (void)
#endif #endif
} }
static MidoriWebSettings*
settings_new_from_file (const gchar* filename)
{
MidoriWebSettings* settings = midori_web_settings_new ();
GKeyFile* key_file = g_key_file_new ();
GError* error = NULL;
if (!g_key_file_load_from_file (key_file, filename,
G_KEY_FILE_KEEP_COMMENTS, &error))
{
if (error->code != G_FILE_ERROR_NOENT)
printf (_("The configuration couldn't be loaded. %s\n"),
error->message);
g_error_free (error);
}
GObjectClass* class = G_OBJECT_GET_CLASS (settings);
guint i, n_properties;
GParamSpec** pspecs = g_object_class_list_properties (class, &n_properties);
for (i = 0; i < n_properties; i++)
{
GParamSpec* pspec = pspecs[i];
if (!(pspec->flags & G_PARAM_WRITABLE))
continue;
GType type = G_PARAM_SPEC_TYPE (pspec);
const gchar* property = g_param_spec_get_name (pspec);
if (type == G_TYPE_PARAM_STRING)
{
gchar* string = sokoke_key_file_get_string_default (key_file,
"settings", property,
G_PARAM_SPEC_STRING (pspec)->default_value, NULL);
g_object_set (settings, property, string, NULL);
g_free (string);
}
else if (type == G_TYPE_PARAM_INT)
{
guint integer = sokoke_key_file_get_integer_default (key_file,
"settings", property,
G_PARAM_SPEC_INT (pspec)->default_value, NULL);
g_object_set (settings, property, integer, NULL);
}
else if (type == G_TYPE_PARAM_BOOLEAN)
{
gboolean boolean = sokoke_key_file_get_boolean_default (key_file,
"settings", property,
G_PARAM_SPEC_BOOLEAN (pspec)->default_value, NULL);
g_object_set (settings, property, boolean, NULL);
}
else if (type == G_TYPE_PARAM_ENUM)
{
GEnumClass* enum_class = G_ENUM_CLASS (
g_type_class_ref (pspec->value_type));
GEnumValue* enum_value = g_enum_get_value (enum_class,
G_PARAM_SPEC_ENUM (pspec)->default_value);
gchar* string = sokoke_key_file_get_string_default (key_file,
"settings", property,
enum_value->value_name, NULL);
enum_value = g_enum_get_value_by_name (enum_class, string);
g_object_set (settings, property, enum_value->value, NULL);
g_free (string);
g_type_class_unref (enum_class);
}
else
g_warning ("Unhandled settings property '%s'", property);
}
return settings;
}
static gboolean
settings_save_to_file (MidoriWebSettings* settings,
const gchar* filename,
GError** error)
{
GKeyFile* key_file = g_key_file_new ();
GObjectClass* class = G_OBJECT_GET_CLASS (settings);
guint i, n_properties;
GParamSpec** pspecs = g_object_class_list_properties (class, &n_properties);
for (i = 0; i < n_properties; i++)
{
GParamSpec* pspec = pspecs[i];
GType type = G_PARAM_SPEC_TYPE (pspec);
const gchar* property = g_param_spec_get_name (pspec);
if (!(pspec->flags & G_PARAM_WRITABLE))
{
gchar* comment = g_strdup_printf ("# %s", property);
g_key_file_set_string (key_file, "settings", comment, "");
g_free (comment);
continue;
}
if (type == G_TYPE_PARAM_STRING)
{
const gchar* string;
g_object_get (settings, property, &string, NULL);
g_key_file_set_string (key_file, "settings", property,
string ? string : "");
}
else if (type == G_TYPE_PARAM_INT)
{
gint integer;
g_object_get (settings, property, &integer, NULL);
g_key_file_set_integer (key_file, "settings", property, integer);
}
else if (type == G_TYPE_PARAM_BOOLEAN)
{
gboolean boolean;
g_object_get (settings, property, &boolean, NULL);
g_key_file_set_boolean (key_file, "settings", property, boolean);
}
else if (type == G_TYPE_PARAM_ENUM)
{
GEnumClass* enum_class = G_ENUM_CLASS (
g_type_class_ref (pspec->value_type));
gint integer;
g_object_get (settings, property, &integer, NULL);
GEnumValue* enum_value = g_enum_get_value (enum_class, integer);
g_key_file_set_string (key_file, "settings", property,
enum_value->value_name);
}
else
g_warning ("Unhandled settings property '%s'", property);
}
gboolean saved = sokoke_key_file_save_to_file (key_file, filename, error);
g_key_file_free (key_file);
return saved;
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
locale_init(); locale_init();
g_set_application_name(_("midori")); g_set_application_name(_("midori"));
// Parse cli options // Parse cli options
gint repeats = 2;
gboolean version = FALSE; gboolean version = FALSE;
GOptionEntry entries[] = GOptionEntry entries[] =
{ {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, N_("Display program version"), NULL } { "version", 'v', 0, G_OPTION_ARG_NONE, &version,
N_("Display program version"), NULL }
}; };
GError* error = NULL; GError* error = NULL;
@ -179,75 +303,69 @@ int main(int argc, char** argv)
} }
// Load configuration files // Load configuration files
GString* errorMessages = g_string_new(NULL); GString* error_messages = g_string_new (NULL);
// TODO: What about default config in a global config folder? gchar* config_path = g_build_filename (g_get_user_config_dir (),
gchar* configPath = g_build_filename(g_get_user_config_dir(), PACKAGE_NAME, NULL); PACKAGE_NAME, NULL);
g_mkdir_with_parents(configPath, 0755); g_mkdir_with_parents (config_path, 0755);
gchar* configFile = g_build_filename(configPath, "config", NULL); gchar* config_file = g_build_filename (config_path, "config", NULL);
error = NULL; error = NULL;
/*CConfig* */config = config_new(); MidoriWebSettings* settings = settings_new_from_file (config_file);
if(!config_from_file(config, configFile, &error)) webSettings = settings;
{ katze_assign (config_file, g_build_filename (config_path, "accels", NULL));
if(error->code != G_FILE_ERROR_NOENT) gtk_accel_map_load (config_file);
g_string_append_printf(errorMessages katze_assign (config_file, g_build_filename (config_path, "search", NULL));
, _("The configuration couldn't be loaded. %s\n"), error->message);
g_error_free(error);
}
g_free(configFile);
configFile = g_build_filename(configPath, "accels", NULL);
gtk_accel_map_load(configFile);
g_free(configFile);
configFile = g_build_filename(configPath, "search", NULL);
error = NULL; error = NULL;
searchEngines = search_engines_new(); searchEngines = search_engines_new ();
if(!search_engines_from_file(&searchEngines, configFile, &error)) if (!search_engines_from_file (&searchEngines, config_file, &error))
{ {
// FIXME: We may have a "file empty" error, how do we recognize that? // FIXME: We may have a "file empty" error, how do we recognize that?
/*if(error->code != G_FILE_ERROR_NOENT) /*if (error->code != G_FILE_ERROR_NOENT)
g_string_append_printf(errorMessages g_string_append_printf (error_messages,
, _("The search engines couldn't be loaded. %s\n"), error->message);*/ _("The search engines couldn't be loaded. %s\n"),
g_error_free(error); error->message);*/
g_error_free (error);
} }
g_free(configFile); katze_assign (config_file, g_build_filename (config_path, "bookmarks.xbel",
configFile = g_build_filename(configPath, "bookmarks.xbel", NULL); NULL));
bookmarks = katze_xbel_folder_new(); bookmarks = katze_xbel_folder_new();
error = NULL; error = NULL;
if(!katze_xbel_folder_from_file(bookmarks, configFile, &error)) if (!katze_xbel_folder_from_file (bookmarks, config_file, &error))
{ {
if(error->code != G_FILE_ERROR_NOENT) if (error->code != G_FILE_ERROR_NOENT)
g_string_append_printf(errorMessages g_string_append_printf (error_messages,
, _("The bookmarks couldn't be loaded. %s\n"), error->message); _("The bookmarks couldn't be loaded. %s\n"), error->message);
g_error_free(error); g_error_free (error);
} }
g_free(configFile); g_free (config_file);
KatzeXbelItem* _session = katze_xbel_folder_new(); KatzeXbelItem* _session = katze_xbel_folder_new();
config = config_new ();
if(config->startup == CONFIG_STARTUP_SESSION) if(config->startup == CONFIG_STARTUP_SESSION)
{ {
configFile = g_build_filename(configPath, "session.xbel", NULL); config_file = g_build_filename (config_path, "session.xbel", NULL);
error = NULL; error = NULL;
if(!katze_xbel_folder_from_file(_session, configFile, &error)) if (!katze_xbel_folder_from_file (_session, config_file, &error))
{ {
if(error->code != G_FILE_ERROR_NOENT) if (error->code != G_FILE_ERROR_NOENT)
g_string_append_printf(errorMessages g_string_append_printf (error_messages,
, _("The session couldn't be loaded. %s\n"), error->message); _("The session couldn't be loaded. %s\n"), error->message);
g_error_free(error); g_error_free (error);
} }
g_free(configFile); g_free (config_file);
} }
configFile = g_build_filename(configPath, "tabtrash.xbel", NULL); config_file = g_build_filename (config_path, "tabtrash.xbel", NULL);
KatzeXbelItem* xbel_trash = katze_xbel_folder_new(); KatzeXbelItem* xbel_trash = katze_xbel_folder_new ();
error = NULL; error = NULL;
if(!katze_xbel_folder_from_file(xbel_trash, configFile, &error)) if (!katze_xbel_folder_from_file (xbel_trash, config_file, &error))
{ {
if(error->code != G_FILE_ERROR_NOENT) if (error->code != G_FILE_ERROR_NOENT)
g_string_append_printf(errorMessages g_string_append_printf(error_messages,
, _("The trash couldn't be loaded. %s\n"), error->message); _("The trash couldn't be loaded. %s\n"), error->message);
g_error_free(error); g_error_free (error);
} }
g_free(configFile); g_free (config_file);
// In case of errors // In case of errors
if(errorMessages->len) if (error_messages->len)
{ {
GtkWidget* dialog = gtk_message_dialog_new(NULL GtkWidget* dialog = gtk_message_dialog_new(NULL
, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE , 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE
@ -257,7 +375,7 @@ int main(int argc, char** argv)
// FIXME: Use custom program icon // FIXME: Use custom program icon
gtk_window_set_icon_name(GTK_WINDOW(dialog), "web-browser"); gtk_window_set_icon_name(GTK_WINDOW(dialog), "web-browser");
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog) gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog)
, "%s", errorMessages->str); , "%s", error_messages->str);
gtk_dialog_add_buttons(GTK_DIALOG(dialog) gtk_dialog_add_buttons(GTK_DIALOG(dialog)
, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL , GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL
, "_Ignore", GTK_RESPONSE_ACCEPT , "_Ignore", GTK_RESPONSE_ACCEPT
@ -269,14 +387,14 @@ int main(int argc, char** argv)
katze_xbel_item_unref(bookmarks); katze_xbel_item_unref(bookmarks);
katze_xbel_item_unref(_session); katze_xbel_item_unref(_session);
katze_xbel_item_unref(xbel_trash); katze_xbel_item_unref(xbel_trash);
g_string_free(errorMessages, TRUE); g_string_free(error_messages, TRUE);
return 0; return 0;
} }
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
/* FIXME: Since we will overwrite files that could not be loaded /* FIXME: Since we will overwrite files that could not be loaded
, would we want to make backups? */ , would we want to make backups? */
} }
g_string_free(errorMessages, TRUE); g_string_free (error_messages, TRUE);
// TODO: Handle any number of separate uris from argv // TODO: Handle any number of separate uris from argv
// Open as many tabs as we have uris, seperated by pipes // Open as many tabs as we have uris, seperated by pipes
@ -301,36 +419,15 @@ int main(int argc, char** argv)
katze_xbel_bookmark_set_href(item, config->homepage); katze_xbel_bookmark_set_href(item, config->homepage);
katze_xbel_folder_prepend_item(_session, item); katze_xbel_folder_prepend_item(_session, item);
} }
g_free(configPath); g_free (config_path);
stock_items_init(); stock_items_init();
MidoriWebSettings* settings;
settings = g_object_new (MIDORI_TYPE_WEB_SETTINGS,
"default-font-family", config->defaultFontFamily,
"default-font-size", config->defaultFontSize,
"minimum-font-size", config->minimumFontSize,
"default-encoding", config->defaultEncoding,
"auto-load-images", config->autoLoadImages,
"auto-shrink-images", config->autoShrinkImages,
"print-backgrounds", config->printBackgrounds,
"resizable-text-areas", config->resizableTextAreas,
"user-stylesheet-uri",
config->userStylesheet ?
config->userStylesheetUri : NULL,
"enable-scripts", config->enableScripts,
"enable-plugins", config->enablePlugins,
"tab-label-size", config->tabSize,
"close-buttons-on-tabs", config->tabClose,
"middle-click-opens-selection", config->middleClickGoto,
NULL);
webSettings = settings;
MidoriTrash* trash = g_object_new (MIDORI_TYPE_TRASH, MidoriTrash* trash = g_object_new (MIDORI_TYPE_TRASH,
"limit", 10, "limit", 10,
NULL); NULL);
guint i;
guint n = katze_xbel_folder_get_n_items (xbel_trash); guint n = katze_xbel_folder_get_n_items (xbel_trash);
guint i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
KatzeXbelItem* item = katze_xbel_folder_get_nth_item (xbel_trash, i); KatzeXbelItem* item = katze_xbel_folder_get_nth_item (xbel_trash, i);
@ -367,59 +464,58 @@ int main(int argc, char** argv)
g_object_unref (accel_group); g_object_unref (accel_group);
// Save configuration files // Save configuration files
configPath = g_build_filename(g_get_user_config_dir(), PACKAGE_NAME, NULL); config_path = g_build_filename (g_get_user_config_dir(), PACKAGE_NAME,
g_mkdir_with_parents(configPath, 0755); NULL);
configFile = g_build_filename(configPath, "search", NULL); g_mkdir_with_parents (config_path, 0755);
config_file = g_build_filename (config_path, "search", NULL);
error = NULL; error = NULL;
if(!search_engines_to_file(searchEngines, configFile, &error)) if (!search_engines_to_file (searchEngines, config_file, &error))
{ {
g_warning("The search engines couldn't be saved. %s", error->message); g_warning("The search engines couldn't be saved. %s", error->message);
g_error_free(error); g_error_free(error);
} }
search_engines_free(searchEngines); search_engines_free(searchEngines);
g_free(configFile); g_free (config_file);
configFile = g_build_filename(configPath, "bookmarks.xbel", NULL); config_file = g_build_filename (config_path, "bookmarks.xbel", NULL);
error = NULL; error = NULL;
if(!katze_xbel_folder_to_file(bookmarks, configFile, &error)) if (!katze_xbel_folder_to_file (bookmarks, config_file, &error))
{ {
g_warning("The bookmarks couldn't be saved. %s", error->message); g_warning("The bookmarks couldn't be saved. %s", error->message);
g_error_free(error); g_error_free(error);
} }
katze_xbel_item_unref(bookmarks); katze_xbel_item_unref(bookmarks);
g_free(configFile); g_free (config_file);
configFile = g_build_filename(configPath, "tabtrash.xbel", NULL); config_file = g_build_filename (config_path, "tabtrash.xbel", NULL);
error = NULL; error = NULL;
if (!katze_xbel_folder_to_file (xbel_trash, configFile, &error)) if (!katze_xbel_folder_to_file (xbel_trash, config_file, &error))
{ {
g_warning ("The trash couldn't be saved. %s", error->message); g_warning ("The trash couldn't be saved. %s", error->message);
g_error_free (error); g_error_free (error);
} }
katze_xbel_item_unref (xbel_trash); katze_xbel_item_unref (xbel_trash);
g_free (configFile);
if(config->startup == CONFIG_STARTUP_SESSION) if(config->startup == CONFIG_STARTUP_SESSION)
{ {
configFile = g_build_filename(configPath, "session.xbel", NULL); katze_assign (config_file, g_build_filename (config_path,
"session.xbel", NULL));
error = NULL; error = NULL;
if(!katze_xbel_folder_to_file(session, configFile, &error)) if (!katze_xbel_folder_to_file (session, config_file, &error))
{ {
g_warning("The session couldn't be saved. %s", error->message); g_warning ("The session couldn't be saved. %s", error->message);
g_error_free(error); g_error_free (error);
} }
g_free(configFile);
} }
katze_xbel_item_unref(session); katze_xbel_item_unref (session);
configFile = g_build_filename(configPath, "config", NULL); katze_assign (config_file, g_build_filename (config_path, "config", NULL));
error = NULL; error = NULL;
if(!config_to_file(config, configFile, &error)) if (!settings_save_to_file (settings, config_file, &error))
{ {
g_warning("The configuration couldn't be saved. %s", error->message); g_warning ("The configuration couldn't be saved. %s", error->message);
g_error_free(error); g_error_free (error);
} }
config_free(config); config_free (config);
g_free(configFile); katze_assign (config_file, g_build_filename (config_path, "accels", NULL));
configFile = g_build_filename(configPath, "accels", NULL); gtk_accel_map_save (config_file);
gtk_accel_map_save(configFile); g_free (config_file);
g_free(configFile); g_free (config_path);
g_free(configPath);
return 0; return 0;
} }

View file

@ -867,7 +867,10 @@ _action_preferences_activate (GtkAction* action,
gtk_window_present (GTK_WINDOW (dialog)); gtk_window_present (GTK_WINDOW (dialog));
else else
{ {
dialog = prefs_preferences_dialog_new (browser); MidoriBrowserPrivate* priv = browser->priv;
dialog = prefs_preferences_dialog_new (GTK_WINDOW (browser),
priv->settings);
gtk_widget_show (dialog); gtk_widget_show (dialog);
} }
} }

View file

@ -60,7 +60,7 @@ midori_trash_get_property (GObject* object,
static void static void
midori_trash_class_init (MidoriTrashClass* class) midori_trash_class_init (MidoriTrashClass* class)
{ {
signals[INSERTED] = g_signal_new( signals[INSERTED] = g_signal_new (
"inserted", "inserted",
G_TYPE_FROM_CLASS(class), G_TYPE_FROM_CLASS(class),
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
@ -71,7 +71,7 @@ midori_trash_class_init (MidoriTrashClass* class)
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
G_TYPE_UINT); G_TYPE_UINT);
signals[REMOVED] = g_signal_new( signals[REMOVED] = g_signal_new (
"removed", "removed",
G_TYPE_FROM_CLASS(class), G_TYPE_FROM_CLASS(class),
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),

View file

@ -14,7 +14,7 @@
#include "global.h" #include "global.h"
#include "sokoke.h" #include "sokoke.h"
#include <webkit/webkitwebframe.h> #include <webkit/webkit.h>
#include <string.h> #include <string.h>
// This is unstable API, so we need to declare it // This is unstable API, so we need to declare it
@ -38,7 +38,7 @@ struct _MidoriWebViewPrivate
gint tab_label_size; gint tab_label_size;
gboolean close_button; gboolean close_button;
gboolean middle_click_goto; gboolean middle_click_opens_selection;
MidoriWebSettings* settings; MidoriWebSettings* settings;
GtkWidget* proxy_menu_item; GtkWidget* proxy_menu_item;
@ -419,7 +419,7 @@ gtk_widget_button_press_event_after (MidoriWebView* web_view,
{ {
MidoriWebViewPrivate* priv = web_view->priv; MidoriWebViewPrivate* priv = web_view->priv;
if (event->button == 2 && priv->middle_click_goto) if (event->button == 2 && priv->middle_click_opens_selection)
{ {
GdkModifierType state = (GdkModifierType) event->state; GdkModifierType state = (GdkModifierType) event->state;
GtkClipboard* clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY); GtkClipboard* clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
@ -544,7 +544,7 @@ _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-buttons-on-tabs", &priv->close_button, "close-buttons-on-tabs", &priv->close_button,
"middle-click-opens-selection", &priv->middle_click_goto, "middle-click-opens-selection", &priv->middle_click_opens_selection,
NULL); NULL);
} }
@ -572,7 +572,7 @@ midori_web_view_settings_notify (MidoriWebSettings* web_settings,
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-opens-selection")) else if (name == g_intern_string ("middle-click-opens-selection"))
priv->middle_click_goto = g_value_get_boolean (&value); priv->middle_click_opens_selection = 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))
g_warning("Unexpected setting '%s'", name); g_warning("Unexpected setting '%s'", name);
@ -591,7 +591,7 @@ midori_web_view_init (MidoriWebView* web_view)
priv->settings = midori_web_settings_new (); priv->settings = midori_web_settings_new ();
_midori_web_view_update_settings (web_view); _midori_web_view_update_settings (web_view);
g_signal_connect (priv->settings, "notify", g_signal_connect (priv->settings, "notify",
G_CALLBACK(midori_web_view_settings_notify), web_view); G_CALLBACK (midori_web_view_settings_notify), web_view);
WebKitWebFrame* web_frame; WebKitWebFrame* web_frame;
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view)); web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));

View file

@ -12,258 +12,26 @@
#include "prefs.h" #include "prefs.h"
#include "helpers.h" #include "helpers.h"
#include "global.h"
#include "sokoke.h" #include "sokoke.h"
#include <glib/gi18n.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
static gboolean on_prefs_homepage_focus_out(GtkWidget* widget static void
, GdkEventFocus event, CPrefs* prefs) clear_button_clicked_cb (GtkWidget* button, GtkWidget* file_chooser)
{ {
katze_assign(config->homepage, g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)))); gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (file_chooser), "");
return FALSE; // Emit "file-set" manually for Gtk doesn't emit it otherwise
g_signal_emit_by_name (file_chooser, "file-set");
} }
static void on_prefs_loadonstartup_changed(GtkWidget* widget, CPrefs* prefs) GtkWidget* prefs_preferences_dialog_new (GtkWindow* window,
{ MidoriWebSettings* settings)
config->startup = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
}
static void on_prefs_defaultFont_changed(GtkWidget* widget, CPrefs* prefs)
{
const gchar* font = gtk_font_button_get_font_name(GTK_FONT_BUTTON(widget));
gchar** components = g_strsplit(font, " ", 0);
guint i, n = g_strv_length(components) - 1;
GString* fontName = g_string_new(NULL);
for(i = 0; i < n; i++)
g_string_append_printf(fontName, "%s ", components[i]);
katze_assign(config->defaultFontFamily, g_string_free(fontName, FALSE));
config->defaultFontSize = atoi(components[n]);
g_strfreev(components);
g_object_set(webSettings, "default-font-family", config->defaultFontFamily
, "default-font-size", config->defaultFontSize, NULL);
}
static void on_prefs_minimumFontSize_changed(GtkWidget* widget, CPrefs* prefs)
{
config->minimumFontSize = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
g_object_set(webSettings, "minimum-font-size", config->minimumFontSize, NULL);
}
static void on_prefs_defaultEncoding_changed(GtkWidget* widget, CPrefs* prefs)
{
gchar* encoding;
switch(gtk_combo_box_get_active(GTK_COMBO_BOX(widget)))
{
case 0:
encoding = g_strdup("BIG5");
break;
case 1:
encoding = g_strdup("SHIFT_JIS");
break;
case 2:
encoding = g_strdup("KOI8-R");
break;
case 3:
encoding = g_strdup("UTF-8");
break;
case 4:
encoding = g_strdup("ISO-8859-1");
break;
default:
encoding = g_strdup("UTF-8");
g_warning("Invalid default encoding");
}
katze_assign(config->defaultEncoding, encoding);
g_object_set(webSettings, "default-encoding", config->defaultEncoding, NULL);
}
static void on_prefs_newpages_changed(GtkWidget* widget, CPrefs* prefs)
{
config->newPages = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
}
void on_prefs_middleClickGoto_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->middleClickGoto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
}
void on_prefs_openTabsInTheBackground_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->openTabsInTheBackground = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
}
static void on_prefs_openPopupsInTabs_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->openPopupsInTabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
}
static void on_prefs_loadImagesAutomatically_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->autoLoadImages = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
g_object_set(webSettings, "auto-load-images", config->autoLoadImages, NULL);
}
static void on_prefs_shrinkImagesToFit_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->autoShrinkImages = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
g_object_set(webSettings, "auto-shrink-images", config->autoShrinkImages, NULL);
}
static void on_prefs_printBackgrounds_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->printBackgrounds = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
g_object_set(webSettings, "print-backgrounds", config->printBackgrounds, NULL);
}
static void on_prefs_resizableTextAreas_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->resizableTextAreas = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
g_object_set(webSettings, "resizable-text-areas", config->resizableTextAreas, NULL);
}
static void on_prefs_enableJavaScript_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->enableScripts = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
g_object_set(webSettings, "enable-scripts", config->enableScripts, NULL);
}
static void on_prefs_enablePlugins_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->enablePlugins = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
g_object_set(webSettings, "enable-plugins", config->enablePlugins, NULL);
}
static void on_prefs_userStylesheet_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->userStylesheet = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
gtk_widget_set_sensitive(prefs->userStylesheetUri, config->userStylesheet);
const gchar* uri = config->userStylesheet ? config->userStylesheetUri : "";
g_object_set(webSettings, "user-stylesheet-uri", uri, NULL);
}
static void on_prefs_userStylesheetUri_file_set(GtkWidget* widget, CPrefs* prefs)
{
katze_assign(config->userStylesheetUri, g_strdup(gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(widget))));
g_object_set(webSettings, "user-stylesheet-uri", config->userStylesheetUri, NULL);
}
static void on_prefs_toolbarstyle_changed(GtkWidget* widget, CPrefs* prefs)
{
config->toolbarStyle = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
/*gtk_toolbar_set_style(GTK_TOOLBAR(prefs->browser->navibar)
, config_to_toolbarstyle(config->toolbarStyle));*/
}
static void on_prefs_toolbarSmall_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->toolbarSmall = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
/*gtk_toolbar_set_icon_size(GTK_TOOLBAR(prefs->browser->navibar)
, config_to_toolbariconsize(config->toolbarSmall));*/
}
static void on_prefs_tabClose_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->tabClose = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
g_object_set(webSettings, "close-button", config->tabClose, NULL);
}
static void on_prefs_tabSize_changed(GtkWidget* widget, CPrefs* prefs)
{
config->tabSize = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
g_object_set(webSettings, "tab-label-size", config->tabSize, NULL);
}
static void on_prefs_toolbarWebSearch_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->toolbarWebSearch = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
//sokoke_widget_set_visible(prefs->browser->webSearch, config->toolbarWebSearch);
}
static void on_prefs_toolbarNewTab_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->toolbarNewTab = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
//sokoke_widget_set_visible(prefs->browser->newTab, config->toolbarNewTab);
}
static void on_prefs_toolbarClosedTabs_toggled(GtkWidget* widget, CPrefs* prefs)
{
config->toolbarClosedTabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
//sokoke_widget_set_visible(prefs->browser->closedTabs, config->toolbarClosedTabs);
}
static gboolean on_prefs_locationsearch_focus_out(GtkWidget* widget
, GdkEventFocus event, CPrefs* prefs)
{
katze_assign(config->locationSearch, g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))));
return FALSE;
}
static void on_prefs_protocols_render_icon(GtkTreeViewColumn* column
, GtkCellRenderer* renderer, GtkTreeModel* model, GtkTreeIter* iter, CPrefs* prefs)
{
gchar* command;
gtk_tree_model_get(model, iter, PROTOCOLS_COL_COMMAND, &command, -1);
// TODO: Would it be better, to not do this on every redraw?
// Determine the actual binary to be able to display an icon
gchar* binary = NULL;
if(command)
binary = strtok(command, " ");
if(binary)
{
gchar* path;
if((path = g_find_program_in_path(binary)))
{
GdkScreen* screen = gtk_widget_get_screen(prefs->treeview);
if(!screen)
screen = gdk_screen_get_default();
GtkIconTheme* icon_theme = gtk_icon_theme_get_for_screen(screen);
if(g_path_is_absolute(binary))
{
g_free(path); path = g_path_get_basename(binary);
}
// TODO: Is it good to just display nothing if there is no icon?
if(!gtk_icon_theme_has_icon(icon_theme, binary))
binary = NULL;
#if GTK_CHECK_VERSION(2, 10, 0)
g_object_set(renderer, "icon-name", binary, NULL);
#else
GdkPixbuf* icon = binary != NULL
? gtk_icon_theme_load_icon(gtk_icon_theme_get_default()
, binary, GTK_ICON_SIZE_MENU, 0, NULL) : NULL;
g_object_set(renderer, "pixbuf", icon, NULL);
if(icon)
g_object_unref(icon);
#endif
g_free(path);
}
else
{
#if GTK_CHECK_VERSION(2, 10, 0)
g_object_set(renderer, "icon-name", NULL, NULL);
#endif
g_object_set(renderer, "stock-id", GTK_STOCK_DIALOG_ERROR, NULL);
}
}
else
{
// We need to reset the icon
#if GTK_CHECK_VERSION(2, 10, 0)
g_object_set(renderer, "icon-name", NULL, NULL);
#else
g_object_set(renderer, "stock-id", NULL, NULL);
#endif
}
g_free(command);
}
GtkWidget* prefs_preferences_dialog_new(MidoriBrowser* browser)
{ {
gchar* dialogTitle = g_strdup_printf(_("%s Preferences"), g_get_application_name()); gchar* dialogTitle = g_strdup_printf(_("%s Preferences"), g_get_application_name());
GtkWidget* dialog = gtk_dialog_new_with_buttons(dialogTitle GtkWidget* dialog = gtk_dialog_new_with_buttons(dialogTitle
, GTK_WINDOW(browser) , window
, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR , GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR
, GTK_STOCK_HELP, GTK_RESPONSE_HELP , GTK_STOCK_HELP, GTK_RESPONSE_HELP
, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE , GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE
@ -274,7 +42,6 @@ GtkWidget* prefs_preferences_dialog_new(MidoriBrowser* browser)
g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog); g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
CPrefs* prefs = g_new0(CPrefs, 1); CPrefs* prefs = g_new0(CPrefs, 1);
prefs->browser = browser;
g_signal_connect(dialog, "response", G_CALLBACK(g_free), prefs); g_signal_connect(dialog, "response", G_CALLBACK(g_free), prefs);
// TODO: Do we want tooltips for explainations or can we omit that? // TODO: Do we want tooltips for explainations or can we omit that?
@ -282,17 +49,16 @@ GtkWidget* prefs_preferences_dialog_new(MidoriBrowser* browser)
// TODO: Take multiple windows into account when applying changes // TODO: Take multiple windows into account when applying changes
GtkWidget* xfce_heading; GtkWidget* xfce_heading;
if((xfce_heading = sokoke_xfce_header_new( if((xfce_heading = sokoke_xfce_header_new(
gtk_window_get_icon_name(GTK_WINDOW(browser)), dialogTitle))) gtk_window_get_icon_name(window), dialogTitle)))
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox) gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox)
, xfce_heading, FALSE, FALSE, 0); , xfce_heading, FALSE, FALSE, 0);
g_free(dialogTitle); g_free(dialogTitle);
GtkWidget* notebook = gtk_notebook_new(); GtkWidget* notebook = gtk_notebook_new();
gtk_container_set_border_width(GTK_CONTAINER(notebook), 6); gtk_container_set_border_width(GTK_CONTAINER(notebook), 6);
GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
GtkSizeGroup* sizegroup2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
GtkWidget* page; GtkWidget* frame; GtkWidget* table; GtkWidget* align; GtkWidget* page; GtkWidget* frame; GtkWidget* table; GtkWidget* align;
GtkWidget* button; GtkWidget* checkbutton; GtkWidget* colorbutton; GtkWidget* label; GtkWidget* button;
GtkWidget* combobox; GtkWidget* entry; GtkWidget* hbox; GtkWidget* spinbutton; GtkWidget* entry; GtkWidget* hbox;
#define PAGE_NEW(__label) page = gtk_vbox_new(FALSE, 0);\ #define PAGE_NEW(__label) page = gtk_vbox_new(FALSE, 0);\
gtk_container_set_border_width(GTK_CONTAINER(page), 5);\ gtk_container_set_border_width(GTK_CONTAINER(page), 5);\
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, gtk_label_new(__label)) gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, gtk_label_new(__label))
@ -315,342 +81,166 @@ GtkWidget* prefs_preferences_dialog_new(MidoriBrowser* browser)
gtk_container_add(GTK_CONTAINER(align), __widget);\ gtk_container_add(GTK_CONTAINER(align), __widget);\
gtk_size_group_add_widget(sizegroup, align);\ gtk_size_group_add_widget(sizegroup, align);\
WIDGET_ADD(align, __left, __right, __top, __bottom) WIDGET_ADD(align, __left, __right, __top, __bottom)
#define SEMI_INDENTED_ADD(__widget, __left, __right, __top, __bottom)\
align = gtk_alignment_new(0, 0.5, 0, 0);\
gtk_container_add(GTK_CONTAINER(align), __widget);\
gtk_size_group_add_widget(sizegroup2, align);\
WIDGET_ADD(align, __left, __right, __top, __bottom)
#define SPANNED_ADD(__widget, __left, __right, __top, __bottom)\ #define SPANNED_ADD(__widget, __left, __right, __top, __bottom)\
align = gtk_alignment_new(0, 0.5, 0, 0);\ align = gtk_alignment_new(0, 0.5, 0, 0);\
gtk_container_add(GTK_CONTAINER(align), __widget);\ gtk_container_add(GTK_CONTAINER(align), __widget);\
FILLED_ADD(align, __left, __right, __top, __bottom) FILLED_ADD(align, __left, __right, __top, __bottom)
// Page "General" // Page "General"
PAGE_NEW(_("General")); PAGE_NEW (_("General"));
FRAME_NEW(_("Startup")); FRAME_NEW (_("Startup"));
TABLE_NEW(2, 2); TABLE_NEW (2, 2);
INDENTED_ADD(gtk_label_new(_("Load on startup")), 0, 1, 0, 1); label = katze_property_label (settings, "load-on-startup");
combobox = gtk_combo_box_new_text(); INDENTED_ADD (label, 0, 1, 0, 1);
sokoke_combo_box_add_strings(GTK_COMBO_BOX(combobox) button = katze_property_proxy (settings, "load-on-startup", NULL);
, _("Blank page"), _("Homepage"), _("Last open pages"), NULL); FILLED_ADD (button, 1, 2, 0, 1);
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), config->startup); label = katze_property_label (settings, "homepage");
g_signal_connect(combobox, "changed" INDENTED_ADD (label, 0, 1, 1, 2);
, G_CALLBACK(on_prefs_loadonstartup_changed), prefs); entry = katze_property_proxy (settings, "homepage", NULL);
FILLED_ADD(combobox, 1, 2, 0, 1); FILLED_ADD (entry, 1, 2, 1, 2);
INDENTED_ADD(gtk_label_new(_("Homepage")), 0, 1, 1, 2);
entry = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entry), config->homepage);
g_signal_connect(entry, "focus-out-event"
, G_CALLBACK(on_prefs_homepage_focus_out), prefs);
FILLED_ADD(entry, 1, 2, 1, 2);
// TODO: We need something like "use current website" // TODO: We need something like "use current website"
FRAME_NEW(_("Transfers")); FRAME_NEW (_("Transfers"));
TABLE_NEW(1, 2); TABLE_NEW (1, 2);
INDENTED_ADD(gtk_label_new(_("Download folder")), 0, 1, 0, 1); label = katze_property_label (settings, "download-folder");
GtkWidget* filebutton = gtk_file_chooser_button_new( INDENTED_ADD (label, 0, 1, 0, 1);
_("Choose downloaded files folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); button = katze_property_proxy (settings, "download-folder", "folder");
// FIXME: The default should probably be ~/Desktop FILLED_ADD (button, 1, 2, 0, 1);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filebutton) button = katze_property_proxy (settings, "show-download-notification", "blurb");
, g_get_home_dir()); //... SPANNED_ADD (button, 0, 2, 1, 2);
gtk_widget_set_sensitive(filebutton, FALSE); //...
FILLED_ADD(filebutton, 1, 2, 0, 1);
checkbutton = gtk_check_button_new_with_mnemonic
(_("Show a notification window for finished transfers"));
gtk_widget_set_sensitive(checkbutton, FALSE); //...
SPANNED_ADD(checkbutton, 0, 2, 1, 2);
FRAME_NEW(_("Languages"));
TABLE_NEW(1, 2);
INDENTED_ADD(gtk_label_new(_("Preferred languages")), 0, 1, 0, 1);
entry = gtk_entry_new();
// TODO: Make sth like get_browser_languages_default filtering encodings and C out
// TODO: Provide a real ui with real language names (iso-codes)
const gchar* const* sLanguages = g_get_language_names();
gchar* sLanguagesPreferred = g_strjoinv(",", (gchar**)sLanguages);
gtk_entry_set_text(GTK_ENTRY(entry), sLanguagesPreferred/*config->sLanguagesPreferred*/);
g_free(sLanguagesPreferred);
gtk_widget_set_sensitive(entry, FALSE); //...
FILLED_ADD(entry, 1, 2, 0, 1);
// Page "Appearance" // Page "Appearance"
PAGE_NEW(_("Appearance")); PAGE_NEW (_("Appearance"));
FRAME_NEW(_("Font settings")); FRAME_NEW (_("Font settings"));
TABLE_NEW(5, 2); TABLE_NEW (5, 2);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("Default _font")), 0, 1, 0, 1); label = katze_property_label (settings, "default-font-family");
gchar* defaultFont = g_strdup_printf("%s %d" INDENTED_ADD (label, 0, 1, 0, 1);
, config->defaultFontFamily, config->defaultFontSize); hbox = gtk_hbox_new (FALSE, 4);
button = gtk_font_button_new_with_font(defaultFont); button = katze_property_proxy (settings, "default-font-family", NULL);
g_free(defaultFont); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
g_signal_connect(button, "font-set", G_CALLBACK(on_prefs_defaultFont_changed), prefs); entry = katze_property_proxy (settings, "default-font-size", NULL);
FILLED_ADD(button, 1, 2, 0, 1); gtk_box_pack_end (GTK_BOX (hbox), entry, FALSE, FALSE, 4);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("_Minimum font size")), 0, 1, 1, 2); FILLED_ADD (hbox, 1, 2, 0, 1);
hbox = gtk_hbox_new(FALSE, 4); label = katze_property_label (settings, "minimum-font-size");
spinbutton = gtk_spin_button_new_with_range(1, G_MAXINT, 1); INDENTED_ADD (label, 0, 1, 1, 2);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), config->minimumFontSize); hbox = gtk_hbox_new (FALSE, 4);
g_signal_connect(spinbutton, "value-changed" entry = katze_property_proxy (settings, "minimum-font-size", NULL);
, G_CALLBACK(on_prefs_minimumFontSize_changed), prefs); INDENTED_ADD (entry, 1, 2, 1, 2);
gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0); label = katze_property_label (settings, "preferred-encoding");
button = gtk_button_new_with_mnemonic(_("_Advanced")); INDENTED_ADD (label, 0, 1, 2, 3);
gtk_widget_set_sensitive(button, FALSE); //... button = katze_property_proxy (settings, "preferred-encoding", NULL);
gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 4); FILLED_ADD (button, 1, 2, 2, 3);
FILLED_ADD(hbox, 1, 2, 1, 2);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("Default _encoding")), 0, 1, 2, 3);
combobox = gtk_combo_box_new_text();
sokoke_combo_box_add_strings(GTK_COMBO_BOX(combobox)
, _("Chinese (BIG5)"), _("Japanese (SHIFT_JIS)"), _("Russian (KOI8-R)")
, _("Unicode (UTF-8)"), _("Western (ISO-8859-1)"), NULL);
if(!strcmp(config->defaultEncoding, "BIG5"))
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
else if(!strcmp(config->defaultEncoding, "SHIFT_JIS"))
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 1);
else if(!strcmp(config->defaultEncoding, "KOI8-R"))
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 2);
else if(!strcmp(config->defaultEncoding, "UTF-8"))
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 3);
else if(!strcmp(config->defaultEncoding, "ISO-8859-1"))
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 4);
// FIXME: Provide a 'Custom' item
g_signal_connect(combobox, "changed"
, G_CALLBACK(on_prefs_defaultEncoding_changed), prefs);
FILLED_ADD(combobox, 1, 2, 2, 3);
button = gtk_button_new_with_label(_("Advanced settings"));
gtk_widget_set_sensitive(button, FALSE); //...
WIDGET_ADD(button, 1, 2, 2, 3);
FRAME_NEW(_("Default colors"));
TABLE_NEW(2, 4);
SEMI_INDENTED_ADD(gtk_label_new(_("Text color")), 0, 1, 0, 1);
colorbutton = gtk_color_button_new();
gtk_widget_set_sensitive(colorbutton, FALSE); //...
WIDGET_ADD(colorbutton, 1, 2, 0, 1);
SEMI_INDENTED_ADD(gtk_label_new(_("Background color")), 2, 3, 0, 1);
colorbutton = gtk_color_button_new();
gtk_widget_set_sensitive(colorbutton, FALSE); //...
WIDGET_ADD(colorbutton, 3, 4, 0, 1);
SEMI_INDENTED_ADD(gtk_label_new(_("Link color")), 0, 1, 1, 2);
colorbutton = gtk_color_button_new();
gtk_widget_set_sensitive(colorbutton, FALSE); //...
WIDGET_ADD(colorbutton, 1, 2, 1, 2);
SEMI_INDENTED_ADD(gtk_label_new(_("Visited link color")), 2, 3, 1, 2);
colorbutton = gtk_color_button_new();
gtk_widget_set_sensitive(colorbutton, FALSE); //...
WIDGET_ADD(colorbutton, 3, 4, 1, 2);
// Page "Behavior" // Page "Behavior"
PAGE_NEW(_("Behavior")); PAGE_NEW (_("Behavior"));
FRAME_NEW(_("Browsing")); FRAME_NEW (_("Features"));
TABLE_NEW(3, 2); TABLE_NEW (5, 2);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("Open _new pages in")), 0, 1, 0, 1); button = katze_property_proxy (settings, "auto-load-images", NULL);
combobox = gtk_combo_box_new_text(); INDENTED_ADD (button, 0, 1, 0, 1);
sokoke_combo_box_add_strings(GTK_COMBO_BOX(combobox) button = katze_property_proxy (settings, "auto-shrink-images", NULL);
, _("New tab"), _("New window"), _("Current tab"), NULL); SPANNED_ADD (button, 1, 2, 0, 1);
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), config->newPages); button = katze_property_proxy (settings, "print-backgrounds", NULL);
g_signal_connect(combobox, "changed", G_CALLBACK(on_prefs_newpages_changed), prefs); INDENTED_ADD (button, 0, 1, 1, 2);
gtk_widget_set_sensitive(combobox, FALSE); //... button = katze_property_proxy (settings, "resizable-text-areas", NULL);
FILLED_ADD(combobox, 1, 2, 0, 1); SPANNED_ADD (button, 1, 2, 1, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("_Middle click opens selection")); button = katze_property_proxy (settings, "enable-scripts", NULL);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->middleClickGoto); INDENTED_ADD (button, 0, 1, 2, 3);
g_signal_connect(checkbutton, "toggled" button = katze_property_proxy (settings, "enable-plugins", NULL);
, G_CALLBACK(on_prefs_middleClickGoto_toggled), prefs); SPANNED_ADD(button, 1, 2, 2, 3);
INDENTED_ADD(checkbutton, 0, 1, 1, 2); label = katze_property_label (settings, "user-stylesheet-uri");
checkbutton = gtk_check_button_new_with_mnemonic(_("Open tabs in the _background")); INDENTED_ADD (label, 0, 1, 3, 4);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->openTabsInTheBackground); hbox = gtk_hbox_new (FALSE, 4);
g_signal_connect(checkbutton, "toggled" entry = katze_property_proxy (settings, "user-stylesheet-uri", "uri");
, G_CALLBACK(on_prefs_openTabsInTheBackground_toggled), prefs); gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
SPANNED_ADD(checkbutton, 1, 2, 1, 2); button = gtk_button_new ();
checkbutton = gtk_check_button_new_with_mnemonic(_("Open popups in _tabs")); gtk_container_add (GTK_CONTAINER (button),
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->openPopupsInTabs); gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU));
g_signal_connect(checkbutton, "toggled" g_signal_connect (button, "clicked",
, G_CALLBACK(on_prefs_openPopupsInTabs_toggled), prefs); G_CALLBACK (clear_button_clicked_cb), entry);
gtk_widget_set_sensitive(checkbutton, FALSE); //... gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 4);
SPANNED_ADD(checkbutton, 0, 2, 2, 3); FILLED_ADD (hbox, 1, 2, 3, 4);
FRAME_NEW(_("Features")); label = katze_property_label (settings, "location-entry-search");
TABLE_NEW(4, 2); INDENTED_ADD (label, 0, 1, 4, 5);
checkbutton = gtk_check_button_new_with_mnemonic(_("Load _images")); entry = katze_property_proxy (settings, "location-entry-search", NULL);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->autoLoadImages); FILLED_ADD (entry, 1, 2, 4, 5);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_loadImagesAutomatically_toggled), prefs);
INDENTED_ADD(checkbutton, 0, 1, 0, 1);
checkbutton = gtk_check_button_new_with_mnemonic(_("_Shrink images to fit"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->autoShrinkImages);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_shrinkImagesToFit_toggled), prefs);
SPANNED_ADD(checkbutton, 1, 2, 0, 1);
checkbutton = gtk_check_button_new_with_mnemonic(_("Print _backgrounds"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->printBackgrounds);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_printBackgrounds_toggled), prefs);
INDENTED_ADD(checkbutton, 0, 1, 1, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("_Resizable textareas"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->resizableTextAreas);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_resizableTextAreas_toggled), prefs);
SPANNED_ADD(checkbutton, 1, 2, 1, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("Enable _scripts"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->enableScripts);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_enableJavaScript_toggled), prefs);
INDENTED_ADD(checkbutton, 0, 1, 2, 3);
checkbutton = gtk_check_button_new_with_mnemonic(_("Enable _plugins"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->enablePlugins);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_enablePlugins_toggled), prefs);
SPANNED_ADD(checkbutton, 1, 2, 2, 3);
checkbutton = gtk_check_button_new_with_mnemonic(_("_User Stylesheet"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->userStylesheet);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_userStylesheet_toggled), prefs);
INDENTED_ADD(checkbutton, 0, 1, 3, 4);
filebutton = gtk_file_chooser_button_new(
_("Choose user stylesheet"), GTK_FILE_CHOOSER_ACTION_OPEN);
prefs->userStylesheetUri = filebutton;
gtk_file_chooser_set_uri(GTK_FILE_CHOOSER(filebutton), config->userStylesheetUri);
g_signal_connect(filebutton, "file-set"
, G_CALLBACK(on_prefs_userStylesheetUri_file_set), prefs);
gtk_widget_set_sensitive(filebutton, config->userStylesheet);
FILLED_ADD(filebutton, 1, 2, 3, 4);
// Page "Interface" // Page "Interface"
PAGE_NEW(_("Interface")); PAGE_NEW (_("Interface"));
FRAME_NEW(_("Navigationbar")); FRAME_NEW (_("Navigationbar"));
TABLE_NEW(3, 2); TABLE_NEW (3, 2);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("_Toolbar style")), 0, 1, 0, 1); INDENTED_ADD (katze_property_label (settings, "toolbar-style"), 0, 1, 0, 1);
combobox = gtk_combo_box_new_text(); button = katze_property_proxy (settings, "toolbar-style", NULL);
sokoke_combo_box_add_strings(GTK_COMBO_BOX(combobox) FILLED_ADD(button, 1, 2, 0, 1);
, _("Default"), _("Icons"), _("Text"), _("Both"), _("Both horizontal"), NULL); button = katze_property_proxy (settings, "small-toolbar", NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), config->toolbarStyle); INDENTED_ADD (button, 0, 1, 1, 2);
g_signal_connect(combobox, "changed" button = katze_property_proxy (settings, "show-web-search", NULL);
, G_CALLBACK(on_prefs_toolbarstyle_changed), prefs); SPANNED_ADD (button, 1, 2, 1, 2);
FILLED_ADD(combobox, 1, 2, 0, 1); button = katze_property_proxy (settings, "show-new-tab", NULL);
checkbutton = gtk_check_button_new_with_mnemonic(_("Show small _icons")); INDENTED_ADD (button, 0, 1, 2, 3);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->toolbarSmall); button = katze_property_proxy (settings, "show-trash", NULL);
g_signal_connect(checkbutton, "toggled" SPANNED_ADD (button, 1, 2, 2, 3);
, G_CALLBACK(on_prefs_toolbarSmall_toggled), prefs); FRAME_NEW(_("Browsing"));
INDENTED_ADD(checkbutton, 0, 1, 1, 2); TABLE_NEW (3, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("Show Web_search")); label = katze_property_label (settings, "open-new-pages-in");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->toolbarWebSearch); INDENTED_ADD (label, 0, 1, 0, 1);
g_signal_connect(checkbutton, "toggled" button = katze_property_proxy (settings, "open-new-pages-in", NULL);
, G_CALLBACK(on_prefs_toolbarWebSearch_toggled), prefs); FILLED_ADD (button, 1, 2, 0, 1);
SPANNED_ADD(checkbutton, 1, 2, 1, 2); button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
checkbutton = gtk_check_button_new_with_mnemonic(_("Show _New Tab")); INDENTED_ADD (button, 0, 1, 1, 2);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->toolbarNewTab); button = katze_property_proxy (settings, "open-tabs-in-the-background", NULL);
g_signal_connect(checkbutton, "toggled" SPANNED_ADD (button, 1, 2, 1, 2);
, G_CALLBACK(on_prefs_toolbarNewTab_toggled), prefs); button = katze_property_proxy (settings, "open-popups-in-tabs", NULL);
INDENTED_ADD(checkbutton, 0, 1, 2, 3); SPANNED_ADD (button, 0, 1, 2, 3);
checkbutton = gtk_check_button_new_with_mnemonic(_("Show _Trash")); button = katze_property_proxy (settings, "close-buttons-on-tabs", NULL);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->toolbarClosedTabs); SPANNED_ADD (button, 1, 2, 2, 3);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_toolbarClosedTabs_toggled), prefs);
SPANNED_ADD(checkbutton, 1, 2, 2, 3);
FRAME_NEW(_("Miscellaneous"));
TABLE_NEW(2, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("Close _buttons on tabs"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->tabClose);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_tabClose_toggled), prefs);
INDENTED_ADD(checkbutton, 0, 1, 0, 1);
hbox = gtk_hbox_new(FALSE, 4);
gtk_box_pack_start(GTK_BOX(hbox)
, gtk_label_new_with_mnemonic(_("Tab Si_ze")), FALSE, FALSE, 4);
spinbutton = gtk_spin_button_new_with_range(0, 36, 1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), config->tabSize);
g_signal_connect(spinbutton, "changed"
, G_CALLBACK(on_prefs_tabSize_changed), prefs);
gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0);
FILLED_ADD(hbox, 1, 2, 0, 1);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("_Location search engine")), 0, 1, 1, 2);
entry = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entry), config->locationSearch);
g_signal_connect(entry, "focus-out-event"
, G_CALLBACK(on_prefs_locationsearch_focus_out), prefs);
FILLED_ADD(entry, 1, 2, 1, 2);
// Page "Network" // Page "Network"
PAGE_NEW(_("Network")); PAGE_NEW (_("Network"));
FRAME_NEW(_("Proxy Server")); FRAME_NEW (_("Network"));
TABLE_NEW(5, 2); TABLE_NEW (2, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("_Custom proxy server")); label = katze_property_label (settings, "http-proxy");
gtk_widget_set_sensitive(checkbutton, FALSE); //... INDENTED_ADD (label, 0, 1, 0, 1);
SPANNED_ADD(checkbutton, 0, 2, 0, 1); button = katze_property_proxy (settings, "http-proxy", NULL);
hbox = gtk_hbox_new(FALSE, 4); FILLED_ADD (button, 1, 2, 0, 1);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("_Host/ Port")), 0, 1, 1, 2); label = katze_property_label (settings, "cache-size");
entry = gtk_entry_new(); INDENTED_ADD (label, 0, 1, 1, 2);
gtk_widget_set_sensitive(entry, FALSE); //... hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); entry = katze_property_proxy (settings, "cache-size", NULL);
spinbutton = gtk_spin_button_new_with_range(0, 65535, 1); gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
gtk_widget_set_sensitive(spinbutton, FALSE); //... gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("MB")),
gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0); FALSE, FALSE, 0);
FILLED_ADD(hbox, 1, 2, 1, 2); FILLED_ADD (hbox, 1, 2, 1, 2);
checkbutton = gtk_check_button_new_with_mnemonic
(_("Proxy requires authentication"));
gtk_widget_set_sensitive(checkbutton, FALSE); //...
// TODO: The proxy user and pass need to be indented further
SPANNED_ADD(checkbutton, 0, 2, 2, 3);
INDENTED_ADD(gtk_label_new(_("Username")), 0, 1, 3, 4);
entry = gtk_entry_new();
gtk_widget_set_sensitive(entry, FALSE); //...
FILLED_ADD(entry, 1, 2, 3, 4);
INDENTED_ADD(gtk_label_new(_("Password")), 0, 1, 4, 5);
entry = gtk_entry_new();
gtk_widget_set_sensitive(entry, FALSE); //...
FILLED_ADD(entry, 1, 2, 4, 5);
FRAME_NEW(_("Cache"));
TABLE_NEW(1, 2);
INDENTED_ADD(gtk_label_new(_("Cache size")), 0, 1, 0, 1);
hbox = gtk_hbox_new(FALSE, 4);
spinbutton = gtk_spin_button_new_with_range(0, 10000, 10);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), 100/*config->iCacheSize*/);
gtk_widget_set_sensitive(spinbutton, FALSE); //...
gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("MB")), FALSE, FALSE, 0);
button = gtk_button_new_with_label(_("Clear cache"));
gtk_widget_set_sensitive(button, FALSE); //...
gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 4);
FILLED_ADD(hbox, 1, 2, 0, 1);
// Page "Privacy" // Page "Privacy"
PAGE_NEW(_("Privacy")); PAGE_NEW (_("Privacy"));
FRAME_NEW(_("Cookies")); FRAME_NEW (_("Cookies"));
TABLE_NEW(3, 2); TABLE_NEW (3, 2);
INDENTED_ADD(gtk_label_new(_("Accept cookies")), 0, 1, 0, 1); label = katze_property_label (settings, "accept-cookies");
combobox = gtk_combo_box_new_text(); INDENTED_ADD (label, 0, 1, 0, 1);
sokoke_combo_box_add_strings(GTK_COMBO_BOX(combobox) button = katze_property_proxy (settings, "accept-cookies", NULL);
, _("All cookies"), _("Session cookies"), _("None"), NULL); FILLED_ADD (button, 1, 2, 0, 1);
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0); //... button = katze_property_proxy (settings, "original-cookies-only", "blurb");
gtk_widget_set_sensitive(combobox, FALSE); //... SPANNED_ADD (button, 0, 2, 1, 2);
FILLED_ADD(combobox, 1, 2, 0, 1); label = katze_property_label (settings, "maximum-cookie-age");
checkbutton = gtk_check_button_new_with_mnemonic INDENTED_ADD (label, 0, 1, 2, 3);
(_("Allow cookies from the original website only")); hbox = gtk_hbox_new (FALSE, 4);
gtk_widget_set_sensitive(checkbutton, FALSE); //... entry = katze_property_proxy (settings, "maximum-cookie-age", NULL);
SPANNED_ADD(checkbutton, 0, 2, 1, 2); gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
INDENTED_ADD(gtk_label_new(_("Maximum cookie age")), 0, 1, 2, 3); gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("days")),
hbox = gtk_hbox_new(FALSE, 4); FALSE, FALSE, 0);
spinbutton = gtk_spin_button_new_with_range(0, 360, 1); FILLED_ADD (hbox, 1, 2, 2, 3);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), 30/*config->iCookieAgeMax*/); FRAME_NEW (_("History"));
gtk_widget_set_sensitive(spinbutton, FALSE); //... TABLE_NEW (3, 2);
gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0); button = katze_property_proxy (settings, "remember-last-visited-pages", NULL);
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("days")), FALSE, FALSE, 0); SPANNED_ADD (button, 0, 1, 0, 1);
button = gtk_button_new_with_label(_("View cookies")); hbox = gtk_hbox_new (FALSE, 4);
gtk_widget_set_sensitive(button, FALSE); //... button = katze_property_proxy (settings, "maximum-history-age", NULL);
gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 4); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
FILLED_ADD(hbox, 1, 2, 2, 3); gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("days")),
FRAME_NEW(_("History")); FALSE, FALSE, 0);
TABLE_NEW(3, 2); SPANNED_ADD (hbox, 1, 2, 0, 1);
checkbutton = gtk_check_button_new_with_mnemonic(_("Remember my visited pages")); button = katze_property_proxy (settings, "remember-last-form-inputs", NULL);
gtk_widget_set_sensitive(checkbutton, FALSE); //... SPANNED_ADD (button, 0, 2, 1, 2);
SPANNED_ADD(checkbutton, 0, 1, 0, 1); button = katze_property_proxy (settings, "remember-last-downloaded-files", NULL);
hbox = gtk_hbox_new(FALSE, 4); SPANNED_ADD (button, 0, 2, 2, 3);
spinbutton = gtk_spin_button_new_with_range(0, 360, 1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), 30/*config->iHistoryAgeMax*/);
gtk_widget_set_sensitive(spinbutton, FALSE); //...
gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("days")), FALSE, FALSE, 0);
SPANNED_ADD(hbox, 1, 2, 0, 1);
checkbutton = gtk_check_button_new_with_mnemonic
(_("Remember my form inputs"));
gtk_widget_set_sensitive(checkbutton, FALSE); //...
SPANNED_ADD(checkbutton, 0, 2, 1, 2);
checkbutton = gtk_check_button_new_with_mnemonic
(_("Remember my downloaded files"));
gtk_widget_set_sensitive(checkbutton, FALSE); //...
SPANNED_ADD(checkbutton, 0, 2, 2, 3);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox) gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox)
, notebook, FALSE, FALSE, 4); , notebook, FALSE, FALSE, 4);

View file

@ -12,15 +12,14 @@
#ifndef __PREFS_H__ #ifndef __PREFS_H__
#define __PREFS_H__ 1 #define __PREFS_H__ 1
#include "midori-browser.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "midori-websettings.h"
// -- Types // -- Types
typedef struct typedef struct
{ {
MidoriBrowser* browser;
GtkWidget* userStylesheetUri; GtkWidget* userStylesheetUri;
GtkWidget* treeview; GtkWidget* treeview;
GtkWidget* combobox; GtkWidget* combobox;
@ -37,6 +36,6 @@ enum
// -- Declarations // -- Declarations
GtkWidget* GtkWidget*
prefs_preferences_dialog_new(MidoriBrowser*); prefs_preferences_dialog_new(GtkWindow*, MidoriWebSettings*);
#endif /* !__PREFS_H__ */ #endif /* !__PREFS_H__ */

View file

@ -316,6 +316,18 @@ gint sokoke_key_file_get_integer_default(GKeyFile* keyFile
return g_key_file_get_integer(keyFile, group, key, error); return g_key_file_get_integer(keyFile, group, key, error);
} }
gboolean
sokoke_key_file_get_boolean_default (GKeyFile* key_file,
const gchar* group,
const gchar* key,
const gboolean default_value,
GError** error)
{
if (!g_key_file_has_key (key_file, group, key, NULL))
return default_value;
return g_key_file_get_boolean (key_file, group, key, error);
}
gboolean sokoke_key_file_save_to_file(GKeyFile* keyFile gboolean sokoke_key_file_save_to_file(GKeyFile* keyFile
, const gchar* filename, GError** error) , const gchar* filename, GError** error)
{ {

View file

@ -64,6 +64,13 @@ gint
sokoke_key_file_get_integer_default(GKeyFile*, const gchar*, const gchar* sokoke_key_file_get_integer_default(GKeyFile*, const gchar*, const gchar*
, const gint, GError**); , const gint, GError**);
gboolean
sokoke_key_file_get_boolean_default (GKeyFile* key_file,
const gchar* group,
const gchar* key,
gboolean default_value,
GError** error);
gboolean gboolean
sokoke_key_file_save_to_file(GKeyFile*, const gchar*, GError**); sokoke_key_file_save_to_file(GKeyFile*, const gchar*, GError**);