Merge lp:~brandontschaefer/unity/one-trash-can into lp:unity

Proposed by Brandon Schaefer
Status: Work in progress
Proposed branch: lp:~brandontschaefer/unity/one-trash-can
Merge into: lp:unity
Diff against target: 209 lines (+137/-4) (has conflicts)
3 files modified
launcher/LauncherController.cpp (+56/-0)
launcher/TrashLauncherIcon.cpp (+64/-4)
launcher/TrashLauncherIcon.h (+17/-0)
Text conflict in launcher/LauncherController.cpp
Text conflict in launcher/TrashLauncherIcon.cpp
Text conflict in launcher/TrashLauncherIcon.h
To merge this branch: bzr merge lp:~brandontschaefer/unity/one-trash-can
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+143377@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

2464. By Brandon Schaefer

* Only one trash can will open now

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/LauncherController.cpp'
2--- launcher/LauncherController.cpp 2013-01-08 11:47:00 +0000
3+++ launcher/LauncherController.cpp 2013-01-15 18:28:29 +0000
4@@ -120,9 +120,37 @@
5 #endif
6
7 UScreen* uscreen = UScreen::GetDefault();
8+<<<<<<< TREE
9 EnsureLaunchers(uscreen->GetPrimaryMonitor(), uscreen->GetMonitors());
10
11 SetupIcons();
12+=======
13+ auto monitors = uscreen->GetMonitors();
14+ int primary = uscreen->GetPrimaryMonitor();
15+
16+ launcher_open = false;
17+ launcher_keynav = false;
18+ launcher_grabbed = false;
19+ reactivate_keynav = false;
20+ keynav_restore_window_ = true;
21+
22+ EnsureLaunchers(primary, monitors);
23+
24+ launcher_ = launchers[0];
25+ device_section_.IconAdded.connect(sigc::mem_fun(this, &Impl::OnIconAdded));
26+
27+ num_workspaces_ = WindowManager::Default()->WorkspaceCount();
28+ if (num_workspaces_ > 1)
29+ {
30+ InsertExpoAction();
31+ }
32+
33+ // Insert the "Show Desktop" launcher icon in the launcher...
34+ if (show_desktop_icon_)
35+ InsertDesktopIcon();
36+
37+ sources_.Add(std::make_shared<glib::Timeout>(500, [&]() { SetupBamf(); InsertTrash(); return false; }));
38+>>>>>>> MERGE-SOURCE
39
40 remote_model_.entry_added.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteAdded));
41 remote_model_.entry_removed.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteRemoved));
42@@ -720,6 +748,7 @@
43 }
44 }
45
46+<<<<<<< TREE
47 template<typename IconType>
48 int Controller::Impl::GetLastIconPriority(std::string const& favorite_uri, bool sticky)
49 {
50@@ -789,6 +818,33 @@
51
52 AbstractLauncherIcon::Ptr Controller::Impl::CreateFavoriteIcon(std::string const& icon_uri)
53 {
54+=======
55+/* static private */
56+void Controller::Impl::OnViewOpened(BamfMatcher* matcher, BamfView* view)
57+{
58+ if (!BAMF_IS_APPLICATION(view))
59+ return;
60+
61+ BamfApplication* app = BAMF_APPLICATION(view);
62+
63+ if (bamf_view_is_sticky(view) ||
64+ g_object_get_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen")))
65+ {
66+ return;
67+ }
68+ printf("%s\n", bamf_view_get_name(BAMF_VIEW(view)));
69+
70+ AbstractLauncherIcon::Ptr icon(new BamfLauncherIcon(app));
71+ icon->visibility_changed.connect(sigc::mem_fun(this, &Impl::SortAndUpdate));
72+ icon->SetSortPriority(sort_priority_++);
73+ RegisterIcon(icon);
74+ SortAndUpdate();
75+}
76+
77+AbstractLauncherIcon::Ptr Controller::Impl::CreateFavorite(const char* file_path)
78+{
79+ BamfApplication* app;
80+>>>>>>> MERGE-SOURCE
81 AbstractLauncherIcon::Ptr result;
82
83 if (!FavoriteStore::IsValidFavoriteUri(icon_uri))
84
85=== modified file 'launcher/TrashLauncherIcon.cpp'
86--- launcher/TrashLauncherIcon.cpp 2012-11-26 16:09:53 +0000
87+++ launcher/TrashLauncherIcon.cpp 2013-01-15 18:28:29 +0000
88@@ -43,7 +43,12 @@
89 TrashLauncherIcon::TrashLauncherIcon()
90 : SimpleLauncherIcon(IconType::TRASH)
91 , proxy_("org.gnome.Nautilus", "/org/gnome/Nautilus", "org.gnome.Nautilus.FileOperations")
92+<<<<<<< TREE
93 , cancellable_(g_cancellable_new())
94+=======
95+ , matcher_(bamf_matcher_get_default())
96+ , view_(nullptr)
97+>>>>>>> MERGE-SOURCE
98 {
99 tooltip_text = _("Trash");
100 icon_name = "user-trash";
101@@ -100,10 +105,65 @@
102 {
103 SimpleLauncherIcon::ActivateLauncherIcon(arg);
104
105- glib::Error error;
106- g_spawn_command_line_async("xdg-open trash://", &error);
107-}
108-
109+ if (GetQuirk(QUIRK_STARTING))
110+ return;
111+
112+ // If view is true then bring it to front
113+ if (view_ && GetQuirk(QUIRK_RUNNING))
114+ {
115+ printf("Raise the bamf view trash window!\n");
116+ }
117+ else
118+ {
119+ glib::Error error;
120+ g_signal_connect (matcher_,
121+ "view-opened",
122+ G_CALLBACK(&TrashLauncherIcon::OnViewOpened),
123+ this);
124+ SetQuirk(QUIRK_STARTING, true);
125+ g_spawn_command_line_async("xdg-open trash://", &error);
126+ }
127+}
128+
129+<<<<<<< TREE
130+=======
131+void TrashLauncherIcon::OnEmptyTrash(DbusmenuMenuitem* item, int time, TrashLauncherIcon* self)
132+{
133+ self->proxy_.Call("EmptyTrash");
134+}
135+
136+void TrashLauncherIcon::OnViewOpened(BamfMatcher* matcher, BamfView* view, gpointer data)
137+{
138+ TrashLauncherIcon* self = (TrashLauncherIcon*)data;
139+
140+ if (g_strcmp0 (_("Trash"), bamf_view_get_name (BAMF_VIEW(view))) == 0 )
141+ {
142+ self->view_ = view;
143+ self->SetQuirk(QUIRK_RUNNING, true);
144+ g_signal_connect (view,
145+ "closed",
146+ G_CALLBACK(&TrashLauncherIcon::OnViewClosed),
147+ self);
148+ g_signal_handlers_disconnect_by_func (matcher,
149+ (void*) (TrashLauncherIcon::OnViewOpened),
150+ self);
151+ printf("Trash Opened!!\n");
152+ }
153+}
154+
155+void TrashLauncherIcon::OnViewClosed(BamfView* view, gpointer data)
156+{
157+ TrashLauncherIcon* self = (TrashLauncherIcon*)data;
158+ printf("ViewClosed\n");
159+ self->SetQuirk(QUIRK_RUNNING, false);
160+
161+ g_signal_handlers_disconnect_by_func (self->view_,
162+ (void*) (&TrashLauncherIcon::OnViewClosed),
163+ self);
164+ self->view_ = nullptr;
165+}
166+
167+>>>>>>> MERGE-SOURCE
168 void TrashLauncherIcon::UpdateTrashIcon()
169 {
170 glib::Object<GFile> location(g_file_new_for_uri("trash:///"));
171
172=== modified file 'launcher/TrashLauncherIcon.h'
173--- launcher/TrashLauncherIcon.h 2012-08-15 02:51:33 +0000
174+++ launcher/TrashLauncherIcon.h 2013-01-15 18:28:29 +0000
175@@ -27,6 +27,7 @@
176
177 #include "DndData.h"
178 #include "SimpleLauncherIcon.h"
179+#include <libbamf/libbamf.h>
180
181 namespace unity
182 {
183@@ -57,10 +58,26 @@
184
185 gboolean empty_;
186 glib::DBusProxy proxy_;
187+<<<<<<< TREE
188 glib::Object<GCancellable> cancellable_;
189 glib::Object<GFileMonitor> trash_monitor_;
190 glib::Signal<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent> trash_changed_signal_;
191 glib::Signal<void, DbusmenuMenuitem*, int> empty_activated_signal_;
192+=======
193+ glib::Object<BamfMatcher> matcher_;
194+ BamfView* view_;
195+
196+ void ActivateLauncherIcon(ActionArg arg);
197+ std::list<DbusmenuMenuitem*> GetMenus();
198+
199+ static void UpdateTrashIconCb(GObject* source, GAsyncResult* res, gpointer data);
200+ static void OnTrashChanged(GFileMonitor* monitor, GFile* file, GFile* other_file,
201+ GFileMonitorEvent event_type, gpointer data);
202+ static void OnEmptyTrash(DbusmenuMenuitem* item, int time, TrashLauncherIcon* self);
203+
204+ static void OnViewOpened(BamfMatcher* matcher, BamfView* view, gpointer data);
205+ static void OnViewClosed(BamfView* view, gpointer data);
206+>>>>>>> MERGE-SOURCE
207 };
208
209 }