aboutsummaryrefslogtreecommitdiff
path: root/swaynag
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-12-21 11:19:04 +0100
committerSimon Ser <contact@emersion.fr>2022-12-22 17:42:33 +0100
commitbd7466e1b7fa7bf567effeb4fcd7ab6f218dff25 (patch)
treeee69039dd830c86e594f9163dde8df0931e10be3 /swaynag
parentfd0af78e43f4dd67a404f475c676b25ae38a4b82 (diff)
swaynag: drop swaynag_type.font
It's too easy to have this go out of sync with font_description.
Diffstat (limited to 'swaynag')
-rw-r--r--swaynag/config.c4
-rw-r--r--swaynag/main.c4
-rw-r--r--swaynag/types.c8
3 files changed, 5 insertions, 11 deletions
diff --git a/swaynag/config.c b/swaynag/config.c
index a0bf3197..6c8c26fc 100644
--- a/swaynag/config.c
+++ b/swaynag/config.c
@@ -226,10 +226,8 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
break;
case 'f': // Font
if (type) {
- free(type->font);
pango_font_description_free(type->font_description);
- type->font = strdup(optarg);
- type->font_description = pango_font_description_from_string(type->font);
+ type->font_description = pango_font_description_from_string(optarg);
}
break;
case 'l': // Detailed Message
diff --git a/swaynag/main.c b/swaynag/main.c
index 2ce37831..679afbce 100644
--- a/swaynag/main.c
+++ b/swaynag/main.c
@@ -98,7 +98,9 @@ int main(int argc, char **argv) {
sway_log(SWAY_DEBUG, "Anchors: %" PRIu32, swaynag.type->anchors);
sway_log(SWAY_DEBUG, "Type: %s", swaynag.type->name);
sway_log(SWAY_DEBUG, "Message: %s", swaynag.message);
- sway_log(SWAY_DEBUG, "Font: %s", swaynag.type->font);
+ char *font = pango_font_description_to_string(swaynag.type->font_description);
+ sway_log(SWAY_DEBUG, "Font: %s", font);
+ free(font);
sway_log(SWAY_DEBUG, "Buttons");
for (int i = 0; i < swaynag.buttons->length; i++) {
struct swaynag_button *button = swaynag.buttons->items[i];
diff --git a/swaynag/types.c b/swaynag/types.c
index a46aacd5..409cc668 100644
--- a/swaynag/types.c
+++ b/swaynag/types.c
@@ -32,9 +32,8 @@ struct swaynag_type *swaynag_type_new(const char *name) {
void swaynag_types_add_default(list_t *types) {
struct swaynag_type *type_defaults = swaynag_type_new("<defaults>");
- type_defaults->font = strdup("pango:Monospace 10");
type_defaults->font_description =
- pango_font_description_from_string(type_defaults->font);
+ pango_font_description_from_string("pango:Monospace 10");
type_defaults->anchors = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP
| ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT
| ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
@@ -92,10 +91,6 @@ void swaynag_type_merge(struct swaynag_type *dest, struct swaynag_type *src) {
return;
}
- if (src->font) {
- dest->font = strdup(src->font);
- }
-
if (src->font_description) {
dest->font_description = pango_font_description_copy(src->font_description);
}
@@ -178,7 +173,6 @@ void swaynag_type_merge(struct swaynag_type *dest, struct swaynag_type *src) {
void swaynag_type_free(struct swaynag_type *type) {
free(type->name);
- free(type->font);
pango_font_description_free(type->font_description);
free(type->output);
free(type);