- --- /home/ivan/Desktop/all/dialog.py 2009-10-31 16:25:33.000000000 +0100
- +++ /home/ivan/SVN/emesene/dialog.py 2009-11-03 14:52:50.514637876 +0100
- -23,6 +23,7 @@
- import gobject
- import paths
- import Avatar
- +import urllib
- import abstract.stock as stock
- -1112,18 +1113,35 @@
- self.shortcut = gtk.Entry()
- self.combo = gtk.combo_box_new_text()
- + tooltip_t = _("You could add an emoticon also by entering the url of a png/gif image.")
- +
- + labelurl = gtk.Label(_("Or enter an image url"))
- + labelurl.set_tooltip_text(tooltip_t)
- + self.url = gtk.Entry()
- +
- self.combo.append_text(CEChooser.SMALL)
- self.combo.append_text(CEChooser.BIG)
- self.combo.set_active(0)
- - hbox = gtk.HBox()
- + hbox0 = gtk.HBox()
- + hbox1 = gtk.HBox()
- + vbox1 = gtk.VBox()
- + vbox2 = gtk.VBox()
- +
- + hbox1.add(self.shortcut)
- + hbox1.add(self.combo)
- +
- + vbox2.add(self.url)
- + vbox2.add(hbox1)
- +
- + vbox1.add(labelurl)
- + vbox1.add(label)
- - hbox.add(label)
- - hbox.add(self.shortcut)
- - hbox.add(self.combo)
- + hbox0.add(vbox1)
- + hbox0.add(vbox2)
- - self.vbox.pack_start(hbox, False)
- - hbox.show_all()
- + self.vbox.pack_start(hbox0, False)
- + hbox0.show_all()
- def _on_accept(self, button):
- '''method called when the user clicks the button'''
- -1131,14 +1149,24 @@
- shortcut = self.shortcut.get_text()
- size = self.combo.get_model().get_value(self.combo.get_active_iter(), 0)
- - if os.path.isfile(filename):
- - if not shortcut:
- - error(_("Empty shortcut"))
- - else:
- - self.hide()
- - self.response_cb(stock.ACCEPT, filename, shortcut, size)
- + URL = self.url.get_text()
- + ENDEXT = URL.endswith('.gif') or URL.endswith('.png')
- + if URL.startswith('http://') and ENDEXT == True:
- + NAME = URL.split('/')[-1]
- + DEST = paths.SMILIES_HOME_PATH + NAME
- + emoticonimg = urllib.urlretrieve(URL, DEST)
- + self.hide()
- + self.response_cb(stock.ACCEPT, DEST, shortcut, size)
- + os.remove(DEST)
- else:
- - error(_("No picture selected"))
- + if os.path.isfile(filename):
- + if not shortcut:
- + error(_("Empty shortcut"))
- + else:
- + self.hide()
- + self.response_cb(stock.ACCEPT, filename, shortcut, size)
- + else:
- + error(_("No picture selected"))
- def _on_cancel(self, button):
- '''method called when the user clicks the button'''
