]> spindle.queued.net Git - midori/commitdiff
Show error dialogue for invalid bookmark export filename
authorChristian Dywan <christian@twotoasts.de>
Wed, 2 Feb 2011 00:10:02 +0000 (01:10 +0100)
committerChristian Dywan <christian@twotoasts.de>
Wed, 2 Feb 2011 00:31:16 +0000 (01:31 +0100)
midori/midori-browser.c
midori/midori-view.c
midori/sokoke.c
midori/sokoke.h

index 30760603fef8da3f8f3dab17c6518311d095e6b6..e0b3c377460dca9cc31169d423dade5258e80387 100644 (file)
@@ -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);
     }
index d45581026c44e17bfac5427e383af6493c8c57b6..3cc4cbc1b24b06b5af8c75a81e834dee9af6a713 100644 (file)
@@ -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);
             }
         }
index 61ff935fe1fd253cfabafb04d9a5301367eebc3a..1a7a4d29e48203a1af453f0ea738a495b7e6361a 100644 (file)
@@ -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);
         }
 
index 288e79abe3811664200efdb1328f120bddcbbed7..679e684c636f0159c1db7078a97eed973c663263 100644 (file)
@@ -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,