Move enabled into widget.

This commit is contained in:
Dave Davenport 2017-09-07 08:52:30 +02:00
parent d4bf5ad020
commit 72f050e2fc
6 changed files with 29 additions and 26 deletions

View file

@ -337,7 +337,6 @@ box * box_create ( 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.enabled = rofi_theme_get_boolean ( WIDGET ( b ), "enabled", TRUE );
b->type = rofi_theme_get_orientation ( WIDGET ( b ), "orientation", b->type );

View file

@ -111,7 +111,6 @@ container * container_create ( 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.enabled = rofi_theme_get_boolean ( WIDGET ( b ), "enabled", TRUE );
return b;
}

View file

@ -524,7 +524,6 @@ listview *listview_create ( const char *name, listview_update_callback cb, void
lv->widget.find_mouse_target = listview_find_mouse_target;
lv->widget.trigger_action = listview_trigger_action;
lv->widget.get_desired_height = listview_get_desired_height;
lv->widget.enabled = rofi_theme_get_boolean ( WIDGET ( lv ), "enabled", TRUE );
lv->eh = eh;
char *n = g_strjoin ( ".", lv->listview_name, "scrollbar", NULL );

View file

@ -119,8 +119,6 @@ scrollbar *scrollbar_create ( const char *name )
sb->pos = 0;
sb->pos_length = 4;
// Enabled by default
sb->widget.enabled = rofi_theme_get_boolean ( WIDGET ( sb ), "enabled", TRUE );
return sb;
}

View file

@ -130,26 +130,8 @@ static WidgetTriggerActionResult textbox_editable_trigger_action ( widget *wid,
return WIDGET_TRIGGER_ACTION_RESULT_IGNORED;
}
textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign )
static void textbox_initialize_font ( textbox *tb )
{
textbox *tb = g_slice_new0 ( textbox );
widget_init ( WIDGET ( tb ), type, name );
tb->widget.draw = textbox_draw;
tb->widget.free = textbox_free;
tb->widget.resize = textbox_resize;
tb->widget.get_width = textbox_get_width;
tb->widget.get_height = _textbox_get_height;
tb->widget.get_desired_height = textbox_get_desired_height;
tb->widget.get_desired_width = textbox_get_desired_width;
tb->flags = flags;
tb->changed = FALSE;
tb->layout = pango_layout_new ( p_context );
textbox_font ( tb, tbft );
tb->metrics = p_metrics;
const char * font = rofi_theme_get_string ( WIDGET ( tb ), "font", NULL );
tb->left_offset = textbox_get_estimated_char_height ();
@ -178,6 +160,31 @@ textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags,
tb->left_offset = ( tbfc->height ) / (double) PANGO_SCALE;
}
}
}
textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign )
{
textbox *tb = g_slice_new0 ( textbox );
widget_init ( WIDGET ( tb ), type, name );
tb->widget.draw = textbox_draw;
tb->widget.free = textbox_free;
tb->widget.resize = textbox_resize;
tb->widget.get_width = textbox_get_width;
tb->widget.get_height = _textbox_get_height;
tb->widget.get_desired_height = textbox_get_desired_height;
tb->widget.get_desired_width = textbox_get_desired_width;
tb->flags = flags;
tb->changed = FALSE;
tb->layout = pango_layout_new ( p_context );
textbox_font ( tb, tbft );
textbox_initialize_font ( tb );
if ( ( tb->flags & TB_ICON ) != TB_ICON ) {
tb->left_offset = 0;
}
@ -204,8 +211,6 @@ textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags,
tb->yalign = MAX ( 0, MIN ( 1.0, tb->yalign ) );
tb->xalign = rofi_theme_get_double ( WIDGET ( tb ), "horizontal-align", yalign );
tb->xalign = MAX ( 0, MIN ( 1.0, tb->xalign ) );
// Enabled by default
tb->widget.enabled = rofi_theme_get_boolean ( WIDGET ( tb ), "enabled", TRUE );
return tb;
}

View file

@ -47,6 +47,9 @@ void widget_init ( widget *widget, WidgetType type, const char *name )
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 );
widget->margin = rofi_theme_get_padding ( widget, "margin", widget->def_margin );
// Enabled by default
widget->enabled = rofi_theme_get_boolean ( widget, "enabled", TRUE );
}
void widget_set_state ( widget *widget, const char *state )