/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to avatarsbox.py

  • Committer: Jelmer Vernooij
  • Date: 2011-11-02 11:11:06 UTC
  • mfrom: (734.1.55 gtk3)
  • Revision ID: jelmer@samba.org-20111102111106-7l0vso8eg24dpf87
Merge gtk3 support from Curtis.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
    def __init__(self, apparent_username):
33
33
        """ Constructor """
34
 
        Gtk.HBox.__init__(self)
 
34
        super(Avatar, self).__init__()
35
35
 
36
36
        self.apparent_username = apparent_username
37
37
        self.username, self.email = parse_username(apparent_username)
65
65
    def show_image(self):
66
66
        """Replace the current content of the Avatar with the Gtk.Image """
67
67
        if self.email and self.image:
68
 
            self.remove(self.get_children()[0])
 
68
            children = self.get_children()
 
69
            if children != []:
 
70
                self.remove(children[0])
69
71
            self.pack_start(self.image, True, True, 0)
70
72
            self.image.set_tooltip_text(self.apparent_username)
71
73
            self.image.show()
75
77
    """HBox showing an avatar."""
76
78
 
77
79
    def __init__(self, homogeneous=False, spacing=0):
78
 
        Gtk.HBox.__init__(self, homogeneous=homogeneous, spacing=spacing)
 
80
        super(AvatarBox, self).__init__(
 
81
            homogeneous=homogeneous, spacing=spacing)
79
82
        self.__avatars = {}
80
83
        self.avatar = None
81
84
        self.__displaying = None
147
150
        self.__displaying = avatar
148
151
 
149
152
    def _show_no_email(self):
150
 
        """Show a Gtk.Label with test 'No email'."""
 
153
        """Show a Gtk.Label with text 'No email'."""
151
154
        no_email = Gtk.Label(label=_i18n("No email"))
152
155
        self.pack_start(no_email, True, True, 0)
153
156
        no_email.show()
157
160
    """GTK container for author and committer avatars."""
158
161
 
159
162
    def __init__(self):
160
 
        Gtk.HBox.__init__(self, homogeneous=False, spacing=10)
161
 
 
 
163
        super(AvatarsBox, self).__init__(homogeneous=False, spacing=10)
162
164
        self.__committer_box = None
163
165
        self.__authors_box = None
164
166
        self._init_gui()
179
181
        # This callback method should be fired by all workers when a request
180
182
        # is done.
181
183
        self.__worker.set_callback_method(self._update_avatar_from_response)
182
 
        self.__worker.start()
 
184
        self.connect('destroy', self.on_destroy)
 
185
 
 
186
    def on_destroy(self, widget):
 
187
        self.__worker.stop()
 
188
        if self.__worker.is_alive():
 
189
            self.__worker.join()
183
190
 
184
191
    def add(self, username, role):
185
192
        """Add the given username in the role box and add in the worker queue.
186
193
        """
187
194
        avatar = Avatar(username)
188
 
        if (role == "author" and not self._role_box_for("committer").showing(avatar)) or role == "committer":
 
195
        is_shown = self._role_box_for("committer").showing(avatar)
 
196
        if (role == "author" and not is_shown) or role == "committer":
189
197
            if self._role_box_for(role).append_avatars_with(avatar):
190
198
                self.__worker.queue(avatar.email)
191
199
 
229
237
            loader.close()
230
238
 
231
239
            for role in ["committer", "author"]:
232
 
                self._role_box_for(role).and_avatar_email(email).update_avatar_image_from_pixbuf_loader(loader)
 
240
                self._role_box_for(role).and_avatar_email(
 
241
                    email).update_avatar_image_from_pixbuf_loader(loader)
233
242
 
234
243
    def _role_box_for(self, role):
235
244
        """ Return the Gtk.HBox for the given role """