emesene forum
July 31, 2010, 01:15:10 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 2183 times)
Ivan!
Sr. Member
****

l33tness: 2
Offline Offline

Posts: 59



View Profile WWW
« on: October 31, 2009, 07:49:31 AM »

Hello all Smiley

I made a patch to add emotes directly from a web address (as http://forum.emesene.org/Smileys/default/cheesy.gif).
Now to add an emoticon, simply copy the address with «Copy image location» from the browser, and in emesene go to add an emoticon, as usually, inserting the address copied.

There is only a issue, the new entry isn't of the same size of the shourtcut entry:

If you know how to make them the same size, or how to get the web addres from the "position" entry ("Posizione" in the image), tell me.  Tongue

I use it sometimes, it's fast...
Hope you like it.  Cheesy

Made from dialog.py - rev 1997
Made with command
Code:
diff -Naurb ~/Desktop/dialog.py ~/SVN/emesene/dialog.py > PatchWebEmot.diff
Code:
--- /home/ivan/Desktop/dialog.py 2009-10-31 16:25:33.000000000 +0100
+++ /home/ivan/SVN/emesene/dialog.py 2009-10-31 16:27:06.999809089 +0100
@@ -23,6 +23,7 @@
 import gobject
 import paths
 import Avatar
+import urllib
 
 import abstract.stock as stock
 
@@ -1112,18 +1113,29 @@
         self.shortcut = gtk.Entry()
         self.combo = gtk.combo_box_new_text()
 
+        labelurl = gtk.Label("Emoticon url")
+        self.url = gtk.Entry()
+
         self.combo.append_text(CEChooser.SMALL)
         self.combo.append_text(CEChooser.BIG)
         self.combo.set_active(0)
 
         hbox = gtk.HBox()
+        vbox1 = gtk.VBox()
+        hbox1 = gtk.HBox()
 
         hbox.add(label)
         hbox.add(self.shortcut)
         hbox.add(self.combo)
 
-        self.vbox.pack_start(hbox, False)
-        hbox.show_all()
+        hbox1.add(labelurl)
+        hbox1.add(self.url)
+
+        vbox1.add(hbox1)
+        vbox1.add(hbox)
+
+        self.vbox.pack_start(vbox1, False)
+        vbox1.show_all()
 
     def _on_accept(self, button):
         '''method called when the user clicks the button'''
@@ -1131,6 +1143,15 @@
         shortcut = self.shortcut.get_text()
         size = self.combo.get_model().get_value(self.combo.get_active_iter(), 0)
 
+        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 = '/tmp/' + NAME
+            emoticonimg = urllib.urlretrieve(URL, DEST)
+            self.hide()
+            self.response_cb(stock.ACCEPT, DEST, shortcut, size)
+        else:
         if os.path.isfile(filename):
             if not shortcut:
                 error(_("Empty shortcut"))
The emoticon is downloaded in /tmp, so there will be no junk file left.
« Last Edit: October 31, 2009, 11:33:32 AM by Ivan! » Logged
C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9990
Offline Offline

Posts: 2308



View Profile Email
« Reply #1 on: October 31, 2009, 01:03:30 PM »

the idea is nice but i have some remarks:
- counter intuitive, the user could think he has to fill it
- platform dependent (tmp)
- breaks the layout

the idea is nice though, improve it! Cheesy
Logged
arielj
Administrator
Hero Member
*****

l33tness: 30
Offline Offline

Posts: 1362


globitz!


View Profile Email
« Reply #2 on: October 31, 2009, 07:55:09 PM »

You can try with the "set_alignment" method to align the label and the entry to the left (http://www.pygtk.org/docs/pygtk/class-gtkmisc.html#method-gtkmisc--set-alignment) and then the "set_padding" method and "set_size_request" to resize those two widget. You can also play with the methods pack_start and pack_end instead of "hbox.add" (http://www.pygtk.org/docs/pygtk/class-gtkbox.html#method-gtkbox--pack-start)

I think you can get the text of "position" using the method self.file_chooser.get_current_folder(), but I'm not sure if it will return the text of the entry or the folder shown in the file explorer :/.
Logged
Ivan!
Sr. Member
****

l33tness: 2
Offline Offline

Posts: 59



View Profile WWW
« Reply #3 on: November 01, 2009, 06:52:55 AM »

Quote
- platform dependent (tmp)
- breaks the layout
These problem are solved (I think).

- I used the emesene paths module. Now the file is downloaded in paths.SMILIES_HOME_PATH and then is removed (with os.remove, that should be cross platform)
- I just added another hbox and changed the way they are packed. Now the two label are the same size, even if the window is resized.
RED = hbox0
left BLUE = vbox1
right BLUE = vbox2
PURPLE = hbox1




For this problem, what do you suggest?  Roll Eyes
Quote
- counter intuitive, the user could think he has to fill it
I thought to a «Or» in the label  Tongue

Diff made from the file in the SVN.
Code:
--- /home/ivan/Desktop/dialog.py 2009-10-31 16:25:33.000000000 +0100
+++ /home/ivan/SVN/emesene/dialog.py 2009-11-01 15:29:40.966727229 +0100
@@ -23,6 +23,7 @@
 import gobject
 import paths
 import Avatar
+import urllib
 
 import abstract.stock as stock
 
@@ -1112,18 +1113,32 @@
         self.shortcut = gtk.Entry()
         self.combo = gtk.combo_box_new_text()
 
+        labelurl = gtk.Label(_("Emoticon Url"))
+        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)
 
-        hbox.add(label)
-        hbox.add(self.shortcut)
-        hbox.add(self.combo)
+        vbox1.add(labelurl)
+        vbox1.add(label)
 
-        self.vbox.pack_start(hbox, False)
-        hbox.show_all()
+        hbox0.add(vbox1)
+        hbox0.add(vbox2)
+
+        self.vbox.pack_start(hbox0, False)
+        hbox0.show_all()
 
     def _on_accept(self, button):
         '''method called when the user clicks the button'''
@@ -1131,6 +1146,16 @@
         shortcut = self.shortcut.get_text()
         size = self.combo.get_model().get_value(self.combo.get_active_iter(), 0)
 
+        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:
         if os.path.isfile(filename):
             if not shortcut:
                 error(_("Empty shortcut"))

the idea is nice though, improve it! Cheesy
thanks!  Cheesy
Logged
arielj
Administrator
Hero Member
*****

l33tness: 30
Offline Offline

Posts: 1362


globitz!


View Profile Email
« Reply #4 on: November 01, 2009, 08:07:19 AM »

You can put an "(option)" in the url label, or an * and add a foot note below.
Logged
Ivan!
Sr. Member
****

l33tness: 2
Offline Offline

Posts: 59



View Profile WWW
« Reply #5 on: November 01, 2009, 09:35:36 AM »

You can put an "(option)" in the url label, or an * and add a foot note below.
Yes Smiley
Or even «Or enter the emoticon url»...

I wait the C10ud opinion. Smiley
Logged
C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9990
Offline Offline

Posts: 2308



View Profile Email
« Reply #6 on: November 01, 2009, 10:33:14 AM »

the new layout seems good, i'm unsure on what would be the best text for that option..
Logged
Ivan!
Sr. Member
****

l33tness: 2
Offline Offline

Posts: 59



View Profile WWW
« Reply #7 on: November 01, 2009, 11:06:00 AM »

Maybe I could add a tooltip on the label, and as text this: «Or enter the emoticon url»  Huh
The tooltip should contain more infos as: «You could add an emoticon also by entering the url of a png/gif image.»

A question, but is possible to insert a tooltip on a label?
On pygtk docs I didn't found information...  Roll Eyes
http://www.pygtk.org/pygtk2reference/class-gtklabel.html

Done  Cheesy
« Last Edit: November 02, 2009, 12:00:58 PM by Ivan! » Logged
Ivan!
Sr. Member
****

l33tness: 2
Offline Offline

Posts: 59



View Profile WWW
« Reply #8 on: November 02, 2009, 12:01:02 PM »

This is a patch with the tooltip.
Code:
--- /home/ivan/Desktop/all/dialog.py 2009-10-31 16:25:33.000000000 +0100
+++ /home/ivan/SVN/emesene/dialog.py 2009-11-02 15:15:42.388996584 +0100
@@ -23,6 +23,7 @@
 import gobject
 import paths
 import Avatar
+import urllib

 import abstract.stock as stock

@@ -1112,18 +1113,36 @@
         self.shortcut = gtk.Entry()
         self.combo = gtk.combo_box_new_text()

+        tooltip = gtk.Tooltips()
+        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 (?)"))
+        tooltip.set_tip(labelurl, 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)

-        hbox.add(label)
-        hbox.add(self.shortcut)
-        hbox.add(self.combo)
+        vbox1.add(labelurl)
+        vbox1.add(label)

-        self.vbox.pack_start(hbox, False)
-        hbox.show_all()
+        hbox0.add(vbox1)
+        hbox0.add(vbox2)
+
+        self.vbox.pack_start(hbox0, False)
+        hbox0.show_all()

     def _on_accept(self, button):
         '''method called when the user clicks the button'''
@@ -1131,6 +1150,16 @@
         shortcut = self.shortcut.get_text()
         size = self.combo.get_model().get_value(self.combo.get_active_iter(), 0)

+        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:
         if os.path.isfile(filename):
             if not shortcut:
                 error(_("Empty shortcut"))

PS: I added the (?) to warn the user that there is an info, moving the cursor over the ?.
Logged
C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9990
Offline Offline

Posts: 2308



View Profile Email
« Reply #9 on: November 02, 2009, 01:07:08 PM »

gtk tooltips is deprecated, use set_tooltip_text instead, and no "(?)" in "official" code Tongue
Logged
x1sc0
improving haxxor™
Hero Member
*****

l33tness: 10
Offline Offline

Posts: 105


View Profile Email
« Reply #10 on: November 02, 2009, 01:19:16 PM »

Talking about emoticons, is the entry "Add an emoticon..." in the action menu necessary while there's already the + icon on the emoticon dialog ?
Logged
C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9990
Offline Offline

Posts: 2308



View Profile Email
« Reply #11 on: November 02, 2009, 01:22:11 PM »

seems like so, because people requested it Wink
Logged
hit^
Hero Member
*****

l33tness: 1
Offline Offline

Posts: 370


svn up´d


View Profile
« Reply #12 on: November 02, 2009, 01:31:30 PM »

Talking about emoticons...
...can the emoticon dialog also be opened with some shortcut, i.e with ctrl+e? Also, the emoticon dialog has scrollbar, if there's a bunch of custom emoticons, but I can't see the bottom of them, if I move around with keyboard there (it won't scroll down).
Just a few thoughts, but you can take them as requests Cheesy
Logged

"We are changing the world, one commit at a time."
x1sc0
improving haxxor™
Hero Member
*****

l33tness: 10
Offline Offline

Posts: 105


View Profile Email
« Reply #13 on: November 02, 2009, 03:10:41 PM »

seems like so, because people requested it Wink

And what about "Hide/Show Emesene" when right click on emesene's icon ?
Logged
arielj
Administrator
Hero Member
*****

l33tness: 30
Offline Offline

Posts: 1362


globitz!


View Profile Email
« Reply #14 on: November 02, 2009, 06:38:57 PM »

"Talking about emoticons, is the entry "Add an emoticon..." in the action menu necessary while there's already the + icon on the emoticon dialog ?"
I've made that patch. What happens if you are not talking with anyone and you just saw a new gif/png that you'd like to add as an emoticon? You need to open a conversation, then click the emoticons button, then click the + button and add this. Or, you can go to actions > add an emoticon.

Following that thought, why are there "block", "unblock" and other buttons when you have them too when you right click a user? or change status in the tray icon when the box is already in the main window? Tongue

It's for a better accessibility, someone would expect that "Actions" give you quick access to do common actions on emesene.

"And what about "Hide/Show Emesene" when right click on emesene's icon?"

This is also for accessibility and completeness (I liked that word when someone asked for that in the forum Tongue). I know that left clicking the tray icon has the same effect, but it can be weird for some people not used to that. The right click menu give you quick actions for emesene and most people know that right click "something" give you a menu, and there's a clear item that do what it says.
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!