/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: Curtis Hovey
  • Date: 2011-08-27 18:35:08 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110827183508-ugqbp58na4mtt1no
Updated the pixbuf calls to gtk3.

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