Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

sni,dconf: enable and disable tray-icons #63

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions data/org.ldelossa.way-shell.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@
Way-Shell must be restarted for changes to take effect.
</description>
</key>
<key name="enable-tray-icons" type="b">
<default>true</default>
<summary>Whether tray icons and their menus should be displayed</summary>
<description>
Way-Shell can display tray icons for applications which present them.

This is an experimental feature which may cause some issues.
Therefore, if issues are encountered you can disable them with this
flag.

Way-Shell must be restarted for changes to take effect.
</description>
</key>
</schema>

</schemalist>
12 changes: 11 additions & 1 deletion src/panel/panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <gdk/wayland/gdkwayland.h>
#include <gtk4-layer-shell/gtk4-layer-shell.h>

#include "../../src/services/status_notifier_service/status_notifier_service.h"
#include "../activities/activities.h"
#include "./indicator_bar/indicator_bar.h"
#include "./panel_status_bar/panel_status_bar.h"
Expand Down Expand Up @@ -67,7 +68,7 @@ static void panel_dispose(GObject *gobject) {
g_object_unref(self->ws_bar);
g_object_unref(self->monitor);
g_object_unref(self->clock);
g_object_unref(self->indicator_bar);
g_object_unref(self->indicator_bar);

g_free(self->monitor_desc);

Expand Down Expand Up @@ -109,6 +110,15 @@ static void panel_init_status_bar(Panel *self) {
}

static void panel_init_indicator_bar(Panel *self) {
// check if StatusNotifierService is available
StatusNotifierService *s = status_notifier_service_get_global();
if (!s) {
g_debug(
"panel.c:panel_init_indicator_bar() StatusNotifierService not "
"available, skipping.");
return;
}

self->indicator_bar = g_object_new(INDICATOR_BAR_TYPE, NULL);
indicator_bar_set_panel(self->indicator_bar, self);
gtk_box_prepend(self->right, indicator_bar_get_widget(self->indicator_bar));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ GHashTable *status_notifier_service_get_items(StatusNotifierService *self) {
}

int status_notifier_service_global_init() {
GSettings *panel_settings = g_settings_new("org.ldelossa.way-shell.panel");

gboolean enabled =
g_settings_get_boolean(panel_settings, "enable-tray-icons");
if (!enabled) return 0;

global = g_object_new(NOTIFICATIONS_SERVICE_TYPE, NULL);
return 0;
}
Expand Down