summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/widgets/box.h3
-rw-r--r--include/widgets/widget-internal.h2
-rw-r--r--source/view.c26
-rw-r--r--source/widgets/box.c12
-rw-r--r--source/widgets/listview.c6
-rw-r--r--test/box-test.c26
6 files changed, 31 insertions, 44 deletions
diff --git a/include/widgets/box.h b/include/widgets/box.h
index cffccd13..21724b1a 100644
--- a/include/widgets/box.h
+++ b/include/widgets/box.h
@@ -59,10 +59,9 @@ box * box_create ( const char *name, RofiOrientation type );
* @param box Handle to the box widget.
* @param child Handle to the child widget to pack.
* @param expand If the child widget should expand and use all available space.
- * @param index The position index.
*
* Add a widget to the box.
*/
-void box_add ( box *box, widget *child, gboolean expand, int index );
+void box_add ( box *box, widget *child, gboolean expand );
/*@}*/
#endif // ROFI_HBOX_H
diff --git a/include/widgets/widget-internal.h b/include/widgets/widget-internal.h
index 76273445..08c910af 100644
--- a/include/widgets/widget-internal.h
+++ b/include/widgets/widget-internal.h
@@ -58,8 +58,6 @@ struct _widget
gboolean enabled;
/** Expand the widget when packed */
gboolean expand;
- /*** The packing index */
- int index;
/** Place widget at end of parent */
gboolean end;
/** Parent widget */
diff --git a/source/view.c b/source/view.c
index 2b036481..ce0ac713 100644
--- a/source/view.c
+++ b/source/view.c
@@ -1498,7 +1498,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
*/
if ( strcmp ( name, "mainbox") == 0 ){
wid = (widget *)box_create ( strbox, ROFI_ORIENTATION_VERTICAL );
- box_add ( (box *)parent_widget, WIDGET ( wid ), TRUE, 0 );
+ box_add ( (box *)parent_widget, WIDGET ( wid ), TRUE );
defaults = "inputbar,message,listview";
}
/**
@@ -1508,7 +1508,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
wid = (widget *)box_create ( strbox, ROFI_ORIENTATION_HORIZONTAL );
defaults = "prompt,entry,case-indicator";
- box_add ( (box *)parent_widget, WIDGET ( wid ), FALSE, 0 );
+ box_add ( (box *)parent_widget, WIDGET ( wid ), FALSE );
}
/**
* PROMPT
@@ -1517,7 +1517,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
// Prompt box.
state->prompt = textbox_create ( str, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "" );
rofi_view_update_prompt ( state );
- box_add ( (box *)parent_widget, WIDGET ( state->prompt ), FALSE, 1 );
+ box_add ( (box *)parent_widget, WIDGET ( state->prompt ), FALSE );
defaults = NULL;
}
/**
@@ -1526,7 +1526,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
else if ( strcmp ( name, "case-indicator") == 0 ){
state->case_indicator = textbox_create ( str, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "*" );
// Add small separator between case indicator and text box.
- box_add ( (box *)parent_widget, WIDGET ( state->case_indicator ), FALSE, 3 );
+ box_add ( (box *)parent_widget, WIDGET ( state->case_indicator ), FALSE );
textbox_text ( state->case_indicator, get_matching_state () );
}
/**
@@ -1537,7 +1537,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
TextboxFlags tfl = TB_EDITABLE;
tfl |= ( ( state->menu_flags & MENU_PASSWORD ) == MENU_PASSWORD ) ? TB_PASSWORD : 0;
state->text = textbox_create ( str, tfl | TB_AUTOHEIGHT, NORMAL, NULL);
- box_add ( (box*)parent_widget, WIDGET ( state->text ), TRUE, 2 );
+ box_add ( (box*)parent_widget, WIDGET ( state->text ), TRUE );
}
/**
* MESSAGE
@@ -1548,7 +1548,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
state->mesg_tb = textbox_create ( strmsg, TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, NULL );
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, 2 );
+ box_add ( (box*)parent_widget, WIDGET ( state->mesg_box ), FALSE );
g_free(strmsg);
}
/**
@@ -1556,7 +1556,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
*/
else if ( strcmp ( name, "listview" ) == 0 ) {
state->list_view = listview_create ( str, update_callback, state, config.element_height, 0);
- box_add ( (box*)parent_widget, WIDGET ( state->list_view ), TRUE, 3 );
+ 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 );
listview_set_scroll_type ( state->list_view, config.scroll_method );
@@ -1572,7 +1572,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
else if ( strcmp( name, "sidebar" ) == 0 ) {
if ( config.sidebar_mode ){
state->sidebar_bar = box_create ( strbox, ROFI_ORIENTATION_HORIZONTAL );
- box_add ( (box*)parent_widget, WIDGET ( state->sidebar_bar ), FALSE, 10 );
+ 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 * ) );
char *strbutton= g_strjoin ( "." , str, "button",NULL );
@@ -1580,17 +1580,17 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
const Mode * mode = rofi_get_mode ( j );
state->modi[j] = textbox_create ( strbutton, TB_CENTER | TB_AUTOHEIGHT, ( mode == state->sw ) ? HIGHLIGHT : NORMAL,
mode_get_display_name ( mode ) );
- box_add ( state->sidebar_bar, WIDGET ( state->modi[j] ), TRUE, j );
+ box_add ( state->sidebar_bar, WIDGET ( state->modi[j] ), TRUE );
//widget_set_clicked_handler ( WIDGET ( state->modi[j] ), rofi_view_modi_clicked_cb, state );
}
g_free(strbutton);
}
} else if ( g_ascii_strncasecmp ( name, "textbox", 7) == 0 ){
textbox *t = textbox_create ( str, TB_WRAP, NORMAL, "");
- box_add ( (box *)parent_widget, WIDGET(t), TRUE, 0);
+ box_add ( (box *)parent_widget, WIDGET(t), TRUE);
} else {
wid = box_create ( strbox, ROFI_ORIENTATION_VERTICAL );
- box_add ( (box *)parent_widget, WIDGET ( wid ), TRUE, 0 );
+ box_add ( (box *)parent_widget, WIDGET ( wid ), TRUE );
//g_error("The widget %s does not exists. Invalid layout.", name);
}
if ( wid ) {
@@ -1685,10 +1685,10 @@ int rofi_view_error_dialog ( const char *msg, int markup )
state->main_window = box_create ( "window.box", ROFI_ORIENTATION_VERTICAL );
box *box = box_create ( "window.mainbox.message.box", ROFI_ORIENTATION_VERTICAL );
- box_add ( state->main_window, WIDGET ( box ), TRUE, 0 );
+ box_add ( state->main_window, WIDGET ( box ), TRUE );
state->text = textbox_create ( "window.mainbox.message.textbox", ( TB_AUTOHEIGHT | TB_WRAP ) + ( ( markup ) ? TB_MARKUP : 0 ),
NORMAL, ( msg != NULL ) ? msg : "" );
- box_add ( box, WIDGET ( state->text ), TRUE, 1 );
+ box_add ( box, WIDGET ( state->text ), TRUE );
// Make sure we enable fixed num lines when in normal window mode.
if ( ( CacheState.flags & MENU_NORMAL_WINDOW ) == MENU_NORMAL_WINDOW ) {
diff --git a/source/widgets/box.c b/source/widgets/box.c
index 6784f0ff..7986cdd3 100644
--- a/source/widgets/box.c
+++ b/source/widgets/box.c
@@ -273,15 +273,7 @@ static void box_free ( widget *wid )
g_free ( b );
}
-static int box_sort_children ( gconstpointer a, gconstpointer b )
-{
- widget *child_a = (widget *) a;
- widget *child_b = (widget *) b;
-
- return child_a->index - child_b->index;
-}
-
-void box_add ( box *box, widget *child, gboolean expand, int index )
+void box_add ( box *box, widget *child, gboolean expand )
{
if ( box == NULL ) {
return;
@@ -298,10 +290,8 @@ void box_add ( box *box, widget *child, gboolean expand, int index )
box->widget.h = height;
}
child->expand = rofi_theme_get_boolean ( child, "expand", expand );
- child->index = rofi_theme_get_integer_exact ( child, "index", index );
child->parent = WIDGET ( box );
box->children = g_list_append ( box->children, (void *) child );
- //box->children = g_list_sort ( box->children, box_sort_children );
widget_update ( WIDGET ( box ) );
}
diff --git a/source/widgets/listview.c b/source/widgets/listview.c
index 52585342..9a3f7e68 100644
--- a/source/widgets/listview.c
+++ b/source/widgets/listview.c
@@ -294,9 +294,11 @@ static void listview_draw ( widget *wid, cairo_t *draw )
int left_offset = widget_padding_get_left ( wid );
int top_offset = widget_padding_get_top ( wid );
+ /*
if ( lv->scrollbar->widget.index == 0 ) {
left_offset += spacing_hori + lv->scrollbar->widget.w;
}
+ */
if ( lv->cur_elements > 0 && lv->max_rows > 0 ) {
// Set new x/y possition.
unsigned int max = MIN ( lv->cur_elements, lv->req_elements - offset );
@@ -415,7 +417,7 @@ static void listview_resize ( widget *wid, short w, short h )
lv->max_rows = ( spacing_vert + height ) / ( lv->element_height + spacing_vert );
lv->max_elements = lv->max_rows * lv->menu_columns;
- if ( lv->scrollbar->widget.index == 0 ) {
+ if ( /*lv->scrollbar->widget.index ==*/ 0 ) {
widget_move ( WIDGET ( lv->scrollbar ),
widget_padding_get_left ( WIDGET ( lv ) ),
widget_padding_get_top ( WIDGET ( lv ) ) );
@@ -526,8 +528,6 @@ listview *listview_create ( const char *name, listview_update_callback cb, void
char *n = g_strjoin ( ".", lv->listview_name, "scrollbar", NULL );
lv->scrollbar = scrollbar_create ( n );
- // Default position on right.
- lv->scrollbar->widget.index = rofi_theme_get_integer_exact ( WIDGET ( lv->scrollbar ), "index", 1 );
g_free ( n );
lv->scrollbar->widget.parent = WIDGET ( lv );
// Calculate height of an element.
diff --git a/test/box-test.c b/test/box-test.c
index fd15eba8..e2fdb2d5 100644
--- a/test/box-test.c
+++ b/test/box-test.c
@@ -97,7 +97,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
widget_resize ( WIDGET (b), 100, 20);
widget *wid1 = g_malloc0(sizeof(widget));
- box_add ( b , WIDGET( wid1 ), TRUE, 0 );
+ box_add ( b , WIDGET( wid1 ), TRUE );
// Widget not enabled. no width allocated.
TASSERTE ( wid1->h, 0);
TASSERTE ( wid1->w, 0 );
@@ -108,7 +108,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
TASSERTE ( wid1->w, 100 );
widget *wid2 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid2 ) );
- box_add ( b , WIDGET( wid2 ), TRUE, 1 );
+ box_add ( b , WIDGET( wid2 ), TRUE );
TASSERTE ( wid1->h, 20);
TASSERTE ( wid1->w, 49);
TASSERTE ( wid2->h, 20);
@@ -116,7 +116,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
widget *wid3 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid3 ) );
- box_add ( b , WIDGET( wid3 ), FALSE, 2 );
+ box_add ( b , WIDGET( wid3 ), FALSE );
TASSERTE ( wid1->h, 20);
TASSERTE ( wid1->w, 48);
TASSERTE ( wid2->h, 20);
@@ -144,12 +144,12 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
widget *wid4 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid4 ) );
widget_resize ( WIDGET ( wid4 ), 20, 20 );
- box_add ( b , WIDGET( wid4 ), FALSE, 5 );
+ box_add ( b , WIDGET( wid4 ), FALSE );
TASSERTE ( wid4->x, 200-20);
widget *wid5 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid5 ) );
widget_resize ( WIDGET ( wid5 ), 20, 20 );
- box_add ( b , WIDGET( wid5 ), TRUE, 6 );
+ box_add ( b , WIDGET( wid5 ), TRUE );
TASSERTE ( wid5->x, 149);
widget_free ( WIDGET ( b ) );
}
@@ -159,7 +159,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
//box_set_padding ( b, 5 );
widget *wid1 = g_malloc0(sizeof(widget));
- box_add ( b , WIDGET( wid1 ), TRUE, 0 );
+ box_add ( b , WIDGET( wid1 ), TRUE );
// Widget not enabled. no width allocated.
TASSERTE ( wid1->h, 0);
TASSERTE ( wid1->w, 0 );
@@ -170,7 +170,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
TASSERTE ( wid1->w, 20 );
widget *wid2 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid2 ) );
- box_add ( b , WIDGET( wid2 ), TRUE, 1 );
+ box_add ( b , WIDGET( wid2 ), TRUE );
TASSERTE ( wid1->w, 20);
TASSERTE ( wid1->h, 49);
TASSERTE ( wid2->w, 20);
@@ -178,7 +178,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
widget *wid3 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid3 ) );
- box_add ( b , WIDGET( wid3 ), FALSE, 2 );
+ box_add ( b , WIDGET( wid3 ), FALSE );
TASSERTE ( wid1->w, 20);
TASSERTE ( wid1->h, 48);
TASSERTE ( wid2->w, 20);
@@ -205,12 +205,12 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
widget *wid4 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid4 ) );
widget_resize ( WIDGET ( wid4 ), 20, 20 );
- box_add ( b , WIDGET( wid4 ), FALSE, 5 );
+ box_add ( b , WIDGET( wid4 ), FALSE );
TASSERTE ( wid4->y, 180);
widget *wid5 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid5 ) );
widget_resize ( WIDGET ( wid5 ), 20, 20 );
- box_add ( b , WIDGET( wid5 ), TRUE, 6 );
+ box_add ( b , WIDGET( wid5 ), TRUE );
TASSERTE ( wid5->y, 149);
widget_free ( WIDGET ( b ) );
}
@@ -221,15 +221,15 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
widget *wid1 = g_malloc0(sizeof(widget));
wid1->type = 1;
widget_enable(wid1);
- box_add ( b , WIDGET( wid1 ), TRUE, 0 );
+ box_add ( b , WIDGET( wid1 ), TRUE );
widget *wid2 = g_malloc0(sizeof(widget));
wid2->type = 1;
widget_enable(wid2);
- box_add ( b , WIDGET( wid2 ), TRUE, 1 );
+ box_add ( b , WIDGET( wid2 ), TRUE );
widget *wid3 = g_malloc0(sizeof(widget));
wid3->type = 2;
widget_enable(wid3);
- box_add ( b , WIDGET( wid3 ), TRUE, 2 );
+ box_add ( b , WIDGET( wid3 ), TRUE );
gint x = 10;
gint y = 50;