mirror of https://github.com/davatorium/rofi.git
Fix Inherit keyword
This commit is contained in:
parent
72f050e2fc
commit
acfc07a63e
|
@ -53,7 +53,7 @@ typedef struct _box box;
|
||||||
*
|
*
|
||||||
* @returns a newly created box, free with #widget_free
|
* @returns a newly created box, free with #widget_free
|
||||||
*/
|
*/
|
||||||
box * box_create ( const char *name, RofiOrientation type );
|
box * box_create ( widget *parent, const char *name, RofiOrientation type );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param box Handle to the box widget.
|
* @param box Handle to the box widget.
|
||||||
|
|
|
@ -44,11 +44,12 @@
|
||||||
typedef struct _window container;
|
typedef struct _window container;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @parem parent The widget's parent
|
||||||
* @param name The name of the widget.
|
* @param name The name of the widget.
|
||||||
*
|
*
|
||||||
* @returns a newly created container, free with #widget_free
|
* @returns a newly created container, free with #widget_free
|
||||||
*/
|
*/
|
||||||
container * container_create ( const char *name );
|
container * container_create ( widget *parent, const char *name );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param container Handle to the container widget.
|
* @param container Handle to the container widget.
|
||||||
|
|
|
@ -77,7 +77,7 @@ typedef void ( *listview_mouse_activated_cb )( listview *, gboolean, void * );
|
||||||
*
|
*
|
||||||
* @returns a new listview
|
* @returns a new listview
|
||||||
*/
|
*/
|
||||||
listview *listview_create ( const char *name, listview_update_callback cb, void *udata, unsigned int eh, gboolean reverse );
|
listview *listview_create ( widget *parent, const char *name, listview_update_callback cb, void *udata, unsigned int eh, gboolean reverse );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param lv The listview handle
|
* @param lv The listview handle
|
||||||
|
|
|
@ -50,13 +50,14 @@ typedef struct _scrollbar
|
||||||
} scrollbar;
|
} scrollbar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @parem parent The parent widget.
|
||||||
* @param name The name of the widget.
|
* @param name The name of the widget.
|
||||||
*
|
*
|
||||||
* Create a new scrollbar
|
* Create a new scrollbar
|
||||||
*
|
*
|
||||||
* @returns the scrollbar object.
|
* @returns the scrollbar object.
|
||||||
*/
|
*/
|
||||||
scrollbar *scrollbar_create ( const char *name );
|
scrollbar *scrollbar_create ( widget *parent, const char *name );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param sb scrollbar object
|
* @param sb scrollbar object
|
||||||
|
|
|
@ -127,7 +127,7 @@ typedef enum
|
||||||
* free with #widget_free
|
* free with #widget_free
|
||||||
* @returns a new #textbox
|
* @returns a new #textbox
|
||||||
*/
|
*/
|
||||||
textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags,
|
textbox* textbox_create ( widget *parent, WidgetType type, const char *name, TextboxFlags flags,
|
||||||
TextBoxFontType tbft, const char *text, double xalign, double yalign );
|
TextBoxFontType tbft, const char *text, double xalign, double yalign );
|
||||||
/**
|
/**
|
||||||
* @param tb Handle to the textbox
|
* @param tb Handle to the textbox
|
||||||
|
|
|
@ -97,14 +97,15 @@ struct _widget
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param widget The widget to initialize.
|
* @param wid The widget to initialize.
|
||||||
|
* @param parent The widget's parent.
|
||||||
* @param type The type of the widget.
|
* @param type The type of the widget.
|
||||||
* @param name The name of the widget.
|
* @param name The name of the widget.
|
||||||
*
|
*
|
||||||
* Initializes the widget structure.
|
* Initializes the widget structure.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void widget_init ( widget *widget, WidgetType type, const char *name );
|
void widget_init ( widget *wid, widget *parent, WidgetType type, const char *name );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param widget The widget handle.
|
* @param widget The widget handle.
|
||||||
|
|
|
@ -735,7 +735,7 @@ void __create_window ( MenuFlags menu_flags )
|
||||||
}
|
}
|
||||||
// Setup font.
|
// Setup font.
|
||||||
// Dummy widget.
|
// Dummy widget.
|
||||||
box *win = box_create ( "window", ROFI_ORIENTATION_HORIZONTAL );
|
box *win = box_create ( NULL, "window", ROFI_ORIENTATION_HORIZONTAL );
|
||||||
const char *font = rofi_theme_get_string ( WIDGET ( win ), "font", config.menu_font );
|
const char *font = rofi_theme_get_string ( WIDGET ( win ), "font", config.menu_font );
|
||||||
if ( font ) {
|
if ( font ) {
|
||||||
PangoFontDescription *pfd = pango_font_description_from_string ( font );
|
PangoFontDescription *pfd = pango_font_description_from_string ( font );
|
||||||
|
@ -1525,7 +1525,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
|
||||||
* MAINBOX
|
* MAINBOX
|
||||||
*/
|
*/
|
||||||
if ( strcmp ( name, "mainbox" ) == 0 ) {
|
if ( strcmp ( name, "mainbox" ) == 0 ) {
|
||||||
wid = (widget *) box_create ( name, ROFI_ORIENTATION_VERTICAL );
|
wid = (widget *) box_create ( parent_widget, name, ROFI_ORIENTATION_VERTICAL );
|
||||||
box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE );
|
box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE );
|
||||||
defaults = "inputbar,message,listview,sidebar";
|
defaults = "inputbar,message,listview,sidebar";
|
||||||
}
|
}
|
||||||
|
@ -1533,7 +1533,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
|
||||||
* INPUTBAR
|
* INPUTBAR
|
||||||
*/
|
*/
|
||||||
else if ( strcmp ( name, "inputbar" ) == 0 ) {
|
else if ( strcmp ( name, "inputbar" ) == 0 ) {
|
||||||
wid = (widget *) box_create ( name, ROFI_ORIENTATION_HORIZONTAL );
|
wid = (widget *) box_create ( parent_widget, name, ROFI_ORIENTATION_HORIZONTAL );
|
||||||
defaults = "prompt,entry,case-indicator";
|
defaults = "prompt,entry,case-indicator";
|
||||||
box_add ( (box *) parent_widget, WIDGET ( wid ), FALSE );
|
box_add ( (box *) parent_widget, WIDGET ( wid ), FALSE );
|
||||||
}
|
}
|
||||||
|
@ -1546,7 +1546,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Prompt box.
|
// Prompt box.
|
||||||
state->prompt = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, name, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "", 0, 0 );
|
state->prompt = textbox_create ( parent_widget, WIDGET_TYPE_TEXTBOX_TEXT, name, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "", 0, 0 );
|
||||||
rofi_view_update_prompt ( state );
|
rofi_view_update_prompt ( state );
|
||||||
box_add ( (box *) parent_widget, WIDGET ( state->prompt ), FALSE );
|
box_add ( (box *) parent_widget, WIDGET ( state->prompt ), FALSE );
|
||||||
defaults = NULL;
|
defaults = NULL;
|
||||||
|
@ -1559,7 +1559,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
|
||||||
g_error ( "Case indicator widget can only be added once to the layout." );
|
g_error ( "Case indicator widget can only be added once to the layout." );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state->case_indicator = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, name, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "*", 0, 0 );
|
state->case_indicator = textbox_create ( parent_widget, WIDGET_TYPE_TEXTBOX_TEXT, name, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "*", 0, 0 );
|
||||||
// Add small separator between case indicator and text box.
|
// Add small separator between case indicator and text box.
|
||||||
box_add ( (box *) parent_widget, WIDGET ( state->case_indicator ), FALSE );
|
box_add ( (box *) parent_widget, WIDGET ( state->case_indicator ), FALSE );
|
||||||
textbox_text ( state->case_indicator, get_matching_state () );
|
textbox_text ( state->case_indicator, get_matching_state () );
|
||||||
|
@ -1575,7 +1575,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
|
||||||
// Entry box
|
// Entry box
|
||||||
TextboxFlags tfl = TB_EDITABLE;
|
TextboxFlags tfl = TB_EDITABLE;
|
||||||
tfl |= ( ( state->menu_flags & MENU_PASSWORD ) == MENU_PASSWORD ) ? TB_PASSWORD : 0;
|
tfl |= ( ( state->menu_flags & MENU_PASSWORD ) == MENU_PASSWORD ) ? TB_PASSWORD : 0;
|
||||||
state->text = textbox_create ( WIDGET_TYPE_EDITBOX, name, tfl | TB_AUTOHEIGHT, NORMAL, NULL, 0, 0 );
|
state->text = textbox_create ( parent_widget, WIDGET_TYPE_EDITBOX, name, tfl | TB_AUTOHEIGHT, NORMAL, NULL, 0, 0 );
|
||||||
box_add ( (box *) parent_widget, WIDGET ( state->text ), TRUE );
|
box_add ( (box *) parent_widget, WIDGET ( state->text ), TRUE );
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1586,8 +1586,8 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
|
||||||
g_error ( "Message widget can only be added once to the layout." );
|
g_error ( "Message widget can only be added once to the layout." );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state->mesg_box = container_create ( name );
|
state->mesg_box = container_create ( parent_widget, name );
|
||||||
state->mesg_tb = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, "textbox", TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, NULL, 0, 0 );
|
state->mesg_tb = textbox_create ( state->mesg_box, WIDGET_TYPE_TEXTBOX_TEXT, "textbox", TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, NULL, 0, 0 );
|
||||||
container_add ( state->mesg_box, WIDGET ( state->mesg_tb ) );
|
container_add ( state->mesg_box, WIDGET ( state->mesg_tb ) );
|
||||||
rofi_view_reload_message_bar ( state );
|
rofi_view_reload_message_bar ( state );
|
||||||
box_add ( (box *) parent_widget, WIDGET ( state->mesg_box ), FALSE );
|
box_add ( (box *) parent_widget, WIDGET ( state->mesg_box ), FALSE );
|
||||||
|
@ -1600,7 +1600,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
|
||||||
g_error ( "Listview widget can only be added once to the layout." );
|
g_error ( "Listview widget can only be added once to the layout." );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state->list_view = listview_create ( name, update_callback, state, config.element_height, 0 );
|
state->list_view = listview_create ( parent_widget, name, update_callback, state, config.element_height, 0 );
|
||||||
box_add ( (box *) parent_widget, WIDGET ( state->list_view ), TRUE );
|
box_add ( (box *) parent_widget, WIDGET ( state->list_view ), TRUE );
|
||||||
// Set configuration
|
// Set configuration
|
||||||
listview_set_multi_select ( state->list_view, ( state->menu_flags & MENU_INDICATOR ) == MENU_INDICATOR );
|
listview_set_multi_select ( state->list_view, ( state->menu_flags & MENU_INDICATOR ) == MENU_INDICATOR );
|
||||||
|
@ -1620,13 +1620,13 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( config.sidebar_mode ) {
|
if ( config.sidebar_mode ) {
|
||||||
state->sidebar_bar = box_create ( name,ROFI_ORIENTATION_HORIZONTAL );
|
state->sidebar_bar = box_create ( parent_widget, name,ROFI_ORIENTATION_HORIZONTAL );
|
||||||
box_add ( (box *) parent_widget, WIDGET ( state->sidebar_bar ), FALSE );
|
box_add ( (box *) parent_widget, WIDGET ( state->sidebar_bar ), FALSE );
|
||||||
state->num_modi = rofi_get_num_enabled_modi ();
|
state->num_modi = rofi_get_num_enabled_modi ();
|
||||||
state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) );
|
state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) );
|
||||||
for ( unsigned int j = 0; j < state->num_modi; j++ ) {
|
for ( unsigned int j = 0; j < state->num_modi; j++ ) {
|
||||||
const Mode * mode = rofi_get_mode ( j );
|
const Mode * mode = rofi_get_mode ( j );
|
||||||
state->modi[j] = textbox_create ( WIDGET_TYPE_SIDEBAR_MODI, "button", TB_AUTOHEIGHT, ( mode == state->sw ) ? HIGHLIGHT : NORMAL,
|
state->modi[j] = textbox_create ( WIDGET ( state->sidebar_bar ), WIDGET_TYPE_SIDEBAR_MODI, "button", TB_AUTOHEIGHT, ( mode == state->sw ) ? HIGHLIGHT : NORMAL,
|
||||||
mode_get_display_name ( mode ), 0.5, 0.5 );
|
mode_get_display_name ( mode ), 0.5, 0.5 );
|
||||||
box_add ( state->sidebar_bar, WIDGET ( state->modi[j] ), TRUE );
|
box_add ( state->sidebar_bar, WIDGET ( state->modi[j] ), TRUE );
|
||||||
widget_set_trigger_action_handler ( WIDGET ( state->modi[j] ), textbox_sidebar_modi_trigger_action, state );
|
widget_set_trigger_action_handler ( WIDGET ( state->modi[j] ), textbox_sidebar_modi_trigger_action, state );
|
||||||
|
@ -1634,11 +1634,11 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( g_ascii_strncasecmp ( name, "textbox", 7 ) == 0 ) {
|
else if ( g_ascii_strncasecmp ( name, "textbox", 7 ) == 0 ) {
|
||||||
textbox *t = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, name, TB_WRAP, NORMAL, "", 0, 0 );
|
textbox *t = textbox_create ( parent_widget, WIDGET_TYPE_TEXTBOX_TEXT, name, TB_WRAP, NORMAL, "", 0, 0 );
|
||||||
box_add ( (box *) parent_widget, WIDGET ( t ), TRUE );
|
box_add ( (box *) parent_widget, WIDGET ( t ), TRUE );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wid = (widget *) box_create ( name, ROFI_ORIENTATION_VERTICAL );
|
wid = (widget *) box_create ( parent_widget, name, ROFI_ORIENTATION_VERTICAL );
|
||||||
box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE );
|
box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE );
|
||||||
//g_error("The widget %s does not exists. Invalid layout.", name);
|
//g_error("The widget %s does not exists. Invalid layout.", name);
|
||||||
}
|
}
|
||||||
|
@ -1678,7 +1678,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
|
||||||
// Get active monitor size.
|
// Get active monitor size.
|
||||||
TICK_N ( "Get active monitor" );
|
TICK_N ( "Get active monitor" );
|
||||||
|
|
||||||
state->main_window = box_create ( "window", ROFI_ORIENTATION_VERTICAL );
|
state->main_window = box_create ( NULL, "window", ROFI_ORIENTATION_VERTICAL );
|
||||||
// Get children.
|
// Get children.
|
||||||
GList *list = rofi_theme_get_list ( WIDGET ( state->main_window ), "children", "mainbox" );
|
GList *list = rofi_theme_get_list ( WIDGET ( state->main_window ), "children", "mainbox" );
|
||||||
for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter ) ) {
|
for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter ) ) {
|
||||||
|
@ -1691,8 +1691,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
|
||||||
textbox_cursor_end ( state->text );
|
textbox_cursor_end ( state->text );
|
||||||
}
|
}
|
||||||
|
|
||||||
state->overlay = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, "overlay", TB_AUTOWIDTH | TB_AUTOHEIGHT, URGENT, "blaat", 0.5, 0 );
|
state->overlay = textbox_create ( WIDGET ( state->main_window), WIDGET_TYPE_TEXTBOX_TEXT, "overlay", TB_AUTOWIDTH | TB_AUTOHEIGHT, URGENT, "blaat", 0.5, 0 );
|
||||||
state->overlay->widget.parent = WIDGET ( state->main_window );
|
|
||||||
widget_disable ( WIDGET ( state->overlay ) );
|
widget_disable ( WIDGET ( state->overlay ) );
|
||||||
|
|
||||||
// filtered list
|
// filtered list
|
||||||
|
@ -1729,10 +1728,10 @@ int rofi_view_error_dialog ( const char *msg, int markup )
|
||||||
state->menu_flags = MENU_ERROR_DIALOG;
|
state->menu_flags = MENU_ERROR_DIALOG;
|
||||||
state->finalize = process_result;
|
state->finalize = process_result;
|
||||||
|
|
||||||
state->main_window = box_create ( "window", ROFI_ORIENTATION_VERTICAL );
|
state->main_window = box_create ( NULL, "window", ROFI_ORIENTATION_VERTICAL );
|
||||||
box *box = box_create ( "message", ROFI_ORIENTATION_VERTICAL );
|
box *box = box_create ( WIDGET ( state->main_window ), "message", ROFI_ORIENTATION_VERTICAL );
|
||||||
box_add ( state->main_window, WIDGET ( box ), TRUE );
|
box_add ( state->main_window, WIDGET ( box ), TRUE );
|
||||||
state->text = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, "textbox", ( TB_AUTOHEIGHT | TB_WRAP ) + ( ( markup ) ? TB_MARKUP : 0 ),
|
state->text = textbox_create ( WIDGET ( box ), WIDGET_TYPE_TEXTBOX_TEXT, "textbox", ( TB_AUTOHEIGHT | TB_WRAP ) + ( ( markup ) ? TB_MARKUP : 0 ),
|
||||||
NORMAL, ( msg != NULL ) ? msg : "", 0, 0 );
|
NORMAL, ( msg != NULL ) ? msg : "", 0, 0 );
|
||||||
box_add ( box, WIDGET ( state->text ), TRUE );
|
box_add ( box, WIDGET ( state->text ), TRUE );
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,7 @@ void box_add ( box *box, widget *child, gboolean expand )
|
||||||
box->widget.h = height;
|
box->widget.h = height;
|
||||||
}
|
}
|
||||||
child->expand = rofi_theme_get_boolean ( child, "expand", expand );
|
child->expand = rofi_theme_get_boolean ( child, "expand", expand );
|
||||||
child->parent = WIDGET ( box );
|
g_assert ( child->parent == WIDGET ( box ) );
|
||||||
box->children = g_list_append ( box->children, (void *) child );
|
box->children = g_list_append ( box->children, (void *) child );
|
||||||
widget_update ( WIDGET ( box ) );
|
widget_update ( WIDGET ( box ) );
|
||||||
}
|
}
|
||||||
|
@ -324,11 +324,11 @@ static widget *box_find_mouse_target ( widget *wid, WidgetType type, gint x, gin
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
box * box_create ( const char *name, RofiOrientation type )
|
box * box_create ( widget *parent, const char *name, RofiOrientation type )
|
||||||
{
|
{
|
||||||
box *b = g_malloc0 ( sizeof ( box ) );
|
box *b = g_malloc0 ( sizeof ( box ) );
|
||||||
// Initialize widget.
|
// Initialize widget.
|
||||||
widget_init ( WIDGET ( b ), WIDGET_TYPE_UNKNOWN, name );
|
widget_init ( WIDGET ( b ), parent, WIDGET_TYPE_UNKNOWN, name );
|
||||||
b->type = type;
|
b->type = type;
|
||||||
b->widget.draw = box_draw;
|
b->widget.draw = box_draw;
|
||||||
b->widget.free = box_free;
|
b->widget.free = box_free;
|
||||||
|
|
|
@ -74,7 +74,7 @@ void container_add ( container *container, widget *child )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container->child = child;
|
container->child = child;
|
||||||
child->parent = WIDGET ( container );
|
g_assert ( child->parent == WIDGET ( container ));
|
||||||
widget_update ( WIDGET ( container ) );
|
widget_update ( WIDGET ( container ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,11 +100,11 @@ static widget *container_find_mouse_target ( widget *wid, WidgetType type, gint
|
||||||
return widget_find_mouse_target ( b->child, type, x, y );
|
return widget_find_mouse_target ( b->child, type, x, y );
|
||||||
}
|
}
|
||||||
|
|
||||||
container * container_create ( const char *name )
|
container * container_create ( widget *parent, const char *name )
|
||||||
{
|
{
|
||||||
container *b = g_malloc0 ( sizeof ( container ) );
|
container *b = g_malloc0 ( sizeof ( container ) );
|
||||||
// Initialize widget.
|
// Initialize widget.
|
||||||
widget_init ( WIDGET ( b ), WIDGET_TYPE_UNKNOWN, name );
|
widget_init ( WIDGET ( b ), parent, WIDGET_TYPE_UNKNOWN, name );
|
||||||
b->widget.draw = container_draw;
|
b->widget.draw = container_draw;
|
||||||
b->widget.free = container_free;
|
b->widget.free = container_free;
|
||||||
b->widget.resize = container_resize;
|
b->widget.resize = container_resize;
|
||||||
|
|
|
@ -371,7 +371,7 @@ static void listview_recompute_elements ( listview *lv )
|
||||||
for ( unsigned int i = lv->cur_elements; i < newne; i++ ) {
|
for ( unsigned int i = lv->cur_elements; i < newne; i++ ) {
|
||||||
TextboxFlags flags = ( lv->multi_select ) ? TB_INDICATOR : 0;
|
TextboxFlags flags = ( lv->multi_select ) ? TB_INDICATOR : 0;
|
||||||
flags |= ( ( config.show_icons ) ? TB_ICON : 0 );
|
flags |= ( ( config.show_icons ) ? TB_ICON : 0 );
|
||||||
lv->boxes[i] = textbox_create ( WIDGET_TYPE_LISTVIEW_ELEMENT, "element", flags, NORMAL, "", 0, 0 );
|
lv->boxes[i] = textbox_create ( WIDGET (lv), WIDGET_TYPE_LISTVIEW_ELEMENT, "element", flags, NORMAL, "", 0, 0 );
|
||||||
widget_set_trigger_action_handler ( WIDGET ( lv->boxes[i] ), listview_element_trigger_action, lv );
|
widget_set_trigger_action_handler ( WIDGET ( lv->boxes[i] ), listview_element_trigger_action, lv );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -511,12 +511,10 @@ static WidgetTriggerActionResult listview_element_trigger_action ( widget *wid,
|
||||||
return WIDGET_TRIGGER_ACTION_RESULT_HANDLED;
|
return WIDGET_TRIGGER_ACTION_RESULT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
listview *listview_create ( const char *name, listview_update_callback cb, void *udata, unsigned int eh, gboolean reverse )
|
listview *listview_create ( widget *parent, const char *name, listview_update_callback cb, void *udata, unsigned int eh, gboolean reverse )
|
||||||
{
|
{
|
||||||
listview *lv = g_malloc0 ( sizeof ( listview ) );
|
listview *lv = g_malloc0 ( sizeof ( listview ) );
|
||||||
gchar *box = g_strjoin ( ".", name, "box", NULL );
|
widget_init ( WIDGET ( lv ), parent, WIDGET_TYPE_LISTVIEW, name );
|
||||||
widget_init ( WIDGET ( lv ), WIDGET_TYPE_LISTVIEW, box );
|
|
||||||
g_free ( box );
|
|
||||||
lv->listview_name = g_strdup ( name );
|
lv->listview_name = g_strdup ( name );
|
||||||
lv->widget.free = listview_free;
|
lv->widget.free = listview_free;
|
||||||
lv->widget.resize = listview_resize;
|
lv->widget.resize = listview_resize;
|
||||||
|
@ -526,13 +524,10 @@ listview *listview_create ( const char *name, listview_update_callback cb, void
|
||||||
lv->widget.get_desired_height = listview_get_desired_height;
|
lv->widget.get_desired_height = listview_get_desired_height;
|
||||||
lv->eh = eh;
|
lv->eh = eh;
|
||||||
|
|
||||||
char *n = g_strjoin ( ".", lv->listview_name, "scrollbar", NULL );
|
lv->scrollbar = scrollbar_create ( WIDGET ( lv ) , "scrollbar" );
|
||||||
lv->scrollbar = scrollbar_create ( n );
|
|
||||||
g_free ( n );
|
|
||||||
lv->scrollbar->widget.parent = WIDGET ( lv );
|
|
||||||
// Calculate height of an element.
|
// Calculate height of an element.
|
||||||
//
|
//
|
||||||
textbox *tb = textbox_create ( WIDGET_TYPE_LISTVIEW_ELEMENT, "element", 0, NORMAL, "", 0, 0 );
|
textbox *tb = textbox_create ( WIDGET (lv), WIDGET_TYPE_LISTVIEW_ELEMENT, "element", 0, NORMAL, "", 0, 0 );
|
||||||
lv->element_height = textbox_get_estimated_height ( tb, lv->eh );
|
lv->element_height = textbox_get_estimated_height ( tb, lv->eh );
|
||||||
widget_free ( WIDGET ( tb ) );
|
widget_free ( WIDGET ( tb ) );
|
||||||
|
|
||||||
|
|
|
@ -98,10 +98,10 @@ static gboolean scrollbar_motion_notify ( widget *wid, G_GNUC_UNUSED gint x, gin
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollbar *scrollbar_create ( const char *name )
|
scrollbar *scrollbar_create ( widget *parent, const char *name )
|
||||||
{
|
{
|
||||||
scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
|
scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
|
||||||
widget_init ( WIDGET ( sb ), WIDGET_TYPE_SCROLLBAR, name );
|
widget_init ( WIDGET ( sb ), parent, WIDGET_TYPE_SCROLLBAR, name );
|
||||||
sb->widget.x = 0;
|
sb->widget.x = 0;
|
||||||
sb->widget.y = 0;
|
sb->widget.y = 0;
|
||||||
sb->width = rofi_theme_get_distance ( WIDGET ( sb ), "handle-width", DEFAULT_SCROLLBAR_WIDTH );
|
sb->width = rofi_theme_get_distance ( WIDGET ( sb ), "handle-width", DEFAULT_SCROLLBAR_WIDTH );
|
||||||
|
|
|
@ -162,11 +162,11 @@ static void textbox_initialize_font ( textbox *tb )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign )
|
textbox* textbox_create ( widget *parent, WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign )
|
||||||
{
|
{
|
||||||
textbox *tb = g_slice_new0 ( textbox );
|
textbox *tb = g_slice_new0 ( textbox );
|
||||||
|
|
||||||
widget_init ( WIDGET ( tb ), type, name );
|
widget_init ( WIDGET ( tb ), parent, type, name );
|
||||||
|
|
||||||
tb->widget.draw = textbox_draw;
|
tb->widget.draw = textbox_draw;
|
||||||
tb->widget.free = textbox_free;
|
tb->widget.free = textbox_free;
|
||||||
|
|
|
@ -34,22 +34,23 @@
|
||||||
/** Default padding. */
|
/** Default padding. */
|
||||||
#define WIDGET_DEFAULT_PADDING 0
|
#define WIDGET_DEFAULT_PADDING 0
|
||||||
|
|
||||||
void widget_init ( widget *widget, WidgetType type, const char *name )
|
void widget_init ( widget *wid, widget *parent, WidgetType type, const char *name )
|
||||||
{
|
{
|
||||||
widget->type = type;
|
wid->type = type;
|
||||||
widget->name = g_strdup ( name );
|
wid->parent = parent;
|
||||||
widget->def_padding = (RofiPadding){ { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID } };
|
wid->name = g_strdup ( name );
|
||||||
widget->def_border = (RofiPadding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
|
wid->def_padding = (RofiPadding){ { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID } };
|
||||||
widget->def_border_radius = (RofiPadding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
|
wid->def_border = (RofiPadding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
|
||||||
widget->def_margin = (RofiPadding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
|
wid->def_border_radius = (RofiPadding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
|
||||||
|
wid->def_margin = (RofiPadding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
|
||||||
|
|
||||||
widget->padding = rofi_theme_get_padding ( widget, "padding", widget->def_padding );
|
wid->padding = rofi_theme_get_padding ( wid, "padding", wid->def_padding );
|
||||||
widget->border = rofi_theme_get_padding ( widget, "border", widget->def_border );
|
wid->border = rofi_theme_get_padding ( wid, "border", wid->def_border );
|
||||||
widget->border_radius = rofi_theme_get_padding ( widget, "border-radius", widget->def_border_radius );
|
wid->border_radius = rofi_theme_get_padding ( wid, "border-radius", wid->def_border_radius );
|
||||||
widget->margin = rofi_theme_get_padding ( widget, "margin", widget->def_margin );
|
wid->margin = rofi_theme_get_padding ( wid, "margin", wid->def_margin );
|
||||||
|
|
||||||
// Enabled by default
|
// bled by default
|
||||||
widget->enabled = rofi_theme_get_boolean ( widget, "enabled", TRUE );
|
wid->enabled = rofi_theme_get_boolean ( wid, "enabled", TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
void widget_set_state ( widget *widget, const char *state )
|
void widget_set_state ( widget *widget, const char *state )
|
||||||
|
|
|
@ -98,7 +98,7 @@ void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int
|
||||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
box *b = box_create ( "box", ROFI_ORIENTATION_HORIZONTAL );
|
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_HORIZONTAL );
|
||||||
//box_set_padding ( b, 5 );
|
//box_set_padding ( b, 5 );
|
||||||
widget_resize ( WIDGET (b), 100, 20);
|
widget_resize ( WIDGET (b), 100, 20);
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
widget_free ( WIDGET ( b ) );
|
widget_free ( WIDGET ( b ) );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
box *b = box_create ( "box", ROFI_ORIENTATION_VERTICAL );
|
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_VERTICAL );
|
||||||
widget_resize ( WIDGET (b), 20, 100);
|
widget_resize ( WIDGET (b), 20, 100);
|
||||||
//box_set_padding ( b, 5 );
|
//box_set_padding ( b, 5 );
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
widget_free ( WIDGET ( b ) );
|
widget_free ( WIDGET ( b ) );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
box *b = box_create ( "box", ROFI_ORIENTATION_VERTICAL );
|
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_VERTICAL );
|
||||||
widget_resize ( WIDGET (b), 20, 90);
|
widget_resize ( WIDGET (b), 20, 90);
|
||||||
//box_set_padding ( b, 5 );
|
//box_set_padding ( b, 5 );
|
||||||
widget *wid1 = g_malloc0(sizeof(widget));
|
widget *wid1 = g_malloc0(sizeof(widget));
|
||||||
|
|
|
@ -90,7 +90,7 @@ void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int
|
||||||
|
|
||||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
{
|
{
|
||||||
scrollbar * sb = scrollbar_create ( "scrollbar" );
|
scrollbar * sb = scrollbar_create ( NULL, "scrollbar" );
|
||||||
widget_resize ( WIDGET (sb), 10, 100);
|
widget_resize ( WIDGET (sb), 10, 100);
|
||||||
|
|
||||||
scrollbar_set_handle ( NULL, 10213);
|
scrollbar_set_handle ( NULL, 10213);
|
||||||
|
|
|
@ -93,7 +93,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
textbox_set_pango_context ( "default", p );
|
textbox_set_pango_context ( "default", p );
|
||||||
|
|
||||||
|
|
||||||
textbox *box = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, "textbox", TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "test",0,0 );
|
textbox *box = textbox_create ( NULL, WIDGET_TYPE_TEXTBOX_TEXT, "textbox", TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "test",0,0 );
|
||||||
TASSERT ( box != NULL );
|
TASSERT ( box != NULL );
|
||||||
|
|
||||||
textbox_keybinding ( box, MOVE_END );
|
textbox_keybinding ( box, MOVE_END );
|
||||||
|
|
Loading…
Reference in New Issue