diff options
author | Marek Kasik <mkasik@redhat.com> | 2008-09-30 08:45:01 +0000 |
---|---|---|
committer | Marek Kašík <mkasik@src.gnome.org> | 2008-09-30 08:45:01 +0000 |
commit | 1d7c1e13e86001104ffddd0b750247dc4dfc4e46 (patch) | |
tree | fb4600172bf533721ca9a4f5c186ea87368ed99d /gtk/gtkprinteroptionwidget.c | |
parent | 6a3a9c957c89a5896d3bd904dc5b59ff1ae40011 (diff) | |
download | gtk+-1d7c1e13e86001104ffddd0b750247dc4dfc4e46.tar.gz |
Bug 344522 – support non-local destination files (GtkPrint):
2008-09-30 Marek Kasik <mkasik@redhat.com>
Bug 344522 – support non-local destination files (GtkPrint):
* gtk/gtkprintunixdialog.c
* gtk/gtkprinteroptionwidget.c: Process URI instead of filename.
* modules/printbackends/file/gtkprintbackendfile.c: Add ability
to save files on non-local filesystems.
svn path=/trunk/; revision=21552
Diffstat (limited to 'gtk/gtkprinteroptionwidget.c')
-rw-r--r-- | gtk/gtkprinteroptionwidget.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/gtk/gtkprinteroptionwidget.c b/gtk/gtkprinteroptionwidget.c index c058adb59b..38cdf00801 100644 --- a/gtk/gtkprinteroptionwidget.c +++ b/gtk/gtkprinteroptionwidget.c @@ -454,8 +454,8 @@ filesave_changed_cb (GtkWidget *button, { GtkPrinterOptionWidgetPrivate *priv = widget->priv; gchar *uri, *file; + gchar *directory; - /* TODO: how do we support nonlocal file systems? */ file = g_filename_from_utf8 (gtk_entry_get_text (GTK_ENTRY (priv->entry)), -1, NULL, NULL, NULL); if (file == NULL) @@ -464,31 +464,38 @@ filesave_changed_cb (GtkWidget *button, /* combine the value of the chooser with the value of the entry */ g_signal_handler_block (priv->source, priv->source_changed_handler); - if (g_path_is_absolute (file)) - uri = g_filename_to_uri (file, NULL, NULL); - else + directory = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->combo)); + + if ((g_uri_parse_scheme (file) == NULL) && (directory != NULL)) { - gchar *path; + if (g_path_is_absolute (file)) + uri = g_filename_to_uri (file, NULL, NULL); + else + { + gchar *path; #ifdef G_OS_UNIX - if (file[0] == '~' && file[1] == '/') - { - path = g_build_filename (g_get_home_dir (), file + 2, NULL); - } - else + if (file[0] == '~' && file[1] == '/') + { + path = g_build_filename (g_get_home_dir (), file + 2, NULL); + } + else #endif - { - gchar *directory; + { + path = g_build_filename (directory, file, NULL); + } - directory = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->combo)); - path = g_build_filename (directory, file, NULL); + uri = g_filename_to_uri (path, NULL, NULL); - g_free (directory); + g_free (path); } - - uri = g_filename_to_uri (path, NULL, NULL); - - g_free (path); + } + else + { + if (g_uri_parse_scheme (file) != NULL) + uri = g_strdup (file); + else + uri = g_build_path ("/", gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (priv->combo)), file, NULL); } if (uri) @@ -496,6 +503,7 @@ filesave_changed_cb (GtkWidget *button, g_free (uri); g_free (file); + g_free (directory); g_signal_handler_unblock (priv->source, priv->source_changed_handler); emit_changed (widget); @@ -783,6 +791,8 @@ construct_widgets (GtkPrinterOptionWidget *widget) priv->combo = gtk_file_chooser_button_new (source->display_text, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); + g_object_set (priv->combo, "local-only", FALSE, NULL); + label = gtk_label_new_with_mnemonic (_("_Name:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->entry); |