Avoid build_config_filename in main() and simplify it
This commit is contained in:
parent
ed0440cd9f
commit
23db2145ad
2 changed files with 22 additions and 41 deletions
|
@ -59,12 +59,7 @@
|
||||||
static gchar*
|
static gchar*
|
||||||
build_config_filename (const gchar* filename)
|
build_config_filename (const gchar* filename)
|
||||||
{
|
{
|
||||||
const gchar* path;
|
return g_build_filename (sokoke_set_config_dir (NULL), filename, NULL);
|
||||||
|
|
||||||
if (g_path_is_absolute (filename))
|
|
||||||
return g_strdup (filename);
|
|
||||||
path = sokoke_set_config_dir (NULL);
|
|
||||||
return g_build_filename (path, filename, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static MidoriWebSettings*
|
static MidoriWebSettings*
|
||||||
|
@ -571,11 +566,8 @@ settings_notify_cb (MidoriWebSettings* settings,
|
||||||
GParamSpec* pspec,
|
GParamSpec* pspec,
|
||||||
MidoriApp* app)
|
MidoriApp* app)
|
||||||
{
|
{
|
||||||
gchar* config_file;
|
gchar* config_file = build_config_filename ("config");
|
||||||
GError* error;
|
GError* error = NULL;
|
||||||
|
|
||||||
config_file = build_config_filename ("config");
|
|
||||||
error = NULL;
|
|
||||||
if (!settings_save_to_file (settings, app, config_file, &error))
|
if (!settings_save_to_file (settings, app, 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);
|
||||||
|
@ -609,11 +601,8 @@ midori_search_engines_modify_cb (KatzeArray* array,
|
||||||
gpointer item,
|
gpointer item,
|
||||||
KatzeArray* search_engines)
|
KatzeArray* search_engines)
|
||||||
{
|
{
|
||||||
gchar* config_file;
|
gchar* config_file = build_config_filename ("search");
|
||||||
GError* error;
|
GError* error = NULL;
|
||||||
|
|
||||||
config_file = build_config_filename ("search");
|
|
||||||
error = NULL;
|
|
||||||
if (!search_engines_save_to_file (search_engines, config_file, &error))
|
if (!search_engines_save_to_file (search_engines, config_file, &error))
|
||||||
{
|
{
|
||||||
g_warning (_("The search engines couldn't be saved. %s"),
|
g_warning (_("The search engines couldn't be saved. %s"),
|
||||||
|
@ -627,12 +616,9 @@ static void
|
||||||
midori_trash_add_item_cb (KatzeArray* trash,
|
midori_trash_add_item_cb (KatzeArray* trash,
|
||||||
GObject* item)
|
GObject* item)
|
||||||
{
|
{
|
||||||
gchar* config_file;
|
gchar* config_file = build_config_filename ("tabtrash.xbel");
|
||||||
GError* error;
|
GError* error = NULL;
|
||||||
GObject* obsolete_item;
|
GObject* obsolete_item;
|
||||||
|
|
||||||
config_file = build_config_filename ("tabtrash.xbel");
|
|
||||||
error = NULL;
|
|
||||||
if (!midori_array_to_file (trash, config_file, "xbel", &error))
|
if (!midori_array_to_file (trash, config_file, "xbel", &error))
|
||||||
{
|
{
|
||||||
/* i18n: Trash, or wastebin, containing closed tabs */
|
/* i18n: Trash, or wastebin, containing closed tabs */
|
||||||
|
@ -652,11 +638,8 @@ static void
|
||||||
midori_trash_remove_item_cb (KatzeArray* trash,
|
midori_trash_remove_item_cb (KatzeArray* trash,
|
||||||
GObject* item)
|
GObject* item)
|
||||||
{
|
{
|
||||||
gchar* config_file;
|
gchar* config_file = build_config_filename ("tabtrash.xbel");
|
||||||
GError* error;
|
GError* error = NULL;
|
||||||
|
|
||||||
config_file = build_config_filename ("tabtrash.xbel");
|
|
||||||
error = NULL;
|
|
||||||
if (!midori_array_to_file (trash, config_file, "xbel", &error))
|
if (!midori_array_to_file (trash, config_file, "xbel", &error))
|
||||||
{
|
{
|
||||||
g_warning (_("The trash couldn't be saved. %s"), error->message);
|
g_warning (_("The trash couldn't be saved. %s"), error->message);
|
||||||
|
@ -706,11 +689,8 @@ static guint save_timeout = 0;
|
||||||
static gboolean
|
static gboolean
|
||||||
midori_session_save_timeout_cb (KatzeArray* session)
|
midori_session_save_timeout_cb (KatzeArray* session)
|
||||||
{
|
{
|
||||||
gchar* config_file;
|
gchar* config_file = build_config_filename ("session.xbel");
|
||||||
GError* error;
|
GError* error = NULL;
|
||||||
|
|
||||||
config_file = build_config_filename ("session.xbel");
|
|
||||||
error = NULL;
|
|
||||||
if (!midori_array_to_file (session, config_file, "xbel", &error))
|
if (!midori_array_to_file (session, config_file, "xbel", &error))
|
||||||
{
|
{
|
||||||
g_warning (_("The session couldn't be saved. %s"), error->message);
|
g_warning (_("The session couldn't be saved. %s"), error->message);
|
||||||
|
@ -946,11 +926,8 @@ static void
|
||||||
button_reset_session_clicked_cb (GtkWidget* button,
|
button_reset_session_clicked_cb (GtkWidget* button,
|
||||||
KatzeArray* session)
|
KatzeArray* session)
|
||||||
{
|
{
|
||||||
gchar* config_file;
|
gchar* config_file = build_config_filename ("session.old.xbel");
|
||||||
GError* error;
|
GError* error = NULL;
|
||||||
|
|
||||||
config_file = build_config_filename ("session.old.xbel");
|
|
||||||
error = NULL;
|
|
||||||
if (!midori_array_to_file (session, config_file, "xbel", &error))
|
if (!midori_array_to_file (session, config_file, "xbel", &error))
|
||||||
{
|
{
|
||||||
g_warning (_("The session couldn't be saved. %s"), error->message);
|
g_warning (_("The session couldn't be saved. %s"), error->message);
|
||||||
|
@ -2004,7 +1981,7 @@ main (int argc,
|
||||||
midori_startup_timer ("Search read: \t%f");
|
midori_startup_timer ("Search read: \t%f");
|
||||||
|
|
||||||
bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
|
bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
|
||||||
bookmarks_file = build_config_filename ("bookmarks.db");
|
bookmarks_file = g_build_filename (config, "bookmarks.db", NULL);
|
||||||
errmsg = NULL;
|
errmsg = NULL;
|
||||||
if ((db = midori_bookmarks_initialize (bookmarks, bookmarks_file, &errmsg)) == NULL)
|
if ((db = midori_bookmarks_initialize (bookmarks, bookmarks_file, &errmsg)) == NULL)
|
||||||
{
|
{
|
||||||
|
@ -2014,7 +1991,11 @@ main (int argc,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gchar* old_bookmarks = build_config_filename (BOOKMARK_FILE);
|
gchar* old_bookmarks;
|
||||||
|
if (g_path_is_absolute (BOOKMARK_FILE))
|
||||||
|
old_bookmarks = g_strdup (BOOKMARK_FILE);
|
||||||
|
else
|
||||||
|
old_bookmarks = g_build_filename (config, BOOKMARK_FILE, NULL);
|
||||||
if (g_access (old_bookmarks, F_OK) == 0)
|
if (g_access (old_bookmarks, F_OK) == 0)
|
||||||
{
|
{
|
||||||
midori_bookmarks_import (old_bookmarks, db);
|
midori_bookmarks_import (old_bookmarks, db);
|
||||||
|
@ -2046,7 +2027,7 @@ main (int argc,
|
||||||
|
|
||||||
trash = katze_array_new (KATZE_TYPE_ITEM);
|
trash = katze_array_new (KATZE_TYPE_ITEM);
|
||||||
#if HAVE_LIBXML
|
#if HAVE_LIBXML
|
||||||
katze_assign (config_file, build_config_filename ("tabtrash.xbel"));
|
katze_assign (config_file, g_build_filename (config, "tabtrash.xbel", NULL));
|
||||||
error = NULL;
|
error = NULL;
|
||||||
if (!midori_array_from_file (trash, config_file, "xbel", &error))
|
if (!midori_array_from_file (trash, config_file, "xbel", &error))
|
||||||
{
|
{
|
||||||
|
@ -2240,7 +2221,7 @@ main (int argc,
|
||||||
if (katze_object_get_int (settings, "load-on-startup")
|
if (katze_object_get_int (settings, "load-on-startup")
|
||||||
< MIDORI_STARTUP_LAST_OPEN_PAGES)
|
< MIDORI_STARTUP_LAST_OPEN_PAGES)
|
||||||
{
|
{
|
||||||
katze_assign (config_file, build_config_filename ("session.xbel"));
|
katze_assign (config_file, g_build_filename (config, "session.xbel", NULL));
|
||||||
g_unlink (config_file);
|
g_unlink (config_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3598,7 +3598,7 @@ _action_location_secondary_icon_released (GtkAction* action,
|
||||||
if (midori_view_is_blank (MIDORI_VIEW (view)))
|
if (midori_view_is_blank (MIDORI_VIEW (view)))
|
||||||
{
|
{
|
||||||
GtkClipboard* clipboard = gtk_clipboard_get_for_display (
|
GtkClipboard* clipboard = gtk_clipboard_get_for_display (
|
||||||
gtk_widget_get_display (view), GDK_SELECTION_CLIPBOARD));
|
gtk_widget_get_display (view), GDK_SELECTION_CLIPBOARD);
|
||||||
gchar* text = gtk_clipboard_wait_for_text (clipboard);
|
gchar* text = gtk_clipboard_wait_for_text (clipboard);
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue