예제 #1
0
파일: plugin.py 프로젝트: pbx/kupfer
    def launch(self, files=(), paths=(), activate=False, ctx=None):
        """
        Launch the represented application

        @files: a seq of GFiles (gio.File)
        @paths: a seq of bytestring paths
        @activate: activate instead of start new
        """
        if self.serverid is not None:
            argv = [VIM, '--servername', self.serverid, '--remote']
        else:
            argv = [VIM]
        if files:
            paths = [f.get_path() or f.get_uri() for f in files]
        if paths:
            argv.extend(paths)
        if paths or self.serverid is None:
            try:
                utils.spawn_async_raise(argv)
            except utils.SpawnError as exc:
                raise OperationError(exc)
        if self.serverid:

            ## focus the window we opened
            def error_handler(exc):
                ctx.register_late_error(OperationError(exc))
            proxy_obj = get_plugin_service_obj(PLUGID)
            if proxy_obj:
                proxy_obj.Foreground(self.serverid,
                        reply_handler=_dummy_handler,
                        error_handler=error_handler)
예제 #2
0
	def activate(self, leaf):
		text = leaf.object
		keys, orig_mods = gtk.accelerator_parse(text)
		m = {
			gtk.gdk.SHIFT_MASK: "Shift_L",
			gtk.gdk.CONTROL_MASK: "Control_L",
			gtk.gdk.SUPER_MASK: "Super_L",
			gtk.gdk.MOD1_MASK: "Alt_L",
		}
		mod_names = []
		mods = orig_mods
		for mod in m:
			if mod & mods:
				mod_names.append(m[mod])
				mods &= ~mod
		if mods != 0:
			raise OperationError("Keys not yet implemented: %s" %
					gtk.accelerator_get_label(keys, orig_mods))
		key_arg = 'key %s' % (gtk.gdk.keyval_name(keys), )
		mods_down = ['keydown ' + n for n in mod_names]
		mods_up = ['keyup ' + n for n in reversed(mod_names)]

		xte_paste_argv = ['xte', 'usleep 300000'] + \
				mods_down + [key_arg] + mods_up
		try:
			utils.spawn_async_raise(xte_paste_argv)
		except utils.SpawnError as exc:
			raise OperationError(exc)
예제 #3
0
 def run(self):
     toggle = int(
         _cmd_output("server config playlist.repeat_all".split(" "))[0][-1])
     toggle = (toggle + 1) % 2
     utils.spawn_async_raise(
         ([XMMS2] +
          ("server config playlist.repeat_all %d" % toggle).split(" ")))
예제 #4
0
파일: plugin.py 프로젝트: jchtt/kupfer-adds
    def launch(self, files=(), paths=(), activate=False, ctx=None):
        """
		Launch the represented application

		@files: a seq of GFiles (gio.File)
		@paths: a seq of bytestring paths
		@activate: activate instead of start new
		"""
        if self.serverid is not None:
            argv = [VIM, '--servername', self.serverid, '--remote']
        else:
            argv = [VIM]
        if files:
            paths = [f.get_path() or f.get_uri() for f in files]
        if paths:
            argv.extend(paths)
        if paths or self.serverid is None:
            try:
                utils.spawn_async_raise(argv)
            except utils.SpawnError as exc:
                raise OperationError(exc)
        if self.serverid:
            ## focus the window we opened
            def error_handler(exc):
                ctx.register_late_error(OperationError(exc))

            proxy_obj = get_plugin_service_obj(PLUGID)
            if proxy_obj:
                proxy_obj.Foreground(self.serverid,
                                     reply_handler=_dummy_handler,
                                     error_handler=error_handler)
예제 #5
0
파일: xmms2.py 프로젝트: curiousleo/kupfer
def play_song(info):
	song_id = info["id"]
	if song_id in get_playlist_songs():
		_jump_and_play(song_id); return

	utils.spawn_async_raise((XMMS2, "add", "id:%d" % song_id))
	# Ensure that the song is first added so we can jump to it afterwards.
	glib.timeout_add(100, _jump_and_play, song_id)
예제 #6
0
파일: xmms2.py 프로젝트: curiousleo/kupfer
def enqueue_songs(info, clear_queue=False):
	songs = list(info)
	if not songs:
		return
	if clear_queue:
		utils.spawn_async_raise((XMMS2, "playlist", "clear"))
	for song in songs:
		song_id = song["id"]
		utils.spawn_async_raise((XMMS2, "add", "id:%s" % song_id))
예제 #7
0
def play_song(info):
    song_id = info["id"]
    if song_id in get_playlist_songs():
        _jump_and_play(song_id)
        return

    utils.spawn_async_raise((XMMS2, "add", "id:%d" % song_id))
    # Ensure that the song is first added so we can jump to it afterwards.
    glib.timeout_add(100, _jump_and_play, song_id)
예제 #8
0
	def activate(self, leaf):
		clip = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
		interface.copy_to_clipboard(leaf, clip)
		xte_paste_argv = ['xte', INIT_DELAY, 'keydown Control_L',
		                  'key v', 'keyup Control_L']
		try:
			utils.spawn_async_raise(xte_paste_argv)
		except utils.SpawnError as exc:
			raise OperationError(exc)
예제 #9
0
def enqueue_songs(info, clear_queue=False):
    songs = list(info)
    if not songs:
        return
    if clear_queue:
        utils.spawn_async_raise((XMMS2, "playlist", "clear"))
    for song in songs:
        song_id = song["id"]
        utils.spawn_async_raise((XMMS2, "add", "id:%s" % song_id))
예제 #10
0
 def activate(self, leaf):
     clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
     interface.copy_to_clipboard(leaf, clip)
     xte_paste_argv = ['xte', INIT_DELAY, 'keydown Control_L',
                       'key v', 'keyup Control_L']
     try:
         utils.spawn_async_raise(xte_paste_argv)
     except utils.SpawnError as exc:
         raise OperationError(exc)
예제 #11
0
 def activate(self, leaf):
     text = interface.get_text_representation(leaf)
     xte_paste_argv = ['xte', 'usleep 300000']
     # replace all newlines with 'key Return'
     for line in text.splitlines(True):
         xte_paste_argv.append("str " + line.rstrip("\r\n"))
         if line.endswith("\n"):
             xte_paste_argv.append("key Return")
     try:
         utils.spawn_async_raise(xte_paste_argv)
     except utils.SpawnError as exc:
         raise OperationError(exc)
예제 #12
0
	def activate(self, leaf):
		text = interface.get_text_representation(leaf)
		xte_paste_argv = ['xte', 'usleep 300000']
		# replace all newlines with 'key Return'
		for line in text.splitlines(True):
			xte_paste_argv.append("str " + line.rstrip("\r\n"))
			if line.endswith("\n"):
				xte_paste_argv.append("key Return")
		try:
			utils.spawn_async_raise(xte_paste_argv)
		except utils.SpawnError as exc:
			raise OperationError(exc)
예제 #13
0
    def activate_multiple(self, objects):
        xte_sendkey_argv = ['xte', INIT_DELAY]
        iterobjects = iter(objects)
        for obj in iterobjects:
            xte_sendkey_argv.extend(self.make_keystr_arguments(obj.object))
            break
        for obj in iterobjects:
            xte_sendkey_argv.append(INTER_DELAY)
            xte_sendkey_argv.extend(self.make_keystr_arguments(obj.object))

        try:
            utils.spawn_async_raise(xte_sendkey_argv)
        except utils.SpawnError as exc:
            raise OperationError(exc)
예제 #14
0
	def activate_multiple(self, objects):
		xte_sendkey_argv = ['xte', INIT_DELAY]
		iterobjects = iter(objects)
		for obj in iterobjects:
			xte_sendkey_argv.extend(self.make_keystr_arguments(obj.object))
			break
		for obj in iterobjects:
			xte_sendkey_argv.append(INTER_DELAY)
			xte_sendkey_argv.extend(self.make_keystr_arguments(obj.object))

		try:
			utils.spawn_async_raise(xte_sendkey_argv)
		except utils.SpawnError as exc:
			raise OperationError(exc)
예제 #15
0
파일: xmms2.py 프로젝트: curiousleo/kupfer
def _jump_and_play(song_id):
	utils.spawn_async_raise((XMMS2, "jump", "id:%d" % song_id))
	utils.spawn_async_raise((XMMS2, "play"))
	# must return False so it's not called again
	return False
예제 #16
0
def _jump_and_play(song_id):
    utils.spawn_async_raise((XMMS2, "jump", "id:%d" % song_id))
    utils.spawn_async_raise((XMMS2, "play"))
    # must return False so it's not called again
    return False
예제 #17
0
파일: devhelp.py 프로젝트: guns/kupfer
 def activate(self, leaf):
     text = leaf.object
     try:
         utils.spawn_async_raise(['devhelp', '--search=%s' % text])
     except utils.SpawnError as exc:
         raise OperationError(exc)
예제 #18
0
파일: rhythmbox.py 프로젝트: engla/kupfer
def spawn_async(argv):
    try:
        utils.spawn_async_raise(argv)
    except utils.SpawnError as exc:
        raise OperationError(exc)
예제 #19
0
 def run(self):
     utils.spawn_async_raise((XMMS2, "prev"))
예제 #20
0
 def run(self):
     utils.spawn_async_raise((XMMS2, "next"))
예제 #21
0
파일: devhelp.py 프로젝트: engla/kupfer
 def activate(self, leaf):
     text = leaf.object
     try:
         utils.spawn_async_raise(['devhelp', '--search=%s' % text])
     except utils.SpawnError as exc:
         raise OperationError(exc)
예제 #22
0
 def run(self):
     utils.spawn_async_raise((XMMS2, "playlist", "clear"))
예제 #23
0
파일: xmms2.py 프로젝트: curiousleo/kupfer
	def run(self):
		toggle = int(
			_cmd_output("server config playlist.repeat_all".split(" "))[0][-1])
		toggle = (toggle + 1) % 2
		utils.spawn_async_raise(([XMMS2] + ("server config playlist.repeat_all %d" % toggle).split(" ")))
예제 #24
0
파일: xmms2.py 프로젝트: curiousleo/kupfer
	def run(self):
		utils.spawn_async_raise((XMMS2, "prev"))
예제 #25
0
 def run(self):
     utils.spawn_async_raise(([XMMS2] + "playlist shuffle".split(" ")))
예제 #26
0
파일: xmms2.py 프로젝트: curiousleo/kupfer
	def run(self):
		utils.spawn_async_raise((XMMS2, "next"))
예제 #27
0
def spawn_operation_err(argv):
    try:
        utils.spawn_async_raise(argv)
    except SpawnError as exc:
        raise OperationError(exc.args[0].message)
예제 #28
0
파일: xmms2.py 프로젝트: curiousleo/kupfer
	def run(self):
		utils.spawn_async_raise((XMMS2, "playlist", "clear"))
예제 #29
0
def spawn_async(argv):
    try:
        utils.spawn_async_raise(argv)
    except utils.SpawnError as exc:
        raise OperationError(exc)
예제 #30
0
파일: xmms2.py 프로젝트: curiousleo/kupfer
	def run(self):
		utils.spawn_async_raise(([XMMS2] + "playlist shuffle".split(" ")))
예제 #31
0
 def activate(self, leaf):
     try:
         args = ['hamster-time-tracker', self.cmd]
         utils.spawn_async_raise(args)
     except utils.SpawnError as exc:
         raise OperationError(exc)
예제 #32
0
파일: tracker1.py 프로젝트: guns/kupfer
 def activate(self, leaf):
     try:
         utils.spawn_async_raise([TRACKER_GUI_SEARCH, leaf.object])
     except utils.SpawnError as exc:
         raise OperationError(exc)
예제 #33
0
파일: tracker1.py 프로젝트: engla/kupfer
 def activate(self, leaf):
     try:
         utils.spawn_async_raise([TRACKER_GUI_SEARCH, leaf.object])
     except utils.SpawnError as exc:
         raise OperationError(exc)
예제 #34
0
 def activate(self, leaf):
     try:
         args = ['hamster-time-tracker', self.cmd]
         utils.spawn_async_raise(args)
     except utils.SpawnError as exc:
         raise OperationError(exc)
예제 #35
0
파일: image.py 프로젝트: engla/kupfer
def spawn_operation_err(argv):
    try:
        utils.spawn_async_raise(argv)
    except SpawnError as exc:
        raise OperationError(exc.args[0].message)