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:
Yann Leboulanger 2007-01-23 12:34:07 +00:00
parent afd2d150d1
commit 20a146dabf
2 changed files with 85 additions and 44 deletions

View File

@ -16,6 +16,7 @@
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</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="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"/> <signal name="destroy" handler="on_profile_window_destroy" last_modification_time="Fri, 08 Sep 2006 11:39:32 GMT"/>
@ -989,41 +990,6 @@
</packing> </packing>
</child> </child>
<child>
<widget class="GtkButton" id="PHOTO_button">
<property name="can_focus">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="Sun, 10 Sep 2006 10:44:01 GMT"/>
<child>
<widget class="GtkEventBox" id="PHOTO_eventbox3">
<property name="visible">True</property>
<property name="visible_window">False</property>
<property name="above_child">False</property>
<child>
<widget class="GtkImage" id="PHOTO_image">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">4</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options"></property>
<property name="y_options">expand</property>
</packing>
</child>
<child> <child>
<widget class="GtkLabel" id="label58"> <widget class="GtkLabel" id="label58">
<property name="visible">True</property> <property name="visible">True</property>
@ -1051,6 +1017,71 @@
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </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>
<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="Sun, 10 Sep 2006 10:44:01 GMT"/>
<child>
<widget class="GtkEventBox" id="PHOTO_eventbox3">
<property name="visible">True</property>
<property name="visible_window">False</property>
<property name="above_child">False</property>
<child>
<widget class="GtkImage" id="PHOTO_image">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</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>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options"></property>
<property name="y_options">expand</property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="tab_expand">False</property> <property name="tab_expand">False</property>

View File

@ -77,6 +77,10 @@ class ProfileWindow:
# Create Image for avatar button # Create Image for avatar button
image = gtk.Image() image = gtk.Image()
self.xml.get_widget('PHOTO_button').set_image(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.xml.signal_autoconnect(self)
self.window.show_all() self.window.show_all()
@ -104,7 +108,9 @@ class ProfileWindow:
button = self.xml.get_widget('PHOTO_button') button = self.xml.get_widget('PHOTO_button')
image = button.get_image() image = button.get_image()
image.set_from_pixbuf(None) 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_encoded = None
self.avatar_mime_type = None self.avatar_mime_type = None
@ -152,7 +158,9 @@ class ProfileWindow:
button = self.xml.get_widget('PHOTO_button') button = self.xml.get_widget('PHOTO_button')
image = button.get_image() image = button.get_image()
image.set_from_pixbuf(pixbuf) 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) self.avatar_encoded = base64.encodestring(data)
# returns None if unknown type # returns None if unknown type
self.avatar_mime_type = mimetypes.guess_type(path_to_file)[0] self.avatar_mime_type = mimetypes.guess_type(path_to_file)[0]
@ -202,25 +210,27 @@ class ProfileWindow:
pass pass
def set_values(self, vcard): def set_values(self, vcard):
button = self.xml.get_widget('PHOTO_button')
image = button.get_image()
text_button = self.xml.get_widget('NOPHOTO_button')
if not 'PHOTO' in vcard: if not 'PHOTO' in vcard:
# set default image # set default image
button = self.xml.get_widget('PHOTO_button')
image = button.get_image()
image.set_from_pixbuf(None) image.set_from_pixbuf(None)
button.set_label(_('Click to set your avatar')) button.hide()
text_button.show()
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])
button = self.xml.get_widget('PHOTO_button')
image = button.get_image()
if not pixbuf: if not pixbuf:
image.set_from_pixbuf(None) image.set_from_pixbuf(None)
button.set_label(_('Click to set your avatar')) button.hide()
text_button.show()
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.set_label('') button.show()
text_button.hide()
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]: