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/helpers.c
src/main.c
src/midori-console.c
src/midori-browser.c
src/midori-panel.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();
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) \
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();
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", "WinWidth", config->winWidth);
g_key_file_set_integer(keyFile, "session", "WinHeight", config->winHeight);

View file

@ -133,17 +133,141 @@ locale_init (void)
#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)
{
locale_init();
g_set_application_name(_("midori"));
// Parse cli options
gint repeats = 2;
gboolean version = FALSE;
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;
@ -179,75 +303,69 @@ int main(int argc, char** argv)
}
// Load configuration files
GString* errorMessages = g_string_new(NULL);
// TODO: What about default config in a global config folder?
gchar* configPath = g_build_filename(g_get_user_config_dir(), PACKAGE_NAME, NULL);
g_mkdir_with_parents(configPath, 0755);
gchar* configFile = g_build_filename(configPath, "config", NULL);
GString* error_messages = g_string_new (NULL);
gchar* config_path = g_build_filename (g_get_user_config_dir (),
PACKAGE_NAME, NULL);
g_mkdir_with_parents (config_path, 0755);
gchar* config_file = g_build_filename (config_path, "config", NULL);
error = NULL;
/*CConfig* */config = config_new();
if(!config_from_file(config, configFile, &error))
{
if(error->code != G_FILE_ERROR_NOENT)
g_string_append_printf(errorMessages
, _("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);
MidoriWebSettings* settings = settings_new_from_file (config_file);
webSettings = settings;
katze_assign (config_file, g_build_filename (config_path, "accels", NULL));
gtk_accel_map_load (config_file);
katze_assign (config_file, g_build_filename (config_path, "search", NULL));
error = NULL;
searchEngines = search_engines_new();
if(!search_engines_from_file(&searchEngines, configFile, &error))
searchEngines = search_engines_new ();
if (!search_engines_from_file (&searchEngines, config_file, &error))
{
// FIXME: We may have a "file empty" error, how do we recognize that?
/*if(error->code != G_FILE_ERROR_NOENT)
g_string_append_printf(errorMessages
, _("The search engines couldn't be loaded. %s\n"), error->message);*/
g_error_free(error);
/*if (error->code != G_FILE_ERROR_NOENT)
g_string_append_printf (error_messages,
_("The search engines couldn't be loaded. %s\n"),
error->message);*/
g_error_free (error);
}
g_free(configFile);
configFile = g_build_filename(configPath, "bookmarks.xbel", NULL);
katze_assign (config_file, g_build_filename (config_path, "bookmarks.xbel",
NULL));
bookmarks = katze_xbel_folder_new();
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)
g_string_append_printf(errorMessages
, _("The bookmarks couldn't be loaded. %s\n"), error->message);
g_error_free(error);
if (error->code != G_FILE_ERROR_NOENT)
g_string_append_printf (error_messages,
_("The bookmarks couldn't be loaded. %s\n"), error->message);
g_error_free (error);
}
g_free(configFile);
g_free (config_file);
KatzeXbelItem* _session = katze_xbel_folder_new();
config = config_new ();
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;
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)
g_string_append_printf(errorMessages
, _("The session couldn't be loaded. %s\n"), error->message);
g_error_free(error);
if (error->code != G_FILE_ERROR_NOENT)
g_string_append_printf (error_messages,
_("The session couldn't be loaded. %s\n"), error->message);
g_error_free (error);
}
g_free(configFile);
g_free (config_file);
}
configFile = g_build_filename(configPath, "tabtrash.xbel", NULL);
KatzeXbelItem* xbel_trash = katze_xbel_folder_new();
config_file = g_build_filename (config_path, "tabtrash.xbel", NULL);
KatzeXbelItem* xbel_trash = katze_xbel_folder_new ();
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)
g_string_append_printf(errorMessages
, _("The trash couldn't be loaded. %s\n"), error->message);
g_error_free(error);
if (error->code != G_FILE_ERROR_NOENT)
g_string_append_printf(error_messages,
_("The trash couldn't be loaded. %s\n"), error->message);
g_error_free (error);
}
g_free(configFile);
g_free (config_file);
// In case of errors
if(errorMessages->len)
if (error_messages->len)
{
GtkWidget* dialog = gtk_message_dialog_new(NULL
, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE
@ -257,7 +375,7 @@ int main(int argc, char** argv)
// FIXME: Use custom program icon
gtk_window_set_icon_name(GTK_WINDOW(dialog), "web-browser");
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_STOCK_CANCEL, GTK_RESPONSE_CANCEL
, "_Ignore", GTK_RESPONSE_ACCEPT
@ -269,14 +387,14 @@ int main(int argc, char** argv)
katze_xbel_item_unref(bookmarks);
katze_xbel_item_unref(_session);
katze_xbel_item_unref(xbel_trash);
g_string_free(errorMessages, TRUE);
g_string_free(error_messages, TRUE);
return 0;
}
gtk_widget_destroy(dialog);
/* FIXME: Since we will overwrite files that could not be loaded
, 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
// 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_folder_prepend_item(_session, item);
}
g_free(configPath);
g_free (config_path);
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,
"limit", 10,
NULL);
guint i;
guint n = katze_xbel_folder_get_n_items (xbel_trash);
guint i;
for (i = 0; i < n; 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);
// Save configuration files
configPath = g_build_filename(g_get_user_config_dir(), PACKAGE_NAME, NULL);
g_mkdir_with_parents(configPath, 0755);
configFile = g_build_filename(configPath, "search", NULL);
config_path = g_build_filename (g_get_user_config_dir(), PACKAGE_NAME,
NULL);
g_mkdir_with_parents (config_path, 0755);
config_file = g_build_filename (config_path, "search", 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_error_free(error);
}
search_engines_free(searchEngines);
g_free(configFile);
configFile = g_build_filename(configPath, "bookmarks.xbel", NULL);
g_free (config_file);
config_file = g_build_filename (config_path, "bookmarks.xbel", 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_error_free(error);
}
katze_xbel_item_unref(bookmarks);
g_free(configFile);
configFile = g_build_filename(configPath, "tabtrash.xbel", NULL);
g_free (config_file);
config_file = g_build_filename (config_path, "tabtrash.xbel", 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_error_free (error);
}
katze_xbel_item_unref (xbel_trash);
g_free (configFile);
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;
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_error_free(error);
g_warning ("The session couldn't be saved. %s", error->message);
g_error_free (error);
}
g_free(configFile);
}
katze_xbel_item_unref(session);
configFile = g_build_filename(configPath, "config", NULL);
katze_xbel_item_unref (session);
katze_assign (config_file, g_build_filename (config_path, "config", 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_error_free(error);
g_warning ("The configuration couldn't be saved. %s", error->message);
g_error_free (error);
}
config_free(config);
g_free(configFile);
configFile = g_build_filename(configPath, "accels", NULL);
gtk_accel_map_save(configFile);
g_free(configFile);
g_free(configPath);
config_free (config);
katze_assign (config_file, g_build_filename (config_path, "accels", NULL));
gtk_accel_map_save (config_file);
g_free (config_file);
g_free (config_path);
return 0;
}

View file

@ -867,7 +867,10 @@ _action_preferences_activate (GtkAction* action,
gtk_window_present (GTK_WINDOW (dialog));
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);
}
}

View file

@ -46,21 +46,21 @@ static void
midori_trash_finalize (GObject* object);
static void
midori_trash_set_property (GObject* object,
guint prop_id,
midori_trash_set_property (GObject* object,
guint prop_id,
const GValue* value,
GParamSpec* pspec);
GParamSpec* pspec);
static void
midori_trash_get_property (GObject* object,
guint prop_id,
GValue* value,
midori_trash_get_property (GObject* object,
guint prop_id,
GValue* value,
GParamSpec* pspec);
static void
midori_trash_class_init (MidoriTrashClass* class)
{
signals[INSERTED] = g_signal_new(
signals[INSERTED] = g_signal_new (
"inserted",
G_TYPE_FROM_CLASS(class),
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
@ -71,7 +71,7 @@ midori_trash_class_init (MidoriTrashClass* class)
G_TYPE_NONE, 1,
G_TYPE_UINT);
signals[REMOVED] = g_signal_new(
signals[REMOVED] = g_signal_new (
"removed",
G_TYPE_FROM_CLASS(class),
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
@ -288,8 +288,8 @@ midori_trash_prepend_xbel_item (MidoriTrash* trash,
* Nothing happens if the function fails.
**/
void
midori_trash_remove_nth_item (MidoriTrash* trash,
guint n)
midori_trash_remove_nth_item (MidoriTrash* trash,
guint n)
{
g_return_if_fail (MIDORI_IS_TRASH (trash));
@ -310,7 +310,7 @@ midori_trash_remove_nth_item (MidoriTrash* trash,
* Deletes all items currently contained in @trash.
**/
void
midori_trash_empty (MidoriTrash* trash)
midori_trash_empty (MidoriTrash* trash)
{
g_return_if_fail (MIDORI_IS_TRASH (trash));

View file

@ -14,7 +14,7 @@
#include "global.h"
#include "sokoke.h"
#include <webkit/webkitwebframe.h>
#include <webkit/webkit.h>
#include <string.h>
// This is unstable API, so we need to declare it
@ -38,7 +38,7 @@ struct _MidoriWebViewPrivate
gint tab_label_size;
gboolean close_button;
gboolean middle_click_goto;
gboolean middle_click_opens_selection;
MidoriWebSettings* settings;
GtkWidget* proxy_menu_item;
@ -419,7 +419,7 @@ gtk_widget_button_press_event_after (MidoriWebView* web_view,
{
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;
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),
"tab-label-size", &priv->tab_label_size,
"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);
}
@ -572,7 +572,7 @@ midori_web_view_settings_notify (MidoriWebSettings* web_settings,
sokoke_widget_set_visible (priv->tab_close, priv->close_button);
}
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),
name))
g_warning("Unexpected setting '%s'", name);
@ -591,7 +591,7 @@ midori_web_view_init (MidoriWebView* web_view)
priv->settings = midori_web_settings_new ();
_midori_web_view_update_settings (web_view);
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;
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));

View file

@ -12,258 +12,26 @@
#include "prefs.h"
#include "helpers.h"
#include "global.h"
#include "sokoke.h"
#include <glib/gi18n.h>
#include <stdlib.h>
#include <string.h>
static gboolean on_prefs_homepage_focus_out(GtkWidget* widget
, GdkEventFocus event, CPrefs* prefs)
static void
clear_button_clicked_cb (GtkWidget* button, GtkWidget* file_chooser)
{
katze_assign(config->homepage, g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))));
return FALSE;
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (file_chooser), "");
// 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)
{
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)
GtkWidget* prefs_preferences_dialog_new (GtkWindow* window,
MidoriWebSettings* settings)
{
gchar* dialogTitle = g_strdup_printf(_("%s Preferences"), g_get_application_name());
GtkWidget* dialog = gtk_dialog_new_with_buttons(dialogTitle
, GTK_WINDOW(browser)
, window
, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR
, GTK_STOCK_HELP, GTK_RESPONSE_HELP
, 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);
CPrefs* prefs = g_new0(CPrefs, 1);
prefs->browser = browser;
g_signal_connect(dialog, "response", G_CALLBACK(g_free), prefs);
// 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
GtkWidget* xfce_heading;
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)
, xfce_heading, FALSE, FALSE, 0);
g_free(dialogTitle);
GtkWidget* notebook = gtk_notebook_new();
gtk_container_set_border_width(GTK_CONTAINER(notebook), 6);
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* button; GtkWidget* checkbutton; GtkWidget* colorbutton;
GtkWidget* combobox; GtkWidget* entry; GtkWidget* hbox; GtkWidget* spinbutton;
GtkWidget* label; GtkWidget* button;
GtkWidget* entry; GtkWidget* hbox;
#define PAGE_NEW(__label) page = gtk_vbox_new(FALSE, 0);\
gtk_container_set_border_width(GTK_CONTAINER(page), 5);\
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_size_group_add_widget(sizegroup, align);\
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)\
align = gtk_alignment_new(0, 0.5, 0, 0);\
gtk_container_add(GTK_CONTAINER(align), __widget);\
FILLED_ADD(align, __left, __right, __top, __bottom)
// Page "General"
PAGE_NEW(_("General"));
FRAME_NEW(_("Startup"));
TABLE_NEW(2, 2);
INDENTED_ADD(gtk_label_new(_("Load on startup")), 0, 1, 0, 1);
combobox = gtk_combo_box_new_text();
sokoke_combo_box_add_strings(GTK_COMBO_BOX(combobox)
, _("Blank page"), _("Homepage"), _("Last open pages"), NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), config->startup);
g_signal_connect(combobox, "changed"
, G_CALLBACK(on_prefs_loadonstartup_changed), prefs);
FILLED_ADD(combobox, 1, 2, 0, 1);
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);
PAGE_NEW (_("General"));
FRAME_NEW (_("Startup"));
TABLE_NEW (2, 2);
label = katze_property_label (settings, "load-on-startup");
INDENTED_ADD (label, 0, 1, 0, 1);
button = katze_property_proxy (settings, "load-on-startup", NULL);
FILLED_ADD (button, 1, 2, 0, 1);
label = katze_property_label (settings, "homepage");
INDENTED_ADD (label, 0, 1, 1, 2);
entry = katze_property_proxy (settings, "homepage", NULL);
FILLED_ADD (entry, 1, 2, 1, 2);
// TODO: We need something like "use current website"
FRAME_NEW(_("Transfers"));
TABLE_NEW(1, 2);
INDENTED_ADD(gtk_label_new(_("Download folder")), 0, 1, 0, 1);
GtkWidget* filebutton = gtk_file_chooser_button_new(
_("Choose downloaded files folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
// FIXME: The default should probably be ~/Desktop
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filebutton)
, g_get_home_dir()); //...
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);
FRAME_NEW (_("Transfers"));
TABLE_NEW (1, 2);
label = katze_property_label (settings, "download-folder");
INDENTED_ADD (label, 0, 1, 0, 1);
button = katze_property_proxy (settings, "download-folder", "folder");
FILLED_ADD (button, 1, 2, 0, 1);
button = katze_property_proxy (settings, "show-download-notification", "blurb");
SPANNED_ADD (button, 0, 2, 1, 2);
// Page "Appearance"
PAGE_NEW(_("Appearance"));
FRAME_NEW(_("Font settings"));
TABLE_NEW(5, 2);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("Default _font")), 0, 1, 0, 1);
gchar* defaultFont = g_strdup_printf("%s %d"
, config->defaultFontFamily, config->defaultFontSize);
button = gtk_font_button_new_with_font(defaultFont);
g_free(defaultFont);
g_signal_connect(button, "font-set", G_CALLBACK(on_prefs_defaultFont_changed), prefs);
FILLED_ADD(button, 1, 2, 0, 1);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("_Minimum font size")), 0, 1, 1, 2);
hbox = gtk_hbox_new(FALSE, 4);
spinbutton = gtk_spin_button_new_with_range(1, G_MAXINT, 1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), config->minimumFontSize);
g_signal_connect(spinbutton, "value-changed"
, G_CALLBACK(on_prefs_minimumFontSize_changed), prefs);
gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0);
button = gtk_button_new_with_mnemonic(_("_Advanced"));
gtk_widget_set_sensitive(button, FALSE); //...
gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 4);
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_NEW (_("Appearance"));
FRAME_NEW (_("Font settings"));
TABLE_NEW (5, 2);
label = katze_property_label (settings, "default-font-family");
INDENTED_ADD (label, 0, 1, 0, 1);
hbox = gtk_hbox_new (FALSE, 4);
button = katze_property_proxy (settings, "default-font-family", NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
entry = katze_property_proxy (settings, "default-font-size", NULL);
gtk_box_pack_end (GTK_BOX (hbox), entry, FALSE, FALSE, 4);
FILLED_ADD (hbox, 1, 2, 0, 1);
label = katze_property_label (settings, "minimum-font-size");
INDENTED_ADD (label, 0, 1, 1, 2);
hbox = gtk_hbox_new (FALSE, 4);
entry = katze_property_proxy (settings, "minimum-font-size", NULL);
INDENTED_ADD (entry, 1, 2, 1, 2);
label = katze_property_label (settings, "preferred-encoding");
INDENTED_ADD (label, 0, 1, 2, 3);
button = katze_property_proxy (settings, "preferred-encoding", NULL);
FILLED_ADD (button, 1, 2, 2, 3);
// Page "Behavior"
PAGE_NEW(_("Behavior"));
FRAME_NEW(_("Browsing"));
TABLE_NEW(3, 2);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("Open _new pages in")), 0, 1, 0, 1);
combobox = gtk_combo_box_new_text();
sokoke_combo_box_add_strings(GTK_COMBO_BOX(combobox)
, _("New tab"), _("New window"), _("Current tab"), NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), config->newPages);
g_signal_connect(combobox, "changed", G_CALLBACK(on_prefs_newpages_changed), prefs);
gtk_widget_set_sensitive(combobox, FALSE); //...
FILLED_ADD(combobox, 1, 2, 0, 1);
checkbutton = gtk_check_button_new_with_mnemonic(_("_Middle click opens selection"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->middleClickGoto);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_middleClickGoto_toggled), prefs);
INDENTED_ADD(checkbutton, 0, 1, 1, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("Open tabs in the _background"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->openTabsInTheBackground);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_openTabsInTheBackground_toggled), prefs);
SPANNED_ADD(checkbutton, 1, 2, 1, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("Open popups in _tabs"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->openPopupsInTabs);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_openPopupsInTabs_toggled), prefs);
gtk_widget_set_sensitive(checkbutton, FALSE); //...
SPANNED_ADD(checkbutton, 0, 2, 2, 3);
FRAME_NEW(_("Features"));
TABLE_NEW(4, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("Load _images"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->autoLoadImages);
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_NEW (_("Behavior"));
FRAME_NEW (_("Features"));
TABLE_NEW (5, 2);
button = katze_property_proxy (settings, "auto-load-images", NULL);
INDENTED_ADD (button, 0, 1, 0, 1);
button = katze_property_proxy (settings, "auto-shrink-images", NULL);
SPANNED_ADD (button, 1, 2, 0, 1);
button = katze_property_proxy (settings, "print-backgrounds", NULL);
INDENTED_ADD (button, 0, 1, 1, 2);
button = katze_property_proxy (settings, "resizable-text-areas", NULL);
SPANNED_ADD (button, 1, 2, 1, 2);
button = katze_property_proxy (settings, "enable-scripts", NULL);
INDENTED_ADD (button, 0, 1, 2, 3);
button = katze_property_proxy (settings, "enable-plugins", NULL);
SPANNED_ADD(button, 1, 2, 2, 3);
label = katze_property_label (settings, "user-stylesheet-uri");
INDENTED_ADD (label, 0, 1, 3, 4);
hbox = gtk_hbox_new (FALSE, 4);
entry = katze_property_proxy (settings, "user-stylesheet-uri", "uri");
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (button),
gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU));
g_signal_connect (button, "clicked",
G_CALLBACK (clear_button_clicked_cb), entry);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 4);
FILLED_ADD (hbox, 1, 2, 3, 4);
label = katze_property_label (settings, "location-entry-search");
INDENTED_ADD (label, 0, 1, 4, 5);
entry = katze_property_proxy (settings, "location-entry-search", NULL);
FILLED_ADD (entry, 1, 2, 4, 5);
// Page "Interface"
PAGE_NEW(_("Interface"));
FRAME_NEW(_("Navigationbar"));
TABLE_NEW(3, 2);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("_Toolbar style")), 0, 1, 0, 1);
combobox = gtk_combo_box_new_text();
sokoke_combo_box_add_strings(GTK_COMBO_BOX(combobox)
, _("Default"), _("Icons"), _("Text"), _("Both"), _("Both horizontal"), NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), config->toolbarStyle);
g_signal_connect(combobox, "changed"
, G_CALLBACK(on_prefs_toolbarstyle_changed), prefs);
FILLED_ADD(combobox, 1, 2, 0, 1);
checkbutton = gtk_check_button_new_with_mnemonic(_("Show small _icons"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->toolbarSmall);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_toolbarSmall_toggled), prefs);
INDENTED_ADD(checkbutton, 0, 1, 1, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("Show Web_search"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->toolbarWebSearch);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_toolbarWebSearch_toggled), prefs);
SPANNED_ADD(checkbutton, 1, 2, 1, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("Show _New Tab"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->toolbarNewTab);
g_signal_connect(checkbutton, "toggled"
, G_CALLBACK(on_prefs_toolbarNewTab_toggled), prefs);
INDENTED_ADD(checkbutton, 0, 1, 2, 3);
checkbutton = gtk_check_button_new_with_mnemonic(_("Show _Trash"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), config->toolbarClosedTabs);
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_NEW (_("Interface"));
FRAME_NEW (_("Navigationbar"));
TABLE_NEW (3, 2);
INDENTED_ADD (katze_property_label (settings, "toolbar-style"), 0, 1, 0, 1);
button = katze_property_proxy (settings, "toolbar-style", NULL);
FILLED_ADD(button, 1, 2, 0, 1);
button = katze_property_proxy (settings, "small-toolbar", NULL);
INDENTED_ADD (button, 0, 1, 1, 2);
button = katze_property_proxy (settings, "show-web-search", NULL);
SPANNED_ADD (button, 1, 2, 1, 2);
button = katze_property_proxy (settings, "show-new-tab", NULL);
INDENTED_ADD (button, 0, 1, 2, 3);
button = katze_property_proxy (settings, "show-trash", NULL);
SPANNED_ADD (button, 1, 2, 2, 3);
FRAME_NEW(_("Browsing"));
TABLE_NEW (3, 2);
label = katze_property_label (settings, "open-new-pages-in");
INDENTED_ADD (label, 0, 1, 0, 1);
button = katze_property_proxy (settings, "open-new-pages-in", NULL);
FILLED_ADD (button, 1, 2, 0, 1);
button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
INDENTED_ADD (button, 0, 1, 1, 2);
button = katze_property_proxy (settings, "open-tabs-in-the-background", NULL);
SPANNED_ADD (button, 1, 2, 1, 2);
button = katze_property_proxy (settings, "open-popups-in-tabs", NULL);
SPANNED_ADD (button, 0, 1, 2, 3);
button = katze_property_proxy (settings, "close-buttons-on-tabs", NULL);
SPANNED_ADD (button, 1, 2, 2, 3);
// Page "Network"
PAGE_NEW(_("Network"));
FRAME_NEW(_("Proxy Server"));
TABLE_NEW(5, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("_Custom proxy server"));
gtk_widget_set_sensitive(checkbutton, FALSE); //...
SPANNED_ADD(checkbutton, 0, 2, 0, 1);
hbox = gtk_hbox_new(FALSE, 4);
INDENTED_ADD(gtk_label_new_with_mnemonic(_("_Host/ Port")), 0, 1, 1, 2);
entry = gtk_entry_new();
gtk_widget_set_sensitive(entry, FALSE); //...
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
spinbutton = gtk_spin_button_new_with_range(0, 65535, 1);
gtk_widget_set_sensitive(spinbutton, FALSE); //...
gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0);
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_NEW (_("Network"));
FRAME_NEW (_("Network"));
TABLE_NEW (2, 2);
label = katze_property_label (settings, "http-proxy");
INDENTED_ADD (label, 0, 1, 0, 1);
button = katze_property_proxy (settings, "http-proxy", NULL);
FILLED_ADD (button, 1, 2, 0, 1);
label = katze_property_label (settings, "cache-size");
INDENTED_ADD (label, 0, 1, 1, 2);
hbox = gtk_hbox_new (FALSE, 4);
entry = katze_property_proxy (settings, "cache-size", NULL);
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("MB")),
FALSE, FALSE, 0);
FILLED_ADD (hbox, 1, 2, 1, 2);
// Page "Privacy"
PAGE_NEW(_("Privacy"));
FRAME_NEW(_("Cookies"));
TABLE_NEW(3, 2);
INDENTED_ADD(gtk_label_new(_("Accept cookies")), 0, 1, 0, 1);
combobox = gtk_combo_box_new_text();
sokoke_combo_box_add_strings(GTK_COMBO_BOX(combobox)
, _("All cookies"), _("Session cookies"), _("None"), NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0); //...
gtk_widget_set_sensitive(combobox, FALSE); //...
FILLED_ADD(combobox, 1, 2, 0, 1);
checkbutton = gtk_check_button_new_with_mnemonic
(_("Allow cookies from the original website only"));
gtk_widget_set_sensitive(checkbutton, FALSE); //...
SPANNED_ADD(checkbutton, 0, 2, 1, 2);
INDENTED_ADD(gtk_label_new(_("Maximum cookie age")), 0, 1, 2, 3);
hbox = gtk_hbox_new(FALSE, 4);
spinbutton = gtk_spin_button_new_with_range(0, 360, 1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), 30/*config->iCookieAgeMax*/);
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);
button = gtk_button_new_with_label(_("View cookies"));
gtk_widget_set_sensitive(button, FALSE); //...
gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 4);
FILLED_ADD(hbox, 1, 2, 2, 3);
FRAME_NEW(_("History"));
TABLE_NEW(3, 2);
checkbutton = gtk_check_button_new_with_mnemonic(_("Remember my visited pages"));
gtk_widget_set_sensitive(checkbutton, FALSE); //...
SPANNED_ADD(checkbutton, 0, 1, 0, 1);
hbox = gtk_hbox_new(FALSE, 4);
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);
PAGE_NEW (_("Privacy"));
FRAME_NEW (_("Cookies"));
TABLE_NEW (3, 2);
label = katze_property_label (settings, "accept-cookies");
INDENTED_ADD (label, 0, 1, 0, 1);
button = katze_property_proxy (settings, "accept-cookies", NULL);
FILLED_ADD (button, 1, 2, 0, 1);
button = katze_property_proxy (settings, "original-cookies-only", "blurb");
SPANNED_ADD (button, 0, 2, 1, 2);
label = katze_property_label (settings, "maximum-cookie-age");
INDENTED_ADD (label, 0, 1, 2, 3);
hbox = gtk_hbox_new (FALSE, 4);
entry = katze_property_proxy (settings, "maximum-cookie-age", NULL);
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("days")),
FALSE, FALSE, 0);
FILLED_ADD (hbox, 1, 2, 2, 3);
FRAME_NEW (_("History"));
TABLE_NEW (3, 2);
button = katze_property_proxy (settings, "remember-last-visited-pages", NULL);
SPANNED_ADD (button, 0, 1, 0, 1);
hbox = gtk_hbox_new (FALSE, 4);
button = katze_property_proxy (settings, "maximum-history-age", NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("days")),
FALSE, FALSE, 0);
SPANNED_ADD (hbox, 1, 2, 0, 1);
button = katze_property_proxy (settings, "remember-last-form-inputs", NULL);
SPANNED_ADD (button, 0, 2, 1, 2);
button = katze_property_proxy (settings, "remember-last-downloaded-files", NULL);
SPANNED_ADD (button, 0, 2, 2, 3);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox)
, notebook, FALSE, FALSE, 4);

View file

@ -12,15 +12,14 @@
#ifndef __PREFS_H__
#define __PREFS_H__ 1
#include "midori-browser.h"
#include <gtk/gtk.h>
#include "midori-websettings.h"
// -- Types
typedef struct
{
MidoriBrowser* browser;
GtkWidget* userStylesheetUri;
GtkWidget* treeview;
GtkWidget* combobox;
@ -37,6 +36,6 @@ enum
// -- Declarations
GtkWidget*
prefs_preferences_dialog_new(MidoriBrowser*);
prefs_preferences_dialog_new(GtkWindow*, MidoriWebSettings*);
#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);
}
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
, const gchar* filename, GError** error)
{

View file

@ -64,6 +64,13 @@ gint
sokoke_key_file_get_integer_default(GKeyFile*, const gchar*, const gchar*
, 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
sokoke_key_file_save_to_file(GKeyFile*, const gchar*, GError**);