From 85cf4de96c686446b79a8f0c47e6343eb76aca3b Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Fri, 26 Aug 2011 17:19:58 -0700 Subject: ui/crumbs/runningbuild: add a 'Copy' item to the messages right-click menu Add another item to the right-click menu enabled for log messages to copy the message to the clipboard. (Bitbake rev: 419b52e832f506504778d4d5957d1e77477bb513) Signed-off-by: Joshua Lock Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/crumbs/runningbuild.py | 36 ++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/bitbake/lib/bb/ui/crumbs/runningbuild.py b/bitbake/lib/bb/ui/crumbs/runningbuild.py index d9e9f26..97d1ebd 100644 --- a/bitbake/lib/bb/ui/crumbs/runningbuild.py +++ b/bitbake/lib/bb/ui/crumbs/runningbuild.py @@ -306,31 +306,49 @@ class RunningBuildTreeView (gtk.TreeView): if event.button == 3: selection = super(RunningBuildTreeView, self).get_selection() - (model, iter) = selection.get_selected() - if iter is not None: - can_paste = model.get(iter, model.COL_LOG)[0] + (model, it) = selection.get_selected() + if it is not None: + can_paste = model.get(it, model.COL_LOG)[0] if can_paste == 'pastebin': # build a simple menu with a pastebin option menu = gtk.Menu() + menuitem = gtk.MenuItem("Copy") + menu.append(menuitem) + menuitem.connect("activate", self.copy_handler, (model, it)) + menuitem.show() menuitem = gtk.MenuItem("Send log to pastebin") menu.append(menuitem) - menuitem.connect("activate", self.pastebin_handler, (model, iter)) + menuitem.connect("activate", self.pastebin_handler, (model, it)) menuitem.show() menu.show() menu.popup(None, None, None, event.button, event.time) + def _add_to_clipboard(self, clipping): + """ + Add the contents of clipping to the system clipboard. + """ + clipboard = gtk.clipboard_get() + clipboard.set_text(clipping) + clipboard.store() + def pastebin_handler(self, widget, data): """ Send the log data to pastebin, then add the new paste url to the clipboard. """ - (model, iter) = data - paste_url = do_pastebin(model.get(iter, model.COL_MESSAGE)[0]) + (model, it) = data + paste_url = do_pastebin(model.get(it, model.COL_MESSAGE)[0]) # @todo Provide visual feedback to the user that it is done and that # it worked. print paste_url - clipboard = gtk.clipboard_get() - clipboard.set_text(paste_url) - clipboard.store() + self._add_to_clipboard(paste_url) + + def clipboard_handler(self, widget, data): + """ + """ + (model, it) = data + message = model.get(it, model.COL_MESSAGE)[0] + + self._add_to_clipboard(message) -- cgit v1.1