summaryrefslogtreecommitdiff
path: root/plugins/python/welcome/board.py
blob: ebebbc3a334423db2d30ec5b2b997a482e76b3df (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
#!/usr/bin/python
# -*- coding: utf-8 -*-

from gi.repository import Gtk


class SmallBoard(Gtk.EventBox):
    """Représente une tuile de support pour le panneau de bienvenue."""


    css = """

#classic {

    border-color: rgba(255, 255, 255, 0.2);
    border-style: solid;
    border-width: 1px;

}

#hover {

    border-color: rgba(255, 255, 255, 0.6);
    border-style: solid;
    border-width: 1px;

}
"""


    def __init__(self):
        """Construit le panneau avec son contenu."""

        super(SmallBoard, self).__init__()

        #self.set_size_request(250, 150)
        self.set_has_window(True)

        self.props.opacity = 0.6

        self._manager = None


    def on_enter(self, widget, event):
        """Réagit à un survol de la zone par la souris."""

        self.set_name('hover')

        self._manager.define_selected_area(self.get_allocation())

        self.props.opacity = 1.0

        return False


    def on_leave(self, widget, event):
        """Réagit à une sortie de la zone par la souris."""

        self.set_name('classic')

        if self._manager != None:
            self._manager.define_selected_area(None)

        self.props.opacity = 0.6

        return False


    def get_location(self):
        """Fournit la localisation souhaitée pour la plache."""

        pass


    def attach(self, manager):
        """Lie partiellement la plache à son support et suit les survols."""

        child = self.get_child()

        if child != None:

            child.props.margin = 20

            self.set_name('classic')

            self._manager = manager


            def track_children(widget, owner):

                widget.connect('enter-notify-event', self.on_enter)
                widget.connect('leave-notify-event', self.on_leave)

                if isinstance(widget, Gtk.Container):

                    children = widget.get_children()

                    for child in children:
                        track_children(child, owner)


            track_children(self, self)