Use speeddial property to store GKeyFile with speeddial entries
This commit is contained in:
parent
733e3cfab6
commit
9c48997a26
3 changed files with 75 additions and 23 deletions
|
@ -1467,19 +1467,28 @@ signal_handler (int signal_id)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
static GKeyFile*
|
||||||
static void
|
speeddial_new_from_file (const gchar* config,
|
||||||
midori_speeddial_import_from_json (const gchar* json_file,
|
GError** error)
|
||||||
const gchar* speeddial_file)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
GKeyFile* key_file = g_key_file_new ();
|
||||||
|
gchar* config_file = g_build_filename (config, "speeddial", NULL);
|
||||||
guint i = 0;
|
guint i = 0;
|
||||||
guint columns = 3;
|
guint columns = 3;
|
||||||
guint slot_count = 0;
|
guint slot_count = 0;
|
||||||
gchar* json_content;
|
gchar* json_content;
|
||||||
gchar** parts;
|
gchar** parts;
|
||||||
GKeyFile* key_file = g_key_file_new ();
|
|
||||||
|
|
||||||
g_file_get_contents (json_file, &json_content, NULL, NULL);
|
if (g_key_file_load_from_file (key_file, config_file, G_KEY_FILE_NONE, error))
|
||||||
|
{
|
||||||
|
g_free (config_file);
|
||||||
|
return key_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
katze_assign (config_file, g_build_filename (config, "speeddial.json", NULL));
|
||||||
|
g_file_get_contents (config_file, &json_content, NULL, NULL);
|
||||||
|
g_free (config_file);
|
||||||
parts = g_strsplit (json_content ? json_content : "", ",", -1);
|
parts = g_strsplit (json_content ? json_content : "", ",", -1);
|
||||||
while (parts && parts[i] != NULL)
|
while (parts && parts[i] != NULL)
|
||||||
{
|
{
|
||||||
|
@ -1588,13 +1597,10 @@ midori_speeddial_import_from_json (const gchar* json_file,
|
||||||
g_key_file_set_integer (key_file, "settings", "columns", columns);
|
g_key_file_set_integer (key_file, "settings", "columns", columns);
|
||||||
g_key_file_set_integer (key_file, "settings", "rows", slot_count / columns);
|
g_key_file_set_integer (key_file, "settings", "rows", slot_count / columns);
|
||||||
|
|
||||||
sokoke_key_file_save_to_file (key_file, speeddial_file, NULL);
|
|
||||||
|
|
||||||
g_strfreev (parts);
|
g_strfreev (parts);
|
||||||
g_free (json_content);
|
g_free (json_content);
|
||||||
g_key_file_free (key_file);
|
return key_file;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_soup_session_block_uris_cb (SoupSession* session,
|
midori_soup_session_block_uris_cb (SoupSession* session,
|
||||||
|
@ -1812,9 +1818,7 @@ main (int argc,
|
||||||
MidoriWebSettings* settings;
|
MidoriWebSettings* settings;
|
||||||
gchar* config_file;
|
gchar* config_file;
|
||||||
gchar* bookmarks_file;
|
gchar* bookmarks_file;
|
||||||
#if 0
|
GKeyFile* speeddial;
|
||||||
gchar* speeddial_file;
|
|
||||||
#endif
|
|
||||||
gboolean bookmarks_exist;
|
gboolean bookmarks_exist;
|
||||||
MidoriStartup load_on_startup;
|
MidoriStartup load_on_startup;
|
||||||
KatzeArray* search_engines;
|
KatzeArray* search_engines;
|
||||||
|
@ -2231,16 +2235,7 @@ main (int argc,
|
||||||
g_free (bookmarks_file);
|
g_free (bookmarks_file);
|
||||||
midori_startup_timer ("History read: \t%f");
|
midori_startup_timer ("History read: \t%f");
|
||||||
|
|
||||||
#if 0
|
speeddial = speeddial_new_from_file (config, &error);
|
||||||
speeddial_file = g_build_filename (config, "speeddial", NULL);
|
|
||||||
if (g_access (speeddial_file, F_OK) != 0)
|
|
||||||
{
|
|
||||||
gchar* json_file = g_build_filename (config, "speeddial.json", NULL);
|
|
||||||
midori_speeddial_import_from_json (json_file, speeddial_file);
|
|
||||||
g_free (json_file);
|
|
||||||
}
|
|
||||||
g_free (speeddial_file);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* In case of errors */
|
/* In case of errors */
|
||||||
if (error_messages->len)
|
if (error_messages->len)
|
||||||
|
@ -2359,6 +2354,7 @@ main (int argc,
|
||||||
"trash", trash,
|
"trash", trash,
|
||||||
"search-engines", search_engines,
|
"search-engines", search_engines,
|
||||||
"history", history,
|
"history", history,
|
||||||
|
"speed-dial", speeddial,
|
||||||
NULL);
|
NULL);
|
||||||
g_object_unref (history);
|
g_object_unref (history);
|
||||||
g_object_unref (search_engines);
|
g_object_unref (search_engines);
|
||||||
|
@ -2419,6 +2415,7 @@ main (int argc,
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
|
g_key_file_free (speeddial);
|
||||||
g_object_unref (app);
|
g_object_unref (app);
|
||||||
g_free (config_file);
|
g_free (config_file);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -60,6 +60,7 @@ struct _MidoriApp
|
||||||
KatzeArray* trash;
|
KatzeArray* trash;
|
||||||
KatzeArray* search_engines;
|
KatzeArray* search_engines;
|
||||||
KatzeArray* history;
|
KatzeArray* history;
|
||||||
|
GKeyFile* speeddial;
|
||||||
KatzeArray* extensions;
|
KatzeArray* extensions;
|
||||||
KatzeArray* browsers;
|
KatzeArray* browsers;
|
||||||
|
|
||||||
|
@ -97,6 +98,7 @@ enum
|
||||||
PROP_TRASH,
|
PROP_TRASH,
|
||||||
PROP_SEARCH_ENGINES,
|
PROP_SEARCH_ENGINES,
|
||||||
PROP_HISTORY,
|
PROP_HISTORY,
|
||||||
|
PROP_SPEED_DIAL,
|
||||||
PROP_EXTENSIONS,
|
PROP_EXTENSIONS,
|
||||||
PROP_BROWSERS,
|
PROP_BROWSERS,
|
||||||
PROP_BROWSER
|
PROP_BROWSER
|
||||||
|
@ -149,6 +151,7 @@ midori_browser_new_window_cb (MidoriBrowser* browser,
|
||||||
"trash", app->trash,
|
"trash", app->trash,
|
||||||
"search-engines", app->search_engines,
|
"search-engines", app->search_engines,
|
||||||
"history", app->history,
|
"history", app->history,
|
||||||
|
"speed-dial", app->speeddial,
|
||||||
NULL);
|
NULL);
|
||||||
else
|
else
|
||||||
new_browser = midori_app_create_browser (app);
|
new_browser = midori_app_create_browser (app);
|
||||||
|
@ -365,6 +368,23 @@ midori_app_class_init (MidoriAppClass* class)
|
||||||
KATZE_TYPE_ARRAY,
|
KATZE_TYPE_ARRAY,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MidoriApp:speed-dial:
|
||||||
|
*
|
||||||
|
* The speed dial configuration file.
|
||||||
|
*
|
||||||
|
* Since: 0.3.4
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_SPEED_DIAL,
|
||||||
|
g_param_spec_pointer (
|
||||||
|
"speed-dial",
|
||||||
|
"Speeddial",
|
||||||
|
"Pointer to key-value object with speed dial items",
|
||||||
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MidoriApp:browsers:
|
* MidoriApp:browsers:
|
||||||
*
|
*
|
||||||
|
@ -717,6 +737,7 @@ midori_app_init (MidoriApp* app)
|
||||||
app->trash = NULL;
|
app->trash = NULL;
|
||||||
app->search_engines = NULL;
|
app->search_engines = NULL;
|
||||||
app->history = NULL;
|
app->history = NULL;
|
||||||
|
app->speeddial = NULL;
|
||||||
app->extensions = NULL;
|
app->extensions = NULL;
|
||||||
app->browsers = katze_array_new (MIDORI_TYPE_BROWSER);
|
app->browsers = katze_array_new (MIDORI_TYPE_BROWSER);
|
||||||
|
|
||||||
|
@ -743,6 +764,7 @@ midori_app_finalize (GObject* object)
|
||||||
katze_object_assign (app->trash, NULL);
|
katze_object_assign (app->trash, NULL);
|
||||||
katze_object_assign (app->search_engines, NULL);
|
katze_object_assign (app->search_engines, NULL);
|
||||||
katze_object_assign (app->history, NULL);
|
katze_object_assign (app->history, NULL);
|
||||||
|
app->speeddial = NULL;
|
||||||
katze_object_assign (app->extensions, NULL);
|
katze_object_assign (app->extensions, NULL);
|
||||||
katze_object_assign (app->browsers, NULL);
|
katze_object_assign (app->browsers, NULL);
|
||||||
|
|
||||||
|
@ -793,6 +815,9 @@ midori_app_set_property (GObject* object,
|
||||||
case PROP_HISTORY:
|
case PROP_HISTORY:
|
||||||
katze_object_assign (app->history, g_value_dup_object (value));
|
katze_object_assign (app->history, g_value_dup_object (value));
|
||||||
break;
|
break;
|
||||||
|
case PROP_SPEED_DIAL:
|
||||||
|
app->speeddial = g_value_get_pointer (value);
|
||||||
|
break;
|
||||||
case PROP_EXTENSIONS:
|
case PROP_EXTENSIONS:
|
||||||
katze_object_assign (app->extensions, g_value_dup_object (value));
|
katze_object_assign (app->extensions, g_value_dup_object (value));
|
||||||
break;
|
break;
|
||||||
|
@ -830,6 +855,9 @@ midori_app_get_property (GObject* object,
|
||||||
case PROP_HISTORY:
|
case PROP_HISTORY:
|
||||||
g_value_set_object (value, app->history);
|
g_value_set_object (value, app->history);
|
||||||
break;
|
break;
|
||||||
|
case PROP_SPEED_DIAL:
|
||||||
|
g_value_set_pointer (value, app->speeddial);
|
||||||
|
break;
|
||||||
case PROP_EXTENSIONS:
|
case PROP_EXTENSIONS:
|
||||||
g_value_set_object (value, app->extensions);
|
g_value_set_object (value, app->extensions);
|
||||||
break;
|
break;
|
||||||
|
@ -1122,6 +1150,7 @@ midori_app_create_browser (MidoriApp* app)
|
||||||
"trash", app->trash,
|
"trash", app->trash,
|
||||||
"search-engines", app->search_engines,
|
"search-engines", app->search_engines,
|
||||||
"history", app->history,
|
"history", app->history,
|
||||||
|
"speed-dial", app->speeddial,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ struct _MidoriBrowser
|
||||||
KatzeArray* trash;
|
KatzeArray* trash;
|
||||||
KatzeArray* search_engines;
|
KatzeArray* search_engines;
|
||||||
KatzeArray* history;
|
KatzeArray* history;
|
||||||
|
GKeyFile* speeddial;
|
||||||
gboolean show_tabs;
|
gboolean show_tabs;
|
||||||
|
|
||||||
gboolean show_navigationbar;
|
gboolean show_navigationbar;
|
||||||
|
@ -128,6 +129,7 @@ enum
|
||||||
PROP_TRASH,
|
PROP_TRASH,
|
||||||
PROP_SEARCH_ENGINES,
|
PROP_SEARCH_ENGINES,
|
||||||
PROP_HISTORY,
|
PROP_HISTORY,
|
||||||
|
PROP_SPEED_DIAL,
|
||||||
PROP_SHOW_TABS,
|
PROP_SHOW_TABS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2085,6 +2087,22 @@ midori_browser_class_init (MidoriBrowserClass* class)
|
||||||
KATZE_TYPE_ARRAY,
|
KATZE_TYPE_ARRAY,
|
||||||
flags));
|
flags));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MidoriBrowser:speed-dial:
|
||||||
|
*
|
||||||
|
* The speed dial configuration file.
|
||||||
|
*
|
||||||
|
* Since: 0.3.4
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_SPEED_DIAL,
|
||||||
|
g_param_spec_pointer (
|
||||||
|
"speed-dial",
|
||||||
|
"Speeddial",
|
||||||
|
"Pointer to key-value object with speed dial items",
|
||||||
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MidoriBrowser:show-tabs:
|
* MidoriBrowser:show-tabs:
|
||||||
*
|
*
|
||||||
|
@ -5651,6 +5669,7 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
browser->bookmarks = NULL;
|
browser->bookmarks = NULL;
|
||||||
browser->trash = NULL;
|
browser->trash = NULL;
|
||||||
browser->search_engines = NULL;
|
browser->search_engines = NULL;
|
||||||
|
browser->speeddial = NULL;
|
||||||
|
|
||||||
/* Setup the window metrics */
|
/* Setup the window metrics */
|
||||||
g_signal_connect (browser, "realize",
|
g_signal_connect (browser, "realize",
|
||||||
|
@ -6097,6 +6116,7 @@ midori_browser_finalize (GObject* object)
|
||||||
katze_object_assign (browser->trash, NULL);
|
katze_object_assign (browser->trash, NULL);
|
||||||
katze_object_assign (browser->search_engines, NULL);
|
katze_object_assign (browser->search_engines, NULL);
|
||||||
katze_object_assign (browser->history, NULL);
|
katze_object_assign (browser->history, NULL);
|
||||||
|
browser->speeddial = NULL;
|
||||||
|
|
||||||
katze_assign (browser->news_aggregator, NULL);
|
katze_assign (browser->news_aggregator, NULL);
|
||||||
|
|
||||||
|
@ -6663,6 +6683,9 @@ midori_browser_set_property (GObject* object,
|
||||||
case PROP_HISTORY:
|
case PROP_HISTORY:
|
||||||
midori_browser_set_history (browser, g_value_get_object (value));
|
midori_browser_set_history (browser, g_value_get_object (value));
|
||||||
break;
|
break;
|
||||||
|
case PROP_SPEED_DIAL:
|
||||||
|
browser->speeddial = g_value_get_pointer (value);
|
||||||
|
break;
|
||||||
case PROP_SHOW_TABS:
|
case PROP_SHOW_TABS:
|
||||||
browser->show_tabs = g_value_get_boolean (value);
|
browser->show_tabs = g_value_get_boolean (value);
|
||||||
if (browser->show_tabs)
|
if (browser->show_tabs)
|
||||||
|
@ -6738,6 +6761,9 @@ midori_browser_get_property (GObject* object,
|
||||||
case PROP_HISTORY:
|
case PROP_HISTORY:
|
||||||
g_value_set_object (value, browser->history);
|
g_value_set_object (value, browser->history);
|
||||||
break;
|
break;
|
||||||
|
case PROP_SPEED_DIAL:
|
||||||
|
g_value_set_pointer (value, browser->speeddial);
|
||||||
|
break;
|
||||||
case PROP_SHOW_TABS:
|
case PROP_SHOW_TABS:
|
||||||
g_value_set_boolean (value, browser->show_tabs);
|
g_value_set_boolean (value, browser->show_tabs);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue