[Goodies-commits] r5746 - in xfce4-screenshooter-plugin/trunk: . lib panel-plugin po src

Jerome Guelfucci jeromeg at xfce.org
Wed Oct 22 19:22:15 CEST 2008


Author: jeromeg
Date: 2008-10-22 17:22:15 +0000 (Wed, 22 Oct 2008)
New Revision: 5746

Added:
   xfce4-screenshooter-plugin/trunk/lib/
   xfce4-screenshooter-plugin/trunk/lib/Makefile.am
   xfce4-screenshooter-plugin/trunk/lib/libscreenshooter.h
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h
   xfce4-screenshooter-plugin/trunk/panel-plugin/
   xfce4-screenshooter-plugin/trunk/panel-plugin/Makefile.am
   xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c
   xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter.desktop.in.in
Removed:
   xfce4-screenshooter-plugin/trunk/src/screenshooter-dialogs.c
   xfce4-screenshooter-plugin/trunk/src/screenshooter-dialogs.h
   xfce4-screenshooter-plugin/trunk/src/screenshooter-plugin.c
   xfce4-screenshooter-plugin/trunk/src/screenshooter-utils.c
   xfce4-screenshooter-plugin/trunk/src/screenshooter-utils.h
   xfce4-screenshooter-plugin/trunk/src/screenshooter.desktop.in.in
Modified:
   xfce4-screenshooter-plugin/trunk/ChangeLog
   xfce4-screenshooter-plugin/trunk/Makefile.am
   xfce4-screenshooter-plugin/trunk/NEWS
   xfce4-screenshooter-plugin/trunk/configure.ac.in
   xfce4-screenshooter-plugin/trunk/po/POTFILES.in
   xfce4-screenshooter-plugin/trunk/src/Makefile.am
   xfce4-screenshooter-plugin/trunk/src/main.c
Log:
* Reorganise the code structure.
* Save the state of the main application's button and reload them the next time.
* Various code cleanups. 


Modified: xfce4-screenshooter-plugin/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter-plugin/trunk/ChangeLog	2008-10-22 13:06:43 UTC (rev 5745)
+++ xfce4-screenshooter-plugin/trunk/ChangeLog	2008-10-22 17:22:15 UTC (rev 5746)
@@ -1,3 +1,13 @@
+2008-10-22 jeromeg
+
+  * Reorganisation of the code structure:
+    - move the generic code to /lib
+    - move the panel stuff to /panel-plugin/
+    - keep the main application in /src
+  * /lib/screenshooter-utils.{c,h} : 
+    - move the preferences file stuff here.
+  * /src/main.c: save the button's state and load it on startup.
+
 2008-10-18 jeromeg
 
   * src/Makefile.am: install desktop file for the main application.

Modified: xfce4-screenshooter-plugin/trunk/Makefile.am
===================================================================
--- xfce4-screenshooter-plugin/trunk/Makefile.am	2008-10-22 13:06:43 UTC (rev 5745)
+++ xfce4-screenshooter-plugin/trunk/Makefile.am	2008-10-22 17:22:15 UTC (rev 5746)
@@ -1,6 +1,6 @@
 @SET_MAKE@
 
-SUBDIRS = src po icons
+SUBDIRS = lib src panel-plugin po icons
 
 distclean-local:
 	rm -rf *.cache *~

Modified: xfce4-screenshooter-plugin/trunk/NEWS
===================================================================
--- xfce4-screenshooter-plugin/trunk/NEWS	2008-10-22 13:06:43 UTC (rev 5745)
+++ xfce4-screenshooter-plugin/trunk/NEWS	2008-10-22 17:22:15 UTC (rev 5746)
@@ -1,5 +1,7 @@
 === Version x.x.x ===
 
+  * Add a dialog to set the screenshot options and take a screenshot when no 
+    CLI option is given to the executable, add a menu entry for the application.
   * Use applets-screenshooter icon for preferences dialog and save dialog.
   * Add some default icons taken from the Rodent icon theme to make sure the
     applet has an icon.
@@ -8,9 +10,8 @@
     desktop when xfdesktop is set up not to display any icons.
   * New and updated translations, thanks to the fabulous translation team.
   * New CLI option to take a screenshot of the desktop.
-  * Add a dialog to set the screenshot options and take a screenshot when no 
-    CLI option is given to the executable.
   
+  
 === Version 1.3.2 ===
   
   * BUGFIX: plug some stupid leaks.

Modified: xfce4-screenshooter-plugin/trunk/configure.ac.in
===================================================================
--- xfce4-screenshooter-plugin/trunk/configure.ac.in	2008-10-22 13:06:43 UTC (rev 5745)
+++ xfce4-screenshooter-plugin/trunk/configure.ac.in	2008-10-22 17:22:15 UTC (rev 5746)
@@ -61,7 +61,9 @@
 icons/Makefile
 icons/48x48/Makefile
 icons/scalable/Makefile
+lib/Makefile
 src/Makefile
+panel-plugin/Makefile
 po/Makefile.in
 ])
 

Added: xfce4-screenshooter-plugin/trunk/lib/Makefile.am
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/Makefile.am	                        (rev 0)
+++ xfce4-screenshooter-plugin/trunk/lib/Makefile.am	2008-10-22 17:22:15 UTC (rev 5746)
@@ -0,0 +1,21 @@
+noinst_LTLIBRARIES = 							\
+	libscreenshooter.la
+
+libscreenshooter_la_SOURCES =							\
+	libscreenshooter.h \
+	screenshooter-utils.c screenshooter-utils.h \
+	screenshooter-dialogs.c screenshooter-dialogs.h
+
+libscreenshooter_la_CFLAGS = \
+	-I$(top_srcdir)	\
+  @GTK_CFLAGS@ \
+	@GLIB_CFLAGS@ \
+	@LIBXFCE4UTIL_CFLAGS@ \
+	@LIBXFCEGUI4_CFLAGS@ \
+	-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+	-Werror
+
+libscreenshooter_la_LIBADD = \
+  @GTK_LIBS@ \
+	@LIBXFCE4UTIL_LIBS@ \
+	@LIBXFCEGUI4_LIBS@

Added: xfce4-screenshooter-plugin/trunk/lib/libscreenshooter.h
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/libscreenshooter.h	                        (rev 0)
+++ xfce4-screenshooter-plugin/trunk/lib/libscreenshooter.h	2008-10-22 17:22:15 UTC (rev 5746)
@@ -0,0 +1,26 @@
+/*  $Id$
+ *
+ *  Copyright © 2008 Jérôme Guelfucci <jerome.guelfucci at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+ 
+#ifndef HAVE_SCREENSHOOTER_H
+#define HAVE_SCREENSHOOTER_H
+
+#include "screenshooter-dialogs.h"
+#include "screenshooter-utils.h"
+
+#endif

Added: xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	                        (rev 0)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	2008-10-22 17:22:15 UTC (rev 5746)
@@ -0,0 +1,288 @@
+/*  $Id$
+ *
+ *  Copyright © 2008 Jérôme Guelfucci <jerome.guelfucci at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "screenshooter-dialogs.h"
+
+/* Prototypes */ 
+
+static void cb_fullscreen_screen_toggled       (GtkToggleButton    *tb,
+                                                ScreenshotData     *sd);
+static void cb_active_window_toggled           (GtkToggleButton    *tb,
+                                                ScreenshotData     *sd);
+static void cb_show_save_dialog_toggled        (GtkToggleButton    *tb,
+                                                ScreenshotData     *sd);
+static void cb_default_folder                  (GtkWidget          *chooser, 
+                                                ScreenshotData     *sd);                                        
+static void cb_delay_spinner_changed           (GtkWidget          *spinner, 
+                                                ScreenshotData     *sd);                                                                              
+                                      
+/* Internals */
+
+static void cb_fullscreen_screen_toggled (GtkToggleButton *tb,
+                                          ScreenshotData   *sd)
+{
+  if (gtk_toggle_button_get_active (tb))
+    {
+      sd->mode = FULLSCREEN;
+    }
+  else
+    {
+      sd->mode = ACTIVE_WINDOW;
+    }
+}
+
+
+
+static void cb_active_window_toggled (GtkToggleButton *tb,
+                                      ScreenshotData   *sd)
+{
+  if (gtk_toggle_button_get_active (tb))
+    {
+      sd->mode = ACTIVE_WINDOW;
+    }
+  else
+    {
+      sd->mode = FULLSCREEN;
+    }
+}
+
+
+
+static void cb_show_save_dialog_toggled (GtkToggleButton *tb,
+                                         ScreenshotData   *sd)
+{
+  sd->show_save_dialog = gtk_toggle_button_get_active (tb);
+}                                  
+
+
+
+static void cb_default_folder (GtkWidget       *chooser, 
+                               ScreenshotData  *sd)
+{
+  sd->screenshot_dir = 
+    gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
+}
+
+   
+
+static void cb_delay_spinner_changed (GtkWidget       *spinner, 
+                                      ScreenshotData  *sd)
+{
+  sd->delay = 
+    gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spinner));
+} 
+
+
+                      
+/* Public */
+
+
+
+GtkWidget *screenshooter_dialog_new (ScreenshotData  *sd, gboolean plugin)
+{
+  GtkWidget *dlg;
+  GtkWidget *vbox;
+  GtkWidget *modes_frame, *modes_box;
+  GtkWidget *active_window_button, *fullscreen_button;
+  GtkWidget *options_frame, *options_box;
+  GtkWidget *save_button;
+  GtkWidget *default_save_label, *dir_chooser;
+  GtkWidget *delay_label, *delay_box, *delay_spinner, *label2;
+  
+  /* Create the dialog */
+  if (!plugin)
+    {
+      dlg = 
+        xfce_titled_dialog_new_with_buttons (_("Screenshot"),
+                                             NULL,
+                                             GTK_DIALOG_DESTROY_WITH_PARENT |
+                                             GTK_DIALOG_NO_SEPARATOR,
+                                             GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
+                                             GTK_STOCK_OK, GTK_RESPONSE_OK,
+                                             NULL);
+    }
+  else
+    {
+      dlg =
+        xfce_titled_dialog_new_with_buttons (_("Screenshooter plugin"),
+                                             NULL,
+                                             GTK_DIALOG_DESTROY_WITH_PARENT |
+                                             GTK_DIALOG_NO_SEPARATOR,
+                                             GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
+                                             NULL);
+    }                                             
+
+  gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER);
+  
+  gtk_container_set_border_width (GTK_CONTAINER (dlg), 2);
+  gtk_window_set_icon_name (GTK_WINDOW (dlg), "applets-screenshooter");
+  
+  /* Create the main box for the dialog */
+	vbox = gtk_vbox_new (FALSE, 8);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
+  gtk_widget_show (vbox);
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), vbox,
+                      TRUE, TRUE, 0);   
+  
+  /* Create the frame for screenshot modes and fill it with the radio buttons */
+  modes_frame = gtk_frame_new (_("Modes"));
+  gtk_container_add (GTK_CONTAINER (vbox), modes_frame);
+  gtk_widget_show (modes_frame);
+      
+  modes_box = gtk_vbox_new (FALSE, 8);
+  gtk_container_add (GTK_CONTAINER (modes_frame), modes_box);
+  gtk_container_set_border_width (GTK_CONTAINER (modes_box), 6);
+  gtk_widget_show (modes_box); 
+  
+  fullscreen_button = 
+    gtk_radio_button_new_with_mnemonic (NULL, 
+                                        _("Take a screenshot of desktop"));
+  gtk_widget_show (fullscreen_button);
+  gtk_box_pack_start (GTK_BOX (modes_box), fullscreen_button, FALSE, FALSE, 0);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fullscreen_button),
+                                (sd->mode == FULLSCREEN));
+  g_signal_connect (fullscreen_button, "toggled", 
+                    G_CALLBACK (cb_fullscreen_screen_toggled),
+                    sd);
+  
+  active_window_button = 
+    gtk_radio_button_new_with_mnemonic (gtk_radio_button_get_group (GTK_RADIO_BUTTON (fullscreen_button)), 
+                                        _("Take a screenshot of the active window"));
+  gtk_widget_show (active_window_button);
+  gtk_box_pack_start (GTK_BOX (modes_box), active_window_button, FALSE, FALSE, 0);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (active_window_button),
+                                (sd->mode == ACTIVE_WINDOW));
+  g_signal_connect (active_window_button, "toggled", 
+                    G_CALLBACK (cb_active_window_toggled),
+                    sd);
+  
+  /* Create the options frame and add the delay and save options */
+  options_frame = gtk_frame_new (_("Options"));
+  gtk_container_add(GTK_CONTAINER (vbox), options_frame);
+  gtk_widget_show (options_frame);
+  
+  options_box = gtk_vbox_new (FALSE, 8);
+  gtk_container_add (GTK_CONTAINER (options_frame), options_box);
+  gtk_container_set_border_width (GTK_CONTAINER (options_box), 6);
+  gtk_widget_show (options_box);
+  
+  
+  if (plugin)
+    {
+		  /* Save option */
+		  save_button = gtk_check_button_new_with_mnemonic (_("Show save dialog"));
+		  gtk_widget_show (save_button);
+		  gtk_box_pack_start (GTK_BOX (options_box), save_button, FALSE, FALSE, 0);
+		  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (save_button),
+		                                sd->show_save_dialog);
+		  g_signal_connect (save_button, "toggled", 
+		                    G_CALLBACK (cb_show_save_dialog_toggled), sd);
+    }
+
+  if (plugin)
+    {
+		  /* Default save location */          
+		  default_save_label = gtk_label_new ( "" );
+		  gtk_label_set_markup (GTK_LABEL (default_save_label),
+			_("<span weight=\"bold\" stretch=\"semiexpanded\">Default save location</span>"));
+			
+			gtk_misc_set_alignment (GTK_MISC (default_save_label), 0, 0);
+		  gtk_widget_show (default_save_label);
+		  gtk_container_add (GTK_CONTAINER (options_box), default_save_label);
+		  
+		  dir_chooser = 
+		    gtk_file_chooser_button_new (_("Default save location"), 
+		                                 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+		  gtk_widget_show (dir_chooser);
+		  gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dir_chooser), 
+		                                       sd->screenshot_dir);
+		  gtk_container_add (GTK_CONTAINER (options_box), dir_chooser);
+		  g_signal_connect (dir_chooser, "selection-changed", 
+		                    G_CALLBACK (cb_default_folder), sd);
+    }
+                    
+  /* Screenshot delay */
+  delay_label = gtk_label_new ( "" );
+  
+  gtk_label_set_markup (GTK_LABEL(delay_label),
+  _("<span weight=\"bold\" stretch=\"semiexpanded\">Delay before taking the screenshot</span>"));
+  
+	gtk_misc_set_alignment(GTK_MISC (delay_label), 0, 0); 
+  gtk_widget_show (delay_label);
+  gtk_container_add (GTK_CONTAINER (options_box), delay_label);
+  
+  delay_box = gtk_hbox_new(FALSE, 8);
+  gtk_widget_show (delay_box);
+  gtk_box_pack_start (GTK_BOX (options_box), delay_box, FALSE, FALSE, 0);
+
+  delay_spinner = gtk_spin_button_new_with_range(0.0, 60.0, 1.0);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (delay_spinner), 
+                             sd->delay);
+  gtk_widget_show (delay_spinner);
+  gtk_box_pack_start (GTK_BOX (delay_box), delay_spinner, FALSE, 
+                      FALSE, 0);
+
+  label2 = gtk_label_new_with_mnemonic(_("seconds"));
+  gtk_widget_show (label2);
+  gtk_box_pack_start (GTK_BOX (delay_box), label2, FALSE, FALSE, 0);
+
+  g_signal_connect (delay_spinner, "value-changed",
+                    G_CALLBACK (cb_delay_spinner_changed), sd);
+  
+  return dlg;                
+}
+
+
+void screenshooter_preferences_dialog (gchar *rc_file, 
+                                       gchar *current_default_dir)
+{
+  GtkWidget * chooser;
+  gint dialog_response;
+  gchar * dir;
+  XfceRc *rc;
+  
+  /* The preferences dialog is a plain gtk_file_chooser, we just get the
+  folder the user selected and write it in the conf file*/
+  
+  chooser = 
+    gtk_file_chooser_dialog_new (_("Default save folder"),
+                                  NULL,
+                                  GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+                                  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                  GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+                                  NULL);
+  gtk_window_set_icon_name (GTK_WINDOW (chooser), "applets-screenshooter");
+  gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT);
+  gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), 
+                                       current_default_dir);
+  
+  dialog_response = gtk_dialog_run(GTK_DIALOG (chooser));
+
+  if (dialog_response == GTK_RESPONSE_ACCEPT)
+    {
+      dir = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
+      
+      rc = xfce_rc_simple_open (rc_file, FALSE);
+      xfce_rc_write_entry (rc, "screenshot_dir", dir);
+      xfce_rc_close (rc);
+  
+      g_free (dir);
+    }
+  gtk_widget_destroy (GTK_WIDGET (chooser));
+}

Added: xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h	                        (rev 0)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h	2008-10-22 17:22:15 UTC (rev 5746)
@@ -0,0 +1,34 @@
+/*  $Id$
+ *
+ *  Copyright © 2008 Jérôme Guelfucci <jerome.guelfucci at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+ 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "screenshooter-utils.h"
+
+#include <gtk/gtk.h>
+#include <libxfce4util/libxfce4util.h>
+#include <libxfcegui4/libxfcegui4.h>
+
+GtkWidget   *screenshooter_dialog_new          (ScreenshotData  *sd,
+                                                gboolean         plugin);
+void         screenshooter_preferences_dialog  (gchar           *rc_file, 
+                                                gchar           *current_default_dir);
+                                      

Added: xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c	                        (rev 0)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c	2008-10-22 17:22:15 UTC (rev 5746)
@@ -0,0 +1,337 @@
+/*  $Id$
+ *
+ *  Copyright © 2008 Jérôme Guelfucci <jerome.guelfucci at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <screenshooter-utils.h>
+
+/* Prototypes */
+static gchar *generate_filename_for_uri      (char             *uri);
+static Window find_toplevel_window           (Window            xid);
+static void cb_current_folder_changed        (GtkFileChooser   *chooser, 
+                                              gpointer          user_data);
+
+
+/* Borrowed from gnome-screenshot */
+/* This function returns the toplevel window containing Window, for most window
+managers this will enable you to get the decorations around Window. Does not
+work with Compiz.
+Window: the X identifier of the window
+Returns: the X identifier of the toplevel window containing Window*/
+static Window
+find_toplevel_window (Window xid)
+{
+  Window root, parent, *children;
+  unsigned int nchildren;
+
+  do
+    {
+      if (XQueryTree (GDK_DISPLAY (), xid, &root,
+		      &parent, &children, &nchildren) == 0)
+	      {
+	        g_warning ( _("Couldn't find window manager window") );
+	        return None;
+	      }
+
+      if (root == parent)
+	      return xid;
+
+      xid = parent;
+    }
+  while (TRUE);
+}
+
+
+
+/* Generates filename Screenshot-n.png where n is the first integer greater than 
+0 so that Screenshot-n.jpg does not exist in the folder whose URI is *uri.
+*uri: the uri of the folder for which the filename should be generated.
+returns: a filename verifying the above conditions or NULL if *uri == NULL.
+*/
+static gchar *generate_filename_for_uri(char *uri)
+{
+  gchar *file_name;
+  unsigned int i = 0;
+    
+  if ( uri == NULL )
+    {
+  	  return NULL;
+    }      
+  
+  file_name = g_strdup (_("Screenshot.png"));
+  
+  /* If the plain filename matches the condition, go for it. */
+  if (g_access (g_build_filename (uri, file_name, NULL), F_OK) != 0) 
+    {
+      return file_name;
+    }
+  
+  /* Else, we find the first n that matches the condition */  
+  do
+    {
+      i++;
+      g_free (file_name);
+      file_name = g_strdup_printf (_("Screenshot-%d.png"), i);
+    }
+  while (g_access (g_build_filename (uri, file_name, NULL), F_OK) == 0);
+    
+  return file_name;
+}
+
+
+
+/* Generate a correct file name when setting a folder in chooser
+GtkFileChooser *chooser: the file chooser we are using.
+gpointer user_data: not used here.
+*/
+static void
+cb_current_folder_changed (GtkFileChooser *chooser, gpointer user_data)
+{
+  gchar *current_folder = 
+    gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (chooser));
+  
+  if (current_folder)
+    {
+      gchar *new_filename = generate_filename_for_uri (current_folder);
+      
+      gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (chooser), 
+                                         new_filename);
+      g_free (new_filename);
+    }
+  
+  g_free (current_folder);
+}
+
+
+
+/* Public */
+
+
+
+/* Takes the screenshot with the options given in sd.
+*sd: a ScreenshotData struct.
+returns: the screenshot in a *GdkPixbuf.
+*/
+GdkPixbuf *take_screenshot (gint mode, gint delay)
+{
+  GdkPixbuf *screenshot;
+  GdkWindow *window = NULL;
+  GdkScreen *screen;
+  
+  gint width;
+  gint height;
+  /* gdk_get_default_root_window (), needs_unref enables us to unref *window 
+  only if a non default window has been grabbed */
+  gboolean needs_unref = TRUE;
+  
+  /* Get the screen on which the screenshot should be taken */
+  screen = gdk_screen_get_default ();
+  
+  /* Get the window/desktop we want to screenshot*/  
+  if (mode == FULLSCREEN)
+    {
+      window = gdk_get_default_root_window ();
+      needs_unref = FALSE;
+    } 
+  else if (mode == ACTIVE_WINDOW)
+    {
+      window = gdk_screen_get_active_window (screen);
+      
+      /* If we are supposed to take a screenshot of the active window, and if 
+      the active window is the desktop background, grab the whole screen.*/      
+      if (window == NULL || 
+          gdk_window_get_type_hint (window) == GDK_WINDOW_TYPE_HINT_DESKTOP)
+        {
+          if (!(window == NULL))
+            {
+              g_object_unref (window);
+            }
+          
+          window = gdk_get_default_root_window ();
+          needs_unref = FALSE;
+        }
+      else
+        {
+          GdkWindow *window2;
+          
+          window2 = 
+            gdk_window_foreign_new (find_toplevel_window 
+                                    (GDK_WINDOW_XID (window)));
+          
+          g_object_unref (window);
+          
+          window = window2;
+        }
+    }
+  
+  /* wait for n=delay seconds */ 
+  sleep (delay);
+  
+  /* get the size of the part of the screen we want to screenshot */
+  gdk_drawable_get_size(window, &width, &height);
+  
+  /* get the screenshot */
+  screenshot = gdk_pixbuf_get_from_drawable (NULL,
+					     window,
+					     NULL, 0, 0, 0, 0,
+					     width, height);
+					     
+	if (needs_unref)
+	  g_object_unref (window);
+		
+	return screenshot;
+}
+
+
+
+/* Saves the screenshot according to the options in sd. 
+*screenshot: a GdkPixbuf containing our screenshot
+*sd: a ScreenshotData struct containing the save options.*/
+void save_screenshot (GdkPixbuf *screenshot, gboolean show_save_dialog,
+                      gchar *default_dir)
+{
+  GdkPixbuf *thumbnail;
+  gchar *filename = NULL;
+  GtkWidget *preview;
+  GtkWidget *chooser;
+  gint dialog_response;
+
+  filename = generate_filename_for_uri (default_dir);
+    
+  if (show_save_dialog)
+	  {
+	    /* If the user wants a save dialog, we run it, and grab the filename 
+	    the user has chosen. */
+	  
+      chooser = 
+        gtk_file_chooser_dialog_new (_("Save screenshot as ..."),
+                                     NULL,
+                                     GTK_FILE_CHOOSER_ACTION_SAVE,
+                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                     GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+                                     NULL);
+      gtk_window_set_icon_name (GTK_WINDOW (chooser), "applets-screenshooter");
+      gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (chooser), 
+                                                      TRUE);
+      gtk_dialog_set_default_response (GTK_DIALOG (chooser), 
+                                     GTK_RESPONSE_ACCEPT);
+      gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (chooser), 
+                                          default_dir);
+
+      preview = gtk_image_new ();
+  
+      gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (chooser), filename);
+      gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (chooser), preview);
+  
+      thumbnail = 
+        gdk_pixbuf_scale_simple (screenshot, gdk_pixbuf_get_width(screenshot)/5, 
+                                 gdk_pixbuf_get_height(screenshot)/5, 
+                                 GDK_INTERP_BILINEAR);
+      gtk_image_set_from_pixbuf (GTK_IMAGE (preview), thumbnail);
+      g_object_unref (thumbnail);
+      
+      /* We the user opens a folder in the fine_chooser, we set a valid
+      filename */
+      g_signal_connect (G_OBJECT (chooser), "current-folder-changed", 
+                        G_CALLBACK(cb_current_folder_changed), NULL);
+    
+      dialog_response = gtk_dialog_run (GTK_DIALOG (chooser));
+	  
+	    if (dialog_response == GTK_RESPONSE_ACCEPT)
+	      {
+	        g_free (filename);
+	        filename = 
+	          gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser) );
+          gdk_pixbuf_save (screenshot, filename, "png", NULL, NULL);
+	      }
+	  
+	    gtk_widget_destroy ( GTK_WIDGET ( chooser ) );
+	  }  
+	else
+	  {    
+	    gchar *savename = NULL;
+	    /* Else, we just save the file in the default folder */
+      
+      savename = g_build_filename (default_dir, filename, NULL);
+	    gdk_pixbuf_save (screenshot, savename, "png", NULL, NULL);
+	    
+	    g_free (savename);
+	  }
+
+  g_free (filename);
+}
+
+
+
+void
+screenshooter_read_rc_file (gchar *file, ScreenshotData *sd, gboolean dir_only)
+{
+  XfceRc *rc;
+  gint delay = 0;
+  gint mode = FULLSCREEN;
+  gint show_save_dialog = 1;
+  gchar *screenshot_dir = g_strdup (DEFAULT_SAVE_DIRECTORY);
+
+  if (g_file_test (file, G_FILE_TEST_EXISTS))
+    {
+      rc = xfce_rc_simple_open (file, TRUE);
+
+      if (rc != NULL)
+        {
+          if (!dir_only)
+            {
+              delay = xfce_rc_read_int_entry (rc, "delay", 0);
+              mode = xfce_rc_read_int_entry (rc, "mode", FULLSCREEN);
+              show_save_dialog = 
+                xfce_rc_read_int_entry (rc, "show_save_dialog", 1);
+            }
+  
+          g_free (screenshot_dir);
+          screenshot_dir = 
+            g_strdup (xfce_rc_read_entry (rc, 
+                                          "screenshot_dir", 
+                                          DEFAULT_SAVE_DIRECTORY));
+        }
+      
+      xfce_rc_close (rc);
+    }
+   
+  /* And set the sd values */
+  sd->delay = delay;
+  sd->mode = mode;
+  sd->show_save_dialog = show_save_dialog;
+  sd->screenshot_dir = screenshot_dir;
+}
+
+
+
+void
+screenshooter_write_rc_file (gchar *file, ScreenshotData *sd)
+{
+  XfceRc *rc;
+
+  rc = xfce_rc_simple_open (file, FALSE);
+  
+  g_return_if_fail (rc != NULL);
+  
+  xfce_rc_write_int_entry (rc, "delay", sd->delay);
+  xfce_rc_write_int_entry (rc, "mode", sd->mode);
+  xfce_rc_write_int_entry (rc, "show_save_dialog", sd->show_save_dialog);
+  xfce_rc_write_entry (rc, "screenshot_dir", sd->screenshot_dir);
+  
+  xfce_rc_close (rc);
+}

Added: xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h	                        (rev 0)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h	2008-10-22 17:22:15 UTC (rev 5746)
@@ -0,0 +1,64 @@
+/*  $Id$
+ *
+ *  Copyright © 2008 Jérôme Guelfucci <jerome.guelfucci at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __HAVE_UTILS_H__
+#define __HAVE_UTILS_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include <glib/gstdio.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#include <unistd.h>
+
+#define DEFAULT_SAVE_DIRECTORY xfce_get_homedir ()
+
+enum {
+  MODE_0,
+  FULLSCREEN,
+  ACTIVE_WINDOW,
+};
+
+/* Struct to store the screenshot options */
+typedef struct
+{
+  gint mode;
+  gint show_save_dialog;
+
+  gint delay;
+  gchar *screenshot_dir;
+}
+ScreenshotData;
+
+GdkPixbuf *take_screenshot       (gint                  mode, 
+                                  gint                  delay);
+void save_screenshot             (GdkPixbuf            *screenshot, 
+                                  gboolean              show_save_dialog,
+                                  gchar                *default_dir);
+void screenshooter_read_rc_file  (gchar                *file, 
+                                  ScreenshotData       *sd, 
+                                  gboolean              dir_only);
+void screenshooter_write_rc_file (gchar                *file, 
+                                  ScreenshotData       *sd);
+#endif                               

Added: xfce4-screenshooter-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-screenshooter-plugin/trunk/panel-plugin/Makefile.am	                        (rev 0)
+++ xfce4-screenshooter-plugin/trunk/panel-plugin/Makefile.am	2008-10-22 17:22:15 UTC (rev 5746)
@@ -0,0 +1,40 @@
+plugindir = $(libexecdir)/xfce4/panel-plugins
+plugin_PROGRAMS = xfce4-screenshooter-plugin
+
+xfce4_screenshooter_plugin_CFLAGS =						\
+	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"				\
+	-I$(top_srcdir)								\
+	-I$(top_srcdir)/lib							\
+	@LIBXFCE4PANEL_CFLAGS@ -Werror
+
+xfce4_screenshooter_plugin_LDFLAGS =						\
+	@LIBXFCE4PANEL_LIBS@ \
+	$(top_builddir)/lib/libscreenshooter.la
+
+xfce4_screenshooter_plugin_SOURCES =						\
+	screenshooter-plugin.c
+	
+# .desktop file
+#
+# Some automake trickery here. Because we cannot use $(libexecdir) in the
+# automake stage, we'll use sed to get the full path into the .desktop file.
+# We also need to let intltool merge the translated fields, so we add an
+# additional level of indirection: a <name>.desktop.in.in file.
+#
+desktop_in_in_files = screenshooter.desktop.in.in
+desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
+
+desktopdir = $(datadir)/xfce4/panel-plugins
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+ at INTLTOOL_DESKTOP_RULE@
+
+# get full path into .desktop file
+%.desktop.in: %.desktop.in.in
+	sed -e "s^@PLUGIN_PATH@^$(libexecdir)/xfce4/panel-plugins^" 	\
+		$< > $@
+
+EXTRA_DIST =								\
+	$(desktop_in_in_files)
+
+DISTCLEANFILES =							\
+	$(desktop_DATA) $(desktop_in_files)

Added: xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c	                        (rev 0)
+++ xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c	2008-10-22 17:22:15 UTC (rev 5746)
@@ -0,0 +1,304 @@
+/*  $Id$
+ *
+ *  Copyright © 2004 German Poo-Caaman~o <gpoo at ubiobio.cl>
+ *  Copyright © 2005,2006 Daniel Bobadilla Leal <dbobadil at dcc.uchile.cl>
+ *  Copyright © 2005 Jasper Huijsmans <jasper at xfce.org>
+ *  Copyright © 2006 Jani Monoses <jani at ubuntu.com>
+ *  Copyright © 2008 Jérôme Guelfucci <jerome.guelfucci at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+t */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+
+#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4panel/xfce-panel-plugin.h>
+#include <libxfce4panel/xfce-panel-convenience.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <X11/Xatom.h>
+
+#include "libscreenshooter.h"
+
+#define SCREENSHOT_ICON_NAME  "applets-screenshooter"
+
+/* Struct containing all panel plugin data */
+typedef struct
+{
+  XfcePanelPlugin *plugin;
+
+  GtkWidget *button;
+  GtkWidget *image;
+  
+  int style_id;
+  ScreenshotData *sd;
+}
+PluginData;
+
+
+
+/* Protoypes */
+
+static void screenshot_properties_dialog (XfcePanelPlugin *plugin,
+                                          PluginData *pd);
+static void screenshot_construct (XfcePanelPlugin *plugin);
+static gboolean screenshot_set_size (XfcePanelPlugin *plugin, 
+                                     int size, PluginData *pd);
+static void screenshot_free_data (XfcePanelPlugin *plugin, 
+                                  PluginData *pd);
+static void button_clicked (GtkWidget *button, PluginData *pd);
+static void screenshot_style_set (XfcePanelPlugin *plugin, gpointer ignored,
+                                  PluginData *pd);
+static void screenshot_read_rc_file (XfcePanelPlugin *plugin, PluginData *pd);                
+static void screenshot_write_rc_file (XfcePanelPlugin *plugin, PluginData *pd);
+                                        
+                                              
+
+/* Register the panel plugin */
+XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (screenshot_construct);
+
+
+
+/* Internal functions */
+
+
+
+/* Modify the size of the panel button 
+Returns TRUE if succesful. 
+*/
+static gboolean
+screenshot_set_size (XfcePanelPlugin *plugin, int size, PluginData *pd)
+{
+  GdkPixbuf *pb;
+  int width = size - 2 - 2 * MAX (pd->button->style->xthickness,
+                                    pd->button->style->ythickness);
+
+  pb = xfce_themed_icon_load (SCREENSHOT_ICON_NAME, width);
+  gtk_image_set_from_pixbuf (GTK_IMAGE (pd->image), pb);
+  g_object_unref (pb);
+  gtk_widget_set_size_request (GTK_WIDGET (plugin), size, size);
+
+  return TRUE;
+}
+
+
+
+/* Free the panel plugin data stored in pd
+plugin: a XfcePanelPlugin (a screenshooter one).
+pd: the associated PluginData. 
+*/
+static void
+screenshot_free_data (XfcePanelPlugin *plugin, PluginData *pd)
+{
+  if (pd->style_id)
+  	g_signal_handler_disconnect (plugin, pd->style_id);
+
+  pd->style_id = 0;
+  g_free (pd->sd->screenshot_dir);
+  g_free (pd->sd);
+  g_free (pd);
+}
+
+
+
+/* Take the screenshot when the button is clicked.
+button: the panel button.
+pd: the PluginData storing the options for taking the screenshot.
+*/
+static void
+button_clicked (GtkWidget *button, PluginData *pd)
+{
+  GdkPixbuf *screenshot;
+    
+	/* Make the button unclickable so that the user does not press it while 
+	another screenshot is in progress */
+	gtk_widget_set_sensitive (GTK_WIDGET (pd->button), FALSE);
+
+  /* Get the screenshot */
+	screenshot = take_screenshot (pd->sd->mode, pd->sd->delay);
+
+  save_screenshot (screenshot, pd->sd->show_save_dialog, 
+                   pd->sd->screenshot_dir);
+  
+	gtk_widget_set_sensitive (GTK_WIDGET (pd->button), TRUE);
+	
+	g_object_unref (screenshot);
+}
+
+
+
+/* Set the style of the panel plugin.
+plugin: a XfcePanelPlugin (a screenshooter one).
+pd: the associated PluginData.
+*/
+static void
+screenshot_style_set (XfcePanelPlugin *plugin, gpointer ignored,
+                       PluginData *pd)
+{
+  screenshot_set_size (plugin, xfce_panel_plugin_get_size (plugin), pd);
+}
+
+
+
+/* Read the rc file associated to the panel plugin and store the options in pd.
+plugin: a XfcePanelPlugin (a screenshooter one).
+pd: the associated PluginData.
+*/
+static void
+screenshot_read_rc_file (XfcePanelPlugin *plugin, PluginData *pd)
+{
+  screenshooter_read_rc_file (xfce_panel_plugin_lookup_rc_file (plugin), 
+                              pd->sd, 
+                              FALSE);
+}
+
+
+
+/* Write the pd options in the rc file associated to plugin
+plugin: a XfcePanelPlugin (a screenshooter one).
+pd: the associated PluginData.
+*/
+static void
+screenshot_write_rc_file (XfcePanelPlugin *plugin, PluginData *pd)
+{
+  screenshooter_write_rc_file (xfce_panel_plugin_save_location (plugin, TRUE), 
+                               pd->sd);  
+}
+
+
+
+/* Callback for dialog response:
+   Update the tooltips if using gtk >= 2.12.
+   Unblock the plugin contextual menu.
+   Save the options in the rc file.*/
+static void
+screenshot_dialog_response (GtkWidget *dlg, int reponse,
+                            PluginData *pd)
+{
+  g_object_set_data (G_OBJECT (pd->plugin), "dialog", NULL);
+
+  gtk_widget_destroy (dlg);
+  
+  /* Update tooltips according to the chosen option */
+  #if GTK_CHECK_VERSION(2,12,0)
+  if (pd->sd->mode == FULLSCREEN)
+  {
+    gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
+                                 _("Take a screenshot of the desktop"));
+  }
+  else
+  {
+    gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
+                                 _("Take a screenshot of the active window"));
+  }
+  #endif
+  
+  /* Unblock the menu and save options */
+  xfce_panel_plugin_unblock_menu (pd->plugin);
+  screenshot_write_rc_file (pd->plugin, pd);
+}
+
+
+
+/* Properties dialog to set the plugin options */
+static void
+screenshot_properties_dialog (XfcePanelPlugin *plugin, PluginData *pd)
+{
+  GtkWidget *dlg;
+  
+  dlg = screenshooter_dialog_new (pd->sd, TRUE);
+  
+  /* Block the menu to prevent the user from launching several dialogs at
+  the same time */
+  xfce_panel_plugin_block_menu (plugin);
+  
+  g_object_set_data (G_OBJECT (plugin), "dialog", dlg);
+
+  g_signal_connect (dlg, "response", G_CALLBACK (screenshot_dialog_response),
+                    pd);
+
+  gtk_widget_show (dlg);
+}
+
+
+
+/* Create the plugin button */
+static void
+screenshot_construct (XfcePanelPlugin *plugin)
+{
+  /* Initialise the data structs */
+  PluginData *pd = g_new0 (PluginData, 1);
+  ScreenshotData *sd = g_new0 (ScreenshotData, 1);
+
+  pd->sd = sd;
+  
+  xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+
+  pd->plugin = plugin;
+
+  /* Read the options */
+  screenshot_read_rc_file (plugin, pd);
+  
+  /* Create the panel button */
+  pd->button = xfce_create_panel_button ();
+
+  pd->image = gtk_image_new ();
+
+  gtk_container_add (GTK_CONTAINER (pd->button), GTK_WIDGET (pd->image));
+  
+  /* Set the tooltips if available */
+  #if GTK_CHECK_VERSION(2,12,0)
+  if (pd->sd->mode == FULLSCREEN)
+  {
+    gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
+                                 _("Take a screenshot of desktop"));
+  }
+  else
+  {
+    gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
+                                 _("Take a screenshot of the active window"));
+  }
+  #endif
+    
+  gtk_widget_show_all (pd->button);
+  
+  gtk_container_add (GTK_CONTAINER (plugin), pd->button);
+  xfce_panel_plugin_add_action_widget (plugin, pd->button);
+  
+  /* Set the callbacks */
+  g_signal_connect (pd->button, "clicked",
+                    G_CALLBACK (button_clicked), pd);
+
+  g_signal_connect (plugin, "free-data",
+                    G_CALLBACK (screenshot_free_data), pd);
+
+  g_signal_connect (plugin, "size-changed",
+                    G_CALLBACK (screenshot_set_size), pd);
+
+  pd->style_id =
+      g_signal_connect (plugin, "style-set",
+                        G_CALLBACK (screenshot_style_set), pd);
+
+  xfce_panel_plugin_menu_show_configure (plugin);
+  g_signal_connect (plugin, "configure-plugin",
+                    G_CALLBACK (screenshot_properties_dialog), pd);
+}
+XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (screenshot_construct);


Property changes on: xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c
___________________________________________________________________
Name: svn:executable
   + *

Added: xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter.desktop.in.in
===================================================================
--- xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter.desktop.in.in	                        (rev 0)
+++ xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter.desktop.in.in	2008-10-22 17:22:15 UTC (rev 5746)
@@ -0,0 +1,7 @@
+[Xfce Panel]
+Type=X-XFCE-PanelPlugin
+_Name= Screenshot
+_Comment= Take a screenshot
+Icon=applets-screenshooter
+X-XFCE-Exec=@PLUGIN_PATH@/xfce4-screenshooter-plugin
+


Property changes on: xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter.desktop.in.in
___________________________________________________________________
Name: svn:executable
   + *

Modified: xfce4-screenshooter-plugin/trunk/po/POTFILES.in
===================================================================
--- xfce4-screenshooter-plugin/trunk/po/POTFILES.in	2008-10-22 13:06:43 UTC (rev 5745)
+++ xfce4-screenshooter-plugin/trunk/po/POTFILES.in	2008-10-22 17:22:15 UTC (rev 5746)
@@ -1,5 +1,6 @@
-src/screenshooter-plugin.c
+lib/screenshooter-utils.c
+lib/screenshooter-dialogs.c
 src/main.c
-src/screenshooter-utils.c
-src/screenshooter.desktop.in.in
-src/screenshooter-dialogs.c
+src/xfce4-screenshooter.desktop.in.in
+panel-plugin/screenshooter-plugin.c
+panel-plugin/screenshooter.desktop.in.in

Modified: xfce4-screenshooter-plugin/trunk/src/Makefile.am
===================================================================
--- xfce4-screenshooter-plugin/trunk/src/Makefile.am	2008-10-22 13:06:43 UTC (rev 5745)
+++ xfce4-screenshooter-plugin/trunk/src/Makefile.am	2008-10-22 17:22:15 UTC (rev 5746)
@@ -1,70 +1,36 @@
-plugindir = $(libexecdir)/xfce4/panel-plugins
-plugin_PROGRAMS = xfce4-screenshooter-plugin
 bin_PROGRAMS = xfce4-screenshooter
-
-xfce4_screenshooter_plugin_CFLAGS =						\
-	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"				\
-	@LIBXFCE4PANEL_CFLAGS@ -Werror
-
-xfce4_screenshooter_plugin_LDFLAGS =						\
-	@LIBXFCE4PANEL_LIBS@
-
-xfce4_screenshooter_plugin_SOURCES =						\
-	screenshooter-plugin.c \
-	screenshooter-utils.c screenshooter-utils.h \
-	screenshooter-dialogs.c screenshooter-dialogs.h
 	
-	
 xfce4_screenshooter_CFLAGS = \
 	@GTK_CFLAGS@ \
 	@GLIB_CFLAGS@ \
 	@LIBXFCE4UTIL_CFLAGS@ \
 	@LIBXFCEGUI4_CFLAGS@ \
-	-DPACKAGE_LOCALE_DIR=\"$(localedir)\" -Werror
+	-DPACKAGE_LOCALE_DIR=\"$(localedir)\" -Werror \
+	-I$(top_srcdir)/lib
 	
 xfce4_screenshooter_LDFLAGS =                       \
 	@GTK_LIBS@ \
 	@LIBXFCE4UTIL_LIBS@ \
-	@LIBXFCEGUI4_LIBS@
+	@LIBXFCEGUI4_LIBS@ \
+	$(top_builddir)/lib/libscreenshooter.la
 	
 xfce4_screenshooter_SOURCES	= \
-	main.c	\
-	screenshooter-utils.c screenshooter-utils.h \
-	screenshooter-dialogs.c screenshooter-dialogs.h				
+	main.c		
 
-# .desktop file
-#
-# Some automake trickery here. Because we cannot use $(libexecdir) in the
-# automake stage, we'll use sed to get the full path into the .desktop file.
-# We also need to let intltool merge the translated fields, so we add an
-# additional level of indirection: a <name>.desktop.in.in file.
-# 
-desktop_plugin_in_in_files = screenshooter.desktop.in.in
-desktop_plugin_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
-	
-desktop_plugindir = $(datadir)/xfce4/panel-plugins
-desktop_plugin_DATA = $(desktop_plugin_in_files:.desktop.in=.desktop)
- at INTLTOOL_DESKTOP_RULE@
-
-# get full path into .desktop file
-screenshooter.desktop.in: screenshooter.desktop.in.in
-	sed -e "s^@PLUGIN_PATH@^$(libexecdir)/xfce4/panel-plugins^" 	\
-		$< > $@
-
+desktopdir = $(datadir)/applications
 desktop_in_in_files = xfce4-screenshooter.desktop.in.in
 desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
-desktopdir = $(datadir)/applications
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
-# Get full path into .desktop file
-xfce4-screenshooter.desktop.in: xfce4-screenshooter.desktop.in.in
-	sed -e "s^@PLUGIN_PATH@^$(libexecdir)/applications^" 		\
+# get full path into .desktop file
+%.desktop.in: %.desktop.in.in
+	sed -e "s^@PLUGIN_PATH@^$(libexecdir)/applications^" 	\
 		$< > $@
 	
 EXTRA_DIST =								\
-	$(desktop_plugin_in_in_files) $(desktop_plugin_in_in_files)
+	$(desktop_in_in_files)
 
 DISTCLEANFILES =							\
-	$(desktop_DATA) $(desktop_plugin_in_files) desktop_plugin_in_files
+	$(desktop_DATA) $(desktop_in_files)
 

Modified: xfce4-screenshooter-plugin/trunk/src/main.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/src/main.c	2008-10-22 13:06:43 UTC (rev 5745)
+++ xfce4-screenshooter-plugin/trunk/src/main.c	2008-10-22 17:22:15 UTC (rev 5746)
@@ -21,7 +21,7 @@
 #include <config.h>
 #endif
 
-#include "screenshooter-dialogs.h"
+#include "libscreenshooter.h"
 
 
 
@@ -81,7 +81,6 @@
   GError *cli_error = NULL;
   GdkPixbuf *screenshot;
   ScreenshotData *sd = g_new0 (ScreenshotData, 1);
-  XfceRc *rc;
   gchar *rc_file;
   
   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
@@ -90,19 +89,7 @@
   rc_file = g_build_filename (xfce_get_homedir(), ".config", "xfce4", 
                               "xfce4-screenshooter", NULL);
   
-  /* If the file exists, we parse it to get the default save folder. Else we use
-  the home dir. */
-  if (g_file_test (rc_file, G_FILE_TEST_EXISTS))
-    {
-      rc = xfce_rc_simple_open (rc_file, TRUE);
-      sd->screenshot_dir = g_strdup (xfce_rc_read_entry (rc, "screenshot_dir", 
-                                     DEFAULT_SAVE_DIRECTORY));
-      xfce_rc_close (rc);
-    }
-  else
-    {
-      sd->screenshot_dir = g_strdup (DEFAULT_SAVE_DIRECTORY);
-    }
+  screenshooter_read_rc_file (rc_file, sd, !(window || fullscreen));
     
   /* Print a message to advise to use help when a non existing cli option is
   passed to the executable. */  
@@ -197,6 +184,8 @@
       GtkWidget *dialog;
       gint response;
       
+      screenshooter_read_rc_file (rc_file, sd, FALSE);
+      
       dialog = screenshooter_dialog_new (sd, FALSE);
             
       response = gtk_dialog_run (GTK_DIALOG (dialog));
@@ -209,6 +198,8 @@
           save_screenshot (screenshot, sd->show_save_dialog, 
                            sd->screenshot_dir);
           g_object_unref (screenshot);
+          
+          screenshooter_write_rc_file (rc_file, sd);
         }
     }
   

Deleted: xfce4-screenshooter-plugin/trunk/src/screenshooter-dialogs.c

Deleted: xfce4-screenshooter-plugin/trunk/src/screenshooter-dialogs.h

Deleted: xfce4-screenshooter-plugin/trunk/src/screenshooter-plugin.c

Deleted: xfce4-screenshooter-plugin/trunk/src/screenshooter-utils.c

Deleted: xfce4-screenshooter-plugin/trunk/src/screenshooter-utils.h

Deleted: xfce4-screenshooter-plugin/trunk/src/screenshooter.desktop.in.in




More information about the Goodies-commits mailing list