[Xfce4-commits] <xfce4-clipman-plugin:master> history: Add "reorder-items" option

Mike Massonnet noreply at xfce.org
Mon Oct 24 21:42:01 CEST 2011


Updating branch refs/heads/master
         to 22e591e64c145ee775769c9bb048093235b7417f (commit)
       from 21d54aa2ce95c96327e37ae6c7b536f2c504a016 (commit)

commit 22e591e64c145ee775769c9bb048093235b7417f
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Mon Oct 24 21:19:53 2011 +0200

    history: Add "reorder-items" option
    
    This option lets user choose to push or not the last copied text to
    the top of the history, by default it's set to true.
    
    The Xfconf property /tweaks/reorder-items is binded to it.

 panel-plugin/common.h  |    1 +
 panel-plugin/history.c |   31 +++++++++++++++++++++++++++++--
 panel-plugin/plugin.c  |    2 ++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/common.h b/panel-plugin/common.h
index 76fa9c5..9542979 100644
--- a/panel-plugin/common.h
+++ b/panel-plugin/common.h
@@ -27,6 +27,7 @@
 #define DEFAULT_MAX_IMAGES_IN_HISTORY                   1
 #define DEFAULT_SAVE_ON_QUIT                            TRUE
 #define DEFAULT_REVERSE_ORDER                           FALSE
+#define DEFAULT_REORDER_ITEMS                           TRUE
 
 /* Collector */
 #define DEFAULT_ADD_PRIMARY_CLIPBOARD                   FALSE
diff --git a/panel-plugin/history.c b/panel-plugin/history.c
index b6c1e58..d1c3f99 100644
--- a/panel-plugin/history.c
+++ b/panel-plugin/history.c
@@ -46,6 +46,7 @@ struct _ClipmanHistoryPrivate
   guint                 max_texts_in_history;
   guint                 max_images_in_history;
   gboolean              save_on_quit;
+  gboolean              reorder_items;
 };
 
 enum
@@ -53,6 +54,7 @@ enum
   MAX_TEXTS_IN_HISTORY = 1,
   MAX_IMAGES_IN_HISTORY,
   SAVE_ON_QUIT,
+  REORDER_ITEMS,
 };
 
 enum
@@ -216,8 +218,17 @@ clipman_history_add_text (ClipmanHistory *history,
   if (list != NULL)
     {
       DBG ("Found a previous occurence for text `%s'", text);
-      __clipman_history_item_free (list->data);
-      history->priv->texts = g_slist_delete_link (history->priv->texts, list);
+      item = list->data;
+      if (history->priv->reorder_items)
+        {
+          __clipman_history_item_free (item);
+          history->priv->texts = g_slist_delete_link (history->priv->texts, list);
+        }
+      else
+        {
+          history->priv->item_to_restore = item;
+          return;
+        }
     }
 
   /* Store the text */
@@ -433,6 +444,14 @@ clipman_history_class_init (ClipmanHistoryClass *klass)
                                                          "True if the history must be saved on quit",
                                                          DEFAULT_SAVE_ON_QUIT,
                                                          G_PARAM_CONSTRUCT|G_PARAM_READWRITE));
+
+  g_object_class_install_property (object_class,
+                                   REORDER_ITEMS,
+                                   g_param_spec_boolean ("reorder-items",
+                                                         "ReorderItems",
+                                                         "Always push last clipboard content to the top of the history",
+                                                         DEFAULT_REORDER_ITEMS,
+                                                         G_PARAM_CONSTRUCT|G_PARAM_READWRITE));
 }
 
 static void
@@ -470,6 +489,10 @@ clipman_history_set_property (GObject *object,
       priv->save_on_quit = g_value_get_boolean (value);
       break;
 
+    case REORDER_ITEMS:
+      priv->reorder_items = g_value_get_boolean (value);
+      break;
+
     default:
       break;
     }
@@ -497,6 +520,10 @@ clipman_history_get_property (GObject *object,
       g_value_set_boolean (value, priv->save_on_quit);
       break;
 
+    case REORDER_ITEMS:
+      g_value_set_boolean (value, priv->reorder_items);
+      break;
+
     default:
       break;
     }
diff --git a/panel-plugin/plugin.c b/panel-plugin/plugin.c
index 12c9d4d..3582035 100644
--- a/panel-plugin/plugin.c
+++ b/panel-plugin/plugin.c
@@ -95,6 +95,8 @@ plugin_register (void)
                           G_TYPE_UINT, plugin->history, "max-images-in-history");
   xfconf_g_property_bind (plugin->channel, "/settings/save-on-quit",
                           G_TYPE_BOOLEAN, plugin->history, "save-on-quit");
+  xfconf_g_property_bind (plugin->channel, "/tweaks/reorder-items",
+                          G_TYPE_BOOLEAN, plugin->history, "reorder-items");
 
   /* ClipmanCollector */
   plugin->collector = clipman_collector_get ();


More information about the Xfce4-commits mailing list