use 2 buttons in profile windows because some GTK themes don't show images in buttons when there is text. gtk-button-images option in gtkrc file.
This commit is contained in:
parent
afd2d150d1
commit
20a146dabf
|
@ -16,6 +16,7 @@
|
|||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="focus_on_map">True</property>
|
||||
<property name="urgency_hint">False</property>
|
||||
<signal name="key_press_event" handler="on_profile_window_key_press_event" last_modification_time="Fri, 08 Sep 2006 11:39:24 GMT"/>
|
||||
<signal name="destroy" handler="on_profile_window_destroy" last_modification_time="Fri, 08 Sep 2006 11:39:32 GMT"/>
|
||||
|
||||
|
@ -989,6 +990,40 @@
|
|||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label58">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Avatar:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">6</property>
|
||||
<property name="bottom_attach">7</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="PHOTO_button">
|
||||
<property name="can_focus">True</property>
|
||||
|
@ -1014,6 +1049,30 @@
|
|||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="NOPHOTO_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Click to set your avatar</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="button_press_event" handler="on_PHOTO_button_press_event" last_modification_time="Tue, 23 Jan 2007 12:25:27 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">4</property>
|
||||
|
@ -1023,34 +1082,6 @@
|
|||
<property name="y_options">expand</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label58">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Avatar:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">6</property>
|
||||
<property name="bottom_attach">7</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
|
|
|
@ -77,6 +77,10 @@ class ProfileWindow:
|
|||
# Create Image for avatar button
|
||||
image = gtk.Image()
|
||||
self.xml.get_widget('PHOTO_button').set_image(image)
|
||||
text_button = self.xml.get_widget('NOPHOTO_button')
|
||||
# We use 2 buttons because some GTK theme don't show images in buttons
|
||||
text_button.set_no_show_all(True)
|
||||
text_button.hide()
|
||||
self.xml.signal_autoconnect(self)
|
||||
self.window.show_all()
|
||||
|
||||
|
@ -104,7 +108,9 @@ class ProfileWindow:
|
|||
button = self.xml.get_widget('PHOTO_button')
|
||||
image = button.get_image()
|
||||
image.set_from_pixbuf(None)
|
||||
button.set_label(_('Click to set your avatar'))
|
||||
button.hide()
|
||||
text_button = self.xml.get_widget('NOPHOTO_button')
|
||||
text_button.show()
|
||||
self.avatar_encoded = None
|
||||
self.avatar_mime_type = None
|
||||
|
||||
|
@ -152,7 +158,9 @@ class ProfileWindow:
|
|||
button = self.xml.get_widget('PHOTO_button')
|
||||
image = button.get_image()
|
||||
image.set_from_pixbuf(pixbuf)
|
||||
button.set_label('')
|
||||
button.show()
|
||||
text_button = self.xml.get_widget('NOPHOTO_button')
|
||||
text_button.hide()
|
||||
self.avatar_encoded = base64.encodestring(data)
|
||||
# returns None if unknown type
|
||||
self.avatar_mime_type = mimetypes.guess_type(path_to_file)[0]
|
||||
|
@ -202,25 +210,27 @@ class ProfileWindow:
|
|||
pass
|
||||
|
||||
def set_values(self, vcard):
|
||||
if not 'PHOTO' in vcard:
|
||||
# set default image
|
||||
button = self.xml.get_widget('PHOTO_button')
|
||||
image = button.get_image()
|
||||
text_button = self.xml.get_widget('NOPHOTO_button')
|
||||
if not 'PHOTO' in vcard:
|
||||
# set default image
|
||||
image.set_from_pixbuf(None)
|
||||
button.set_label(_('Click to set your avatar'))
|
||||
button.hide()
|
||||
text_button.show()
|
||||
for i in vcard.keys():
|
||||
if i == 'PHOTO':
|
||||
pixbuf, self.avatar_encoded, self.avatar_mime_type = \
|
||||
get_avatar_pixbuf_encoded_mime(vcard[i])
|
||||
button = self.xml.get_widget('PHOTO_button')
|
||||
image = button.get_image()
|
||||
if not pixbuf:
|
||||
image.set_from_pixbuf(None)
|
||||
button.set_label(_('Click to set your avatar'))
|
||||
button.hide()
|
||||
text_button.show()
|
||||
continue
|
||||
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'vcard')
|
||||
image.set_from_pixbuf(pixbuf)
|
||||
button.set_label('')
|
||||
button.show()
|
||||
text_button.hide()
|
||||
continue
|
||||
if i == 'ADR' or i == 'TEL' or i == 'EMAIL':
|
||||
for entry in vcard[i]:
|
||||
|
|
Loading…
Reference in New Issue