-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REQUEST] Allow setting columns using calc #1857
Comments
Good idea. Need to see how to add cleanly, currently calc only applies to 'distance'. (calc requires the direction to be passed, (so it knows to get width/height) so this is one unclearity. What should be used for a generic 'integer'). |
diff --git a/source/widgets/listview.c b/source/widgets/listview.c
index 2e333cb6..301ce930 100644
--- a/source/widgets/listview.c
+++ b/source/widgets/listview.c
@@ -784,8 +784,10 @@ listview *listview_create(widget *parent, const char *name,
// Some settings.
lv->spacing = rofi_theme_get_distance(WIDGET(lv), "spacing", DEFAULT_SPACING);
- lv->menu_columns =
- rofi_theme_get_integer(WIDGET(lv), "columns", DEFAULT_MENU_COLUMNS);
+
+ RofiDistance d = {DEFAULT_MENU_COLUMNS, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL};
+ RofiPadding pad = rofi_theme_get_padding(WIDGET(lv), "columns", (RofiPadding){d,d,d,d});
+ lv->menu_columns = distance_get_pixel(pad.top, ROFI_ORIENTATION_HORIZONTAL);
lv->menu_lines =
rofi_theme_get_integer(WIDGET(lv), "lines", DEFAULT_MENU_LINES);
lv->fixed_num_lines = rofi_theme_get_boolean(WIDGET(lv), "fixed-height", quick hack for columns. But a more generic solution would be nice. |
Thanks I was planning on giving it a try this weekend. I'll try your patch and let you know |
diff --git a/source/theme.c b/source/theme.c
index 615c6fb9..880f7754 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -46,6 +46,12 @@
#include "widgets/textbox.h"
#include <gio/gio.h>
+
+
+static RofiPadding rofi_theme_get_padding_inside(Property *p,
+ const widget *widget,
+ const char *property,
+ RofiPadding pad);
/**
* list of config files we parsed.
*/
@@ -768,7 +774,8 @@ Property *rofi_theme_find_property(ThemeWidget *widget, PropertyType type,
return p;
}
// RofiPadding and integer can be converted.
- if (p->type == P_INTEGER && type == P_PADDING) {
+ if (( p->type == P_INTEGER && type == P_PADDING) ||
+ ( type == P_INTEGER && p->type == P_PADDING) ) {
return p;
}
g_debug("Found property: '%s' on '%s', but type %s does not match "
@@ -839,6 +846,14 @@ static int rofi_theme_get_integer_inside(Property *p, const widget *widget,
return rofi_theme_get_integer_inside(pv, widget->parent, property, def);
}
return def;
+ } else if ( p->type == P_PADDING ) {
+ RofiDistance d =
+ (RofiDistance){.base = {p->value.i, ROFI_PU_PX,
+ ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL},
+ .style = ROFI_HL_SOLID};
+ RofiPadding val = rofi_theme_get_padding_inside ( p, widget, property,(RofiPadding){d,d,d,d});
+ printf("calc integer value\r\n");
+ return distance_get_pixel ( val.top, ROFI_ORIENTATION_HORIZONTAL);
}
return p->value.i;
} this one is more generic, but hardcodes the calc orientation. |
Before opening a feature request
What is the user problem or growth opportunity you want to see solved?
I currently use two monitors with different sizes. Setting the number of columns of the listView widget to a fixed number results in either too few or too many elements on the rofi window at any given time, depending on what screen is focused.
How do you know that this problem exists today? Why is this important?
I tried the following:
Hoping to get 12 or 5 on each monitor, respectively. But the result is the same as setting columns to 1.
Who will benefit from it?
Many people, specially desktop enthusiasts like to have many screens with many different configurations.
Rofi version (rofi -v)
1.7.5
Configuration
https://gist.github.com/arielnmz/54864a106fa3fbfd796aa294a089e46a
Additional information
No response
The text was updated successfully, but these errors were encountered: