@girs/unique-3.0 3.0.0-3.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/package.json +64 -0
- package/tsconfig.doc.json +19 -0
- package/unique-3.0.cjs +9 -0
- package/unique-3.0.d.cts +554 -0
- package/unique-3.0.d.ts +559 -0
- package/unique-3.0.js +8 -0
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
# Unique-3.0
|
|
3
|
+
|
|
4
|
+
GJS TypeScript type definitions for Unique-3.0, generated from library version 3.0.0 using [ts-for-gir](https://github.com/gjsify/ts-for-gjs) v3.0.0-beta.12.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
To use this type definitions, install them with NPM like this:
|
|
9
|
+
```bash
|
|
10
|
+
npm install @girs/unique-3.0
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
You can import this package into your project like this:
|
|
16
|
+
```ts
|
|
17
|
+
import Unique from '@girs/unique-3.0';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or if you prefer CommonJS, you can also use this:
|
|
21
|
+
```ts
|
|
22
|
+
const Unique = require('@girs/unique-3.0');
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If you use [ambient modules](https://github.com/gjsify/ts-for-gir/tree/main/packages/cli#ambient-modules), you can also import this module like you would do this in JavaScript:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import Unique from 'gi://Unique?version=3.0';
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Depending on your project configuration, it is recommended to use a bundler like [esbuild](https://esbuild.github.io/). You can find examples using different bundlers [here](https://github.com/gjsify/ts-for-gir/tree/main/examples).
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@girs/unique-3.0",
|
|
3
|
+
"version": "3.0.0-3.0.0-beta.12",
|
|
4
|
+
"description": "GJS TypeScript type definitions for Unique-3.0, generated from library version 3.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "unique-3.0.js",
|
|
7
|
+
"main": "unique-3.0.js",
|
|
8
|
+
"typedoc": {
|
|
9
|
+
"entryPoint": "./unique-3.0.d.ts",
|
|
10
|
+
"readmeFile": "./README.md",
|
|
11
|
+
"displayName": "Unique-3.0",
|
|
12
|
+
"tsconfig": "./tsconfig.doc.json"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./unique-3.0.d.ts",
|
|
18
|
+
"default": "./unique-3.0.js"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./unique-3.0.d.cts",
|
|
22
|
+
"default": "./unique-3.0.cjs"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "yarn test:esm && yarn test:cjs",
|
|
28
|
+
"test:esm": "tsc --noEmit unique-3.0.d.ts",
|
|
29
|
+
"test:cjs": "tsc --noEmit unique-3.0.d.cts"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@girs/atk-1.0": "^2.45.1-3.0.0-beta.12",
|
|
33
|
+
"@girs/cairo-1.0": "^1.0.0-3.0.0-beta.12",
|
|
34
|
+
"@girs/freetype2-2.0": "^2.0.0-3.0.0-beta.12",
|
|
35
|
+
"@girs/gdk-3.0": "^3.24.36-3.0.0-beta.12",
|
|
36
|
+
"@girs/gdkpixbuf-2.0": "^2.0.0-3.0.0-beta.12",
|
|
37
|
+
"@girs/gio-2.0": "^2.75.1-3.0.0-beta.12",
|
|
38
|
+
"@girs/glib-2.0": "^2.75.1-3.0.0-beta.12",
|
|
39
|
+
"@girs/gmodule-2.0": "^2.0.0-3.0.0-beta.12",
|
|
40
|
+
"@girs/gobject-2.0": "^2.75.1-3.0.0-beta.12",
|
|
41
|
+
"@girs/gtk-3.0": "^3.24.36-3.0.0-beta.12",
|
|
42
|
+
"@girs/harfbuzz-0.0": "^6.0.0-3.0.0-beta.12",
|
|
43
|
+
"@girs/pango-1.0": "^1.50.13-3.0.0-beta.12",
|
|
44
|
+
"@girs/xlib-2.0": "^2.0.0-3.0.0-beta.12"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"typescript": "^*"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"Gir",
|
|
51
|
+
"TypeScript",
|
|
52
|
+
"Unique-3.0"
|
|
53
|
+
],
|
|
54
|
+
"author": "ts-for-gir",
|
|
55
|
+
"license": "Apache-2.0",
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "git+https://github.com/gjsify/ts-for-gir.git"
|
|
59
|
+
},
|
|
60
|
+
"bugs": {
|
|
61
|
+
"url": "https://github.com/gjsify/ts-for-gir/issues"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://github.com/gjsify/ts-for-gir#readme"
|
|
64
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// General settings for code interpretation
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"experimentalDecorators": true,
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"noEmitOnError": false,
|
|
10
|
+
"baseUrl": "./",
|
|
11
|
+
"rootDir": ".",
|
|
12
|
+
// General settings for code generation
|
|
13
|
+
"removeComments": false,
|
|
14
|
+
"inlineSourceMap": false,
|
|
15
|
+
"inlineSources": false,
|
|
16
|
+
"newLine": "LF"
|
|
17
|
+
},
|
|
18
|
+
"include": ["./unique-3.0.d.ts"]
|
|
19
|
+
}
|
package/unique-3.0.cjs
ADDED
package/unique-3.0.d.cts
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* Type Definitions for Gjs (https://gjs.guide/)
|
|
4
|
+
*
|
|
5
|
+
* These type definitions are automatically generated, do not edit them by hand.
|
|
6
|
+
* If you found a bug fix it in `ts-for-gir` or create a bug report on https://github.com/gjsify/ts-for-gjs
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Unique-3.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type xlib from '@girs/xlib-2.0';
|
|
13
|
+
import type cairo from '@girs/cairo-1.0';
|
|
14
|
+
import type Pango from '@girs/pango-1.0';
|
|
15
|
+
import type HarfBuzz from '@girs/harfbuzz-0.0';
|
|
16
|
+
import type freetype2 from '@girs/freetype2-2.0';
|
|
17
|
+
import type GObject from '@girs/gobject-2.0';
|
|
18
|
+
import type GLib from '@girs/glib-2.0';
|
|
19
|
+
import type Gio from '@girs/gio-2.0';
|
|
20
|
+
import type Gtk from '@girs/gtk-3.0';
|
|
21
|
+
import type Gdk from '@girs/gdk-3.0';
|
|
22
|
+
import type GdkPixbuf from '@girs/gdkpixbuf-2.0';
|
|
23
|
+
import type GModule from '@girs/gmodule-2.0';
|
|
24
|
+
import type Atk from '@girs/atk-1.0';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Command to send to a currently active instance. User defined commands
|
|
28
|
+
* should be positive integers, and should be added using the
|
|
29
|
+
* unique_app_add_command() function after creating a #UniqueApp instance
|
|
30
|
+
*/
|
|
31
|
+
export enum Command {
|
|
32
|
+
INVALID,
|
|
33
|
+
ACTIVATE,
|
|
34
|
+
NEW,
|
|
35
|
+
OPEN,
|
|
36
|
+
CLOSE,
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Response that a currently active instance of the application should
|
|
40
|
+
* return to the caller which sent a command.
|
|
41
|
+
*/
|
|
42
|
+
export enum Response {
|
|
43
|
+
INVALID,
|
|
44
|
+
OK,
|
|
45
|
+
CANCEL,
|
|
46
|
+
FAIL,
|
|
47
|
+
PASSTHROUGH,
|
|
48
|
+
}
|
|
49
|
+
export module App {
|
|
50
|
+
|
|
51
|
+
// Signal callback interfaces
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Signal callback interface for `message-received`
|
|
55
|
+
*/
|
|
56
|
+
export interface MessageReceivedSignalCallback {
|
|
57
|
+
($obj: App, command: number, message_data: MessageData, time_: number): Response
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
// Constructor properties interface
|
|
62
|
+
|
|
63
|
+
export interface ConstructorProperties extends GObject.Object.ConstructorProperties {
|
|
64
|
+
|
|
65
|
+
// Own constructor properties of Unique-3.0.Unique.App
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The unique name of the application. It must be in form of
|
|
69
|
+
* a domain-like string, like <literal>org.gnome.MyApplication</literal>.
|
|
70
|
+
*/
|
|
71
|
+
name?: string | null
|
|
72
|
+
/**
|
|
73
|
+
* The #GdkScreen of the application.
|
|
74
|
+
*/
|
|
75
|
+
screen?: Gdk.Screen | null
|
|
76
|
+
/**
|
|
77
|
+
* The startup notification id, needed to complete the startup
|
|
78
|
+
* notification sequence. If not set, a default id will be
|
|
79
|
+
* automatically given.
|
|
80
|
+
*/
|
|
81
|
+
startup_id?: string | null
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface App {
|
|
87
|
+
|
|
88
|
+
// Own properties of Unique-3.0.Unique.App
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Whether another instance of the application is running.
|
|
92
|
+
*/
|
|
93
|
+
readonly is_running: boolean
|
|
94
|
+
/**
|
|
95
|
+
* The unique name of the application. It must be in form of
|
|
96
|
+
* a domain-like string, like <literal>org.gnome.MyApplication</literal>.
|
|
97
|
+
*/
|
|
98
|
+
readonly name: string
|
|
99
|
+
/**
|
|
100
|
+
* The #GdkScreen of the application.
|
|
101
|
+
*/
|
|
102
|
+
screen: Gdk.Screen
|
|
103
|
+
/**
|
|
104
|
+
* The startup notification id, needed to complete the startup
|
|
105
|
+
* notification sequence. If not set, a default id will be
|
|
106
|
+
* automatically given.
|
|
107
|
+
*/
|
|
108
|
+
readonly startup_id: string
|
|
109
|
+
|
|
110
|
+
// Owm methods of Unique-3.0.Unique.App
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Adds `command_name` as a custom command that can be used by `app`. You
|
|
114
|
+
* must call unique_app_add_command() before unique_app_send_message() in
|
|
115
|
+
* order to use the newly added command.
|
|
116
|
+
*
|
|
117
|
+
* The command name is used internally: you need to use the command's logical
|
|
118
|
+
* id in unique_app_send_message() and inside the UniqueApp::message-received
|
|
119
|
+
* signal.
|
|
120
|
+
* @param command_name command name
|
|
121
|
+
* @param command_id command logical id
|
|
122
|
+
*/
|
|
123
|
+
add_command(command_name: string | null, command_id: number): void
|
|
124
|
+
/**
|
|
125
|
+
* Sends `command` to a running instance of `app`. If you need to pass data
|
|
126
|
+
* to the instance, you should create a #UniqueMessageData object using
|
|
127
|
+
* unique_message_data_new() and then fill it with the data you intend to
|
|
128
|
+
* pass.
|
|
129
|
+
*
|
|
130
|
+
* The running application will receive a UniqueApp::message-received signal
|
|
131
|
+
* and will call the various signal handlers attach to it. If any handler
|
|
132
|
+
* returns a #UniqueResponse different than %UNIQUE_RESPONSE_OK, the emission
|
|
133
|
+
* will stop.
|
|
134
|
+
* @param command_id command to send
|
|
135
|
+
* @param message_data #UniqueMessageData, or %NULL
|
|
136
|
+
* @returns The #UniqueResponse returned by the running instance
|
|
137
|
+
*/
|
|
138
|
+
send_message(command_id: number, message_data?: MessageData | null): Response
|
|
139
|
+
/**
|
|
140
|
+
* Makes `app` "watch" a window. Every watched window will receive
|
|
141
|
+
* startup notification changes automatically.
|
|
142
|
+
* @param window the #GtkWindow to watch
|
|
143
|
+
*/
|
|
144
|
+
watch_window(window: Gtk.Window): void
|
|
145
|
+
|
|
146
|
+
// Own virtual methods of Unique-3.0.Unique.App
|
|
147
|
+
|
|
148
|
+
vfunc_message_received(command: number, message_data: MessageData, time_: number): Response
|
|
149
|
+
|
|
150
|
+
// Own signals of Unique-3.0.Unique.App
|
|
151
|
+
|
|
152
|
+
connect(sigName: "message-received", callback: App.MessageReceivedSignalCallback): number
|
|
153
|
+
connect_after(sigName: "message-received", callback: App.MessageReceivedSignalCallback): number
|
|
154
|
+
emit(sigName: "message-received", command: number, message_data: MessageData, time_: number, ...args: any[]): void
|
|
155
|
+
|
|
156
|
+
// Class property signals of Unique-3.0.Unique.App
|
|
157
|
+
|
|
158
|
+
connect(sigName: "notify::is-running", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
159
|
+
connect_after(sigName: "notify::is-running", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
160
|
+
emit(sigName: "notify::is-running", ...args: any[]): void
|
|
161
|
+
connect(sigName: "notify::name", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
162
|
+
connect_after(sigName: "notify::name", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
163
|
+
emit(sigName: "notify::name", ...args: any[]): void
|
|
164
|
+
connect(sigName: "notify::screen", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
165
|
+
connect_after(sigName: "notify::screen", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
166
|
+
emit(sigName: "notify::screen", ...args: any[]): void
|
|
167
|
+
connect(sigName: "notify::startup-id", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
168
|
+
connect_after(sigName: "notify::startup-id", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
169
|
+
emit(sigName: "notify::startup-id", ...args: any[]): void
|
|
170
|
+
connect(sigName: string, callback: (...args: any[]) => void): number
|
|
171
|
+
connect_after(sigName: string, callback: (...args: any[]) => void): number
|
|
172
|
+
emit(sigName: string, ...args: any[]): void
|
|
173
|
+
disconnect(id: number): void
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The base class for every single instance application. The #UniqueApp
|
|
178
|
+
* structure contains only private data and should be manipulated only
|
|
179
|
+
* with the provided functions.
|
|
180
|
+
* @class
|
|
181
|
+
*/
|
|
182
|
+
export class App extends GObject.Object {
|
|
183
|
+
|
|
184
|
+
// Own properties of Unique-3.0.Unique.App
|
|
185
|
+
|
|
186
|
+
static name: string
|
|
187
|
+
static $gtype: GObject.GType<App>
|
|
188
|
+
|
|
189
|
+
// Constructors of Unique-3.0.Unique.App
|
|
190
|
+
|
|
191
|
+
constructor(config?: App.ConstructorProperties)
|
|
192
|
+
/**
|
|
193
|
+
* Creates a new #UniqueApp instance for `name` passing a start-up notification
|
|
194
|
+
* id `startup_id`. The name must be a unique identifier for the application,
|
|
195
|
+
* and it must be in form of a domain name, like
|
|
196
|
+
* <literal>org.gnome.YourApplication</literal>.
|
|
197
|
+
*
|
|
198
|
+
* If `startup_id` is %NULL the <literal>DESKTOP_STARTUP_ID</literal>
|
|
199
|
+
* environment variable will be check, and if that fails a "fake" startup
|
|
200
|
+
* notification id will be created.
|
|
201
|
+
*
|
|
202
|
+
* Once you have created a #UniqueApp instance, you should check if
|
|
203
|
+
* any other instance is running, using unique_app_is_running().
|
|
204
|
+
* If another instance is running you can send a command to it, using
|
|
205
|
+
* the unique_app_send_message() function; after that, the second instance
|
|
206
|
+
* should quit. If no other instance is running, the usual logic for
|
|
207
|
+
* creating the application can follow.
|
|
208
|
+
* @constructor
|
|
209
|
+
* @param name the name of the application's instance
|
|
210
|
+
* @param startup_id the startup notification id, or %NULL
|
|
211
|
+
* @returns the newly created #UniqueApp instance.
|
|
212
|
+
*/
|
|
213
|
+
constructor(name: string | null, startup_id?: string | null)
|
|
214
|
+
/**
|
|
215
|
+
* Creates a new #UniqueApp instance for `name` passing a start-up notification
|
|
216
|
+
* id `startup_id`. The name must be a unique identifier for the application,
|
|
217
|
+
* and it must be in form of a domain name, like
|
|
218
|
+
* <literal>org.gnome.YourApplication</literal>.
|
|
219
|
+
*
|
|
220
|
+
* If `startup_id` is %NULL the <literal>DESKTOP_STARTUP_ID</literal>
|
|
221
|
+
* environment variable will be check, and if that fails a "fake" startup
|
|
222
|
+
* notification id will be created.
|
|
223
|
+
*
|
|
224
|
+
* Once you have created a #UniqueApp instance, you should check if
|
|
225
|
+
* any other instance is running, using unique_app_is_running().
|
|
226
|
+
* If another instance is running you can send a command to it, using
|
|
227
|
+
* the unique_app_send_message() function; after that, the second instance
|
|
228
|
+
* should quit. If no other instance is running, the usual logic for
|
|
229
|
+
* creating the application can follow.
|
|
230
|
+
* @constructor
|
|
231
|
+
* @param name the name of the application's instance
|
|
232
|
+
* @param startup_id the startup notification id, or %NULL
|
|
233
|
+
* @returns the newly created #UniqueApp instance.
|
|
234
|
+
*/
|
|
235
|
+
static new(name: string | null, startup_id?: string | null): App
|
|
236
|
+
_init(config?: App.ConstructorProperties): void
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export module Backend {
|
|
240
|
+
|
|
241
|
+
// Constructor properties interface
|
|
242
|
+
|
|
243
|
+
export interface ConstructorProperties extends GObject.Object.ConstructorProperties {
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface Backend {
|
|
249
|
+
|
|
250
|
+
// Own fields of Unique-3.0.Unique.Backend
|
|
251
|
+
|
|
252
|
+
parent_instance: GObject.Object
|
|
253
|
+
|
|
254
|
+
// Owm methods of Unique-3.0.Unique.Backend
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* FIXME
|
|
258
|
+
* @returns FIXME
|
|
259
|
+
*/
|
|
260
|
+
get_name(): string | null
|
|
261
|
+
/**
|
|
262
|
+
* FIXME
|
|
263
|
+
* @returns FIXME
|
|
264
|
+
*/
|
|
265
|
+
get_screen(): Gdk.Screen
|
|
266
|
+
/**
|
|
267
|
+
* FIXME
|
|
268
|
+
* @returns FIXME
|
|
269
|
+
*/
|
|
270
|
+
get_startup_id(): string | null
|
|
271
|
+
/**
|
|
272
|
+
* Retrieves the current workspace.
|
|
273
|
+
* @returns a workspace number
|
|
274
|
+
*/
|
|
275
|
+
get_workspace(): number
|
|
276
|
+
/**
|
|
277
|
+
* Requests the name set using unique_backend_set_name() using `backend`.
|
|
278
|
+
*
|
|
279
|
+
* already is a registered name
|
|
280
|
+
* @returns %TRUE if the name was assigned to us, %FALSE if there
|
|
281
|
+
*/
|
|
282
|
+
request_name(): boolean
|
|
283
|
+
/**
|
|
284
|
+
* Sends `command_id,` and optionally `message_data,` to a running instance
|
|
285
|
+
* using `backend`.
|
|
286
|
+
* @param command_id command to send
|
|
287
|
+
* @param message_data message to send, or %NULL
|
|
288
|
+
* @param time_ time of the command emission, or 0 for the current time
|
|
289
|
+
* @returns a #UniqueResponse value sent by the running instance
|
|
290
|
+
*/
|
|
291
|
+
send_message(command_id: number, message_data: MessageData, time_: number): Response
|
|
292
|
+
/**
|
|
293
|
+
* FIXME
|
|
294
|
+
* @param name FIXME
|
|
295
|
+
*/
|
|
296
|
+
set_name(name: string | null): void
|
|
297
|
+
/**
|
|
298
|
+
* FIXME
|
|
299
|
+
* @param screen FIXME
|
|
300
|
+
*/
|
|
301
|
+
set_screen(screen: Gdk.Screen): void
|
|
302
|
+
/**
|
|
303
|
+
* FIXME
|
|
304
|
+
* @param startup_id FIXME
|
|
305
|
+
*/
|
|
306
|
+
set_startup_id(startup_id: string | null): void
|
|
307
|
+
|
|
308
|
+
// Own virtual methods of Unique-3.0.Unique.Backend
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Requests the name set using unique_backend_set_name() using `backend`.
|
|
312
|
+
*
|
|
313
|
+
* already is a registered name
|
|
314
|
+
* @virtual
|
|
315
|
+
* @returns %TRUE if the name was assigned to us, %FALSE if there
|
|
316
|
+
*/
|
|
317
|
+
vfunc_request_name(): boolean
|
|
318
|
+
/**
|
|
319
|
+
* Sends `command_id,` and optionally `message_data,` to a running instance
|
|
320
|
+
* using `backend`.
|
|
321
|
+
* @virtual
|
|
322
|
+
* @param command_id command to send
|
|
323
|
+
* @param message_data message to send, or %NULL
|
|
324
|
+
* @param time_ time of the command emission, or 0 for the current time
|
|
325
|
+
* @returns a #UniqueResponse value sent by the running instance
|
|
326
|
+
*/
|
|
327
|
+
vfunc_send_message(command_id: number, message_data: MessageData, time_: number): Response
|
|
328
|
+
|
|
329
|
+
// Class property signals of Unique-3.0.Unique.Backend
|
|
330
|
+
|
|
331
|
+
connect(sigName: string, callback: (...args: any[]) => void): number
|
|
332
|
+
connect_after(sigName: string, callback: (...args: any[]) => void): number
|
|
333
|
+
emit(sigName: string, ...args: any[]): void
|
|
334
|
+
disconnect(id: number): void
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* The #UniqueBackend structure contains only private data and should only
|
|
339
|
+
* be accessed using the provided functions.
|
|
340
|
+
* @class
|
|
341
|
+
*/
|
|
342
|
+
export class Backend extends GObject.Object {
|
|
343
|
+
|
|
344
|
+
// Own properties of Unique-3.0.Unique.Backend
|
|
345
|
+
|
|
346
|
+
static name: string
|
|
347
|
+
static $gtype: GObject.GType<Backend>
|
|
348
|
+
|
|
349
|
+
// Constructors of Unique-3.0.Unique.Backend
|
|
350
|
+
|
|
351
|
+
constructor(config?: Backend.ConstructorProperties)
|
|
352
|
+
_init(config?: Backend.ConstructorProperties): void
|
|
353
|
+
/**
|
|
354
|
+
* Creates a #UniqueBackend using the default backend defined at
|
|
355
|
+
* compile time. You can override the default backend by setting the
|
|
356
|
+
* <literal>UNIQUE_BACKEND</literal> environment variable with the
|
|
357
|
+
* name of the desired backend.
|
|
358
|
+
* @returns the newly created #UniqueBackend instance
|
|
359
|
+
*/
|
|
360
|
+
static create(): Backend
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface AppClass {
|
|
364
|
+
|
|
365
|
+
// Own fields of Unique-3.0.Unique.AppClass
|
|
366
|
+
|
|
367
|
+
message_received: (app: App, command: number, message_data: MessageData, time_: number) => Response
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Base class for every single instance application.
|
|
372
|
+
* @record
|
|
373
|
+
*/
|
|
374
|
+
export abstract class AppClass {
|
|
375
|
+
|
|
376
|
+
// Own properties of Unique-3.0.Unique.AppClass
|
|
377
|
+
|
|
378
|
+
static name: string
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export interface AppPrivate {
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export class AppPrivate {
|
|
385
|
+
|
|
386
|
+
// Own properties of Unique-3.0.Unique.AppPrivate
|
|
387
|
+
|
|
388
|
+
static name: string
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export interface BackendClass {
|
|
392
|
+
|
|
393
|
+
// Own fields of Unique-3.0.Unique.BackendClass
|
|
394
|
+
|
|
395
|
+
request_name: (backend: Backend) => boolean
|
|
396
|
+
send_message: (backend: Backend, command_id: number, message_data: MessageData, time_: number) => Response
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* The class that should be implemented by every backend for #UniqueApp.
|
|
401
|
+
* @record
|
|
402
|
+
*/
|
|
403
|
+
export abstract class BackendClass {
|
|
404
|
+
|
|
405
|
+
// Own properties of Unique-3.0.Unique.BackendClass
|
|
406
|
+
|
|
407
|
+
static name: string
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export interface MessageData {
|
|
411
|
+
|
|
412
|
+
// Owm methods of Unique-3.0.Unique.MessageData
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Copies `message_data`.
|
|
416
|
+
* @returns a copy of the passed #UniqueMessageData
|
|
417
|
+
*/
|
|
418
|
+
copy(): MessageData
|
|
419
|
+
/**
|
|
420
|
+
* Frees all the resources allocated by `message_data`.
|
|
421
|
+
*/
|
|
422
|
+
free(): void
|
|
423
|
+
/**
|
|
424
|
+
* Retrieves the raw contents of `message_data` set using
|
|
425
|
+
* unique_messaget_data_set().
|
|
426
|
+
*
|
|
427
|
+
* returned string is owned by the #UniqueMessageData and should
|
|
428
|
+
* never be modified or freed
|
|
429
|
+
* @returns the contents of the message data or %NULL. The
|
|
430
|
+
*/
|
|
431
|
+
get(): [ /* returnType */ number, /* length */ number ]
|
|
432
|
+
/**
|
|
433
|
+
* Retrieves the filename set with unique_message_data_set_filename().
|
|
434
|
+
*
|
|
435
|
+
* filename. Use g_free() to free the resources used by the returned
|
|
436
|
+
* value.
|
|
437
|
+
* @returns a newly allocated string containing the
|
|
438
|
+
*/
|
|
439
|
+
get_filename(): string | null
|
|
440
|
+
/**
|
|
441
|
+
* Returns a pointer to the screen from where the message came. You
|
|
442
|
+
* can use gtk_window_set_screen() to move windows or dialogs to the
|
|
443
|
+
* right screen. This field is always set by the Unique library.
|
|
444
|
+
* @returns a #GdkScreen
|
|
445
|
+
*/
|
|
446
|
+
get_screen(): Gdk.Screen
|
|
447
|
+
/**
|
|
448
|
+
* Retrieves the startup notification id set inside `message_data`. This
|
|
449
|
+
* field is always set by the Unique library.
|
|
450
|
+
*
|
|
451
|
+
* owned by the #UniqueMessageData structure and should not be
|
|
452
|
+
* modified or freed
|
|
453
|
+
* @returns the startup notification id. The returned string is
|
|
454
|
+
*/
|
|
455
|
+
get_startup_id(): string | null
|
|
456
|
+
/**
|
|
457
|
+
* Retrieves the text set using unique_message_data_set_text().
|
|
458
|
+
* @returns a newly-allocated string.
|
|
459
|
+
*/
|
|
460
|
+
get_text(): string | null
|
|
461
|
+
/**
|
|
462
|
+
* Retrieves a %NULL-terminated string vector containing the URIs set with
|
|
463
|
+
* unique_message_data_set_uris().
|
|
464
|
+
*
|
|
465
|
+
* %NULL-terminated list of URIs. Use g_strfreev() to free it.
|
|
466
|
+
* @returns a newly-allocated,
|
|
467
|
+
*/
|
|
468
|
+
get_uris(): string[]
|
|
469
|
+
/**
|
|
470
|
+
* Retrieves the workspace number from where the message came. This
|
|
471
|
+
* field is always set by the Unique library.
|
|
472
|
+
* @returns the workspace number
|
|
473
|
+
*/
|
|
474
|
+
get_workspace(): number
|
|
475
|
+
/**
|
|
476
|
+
* Sets `data` as the payload of `message_data`. Any other data is removed
|
|
477
|
+
* from the message data. If `data` is %NULL, a `length` of -1 will unset
|
|
478
|
+
* the payload, while a `length` of 0 will set the payload to an empty
|
|
479
|
+
* string.
|
|
480
|
+
*
|
|
481
|
+
* You can use unique_message_data_get() to retrieve the data.
|
|
482
|
+
* @param data binary blob to set, or %NULL
|
|
483
|
+
* @param length length of `data`
|
|
484
|
+
*/
|
|
485
|
+
set(data: number | null, length: number): void
|
|
486
|
+
/**
|
|
487
|
+
* Sets `filename` as the contents of `message_data`.
|
|
488
|
+
* @param filename a filename
|
|
489
|
+
*/
|
|
490
|
+
set_filename(filename: string | null): void
|
|
491
|
+
/**
|
|
492
|
+
* Sets `str` as the plain text payload of `message_data,` converting it
|
|
493
|
+
* to UTF-8 if needed. If `length` is -1, the length of the string will
|
|
494
|
+
* be used. Use unique_message_data_get_text() to retrieve the text.
|
|
495
|
+
* @param str plain text to be set as payload
|
|
496
|
+
* @param length length of the text, or -1
|
|
497
|
+
* @returns %TRUE if the text was successfully converted to UTF-8
|
|
498
|
+
*/
|
|
499
|
+
set_text(str: string | null, length: number): boolean
|
|
500
|
+
/**
|
|
501
|
+
* Converts `uris` to a valid URI list and sets it as payload of
|
|
502
|
+
* `message_data`. You can use unique_message_data_get_uris() to
|
|
503
|
+
* retrieve the list from a #UniqueMessageData.
|
|
504
|
+
* @param uris a list of URIs in a %NULL-terminated string vector
|
|
505
|
+
* @returns %TRUE if the URIs were successfully converted
|
|
506
|
+
*/
|
|
507
|
+
set_uris(uris: string[]): boolean
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* #UniqueMessageData contains the data passed between instances of
|
|
512
|
+
* a #UniqueApp. The #UniqueMessageData structure received inside
|
|
513
|
+
* the signal handlers for UniqueApp::message-received is guaranteed
|
|
514
|
+
* to contain the #GdkScreen, the workspace and the startup notification
|
|
515
|
+
* id of the instance sending the message.
|
|
516
|
+
* @record
|
|
517
|
+
*/
|
|
518
|
+
export class MessageData {
|
|
519
|
+
|
|
520
|
+
// Own properties of Unique-3.0.Unique.MessageData
|
|
521
|
+
|
|
522
|
+
static name: string
|
|
523
|
+
|
|
524
|
+
// Constructors of Unique-3.0.Unique.MessageData
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Creates a new #UniqueMessageData structure. This structure holds the
|
|
528
|
+
* message data passed between running instances with
|
|
529
|
+
* unique_app_send_message().
|
|
530
|
+
* @constructor
|
|
531
|
+
* @returns the newly created #UniqueMessageData
|
|
532
|
+
*/
|
|
533
|
+
constructor()
|
|
534
|
+
/**
|
|
535
|
+
* Creates a new #UniqueMessageData structure. This structure holds the
|
|
536
|
+
* message data passed between running instances with
|
|
537
|
+
* unique_app_send_message().
|
|
538
|
+
* @constructor
|
|
539
|
+
* @returns the newly created #UniqueMessageData
|
|
540
|
+
*/
|
|
541
|
+
static new(): MessageData
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Name of the imported GIR library
|
|
546
|
+
* @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188
|
|
547
|
+
*/
|
|
548
|
+
export const __name__: string
|
|
549
|
+
/**
|
|
550
|
+
* Version of the imported GIR library
|
|
551
|
+
* @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189
|
|
552
|
+
*/
|
|
553
|
+
export const __version__: string
|
|
554
|
+
// END
|
package/unique-3.0.d.ts
ADDED
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* Type Definitions for Gjs (https://gjs.guide/)
|
|
4
|
+
*
|
|
5
|
+
* These type definitions are automatically generated, do not edit them by hand.
|
|
6
|
+
* If you found a bug fix it in `ts-for-gir` or create a bug report on https://github.com/gjsify/ts-for-gjs
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Unique-3.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type xlib from '@girs/xlib-2.0';
|
|
13
|
+
import type cairo from '@girs/cairo-1.0';
|
|
14
|
+
import type Pango from '@girs/pango-1.0';
|
|
15
|
+
import type HarfBuzz from '@girs/harfbuzz-0.0';
|
|
16
|
+
import type freetype2 from '@girs/freetype2-2.0';
|
|
17
|
+
import type GObject from '@girs/gobject-2.0';
|
|
18
|
+
import type GLib from '@girs/glib-2.0';
|
|
19
|
+
import type Gio from '@girs/gio-2.0';
|
|
20
|
+
import type Gtk from '@girs/gtk-3.0';
|
|
21
|
+
import type Gdk from '@girs/gdk-3.0';
|
|
22
|
+
import type GdkPixbuf from '@girs/gdkpixbuf-2.0';
|
|
23
|
+
import type GModule from '@girs/gmodule-2.0';
|
|
24
|
+
import type Atk from '@girs/atk-1.0';
|
|
25
|
+
|
|
26
|
+
export namespace Unique {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Command to send to a currently active instance. User defined commands
|
|
30
|
+
* should be positive integers, and should be added using the
|
|
31
|
+
* unique_app_add_command() function after creating a #UniqueApp instance
|
|
32
|
+
*/
|
|
33
|
+
enum Command {
|
|
34
|
+
INVALID,
|
|
35
|
+
ACTIVATE,
|
|
36
|
+
NEW,
|
|
37
|
+
OPEN,
|
|
38
|
+
CLOSE,
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Response that a currently active instance of the application should
|
|
42
|
+
* return to the caller which sent a command.
|
|
43
|
+
*/
|
|
44
|
+
enum Response {
|
|
45
|
+
INVALID,
|
|
46
|
+
OK,
|
|
47
|
+
CANCEL,
|
|
48
|
+
FAIL,
|
|
49
|
+
PASSTHROUGH,
|
|
50
|
+
}
|
|
51
|
+
module App {
|
|
52
|
+
|
|
53
|
+
// Signal callback interfaces
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Signal callback interface for `message-received`
|
|
57
|
+
*/
|
|
58
|
+
interface MessageReceivedSignalCallback {
|
|
59
|
+
($obj: App, command: number, message_data: MessageData, time_: number): Response
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
// Constructor properties interface
|
|
64
|
+
|
|
65
|
+
interface ConstructorProperties extends GObject.Object.ConstructorProperties {
|
|
66
|
+
|
|
67
|
+
// Own constructor properties of Unique-3.0.Unique.App
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The unique name of the application. It must be in form of
|
|
71
|
+
* a domain-like string, like <literal>org.gnome.MyApplication</literal>.
|
|
72
|
+
*/
|
|
73
|
+
name?: string | null
|
|
74
|
+
/**
|
|
75
|
+
* The #GdkScreen of the application.
|
|
76
|
+
*/
|
|
77
|
+
screen?: Gdk.Screen | null
|
|
78
|
+
/**
|
|
79
|
+
* The startup notification id, needed to complete the startup
|
|
80
|
+
* notification sequence. If not set, a default id will be
|
|
81
|
+
* automatically given.
|
|
82
|
+
*/
|
|
83
|
+
startup_id?: string | null
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface App {
|
|
89
|
+
|
|
90
|
+
// Own properties of Unique-3.0.Unique.App
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Whether another instance of the application is running.
|
|
94
|
+
*/
|
|
95
|
+
readonly is_running: boolean
|
|
96
|
+
/**
|
|
97
|
+
* The unique name of the application. It must be in form of
|
|
98
|
+
* a domain-like string, like <literal>org.gnome.MyApplication</literal>.
|
|
99
|
+
*/
|
|
100
|
+
readonly name: string
|
|
101
|
+
/**
|
|
102
|
+
* The #GdkScreen of the application.
|
|
103
|
+
*/
|
|
104
|
+
screen: Gdk.Screen
|
|
105
|
+
/**
|
|
106
|
+
* The startup notification id, needed to complete the startup
|
|
107
|
+
* notification sequence. If not set, a default id will be
|
|
108
|
+
* automatically given.
|
|
109
|
+
*/
|
|
110
|
+
readonly startup_id: string
|
|
111
|
+
|
|
112
|
+
// Owm methods of Unique-3.0.Unique.App
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Adds `command_name` as a custom command that can be used by `app`. You
|
|
116
|
+
* must call unique_app_add_command() before unique_app_send_message() in
|
|
117
|
+
* order to use the newly added command.
|
|
118
|
+
*
|
|
119
|
+
* The command name is used internally: you need to use the command's logical
|
|
120
|
+
* id in unique_app_send_message() and inside the UniqueApp::message-received
|
|
121
|
+
* signal.
|
|
122
|
+
* @param command_name command name
|
|
123
|
+
* @param command_id command logical id
|
|
124
|
+
*/
|
|
125
|
+
add_command(command_name: string | null, command_id: number): void
|
|
126
|
+
/**
|
|
127
|
+
* Sends `command` to a running instance of `app`. If you need to pass data
|
|
128
|
+
* to the instance, you should create a #UniqueMessageData object using
|
|
129
|
+
* unique_message_data_new() and then fill it with the data you intend to
|
|
130
|
+
* pass.
|
|
131
|
+
*
|
|
132
|
+
* The running application will receive a UniqueApp::message-received signal
|
|
133
|
+
* and will call the various signal handlers attach to it. If any handler
|
|
134
|
+
* returns a #UniqueResponse different than %UNIQUE_RESPONSE_OK, the emission
|
|
135
|
+
* will stop.
|
|
136
|
+
* @param command_id command to send
|
|
137
|
+
* @param message_data #UniqueMessageData, or %NULL
|
|
138
|
+
* @returns The #UniqueResponse returned by the running instance
|
|
139
|
+
*/
|
|
140
|
+
send_message(command_id: number, message_data?: MessageData | null): Response
|
|
141
|
+
/**
|
|
142
|
+
* Makes `app` "watch" a window. Every watched window will receive
|
|
143
|
+
* startup notification changes automatically.
|
|
144
|
+
* @param window the #GtkWindow to watch
|
|
145
|
+
*/
|
|
146
|
+
watch_window(window: Gtk.Window): void
|
|
147
|
+
|
|
148
|
+
// Own virtual methods of Unique-3.0.Unique.App
|
|
149
|
+
|
|
150
|
+
vfunc_message_received(command: number, message_data: MessageData, time_: number): Response
|
|
151
|
+
|
|
152
|
+
// Own signals of Unique-3.0.Unique.App
|
|
153
|
+
|
|
154
|
+
connect(sigName: "message-received", callback: App.MessageReceivedSignalCallback): number
|
|
155
|
+
connect_after(sigName: "message-received", callback: App.MessageReceivedSignalCallback): number
|
|
156
|
+
emit(sigName: "message-received", command: number, message_data: MessageData, time_: number, ...args: any[]): void
|
|
157
|
+
|
|
158
|
+
// Class property signals of Unique-3.0.Unique.App
|
|
159
|
+
|
|
160
|
+
connect(sigName: "notify::is-running", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
161
|
+
connect_after(sigName: "notify::is-running", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
162
|
+
emit(sigName: "notify::is-running", ...args: any[]): void
|
|
163
|
+
connect(sigName: "notify::name", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
164
|
+
connect_after(sigName: "notify::name", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
165
|
+
emit(sigName: "notify::name", ...args: any[]): void
|
|
166
|
+
connect(sigName: "notify::screen", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
167
|
+
connect_after(sigName: "notify::screen", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
168
|
+
emit(sigName: "notify::screen", ...args: any[]): void
|
|
169
|
+
connect(sigName: "notify::startup-id", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
170
|
+
connect_after(sigName: "notify::startup-id", callback: (($obj: App, pspec: GObject.ParamSpec) => void)): number
|
|
171
|
+
emit(sigName: "notify::startup-id", ...args: any[]): void
|
|
172
|
+
connect(sigName: string, callback: (...args: any[]) => void): number
|
|
173
|
+
connect_after(sigName: string, callback: (...args: any[]) => void): number
|
|
174
|
+
emit(sigName: string, ...args: any[]): void
|
|
175
|
+
disconnect(id: number): void
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The base class for every single instance application. The #UniqueApp
|
|
180
|
+
* structure contains only private data and should be manipulated only
|
|
181
|
+
* with the provided functions.
|
|
182
|
+
* @class
|
|
183
|
+
*/
|
|
184
|
+
class App extends GObject.Object {
|
|
185
|
+
|
|
186
|
+
// Own properties of Unique-3.0.Unique.App
|
|
187
|
+
|
|
188
|
+
static name: string
|
|
189
|
+
static $gtype: GObject.GType<App>
|
|
190
|
+
|
|
191
|
+
// Constructors of Unique-3.0.Unique.App
|
|
192
|
+
|
|
193
|
+
constructor(config?: App.ConstructorProperties)
|
|
194
|
+
/**
|
|
195
|
+
* Creates a new #UniqueApp instance for `name` passing a start-up notification
|
|
196
|
+
* id `startup_id`. The name must be a unique identifier for the application,
|
|
197
|
+
* and it must be in form of a domain name, like
|
|
198
|
+
* <literal>org.gnome.YourApplication</literal>.
|
|
199
|
+
*
|
|
200
|
+
* If `startup_id` is %NULL the <literal>DESKTOP_STARTUP_ID</literal>
|
|
201
|
+
* environment variable will be check, and if that fails a "fake" startup
|
|
202
|
+
* notification id will be created.
|
|
203
|
+
*
|
|
204
|
+
* Once you have created a #UniqueApp instance, you should check if
|
|
205
|
+
* any other instance is running, using unique_app_is_running().
|
|
206
|
+
* If another instance is running you can send a command to it, using
|
|
207
|
+
* the unique_app_send_message() function; after that, the second instance
|
|
208
|
+
* should quit. If no other instance is running, the usual logic for
|
|
209
|
+
* creating the application can follow.
|
|
210
|
+
* @constructor
|
|
211
|
+
* @param name the name of the application's instance
|
|
212
|
+
* @param startup_id the startup notification id, or %NULL
|
|
213
|
+
* @returns the newly created #UniqueApp instance.
|
|
214
|
+
*/
|
|
215
|
+
constructor(name: string | null, startup_id?: string | null)
|
|
216
|
+
/**
|
|
217
|
+
* Creates a new #UniqueApp instance for `name` passing a start-up notification
|
|
218
|
+
* id `startup_id`. The name must be a unique identifier for the application,
|
|
219
|
+
* and it must be in form of a domain name, like
|
|
220
|
+
* <literal>org.gnome.YourApplication</literal>.
|
|
221
|
+
*
|
|
222
|
+
* If `startup_id` is %NULL the <literal>DESKTOP_STARTUP_ID</literal>
|
|
223
|
+
* environment variable will be check, and if that fails a "fake" startup
|
|
224
|
+
* notification id will be created.
|
|
225
|
+
*
|
|
226
|
+
* Once you have created a #UniqueApp instance, you should check if
|
|
227
|
+
* any other instance is running, using unique_app_is_running().
|
|
228
|
+
* If another instance is running you can send a command to it, using
|
|
229
|
+
* the unique_app_send_message() function; after that, the second instance
|
|
230
|
+
* should quit. If no other instance is running, the usual logic for
|
|
231
|
+
* creating the application can follow.
|
|
232
|
+
* @constructor
|
|
233
|
+
* @param name the name of the application's instance
|
|
234
|
+
* @param startup_id the startup notification id, or %NULL
|
|
235
|
+
* @returns the newly created #UniqueApp instance.
|
|
236
|
+
*/
|
|
237
|
+
static new(name: string | null, startup_id?: string | null): App
|
|
238
|
+
_init(config?: App.ConstructorProperties): void
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
module Backend {
|
|
242
|
+
|
|
243
|
+
// Constructor properties interface
|
|
244
|
+
|
|
245
|
+
interface ConstructorProperties extends GObject.Object.ConstructorProperties {
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
interface Backend {
|
|
251
|
+
|
|
252
|
+
// Own fields of Unique-3.0.Unique.Backend
|
|
253
|
+
|
|
254
|
+
parent_instance: GObject.Object
|
|
255
|
+
|
|
256
|
+
// Owm methods of Unique-3.0.Unique.Backend
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* FIXME
|
|
260
|
+
* @returns FIXME
|
|
261
|
+
*/
|
|
262
|
+
get_name(): string | null
|
|
263
|
+
/**
|
|
264
|
+
* FIXME
|
|
265
|
+
* @returns FIXME
|
|
266
|
+
*/
|
|
267
|
+
get_screen(): Gdk.Screen
|
|
268
|
+
/**
|
|
269
|
+
* FIXME
|
|
270
|
+
* @returns FIXME
|
|
271
|
+
*/
|
|
272
|
+
get_startup_id(): string | null
|
|
273
|
+
/**
|
|
274
|
+
* Retrieves the current workspace.
|
|
275
|
+
* @returns a workspace number
|
|
276
|
+
*/
|
|
277
|
+
get_workspace(): number
|
|
278
|
+
/**
|
|
279
|
+
* Requests the name set using unique_backend_set_name() using `backend`.
|
|
280
|
+
*
|
|
281
|
+
* already is a registered name
|
|
282
|
+
* @returns %TRUE if the name was assigned to us, %FALSE if there
|
|
283
|
+
*/
|
|
284
|
+
request_name(): boolean
|
|
285
|
+
/**
|
|
286
|
+
* Sends `command_id,` and optionally `message_data,` to a running instance
|
|
287
|
+
* using `backend`.
|
|
288
|
+
* @param command_id command to send
|
|
289
|
+
* @param message_data message to send, or %NULL
|
|
290
|
+
* @param time_ time of the command emission, or 0 for the current time
|
|
291
|
+
* @returns a #UniqueResponse value sent by the running instance
|
|
292
|
+
*/
|
|
293
|
+
send_message(command_id: number, message_data: MessageData, time_: number): Response
|
|
294
|
+
/**
|
|
295
|
+
* FIXME
|
|
296
|
+
* @param name FIXME
|
|
297
|
+
*/
|
|
298
|
+
set_name(name: string | null): void
|
|
299
|
+
/**
|
|
300
|
+
* FIXME
|
|
301
|
+
* @param screen FIXME
|
|
302
|
+
*/
|
|
303
|
+
set_screen(screen: Gdk.Screen): void
|
|
304
|
+
/**
|
|
305
|
+
* FIXME
|
|
306
|
+
* @param startup_id FIXME
|
|
307
|
+
*/
|
|
308
|
+
set_startup_id(startup_id: string | null): void
|
|
309
|
+
|
|
310
|
+
// Own virtual methods of Unique-3.0.Unique.Backend
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Requests the name set using unique_backend_set_name() using `backend`.
|
|
314
|
+
*
|
|
315
|
+
* already is a registered name
|
|
316
|
+
* @virtual
|
|
317
|
+
* @returns %TRUE if the name was assigned to us, %FALSE if there
|
|
318
|
+
*/
|
|
319
|
+
vfunc_request_name(): boolean
|
|
320
|
+
/**
|
|
321
|
+
* Sends `command_id,` and optionally `message_data,` to a running instance
|
|
322
|
+
* using `backend`.
|
|
323
|
+
* @virtual
|
|
324
|
+
* @param command_id command to send
|
|
325
|
+
* @param message_data message to send, or %NULL
|
|
326
|
+
* @param time_ time of the command emission, or 0 for the current time
|
|
327
|
+
* @returns a #UniqueResponse value sent by the running instance
|
|
328
|
+
*/
|
|
329
|
+
vfunc_send_message(command_id: number, message_data: MessageData, time_: number): Response
|
|
330
|
+
|
|
331
|
+
// Class property signals of Unique-3.0.Unique.Backend
|
|
332
|
+
|
|
333
|
+
connect(sigName: string, callback: (...args: any[]) => void): number
|
|
334
|
+
connect_after(sigName: string, callback: (...args: any[]) => void): number
|
|
335
|
+
emit(sigName: string, ...args: any[]): void
|
|
336
|
+
disconnect(id: number): void
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* The #UniqueBackend structure contains only private data and should only
|
|
341
|
+
* be accessed using the provided functions.
|
|
342
|
+
* @class
|
|
343
|
+
*/
|
|
344
|
+
class Backend extends GObject.Object {
|
|
345
|
+
|
|
346
|
+
// Own properties of Unique-3.0.Unique.Backend
|
|
347
|
+
|
|
348
|
+
static name: string
|
|
349
|
+
static $gtype: GObject.GType<Backend>
|
|
350
|
+
|
|
351
|
+
// Constructors of Unique-3.0.Unique.Backend
|
|
352
|
+
|
|
353
|
+
constructor(config?: Backend.ConstructorProperties)
|
|
354
|
+
_init(config?: Backend.ConstructorProperties): void
|
|
355
|
+
/**
|
|
356
|
+
* Creates a #UniqueBackend using the default backend defined at
|
|
357
|
+
* compile time. You can override the default backend by setting the
|
|
358
|
+
* <literal>UNIQUE_BACKEND</literal> environment variable with the
|
|
359
|
+
* name of the desired backend.
|
|
360
|
+
* @returns the newly created #UniqueBackend instance
|
|
361
|
+
*/
|
|
362
|
+
static create(): Backend
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
interface AppClass {
|
|
366
|
+
|
|
367
|
+
// Own fields of Unique-3.0.Unique.AppClass
|
|
368
|
+
|
|
369
|
+
message_received: (app: App, command: number, message_data: MessageData, time_: number) => Response
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Base class for every single instance application.
|
|
374
|
+
* @record
|
|
375
|
+
*/
|
|
376
|
+
abstract class AppClass {
|
|
377
|
+
|
|
378
|
+
// Own properties of Unique-3.0.Unique.AppClass
|
|
379
|
+
|
|
380
|
+
static name: string
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
interface AppPrivate {
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
class AppPrivate {
|
|
387
|
+
|
|
388
|
+
// Own properties of Unique-3.0.Unique.AppPrivate
|
|
389
|
+
|
|
390
|
+
static name: string
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
interface BackendClass {
|
|
394
|
+
|
|
395
|
+
// Own fields of Unique-3.0.Unique.BackendClass
|
|
396
|
+
|
|
397
|
+
request_name: (backend: Backend) => boolean
|
|
398
|
+
send_message: (backend: Backend, command_id: number, message_data: MessageData, time_: number) => Response
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* The class that should be implemented by every backend for #UniqueApp.
|
|
403
|
+
* @record
|
|
404
|
+
*/
|
|
405
|
+
abstract class BackendClass {
|
|
406
|
+
|
|
407
|
+
// Own properties of Unique-3.0.Unique.BackendClass
|
|
408
|
+
|
|
409
|
+
static name: string
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
interface MessageData {
|
|
413
|
+
|
|
414
|
+
// Owm methods of Unique-3.0.Unique.MessageData
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Copies `message_data`.
|
|
418
|
+
* @returns a copy of the passed #UniqueMessageData
|
|
419
|
+
*/
|
|
420
|
+
copy(): MessageData
|
|
421
|
+
/**
|
|
422
|
+
* Frees all the resources allocated by `message_data`.
|
|
423
|
+
*/
|
|
424
|
+
free(): void
|
|
425
|
+
/**
|
|
426
|
+
* Retrieves the raw contents of `message_data` set using
|
|
427
|
+
* unique_messaget_data_set().
|
|
428
|
+
*
|
|
429
|
+
* returned string is owned by the #UniqueMessageData and should
|
|
430
|
+
* never be modified or freed
|
|
431
|
+
* @returns the contents of the message data or %NULL. The
|
|
432
|
+
*/
|
|
433
|
+
get(): [ /* returnType */ number, /* length */ number ]
|
|
434
|
+
/**
|
|
435
|
+
* Retrieves the filename set with unique_message_data_set_filename().
|
|
436
|
+
*
|
|
437
|
+
* filename. Use g_free() to free the resources used by the returned
|
|
438
|
+
* value.
|
|
439
|
+
* @returns a newly allocated string containing the
|
|
440
|
+
*/
|
|
441
|
+
get_filename(): string | null
|
|
442
|
+
/**
|
|
443
|
+
* Returns a pointer to the screen from where the message came. You
|
|
444
|
+
* can use gtk_window_set_screen() to move windows or dialogs to the
|
|
445
|
+
* right screen. This field is always set by the Unique library.
|
|
446
|
+
* @returns a #GdkScreen
|
|
447
|
+
*/
|
|
448
|
+
get_screen(): Gdk.Screen
|
|
449
|
+
/**
|
|
450
|
+
* Retrieves the startup notification id set inside `message_data`. This
|
|
451
|
+
* field is always set by the Unique library.
|
|
452
|
+
*
|
|
453
|
+
* owned by the #UniqueMessageData structure and should not be
|
|
454
|
+
* modified or freed
|
|
455
|
+
* @returns the startup notification id. The returned string is
|
|
456
|
+
*/
|
|
457
|
+
get_startup_id(): string | null
|
|
458
|
+
/**
|
|
459
|
+
* Retrieves the text set using unique_message_data_set_text().
|
|
460
|
+
* @returns a newly-allocated string.
|
|
461
|
+
*/
|
|
462
|
+
get_text(): string | null
|
|
463
|
+
/**
|
|
464
|
+
* Retrieves a %NULL-terminated string vector containing the URIs set with
|
|
465
|
+
* unique_message_data_set_uris().
|
|
466
|
+
*
|
|
467
|
+
* %NULL-terminated list of URIs. Use g_strfreev() to free it.
|
|
468
|
+
* @returns a newly-allocated,
|
|
469
|
+
*/
|
|
470
|
+
get_uris(): string[]
|
|
471
|
+
/**
|
|
472
|
+
* Retrieves the workspace number from where the message came. This
|
|
473
|
+
* field is always set by the Unique library.
|
|
474
|
+
* @returns the workspace number
|
|
475
|
+
*/
|
|
476
|
+
get_workspace(): number
|
|
477
|
+
/**
|
|
478
|
+
* Sets `data` as the payload of `message_data`. Any other data is removed
|
|
479
|
+
* from the message data. If `data` is %NULL, a `length` of -1 will unset
|
|
480
|
+
* the payload, while a `length` of 0 will set the payload to an empty
|
|
481
|
+
* string.
|
|
482
|
+
*
|
|
483
|
+
* You can use unique_message_data_get() to retrieve the data.
|
|
484
|
+
* @param data binary blob to set, or %NULL
|
|
485
|
+
* @param length length of `data`
|
|
486
|
+
*/
|
|
487
|
+
set(data: number | null, length: number): void
|
|
488
|
+
/**
|
|
489
|
+
* Sets `filename` as the contents of `message_data`.
|
|
490
|
+
* @param filename a filename
|
|
491
|
+
*/
|
|
492
|
+
set_filename(filename: string | null): void
|
|
493
|
+
/**
|
|
494
|
+
* Sets `str` as the plain text payload of `message_data,` converting it
|
|
495
|
+
* to UTF-8 if needed. If `length` is -1, the length of the string will
|
|
496
|
+
* be used. Use unique_message_data_get_text() to retrieve the text.
|
|
497
|
+
* @param str plain text to be set as payload
|
|
498
|
+
* @param length length of the text, or -1
|
|
499
|
+
* @returns %TRUE if the text was successfully converted to UTF-8
|
|
500
|
+
*/
|
|
501
|
+
set_text(str: string | null, length: number): boolean
|
|
502
|
+
/**
|
|
503
|
+
* Converts `uris` to a valid URI list and sets it as payload of
|
|
504
|
+
* `message_data`. You can use unique_message_data_get_uris() to
|
|
505
|
+
* retrieve the list from a #UniqueMessageData.
|
|
506
|
+
* @param uris a list of URIs in a %NULL-terminated string vector
|
|
507
|
+
* @returns %TRUE if the URIs were successfully converted
|
|
508
|
+
*/
|
|
509
|
+
set_uris(uris: string[]): boolean
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* #UniqueMessageData contains the data passed between instances of
|
|
514
|
+
* a #UniqueApp. The #UniqueMessageData structure received inside
|
|
515
|
+
* the signal handlers for UniqueApp::message-received is guaranteed
|
|
516
|
+
* to contain the #GdkScreen, the workspace and the startup notification
|
|
517
|
+
* id of the instance sending the message.
|
|
518
|
+
* @record
|
|
519
|
+
*/
|
|
520
|
+
class MessageData {
|
|
521
|
+
|
|
522
|
+
// Own properties of Unique-3.0.Unique.MessageData
|
|
523
|
+
|
|
524
|
+
static name: string
|
|
525
|
+
|
|
526
|
+
// Constructors of Unique-3.0.Unique.MessageData
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Creates a new #UniqueMessageData structure. This structure holds the
|
|
530
|
+
* message data passed between running instances with
|
|
531
|
+
* unique_app_send_message().
|
|
532
|
+
* @constructor
|
|
533
|
+
* @returns the newly created #UniqueMessageData
|
|
534
|
+
*/
|
|
535
|
+
constructor()
|
|
536
|
+
/**
|
|
537
|
+
* Creates a new #UniqueMessageData structure. This structure holds the
|
|
538
|
+
* message data passed between running instances with
|
|
539
|
+
* unique_app_send_message().
|
|
540
|
+
* @constructor
|
|
541
|
+
* @returns the newly created #UniqueMessageData
|
|
542
|
+
*/
|
|
543
|
+
static new(): MessageData
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Name of the imported GIR library
|
|
548
|
+
* @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188
|
|
549
|
+
*/
|
|
550
|
+
const __name__: string
|
|
551
|
+
/**
|
|
552
|
+
* Version of the imported GIR library
|
|
553
|
+
* @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189
|
|
554
|
+
*/
|
|
555
|
+
const __version__: string
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export default Unique;
|
|
559
|
+
// END
|