diff --git a/usr/lib/sticky/sticky.py b/usr/lib/sticky/sticky.py index 2b227e9..c8991f8 100755 --- a/usr/lib/sticky/sticky.py +++ b/usr/lib/sticky/sticky.py @@ -130,6 +130,7 @@ def __init__(self, app, parent, info={}): title = info.get('title', '') self.cached_text = info.get('text', '') self.color = info.get('color', self.app.settings.get_string('default-color')) + self.locked = info.get('locked', False) super(Note, self).__init__( skip_taskbar_hint=True, @@ -197,6 +198,14 @@ def __init__(self, app, parent, info={}): close_button.set_tooltip_text(_("Delete Note")) self.title_bar.pack_end(close_button, False, False, 0) + self.lock_icon = Gtk.Image.new_from_icon_name('sticky-lock', Gtk.IconSize.BUTTON) + self.unlock_icon = Gtk.Image.new_from_icon_name('sticky-unlock', Gtk.IconSize.BUTTON) + self.lock_button = Gtk.Button(image={False:self.unlock_icon, True:self.lock_icon}[self.locked], relief=Gtk.ReliefStyle.NONE, name='window-button', valign=Gtk.Align.CENTER) + self.lock_button.connect('clicked', self.on_lock_toggle, self) + self.lock_button.connect('button-press-event', self.on_title_click) + self.lock_button.set_tooltip_text(_("Lock/Unlock Edit")) + self.title_bar.pack_end(self.lock_button, False, False, 0) + add_icon = Gtk.Image.new_from_icon_name('sticky-add', Gtk.IconSize.BUTTON) add_button = Gtk.Button(image=add_icon, relief=Gtk.ReliefStyle.NONE, name='window-button', valign=Gtk.Align.CENTER) add_button.connect('clicked', self.app.new_note, self) @@ -228,6 +237,8 @@ def __init__(self, app, parent, info={}): self.view.connect('populate-popup', lambda w, p: self.add_context_menu_items(p)) self.view.connect('key-press-event', self.on_key_press) self.view_style_manager = XApp.StyleManager(widget=self.view) + self.view.set_cursor_visible(not self.locked) + self.view.set_editable(not self.locked) scroll = Gtk.ScrolledWindow() self.add(scroll) @@ -397,7 +408,8 @@ def get_info(self): 'width': self.width, 'color': self.color, 'title': self.title.get_text(), - 'text': self.cached_text + 'text': self.cached_text, + 'locked': self.locked } return info @@ -598,6 +610,15 @@ def save_title(self, w, event): return Gdk.EVENT_STOP + def on_lock_toggle(self, *args): + # locked = not editable + self.locked = self.view.get_editable() + self.view.set_editable(not self.locked) + self.view.set_cursor_visible(not self.locked) + self.lock_button.set_image({False:self.unlock_icon, True:self.lock_icon}[self.locked]) + + self.emit('update') + class SettingsWindow(XApp.PreferencesWindow): def __init__(self, app): super(SettingsWindow, self).__init__(skip_taskbar_hint=False, title=_("Preferences")) diff --git a/usr/share/icons/hicolor/scalable/status/sticky-lock.svg b/usr/share/icons/hicolor/scalable/status/sticky-lock.svg new file mode 100644 index 0000000..d463fe1 --- /dev/null +++ b/usr/share/icons/hicolor/scalable/status/sticky-lock.svg @@ -0,0 +1,8 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"> + <defs> + <style id="current-color-scheme" type="text/css"> + .ColorScheme-Text { color:#404040; } .ColorScheme-Highlight { color:#5294e2; } + </style> + </defs> + <path style="fill:currentColor" class="ColorScheme-Text" d="M 12.5 7 L 11.5 7 L 11.5 3.5 C 11.5 1.570312 9.929688 0 8 0 C 6.070312 0 4.5 1.570312 4.5 3.5 L 4.5 7 L 3.5 7 C 2.949219 7 2.5 7.449219 2.5 8 L 2.5 15 C 2.5 15.550781 2.949219 16 3.5 16 L 12.5 16 C 13.050781 16 13.5 15.550781 13.5 15 L 13.5 8 C 13.5 7.449219 13.050781 7 12.5 7 Z M 8.5 12.410156 L 8.5 13.5 C 8.5 13.777344 8.277344 14 8 14 C 7.722656 14 7.5 13.777344 7.5 13.5 L 7.5 12.40625 C 6.917969 12.203125 6.5 11.652344 6.5 11 C 6.5 10.171875 7.171875 9.5 8 9.5 C 8.828125 9.5 9.5 10.171875 9.5 11 C 9.5 11.652344 9.082031 12.203125 8.5 12.410156 Z M 6.5 7 L 6.5 3.5 C 6.5 2.671875 7.171875 2 8 2 C 8.828125 2 9.5 2.671875 9.5 3.5 L 9.5 7 Z M 6.5 7 "></path> +</svg> \ No newline at end of file diff --git a/usr/share/icons/hicolor/scalable/status/sticky-unlock.svg b/usr/share/icons/hicolor/scalable/status/sticky-unlock.svg new file mode 100644 index 0000000..b5864a9 --- /dev/null +++ b/usr/share/icons/hicolor/scalable/status/sticky-unlock.svg @@ -0,0 +1,8 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"> + <defs> + <style id="current-color-scheme" type="text/css"> + .ColorScheme-Text { color:#404040; } .ColorScheme-Highlight { color:#5294e2; } + </style> + </defs> + <path style="fill:currentColor" class="ColorScheme-Text" d="M 11.5 0 C 9.570312 0 8 1.570312 8 3.5 L 8 7 L 2 7 C 1.449219 7 1 7.449219 1 8 L 1 15 C 1 15.550781 1.449219 16 2 16 L 11 16 C 11.550781 16 12 15.550781 12 15 L 12 8 C 12 7.449219 11.550781 7 11 7 L 10 7 L 10 3.5 C 10 2.671875 10.671875 2 11.5 2 C 12.328125 2 13 2.671875 13 3.5 L 13 6 C 13 6.550781 13.449219 7 14 7 C 14.550781 7 15 6.550781 15 6 L 15 3.5 C 15 1.570312 13.429688 0 11.5 0 Z M 7 12.410156 L 7 13.5 C 7 13.777344 6.777344 14 6.5 14 C 6.222656 14 6 13.777344 6 13.5 L 6 12.40625 C 5.417969 12.203125 5 11.652344 5 11 C 5 10.171875 5.671875 9.5 6.5 9.5 C 7.328125 9.5 8 10.171875 8 11 C 8 11.652344 7.582031 12.203125 7 12.410156 Z M 7 12.410156 "/> +</svg> \ No newline at end of file