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)
{
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;
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);
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);
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;
#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)
{
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;
+}