From fa69a99d048a60777bb13fc9d59506db3cdb2da5 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Wed, 5 Feb 2020 12:27:24 +0100 Subject: [PATCH 1/3] Add option to disable imgur upload --- lib/screenshooter-global.h | 1 + lib/screenshooter-utils.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/screenshooter-global.h b/lib/screenshooter-global.h index 6280298..80d0a83 100644 --- a/lib/screenshooter-global.h +++ b/lib/screenshooter-global.h @@ -50,6 +50,7 @@ typedef struct gboolean action_specified; gboolean region_specified; gboolean timestamp; + gboolean enable_imgur_upload; gboolean path_is_dir; gchar *screenshot_dir; gchar *title; diff --git a/lib/screenshooter-utils.c b/lib/screenshooter-utils.c index 8e3cfa5..050c7a4 100644 --- a/lib/screenshooter-utils.c +++ b/lib/screenshooter-utils.c @@ -124,6 +124,7 @@ screenshooter_read_rc_file (const gchar *file, ScreenshotData *sd) gchar *title = g_strdup (_("Screenshot")); gchar *app = g_strdup ("none"); gchar *last_user = g_strdup (""); + gboolean enable_imgur_upload = TRUE; if (G_LIKELY (file != NULL)) { @@ -140,6 +141,7 @@ screenshooter_read_rc_file (const gchar *file, ScreenshotData *sd) action = xfce_rc_read_int_entry (rc, "action", SAVE); show_mouse = xfce_rc_read_int_entry (rc, "show_mouse", 1); timestamp = xfce_rc_read_bool_entry (rc, "timestamp", TRUE); + enable_imgur_upload = xfce_rc_read_bool_entry (rc, "enable_imgur_upload", TRUE); g_free (app); app = g_strdup (xfce_rc_read_entry (rc, "app", "none")); @@ -169,6 +171,7 @@ screenshooter_read_rc_file (const gchar *file, ScreenshotData *sd) sd->action = action; sd->show_mouse = show_mouse; sd->timestamp = timestamp; + sd->enable_imgur_upload = enable_imgur_upload; sd->screenshot_dir = screenshot_dir; sd->title = title; sd->app = app; @@ -200,6 +203,7 @@ screenshooter_write_rc_file (const gchar *file, ScreenshotData *sd) xfce_rc_write_entry (rc, "app", sd->app); xfce_rc_write_entry (rc, "last_user", sd->last_user); xfce_rc_write_entry (rc, "screenshot_dir", sd->screenshot_dir); + xfce_rc_write_bool_entry (rc, "enable_imgur_upload", sd->enable_imgur_upload); /* do not save if action was specified from cli */ if (!sd->action_specified) -- 2.23.0 From 2a8d8faa16a3f96dcf736428756333df5d344f1d Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Wed, 5 Feb 2020 13:17:55 +0100 Subject: [PATCH 2/3] Add "Enable Imgur upload" checkbox --- lib/screenshooter-dialogs.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/screenshooter-dialogs.c b/lib/screenshooter-dialogs.c index 33f919a..0c77abc 100644 --- a/lib/screenshooter-dialogs.c +++ b/lib/screenshooter-dialogs.c @@ -38,6 +38,9 @@ static void cb_show_mouse_toggled (GtkToggleButton *tb, ScreenshotData *sd); static void +cb_enable_imgur_toggled (GtkToggleButton *tb, + ScreenshotData *sd); +static void cb_save_toggled (GtkToggleButton *tb, ScreenshotData *sd); static void @@ -136,7 +139,14 @@ static void cb_show_mouse_toggled (GtkToggleButton *tb, ScreenshotData *sd) sd->show_mouse = 0; } - +/* Set whether the Imgur option should be enable when the button is toggled */ +static void cb_enable_imgur_toggled (GtkToggleButton *tb, ScreenshotData *sd) +{ + if (gtk_toggle_button_get_active (tb)) + sd->enable_imgur_upload = 1; + else + sd->enable_imgur_upload = 0; +} /* Set the action when the button is toggled */ static void cb_save_toggled (GtkToggleButton *tb, ScreenshotData *sd) @@ -663,6 +673,7 @@ GtkWidget *screenshooter_region_dialog_new (ScreenshotData *sd, gboolean plugin) *rectangle_button; GtkWidget *show_mouse_checkbox; + GtkWidget *enable_imgur_checkbox; GtkWidget *delay_main_box, *delay_box, *delay_label, *delay_alignment; GtkWidget *delay_spinner_box, *delay_spinner, *seconds_label; @@ -827,6 +838,19 @@ GtkWidget *screenshooter_region_dialog_new (ScreenshotData *sd, gboolean plugin) g_signal_connect (G_OBJECT (rectangle_button), "toggled", G_CALLBACK (cb_toggle_set_insensi), show_mouse_checkbox); + /* Create enable imgur checkbox */ + enable_imgur_checkbox = + gtk_check_button_new_with_label (_("Enable Imgur upload")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enable_imgur_checkbox), + (sd->enable_imgur_upload == 1)); + gtk_widget_set_tooltip_text (enable_imgur_checkbox, + _("Enable \"Upload to Imgur\" option")); + gtk_box_pack_start (GTK_BOX (area_box), + enable_imgur_checkbox, FALSE, + FALSE, 5); + g_signal_connect (G_OBJECT (enable_imgur_checkbox), "toggled", + G_CALLBACK (cb_enable_imgur_toggled), sd); + /* Create the main box for the delay stuff */ delay_main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_grid_attach (GTK_GRID (layout_grid), delay_main_box, 1, 0, 1, 1); -- 2.23.0 From 75430bdc67b2109cae37d781d58742da45cd14c8 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Wed, 5 Feb 2020 13:37:22 +0100 Subject: [PATCH 3/3] Connect Imgur upload option to Imgur option --- lib/screenshooter-dialogs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/screenshooter-dialogs.c b/lib/screenshooter-dialogs.c index 0c77abc..8776d94 100644 --- a/lib/screenshooter-dialogs.c +++ b/lib/screenshooter-dialogs.c @@ -1084,7 +1084,8 @@ GtkWidget *screenshooter_actions_dialog_new (ScreenshotData *sd) gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (save_radio_button), _("Host on Imgur")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (imgur_radio_button), - (sd->action & UPLOAD_IMGUR)); + (sd->action & UPLOAD_IMGUR && sd->enable_imgur_upload)); + gtk_widget_set_sensitive (imgur_radio_button, sd->enable_imgur_upload); gtk_widget_set_tooltip_text (imgur_radio_button, _("Host the screenshot on Imgur, a free online " "image hosting service")); -- 2.23.0