Пример #1
0
    def on_splash_show(hidden=False, *args):
        global builder
        if hidden is False:
            splash_win.show_all()
        if hidden is True:
            splash_win.hide()

        splash_prog_lbl = builder.get_object('splash_prog_lbl')
        splash_progbar = builder.get_object('splash_progbar')
        splash_prog_lbl.props.label = "Reading theme index into memory"
        abapp.load_index_to_dict(abapp.Ardis_kw['path'])

        set_fr = splash_progbar.set_fraction

        set_fr(0.1)

        splash_prog_lbl.props.label = "Reading edition-specific properties"
        theme_dict.apply_unlocks(abapp.Ardis_kw['edition'])
        set_fr(0.2)

        splash_prog_lbl.props.label = "Loading additional preview icons"
        theme_dict.refresh_unlocked_icons(builder)
        set_fr(0.3)

        splash_prog_lbl.props.label = "Hiding Locked Items"
        hide_bonus_choices(theme_dict.unlocked['places'], 'box10')
        set_fr(0.4)
        hide_bonus_choices(theme_dict.unlocked['statuses'], 'box20')
        set_fr(0.5)
        hide_bonus_choices(theme_dict.unlocked['categories'], 'box31')
        set_fr(0.6)
        hide_bonus_choices(theme_dict.unlocked['apps'], 'box15')
        set_fr(0.7)
        hide_bonus_choices(theme_dict.unlocked['actions'], 'box3')
        set_fr(0.8)
        # theme_dict.refresh_unlocked_icons(builder)
        theme_dict.apply_edition_labels(abapp.Ardis_kw['edition'], theme=abapp.Ardis_kw['dir'])
        splash_progbar.set_fraction(1.0)
        if "--debug" not in sys.argv:
            splash_win.hide()
            window.show_all()
            backbutton.hide()
            builder.get_object('SVG_PNG_choice_box').set_visible(abapp.AB_rc_dict['has_vectors'])
            return False
        print "done"
        print "woken"
        print Gtk.main_level()
        print splash_prog_lbl.props.label
        for prop in dir(splash_prog_lbl.props):
            try:
                print "\n", prop
                print splash_prog_lbl.props.__getattribute__(str(prop))
            except AttributeError:
                pass
            except TypeError:
                pass
        splash_win.hide()
        window.show_all()
Пример #2
0
def start():
    global builder
    global theme_dict
    global custom_color_gen
    global abapp
    AB_Gtk_app = Gtk.Application()
    AB_Gtk_app.register()
    AB_Gtk_app.add_window(window)
    # AB_Gtk_app.add_window(splash_win)

    # picker_win.show_all()
    # splash_win.show_all()
    # AB_Gtk_app.run()
    Gtk.main()
Пример #3
0
def show_window_gtk():
    from gi.overrides.Gtk import Gtk
    class MyWindow(Gtk.Window):
    
        def __init__(self):
            super().__init__(title="Hello World Gtk")
    
            self.button = Gtk.Button(label="Hello World Gtk")
            self.add(self.button)
    win = MyWindow()
    def quit_gtk(*args, **kwd):
        Gtk.main_quit()
    win.connect("delete-event", quit_gtk)
    win.show_all()
    Gtk.main()
Пример #4
0
    def ensure_interactive_directory(self):
        toplevel = self._treeview.get_toplevel()
        screen = self._treeview.get_screen()
        if self._search_window:
            if toplevel.has_group():
                toplevel.get_group().add_window(self._search_window)
            elif self._search_window.has_group():
                self._search_window.get_group().remove_window(
                    self._search_window)
            self._search_window.set_screen(screen)
            return

        self._search_window = Gtk.Window(Gtk.WindowType.POPUP)
        self._search_window.set_screen(screen)
        if toplevel.has_group():
            toplevel.get_group().add_window(self._search_window)
        self._search_window.set_type_hint(Gdk.WindowTypeHint.UTILITY)
        self._search_window.set_modal(True)
        self._search_window.connect("delete-event", self._delete_event)
        self._search_window.connect("key-press-event", self._key_press_event)
        self._search_window.connect("button-press-event",
                                    self._button_press_event)
        self._search_window.connect("scroll-event", self._scroll_event)
        frame = Gtk.Frame()
        frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        frame.show()
        self._search_window.add(frame)

        vbox = Gtk.VBox()
        vbox.show()
        frame.add(vbox)
        vbox.set_border_width(3)

        """ add entry """
        # To be change by Gtk 3.10 SearchEntry when agreed
        if (Gtk.get_major_version(), Gtk.get_minor_version()) >= (3, 6):
            self._search_entry = Gtk.SearchEntry()
        else:
            self._search_entry = Gtk.Entry()
        self._search_entry.show()
        self._search_entry.connect("populate-popup", self._disable_popdown)
        self._search_entry.connect("activate", self._activate)
        self._search_entry.connect("preedit-changed", self._preedit_changed)

        vbox.add(self._search_entry)
        self._search_entry.realize()
Пример #5
0
    def search_iter_sorted_column_flat(self, selection, cur_iter, text, count,
                                       n):
        """
        Search among the currently set search-column for a cell starting with
        text
        It assumes that this column is currently sorted, and as 
        a LIST_ONLY view it therefore contains index2hndl = model.node_map._index2hndl
        which is a _sorted_ list of (sortkey, handle) tuples
        """
        model = self._treeview.get_model()
        search_column = self._treeview.get_search_column()
        is_tree = not (model.get_flags() & Gtk.TreeModelFlags.LIST_ONLY)

        # If there is a sort_key index, let's use it
        if not is_tree and hasattr(model, "node_map"):
            import bisect
            index2hndl = model.node_map._index2hndl

            # create lookup key from the appropriate sort_func
            # TODO: explicitely announce the data->sortkey func in models
            # sort_key = model.sort_func(text)
            sort_key = glocale.sort_key(text.lower())
            srtkey_hndl = (sort_key, None)
            lo_bound = 0  # model.get_path(cur_iter)
            found_index = bisect.bisect_left(index2hndl,
                                             srtkey_hndl,
                                             lo=lo_bound)
            # if insert position is at tail, no match
            if found_index == len(index2hndl):
                return False
            srt_key, hndl = index2hndl[found_index]
            # Check if insert position match for real
            # (as insert position might not start with the text)
            if not model[found_index][search_column].lower().startswith(
                    text.lower()):
                return False
            found_path = Gtk.TreePath(
                (model.node_map.real_path(found_index), ))
            self._treeview.scroll_to_cell(found_path, None, 1, 0.5, 0)
            selection.select_path(found_path)
            self._treeview.set_cursor(found_path)
            return True
        return False
Пример #6
0
    def main_menu() -> None:
        main_menu = BetterMainMenu(
            "Crucipixel GTK",
            [
                "New game",
                "Create level",
                "Help",
                "Exit"
            ], [
                click_left_button_wrapper(lambda: print("New game!")),
                click_left_button_wrapper(lambda: print("Create level!")),
                click_left_button_wrapper(lambda: print("Help")),
                click_left_button_wrapper(lambda: Gtk.main_quit())
            ])
        main_menu.set_callback(0, click_left_button_wrapper(create_new_game(root)))
        main_menu.set_callback(1, click_left_button_wrapper(create_editor_input(root)))
        main_menu.set_callback(2, click_left_button_wrapper(create_help_screen(root)))

        root.set_child(main_menu)
Пример #7
0
 def on_window1_delete_event(arg1, arg2):
     # Captures exit request made by a window manager
     # Disabling this means closing the window leaves a ZOMBIE!!!
     Gtk.main_quit()
Пример #8
0
                # Apply the temp theme to theme index
                temp_theme_file = open(self.Ardis_kw['path'] + "/temp_index.theme", 'r')
                final_theme_file = open(self.Ardis_kw['path'] + "/index.theme", 'w')
                try:
                    final_theme_file.write('[Icon Theme]\n')
                    final_theme_file.writelines(["{0}={1}\n".format(k, v) for (k, v) in self.Ardis_index_dict.items()])
                    final_theme_file.writelines([line for line in temp_theme_file])

                finally:
                    temp_theme_file.close()
                    final_theme_file.close()

                # Politely Trigger updates
                os.utime(self.Ardis_kw['path'], None)
                theme = Gtk.IconTheme()
                theme.set_custom_theme(self.Ardis_kw['dir'])
                theme.emit('changed')
                theme.rescan_if_needed()
                theme.set_custom_theme(None)
                try:
                    print Gtk.Settings.props.gtk_icon_theme_name()
                except TypeError:
                    pass

                theme2 = Gtk.IconTheme.get_default()
                theme2.emit('changed')
                theme2.rescan_if_needed()

                if self.mac_patch is True:
                    print "-" * 40
Пример #9
0
 def quit_gtk(*args, **kwd):
     Gtk.main_quit()