1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#!/usr/bin/python3
#
# Copyright © 2012 Umang Varma <umang.me@gmail.com>
#
# This file is part of indicator-stickynotes.
#
# indicator-stickynotes is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# indicator-stickynotes is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# indicator-stickynotes. If not, see <http://www.gnu.org/licenses/>.
from stickynotes.backend import Note, NoteSet
from stickynotes.gui import StickyNote
from gi.repository import Gtk, Gdk
from gi.repository import AppIndicator3 as appindicator
class IndicatorStickyNotes:
def __init__(self):
# Initialize NoteSet
self.nset = NoteSet(StickyNote)
self.nset.open()
self.nset.showall()
# Create App Indicator
self.ind = appindicator.Indicator.new(
"Sticky Notes", "indicator-stickynotes",
appindicator.IndicatorCategory.APPLICATION_STATUS)
self.ind.set_status(appindicator.IndicatorStatus.ACTIVE)
self.ind.set_title("Sticky Notes")
# Create Menu
self.menu = Gtk.Menu()
self.mNewNote = Gtk.MenuItem("New Note")
self.menu.append(self.mNewNote)
self.mNewNote.connect("activate", self.new_note, None)
self.mNewNote.show()
s = Gtk.SeparatorMenuItem.new()
self.menu.append(s)
s.show()
self.mShowAll = Gtk.MenuItem("Show All")
self.menu.append(self.mShowAll)
self.mShowAll.connect("activate", self.showall, None)
self.mShowAll.show()
self.mHideAll = Gtk.MenuItem("Hide All")
self.menu.append(self.mHideAll)
self.mHideAll.connect("activate", self.hideall, None)
self.mHideAll.show()
s = Gtk.SeparatorMenuItem.new()
self.menu.append(s)
s.show()
self.mLockAll = Gtk.MenuItem("Lock All")
self.menu.append(self.mLockAll)
self.mLockAll.connect("activate", self.lockall, None)
self.mLockAll.show()
self.mUnlockAll = Gtk.MenuItem("Unlock All")
self.menu.append(self.mUnlockAll)
self.mUnlockAll.connect("activate", self.unlockall, None)
self.mUnlockAll.show()
s = Gtk.SeparatorMenuItem.new()
self.menu.append(s)
s.show()
self.mQuit = Gtk.MenuItem("Quit")
self.menu.append(self.mQuit)
self.mQuit.connect("activate", Gtk.main_quit, None)
self.mQuit.show()
# Connect Indicator to menu
self.ind.set_menu(self.menu)
def new_note(self, *args):
self.nset.new()
def showall(self, *args):
self.nset.showall(*args)
def hideall(self, *args):
self.nset.hideall()
def lockall(self, *args):
for note in self.nset.notes:
note.gui.set_locked_state(True)
def unlockall(self, *args):
for note in self.nset.notes:
note.gui.set_locked_state(False)
def save(self):
self.nset.save()
def main():
indicator = IndicatorStickyNotes()
Gtk.main()
indicator.save()
if __name__ == "__main__":
main()
|