Subversion Repositories basico

Rev

Rev 9 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 t00mlabs 1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
# File: uiapp.py
4
# Author: Tomás Vírseda
5
# License: GPL v3
6
# Description: Gtk.Application instance
7
 
8
import os
9
import sys
10
import subprocess
11
from datetime import datetime
12
 
13
from gi.repository import Gtk
14
from gi.repository import Gdk
15
from gi.repository.GdkPixbuf import Pixbuf
16
from gi.repository import Pango
17
from gi.repository import GLib
18
from gi.repository import GObject
19
from gi.repository import Gio
20
 
21
from .service import Service
22
from .window import GtkAppWindow
23
from .log import get_logger
74 t00mlabs 24
from .env import FILE, APP
4 t00mlabs 25
 
26
class UIApp(Gtk.Application):
27
    """
28
    """
29
    def __init__(self, controller):
30
        Gtk.Application.__init__(self,
31
                                 application_id="net.t00mlabs.basico",
32
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)
33
        GLib.set_application_name("Basico")
34
        GLib.set_prgname('basico')
35
        self.log = get_logger(self.__class__.__name__, FILE['LOG'])
36
        self.controller = controller
37
        self.get_services()
38
 
39
 
40
    def get_services(self):
41
        self.gui = self.controller.get_service('GUI')
42
        self.im = self.controller.get_service('IM')
43
        self.cb = self.controller.get_service('Callbacks')
44
 
45
 
46
    def do_activate(self):
47
        self.window = GtkAppWindow(self)
48
        self.window.connect("delete-event", self.gui.quit)
49
        self.window.show()
50
 
51
 
52
    def do_startup(self):
53
        Gtk.Application.do_startup(self)
54
 
55
        # show icons on the buttons
56
        #~ settings = Gtk.Settings.get_default()
57
        #~ DEPRECATED: settings.props.gtk_button_images = True
58
 
59
        # actions that control the application: create, connect their
60
        # signal to a callback method (see below), add the action to the
61
        # application
62
 
63
 
64
    def get_window(self):
65
        return self
66
 
67
 
68
    def get_controller(self):
69
        return self.controller
70
 
71
 
72
    def cb_hide_about(self, aboutdialog, user_data):
73
        aboutdialog.destroy()
74
 
75
 
76
    def cb_toggle_fullscreen(self, tgbutton, user_data=None):
77
        if tgbutton.get_active():
78
            self.window.fullscreen()
79
        else:
80
            self.window.unfullscreen()
81
 
82
 
83
    def cb_show_about(self, *args):
84
        DIR_ICONS = self.controller.get_var("ICONS")
85
        CREDITS = self.controller.get_file("CREDITS")
86
        rootwin = self.gui.get_widget('mainwindow')
74 t00mlabs 87
        version = APP['version']
4 t00mlabs 88
 
89
        aboutdialog = Gtk.AboutDialog()
90
        aboutdialog.set_hide_titlebar_when_maximized(True)
91
        icon_dlg = self.im.get_icon('basico', 96, 96)
92
        applicense = Gtk.License(Gtk.License.GPL_3_0)
93
        shortname = self.controller.get_app_info('short')
9 t00mlabs 94
        longname = self.controller.get_app_info('desc')
4 t00mlabs 95
        authors = self.controller.get_app_info('authors')
96
        aboutdialog.set_logo(icon_dlg)
97
        aboutdialog.set_icon(icon_dlg)
98
        aboutdialog.set_comments(longname)
74 t00mlabs 99
        aboutdialog.set_version(version)
4 t00mlabs 100
        aboutdialog.set_copyright("Copyright \xa9 2016 Tomás Vírseda García")
101
        aboutdialog.set_license_type(applicense)
102
        aboutdialog.set_authors(authors)
103
        aboutdialog.set_website("http://t00mlabs.net")
104
        aboutdialog.set_website_label("t00mlabs Website")
105
        aboutdialog.set_title("")
106
        aboutdialog.connect("response", self.cb_hide_about)
107
        aboutdialog.set_transient_for(rootwin)
108
        aboutdialog.set_modal(True)
109
        aboutdialog.show()