]> saetta.ns0.it Git - libgtkmapserver/commitdiff
Added function ::get_soup_message.
authorAndrea Zagli <andrea.zagli@email.it>
Tue, 18 Aug 2015 21:21:00 +0000 (23:21 +0200)
committerAndrea Zagli <andrea.zagli@email.it>
Tue, 18 Aug 2015 21:21:00 +0000 (23:21 +0200)
src/gtkmapserver.c
src/gtkmapserver.h

index a4e1422b53a70b3b525bf5074120f757fccf7d75..a9b54c85014714663e0177cbf52ce6fd11245183 100644 (file)
@@ -32,8 +32,6 @@
        #include <windows.h>
 #endif
 
-#include <libsoup/soup.h>
-
 #include "gtkmapserver.h"
 
 static void gtk_mapserver_class_init (GtkMapserverClass *klass);
@@ -190,16 +188,16 @@ GtkWidget
        return gtk_mapserver;
 }
 
-void
-gtk_mapserver_set_home (GtkMapserver *gtkm,
-                                               const gchar *url)
+SoupMessage
+*gtk_mapserver_get_soup_message (GtkMapserver *gtkm,
+                                                                const gchar *url)
 {
-       GError *error;
        SoupMessage *msg;
-       GdkPixbufLoader *pxb_loader;
 
        GtkMapserverPrivate *priv = GTK_MAPSERVER_GET_PRIVATE (gtkm);
 
+       msg = NULL;
+
        msg = soup_message_new (SOUP_METHOD_GET, url);
        if (SOUP_IS_MESSAGE (msg))
                {
@@ -209,7 +207,27 @@ gtk_mapserver_set_home (GtkMapserver *gtkm,
 
        if (!SOUP_IS_MESSAGE (msg) || !SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
                {
-                       g_warning ("Error on retrieving url.");
+                       g_warning ("Error on retrieving url: %s.", url);
+                       msg = NULL;
+               }
+
+       return msg;
+}
+
+void
+gtk_mapserver_set_home (GtkMapserver *gtkm,
+                                               const gchar *url)
+{
+       GError *error;
+       SoupMessage *msg;
+       GdkPixbufLoader *pxb_loader;
+
+       GtkMapserverPrivate *priv = GTK_MAPSERVER_GET_PRIVATE (gtkm);
+
+       msg = gtk_mapserver_get_soup_message (gtkm, url);
+
+       if (msg == NULL)
+               {
                        pxb_loader = NULL;
                }
        else
@@ -337,3 +355,5 @@ gtk_mapserver_on_motion_notify_event (GtkWidget *widget,
                        priv->sel_y_start = y;
                }
 }
+
+/* UTILS */
index 0d50ceecf492e9985a10ed2e6f05dfeaec0138fc..4d73727a7fe27e843d197a1ca0aa753660f82b40 100644 (file)
@@ -27,7 +27,9 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <gtk/gtk.h>
+
 #include <goocanvas.h>
+#include <libsoup/soup.h>
 
 
 G_BEGIN_DECLS
@@ -59,6 +61,9 @@ GType gtk_mapserver_get_type (void) G_GNUC_CONST;
 
 GtkWidget *gtk_mapserver_new (void);
 
+SoupMessage *gtk_mapserver_get_soup_message (GtkMapserver *gtkm,
+                                                                                        const gchar *url);
+
 void gtk_mapserver_set_home (GtkMapserver *gtkm, const gchar *url);