switch (webkit_download_get_status (download))
{
case WEBKIT_DOWNLOAD_STATUS_FINISHED:
+ {
+ MidoriBrowser* browser = midori_browser_get_for_widget (button);
+
icon = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
gtk_button_set_image (GTK_BUTTON (button), icon);
if (g_object_get_data (G_OBJECT (download), "open-download"))
else
g_object_set_data (G_OBJECT (gtk_widget_get_parent (button)),
"done", (void*)1);
+
+ if (browser->settings && katze_object_get_boolean (
+ browser->settings, "notify-transfer-completed"))
+ {
+ gchar* program = g_find_program_in_path ("notify-send");
+ if (program != NULL)
+ {
+ gchar* msg = g_strdup_printf (
+ _("The file <b>%s</b> has been downloaded."),
+ webkit_download_get_suggested_filename (download));
+ gchar* msgq = g_shell_quote (msg);
+ gchar* titleq = g_shell_quote (_("Transfer completed"));
+ gchar* command = g_strconcat (titleq, " ", msgq, NULL);
+ g_free (msg);
+ g_free (titleq);
+ g_free (msgq);
+ sokoke_spawn_program ("notify-send -i midori %s", command, FALSE);
+ g_free (command);
+ g_free (program);
+ }
+ }
+ }
break;
case WEBKIT_DOWNLOAD_STATUS_CANCELLED:
case WEBKIT_DOWNLOAD_STATUS_ERROR:
g_object_get (browser->settings,
"text-editor", &text_editor, NULL);
if (text_editor && *text_editor)
- sokoke_spawn_program (text_editor, unique_filename);
+ sokoke_spawn_program (text_editor, unique_filename, TRUE);
else
sokoke_show_uri (NULL, unique_filename,
gtk_get_current_event_time (), NULL);
{
const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
if (browser->news_aggregator && *browser->news_aggregator)
- sokoke_spawn_program (browser->news_aggregator, uri);
+ sokoke_spawn_program (browser->news_aggregator, uri, TRUE);
}
}
midori_web_view_menu_download_activate_cb (GtkWidget* widget,
MidoriView* view)
{
- sokoke_spawn_program (view->download_manager, view->link_uri);
+ sokoke_spawn_program (view->download_manager, view->link_uri, TRUE);
}
static void
gchar* homepage;
gboolean show_crash_dialog;
gchar* download_folder;
+ gboolean notify_transfer_completed;
gchar* download_manager;
gchar* text_editor;
gchar* news_aggregator;
PROP_HOMEPAGE,
PROP_SHOW_CRASH_DIALOG,
PROP_DOWNLOAD_FOLDER,
+ PROP_NOTIFY_TRANSFER_COMPLETED,
PROP_DOWNLOAD_MANAGER,
PROP_TEXT_EDITOR,
PROP_NEWS_AGGREGATOR,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
#endif
+ /**
+ * MidoriWebSettings:notify-transfer-completed:
+ *
+ * Whether to show a notification when a transfer has been completed.
+ *
+ * Since: 0.1.7
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_NOTIFY_TRANSFER_COMPLETED,
+ g_param_spec_boolean (
+ "notify-transfer-completed",
+ _("Notify when a transfer has been completed"),
+ _("Whether to show a notification when a transfer has been completed"),
+ TRUE,
+ #if WEBKIT_CHECK_VERSION (1, 1, 3)
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ #else
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ #endif
+
g_object_class_install_property (gobject_class,
PROP_DOWNLOAD_MANAGER,
g_param_spec_string (
static void
midori_web_settings_init (MidoriWebSettings* web_settings)
{
+ web_settings->notify_transfer_completed = TRUE;
web_settings->download_folder = g_strdup (midori_get_download_dir ());
web_settings->http_proxy = NULL;
web_settings->open_popups_in_tabs = TRUE;
case PROP_DOWNLOAD_FOLDER:
katze_assign (web_settings->download_folder, g_value_dup_string (value));
break;
+ case PROP_NOTIFY_TRANSFER_COMPLETED:
+ web_settings->notify_transfer_completed = g_value_get_boolean (value);
+ break;
case PROP_DOWNLOAD_MANAGER:
katze_assign (web_settings->download_manager, g_value_dup_string (value));
break;
case PROP_DOWNLOAD_FOLDER:
g_value_set_string (value, web_settings->download_folder);
break;
+ case PROP_NOTIFY_TRANSFER_COMPLETED:
+ g_value_set_boolean (value, web_settings->notify_transfer_completed);
+ break;
case PROP_DOWNLOAD_MANAGER:
g_value_set_string (value, web_settings->download_manager);
break;
gboolean
sokoke_spawn_program (const gchar* command,
- const gchar* argument)
+ const gchar* argument,
+ gboolean quote)
{
gchar* argument_escaped;
gchar* command_ready;
g_return_val_if_fail (command != NULL, FALSE);
g_return_val_if_fail (argument != NULL, FALSE);
- argument_escaped = g_shell_quote (argument);
+ argument_escaped = quote ? g_shell_quote (argument) : g_strdup (argument);
if (strstr (command, "%s"))
command_ready = g_strdup_printf (command, argument_escaped);
else
gboolean
sokoke_spawn_program (const gchar* command,
- const gchar* argument);
+ const gchar* argument,
+ gboolean quote);
gchar* sokoke_search_uri (const gchar* uri,
const gchar* keywords);