diff -ru xfce4-screenshooter-1.8.2/lib/screenshooter-actions.c xfce4-screenshooter-1.8.2.new/lib/screenshooter-actions.c --- xfce4-screenshooter-1.8.2/lib/screenshooter-actions.c 2014-12-16 23:58:09.000000000 +0100 +++ xfce4-screenshooter-1.8.2.new/lib/screenshooter-actions.c 2015-08-08 11:15:14.448371301 +0200 @@ -92,7 +92,8 @@ sd->title, sd->timestamp, TRUE, - sd->action_specified); + sd->action_specified, + sd->as_jpeg); if (save_location) { @@ -118,7 +119,8 @@ sd->title, sd->timestamp, FALSE, - FALSE); + FALSE, + sd->as_jpeg); if (screenshot_path != NULL) { diff -ru xfce4-screenshooter-1.8.2/lib/screenshooter-dialogs.c xfce4-screenshooter-1.8.2.new/lib/screenshooter-dialogs.c --- xfce4-screenshooter-1.8.2/lib/screenshooter-dialogs.c 2014-12-20 10:23:33.000000000 +0100 +++ xfce4-screenshooter-1.8.2.new/lib/screenshooter-dialogs.c 2015-08-08 11:18:27.610351085 +0200 @@ -64,7 +64,8 @@ static gchar *generate_filename_for_uri (const gchar *uri, const gchar *title, - gboolean timestamp); + gboolean timestamp, + gboolean as_jpeg); static void cb_combo_active_item_changed (GtkWidget *box, ScreenshotData *sd); @@ -92,13 +93,16 @@ GCancellable *cancellable); static gchar *save_screenshot_to_local_path (GdkPixbuf *screenshot, - GFile *save_file); + GFile *save_file, + gboolean as_jpeg); static void save_screenshot_to_remote_location (GdkPixbuf *screenshot, - GFile *save_file); + GFile *save_file, + gboolean as_jpeg); static gchar *save_screenshot_to (GdkPixbuf *screenshot, - const gchar *save_uri); + const gchar *save_uri, + gboolean as_jpeg); @@ -224,7 +228,8 @@ */ static gchar *generate_filename_for_uri (const gchar *uri, const gchar *title, - gboolean timestamp) + gboolean timestamp, + gboolean as_jpeg) { gboolean exists = TRUE; GFile *directory; @@ -246,9 +251,9 @@ datetime = screenshooter_get_datetime (strftime_format); directory = g_file_new_for_uri (uri); if (!timestamp) - base_name = g_strconcat (title, ".png", NULL); + base_name = g_strconcat (title, as_jpeg ? ".jpg" : ".png", NULL); else - base_name = g_strconcat (title, "_", datetime, ".png", NULL); + base_name = g_strconcat (title, "_", datetime, as_jpeg ? ".jpg" : ".png", NULL); file = g_file_get_child (directory, base_name); @@ -266,7 +271,7 @@ for (i = 1; exists; ++i) { const gchar *extension = - g_strdup_printf ("-%d.png", i); + g_strdup_printf (as_jpeg ? "-%d.jpg" : "-%d.png", i); if (!timestamp) base_name = g_strconcat (title, extension, NULL); @@ -516,12 +521,12 @@ static gchar -*save_screenshot_to_local_path (GdkPixbuf *screenshot, GFile *save_file) +*save_screenshot_to_local_path (GdkPixbuf *screenshot, GFile *save_file, gboolean as_jpeg) { GError *error = NULL; gchar *save_path = g_file_get_path (save_file); - if (G_UNLIKELY (!gdk_pixbuf_save (screenshot, save_path, "png", &error, NULL))) + if (G_UNLIKELY (!gdk_pixbuf_save (screenshot, save_path, as_jpeg ? "jpeg" : "png", &error, NULL))) { if (error) { @@ -539,7 +544,7 @@ } static void -save_screenshot_to_remote_location (GdkPixbuf *screenshot, GFile *save_file) +save_screenshot_to_remote_location (GdkPixbuf *screenshot, GFile *save_file, gboolean as_jpeg) { gchar *save_basename = g_file_get_basename (save_file); gchar *save_path = g_build_filename (g_get_tmp_dir (), save_basename, NULL); @@ -560,7 +565,7 @@ GtkWidget *label1= gtk_label_new (""); GtkWidget *label2 = gtk_label_new (parent_uri); - save_screenshot_to_local_path (screenshot, save_file_temp); + save_screenshot_to_local_path (screenshot, save_file_temp, as_jpeg); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); @@ -618,7 +623,7 @@ } static gchar -*save_screenshot_to (GdkPixbuf *screenshot, const gchar *save_uri) +*save_screenshot_to (GdkPixbuf *screenshot, const gchar *save_uri, gboolean as_jpeg) { GFile *save_file = g_file_new_for_uri (save_uri); gchar *result = NULL; @@ -632,9 +637,9 @@ /* If the URI is a local one, we save directly */ if (!screenshooter_is_remote_uri (save_uri)) - result = save_screenshot_to_local_path (screenshot, save_file); + result = save_screenshot_to_local_path (screenshot, save_file, as_jpeg); else - save_screenshot_to_remote_location (screenshot, save_file); + save_screenshot_to_remote_location (screenshot, save_file, as_jpeg); g_object_unref (save_file); @@ -1104,9 +1109,10 @@ const gchar *title, gboolean timestamp, gboolean save_dialog, - gboolean show_preview) + gboolean show_preview, + gboolean as_jpeg) { - const gchar *filename = generate_filename_for_uri (directory, title, timestamp); + const gchar *filename = generate_filename_for_uri (directory, title, timestamp, as_jpeg); gchar *save_uri = g_build_filename (directory, filename, NULL); gchar *result; @@ -1169,7 +1175,9 @@ { g_free (save_uri); save_uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser)); - result = save_screenshot_to (screenshot, save_uri); + /* Check the file extension to reset the as_jpeg flag; */ + as_jpeg = g_str_has_suffix(save_uri, ".jpg"); + result = save_screenshot_to (screenshot, save_uri, as_jpeg); } else result = NULL; @@ -1177,7 +1185,7 @@ gtk_widget_destroy (chooser); } else - result = save_screenshot_to (screenshot, save_uri); + result = save_screenshot_to (screenshot, save_uri, as_jpeg); g_free (save_uri); diff -ru xfce4-screenshooter-1.8.2/lib/screenshooter-dialogs.h xfce4-screenshooter-1.8.2.new/lib/screenshooter-dialogs.h --- xfce4-screenshooter-1.8.2/lib/screenshooter-dialogs.h 2014-12-16 23:02:42.000000000 +0100 +++ xfce4-screenshooter-1.8.2.new/lib/screenshooter-dialogs.h 2015-08-08 11:15:42.689368345 +0200 @@ -44,7 +44,8 @@ const gchar *title, gboolean timestamp, gboolean save_dialog, - gboolean show_preview); + gboolean show_preview, + gboolean as_jpeg); diff -ru xfce4-screenshooter-1.8.2/lib/screenshooter-global.h xfce4-screenshooter-1.8.2.new/lib/screenshooter-global.h --- xfce4-screenshooter-1.8.2/lib/screenshooter-global.h 2014-12-12 22:20:23.000000000 +0100 +++ xfce4-screenshooter-1.8.2.new/lib/screenshooter-global.h 2015-08-08 10:59:26.820470473 +0200 @@ -55,6 +55,7 @@ gchar *app; gchar *last_user; GdkPixbuf *screenshot; + gboolean as_jpeg; } ScreenshotData; diff -ru xfce4-screenshooter-1.8.2/src/main.c xfce4-screenshooter-1.8.2.new/src/main.c --- xfce4-screenshooter-1.8.2/src/main.c 2014-12-16 21:29:35.000000000 +0100 +++ xfce4-screenshooter-1.8.2.new/src/main.c 2015-08-08 11:26:42.026299343 +0200 @@ -39,7 +39,7 @@ gchar *screenshot_dir; gchar *application; gint delay = 0; - +gboolean as_jpeg = FALSE; /* Set cli options. */ @@ -103,6 +103,11 @@ NULL }, { + "jpeg", 'j', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &as_jpeg, + N_("Save the screenshot to a jpeg file"), + NULL + }, + { NULL, ' ', 0, 0, NULL, NULL, NULL @@ -286,6 +291,8 @@ /* Default to no action specified */ sd->action_specified = FALSE; + sd->as_jpeg = as_jpeg; + /* Check if the directory read from the preferences is valid */ default_save_dir = g_file_new_for_uri (sd->screenshot_dir); diff -ru xfce4-screenshooter-1.8.2/xfce4-screenshooter.1 xfce4-screenshooter-1.8.2.new/xfce4-screenshooter.1 --- xfce4-screenshooter-1.8.2/xfce4-screenshooter.1 2014-12-12 22:14:58.000000000 +0100 +++ xfce4-screenshooter-1.8.2.new/xfce4-screenshooter.1 2015-08-08 11:26:22.740301362 +0200 @@ -33,6 +33,9 @@ \fB\-d\fR, \fB\-\-delay\fR Delay in seconds before taking the screenshot .TP +\fB\-j\fR, \fB\-\-jpeg\fR +Save the screenshot as a jpeg file +.TP \fB\-m\fR, \fB\-\-mouse\fR Display the mouse on the screenshot .TP