[Xfce4-commits] [apps/xfce4-screenshooter] 01/01: Allow --clipboard option to be used with the others (Bug #14120)
noreply at xfce.org
noreply at xfce.org
Sat Feb 24 22:49:15 CET 2018
This is an automated email from the git hooks/post-receive script.
a n d r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-screenshooter.
commit 4225942f7237f6d0bb47f1d49db53e2dac60fa71
Author: Andre Miranda <andreldm at xfce.org>
Date: Sat Feb 24 18:45:44 2018 -0300
Allow --clipboard option to be used with the others (Bug #14120)
Bonus: small code cleanup
---
lib/screenshooter-actions.c | 21 +++++++++------------
lib/screenshooter-dialogs.c | 12 ++++++------
lib/screenshooter-global.h | 12 ++++++------
src/main.c | 44 ++++++++++++--------------------------------
4 files changed, 33 insertions(+), 56 deletions(-)
diff --git a/lib/screenshooter-actions.c b/lib/screenshooter-actions.c
index ad288fb..8cea9f3 100644
--- a/lib/screenshooter-actions.c
+++ b/lib/screenshooter-actions.c
@@ -80,7 +80,10 @@ gboolean screenshooter_action_idle (ScreenshotData *sd)
}
}
- if (sd->action == SAVE)
+ if (sd->action & CLIPBOARD)
+ screenshooter_copy_to_clipboard (sd->screenshot);
+
+ if (sd->action & SAVE)
{
const gchar *save_location;
@@ -92,7 +95,7 @@ gboolean screenshooter_action_idle (ScreenshotData *sd)
sd->title,
sd->timestamp,
TRUE,
- sd->action_specified);
+ TRUE);
if (save_location)
{
@@ -104,10 +107,6 @@ gboolean screenshooter_action_idle (ScreenshotData *sd)
TRACE ("New save directory: %s", sd->screenshot_dir);
}
}
- else if (sd->action == CLIPBOARD)
- {
- screenshooter_copy_to_clipboard (sd->screenshot);
- }
else
{
GFile *temp_dir = g_file_new_for_path (g_get_tmp_dir ());
@@ -122,13 +121,11 @@ gboolean screenshooter_action_idle (ScreenshotData *sd)
if (screenshot_path != NULL)
{
- if (sd->action == OPEN)
+ if (sd->action & OPEN)
screenshooter_open_screenshot (screenshot_path, sd->app, sd->app_info);
- else if (sd->action == UPLOAD_IMGUR) {
- screenshooter_upload_to_imgur (screenshot_path,
- sd->title);
- }
- else
+ else if (sd->action & UPLOAD_IMGUR)
+ screenshooter_upload_to_imgur (screenshot_path, sd->title);
+ else if (sd->action & UPLOAD_ZIMAGEZ)
{
gchar *new_last_user = NULL;
diff --git a/lib/screenshooter-dialogs.c b/lib/screenshooter-dialogs.c
index e643fae..0ffd8f0 100644
--- a/lib/screenshooter-dialogs.c
+++ b/lib/screenshooter-dialogs.c
@@ -190,7 +190,7 @@ static void cb_clipboard_toggled (GtkToggleButton *tb, ScreenshotData *sd)
static void cb_zimagez_toggled (GtkToggleButton *tb, ScreenshotData *sd)
{
if (gtk_toggle_button_get_active (tb))
- sd->action = UPLOAD;
+ sd->action = UPLOAD_ZIMAGEZ;
}
static void cb_imgur_toggled (GtkToggleButton *tb, ScreenshotData *sd)
@@ -1006,7 +1006,7 @@ GtkWidget *screenshooter_actions_dialog_new (ScreenshotData *sd)
/* Save option radio button */
save_radio_button = gtk_radio_button_new_with_mnemonic (NULL, _("Save"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (save_radio_button),
- (sd->action == SAVE));
+ (sd->action & SAVE));
g_signal_connect (G_OBJECT (save_radio_button), "toggled",
G_CALLBACK (cb_save_toggled), sd);
gtk_widget_set_tooltip_text (save_radio_button, _("Save the screenshot to a PNG file"));
@@ -1023,7 +1023,7 @@ GtkWidget *screenshooter_actions_dialog_new (ScreenshotData *sd)
_("Copy the screenshot to the clipboard so that it can be "
"pasted later"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (clipboard_radio_button),
- (sd->action == CLIPBOARD));
+ (sd->action & CLIPBOARD));
g_signal_connect (G_OBJECT (clipboard_radio_button), "toggled",
G_CALLBACK (cb_clipboard_toggled), sd);
gtk_grid_attach (GTK_GRID (actions_grid), clipboard_radio_button, 0, 1, 1, 1);
@@ -1034,7 +1034,7 @@ GtkWidget *screenshooter_actions_dialog_new (ScreenshotData *sd)
gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (save_radio_button),
_("Open with:"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (open_with_radio_button),
- (sd->action == OPEN));
+ (sd->action & OPEN));
g_signal_connect (G_OBJECT (open_with_radio_button), "toggled",
G_CALLBACK (cb_open_toggled), sd);
gtk_widget_set_tooltip_text (open_with_radio_button,
@@ -1069,7 +1069,7 @@ GtkWidget *screenshooter_actions_dialog_new (ScreenshotData *sd)
gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (save_radio_button),
_("Host on ZimageZ"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (zimagez_radio_button),
- (sd->action == UPLOAD));
+ (sd->action & UPLOAD_ZIMAGEZ));
gtk_widget_set_tooltip_text (zimagez_radio_button,
_("Host the screenshot on ZimageZ, a free online "
"image hosting service"));
@@ -1082,7 +1082,7 @@ 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));
gtk_widget_set_tooltip_text (imgur_radio_button,
_("Host the screenshot on Imgur, a free online "
"image hosting service"));
diff --git a/lib/screenshooter-global.h b/lib/screenshooter-global.h
index 3ffcf2c..ce62b47 100644
--- a/lib/screenshooter-global.h
+++ b/lib/screenshooter-global.h
@@ -29,12 +29,12 @@
/* Possible actions */
enum {
- ACTION_0,
- SAVE,
- CLIPBOARD,
- OPEN,
- UPLOAD,
- UPLOAD_IMGUR,
+ NONE = 0,
+ SAVE = 1,
+ CLIPBOARD = 2,
+ OPEN = 4,
+ UPLOAD_ZIMAGEZ = 8,
+ UPLOAD_IMGUR = 16,
};
diff --git a/src/main.c b/src/main.c
index f7a0568..0a0dd8a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -151,6 +151,7 @@ int main (int argc, char **argv)
ScreenshotData *sd = g_new0 (ScreenshotData, 1);
sd->plugin = FALSE;
sd->app_info = NULL;
+ sd->action = 0;
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
@@ -209,13 +210,6 @@ int main (int argc, char **argv)
g_free (sd);
return EXIT_FAILURE;
}
- else if (upload && clipboard)
- {
- g_printerr (conflict_error, "upload", "clipboard");
-
- g_free (sd);
- return EXIT_FAILURE;
- }
else if ((application != NULL) && (screenshot_dir != NULL))
{
g_printerr (conflict_error, "open", "save");
@@ -223,20 +217,6 @@ int main (int argc, char **argv)
g_free (sd);
return EXIT_FAILURE;
}
- else if ((application != NULL) && clipboard)
- {
- g_printerr (conflict_error, "open", "clipboard");
-
- g_free (sd);
- return EXIT_FAILURE;
- }
- else if ((screenshot_dir != NULL) && clipboard)
- {
- g_printerr (conflict_error, "save", "clipboard");
-
- g_free (sd);
- return EXIT_FAILURE;
- }
else if (upload_imgur && upload)
{
g_printerr (conflict_error, "upload", "imgur");
@@ -322,29 +302,29 @@ int main (int argc, char **argv)
}
else if (upload)
{
- sd->app = g_strdup ("none");
- sd->action = UPLOAD;
+ sd->action = UPLOAD_ZIMAGEZ;
sd->action_specified = TRUE;
}
- else if (clipboard)
+ else if (upload_imgur)
{
- sd->app = g_strdup ("none");
- sd->action = CLIPBOARD;
+ sd->action = UPLOAD_IMGUR;
sd->action_specified = TRUE;
}
- else if (upload_imgur)
+ else if (screenshot_dir != NULL)
{
- sd->app = g_strdup ("none");
- sd->action = UPLOAD_IMGUR;
+ sd->action = SAVE;
+ sd->action_specified = TRUE;
+ }
+
+ if (clipboard)
+ {
+ sd->action |= CLIPBOARD;
sd->action_specified = TRUE;
}
if (!sd->app)
sd->app = g_strdup ("none");
- if (!sd->action)
- sd->action = SAVE;
-
/* If the user gave a directory name, check that it is valid */
if (screenshot_dir != NULL)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list