Example #1
0
    def send_notification( self, message, title="gPodder", actions=[], is_error=False):
        if not self.__is_notification_on(): return

        message=message.strip()
        log('Notification: %s', message, sender=self)
        if gpodder.interface == gpodder.MAEMO:
            pango_markup='<b>%s</b>\n<small>%s</small>' % (title, message)
            hildon.hildon_banner_show_information_with_markup(gtk.Label(''), None, pango_markup)
        elif gpodder.interface == gpodder.GUI and have_pynotify:
            notification=pynotify.Notification(title, message, self.__icon_filename)
            if is_error: notification.set_urgency(pynotify.URGENCY_CRITICAL)
            try:
                notification.attach_to_status_icon(self)
            except:
                log('Warning: Cannot attach notification to status icon.', sender=self)
            for action in actions:
                notification.add_action(action[0], action[1], self.__action_callback)
            if not notification.show():
                log("Error: enable to send notification %s", message)
            if len(actions) > 0:
                gtk.main() # needed for action callback to be triggered
        else:
            return
        
        # If we showed any kind of notification, remember it for next time
        self.__previous_notification=[message, title, actions, is_error]
        self.menuItem_previous_msg.set_sensitive(True)
Example #2
0
    def _display_hildonnotification(self,
                                    title,
                                    message,
                                    icon=None,
                                    userdata=None):
        self._notification_displaying = True
        if self._parent is None:
            logging.info("not showing notification, no parent widget")
        logging.debug("showing notification: %s %s" % (title, message))
        try:
            b = hildon.hildon_banner_show_information_with_markup(
                self._parent, icon, "<b>%s</b>\n%s" % (title, message))
        except TypeError:
            #banner bug not fixed yet
            b = hildon.hildon_banner_show_information_with_markup(
                self._parent, "NULL", "<b>%s</b>\n%s" % (title, message))
        if icon is not None:
            b.set_icon_from_file(icon)
        b.set_timeout(3000)

        def done_showing():
            self._notification_displaying = False
            return False

        gobject.timeout_add(5000, done_showing)
Example #3
0
 def notify(self, message, icon=None):
   if self.GTK:
     import hildon
     print("Hildon notification: %s" % message)
     hildon.hildon_banner_show_information_with_markup(self.mieru.gui.getWindow(), "icon_text", message)
   else:
     self.mieru.gui._notify(message, icon)
Example #4
0
 def notify(self, message, icon=None):
     if self.GTK:
         import hildon
         print("Hildon notification: %s" % message)
         hildon.hildon_banner_show_information_with_markup(
             self.mieru.gui.getWindow(), "icon_text", message)
     else:
         self.mieru.gui._notify(message, icon)
Example #5
0
    def show_message(self, message, title=None, important=False, widget=None):
        if gpodder.ui.diablo:
            import hildon
            if important:
                dlg = hildon.Note('information', (self.main_window, message))
                dlg.run()
                dlg.destroy()
            else:
                if title is None:
                    title = 'gPodder'
                pango_markup = '<b>%s</b>\n<small>%s</small>' % (title, message)
                hildon.hildon_banner_show_information_with_markup(gtk.Label(''), None, pango_markup)
        elif gpodder.ui.fremantle:
            import hildon
            if important:
                if title is None:
                    message = message
                else:
                    message = '%s\n%s' % (title, message)
                dlg = hildon.hildon_note_new_information(self.main_window, \
                        message)
                dlg.run()
                dlg.destroy()
            else:
                hildon.hildon_banner_show_information(self.main_window, \
                        '', message)
        else:
            # XXX: Dirty hack to get access to the gPodder-specific config object
            config = getattr(self, '_config', getattr(self, 'config', None))

            if important:
                dlg = gtk.MessageDialog(self.main_window, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK)
                if title:
                    dlg.set_title(str(title))
                    dlg.set_markup('<span weight="bold" size="larger">%s</span>\n\n%s' % (title, message))
                else:
                    dlg.set_markup('<span weight="bold" size="larger">%s</span>' % (message))
                dlg.run()
                dlg.destroy()
            elif config is not None and config.enable_notifications:
                if pynotify is not None:
                    if title is None:
                        title = 'gPodder'
                    notification = pynotify.Notification(title, message,\
                            gpodder.icon_file)
                    notification.show()
                elif widget and isinstance(widget, gtk.Widget):
                    if not widget.window:
                        widget = self.main_window
                    else:
                        widget = self.main_window
                    notification = NotificationWindow(message, title, important=False, widget=widget)
                    notification.show_timeout()
Example #6
0
    def show_information(self, button, data=None):
        icon_text = self.icon_entry.get_text()

        if icon_text == "":
            icon_text = None

        if not self.markup_check.get_active():
            hildon.hildon_banner_show_information(self.window, icon_text,
                                                  self.text_entry.get_text())
        else:
            hildon.hildon_banner_show_information_with_markup(
                self.window, icon_text, self.text_entry.get_text())
Example #7
0
 def notify(self, message):
     """ Sends a notification using pynotify, returns message """
     if platform.DESKTOP and have_pynotify:
         icon = util.find_data_file('panucci_64x64.png')
         notification = pynotify.Notification(self.main_window.get_title(), message, icon)
         notification.show()
     elif platform.FREMANTLE:
         hildon.hildon_banner_show_information(self.main_window, \
                 '', message)
     elif platform.MAEMO:
         # Note: This won't work if we're not in the gtk main loop
         markup = '<b>%s</b>\n<small>%s</small>' % (self.main_window.get_title(), message)
         hildon.hildon_banner_show_information_with_markup(self.main_window, None, markup)
Example #8
0
 def notify(self, message):
     """ Sends a notification using pynotify, returns message """
     if platform.DESKTOP and have_pynotify:
         icon = util.find_data_file('panucci_64x64.png')
         notification = pynotify.Notification(self.main_window.get_title(),
                                              message, icon)
         notification.show()
     elif platform.FREMANTLE:
         hildon.hildon_banner_show_information(self.main_window, \
                 '', message)
     elif platform.MAEMO:
         # Note: This won't work if we're not in the gtk main loop
         markup = '<b>%s</b>\n<small>%s</small>' % (
             self.main_window.get_title(), message)
         hildon.hildon_banner_show_information_with_markup(
             self.main_window, None, markup)
Example #9
0
	def _display_hildonnotification(self, title, message, icon=None, userdata=None):
		self._notification_displaying = True
		if self._parent is None:
			logging.info("not showing notification, no parent widget")
		logging.debug("showing notification: %s %s" % (title, message))
		try:
			b = hildon.hildon_banner_show_information_with_markup(self._parent, icon, "<b>%s</b>\n%s" % (title, message))
		except TypeError:
			#banner bug not fixed yet
			b = hildon.hildon_banner_show_information_with_markup(self._parent, "NULL", "<b>%s</b>\n%s" % (title, message))
		if icon is not None:
			b.set_icon_from_file(icon)
		b.set_timeout(3000)
		def done_showing():
			self._notification_displaying = False
			return False
		gobject.timeout_add(5000, done_showing)
Example #10
0
    def _showNotificationCB(self, message, msTimeout=0, icon="icon_text"):
        """the third parameter has to be a non zero-length string or
        else the banner is not created"""
        #TODO: find what strings to submit to actually get an icon displayed

        if len(icon) == 0:
            icon = "spam" # as mentioned above, the string has to be longer than zero

        topWindow = self.modrana.gui.getWindow()
        banner = hildon.hildon_banner_show_information_with_markup(topWindow, icon, message)
        if msTimeout:
            banner.set_timeout(int(msTimeout))
Example #11
0
    def _showNotificationCB(self, message, msTimeout=0, icon="icon_text"):
        """the third parameter has to be a non zero-length string or
        else the banner is not created"""
        #TODO: find what strings to submit to actually get an icon displayed

        if len(icon) == 0:
            icon = "spam"  # as mentioned above, the string has to be longer than zero

        topWindow = self.modrana.gui.getWindow()
        banner = hildon.hildon_banner_show_information_with_markup(
            topWindow, icon, message)
        if msTimeout:
            banner.set_timeout(msTimeout)
Example #12
0
    def notify(self, message, msTimeout=0, icon="icon_text"):
        """the third parameter has to be a non zero-length string or
        else the banner is not created"""
        #TODO: find what strings to submit to actually get an icon displayed

        if len(icon) == 0:
            icon = "spam" # as mentioned above, the string has to be longer than zero
        if gs.GUIString == "GTK":
            topWindow = self.modrana.gui.getWindow()
            banner = hildon.hildon_banner_show_information_with_markup(topWindow, icon, message)
            if msTimeout:
                banner.set_timeout(msTimeout)
        else:
            print("n900: the N900 device module currently handles only Hildon based notifications")
Example #13
0
    def show_message(self, message, title=None, important=False, widget=None):
        if gpodder.ui.diablo:
            import hildon
            if important:
                try:
                    dlg = hildon.Note('information',
                                      (self.main_window, message))
                except TypeError:
                    if title is None:
                        message = message
                    else:
                        message = '%s\n%s' % (title, message)
                    dlg = hildon.hildon_note_new_information(self.main_window, \
                            message)
                dlg.run()
                dlg.destroy()
            else:
                if title is None:
                    title = 'gPodder'
                pango_markup = '<b>%s</b>\n<small>%s</small>' % (title,
                                                                 message)
                try:
                    hildon.hildon_banner_show_information_with_markup(
                        gtk.Label(''), None, pango_markup)
                except TypeError:
                    # We're probably running the Diablo UI on Maemo 5 :)
                    hildon.hildon_banner_show_information(self.main_window, \
                            '', message)
        elif gpodder.ui.fremantle:
            import hildon
            if important:
                if title is None:
                    message = message
                else:
                    message = '%s\n%s' % (title, message)

                dlg = hildon.hildon_note_new_information( \
                        self.get_dialog_parent(), \
                        message)
                dlg.run()
                dlg.destroy()
            else:
                hildon.hildon_banner_show_information(self.get_dialog_parent(), \
                        '', message)
        else:
            # XXX: Dirty hack to get access to the gPodder-specific config object
            config = getattr(self, '_config', getattr(self, 'config', None))

            if important:
                dlg = gtk.MessageDialog(self.main_window, gtk.DIALOG_MODAL,
                                        gtk.MESSAGE_INFO, gtk.BUTTONS_OK)
                if title:
                    dlg.set_title(str(title))
                    dlg.set_markup(
                        '<span weight="bold" size="larger">%s</span>\n\n%s' %
                        (title, message))
                else:
                    dlg.set_markup(
                        '<span weight="bold" size="larger">%s</span>' %
                        (message))
                dlg.run()
                dlg.destroy()
            elif config is not None and config.enable_notifications:
                if pynotify is not None:
                    if title is None:
                        title = 'gPodder'
                    notification = pynotify.Notification(title, message,\
                            gpodder.icon_file)
                    try:
                        notification.show()
                    except:
                        # See http://gpodder.org/bug/966
                        pass
                elif widget and isinstance(widget, gtk.Widget):
                    if not widget.window:
                        widget = self.main_window
                    elif not gpodder.win32:
                        widget = self.main_window
                    notification = NotificationWindow(message,
                                                      title,
                                                      important=False,
                                                      widget=widget)
                    notification.show_timeout()
Example #14
0
    def _display_results(self, caches, truncated):
        sortfuncs = [
            ('Dist', lambda x, y: cmp(x.prox, y.prox)),
            ('Name', lambda x, y: cmp(x.title, y.title)),
            ('Diff',
             lambda x, y: cmp(x.difficulty
                              if x.difficulty > 0 else 100, y.difficulty
                              if y.difficulty > 0 else 100)),
            ('Terr', lambda x, y: cmp(x.terrain
                                      if x.terrain > 0 else 100, y.terrain
                                      if y.terrain > 0 else 100)),
            ('Size', lambda x, y: cmp(x.size if x.size > 0 else 100, y.size
                                      if y.size > 0 else 100)),
            ('Type', lambda x, y: cmp(x.type, y.type)),
        ]

        if self.gps_data != None and self.gps_data.position != None:
            for c in caches:
                c.prox = c.distance_to(self.gps_data.position)
        else:
            for c in caches:
                c.prox = None

        win = hildon.StackableWindow()
        win.set_title("Search results")
        ls = gtk.ListStore(str, str, str, str, object)

        tv = hildon.TouchSelector()
        col1 = tv.append_column(ls, gtk.CellRendererText())

        c1cr = gtk.CellRendererText()
        c1cr.ellipsize = pango.ELLIPSIZE_MIDDLE
        c2cr = gtk.CellRendererText()
        c3cr = gtk.CellRendererText()
        c4cr = gtk.CellRendererText()

        col1.pack_start(c1cr, True)
        col1.pack_end(c2cr, False)
        col1.pack_start(c3cr, False)
        col1.pack_end(c4cr, False)

        col1.set_attributes(c1cr, text=0)
        col1.set_attributes(c2cr, text=1)
        col1.set_attributes(c3cr, text=2)
        col1.set_attributes(c4cr, text=3)

        def select_cache(widget, data, more):
            self.show_cache(self._get_selected(tv)[4])

        tv.connect("changed", select_cache, None)

        def on_change_sort(widget, sortfunc):
            tv.handler_block_by_func(select_cache)
            ls.clear()
            caches.sort(cmp=sortfunc)
            for c in caches:
                ls.append([
                    self.shorten_name(c.title, 40), " " + c.get_size_string(),
                    ' D%s T%s' % (c.get_difficulty(), c.get_terrain()),
                    " " + geo.Coordinate.format_distance(c.prox), c
                ])
            tv.handler_unblock_by_func(select_cache)

        menu = hildon.AppMenu()
        button = None
        for name, function in sortfuncs:
            button = hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, button)
            button.set_label(name)
            button.connect("clicked", on_change_sort, function)
            menu.add_filter(button)
            button.set_mode(False)

        def download_geocaches(widget):
            self.core.download_cache_details_list(caches)

        button = hildon.Button(gtk.HILDON_SIZE_AUTO,
                               hildon.BUTTON_ARRANGEMENT_VERTICAL)
        button.set_title("Download Details")
        button.set_value("for all Geocaches")
        button.connect("clicked", download_geocaches)
        menu.append(button)

        menu.show_all()
        win.set_app_menu(menu)
        win.add(tv)

        on_change_sort(None, sortfuncs[0][1])

        win.show_all()
        if truncated:
            hildon.hildon_banner_show_information_with_markup(
                win, "hu", "Showing only the first %d results." % len(caches))

        win.connect('delete_event', self.hide_search_view)
Example #15
0
 def notify(self, message, icon=None):
   if self.GTK:
     print message
     hildon.hildon_banner_show_information_with_markup(self.mieru.gui.getWindow(), "icon_text", message)
   else:
     self.mieru.gui._notify(message, icon)
    def _display_results(self, caches, truncated):
        sortfuncs = [
            ('Dist', lambda x, y: cmp(x.prox, y.prox)),
            ('Name', lambda x, y: cmp(x.title, y.title)),
            ('Diff', lambda x, y: cmp(x.difficulty if x.difficulty > 0 else 100, y.difficulty if y.difficulty > 0 else 100)),
            ('Terr', lambda x, y: cmp(x.terrain if x.terrain > 0 else 100, y.terrain if y.terrain > 0 else 100)),
            ('Size', lambda x, y: cmp(x.size if x.size > 0 else 100, y.size if y.size > 0 else 100)),
            ('Type', lambda x, y: cmp(x.type, y.type)),
        ]

        if self.gps_data != None and self.gps_data.position != None:
            for c in caches:
                c.prox = c.distance_to(self.gps_data.position)
        else:
            for c in caches:
                c.prox = None

        win = hildon.StackableWindow()
        win.set_title("Search results")
        ls = gtk.ListStore(str, str, str, str, object)

        tv = hildon.TouchSelector()
        col1 = tv.append_column(ls, gtk.CellRendererText())

        c1cr = gtk.CellRendererText()
        c1cr.ellipsize = pango.ELLIPSIZE_MIDDLE
        c2cr = gtk.CellRendererText()
        c3cr = gtk.CellRendererText()
        c4cr = gtk.CellRendererText()

        col1.pack_start(c1cr, True)
        col1.pack_end(c2cr, False)
        col1.pack_start(c3cr, False)
        col1.pack_end(c4cr, False)

        col1.set_attributes(c1cr, text=0)
        col1.set_attributes(c2cr, text=1)
        col1.set_attributes(c3cr, text=2)
        col1.set_attributes(c4cr, text=3)

        def select_cache(widget, data, more):
            self.show_cache(self._get_selected(tv)[4])

        tv.connect("changed", select_cache, None)


        def on_change_sort(widget, sortfunc):
            tv.handler_block_by_func(select_cache)
            ls.clear()
            caches.sort(cmp=sortfunc)
            for c in caches:
                ls.append([self.shorten_name(c.title, 40), " " + c.get_size_string(), ' D%s T%s' % (c.get_difficulty(), c.get_terrain()), " " + geo.Coordinate.format_distance(c.prox), c])
            tv.handler_unblock_by_func(select_cache)


        menu = hildon.AppMenu()
        button = None
        for name, function in sortfuncs:
            button = hildon.GtkRadioButton(gtk.HILDON_SIZE_AUTO, button)
            button.set_label(name)
            button.connect("clicked", on_change_sort, function)
            menu.add_filter(button)
            button.set_mode(False)

        def download_geocaches(widget):
            self.core.download_cache_details_list(caches)



        button = hildon.Button(gtk.HILDON_SIZE_AUTO, hildon.BUTTON_ARRANGEMENT_VERTICAL)
        button.set_title("Download Details")
        button.set_value("for all Geocaches")
        button.connect("clicked", download_geocaches)
        menu.append(button)

        menu.show_all()
        win.set_app_menu(menu)
        win.add(tv)

        on_change_sort(None, sortfuncs[0][1])

        win.show_all()
        if truncated:
            hildon.hildon_banner_show_information_with_markup(win, "hu", "Showing only the first %d results." % len(caches))

        win.connect('delete_event', self.hide_search_view)
Example #17
0
 def testShowInformationWithMarkup(self):
     hildon.hildon_banner_show_information_with_markup(self.parent,
                                           "",
                                           "Dummy text")
Example #18
0
    def show_message(self, message, title=None, important=False, widget=None):
        if gpodder.ui.diablo:
            import hildon
            if important:
                try:
                    dlg = hildon.Note('information', (self.main_window, message))
                except TypeError:
                    if title is None:
                        message = message
                    else:
                        message = '%s\n%s' % (title, message)
                    dlg = hildon.hildon_note_new_information(self.main_window, \
                            message)
                dlg.run()
                dlg.destroy()
            else:
                if title is None:
                    title = 'gPodder'
                pango_markup = '<b>%s</b>\n<small>%s</small>' % (title, message)
                try:
                    hildon.hildon_banner_show_information_with_markup(gtk.Label(''), None, pango_markup)
                except TypeError:
                    # We're probably running the Diablo UI on Maemo 5 :)
                    hildon.hildon_banner_show_information(self.main_window, \
                            '', message)
        elif gpodder.ui.fremantle:
            import hildon
            if important:
                if title is None:
                    message = message
                else:
                    message = '%s\n%s' % (title, message)

                # Determine the topmost visible window and attach the
                # message to that window to avoid Maemo Bug 10030
                stack = hildon.WindowStack.get_default()
                visible_windows = stack.get_windows()
                if visible_windows:
                    parent_window = visible_windows[0]
                else:
                    parent_window = self.main_window

                dlg = hildon.hildon_note_new_information(parent_window, \
                        message)
                dlg.run()
                dlg.destroy()
            else:
                hildon.hildon_banner_show_information(self.main_window, \
                        '', message)
        else:
            # XXX: Dirty hack to get access to the gPodder-specific config object
            config = getattr(self, '_config', getattr(self, 'config', None))

            if important:
                dlg = gtk.MessageDialog(self.main_window, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK)
                if title:
                    dlg.set_title(str(title))
                    dlg.set_markup('<span weight="bold" size="larger">%s</span>\n\n%s' % (title, message))
                else:
                    dlg.set_markup('<span weight="bold" size="larger">%s</span>' % (message))
                dlg.run()
                dlg.destroy()
            elif config is not None and config.enable_notifications:
                if pynotify is not None:
                    if title is None:
                        title = 'gPodder'
                    notification = pynotify.Notification(title, message,\
                            gpodder.icon_file)
                    try:
                        notification.show()
                    except:
                        # See http://gpodder.org/bug/966
                        pass
                elif widget and isinstance(widget, gtk.Widget):
                    if not widget.window:
                        widget = self.main_window
                    else:
                        widget = self.main_window
                    notification = NotificationWindow(message, title, important=False, widget=widget)
                    notification.show_timeout()