dwlb

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

commit cba6fa56a1a6541ead42bcac5fac1b9a5a850746
parent 1f352fb58c4220e2129aaff835527ab41313ed32
Author: Janne Veteläinen <janne.vetelainen@elisanet.fi>
Date:   Mon,  8 Jul 2024 20:30:19 +0300

Remove unused function

Diffstat:
Msystray/Makefile | 11++++++-----
Msystray/dwlbtray.c | 19++++++++++---------
Msystray/sndbusmenu.c | 13++++++++++---
Msystray/sndbusmenu.h | 2--
Msystray/snhost.c | 7-------
Msystray/snitem.c | 21+++++----------------
Msystray/snitem.h | 10++++++----
7 files changed, 37 insertions(+), 46 deletions(-)

diff --git a/systray/Makefile b/systray/Makefile @@ -3,13 +3,14 @@ PROGNAME = dwlbtray CC = cc RM = rm -f +PKG_CONFIG = pkg-config PREFIX = /usr/local CFLAGS = -Wall -Wextra -g SUPPRESS = -Wno-missing-field-initializers -Wno-unused-parameter -DEPINCLUDES = `pkg-config --cflags glib-2.0 gobject-2.0 gio-2.0 gdk-pixbuf-2.0 \ - gtk4 gtk4-layer-shell-0` -DEPLIBS = `pkg-config --libs glib-2.0 gobject-2.0 gio-2.0 gdk-pixbuf-2.0 \ - gtk4 gtk4-layer-shell-0` +DEPINCLUDES = `$(PKG_CONFIG) --cflags glib-2.0 gobject-2.0 gio-2.0 \ + gdk-pixbuf-2.0 gtk4 gtk4-layer-shell-0` +DEPLIBS = `$(PKG_CONFIG) --libs glib-2.0 gobject-2.0 gio-2.0 \ + gdk-pixbuf-2.0 gtk4 gtk4-layer-shell-0` OBJS = dwlbtray.o snwatcher.o snhost.o snitem.o sndbusmenu.o all: $(PROGNAME) @@ -20,7 +21,7 @@ clean: install: all install -D -t $(PREFIX)/bin $(PROGNAME) -dwlbtray: $(OBJS) +$(PROGNAME): $(OBJS) $(CC) $(DEPLIBS) -o $(PROGNAME) $(LDFLAGS) $? .SUFFIXES: .c .o diff --git a/systray/dwlbtray.c b/systray/dwlbtray.c @@ -21,7 +21,6 @@ typedef struct args_parsed { static const int margin = 4; static const int spacing = 4; -static const char cssskele[] = "window{background-color:%s;}"; enum { DWLB_POSITION_TOP, @@ -52,16 +51,16 @@ activate(GtkApplication* app, void *data) switch (args->position) { case DWLB_POSITION_TOP: - anchors[0] = FALSE; // left - anchors[1] = TRUE; // right - anchors[2] = TRUE; // top - anchors[3] = FALSE; // bottom + anchors[GTK_LAYER_SHELL_EDGE_LEFT] = FALSE; + anchors[GTK_LAYER_SHELL_EDGE_RIGHT] = TRUE; + anchors[GTK_LAYER_SHELL_EDGE_TOP] = TRUE; + anchors[GTK_LAYER_SHELL_EDGE_BOTTOM] = FALSE; break; case DWLB_POSITION_BOTTOM: - anchors[0] = FALSE; // left - anchors[1] = TRUE; // right - anchors[2] = FALSE; // top - anchors[3] = TRUE; // bottom + anchors[GTK_LAYER_SHELL_EDGE_LEFT] = FALSE; + anchors[GTK_LAYER_SHELL_EDGE_RIGHT] = TRUE; + anchors[GTK_LAYER_SHELL_EDGE_TOP] = FALSE; + anchors[GTK_LAYER_SHELL_EDGE_BOTTOM] = TRUE; break; default: g_assert_not_reached(); @@ -121,6 +120,8 @@ terminate_app(GtkApplication *app) int main(int argc, char *argv[]) { + const char cssskele[] = "window{background-color:%s;}"; + args_parsed args; args.barheight = 22; args.position = DWLB_POSITION_TOP; diff --git a/systray/sndbusmenu.c b/systray/sndbusmenu.c @@ -139,6 +139,7 @@ create_menuitem(int32_t id, GVariant *menuitem_data, GVariant *submenuitem_data, const char *type = NULL; gboolean isenabled = TRUE; gboolean isvisible = TRUE; + gboolean isseparator = FALSE; gboolean has_submenu = FALSE; /* @@ -167,6 +168,10 @@ create_menuitem(int32_t id, GVariant *menuitem_data, GVariant *submenuitem_data, if (has_submenu_s && strcmp(has_submenu_s, "submenu") == 0) has_submenu = TRUE; + if (type && strcmp(type, "separator") == 0) { + isseparator = TRUE; + } + /* * if (toggle_type && strcmp(toggle_type, "checkmark") == 0) * ischeckmark = TRUE; @@ -174,7 +179,10 @@ create_menuitem(int32_t id, GVariant *menuitem_data, GVariant *submenuitem_data, * isradio = TRUE; */ - if ((label && isvisible && isenabled) && !(type && strcmp(type, "separator") == 0)) { + if (!isvisible || isseparator) + return NULL; + + if (label && isenabled) { GSimpleAction *action = create_action(id, self); snprintf(detailed_name, sizeof(detailed_name), "%s.%u", actiongroup_pfx, id); g_action_map_add_action(actionmap, G_ACTION(action)); @@ -182,8 +190,7 @@ create_menuitem(int32_t id, GVariant *menuitem_data, GVariant *submenuitem_data, g_object_unref(action); - } else if ((label && isvisible && !isenabled && - !(type && strcmp(type, "separator") == 0))) { + } else if (label && !isenabled) { GSimpleAction *action = create_action(id, self); g_simple_action_set_enabled(action, FALSE); snprintf(detailed_name, sizeof(detailed_name), "%s.%u", actiongroup_pfx, id); diff --git a/systray/sndbusmenu.h b/systray/sndbusmenu.h @@ -14,8 +14,6 @@ SnDbusmenu* sn_dbusmenu_new (const char *busname, const char *busobj, SnItem *snitem); -GDBusProxy* sn_dbusmenu_get_proxy (SnDbusmenu *self); - G_END_DECLS #define DBUSMENU_XML \ diff --git a/systray/snhost.c b/systray/snhost.c @@ -178,18 +178,11 @@ sn_host_set_property(GObject *object, } static void -sn_host_get_property(GObject *object, unsigned int property_id, GValue *value, GParamSpec *pspec) -{ - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); -} - -static void sn_host_class_init(SnHostClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); object_class->set_property = sn_host_set_property; - object_class->get_property = sn_host_get_property; object_class->constructed = sn_host_constructed; object_class->dispose = sn_host_dispose; object_class->finalize = sn_host_finalize; diff --git a/systray/snitem.c b/systray/snitem.c @@ -218,13 +218,6 @@ get_paintable_from_name(const char *iconname, int32_t iconsize) return paintable; } -static int -find_cached_name(CachedIcon *cicon, const char *name) -{ - - return strcmp(cicon->iconname, name); -} - static void sn_item_proxy_new_iconname_handler(GObject *obj, GAsyncResult *res, void *data) { @@ -262,7 +255,7 @@ sn_item_proxy_new_iconname_handler(GObject *obj, GAsyncResult *res, void *data) GSList *elem = g_slist_find_custom(self->cachedicons, iconname, - (GCompareFunc)find_cached_name); + (GCompareFunc)strcmp); if (elem) { // Cache hit @@ -287,14 +280,10 @@ sn_item_proxy_new_iconname_handler(GObject *obj, GAsyncResult *res, void *data) static int find_cached_pixmap(CachedIcon *cicon, GVariant *pixmap) { - int ret; - if (cicon->iconpixmap && g_variant_equal(cicon->iconpixmap, pixmap)) { - ret = 0; - } else { - ret = 1; - } - - return ret; + if (cicon->iconpixmap && g_variant_equal(cicon->iconpixmap, pixmap)) + return 0; + else + return 1; } static void diff --git a/systray/snitem.h b/systray/snitem.h @@ -13,12 +13,14 @@ SnItem* sn_item_new (const char *busname, const char *busobj, int iconsize); -void sn_item_set_menu_model (SnItem *widget, GMenu *menu); -void sn_item_clear_menu_model (SnItem *widget); char* sn_item_get_busname (SnItem *self); gboolean sn_item_get_popover_visible (SnItem *self); -void sn_item_set_actiongroup(SnItem *self, const char *prefix, GSimpleActionGroup *group); -void sn_item_clear_actiongroup(SnItem *self, const char *prefix); +void sn_item_set_menu_model (SnItem *widget, GMenu *menu); +void sn_item_set_actiongroup (SnItem *self, + const char *prefix, + GSimpleActionGroup *group); +void sn_item_clear_actiongroup (SnItem *self, const char *prefix); +void sn_item_clear_menu_model (SnItem *widget); G_END_DECLS