1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
|
#include "application.h"
#include "panel.h"
#include "launcher.h"
#include "control-center.h"
#include "notification-area.h"
#include "dbus/server.h"
#include "services/battery-service.h"
#include "services/clock-service.h"
#include "services/brightness-service.h"
#include "services/quick-answer-service.h"
#include "services/workspace-service.h"
#include "services/workspaces/hyprland-workspace-service.h"
#include "services/workspaces/sway-workspace-service.h"
#include "services/notification-service.h"
#include "services/audio-service.h"
#include "services/network-service.h"
#include "services/bluetooth-service.h"
#include "services/application-service.h"
#include "services/configuration-service.h"
//
// FoobarApplication:
//
// Entry point for the application. This class is responsible for parsing and handling command line arguments, creating
// services and presenting windows as needed.
//
// Only the panel windows are application windows -- when all panels are closed, the application quits. Because of this,
// the application can't own a reference to the panel windows but needs to store their window IDs. Since all other
// windows are not attached to the application object, the application can hold a reference on them.
//
struct _FoobarApplication
{
GtkApplication parent_instance;
FoobarBatteryService* battery_service;
FoobarClockService* clock_service;
FoobarBrightnessService* brightness_service;
FoobarWorkspaceService* workspace_service;
FoobarNotificationService* notification_service;
FoobarAudioService* audio_service;
FoobarNetworkService* network_service;
FoobarBluetoothService* bluetooth_service;
FoobarApplicationService* application_service;
FoobarQuickAnswerService* quick_answer_service;
FoobarConfigurationService* configuration_service;
gulong config_handler_id;
FoobarServer* server_skeleton;
GtkCssProvider* style_provider;
guint bus_owner_id;
GArray* panel_window_ids;
gboolean panel_is_multi_monitor;
GListModel* monitors;
gulong monitors_handler_id;
FoobarLauncher* launcher;
FoobarControlCenter* control_center;
FoobarNotificationArea* notification_area;
gboolean option_inspector;
gboolean option_quit;
gboolean option_toggle_launcher;
gboolean option_toggle_control_center;
};
static void foobar_application_class_init ( FoobarApplicationClass* klass );
static void foobar_application_init ( FoobarApplication* self );
static void foobar_application_activate ( GApplication* app );
static int foobar_application_command_line ( GApplication* app,
GApplicationCommandLine* cmdline );
static void foobar_application_finalize ( GObject* object );
static void foobar_application_handle_bus_acquired ( GDBusConnection* connection,
gchar const* name,
gpointer userdata );
static gboolean foobar_application_handle_inspector ( FoobarServer* server,
GDBusMethodInvocation* invocation,
gpointer userdata );
static gboolean foobar_application_handle_quit ( FoobarServer* server,
GDBusMethodInvocation* invocation,
gpointer userdata );
static gboolean foobar_application_handle_toggle_launcher ( FoobarServer* server,
GDBusMethodInvocation* invocation,
gpointer userdata );
static gboolean foobar_application_handle_toggle_control_center( FoobarServer* server,
GDBusMethodInvocation* invocation,
gpointer userdata );
static void foobar_application_handle_config_changed ( GObject* object,
GParamSpec* pspec,
gpointer userdata );
static void foobar_application_handle_monitors_changed ( GListModel* list,
guint position,
guint removed,
guint added,
gpointer userdata );
static void foobar_application_destroy_panels ( FoobarApplication* self );
static void foobar_application_create_panels ( FoobarApplication* self );
static guint foobar_application_create_panel ( FoobarApplication* self,
GdkMonitor* monitor );
static void foobar_application_initialize_workspaces ( FoobarApplication* self );
G_DEFINE_FINAL_TYPE( FoobarApplication, foobar_application, GTK_TYPE_APPLICATION )
// ---------------------------------------------------------------------------------------------------------------------
// Application Implementation
// ---------------------------------------------------------------------------------------------------------------------
//
// Static initialization for the application.
//
void foobar_application_class_init( FoobarApplicationClass* klass )
{
GApplicationClass* app_klass = G_APPLICATION_CLASS( klass );
app_klass->activate = foobar_application_activate;
app_klass->command_line = foobar_application_command_line;
GObjectClass* object_klass = G_OBJECT_CLASS( klass );
object_klass->finalize = foobar_application_finalize;
}
//
// Instance initialization for the application.
//
void foobar_application_init( FoobarApplication* self )
{
g_application_set_default( G_APPLICATION( self ) );
g_application_set_option_context_summary( G_APPLICATION( self ), "A bar." );
GOptionEntry const options[] =
{
{
.long_name = "inspector",
.short_name = 'i',
.flags = G_OPTION_FLAG_NONE,
.arg = G_OPTION_ARG_NONE,
.arg_data = &self->option_inspector,
.description = "Open the GTK inspector for the active bar instance.",
.arg_description = NULL,
},
{
.long_name = "quit",
.short_name = 'q',
.flags = G_OPTION_FLAG_NONE,
.arg = G_OPTION_ARG_NONE,
.arg_data = &self->option_quit,
.description = "Quit the active bar instance.",
.arg_description = NULL,
},
{
.long_name = "toggle-launcher",
.short_name = 'l',
.flags = G_OPTION_FLAG_NONE,
.arg = G_OPTION_ARG_NONE,
.arg_data = &self->option_toggle_launcher,
.description = "Toggle the launcher visibility for the active bar instance.",
.arg_description = NULL,
},
{
.long_name = "toggle-control-center",
.short_name = 'c',
.flags = G_OPTION_FLAG_NONE,
.arg = G_OPTION_ARG_NONE,
.arg_data = &self->option_toggle_control_center,
.description = "Toggle the control center visibility for the active bar instance.",
.arg_description = NULL,
},
{ 0 },
};
g_application_add_main_option_entries( G_APPLICATION( self ), options );
}
//
// Called by GTK when the application is activated (only for a single instance of the application).
//
// This is where the services are created and the windows are presented.
//
void foobar_application_activate( GApplication* app )
{
FoobarApplication* self = (FoobarApplication*)app;
// Initialize services.
self->battery_service = foobar_battery_service_new( );
self->clock_service = foobar_clock_service_new( );
self->brightness_service = foobar_brightness_service_new( );
foobar_application_initialize_workspaces( self );
self->notification_service = foobar_notification_service_new( );
self->audio_service = foobar_audio_service_new( );
self->network_service = foobar_network_service_new( );
self->bluetooth_service = foobar_bluetooth_service_new( );
self->application_service = foobar_application_service_new( );
self->quick_answer_service = foobar_quick_answer_service_new( );
self->configuration_service = foobar_configuration_service_new( );
// Enforce a uniform style by forcing Adwaita and shipping our own icons.
GtkSettings* settings = gtk_settings_get_default( );
g_object_set( settings, "gtk-theme-name", "Adwaita", NULL );
GtkIconTheme* icon_theme = gtk_icon_theme_get_for_display( gdk_display_get_default( ) );
gtk_icon_theme_add_resource_path( icon_theme, "/foobar/icons" );
// This application instance now becomes the "server" process, listening for commands from clients (which can be
// invoked via the command line).
self->bus_owner_id = g_bus_own_name(
G_BUS_TYPE_SESSION,
g_application_get_application_id( G_APPLICATION( self ) ),
G_BUS_NAME_OWNER_FLAGS_NONE,
foobar_application_handle_bus_acquired,
NULL,
NULL,
self,
NULL );
// React to configuration file changes.
FoobarConfiguration const* config = foobar_configuration_service_get_current( self->configuration_service );
foobar_application_apply_configuration( self, foobar_configuration_get_general( config ) );
self->panel_is_multi_monitor = foobar_panel_configuration_get_multi_monitor( foobar_configuration_get_panel( config ) );
self->config_handler_id = g_signal_connect(
self->configuration_service,
"notify::current",
G_CALLBACK( foobar_application_handle_config_changed ),
self );
// React to monitor configuration changes (for multi-monitor support in the panel).
self->monitors = gdk_display_get_monitors( gdk_display_get_default( ) );
g_object_ref( self->monitors );
self->monitors_handler_id = g_signal_connect(
self->monitors,
"items-changed",
G_CALLBACK( foobar_application_handle_monitors_changed ),
self );
// Create all the windows.
foobar_application_create_panels( self );
self->launcher = foobar_launcher_new(
self->application_service,
self->quick_answer_service,
self->configuration_service );
g_object_ref( self->launcher );
self->control_center = foobar_control_center_new(
self->brightness_service,
self->audio_service,
self->network_service,
self->bluetooth_service,
self->notification_service,
self->configuration_service );
g_object_ref( self->control_center );
self->notification_area = foobar_notification_area_new(
self->notification_service,
self->configuration_service );
g_object_ref( self->notification_area );
// Only present the notification area, all other windows start out as hidden windows.
gtk_window_present( GTK_WINDOW( self->notification_area ) );
}
//
// Called before activating the application, when GTK has parsed the command line arguments.
//
// This method decides whether the application should be activated (if it is the first instance). Otherwise it will
// handle command line flags for controlling the application.
//
int foobar_application_command_line(
GApplication* app,
GApplicationCommandLine* cmdline )
{
(void)cmdline;
FoobarApplication* self = (FoobarApplication*)app;
// Try to open a connection to the existing server.
g_autoptr( GError ) error = NULL;
g_autoptr( FoobarServer ) proxy = foobar_server_proxy_new_for_bus_sync(
G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
g_application_get_application_id( G_APPLICATION( self ) ),
"/com/github/hannesschulze/foobar/server",
NULL,
&error );
if ( !proxy )
{
g_printerr( "Unable to create proxy: %s\n", error->message );
return 1;
}
// If there is no existing server application, the "name owner" will not be set.
g_autofree gchar* owner = g_dbus_proxy_get_name_owner( G_DBUS_PROXY( proxy ) );
if ( owner )
{
// There is an active instance -> this is a client. Handle all command line flags.
if ( self->option_inspector && !foobar_server_call_inspector_sync( proxy, NULL, &error ) )
{
g_printerr( "Unable to open inspector: %s\n", error->message );
return 2;
}
if ( self->option_toggle_launcher && !foobar_server_call_toggle_launcher_sync( proxy, NULL, &error ) )
{
g_printerr( "Unable to toggle launcher: %s\n", error->message );
return 2;
}
if ( self->option_toggle_control_center && !foobar_server_call_toggle_control_center_sync( proxy, NULL, &error ) )
{
g_printerr( "Unable to toggle control center: %s\n", error->message );
return 2;
}
if ( self->option_quit && !foobar_server_call_quit_sync( proxy, NULL, &error ) )
{
g_printerr( "Unable to quit server: %s\n", error->message );
return 2;
}
}
else if ( !self->option_quit )
{
// This is the main application -> launch the server.
g_application_activate( G_APPLICATION( self ) );
}
return 0;
}
//
// Instance cleanup for the application.
//
void foobar_application_finalize( GObject* object )
{
FoobarApplication* self = (FoobarApplication*)object;
// Destroy the DBus server.
if ( self->server_skeleton )
{
g_dbus_interface_skeleton_unexport( G_DBUS_INTERFACE_SKELETON( self->server_skeleton ) );
}
// Destroy non-application windows.
if ( self->launcher ) { gtk_window_destroy( GTK_WINDOW( self->launcher ) ); }
if ( self->control_center ) { gtk_window_destroy( GTK_WINDOW( self->control_center ) ); }
if ( self->notification_area ) { gtk_window_destroy( GTK_WINDOW( self->notification_area ) ); }
// Destroy all other objects.
g_clear_handle_id( &self->bus_owner_id, g_bus_unown_name );
g_clear_signal_handler( &self->config_handler_id, self->configuration_service );
g_clear_signal_handler( &self->monitors_handler_id, self->monitors );
g_clear_object( &self->battery_service );
g_clear_object( &self->clock_service );
g_clear_object( &self->brightness_service );
g_clear_object( &self->workspace_service );
g_clear_object( &self->notification_service );
g_clear_object( &self->audio_service );
g_clear_object( &self->network_service );
g_clear_object( &self->bluetooth_service );
g_clear_object( &self->application_service );
g_clear_object( &self->quick_answer_service );
g_clear_object( &self->configuration_service );
g_clear_object( &self->style_provider );
g_clear_object( &self->server_skeleton );
g_clear_object( &self->launcher );
g_clear_object( &self->control_center );
g_clear_object( &self->notification_area );
g_clear_object( &self->monitors );
g_clear_pointer( &self->panel_window_ids, g_array_unref );
G_OBJECT_CLASS( foobar_application_parent_class )->finalize( object );
}
// ---------------------------------------------------------------------------------------------------------------------
// Public API
// ---------------------------------------------------------------------------------------------------------------------
//
// Create a new application instance.
//
FoobarApplication* foobar_application_new( void )
{
return g_object_new(
FOOBAR_TYPE_APPLICATION,
"application-id",
"com.github.hannesschulze.foobar",
"flags",
G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_NON_UNIQUE,
NULL );
}
//
// Toggle the launcher window's visibility.
//
void foobar_application_toggle_launcher( FoobarApplication* self )
{
g_return_if_fail( FOOBAR_IS_APPLICATION( self ) );
gboolean previously_visible = gtk_widget_is_visible( GTK_WIDGET( self->launcher ) );
gtk_widget_set_visible( GTK_WIDGET( self->launcher ), !previously_visible );
}
//
// Toggle the control center window's visibility.
//
void foobar_application_toggle_control_center( FoobarApplication* self )
{
g_return_if_fail( FOOBAR_IS_APPLICATION( self ) );
gboolean previously_visible = gtk_widget_is_visible( GTK_WIDGET( self->control_center ) );
gtk_widget_set_visible( GTK_WIDGET( self->control_center ), !previously_visible );
}
//
// Apply the general application configuration provided by the configuration service.
//
void foobar_application_apply_configuration(
FoobarApplication* self,
FoobarGeneralConfiguration const* config )
{
g_return_if_fail( FOOBAR_IS_APPLICATION( self ) );
g_return_if_fail( config != NULL );
GdkDisplay* display = gdk_display_get_default( );
// Remove the old stylesheet from the application.
if ( self->style_provider )
{
gtk_style_context_remove_provider_for_display( display, GTK_STYLE_PROVIDER( self->style_provider ) );
g_clear_object( &self->style_provider );
}
// Add the new stylesheet.
g_autoptr( GFile ) file = g_file_new_for_uri( foobar_general_configuration_get_stylesheet( config ) );
self->style_provider = gtk_css_provider_new( );
gtk_css_provider_load_from_file( self->style_provider, file );
gtk_style_context_add_provider_for_display(
display,
GTK_STYLE_PROVIDER( self->style_provider ),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION );
}
// ---------------------------------------------------------------------------------------------------------------------
// Signal Handlers
// ---------------------------------------------------------------------------------------------------------------------
//
// Called after the application server process has asynchronously acquired the bus.
//
// This is where we can export server functionality using the corresponding DBus skeleton object.
//
void foobar_application_handle_bus_acquired(
GDBusConnection* connection,
gchar const* name,
gpointer userdata )
{
(void)name;
FoobarApplication* self = (FoobarApplication*)userdata;
self->server_skeleton = foobar_server_skeleton_new( );
g_signal_connect(
self->server_skeleton,
"handle-inspector",
G_CALLBACK( foobar_application_handle_inspector ),
self );
g_signal_connect(
self->server_skeleton,
"handle-quit",
G_CALLBACK( foobar_application_handle_quit ),
self );
g_signal_connect(
self->server_skeleton,
"handle-toggle-launcher",
G_CALLBACK( foobar_application_handle_toggle_launcher ),
self );
g_signal_connect(
self->server_skeleton,
"handle-toggle-control-center",
G_CALLBACK( foobar_application_handle_toggle_control_center ),
self );
g_autoptr( GError ) error = NULL;
if ( !g_dbus_interface_skeleton_export(
G_DBUS_INTERFACE_SKELETON( self->server_skeleton ),
connection,
"/com/github/hannesschulze/foobar/server",
&error ) )
{
g_warning( "Unable to export server interface: %s", error->message );
}
}
//
// DBus skeleton callback for the "Inspector" method.
//
gboolean foobar_application_handle_inspector(
FoobarServer* server,
GDBusMethodInvocation* invocation,
gpointer userdata )
{
(void)userdata;
gtk_window_set_interactive_debugging( TRUE );
foobar_server_complete_inspector( server, invocation );
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
//
// DBus skeleton callback for the "Quit" method.
//
gboolean foobar_application_handle_quit(
FoobarServer* server,
GDBusMethodInvocation* invocation,
gpointer userdata )
{
FoobarApplication* self = (FoobarApplication*)userdata;
foobar_application_destroy_panels( self );
foobar_server_complete_quit( server, invocation );
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
//
// DBus skeleton callback for the "ToggleLauncher" method.
//
gboolean foobar_application_handle_toggle_launcher(
FoobarServer* server,
GDBusMethodInvocation* invocation,
gpointer userdata )
{
FoobarApplication* self = (FoobarApplication*)userdata;
foobar_application_toggle_launcher( self );
foobar_server_complete_toggle_launcher( server, invocation );
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
//
// DBus skeleton callback for the "ToggleControlCenter" method.
//
gboolean foobar_application_handle_toggle_control_center(
FoobarServer* server,
GDBusMethodInvocation* invocation,
gpointer userdata )
{
FoobarApplication* self = (FoobarApplication*)userdata;
foobar_application_toggle_control_center( self );
foobar_server_complete_toggle_control_center( server, invocation );
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
//
// Signal handler called when the global configuration file has changed.
//
void foobar_application_handle_config_changed(
GObject* object,
GParamSpec* pspec,
gpointer userdata )
{
(void)object;
(void)pspec;
FoobarApplication* self = (FoobarApplication*)userdata;
// Apply general settings.
FoobarConfiguration const* config = foobar_configuration_service_get_current( self->configuration_service );
foobar_application_apply_configuration( self, foobar_configuration_get_general( config ) );
// Update panel instances depending on whether multi-monitor mode is enabled.
FoobarPanelConfiguration const* panel_config = foobar_configuration_get_panel( config );
gboolean panel_is_multi_monitor = foobar_panel_configuration_get_multi_monitor( panel_config );
if ( self->panel_is_multi_monitor != panel_is_multi_monitor )
{
self->panel_is_multi_monitor = panel_is_multi_monitor;
// Panel windows keep the application alive, so we need to "hold" it while we re-create the panel windows.
g_application_hold( G_APPLICATION( self ) );
foobar_application_destroy_panels( self );
foobar_application_create_panels( self );
g_application_release( G_APPLICATION( self ) );
}
}
//
// Signal handler called when the list of GdkMonitor objects has changed, possibly requiring us to re-create the panel
// windows.
//
void foobar_application_handle_monitors_changed(
GListModel* list,
guint position,
guint removed,
guint added,
gpointer userdata )
{
(void)list;
(void)position;
(void)removed;
(void)added;
FoobarApplication* self = (FoobarApplication*)userdata;
if ( self->panel_is_multi_monitor )
{
// Panel windows keep the application alive, so we need to "hold" it while we re-create the panel windows.
g_application_hold( G_APPLICATION( self ) );
foobar_application_destroy_panels( self );
foobar_application_create_panels( self );
g_application_release( G_APPLICATION( self ) );
}
}
// ---------------------------------------------------------------------------------------------------------------------
// Helper Methods
// ---------------------------------------------------------------------------------------------------------------------
//
// Destroy all currently active panel windows.
//
void foobar_application_destroy_panels( FoobarApplication* self )
{
for ( guint i = 0; i < self->panel_window_ids->len; ++i )
{
guint window_id = g_array_index( self->panel_window_ids, guint, i );
GtkWindow* window = gtk_application_get_window_by_id( GTK_APPLICATION( self ), window_id );
if ( window ) { gtk_window_destroy( window ); }
}
g_clear_pointer( &self->panel_window_ids, g_array_unref );
}
//
// Create and present panel windows for
// - each monitor, if multi-monitor mode is enabled
// - the current monitor, if multi-monitor mode is disabled.
//
void foobar_application_create_panels( FoobarApplication* self )
{
self->panel_window_ids = g_array_new( FALSE, FALSE, sizeof( guint ) );
if ( self->panel_is_multi_monitor )
{
for ( guint i = 0; i < g_list_model_get_n_items( self->monitors ); ++i )
{
GdkMonitor* monitor = g_list_model_get_item( self->monitors, i );
guint id = foobar_application_create_panel( self, monitor );
g_array_append_val( self->panel_window_ids, id );
}
}
else
{
guint id = foobar_application_create_panel( self, NULL );
g_array_append_val( self->panel_window_ids, id );
}
}
//
// Create and present a panel for a single monitor (or NULL to use the current monitor).
//
guint foobar_application_create_panel(
FoobarApplication* self,
GdkMonitor* monitor )
{
FoobarPanel* panel = foobar_panel_new(
GTK_APPLICATION( self ),
monitor,
self->battery_service,
self->clock_service,
self->brightness_service,
self->workspace_service,
self->audio_service,
self->network_service,
self->bluetooth_service,
self->notification_service,
self->configuration_service );
gtk_window_present( GTK_WINDOW( panel ) );
return gtk_application_window_get_id( GTK_APPLICATION_WINDOW( panel ) );
}
//
// Initialize the instance's workspace_service, attempting multiple window manager implementations.
//
void foobar_application_initialize_workspaces( FoobarApplication* self )
{
g_clear_object( &self->workspace_service );
self->workspace_service = foobar_hyprland_workspace_service_new( );
if ( foobar_workspace_service_is_available( self->workspace_service ) ) { return; }
g_clear_object( &self->workspace_service );
self->workspace_service = foobar_sway_workspace_service_new( );
if ( foobar_workspace_service_is_available( self->workspace_service ) ) { return; }
g_warning( "No suitable workspace manager implementation found." );
}
|