summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-01-05 18:33:57 +0100
committerDave Davenport <qball@gmpclient.org>2017-01-05 18:33:57 +0100
commit3eb450c37eee98bab34c014899b81964b01caee4 (patch)
tree2688a209936bebb6d1e91fd6c2f63fe147d1962b /source
parente6a6d5f8947c1950be2a8354d27040e32f4d49de (diff)
Add generic container (renamed window widget) put container around message.
Diffstat (limited to 'source')
-rw-r--r--source/view.c14
-rw-r--r--source/widgets/container.c (renamed from source/widgets/window.c)70
2 files changed, 39 insertions, 45 deletions
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
index 7d63bed7..e1fabb46 100644
--- a/source/widgets/window.c
+++ b/source/widgets/container.c
@@ -28,34 +28,26 @@
#include <stdio.h>
#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)),