[gnome-utils] screenshot: don't save back settings when we're not in interactive mode



commit 26cbe261e515b70ce639c03665ef9d4a28988550
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Sep 26 17:19:39 2011 -0400

    screenshot: don't save back settings when we're not in interactive mode
    
    It doesn't make sense to save settings specified on the command line in
    GSettings, as the command line use is typically one-shot for a specific
    purpose (or inside a script which will always append settings).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=572817

 gnome-screenshot/gnome-screenshot.c  |   11 ++++++-----
 gnome-screenshot/screenshot-config.c |   11 ++++++++++-
 gnome-screenshot/screenshot-config.h |    5 ++++-
 3 files changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/gnome-screenshot/gnome-screenshot.c b/gnome-screenshot/gnome-screenshot.c
index 6a83ef2..3390914 100644
--- a/gnome-screenshot/gnome-screenshot.c
+++ b/gnome-screenshot/gnome-screenshot.c
@@ -542,7 +542,7 @@ prepare_screenshot_timeout (gpointer data)
 }
 
 static void
-screenshot_start (gboolean interactive)
+screenshot_start ()
 {
   guint delay = screenshot_config->delay * 1000;
 
@@ -550,7 +550,7 @@ screenshot_start (gboolean interactive)
    * We don't have any way to tell when the compositor has finished 
    * re-drawing.
    */
-  if (delay == 0 && interactive)
+  if (delay == 0 && screenshot_config->interactive)
     delay = 200;
 
   if (delay > 0)
@@ -575,7 +575,7 @@ interactive_dialog_response_cb (GtkWidget *d,
       gtk_main_quit ();
       break;
     case GTK_RESPONSE_OK:
-      screenshot_start (TRUE);
+      screenshot_start ();
       break;
     default:
       g_assert_not_reached ();
@@ -701,7 +701,8 @@ main (int argc, char *argv[])
                                 include_border_arg,
                                 disable_border_arg,
                                 border_effect_arg,
-                                delay_arg);
+                                delay_arg,
+                                interactive_arg);
 
   if (!res || !screenshot_app_init ())
     exit (1);
@@ -718,7 +719,7 @@ main (int argc, char *argv[])
     }
   else
     {
-      screenshot_start (FALSE);
+      screenshot_start ();
     }
 
   gtk_main ();
diff --git a/gnome-screenshot/screenshot-config.c b/gnome-screenshot/screenshot-config.c
index 6441919..1056737 100644
--- a/gnome-screenshot/screenshot-config.c
+++ b/gnome-screenshot/screenshot-config.c
@@ -64,7 +64,8 @@ screenshot_load_config (gboolean clipboard_arg,
                         gboolean include_border_arg,
                         gboolean disable_border_arg,
                         const gchar *border_effect_arg,
-                        guint delay_arg)
+                        guint delay_arg,
+                        gboolean interactive_arg)
 {
   static gboolean initialized = FALSE;
   ScreenshotConfig *config;
@@ -89,6 +90,8 @@ screenshot_load_config (gboolean clipboard_arg,
   config = g_slice_new0 (ScreenshotConfig);
   initialized = TRUE;
 
+  config->interactive = interactive_arg;
+
   config->settings = g_settings_new ("org.gnome.gnome-screenshot");
   populate_from_settings (config);
 
@@ -129,6 +132,12 @@ screenshot_save_config (void)
 
   g_assert (c != NULL);
 
+  /* if we were not started up in interactive mode, avoid
+   * overwriting these settings.
+   */
+  if (!c->interactive)
+    return;
+
   g_settings_set_boolean (c->settings,
                           INCLUDE_BORDER_KEY, c->include_border);
   g_settings_set_boolean (c->settings,
diff --git a/gnome-screenshot/screenshot-config.h b/gnome-screenshot/screenshot-config.h
index 82a0acf..7534391 100644
--- a/gnome-screenshot/screenshot-config.h
+++ b/gnome-screenshot/screenshot-config.h
@@ -42,6 +42,8 @@ typedef struct {
   gchar *border_effect;
 
   guint delay;
+
+  gboolean interactive;
 } ScreenshotConfig;
 
 ScreenshotConfig *screenshot_config;
@@ -52,7 +54,8 @@ gboolean screenshot_load_config (gboolean clipboard_arg,
                                  gboolean include_border_arg,
                                  gboolean disable_border_arg,
                                  const gchar *border_effect_arg,
-                                 guint delay_arg);
+                                 guint delay_arg,
+                                 gboolean interactive_arg);
 void screenshot_save_config      (void);
 
 G_END_DECLS



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]