コード例 #1
0
    def __authenticate(self):
        url = None
        if Config.get("stay_logged_in"):
            token = Config.get("refresh_token")
        else:
            Config.unset("username")
            Config.unset("refresh_token")
            token = None

        # Make sure there is an internet connection
        if not self.api.can_connect():
            return

        authenticated = self.api.authenticate(refresh_token=token,
                                              login_code=url)

        while not authenticated and 'Login' in dir():
            login_url = self.api.get_login_url()
            redirect_url = self.api.get_redirect_url()
            login = Login(login_url=login_url,
                          redirect_url=redirect_url,
                          parent=self)
            response = login.run()
            login.hide()
            if response == Gtk.ResponseType.DELETE_EVENT:
                Gtk.main_quit()
                exit(0)
            if response == Gtk.ResponseType.NONE:
                result = login.get_result()
                authenticated = self.api.authenticate(login_code=result)

        Config.set("refresh_token", authenticated)
コード例 #2
0
 def update_gtk_box_for_dlc(self, icon, title, installer):
     if title not in self.dlc_dict:
         dlc_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
         dlc_box.set_spacing(8)
         image = Gtk.Image()
         image.set_from_icon_name("media-optical", Gtk.IconSize.BUTTON)
         dlc_box.pack_start(image, False, True, 0)
         label = Gtk.Label(label=title, xalign=0)
         dlc_box.pack_start(label, True, True, 0)
         install_button = Gtk.Button()
         dlc_box.pack_start(install_button, False, True, 0)
         self.dlc_dict[title] = [install_button, image]
         self.dlc_dict[title][0].connect("clicked",
                                         self.__dlc_button_clicked,
                                         installer)
         self.dlc_horizontal_box.pack_start(dlc_box, False, True, 0)
         dlc_box.show_all()
         self.get_async_image_dlc_icon(icon, title)
     download_info = self.api.get_download_info(self.game,
                                                dlc_installers=installer)
     if self.game.is_update_available(
             version_from_api=download_info["version"], dlc_title=title):
         icon_name = "emblem-synchronizing"
         self.dlc_dict[title][0].set_sensitive(True)
     elif self.game.is_installed(dlc_title=title):
         icon_name = "object-select"
         self.dlc_dict[title][0].set_sensitive(False)
     else:
         icon_name = "document-save"
         if not self.download_list:
             self.dlc_dict[title][0].set_sensitive(True)
     install_button_image = Gtk.Image()
     install_button_image.set_from_icon_name(icon_name, Gtk.IconSize.BUTTON)
     self.dlc_dict[title][0].set_image(install_button_image)
コード例 #3
0
 def __create_progress_bar(self) -> None:
     self.progress_bar = Gtk.ProgressBar()
     self.progress_bar.set_halign(Gtk.Align.CENTER)
     self.progress_bar.set_size_request(196, -1)
     self.progress_bar.set_hexpand(False)
     self.progress_bar.set_vexpand(False)
     self.set_center_widget(self.progress_bar)
     self.progress_bar.set_fraction(0.0)
コード例 #4
0
    def __set_view_list(self) -> None:
        views = Gtk.ListStore(str, str)
        for view in VIEWS:
            views.append(view)

        self.combobox_view.set_model(views)
        self.combobox_view.set_entry_text_column(1)
        self.renderer_text = Gtk.CellRendererText()
        self.combobox_view.pack_start(self.renderer_text, False)
        self.combobox_view.add_attribute(self.renderer_text, "text", 1)

        # Set the active option
        current_view = Config.get("view")
        for key in range(len(views)):
            if views[key][:1][0] == current_view:
                self.combobox_view.set_active(key)
                break
コード例 #5
0
    def __set_language_list(self) -> None:
        languages = Gtk.ListStore(str, str)
        for lang in SUPPORTED_DOWNLOAD_LANGUAGES:
            languages.append(lang)

        self.combobox_language.set_model(languages)
        self.combobox_language.set_entry_text_column(1)
        self.renderer_text = Gtk.CellRendererText()
        self.combobox_language.pack_start(self.renderer_text, False)
        self.combobox_language.add_attribute(self.renderer_text, "text", 1)

        # Set the active option
        current_lang = Config.get("lang")
        for key in range(len(languages)):
            if languages[key][:1][0] == current_lang:
                self.combobox_language.set_active(key)
                break
コード例 #6
0
ファイル: login.py プロジェクト: sharkwouter/minigalaxy
 def on_create(self, widget, action):
     popup = Gtk.Dialog(title=_("Facebook Login"), parent=self, flags=0, buttons=())
     webview = WebKit2.WebView.new_with_related_view(widget)
     webview.load_uri(action.get_request().get_uri())
     webview.__dict__['popup'] = popup
     webview.connect('close', self.on_close_popup)
     popup.get_content_area().pack_start(webview, True, True, 0)
     popup.set_size_request(400, 600)
     popup.set_modal(True)
     popup.show_all()
     return webview
コード例 #7
0
 def show_question(self, text, secondary_text=""):
     dialog = Gtk.MessageDialog(parent=self,
                                flags=Gtk.DialogFlags.MODAL,
                                message_type=Gtk.MessageType.WARNING,
                                buttons=Gtk.ButtonsType.OK_CANCEL,
                                message_format=text)
     if secondary_text:
         dialog.format_secondary_text(secondary_text)
     response = dialog.run()
     dialog.destroy()
     return response == Gtk.ResponseType.OK
コード例 #8
0
ファイル: window.py プロジェクト: thomasb22/minigalaxy
 def show_error(self, text, secondary_text=""):
     dialog = Gtk.MessageDialog(parent=self,
                                modal=True,
                                destroy_with_parent=True,
                                message_type=Gtk.MessageType.ERROR,
                                buttons=Gtk.ButtonsType.OK,
                                text=text)
     if secondary_text:
         dialog.format_secondary_text(secondary_text)
     dialog.run()
     dialog.destroy()
コード例 #9
0
    def __set_locale_list(self) -> None:
        locales = Gtk.ListStore(str, str)
        for local in SUPPORTED_LOCALES:
            locales.append(local)

        self.combobox_program_language.set_model(locales)
        self.combobox_program_language.set_entry_text_column(1)
        self.renderer_text = Gtk.CellRendererText()
        self.combobox_program_language.pack_start(self.renderer_text, False)
        self.combobox_program_language.add_attribute(self.renderer_text, "text", 1)

        # Set the active option
        current_locale = Config.get("locale")
        default_locale = locale.getdefaultlocale()
        if current_locale is None:
            locale.setlocale(locale.LC_ALL, default_locale)
        for key in range(len(locales)):
            if locales[key][:1][0] == current_locale:
                self.combobox_program_language.set_active(key)
                break
コード例 #10
0
from minigalaxy.ui.gtk import Gtk

css = '.test { border: 1px solid green; }'
CSS_PROVIDER = Gtk.CssProvider()
CSS_PROVIDER.load_from_data(css.encode('utf-8'))