|
1 |
| -# -*- coding: utf-8 -*- |
| 1 | +from RPC import RPC |
2 | 2 |
|
3 |
| -from json import dumps |
4 | 3 |
|
5 | 4 | class FlowLauncherAPI:
|
6 |
| - |
7 | 5 | @classmethod
|
8 | 6 | def change_query(cls, query, requery: bool = False):
|
9 | 7 | """
|
10 | 8 | change flow launcher query
|
11 | 9 | """
|
12 |
| - print(dumps({ |
13 |
| - "method": "Flow.Launcher.ChangeQuery", |
14 |
| - "parameters": [query, requery]})) |
| 10 | + RPC( |
| 11 | + method="Flow.Launcher.ChangeQuery", |
| 12 | + parameters=[query, requery], |
| 13 | + ).to_string() |
15 | 14 |
|
16 | 15 | @classmethod
|
17 | 16 | def shell_run(cls, cmd):
|
18 | 17 | """
|
19 | 18 | run shell commands
|
20 | 19 | """
|
21 |
| - print(dumps({ |
22 |
| - "method": "Flow.Launcher.ShellRun", |
23 |
| - "parameters": [cmd]})) |
| 20 | + RPC( |
| 21 | + method="Flow.Launcher.ShellRun", |
| 22 | + parameters=[cmd], |
| 23 | + ).to_string() |
24 | 24 |
|
25 | 25 | @classmethod
|
26 | 26 | def close_app(cls):
|
27 | 27 | """
|
28 | 28 | close flow launcher
|
29 | 29 | """
|
30 |
| - print(dumps({ |
31 |
| - "method": "Flow.Launcher.CloseApp", |
32 |
| - "parameters": []})) |
| 30 | + RPC(method="Flow.Launcher.CloseApp").to_string() |
33 | 31 |
|
34 | 32 | @classmethod
|
35 | 33 | def hide_app(cls):
|
36 | 34 | """
|
37 | 35 | hide flow launcher
|
38 | 36 | """
|
39 |
| - print(dumps({ |
40 |
| - "method": "Flow.Launcher.HideApp", |
41 |
| - "parameters": []})) |
| 37 | + RPC(method="Flow.Launcher.HideApp").to_string() |
42 | 38 |
|
43 | 39 | @classmethod
|
44 | 40 | def show_app(cls):
|
45 | 41 | """
|
46 | 42 | show flow launcher
|
47 | 43 | """
|
48 |
| - print(dumps({ |
49 |
| - "method": "Flow.Launcher.ShowApp", |
50 |
| - "parameters": []})) |
| 44 | + RPC(method="Flow.Launcher.ShowApp").to_string() |
51 | 45 |
|
52 | 46 | @classmethod
|
53 | 47 | def show_msg(cls, title: str, sub_title: str, ico_path: str = ""):
|
54 | 48 | """
|
55 | 49 | show messagebox
|
56 | 50 | """
|
57 |
| - print(dumps({ |
58 |
| - "method": "Flow.Launcher.ShowMsg", |
59 |
| - "parameters": [title, sub_title, ico_path]})) |
| 51 | + RPC( |
| 52 | + method="Flow.Launcher.ShowMsg", |
| 53 | + parameters=[ |
| 54 | + title, |
| 55 | + sub_title, |
| 56 | + ico_path, |
| 57 | + ], |
| 58 | + ).to_string() |
60 | 59 |
|
61 | 60 | @classmethod
|
62 | 61 | def open_setting_dialog(cls):
|
63 | 62 | """
|
64 | 63 | open setting dialog
|
65 | 64 | """
|
66 |
| - print(dumps({ |
67 |
| - "method": "Flow.Launcher.OpenSettingDialog", |
68 |
| - "parameters": []})) |
| 65 | + RPC(method="Flow.Launcher.OpenSettingDialog").to_string() |
69 | 66 |
|
70 | 67 | @classmethod
|
71 | 68 | def start_loadingbar(cls):
|
72 | 69 | """
|
73 | 70 | start loading animation in flow launcher
|
74 | 71 | """
|
75 |
| - print(dumps({ |
76 |
| - "method": "Flow.Launcher.StartLoadingBar", |
77 |
| - "parameters": []})) |
| 72 | + RPC(method="Flow.Launcher.StartLoadingBar").to_string() |
78 | 73 |
|
79 | 74 | @classmethod
|
80 | 75 | def stop_loadingbar(cls):
|
81 | 76 | """
|
82 | 77 | stop loading animation in flow launcher
|
83 | 78 | """
|
84 |
| - print(dumps({ |
85 |
| - "method": "Flow.Launcher.StopLoadingBar", |
86 |
| - "parameters": []})) |
| 79 | + RPC(method="Flow.Launcher.StartLoadingBar").to_string() |
87 | 80 |
|
88 | 81 | @classmethod
|
89 | 82 | def reload_plugins(cls):
|
90 | 83 | """
|
91 | 84 | reload all flow launcher plugins
|
92 | 85 | """
|
93 |
| - print(dumps({ |
94 |
| - "method": "Flow.Launcher.ReloadPlugins", |
95 |
| - "parameters": []})) |
| 86 | + RPC(method="Flow.Launcher.ReloadPlugins").to_string() |
0 commit comments