mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[Widget] Propaget set_state to children.
This commit is contained in:
parent
0a33aadd8b
commit
f2b6cf6b3c
5 changed files with 25 additions and 16 deletions
|
@ -81,6 +81,8 @@ struct _widget
|
|||
int ( *get_desired_height )( struct _widget * );
|
||||
int ( *get_desired_width )( struct _widget * );
|
||||
|
||||
void ( *set_state ) ( struct _widget *, const char *);
|
||||
|
||||
/** widget find_mouse_target callback */
|
||||
widget_find_mouse_target_cb find_mouse_target;
|
||||
/** widget trigger_action callback */
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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 );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue