fix behaviour of PHOTO_button in profile_window. Fixes #2381
This commit is contained in:
parent
746a0bf98e
commit
de22429a6f
|
@ -991,11 +991,11 @@
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkButton" id="set_avatar_button">
|
<widget class="GtkButton" id="PHOTO_button">
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
<property name="focus_on_click">True</property>
|
<property name="focus_on_click">True</property>
|
||||||
<signal name="clicked" handler="on_set_avatar_button_clicked" last_modification_time="Fri, 08 Sep 2006 14:14:38 GMT"/>
|
<signal name="button_press_event" handler="on_PHOTO_button_press_event" last_modification_time="Sun, 10 Sep 2006 10:44:01 GMT"/>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkEventBox" id="PHOTO_eventbox3">
|
<widget class="GtkEventBox" id="PHOTO_eventbox3">
|
||||||
|
|
|
@ -66,7 +66,6 @@ class ProfileWindow:
|
||||||
|
|
||||||
self.avatar_mime_type = None
|
self.avatar_mime_type = None
|
||||||
self.avatar_encoded = None
|
self.avatar_encoded = None
|
||||||
self.avatar_save_as_id = None
|
|
||||||
|
|
||||||
self.xml.signal_autoconnect(self)
|
self.xml.signal_autoconnect(self)
|
||||||
self.window.show_all()
|
self.window.show_all()
|
||||||
|
@ -80,13 +79,10 @@ class ProfileWindow:
|
||||||
|
|
||||||
def on_clear_button_clicked(self, widget):
|
def on_clear_button_clicked(self, widget):
|
||||||
# empty the image
|
# empty the image
|
||||||
path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'person.png')
|
self.xml.get_widget('PHOTO_image').set_from_icon_name('stock_person',
|
||||||
self.xml.get_widget('PHOTO_image').set_from_file(path)
|
gtk.ICON_SIZE_DIALOG)
|
||||||
self.avatar_encoded = None
|
self.avatar_encoded = None
|
||||||
if self.avatar_save_as_id:
|
self.avatar_mime_type = None
|
||||||
self.xml.get_widget('set_avatar_button').disconnect(
|
|
||||||
self.avatar_save_as_id)
|
|
||||||
self.avatar_save_as_id = None
|
|
||||||
|
|
||||||
def on_set_avatar_button_clicked(self, widget):
|
def on_set_avatar_button_clicked(self, widget):
|
||||||
f = None
|
f = None
|
||||||
|
@ -138,9 +134,9 @@ class ProfileWindow:
|
||||||
|
|
||||||
def on_PHOTO_button_press_event(self, widget, event):
|
def on_PHOTO_button_press_event(self, widget, event):
|
||||||
'''If right-clicked, show popup'''
|
'''If right-clicked, show popup'''
|
||||||
if event.button == 3: # right click
|
if event.button == 3 and self.avatar_encoded: # right click
|
||||||
nick = gajim.config.get_per('accounts', self.account, 'name')
|
|
||||||
menu = gtk.Menu()
|
menu = gtk.Menu()
|
||||||
|
nick = gajim.config.get_per('accounts', self.account, 'name')
|
||||||
menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS)
|
menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS)
|
||||||
menuitem.connect('activate',
|
menuitem.connect('activate',
|
||||||
gtkgui_helpers.on_avatar_save_as_menuitem_activate,
|
gtkgui_helpers.on_avatar_save_as_menuitem_activate,
|
||||||
|
@ -154,6 +150,8 @@ class ProfileWindow:
|
||||||
# show the menu
|
# show the menu
|
||||||
menu.show_all()
|
menu.show_all()
|
||||||
menu.popup(None, None, None, event.button, event.time)
|
menu.popup(None, None, None, event.button, event.time)
|
||||||
|
elif event.button == 1: # left click
|
||||||
|
self.on_set_avatar_button_clicked(widget)
|
||||||
|
|
||||||
def set_value(self, entry_name, value):
|
def set_value(self, entry_name, value):
|
||||||
try:
|
try:
|
||||||
|
@ -162,21 +160,20 @@ class ProfileWindow:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def set_values(self, vcard):
|
def set_values(self, vcard):
|
||||||
|
if not 'PHOTO' in vcard:
|
||||||
|
# set default image
|
||||||
|
image = self.xml.get_widget('PHOTO_image')
|
||||||
|
image.set_from_icon_name('stock_person', gtk.ICON_SIZE_DIALOG)
|
||||||
for i in vcard.keys():
|
for i in vcard.keys():
|
||||||
if i == 'PHOTO':
|
if i == 'PHOTO':
|
||||||
pixbuf, self.avatar_encoded, self.avatar_mime_type = \
|
pixbuf, self.avatar_encoded, self.avatar_mime_type = \
|
||||||
get_avatar_pixbuf_encoded_mime(vcard[i])
|
get_avatar_pixbuf_encoded_mime(vcard[i])
|
||||||
image = self.xml.get_widget('PHOTO_image')
|
image = self.xml.get_widget('PHOTO_image')
|
||||||
if not pixbuf:
|
if not pixbuf:
|
||||||
image.set_from_icon_name('stock_person',
|
image.set_from_icon_name('stock_person', gtk.ICON_SIZE_DIALOG)
|
||||||
gtk.ICON_SIZE_DIALOG)
|
|
||||||
continue
|
continue
|
||||||
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'vcard')
|
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'vcard')
|
||||||
image.set_from_pixbuf(pixbuf)
|
image.set_from_pixbuf(pixbuf)
|
||||||
button = self.xml.get_widget('set_avatar_button')
|
|
||||||
self.avatar_save_as_id = button.connect('button-press-event',
|
|
||||||
self.on_PHOTO_button_press_event)
|
|
||||||
button.show()
|
|
||||||
continue
|
continue
|
||||||
if i == 'ADR' or i == 'TEL' or i == 'EMAIL':
|
if i == 'ADR' or i == 'TEL' or i == 'EMAIL':
|
||||||
for entry in vcard[i]:
|
for entry in vcard[i]:
|
||||||
|
@ -278,11 +275,8 @@ class ProfileWindow:
|
||||||
for e in entries:
|
for e in entries:
|
||||||
self.xml.get_widget(e + '_entry').set_text('')
|
self.xml.get_widget(e + '_entry').set_text('')
|
||||||
self.xml.get_widget('DESC_textview').get_buffer().set_text('')
|
self.xml.get_widget('DESC_textview').get_buffer().set_text('')
|
||||||
self.xml.get_widget('PHOTO_image').set_from_pixbuf(None)
|
self.xml.get_widget('PHOTO_image').set_from_icon_name('stock_person',
|
||||||
if self.avatar_save_as_id:
|
gtk.ICON_SIZE_DIALOG)
|
||||||
self.xml.get_widget('set_avatar_button').disconnect(
|
|
||||||
self.avatar_save_as_id)
|
|
||||||
self.avatar_save_as_id = None
|
|
||||||
gajim.connections[self.account].request_vcard(self.jid)
|
gajim.connections[self.account].request_vcard(self.jid)
|
||||||
else:
|
else:
|
||||||
dialogs.ErrorDialog(_('You are not connected to the server'),
|
dialogs.ErrorDialog(_('You are not connected to the server'),
|
||||||
|
|
Loading…
Reference in New Issue