Exemple #1
0
    def on_startup(self, app):
        """
        Startup function.
        Loads the GtkBuilder resources, settings and start the main loop.
        """

        try:
            # Load settings
            helpers.debug_msg([GTK_MSG, i18n._("Obozrenie is starting")])
            guiactions = self.guiactions

            self.status = "starting"
            guiactions.fill_game_store()

            self.settings.load(
                callback_postgenload=self.guiactions.cb_post_settings_genload)

            # Connect signals
            self.builder.connect_signals(self.guiactions)
            guiactions.gtk_widgets["server-list-filter"].set_visible_func(
                guiactions.server_filter_func)

            gtk_helpers.set_widget_value(
                self.guiactions.gtk_widgets["game-combobox"],
                self.settings.settings_table["common"]
                ["selected-game-browser"])
            for entry in self.guiactions.filter_secure_list:
                guiactions.gtk_widgets["filter-secure"].append(
                    entry["id"], entry["text"])
            guiactions.cb_game_treeview_togglebutton_clicked()
            guiactions.cb_server_filters_changed()
            try:
                guiactions.cb_server_connect_data_changed()
            except ValueError:
                pass

            # Add main window
            main_window = self.guiactions.gtk_widgets["main-window"]
            self.add_window(main_window)

            # Create menu actions
            about_action = Gio.SimpleAction.new("about", None)
            quit_action = Gio.SimpleAction.new("quit", None)

            about_action.connect("activate", self.guiactions.cb_about,
                                 main_window)
            quit_action.connect("activate", self.guiactions.cb_quit, self)

            self.add_action(about_action)
            self.add_action(quit_action)

            self.set_app_menu(self.builder.get_object("app-menu"))

            gtk_helpers.set_object_properties(self.guiactions.gtk_widgets,
                                              GTK_STRING_TABLE)

            self.status = "up"
        except Exception as e:
            app.quit()
            raise e
Exemple #2
0
def get_entry_with_label(label_text="", tooltip_text=""):
    grid = Gtk.Grid()
    entry = Gtk.Entry()
    label = Gtk.Label()

    widget_object_dict = {"grid": grid, "entry": entry, "label": label}
    widget_property_dict = {
        "grid": {
            "column-homogeneous": True,
            "column-spacing": 5
        },
        "entry": {
            "tooltip-text": i18n._(tooltip_text),
            "halign": Gtk.Align.FILL,
            "hexpand-set": True,
            "hexpand": True
        },
        "label": {
            "label": i18n._(label_text),
            "halign": Gtk.Align.END
        }
    }

    gtk_helpers.set_object_properties(widget_object_dict, widget_property_dict)

    grid.add(entry)

    widget_group = {"container": grid, "label": label, "substance": entry}

    return widget_group
def get_checkbutton(label_text="", tooltip_text=""):
    checkbutton = Gtk.CheckButton.new()

    widget_object_dict = {"checkbutton": checkbutton}
    widget_property_dict = {"checkbutton": {"label": i18n._(label_text), "tooltip-text": i18n._(tooltip_text)}}

    gtk_helpers.set_object_properties(widget_object_dict, widget_property_dict)

    widget_group = {"container": checkbutton, "substance": checkbutton}

    return widget_group
Exemple #4
0
    def on_startup(self, app):
        """
        Startup function.
        Loads the GtkBuilder resources, settings and start the main loop.
        """

        try:
            # Load settings
            helpers.debug_msg([GTK_MSG, i18n._("Obozrenie is starting")])
            guiactions = self.guiactions

            self.status = "starting"
            guiactions.fill_game_store()

            self.settings.load(callback_postgenload=self.guiactions.cb_post_settings_genload)

            # Connect signals
            self.builder.connect_signals(self.guiactions)
            guiactions.gtk_widgets["server-list-filter"].set_visible_func(guiactions.server_filter_func)

            gtk_helpers.set_widget_value(self.guiactions.gtk_widgets["game-combobox"], self.settings.settings_table["common"]["selected-game-browser"])
            for entry in self.guiactions.filter_secure_list:
                guiactions.gtk_widgets["filter-secure"].append(entry["id"], entry["text"])
            guiactions.cb_game_treeview_togglebutton_clicked()
            guiactions.cb_server_filters_changed()
            try:
                guiactions.cb_server_connect_data_changed()
            except ValueError:
                pass

            # Add main window
            main_window = self.guiactions.gtk_widgets["main-window"]
            self.add_window(main_window)

            # Create menu actions
            about_action = Gio.SimpleAction.new("about", None)
            quit_action = Gio.SimpleAction.new("quit", None)

            about_action.connect("activate", self.guiactions.cb_about, main_window)
            quit_action.connect("activate", self.guiactions.cb_quit, self)

            self.add_action(about_action)
            self.add_action(quit_action)

            self.set_app_menu(self.builder.get_object("app-menu"))

            gtk_helpers.set_object_properties(self.guiactions.gtk_widgets, GTK_STRING_TABLE)

            self.status = "up"
        except Exception as e:
            app.quit()
            raise e
Exemple #5
0
def get_checkbutton(label_text="", tooltip_text=""):
    checkbutton = Gtk.CheckButton.new()

    widget_object_dict = {"checkbutton": checkbutton}
    widget_property_dict = {
        "checkbutton": {
            "label": i18n._(label_text),
            "tooltip-text": i18n._(tooltip_text)
        }
    }

    gtk_helpers.set_object_properties(widget_object_dict, widget_property_dict)

    widget_group = {"container": checkbutton, "substance": checkbutton}

    return widget_group
def get_entry_with_label(label_text="", tooltip_text=""):
    grid = Gtk.Grid()
    entry = Gtk.Entry()
    label = Gtk.Label()

    widget_object_dict = {"grid": grid, "entry": entry, "label": label}
    widget_property_dict = {"grid":  {"column-homogeneous": True,           "column-spacing": 5},
                            "entry": {"tooltip-text": i18n._(tooltip_text), "halign": Gtk.Align.FILL, "hexpand-set": True, "hexpand": True},
                            "label": {"label": i18n._(label_text),          "halign": Gtk.Align.END}}

    gtk_helpers.set_object_properties(widget_object_dict, widget_property_dict)

    grid.add(entry)

    widget_group = {"container": grid, "label": label, "substance": entry}

    return widget_group
def get_textview_with_label(label_text="", tooltip_text="Single entry per line", placeholder_text=""):
    grid = Gtk.Grid()
    text_view = Gtk.TextView()
    text_buffer = text_view.get_buffer()
    label = Gtk.Label()

    widget_object_dict = {"grid": grid, "text_view": text_view, "label": label}
    widget_property_dict = {"grid":      {"column-homogeneous": True,           "column-spacing": 5},
                            "text_view": {"tooltip-text": i18n._(tooltip_text), "halign": Gtk.Align.FILL, "hexpand-set": True, "hexpand": True, "left-margin": 8, "right-margin": 8},
                            "label":     {"label": i18n._(label_text),          "halign": Gtk.Align.END,  "valign": Gtk.Align.START}}

    gtk_helpers.set_object_properties(widget_object_dict, widget_property_dict)

    grid.add(text_view)

    widget_group = {"container": grid, "label": label, "substance": text_buffer}

    return widget_group
Exemple #8
0
def get_textview_with_label(label_text="",
                            tooltip_text="Single entry per line",
                            placeholder_text=""):
    grid = Gtk.Grid()
    text_view = Gtk.TextView()
    text_buffer = text_view.get_buffer()
    label = Gtk.Label()

    widget_object_dict = {"grid": grid, "text_view": text_view, "label": label}
    widget_property_dict = {
        "grid": {
            "column-homogeneous": True,
            "column-spacing": 5
        },
        "text_view": {
            "tooltip-text": i18n._(tooltip_text),
            "halign": Gtk.Align.FILL,
            "hexpand-set": True,
            "hexpand": True,
            "left-margin": 8,
            "right-margin": 8
        },
        "label": {
            "label": i18n._(label_text),
            "halign": Gtk.Align.END,
            "valign": Gtk.Align.START
        }
    }

    gtk_helpers.set_object_properties(widget_object_dict, widget_property_dict)

    grid.add(text_view)

    widget_group = {
        "container": grid,
        "label": label,
        "substance": text_buffer
    }

    return widget_group