Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/OficinaActivity.py
blob: add4fca02ed50d0726f664da752d38f1d9a1ed13 (plain)
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
import os
from gettext import gettext as _

import gtk

from sugar.activity import activity

#from Oficina import Oficina
from toolbox import Toolbox
from Area import Area
from Cursors import Cursors

# DRAW_WIDTH  = 1195
# DRAW_HEIGHT = 800

class OficinaActivity(activity.Activity):
    def __init__(self, handle):
        """Initialize the OficinaActivity object.

            Keyword arguments:
            self -- 
            handle --

        """
        activity.Activity.__init__(self, handle)

        os.chdir(activity.get_bundle_path())
        #print activity.get_bundle_path()
        
        toolbox = Toolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()       
  

        # addind a textview widget
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        self._fixed = gtk.Fixed()	
        self._area = Area(self)	
        color = gtk.gdk.color_parse("white")
        self._fixed.modify_bg(gtk.STATE_NORMAL, color)

	self.bg = gtk.Image()
	self.bg.set_from_file('./icons/bg.svg')
	self._fixed.put(self.bg, 200, 100)
        self.bg.show()

        #FIXME: use a textview instead of a Entry
        #self._textview = gtk.TextView()
        self._textview = gtk.Entry()
        self._area.tool = 2
        self._fixed.put(self._area, 200 , 100)

        sw.add_with_viewport(self._fixed)
        self._area.show()
        self._fixed.show()


        self._fixed.put(self._textview, 0, 0)
        self._textview.hide()
        sw.show()

        # setting scrolledwindow as activity canvas...
        self.set_canvas(sw)


    def read_file(self, file_path):
        '''Read file from Sugar Journal.

        self --
		file_path --

        '''
        print 'read file...'
        print file_path
        #self._area.d.limpatudo()
        #self._area.d.clear()
        self._area.d.loadImage(file_path)


    def write_file(self, file_path):
        '''Save file on Sugar Journal.

		self --
		file_path -- 

        '''
        print file_path
        width, height = self._area.window.get_size()
        pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
        pixbuf.get_from_drawable(self._area.pixmap, gtk.gdk.colormap_get_system(), 0, 0, 0, 0, -1, -1)
        pixbuf.save(file_path, 'png', {})