Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Workshop.activity/TutorialStoreSuggestion.py
blob: 45fc1c35532d3250bcec8e20395b1c73dae4465e (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
import sys, os
import gtk

class TutorialStoreSuggestion(gtk.HBox):

    def __init__(self,controller):
        gtk.HBox.__init__(self,homogeneous=True, spacing=5)
        self.controller = controller
        
        self.popular = gtk.VBox(homogeneous=True, spacing=0)
        self.popular_frame = gtk.Frame('Most Popular')

        #top_five.pack_start(tutorial1_frame, expand=True, fill=True, padding=0)
        #top_five.pack_start(tutorial2_frame, expand=True, fill=True, padding=0)
        #top_five.pack_start(tutorial3_frame, expand=True, fill=True, padding=0)
        
        self.also_like = gtk.VBox(homogeneous=True, spacing=0)
        self.also_like_frame = gtk.Frame('You might also like :')

        #also_like.pack_start(tutorial4_frame, expand=True, fill=True, padding=0)
        #also_like.pack_start(tutorial5_frame, expand=True, fill=True, padding=0)
        #also_like.pack_start(tutorial6_frame, expand=True, fill=True, padding=0)

        self.popular_frame.add(self.popular)
        self.also_like_frame.add(self.also_like)
        
        self.popular.show()
        self.popular_frame.show()
        self.also_like.show()
        self.also_like_frame.show()
        
        self.pack_start(self.popular_frame)
        self.pack_start(self.also_like_frame)
        
    def set_popular(self,tutorials):
        for child in self.popular.get_children():
            self.popular.remove(child)
        if len(tutorials)> 3:
            for x in range(0,3):
                item = SuggestionListItem(self.controller,tutorials[x])
                self.popular.pack_start(item)
                item.show()
        else:
            for x in tutorials:
                item = SuggestionListItem(self.controller,x)
                self.popular.pack_start(item)
                item.show()
    
    def set_also_like(self,tutorials):
        for child in self.also_like.get_children():
            self.also_like.remove(child)
        if len(tutorials)> 3:
            for x in range(0,3):
                item = SuggestionListItem(self.controller,tutorials[x])
                self.also_like.pack_start(item)
                item.show()
        else:
            for x in tutorials:
                item = SuggestionListItem(self.controller,x)
                self.also_like.pack_start(item)
                item.show()

class SuggestionListItem(gtk.Frame):
    def __init__(self,controller,tutorial):
        gtk.Frame.__init__(self)
        
        self.container = gtk.HBox()
        
        self.label = gtk.Label(tutorial.name)
        self.icon = gtk.Image()
        self.icon.set_from_file('icon.svg')
        self.button = gtk.Button("More")
        
        self.container.pack_start(icon5, expand=True, fill=True, padding=4)
        self.container.pack_start(label5, expand=True, fill=True, padding=0)
        self.container.pack_start(more_button5, expand=False, fill=False, padding=5)
        self.add(self.container)
        #tutorial5_frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0,0,0))
        
        self.container.show_all()