Added support for pango markup

This commit is contained in:
Scoopta 2019-08-28 00:58:45 -07:00
parent 3db89a431f
commit abd571485f
2 changed files with 19 additions and 2 deletions

View File

@ -62,6 +62,7 @@ static void print_usage(char** argv) {
printf("--yoffset\t-y\tThe y offset\n"); printf("--yoffset\t-y\tThe y offset\n");
printf("--normal-window\t-n\tRender to a normal window\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-images\t-i\tAllows images to be rendered\n");
printf("--allow-markup\t-m\tAllows pango markup\n");
exit(0); exit(0);
} }
@ -249,6 +250,12 @@ int main(int argc, char** argv) {
.flag = NULL, .flag = NULL,
.val = 'i' .val = 'i'
}, },
{
.name = "allow-markup",
.has_arg = no_argument,
.flag = NULL,
.val = 'm'
},
{ {
.name = NULL, .name = NULL,
.has_arg = 0, .has_arg = 0,
@ -268,8 +275,9 @@ int main(int argc, char** argv) {
char* y = NULL; char* y = NULL;
char* normal_window = NULL; char* normal_window = NULL;
char* allow_images = NULL; char* allow_images = NULL;
char* allow_markup = NULL;
char opt; 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) { switch(opt) {
case 'h': case 'h':
print_usage(argv); print_usage(argv);
@ -318,6 +326,9 @@ int main(int argc, char** argv) {
case 'i': case 'i':
allow_images = "true"; allow_images = "true";
break; break;
case 'm':
allow_markup = "true";
break;
} }
} }
@ -414,6 +425,9 @@ int main(int argc, char** argv) {
if(allow_images != NULL) { if(allow_images != NULL) {
map_put(config, "allow_images", allow_images); map_put(config, "allow_images", allow_images);
} }
if(allow_markup != NULL) {
map_put(config, "allow_markup", allow_markup);
}
gtk_init(&argc, &argv); gtk_init(&argc, &argv);

View File

@ -25,7 +25,7 @@ static const gchar* filter;
static char* mode; static char* mode;
static time_t filter_time; static time_t filter_time;
static int64_t filter_rate; static int64_t filter_rate;
static bool allow_images; static bool allow_images, allow_markup;
struct node { struct node {
char* text, *action; char* text, *action;
@ -115,6 +115,7 @@ static GtkWidget* create_label(char* text, char* action) {
filter = tmp_filter; filter = tmp_filter;
} }
GtkWidget* label = gtk_label_new(tmp); 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_label_set_xalign(GTK_LABEL(label), 0);
gtk_container_add(GTK_CONTAINER(box), label); gtk_container_add(GTK_CONTAINER(box), label);
} }
@ -128,6 +129,7 @@ static GtkWidget* create_label(char* text, char* action) {
} else { } else {
wofi_property_box_add_property(WOFI_PROPERTY_BOX(box), "filter", text); wofi_property_box_add_property(WOFI_PROPERTY_BOX(box), "filter", text);
GtkWidget* label = gtk_label_new(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_label_set_xalign(GTK_LABEL(label), 0);
gtk_container_add(GTK_CONTAINER(box), label); 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_rate = strtol(config_get(config, "filter_rate", "100"), NULL, 10);
filter_time = utils_get_time_millis(); filter_time = utils_get_time_millis();
allow_images = strcmp(config_get(config, "allow_images", "false"), "true") == 0; 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); window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_realize(window); gtk_widget_realize(window);