[Xfce4-commits] <xfce4-screenshooter:master> If the user gives an action, don't show the dialog.

Jérôme Guelfucci noreply at xfce.org
Fri Oct 30 23:56:01 CET 2009


Updating branch refs/heads/master
         to a4450eaad93187a325fcd6c4c2138a6d3230a4ca (commit)
       from ddb1b3c9d7038cd2d138a7c23e1c7495c567f59a (commit)

commit a4450eaad93187a325fcd6c4c2138a6d3230a4ca
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Fri Oct 30 23:49:32 2009 +0100

    If the user gives an action, don't show the dialog.
    
    Instead we launch that action directly, supposing that if the user
    specified an action, he expects it to be used and not to be asked
    again what he wants to do.

 lib/screenshooter-actions.c         |   29 ++++++++++++++++-------------
 lib/screenshooter-global.h          |    1 +
 panel-plugin/screenshooter-plugin.c |    3 +++
 src/main.c                          |    6 ++++++
 4 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/lib/screenshooter-actions.c b/lib/screenshooter-actions.c
index cfb73d6..0d77661 100644
--- a/lib/screenshooter-actions.c
+++ b/lib/screenshooter-actions.c
@@ -54,22 +54,26 @@ gboolean screenshooter_take_screenshot_idle (ScreenshotData *sd)
 
 gboolean screenshooter_action_idle (ScreenshotData *sd)
 {
-  GtkWidget *dialog = screenshooter_actions_dialog_new (sd);
-  gint response;
+  if (!sd->action_specified)
+    {
+      GtkWidget *dialog = screenshooter_actions_dialog_new (sd);
+      gint response;
 
-  g_signal_connect (dialog, "response",
-                    (GCallback) cb_help_response, NULL);
-  g_signal_connect (dialog, "key-press-event",
-                    (GCallback) screenshooter_f1_key, NULL);
+      g_signal_connect (dialog, "response",
+                        (GCallback) cb_help_response, NULL);
+      g_signal_connect (dialog, "key-press-event",
+                        (GCallback) screenshooter_f1_key, NULL);
 
-  response = gtk_dialog_run (GTK_DIALOG (dialog));
+      response = gtk_dialog_run (GTK_DIALOG (dialog));
 
-  if (response == GTK_RESPONSE_CANCEL)
-    {
       gtk_widget_destroy (dialog);
-      if (!sd->plugin)
-        gtk_main_quit ();
-      return FALSE;
+
+      if (response == GTK_RESPONSE_CANCEL)
+        {
+          if (!sd->plugin)
+            gtk_main_quit ();
+          return FALSE;
+        }
     }
 
   if (sd->action == SAVE)
@@ -137,7 +141,6 @@ gboolean screenshooter_action_idle (ScreenshotData *sd)
   if (!sd->plugin)
     gtk_main_quit ();
 
-  gtk_widget_destroy (dialog);
   g_object_unref (sd->screenshot);
 
   return FALSE;
diff --git a/lib/screenshooter-global.h b/lib/screenshooter-global.h
index 8fb9996..41dfc0f 100644
--- a/lib/screenshooter-global.h
+++ b/lib/screenshooter-global.h
@@ -47,6 +47,7 @@ typedef struct
   gint delay;
   gint action;
   gboolean plugin;
+  gboolean action_specified;
   gboolean horodate;
   gchar *screenshot_dir;
   gchar *title;
diff --git a/panel-plugin/screenshooter-plugin.c b/panel-plugin/screenshooter-plugin.c
index a3dbfb6..5d6bd60 100644
--- a/panel-plugin/screenshooter-plugin.c
+++ b/panel-plugin/screenshooter-plugin.c
@@ -360,6 +360,9 @@ screenshooter_plugin_construct (XfcePanelPlugin *plugin)
      loop after taking a screenshot */
   pd->sd->plugin = TRUE;
 
+  /* We want the actions dialog to be always displayed */
+  pd->sd->action_specified = FALSE;
+
   /* Create the panel button */
   TRACE ("Create the panel button");
   pd->button = xfce_create_panel_button ();
diff --git a/src/main.c b/src/main.c
index fa1a5f8..0df1f9e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -211,6 +211,9 @@ int main (int argc, char **argv)
   rc_file = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, "xfce4/xfce4-screenshooter");
   screenshooter_read_rc_file (rc_file, sd);
 
+  /* Default to no action specified */
+  sd->action_specified = FALSE;
+
   /* Check if the directory read from the preferences is valid */
   default_save_dir = g_file_new_for_uri (sd->screenshot_dir);
 
@@ -250,11 +253,13 @@ int main (int argc, char **argv)
         {
           sd->app = application;
           sd->action = OPEN;
+          sd->action_specified = TRUE;
         }
       else if (upload)
         {
           sd->app = g_strdup ("none");
           sd->action = UPLOAD;
+          sd->action_specified = TRUE;
         }
       else
         {
@@ -271,6 +276,7 @@ int main (int argc, char **argv)
             {
               g_free (sd->screenshot_dir);
               sd->screenshot_dir = g_file_get_uri (default_save_dir);
+              sd->action_specified = TRUE;
             }
           else
               screenshooter_error (_("%s is not a valid directory, the default"



More information about the Xfce4-commits mailing list