diff options
author | Dave Davenport <qball@gmpclient.org> | 2020-05-13 16:25:12 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2020-05-13 16:25:12 +0200 |
commit | f2b6cf6b3cdc3211ec17634358765fdb7898dcf1 (patch) | |
tree | b5cd2a8c2ae60adae54b2899484a3c167aff82f8 /source | |
parent | 0a33aadd8b011fac91d694b3f1356fef1994a799 (diff) |
[Widget] Propaget set_state to children.
Diffstat (limited to 'source')
-rw-r--r-- | source/widgets/box.c | 9 | ||||
-rw-r--r-- | source/widgets/container.c | 7 | ||||
-rw-r--r-- | source/widgets/listview.c | 18 | ||||
-rw-r--r-- | source/widgets/widget.c | 5 |
4 files changed, 23 insertions, 16 deletions
diff --git a/source/widgets/box.c b/source/widgets/box.c index 605ec0ce..42f95f4e 100644 --- a/source/widgets/box.c +++ b/source/widgets/box.c @@ -329,6 +329,14 @@ static widget *box_find_mouse_target ( widget *wid, WidgetType type, gint x, gin return NULL; } +static void box_set_state ( widget *wid, const char *state ) +{ + for ( GList *iter = g_list_first ( ((box*)wid)->children ); iter != NULL; iter = g_list_next ( iter ) ) { + widget * child = (widget *) iter->data; + widget_set_state ( child, state ); + } +} + box * box_create ( widget *parent, const char *name, RofiOrientation type ) { box *b = g_malloc0 ( sizeof ( box ) ); @@ -342,6 +350,7 @@ box * box_create ( widget *parent, const char *name, RofiOrientation type ) b->widget.find_mouse_target = box_find_mouse_target; b->widget.get_desired_height = box_get_desired_height; b->widget.get_desired_width = box_get_desired_width; + b->widget.set_state = box_set_state; b->type = rofi_theme_get_orientation ( WIDGET ( b ), "orientation", b->type ); diff --git a/source/widgets/container.c b/source/widgets/container.c index e2019767..c53efd53 100644 --- a/source/widgets/container.c +++ b/source/widgets/container.c @@ -101,6 +101,12 @@ static widget *container_find_mouse_target ( widget *wid, WidgetType type, gint return widget_find_mouse_target ( b->child, type, x, y ); } +static void container_set_state ( widget *wid, const char *state ) +{ + container *b = (container *) wid; + widget_set_state ( b->child, state ); +} + container * container_create ( widget *parent, const char *name ) { container *b = g_malloc0 ( sizeof ( container ) ); @@ -112,6 +118,7 @@ container * container_create ( widget *parent, const char *name ) b->widget.update = container_update; b->widget.find_mouse_target = container_find_mouse_target; b->widget.get_desired_height = container_get_desired_height; + b->widget.set_state = container_set_state; return b; } diff --git a/source/widgets/listview.c b/source/widgets/listview.c index 81f34678..3ff797ea 100644 --- a/source/widgets/listview.c +++ b/source/widgets/listview.c @@ -141,8 +141,9 @@ const char *const listview_theme_prop_names[][3] = { { "normal.active", "selected.active", "alternate.active" }, }; -static void listview_set_style ( widget *w, TextBoxFontType tbft ) +static void listview_set_state ( _listview_row r, TextBoxFontType tbft ) { + widget *w = WIDGET(r.box); TextBoxFontType t = tbft & STATE_MASK; if ( w == NULL ) { return; @@ -164,6 +165,7 @@ static void listview_set_style ( widget *w, TextBoxFontType tbft ) break; } } + static void listview_create_row ( listview *lv, _listview_row *row ) { TextboxFlags flags = ( lv->multi_select ) ? TB_INDICATOR : 0; @@ -194,20 +196,6 @@ static void listview_create_row ( listview *lv, _listview_row *row ) g_list_free_full ( list, g_free ); } -static void listview_set_state ( _listview_row r, TextBoxFontType type ) -{ - listview_set_style ( WIDGET ( r.box ), type ); - if ( r.textbox ) { - listview_set_style ( WIDGET ( r.textbox ), type ); - } - if ( r.index ) { - listview_set_style ( WIDGET ( r.index ), type ); - } - if ( r.icon ) { - listview_set_style ( WIDGET ( r.icon ), type ); - } - widget_queue_redraw ( WIDGET ( r.box ) ); -} static int listview_get_desired_height ( widget *wid ); static void listview_free ( widget *wid ) diff --git a/source/widgets/widget.c b/source/widgets/widget.c index c0e89859..b35b60ab 100644 --- a/source/widgets/widget.c +++ b/source/widgets/widget.c @@ -62,8 +62,11 @@ void widget_set_state ( widget *widget, const char *state ) // Update border. widget->border = rofi_theme_get_padding ( widget, "border", widget->def_border ); widget->border_radius = rofi_theme_get_padding ( widget, "border-radius", widget->def_border_radius ); - + if ( widget->set_state ) { + widget->set_state ( widget, state ); + } widget_queue_redraw ( widget ); + } } |