Share one session among all KatzeNet instances
This commit is contained in:
parent
86dcb8b284
commit
191a613fc8
2 changed files with 15 additions and 9 deletions
|
@ -61,13 +61,19 @@ katze_net_object_maybe_unref (gpointer object)
|
||||||
static void
|
static void
|
||||||
katze_net_init (KatzeNet* net)
|
katze_net_init (KatzeNet* net)
|
||||||
{
|
{
|
||||||
|
#if HAVE_LIBSOUP
|
||||||
|
static SoupSession* session = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
net->memory = g_hash_table_new_full (g_str_hash, g_str_equal,
|
net->memory = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
g_free, katze_net_object_maybe_unref);
|
g_free, katze_net_object_maybe_unref);
|
||||||
net->cache_path = g_build_filename (g_get_user_cache_dir (),
|
net->cache_path = g_build_filename (g_get_user_cache_dir (),
|
||||||
PACKAGE_NAME, NULL);
|
PACKAGE_NAME, NULL);
|
||||||
|
|
||||||
#if HAVE_LIBSOUP
|
#if HAVE_LIBSOUP
|
||||||
net->session = soup_session_async_new ();
|
if (!session)
|
||||||
|
session = soup_session_async_new ();
|
||||||
|
net->session = session;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,17 +91,19 @@ katze_net_finalize (GObject* object)
|
||||||
/**
|
/**
|
||||||
* katze_net_new:
|
* katze_net_new:
|
||||||
*
|
*
|
||||||
* Instantiates a new #KatzeNet singleton.
|
* Instantiates a new #KatzeNet instance.
|
||||||
*
|
|
||||||
* Subsequent calls will ref the initial instance.
|
|
||||||
*
|
*
|
||||||
* Return value: a new #KatzeNet
|
* Return value: a new #KatzeNet
|
||||||
**/
|
**/
|
||||||
KatzeNet*
|
KatzeNet*
|
||||||
katze_net_new (void)
|
katze_net_new (void)
|
||||||
{
|
{
|
||||||
KatzeNet* net = g_object_new (KATZE_TYPE_NET,
|
static KatzeNet* net = NULL;
|
||||||
NULL);
|
|
||||||
|
if (!net)
|
||||||
|
net = g_object_new (KATZE_TYPE_NET, NULL);
|
||||||
|
else
|
||||||
|
g_object_ref (net);
|
||||||
|
|
||||||
return net;
|
return net;
|
||||||
}
|
}
|
||||||
|
|
|
@ -502,7 +502,7 @@ midori_view_class_init (MidoriViewClass* class)
|
||||||
"Net",
|
"Net",
|
||||||
"The associated net",
|
"The associated net",
|
||||||
KATZE_TYPE_NET,
|
KATZE_TYPE_NET,
|
||||||
G_PARAM_READWRITE));
|
flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1098,8 +1098,6 @@ midori_view_init (MidoriView* view)
|
||||||
|
|
||||||
view->download_manager = NULL;
|
view->download_manager = NULL;
|
||||||
|
|
||||||
view->net = katze_net_new ();
|
|
||||||
|
|
||||||
g_object_connect (view,
|
g_object_connect (view,
|
||||||
"signal::notify::icon",
|
"signal::notify::icon",
|
||||||
midori_view_notify_icon_cb, NULL,
|
midori_view_notify_icon_cb, NULL,
|
||||||
|
|
Loading…
Reference in a new issue