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

Jerome Guelfucci jeromeg at xfce.org
Sat Nov 1 11:43:32 CET 2008


Author: jeromeg
Date: 2008-11-01 10:43:32 +0000 (Sat, 01 Nov 2008)
New Revision: 5888

Added:
   xfce4-screenshooter-plugin/trunk/TODO
Modified:
   xfce4-screenshooter-plugin/trunk/ChangeLog
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
Log:
Add icons to the combobox when available.

Modified: xfce4-screenshooter-plugin/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter-plugin/trunk/ChangeLog	2008-11-01 09:50:30 UTC (rev 5887)
+++ xfce4-screenshooter-plugin/trunk/ChangeLog	2008-11-01 10:43:32 UTC (rev 5888)
@@ -1,3 +1,11 @@
+2008-11-01 jeromeg
+
+  * lib/screenshooter-dialogs.c, Implement the Open with stuff:
+    - add (cb_combo_active_item_changed), (add_item) and (populate_liststore)
+      to manage the combobox stuff.
+    - (screenshooter_dialog_new): add the combobox and set signals.
+  * Only build the open with stuff if gio is available.    
+
 2008-10-28 jeromeg
 
   * lib/screenshooter-utils.{c,h}:
@@ -6,9 +14,7 @@
     - start implementing (screenshooter_open_screenshot) to open screenshots
       with a given application.
   * src/main.c:
-  
-  * panel-plugin/screenshooter-plugin.c:   
-  
+    - if an application has been chosen, open the screenshot after taking it.
 
 2008-10-28 jeromeg
 

Added: xfce4-screenshooter-plugin/trunk/TODO
===================================================================
--- xfce4-screenshooter-plugin/trunk/TODO	                        (rev 0)
+++ xfce4-screenshooter-plugin/trunk/TODO	2008-11-01 10:43:32 UTC (rev 5888)
@@ -0,0 +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.
+
+Low priority:
+* Try to get borders captured with compiz.


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

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	2008-11-01 09:50:30 UTC (rev 5887)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	2008-11-01 10:43:32 UTC (rev 5888)
@@ -34,6 +34,10 @@
 #ifdef HAVE_GIO                                                
 static void cb_combo_active_item_changed       (GtkComboBox        *box, 
                                                 ScreenshotData     *sd);
+static void add_item                           (GAppInfo           *app_info, 
+                                                GtkWidget          *liststore);
+static void populate_liststore                 (GtkListStore       *liststore);                                                
+                                                                                               
 #endif                                                                                                                                                                         
                                       
 /* Internals */
@@ -95,6 +99,9 @@
 
 
 #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));
@@ -103,23 +110,66 @@
    
   gtk_combo_box_get_active_iter (GTK_COMBO_BOX (box), &iter);
   
-  gtk_tree_model_get (model, &iter, 0, &active_command, -1);
+  gtk_tree_model_get (model, &iter, 2, &active_command, -1);
   
   sd->app = active_command; 
 }
 
+
+
 static void add_item (GAppInfo *app_info, GtkWidget *liststore)
 {
   GtkTreeIter iter;
   gchar *command = g_strdup (g_app_info_get_executable (app_info));
+  gchar *name = g_strdup (g_app_info_get_name (app_info));
+  GIcon *icon = g_app_info_get_icon (app_info);
+  GdkPixbuf *pixbuf = NULL;
   
+  if (G_IS_LOADABLE_ICON (icon))
+    {
+      GFile *file = g_file_icon_get_file (G_FILE_ICON (icon));
+      gchar *path = g_file_get_path (file);
+      
+      pixbuf = 
+        gdk_pixbuf_new_from_file_at_size (path, 22, 22, NULL);
+    }
+  else
+    {
+      gchar **names = NULL;
+      
+      g_object_get (G_OBJECT (icon), "names", &names, NULL);
+           
+      if (names != NULL)
+        {
+          GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
+          
+          if (names[0] != NULL)
+            {
+              pixbuf = 
+                gtk_icon_theme_load_icon (icon_theme, 
+                                          names[0], 
+                                          22,
+                                          GTK_ICON_LOOKUP_GENERIC_FALLBACK,
+                                          NULL);
+            }                                          
+          
+          g_free (names);                                             
+        }
+    }
+  
   gtk_list_store_append (GTK_LIST_STORE (liststore), &iter);
           
-  gtk_list_store_set (GTK_LIST_STORE (liststore), &iter, 0, command, -1);
+  gtk_list_store_set (GTK_LIST_STORE (liststore), &iter, 0, pixbuf, 1, name,
+                      2, command, -1);
           
   g_free (command);
+  g_free (name);
+  if (pixbuf != NULL)
+    g_object_unref (pixbuf);
 }
 
+
+
 static void populate_liststore (GtkListStore *liststore)
 {
   const gchar *content_type;
@@ -155,9 +205,9 @@
   GtkWidget *delay_label, *delay_box, *delay_spinner, *label2;
 #ifdef HAVE_GIO
   GtkWidget *open_with_label;
-  GtkListStore *liststore = gtk_list_store_new (1, G_TYPE_STRING);
+  GtkListStore *liststore;
   GtkWidget *combobox;
-  GtkCellRenderer *renderer;
+  GtkCellRenderer *renderer, *renderer_pixbuf;
 #endif
   
   /* Create the dialog */
@@ -310,13 +360,21 @@
   gtk_widget_show (open_with_label);
   gtk_container_add (GTK_CONTAINER (options_box), open_with_label);
   
+  liststore = gtk_list_store_new (3, GDK_TYPE_PIXBUF, 
+                                  G_TYPE_STRING, G_TYPE_STRING);
+  
   combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (liststore));
   
   renderer = gtk_cell_renderer_text_new ();
+  renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
   
-  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
-  gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), 
-                                 renderer, "text", 0, NULL);
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), 
+                              renderer_pixbuf, FALSE);
+  gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), 
+                                  renderer, "text", 1, NULL);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer_pixbuf,
+                                  "pixbuf", 0, NULL);                                  
   
   populate_liststore (liststore);
   




More information about the Goodies-commits mailing list