~jconti/recent-notifications/trunk

« back to all changes in this revision

Viewing changes to recent_notifications/Main.py

  • Committer: Jason Conti
  • Date: 2011-03-01 21:45:18 UTC
  • Revision ID: jason.conti@gmail.com-20110301214518-0r2lqeld3aw3i78l
Moved the unread message label to the toggle button, so that it will be highlighted when the button is clicked.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    icon_size = self.get_icon_size(self._applet_size)
41
41
    self.load_icons(icon_size)
42
42
 
43
 
    if self.get_orient() in (gnomeapplet.ORIENT_LEFT, gnomeapplet.ORIENT_RIGHT):
44
 
      self._box = gtk.VBox()
45
 
    else:
46
 
      self._box = gtk.HBox()
47
 
    self._applet.add(self._box)
48
 
 
49
43
    self._button = ImageToggleButton()
50
44
    self._button.set_from_pixbuf(self._read_icon)
51
45
    self._button.set_orient(self.get_orient())
52
46
    self._button.connect("toggled", self.on_button_toggled)
53
47
    self._button.show()
54
 
    self._box.pack_start(self._button)
55
 
 
56
 
    self._unread_label = gtk.Label("0")
57
 
    self._unread_label.show()
 
48
    self._applet.add(self._button)
58
49
 
59
50
    self._applet.setup_menu(Template("""
60
51
      <popup name="button3">
173
164
    n = self._unread_messages
174
165
    label = ngettext("1 unread message", "{0} unread messages", n).format(n)
175
166
    self._button.set_tooltip_text(label)
176
 
    self._unread_label.set_text(str(n))
 
167
    if self._show_count:
 
168
      self._button.set_label(str(n))
177
169
 
178
170
  def show_window(self):
179
171
    """Shows the applet window"""
203
195
    """Updates the button orientation when the panel changes orientation"""
204
196
    self._button.set_orient(orient)
205
197
 
206
 
    old_box = self._box
207
 
    old_box.remove(self._button)
208
 
    if self._show_count:
209
 
      old_box.remove(self._unread_label)
210
 
 
211
 
    if orient in (gnomeapplet.ORIENT_LEFT, gnomeapplet.ORIENT_RIGHT):
212
 
      self._box = gtk.VBox()
213
 
    else:
214
 
      self._box = gtk.HBox()
215
 
 
216
 
    self._applet.remove(old_box)
217
 
    self._applet.add(self._box)
218
 
 
219
 
    self._box.pack_start(self._button)
220
 
 
221
 
    if self._preferences.get_bool("show_count", False):
222
 
      self._box.pack_start(self._unread_label)
223
 
      self._show_count = True
224
 
 
225
 
    self._applet.show_all()
226
 
 
227
 
    old_box.destroy()
228
 
 
229
198
  def on_applet_destroyed(self, applet):
230
199
    """Stop the message notifications before destroying the applet."""
231
200
    self._notify.close()
263
232
    elif key == "message_limit":
264
233
      self._window.set_message_limit(self._preferences.get_int(key, 0))
265
234
    elif key == "show_count":
266
 
      if self._preferences.get_bool(key, False):
267
 
        if not self._show_count:
268
 
          self._box.pack_end(self._unread_label)
269
 
          self._show_count = True
 
235
      self._show_count = self._preferences.get_bool(key, False)
 
236
      if self._show_count:
 
237
        self.update()
270
238
      else:
271
 
        if self._show_count:
272
 
          self._box.remove(self._unread_label)
273
 
          self._show_count = False
 
239
        self._button.set_label("")
274
240