dwlb

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

commit 3fcbff751fa7f2b447d290212da3317e6db2024d
parent 114c02d47f39d3833123f5ddf9a91977050363e0
Author: Janne Veteläinen <janne.vetelainen@elisanet.fi>
Date:   Sun, 14 Apr 2024 01:42:49 +0300

Cleanup

Diffstat:
Mstatusnotifierhost.c | 41++++++++++++-----------------------------
Mstatusnotifieritem.c | 19+++++++++----------
2 files changed, 21 insertions(+), 39 deletions(-)

diff --git a/statusnotifierhost.c b/statusnotifierhost.c @@ -149,21 +149,25 @@ unregister_statusnotifieritem(StatusNotifierItem *snitem, StatusNotifierHost *sn g_slist_free_full(snitem->action_cb_data_slist, g_free); g_object_unref(snitem->menu); } - - g_object_unref(snitem->paintable); - if (snitem->iconpixmap_v) - g_variant_unref(snitem->iconpixmap_v); + if (snitem->menunodeinfo) + g_dbus_node_info_unref(snitem->menunodeinfo); + + if (snitem->paintable) { + g_object_unref(snitem->paintable); + if (snitem->iconpixmap_v) + g_variant_unref(snitem->iconpixmap_v); + if (snitem->iconname) + g_free(snitem->iconname); + } g_object_unref(snitem->proxy); - g_object_unref(snitem->actiongroup); - g_dbus_node_info_unref(snitem->menunodeinfo); g_dbus_node_info_unref(snitem->nodeinfo); - if (snitem->iconname) - g_free(snitem->iconname); + g_object_unref(snitem->actiongroup); g_free(snitem->busname); g_free(snitem->busobj); g_free(snitem->menuobj); snhost->trayitems = g_slist_remove(snhost->trayitems, snitem); + g_free(snitem); snitem = NULL; @@ -172,15 +176,6 @@ unregister_statusnotifieritem(StatusNotifierItem *snitem, StatusNotifierHost *sn } -/* - * static void - * unregister_all(StatusNotifierHost *snhost) - * { - * g_slist_foreach(snhost->trayitems, (GFunc)unregister_statusnotifieritem, snhost); - * } -*/ - - static void handle_method_call(GDBusConnection *conn, const char *sender, @@ -255,18 +250,6 @@ handle_get_prop(GDBusConnection* conn, } } -/* - * void - * terminate_statusnotifierhost(StatusNotifierHost *snhost) - * { - * g_dbus_connection_signal_unsubscribe(snhost->conn, snhost->nameowner_sig_sub_id); - * g_bus_unown_name(snhost->owner_id); - * unregister_all(snhost); - * g_slist_free(snhost->trayitems); - * g_dbus_node_info_unref(snhost->nodeinfo); - * g_free(snhost); - * } - */ // Finds trayitems which dropped from the bus and untracks them static void diff --git a/statusnotifieritem.c b/statusnotifieritem.c @@ -207,23 +207,24 @@ new_iconname_handler(GDBusProxy *proxy, GAsyncResult *res, StatusNotifierItem *s } GVariant *iconname_v; - char *iconname = NULL; + const char *iconname = NULL; g_variant_get(data, "(v)", &iconname_v); - g_variant_get(iconname_v, "s", &iconname); + g_variant_get(iconname_v, "&s", &iconname); + g_variant_unref(iconname_v); if (strcmp(iconname, snitem->iconname) == 0) { g_debug("%s\n", "pixmap didnt change, nothing to"); - g_variant_unref(iconname_v); g_variant_unref(data); return; } + g_free(snitem->iconname); g_object_unref(snitem->paintable); - snitem->iconname = iconname; + + snitem->iconname = g_strdup(iconname); snitem->paintable = get_paintable_from_name(snitem->iconname); gtk_image_set_from_paintable(GTK_IMAGE(snitem->icon), snitem->paintable); - g_variant_unref(iconname_v); g_variant_unref(data); } @@ -297,19 +298,19 @@ create_icon(GDBusProxy *proxy, StatusNotifierItem *snitem) GtkWidget *image = NULL; - char *iconname = NULL; + const char *iconname = NULL; GdkPaintable *paintable = NULL; GVariant *iconname_v = g_dbus_proxy_get_cached_property(proxy, "IconName"); if (iconname_v) { - g_variant_get(iconname_v, "s", &iconname); + g_variant_get(iconname_v, "&s", &iconname); g_variant_unref(iconname_v); } if (iconname && strcmp(iconname, "") != 0) { paintable = get_paintable_from_name(iconname); - snitem->iconname = iconname; + snitem->iconname = g_strdup(iconname); } else { GVariant *iconpixmap_v = g_dbus_proxy_get_cached_property(proxy, "IconPixmap"); @@ -319,8 +320,6 @@ create_icon(GDBusProxy *proxy, StatusNotifierItem *snitem) snitem->iconpixmap_v = iconpixmap_v; - if (iconname) - g_free(iconname); } image = gtk_image_new_from_paintable(paintable);