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

Jerome Guelfucci jeromeg at xfce.org
Thu Oct 30 11:16:24 CET 2008


Author: jeromeg
Date: 2008-10-30 10:16:24 +0000 (Thu, 30 Oct 2008)
New Revision: 5871

Modified:
   xfce4-screenshooter-plugin/trunk/ChangeLog
   xfce4-screenshooter-plugin/trunk/configure.ac.in
   xfce4-screenshooter-plugin/trunk/lib/Makefile.am
   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/src/main.c
Log:
Partial broken commit for open-with functionnality.

Modified: xfce4-screenshooter-plugin/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter-plugin/trunk/ChangeLog	2008-10-29 22:39:39 UTC (rev 5870)
+++ xfce4-screenshooter-plugin/trunk/ChangeLog	2008-10-30 10:16:24 UTC (rev 5871)
@@ -1,5 +1,17 @@
 2008-10-28 jeromeg
 
+  * lib/screenshooter-utils.{c,h}:
+    - modify (screenshooter_save_screenshot) so that it returns the save 
+      location.
+    - start implementing (screenshooter_open_screenshot) to open screenshots
+      with a given application.
+  * src/main.c:
+  
+  * panel-plugin/screenshooter-plugin.c:   
+  
+
+2008-10-28 jeromeg
+
   * lib/screenshooter-utils.{c,h}: add the "screenshooter_" prefix before
     (take_screenshot) and (save_screenshot).
   * src/main.c: use the new function names in (main).

Modified: xfce4-screenshooter-plugin/trunk/configure.ac.in
===================================================================
--- xfce4-screenshooter-plugin/trunk/configure.ac.in	2008-10-29 22:39:39 UTC (rev 5870)
+++ xfce4-screenshooter-plugin/trunk/configure.ac.in	2008-10-30 10:16:24 UTC (rev 5871)
@@ -50,6 +50,9 @@
 dnl Check for glib
 XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.12.0])
 
+dnl Optionnal check for gio
+XDT_CHECK_OPTIONAL_PACKAGE([GIO], [gio-2.0], [2.16])
+
 dnl Translations
 XDT_I18N([ar ca cs da de el en_GB es eu fr gl hr hu id ja lv nb_NO nl pl pt_BR pt_PT sq uk ur zh_TW])
 

Modified: xfce4-screenshooter-plugin/trunk/lib/Makefile.am
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/Makefile.am	2008-10-29 22:39:39 UTC (rev 5870)
+++ xfce4-screenshooter-plugin/trunk/lib/Makefile.am	2008-10-30 10:16:24 UTC (rev 5871)
@@ -19,3 +19,16 @@
   @GTK_LIBS@ \
 	@LIBXFCE4UTIL_LIBS@ \
 	@LIBXFCEGUI4_LIBS@
+	
+if HAVE_GIO
+
+libscreenshooter_la_SOURCES += \
+  screenshooter-open-with.c screenshooter-open-with.h
+  
+libscreenshooter_la_CFLAGS += \
+  @GIO_CFLAGS@
+  
+libscreenshooter_la_LIBADD += \
+  @GIO_LIBS@
+  
+endif

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	2008-10-29 22:39:39 UTC (rev 5870)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	2008-10-30 10:16:24 UTC (rev 5871)
@@ -30,7 +30,11 @@
 static void cb_default_folder                  (GtkWidget          *chooser, 
                                                 ScreenshotData     *sd);                                        
 static void cb_delay_spinner_changed           (GtkWidget          *spinner, 
-                                                ScreenshotData     *sd);                                                                              
+                                                ScreenshotData     *sd);
+#ifdef HAVE_GIO                                                
+static void cb_combo_active_item_changed       (GtkComboBox        *box, 
+                                                ScreenshotData     *sd);
+#endif                                                                                                                                                                         
                                       
 /* Internals */
 
@@ -86,9 +90,25 @@
 {
   sd->delay = 
     gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spinner));
-} 
+}
 
 
+
+#ifdef HAVE_GIO
+static void cb_combo_active_item_changed (GtkComboBox *box, ScreenshotData *sd)
+{
+  GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (box));
+  GtkTreeIter iter;
+  gchar *active_command = NULL;
+   
+  gtk_combo_box_get_active_iter (GTK_COMBO_BOX (box), &iter);
+  
+  gtk_tree_model_get (model, &iter, 0, &active_command, -1);
+  
+  sd->app = active_command; 
+}
+#endif
+
                       
 /* Public */
 
@@ -104,6 +124,9 @@
   GtkWidget *save_button;
   GtkWidget *default_save_label, *dir_chooser;
   GtkWidget *delay_label, *delay_box, *delay_spinner, *label2;
+#ifdef HAVE_GIO
+  GtkWidget *combo_box, *open_with_label;
+#endif
   
   /* Create the dialog */
   if (!plugin)
@@ -198,7 +221,7 @@
   if (plugin)
     {
 		  /* Default save location */          
-		  default_save_label = gtk_label_new ( "" );
+		  default_save_label = gtk_label_new ("");
 		  gtk_label_set_markup (GTK_LABEL (default_save_label),
 			_("<span weight=\"bold\" stretch=\"semiexpanded\">Default save location</span>"));
 			
@@ -218,7 +241,7 @@
     }
                     
   /* Screenshot delay */
-  delay_label = gtk_label_new ( "" );
+  delay_label = gtk_label_new ("");
   
   gtk_label_set_markup (GTK_LABEL(delay_label),
   _("<span weight=\"bold\" stretch=\"semiexpanded\">Delay before taking the screenshot</span>"));
@@ -244,7 +267,26 @@
 
   g_signal_connect (delay_spinner, "value-changed",
                     G_CALLBACK (cb_delay_spinner_changed), sd);
+                    
+  /* Open with */
+#ifdef HAVE_GIO 
+  open_with_label = gtk_label_new ("");
+  gtk_label_set_markup (GTK_LABEL(open_with_label),
+  _("<span weight=\"bold\" stretch=\"semiexpanded\">Open the screenshot with</span>"));
   
+  gtk_misc_set_alignment(GTK_MISC (open_with_label), 0, 0); 
+  gtk_widget_show (open_with_label);
+  gtk_container_add (GTK_CONTAINER (options_box), open_with_label);
+  
+  combo_box = screenshooter_open_with_combo_box ();
+  gtk_container_add (GTK_CONTAINER (options_box), combo_box);
+  
+  g_signal_connect (G_OBJECT (combo_box), "changed", 
+                    G_CALLBACK (cb_combo_active_item_changed), sd);
+  
+  gtk_widget_show (combo_box);                    
+#endif
+
   return dlg;                
 }
 

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h	2008-10-29 22:39:39 UTC (rev 5870)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h	2008-10-30 10:16:24 UTC (rev 5871)
@@ -22,6 +22,9 @@
 #endif
 
 #include "screenshooter-utils.h"
+#ifdef HAVE_GIO
+#include "screenshooter-open-with.h"
+#endif
 
 #include <gtk/gtk.h>
 #include <libxfce4util/libxfce4util.h>

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c	2008-10-29 22:39:39 UTC (rev 5870)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c	2008-10-30 10:16:24 UTC (rev 5871)
@@ -202,12 +202,13 @@
 /* Saves the screenshot according to the options in sd. 
 *screenshot: a GdkPixbuf containing our screenshot
 *sd: a ScreenshotData struct containing the save options.*/
-void screenshooter_save_screenshot (GdkPixbuf      *screenshot, 
+gchar 
+*screenshooter_save_screenshot     (GdkPixbuf      *screenshot, 
                                     gboolean        show_save_dialog,
                                     gchar          *default_dir)
 {
   GdkPixbuf *thumbnail;
-  gchar *filename = NULL;
+  gchar *filename = NULL, *savename = NULL;;
   GtkWidget *preview;
   GtkWidget *chooser;
   gint dialog_response;
@@ -255,26 +256,26 @@
 	  
 	    if (dialog_response == GTK_RESPONSE_ACCEPT)
 	      {
-	        g_free (filename);
-	        filename = 
+	        savename = 
 	          gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser) );
-          gdk_pixbuf_save (screenshot, filename, "png", NULL, NULL);
+          gdk_pixbuf_save (screenshot, savename, "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);
+  
+  return savename;
 }
 
 
@@ -340,3 +341,17 @@
   
   xfce_rc_close (rc);
 }
+
+
+
+void
+screenshooter_open_screenshot (gchar *screenshot_path,
+                               gchar *application)
+{
+  if (screenshot_path != NULL)
+    {
+      gchar *command = g_strconcat (application, " ", screenshot_path, NULL);
+    
+      xfce_exec (command, FALSE, TRUE, NULL);
+    }
+}                                    

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h	2008-10-29 22:39:39 UTC (rev 5870)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h	2008-10-30 10:16:24 UTC (rev 5871)
@@ -29,6 +29,7 @@
 #include <glib/gstdio.h>
 
 #include <libxfce4util/libxfce4util.h>
+#include <libxfcegui4/libxfcegui4.h>
 
 #include <unistd.h>
 
@@ -48,19 +49,30 @@
 
   gint delay;
   gchar *screenshot_dir;
+  
+  gchar *app;
 }
 ScreenshotData;
 
 GdkPixbuf 
 *screenshooter_take_screenshot   (gint                  mode, 
                                   gint                  delay);
-void 
-screenshooter_save_screenshot    (GdkPixbuf            *screenshot, 
+                                  
+gchar 
+*screenshooter_save_screenshot   (GdkPixbuf            *screenshot, 
                                   gboolean              show_save_dialog,
                                   gchar                *default_dir);
-void screenshooter_read_rc_file  (gchar                *file, 
+                                  
+void 
+screenshooter_read_rc_file       (gchar                *file, 
                                   ScreenshotData       *sd, 
                                   gboolean              dir_only);
-void screenshooter_write_rc_file (gchar                *file, 
+                                  
+void 
+screenshooter_write_rc_file      (gchar                *file, 
                                   ScreenshotData       *sd);
+                                  
+void
+screenshooter_open_screenshot    (gchar *screenshot_path,
+                                  gchar *application);                                  
 #endif                               

Modified: xfce4-screenshooter-plugin/trunk/src/main.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/src/main.c	2008-10-29 22:39:39 UTC (rev 5870)
+++ xfce4-screenshooter-plugin/trunk/src/main.c	2008-10-30 10:16:24 UTC (rev 5871)
@@ -195,11 +195,20 @@
       
       if (response == GTK_RESPONSE_OK)
         {
+          gchar *screenshot_path = NULL;
+          
           screenshot = screenshooter_take_screenshot (sd->mode, sd->delay);
-          screenshooter_save_screenshot (screenshot, sd->show_save_dialog, 
-                                         sd->screenshot_dir);
+          screenshot_path =
+            screenshooter_save_screenshot (screenshot, sd->show_save_dialog, 
+                                           sd->screenshot_dir);
           g_object_unref (screenshot);
           
+          if (screenshot_path != NULL)
+            {
+              screenshooter_open_screenshot (screenshot_path, sd->app);
+              g_free (screenshot_path);
+            }
+                   
           screenshooter_write_rc_file (rc_file, sd);
         }
     }




More information about the Goodies-commits mailing list