[recipes/image-download: 8/11] Add api to get a soup session
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/image-download: 8/11] Add api to get a soup session
- Date: Thu, 30 Mar 2017 11:46:16 +0000 (UTC)
commit 6591e06cc3c482b5fb41f85718ca625edf8306be
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 5 18:20:06 2017 -0500
Add api to get a soup session
We want to keep a single, global soup session.
src/gr-app.c | 12 ++++++++++++
src/gr-app.h | 2 ++
2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-app.c b/src/gr-app.c
index 966e6f5..77ad37d 100644
--- a/src/gr-app.c
+++ b/src/gr-app.c
@@ -39,6 +39,7 @@ struct _GrApp
{
GtkApplication parent_instance;
+ SoupSession *session;
GrShellSearchProvider *search_provider;
GtkCssProvider *css_provider;
};
@@ -51,6 +52,7 @@ gr_app_finalize (GObject *object)
{
GrApp *self = GR_APP (object);
+ g_clear_object (&self->session);
g_clear_object (&self->search_provider);
g_clear_object (&self->css_provider);
@@ -397,6 +399,10 @@ gr_app_init (GrApp *self)
_("Turn on verbose logging"), NULL);
g_log_set_writer_func (gr_log_writer, NULL, NULL);
+
+ self->session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT,
+ PACKAGE_NAME "/" PACKAGE_VERSION,
+ NULL);
}
static int
@@ -450,3 +456,9 @@ gr_app_new (void)
"flags", G_APPLICATION_HANDLES_OPEN | G_APPLICATION_CAN_OVERRIDE_APP_ID,
NULL);
}
+
+SoupSession *
+gr_app_get_soup_session (GrApp *app)
+{
+ return app->session;
+}
diff --git a/src/gr-app.h b/src/gr-app.h
index 91f491c..650fd55 100644
--- a/src/gr-app.h
+++ b/src/gr-app.h
@@ -19,6 +19,7 @@
#pragma once
#include <gtk/gtk.h>
+#include <libsoup/soup.h>
G_BEGIN_DECLS
@@ -27,5 +28,6 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GrApp, gr_app, GR, APP, GtkApplication)
GrApp *gr_app_new (void);
+SoupSession *gr_app_get_soup_session (GrApp *app);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]