[Xfce4-commits] <xfce4-screenshooter:master> Fix a crash in the panel plugin and improve cli options handling.
Jérôme Guelfucci
jeromeg at xfce.org
Fri Aug 14 00:26:12 CEST 2009
Updating branch refs/heads/master
to 6e4a655b63002699138cd715ff41fc3636dd79b9 (commit)
from e1d446387ba42bae3d8f52056f90809177bd6724 (commit)
commit 6e4a655b63002699138cd715ff41fc3636dd79b9
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date: Mon Aug 3 17:07:31 2009 +0200
Fix a crash in the panel plugin and improve cli options handling.
Don't exit the gtk main loop when running the panel plugin, or the
panel plugin will be killed.
Don't accept two region options or two action options. Warn the user
that mouse, delay and action option are ignored when passed without a
region option. At the moment, those error and warning messages are only
displayed in logs or in a terminal. I don't think it's worth showing an
error dialog for this.
ChangeLog | 13 +++++++
lib/screenshooter-actions.c | 5 ++-
src/main.c | 74 ++++++++++++++++++++++++++++++++++---------
3 files changed, 75 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 439e579..fa50c20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,19 @@ Updated Italian and Galician documentation translation.
2009-08-03 jeromeg
+Fix a crash in the panel plugin and improve cli options handling.
+
+Don't exit the gtk main loop when running the panel plugin, or the
+panel plugin will be killed.
+
+Don't accept two region options or two action options. Warn the user
+that mouse, delay and action option are ignored when passed without a
+region option. At the moment, those error and warning messages are only
+displayed in logs or in a terminal. I don't think it's worth showing an
+error dialog for this.
+
+2009-08-03 jeromeg
+
Rainy day. Major interface rethinking.
This new interface is based on a suggestion by Yves-Alexis Pérez. The
diff --git a/lib/screenshooter-actions.c b/lib/screenshooter-actions.c
index 3faa9a8..7cc1fdd 100644
--- a/lib/screenshooter-actions.c
+++ b/lib/screenshooter-actions.c
@@ -54,7 +54,7 @@ gboolean screenshooter_take_screenshot_idle (ScreenshotData *sd)
if (sd->screenshot != NULL)
g_idle_add ((GSourceFunc) screenshooter_action_idle, sd);
- else
+ else if (!sd->plugin)
gtk_main_quit ();
return FALSE;
@@ -73,7 +73,8 @@ gboolean screenshooter_action_idle (ScreenshotData *sd)
if (response == GTK_RESPONSE_CANCEL)
{
gtk_widget_destroy (dialog);
- gtk_main_quit ();
+ if (!sd->plugin)
+ gtk_main_quit ();
return FALSE;
}
diff --git a/src/main.c b/src/main.c
index e24599e..3af8206 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,7 +32,7 @@ gboolean version = FALSE;
gboolean window = FALSE;
gboolean region = FALSE;
gboolean fullscreen = FALSE;
-gboolean hide_mouse = FALSE;
+gboolean mouse = FALSE;
gboolean upload = FALSE;
gchar *screenshot_dir;
gchar *application;
@@ -54,8 +54,8 @@ static GOptionEntry entries[] =
NULL
},
{
- "mouse", 'm', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &hide_mouse,
- N_("Do not display the mouse on the screenshot"),
+ "mouse", 'm', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &mouse,
+ N_("Display the mouse on the screenshot"),
NULL
},
{
@@ -139,6 +139,11 @@ int main (int argc, char **argv)
GError *cli_error = NULL;
GFile *default_save_dir;
const gchar *rc_file;
+ const gchar *conflict_error =
+ _("Conflicting options: --%s and --%s cannot be used at the same time.\n");
+ const gchar *ignore_error =
+ _("The --%s option is only used when --fullscreen, --window or"
+ " --region is given. It will be ignored.\n");
ScreenshotData *sd = g_new0 (ScreenshotData, 1);
sd->plugin = FALSE;
@@ -161,6 +166,53 @@ int main (int argc, char **argv)
}
}
+ /* Exit if two region options were given */
+ if (window && fullscreen)
+ {
+ g_printerr (conflict_error, "window", "fullscreen");
+ return EXIT_FAILURE;
+ }
+ else if (window && region)
+ {
+ g_printerr (conflict_error, "window", "region");
+ return EXIT_FAILURE;
+ }
+ else if (fullscreen && region)
+ {
+ g_printerr (conflict_error, "fullscreen", "region");
+ return EXIT_FAILURE;
+ }
+
+ /* Exit if two actions options were given */
+ if (upload && (application != NULL))
+ {
+ g_printerr (conflict_error, "upload", "open");
+ return EXIT_FAILURE;
+ }
+ else if (upload && (screenshot_dir != NULL))
+ {
+ g_printerr (conflict_error, "upload", "save");
+ return EXIT_FAILURE;
+ }
+ else if ((application != NULL) && (screenshot_dir != NULL))
+ {
+ g_printerr (conflict_error, "open", "save");
+ return EXIT_FAILURE;
+ }
+
+ /* Warn that action options, mouse and delay will be ignored in
+ * non-cli mode */
+ if ((application != NULL) && !(fullscreen || window || region))
+ g_printerr (ignore_error, "open");
+ if ((screenshot_dir != NULL) && !(fullscreen || window || region ))
+ g_printerr (ignore_error, "save");
+ if (upload && !(fullscreen || window || region))
+ g_printerr (ignore_error, "upload");
+ if (delay && !(fullscreen || window || region))
+ g_printerr (ignore_error, "delay");
+ if (mouse && !(fullscreen || window || region))
+ g_printerr (ignore_error, "mouse");
+
if (!g_thread_supported ())
g_thread_init (NULL);
@@ -193,20 +245,14 @@ int main (int argc, char **argv)
{
/* Set the region to be captured */
if (window)
- {
- sd->region = ACTIVE_WINDOW;
- }
+ sd->region = ACTIVE_WINDOW;
else if (fullscreen)
- {
- sd->region = FULLSCREEN;
- }
+ sd->region = FULLSCREEN;
else if (region)
- {
- sd->region = SELECT;
- }
+ sd->region = SELECT;
/* Whether to display the mouse pointer on the screenshot */
- hide_mouse ? (sd->show_mouse = 0) : (sd->show_mouse = 1);
+ mouse ? (sd->show_mouse = 1) : (sd->show_mouse = 0);
sd->delay = delay;
@@ -237,12 +283,10 @@ int main (int argc, char **argv)
sd->screenshot_dir = g_file_get_uri (default_save_dir);
}
else
- {
screenshooter_error ("%s",
_("%s is not a valid directory, the default"
" directory will be used."),
screenshot_dir);
- }
g_object_unref (default_save_dir);
g_free (screenshot_dir);
More information about the Xfce4-commits
mailing list