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)
Beispiel #2
0
 def ok_action(self, event):
     textbuffer = self.textview.get_buffer()
     new_text = textbuffer.get_text(textbuffer.get_start_iter(),
                                    textbuffer.get_end_iter())
     if new_text not in ("", None):
         gtk.clipboard_get().set_text(new_text)
     self.window.destroy()
Beispiel #3
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
Beispiel #4
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
Beispiel #5
0
 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)
Beispiel #6
0
    def __init__(self):
        gobject.GObject.__init__(self)
        self.default_clipboard = gtk.clipboard_get()
        self.primary_clipboard = gtk.clipboard_get("PRIMARY")

        self.default_clipboard_text = self.default_clipboard.wait_for_text()
        self.primary_clipboard_text = self.primary_clipboard.wait_for_text()
        self.default_clipboard.connect('owner-change',
                                       self.on_default_clipboard_owner_change)
        self.primary_clipboard.connect('owner-change',
                                       self.on_primary_clipboard_owner_change)

        self.use_default_clipboard = glipper.GCONF_CLIENT.get_bool(
            glipper.GCONF_USE_DEFAULT_CLIPBOARD)
        if self.use_default_clipboard == None:
            self.use_default_clipboard = True
        glipper.GCONF_CLIENT.notify_add(
            glipper.GCONF_USE_DEFAULT_CLIPBOARD,
            lambda x, y, z, a: self.on_use_default_clipboard_changed(z.value))

        self.use_primary_clipboard = glipper.GCONF_CLIENT.get_bool(
            glipper.GCONF_USE_PRIMARY_CLIPBOARD)
        if self.use_primary_clipboard == None:
            self.use_primary_clipboard = True
        glipper.GCONF_CLIENT.notify_add(
            glipper.GCONF_USE_PRIMARY_CLIPBOARD,
            lambda x, y, z, a: self.on_use_primary_clipboard_changed(z.value))
Beispiel #7
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()
Beispiel #8
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
Beispiel #9
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()
Beispiel #10
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()
    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()
Beispiel #12
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)
    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
Beispiel #14
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()
Beispiel #15
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()
Beispiel #16
0
 def edit_copy(self, *argv):
     tm, row = self.data_view.get_selection().get_selected_rows()
     row = row[-1] if row else '0'
     itr = tm.get_iter(row)
     if tm.get_value(itr, 2):
         gtk.clipboard_get().set_text(','.join(
             [tm.get_value(itr, n) for n in xrange(9)]))
Beispiel #17
0
def copy_url(url):
    """Copy the url into the clipboard."""
    # try windows first
    try:
        import win32clipboard
    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 PIPE, Popen

        try:
            client = Popen(["pbcopy"], stdin=PIPE)
        except OSError:
            try:
                import pygtk

                pygtk.require("2.0")
                import gobject
                import gtk
            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()
Beispiel #18
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
    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)
Beispiel #20
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
Beispiel #21
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)
Beispiel #23
0
	def __init__(self):
		gobject.GObject.__init__(self)
		self.default_clipboard = Clipboard(gtk.clipboard_get(),
		                                   self.emit_new_item,
		                                   glipper.GCONF_USE_DEFAULT_CLIPBOARD)
		self.primary_clipboard = Clipboard(gtk.clipboard_get("PRIMARY"),
		                                   self.emit_new_item_selection,
		                                   glipper.GCONF_USE_PRIMARY_CLIPBOARD)
Beispiel #24
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
Beispiel #25
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)
Beispiel #26
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)
    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)
    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)
Beispiel #29
0
def main():
    clipboard = gtk.clipboard_get()

    clipboard.set_text("test")

    clipboard.store()

    clipboard = gtk.clipboard_get()

    print "rta=" + str(clipboard.wait_for_text())
    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)
Beispiel #31
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.encode('utf8')))
            gtk.clipboard_get().store()
Beispiel #32
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()
Beispiel #33
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
Beispiel #34
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
Beispiel #35
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)
Beispiel #36
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
Beispiel #37
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()
    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()
Beispiel #40
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)
Beispiel #41
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()
Beispiel #42
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))
Beispiel #43
0
 def okp_copy(self, event):
     #	copy selection to clipboard
     if event.state & gtk.gdk.CONTROL_MASK and self.sel:
         clp = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
         r1, c1, r2, c2 = self.sel
         shift = 0
         end = "\n"
         if event.state & gtk.gdk.SHIFT_MASK:
             shift = 1
             end = ""
         if r1 == r2:
             text = self.hvlines[r1][shift][c1 * 3:c2 * 3]
         else:
             text = self.hvlines[r1][shift][c1 * 3:] + end
             for i in range(min(r2 - r1 - 1, self.lines - 1)):
                 if self.hvlines[r1 + i + 1] == "":
                     text += self.get_string(r1 + i + 1)[shift] + end
                 else:
                     text += self.hvlines[r1 + i + 1][shift] + end
             if self.hvlines[r2] == "":
                 text += self.get_string(r2)[shift][:c2 * 3]
             else:
                 text += self.hvlines[r2][shift][:c2 * 3]
         clp.set_text(text)
         clp.store()
Beispiel #44
0
    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(gtk.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
Beispiel #45
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()
Beispiel #46
0
def get_clipboard():
    """
    Get content of OS clipboard.
    """
    if 'xerox' in sys.modules.keys():
        print("Returning clipboard content using xerox...")
        return xerox.paste()
    elif 'pyperclip' in sys.modules.keys():
        print("Returning clipboard content using pyperclip...")
        return pyperclip.paste()
    elif 'gtk' in sys.modules.keys():
        print("Returning clipboard content using gtk...")
        clipboard = gtk.clipboard_get()
        return clipboard.wait_for_text()
    elif 'win32clipboard' in sys.modules.keys():
        wcb = win32clipboard
        wcb.OpenClipboard()
        try:
            data = wcb.GetClipboardData(wcb.CF_TEXT)
        except TypeError as err:
            print(err)
            print("No text in clipboard.")
        wcb.CloseClipboard() # User cannot use clipboard until it is closed.
        return data
    else:
        #print("sys.modules.keys() is: ", sys.modules.keys())
        print("Neither of win32clipboard, gtk, pyperclip, or xerox available.")
        print("- Falling back to Tk...")
        tkroot = Tk()
        tkroot.withdraw()
        result = tkroot.selection_get(selection="CLIPBOARD")
        tkroot.destroy()
        print("Returning clipboard content using Tkinter...")
        return result
Beispiel #47
0
def set_clipboard(text, datatype=None):
    """
    Arg datatype currently not used. (This can be used to get e.g. an image from clipboard instead of text.)
    For now, this is generally assumed to be unicode text.
    From http://stackoverflow.com/questions/579687/how-do-i-copy-a-string-to-the-clipboard-on-windows-using-python
    """
    if 'xerox' in sys.modules.keys():
        xerox.copy(text)
    elif 'pyperclip' in sys.modules.keys():
        pyperclip.copy(text)
    elif 'gtk' in sys.modules.keys():
        clipboard = gtk.clipboard_get()
        text = clipboard.set_text(text)
    elif 'win32clipboard' in sys.modules.keys():
        wcb = win32clipboard
        wcb.OpenClipboard()
        wcb.EmptyClipboard()
        # wcb.SetClipboardText(text)  # doesn't work
        # SetClipboardData Usage:
        # >>> wcb.SetClipboardData(<type>, <data>)
        # wcb.SetClipboardData(wcb.CF_TEXT, text.encode('utf-8')) # doesn't work
        wcb.SetClipboardData(wcb.CF_UNICODETEXT, unicode(text)) # works
        wcb.CloseClipboard() # User cannot use clipboard until it is closed.
    else:
        # If code is run from within e.g. an ipython qt console, invoking Tk root's mainloop() may hang the console.
        tkroot = Tk()
        # r.withdraw()
        tkroot.clipboard_clear()
        tkroot.clipboard_append(text)
        tkroot.mainloop() # the Tk root's mainloop() must be invoked.
        tkroot.destroy()
 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 Wikipedia for \"%s\"" % displaystring)
         item.set_sensitive(True)
     else:
         item.set_label("Search Wikipedia")
         item.set_sensitive(False)
     # Avoid turning any underscores in selection into menu accelerators
     item.set_use_underline(False)
     menuitems.append(item)
Beispiel #49
0
    def set_body(post_type, obj_post):

        try:

            print("COMPUTER [.. -> Add " + post_type +
                  " -> Body]: Copy text for post and " +
                  "press \"Enter\", or enter \"00\" for cancel.")

            user_answer = raw_input("USER [.. -> Add " + post_type +
                                    " -> Body]: (-/00) ")

            user_answer = re.sub("[^0123456789\.]", "", user_answer)

            if user_answer == "00":
                print("COMPUTER: Cancel...")
                add_post()
            else:
                cb = gtk.clipboard_get()

                text = str(gtk.Clipboard.wait_for_text(cb))

                obj_post.set_var_body(text)

                print("\n" + str(obj_post.get_var_number_category()) + "." +
                      str(obj_post.get_var_number_post()) + ") " +
                      obj_post.get_var_body() + str() + "\n")

                return obj_post

        except Exception as var_except:
            print("COMPUTER [Main menu -> Add post -> Add " + post_type +
                  " -> Body]: Error, " + str(var_except) +
                  ". Return to menu Add post...")
            add_post()
Beispiel #50
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()
Beispiel #51
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))
Beispiel #52
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))
 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)