-
Notifications
You must be signed in to change notification settings - Fork 385
/
scratchwindow.py
63 lines (49 loc) · 2.12 KB
/
scratchwindow.py
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
# This file is part of MyPaint.
# Copyright (C) 2011-2018 by the MyPaint Development Team.
# Copyright (C) 2011 by Ben O'Steen <bosteen@gmail.com>
#
# This program 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 2 of the License, or
# (at your option) any later version.
"""Scratchpad panel"""
## Imports
from __future__ import division, print_function
import logging
from lib.gettext import gettext as _
from .toolstack import SizedVBoxToolWidget, TOOL_WIDGET_NATURAL_HEIGHT_SHORT
from .widgets import inline_toolbar
from lib.gibindings import Gtk
logger = logging.getLogger(__name__)
## Class defs
class ScratchpadTool (SizedVBoxToolWidget):
__gtype_name__ = 'MyPaintScratchpadTool'
SIZED_VBOX_NATURAL_HEIGHT = TOOL_WIDGET_NATURAL_HEIGHT_SHORT
tool_widget_title = _("Scratchpad")
tool_widget_icon_name = 'mypaint-scratchpad-symbolic'
tool_widget_description = _("Mix colors and make sketches on "
"separate scrap pages")
def __init__(self):
super(SizedVBoxToolWidget, self).__init__()
from gui.application import get_app
app = get_app()
self.app = app
toolbar = inline_toolbar(
app, [
("ScratchNew", "mypaint-add-symbolic"),
("ScratchLoad", None),
("ScratchSaveAs", "mypaint-document-save-symbolic"),
("ScratchRevert", "mypaint-document-revert-symbolic"),
])
scratchpad_view = app.scratchpad_doc.tdw
scratchpad_view.set_size_request(64, 64)
self.connect("destroy-event", self._save_cb)
self.connect("delete-event", self._save_cb)
scratchpad_box = Gtk.EventBox()
scratchpad_box.add(scratchpad_view)
self.pack_start(scratchpad_box, True, True, 0)
self.pack_start(toolbar, False, True, 0)
def _save_cb(self, action):
filename = self.app.scratchpad_filename
logger.info("Saving the scratchpad to %r", filename)
self.app.filehandler.save_scratchpad(filename)