diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/python/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/python/welcome/Makefile.am | 14 | ||||
-rw-r--r-- | plugins/python/welcome/__init__.py | 4 | ||||
-rw-r--r-- | plugins/python/welcome/binary.py | 40 | ||||
-rw-r--r-- | plugins/python/welcome/board.py | 102 | ||||
-rw-r--r-- | plugins/python/welcome/panel.py | 148 | ||||
-rw-r--r-- | plugins/python/welcome/plugin.py | 36 | ||||
-rw-r--r-- | plugins/python/welcome/tip.py | 146 | ||||
-rw-r--r-- | plugins/python/welcome/tipoftheday.png | bin | 10206 -> 0 bytes | |||
-rw-r--r-- | plugins/python/welcome/tipoftheday.xcf | bin | 17942 -> 0 bytes | |||
-rw-r--r-- | plugins/python/welcome/version.py | 116 | ||||
-rw-r--r-- | plugins/python/welcome/website.py | 30 |
12 files changed, 1 insertions, 637 deletions
diff --git a/plugins/python/Makefile.am b/plugins/python/Makefile.am index ae5baed..35f15eb 100644 --- a/plugins/python/Makefile.am +++ b/plugins/python/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = apkfiles samples welcome +SUBDIRS = apkfiles samples diff --git a/plugins/python/welcome/Makefile.am b/plugins/python/welcome/Makefile.am deleted file mode 100644 index 7dd16fa..0000000 --- a/plugins/python/welcome/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ - -welcomedir = $(datadir)/openida/plugins/python/welcome - -welcome_DATA = \ - __init__.py \ - binary.py \ - board.py \ - panel.py \ - plugin.py \ - tip.py \ - version.py \ - website.py \ - tipoftheday.png \ - tipoftheday.xcf diff --git a/plugins/python/welcome/__init__.py b/plugins/python/welcome/__init__.py deleted file mode 100644 index 00a76af..0000000 --- a/plugins/python/welcome/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -from welcome.plugin import WelcomePlugin as AutoLoad diff --git a/plugins/python/welcome/binary.py b/plugins/python/welcome/binary.py deleted file mode 100644 index 205934e..0000000 --- a/plugins/python/welcome/binary.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -from welcome.board import SmallBoard -from gi.repository import Gtk, Gdk -import pychrysalide - - -class NewBinary(SmallBoard): - """Encourage l'ouverture d'un (premier) binaire.""" - - - def __init__(self): - """Construit le panneau avec son contenu.""" - - super(NewBinary, self).__init__() - - self._menu_item = pychrysalide.get_global_gobject('mnu_project_add_binary') - - msg = 'Analyse a new binary by clicking <a href="file:///#">here</a>.' - - desc = Gtk.Label(msg, use_markup=True, wrap=True) - desc.add_events(Gdk.EventMask.ENTER_NOTIFY_MASK) - desc.set_track_visited_links(False) - desc.connect('activate-link', self.on_link_activated) - self.add(desc) - - - def on_link_activated(self, uri, data): - """Lance l'action associée au lien représenté.""" - - self._menu_item.activate() - - return True - - - def get_location(self): - """Fournit la localisation souhaitée pour la planche.""" - - return [ 0, 0, 1, 1 ] diff --git a/plugins/python/welcome/board.py b/plugins/python/welcome/board.py deleted file mode 100644 index 39cd885..0000000 --- a/plugins/python/welcome/board.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/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 planche.""" - - pass - - - def attach(self, manager): - """Lie partiellement la planche à 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) 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 diff --git a/plugins/python/welcome/plugin.py b/plugins/python/welcome/plugin.py deleted file mode 100644 index a26c93b..0000000 --- a/plugins/python/welcome/plugin.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -from pychrysalide import PluginModule -from welcome.panel import WelcomePanel - - -class WelcomePlugin(PluginModule): - """Interface graphique d'accueil.""" - - - def get_interface(self): - """Provide the full plugin description.""" - - desc = { - - 'name' : 'Welcome', - 'desc' : 'Introduce the software when no project is loaded', - 'version' : '0.1', - - 'actions' : [ PluginModule.PGA_PLUGIN_INIT ] - - } - - return desc - - - def init(self, ref): - """Initialise l'extension.""" - - self._panel = WelcomePanel() - - #self._panel.dock() - #self._panel.register() - - return True diff --git a/plugins/python/welcome/tip.py b/plugins/python/welcome/tip.py deleted file mode 100644 index 642619e..0000000 --- a/plugins/python/welcome/tip.py +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -from welcome.board import SmallBoard -from gi.repository import Gtk -import random - -try: - import cairo - has_cairo = True - import os -except: - has_cairo = False - - -_tip_messages = [ - "Message 1", - "Message 2", - "Message 3", - "Message 4", - "Message 5", - "Message 6" -] - -assert(len(_tip_messages) > 0) - - -class TipOfTheDay(SmallBoard): - """Présente une série d'astuces du jour.""" - - - def __init__(self): - """Construit le panneau avec son contenu.""" - - super(TipOfTheDay, self).__init__() - - box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) - self.add(box) - - # Barre de contrôle - - toolbar = Gtk.Box(spacing=10) - toolbar.props.margin = 20 - box.pack_end(toolbar, False, True, 0) - - btn = Gtk.Button('Previous') - btn.connect('clicked', self.show_previous_message) - toolbar.pack_start(btn, False, True, 8) - - btn = Gtk.Button('Next') - btn.connect('clicked', self.show_next_message) - toolbar.pack_start(btn, False, True, 8) - - # Contenu de l'astuce courante - - desc = Gtk.Label('', use_markup=True, wrap=True, xalign=0) - self._message = desc - desc.set_justify(Gtk.Justification.LEFT) - box.pack_end(desc, False, True, 0) - - # Titre - - desc = Gtk.Label("<b>Did you know?</b>", use_markup=True, wrap=True, xalign=0) - desc.set_justify(Gtk.Justification.LEFT) - box.pack_end(desc, False, True, 0) - - # Image de fond, si possible - - if has_cairo: - - os.chdir(os.path.dirname(__file__)) - - self._img = cairo.ImageSurface.create_from_png('tipoftheday.png') - - self.connect_after('draw', self.draw_background) - - # Sélection du message courant - - self._indexes = [i for i in range(len(_tip_messages))] - random.shuffle(self._indexes) - - self._index = 0 - - self.show_message() - - - def draw_background(self, widget, cr): - """Dessine une image de fond pour les conseils.""" - - img_width = self._img.get_width() - img_height = self._img.get_height() - - alloc = self.get_allocation() - target_height = alloc.height * 0.7 - - if img_height > target_height: - - scale = float(target_height) / float(img_height) - - cr.translate(alloc.width - img_width * scale - 10, 10) - cr.scale(scale, scale) - - else: - - cr.translate(alloc.width - img_width - 10, 10) - - cr.set_source_surface(self._img) - cr.paint_with_alpha(0.6) - - - def show_message(self): - """Affiche un conseil du jour donné.""" - - selected = self._indexes[self._index] - - msg = _tip_messages[selected] - - self._message.set_markup(msg) - - - def show_previous_message(self, button): - """Affiche un conseil du jour précédent.""" - - if self._index == 0: - self._index = len(_tip_messages) - 1 - else: - self._index = self._index - 1 - - self.show_message() - - - def show_next_message(self, button): - """Affiche un conseil du jour suivant.""" - - self._index = self._index + 1 - - if self._index == len(_tip_messages): - self._index = 0 - - self.show_message() - - - def get_location(self): - """Fournit la localisation souhaitée pour la planche.""" - - return [ 2, 1, 2, 2 ] diff --git a/plugins/python/welcome/tipoftheday.png b/plugins/python/welcome/tipoftheday.png Binary files differdeleted file mode 100644 index 12f017a..0000000 --- a/plugins/python/welcome/tipoftheday.png +++ /dev/null diff --git a/plugins/python/welcome/tipoftheday.xcf b/plugins/python/welcome/tipoftheday.xcf Binary files differdeleted file mode 100644 index dc9cf06..0000000 --- a/plugins/python/welcome/tipoftheday.xcf +++ /dev/null diff --git a/plugins/python/welcome/version.py b/plugins/python/welcome/version.py deleted file mode 100644 index 9bd4db2..0000000 --- a/plugins/python/welcome/version.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -from welcome.board import SmallBoard -from gi.repository import Gtk -import pychrysalide - -try: - import urllib3 - has_urllib3 = True -except: - has_urllib3 = False - - -class VersionChecker(SmallBoard): - """Affichage des versions courante et disponible, ainsi que des conclusions associées.""" - - - def __init__(self): - """Construit le panneau avec son contenu.""" - - super(VersionChecker, self).__init__() - - current = pychrysalide.revision() - - if has_urllib3: - - lastest = self.get_lastest_version('community') - - if lastest != None: - up2date = self.get_update_status(current, lastest) - else: - up2date = None - - if lastest != None and up2date != None: - - msg = '''Your version is: <b>%s</b> - -Lastest version is: <b>%s</b>''' - - caption = msg % (current, lastest if lastest != None else 'unknown') - - if up2date: - caption = caption + ''' - -Your software is <span color='green'><b>up-to-date</b></span>.''' - else: - caption = caption + ''' - -Your software is <b><span color='red'>outdated</span></b>.''' - - else: - - msg = '''Your version is: <b>%s</b> - -An error occurred while dealing with revision numbers.''' - - caption = msg % current - - else: - - msg = '''Your version is: <b>%s</b> - -To display the lastest available version, please install the <b>urllib3</b> package for Python.''' - - caption = msg % current - - desc = Gtk.Label(caption, use_markup=True, wrap=True) - desc.set_track_visited_links(False) - self.add(desc) - - - def get_lastest_version(self, category): - """Retrouve la dernière version disponible à partir du site officiel.""" - - lastest = None - - http = urllib3.PoolManager() - try: - request = http.request('GET', 'http://0xdeadc0de.fr/chrysalide/updates/versions') - except urllib3.exceptions.MaxRetryError: - request = None - - if request != None: - - html = request.data.decode('utf-8') - - request.release_conn() - - available = html.split('\n') - - for a in available: - desc = a.split('=') - if desc[0] == category: - lastest = desc[1] - break - - return lastest - - - def get_update_status(self, current, lastest): - """Détermine le degré de mise à jour du système.""" - - if current[0] != 'r' or lastest[0] != 'r': - return None - - cur_rev = int(current[1:]) - last_rev = int(lastest[1:]) - - return (cur_rev >= last_rev) - - - def get_location(self): - """Fournit la localisation souhaitée pour la planche.""" - - return [ 2, 0, 1, 1 ] diff --git a/plugins/python/welcome/website.py b/plugins/python/welcome/website.py deleted file mode 100644 index f8f1b9a..0000000 --- a/plugins/python/welcome/website.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -from welcome.board import SmallBoard -from gi.repository import Gtk, Gdk - - -class WebInvitation(SmallBoard): - """Présente un lien rapide vers le site Web officiel.""" - - - def __init__(self): - """Construit le panneau avec son contenu.""" - - super(WebInvitation, self).__init__() - - msg = '''Get access to the online documentation and stay tuned by visiting the official website : - -<a href="http://0xdeadc0de.fr/chrysalide/">0xdeadc0de.fr/chrysalide</a>''' - - desc = Gtk.Label(msg, use_markup=True, wrap=True) - desc.add_events(Gdk.EventMask.ENTER_NOTIFY_MASK) - desc.set_track_visited_links(False) - self.add(desc) - - - def get_location(self): - """Fournit la localisation souhaitée pour la planche.""" - - return [ 3, 0, 1, 1 ] |