A bit of cleanup
This commit is contained in:
@@ -70,12 +70,14 @@ functions and properties first:
|
||||
function. Instead, use a periodic ping that updates a state variable that
|
||||
this function returns.
|
||||
|
||||
.. TODO: these are totally wrong
|
||||
|
||||
* ``get_configuration_form``: This function should return a :class:`Gtk.Box`
|
||||
that gets any inputs required from the user and uses the given
|
||||
``config_store`` to store the configuration values.
|
||||
|
||||
The ``Gtk.Box`` must expose a signal with the name ``"config-valid-changed"``
|
||||
which returns a single boolean value indicating whether or not the
|
||||
configuration is valid.
|
||||
|
||||
If you don't want to implement all of the GTK logic yourself, and just want a
|
||||
simple form, then you can use the
|
||||
:class:`sublime.adapters.ConfigureServerForm` class to generate a form in a
|
||||
|
6
setup.py
6
setup.py
@@ -20,10 +20,10 @@ package_data_dirs = [
|
||||
]
|
||||
package_data_files = []
|
||||
for data_dir in package_data_dirs:
|
||||
for icon in data_dir.iterdir():
|
||||
if not str(icon).endswith(".svg"):
|
||||
for file in data_dir.iterdir():
|
||||
if not str(file).endswith(".svg"):
|
||||
continue
|
||||
package_data_files.append(str(icon))
|
||||
package_data_files.append(str(file))
|
||||
|
||||
setup(
|
||||
name="sublime-music",
|
||||
|
@@ -5,6 +5,7 @@ This file contains all of the classes related for a shared server configuration
|
||||
from dataclasses import dataclass
|
||||
from functools import partial
|
||||
from pathlib import Path
|
||||
from time import sleep
|
||||
from typing import Any, Callable, cast, Dict, Iterable, Optional, Tuple, Type, Union
|
||||
|
||||
from gi.repository import GLib, GObject, Gtk, Pango
|
||||
@@ -253,9 +254,13 @@ class ConfigureServerForm(Gtk.Box):
|
||||
if not self.verifying_in_progress:
|
||||
for c in self.config_verification_box.get_children():
|
||||
self.config_verification_box.remove(c)
|
||||
self.config_verification_box.add(Gtk.Spinner(active=True))
|
||||
self.config_verification_box.add(
|
||||
Gtk.Label(label="Verifying configuration...")
|
||||
Gtk.Spinner(active=True, name="verify-config-spinner")
|
||||
)
|
||||
self.config_verification_box.add(
|
||||
Gtk.Label(
|
||||
label="<b>Verifying configuration...</b>", use_markup=True
|
||||
)
|
||||
)
|
||||
self.verifying_in_progress = True
|
||||
else:
|
||||
@@ -316,7 +321,11 @@ class ConfigureServerForm(Gtk.Box):
|
||||
|
||||
self.had_all_required_keys = True
|
||||
if has_empty:
|
||||
self._set_verification_status(False)
|
||||
self._set_verification_status(
|
||||
False,
|
||||
error_text="<b>There are missing fields</b>\n"
|
||||
"Please fill out all required fields.",
|
||||
)
|
||||
return
|
||||
|
||||
def on_verify_result(verification_errors: Dict[str, Optional[str]]):
|
||||
@@ -342,9 +351,14 @@ class ConfigureServerForm(Gtk.Box):
|
||||
False, error_text=verification_errors.get("__ping__")
|
||||
)
|
||||
|
||||
errors_result: Result[Dict[str, Optional[str]]] = Result(
|
||||
self.verify_configuration
|
||||
)
|
||||
def verify_with_delay() -> Dict[str, Optional[str]]:
|
||||
sleep(0.75)
|
||||
if self._verification_status_ratchet != ratchet:
|
||||
return {}
|
||||
|
||||
return self.verify_configuration()
|
||||
|
||||
errors_result: Result[Dict[str, Optional[str]]] = Result(verify_with_delay)
|
||||
errors_result.add_done_callback(
|
||||
lambda f: GLib.idle_add(on_verify_result, f.result())
|
||||
)
|
||||
|
@@ -282,8 +282,6 @@ class AdapterManager:
|
||||
|
||||
AdapterManager._offline_mode = config.offline_mode
|
||||
|
||||
# TODO (#197): actually do stuff with the config to determine which adapters to
|
||||
# create, etc.
|
||||
assert config.provider is not None
|
||||
assert isinstance(config.provider, ProviderConfiguration)
|
||||
assert config.cache_location
|
||||
|
@@ -519,7 +519,7 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
page: int = 0
|
||||
num_pages: Optional[int] = None
|
||||
next_page_fn = None
|
||||
server_id: Optional[str] = None
|
||||
provider_id: Optional[str] = None
|
||||
|
||||
def update_params(self, query: AlbumSearchQuery, offline_mode: bool) -> int:
|
||||
# If there's a diff, increase the ratchet.
|
||||
@@ -621,9 +621,9 @@ class AlbumsGrid(Gtk.Overlay):
|
||||
self.page = app_config.state.album_page
|
||||
|
||||
assert app_config.provider
|
||||
if self.server_id != app_config.provider.id:
|
||||
if self.provider_id != app_config.provider.id:
|
||||
self.order_ratchet += 1
|
||||
self.server_id = app_config.provider.id
|
||||
self.provider_id = app_config.provider.id
|
||||
|
||||
self.update_grid(
|
||||
order_token,
|
||||
|
@@ -77,6 +77,11 @@
|
||||
margin: 5px -10px;
|
||||
}
|
||||
|
||||
#verify-config-spinner {
|
||||
min-height: 32px;
|
||||
min-width: 32px;
|
||||
}
|
||||
|
||||
.configure-form-help-icon {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
@@ -26,19 +26,6 @@ class ConfigureProviderDialog(Gtk.Dialog):
|
||||
_current_index = -1
|
||||
stage = DialogStage.SELECT_ADAPTER
|
||||
|
||||
__gsignals__ = {
|
||||
"server-list-changed": (
|
||||
GObject.SignalFlags.RUN_FIRST,
|
||||
GObject.TYPE_NONE,
|
||||
(object,),
|
||||
),
|
||||
"connected-server-changed": (
|
||||
GObject.SignalFlags.RUN_FIRST,
|
||||
GObject.TYPE_NONE,
|
||||
(object,),
|
||||
),
|
||||
}
|
||||
|
||||
def set_title(self, editing: bool, provider_config: ProviderConfiguration = None):
|
||||
if editing:
|
||||
assert provider_config is not None
|
||||
|
Reference in New Issue
Block a user