clipit-1.4.1 ("Remove All" item menu added)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
diff -Naur clipit-1.4.1.orig/po/ru.po clipit-1.4.1/po/ru.po
--- clipit-1.4.1.orig/po/ru.po 2011-05-27 10:33:51.000000000 +0300
+++ clipit-1.4.1/po/ru.po 2014-06-08 23:07:20.875130296 +0300
@@ -50,6 +50,11 @@
msgid "Empty"
msgstr "Пусто"
+#. Clear
+#: ../src/main.c:439 ../src/main.c:635
+msgid "Clear"
+msgstr "Очистить"
+
#. Edit actions
#: ../src/main.c:542
msgid "_Edit actions"
diff -Naur clipit-1.4.1.orig/src/history.c clipit-1.4.1/src/history.c
--- clipit-1.4.1.orig/src/history.c 2011-05-27 10:10:07.000000000 +0300
+++ clipit-1.4.1/src/history.c 2014-06-08 23:07:20.871130282 +0300
@@ -219,6 +219,22 @@
#endif
}
+/* Clear all history */
+void clear_history()
+{
+ history = NULL;
+
+ GtkClipboard *primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+ gtk_clipboard_clear(primary);
+ gtk_clipboard_set_text(primary, "", 0);
+
+ GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+ gtk_clipboard_clear(clipboard);
+ gtk_clipboard_set_text(clipboard, "", 0);
+
+ save_history();
+}
+
/* Checks if item should be included in history and calls append */
void check_and_append(gchar *item)
{
diff -Naur clipit-1.4.1.orig/src/history.h clipit-1.4.1/src/history.h
--- clipit-1.4.1.orig/src/history.h 2011-05-27 10:10:07.000000000 +0300
+++ clipit-1.4.1/src/history.h 2014-06-08 23:07:20.871130282 +0300
@@ -43,6 +43,8 @@
void save_history();
+void clear_history();
+
void check_and_append(gchar *item);
void append_item(gchar *item);
diff -Naur clipit-1.4.1.orig/src/main.c clipit-1.4.1/src/main.c
--- clipit-1.4.1.orig/src/main.c 2011-05-27 10:10:07.000000000 +0300
+++ clipit-1.4.1/src/main.c 2014-06-08 23:08:46.491554850 +0300
@@ -435,6 +435,11 @@
}
/* -------------------- */
gtk_menu_shell_append((GtkMenuShell*)menu, gtk_separator_menu_item_new());
+ /* Append "Clear" item */
+ menu_item = gtk_menu_item_new_with_label(_("Clear"));
+ gtk_menu_shell_append((GtkMenuShell*)menu, menu_item);
+ g_signal_connect((GObject*)menu_item, "activate",
+ (GCallback)clear_history, NULL);
/* Edit actions */
menu_item = gtk_image_menu_item_new_with_mnemonic(_("_Edit actions"));
menu_image = gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU);
@@ -625,6 +630,13 @@
elem = elem->next;
}
}
+
+ /* Append "Clear" item */
+ menu_item = gtk_menu_item_new_with_label(_("Clear"));
+ gtk_menu_shell_append((GtkMenuShell*)history_menu, menu_item);
+ g_signal_connect((GObject*)menu_item, "activate",
+ (GCallback)clear_history, NULL);
+
return history_menu;
}