Ticket #4008: activity.py

File activity.py, 7.5 KB (added by erikos, 11 years ago)

test case that can be used with the helloworld activity

Line 
1# Copyright 2009 Simon Schampijer
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16
17"""HelloWorld Activity: A case study for developing an activity."""
18
19from gi.repository import Gtk
20import logging
21
22from gettext import gettext as _
23
24from sugar3.activity import activity
25from sugar3.graphics.toolbarbox import ToolbarBox
26from sugar3.activity.widgets import ActivityButton, ActivityToolbarButton
27from sugar3.activity.widgets import TitleEntry
28from sugar3.activity.widgets import StopButton
29from sugar3.activity.widgets import ShareButton
30from sugar3.activity.widgets import DescriptionItem
31
32from sugar3.graphics.colorbutton import ColorToolButton
33
34class HelloWorldActivity(activity.Activity):
35    """HelloWorldActivity class as specified in activity.info"""
36
37    def __init__(self, handle):
38        """Set up the HelloWorld activity."""
39        activity.Activity.__init__(self, handle)
40
41        # we do not have collaboration features
42        # make the share option insensitive
43        self.max_participants = 1
44
45        # toolbar with the new toolbar redesign
46        toolbar_box = ToolbarBox()
47
48        activity_button = ActivityToolbarButton(self)
49        toolbar_box.toolbar.insert(activity_button, 0)
50        activity_button.show()
51
52        title_entry = TitleEntry(self)
53        toolbar_box.toolbar.insert(title_entry, -1)
54        title_entry.show()
55
56        color_button = ColorToolButton()
57        toolbar_box.toolbar.insert(color_button, -1)
58        color_button.show()
59
60        description_item = DescriptionItem(self)
61        toolbar_box.toolbar.insert(description_item, -1)
62        description_item.show()
63
64        share_button = ShareButton(self)
65        toolbar_box.toolbar.insert(share_button, -1)
66        share_button.show()
67       
68        separator = Gtk.SeparatorToolItem()
69        separator.props.draw = False
70        separator.set_expand(True)
71        toolbar_box.toolbar.insert(separator, -1)
72        separator.show()
73
74        stop_button = StopButton(self)
75        toolbar_box.toolbar.insert(stop_button, -1)
76        stop_button.show()
77
78        self.set_toolbar_box(toolbar_box)
79        toolbar_box.show()
80
81        scrolledwindow = Gtk.ScrolledWindow()
82        scrolledwindow.set_hexpand(True)
83        scrolledwindow.set_vexpand(True)
84
85        self.textview = Gtk.TextView()
86        self.textview.set_wrap_mode(Gtk.WrapMode.WORD)
87        self.textbuffer = self.textview.get_buffer()
88
89        self.textbuffer.set_text('Hi this is a test, selecting is a must!'
90                                 'Let\'s try if we can do that in several lines as well.'
91                                 'Try to select the following paragraph: \"Please select me\"'
92                                 'and then we have done the first part of this test. \n\n\n\n'
93                                 'Let\'s see how this goes.'
94                                 '\n\n\n\n\n\n Here the text continues...\n\n\n\n'
95                                 '\n\n and then again another paragraph to make this even bigger...'
96                                 '\n\n\n\n\n\n Here the text continues...\n\n\n\n'
97                                 'Hi this is a test, selecting is a must!'
98                                 'Let\'s try if we can do that in several lines as well.'
99                                 'Try to select the following paragraph: \"Please select me\"'
100                                 'and then we have done the first part of this test. '
101                                 '\n\n\n\n\n\n Here the text continues...'
102                                 '\n\n and then again another paragraph to make this even bigger...'
103                                 '\n\n\n\n\n\n Here the text continues...\n\n\n\n'
104                                 'The move from Fedora 17 to Fedora 18 has some risks. However the'
105                                 'new features do not seem particularly risky for us. '
106                                 'The ARM builders are already doing a good job on Fedora 18.'
107                                 'A lot of work is needed for the Sugar GTK3 and touch efforts. '
108                                 'Alignment with the proposed Sugar-0.98 release cycle aims to '
109                                 'maximize the development time available while also leaving '
110                                 'time for stabilisation. However the Sugar cycle is aligned '
111                                 'to a later point in this plan, meaning risk is improved: '
112                                 'we have very little room for delay,'
113                                 'and we can\'t slip on implementing major features or fixing major issues. \n\n\n\n'
114                                 'Risk in general is mitigated by the possibility of delaying the whole \n\n\n\n'
115                                 'release cycle if hardware production delays become known. '
116                                 'Let\'s try if we can do that in several lines as well.'
117                                 'Try to select the following paragraph: \"Please select me\"'
118                                 'and then we have done the first part of this test. \n\n\n\n'
119                                 'Let\'s see how this goes.'
120                                 '\n\n\n\n\n\n Here the text continues...\n\n\n\n'
121                                 '\n\n and then again another paragraph to make this even bigger...'
122                                 '\n\n\n\n\n\n Here the text continues...\n\n\n\n'
123                                 'Hi this is a test, selecting is a must!'
124                                 'Let\'s try if we can do that in several lines as well.'
125                                 'Try to select the following paragraph: \"Please select me\"'
126                                 'and then we have done the first part of this test. '
127                                 '\n\n\n\n\n\n Here the text continues...'
128                                 '\n\n and then again another paragraph to make this even bigger...'
129                                 '\n\n\n\n\n\n Here the text continues...\n\n\n\n'
130                                 'The move from Fedora 17 to Fedora 18 has some risks. However the'
131                                 'new features do not seem particularly risky for us. '
132                                 'The ARM builders are already doing a good job on Fedora 18.'
133                                 'A lot of work is needed for the Sugar GTK3 and touch efforts. '
134                                 'Alignment with the proposed Sugar-0.98 release cycle aims to '
135                                 'maximize the development time available while also leaving '
136                                 'time for stabilisation. However the Sugar cycle is aligned '
137                                 'to a later point in this plan, meaning risk is improved: '
138                                 'we have very little room for delay,'
139)
140        scrolledwindow.add(self.textview)
141        self.textview.show()
142
143        self.set_canvas(scrolledwindow)
144        scrolledwindow.show()
145