[Goodies-commits] r6420 - in xfce4-clipman-plugin/trunk: . panel-plugin

Mike Massonnet mmassonnet at xfce.org
Fri Jan 9 14:10:06 CET 2009


Author: mmassonnet
Date: 2009-01-09 13:10:06 +0000 (Fri, 09 Jan 2009)
New Revision: 6420

Modified:
   xfce4-clipman-plugin/trunk/ChangeLog
   xfce4-clipman-plugin/trunk/THANKS
   xfce4-clipman-plugin/trunk/configure.in.in
   xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am
   xfce4-clipman-plugin/trunk/panel-plugin/clipman.c
   xfce4-clipman-plugin/trunk/panel-plugin/clipman.h
Log:
	- Fix g_free(clip) against panel_slice_free(clip)
	- Add dependency on exo and use exo_gdk_pixbuf_scale_ratio to create a
	preview of the image inside the menu
	- Don't save image data inside the rc file
	- Left two topics as TODO inside the code
	- At last but not least, bump release to 0.9.0 
 

Modified: xfce4-clipman-plugin/trunk/ChangeLog
===================================================================
--- xfce4-clipman-plugin/trunk/ChangeLog	2009-01-09 11:39:16 UTC (rev 6419)
+++ xfce4-clipman-plugin/trunk/ChangeLog	2009-01-09 13:10:06 UTC (rev 6420)
@@ -1,3 +1,14 @@
+2008-01-09	Mike Massonnet <mmassonnet at xfce.org>
+
+A quick review over the changes.
+
+	- Fix g_free(clip) against panel_slice_free(clip)
+	- Add dependency on exo and use exo_gdk_pixbuf_scale_ratio to create a
+	preview of the image inside the menu
+	- Don't save image data inside the rc file
+	- Left two topics as TODO inside the code
+	- At last but not least, bump release to 0.9.0
+
 2008-01-02	Mike Massonnet <mmassonnet at xfce.org>
 
 This is the second part of the rewrite that introduces the storage of an image

Modified: xfce4-clipman-plugin/trunk/THANKS
===================================================================
--- xfce4-clipman-plugin/trunk/THANKS	2009-01-09 11:39:16 UTC (rev 6419)
+++ xfce4-clipman-plugin/trunk/THANKS	2009-01-09 13:10:06 UTC (rev 6420)
@@ -4,3 +4,8 @@
 
  Darren Salt <linux at youmustbejoking.demon.co.uk>
   * Patches
+
+ David Collins <david.8.collins at gmail.com>
+  * Rewrite with the motivation to make the plugin more user-friendly and
+    introduce the storage of an image
+

Modified: xfce4-clipman-plugin/trunk/configure.in.in
===================================================================
--- xfce4-clipman-plugin/trunk/configure.in.in	2009-01-09 11:39:16 UTC (rev 6419)
+++ xfce4-clipman-plugin/trunk/configure.in.in	2009-01-09 13:10:06 UTC (rev 6420)
@@ -10,8 +10,8 @@
 dnl *** Version information ***
 dnl ***************************
 m4_define([clipman_version_major], [0])
-m4_define([clipman_version_minor], [8])
-m4_define([clipman_version_micro], [1])
+m4_define([clipman_version_minor], [9])
+m4_define([clipman_version_micro], [0])
 m4_define([clipman_version_build], [r at REVISION@])
 m4_define([clipman_version_tag], [svn])
 m4_define([clipman_version], [clipman_version_major().clipman_version_minor().clipman_version_micro()ifelse(clipman_version_tag(), [svn], [clipman_version_tag()-clipman_version_build()], [clipman_version_tag()])])
@@ -61,8 +61,8 @@
 dnl ***********************************
 dnl *** Check for required packages ***
 dnl ***********************************
-XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.0])
 XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
+XDT_CHECK_PACKAGE([EXO], [exo-0.3], [0.3.0])
 XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0])
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.4.0])

Modified: xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am	2009-01-09 11:39:16 UTC (rev 6419)
+++ xfce4-clipman-plugin/trunk/panel-plugin/Makefile.am	2009-01-09 13:10:06 UTC (rev 6420)
@@ -21,10 +21,12 @@
 	clipman-dialogs.c
 
 xfce4_clipman_plugin_CFLAGS =						\
+	$(EXO_CFLAGS)							\
 	$(LIBXFCEGUI4_CFLAGS)						\
 	$(LIBXFCE4PANEL_CFLAGS)
 
 xfce4_clipman_plugin_LDADD =						\
+	$(EXO_LIBS)							\
 	$(LIBXFCE4PANEL_LIBS)						\
 	$(LIBXFCEGUI4_LIBS)
 

Modified: xfce4-clipman-plugin/trunk/panel-plugin/clipman.c
===================================================================
--- xfce4-clipman-plugin/trunk/panel-plugin/clipman.c	2009-01-09 11:39:16 UTC (rev 6419)
+++ xfce4-clipman-plugin/trunk/panel-plugin/clipman.c	2009-01-09 13:10:06 UTC (rev 6420)
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <gtk/gtk.h>
 
+#include <exo/exo.h>
 #include <libxfcegui4/libxfcegui4.h>
 #include <libxfce4util/libxfce4util.h>
 #include <libxfce4panel/xfce-panel-plugin.h>
@@ -164,8 +165,10 @@
   const gchar          *offset;
 
   g_return_val_if_fail (G_LIKELY (NULL != text), NULL);
-  g_return_val_if_fail (G_LIKELY (g_utf8_validate (text, -1, NULL)), NULL);
 
+  if (G_UNLIKELY (!g_utf8_validate (text, -1, NULL)))
+    return NULL;
+
   short_text = g_strstrip (g_strdup (text));
 
   /* Shorten */
@@ -201,13 +204,15 @@
     if (datatype == RAWTEXT) {
       clip->title = clipman_create_title (data, clipman->MenuCharacters);
     } else {
+      /* Change this to store a pixbuf preview */
       clip->title = clipman_create_title (CLIPIMAGETITLE, clipman->MenuCharacters);
+      clip->preview = exo_gdk_pixbuf_scale_ratio (GDK_PIXBUF (data), 128);
     }
 
   	/* No valid title could be created, drop it */
 	  if (clip->title == NULL) {
 	    DBG("A title couldn't be created");
-	    g_free (clip);
+        panel_slice_free (ClipmanClip, clip);
 	    return;
 	  }
 
@@ -272,12 +277,12 @@
 {
     gboolean defaultcleared, primarycleared; 
 
-    // This will fucntion will send a clipboard 'owner-change' signal
-    // which we will ignore.
-    IgnoreSignal=TRUE;
-    
+    /* This function will send a clipboard 'owner-change' signal which we will
+     * ignore by setting IgnoreSignal to TRUE. */
+
     /* Left mouse button - put item in BOTH clipboards */
     if (ev->button == 1) {
+      IgnoreSignal=TRUE;
       gtk_clipboard_clear (defaultClip);
       clipman_set_data (action->clip, defaultClip);      
       //gtk_clipboard_set_text (defaultClip, action->clip->data, -1);
@@ -285,6 +290,7 @@
 	    DBG ("Clip copied to default clipboard");
 
 	    if (action->clipman->AddSelect)	{
+          IgnoreSignal=TRUE;
 	      gtk_clipboard_clear (primaryClip);
         clipman_set_data (action->clip, primaryClip);      
         action->clipman->PrimaryIndex = action->index;
@@ -390,6 +396,18 @@
     return mi;
 }
 
+static GtkWidget *
+clipman_create_imagemenuitem (ClipmanAction *action) {
+
+    GtkWidget *mi, *image;
+
+    mi = gtk_menu_item_new ();
+    image = gtk_image_new_from_pixbuf (action->clip->preview);
+    gtk_container_add (GTK_CONTAINER (mi), image);
+
+    return mi;
+}
+
 static void
 clipman_build_menu_body (GtkWidget *menu, ClipmanPlugin *clipman) {
                                
@@ -406,18 +424,24 @@
         action->clip = clip;
         action->index = i;
 
-        if (clipman->DefaultIndex == i) {
+        if (clip->datatype == RAWTEXT) {
+          if (clipman->DefaultIndex == i) {
             mi = clipman_create_menuitem (action, clipman->MenuCharacters,
                                           clipman->clips->len-i, BOLD);
-        }
-        else if (clipman->PrimaryIndex == i) {
+          }
+          else if (clipman->PrimaryIndex == i) {
             mi = clipman_create_menuitem (action, clipman->MenuCharacters,
                                           clipman->clips->len-i, ITALICS);
-        } else {
+          } else {
             mi = clipman_create_menuitem (action, clipman->MenuCharacters,
                                           clipman->clips->len-i, PLAIN);
+          }
+        } else if (clip->datatype == IMAGE) {
+          mi = clipman_create_imagemenuitem (action);
         }
 
+        /* TODO action ends in a leak as it gets never freed in the items that
+         * are not clicked */
         g_signal_connect (G_OBJECT(mi), "button_release_event",
                 G_CALLBACK(clipman_item_clicked), action);
         gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
@@ -771,6 +795,10 @@
         {
             clip = g_ptr_array_index (clipman->clips, i);
 
+            /* Don't save the image */
+            if (clip->datatype == IMAGE)
+              continue;
+
             g_snprintf (name, 13, "clip_%d_text", i);
             xfce_rc_write_entry (rc, name, clip->data);
 
@@ -889,6 +917,7 @@
             G_CALLBACK(clipman_icon_clicked), clipman);
 
     /* Start the clipman_timed_poll function */
+    /* TODO Run the timeout only if the plugin takes care of the selections */
     clipman->TimeoutId = g_timeout_add_full(G_PRIORITY_LOW,
                                             TIMER_INTERVAL,
                                             (GSourceFunc) clipman_timed_poll,

Modified: xfce4-clipman-plugin/trunk/panel-plugin/clipman.h
===================================================================
--- xfce4-clipman-plugin/trunk/panel-plugin/clipman.h	2009-01-09 11:39:16 UTC (rev 6419)
+++ xfce4-clipman-plugin/trunk/panel-plugin/clipman.h	2009-01-09 13:10:06 UTC (rev 6420)
@@ -96,6 +96,7 @@
 {
     void         *data;
     gchar        *title;
+    GdkPixbuf    *preview;
     ClipDataType  datatype;
 }
 ClipmanClip;




More information about the Goodies-commits mailing list