Subversion Repositories basico

Rev

Rev 6 | 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
24
from .env import FILE
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
        #~ print (controller.list_services())
38
        #~ print (dir(controller))
39
        self.get_services()
40
 
41
 
42
    def get_services(self):
43
        self.gui = self.controller.get_service('GUI')
44
        self.im = self.controller.get_service('IM')
45
        self.cb = self.controller.get_service('Callbacks')
46
 
47
 
48
    def do_activate(self):
49
        self.window = GtkAppWindow(self)
50
        self.window.connect("delete-event", self.gui.quit)
51
        self.window.show()
52
 
53
 
54
    def do_startup(self):
55
        Gtk.Application.do_startup(self)
56
 
57
        # show icons on the buttons
58
        #~ settings = Gtk.Settings.get_default()
59
        #~ DEPRECATED: settings.props.gtk_button_images = True
60
 
61
        # actions that control the application: create, connect their
62
        # signal to a callback method (see below), add the action to the
63
        # application
64
 
65
 
66
    def get_window(self):
67
        return self
68
 
69
 
70
    def get_controller(self):
71
        return self.controller
72
 
73
 
74
    def cb_hide_about(self, aboutdialog, user_data):
75
        aboutdialog.destroy()
76
 
77
 
78
    def cb_toggle_fullscreen(self, tgbutton, user_data=None):
79
        if tgbutton.get_active():
80
            self.window.fullscreen()
81
        else:
82
            self.window.unfullscreen()
83
 
84
 
85
    def cb_show_about(self, *args):
86
        DIR_ICONS = self.controller.get_var("ICONS")
87
        CREDITS = self.controller.get_file("CREDITS")
88
        rootwin = self.gui.get_widget('mainwindow')
89
 
90
        aboutdialog = Gtk.AboutDialog()
91
        aboutdialog.set_hide_titlebar_when_maximized(True)
92
        icon_dlg = self.im.get_icon('basico', 96, 96)
93
        applicense = Gtk.License(Gtk.License.GPL_3_0)
94
        shortname = self.controller.get_app_info('short')
10 t00mlabs 95
        longname = self.controller.get_app_info('desc')
4 t00mlabs 96
        authors = self.controller.get_app_info('authors')
97
        #~ documenters = self.controller.get_app_info('documenters')
98
        #~ aboutdialog.set_title("About %s" % longname)
99
        aboutdialog.set_logo(icon_dlg)
100
        aboutdialog.set_icon(icon_dlg)
101
        #~ aboutdialog.add_credit_section("Icon 🙇", ["Single Unicode character (U+1F64x).\nSee Emoticons section from Unicode Standard version 6.0"])
102
 
103
        #~ for line in open(CREDITS, 'r').readlines():
104
            #~ data = line.split(';')
105
            #~ aboutdialog.add_credit_section(data[0], [data[1]])
106
        aboutdialog.set_comments(longname)
107
        #~ aboutdialog.set_comments(longname)
108
        #~ aboutdialog.set_program_name("%s\n(%s)" % (shortname, longname))
109
        aboutdialog.set_version("0.1")
110
        aboutdialog.set_copyright("Copyright \xa9 2016 Tomás Vírseda García")
111
        aboutdialog.set_license_type(applicense)
112
        aboutdialog.set_authors(authors)
113
        #~ aboutdialog.set_documenters(documenters)
114
        aboutdialog.set_website("http://t00mlabs.net")
115
        aboutdialog.set_website_label("t00mlabs Website")
116
        aboutdialog.set_title("")
117
        aboutdialog.connect("response", self.cb_hide_about)
118
        aboutdialog.set_transient_for(rootwin)
119
        aboutdialog.set_modal(True)
120
        #~ icon_app = Pixbuf.new_from_file_at_scale(DIR_ICONS + 'basico.png', 64, 64, True)
121
        #~ aboutdialog.set_logo(icon_app)
122
        aboutdialog.show()