[Goodies-commits] r7356 - in xfce4-screenshooter/trunk: . lib src

Jerome Guelfucci jeromeg at xfce.org
Sun May 17 17:56:42 CEST 2009


Author: jeromeg
Date: 2009-05-17 15:56:41 +0000 (Sun, 17 May 2009)
New Revision: 7356

Modified:
   xfce4-screenshooter/trunk/ChangeLog
   xfce4-screenshooter/trunk/lib/screenshooter-utils.c
   xfce4-screenshooter/trunk/lib/screenshooter-utils.h
   xfce4-screenshooter/trunk/src/main.c
Log:
	* lib/screenshooter-utils.{c,h}: use a constant in
	  (screenshooter_read_rc_file) and (screenshooter_write_rc_file).
	* src/main.c:
	  - use a constant for the rc file.
	  - don't save the preferences in the callback but in (main).


Modified: xfce4-screenshooter/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter/trunk/ChangeLog	2009-05-17 11:35:48 UTC (rev 7355)
+++ xfce4-screenshooter/trunk/ChangeLog	2009-05-17 15:56:41 UTC (rev 7356)
@@ -1,6 +1,14 @@
+2009-05-17 jeromeg
+
+	* lib/screenshooter-utils.{c,h}: use a constant in
+	  (screenshooter_read_rc_file) and (screenshooter_write_rc_file).
+	* src/main.c:
+	  - use a constant for the rc file.
+	  - don't save the preferences in the callback but in (main).
+
 2009-05-16 jeromeg
 
-	* src/screenshooter-utils.{c,h}: add (screenshooter_error) which shows
+	* lib/screenshooter-utils.{c,h}: add (screenshooter_error) which shows
 	  an error using a GtkMessageDialog.
 	* lib/*, panel-plugin/screenshooter-plugin.c, src/main.c:
 	  - use (screenshooter_error) instead of (xfce_err).

Modified: xfce4-screenshooter/trunk/lib/screenshooter-utils.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-utils.c	2009-05-17 11:35:48 UTC (rev 7355)
+++ xfce4-screenshooter/trunk/lib/screenshooter-utils.c	2009-05-17 15:56:41 UTC (rev 7356)
@@ -52,7 +52,7 @@
 @dir_only: if true, only read the screenshot_dir.
 */
 void
-screenshooter_read_rc_file (gchar *file, ScreenshotData *sd)
+screenshooter_read_rc_file (const gchar *file, ScreenshotData *sd)
 {
   const gchar *home_uri = screenshooter_get_home_uri ();
 
@@ -116,7 +116,7 @@
 @sd: a ScreenshotData.
 */
 void
-screenshooter_write_rc_file (gchar *file, ScreenshotData *sd)
+screenshooter_write_rc_file (const gchar *file, ScreenshotData *sd)
 {
   XfceRc *rc;
 

Modified: xfce4-screenshooter/trunk/lib/screenshooter-utils.h
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-utils.h	2009-05-17 11:35:48 UTC (rev 7355)
+++ xfce4-screenshooter/trunk/lib/screenshooter-utils.h	2009-05-17 15:56:41 UTC (rev 7356)
@@ -35,9 +35,9 @@
 
 
 void screenshooter_copy_to_clipboard (GdkPixbuf      *screenshot) ;
-void screenshooter_read_rc_file      (gchar          *file,
+void screenshooter_read_rc_file      (const gchar    *file,
                                       ScreenshotData *sd);
-void screenshooter_write_rc_file     (gchar          *file,
+void screenshooter_write_rc_file     (const gchar    *file,
                                       ScreenshotData *sd);
 void screenshooter_open_screenshot   (const gchar    *screenshot_path,
                                       const gchar    *application);

Modified: xfce4-screenshooter/trunk/src/main.c
===================================================================
--- xfce4-screenshooter/trunk/src/main.c	2009-05-17 11:35:48 UTC (rev 7355)
+++ xfce4-screenshooter/trunk/src/main.c	2009-05-17 15:56:41 UTC (rev 7356)
@@ -128,8 +128,6 @@
     }
   else if (response == GTK_RESPONSE_OK)
     {
-      gchar *rc_file;
-
       GdkDisplay *display = gdk_display_get_default ();
 
       gtk_widget_hide (dialog);
@@ -146,20 +144,6 @@
       if (sd->close == 1)
         {
           gtk_widget_destroy (dialog);
-
-          rc_file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG,
-                                                 "xfce4/xfce4-screenshooter",
-                                                 TRUE);
-
-          /* Save preferences */
-
-          if (rc_file != NULL)
-            {
-              screenshooter_write_rc_file (rc_file, sd);
-
-              g_free (rc_file);
-            }
-
           gtk_main_quit ();
         }
       else
@@ -169,23 +153,7 @@
     }
   else
     {
-      gchar *rc_file;
-
       gtk_widget_destroy (dialog);
-
-      rc_file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG,
-                                             "xfce4/xfce4-screenshooter",
-                                             TRUE);
-
-      /* Save preferences */
-
-      if (rc_file != NULL)
-        {
-          screenshooter_write_rc_file (rc_file, sd);
-
-          g_free (rc_file);
-        }
-
       gtk_main_quit ();
     }
 }
@@ -203,7 +171,7 @@
 
   ScreenshotData *sd = g_new0 (ScreenshotData, 1);
 
-  gchar *rc_file;
+  const gchar *rc_file;
 
   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
 
@@ -227,16 +195,10 @@
     g_thread_init (NULL);
 
   /* Read the preferences */
-
   rc_file = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, "xfce4/xfce4-screenshooter");
-
   screenshooter_read_rc_file (rc_file, sd);
 
-  if (G_LIKELY (rc_file != NULL))
-    g_free (rc_file);
-
   /* Check if the directory read from the preferences is valid */
-
   default_save_dir = g_file_new_for_uri (sd->screenshot_dir);
 
   if (G_UNLIKELY (!g_file_query_exists (default_save_dir, NULL)))
@@ -326,18 +288,24 @@
   else
     {
       GtkWidget *dialog;
+      const gchar *preferences_file =
+        xfce_resource_save_location (XFCE_RESOURCE_CONFIG,
+                                     "xfce4/xfce4-screenshooter",
+                                     TRUE);
 
       /* Set the dialog up */
 
       dialog = screenshooter_dialog_new (sd, FALSE);
 
-      gtk_window_set_type_hint(GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL);
-
       g_signal_connect (dialog, "response", G_CALLBACK (cb_dialog_response), sd);
-
       gtk_widget_show (dialog);
 
       gtk_main ();
+
+      /* Save preferences */
+      if (preferences_file != NULL)
+        screenshooter_write_rc_file (preferences_file, sd);
+
     }
 
   g_free (sd->screenshot_dir);




More information about the Goodies-commits mailing list