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