Share Pastebin
Guest
Public paste!

Ivan

By: a guest | Nov 3rd, 2009 | Syntax: None | Size: 2.74 KB | Hits: 80 | Expires: Never
Copy text to clipboard
  1. --- /home/ivan/Desktop/all/dialog.py    2009-10-31 16:25:33.000000000 +0100
  2. +++ /home/ivan/SVN/emesene/dialog.py    2009-11-03 14:52:50.514637876 +0100
  3.  -23,6 +23,7 @@
  4.  import gobject
  5.  import paths
  6.  import Avatar
  7. +import urllib
  8.  
  9.  import abstract.stock as stock
  10.  
  11.  -1112,18 +1113,35 @@
  12.          self.shortcut = gtk.Entry()
  13.          self.combo = gtk.combo_box_new_text()
  14.  
  15. +        tooltip_t = _("You could add an emoticon also by entering the url of a png/gif image.")
  16. +
  17. +        labelurl = gtk.Label(_("Or enter an image url"))
  18. +        labelurl.set_tooltip_text(tooltip_t)
  19. +        self.url = gtk.Entry()
  20. +
  21.          self.combo.append_text(CEChooser.SMALL)
  22.          self.combo.append_text(CEChooser.BIG)
  23.          self.combo.set_active(0)
  24.  
  25. -        hbox = gtk.HBox()
  26. +        hbox0 = gtk.HBox()
  27. +        hbox1 = gtk.HBox()
  28. +        vbox1 = gtk.VBox()
  29. +        vbox2 = gtk.VBox()
  30. +
  31. +        hbox1.add(self.shortcut)
  32. +        hbox1.add(self.combo)
  33. +
  34. +        vbox2.add(self.url)
  35. +        vbox2.add(hbox1)
  36. +
  37. +        vbox1.add(labelurl)
  38. +        vbox1.add(label)
  39.  
  40. -        hbox.add(label)
  41. -        hbox.add(self.shortcut)
  42. -        hbox.add(self.combo)
  43. +        hbox0.add(vbox1)
  44. +        hbox0.add(vbox2)
  45.  
  46. -        self.vbox.pack_start(hbox, False)
  47. -        hbox.show_all()
  48. +        self.vbox.pack_start(hbox0, False)
  49. +        hbox0.show_all()
  50.  
  51.      def _on_accept(self, button):
  52.          '''method called when the user clicks the button'''
  53.  -1131,14 +1149,24 @@
  54.          shortcut = self.shortcut.get_text()
  55.          size = self.combo.get_model().get_value(self.combo.get_active_iter(), 0)
  56.  
  57. -        if os.path.isfile(filename):
  58. -            if not shortcut:
  59. -                error(_("Empty shortcut"))
  60. -            else:
  61. -                self.hide()
  62. -                self.response_cb(stock.ACCEPT, filename, shortcut, size)
  63. +        URL = self.url.get_text()
  64. +        ENDEXT = URL.endswith('.gif') or URL.endswith('.png')
  65. +        if URL.startswith('http://') and ENDEXT == True:
  66. +            NAME = URL.split('/')[-1]
  67. +            DEST = paths.SMILIES_HOME_PATH + NAME
  68. +            emoticonimg = urllib.urlretrieve(URL, DEST)
  69. +            self.hide()
  70. +            self.response_cb(stock.ACCEPT, DEST, shortcut, size)
  71. +            os.remove(DEST)
  72.          else:
  73. -            error(_("No picture selected"))
  74. +            if os.path.isfile(filename):
  75. +                if not shortcut:
  76. +                    error(_("Empty shortcut"))
  77. +                else:
  78. +                    self.hide()
  79. +                    self.response_cb(stock.ACCEPT, filename, shortcut, size)
  80. +            else:
  81. +                error(_("No picture selected"))
  82.  
  83.      def _on_cancel(self, button):
  84.          '''method called when the user clicks the button'''