Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity/Workshop.activity/Workshop.py
blob: 270b82c4d84a1db1a69efa1d4cb3b3ed39416093 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
import gtk

from WorkshopListItem import WorkshopListItem,Rating

class WorkshopView(gtk.Alignment):
    def __init__(self):
        gtk.Alignment.__init__(self,0.0,0.0,1.0,1.0)
        self.mainView = WorkshopMain()
        self.detailView = WorkshopDetail(None)

        self.add(self.mainView)
        
        self.mainView.show()
        self.detailView.show()

        def set_tutorial_list(self,tutorial_list):
            """
            Set the list of tutorial to display in the main View
            Refresh the View

            @param tutorial_list the list of tutorial
            """
            pass


        def change_sorting(self,sorting_key):
            """
            Sort the list of tutorial base on the sorting_key

            @param sorting_key the tutorial metadata to use to sort the tutorials
            """
            pass

        def refresh_tutorial_info(self):
            """
            Tell the view to refresh the content of the tutorial list because some info have changed

            Call this function when information about tutorial have changed, but the tutorial to display are the same
            """
            pass

        def toggle_tutorial_publish(self,tutorial,published):
            """
            Change the publish/unpublish status of the tutorial on the view

            @param tutorial the tutorial to change the status
            @param published True if the tutorial is published, False if not
            """
            pass
        
        def display_detail(self,tutorial):
            """
            Displays the detail view of a tutorial

            @param tutorial the tutorial to display
            """
            pass

        def display_main_view(self):
            """
            Displays the main view of the Workshop
            """
            pass

        def display_info_dialog(self,tutorial):
            """
            Displays the infos dialog on a tutorial

            @param tutorial the tutorial to edit
            """
            pass


        


class WorkshopMain(gtk.VBox):
    def __init__(self):
        gtk.VBox.__init__(self,False,10)

        self.set_border_width(10)
        self.search_bar = SearchBar()
        self.pack_start(self.search_bar,False,False)

        sep = gtk.HSeparator()
        self.pack_start(sep,False,False)
        self.main_container = gtk.ScrolledWindow()
        self.main_container.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)

        self.list_container= gtk.VBox()

        item = WorkshopListItem()
        self.list_container.pack_start(item,False,False)
        item.show()
        self.main_container.add_with_viewport(self.list_container)
        self.pack_start(self.main_container)

        self.search_bar.show()
        self.list_container.show()
        self.main_container.show()
        sep.show()

class SearchBar(gtk.HBox):
    def __init__(self):
        gtk.HBox.__init__(self,False,10)
        self.set_border_width(5)

        self.search_entry = gtk.Entry(400)
        self.search_button = gtk.Button("Go")
        self.separator = gtk.VSeparator()
        self.sort_label = gtk.Label("Sort by")
        self.sort_combo = gtk.combo_box_new_text()
        self.sort_combo.insert_text(0,"Name")
        self.sort_combo.insert_text(1,"Rating")


        self.pack_start(self.search_entry,padding=5)
        self.pack_start(self.search_button,False,False,padding=10)
        self.pack_start(self.separator,False,False,padding=10)
        self.pack_start(self.sort_label,False,False,padding=5)
        self.pack_start(self.sort_combo,)

        self.search_entry.show()
        self.search_button.show()
        self.separator.show()
        self.sort_label.show()
        self.sort_combo.show()


class WorkshopDetail(gtk.VBox):
    def __init__(self,tutorial):
        self.title_text = '<span size="xx-large">%(title)s</span>'
        self.author_text = '<span size="large">by %(author)s</span>'
        self.desc_text = 'Description: %(description)s'
        
        gtk.VBox.__init__(self,False,10)
        self.set_border_width(10)
        
        first_row = gtk.HBox(False)
        back_image = gtk.Image()
        back_image.set_from_file('arrow_back.png')
        self.back_button = gtk.Button("Back")
        self.back_button.set_image(back_image)

        first_row.pack_start(self.back_button,False,False)

        second_row = gtk.HBox(False)
        icon = gtk.Image()
        icon.set_from_file('icon.svg')

        label_holder = gtk.VBox(False,10)

        self.title_label = gtk.Label("Title")
        self.title_label.set_alignment(0.0,0.5)
        self.author_label = gtk.Label("by Me")
        self.author_label.set_alignment(0.05,0.5)

        label_holder.pack_start(self.title_label)
        label_holder.pack_start(self.author_label)

        self.rating = Rating(3.5)

        second_row.pack_start(icon,False,False)
        second_row.pack_start(label_holder)
        second_row.pack_end(self.rating,False,False)

        self.desc_view = gtk.TextView()
        self.desc_buff = gtk.TextBuffer()
        self.desc_buff.set_text('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris tincidunt orci in eli    t semper aliquam. Pellentesque ut lectus arcu. Mauris arcu dolor, venenatis eget tincidunt vitae, tincidunt ac urna. Quisque sodales odio in risus alique    t laoreet. In commodo porttitor arcu, a viverra dui faucibus nec. Donec neque leo, aliquet eget luctus et, viverra sed turpis. Pellentesque sed turpis qu    am, in placerat mi. Etiam est lorem, tempus sed tempus quis, tempor ut magna. Aenean velit eros, ornare quis rutrum vitae, lacinia et urna. Morbi iaculis     molestie tempus. Proin egestas luctus diam. Suspendisse pretium adipiscing magna, non varius purus molestie vitae. Maecenas laoreet adipiscing nulla eu     consequat. Morbi et felis a nunc fermentum tincidunt eget et enim. Phasellus ligula lorem, vulputate a ullamcorper non, pretium nec libero')
        self.desc_view.set_buffer(self.desc_buff)
        self.desc_view.set_editable(False)
        self.desc_view.set_wrap_mode(gtk.WRAP_WORD)
        self.desc_view.set_cursor_visible(False)
        self.desc_view.connect("realize",self.realize_cb,None)
        self.desc_view.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse("gray") )

        fourth_row = gtk.HBox(False,15)
        self.launch_button = gtk.Button('Launch')
        self.launch_button.get_child().set_markup(self.title_text %{"title":"Launch"})
        self.edit_button = gtk.Button('Edit')
        self.edit_button.get_child().set_markup(self.title_text %{"title":"Edit"})
        self.update_button = gtk.Button('Update')
        self.update_button.get_child().set_markup(self.title_text %{"title":"Update"})
        self.info_button = gtk.Button('Infos')
        self.info_button.get_child().set_markup(self.title_text %{"title":"Infos"})
        self.delete_button = gtk.Button('Delete')
        self.delete_button.get_child().set_markup(self.title_text %{"title":"Delete"})

        fourth_row.pack_start(self.launch_button,False,False)
        fourth_row.pack_start(self.edit_button,False,False)
        fourth_row.pack_start(self.update_button,False,False)
        fourth_row.pack_start(self.info_button,False,False)
        fourth_row.pack_end(self.delete_button,False,False)

        fifth_row = gtk.HBox(False,15)
        self.publish_button = gtk.Button('')
        self.publish_button.get_child().set_markup(self.title_text %{"title":"Publish"})
        self.unpublish_button = gtk.Button('')
        self.unpublish_button.get_child().set_markup(self.title_text %{"title":"Unpublish"})

        fifth_row.pack_start(self.publish_button,False,False)
        fifth_row.pack_start(self.unpublish_button,False,False)

        self.pack_start(first_row,False,False)
        self.pack_start(second_row,False,False)
        self.pack_start(self.desc_view)
        self.pack_end(fifth_row,False,False)
        self.pack_end(fourth_row,False,False)


        self.back_button.show()
        first_row.show()
        self.title_label.show()
        self.author_label.show()
        self.rating.show()
        label_holder.show()
        second_row.show()
        icon.show()
        self.desc_view.show()
        self.launch_button.show()
        self.edit_button.show()
        self.update_button.show()
        self.info_button.show()
        self.delete_button.show()
        fourth_row.show()
        
        self.publish_button.show()
        self.unpublish_button.show()
        fifth_row.show()

        self.title_label.set_markup(self.title_text % {"title":"Tutorial Title"})
        self.author_label.set_markup(self.author_text % {"author":"Tutorial author"})

    def realize_cb(self,widget,data=None):
        widget.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))