Esempio n. 1
0
    def do_startup(self):
        Gtk.Application.do_startup(self)

        if self.prefers_app_menu():
            print("prefers app_menu")
            builder = Gtk.Builder()
            builder.add_from_string(APP_MENU)
            self.set_app_menu(builder.get_object("menu"))
        else:
            builder = Gtk.Builder()
            print(views(self.pkgdatadir, "menubar.ui"))
            builder.add_from_file(views(self.pkgdatadir, "menubar.ui"))
            self.set_menubar(builder.get_object("menu"))

        new_window_action = Gio.SimpleAction.new("new_window", None)
        new_window_action.connect("activate", self.on_new_window)
        self.add_action(new_window_action)

        quit_action = Gio.SimpleAction.new("quit", None)
        quit_action.connect("activate", self.on_quit)
        self.add_action(quit_action)

        preferences_action = Gio.SimpleAction.new("preferences", None)
        preferences_action.connect("activate", self.on_preferences)
        self.add_action(preferences_action)

        about_action = Gio.SimpleAction.new("about", None)
        about_action.connect("activate", self.on_about)
        self.add_action(about_action)
Esempio n. 2
0
    def do_startup(self):
        Gtk.Application.do_startup(self)

        if self.prefers_app_menu():
            print("prefers app_menu")
            builder = Gtk.Builder()
            builder.add_from_string(APP_MENU)
            self.set_app_menu(builder.get_object("menu"))
        else:
            builder = Gtk.Builder()
            print(views(self.pkgdatadir, "menubar.ui"))
            builder.add_from_file(views(self.pkgdatadir, "menubar.ui"))
            self.set_menubar(builder.get_object("menu"))

        new_window_action = Gio.SimpleAction.new("new_window", None)
        new_window_action.connect("activate", self.on_new_window)
        self.add_action(new_window_action)

        quit_action = Gio.SimpleAction.new("quit", None)
        quit_action.connect("activate", self.on_quit)
        self.add_action(quit_action)

        preferences_action = Gio.SimpleAction.new("preferences", None)
        preferences_action.connect("activate", self.on_preferences)
        self.add_action(preferences_action)

        about_action = Gio.SimpleAction.new("about", None)
        about_action.connect("activate", self.on_about)
        self.add_action(about_action)
Esempio n. 3
0
    def on_about(self, action, parameter, transient_for=None):
        builder = Gtk.Builder()
        if self.prefers_app_menu():
            builder.add_from_file(views(self.pkgdatadir, "about_dialog_hb.ui"))
        else:
            builder.add_from_file(views(self.pkgdatadir, "about_dialog.ui"))

        about_dialog = builder.get_object("about_dialog")
        if transient_for:
            about_dialog.set_transient_for(transient_for)
        about_dialog.run()
        about_dialog.destroy()
Esempio n. 4
0
    def on_about(self, action, parameter, transient_for=None):
        builder = Gtk.Builder()
        if self.prefers_app_menu():
            builder.add_from_file(views(self.pkgdatadir, "about_dialog_hb.ui"))
        else:
            builder.add_from_file(views(self.pkgdatadir, "about_dialog.ui"))

        about_dialog = builder.get_object("about_dialog")
        if transient_for:
            about_dialog.set_transient_for(transient_for)
        about_dialog.run()
        about_dialog.destroy()