/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-01 20:28:54 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110801202854-eybt6inxyjg7shz6
Added a very rough fix to see gannontation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
from gi.repository import Gtk
18
 
from gi.repository import GdkPixbuf
19
18
 
20
19
from bzrlib.config import parse_username
21
20
 
31
30
 
32
31
    def __init__(self, apparent_username):
33
32
        """ Constructor """
34
 
        super(Avatar, self).__init__()
 
33
        Gtk.HBox.__init__(self)
35
34
 
36
35
        self.apparent_username = apparent_username
37
36
        self.username, self.email = parse_username(apparent_username)
65
64
    def show_image(self):
66
65
        """Replace the current content of the Avatar with the Gtk.Image """
67
66
        if self.email and self.image:
68
 
            children = self.get_children()
69
 
            if children != []:
70
 
                self.remove(children[0])
 
67
            self.remove(self.get_children()[0])
71
68
            self.pack_start(self.image, True, True, 0)
72
69
            self.image.set_tooltip_text(self.apparent_username)
73
70
            self.image.show()
77
74
    """HBox showing an avatar."""
78
75
 
79
76
    def __init__(self, homogeneous=False, spacing=0):
80
 
        super(AvatarBox, self).__init__(
81
 
            homogeneous=homogeneous, spacing=spacing)
 
77
        Gtk.HBox.__init__(self, homogeneous=homogeneous, spacing=spacing)
82
78
        self.__avatars = {}
83
79
        self.avatar = None
84
80
        self.__displaying = None
150
146
        self.__displaying = avatar
151
147
 
152
148
    def _show_no_email(self):
153
 
        """Show a Gtk.Label with text 'No email'."""
 
149
        """Show a Gtk.Label with test 'No email'."""
154
150
        no_email = Gtk.Label(label=_i18n("No email"))
155
151
        self.pack_start(no_email, True, True, 0)
156
152
        no_email.show()
160
156
    """GTK container for author and committer avatars."""
161
157
 
162
158
    def __init__(self):
163
 
        super(AvatarsBox, self).__init__(homogeneous=False, spacing=10)
 
159
        Gtk.HBox.__init__(self, homogeneous=False, spacing=10)
 
160
 
164
161
        self.__committer_box = None
165
162
        self.__authors_box = None
166
163
        self._init_gui()
181
178
        # This callback method should be fired by all workers when a request
182
179
        # is done.
183
180
        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()
 
181
        self.__worker.start()
190
182
 
191
183
    def add(self, username, role):
192
184
        """Add the given username in the role box and add in the worker queue.
193
185
        """
194
186
        avatar = Avatar(username)
195
 
        is_shown = self._role_box_for("committer").showing(avatar)
196
 
        if (role == "author" and not is_shown) or role == "committer":
 
187
        if (role == "author" and not self._role_box_for("committer").showing(avatar)) or role == "committer":
197
188
            if self._role_box_for(role).append_avatars_with(avatar):
198
189
                self.__worker.queue(avatar.email)
199
190
 
230
221
        :param response: a urllib2.urlopen() return value.
231
222
        :param email: used to identify item from self.__avatars.
232
223
        """
233
 
        if email:
234
 
            # Convert downloaded image from provider to Gtk.Image
235
 
            loader = GdkPixbuf.PixbufLoader()
236
 
            loader.write(response.read())
237
 
            loader.close()
 
224
        # XXX sinzui 2011-08-01: This must be implemented in cairo
 
225
#        if email:
 
226
#            # Convert downloaded image from provider to Gtk.Image
 
227
#            loader = Gdk.GdkPixbuf.PixbufLoader()
 
228
#            loader.write(response.read())
 
229
#            loader.close()
238
230
 
239
 
            for role in ["committer", "author"]:
240
 
                self._role_box_for(role).and_avatar_email(
241
 
                    email).update_avatar_image_from_pixbuf_loader(loader)
 
231
#            for role in ["committer", "author"]:
 
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 """