Wrap file chooser into the function sokoke_file_chooser_dialog_new
This commit is contained in:
parent
9bcfba8ddc
commit
e5d8016bf4
5 changed files with 57 additions and 28 deletions
|
@ -872,14 +872,8 @@ midori_browser_save_uri (MidoriBrowser* browser,
|
|||
if (!GTK_WIDGET_VISIBLE (browser))
|
||||
return;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new (
|
||||
_("Save file as"), GTK_WINDOW (browser),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_SAVE);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (browser));
|
||||
dialog = sokoke_file_chooser_dialog_new (_("Save file as"),
|
||||
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
|
||||
if (uri)
|
||||
{
|
||||
|
@ -915,7 +909,7 @@ midori_browser_save_uri (MidoriBrowser* browser,
|
|||
if (!folder_set && last_dir && *last_dir)
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), last_dir);
|
||||
|
||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
|
||||
{
|
||||
#if WEBKIT_CHECK_VERSION (1, 1, 3)
|
||||
WebKitNetworkRequest* request;
|
||||
|
@ -1425,14 +1419,8 @@ midori_view_download_requested_cb (GtkWidget* view,
|
|||
|
||||
if (!dialog)
|
||||
{
|
||||
dialog = gtk_file_chooser_dialog_new (
|
||||
_("Save file"), GTK_WINDOW (browser),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_SAVE);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (browser));
|
||||
dialog = sokoke_file_chooser_dialog_new (_("Save file"),
|
||||
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
|
||||
folder = katze_object_get_string (browser->settings, "download-folder");
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), folder);
|
||||
|
@ -2128,21 +2116,16 @@ _action_open_activate (GtkAction* action,
|
|||
gchar* uri = NULL;
|
||||
gboolean folder_set = FALSE;
|
||||
GtkWidget* dialog;
|
||||
GtkWidget* view;
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (browser))
|
||||
return;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new (
|
||||
_("Open file"), GTK_WINDOW (browser),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_OPEN);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (browser));
|
||||
dialog = sokoke_file_chooser_dialog_new (_("Open file"),
|
||||
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
|
||||
/* base the start folder on the current view's uri if it is local */
|
||||
GtkWidget* view = midori_browser_get_current_tab (browser);
|
||||
view = midori_browser_get_current_tab (browser);
|
||||
if ((uri = (gchar*)midori_view_get_display_uri (MIDORI_VIEW (view))))
|
||||
{
|
||||
gchar* filename = g_filename_from_uri (uri, NULL, NULL);
|
||||
|
@ -2163,7 +2146,7 @@ _action_open_activate (GtkAction* action,
|
|||
if (!folder_set && last_dir && *last_dir)
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), last_dir);
|
||||
|
||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
|
||||
{
|
||||
gchar* folder;
|
||||
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
#include <idna.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HILDON_FM
|
||||
#include <hildon/hildon-file-chooser-dialog.h>
|
||||
#endif
|
||||
|
||||
static gchar*
|
||||
sokoke_js_string_utf8 (JSStringRef js_string)
|
||||
{
|
||||
|
@ -1295,3 +1299,37 @@ sokoke_window_activate_key (GtkWindow* window,
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* sokoke_file_chooser_dialog_new:
|
||||
* @title: a window title, or %NULL
|
||||
* @window: a parent #GtkWindow, or %NULL
|
||||
* @action: a #GtkFileChooserAction
|
||||
*
|
||||
* Creates a new file chooser dialog, as appropriate for
|
||||
* the platform, with buttons according to the @action.
|
||||
*
|
||||
* The positive response is %GTK_RESPONSE_OK.
|
||||
*
|
||||
* Return value: a new #GtkFileChooser
|
||||
**/
|
||||
GtkWidget*
|
||||
sokoke_file_chooser_dialog_new (const gchar* title,
|
||||
GtkWindow* window,
|
||||
GtkFileChooserAction action)
|
||||
{
|
||||
const gchar* stock_id = GTK_STOCK_OPEN;
|
||||
GtkWidget* dialog;
|
||||
|
||||
if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
||||
stock_id = GTK_STOCK_SAVE;
|
||||
#ifdef HAVE_HILDON_FM
|
||||
dialog = hildon_file_chooser_dialog_new (window, action);
|
||||
#else
|
||||
dialog = gtk_file_chooser_dialog_new (title, window, action,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
stock_id, GTK_RESPONSE_OK, NULL);
|
||||
gtk_window_set_icon_name (GTK_WINDOW (dialog), stock_id);
|
||||
#endif
|
||||
return dialog;
|
||||
}
|
||||
|
|
|
@ -176,4 +176,9 @@ gboolean
|
|||
sokoke_window_activate_key (GtkWindow* window,
|
||||
GdkEventKey* event);
|
||||
|
||||
GtkWidget*
|
||||
sokoke_file_chooser_dialog_new (const gchar* title,
|
||||
GtkWindow* window,
|
||||
GtkFileChooserAction action);
|
||||
|
||||
#endif /* !__SOKOKE_H__ */
|
||||
|
|
|
@ -10,7 +10,9 @@ obj.target = 'midori'
|
|||
obj.includes = '. ..'
|
||||
obj.find_sources_in_dirs ('.', excludes=['main.c'])
|
||||
obj.add_marshal_file ('marshal.list', 'midori_cclosure_marshal')
|
||||
obj.uselib = 'UNIQUE LIBSOUP LIBIDN GIO GTK SQLITE WEBKIT LIBXML WS2_32 OPENSSL HILDON'
|
||||
obj.uselib = 'UNIQUE LIBSOUP LIBIDN GIO GTK SQLITE WEBKIT LIBXML ' \
|
||||
'WS2_32 OPENSSL' \
|
||||
'HILDON HILDON_FM'
|
||||
obj.uselib_local = 'katze'
|
||||
obj.install_path = None
|
||||
|
||||
|
|
1
wscript
1
wscript
|
@ -223,6 +223,7 @@ def configure (conf):
|
|||
if check_pkg ('hildon-1', mandatory=False, var='HILDON'):
|
||||
check_pkg ('libosso', var='HILDON')
|
||||
check_pkg ('hildon-1', '2.2', var='HILDON_2_2')
|
||||
check_pkg ('hildon-fm-2', var='HILDON_FM')
|
||||
hildon = ['N/A','yes'][conf.env['HAVE_HILDON'] == 1]
|
||||
if hildon != 'yes':
|
||||
option_checkfatal ('hildon', 'Maemo integration')
|
||||
|
|
Loading…
Reference in a new issue