clan-app: Improve method_name argument
This commit is contained in:
@@ -14,7 +14,7 @@ Follow the instructions below to set up your development environment and start t
|
||||
Go to the `clan-core/pkgs/webview-ui/app` directory and start the web server by executing:
|
||||
|
||||
```bash
|
||||
npm i
|
||||
npm install
|
||||
vite
|
||||
```
|
||||
|
||||
@@ -29,36 +29,6 @@ Follow the instructions below to set up your development environment and start t
|
||||
This will start the application in debug mode and link it to the web server running at `http://localhost:3000`.
|
||||
|
||||
|
||||
# clan app (old)
|
||||
|
||||
Provides users with the simple functionality to manage their locally registered clans.
|
||||
|
||||

|
||||
|
||||
## Available commands
|
||||
|
||||
Run this application
|
||||
|
||||
```bash
|
||||
./bin/clan-app
|
||||
```
|
||||
|
||||
Join the default machine of a clan
|
||||
|
||||
```bash
|
||||
./bin/clan-app [clan-uri]
|
||||
```
|
||||
|
||||
Join a specific machine of a clan
|
||||
|
||||
```bash
|
||||
./bin/clan-app [clan-uri]#[machine]
|
||||
```
|
||||
|
||||
For more available commands see the developer section below.
|
||||
|
||||
## Developing this Application
|
||||
|
||||
### Debugging Style and Layout
|
||||
|
||||
```bash
|
||||
@@ -108,14 +78,10 @@ gtk4-icon-browser
|
||||
|
||||
Here are some important documentation links related to the Clan App:
|
||||
|
||||
- [Adw PyGobject Reference](http://lazka.github.io/pgi-docs/index.html#Adw-1): This link provides the PyGObject reference documentation for the Adw library, which is used in the Clan App. It contains detailed information about the Adw widgets and their usage.
|
||||
|
||||
- [GTK4 PyGobject Reference](http://lazka.github.io/pgi-docs/index.html#Gtk-4.0): This link provides the PyGObject reference documentation for GTK4, the toolkit used for building the user interface of the clan app. It includes information about GTK4 widgets, signals, and other features.
|
||||
|
||||
- [Adw Widget Gallery](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/widget-gallery.html): This link showcases a widget gallery for Adw, allowing you to see the available widgets and their visual appearance. It can be helpful for designing the user interface of the clan app.
|
||||
|
||||
- [Python + GTK3 Tutorial](https://python-gtk-3-tutorial.readthedocs.io/en/latest/textview.html): Although the clan app uses GTK4, this tutorial for GTK3 can still be useful as it covers the basics of building GTK-based applications with Python. It includes examples and explanations for various GTK widgets, including text views.
|
||||
|
||||
- [GNOME Human Interface Guidelines](https://developer.gnome.org/hig/): This link provides the GNOME Human Interface Guidelines, which offer design and usability recommendations for creating GNOME applications. It covers topics such as layout, navigation, and interaction patterns.
|
||||
|
||||
## Error handling
|
||||
|
||||
@@ -29,7 +29,9 @@ class ImplFunc(GObject.Object, Generic[P, B]):
|
||||
"returns": (GObject.SignalFlags.RUN_FIRST, None, [GResult]),
|
||||
}
|
||||
|
||||
def returns(self, method_name: str, result: B) -> None:
|
||||
def returns(self, result: B, *, method_name: str | None = None) -> None:
|
||||
if method_name is None:
|
||||
method_name = self.__class__.__name__
|
||||
if self.op_key is None:
|
||||
raise ValueError(f"op_key is not set for the function {method_name}")
|
||||
self.emit("returns", GResult(result, method_name, self.op_key))
|
||||
@@ -57,7 +59,7 @@ class GObjApi:
|
||||
self._methods: dict[str, Callable[..., Any]] = methods
|
||||
self._obj_registry: dict[str, type[ImplFunc]] = {}
|
||||
|
||||
def register_overwrite(self, obj: type[ImplFunc]) -> None:
|
||||
def overwrite_fn(self, obj: type[ImplFunc]) -> None:
|
||||
fn_name = obj.__name__
|
||||
|
||||
if not isinstance(obj, type(ImplFunc)):
|
||||
|
||||
@@ -42,20 +42,20 @@ class WebExecutor(GObject.Object):
|
||||
|
||||
self.api: GObjApi = GObjApi(self.plain_api.functions)
|
||||
|
||||
self.api.register_overwrite(open_file)
|
||||
self.api.overwrite_fn(open_file)
|
||||
self.api.check_signature(self.plain_api.annotations)
|
||||
|
||||
def on_decide_policy(
|
||||
self,
|
||||
webview: WebKit.WebView,
|
||||
decision: WebKit.PolicyDecision,
|
||||
decision: WebKit.NavigationPolicyDecision,
|
||||
decision_type: WebKit.PolicyDecisionType,
|
||||
) -> bool:
|
||||
if decision_type != WebKit.PolicyDecisionType.NAVIGATION_ACTION:
|
||||
return False # Continue with the default handler
|
||||
|
||||
navigation_action = decision.get_navigation_action()
|
||||
request = navigation_action.get_request()
|
||||
navigation_action: WebKit.NavigationAction = decision.get_navigation_action()
|
||||
request: WebKit.URIRequest = navigation_action.get_request()
|
||||
uri = request.get_uri()
|
||||
if self.content_uri.startswith("http://") and uri.startswith(self.content_uri):
|
||||
log.debug(f"Allow navigation request: {uri}")
|
||||
@@ -117,7 +117,7 @@ class WebExecutor(GObject.Object):
|
||||
result["result"] = dataclass_to_dict(data.result)
|
||||
result["op_key"] = data.op_key
|
||||
serialized = json.dumps(result, indent=4)
|
||||
log.debug(f"Result: {serialized}")
|
||||
log.debug(f"Result for {data.method_name}: {serialized}")
|
||||
# Use idle_add to queue the response call to js on the main GTK thread
|
||||
self.return_data_to_js(data.method_name, serialized)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user