summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-09-07 13:46:09 +0200
committerDave Davenport <qball@gmpclient.org>2017-09-07 13:46:09 +0200
commitacfc07a63e056bff1338a3430acc3ea93bd9ecc6 (patch)
treecebdfb095949292decfa14644a0200c465df30f7 /source
parent72f050e2fc2f7fdc2565100b6e1c0ddc10910c53 (diff)
Fix Inherit keyword
Diffstat (limited to 'source')
-rw-r--r--source/view.c37
-rw-r--r--source/widgets/box.c6
-rw-r--r--source/widgets/container.c6
-rw-r--r--source/widgets/listview.c15
-rw-r--r--source/widgets/scrollbar.c4
-rw-r--r--source/widgets/textbox.c4
-rw-r--r--source/widgets/widget.c33
7 files changed, 50 insertions, 55 deletions
diff --git a/source/view.c b/source/view.c
index 73e3bd43..bf90ca6c 100644
--- a/source/view.c
+++ b/source/view.c
@@ -735,7 +735,7 @@ void __create_window ( MenuFlags menu_flags )
}
// Setup font.
// 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 );
if ( 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
*/
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 );
defaults = "inputbar,message,listview,sidebar";
}
@@ -1533,7 +1533,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
* INPUTBAR
*/
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";
box_add ( (box *) parent_widget, WIDGET ( wid ), FALSE );
}
@@ -1546,7 +1546,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
return;
}
// 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 );
box_add ( (box *) parent_widget, WIDGET ( state->prompt ), FALSE );
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." );
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.
box_add ( (box *) parent_widget, WIDGET ( state->case_indicator ), FALSE );
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
TextboxFlags tfl = TB_EDITABLE;
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 );
}
/**
@@ -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." );
return;
}
- state->mesg_box = container_create ( name );
- state->mesg_tb = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, "textbox", TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, NULL, 0, 0 );
+ state->mesg_box = container_create ( parent_widget, name );
+ 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 ) );
rofi_view_reload_message_bar ( state );
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." );
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 );
// Set configuration
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;
}
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 );
state->num_modi = rofi_get_num_enabled_modi ();
state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) );
for ( unsigned int j = 0; j < state->num_modi; 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 );
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 );
@@ -1634,11 +1634,11 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
}
}
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 );
}
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 );
//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.
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.
GList *list = rofi_theme_get_list ( WIDGET ( state->main_window ), "children", "mainbox" );
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 );
}
- state->overlay = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, "overlay", TB_AUTOWIDTH | TB_AUTOHEIGHT, URGENT, "blaat", 0.5, 0 );
- state->overlay->widget.parent = WIDGET ( state->main_window );
+ state->overlay = textbox_create ( WIDGET ( state->main_window), WIDGET_TYPE_TEXTBOX_TEXT, "overlay", TB_AUTOWIDTH | TB_AUTOHEIGHT, URGENT, "blaat", 0.5, 0 );
widget_disable ( WIDGET ( state->overlay ) );
// filtered list
@@ -1729,10 +1728,10 @@ int rofi_view_error_dialog ( const char *msg, int markup )
state->menu_flags = MENU_ERROR_DIALOG;
state->finalize = process_result;
- state->main_window = box_create ( "window", ROFI_ORIENTATION_VERTICAL );
- box *box = box_create ( "message", ROFI_ORIENTATION_VERTICAL );
+ state->main_window = box_create ( NULL, "window", ROFI_ORIENTATION_VERTICAL );
+ box *box = box_create ( WIDGET ( state->main_window ), "message", ROFI_ORIENTATION_VERTICAL );
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 );
box_add ( box, WIDGET ( state->text ), TRUE );
diff --git a/source/widgets/box.c b/source/widgets/box.c
index f2c8b92f..8ebd9257 100644
--- a/source/widgets/box.c
+++ b/source/widgets/box.c
@@ -289,7 +289,7 @@ void box_add ( box *box, widget *child, gboolean expand )
box->widget.h = height;
}
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 );
widget_update ( WIDGET ( box ) );
}
@@ -324,11 +324,11 @@ static widget *box_find_mouse_target ( widget *wid, WidgetType type, gint x, gin
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 ) );
// Initialize widget.
- widget_init ( WIDGET ( b ), WIDGET_TYPE_UNKNOWN, name );
+ widget_init ( WIDGET ( b ), parent, WIDGET_TYPE_UNKNOWN, name );
b->type = type;
b->widget.draw = box_draw;
b->widget.free = box_free;
diff --git a/source/widgets/container.c b/source/widgets/container.c
index 4ceaa694..9791dd21 100644
--- a/source/widgets/container.c
+++ b/source/widgets/container.c
@@ -74,7 +74,7 @@ void container_add ( container *container, widget *child )
return;
}
container->child = child;
- child->parent = WIDGET ( container );
+ g_assert ( child->parent == 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 );
}
-container * container_create ( const char *name )
+container * container_create ( widget *parent, const char *name )
{
container *b = g_malloc0 ( sizeof ( container ) );
// 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.free = container_free;
b->widget.resize = container_resize;
diff --git a/source/widgets/listview.c b/source/widgets/listview.c
index 5d1fd01a..40537af4 100644
--- a/source/widgets/listview.c
+++ b/source/widgets/listview.c
@@ -371,7 +371,7 @@ static void listview_recompute_elements ( listview *lv )
for ( unsigned int i = lv->cur_elements; i < newne; i++ ) {
TextboxFlags flags = ( lv->multi_select ) ? TB_INDICATOR : 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 );
}
}
@@ -511,12 +511,10 @@ static WidgetTriggerActionResult listview_element_trigger_action ( widget *wid,
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 ) );
- gchar *box = g_strjoin ( ".", name, "box", NULL );
- widget_init ( WIDGET ( lv ), WIDGET_TYPE_LISTVIEW, box );
- g_free ( box );
+ widget_init ( WIDGET ( lv ), parent, WIDGET_TYPE_LISTVIEW, name );
lv->listview_name = g_strdup ( name );
lv->widget.free = listview_free;
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->eh = eh;
- char *n = g_strjoin ( ".", lv->listview_name, "scrollbar", NULL );
- lv->scrollbar = scrollbar_create ( n );
- g_free ( n );
- lv->scrollbar->widget.parent = WIDGET ( lv );
+ lv->scrollbar = scrollbar_create ( WIDGET ( lv ) , "scrollbar" );
// 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 );
widget_free ( WIDGET ( tb ) );
diff --git a/source/widgets/scrollbar.c b/source/widgets/scrollbar.c
index 7149cc44..32f92716 100644
--- a/source/widgets/scrollbar.c
+++ b/source/widgets/scrollbar.c
@@ -98,10 +98,10 @@ static gboolean scrollbar_motion_notify ( widget *wid, G_GNUC_UNUSED gint x, gin
return TRUE;
}
-scrollbar *scrollbar_create ( const char *name )
+scrollbar *scrollbar_create ( widget *parent, const char *name )
{
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.y = 0;
sb->width = rofi_theme_get_distance ( WIDGET ( sb ), "handle-width", DEFAULT_SCROLLBAR_WIDTH );
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index 2df91c7f..0fed9d38 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -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 );
- widget_init ( WIDGET ( tb ), type, name );
+ widget_init ( WIDGET ( tb ), parent, type, name );
tb->widget.draw = textbox_draw;
tb->widget.free = textbox_free;
diff --git a/source/widgets/widget.c b/source/widgets/widget.c
index 7e951aad..774ab502 100644
--- a/source/widgets/widget.c
+++ b/source/widgets/widget.c
@@ -34,22 +34,23 @@
/** Default padding. */
#define WIDGET_DEFAULT_PADDING 0
-void widget_init ( widget *widget, WidgetType type, const char *name )
-{
- widget->type = type;
- widget->name = g_strdup ( name );
- 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 } };
- 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 } };
- 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 } };
- 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 } };
-
- widget->padding = rofi_theme_get_padding ( widget, "padding", widget->def_padding );
- 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_init ( widget *wid, widget *parent, WidgetType type, const char *name )
+{
+ wid->type = type;
+ wid->parent = parent;
+ wid->name = g_strdup ( name );
+ 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 } };
+ 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 } };
+ 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 } };
+
+ wid->padding = rofi_theme_get_padding ( wid, "padding", wid->def_padding );
+ wid->border = rofi_theme_get_padding ( wid, "border", wid->def_border );
+ wid->border_radius = rofi_theme_get_padding ( wid, "border-radius", wid->def_border_radius );
+ wid->margin = rofi_theme_get_padding ( wid, "margin", wid->def_margin );
+
+ // bled by default
+ wid->enabled = rofi_theme_get_boolean ( wid, "enabled", TRUE );
}
void widget_set_state ( widget *widget, const char *state )