~jconti/recent-notifications/trunk

« back to all changes in this revision

Viewing changes to unity/main.py

  • Committer: Jason Conti
  • Date: 2011-03-26 21:20:00 UTC
  • Revision ID: jason.conti@gmail.com-20110326212000-48rj1zased29tne4
Ported Notification.py to gobject introspection, everything except dbus. Going to attempt that next, but may revert if it doesn't work so well yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
"""
3
 
main.py
4
 
March 26, 2011
5
 
 
6
 
The main recent-notifications-unity application.
7
 
"""
8
 
 
9
 
import os
10
 
 
11
 
from gi.repository import GObject, Gtk, Unity
12
 
 
13
 
class MainWindow(Gtk.Window):
14
 
  def __init__(self):
15
 
    GObject.GObject.__init__(self)
16
 
    self.set_title("Recent Notifications")
17
 
    self.set_default_size(400, 400)
18
 
    self.connect("destroy", Gtk.main_quit)
19
 
 
20
 
    self._button = Gtk.Button("Test")
21
 
    self._button.connect("clicked", self.on_button_clicked)
22
 
    self.add(self._button)
23
 
 
24
 
    self._message_count = 0
25
 
 
26
 
    self._launcher = Unity.LauncherEntry.get_for_desktop_id("rn-unity.desktop")
27
 
 
28
 
  def on_button_clicked(self, button):
29
 
    self._message_count += 1
30
 
    self._launcher.set_property("count", self._message_count)
31
 
    if self._message_count > 0:
32
 
      self._launcher.set_property("count_visible", True)
33
 
 
34
 
def main():
35
 
  window = MainWindow()
36
 
  window.show_all()
37
 
  Gtk.main()
38
 
 
39
 
if __name__ == "__main__":
40
 
  main()