Exemplo n.º 1
0
 def startup(self, application):
     """Configure the application during the startup"""
     self.ui = UIMain(self)
     # Add the about action to the app menu
     action = Gio.SimpleAction(name="settings_folder")
     action.connect("activate", self.on_app_settings_folder_activate)
     self.add_action(action)
     # Add the about action to the app menu
     action = Gio.SimpleAction(name="about")
     action.connect("activate", self.on_app_about_activate)
     self.add_action(action)
     # Add the quit action to the app menu
     action = Gio.SimpleAction(name="quit")
     action.connect("activate", self.on_app_quit_activate)
     self.add_action(action)
     # Add the app menu
     builder_appmenu = GtkBuilderLoader(get_ui_file('appmenu.ui'))
     self.set_app_menu(builder_appmenu.app_menu)
Exemplo n.º 2
0
class Application(Gtk.Application):
    def __init__(self):
        """Create the application object"""
        super(self.__class__, self).__init__(application_id=APP_ID)
        self.connect("activate", self.activate)
        self.connect('startup', self.startup)

    def startup(self, application):
        """Configure the application during the startup"""
        self.ui = UIMain(self)
        # Add the about action to the app menu
        action = Gio.SimpleAction(name="settings_folder")
        action.connect("activate", self.on_app_settings_folder_activate)
        self.add_action(action)
        # Add the about action to the app menu
        action = Gio.SimpleAction(name="about")
        action.connect("activate", self.on_app_about_activate)
        self.add_action(action)
        # Add the quit action to the app menu
        action = Gio.SimpleAction(name="quit")
        action.connect("activate", self.on_app_quit_activate)
        self.add_action(action)
        # Add the app menu
        builder_appmenu = GtkBuilderLoader(get_ui_file('appmenu.ui'))
        self.set_app_menu(builder_appmenu.app_menu)

    def activate(self, application):
        """Execute the application"""
        self.ui.run()

    def on_app_settings_folder_activate(self, action, data):
        """Open the settings folder from the app menu"""
        Gtk.show_uri(None, 'file://%s' % DIR_SETTINGS, Gdk.CURRENT_TIME)

    def on_app_about_activate(self, action, data):
        """Show the about dialog from the app menu"""
        self.ui.on_action_about_activate(action)

    def on_app_quit_activate(self, action, data):
        """Quit the application from the app menu"""
        self.ui.on_action_quit_activate(action)