dwlb

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 2700650aab3e1825620a834fd7b1f3aeb29c3179
parent 043d5fe8b6b92fd09ef678278cd0e8e6a718fdc1
Author: Janne Veteläinen <janne.vetelainen@elisanet.fi>
Date:   Fri, 19 Apr 2024 00:54:30 +0300

Move snhost to main

Diffstat:
Mdwlbtray.c | 27+++++++++++++++++++--------
Mdwlbtray.h | 3++-
Mstatusnotifierhost.c | 13++-----------
3 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/dwlbtray.c b/dwlbtray.c @@ -81,7 +81,17 @@ terminate_app(StatusNotifierHost *snhost) int main(int argc, char *argv[]) { - StatusNotifierHost *snhost = start_statusnotifierhost(); + + StatusNotifierHost snhost; + snhost.height = 22; + snhost.curwidth = 22; + snhost.margin = 4; + snhost.noitems = 0; + snhost.position = 0; + snhost.cssdata = NULL; + snhost.traymon = NULL; + snhost.trayitems = NULL; + snhost.in_exit = FALSE; char *bgcolor = NULL; char *cssdata; @@ -91,9 +101,9 @@ main(int argc, char *argv[]) for (; i < argc; i++) { char **strings = g_strsplit(argv[i], "=", 0); if (strcmp(strings[0], "--height") == 0) { - snhost->height = atoi(strings[1]); + snhost.height = atoi(strings[1]); } else if (strcmp(strings[0], "--traymon") == 0) { - snhost->traymon = g_strdup(strings[1]); + snhost.traymon = g_strdup(strings[1]); } else if (strcmp(strings[0], "--bg-color") == 0) { bgcolor = strdup(strings[1]); } else if (strcmp(strings[0], "--position") == 0) { @@ -103,24 +113,25 @@ main(int argc, char *argv[]) g_strfreev(strings); } - snhost->position = position; + snhost.position = position; if (bgcolor) cssdata = g_strdup_printf("window.dwlbtray{background-color:%s;}", bgcolor); else cssdata = g_strdup_printf("window.dwlbtray{background-color:%s;}", "#222222"); - snhost->cssdata = cssdata; + snhost.cssdata = cssdata; g_free(bgcolor); GtkApplication *app = gtk_application_new("org.dwlb.dwlbtray", G_APPLICATION_DEFAULT_FLAGS); - g_signal_connect(app, "activate", G_CALLBACK(activate), snhost); + g_signal_connect(app, "activate", G_CALLBACK(activate), &snhost); - g_unix_signal_add(SIGINT, (GSourceFunc)terminate_app, snhost); - g_unix_signal_add(SIGTERM, (GSourceFunc)terminate_app, snhost); + g_unix_signal_add(SIGINT, (GSourceFunc)terminate_app, &snhost); + g_unix_signal_add(SIGTERM, (GSourceFunc)terminate_app, &snhost); + start_statusnotifierhost(&snhost); char *argv_inner[] = { argv[0], NULL }; int status = g_application_run(G_APPLICATION(app), 1, argv_inner); diff --git a/dwlbtray.h b/dwlbtray.h @@ -52,7 +52,8 @@ typedef struct StatusNotifierItem { void create_trayitem(GObject *obj, GAsyncResult *res, StatusNotifierItem *snitem); void create_menu(GObject *obj, GAsyncResult *res, StatusNotifierItem *snitem); -StatusNotifierHost* start_statusnotifierhost(); +//StatusNotifierHost* start_statusnotifierhost(); +void start_statusnotifierhost(StatusNotifierHost *snhost); void dwlb_request_resize(StatusNotifierHost *snhost); void terminate_statusnotifierhost(StatusNotifierHost *snhost); diff --git a/statusnotifierhost.c b/statusnotifierhost.c @@ -385,7 +385,6 @@ snhost_finalize(StatusNotifierHost *snhost) snhost->in_exit = TRUE; dwlb_request_resize(snhost); gtk_window_close(snhost->window); - g_free(snhost); snhost = NULL; } @@ -413,15 +412,9 @@ terminate_statusnotifierhost(StatusNotifierHost *snhost) } -StatusNotifierHost* -start_statusnotifierhost() +void +start_statusnotifierhost(StatusNotifierHost *snhost) { - StatusNotifierHost *snhost = g_malloc0(sizeof(StatusNotifierHost)); - - snhost->height = 22; - snhost->margin = 4; - snhost->noitems = 0; - snhost->owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, "org.kde.StatusNotifierWatcher", G_BUS_NAME_OWNER_FLAGS_NONE, @@ -430,6 +423,4 @@ start_statusnotifierhost() (GBusNameLostCallback)name_lost_handler, snhost, (GDestroyNotify)snhost_finalize); - - return snhost; }