Added --columns
This commit is contained in:
parent
b7fcedf877
commit
df75b649a5
@ -97,6 +97,9 @@ Sets a config option
|
|||||||
.TP
|
.TP
|
||||||
.B \-L, \-\-lines=\fILINES\fR
|
.B \-L, \-\-lines=\fILINES\fR
|
||||||
Specifies the height in number of lines instead of pixels.
|
Specifies the height in number of lines instead of pixels.
|
||||||
|
.TP
|
||||||
|
.B \-w, \-\-columns=\fICOLUMNS\fR
|
||||||
|
Specifies the number of columns to display, default is 1.
|
||||||
|
|
||||||
.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.
|
||||||
|
@ -94,6 +94,9 @@ If true disables multiple actions for modes that support it, default is false.
|
|||||||
.B lines=\fILINES\fR
|
.B lines=\fILINES\fR
|
||||||
Specifies the height in number of lines instead of pixels.
|
Specifies the height in number of lines instead of pixels.
|
||||||
.TP
|
.TP
|
||||||
|
.B columns=\fICOLUMNS\fR
|
||||||
|
Specifies the number of columns to display, default is 1.
|
||||||
|
.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
@ -81,6 +81,7 @@ static void print_usage(char** argv) {
|
|||||||
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");
|
printf("--lines\t\t-L\tSets the height in number of lines\n");
|
||||||
|
printf("--columns\t-w\tSets the number of columns to display\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,6 +367,12 @@ int main(int argc, char** argv) {
|
|||||||
.flag = NULL,
|
.flag = NULL,
|
||||||
.val = 'L'
|
.val = 'L'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "columns",
|
||||||
|
.has_arg = required_argument,
|
||||||
|
.flag = NULL,
|
||||||
|
.val = 'w'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = NULL,
|
.name = NULL,
|
||||||
.has_arg = 0,
|
.has_arg = 0,
|
||||||
@ -397,13 +404,14 @@ int main(int argc, char** argv) {
|
|||||||
char* location = NULL;
|
char* location = NULL;
|
||||||
char* no_actions = NULL;
|
char* no_actions = NULL;
|
||||||
char* lines = NULL;
|
char* lines = NULL;
|
||||||
|
char* columns = 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:L:", 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:w:", opts, NULL)) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'h':
|
case 'h':
|
||||||
print_usage(argv);
|
print_usage(argv);
|
||||||
@ -497,6 +505,9 @@ int main(int argc, char** argv) {
|
|||||||
case 'L':
|
case 'L':
|
||||||
lines = optarg;
|
lines = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
columns = optarg;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,6 +675,9 @@ int main(int argc, char** argv) {
|
|||||||
if(lines != NULL) {
|
if(lines != NULL) {
|
||||||
map_put(config, "lines", lines);
|
map_put(config, "lines", lines);
|
||||||
}
|
}
|
||||||
|
if(columns != NULL) {
|
||||||
|
map_put(config, "columns", columns);
|
||||||
|
}
|
||||||
|
|
||||||
struct sigaction sigact;
|
struct sigaction sigact;
|
||||||
memset(&sigact, 0, sizeof(sigact));
|
memset(&sigact, 0, sizeof(sigact));
|
||||||
|
@ -63,6 +63,7 @@ static GtkAlign content_halign;
|
|||||||
static struct map* config;
|
static struct map* config;
|
||||||
static enum locations location;
|
static enum locations location;
|
||||||
static bool no_actions;
|
static bool no_actions;
|
||||||
|
static uint64_t columns;
|
||||||
|
|
||||||
struct mode {
|
struct mode {
|
||||||
void (*mode_exec)(const gchar* cmd);
|
void (*mode_exec)(const gchar* cmd);
|
||||||
@ -405,9 +406,9 @@ static gboolean _insert_widget(gpointer data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(allow_images) {
|
if(allow_images) {
|
||||||
gtk_widget_set_size_request(child, width, (image_size + 10) * lf_count);
|
gtk_widget_set_size_request(child, width / columns, (image_size + 10) * lf_count);
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_set_size_request(child, width, LINE_HEIGHT * lf_count);
|
gtk_widget_set_size_request(child, width / columns, LINE_HEIGHT * lf_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_container_add(GTK_CONTAINER(child), parent);
|
gtk_container_add(GTK_CONTAINER(child), parent);
|
||||||
@ -1057,6 +1058,7 @@ void wofi_init(struct map* _config) {
|
|||||||
"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);
|
uint64_t lines = strtol(config_get(config, "lines", "0"), NULL, 10);
|
||||||
|
columns = strtol(config_get(config, "columns", "1"), NULL, 10);
|
||||||
modes = map_init_void();
|
modes = map_init_void();
|
||||||
|
|
||||||
if(lines > 0) {
|
if(lines > 0) {
|
||||||
@ -1118,7 +1120,7 @@ void wofi_init(struct map* _config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inner_box = gtk_flow_box_new();
|
inner_box = gtk_flow_box_new();
|
||||||
gtk_flow_box_set_max_children_per_line(GTK_FLOW_BOX(inner_box), 1);
|
gtk_flow_box_set_max_children_per_line(GTK_FLOW_BOX(inner_box), columns);
|
||||||
gtk_orientable_set_orientation(GTK_ORIENTABLE(inner_box), orientation);
|
gtk_orientable_set_orientation(GTK_ORIENTABLE(inner_box), orientation);
|
||||||
gtk_widget_set_halign(inner_box, halign);
|
gtk_widget_set_halign(inner_box, halign);
|
||||||
gtk_widget_set_valign(inner_box, valign);
|
gtk_widget_set_valign(inner_box, valign);
|
||||||
|
Loading…
Reference in New Issue
Block a user