From a528c5b40534b666dfdf1bcd4736786d4034fc2e Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 16 Mar 2009 14:09:25 +0000 Subject: Cleanup loading error handling. --- (limited to 'browser-plugin') diff --git a/browser-plugin/glue.cpp b/browser-plugin/glue.cpp index 48562b4..148f566 100644 --- a/browser-plugin/glue.cpp +++ b/browser-plugin/glue.cpp @@ -148,7 +148,12 @@ int32 NPP_Write (NPP instance, NPStream* stream, void NPP_StreamAsFile (NPP instance, NPStream* stream, const char* fname) { Plugin *plugin = reinterpret_cast (instance->pdata); - plugin->Load (fname); + + if (fname != NULL) { + plugin->Load (fname); + } else { + plugin->ShowLoadingError (); + } } void NPP_Print (NPP instance, NPPrint* platformPrint) diff --git a/browser-plugin/plugin.cpp b/browser-plugin/plugin.cpp index 15f39ea..295c0f7 100644 --- a/browser-plugin/plugin.cpp +++ b/browser-plugin/plugin.cpp @@ -89,6 +89,12 @@ Plugin::SetWindow (GdkNativeWindow window) } void +Plugin::ShowLoadingError() +{ + /* FIXME display loading error in the UI */ +} + +void Plugin::Load (const char *fname) { GError *error = NULL; @@ -97,11 +103,9 @@ Plugin::Load (const char *fname) char *uri = g_file_get_uri (file); g_object_unref (file); - /* FIXME display loading error in the UI */ - EvDocument *document = ev_document_factory_get_document (uri, &error); if (error) { - g_warning ("Cannot create document for %s", uri); + ShowLoadingError (); g_error_free (error); return; } @@ -111,7 +115,7 @@ Plugin::Load (const char *fname) ev_document_load (document, uri, &error); if (error) { - g_warning ("Cannot load %s", uri); + ShowLoadingError (); g_error_free (error); return; } diff --git a/browser-plugin/plugin.h b/browser-plugin/plugin.h index 281affd..a46e07b 100644 --- a/browser-plugin/plugin.h +++ b/browser-plugin/plugin.h @@ -37,6 +37,7 @@ class Plugin { void ZoomOut (); void FindNext (const char *text); void FindPrevious (const char *text); + void ShowLoadingError (); NPObject *GetScriptableNPObject (); private: -- cgit v0.9.1