コード例 #1
0
ファイル: __init__.py プロジェクト: thnguyn2/ECE_527_MP
  def notify(title, text, icon = None, timeout = None, iconsize = 48):
    if icon is None:
      icon = resources.get_ui_asset("icons/hicolor/scalable/apps/gwibber.svg")

    if icon is None:
      return
    
    caps = Notify.get_server_caps()
    
    notification = Notify.Notification.new(title, text, "gwibber")

    pixbuf = None
    try:
      pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(icon, iconsize, iconsize)
    except GLib.Error as e:
      logger.error("Avatar failure - %s - %s", icon, e.message)
      resources.del_avatar(icon)

    if pixbuf:
      try:
        notification.set_icon_from_pixbuf(pixbuf)
      except GLib.Error as e:
        logger.error("Notification failure - %s", e.message)

    if timeout:
      notification.set_timeout(timeout)

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

    try:
      notification.show ()
    except:
      logger.error("Notification failed")
    return
コード例 #2
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()