[Xfce4-commits] <midori:master> Show error dialogue for invalid bookmark export filename

Christian Dywan noreply at xfce.org
Wed Feb 2 01:32:01 CET 2011


Updating branch refs/heads/master
         to e8d2dc3ee7bee3fdf333f7ba1b093ad9b926a3ba (commit)
       from d925935b565e60dc75da97aad9e11b638164c05d (commit)

commit e8d2dc3ee7bee3fdf333f7ba1b093ad9b926a3ba
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Feb 2 01:10:02 2011 +0100

    Show error dialogue for invalid bookmark export filename

 midori/midori-browser.c |   31 ++++++++++++++++++++-----------
 midori/midori-view.c    |    3 ++-
 midori/sokoke.c         |   28 +++++++++++++++++++---------
 midori/sokoke.h         |    3 ++-
 4 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 3076060..e0b3c37 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -989,7 +989,7 @@ midori_browser_prepare_download (MidoriBrowser*  browser,
         else
             g_assert_not_reached ();
 
-        sokoke_message_dialog (GTK_MESSAGE_ERROR, message, detailed_message);
+        sokoke_message_dialog (GTK_MESSAGE_ERROR, message, detailed_message, FALSE);
         g_free (message);
         g_free (detailed_message);
         g_object_unref (download);
@@ -2260,7 +2260,7 @@ midori_browser_subscribe_to_news_feed (MidoriBrowser* browser,
             "Alternatively go to Preferences, Applications in Midori, "
             "and select a News Aggregator. Next time you click the "
             "news feed icon, it will be added automatically."));
-        sokoke_message_dialog (GTK_MESSAGE_INFO, _("New feed"), description);
+        sokoke_message_dialog (GTK_MESSAGE_INFO, _("New feed"), description, FALSE);
         g_free (description);
     }
 }
@@ -3325,7 +3325,8 @@ _action_source_view_activate (GtkAction*     action,
             if (!sokoke_show_uri_with_mime_type (gtk_widget_get_screen (view),
                 uri, "text/plain", gtk_get_current_event_time (), &error))
                 sokoke_message_dialog (GTK_MESSAGE_ERROR,
-                    _("Could not run external program."), error ? error->message : "");
+                    _("Could not run external program."),
+                    error ? error->message : "", FALSE);
             if (error)
                 g_error_free (error);
             g_free (text_editor);
@@ -4115,7 +4116,8 @@ _action_bookmarks_import_activate (GtkAction*     action,
         if (path && !midori_array_from_file (bookmarks, path, NULL, &error))
         {
             sokoke_message_dialog (GTK_MESSAGE_ERROR,
-                _("Failed to import bookmarks"), error ? error->message : "");
+                _("Failed to import bookmarks"),
+                error ? error->message : "", FALSE);
             if (error)
                 g_error_free (error);
         }
@@ -4144,6 +4146,7 @@ _action_bookmarks_export_activate (GtkAction*     action,
     if (!browser->bookmarks || !gtk_widget_get_visible (GTK_WIDGET (browser)))
         return;
 
+wrong_format:
     file_dialog = sokoke_file_chooser_dialog_new (_("Save file as"),
         GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
     gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_dialog),
@@ -4161,6 +4164,18 @@ _action_bookmarks_export_activate (GtkAction*     action,
     if (gtk_dialog_run (GTK_DIALOG (file_dialog)) == GTK_RESPONSE_OK)
         path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_dialog));
     gtk_widget_destroy (file_dialog);
+    if (g_str_has_suffix (path, ".xbel"))
+        format = "xbel";
+    else if (g_str_has_suffix (path, ".html"))
+        format = "netscape";
+    else if (path != NULL)
+    {
+        sokoke_message_dialog (GTK_MESSAGE_ERROR,
+            _("Midori can only export to XBEL (*.xbel) and Netscape (*.html)"),
+            "", TRUE);
+        katze_assign (path, NULL);
+        goto wrong_format;
+    }
 
     if (path == NULL)
         return;
@@ -4169,16 +4184,10 @@ _action_bookmarks_export_activate (GtkAction*     action,
     db = g_object_get_data (G_OBJECT (browser->history), "db");
     bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
     midori_bookmarks_export_array_db (db, bookmarks, "");
-    if (g_str_has_suffix (path, ".xbel"))
-        format = "xbel";
-    else if (g_str_has_suffix (path, ".html"))
-        format = "netscape";
-    else
-        g_assert_not_reached ();
     if (!midori_array_to_file (bookmarks, path, format, &error))
     {
         sokoke_message_dialog (GTK_MESSAGE_ERROR,
-            _("Failed to export bookmarks"), error ? error->message : "");
+            _("Failed to export bookmarks"), error ? error->message : "", FALSE);
         if (error)
             g_error_free (error);
     }
diff --git a/midori/midori-view.c b/midori/midori-view.c
index d455810..3cc4cbc 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -3962,7 +3962,8 @@ midori_view_set_uri (MidoriView*  view,
             result = midori_view_execute_script (view, &uri[11], &exception);
             if (!result)
             {
-                sokoke_message_dialog (GTK_MESSAGE_ERROR, "javascript:", exception);
+                sokoke_message_dialog (GTK_MESSAGE_ERROR, "javascript:",
+                                       exception, FALSE);
                 g_free (exception);
             }
         }
diff --git a/midori/sokoke.c b/midori/sokoke.c
index 61ff935..1a7a4d2 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -153,7 +153,8 @@ sokoke_message_dialog_response_cb (GtkWidget* dialog,
 void
 sokoke_message_dialog (GtkMessageType message_type,
                        const gchar*   short_message,
-                       const gchar*   detailed_message)
+                       const gchar*   detailed_message,
+                       gboolean       modal)
 {
     GtkWidget* dialog = gtk_message_dialog_new (
         NULL, 0, message_type,
@@ -165,9 +166,18 @@ sokoke_message_dialog (GtkMessageType message_type,
         "%s", short_message);
     gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                                               "%s", detailed_message);
-    g_signal_connect (dialog, "response",
-                      G_CALLBACK (sokoke_message_dialog_response_cb), NULL);
-    gtk_widget_show (dialog);
+    if (modal)
+    {
+        gtk_dialog_run (GTK_DIALOG (dialog));
+        gtk_widget_destroy (dialog);
+    }
+    else
+    {
+        g_signal_connect (dialog, "response",
+                          G_CALLBACK (sokoke_message_dialog_response_cb), NULL);
+        gtk_widget_show (dialog);
+    }
+
 }
 
 /**
@@ -434,7 +444,7 @@ sokoke_spawn_program (const gchar* command,
         {
             sokoke_message_dialog (GTK_MESSAGE_ERROR,
                                    _("Could not run external program."),
-                                   "Failed to initialize libosso");
+                                   "Failed to initialize libosso", FALSE);
             return FALSE;
         }
 
@@ -444,7 +454,7 @@ sokoke_spawn_program (const gchar* command,
             osso_deinitialize (osso);
             sokoke_message_dialog (GTK_MESSAGE_ERROR,
                                    _("Could not run external program."),
-                                   "Failed to get dbus connection from osso context");
+                                   "Failed to get dbus connection from osso context", FALSE);
             return FALSE;
         }
 
@@ -472,7 +482,7 @@ sokoke_spawn_program (const gchar* command,
         {
             sokoke_message_dialog (GTK_MESSAGE_ERROR,
                 _("Could not run external program."),
-                error ? error->message : "");
+                error ? error->message : "", FALSE);
             if (error)
                 g_error_free (error);
             return FALSE;
@@ -501,7 +511,7 @@ sokoke_spawn_program (const gchar* command,
         {
             sokoke_message_dialog (GTK_MESSAGE_ERROR,
                                    _("Could not run external program."),
-                                   error->message);
+                                   error->message, FALSE);
             g_error_free (error);
             g_free (command_ready);
             return FALSE;
@@ -515,7 +525,7 @@ sokoke_spawn_program (const gchar* command,
         {
             sokoke_message_dialog (GTK_MESSAGE_ERROR,
                                    _("Could not run external program."),
-                                   error->message);
+                                   error->message, FALSE);
             g_error_free (error);
         }
 
diff --git a/midori/sokoke.h b/midori/sokoke.h
index 288e79a..679e684 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -85,7 +85,8 @@ sokoke_js_script_eval                   (JSContextRef    js_context,
 void
 sokoke_message_dialog                   (GtkMessageType  message_type,
                                          const gchar*    short_message,
-                                         const gchar*    detailed_message);
+                                         const gchar*    detailed_message,
+                                         gboolean        modal);
 
 gboolean
 sokoke_show_uri_with_mime_type          (GdkScreen*      screen,



More information about the Xfce4-commits mailing list