Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Workshop.activity/TutoriusActivity.py
blob: f2f3adce17b60b5f52b0231880a7c0673865356b (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Copyright (C) 2009, Tutorius.org
#
# 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.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
from sugar.activity import activity
from TutorialStoreHome import TutorialStore
from Workshop import WorkshopView
from WorkshopModel import WorkshopModel
import logging

import sys, os
import gtk
from dialogs import LoginDialog

class TutoriusActivity(activity.Activity):
        
    def callback(self, widget, button_string):
        
        if button_string == 'search_button':
            self.right_container.remove(self.tutorial_store_home.tutorial_store_home)
        
            results_widget = self.tutorial_store_home.get_results_widget()
        
            self.right_container.pack_start(results_widget)
        
            results_widget.show()
            self.right_container.show()
            
        elif button_string == 'more_button':
            self.right_container.remove(self.tutorial_store_home.tutorial_store_home)
        
            details_widget = self.tutorial_store_home.get_details_widget()
        
            self.right_container.pack_start(details_widget)
        
            details_widget.show()
            self.right_container.show()

    def __init__(self,handle):
        activity.Activity.__init__(self,handle)
        gtk.gdk.threads_init()
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        self.table = gtk.VPaned()
        self.table.set_position(500)
        self.left_container = gtk.HBox()
        btn1 = gtk.Button("My tutorials")
        btn2 = gtk.Button("Tutorial Store")

        self.left_container.pack_start(btn1,expand=False)
        self.left_container.pack_start(btn2,expand=False)
        
        #tutorial_store_search_button = self.tutorial_store_home.get_search_button()
        #tutorial_store_search_button.connect("clicked", self.callback, 'search_button')
        
        #tutorial_store_more_button = self.tutorial_store_home.get_more_button()
        #tutorial_store_more_button.connect("clicked", self.callback, 'more_button')
        
        self.right_container = gtk.VBox()
        #self.right_container.pack_start(self.tutorial_store_home.tutorial_store_home)
        
        self.model = WorkshopModel()
        
        self.workshop_my_tutorial = WorkshopView(self.model)
        self.workshop_store = TutorialStore(self.model)
        self.model.set_workshop_view(self.workshop_my_tutorial)
        self.model.set_store_view(self.workshop_store)
        
        self.model.query(None)
        
        self.table.add2(self.left_container)
        self.table.add1(self.workshop_my_tutorial)
        self.set_canvas(self.table)

        self.workshop_store.show()
        self.workshop_my_tutorial.show()
        self.table.show_all()
        
        
        btn1.connect("clicked",self.display_my_tutorial,None)
        btn2.connect("clicked",self.display_store,None)
    
    def display_store(self,widget,data):
        """
        Display the Tutorial store view
        
        @param widget The widget that made the call
        @param data parameter not used
        """
        if self.table.get_child1() == self.workshop_my_tutorial:
            self.table.remove(self.workshop_my_tutorial)
        if self.table.get_child1() is None:
            logging.info("here store")
            self.table.add1(self.workshop_store)
    
    def display_my_tutorial(self,widget,data):
        """
        Display the My Tutorial view
        
        @param widget The widget that made the call
        @param data parameter not used
        """
        if self.table.get_child1() == self.workshop_store:
            self.table.remove(self.workshop_store)
        if self.table.get_child1() is None:
            logging.info("here my")
            self.table.add1(self.workshop_my_tutorial)