Example #1
0
    def register_late_result(self, token, result, show=True, ctxenv=None):
        """Register a late result

		Result must be a Leaf (as in result object, not factory or async)

		If @show, possibly display the result to the user.
		"""
        self.output_debug("Late result", repr(result), "for", token)
        command_id, (_ign1, action, _ign2) = token
        if result is None:
            raise ActionExecutionError("Late result from %s was None" % action)
        res_name = unicode(result)
        res_desc = result.get_description()
        if res_desc:
            description = "%s (%s)" % (res_name, res_desc)
        else:
            description = res_name
        uiutils.show_notification(
            _('"%s" produced a result') % action, description)

        # If only registration was requsted, remove the command id info
        if not show:
            command_id = -1
        self.emit("late-command-result", command_id, RESULT_OBJECT, result,
                  ctxenv)
        self._append_result(RESULT_OBJECT, result)
Example #2
0
 def activate(self, leaf):
     p = subprocess.Popen(["gpg", "--import"],
                          stdout=subprocess.PIPE,
                          stdin=subprocess.PIPE,
                          stderr=subprocess.PIPE)
     stdout, stderr = p.communicate(leaf.object)
     uiutils.show_notification(_("Import Public Key"), stdout or stderr)
Example #3
0
	def activate(self, leaf):
		title, body = textutils.extract_title_body(leaf.object)
		if body:
			uiutils.show_notification(title, body,
					icon_name=self.get_icon_name())
		else:
			uiutils.show_notification(title)
Example #4
0
 def activate(self, leaf):
     title, body = textutils.extract_title_body(leaf.object)
     if body:
         uiutils.show_notification(title, body,
                 icon_name=self.get_icon_name())
     else:
         uiutils.show_notification(title)
Example #5
0
    def register_late_result(self, token, result, show=True, ctxenv=None):
        """Register a late result

        Result must be a Leaf (as in result object, not factory or async)

        If @show, possibly display the result to the user.
        """
        self.output_debug("Late result", repr(result), "for", token)
        command_id, (_ign1, action, _ign2) = token
        if result is None:
            raise ActionExecutionError("Late result from %s was None" % action)
        res_name = unicode(result)
        res_desc = result.get_description()
        if res_desc:
            description = "%s (%s)" % (res_name, res_desc)
        else:
            description = res_name
        uiutils.show_notification(_('"%s" produced a result') % action,
                description)

        # If only registration was requsted, remove the command id info
        if not show:
            command_id = -1
        self.emit("late-command-result", command_id, RESULT_OBJECT, result,
                                         ctxenv)
        self._append_result(RESULT_OBJECT, result)
	def thread_finish(self):
		if self.error:
			title = "Error"
			message = self.error
		else:
			title = "Extraction Complete"
			message = "Extracted\n%s\nto\n%s" %	(self.archive_name, self.extract_path)
		uiutils.show_notification(title, message)
Example #7
0
 def thread_do(self):
     # TODO: change import to popen https://github.com/pypa/pip/issues/3889
     # NOTE: which pip will use? pip, pip2 or pip3?
     from pip.commands import install
     from pip.utils.logging import _log_state
     leaf = self.leaf
     _log_state.indentation = 0
     install.InstallCommand().main(['--upgrade', '--user', leaf.object.get("name")] )
     uiutils.show_notification(_("Plugin Installed"), 
         "Now enable {} at preferences".format(leaf.name), icon_name='info')
Example #8
0
 def thread_do(self):
     # TODO: change import to popen https://github.com/pypa/pip/issues/3889
     # NOTE: which pip will use? pip, pip2 or pip3?
     from pip.commands import install
     from pip.utils.logging import _log_state
     leaf = self.leaf
     _log_state.indentation = 0
     install.InstallCommand().main(
         ['--upgrade', '--user',
          leaf.object.get("name")])
     uiutils.show_notification(_("Plugin Installed"),
                               "Now enable {} at preferences".format(
                                   leaf.name),
                               icon_name='info')
Example #9
0
	def _execute_file_received(self, sender, filepath):
		from kupfer import execfile
		from kupfer import uiutils
		try:
			execfile.execute_file(filepath)
		except execfile.ExecutionError, exc:
			if not uiutils.show_notification(unicode(exc)):
				raise
Example #10
0
    def activate(self, leaf):
        shortcut = leaf.object
        args = "xdotool search --class \"eclipse\" windowactivate --sync key --clearmodifiers \"%s\"" % shortcut['keys'].lower()
        argv = ['sh', '-c', args, '--']
        def finish_callback(acommand, stdout, stderr):
            pretty.print_debug(__name__, "%s: stdout: %s, stderr: %s, shortcut: %s" % (acommand, stdout, stderr, shortcut['keys'].lower()))
        utils.AsyncCommand(argv, finish_callback, 15)
        uiutils.show_notification(shortcut['keys'], shortcut['desc'],
            icon_name=self.get_icon_name())

# ROADMAP
# 0.1 show shortcuts for eclipse in notification
# 1.0 show shortcuts for any in notification
# UNSORTED future possible features:
# - read / import shortcuts from server maybe using DICT protocol
# - execute this shortcut at app
# - edit shortcuts file/online
# - use sqlite for database
# - suggestions? :)
    def activate(self, leaf):
        shortcut = leaf.object
        args = "xdotool search --class \"eclipse\" windowactivate --sync key --clearmodifiers \"%s\"" % shortcut['keys'].lower()
        argv = ['sh', '-c', args, '--']
        def finish_callback(acommand, stdout, stderr):
            pretty.print_debug(__name__, "%s: stdout: %s, stderr: %s, shortcut: %s" % (acommand, stdout, stderr, shortcut['keys'].lower()))
        utils.AsyncCommand(argv, finish_callback, 15)
        uiutils.show_notification(shortcut['keys'], shortcut['desc'],
            icon_name=self.get_icon_name())

# ROADMAP
# 0.1 show shortcuts for eclipse in notification
# 1.0 show shortcuts for any in notification
# UNSORTED future possible features:
# - read / import shortcuts from server maybe using DICT protocol
# - execute this shortcut at app
# - edit shortcuts file/online
# - use sqlite for database
# - suggestions? :)
Example #12
0
 def operation_error(self, exc_info, cmdtuple):
     "Error when executing action. Return True when error was handled"
     if self._is_nested():
         return
     etype, value, tb = exc_info
     obj, action, iobj = cmdtuple
     # TRANS: When an error occurs in an action to be carried out,
     # TRANS: then this is the heading of the error notification
     return uiutils.show_notification(
             _("Could not to carry out '%s'") % action,
             unicode(value), icon_name="kupfer")
Example #13
0
 def run_on_player(self, player):
     # TODO: more error checking (for example when no track is selected in Banshee)
     meta = player.get_player_property('Metadata')
     if len(meta) > 0:
         pretty.print_debug(__name__, meta)
         title = meta.get('xesam:title', _('unknown'))
         icon = meta.get('mpris:artUrl', 'applications-multimedia')
         ShowPlaying.notification_id \
             = uiutils.show_notification(title,
                                         format_metadata(meta).replace('&', '&'),
                                         icon,
                                         ShowPlayingLeaf.notification_id)
 def run_on_player(self, player):
     # TODO: more error checking (for example when no track is selected in Banshee)
     meta = player.get_player_property('Metadata')
     if len(meta) > 0:
         pretty.print_debug(__name__, meta)
         title = meta.get('xesam:title', _('unknown'))
         icon = meta.get('mpris:artUrl', 'applications-multimedia')
         ShowPlaying.notification_id \
             = uiutils.show_notification(title,
                                         format_metadata(meta).replace('&', '&'),
                                         icon,
                                         ShowPlayingLeaf.notification_id)
Example #15
0
 def operation_error(self, exc_info, cmdtuple):
     "Error when executing action. Return True when error was handled"
     if self._is_nested():
         return
     etype, value, tb = exc_info
     obj, action, iobj = cmdtuple
     # TRANS: When an error occurs in an action to be carried out,
     # TRANS: then this is the heading of the error notification
     return uiutils.show_notification(_("Could not to carry out '%s'") %
                                      action,
                                      unicode(value),
                                      icon_name="kupfer")
Example #16
0
 def run(self):
     facts = get_hamster().GetTodaysFacts()
     total = 0
     current = None
     for f in facts:
         end = f[2]
         if end == 0:
             current = f
             end = get_timestamp()
         duration = end - f[1]
         total += duration
     notification_body = "Total time today: %s" % format_duration(total)
     if current:
         notification_body += "\nCurrent: %s@%s (%s)" % (current[4], current[6],
                                                         format_duration(get_timestamp() - current[1]))
     ShowHamsterInfo.notification_id = uiutils.show_notification('Hamster Info',
                                       notification_body, 'hamster-indicator', ShowHamsterInfo.notification_id)
Example #17
0
 def run(self):
     facts = get_hamster().GetTodaysFacts()
     total = 0
     current = None
     for f in facts:
         end = f[2]
         if end == 0:
             current = f
             end = get_timestamp()
         duration = end - f[1]
         total += duration
     notification_body = "Total time today: %s" % format_duration(total)
     if current:
         notification_body += "\nCurrent: %s@%s (%s)" % (
             current[4], current[6],
             format_duration(get_timestamp() - current[1]))
     ShowHamsterInfo.notification_id = uiutils.show_notification(
         'Hamster Info', notification_body, 'hamster-indicator',
         ShowHamsterInfo.notification_id)
Example #18
0
def show_msg(msg, title='Info'):
    uiutils.show_notification(_(title), _(msg))
Example #19
0
 def run(self):
     song = get_current_song()
     if song is not None:
         uiutils.show_notification(song, icon_name="audio-x-generic")
Example #20
0
 def run(self):
     song = get_current_song()
     uiutils.show_notification(title=song["artist"], text=song["title"])
Example #21
0
 def activate(self, leaf):
     p = subprocess.Popen(["gpg", "--import"], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
     stdout, stderr = p.communicate(leaf.object)
     uiutils.show_notification(_("Import Public Key"), stdout or stderr)
Example #22
0
 def activate(self, leaf):
     shortcut = leaf.object
     uiutils.show_notification(shortcut['keys'], shortcut['desc'],
         icon_name=self.get_icon_name())
Example #23
0
 def success(self, name):
     uiutils.show_notification(_("Unmount finished"),
                               _('"%s" was successfully unmounted') % name,
                               icon_name=Volume.get_icon_name())
Example #24
0
 def run(self):
     song = get_current_song()
     if song is not None:
         uiutils.show_notification(song, icon_name="audio-x-generic")
Example #25
0
def show_msg(msg, title='Info'):
    uiutils.show_notification(_(title), _(msg))
Example #26
0
	def show_notification(self, title, body, icon_name):
		VolumeNotifier.nid = uiutils.show_notification(title, body, icon_name, VolumeNotifier.nid)
 def activate(self, leaf):
     shortcut = leaf.object
     uiutils.show_notification(shortcut['keys'], shortcut['desc'],
         icon_name=self.get_icon_name())
Example #28
0
	def run(self):
		song = get_current_song()
		uiutils.show_notification(title=song["artist"], text=song["title"])