Index: src/preferences.c
===================================================================
--- src/preferences.c	(revision 211)
+++ src/preferences.c	(working copy)
@@ -29,6 +29,7 @@
 GtkWidget *copy_check,
           *primary_check,
           *synchronize_check,
+          *trim_check,
           *history_spin,
           *charlength_spin,
           *ellipsize_combo,
@@ -69,6 +70,7 @@
   prefs.use_copy = gtk_toggle_button_get_active((GtkToggleButton*)copy_check);
   prefs.use_primary = gtk_toggle_button_get_active((GtkToggleButton*)primary_check);
   prefs.synchronize = gtk_toggle_button_get_active((GtkToggleButton*)synchronize_check);
+  prefs.trim = gtk_toggle_button_get_active((GtkToggleButton*)trim_check);
   prefs.save_history = gtk_toggle_button_get_active((GtkToggleButton*)save_check);
   prefs.history_limit = gtk_spin_button_get_value_as_int((GtkSpinButton*)history_spin);
   prefs.history_pos = gtk_toggle_button_get_active((GtkToggleButton*)history_pos);
@@ -105,6 +107,7 @@
   g_key_file_set_boolean(rc_key, "rc", "use_copy", prefs.use_copy);
   g_key_file_set_boolean(rc_key, "rc", "use_primary", prefs.use_primary);
   g_key_file_set_boolean(rc_key, "rc", "synchronize", prefs.synchronize);
+  g_key_file_set_boolean(rc_key, "rc", "trim", prefs.trim);
   g_key_file_set_boolean(rc_key, "rc", "save_history", prefs.save_history);
   g_key_file_set_integer(rc_key, "rc", "history_limit", prefs.history_limit);
   g_key_file_set_boolean(rc_key, "rc", "hyperlinks_only", prefs.hyperlinks_only);
@@ -144,6 +147,7 @@
     prefs.use_copy = g_key_file_get_boolean(rc_key, "rc", "use_copy", NULL);
     prefs.use_primary = g_key_file_get_boolean(rc_key, "rc", "use_primary", NULL);
     prefs.synchronize = g_key_file_get_boolean(rc_key, "rc", "synchronize", NULL);
+    prefs.trim = g_key_file_get_boolean(rc_key, "rc", "trim", NULL);
     prefs.save_history = g_key_file_get_boolean(rc_key, "rc", "save_history", NULL);
     prefs.history_limit = g_key_file_get_integer(rc_key, "rc", "history_limit", NULL);
     prefs.hyperlinks_only = g_key_file_get_boolean(rc_key, "rc", "hyperlinks_only", NULL);
@@ -298,7 +302,6 @@
     /* Disable synchronize option */
     gtk_toggle_button_set_active((GtkToggleButton*)synchronize_check, FALSE);
     gtk_widget_set_sensitive((GtkWidget*)synchronize_check, FALSE);
-
   }
 }
 
@@ -467,6 +470,8 @@
   gtk_box_pack_start((GtkBox*)vbox, primary_check, FALSE, FALSE, 0);
   synchronize_check = gtk_check_button_new_with_mnemonic(_("S_ynchronize clipboards"));
   gtk_box_pack_start((GtkBox*)vbox, synchronize_check, FALSE, FALSE, 0);
+  trim_check = gtk_check_button_new_with_mnemonic(_("_Trim whitespace content"));
+  gtk_box_pack_start((GtkBox*)vbox, trim_check, FALSE, FALSE, 0);
   gtk_box_pack_start((GtkBox*)vbox_behavior, frame, FALSE, FALSE, 0);
   
   /* Build the history frame */
@@ -722,6 +727,7 @@
   gtk_toggle_button_set_active((GtkToggleButton*)copy_check, prefs.use_copy);
   gtk_toggle_button_set_active((GtkToggleButton*)primary_check, prefs.use_primary);
   gtk_toggle_button_set_active((GtkToggleButton*)synchronize_check, prefs.synchronize);
+  gtk_toggle_button_set_active((GtkToggleButton*)trim_check, prefs.trim);
   gtk_toggle_button_set_active((GtkToggleButton*)save_check, prefs.save_history);
   gtk_spin_button_set_value((GtkSpinButton*)history_spin, (gdouble)prefs.history_limit);
   gtk_toggle_button_set_active((GtkToggleButton*)hyperlinks_check, prefs.hyperlinks_only);
Index: src/preferences.h
===================================================================
--- src/preferences.h	(revision 211)
+++ src/preferences.h	(working copy)
@@ -28,6 +28,7 @@
 #define DEF_USE_COPY          TRUE
 #define DEF_USE_PRIMARY       FALSE
 #define DEF_SYNCHRONIZE       FALSE
+#define DEF_TRIM              FALSE
 #define DEF_SAVE_HISTORY      TRUE
 #define DEF_HISTORY_LIMIT     25
 #define DEF_HYPERLINKS_ONLY   FALSE
Index: src/main.c
===================================================================
--- src/main.c	(revision 211)
+++ src/main.c	(working copy)
@@ -68,6 +68,7 @@
 
 /* Init preferences structure */
 prefs_t prefs = {DEF_USE_COPY,        DEF_USE_PRIMARY,      DEF_SYNCHRONIZE,
+                 DEF_TRIM,
                  DEF_SAVE_HISTORY,    DEF_HISTORY_LIMIT,
                  DEF_HYPERLINKS_ONLY, DEF_CONFIRM_CLEAR,
                  DEF_SINGLE_LINE,     DEF_REVERSE_HISTORY,  DEF_ITEM_LENGTH,
@@ -130,16 +131,23 @@
         /* Check if primary option is enabled and if there's text to add */
         if (prefs.use_primary && primary_text)
         {
+          /* Trim if enabled */
+          if (prefs.trim && strlen(primary_text) > 0)
+          {
+            primary_text = g_strstrip(primary_text);
+          }
           /* Check contents before adding */
           if (prefs.hyperlinks_only && is_hyperlink(primary_text))
           {
             delete_duplicate(primary_text);
-            append_item(primary_text);
+            if (strlen(primary_text) > 0)
+              append_item(primary_text);
           }
           else
           {
             delete_duplicate(primary_text);
-            append_item(primary_text);
+            if (strlen(primary_text) > 0)
+              append_item(primary_text);
           }
         }
       }
@@ -172,16 +180,23 @@
       /* Check if clipboard option is enabled and if there's text to add */
       if (prefs.use_copy && clipboard_text)
       {
+        /* Trim if enabled */
+        if (prefs.trim && strlen(clipboard_text) > 0)
+        {
+          clipboard_text = g_strstrip(clipboard_text);
+        }
         /* Check contents before adding */
         if (prefs.hyperlinks_only && is_hyperlink(clipboard_text))
         {
           delete_duplicate(clipboard_text);
-          append_item(clipboard_text);
+          if (strlen(clipboard_text) > 0)
+            append_item(clipboard_text);
         }
         else
         {
           delete_duplicate(clipboard_text);
-          append_item(clipboard_text);
+          if (strlen(clipboard_text) > 0)
+            append_item(clipboard_text);
         }
       }
     }
Index: src/main.h
===================================================================
--- src/main.h	(revision 211)
+++ src/main.h	(working copy)
@@ -32,6 +32,7 @@
   gboolean  use_copy;         /* Use copy */
   gboolean  use_primary;      /* Use primary */
   gboolean  synchronize;      /* Synchronize copy and primary */
+  gboolean  trim;             /* Trim contents */
   
   gboolean  save_history;     /* Save history */
   gint      history_limit;    /* Items in history */
