1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[LISTVIEW] Support more customization in element.

This commit is contained in:
Dave Davenport 2020-05-13 17:17:15 +02:00
parent f2b6cf6b3c
commit 191f49dbea
2 changed files with 29 additions and 15 deletions

View file

@ -225,12 +225,13 @@ static void hori_calculate_size ( box *b )
if ( b->max_size > ( rem_width ) ) {
b->max_size = rem_width;
g_debug ( "Widgets to large (width) for box: %d %d", b->max_size, b->widget.w );
return;
//return;
}
if ( active_widgets > 0 ) {
int left = widget_padding_get_left ( WIDGET ( b ) );
double rem = rem_width - b->max_size;
int index = 0;
if ( rem < 0 ) rem = 0;
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
widget * child = (widget *) iter->data;
if ( child->enabled == FALSE ) {

View file

@ -165,6 +165,32 @@ static void listview_set_state ( _listview_row r, TextBoxFontType tbft )
break;
}
}
static void listview_add_widget ( listview *lv, _listview_row *row, widget *wid, const char *label )
{
TextboxFlags flags = ( lv->multi_select ) ? TB_INDICATOR : 0;
if ( strcasecmp ( label, "element-icon" ) == 0 ) {
if ( config.show_icons ) {
row->icon = icon_create ( WIDGET ( wid ), "element-icon" );
box_add ( (box *)wid, WIDGET ( row->icon ), FALSE );
}
}
else if ( strcasecmp ( label, "element-text" ) == 0 ) {
row->textbox = textbox_create ( WIDGET ( wid ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT | flags, NORMAL, "DDD", 0, 0 );
box_add ( (box *)wid, WIDGET ( row->textbox ), TRUE );
}
else if ( strcasecmp ( label, "element-index" ) == 0 ) {
row->index = textbox_create ( WIDGET ( wid ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT, NORMAL, " ", 0, 0 );
box_add ( (box *)wid, WIDGET ( row->index ), FALSE );
} else {
widget *wid2 = (widget *) box_create ( wid, label, ROFI_ORIENTATION_VERTICAL );
box_add ( (box *) wid, WIDGET ( wid2 ), TRUE );
GList *list = rofi_theme_get_list ( WIDGET ( wid2 ), "children", "" );
for ( GList *iter = g_list_first ( list ); iter != NULL; iter = g_list_next ( iter ) ) {
listview_add_widget ( lv,row, wid2, (const char *)iter->data );
}
}
}
static void listview_create_row ( listview *lv, _listview_row *row )
{
@ -178,20 +204,7 @@ static void listview_create_row ( listview *lv, _listview_row *row )
row->index = NULL;
for ( GList *iter = g_list_first ( list ); iter != NULL; iter = g_list_next ( iter ) ) {
if ( strcasecmp ( (char *) iter->data, "element-icon" ) == 0 ) {
if ( config.show_icons ) {
row->icon = icon_create ( WIDGET ( row->box ), "element-icon" );
box_add ( row->box, WIDGET ( row->icon ), FALSE );
}
}
else if ( strcasecmp ( (char *) iter->data, "element-text" ) == 0 ) {
row->textbox = textbox_create ( WIDGET ( row->box ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT | flags, NORMAL, "DDD", 0, 0 );
box_add ( row->box, WIDGET ( row->textbox ), TRUE );
}
else if ( strcasecmp ( (char*) iter->data, "element-index" ) == 0 ) {
row->index = textbox_create ( WIDGET ( row->box ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT, NORMAL, " ", 0, 0 );
box_add ( row->box, WIDGET ( row->index ), FALSE );
}
listview_add_widget ( lv,row, WIDGET(row->box), (const char *)iter->data );
}
g_list_free_full ( list, g_free );
}