Added --columns

This commit is contained in:
Scoopta 2020-02-06 18:22:50 -08:00
parent b7fcedf877
commit df75b649a5
4 changed files with 26 additions and 4 deletions

View File

@ -97,6 +97,9 @@ Sets a config option
.TP
.B \-L, \-\-lines=\fILINES\fR
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
Wofi has 3 main files used for configuration. All files are completely optional.

View File

@ -94,6 +94,9 @@ If true disables multiple actions for modes that support it, default is false.
.B lines=\fILINES\fR
Specifies the height in number of lines instead of pixels.
.TP
.B columns=\fICOLUMNS\fR
Specifies the number of columns to display, default is 1.
.TP
.B orientation=\fIORIENTATION\fR
Specifies the orientation, it can be either horizontal or vertical, default is vertical.
.TP

View File

@ -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("--define\t-D\tSets a config option\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);
}
@ -366,6 +367,12 @@ int main(int argc, char** argv) {
.flag = NULL,
.val = 'L'
},
{
.name = "columns",
.has_arg = required_argument,
.flag = NULL,
.val = 'w'
},
{
.name = NULL,
.has_arg = 0,
@ -397,13 +404,14 @@ int main(int argc, char** argv) {
char* location = NULL;
char* no_actions = NULL;
char* lines = NULL;
char* columns = 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: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) {
case 'h':
print_usage(argv);
@ -497,6 +505,9 @@ int main(int argc, char** argv) {
case 'L':
lines = optarg;
break;
case 'w':
columns = optarg;
break;
}
}
@ -664,6 +675,9 @@ int main(int argc, char** argv) {
if(lines != NULL) {
map_put(config, "lines", lines);
}
if(columns != NULL) {
map_put(config, "columns", columns);
}
struct sigaction sigact;
memset(&sigact, 0, sizeof(sigact));

View File

@ -63,6 +63,7 @@ static GtkAlign content_halign;
static struct map* config;
static enum locations location;
static bool no_actions;
static uint64_t columns;
struct mode {
void (*mode_exec)(const gchar* cmd);
@ -405,9 +406,9 @@ static gboolean _insert_widget(gpointer data) {
}
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 {
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);
@ -1057,6 +1058,7 @@ void wofi_init(struct map* _config) {
"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);
columns = strtol(config_get(config, "columns", "1"), NULL, 10);
modes = map_init_void();
if(lines > 0) {
@ -1118,7 +1120,7 @@ void wofi_init(struct map* _config) {
}
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_widget_set_halign(inner_box, halign);
gtk_widget_set_valign(inner_box, valign);