Exemplo n.º 1
0
	def __new__(cls, *a, **k):
		if cls is Indicator:
			import pynotify
			capabilities = set(pynotify.get_server_caps())
			if set(REQUIRED_CAPABILITIES).issubset(capabilities):
				cls = PyNotifyIndicator
			else:
				try:
					import appindicator
				except ImportError:
					raise NoSuitableImplementation("the `appindicator` module was not found (try installing python-appindicator?)\n"
						"And your notification server lacks the required capabilities for this program.\n"
						"I need: %r\nbut you only have: %r" % (REQUIRED_CAPABILITIES, tuple(pynotify.get_server_caps())))
				cls = AppIndicator
		return super(Indicator, cls).__new__(cls)
Exemplo n.º 2
0
 def __init__(self):
   self.conf_dlg = None
   self.conf = {}
   self.load_conf()
   self.TIMER_ID=None
   self.first_update=True
   self.about_dlg = AboutDLG()
   self.statusicon = gtk.StatusIcon()
   self.statusicon.set_visible(False)
   self.statusicon.connect('popup-menu',self.popup_cb)
   self.statusicon.set_title(_("Liber DNS Update"))
   #self.statusicon.set_tooltip(_("liberdns Update"))
   #self.statusicon.set_from_file(os.path.join('/home/ehab/oj/liberdns','liberdns.svg'))
   self.statusicon.set_from_icon_name('liberdns')
   self.statusicon.set_visible(True)
   pynotify.init('Liber DNS Update')
   self.notifycaps = pynotify.get_server_caps ()
   self.notify=pynotify.Notification(_("Liber DNS Update"))
   self.notify.set_property('icon-name', 'liberdns')
   self.notify.set_property('summary', _("Liber DNS Update....") )
   self.notify.set_hint('resident', True)
   self.notify.set_timeout(5000)
   #notify.set_hint('transient', True)
   self.init_menu()
   self.start_timer_cb()
Exemplo n.º 3
0
def initCaps():
    caps = pynotify.get_server_caps()
    if caps is None:
        sys.exit(1)

    for cap in caps:
        capabilities[cap] = True
Exemplo n.º 4
0
def initCaps ():
    caps = pynotify.get_server_caps ()
    if caps is None:
        print "Failed to receive server caps."
        sys.exit()
    for cap in caps:
        capabilities[cap] = True
Exemplo n.º 5
0
    def __init__ (self, replace):
        pynotify.init("ibus")
        self.__bus = ibus.Bus()
        self.__bus.connect("disconnected", gtk.main_quit)
        self.__bus.connect("registry-changed", self.__registry_changed_cb)

        match_rule = "type='signal',\
                      sender='org.freedesktop.IBus',\
                      path='/org/freedesktop/IBus'"
        self.__bus.add_match(match_rule)

        self.__panel = panel.Panel(self.__bus)
        flag = ibus.BUS_NAME_FLAG_ALLOW_REPLACEMENT
        if replace:
            flag = flag | ibus.BUS_NAME_FLAG_REPLACE_EXISTING
        self.__bus.request_name(ibus.IBUS_SERVICE_PANEL, flag)
        self.__bus.get_dbusconn().add_signal_receiver(self.__name_acquired_cb,
                                                      signal_name="NameAcquired")
        self.__bus.get_dbusconn().add_signal_receiver(self.__name_lost_cb,
                                                      signal_name="NameLost")
        self.__notify = pynotify.Notification("IBus", \
                            _("Some input methods have been installed, removed or updated. " \
                            "Please restart ibus input platform."), \
                            "ibus")
        self.__notify.set_timeout(10 * 1000)
        if "actions" in pynotify.get_server_caps():
            self.__notify.add_action("restart", _("Restart Now"), self.__restart_cb, None)
            self.__notify.add_action("ignore", _("Later"), lambda *args: None, None)
Exemplo n.º 6
0
    def __init__(self, specto, notifier):
        global notifyInitialized
        self.specto = specto
        self.notifier = notifier

        if not notifyInitialized:
            pynotify.init(self._notifyRealm)
            notifyInitialized = True

        # Check the features available from the notification daemon
        self.capabilities = {'actions': False,
                        'body': False,
                        'body-hyperlinks': False,
                        'body-images': False,
                        'body-markup': False,
                        'icon-multi': False,
                        'icon-static': False,
                        'sound': False,
                        'image/svg+xml': False,
                        'append': False}
        caps = pynotify.get_server_caps()
        if caps is None:
            print "Failed to receive server caps."
            sys.exit(1)
        for cap in caps:
            self.capabilities[cap] = True
Exemplo n.º 7
0
    def __init__(self, specto, notifier):
        global notifyInitialized
        self.specto = specto
        self.notifier = notifier

        if not notifyInitialized:
            pynotify.init(self._notifyRealm)
            notifyInitialized = True

        # Check the features available from the notification daemon
        self.capabilities = {
            'actions': False,
            'body': False,
            'body-hyperlinks': False,
            'body-images': False,
            'body-markup': False,
            'icon-multi': False,
            'icon-static': False,
            'sound': False,
            'image/svg+xml': False,
            'append': False
        }
        caps = pynotify.get_server_caps()
        if caps is None:
            print "Failed to receive server caps."
            sys.exit(1)
        for cap in caps:
            self.capabilities[cap] = True
def init_pynotify():
    caps = pynotify.get_server_caps()
    if not caps:
        print "Failed to receive server caps."
        sys.exit(True)

    for cap in caps:
        capabilities[cap] = True
def init_pynotify():
    caps = pynotify.get_server_caps()
    if not caps:
        print "Failed to receive server caps."
        sys.exit(True)

    for cap in caps:
        capabilities[cap] = True
Exemplo n.º 10
0
 def _init_pynotify(self):
     logging.info('Configuring pynotify')
     try:
         import pynotify
         pynotify.init('Watson')
         assert pynotify.get_server_caps() is not None
     except ImportError:
         logging.error('pynotify not found; notifications disabled')
Exemplo n.º 11
0
 def _init_pynotify(self):
     logging.info('Configuring pynotify')
     try:
         import pynotify
         pynotify.init('Watson')
         assert pynotify.get_server_caps() is not None
     except ImportError:
         logging.error('pynotify not found; notifications disabled')
Exemplo n.º 12
0
def initCaps ():
  caps = pynotify.get_server_caps ()
  if caps is None:
    print "Failed to receive server caps."
    sys.exit (1)

  for cap in caps:
    capabilities[cap] = True
Exemplo n.º 13
0
def initCaps ():
	caps = pynotify.get_server_caps ()
	if caps is None:
		print "Failed to receive server caps."
		return False

	for cap in caps:
		capabilities[cap] = True
	return True
Exemplo n.º 14
0
    def notify_str(self):
        """Calculate trigger date for contact.

        :rtype: `str`
        :return: Stylised name for use with notifications
        """
        if "body-hyperlinks" in pynotify.get_server_caps():
            name = "<a href='mailto:%s'>%s</a>" % (self.addresses[0], self.name)
        else:
            name = self.name
        return name
Exemplo n.º 15
0
def initCaps ():
    caps = pynotify.get_server_caps ()
    if caps and 'actions' in caps:
        #Adds "Previous" and "Next" buttons in the notification if allowed.
        notification.add_action("previous", "Previous", Prev)
        notification.add_action("next", "Next", Next)
    if caps is None:
            print "Failed to receive server caps."
            sys.exit (1)
 
    for cap in caps:
        capabilities[cap] = True
Exemplo n.º 16
0
    def __init__(self):
        gobject.set_prgname(CONFIGURATION.get("name"))
        gobject.set_application_name("Internet Enabler")

        pynotify.init(CONFIGURATION.get("name"))
        self.notifications_show_actions = 'actions' in pynotify.get_server_caps()
        self.online = False

        self._create_gui()
        self.nm = NetworkListener()
        self.nm.connect("online", lambda x: self.authenticate("Enable"))
        if self.nm.online:
            delay_ms = int(CONFIGURATION.get("delay_ms"))
            if delay_ms >= 0:
                gobject.timeout_add(delay_ms,self.authenticate,"Enable")
Exemplo n.º 17
0
	def __init__ (self):
		sushi.Plugin.__init__(self, "notify")

		pynotify.init("tekka")

		self.caps = pynotify.get_server_caps()

		try:
			self.pixbuf = gtk.icon_theme_get_default().load_icon("tekka",64,0)
		except:
			self.pixbuf = None

		# FIXME
		self.connect_signal("message", self.message_cb)
		self.connect_signal("action", self.action_cb)
Exemplo n.º 18
0
    def __init__(self):
        sushi.Plugin.__init__(self, "notify")

        pynotify.init("tekka")

        self.caps = pynotify.get_server_caps()

        try:
            self.pixbuf = gtk.icon_theme_get_default().load_icon(
                "tekka", 64, 0)
        except:
            self.pixbuf = None

        # FIXME
        self.connect_signal("message", self.message_cb)
        self.connect_signal("action", self.action_cb)
Exemplo n.º 19
0
def printCaps ():
	info = pynotify.get_server_info ()
	print "Name:          " + info["name"]
	print "Vendor:        " + info["vendor"]
	print "Version:       " + info["version"]
	print "Spec. Version: " + info["spec-version"]

	caps = pynotify.get_server_caps ()
	if caps is None:
	        print "Failed to receive server caps."
		sys.exit (1)

	print "Supported capabilities/hints:"
	if capabilities['actions']:
		print "\tactions"
	if capabilities['body']:
		print "\tbody"
	if capabilities['body-hyperlinks']:
		print "\tbody-hyperlinks"
	if capabilities['body-images']:
		print "\tbody-images"
	if capabilities['body-markup']:
		print "\tbody-markup"
	if capabilities['icon-multi']:
		print "\ticon-multi"
	if capabilities['icon-static']:
		print "\ticon-static"
	if capabilities['sound']:
		print "\tsound"
	if capabilities['image/svg+xml']:
		print "\timage/svg+xml"
	if capabilities['x-canonical-private-synchronous']:
		print "\tx-canonical-private-synchronous"
	if capabilities['x-canonical-append']:
		print "\tx-canonical-append"
	if capabilities['x-canonical-private-icon-only']:
		print "\tx-canonical-private-icon-only"
	if capabilities['x-canonical-truncation']:
		print "\tx-canonical-truncation"

	print "Notes:"
	if info["name"] == "notify-osd":
		print "\tx- and y-coordinates hints are ignored"
		print "\texpire-timeout is ignored"
		print "\tbody-markup is accepted but filtered"
	else:
		print "\tnone"
    def show(self):
        """Displays a notification for icecat.

        Adds actions open and opendir if available
        
        """
        caps = pynotify.get_server_caps()
        if caps is None:
            raise GalagoNotRunningException

        body = BODY % {'title': self.title,
                       'location': self.location}
        self.notif = pynotify.Notification(SUMMARY,
                                      body,
                                      get_icon(),
                                      )
        self.notif.connect('closed', self._cleanup)
        self.notif.set_hint_string("category", "transfer.complete")
        # Note: This won't work until we get the pynotify instance to be
        # static through calls
        self.notif.set_hint_string("x-canonical-append", "allowed")

        if 'actions' in caps:
            try:
                call([OPEN_COMMAND, '--version'])
            except OSError:
                LOG.warn(_("xdg-open was not found"))
                xdg_exists = False
            else:
                xdg_exists = True
                self.notif.add_action("open",
                                    _("Open"),
                                    self.open_file)
                self.notif.add_action("opendir",
                                    _("Open Directory"),
                                    self.open_directory)
        else:
            xdg_exists = False

        LOG.info(_("Displaying notification"))
        if not self.notif.show():
            raise GalagoNotRunningException(_("Could not display notification"))
        if xdg_exists:
            gtk.main()
Exemplo n.º 21
0
def initCaps ():
	capabilities = {'actions':             False,
	'body':                False,
	'body-hyperlinks':     False,
	'body-images':         False,
	'body-markup':         False,
	'icon-multi':          False,
	'icon-static':         False,
	'sound':               False,
	'image/svg+xml':       False,
	'private-synchronous': False,
	'append':              False,
	'private-icon-only':   False}
	caps = pynotify.get_server_caps ()
	if caps is None:
        	print "Failed to receive server caps."
		gtk.main_quit()
	for cap in caps:
		capabilities[cap] = True
Exemplo n.º 22
0
    def __init__(self):

	self.lib_path = os.path.join(os.path.dirname(__file__)) ## get libfacebooknotify path

	self.config = ConfigParser.SafeConfigParser()
	self.config.optionxform = str ## dont save as lowercase !!!!
	self.config.read(self.lib_path + '/config.cfg')

	self.HISTORY_MAX = int(self.config.get('MY_CONFIG', 'HISTORY_MAX'))
	self.SECONDS_UPDATE_FREQ = int(self.config.get('MY_CONFIG', 'SECONDS_UPDATE_FREQ'))

	self.LOGIN_HIGHT = int(self.config.get('MY_CONFIG', 'LOGIN_HIGHT'))
	self.LOGIN_WIDTH = int(self.config.get('MY_CONFIG', 'LOGIN_WIDTH'))

    	pynotify.init(APP_NAME)

        self.indicator = indicate.Indicator()
        self.indicator.set_property("subtype", "im")
        self.indicator.connect("user-display", self.mmClicked)
        self.indicator.set_property("draw-attention", "true")

        self._create_gui()
        self._fbcm = FacebookCommunicationManager()
        self._fbcm.start()
        self._sb = SimpleBrowser()
        self._sb.connect("delete-event", self._login_window_closed)

        self._uid = None
        self._tried_permissions = False
        self._friends = []
        self._friend_index = {}
        self._first_friends_query = True
        self._notifications = {}
        self._notifications_first_query = True
        self._notifications_show_actions = 'actions' in pynotify.get_server_caps()
        self._notificationslist = {}
        self._notifications_lasttime = 0
        self._album_index = {}
        self._first_album_query = True
        self._state = 0

        gobject.timeout_add_seconds(2, self._login_start)
    def __init__(self):
        pynotify.init(self.APP_NAME)
        self._create_gui()
        self._fbcm = FacebookCommunicationManager()
        self._fbcm.start()
        self._sb = SimpleBrowser()
        self._sb.connect("delete-event", self._login_window_closed)

        self._uid = None
        self._friends = []
        self._friend_index = {}
        self._first_friends_query = True
        self._notifications = {}
        self._notifications_first_query = True
        self._notifications_show_actions = 'actions' in pynotify.get_server_caps()
        self._album_index = {}
        self._first_album_query = True
        self._state = 0

        gobject.timeout_add_seconds(2, self._login_start)
    def configure(self, parent):
        """ Show the configuration window """
        if self.cfgWin is None:
            import pynotify

            self.cfgWin = gui.window.Window('DesktopNotification.glade', 'vbox1', __name__, MOD_L10N, 355, 345)
            self.cfgWin.getWidget('btn-ok').connect('clicked', self.onBtnOk)
            self.cfgWin.getWidget('btn-help').connect('clicked', self.onBtnHelp)
            self.cfgWin.getWidget('btn-cancel').connect('clicked', lambda btn: self.cfgWin.hide())

            if 'actions' not in pynotify.get_server_caps():
                self.cfgWin.getWidget('chk-skipTrack').set_sensitive(False)

        if not self.cfgWin.isVisible():
            self.cfgWin.getWidget('txt-title').set_text(prefs.get(__name__, 'title', PREFS_DEFAULT_TITLE))
            self.cfgWin.getWidget('spn-duration').set_value(prefs.get(__name__, 'timeout', PREFS_DEFAULT_TIMEOUT))
            self.cfgWin.getWidget('txt-body').get_buffer().set_text(prefs.get(__name__, 'body', PREFS_DEFAULT_BODY))
            self.cfgWin.getWidget('chk-skipTrack').set_active(prefs.get(__name__, 'skip-track', PREFS_DEFAULT_SKIP_TRACK))
            self.cfgWin.getWidget('btn-ok').grab_focus()

        self.cfgWin.show()
Exemplo n.º 25
0
  def notify(title, text, icon = None, timeout = None, iconsize = 48):
    if icon is None:
      icon = resources.get_ui_asset("gwibber.svg")
    
    caps = pynotify.get_server_caps()
    
    notification = pynotify.Notification(title, text)

    try:
      pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon, iconsize, iconsize)
      notification.set_icon_from_pixbuf(pixbuf)
    except glib.GError as e:
      log.logger.error("Avatar failure - %s - %s", icon, e.message)
      resources.del_avatar(icon)

    if timeout:
      notification.set_timeout(timeout)

    if "x-canonical-append" in caps:
      notification.set_hint('x-canonical-append', 'allowed')

    return notification.show()
Exemplo n.º 26
0
    def __init__(self):
        pynotify.init(APP_NAME)
        self._create_gui()
        self._fbcm = comm.FacebookCommunicationManager()
        self._fbcm.start()
        self._sb = SimpleBrowser()
        self._sb.connect("delete-event", self._login_window_closed)

        self._uid = None
        self._friends = []
        self._friend_index = {}
        self._first_friends_query = True
        self._notifications = {}
        self._notifications_first_query = True
        self._notifications_show_actions = 'actions' in pynotify.get_server_caps(
        )
        self._notificationslist = {}
        self._notifications_lasttime = 0
        self._album_index = {}
        self._first_album_query = True
        self._state = 0

        gobject.timeout_add_seconds(2, self._login_start)
Exemplo n.º 27
0
def usage_note(message, title=None, level=warn, icon=None):
    """Display a usage notification

    :param str message: Message to display
    :type title: ``str`` or ``None`
    :param title: Title for notification popup
    :param func level: Function to display text message with
    :param str icon: Icon to use for notification popup
    """

    message = message.replace("%prog", sys.argv[0])
    if not title:
        title = "%%prog %s" % _version.dotted
    title = title.replace("%prog", os.path.basename(sys.argv[0]))
    print(level(message))
    if "icon-static" in pynotify.get_server_caps():
        if not icon:
            if level == success:
                icon = find_app_icon()
            elif level == warn:
                icon = "stock_dialog-warning"
            elif level == fail:
                icon = "error"
    else:
        icon = None
    # pylint: disable-msg=E1101
    note = pynotify.Notification(title, message, icon)
    if level == warn:
        note.set_urgency(pynotify.URGENCY_LOW)
    elif level == fail:
        note.set_urgency(pynotify.URGENCY_CRITICAL)
        note.set_timeout(pynotify.EXPIRES_NEVER)
    # pylint: enable-msg=E1101
    if not note.show():
        raise OSError("Notification failed to display!")
    return errno.EPERM
Exemplo n.º 28
0
def printCaps():
    info = pynotify.get_server_info()
    print "Name:          " + info["name"]
    print "Vendor:        " + info["vendor"]
    print "Version:       " + info["version"]
    print "Spec. Version: " + info["spec-version"]

    caps = pynotify.get_server_caps()
    if caps is None:
        print "Failed to receive server caps."
        sys.exit(1)

    print "Supported capabilities/hints:"
    if capabilities['actions']:
        print "\tactions"
    if capabilities['body']:
        print "\tbody"
    if capabilities['body-hyperlinks']:
        print "\tbody-hyperlinks"
    if capabilities['body-images']:
        print "\tbody-images"
    if capabilities['body-markup']:
        print "\tbody-markup"
    if capabilities['icon-multi']:
        print "\ticon-multi"
    if capabilities['icon-static']:
        print "\ticon-static"
    if capabilities['sound']:
        print "\tsound"
    if capabilities['sound-file']:
        print "\tsound-file"
    if capabilities['suppress-sound']:
        print "\tsuppress-sound"
    if capabilities['urgency']:
        print "\turgency"
    if capabilities['value']:
        print "\tvalue"
    if capabilities['x-canonical-value-bar-tint']:
        print "\tx-canonical-value-bar-tint"
    if capabilities['image/svg+xml']:
        print "\timage/svg+xml"
    if capabilities['x-canonical-private-synchronous']:
        print "\tx-canonical-private-synchronous"
    if capabilities['x-canonical-private-icon-only']:
        print "\tx-canonical-private-icon-only"
    if capabilities['x-canonical-truncation']:
        print "\tx-canonical-truncation"
    if capabilities['x-canonical-snap-decisions']:
        print "\tx-canonical-snap-decisions"
    if capabilities['x-canonical-snap-decisions-timeout']:
        print "\tx-canonical-snap-decisions-timeout"
    if capabilities['x-canonical-snap-decisions-swipe']:
        print "\tx-canonical-snap-decisions-swipe"
    if capabilities['x-canonical-switch-to-application']:
        print "\tx-canonical-switch-to-application"
    if capabilities['x-canonical-secondary-icon']:
        print "\tx-canonical-secondary-icon"
    if capabilities['x-canonical-private-affirmative-tint']:
        print "\tx-canonical-private-affirmative-tint"
    if capabilities['x-canonical-private-rejection-tint']:
        print "\tx-canonical-private-rejection-tint"
    if capabilities['x-canonical-private-menu-model']:
        print "\tx-canonical-private-menu-model"
    if capabilities['x-canonical-non-shaped-icon']:
        print "\tx-canonical-non-shaped-icon"

    print "Notes:"
    if info["name"] == "notify-osd":
        print "\tx- and y-coordinates hints are ignored"
        print "\texpire-timeout is ignored"
        print "\tbody-markup is accepted but filtered"
    else:
        print "\tnone"
Exemplo n.º 29
0
    def NewPrinter (self, status, name, mfg, mdl, des, cmd):
        if name.find("/") >= 0:
            # name is a URI, no queue was generated, because no suitable
            # driver was found
            title = _("Missing printer driver")
            devid = "MFG:%s;MDL:%s;DES:%s;CMD:%s;" % (mfg, mdl, des, cmd)
            if (mfg and mdl) or des:
                if (mfg and mdl):
                    device = "%s %s" % (mfg, mdl)
                else:
                    device = des
                text = _("No printer driver for %s.") % device
            else:
                text = _("No driver for this printer.")
            n = pynotify.Notification (title, text, 'printer')
            if "actions" in pynotify.get_server_caps():
                n.set_urgency (pynotify.URGENCY_CRITICAL)
                n.set_timeout (pynotify.EXPIRES_NEVER)
                n.add_action ("setup-printer", _("Search"),
                              lambda x, y:
                                  self.setup_printer (x, y, name, devid))
            else:
                self.setup_printer (None, None, name, devid)

        else:
            # name is the name of the queue which hal_lpadmin has set up
            # automatically.
            c = cups.Connection ()
            try:
                printer = c.getPrinters ()[name]
            except KeyError:
                return

            try:
                filename = c.getPPD (name)
            except cups.IPPError:
                return

            del c

            # Check for missing packages
            cups.ppdSetConformance (cups.PPD_CONFORM_RELAXED)
            ppd = cups.PPD (filename)
            import os
            os.unlink (filename)
            import sys
            sys.path.append (APPDIR)
            import cupshelpers
            (missing_pkgs,
             missing_exes) = cupshelpers.missingPackagesAndExecutables (ppd)

            from cupshelpers.ppds import ppdMakeModelSplit
            (make, model) = ppdMakeModelSplit (printer['printer-make-and-model'])
            driver = make + " " + model
            if status < self.STATUS_GENERIC_DRIVER:
                title = _("Printer added")
            else:
                title = _("Missing printer driver")

            if len (missing_pkgs) > 0:
                pkgs = reduce (lambda x,y: x + ", " + y, missing_pkgs)
                title = _("Install printer driver")
                text = _("`%s' requires driver installation: %s.") % (name, pkgs)
                n = pynotify.Notification (title, text)
                import installpackage
                if "actions" in pynotify.get_server_caps():
                    try:
                        self.packagekit = installpackage.PackageKit ()
                        n.set_timeout (pynotify.EXPIRES_NEVER)
                        n.add_action ("install-driver", _("Install"),
                                      lambda x, y:
                                          self.install_driver (x, y,
                                                               missing_pkgs))
                    except:
                        pass
                else:
                    try:
                        self.packagekit = installpackage.PackageKit ()
                        self.packagekit.InstallPackageName (0, 0,
                                                            missing_pkgs[0])
                    except:
                        pass

            elif status == self.STATUS_SUCCESS:
                devid = "MFG:%s;MDL:%s;DES:%s;CMD:%s;" % (mfg, mdl, des, cmd)
                text = _("`%s' is ready for printing.") % name
                n = pynotify.Notification (title, text)
                if "actions" in pynotify.get_server_caps():
                    n.set_urgency (pynotify.URGENCY_NORMAL)
                    n.add_action ("test-page", _("Print test page"),
                                  lambda x, y:
                                      self.print_test_page (x, y, name))
                    n.add_action ("configure", _("Configure"),
                                  lambda x, y: self.configure (x, y, name))
            else: # Model mismatch
                devid = "MFG:%s;MDL:%s;DES:%s;CMD:%s;" % (mfg, mdl, des, cmd)
                text = (_("`%s' has been added, using the `%s' driver.") %
                        (name, driver))
                n = pynotify.Notification (title, text, 'printer')
                if "actions" in pynotify.get_server_caps():
                    n.set_urgency (pynotify.URGENCY_CRITICAL)
                    n.add_action ("test-page", _("Print test page"),
                                  lambda x, y:
                                      self.print_test_page (x, y, name, devid))
                    n.add_action ("find-driver", _("Find driver"),
                                  lambda x, y: 
                                  self.find_driver (x, y, name, devid))
                    n.set_timeout (pynotify.EXPIRES_NEVER)
                else:
                    self.configure (None, None, name)

        self.timeout_ready ()
        n.show ()
        self.notification = n
Exemplo n.º 30
0
	def obtener_capacidades(self):
		self.capacidades = {};
		capacidades = pynotify.get_server_caps()
		for i in capacidades:
			self.capacidades[i] = True
Exemplo n.º 31
0
	def __new__(cls, summary, message, timeout=-1, actions= None, actions_cb=None, pixbuf=None, status_icon=None):
		if not "actions" in pynotify.get_server_caps():
			if actions != None:
				return NotificationDialog(summary, message, timeout, actions, actions_cb, pixbuf, status_icon)
				
		return NotificationBubble(summary, message, timeout, actions, actions_cb, pixbuf, status_icon)
Exemplo n.º 32
0
	def actions_supported():
		return "actions" in pynotify.get_server_caps()
Exemplo n.º 33
0
def main():
    socket.setdefaulttimeout(SOCKET_TIMEOUT)

    parser = optparse.OptionParser()
    parser.add_option('--no-systray-icon', dest='systray_icon',
                      action='store_false', default=True,
                      help='don\'t show the systray icon')
    parser.add_option('-i', '--update-interval',
                      action='store', type='int', dest='interval', default=300,
                      help='set the feed update interval (in seconds)')
    parser.add_option('-m', '--max-items',
                      action='store', type='int', dest='max_items', default=3,
                      help='maximum number of items to be displayed per update')
    parser.add_option('-t', '--display-timeout',
                      action='store', type='int', dest='timeout',
                      help='set the notification display timeout (in seconds)')
    parser.add_option('-b', '--blog',
                      action='store_true', dest='blog', default=False,
                      help='enable notifications from GitHub\'s blog')
    parser.add_option('-a', '--important_authors',
                      action='store_true', dest='important_authors', default=False,
                      help='only consider notifications from important authors')
    parser.add_option('-o', '--organizations',
                      action='store_true', dest='organizations', default=True,
                      help='consider notifications of all user\'s organizations')
    parser.add_option('-k', '--blacklist_organizations',
                      action='store_true', dest='blacklist_organizations',
                      default=False, help='filter out blacklisted organizations')
    parser.add_option('-p', '--important_projects',
                      action='store_true', dest='important_projects', default=False,
                      help='only consider notifications from important projects')
    parser.add_option('-u', '--blacklist_authors',
                      action='store_true', dest='blacklist_authors', default=False,
                      help='filter out blacklisted authors')
    parser.add_option('-r', '--blacklist_projects',
                      action='store_true', dest='blacklist_projects', default=False,
                      help='filter out blacklisted projects')
    parser.add_option('-n', '--new-config',
                      action='store_true', dest='new_config', default=False,
                      help='create a new config.cfg at ~/.githubnotifier/')
    parser.add_option('-v', '--verbose',
                      action='store_true', dest='verbose', default=False,
                      help='enable verbose logging')
    parser.add_option('-d', '--debug',
                      action='store_true', dest='debug', default=False,
                      help='enable debug logging')
    (options, args) = parser.parse_args()

    # Create logger
    logger = logging.getLogger('github-notifier')
    handler = logging.StreamHandler()

    if options.debug:
        logger.setLevel(logging.DEBUG)
    elif options.verbose:
        logger.setLevel(logging.INFO)
    else:
        logger.setLevel(logging.WARNING)

    formatter = logging.Formatter('[%(levelname)s] %(asctime)s\n%(message)s',
                                    datefmt='%d %b %H:%M:%S')
    handler.setFormatter(formatter)
    logger.addHandler(handler)

    if options.interval <= 0:
        logger.error('The update interval must be > 0')
        sys.exit(1)

    if options.max_items <= 0:
        logger.error('The maximum number of items must be > 0')
        sys.exit(1)

    if not os.path.isdir(CACHE_DIR):
        logger.warning('Making the cache directory {0}'.format(CACHE_DIR))
        os.makedirs(CACHE_DIR)

    if not os.path.isfile(CONFIG_FILE) or options.new_config:
        logger.warning('Making the config file {0}'.format(CONFIG_FILE))
        config_file = open(CONFIG_FILE, 'w')
        config_file.write('[important]  # Separated by commas, projects (can' \
                          ' be either <user>/<project> or <project>)\n')
        config_file.write('authors=\nprojects=')
        config_file.write('\n[blacklist]  # Separated by commas, projects (can' \
                          ' be either <user>/<project> or <project>)\n')
        config_file.write('authors=\nprojects=')
        config_file.write('\norganizations=')
        config_file.close()

    if not pynotify.init('github-notifier'):
        logger.error('Couldn\'t initialize pynotify')
        sys.exit(1)

    server_caps = pynotify.get_server_caps()
    if 'body-hyperlinks' in server_caps:
        logger.info('github-notifier is capable of using hyperlinks')
        hyperlinks = True
    else:
        logger.info('github-notifier is not capable of using hyperlinks')
        hyperlinks = False

    (user, token) = get_github_config()
    if not user or not token:
        logger.error(
            '''Could not get GitHub username and token from git config
            you can run
               $git config --global github.user <username>
            and
               $git config --global github.token <token>
            to configure it.\n
            for more information about token check the link https://help.github.com/articles/creating-an-access-token-for-command-line-use''')
        sys.exit(1)

    if options.systray_icon:
        logger.info('Creating system tray icon')
        gtk.gdk.threads_init()

    # Start a new thread to check for feed updates
    upd = GithubFeedUpdatherThread(user, token, options.interval,
                                   options.max_items, hyperlinks, options.blog,
                                   options.important_authors,
                                   options.important_projects,
                                   options.blacklist_authors,
                                   options.blacklist_projects,
                                   options.organizations,
                                   options.blacklist_organizations)
    upd.setDaemon(True)
    upd.start()

    DISPLAY_INTERVAL = 1  # In seconds
    if options.systray_icon:
        gui = GtkGui(upd)
        gobject.timeout_add(DISPLAY_INTERVAL * 1000, display_notifications,
                            options.timeout)
        gtk.main()
    else:
        while True:
            display_notifications(options.timeout)
            time.sleep(DISPLAY_INTERVAL)
Exemplo n.º 34
0
#!/usr/bin/env python

import pygtk

pygtk.require('2.0')
import pynotify
import sys

if __name__ == '__main__':
    if not pynotify.init("TestCaps"):
        sys.exit(1)

    info = pynotify.get_server_info()

    print "Name:         " + info["name"]
    print "Vendor:       " + info["vendor"]
    print "Version:      " + info["version"]
    print "Spec Version: " + info["spec-version"]
    print "Capabilities:"

    caps = pynotify.get_server_caps()

    if caps is None:
        print "Failed to receive server caps."
        sys.exit(1)

    for cap in caps:
        print "\t" + cap
Exemplo n.º 35
0
def main():
    socket.setdefaulttimeout(SOCKET_TIMEOUT)

    parser = optparse.OptionParser()
    parser.add_option('--no-systray-icon', dest='systray_icon',
                      action='store_false', default=True,
                      help='don\'t show the systray icon')
    parser.add_option('-i', '--update-interval',
                      action='store', type='int', dest='interval', default=300,
                      help='set the feed update interval (in seconds)')
    parser.add_option('-m', '--max-items',
                      action='store', type='int', dest='max_items', default=3,
                      help='maximum number of items to be displayed per update')
    parser.add_option('-t', '--display-timeout',
                      action='store', type='int', dest='timeout',
                      help='set the notification display timeout (in seconds)')
    parser.add_option('-v', '--verbose',
                      action='store_true', dest='verbose', default=False,
                      help='enable verbose logging')
    (options, args) = parser.parse_args()

    if options.interval <= 0:
        print >>sys.stderr, 'Error: the update interval must be > 0.'
        sys.exit(1)

    if options.max_items <= 0:
        print >>sys.stderr, 'Error: the maximum number of items must be > 0.'
        sys.exit(1)

    log = logging.getLogger('github-notifier')
    log.addHandler(logging.StreamHandler())
    if options.verbose:
        log.setLevel(logging.INFO)
    else:
        log.setLevel(logging.ERROR)

    if not os.path.isdir(CACHE_DIR):
        os.makedirs(CACHE_DIR)

    if not pynotify.init('github-notifier'):
        print >>sys.stderr, 'Error: couldn\'t initialize pynotify.'
        sys.exit(1)

    server_caps = pynotify.get_server_caps()

    if 'body-hyperlinks' in server_caps:
        hyperlinks = True
    else:
        hyperlinks = False

    (user, token) = get_github_config()
    if not user or not token:
        print >>sys.stderr, 'Error: couldn\'t get github config.'
        sys.exit(1)

    if options.systray_icon:
        gtk.gdk.threads_init()

    # Start a new thread to check for feed updates
    upd = GithubFeedUpdatherThread(user, token, options.interval,
                                   options.max_items, hyperlinks)
    upd.setDaemon(True)
    upd.start()

    DISPLAY_INTERVAL = 1 # seconds
    if options.systray_icon:
        gui = GtkGui()
        gobject.timeout_add(DISPLAY_INTERVAL * 1000, display_notifications,
                            options.timeout)
        gtk.main()
    else:
        while True:
            display_notifications(options.timeout)
            time.sleep(DISPLAY_INTERVAL)
Exemplo n.º 36
0
        if not title:
            _title = ''
        else:
            _title = title

        notification = pynotify.Notification(_title, _text)
        notification.set_timeout(timeout*1000)

        notification.set_category(event_type)
        notification.set_data('event_type', event_type)
        notification.set_data('jid', jid)
        notification.set_data('account', account)
        notification.set_data('msg_type', msg_type)
        notification.set_property('icon-name', path_to_image)
        if 'actions' in pynotify.get_server_caps():
            notification.add_action('default', 'Default Action',
                    on_pynotify_notification_clicked)

        try:
            notification.show()
            return
        except gobject.GError, e:
            # Connection to notification-daemon failed, see #2893
            gajim.log.debug(str(e))

    # Either nothing succeeded or the user wants old-style notifications
    instance = PopupNotificationWindow(event_type, jid, account, msg_type,
        path_to_image, title, text, timeout)
    gajim.interface.roster.popup_notification_windows.append(instance)
Exemplo n.º 37
0
'''
this is a part of the heybuddy project
copyright 2010 jezra lickter http://www.jezra.net
'''
try:
	import pynotify
	has_pynotify = True
	notifier_reads_markup = 'body-markup' in pynotify.get_server_caps()
except:
	has_pynotify = False
	notifier_reads_markup = False



class Notify():
	def __init__(self):
		pynotify.init('Heybuddy')

	def notify_send(self,summary,content,image):
		notify=pynotify.Notification(summary,content,image)
		if not notify.show():
			print _("Failed to show notification")

	def notify_updates(self,num_updates,avatar):
		summary=_("New updates in timeline")
		content=_("%d new dents in timeline") % (num_updates)
		self.notify_send(summary,content,avatar)

	def notify_reply(self,name,message,image):
		summary=_("%s wrote:") % (name)
		self.notify_send(summary,message,image)
Exemplo n.º 38
0
#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import pynotify
import sys

if __name__ == '__main__':
    if not pynotify.init("TestCaps"):
        sys.exit(1)

    info = pynotify.get_server_info()

    print "Name:         " + info["name"]
    print "Vendor:       " + info["vendor"]
    print "Version:      " + info["version"]
    print "Spec Version: " + info["spec-version"]
    print "Capabilities:"

    caps = pynotify.get_server_caps()

    if caps is None:
        print "Failed to receive server caps."
        sys.exit(1)

    for cap in caps:
        print "\t" + cap
Exemplo n.º 39
0
def cached_notify(title, body, icon):
    """A function to replace pynotify.notify if the 'x-canonical-append'
    capability is not provided.
    """
    n = cache.get_notification(title)
    if n:
        n.close()
        n.update(title, n.props.body + '\n' + body, icon)
    else:
        n = pynotify.Notification(title, body, icon)
        cache.add_notification(n, title)
    n.show()


append = 'x-canonical-append' in pynotify.get_server_caps()
if not append:
    cache = NotificationCache()
    notify = cached_notify


def shutdownNotify(host):
    notify(_("Shut down:"), "%s" % (host),
           os.path.abspath("images/shutdown.svg"))


def loginNotify(user, host):
    notify(_("Connected:"),
           _("%(user)s on %(host)s") % {
               "user": user,
               "host": host