Added --lines
This commit is contained in:
parent
b266a82b4b
commit
7534181a8f
@ -94,6 +94,9 @@ Disables multiple actions for modes that support it.
|
||||
.TP
|
||||
.B \-D, \-\-define=\fIKEY=VALUE\fR
|
||||
Sets a config option
|
||||
.TP
|
||||
.B \-L, \-\-lines=\fILINES\fR
|
||||
Specifies the height in number of lines instead of pixels.
|
||||
|
||||
.SH CONFIGURATION
|
||||
Wofi has 3 main files used for configuration. All files are completely optional.
|
||||
|
@ -91,6 +91,9 @@ Specifies the location. See \fBwofi\fR(7) for more information, default is cente
|
||||
.B no_actions=\fIBOOL\fR
|
||||
If true disables multiple actions for modes that support it, default is false.
|
||||
.TP
|
||||
.B lines=\fILINES\fR
|
||||
Specifies the height in number of lines instead of pixels.
|
||||
.TP
|
||||
.B orientation=\fIORIENTATION\fR
|
||||
Specifies the orientation, it can be either horizontal or vertical, default is vertical.
|
||||
.TP
|
||||
|
16
src/main.c
16
src/main.c
@ -80,6 +80,7 @@ static void print_usage(char** argv) {
|
||||
printf("--location\t-l\tSets the location\n");
|
||||
printf("--no-actions\t-a\tDisables multiple actions for modes that support it\n");
|
||||
printf("--define\t-D\tSets a config option\n");
|
||||
printf("--lines\t\t-L\tSets the height in number of lines\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -359,6 +360,12 @@ int main(int argc, char** argv) {
|
||||
.flag = NULL,
|
||||
.val = 'D'
|
||||
},
|
||||
{
|
||||
.name = "lines",
|
||||
.has_arg = required_argument,
|
||||
.flag = NULL,
|
||||
.val = 'L'
|
||||
},
|
||||
{
|
||||
.name = NULL,
|
||||
.has_arg = 0,
|
||||
@ -389,13 +396,14 @@ int main(int argc, char** argv) {
|
||||
char* parse_search = NULL;
|
||||
char* location = NULL;
|
||||
char* no_actions = NULL;
|
||||
char* lines = NULL;
|
||||
|
||||
struct wl_list options;
|
||||
wl_list_init(&options);
|
||||
struct option_node* node;
|
||||
|
||||
int opt;
|
||||
while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nImk:t:P::ebM:iqvl:aD:", opts, NULL)) != -1) {
|
||||
while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nImk:t:P::ebM:iqvl:aD:L:", opts, NULL)) != -1) {
|
||||
switch(opt) {
|
||||
case 'h':
|
||||
print_usage(argv);
|
||||
@ -486,6 +494,9 @@ int main(int argc, char** argv) {
|
||||
node->option = optarg;
|
||||
wl_list_insert(&options, &node->link);
|
||||
break;
|
||||
case 'L':
|
||||
lines = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -650,6 +661,9 @@ int main(int argc, char** argv) {
|
||||
if(no_actions != NULL) {
|
||||
map_put(config, "no_actions", no_actions);
|
||||
}
|
||||
if(lines != NULL) {
|
||||
map_put(config, "lines", lines);
|
||||
}
|
||||
|
||||
struct sigaction sigact;
|
||||
memset(&sigact, 0, sizeof(sigact));
|
||||
|
26
src/wofi.c
26
src/wofi.c
@ -17,6 +17,8 @@
|
||||
|
||||
#include <wofi.h>
|
||||
|
||||
#define LINE_HEIGHT 25
|
||||
|
||||
static const char* terminals[] = {"kitty", "termite", "gnome-terminal", "weston-terminal"};
|
||||
|
||||
enum matching_mode {
|
||||
@ -394,6 +396,20 @@ static gboolean _insert_widget(gpointer data) {
|
||||
GtkWidget* child = gtk_flow_box_child_new();
|
||||
gtk_widget_set_name(child, "entry");
|
||||
|
||||
size_t lf_count = 1;
|
||||
size_t text_len = strlen(node->text[0]);
|
||||
for(size_t count = 0; count < text_len; ++count) {
|
||||
if(node->text[0][count] == '\n') {
|
||||
++lf_count;
|
||||
}
|
||||
}
|
||||
|
||||
if(allow_images) {
|
||||
gtk_widget_set_size_request(child, width, (image_size + 10) * lf_count);
|
||||
} else {
|
||||
gtk_widget_set_size_request(child, width, LINE_HEIGHT * lf_count);
|
||||
}
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(child), parent);
|
||||
gtk_container_add(GTK_CONTAINER(inner_box), child);
|
||||
gtk_widget_show_all(child);
|
||||
@ -1040,8 +1056,17 @@ void wofi_init(struct map* _config) {
|
||||
"center", "top_left", "top", "top_right", "right", "bottom_right", "bottom", "bottom_left", "left",
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8");
|
||||
no_actions = strcmp(config_get(config, "no_actions", "false"), "true") == 0;
|
||||
uint64_t lines = strtol(config_get(config, "lines", "0"), NULL, 10);
|
||||
modes = map_init_void();
|
||||
|
||||
if(lines > 0) {
|
||||
if(allow_images) {
|
||||
height = lines * (image_size + 10);
|
||||
} else {
|
||||
height = lines * LINE_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_realize(window);
|
||||
gtk_widget_set_name(window, "window");
|
||||
@ -1075,6 +1100,7 @@ void wofi_init(struct map* _config) {
|
||||
gtk_widget_set_name(outer_box, "outer-box");
|
||||
gtk_container_add(GTK_CONTAINER(window), outer_box);
|
||||
entry = gtk_search_entry_new();
|
||||
|
||||
gtk_widget_set_name(entry, "input");
|
||||
gtk_entry_set_placeholder_text(GTK_ENTRY(entry), prompt);
|
||||
gtk_container_add(GTK_CONTAINER(outer_box), entry);
|
||||
|
Loading…
Reference in New Issue
Block a user