Coverage for lutris.gui.dialogs : 30%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
super(GtkBuilderDialog, self).__init__() ui_filename = os.path.join(datapath.get(), 'ui', self.glade_file) if not os.path.exists(ui_filename): raise ValueError("ui file does not exists: %s" % ui_filename)
self.builder = Gtk.Builder() self.builder.add_from_file(ui_filename) self.dialog = self.builder.get_object(self.dialog_object) self.builder.connect_signals(self) self.dialog.show_all() self.initialize(**kwargs)
pass
self.dialog.destroy()
""" Displays a message to the user. """ super(NoticeDialog, self).__init__(buttons=Gtk.ButtonsType.OK) self.set_markup(message) self.run() self.destroy()
""" Displays an error message. """ super(ErrorDialog, self).__init__(buttons=Gtk.ButtonsType.OK) self.set_markup(message) self.run() self.destroy()
""" Asks a question. """ super(QuestionDialog, self).__init__( message_type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO ) self.set_markup(settings['question']) self.set_title(settings['title']) self.result = self.run() self.destroy()
"""Ask the user to select a directory""" super(DirectoryDialog, self).__init__( title=message, action=Gtk.FileChooserAction.SELECT_FOLDER, buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE, Gtk.STOCK_OK, Gtk.ResponseType.OK) ) self.result = self.run() self.folder = self.get_current_folder() self.destroy()
self.filename = None if not message: message = "Please choose a file" super(FileDialog, self).__init__( message, None, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK) ) self.set_local_only(False) response = self.run() if response == Gtk.ResponseType.OK: self.filename = self.get_filename()
self.destroy()
""" Dialog showing a download in progress. """
super(DownloadDialog, self).__init__("Downloading file") self.set_size_request(560, 100) params = {'url': url, 'dest': dest} self.download_progress_box = DownloadProgressBox(params) self.download_progress_box.connect('complete', self.download_complete) self.download_progress_box.connect('cancelrequested', self.download_cancelled) label = Gtk.Label(label='Downloading %s' % url) label.set_selectable(True) label.set_padding(0, 0) label.set_alignment(0.0, 1.0) self.vbox.pack_start(label, True, True, 0) self.vbox.pack_start(self.download_progress_box, True, False, 0) self.show_all() self.download_progress_box.start()
self.destroy()
self.destroy()
super(PgaSourceDialog, self).__init__()
# GtkBuilder Objects self.sources_selection = self.builder.get_object("sources_selection") self.sources_treeview = self.builder.get_object("sources_treeview") self.remove_source_button = self.builder.get_object( "remove_source_button" )
# Treeview setup self.sources_liststore = Gtk.ListStore(str) renderer = Gtk.CellRendererText() renderer.set_padding(4, 10) uri_column = Gtk.TreeViewColumn("URI", renderer, text=0) self.sources_treeview.append_column(uri_column) self.sources_treeview.set_model(self.sources_liststore) sources = pga.read_sources() for index, source in enumerate(sources): self.sources_liststore.append((source, ))
self.remove_source_button.set_sensitive(False) self.dialog.show_all()
def sources_list(self): return [source[0] for source in self.sources_liststore]
pga.write_sources(self.sources_list) self.on_close(widget, data)
chooser = Gtk.FileChooserDialog( "Select directory", self.dialog, Gtk.FileChooserAction.SELECT_FOLDER, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, "Select", Gtk.ResponseType.OK) ) chooser.set_local_only(False) response = chooser.run() if response == Gtk.ResponseType.OK: uri = chooser.get_uri() if uri not in self.sources_list: self.sources_liststore.append((uri, )) chooser.destroy()
""" Remove a source """ (model, treeiter) = self.sources_selection.get_selected() if treeiter: # TODO : Add confirmation model.remove(treeiter)
""" Set sentivity of remove source button """ (model, treeiter) = self.sources_selection.get_selected() self.remove_source_button.set_sensitive(treeiter is not None)
"connected": (GObject.SIGNAL_RUN_FIRST, None, (str, )), }
super(ClientLoginDialog, self).__init__()
self.username_entry = self.builder.get_object('username_entry') self.password_entry = self.builder.get_object('password_entry')
cancel_button = self.builder.get_object('cancel_button') cancel_button.connect('clicked', self.on_cancel) connect_button = self.builder.get_object('connect_button') connect_button.connect('clicked', self.on_connect)
username = self.username_entry.get_text() password = self.password_entry.get_text() return (username, password)
if all(self.get_credentials()): self.on_connect(None) else: self.password_entry.grab_focus()
if all(self.get_credentials()): self.on_connect(None) else: self.username_entry.grab_focus()
self.dialog.destroy()
username, password = self.get_credentials() token = api.connect(username, password) if not token: NoticeDialog("Login failed") else: self.emit('connected', token) self.dialog.destroy()
Gtk.MessageDialog.__init__(self, parent, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.NONE, "Unable to install the game") self.format_secondary_text("No installer is available for this game") self.add_buttons("Configure manually", 1, "Write installer", 2, "Exit", 4) self.result = self.run() self.destroy() |