Show error dialogue for invalid bookmark export filename
This commit is contained in:
parent
d925935b56
commit
e8d2dc3ee7
4 changed files with 43 additions and 22 deletions
|
@ -989,7 +989,7 @@ midori_browser_prepare_download (MidoriBrowser* browser,
|
||||||
else
|
else
|
||||||
g_assert_not_reached ();
|
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 (message);
|
||||||
g_free (detailed_message);
|
g_free (detailed_message);
|
||||||
g_object_unref (download);
|
g_object_unref (download);
|
||||||
|
@ -2260,7 +2260,7 @@ midori_browser_subscribe_to_news_feed (MidoriBrowser* browser,
|
||||||
"Alternatively go to Preferences, Applications in Midori, "
|
"Alternatively go to Preferences, Applications in Midori, "
|
||||||
"and select a News Aggregator. Next time you click the "
|
"and select a News Aggregator. Next time you click the "
|
||||||
"news feed icon, it will be added automatically."));
|
"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);
|
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),
|
if (!sokoke_show_uri_with_mime_type (gtk_widget_get_screen (view),
|
||||||
uri, "text/plain", gtk_get_current_event_time (), &error))
|
uri, "text/plain", gtk_get_current_event_time (), &error))
|
||||||
sokoke_message_dialog (GTK_MESSAGE_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)
|
if (error)
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_free (text_editor);
|
g_free (text_editor);
|
||||||
|
@ -4115,7 +4116,8 @@ _action_bookmarks_import_activate (GtkAction* action,
|
||||||
if (path && !midori_array_from_file (bookmarks, path, NULL, &error))
|
if (path && !midori_array_from_file (bookmarks, path, NULL, &error))
|
||||||
{
|
{
|
||||||
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
_("Failed to import bookmarks"), error ? error->message : "");
|
_("Failed to import bookmarks"),
|
||||||
|
error ? error->message : "", FALSE);
|
||||||
if (error)
|
if (error)
|
||||||
g_error_free (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)))
|
if (!browser->bookmarks || !gtk_widget_get_visible (GTK_WIDGET (browser)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
wrong_format:
|
||||||
file_dialog = sokoke_file_chooser_dialog_new (_("Save file as"),
|
file_dialog = sokoke_file_chooser_dialog_new (_("Save file as"),
|
||||||
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
|
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_dialog),
|
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)
|
if (gtk_dialog_run (GTK_DIALOG (file_dialog)) == GTK_RESPONSE_OK)
|
||||||
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_dialog));
|
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_dialog));
|
||||||
gtk_widget_destroy (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)
|
if (path == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -4169,16 +4184,10 @@ _action_bookmarks_export_activate (GtkAction* action,
|
||||||
db = g_object_get_data (G_OBJECT (browser->history), "db");
|
db = g_object_get_data (G_OBJECT (browser->history), "db");
|
||||||
bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
|
bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
|
||||||
midori_bookmarks_export_array_db (db, bookmarks, "");
|
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))
|
if (!midori_array_to_file (bookmarks, path, format, &error))
|
||||||
{
|
{
|
||||||
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
_("Failed to export bookmarks"), error ? error->message : "");
|
_("Failed to export bookmarks"), error ? error->message : "", FALSE);
|
||||||
if (error)
|
if (error)
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3962,7 +3962,8 @@ midori_view_set_uri (MidoriView* view,
|
||||||
result = midori_view_execute_script (view, &uri[11], &exception);
|
result = midori_view_execute_script (view, &uri[11], &exception);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sokoke_message_dialog (GTK_MESSAGE_ERROR, "javascript:", exception);
|
sokoke_message_dialog (GTK_MESSAGE_ERROR, "javascript:",
|
||||||
|
exception, FALSE);
|
||||||
g_free (exception);
|
g_free (exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,8 @@ sokoke_message_dialog_response_cb (GtkWidget* dialog,
|
||||||
void
|
void
|
||||||
sokoke_message_dialog (GtkMessageType message_type,
|
sokoke_message_dialog (GtkMessageType message_type,
|
||||||
const gchar* short_message,
|
const gchar* short_message,
|
||||||
const gchar* detailed_message)
|
const gchar* detailed_message,
|
||||||
|
gboolean modal)
|
||||||
{
|
{
|
||||||
GtkWidget* dialog = gtk_message_dialog_new (
|
GtkWidget* dialog = gtk_message_dialog_new (
|
||||||
NULL, 0, message_type,
|
NULL, 0, message_type,
|
||||||
|
@ -165,9 +166,18 @@ sokoke_message_dialog (GtkMessageType message_type,
|
||||||
"%s", short_message);
|
"%s", short_message);
|
||||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||||
"%s", detailed_message);
|
"%s", detailed_message);
|
||||||
g_signal_connect (dialog, "response",
|
if (modal)
|
||||||
G_CALLBACK (sokoke_message_dialog_response_cb), NULL);
|
{
|
||||||
gtk_widget_show (dialog);
|
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,
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
_("Could not run external program."),
|
_("Could not run external program."),
|
||||||
"Failed to initialize libosso");
|
"Failed to initialize libosso", FALSE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +454,7 @@ sokoke_spawn_program (const gchar* command,
|
||||||
osso_deinitialize (osso);
|
osso_deinitialize (osso);
|
||||||
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
_("Could not run external program."),
|
_("Could not run external program."),
|
||||||
"Failed to get dbus connection from osso context");
|
"Failed to get dbus connection from osso context", FALSE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +482,7 @@ sokoke_spawn_program (const gchar* command,
|
||||||
{
|
{
|
||||||
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
_("Could not run external program."),
|
_("Could not run external program."),
|
||||||
error ? error->message : "");
|
error ? error->message : "", FALSE);
|
||||||
if (error)
|
if (error)
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -501,7 +511,7 @@ sokoke_spawn_program (const gchar* command,
|
||||||
{
|
{
|
||||||
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
_("Could not run external program."),
|
_("Could not run external program."),
|
||||||
error->message);
|
error->message, FALSE);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_free (command_ready);
|
g_free (command_ready);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -515,7 +525,7 @@ sokoke_spawn_program (const gchar* command,
|
||||||
{
|
{
|
||||||
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
_("Could not run external program."),
|
_("Could not run external program."),
|
||||||
error->message);
|
error->message, FALSE);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,8 @@ sokoke_js_script_eval (JSContextRef js_context,
|
||||||
void
|
void
|
||||||
sokoke_message_dialog (GtkMessageType message_type,
|
sokoke_message_dialog (GtkMessageType message_type,
|
||||||
const gchar* short_message,
|
const gchar* short_message,
|
||||||
const gchar* detailed_message);
|
const gchar* detailed_message,
|
||||||
|
gboolean modal);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
sokoke_show_uri_with_mime_type (GdkScreen* screen,
|
sokoke_show_uri_with_mime_type (GdkScreen* screen,
|
||||||
|
|
Loading…
Reference in a new issue