diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-09-21 19:29:39 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-09-21 19:29:39 (GMT) |
commit | b6afbe8c699ae76443628badae33beee9934c6bc (patch) | |
tree | 69878624d3ae529314a9824f0c0ceca8bca617b7 /plugins/python/welcome/panel.py | |
parent | 291968f4f4a5e85f6963813a43f2176320fb8d49 (diff) |
Provided a real welcome panel at startup, with tricks and actions.
Diffstat (limited to 'plugins/python/welcome/panel.py')
-rw-r--r-- | plugins/python/welcome/panel.py | 148 |
1 files changed, 0 insertions, 148 deletions
diff --git a/plugins/python/welcome/panel.py b/plugins/python/welcome/panel.py deleted file mode 100644 index a577c8c..0000000 --- a/plugins/python/welcome/panel.py +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -from welcome.binary import NewBinary -from welcome.version import VersionChecker -from welcome.website import WebInvitation -from welcome.board import SmallBoard -from welcome.tip import TipOfTheDay -from gi.repository import GObject, Gtk, Gdk -from pychrysalide.gui.panels import PanelItem - - -class WelcomePanel(PanelItem): - """Display a welcome panel if nothing is open in the main part of the editor.""" - - - def __init__(self): - """Initialize the Python instance of the panel.""" - - content = self._build_panel_content() - - super(WelcomePanel, self).__init__(PanelItem.PIP_SINGLETON, 'Welcome', 'First commands', \ - content, False, 'N') - - - def _build_panel_content(self): - """Build content for the welcome panel.""" - - self._area = None - - # Constitution du support principal - - support = Gtk.Grid() - - support.props.halign = Gtk.Align.CENTER - support.props.valign = Gtk.Align.CENTER - support.props.margin = 20 - - support.set_column_homogeneous(True) - support.set_row_homogeneous(True) - support.set_column_spacing(20) - support.set_row_spacing(20) - - # Mise en place des différentes tuiles - - cells = { } - - for x in range(4): - for y in range(3): - cells[(x, y)] = False - - tiles = [ - - NewBinary(), - VersionChecker(), - WebInvitation(), - TipOfTheDay() - - ] - - for t in tiles: - - x, y, w, h = t.get_location() - - for i in range(x, x + w): - for j in range(y, y + h): - assert(cells[(i, j)] == False) - cells[(i, j)] = True - - t.attach(self) - support.attach(t, x, y, w, h) - - for x in range(4): - for y in range(3): - if not cells[(x, y)]: - tile = SmallBoard() - tile.attach(self) - support.attach(tile, x, y, 1, 1) - - # Charge les styles propres aux panneaux - - style_provider = Gtk.CssProvider() - - style_provider.load_from_data(SmallBoard.css.encode()) - - Gtk.StyleContext.add_provider_for_screen( - Gdk.Screen.get_default(), - style_provider, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ) - - - support.show_all() - return support - - - def define_selected_area(self, area): - - self._area = area - - #### - #self.queue_draw() - - - def draw_selected_area(self, widget, cr): - - - alloc = widget.get_allocation() - - - - - def draw_rounded2(cr, area, radius): - """ draws rectangles with rounded (circular arc) corners """ - from math import pi - a,b,c,d=area - cr.arc(a + radius, c + radius, radius, 2*(pi/2), 3*(pi/2)) - cr.arc(b - radius, c + radius, radius, 3*(pi/2), 4*(pi/2)) - cr.arc(b - radius, d - radius, radius, 0*(pi/2), 1*(pi/2)) # ;o) - cr.arc(a + radius, d - radius, radius, 1*(pi/2), 2*(pi/2)) - cr.rectangle(self._area.x, self._area.y, self._area.width, self._area.height) - cr.close_path() - cr.fill() - - - if self._area != None: - cr.set_source_rgba(0, 0, 0, 0.15) - - border = 4 - - pts = ( self._area.x - border, self._area.x + self._area.width + border, - self._area.y - border, self._area.y + self._area.height + border ) - - #cr.save() - - draw_rounded2(cr, pts, 16) - - ctx = self.get_style_context() - - - Gtk.render_background(ctx, cr, 0, 20, 100, 100) - Gtk.render_background(ctx, cr, self._area.x, self._area.y, self._area.width, self._area.height) - - - #cr.restore() - - - return False |