* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
const gchar *default_format)
{
gchar *uri = NULL;
-
+
if (settings)
uri = g_strdup (gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_URI));
if (uri == NULL)
{
- const gchar *extension;
+ const gchar *extension, *basename, *output_dir;
gchar *name, *locale_name, *path;
if (default_format)
break;
}
}
-
- /* default filename used for print-to-file */
- name = g_strdup_printf (_("output.%s"), extension);
+
+ basename = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_BASENAME);
+ if (basename == NULL)
+ basename = _("output");
+
+ name = g_strconcat (basename, ".", extension, NULL);
+
locale_name = g_filename_from_utf8 (name, -1, NULL, NULL, NULL);
g_free (name);
if (locale_name != NULL)
- {
- const gchar *document_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
-
- if (document_dir == NULL)
+ {
+ output_dir = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_DIR);
+ if (output_dir == NULL)
{
- gchar *current_dir = g_get_current_dir ();
- path = g_build_filename (current_dir, locale_name, NULL);
- g_free (current_dir);
- }
+ const gchar *document_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
+
+ if (document_dir == NULL)
+ {
+ gchar *current_dir = g_get_current_dir ();
+ path = g_build_filename (current_dir, locale_name, NULL);
+ g_free (current_dir);
+ }
+ else
+ path = g_build_filename (document_dir, locale_name, NULL);
+
+ uri = g_filename_to_uri (path, NULL, NULL);
+ }
else
- path = g_build_filename (document_dir, locale_name, NULL);
-
- uri = g_filename_to_uri (path, NULL, NULL);
+ {
+ path = g_build_filename (output_dir, locale_name, NULL);
+ uri = g_filename_to_uri (path, NULL, NULL);
+ }
+ g_free (path);
g_free (locale_name);
- g_free (path);
- }
+ }
}
return uri;
GDestroyNotify dnotify;
} _PrintStreamData;
+/* expects GDK lock to be held */
static void
-file_print_cb (GtkPrintBackendFile *print_backend,
- GError *error,
- gpointer user_data)
+file_print_cb_locked (GtkPrintBackendFile *print_backend,
+ GError *error,
+ gpointer user_data)
{
_PrintStreamData *ps = (_PrintStreamData *) user_data;
- GDK_THREADS_ENTER ();
-
if (ps->target_io_stream != NULL)
g_output_stream_close (G_OUTPUT_STREAM (ps->target_io_stream), NULL, NULL);
if (ps->job)
g_object_unref (ps->job);
-
+
g_free (ps);
+}
+
+static void
+file_print_cb (GtkPrintBackendFile *print_backend,
+ GError *error,
+ gpointer user_data)
+{
+ GDK_THREADS_ENTER ();
+
+ file_print_cb_locked (print_backend, error, user_data);
GDK_THREADS_LEAVE ();
}
error = NULL;
- read_status =
+ read_status =
g_io_channel_read_chars (source,
buf,
_STREAM_MAX_CHUNK_SIZE,
error:
if (internal_error != NULL)
{
- file_print_cb (GTK_PRINT_BACKEND_FILE (print_backend),
- internal_error, ps);
+ file_print_cb_locked (GTK_PRINT_BACKEND_FILE (print_backend),
+ internal_error, ps);
g_error_free (internal_error);
return;