From e0697d9879005249338eb9054d4e12cd762fffc9 Mon Sep 17 00:00:00 2001 From: FelixKratz Date: Sun, 3 Oct 2021 00:48:25 +0200 Subject: [PATCH] preparing item grouping --- makefile | 3 +++ src/bar_item.c | 1 + src/bar_item.h | 3 +++ src/group.c | 25 +++++++++++++++++++++++++ src/group.h | 10 ++++++++-- src/manifest.m | 2 ++ 6 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 src/group.c diff --git a/makefile b/makefile index 105b4b8..0cd9e2f 100644 --- a/makefile +++ b/makefile @@ -22,6 +22,9 @@ install: clean $(UNIVERSAL_BINS) uninstall: clean rm /usr/local/bin/sketchybar +profile: BUILD_FLAGS=-std=c99 -Wall -DDEBUG -g -Ofast -fvisibility=hidden +profile: clean $(x86_BINS) + debug: BUILD_FLAGS=-std=c99 -Wall -DDEBUG -fsanitize=address -fsanitize=undefined -g -O0 -fvisibility=hidden debug: clean $(x86_BINS) diff --git a/src/bar_item.c b/src/bar_item.c index e92a10f..8fa3f84 100644 --- a/src/bar_item.c +++ b/src/bar_item.c @@ -59,6 +59,7 @@ void bar_item_init(struct bar_item* bar_item, struct bar_item* default_item) { bar_item->y_offset = 0; bar_item->num_rects = 0; bar_item->bounding_rects = NULL; + bar_item->group = NULL; bar_item->has_alias = false; bar_item->has_graph = false; diff --git a/src/bar_item.h b/src/bar_item.h index d2d1fa7..376d4f6 100644 --- a/src/bar_item.h +++ b/src/bar_item.h @@ -65,6 +65,9 @@ struct bar_item { bool has_alias; struct alias alias; + // Group Properties + struct group* group; + // Update Events uint32_t update_mask; diff --git a/src/group.c b/src/group.c new file mode 100644 index 0000000..80c8db6 --- /dev/null +++ b/src/group.c @@ -0,0 +1,25 @@ +#include "group.h" +#include "background.h" +#include +#include + +struct group* group_create() { + struct group* group = malloc(sizeof(struct group)); + memset(group, 0, sizeof(struct group)); + return group; +} + +void group_init(struct group* group) { + group->name = string_copy(""); + background_init(&group->background); +} + +void group_set_name(struct group* group, char* _name) { + if (group->name && group->name != _name) free(group->name); + group->name = _name; +} + +void group_destroy(struct group* group) { + if (group->name) free(group->name); + free(group); +} diff --git a/src/group.h b/src/group.h index 2e5823a..07547c2 100644 --- a/src/group.h +++ b/src/group.h @@ -1,11 +1,17 @@ #ifndef GROUP_H_ #define GROUP_H_ +#include <_types/_uint32_t.h> + struct group { char* name; - // Background - struct rgba_color background_color; + struct background background; }; +struct group* group_create(); +void group_init(struct group* group); +void group_set_name(struct group* group, char* _name); +void group_destroy(struct group* group); + #endif diff --git a/src/manifest.m b/src/manifest.m index f04244a..70eb522 100644 --- a/src/manifest.m +++ b/src/manifest.m @@ -29,6 +29,7 @@ #include "text.h" #include "graph.h" #include "alias.h" +#include "group.h" #include "bar_item.h" #include "custom_events.h" #include "bar_manager.h" @@ -44,6 +45,7 @@ #include "text.c" #include "graph.c" #include "alias.c" +#include "group.c" #include "bar_item.c" #include "custom_events.c" #include "bar_manager.c"