From abd571485fbfdb620a9588c4b02276c3b6812d28 Mon Sep 17 00:00:00 2001 From: Scoopta Date: Wed, 28 Aug 2019 00:58:45 -0700 Subject: [PATCH] Added support for pango markup --- src/main.c | 16 +++++++++++++++- src/wofi.c | 5 ++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 39552ca..8d36cd2 100644 --- a/src/main.c +++ b/src/main.c @@ -62,6 +62,7 @@ static void print_usage(char** argv) { printf("--yoffset\t-y\tThe y offset\n"); printf("--normal-window\t-n\tRender to a normal window\n"); printf("--allow-images\t-i\tAllows images to be rendered\n"); + printf("--allow-markup\t-m\tAllows pango markup\n"); exit(0); } @@ -249,6 +250,12 @@ int main(int argc, char** argv) { .flag = NULL, .val = 'i' }, + { + .name = "allow-markup", + .has_arg = no_argument, + .flag = NULL, + .val = 'm' + }, { .name = NULL, .has_arg = 0, @@ -268,8 +275,9 @@ int main(int argc, char** argv) { char* y = NULL; char* normal_window = NULL; char* allow_images = NULL; + char* allow_markup = NULL; char opt; - while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:ni", opts, NULL)) != -1) { + while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nim", opts, NULL)) != -1) { switch(opt) { case 'h': print_usage(argv); @@ -318,6 +326,9 @@ int main(int argc, char** argv) { case 'i': allow_images = "true"; break; + case 'm': + allow_markup = "true"; + break; } } @@ -414,6 +425,9 @@ int main(int argc, char** argv) { if(allow_images != NULL) { map_put(config, "allow_images", allow_images); } + if(allow_markup != NULL) { + map_put(config, "allow_markup", allow_markup); + } gtk_init(&argc, &argv); diff --git a/src/wofi.c b/src/wofi.c index c52ba12..5f29dff 100644 --- a/src/wofi.c +++ b/src/wofi.c @@ -25,7 +25,7 @@ static const gchar* filter; static char* mode; static time_t filter_time; static int64_t filter_rate; -static bool allow_images; +static bool allow_images, allow_markup; struct node { char* text, *action; @@ -115,6 +115,7 @@ static GtkWidget* create_label(char* text, char* action) { filter = tmp_filter; } GtkWidget* label = gtk_label_new(tmp); + gtk_label_set_use_markup(GTK_LABEL(label), allow_markup); gtk_label_set_xalign(GTK_LABEL(label), 0); gtk_container_add(GTK_CONTAINER(box), label); } @@ -128,6 +129,7 @@ static GtkWidget* create_label(char* text, char* action) { } else { wofi_property_box_add_property(WOFI_PROPERTY_BOX(box), "filter", text); GtkWidget* label = gtk_label_new(text); + gtk_label_set_use_markup(GTK_LABEL(label), allow_markup); gtk_label_set_xalign(GTK_LABEL(label), 0); gtk_container_add(GTK_CONTAINER(box), label); } @@ -474,6 +476,7 @@ void wofi_init(struct map* config) { filter_rate = strtol(config_get(config, "filter_rate", "100"), NULL, 10); filter_time = utils_get_time_millis(); allow_images = strcmp(config_get(config, "allow_images", "false"), "true") == 0; + allow_markup = strcmp(config_get(config, "allow_markup", "false"), "true") == 0; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_realize(window);