Exemple #1
0
    def onExecute(self, widget, data=None):
        pynotify.Notification(APPNAME, _(u"I'm reading the text. One moment please."), self.icon).show()

        if widget.get_label() == _(u"Read selected text") :
            text = gtk.clipboard_get(selection="PRIMARY").wait_for_text()
        else :
            text = gtk.clipboard_get(selection="CLIPBOARD").wait_for_text()

        #~ text = text.lower()
        text = text.replace('\"', '')
        text = text.replace('`', '')
        text = text.replace('´', '')

        dic = CONFIGDIR + '/' + self.lang + '.dic'

        if os.path.exists(dic) :
            for line in open(dic,'r').readlines():

                bad = line.split('=')[0]
                #~ bad = bad.lower()
                try :
                    good = line.split('=')[1]
                except :
                    good = ' '
                text = text.replace(bad, good)

        os.system('pico2wave -l %s -w %s \"%s\" ' % ( self.lang, SPEECH, text ))

        player = self.onPlayer(SPEECH)
        self.player.set_state(gst.STATE_PLAYING)

        self.buttonState()
Exemple #2
0
def copy_url(url):
    """Copy the url into the clipboard."""
    # try windows first
    try:
        import win32clipboard
        import win32con
    except ImportError:
        # then give pbcopy a try.  do that before gtk because
        # gtk might be installed on os x but nobody is interested
        # in the X11 clipboard there.
        from subprocess import Popen, PIPE
        try:
            client = Popen(['pbcopy'], stdin=PIPE)
        except OSError:
            try:
                import pygtk
                pygtk.require('2.0')
                import gtk
                import gobject
            except ImportError:
                return
            gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD).set_text(url)
            gobject.idle_add(gtk.main_quit)
            gtk.main()
        else:
            client.stdin.write(url)
            client.stdin.close()
            client.wait()
    else:
        win32clipboard.OpenClipboard()
        win32clipboard.EmptyClipboard()
        win32clipboard.SetClipboardText(url)
        win32clipboard.CloseClipboard()
Exemple #3
0
	def _clipboard_changed(self, clip, event, *args):
		is_selection = (event.selection == gtk.gdk.SELECTION_PRIMARY)
		if is_selection and not __kupfer_settings__["use_selection"]:
			return

		max_len = __kupfer_settings__["max"]
		newtext = clip.wait_for_text()
		if not (newtext and newtext.strip()):
			return

		if newtext in self.clipboards:
			self.clipboards.remove(newtext)
		# if the previous text is a prefix of the new selection, supercede it
		if (is_selection and self.clipboards
				and (newtext.startswith(self.clipboards[-1])
				or newtext.endswith(self.clipboards[-1]))):
			self.clipboards.pop()
		self.clipboards.append(newtext)

		if is_selection and __kupfer_settings__["sync_selection"]:
			gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD).set_text(newtext)

		while len(self.clipboards) > max_len:
			self.clipboards.popleft()
		self.mark_for_update()
Exemple #4
0
	def disable(self):
		""""""
		if cons.OS_WINDOWS or cons.OS_OSX:
			self.enabled = False
		else:
			if self.handler_id:
				gtk.clipboard_get().disconnect(self.handler_id)
Exemple #5
0
    def _clipboard_changed(self, clip, event, *args):
        is_selection = (event.selection == gtk.gdk.SELECTION_PRIMARY)

        max_len = __kupfer_settings__["max"]
        # receive clipboard as gtk text
        newtext = kupferstring.tounicode(clip.wait_for_text())

        is_valid = bool(newtext and newtext.strip())
        is_sync_selection = (is_selection and
                             __kupfer_settings__["sync_selection"])

        if not is_selection or __kupfer_settings__["use_selection"]:
            if is_valid:
                self._add_to_history(newtext, is_selection)

        if is_sync_selection and is_valid:
            gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD).set_text(newtext)

        if is_selection:
            self.selected_text = newtext
        if not is_selection or is_sync_selection:
            self.clipboard_text = newtext
            if clip.wait_is_target_available(URI_TARGET):
                sdata = clip.wait_for_contents(URI_TARGET)
                self.clipboard_uris = list(sdata.get_uris())
            else:
                self.clipboard_uris = []
        self._prune_to_length(max_len)
        self.mark_for_update()
Exemple #6
0
def copy_url(url):
    """Copy the url into the clipboard."""
    if sys.platform == 'darwin':
        url = re.escape(url)
        os.system(r"echo %s | pbcopy" % url)
        return True

    try:
        import win32clipboard
        import win32con
        win32clipboard.OpenClipboard()
        win32clipboard.EmptyClipboard()
        win32clipboard.SetClipboardText(url)
        win32clipboard.CloseClipboard()
        return True
    except ImportError:
        try:
            if os.environ.get('DISPLAY'):
                import pygtk
                pygtk.require('2.0')
                import gtk
                import gobject
                gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD).set_text(url)
                gobject.idle_add(gtk.main_quit)
                gtk.main()
                return True
        except:
            pass
    return False
 def performOnCurrent(self):
     fileName, comp = self.currFileSelection[0]
     if comp and hasattr(comp, "tmpFile"):
         fileName = comp.tmpFile
     # Copy to both, for good measure, avoid problems with e.g. Exceed configuration
     for clipboard in [ gtk.clipboard_get(), gtk.clipboard_get("PRIMARY") ]:
         clipboard.set_text(fileName)
    def __init__(self):
        self.config = ConfigObj(self.config_file, write_empty_values=True)
        self.populate_config()

        self.display = display.Display()
        self.screen = wnck.screen_get_default()
        self.clipboard = gtk.clipboard_get("CLIPBOARD")
        self.alt_clip = gtk.clipboard_get("PRIMARY")
        self.new_clip = None
        self.our_data = None
        self.clips = []
        self.clips_ins = 0
        self.pasting = False
        self.need_paste = False

        self.terminals = ["Terminal", "terminator", "lxterminal", "Yakuake", "guake.py", "sakura", "tilda", "ROXTerm"]

        self.alt_terms = ["xterm", "mrxvt", "urxvt", "Eterm"]

        if self.options["initial_clip"]:
            self.clipboard.request_text(self.on_clipboard_text)
        else:
            self.our_data = self.clipboard.wait_for_text()
        gobject.timeout_add(500, self.fetch_clipboard_info)

        self.setup_ui()

        gtk.main()
Exemple #9
0
    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(gtk.gdk.SELECTION_CLIPBOARD).set_text(text)
        gtk.clipboard_get(gtk.gdk.SELECTION_PRIMARY).set_text(text)

        return text
Exemple #10
0
 def initialize(self):
     clip = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
     gobject_connect_weakly(clip, "owner-change", self._clipboard_changed)
     clip = gtk.clipboard_get(gtk.gdk.SELECTION_PRIMARY)
     gobject_connect_weakly(clip, "owner-change", self._clipboard_changed)
     self.clipboard_uris = []
     self.clipboard_text = None
     self.selected_text = None
Exemple #11
0
 def ao_clicar_bt_copiar(self, *args):
     csv = 'Logradouro\tLado\tNº de\tNº até\tBairro\tCidade\tUF\tCEP\tUnidade/Cliente\tCaixa Postal\tLatitude\tLongitude\n'
     csv += '\n'.join(['\t'.join([str(c) for c in l]) for l in self.ls_dados]) + '\n'
     gtk.clipboard_get().set_text(csv)
     d = gtk.MessageDialog(self.jn_principal, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "Dados copiados para a área de transferência!")
     d.run()
     d.destroy()
     del d
    def on_button_released(self, widget, event):
        """ Text selection a la mIRC """
        ret = self.buffer.get_selection_bounds()

        if ret:
            start, end = ret
            gtk.clipboard_get().set_text(self.buffer.get_text(start, end, True))
            self.buffer.place_cursor(end)
Exemple #13
0
 def _add_uri_button_released(self, add_uri_item, event):
     clipboard = gtk.clipboard_get('CLIPBOARD')
     uri = clipboard.wait_for_text()
     if not uri:
         clipboard = gtk.clipboard_get('PRIMARY')
         uri = clipboard.wait_for_text()
     if uri:
         filename = uri.split('/')[-1]
         self.add_download(uri, filename)
Exemple #14
0
 def __init__(self):
     self._xdisplay = Display()
     self._xroot = self._xdisplay.screen().root
     self._clipboard = gtk.clipboard_get()
     self._clipPrimay = gtk.clipboard_get("PRIMARY")
     self._entryForPaste = 118, X.ShiftMask
     self._group = 0
     self.loadModifiers()
     self._keymap = gdk.keymap_get_default()  # @UndefinedVariable
    def __on_copy(self, action, typo):
        bounds = self.get_selection()

        if not bounds:
            return

        data = self._document.get_data(bounds[0], bounds[1])

        def hexdump():
            idx = 0
            out = ""

            for x in data:
                i = hex(ord(x))[2:].upper()

                if len(i) == 1:
                    out += "0"

                out += "%s" % i
                idx += 1

                if idx % 8 == 0:
                    out += "\n"
                    idx = 0
                else:
                    out += " "
            return out

        def asciidump():
            idx = 0
            out = ""

            for x in data:
                i = x.isalpha() and x or "."

                out += "%s" % i
                idx += 1

                if idx % 8 == 0:
                    out += "\n"
                    idx = 0
            return out

        if typo == 0:
            gtk.clipboard_get().set_text(hexdump())

        elif typo == 1:
            self.copy_to_clipboard()
        else:
            out = ""

            for h, a in zip(hexdump().splitlines(), asciidump().splitlines()):
                padding = 8 - len(a)
                out += h + (" " * ((padding * 3) - 1)) + "\t" + a + "\n"

            gtk.clipboard_get().set_text(out)
Exemple #16
0
    def _on_copy_clipboard(self, textview):
        ''' replaces the copied text with a new text with the
        alt text of the images selected at copying '''
        buffer = self._buffer
        if buffer.get_has_selection():
            text = self._replace_emo_with_shortcut()

            # replace clipboard content
            gtk.clipboard_get().set_text(text, len(text))
            gtk.clipboard_get().store()
    def __on_copy(self, action):
        sel = self.tree.get_selection()
        model, rows = sel.get_selected_rows()

        out = ''

        for path in rows:
            out += self.get_row_txt(model, model.get_iter(path))

        gtk.clipboard_get().set_text(out)
Exemple #18
0
 def __init__(self):
     self.clipboard_history = []
     #self.got_content = None
     self.history_count = int(get_config_key('global', 'clipboard_history_size', '15'))
     self.clipboard = gtk.clipboard_get(selection="PRIMARY")
     if sys.platform != 'win32':
       self.clipboard1 = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
       self.clipboard1.request_text(self.clipboard_text_received)
     self.clipboard.request_text(self.clipboard_text_received)
     gobject.timeout_add(1500, self.fetch_clipboard_info)
     return
Exemple #19
0
	def copy_uri(self, explorer):
		clipboard = gtk.clipboard_get()
		try:
			clipboard.set_text(self.uri)
		except TypeError:
			clipboard.set_text(self.uri, len(self.uri))		# GTK 3
		primary = gtk.clipboard_get('PRIMARY')
		try:
			primary.set_text(self.uri)
		except TypeError:
			primary.set_text(self.uri, len(self.uri))		# GTK 3
Exemple #20
0
	def enable(self):
		""""""
		if cons.OS_WINDOWS or cons.OS_OSX:
			self.enabled = True
			tmp = gtk.clipboard_get().wait_for_text()
			if tmp:
				self.old_content = tmp
				self.len_old = len(tmp)
			gobject.timeout_add_seconds(1, self.check_clipboard)
		else:
			self.handler_id = gtk.clipboard_get().connect("owner-change", self.poll_clipboard)
Exemple #21
0
	def __init__(self):
		gobject.GObject.__init__(self)

		self.clip_clipboard	= gtk.clipboard_get("CLIPBOARD")
		self.clip_primary	= gtk.clipboard_get("PRIMARY")

		self.cleartimer		= Timer(10)
		self.cleartimeout	= 60
		self.cleartimer.connect("ring", self.__cb_clear_ring)

		self.content		= None
		self.contentpointer	= 0
    def __on_dialog_response(self, dialog, rid):
        if rid == gtk.RESPONSE_ACCEPT:
            dialog.stop_emission('response')
            details = dialog.vbox.get_children()[0].get_child()

            assert isinstance(details, HostListDetails)

            text = details.copy_selected()

            if text:
                gtk.clipboard_get().set_text(text)
        else:
            dialog.hide()
            dialog.destroy()
Exemple #23
0
    def onExecute(self, widget, data=None):
        pynotify.Notification(APPNAME, _(u"I'm reading the text. One moment please."), self.icon).show()

        if widget.get_label() == _(u"Read selected text") :
            text = gtk.clipboard_get(selection="PRIMARY").wait_for_text()
        else :
            text = gtk.clipboard_get(selection="CLIPBOARD").wait_for_text()

        #~ text = text.lower()
        text = text.replace('\"', '')
        text = text.replace('`', '')
        text = text.replace('´', '')
        text = text.replace('-','')

        dic = CONFIGDIR + '/' + self.lang + '.dic'

        if os.path.exists(dic) :
            for line in open(dic,'r').readlines():

                bad = line.split('=')[0]
                #~ bad = bad.lower()
                try :
                    good = line.split('=')[1]
                except :
                    good = ' '
                text = text.replace(bad, good)
        if len(text) <= 32768:
            os.system('pico2wave -l %s -w %s \"%s\" ' % ( self.lang, SPEECH, text ))
        else:
            discours = text.split('\n\n')
            commands = []
            fichiers = []
            noms = []
            text = ''
            for idx,paragraph in enumerate(discours):
                text += paragraph
                if idx == len(discours)-1 or len(text) + len(discours[idx+1]) >= 32767:
                    filename = CACHEFOLDER + 'speech' + str(idx) + '.wav'
                    commands.append('pico2wave -l %s -w %s \"%s\" ' % ( self.lang, filename, text ))
                    noms.append(filename)
                    text = ''
            nproc = int(.5 * multiprocessing.cpu_count())
            if nproc == 0: nproc = 1
            multiprocessing.Pool(nproc).map(os.system, commands)
            os.system('sox %s %s' % ( ' '.join(noms), SPEECH ))
            player = self.onPlayer(SPEECH)
            self.player.set_state(gst.STATE_PLAYING)
            for fichier in noms:
                os.remove(fichier)
Exemple #24
0
def crack_action(params):
    if params[1] == 'search':
        load_search(params[2])
    elif params[1] == 'choose_file':
        callback = params[2]
        file_path = utils.open_file_chooser_dialog()
        webv.execute_script('%s("%s")' % (callback, file_path))
    elif params[1] == 'save_avatar':
        img_uri = urllib.unquote(params[2])
        avatar_file = urllib.unquote(params[3])
        avatar_path = os.path.join(config.AVATAR_CACHE_DIR, avatar_file)
        if not (os.path.exists(avatar_path) and avatar_file.endswith(img_uri[img_uri.rfind('/')+1:])):
            print 'Download:', img_uri , 'To' , avatar_path
            th = threading.Thread(
                target = save_file_proc, 
                args=(img_uri, avatar_path))
            th.start()
    elif params[1] == 'log':
        print '\033[1;31;40m[%s]\033[0m %s' % (urllib.unquote(params[2]) ,urllib.unquote(params[3]))
    elif params[1] == 'paste_clipboard_text':
        webv.paste_clipboard();
    elif params[1] == 'set_clipboard_text':
        clipboard = gtk.clipboard_get()
        text = list(params)
        del text[0:2]
        clipboard.set_text('/'.join(text))
Exemple #25
0
 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()
Exemple #26
0
def main():
        DEF_TIME=10  #delay before clear bufer

        parser = argparse.ArgumentParser(description='update db OSHS')
        # parser.add_argument('-p', '--password', type=str, help='enter password')
        parser.add_argument('-p', '--password', action="store_true", help='enter password')
        parser.add_argument('-n', '--insert_n', action="store_true", help='insert line break character')
        parser.add_argument('-t', '--time', type=int, help='delay before clear bufer')
        args = parser.parse_args()
        if len(sys.argv) == 1:
                parser.print_help()
                exit(1)

        if args.password:
            password = getpass.getpass()
            if args.insert_n: password += "\n"

            hasher = hashlib.sha512()
            hasher.update(password)
            hash_password = hasher.hexdigest()

            clipboard = gtk.clipboard_get()
            clipboard.set_text(hash_password)
            clipboard.store()

            if args.time:  DEF_TIME = args.time
            time.sleep(DEF_TIME)
            clipboard.clear()
Exemple #27
0
    def copy_mail(self, data, widget=None):
        mail_list = []
        for member in self.members:
            mail_list.append(member)

        clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
        clipboard.set_text(', '.join(mail_list))
 def callback(self, menuitems, menu, terminal):
     """Add our menu item to the menu"""
     self.terminal = terminal
     item = gtk.ImageMenuItem(gtk.STOCK_FIND)
     item.connect('activate', self.do_search)
     if terminal.vte.get_has_selection():
         clip = gtk.clipboard_get(gtk.gdk.SELECTION_PRIMARY)
         self.searchstring = clip.wait_for_text().strip()
         self.searchstring = self.searchstring.replace("\n", " ")
         self.searchstring = self.searchstring.replace("\t", " ")
         self.searchstring = _spaces.sub(" ", self.searchstring)
     else:
         self.searchstring = None
     if self.searchstring:
         if len(self.searchstring) > 40:
             displaystring = self.searchstring[:37] + "..."
         else:
             displaystring = self.searchstring
         item.set_label("Search Github Issues for \"%s\"" % displaystring)
         item.set_sensitive(True)
     else:
         item.set_label("Search Github Issues")
         item.set_sensitive(False)
     # Avoid turning any underscores in selection into menu accelerators
     item.set_use_underline(False)
     menuitems.append(item)
Exemple #29
0
def main(argv=None):
	if argv is None: argv = sys.argv

	from optparse import OptionParser
	parser = OptionParser()

	parser.add_option('-c', '--clipboard', action='store_true', dest='clipboard', default=True)
	parser.add_option('--no-clipboard', action='store_false', dest='clipboard')
	parser.add_option('-p', '--paste', action='store_true', dest='paste', default=False)

	(opts, args) = parser.parse_args(argv[1:])

	clipboard = None

	if opts.clipboard or opts.paste:
		import gtk
		clipboard = gtk.clipboard_get()

	if opts.paste: url = clipboard.wait_for_text()
	elif len(args) > 0: url = args.pop()
	else:
		print('You must supply a URL to obfuscate, or use the -c parameter')
		exit(1)

	if opts.clipboard:
		clipboard.set_text(obfuscate_url(url))
		clipboard.store()
	else:
		print(obfuscate_url(url))
Exemple #30
0
 def diagnostic_dialog(self, parent):
     """Show diagnostic information"""
     dialog = gtk.Dialog(_("System information"), parent)
     dialog.resize(600, 400)
     txtbuffer = gtk.TextBuffer()
     import Diagnostic
     txt = Diagnostic.diagnostic_info()
     txtbuffer.set_text(txt)
     textview = gtk.TextView(txtbuffer)
     textview.set_editable(False)
     swindow = gtk.ScrolledWindow()
     swindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     swindow.add_with_viewport(textview)
     dialog.vbox.pack_start(swindow)
     dialog.add_buttons(
         gtk.STOCK_COPY, 100, gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
     dialog.show_all()
     while True:
         rc = dialog.run()
         if 100 == rc:
             clipboard = gtk.clipboard_get()
             clipboard.set_text(txt)
         else:
             break
     dialog.hide()