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

Jerome Guelfucci jeromeg at xfce.org
Mon Nov 3 16:09:56 CET 2008


Author: jeromeg
Date: 2008-11-03 15:09:55 +0000 (Mon, 03 Nov 2008)
New Revision: 5937

Modified:
   xfce4-screenshooter-plugin/trunk/ChangeLog
   xfce4-screenshooter-plugin/trunk/TODO
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h
Log:
  * TODO: updated.
  * lib/screenshooter-utils.h: add define for default application.
  * lib/screenshooter-utils.c:
    - (screenshooter_read_rc_file) read the default application.
    - (screenshooter_write_rc_file) write the default application.
    - (screenshooter_open_screenshot) only open if app != "none".
  * lib/screenshooter-dialogs.c:
    - add a define for icon size.
    - (set_default_item) added to select the correct item of the combobox when
      displaying the interface.
    - (add_item) use the icon size define.
    - (populate_liststore) add the "none" item on the top of the liststore.
    - (screenshooter_dialog_new) add a call to set_default_item.


Modified: xfce4-screenshooter-plugin/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter-plugin/trunk/ChangeLog	2008-11-03 08:43:05 UTC (rev 5936)
+++ xfce4-screenshooter-plugin/trunk/ChangeLog	2008-11-03 15:09:55 UTC (rev 5937)
@@ -1,3 +1,19 @@
+2008-11-03 jeromeg
+
+  * TODO: updated.
+  * lib/screenshooter-utils.h: add define for default application.
+  * lib/screenshooter-utils.c:
+    - (screenshooter_read_rc_file) read the default application.
+    - (screenshooter_write_rc_file) write the default application.
+    - (screenshooter_open_screenshot) only open if app != "none".
+  * lib/screenshooter-dialogs.c:
+    - add a define for icon size.
+    - (set_default_item) added to select the correct item of the combobox when
+      displaying the interface.
+    - (add_item) use the icon size define.
+    - (populate_liststore) add the "none" item on the top of the liststore.
+    - (screenshooter_dialog_new) add a call to set_default_item.
+
 2008-11-02 jeromeg
 
   * lib/screenshooter-dialogs.c:

Modified: xfce4-screenshooter-plugin/trunk/TODO
===================================================================
--- xfce4-screenshooter-plugin/trunk/TODO	2008-11-03 08:43:05 UTC (rev 5936)
+++ xfce4-screenshooter-plugin/trunk/TODO	2008-11-03 15:09:55 UTC (rev 5937)
@@ -1,9 +1,8 @@
-* Save the chosen application to open screenshots with, and set it as active when creating the combobox.
 * Add open with support to the plugin.
 * Write some documentation.
 * Update the code comments.
 * Update the website.
-* Correctly free the stuff in the GLists and liststore in screenshooter-dialogs.c
+* Correctly free the stuff in the GLists in screenshooter-dialogs.c
 
 Low priority:
 * Try to get borders captured with compiz.

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	2008-11-03 08:43:05 UTC (rev 5936)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	2008-11-03 15:09:55 UTC (rev 5937)
@@ -19,6 +19,8 @@
 
 #include "screenshooter-dialogs.h"
 
+#define ICON_SIZE 22
+
 /* Prototypes */ 
 
 static void cb_fullscreen_screen_toggled       (GtkToggleButton    *tb,
@@ -36,7 +38,9 @@
                                                 ScreenshotData     *sd);
 static void add_item                           (GAppInfo           *app_info, 
                                                 GtkWidget          *liststore);
-static void populate_liststore                 (GtkListStore       *liststore);                                                
+static void populate_liststore                 (GtkListStore       *liststore);
+static void set_default_item                   (GtkWidget          *combobox, 
+                                                gchar              *default_app);                                               
                                                                                                
 #endif                                                                                                                                                                         
                                       
@@ -134,7 +138,7 @@
       gchar *path = g_file_get_path (file);
       
       pixbuf = 
-        gdk_pixbuf_new_from_file_at_size (path, 22, 22, NULL);
+        gdk_pixbuf_new_from_file_at_size (path, ICON_SIZE, ICON_SIZE, NULL);
       
       g_free (path);
       g_object_unref (file);
@@ -154,7 +158,7 @@
               pixbuf = 
                 gtk_icon_theme_load_icon (icon_theme, 
                                           names[0], 
-                                          22,
+                                          ICON_SIZE,
                                           GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                                           NULL);
             }                                          
@@ -181,6 +185,16 @@
 {
   const gchar *content_type;
   GList	*list_app;
+  GtkTreeIter iter;
+  
+  gtk_list_store_append (GTK_LIST_STORE (liststore), &iter);
+  
+  gtk_list_store_set (GTK_LIST_STORE (liststore), 
+                      &iter, 
+                      0, NULL, 
+                      1, _("Do not open screenshots"),
+                      2, "none", 
+                      -1);
      
   content_type = "image/png";
     
@@ -193,6 +207,30 @@
       g_list_free (list_app);
     }
 }
+
+static void set_default_item (GtkWidget     *combobox, 
+                              gchar         *default_app)
+{
+  GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
+  GtkTreeIter iter; 
+  gchar *command = NULL;
+  
+  gtk_tree_model_get_iter_first (model , &iter);    
+
+  do
+    {
+      gtk_tree_model_get (model, &iter, 2, &command, -1);
+      
+      if (g_str_equal (command, default_app))
+        {
+          gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
+          break;
+        }
+      
+      g_free (command);      
+    }
+  while (gtk_tree_model_iter_next (model, &iter)); 
+}                              
 #endif
 
                       
@@ -385,6 +423,8 @@
   
   populate_liststore (liststore);
   
+  set_default_item (combobox, sd->app);
+  
   gtk_container_add (GTK_CONTAINER (options_box), combobox);
   
   g_signal_connect (G_OBJECT (combobox), "changed", 

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c	2008-11-03 08:43:05 UTC (rev 5936)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c	2008-11-03 15:09:55 UTC (rev 5937)
@@ -290,6 +290,7 @@
   gint mode = FULLSCREEN;
   gint show_save_dialog = 1;
   gchar *screenshot_dir = g_strdup (DEFAULT_SAVE_DIRECTORY);
+  gchar *app = DEFAULT_APPLICATION;
 
   if (g_file_test (file, G_FILE_TEST_EXISTS))
     {
@@ -303,6 +304,8 @@
               mode = xfce_rc_read_int_entry (rc, "mode", FULLSCREEN);
               show_save_dialog = 
                 xfce_rc_read_int_entry (rc, "show_save_dialog", 1);
+              app = 
+                g_strdup (xfce_rc_read_entry (rc, "app", DEFAULT_APPLICATION));
             }
   
           g_free (screenshot_dir);
@@ -320,6 +323,7 @@
   sd->mode = mode;
   sd->show_save_dialog = show_save_dialog;
   sd->screenshot_dir = screenshot_dir;
+  sd->app = app;
 }
 
 
@@ -338,6 +342,7 @@
   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_write_entry (rc, "app", sd->app);
   
   xfce_rc_close (rc);
 }
@@ -350,8 +355,12 @@
 {
   if (screenshot_path != NULL)
     {
-      gchar *command = g_strconcat (application, " ", screenshot_path, NULL);
+      if (!g_str_equal (application, "none"))
+        {
+          gchar *command = 
+            g_strconcat (application, " ", screenshot_path, NULL);
     
-      xfce_exec (command, FALSE, TRUE, 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-11-03 08:43:05 UTC (rev 5936)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h	2008-11-03 15:09:55 UTC (rev 5937)
@@ -34,6 +34,7 @@
 #include <unistd.h>
 
 #define DEFAULT_SAVE_DIRECTORY xfce_get_homedir ()
+#define DEFAULT_APPLICATION "none"
 
 enum {
   MODE_0,




More information about the Goodies-commits mailing list