def copy(self): startend = self.get_buffer().get_selection_bounds() tagsandtext = [] if startend: start, end = startend while not start.equal(end): tags_at_iter = {} for tag in start.get_tags(): try: tagname, tagval = eval(tag.get_property('name')) tags_at_iter[tagname] = tagval except NameError: continue tagsandtext.append((dict(tags_at_iter), start.get_char())) start.forward_char() text = parse_mirc.unparse_mirc(tagsandtext) Gtk.clipboard_get(Gdk.SELECTION_CLIPBOARD).set_text(text) Gtk.clipboard_get(Gdk.SELECTION_PRIMARY).set_text(text) return text
def __init__(self, coherence): self.coherence = coherence self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL) self.window.set_default_size(500,460) self.window.set_title('Details') scroll_window = Gtk.ScrolledWindow() scroll_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.store = Gtk.TreeStore(str,object) self.treeview = Gtk.TreeView(self.store) column = Gtk.TreeViewColumn('Name') self.treeview.append_column(column) text_cell = Gtk.CellRendererText() column.pack_start(text_cell, False) column.set_attributes(text_cell,text=0) column = Gtk.TreeViewColumn('Value') self.treeview.insert_column_with_data_func(-1,'Value',Gtk.CellRendererText(),self.celldatamethod) text_cell = Gtk.CellRendererText() column.pack_start(text_cell, True) column.set_attributes(text_cell,text=1) self.treeview.connect("button_press_event", self.button_action) self.clipboard = Gtk.clipboard_get(Gdk.SELECTION_CLIPBOARD) scroll_window.add(self.treeview) self.window.add(scroll_window)
def button_action(self, widget, event): #print "ItemDetailsWidget button_action", widget, self x = int(event.x) y = int(event.y) path = widget.get_path_at_pos(x, y) if path == None: return True row_path,column,_,_ = path if event.button == 3: store = widget.get_model() iter = store.get_iter(row_path) menu = Gtk.Menu() key,= store.get(iter,0) value,= store.get(iter,1) clipboard = Gtk.clipboard_get(Gdk.SELECTION_CLIPBOARD) if key in ['DIDL-Lite:res','upnp:albumArtURI']: item = Gtk.MenuItem("copy URL") item.connect("activate", lambda w: clipboard.set_text(value)) menu.append(item) item = Gtk.MenuItem("open URL") item.connect("activate", lambda w: self.open_url(value)) menu.append(item) else: item = Gtk.MenuItem("copy value") item.connect("activate", lambda w: clipboard.set_text(value)) menu.append(item) menu.show_all() menu.popup(None,None,None,event.button,event.time) return True return False
def run(self): self.update_patch() while 1: result = self.widget.run() if result < 0: break buf = self.textview.get_buffer() start, end = buf.get_bounds() txt = text_type(buf.get_text(start, end, False), 'utf8') # Copy patch to clipboard if result == 1: clip = Gtk.clipboard_get() clip.set_text(txt) clip.store() break # Save patch as a file else: # FIXME: These filediff methods are actually general utility. filename = self.filediff._get_filename_for_saving( _("Save Patch")) if filename: txt = txt.encode('utf-8') self.filediff._save_text_to_filename(filename, txt) break self.widget.hide()
def copy_text(self, widget): clipboard = Gtk.clipboard_get() url = self.text_area.get_text() clipboard.set_text(url) clipboard.store()
def _copy_to_clipboard_cb(self, menuitem): logging.debug('Copy %s to clipboard', self.url) clipboard = Gtk.clipboard_get() targets = [('text/uri-list', 0, 0), ('UTF8_STRING', 0, 1)] if not clipboard.set_with_data(targets, self._clipboard_data_get_cb, self._clipboard_clear_cb, (self.url)): logging.debug('GtkClipboard.set_with_data failed!') else: self.owns_clipboard = True
def on_paste_code(self, action): doc = self.window.get_active_document() if not doc: return lines = Gtk.clipboard_get().wait_for_text().split('\n') to_copy = "\n".join([line for line in lines[1:]]) doc.insert_at_cursor('..sourcecode:: ChoosenLanguage\n\n %s\n' % lines[0]) doc.insert_at_cursor(to_copy + '\n\n')
def _paste(self, syntax, priv, text, link): "pastes selected text and displays window with link" p = pastie.Pastie(text, syntax, priv) paste = p.paste() if link == "Window": self.inform.entry.set_text("please wait") self.inform.show() #shows window self.inform.entry.set_text(paste) else: clipboard = Gtk.clipboard_get('CLIPBOARD') clipboard.set_text(paste) clipboard.store()
def paste_text(self, widget): """Função para colar o texto armazenado no clipboard na área de texto do programa""" #Obtendo o acesso ao clipboard do sistema clipboard = Gtk.clipboard_get() #Obtendo o texto armazenado no clipboard url = clipboard.wait_for_text() #Inserindo o texto obtido do clipboard na área de texto do programa self.text_area.set_text(url)
def copy_text(self, widget): """Função para copiar o valor digitado na área de texto para o clipboard do sistema""" #Obtendo o acesso ao clipboard do sistema clipboard = Gtk.clipboard_get() #Obtendo a URL digitada na área de texto para que possamos copia-la url = self.text_area.get_text() #Copiando a URL para o clipboard do sistema clipboard.set_text(url) #Para que a URL permanceça amazenada no clipboard mesmo depois do #programa ser encerrado utilizamos a função store() do Gtk.clipboard clipboard.store()
def on_copy(self, widget=None): if self._handle_clipboard(widget, "copy"): return (model, row) = self.treeview.get_selection().get_selected() if row is None: return tree = etree.ElementTree(self.__get_treestore(row)) ios = io.StringIO() tree.write(ios, pretty_print = True, xml_declaration = False, encoding = "utf-8") clipboard = gtk.clipboard_get() clipboard.set_text(ios.getvalue()) clipboard.store() ios.close()
def button_action(self, widget, event): x = int(event.x) y = int(event.y) path = self.treeview.get_path_at_pos(x, y) if path == None: return True row_path,column,_,_ = path if event.button == 3: clipboard = Gtk.clipboard_get(Gdk.SELECTION_CLIPBOARD) iter = self.store.get_iter(row_path) menu = Gtk.Menu() item = Gtk.MenuItem("copy value") value,= self.store.get(iter,4) item.connect("activate", lambda w: clipboard.set_text(value)) menu.append(item) item = Gtk.MenuItem("copy raw event") raw,= self.store.get(iter,5) try: from coherence.extern.et import ET, indent, parse_xml xml = parse_xml(raw) xml = xml.getroot() indent(xml,0) raw = ET.tostring(xml, encoding='utf-8') except: import traceback print traceback.format_exc() item.connect("activate", lambda w: clipboard.set_text(raw)) menu.append(item) menu.show_all() menu.popup(None,None,None,event.button,event.time) return True return False
def paste_selection(self, action): if not self.term.isOpen(): return Gtk.clipboard_get().request_text(lambda x, y, z: self.term.write(y if y else ''))
def set_clipboard(text): Gtk.clipboard_get(Gdk.SELECTION_CLIPBOARD).set_text(text) Gtk.clipboard_get(Gdk.SELECTION_PRIMARY).set_text(text)
def paste_text(self, widget): clipboard = Gtk.clipboard_get() url = clipboard.wait_for_text() self.text_area.set_text(url)
def copy_cb(tview): tview.get_buffer().copy_clipboard(Gtk.clipboard_get())