Пример #1
0
 def update(self, lock):
     """
     Check if an error sound has to be played or if a watch has to be flagged updated.
     """
     #play error sound
     if self.error == True and self.specto.specto_gconf.get_entry("use_problem_sound"):
         problem_sound = self.specto.specto_gconf.get_entry("problem_sound")
         gnome.sound_play(problem_sound)
         pop_toast = self.specto.specto_gconf.get_entry("pop_toast")  
         if (pop_toast == True) and (self.specto.GTK):
             NotificationToast(self.specto, _("The watch, <b>%s</b>, has a problem. You may need to check the error log.") % self.name, self.specto.icon_theme.load_icon("error", 64, 0), urgency="critical")#fixme: not sure if that's possible, but this has no self.tray_x, self.tray_y, because we cannot be sure that the tray icon is actually displayed already
     
     #call update function if watch was updated
     if self.actually_updated:#we want to notify, but ONLY if it has not been marked as updated already
         try:
             self.specto.toggle_updated(self.id) #call the main function to update the notifier entry. We need to use a try statement in case the watch was already toggled in the notifier entry.
         except: 
             if self.specto.DEBUG : self.specto.logger.log(_("Watch \"%s\" is already marked as updated in the notifier") % self.name, "info", self.__class__)
         else: pass
         self.specto.count_updated_watches()
         self.notify()
         self.updated = True
         self.actually_updated = False
     self.timer_id = gobject.timeout_add(self.refresh, self.thread_update)
     lock.release()
Пример #2
0
def sound(button):
    """ Gtk callback for all button """
    playFile = "%s/plugin/%s/sounds/%s.wav" % (os.getcwd(), ui.get_widget('selectPlugin').get_active_text(), button.get_name())
    print playFile
    if SOUND_ENV == 'gnome':
        gnome.sound_play(playFile)
    else:
        playWave(playFile)
Пример #3
0
 def play_sound(self, path):
     try:
         # Gnome
         import gnome
         gnome.sound_init('localhost')
         gnome.sound_play(path)
     except ImportError:
         try:
             # Windows
             import winsound
             winsound.PlaySound(path, winsound.SND_FILENAME)
         except ImportError:
             # Unable to play sound
             logging.error('Unable to play sound. No player found.')
Пример #4
0
    def update(self, lock):
        """
        Check if an error sound has to be played or if a watch has to be flagged updated.
        """
        #play error sound
        if self.error == True and self.specto.specto_gconf.get_entry(
                "use_problem_sound"):
            problem_sound = self.specto.specto_gconf.get_entry("problem_sound")
            gnome.sound_play(problem_sound)
            pop_toast = self.specto.specto_gconf.get_entry("pop_toast")
            if (pop_toast == True) and (self.specto.GTK):
                NotificationToast(
                    self.specto,
                    _("The watch, <b>%s</b>, has a problem. You may need to check the error log."
                      ) % self.name,
                    self.specto.icon_theme.load_icon("error", 64, 0),
                    urgency="critical"
                )  #fixme: not sure if that's possible, but this has no self.tray_x, self.tray_y, because we cannot be sure that the tray icon is actually displayed already

        #call update function if watch was updated
        if self.actually_updated:  #we want to notify, but ONLY if it has not been marked as updated already
            try:
                self.specto.toggle_updated(
                    self.id
                )  #call the main function to update the notifier entry. We need to use a try statement in case the watch was already toggled in the notifier entry.
            except:
                if self.specto.DEBUG:
                    self.specto.logger.log(
                        _("Watch \"%s\" is already marked as updated in the notifier"
                          ) % self.name, "info", self.__class__)
            else:
                pass
            self.specto.count_updated_watches()
            self.notify()
            self.updated = True
            self.actually_updated = False
        self.timer_id = gobject.timeout_add(self.refresh, self.thread_update)
        lock.release()
Пример #5
0
    def notify(self):
        """
        Notify the user when a watch was updated.
        """
        global _
        if self.specto.DEBUG or not self.specto.GTK:
            self.specto.logger.log(_("Watch \"%s\" updated!") % self.name, "info", self.__class__)
        #play a sound   
        update_sound = self.specto.specto_gconf.get_entry("update_sound")
        if self.specto.specto_gconf.get_entry("use_update_sound"):
            gnome.sound_play(update_sound)
        #determine if libnotify support is to be used
        pop_toast = self.specto.specto_gconf.get_entry("pop_toast")
        if (pop_toast == True) and (self.specto.GTK):
            sleep(0.5)#this is an important hack :) the reason why there is a sleep of half a second is to leave time for the tray icon to appear before getting its coordinates
            self.tray_x = self.specto.tray.get_x()
            self.tray_y = self.specto.tray.get_y()

            if self.type==0:#web
                NotificationToast(self.specto, _("The website, <b>%s</b>, has been updated.") % str(self.name), self.specto.icon_theme.load_icon("applications-internet", 64, 0), self.tray_x, self.tray_y, name=self.name)
            elif self.type==1:#email

                if self.prot==0:#pop3 account
                    notification_toast = i18n._translation.ungettext(\
                    # English singular form:
                    (_("Your email account, <b>%s</b>, has <b>%d</b> new mail.") % (self.name, self.newMsg)),\
                    # English plural form:
                    (_("Your email account, <b>%s</b>, has <b>%d</b> new unread mails, totalling %s") % (self.name, self.newMsg, self.oldMsg)),\
                    self.oldMsg)
                elif self.prot==1:#imap account
                    notification_toast = _("Your email account, <b>%s</b>, has new mail.") % str(self.name)
                elif self.prot==2:#gmail
                    notification_toast = i18n._translation.ungettext(\
                        # English singular form:
                        (_("Your email account, <b>%s</b>, has <b>%d</b> new mail.") % (self.name, self.newMsg)),\
                        # English plural form:
                        (_("Your email account, <b>%s</b>, has <b>%d</b> new unread mails, totalling %s") % (self.name, self.newMsg, self.oldMsg)),\
                        self.oldMsg)
                    
                if notification_toast:
                    NotificationToast(self.specto, notification_toast, self.specto.icon_theme.load_icon("emblem-mail", 64, 0), self.tray_x, self.tray_y, name=self.name)

            elif self.type==2:#folder
                NotificationToast(self.specto, _("The file/folder, <b>%s</b>, has been updated.") % self.name, self.specto.icon_theme.load_icon("folder", 64, 0), self.tray_x, self.tray_y, name=self.name)
            elif self.type==3:#process
                if self.running==False:
                    NotificationToast(self.specto, _("The process, <b>%s</b>, has stopped.") % self.name, self.specto.icon_theme.load_icon("applications-system", 64, 0), self.tray_x, self.tray_y)
                elif self.running==True:
                    NotificationToast(self.specto, _("The process, <b>%s</b>, has started.") % self.name, self.specto.icon_theme.load_icon("applications-system", 64, 0), self.tray_x, self.tray_y)
                else:
                    self.specto.logger.log(("This is a bug. The watch" + str(self.name) + "'s value for self.running is" + str(self.running)), "debug", self.__class__)
            elif self.type==4:#port
                if self.running==False:
                    NotificationToast(self.specto, _("The connection, <b>%s</b>, was closed.") % self.name, self.specto.icon_theme.load_icon("network-offline", 64, 0), self.tray_x, self.tray_y)
                elif self.running==True:
                    NotificationToast(self.specto, _("The connection, <b>%s</b>, was established.") % self.name, self.specto.icon_theme.load_icon("network-transmit-receive", 64, 0), self.tray_x, self.tray_y)
                else:
                    self.specto.logger.log(("This is a bug. The watch" + str(self.name) + "'s value for self.running is" + str(self.running)), "debug", self.__class__)
            elif self.type==5: #google reader
                notification_toast = i18n._translation.ungettext(\
                    # English singular form:
                    (_("Your Google Reader watch, <b>%s</b>, has <b>%d</b> new message.") % (self.name, self.newMsg)),\
                    # English plural form:
                    (_("Your Google Reader watch, <b>%s</b>, has <b>%d</b> new messages, totalling %s") % (self.name, self.newMsg, self.oldMsg)),\
                    self.oldMsg)
                
                if notification_toast:
                    NotificationToast(self.specto, notification_toast, self.specto.icon_theme.load_icon("applications-internet", 64, 0), self.tray_x, self.tray_y, name=self.name)                
            else:
                self.specto.logger.log(_("Not implemented yet"), "warning", self.__class__)#TODO: implement other notifications
Пример #6
0
    def notify(self):
        """
        Notify the user when a watch was updated.
        """
        global _
        if self.specto.DEBUG or not self.specto.GTK:
            self.specto.logger.log(
                _("Watch \"%s\" updated!") % self.name, "info", self.__class__)
        #play a sound
        update_sound = self.specto.specto_gconf.get_entry("update_sound")
        if self.specto.specto_gconf.get_entry("use_update_sound"):
            gnome.sound_play(update_sound)
        #determine if libnotify support is to be used
        pop_toast = self.specto.specto_gconf.get_entry("pop_toast")
        if (pop_toast == True) and (self.specto.GTK):
            sleep(
                0.5
            )  #this is an important hack :) the reason why there is a sleep of half a second is to leave time for the tray icon to appear before getting its coordinates
            self.tray_x = self.specto.tray.get_x()
            self.tray_y = self.specto.tray.get_y()

            if self.type == 0:  #web
                NotificationToast(
                    self.specto,
                    _("The website, <b>%s</b>, has been updated.") %
                    str(self.name),
                    self.specto.icon_theme.load_icon("applications-internet",
                                                     64, 0),
                    self.tray_x,
                    self.tray_y,
                    name=self.name)
            elif self.type == 1:  #email

                if self.prot == 0:  #pop3 account
                    notification_toast = i18n._translation.ungettext(\
                    # English singular form:

                    (_("Your email account, <b>%s</b>, has <b>%d</b> new mail.") % (self.name, self.newMsg)),\
                    # English plural form:

                    (_("Your email account, <b>%s</b>, has <b>%d</b> new unread mails, totalling %s") % (self.name, self.newMsg, self.oldMsg)),\
                    self.oldMsg)
                elif self.prot == 1:  #imap account
                    notification_toast = _(
                        "Your email account, <b>%s</b>, has new mail.") % str(
                            self.name)
                elif self.prot == 2:  #gmail
                    notification_toast = i18n._translation.ungettext(\
                        # English singular form:

                        (_("Your email account, <b>%s</b>, has <b>%d</b> new mail.") % (self.name, self.newMsg)),\
                        # English plural form:

                        (_("Your email account, <b>%s</b>, has <b>%d</b> new unread mails, totalling %s") % (self.name, self.newMsg, self.oldMsg)),\
                        self.oldMsg)

                if notification_toast:
                    NotificationToast(self.specto,
                                      notification_toast,
                                      self.specto.icon_theme.load_icon(
                                          "emblem-mail", 64, 0),
                                      self.tray_x,
                                      self.tray_y,
                                      name=self.name)

            elif self.type == 2:  #folder
                NotificationToast(
                    self.specto,
                    _("The file/folder, <b>%s</b>, has been updated.") %
                    self.name,
                    self.specto.icon_theme.load_icon("folder", 64, 0),
                    self.tray_x,
                    self.tray_y,
                    name=self.name)
            elif self.type == 3:  #process
                if self.running == False:
                    NotificationToast(
                        self.specto,
                        _("The process, <b>%s</b>, has stopped.") % self.name,
                        self.specto.icon_theme.load_icon(
                            "applications-system", 64, 0), self.tray_x,
                        self.tray_y)
                elif self.running == True:
                    NotificationToast(
                        self.specto,
                        _("The process, <b>%s</b>, has started.") % self.name,
                        self.specto.icon_theme.load_icon(
                            "applications-system", 64, 0), self.tray_x,
                        self.tray_y)
                else:
                    self.specto.logger.log(
                        ("This is a bug. The watch" + str(self.name) +
                         "'s value for self.running is" + str(self.running)),
                        "debug", self.__class__)
            elif self.type == 4:  #port
                if self.running == False:
                    NotificationToast(
                        self.specto,
                        _("The connection, <b>%s</b>, was closed.") %
                        self.name,
                        self.specto.icon_theme.load_icon(
                            "network-offline", 64,
                            0), self.tray_x, self.tray_y)
                elif self.running == True:
                    NotificationToast(
                        self.specto,
                        _("The connection, <b>%s</b>, was established.") %
                        self.name,
                        self.specto.icon_theme.load_icon(
                            "network-transmit-receive", 64,
                            0), self.tray_x, self.tray_y)
                else:
                    self.specto.logger.log(
                        ("This is a bug. The watch" + str(self.name) +
                         "'s value for self.running is" + str(self.running)),
                        "debug", self.__class__)
            elif self.type == 5:  #google reader
                notification_toast = i18n._translation.ungettext(\
                    # English singular form:

                    (_("Your Google Reader watch, <b>%s</b>, has <b>%d</b> new message.") % (self.name, self.newMsg)),\
                    # English plural form:

                    (_("Your Google Reader watch, <b>%s</b>, has <b>%d</b> new messages, totalling %s") % (self.name, self.newMsg, self.oldMsg)),\
                    self.oldMsg)

                if notification_toast:
                    NotificationToast(self.specto,
                                      notification_toast,
                                      self.specto.icon_theme.load_icon(
                                          "applications-internet", 64, 0),
                                      self.tray_x,
                                      self.tray_y,
                                      name=self.name)
            else:
                self.specto.logger.log(
                    _("Not implemented yet"), "warning",
                    self.__class__)  #TODO: implement other notifications