diff --git a/Makefile.am b/Makefile.am index 2c0f7752..10d406a0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,7 +38,7 @@ rofi_SOURCES=\ source/history.c\ source/theme.c\ source/widgets/box.c\ - source/widgets/window.c\ + source/widgets/container.c\ source/widgets/widget.c\ source/widgets/textbox.c\ source/widgets/listview.c\ @@ -70,7 +70,7 @@ rofi_SOURCES=\ include/history.h\ include/theme.h\ include/widgets/box.h\ - include/widgets/window.h\ + include/widgets/container.h\ include/widgets/widget.h\ include/widgets/widget-internal.h\ include/widgets/textbox.h\ diff --git a/doc/themer.md b/doc/themer.md index 74e8ff1e..276ad3eb 100644 --- a/doc/themer.md +++ b/doc/themer.md @@ -34,6 +34,7 @@ List of names in **rofi**: * `#window.mainbox.message` * `#window.mainbox.message.textbox`: The message textbox. * `#window.mainbox.message.separator`: The separator under/above the sidebar. + * `#window.mainbox.message.box`: The box containing the message. ## State diff --git a/include/view-internal.h b/include/view-internal.h index 96dffdb7..0b7e6e5b 100644 --- a/include/view-internal.h +++ b/include/view-internal.h @@ -1,6 +1,6 @@ #ifndef ROFI_VIEW_INTERNAL_H #define ROFI_VIEW_INTERNAL_H -#include "widgets/window.h" +#include "widgets/container.h" #include "widgets/widget.h" #include "widgets/textbox.h" #include "widgets/separator.h" @@ -24,8 +24,8 @@ struct RofiViewState /** Flag indicating if view needs to be refiltered. */ int refilter; - /** Widget representing the main window. */ - window *main_window; + /** Widget representing the main container. */ + container *main_window; /** Main #box widget holding different elements. */ box *main_box; /** #box widget packing the input bar widgets. */ diff --git a/include/widgets/container.h b/include/widgets/container.h new file mode 100644 index 00000000..6b417075 --- /dev/null +++ b/include/widgets/container.h @@ -0,0 +1,34 @@ +#ifndef ROFI_CONTAINER_H +#define ROFI_CONTAINER_H + +#include "widget.h" + +/** + * @defgroup container container + * @ingroup widget + * + * + * @{ + */ + +/** + * Abstract handle to the container widget internal state. + */ +typedef struct _window container; + +/** + * @param name The name of the widget. + * + * @returns a newly created container, free with #widget_free + */ +container * container_create ( const char *name ); + +/** + * @param container Handle to the container widget. + * @param child Handle to the child widget to pack. + * + * Add a widget to the container. + */ +void container_add ( container *container, widget *child ); +/*@}*/ +#endif // ROFI_CONTAINER_H diff --git a/include/widgets/window.h b/include/widgets/window.h deleted file mode 100644 index fe106ea8..00000000 --- a/include/widgets/window.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef ROFI_WINDOW_H -#define ROFI_WINDOW_H - -#include "widget.h" - -/** - * @defgroup window window - * @ingroup widget - * - * - * @{ - */ - -/** - * Abstract handle to the window widget internal state. - */ -typedef struct _window window; - -/** - * @param name The name of the widget. - * - * @returns a newly created window, free with #widget_free - */ -window * window_create ( const char *name ); - -/** - * @param window Handle to the window widget. - * @param child Handle to the child widget to pack. - * - * Add a widget to the window. - */ -void window_add ( window *window, widget *child ); -/*@}*/ -#endif // ROFI_WINDOW_H diff --git a/source/view.c b/source/view.c index 337ee5b0..a7ea0b7b 100644 --- a/source/view.c +++ b/source/view.c @@ -613,7 +613,7 @@ void __create_window ( MenuFlags menu_flags ) } // Setup font. // Dummy widget. - window *win = window_create ( "window" ); + container *win = container_create ( "window" ); char *font = rofi_theme_get_string ( WIDGET ( win ), "font" , config.menu_font ); if ( font ) { PangoFontDescription *pfd = pango_font_description_from_string ( font ); @@ -1452,9 +1452,9 @@ RofiViewState *rofi_view_create ( Mode *sw, // Get active monitor size. TICK_N ( "Get active monitor" ); - state->main_window = window_create ( "window" ); + state->main_window = container_create ( "window" ); state->main_box = box_create ( "window.mainbox.box", BOX_VERTICAL ); - window_add ( state->main_window, WIDGET ( state->main_box ) ); + container_add ( state->main_window, WIDGET ( state->main_box ) ); state->input_bar = box_create ( "window.mainbox.inputbar.box", BOX_HORIZONTAL ); @@ -1495,8 +1495,10 @@ RofiViewState *rofi_view_create ( Mode *sw, textbox_text ( state->case_indicator, get_matching_state () ); if ( message ) { + container *box = container_create ( "window.mainbox.message.box" ); textbox *message_tb = textbox_create ( "window.mainbox.message.textbox", TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, message ); - box_add ( state->main_box, WIDGET ( message_tb ), FALSE, end); + container_add ( box, WIDGET (message_tb) ); + box_add ( state->main_box, WIDGET ( box ), FALSE, end); } state->overlay = textbox_create ( "window.overlay", TB_AUTOWIDTH|TB_AUTOHEIGHT, URGENT, "blaat" ); @@ -1546,9 +1548,9 @@ int rofi_view_error_dialog ( const char *msg, int markup ) state->menu_flags = MENU_ERROR_DIALOG; state->finalize = process_result; - state->main_window = window_create ( "window" ); + state->main_window = container_create ( "window" ); state->main_box = box_create ( "window.mainbox", BOX_VERTICAL); - window_add ( state->main_window, WIDGET ( state->main_box ) ); + container_add ( state->main_window, WIDGET ( state->main_box ) ); state->text = textbox_create ( "window.mainbox.message", ( TB_AUTOHEIGHT | TB_WRAP ) + ( ( markup ) ? TB_MARKUP : 0 ), NORMAL, ( msg != NULL ) ? msg : "" ); box_add ( state->main_box, WIDGET ( state->text ), TRUE, FALSE ); diff --git a/source/widgets/window.c b/source/widgets/container.c similarity index 64% rename from source/widgets/window.c rename to source/widgets/container.c index 7d63bed7..e1fabb46 100644 --- a/source/widgets/window.c +++ b/source/widgets/container.c @@ -28,34 +28,26 @@ #include #include "widgets/widget.h" #include "widgets/widget-internal.h" -#include "widgets/window.h" +#include "widgets/container.h" #include "theme.h" #define LOG_DOMAIN "Widgets.Window" -/** The default border width of the window */ +/** The default border width of the container */ #define DEFAULT_BORDER_WIDTH 2 -/** - * @param window Handle to the window widget. - * @param spacing The spacing to apply. - * - * Set the spacing to apply between the children in pixels. - */ -void window_set_spacing ( window * window, unsigned int spacing ); - struct _window { widget widget; widget *child; }; -static void window_update ( widget *wid ); +static void container_update ( widget *wid ); -static int window_get_desired_height ( widget *widget ) +static int container_get_desired_height ( widget *widget ) { - window *b = (window *) widget; + container *b = (container *) widget; int height = 0; if ( b->child ) { height += widget_get_desired_height ( b->child ); @@ -65,34 +57,34 @@ static int window_get_desired_height ( widget *widget ) } -static void window_draw ( widget *wid, cairo_t *draw ) +static void container_draw ( widget *wid, cairo_t *draw ) { - window *b = (window *) wid; + container *b = (container *) wid; widget_draw ( b->child, draw ); } -static void window_free ( widget *wid ) +static void container_free ( widget *wid ) { - window *b = (window *) wid; + container *b = (container *) wid; widget_free ( b->child ); g_free ( b ); } -void window_add ( window *window, widget *child ) +void container_add ( container *container, widget *child ) { - if ( window == NULL ) { + if ( container == NULL ) { return; } - window->child = child; - child->parent = WIDGET ( window ); - widget_update ( WIDGET ( window ) ); + container->child = child; + child->parent = WIDGET ( container ); + widget_update ( WIDGET ( container ) ); } -static void window_resize ( widget *widget, short w, short h ) +static void container_resize ( widget *widget, short w, short h ) { - window *b = (window *) widget; + container *b = (container *) widget; if ( b->widget.w != w || b->widget.h != h ) { b->widget.w = w; b->widget.h = h; @@ -100,9 +92,9 @@ static void window_resize ( widget *widget, short w, short h ) } } -static gboolean window_clicked ( widget *wid, xcb_button_press_event_t *xbe, G_GNUC_UNUSED void *udata ) +static gboolean container_clicked ( widget *wid, xcb_button_press_event_t *xbe, G_GNUC_UNUSED void *udata ) { - window *b = (window *) wid; + container *b = (container *) wid; if ( widget_intersect ( b->child, xbe->event_x, xbe->event_y ) ) { xcb_button_press_event_t rel = *xbe; rel.event_x -= b->child->x; @@ -111,9 +103,9 @@ static gboolean window_clicked ( widget *wid, xcb_button_press_event_t *xbe, G_G } return FALSE; } -static gboolean window_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme ) +static gboolean container_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme ) { - window *b = (window *) wid; + container *b = (container *) wid; if ( widget_intersect ( b->child, xme->event_x, xme->event_y ) ) { xcb_motion_notify_event_t rel = *xme; rel.event_x -= b->child->x; @@ -123,25 +115,25 @@ static gboolean window_motion_notify ( widget *wid, xcb_motion_notify_event_t *x return FALSE; } -window * window_create ( const char *name ) +container * container_create ( const char *name ) { - window *b = g_malloc0 ( sizeof ( window ) ); + container *b = g_malloc0 ( sizeof ( container ) ); // Initialize widget. widget_init ( WIDGET(b), name ); - b->widget.draw = window_draw; - b->widget.free = window_free; - b->widget.resize = window_resize; - b->widget.update = window_update; - b->widget.clicked = window_clicked; - b->widget.motion_notify = window_motion_notify; - b->widget.get_desired_height = window_get_desired_height; + b->widget.draw = container_draw; + b->widget.free = container_free; + b->widget.resize = container_resize; + b->widget.update = container_update; + b->widget.clicked = container_clicked; + b->widget.motion_notify = container_motion_notify; + b->widget.get_desired_height = container_get_desired_height; b->widget.enabled = TRUE; return b; } -static void window_update ( widget *wid ) +static void container_update ( widget *wid ) { - window *b = (window *) wid; + container *b = (container *) wid; if ( b->child && b->child->enabled ){ widget_resize ( WIDGET ( b->child ), widget_padding_get_remaining_width (WIDGET(b)),