Reintroduce Download Manager preference
This commit is contained in:
parent
05426deadb
commit
7f388237dc
6 changed files with 161 additions and 27 deletions
|
@ -68,9 +68,12 @@ static void
|
||||||
clear_button_clicked_cb (GtkWidget* button, GtkWidget* file_chooser)
|
clear_button_clicked_cb (GtkWidget* button, GtkWidget* file_chooser)
|
||||||
{
|
{
|
||||||
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (file_chooser), "");
|
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (file_chooser), "");
|
||||||
/* Emit "file-set" manually for Gtk doesn't emit it otherwise
|
/* Emit signal manually for Gtk doesn't emit it otherwise */
|
||||||
FIXME: file-set is Gtk+ >= 2.12 */
|
#if GTK_CHECK_VERSION (2, 12, 0)
|
||||||
g_signal_emit_by_name (file_chooser, "file-set");
|
g_signal_emit_by_name (file_chooser, "file-set");
|
||||||
|
#else
|
||||||
|
g_signal_emit_by_name (file_chooser, "selection-changed");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -173,6 +176,34 @@ midori_preferences_new (GtkWindow* parent,
|
||||||
return GTK_WIDGET (preferences);
|
return GTK_WIDGET (preferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
proxy_download_manager_icon_cb (GtkWidget* entry,
|
||||||
|
GdkEventFocus* event,
|
||||||
|
GtkImage* icon)
|
||||||
|
{
|
||||||
|
const gchar* program;
|
||||||
|
gchar* path;
|
||||||
|
|
||||||
|
program = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||||
|
path = g_find_program_in_path (program);
|
||||||
|
|
||||||
|
if (path)
|
||||||
|
{
|
||||||
|
if (gtk_icon_theme_has_icon (gtk_icon_theme_get_for_screen (
|
||||||
|
gtk_widget_get_screen (entry)), program))
|
||||||
|
gtk_image_set_from_icon_name (icon, program, GTK_ICON_SIZE_MENU);
|
||||||
|
else
|
||||||
|
gtk_image_set_from_stock (icon, GTK_STOCK_EXECUTE, GTK_ICON_SIZE_MENU);
|
||||||
|
g_free (path);
|
||||||
|
}
|
||||||
|
else if (program && *program)
|
||||||
|
gtk_image_set_from_stock (icon, GTK_STOCK_STOP, GTK_ICON_SIZE_MENU);
|
||||||
|
else
|
||||||
|
gtk_image_clear (icon);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* midori_preferences_set_settings:
|
* midori_preferences_set_settings:
|
||||||
* @settings: the settings
|
* @settings: the settings
|
||||||
|
@ -185,6 +216,17 @@ void
|
||||||
midori_preferences_set_settings (MidoriPreferences* preferences,
|
midori_preferences_set_settings (MidoriPreferences* preferences,
|
||||||
MidoriWebSettings* settings)
|
MidoriWebSettings* settings)
|
||||||
{
|
{
|
||||||
|
GtkSizeGroup* sizegroup;
|
||||||
|
GtkWidget* page;
|
||||||
|
GtkWidget* frame;
|
||||||
|
GtkWidget* table;
|
||||||
|
GtkWidget* align;
|
||||||
|
GtkWidget* label;
|
||||||
|
GtkWidget* button;
|
||||||
|
GtkWidget* entry;
|
||||||
|
GtkWidget* hbox;
|
||||||
|
gint icon_width, icon_height;
|
||||||
|
|
||||||
g_return_if_fail (MIDORI_IS_PREFERENCES (preferences));
|
g_return_if_fail (MIDORI_IS_PREFERENCES (preferences));
|
||||||
g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));
|
g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));
|
||||||
|
|
||||||
|
@ -192,10 +234,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
|
||||||
|
|
||||||
preferences->notebook = gtk_notebook_new ();
|
preferences->notebook = gtk_notebook_new ();
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (preferences->notebook), 6);
|
gtk_container_set_border_width (GTK_CONTAINER (preferences->notebook), 6);
|
||||||
GtkSizeGroup* sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||||
GtkWidget* page; GtkWidget* frame; GtkWidget* table; GtkWidget* align;
|
|
||||||
GtkWidget* label; GtkWidget* button;
|
|
||||||
GtkWidget* entry; GtkWidget* hbox;
|
|
||||||
#define PAGE_NEW(__label) page = gtk_vbox_new (FALSE, 0); \
|
#define PAGE_NEW(__label) page = gtk_vbox_new (FALSE, 0); \
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (page), 5); \
|
gtk_container_set_border_width (GTK_CONTAINER (page), 5); \
|
||||||
gtk_notebook_append_page (GTK_NOTEBOOK (preferences->notebook), page, \
|
gtk_notebook_append_page (GTK_NOTEBOOK (preferences->notebook), page, \
|
||||||
|
@ -243,8 +282,20 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
|
||||||
INDENTED_ADD (label, 0, 1, 0, 1);
|
INDENTED_ADD (label, 0, 1, 0, 1);
|
||||||
button = katze_property_proxy (settings, "download-folder", "folder");
|
button = katze_property_proxy (settings, "download-folder", "folder");
|
||||||
FILLED_ADD (button, 1, 2, 0, 1);
|
FILLED_ADD (button, 1, 2, 0, 1);
|
||||||
button = katze_property_proxy (settings, "show-download-notification", "blurb");
|
label = katze_property_label (settings, "download-manager");
|
||||||
SPANNED_ADD (button, 0, 2, 1, 2);
|
INDENTED_ADD (label, 0, 1, 1, 2);
|
||||||
|
hbox = gtk_hbox_new (FALSE, 4);
|
||||||
|
button = gtk_image_new ();
|
||||||
|
gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (button),
|
||||||
|
GTK_ICON_SIZE_MENU, &icon_width, &icon_height);
|
||||||
|
gtk_widget_set_size_request (button, icon_width, icon_height);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 4);
|
||||||
|
entry = katze_property_proxy (settings, "download-manager", NULL);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
|
||||||
|
proxy_download_manager_icon_cb (entry, NULL, GTK_IMAGE (button));
|
||||||
|
g_signal_connect (entry, "focus-out-event",
|
||||||
|
G_CALLBACK (proxy_download_manager_icon_cb), button);
|
||||||
|
FILLED_ADD (hbox, 1, 2, 1, 2);
|
||||||
|
|
||||||
/* Page "Appearance" */
|
/* Page "Appearance" */
|
||||||
PAGE_NEW (_("Appearance"));
|
PAGE_NEW (_("Appearance"));
|
||||||
|
@ -260,7 +311,6 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
|
||||||
FILLED_ADD (hbox, 1, 2, 0, 1);
|
FILLED_ADD (hbox, 1, 2, 0, 1);
|
||||||
label = katze_property_label (settings, "minimum-font-size");
|
label = katze_property_label (settings, "minimum-font-size");
|
||||||
INDENTED_ADD (label, 0, 1, 1, 2);
|
INDENTED_ADD (label, 0, 1, 1, 2);
|
||||||
hbox = gtk_hbox_new (FALSE, 4);
|
|
||||||
entry = katze_property_proxy (settings, "minimum-font-size", NULL);
|
entry = katze_property_proxy (settings, "minimum-font-size", NULL);
|
||||||
INDENTED_ADD (entry, 1, 2, 1, 2);
|
INDENTED_ADD (entry, 1, 2, 1, 2);
|
||||||
label = katze_property_label (settings, "preferred-encoding");
|
label = katze_property_label (settings, "preferred-encoding");
|
||||||
|
|
|
@ -43,7 +43,7 @@ struct _MidoriWebSettings
|
||||||
MidoriStartup load_on_startup;
|
MidoriStartup load_on_startup;
|
||||||
gchar* homepage;
|
gchar* homepage;
|
||||||
gchar* download_folder;
|
gchar* download_folder;
|
||||||
gboolean show_download_notification;
|
gchar* download_manager;
|
||||||
gchar* location_entry_search;
|
gchar* location_entry_search;
|
||||||
MidoriPreferredEncoding preferred_encoding;
|
MidoriPreferredEncoding preferred_encoding;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ enum
|
||||||
PROP_LOAD_ON_STARTUP,
|
PROP_LOAD_ON_STARTUP,
|
||||||
PROP_HOMEPAGE,
|
PROP_HOMEPAGE,
|
||||||
PROP_DOWNLOAD_FOLDER,
|
PROP_DOWNLOAD_FOLDER,
|
||||||
PROP_SHOW_DOWNLOAD_NOTIFICATION,
|
PROP_DOWNLOAD_MANAGER,
|
||||||
PROP_LOCATION_ENTRY_SEARCH,
|
PROP_LOCATION_ENTRY_SEARCH,
|
||||||
PROP_PREFERRED_ENCODING,
|
PROP_PREFERRED_ENCODING,
|
||||||
|
|
||||||
|
@ -423,13 +423,13 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
|
||||||
G_PARAM_READABLE));
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_SHOW_DOWNLOAD_NOTIFICATION,
|
PROP_DOWNLOAD_MANAGER,
|
||||||
g_param_spec_boolean (
|
g_param_spec_string (
|
||||||
"show-download-notification",
|
"download-manager",
|
||||||
_("Show Download Notification"),
|
_("Download Manager"),
|
||||||
_("Show a notification window for finished downloads"),
|
_("An external download manager"),
|
||||||
TRUE,
|
NULL,
|
||||||
G_PARAM_READABLE));
|
flags));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_LOCATION_ENTRY_SEARCH,
|
PROP_LOCATION_ENTRY_SEARCH,
|
||||||
|
@ -705,8 +705,8 @@ midori_web_settings_set_property (GObject* object,
|
||||||
case PROP_DOWNLOAD_FOLDER:
|
case PROP_DOWNLOAD_FOLDER:
|
||||||
katze_assign (web_settings->download_folder, g_value_dup_string (value));
|
katze_assign (web_settings->download_folder, g_value_dup_string (value));
|
||||||
break;
|
break;
|
||||||
case PROP_SHOW_DOWNLOAD_NOTIFICATION:
|
case PROP_DOWNLOAD_MANAGER:
|
||||||
web_settings->show_download_notification = g_value_get_boolean (value);
|
katze_assign (web_settings->download_manager, g_value_dup_string (value));
|
||||||
break;
|
break;
|
||||||
case PROP_LOCATION_ENTRY_SEARCH:
|
case PROP_LOCATION_ENTRY_SEARCH:
|
||||||
katze_assign (web_settings->location_entry_search, g_value_dup_string (value));
|
katze_assign (web_settings->location_entry_search, g_value_dup_string (value));
|
||||||
|
@ -863,8 +863,8 @@ midori_web_settings_get_property (GObject* object,
|
||||||
case PROP_DOWNLOAD_FOLDER:
|
case PROP_DOWNLOAD_FOLDER:
|
||||||
g_value_set_string (value, web_settings->download_folder);
|
g_value_set_string (value, web_settings->download_folder);
|
||||||
break;
|
break;
|
||||||
case PROP_SHOW_DOWNLOAD_NOTIFICATION:
|
case PROP_DOWNLOAD_MANAGER:
|
||||||
g_value_set_boolean (value, web_settings->show_download_notification);
|
g_value_set_string (value, web_settings->download_manager);
|
||||||
break;
|
break;
|
||||||
case PROP_LOCATION_ENTRY_SEARCH:
|
case PROP_LOCATION_ENTRY_SEARCH:
|
||||||
g_value_set_string (value, web_settings->location_entry_search);
|
g_value_set_string (value, web_settings->location_entry_search);
|
||||||
|
@ -964,7 +964,7 @@ midori_web_settings_copy (MidoriWebSettings* web_settings)
|
||||||
"load-on-startup", web_settings->load_on_startup,
|
"load-on-startup", web_settings->load_on_startup,
|
||||||
"homepage", web_settings->homepage,
|
"homepage", web_settings->homepage,
|
||||||
"download-folder", web_settings->download_folder,
|
"download-folder", web_settings->download_folder,
|
||||||
"show-download-notification", web_settings->show_download_notification,
|
"download-manager", web_settings->download_manager,
|
||||||
"location-entry-search", web_settings->location_entry_search,
|
"location-entry-search", web_settings->location_entry_search,
|
||||||
"preferred-encoding", web_settings->preferred_encoding,
|
"preferred-encoding", web_settings->preferred_encoding,
|
||||||
|
|
||||||
|
|
|
@ -107,10 +107,6 @@ midori_accept_cookies_get_type (void) G_GNUC_CONST;
|
||||||
struct _MidoriWebSettingsClass
|
struct _MidoriWebSettingsClass
|
||||||
{
|
{
|
||||||
WebKitWebSettingsClass parent_class;
|
WebKitWebSettingsClass parent_class;
|
||||||
|
|
||||||
/* Signals */
|
|
||||||
void
|
|
||||||
(*dummy) (MidoriWebSettings* web_settings);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GType
|
GType
|
||||||
|
|
|
@ -411,6 +411,19 @@ midori_web_view_menu_new_window_activate_cb (GtkWidget* widget,
|
||||||
g_signal_emit (web_view, signals[NEW_WINDOW], 0, uri);
|
g_signal_emit (web_view, signals[NEW_WINDOW], 0, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
midori_web_view_menu_download_activate_cb (GtkWidget* widget,
|
||||||
|
MidoriWebView* web_view)
|
||||||
|
{
|
||||||
|
gchar* program;
|
||||||
|
const gchar* uri;
|
||||||
|
|
||||||
|
g_object_get (web_view->settings, "download-manager", &program, NULL);
|
||||||
|
uri = g_object_get_data (G_OBJECT (widget), "uri");
|
||||||
|
sokoke_spawn_program (program, uri);
|
||||||
|
g_free (program);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
webkit_web_view_populate_popup_cb (GtkWidget* web_view,
|
webkit_web_view_populate_popup_cb (GtkWidget* web_view,
|
||||||
GtkWidget* menu)
|
GtkWidget* menu)
|
||||||
|
@ -422,6 +435,7 @@ webkit_web_view_populate_popup_cb (GtkWidget* web_view,
|
||||||
GtkWidget* icon;
|
GtkWidget* icon;
|
||||||
gchar* text;
|
gchar* text;
|
||||||
GList* items;
|
GList* items;
|
||||||
|
gchar* program;
|
||||||
|
|
||||||
uri = midori_web_view_get_link_uri (MIDORI_WEB_VIEW (web_view));
|
uri = midori_web_view_get_link_uri (MIDORI_WEB_VIEW (web_view));
|
||||||
if (uri)
|
if (uri)
|
||||||
|
@ -450,6 +464,21 @@ webkit_web_view_populate_popup_cb (GtkWidget* web_view,
|
||||||
/* hack to disable non-functional Download File */
|
/* hack to disable non-functional Download File */
|
||||||
gtk_widget_set_sensitive (menuitem, FALSE);
|
gtk_widget_set_sensitive (menuitem, FALSE);
|
||||||
g_list_free (items);
|
g_list_free (items);
|
||||||
|
g_object_get (MIDORI_WEB_VIEW (web_view)->settings,
|
||||||
|
"download-manager", &program, NULL);
|
||||||
|
if (program && *program)
|
||||||
|
{
|
||||||
|
menuitem = gtk_image_menu_item_new_with_mnemonic (
|
||||||
|
_("Download Link with Download _Manager"));
|
||||||
|
icon = gtk_image_new_from_stock (GTK_STOCK_SAVE_AS,
|
||||||
|
GTK_ICON_SIZE_MENU);
|
||||||
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), icon);
|
||||||
|
gtk_menu_shell_insert (GTK_MENU_SHELL (menu), menuitem, 4);
|
||||||
|
g_object_set_data (G_OBJECT (menuitem), "uri", (gchar*)uri);
|
||||||
|
g_signal_connect (menuitem, "activate",
|
||||||
|
G_CALLBACK (midori_web_view_menu_download_activate_cb), web_view);
|
||||||
|
gtk_widget_show (menuitem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uri && webkit_web_view_has_selection (WEBKIT_WEB_VIEW (web_view)))
|
if (!uri && webkit_web_view_has_selection (WEBKIT_WEB_VIEW (web_view)))
|
||||||
|
|
|
@ -24,6 +24,61 @@
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
error_dialog (const gchar* short_message,
|
||||||
|
const gchar* detailed_message)
|
||||||
|
{
|
||||||
|
GtkWidget* dialog = gtk_message_dialog_new (
|
||||||
|
NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, short_message);
|
||||||
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||||
|
"%s", detailed_message);
|
||||||
|
gtk_widget_show (dialog);
|
||||||
|
g_signal_connect_swapped (dialog, "response",
|
||||||
|
G_CALLBACK (gtk_widget_destroy), dialog);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
sokoke_spawn_program (const gchar* command,
|
||||||
|
const gchar* argument)
|
||||||
|
{
|
||||||
|
gchar* argument_escaped;
|
||||||
|
gchar* command_ready;
|
||||||
|
gchar** argv;
|
||||||
|
GError* error;
|
||||||
|
|
||||||
|
argument_escaped = g_shell_quote (argument);
|
||||||
|
if (strstr (command, "%s"))
|
||||||
|
command_ready = g_strdup_printf (command, argument_escaped);
|
||||||
|
else
|
||||||
|
command_ready = g_strconcat (command, " ", argument_escaped, NULL);
|
||||||
|
|
||||||
|
error = NULL;
|
||||||
|
if (!g_shell_parse_argv (command_ready, NULL, &argv, &error))
|
||||||
|
{
|
||||||
|
error_dialog (_("Could not run external program."), error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
g_free (command_ready);
|
||||||
|
g_free (argument_escaped);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = NULL;
|
||||||
|
if (!g_spawn_async (NULL, argv, NULL,
|
||||||
|
(GSpawnFlags)G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
|
||||||
|
NULL, NULL, NULL, &error))
|
||||||
|
{
|
||||||
|
error_dialog (_("Could not run external program."), error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_strfreev (argv);
|
||||||
|
g_free (command_ready);
|
||||||
|
g_free (argument_escaped);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
sokoke_magic_uri (const gchar* uri,
|
sokoke_magic_uri (const gchar* uri,
|
||||||
MidoriWebList* search_engines)
|
MidoriWebList* search_engines)
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
/* Many themes need this hack for small toolbars to work */
|
/* Many themes need this hack for small toolbars to work */
|
||||||
#define GTK_ICON_SIZE_SMALL_TOOLBAR GTK_ICON_SIZE_BUTTON
|
#define GTK_ICON_SIZE_SMALL_TOOLBAR GTK_ICON_SIZE_BUTTON
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
sokoke_spawn_program (const gchar* command,
|
||||||
|
const gchar* argument);
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
sokoke_magic_uri (const gchar* uri,
|
sokoke_magic_uri (const gchar* uri,
|
||||||
MidoriWebList* search_engines);
|
MidoriWebList* search_engines);
|
||||||
|
|
Loading…
Reference in a new issue