Merge lp:~marcobiscaro2112/unity/2011-03-08 into lp:unity

Proposed by Marco Biscaro
Status: Merged
Approved by: Neil J. Patel
Approved revision: no longer in the source branch.
Merged at revision: 936
Proposed branch: lp:~marcobiscaro2112/unity/2011-03-08
Merge into: lp:unity
Diff against target: 106 lines (+42/-29)
1 file modified
src/TrashLauncherIcon.cpp (+42/-29)
To merge this branch: bzr merge lp:~marcobiscaro2112/unity/2011-03-08
Reviewer Review Type Date Requested Status
Neil J. Patel Pending
Review via email: mp+52611@code.launchpad.net

Description of the change

    [launcher] Empty trash quicklist item is missing an ellipsis (LP: #731472)
    [launcher] Show disabled 'Empty trash' option when trash is already empty (LP: #723880)
    [dash] Adding ellipsis to 'Find XYZ' options (LP: #731162)

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Nice work, approved and merged, thank you!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/TrashLauncherIcon.cpp'
2--- src/TrashLauncherIcon.cpp 2011-02-22 17:05:31 +0000
3+++ src/TrashLauncherIcon.cpp 2011-03-09 16:32:29 +0000
4@@ -26,6 +26,9 @@
5
6 #include <gio/gio.h>
7 #include <glib/gi18n-lib.h>
8+#include <gconf/gconf-client.h>
9+
10+#define ASK_CONFIRMATION_KEY "/apps/nautilus/preferences/confirm_trash"
11
12 TrashLauncherIcon::TrashLauncherIcon (Launcher* IconManager)
13 : SimpleLauncherIcon(IconManager)
14@@ -73,21 +76,18 @@
15 DbusmenuMenuitem *menu_item;
16
17 /* Empty Trash */
18- if (_menu_items.find ("Empty") == _menu_items.end ())
19- {
20- menu_item = dbusmenu_menuitem_new ();
21- g_object_ref (menu_item);
22-
23- dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash"));
24- dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
25- dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
26-
27- g_signal_connect (menu_item,
28- DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
29- (GCallback)&TrashLauncherIcon::OnEmptyTrash, this);
30-
31- _menu_items["Empty"] = menu_item;
32- }
33+ menu_item = dbusmenu_menuitem_new ();
34+ g_object_ref (menu_item);
35+
36+ dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash..."));
37+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, !_empty);
38+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
39+
40+ g_signal_connect (menu_item,
41+ DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
42+ (GCallback)&TrashLauncherIcon::OnEmptyTrash, this);
43+
44+ _menu_items["Empty"] = menu_item;
45 }
46
47 void
48@@ -98,7 +98,7 @@
49 if (button == 1)
50 ActivateLauncherIcon ();
51
52- else if (button == 3 && _empty == FALSE)
53+ else if (button == 3)
54 {
55 EnsureMenuItemsReady ();
56
57@@ -128,24 +128,37 @@
58 void
59 TrashLauncherIcon::OnEmptyTrash(DbusmenuMenuitem *item, int time, TrashLauncherIcon *self)
60 {
61- GtkWidget *dialog;
62- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
63- GTK_MESSAGE_WARNING,
64- GTK_BUTTONS_CANCEL,
65- NULL);
66-
67- g_object_set (GTK_DIALOG (dialog),
68- "text", _("Empty all items from Trash?"),
69- "secondary-text", _("All items in the Trash will be permanently deleted."),
70- NULL);
71- gtk_dialog_add_button (GTK_DIALOG (dialog), _("Empty Trash"), GTK_RESPONSE_OK );
72+ GConfClient *client;
73+ GtkWidget *dialog;
74+ bool ask_confirmation;
75+
76+ client = gconf_client_get_default ();
77+ ask_confirmation = gconf_client_get_bool (client, ASK_CONFIRMATION_KEY, NULL);
78+ g_object_unref (client);
79+
80+ if (ask_confirmation)
81+ {
82+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
83+ GTK_MESSAGE_WARNING,
84+ GTK_BUTTONS_CANCEL,
85+ NULL);
86+
87+ g_object_set (GTK_DIALOG (dialog),
88+ "text", _("Empty all items from Trash?"),
89+ "secondary-text", _("All items in the Trash will be permanently deleted."),
90+ NULL);
91+ gtk_dialog_add_button (GTK_DIALOG (dialog), _("Empty Trash"), GTK_RESPONSE_OK );
92+ }
93
94 QuicklistManager::Default ()->HideQuicklist (self->_quicklist);
95
96- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
97+ if (!ask_confirmation || gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
98+ {
99 g_thread_create ((GThreadFunc)&TrashLauncherIcon::EmptyTrashAction, NULL, FALSE, NULL);
100+ }
101
102- gtk_widget_destroy (dialog);
103+ if (ask_confirmation)
104+ gtk_widget_destroy (dialog);
105
106 }
107