emesene forum
July 31, 2010, 01:15:44 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: CACHE KEY ERRORS? NICK NOT SAVED? UPGRADE TO 1.6.2 FIRST!

REPORT ANY ISSUE HERE - PLEASE CHECK IF THE PROBLEM HAS ALREADY BEEN REPORTED FIRST -- THANKS
 
  Home   Forum   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: Add emoticon from URL  (Read 2184 times)
Ivan!
Sr. Member
****

l33tness: 2
Offline Offline

Posts: 59



View Profile WWW
« Reply #15 on: November 03, 2009, 06:23:33 AM »

New diff:
ø No (?)
ø Use set_tooltip_text instead of gtk.Tooltips


Patch made with:
Code:
diff -Naur ~/Desktop/all/dialog.py ~/SVN/emesene/dialog.py > PatchEmoticonAP.diff
Code:
--- /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'''
With syntax highlight: http://pastebin.com/f1d587092
Logged
C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9990
Offline Offline

Posts: 2308



View Profile Email
« Reply #16 on: November 03, 2009, 08:55:00 AM »

looks fine, it will get svn soon! Grin
Logged
Ivan!
Sr. Member
****

l33tness: 2
Offline Offline

Posts: 59



View Profile WWW
« Reply #17 on: November 03, 2009, 09:20:16 AM »

looks fine, it will get svn soon! Grin
Wonderful! Cheesy

Logged
x1sc0
improving haxxor™
Hero Member
*****

l33tness: 10
Offline Offline

Posts: 105


View Profile Email
« Reply #18 on: November 03, 2009, 09:59:25 AM »

I tried it and it doesn't work properly.
When I try to add any kind of file I always get the error "Any picture selected" and the "Select a picture" window doesn't dissapear. When I try with a PNG file it dissapears but it does nothing.
Logged
Ivan!
Sr. Member
****

l33tness: 2
Offline Offline

Posts: 59



View Profile WWW
« Reply #19 on: November 03, 2009, 10:40:59 AM »

You can enter only a url address starting by http:// and ending by .png or .gif.
The patch controls: 1) if in the url entry there is an url (as above). If there is an url downloads it, if no, uses the picture selected in the file selector.

Try to start emesene from terminal and paste what you get.
Does emesene show you errors?

When I try to add any kind of file I always get the error "Any picture selected" and the "Select a picture" window doesn't dissapear. When I try with a PNG file it dissapears but it does nothing.
But you are selecting a file or entering an url?
« Last Edit: November 03, 2009, 10:48:45 AM by Ivan! » Logged
Ivan!
Sr. Member
****

l33tness: 2
Offline Offline

Posts: 59



View Profile WWW
« Reply #20 on: November 03, 2009, 11:20:39 AM »

@c10ud
I made a little change.
Now check also for the url if the shortcut isn't blank.
Code:
--- /home/ivan/Desktop/all/dialog.py 2009-11-03 18:05:59.000000000 +0100
+++ /home/ivan/SVN/emesene/dialog.py 2009-11-03 19:43:25.259190187 +0100
@@ -1152,12 +1152,15 @@
         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)
+            if not shortcut:
+                error(_("Empty shortcut"))
+            else:
+                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:
             if os.path.isfile(filename):
                 if not shortcut:
Logged
x1sc0
improving haxxor™
Hero Member
*****

l33tness: 10
Offline Offline

Posts: 105


View Profile Email
« Reply #21 on: November 03, 2009, 01:01:48 PM »

Now it works right with a PNG file. But with other types I still get "Any picture selected". it should be replaced by "This extension is not accepted" or anything like this or even better, acept this kind of files as the pictures selector does.
bye
Logged
x1sc0
improving haxxor™
Hero Member
*****

l33tness: 10
Offline Offline

Posts: 105


View Profile Email
« Reply #22 on: November 03, 2009, 01:33:33 PM »

Small Patch to add pictures from URL which start with www as well.
Logged
zipatei
Hero Member
*****

l33tness: 4
Offline Offline

Posts: 378



View Profile WWW
« Reply #23 on: February 02, 2010, 09:38:59 AM »

Error: "No Image Selected"

Url: http://upload.wikimedia.org/wikipedia/commons/4/40/Emesene-logo.png

Look:
Logged
arielj
Administrator
Hero Member
*****

l33tness: 30
Offline Offline

Posts: 1362


globitz!


View Profile Email
« Reply #24 on: February 23, 2010, 09:45:39 AM »

I was trying to fix this, but it looks like a bug with urllib (a basic python module, not an emesene's module). The image is retrieved broken from the wikipedia servers, it can't be open even with an image viewer software, so emesene can't open it either and then the error appears...

I don't know if we can fix that, maybe add a better description of the problem?...
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

TinyPortal v.1.0.6 beta 2 © Bloc
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!