/[straw]/straw/src/lib/MainWindow.py
ViewVC logotype

Diff of /straw/src/lib/MainWindow.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.71 by jmalonzo, Tue Aug 19 09:47:55 2003 UTC revision 1.72 by jmalonzo, Fri Aug 22 09:34:57 2003 UTC
# Line 252  def read_text(fragment, chars): Line 252  def read_text(fragment, chars):
252                  res_len += 1                  res_len += 1
253      return "".join(res)      return "".join(res)
254    
255    entity = re.compile(r'\&.\w*?\;')
256  def convert_entities(text):  def convert_entities(text):
257      nt = []      def conv(ents):
258      in_entity = 0          entities = htmlentitydefs.entitydefs
259      entity = ""          ents = ents.group(0)
260      for c in text:          ent_code = entities.get(ents[1:-1], None)
261          if in_entity:          if ent_code is not None:
262              entity += c              return unicode(ent_code, 'iso8859-1')
             if c == ';':  
                 in_entity = 0;  
                 entities = htmlentitydefs.entitydefs  
                 e = entities.get(entity[1:-1], None)  
                 if e is not None:  
                     nt.append(unicode(e, 'iso8859-1'))  
                 else:  
                     try:  
                         assert len(entity) > 1, "entity less than 1"  
                         if entity[1] == '#':  
                             code = entity[2:-1]  
                             base = 10  
                             if code[0] == 'x':  
                                 code = code[1:]  
                                 base = 16  
                             nt.append(unichr(int(code, base)))  
                         else:  
                             nt.append(' ')  
                     except AssertionError:  
                         raise  
                     except ValueError:  
                         raise  
                 entity = ""  
263          else:          else:
264              if c == '&':              if ents[1] == '#':
265                  in_entity = 1                  code = ents[2:-1]
266                  entity = "&"                  base = 10
267                    if code[0] == 'x':
268                        code = code[1:]
269                        base = 16
270                    return unichr(int(code, base))
271              else:              else:
272                  nt.append(c)                  return
273      return "".join(nt)  
274        in_entity = entity.search(text)
275        if in_entity is None:
276            return text
277        else:
278            # convert all entities found in text then return the converted text
279            ctext = in_entity.re.sub(conv, text)
280            return ctext
281    
282    html_tags = re.compile(r'\<.*?\>')
283    def is_html(text):
284        is_tag = html_tags.search(text)
285        if is_tag: return 1
286        else: return 0
287    
288  class ItemList:  class ItemList:
289      COLUMN_TITLE = 0      COLUMN_TITLE = 0
# Line 482  class StatusTime: Line 477  class StatusTime:
477          straw.config.signal_connect(straw.LastPollChangedSignal, self.next_poll)          straw.config.signal_connect(straw.LastPollChangedSignal, self.next_poll)
478    
479      def next_poll(self, *args):      def next_poll(self, *args):
480          format = '%d %b %H:%M:%S'          now = time.localtime()
481          npoll = straw.config.last_poll + straw.config.poll_frequency          npoll = time.localtime(straw.config.last_poll + straw.config.poll_frequency)
482          npoll_sane = _("Next polling time: <b>%s</b>" %  time.strftime(format,time.localtime(npoll)))          hr_now  = now[3]
483            mo_now = now[2]
484            hr_npoll = npoll[3]
485            mo_npoll = npoll[2]
486            if hr_now > hr_npoll and mo_now == mo_npoll:
487                self.hide()
488                return
489            elif mo_now != mo_npoll and hr_now < hr_npoll:
490                format = '%d %b %H:%M'
491            else:
492                format = '%H:%M'
493            npoll_sane = _("Next poll: <b>%s</b>") %  (time.strftime(format,npoll))
494          self.time_label.set_text(npoll_sane)          self.time_label.set_text(npoll_sane)
495          self.time_label.set_property("use_markup", True)          self.time_label.set_property("use_markup", True)
496          self.time_label.show()          self.time_label.show()
497    
498            return
499    
500      def show(self):      def show(self):
501          self.next_poll()          self.next_poll()
502          return          return
503    
504        def hide(self):
505            self.time_label.hide()
506            return
507    
508  class Toolbar:  class Toolbar:
509      def __init__(self,widget):      def __init__(self,widget):
510          # set toolbar tooltips          # set toolbar tooltips
# Line 569  class FeedInfoDisplay: Line 581  class FeedInfoDisplay:
581              self._title_display.hide()              self._title_display.hide()
582    
583          description = feed.channel_description          description = feed.channel_description
584          self._description_display.set_text(description)          size = len(description)
585          if len(description):          if size:
586                if is_html(description):
587                    description = read_text(description, size)
588                self._description_display.set_text(description)
589              self._description_display.show()              self._description_display.show()
590          else:          else:
591              self._description_display.hide()              self._description_display.hide()
# Line 750  class MainWindow: Line 765  class MainWindow:
765          straw.main.display_previous_item()          straw.main.display_previous_item()
766    
767      def on_menu_about_activate(self, menuitem, *args):      def on_menu_about_activate(self, menuitem, *args):
768            whatis = "Straw is a desktop news aggregator for GNOME"
769          gnome.ui.About(          gnome.ui.About(
770              straw.APPNAME, straw.VERSION, "Copyright (c) 2002-2003 Juri Pakaste", "",              straw.APPNAME, straw.VERSION, "Copyright (c) 2002-2003 Juri Pakaste", whatis,
771              ["Juri Pakaste <juri@iki.fi>",              ["Juri Pakaste <juri@iki.fi>",
772               "Jan Alonzo <jmalonzo@spaceants.org>",               "Jan Alonzo <jmalonzo@spaceants.org>",
773               "rssparser.py and rssfinder.py by Mark Pilgrim",               "rssparser.py and rssfinder.py by Mark Pilgrim",
# Line 761  class MainWindow: Line 777  class MainWindow:
777              "Martin Steldinger <tribble@hanfplantage.de>\n"              "Martin Steldinger <tribble@hanfplantage.de>\n"
778              "David Rousseau <boiteaflood@wanadoo.fr>\n"              "David Rousseau <boiteaflood@wanadoo.fr>\n"
779              "Sergei Vavinov <svv@cmc.msu.ru>\n"              "Sergei Vavinov <svv@cmc.msu.ru>\n"
780               u"Terje Rosten <terjeros@phys.ntnu.no>",              u"Terje R\xf8sten <terjeros@phys.ntnu.no>",
781              gtk.gdk.pixbuf_new_from_file(straw.main._libdir +              gtk.gdk.pixbuf_new_from_file(straw.main._libdir +
782                                           "/straw.png")).show()                                           "/straw.png")).show()
783    

Legend:
Removed from v.1.71  
changed lines
  Added in v.1.72

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26