1
Index: awn-extras-0.4.0~rc1/applets/maintained/tomboy-applet/tomboy-applet.py
2
===================================================================
3
--- awn-extras-0.4.0~rc1.orig/applets/maintained/tomboy-applet/tomboy-applet.py 2010-03-30 00:41:03.000000000 +0200
4
+++ awn-extras-0.4.0~rc1/applets/maintained/tomboy-applet/tomboy-applet.py 2010-03-30 00:41:42.000000000 +0200
6
# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
-from awn.extras import awnlib, __version__
16
+from awn.extras import awnlib, __version__, _
20
+ from dbus.mainloop.glib import DBusGMainLoop
22
+ DBusGMainLoop(set_as_default=True)
26
-applet_name = "Tomboy Applet"
27
-applet_description = "Control Tomboy with D-Bus"
28
+applet_name = _("Tomboy Applet")
29
+applet_description = _("Control Tomboy with D-Bus")
30
applet_system_notebook = "system:notebook:"
31
applet_system_template = "system:template"
39
def __init__(self, awnlib):
42
awnlib.icon.file(applet_logo)
47
- bus = dbus.SessionBus()
48
- if bus_name not in bus.list_names():
49
- bus.start_service_by_name(bus_name)
51
- except dbus.DBusException, e:
52
- awnlib.errors.general("Could not connect to Tomboy: %s" % e)
53
- threading.Thread(target=run_tomboy).start()
55
+ bus = dbus.SessionBus()
56
+ if bus_name not in bus.list_names():
57
+ bus.start_service_by_name(bus_name)
59
+ except dbus.DBusException, e:
60
+ awnlib.errors.general("Could not connect to Tomboy: %s" % e)
62
def connect(self, bus):
63
object = bus.get_object(bus_name, object_name)
64
self.__interface = dbus.Interface(object, if_name)
65
+ self.__interface.connect_to_signal("NoteAdded", self.notes_changed)
66
+ self.__interface.connect_to_signal("NoteDeleted", self.notes_changed)
67
self.__version = self.__interface.Version()
68
if self.__interface is not None:
71
+ def notes_changed(self, *args, **kwargs):
74
def display_search(self, widget):
75
self.__interface.DisplaySearch()
79
def create_from_tag_dialog(self, widget):
80
dialog = self.awn.dialog.new("create_from_tag")
81
- dialog.add(gtk.Label("Select a tag:"))
82
- for tag in self.collect_tags():
83
- button = gtk.Button(tag)
84
- button.connect("clicked", self.create_from_tag, tag)
86
+ available_tags = self.collect_tags()
87
+ if len(available_tags) > 0:
88
+ dialog.add(gtk.Label(_("Select a tag:")))
89
+ for tag in available_tags:
90
+ button = gtk.Button(tag)
91
+ button.connect("clicked", self.create_from_tag, tag)
94
+ dialog.add(gtk.Label(_("No tags were created yet")))
97
def view_from_tag(self, widget, tag):
98
dialog = self.awn.dialog.new("view_from_tag")
99
- dialog.add(gtk.Label("Select a note:"))
100
+ dialog.add(gtk.Label(_("Select a note:")))
102
for note in self.__interface.GetAllNotesWithTag(applet_system_notebook + tag):
103
if applet_system_template not in self.__interface.GetTagsForNote(note):
106
def view_from_tag_dialog(self, widget):
107
dialog = self.awn.dialog.new("view_from_tag_select")
108
- dialog.add(gtk.Label("Select a tag:"))
109
+ dialog.add(gtk.Label(_("Select a tag:")))
110
for tag in self.collect_tags():
111
button = gtk.Button(tag)
112
button.connect("clicked", self.view_from_tag, tag)
113
@@ -131,28 +141,32 @@
116
def main_dialog(self):
117
- dialog = self.awn.dialog.new("main")
118
+ if self.__dialog != None:
119
+ self.awn.dialog.unregister("main")
120
+ self.__dialog = None
122
+ self.__dialog = dialog = self.awn.dialog.new("main")
124
for note in self.list_all_notes()[:10]:
125
self.button = gtk.Button(self.__interface.GetNoteTitle(note))
126
self.button.connect("clicked", self.button_display, note)
127
dialog.add(self.button)
129
- dialog.add(gtk.Label("Version : " + self.__version))
130
+ dialog.add(gtk.Label(_("Version: %s") % self.__version))
132
- button1 = gtk.Button("Search")
133
+ button1 = gtk.Button(_("Search"))
134
button1.connect("clicked", self.display_search)
137
- button2 = gtk.Button("New Note")
138
+ button2 = gtk.Button(_("New Note"))
139
button2.connect("clicked", self.create_note)
142
- button3 = gtk.Button("New Tagged Note")
143
+ button3 = gtk.Button(_("New Tagged Note"))
144
button3.connect("clicked", self.create_from_tag_dialog)
147
- button4 = gtk.Button("View Tagged Note")
148
+ button4 = gtk.Button(_("View Tagged Note"))
149
button4.connect("clicked", self.view_from_tag_dialog)