mirror of https://github.com/davatorium/rofi.git
Support linestyle on border
This commit is contained in:
parent
a77e080c60
commit
9dd3cb312e
|
@ -2,7 +2,12 @@
|
||||||
#define THEME_H
|
#define THEME_H
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
#include <widgets/widget.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SOLID,
|
||||||
|
DASH
|
||||||
|
} LineStyle;
|
||||||
/**
|
/**
|
||||||
* Distance unit type.
|
* Distance unit type.
|
||||||
*/
|
*/
|
||||||
|
@ -23,6 +28,8 @@ typedef struct {
|
||||||
double distance;
|
double distance;
|
||||||
/** Unit type of the distance */
|
/** Unit type of the distance */
|
||||||
PixelWidth type;
|
PixelWidth type;
|
||||||
|
/** Style of the line */
|
||||||
|
LineStyle style;
|
||||||
} Distance;
|
} Distance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,7 +157,7 @@ void rofi_theme_property_free ( Property *p );
|
||||||
void rofi_theme_free ( ThemeWidget *wid );
|
void rofi_theme_free ( ThemeWidget *wid );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param file filename to parse.
|
* @param file filename to parse.
|
||||||
*
|
*
|
||||||
* Parse the input theme file.
|
* Parse the input theme file.
|
||||||
*/
|
*/
|
||||||
|
@ -169,87 +176,87 @@ void rofi_theme_widget_add_properties ( ThemeWidget *widget, GHashTable *table )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name class
|
* @param widget The widget to query
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
* @param def The default value.
|
* @param def The default value.
|
||||||
*
|
*
|
||||||
* Obtain the distance of the widget.
|
* Obtain the distance of the widget.
|
||||||
*
|
*
|
||||||
* @returns The distance value of this property for this widget.
|
* @returns The distance value of this property for this widget.
|
||||||
*/
|
*/
|
||||||
Distance rofi_theme_get_distance ( const char *name, const char *state, const char *property, int def );
|
Distance rofi_theme_get_distance ( const widget *widget, const char *property, int def );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name class
|
* @param widget The widget to query
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
* @param def The default value.
|
* @param def The default value.
|
||||||
*
|
*
|
||||||
* Obtain the integer of the widget.
|
* Obtain the integer of the widget.
|
||||||
*
|
*
|
||||||
* @returns The integer value of this property for this widget.
|
* @returns The integer value of this property for this widget.
|
||||||
*/
|
*/
|
||||||
int rofi_theme_get_integer ( const char *name, const char *state, const char *property, int def );
|
int rofi_theme_get_integer ( const widget *widget, const char *property, int def );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name class
|
* @param widget The widget to query
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
* @param def The default value.
|
* @param def The default value.
|
||||||
*
|
*
|
||||||
* Obtain the boolean of the widget.
|
* Obtain the boolean of the widget.
|
||||||
*
|
*
|
||||||
* @returns The boolean value of this property for this widget.
|
* @returns The boolean value of this property for this widget.
|
||||||
*/
|
*/
|
||||||
int rofi_theme_get_boolean ( const char *name, const char *state, const char *property, int def );
|
int rofi_theme_get_boolean ( const widget *widget, const char *property, int def );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name class
|
* @param widget The widget to query
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
* @param def The default value.
|
* @param def The default value.
|
||||||
*
|
*
|
||||||
* Obtain the string of the widget.
|
* Obtain the string of the widget.
|
||||||
*
|
*
|
||||||
* @returns The string value of this property for this widget.
|
* @returns The string value of this property for this widget.
|
||||||
*/
|
*/
|
||||||
char *rofi_theme_get_string ( const char *name, const char *state, const char *property, char *def );
|
char *rofi_theme_get_string ( const widget *widget, const char *property, char *def );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name class
|
* @param widget The widget to query
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
* @param def The default value.
|
* @param def The default value.
|
||||||
*
|
*
|
||||||
* Obtain the padding of the widget.
|
* Obtain the padding of the widget.
|
||||||
*
|
*
|
||||||
* @returns The double value of this property for this widget.
|
* @returns The double value of this property for this widget.
|
||||||
*/
|
*/
|
||||||
double rofi_theme_get_double ( const char *name, const char *state, const char *property, double def );
|
double rofi_theme_get_double ( const widget *widget, const char *property, double def );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name class
|
* @param widget The widget to query
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
* @param d The drawable to apply color.
|
* @param d The drawable to apply color.
|
||||||
*
|
*
|
||||||
* Obtain the color of the widget and applies this to the drawable d.
|
* Obtain the color of the widget and applies this to the drawable d.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void rofi_theme_get_color ( const char *name, const char *state, const char *property, cairo_t *d);
|
void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t *d);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name class
|
* @param widget The widget to query
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
* @param pad The default value.
|
* @param pad The default value.
|
||||||
*
|
*
|
||||||
* Obtain the padding of the widget.
|
* Obtain the padding of the widget.
|
||||||
*
|
*
|
||||||
* @returns The padding of this property for this widget.
|
* @returns The padding of this property for this widget.
|
||||||
*/
|
*/
|
||||||
Padding rofi_theme_get_padding ( const char *name, const char *state, const char *property, Padding pad );
|
Padding rofi_theme_get_padding ( const widget *widget, const char *property, Padding pad );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param d The distance handle.
|
* @param d The distance handle.
|
||||||
|
@ -259,6 +266,13 @@ Padding rofi_theme_get_padding ( const char *name, const char *state, const cha
|
||||||
* @returns the number of pixels this distance represents.
|
* @returns the number of pixels this distance represents.
|
||||||
*/
|
*/
|
||||||
int distance_get_pixel ( Distance d, Orientation ori );
|
int distance_get_pixel ( Distance d, Orientation ori );
|
||||||
|
/**
|
||||||
|
* @param d The distance handle.
|
||||||
|
* @param draw The cairo drawable.
|
||||||
|
*
|
||||||
|
* Set linestyle.
|
||||||
|
*/
|
||||||
|
void distance_get_linestyle ( Distance d, cairo_t *draw );
|
||||||
|
|
||||||
#ifdef THEME_CONVERTER
|
#ifdef THEME_CONVERTER
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,6 +30,9 @@ EM (em)
|
||||||
PERCENT (\%)
|
PERCENT (\%)
|
||||||
NEWLINES (\r|\n)+
|
NEWLINES (\r|\n)+
|
||||||
|
|
||||||
|
LS_DASH "dash"
|
||||||
|
LS_SOLID "solid"
|
||||||
|
|
||||||
%x PROPERTIES
|
%x PROPERTIES
|
||||||
%x NAMESTR
|
%x NAMESTR
|
||||||
%x ENTRY
|
%x ENTRY
|
||||||
|
@ -110,16 +113,55 @@ if ( queue == NULL ){
|
||||||
<PROPERTIES>{REAL}{EM} {
|
<PROPERTIES>{REAL}{EM} {
|
||||||
yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL);
|
yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL);
|
||||||
yylval->distance.type = PW_EM;
|
yylval->distance.type = PW_EM;
|
||||||
|
yylval->distance.style = SOLID;
|
||||||
return T_PIXEL;
|
return T_PIXEL;
|
||||||
}
|
}
|
||||||
<PROPERTIES>{NUMBER}+{PX} {
|
<PROPERTIES>{NUMBER}+{PX} {
|
||||||
yylval->distance.distance = (double)g_ascii_strtoll(yytext, NULL, 10);
|
yylval->distance.distance = (double)g_ascii_strtoll(yytext, NULL, 10);
|
||||||
yylval->distance.type = PW_PX;
|
yylval->distance.type = PW_PX;
|
||||||
|
yylval->distance.style = SOLID;
|
||||||
|
return T_PIXEL;
|
||||||
|
}
|
||||||
|
<PROPERTIES>{NUMBER}+{PX}{WHITESPACE}{LS_DASH} {
|
||||||
|
yylval->distance.distance = (double)g_ascii_strtoll(yytext, NULL, 10);
|
||||||
|
yylval->distance.type = PW_PX;
|
||||||
|
yylval->distance.style = DASH;
|
||||||
|
return T_PIXEL;
|
||||||
|
}
|
||||||
|
<PROPERTIES>{NUMBER}+{EM}{WHITESPACE}{LS_DASH} {
|
||||||
|
yylval->distance.distance = (double)g_ascii_strtoll(yytext, NULL, 10);
|
||||||
|
yylval->distance.type = PW_PX;
|
||||||
|
yylval->distance.style = DASH;
|
||||||
|
return T_PIXEL;
|
||||||
|
}
|
||||||
|
<PROPERTIES>{NUMBER}+{PX}{WHITESPACE}{LS_SOLID} {
|
||||||
|
yylval->distance.distance = (double)g_ascii_strtoll(yytext, NULL, 10);
|
||||||
|
yylval->distance.type = PW_PX;
|
||||||
|
yylval->distance.style = SOLID;
|
||||||
|
return T_PIXEL;
|
||||||
|
}
|
||||||
|
<PROPERTIES>{NUMBER}+{EM}{WHITESPACE}{LS_SOLID} {
|
||||||
|
yylval->distance.distance = (double)g_ascii_strtoll(yytext, NULL, 10);
|
||||||
|
yylval->distance.type = PW_PX;
|
||||||
|
yylval->distance.style = SOLID;
|
||||||
return T_PIXEL;
|
return T_PIXEL;
|
||||||
}
|
}
|
||||||
<PROPERTIES>{REAL}{PERCENT} {
|
<PROPERTIES>{REAL}{PERCENT} {
|
||||||
yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL);
|
yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL);
|
||||||
yylval->distance.type = PW_PERCENT;
|
yylval->distance.type = PW_PERCENT;
|
||||||
|
yylval->distance.style = SOLID;
|
||||||
|
return T_PIXEL;
|
||||||
|
}
|
||||||
|
<PROPERTIES>{REAL}{PERCENT}{WHITESPACE}{LS_SOLID} {
|
||||||
|
yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL);
|
||||||
|
yylval->distance.type = PW_PERCENT;
|
||||||
|
yylval->distance.style = SOLID;
|
||||||
|
return T_PIXEL;
|
||||||
|
}
|
||||||
|
<PROPERTIES>{REAL}{PERCENT}{WHITESPACE}{LS_DASH} {
|
||||||
|
yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL);
|
||||||
|
yylval->distance.type = PW_PERCENT;
|
||||||
|
yylval->distance.style = DASH;
|
||||||
return T_PIXEL;
|
return T_PIXEL;
|
||||||
}
|
}
|
||||||
<PROPERTIES>#{HEX}{8} {
|
<PROPERTIES>#{HEX}{8} {
|
||||||
|
|
211
source/theme.c
211
source/theme.c
|
@ -287,67 +287,66 @@ static ThemeWidget *rofi_theme_find_widget ( const char *name, const char *state
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rofi_theme_get_integer ( const char *name, const char *state, const char *property, int def )
|
int rofi_theme_get_integer ( const widget *widget, const char *property, int def )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_INTEGER, property );
|
Property *p = rofi_theme_find_property ( wid, P_INTEGER, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
return p->value.i;
|
return p->value.i;
|
||||||
}
|
}
|
||||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", widget->name, widget->state?widget->state:"", property );
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
Distance rofi_theme_get_distance ( const char *name, const char *state, const char *property, int def )
|
Distance rofi_theme_get_distance ( const widget *widget, const char *property, int def )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_PADDING, property );
|
Property *p = rofi_theme_find_property ( wid, P_PADDING, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
return p->value.padding.left;
|
if ( p->type == P_INTEGER ){
|
||||||
|
return (Distance){p->value.i,PW_PX, SOLID};
|
||||||
|
} else {
|
||||||
|
return p->value.padding.left;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Fall back to px if no metric is given.
|
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", widget->name, widget->state?widget->state:"", property );
|
||||||
p = rofi_theme_find_property ( widget, P_INTEGER, property );
|
return (Distance){def, PW_PX, SOLID};
|
||||||
if ( p ){
|
|
||||||
return (Distance){(double)p->value.i, PW_PX};
|
|
||||||
}
|
|
||||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
|
||||||
return (Distance){def, PW_PX};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int rofi_theme_get_boolean ( const char *name, const char *state, const char *property, int def )
|
int rofi_theme_get_boolean ( const widget *widget, const char *property, int def )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_BOOLEAN, property );
|
Property *p = rofi_theme_find_property ( wid, P_BOOLEAN, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
return p->value.b;
|
return p->value.b;
|
||||||
}
|
}
|
||||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", widget->name, widget->state?widget->state:"", property );
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *rofi_theme_get_string ( const char *name, const char *state, const char *property, char *def )
|
char *rofi_theme_get_string ( const widget *widget, const char *property, char *def )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_STRING, property );
|
Property *p = rofi_theme_find_property ( wid, P_STRING, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
return p->value.s;
|
return p->value.s;
|
||||||
}
|
}
|
||||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", widget->name, widget->state?widget->state:"", property );
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
double rofi_theme_get_double ( const char *name, const char *state, const char *property, double def )
|
double rofi_theme_get_double ( const widget *widget, const char *property, double def )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_DOUBLE, property );
|
Property *p = rofi_theme_find_property ( wid, P_DOUBLE, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
return p->value.b;
|
return p->value.b;
|
||||||
}
|
}
|
||||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", widget->name, widget->state?widget->state:"", property );
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
void rofi_theme_get_color ( const char *name, const char *state, const char *property, cairo_t *d)
|
void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t *d)
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_COLOR, property );
|
Property *p = rofi_theme_find_property ( wid, P_COLOR, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
cairo_set_source_rgba ( d,
|
cairo_set_source_rgba ( d,
|
||||||
p->value.color.red,
|
p->value.color.red,
|
||||||
|
@ -356,22 +355,22 @@ void rofi_theme_get_color ( const char *name, const char *state, const char *pr
|
||||||
p->value.color.alpha
|
p->value.color.alpha
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", widget->name, widget->state?widget->state:"", property );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Padding rofi_theme_get_padding ( const char *name, const char *state, const char *property, Padding pad )
|
Padding rofi_theme_get_padding ( const widget *widget, const char *property, Padding pad )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_PADDING, property );
|
Property *p = rofi_theme_find_property ( wid, P_PADDING, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
if ( p->type == P_PADDING ){
|
if ( p->type == P_PADDING ){
|
||||||
pad = p->value.padding;
|
pad = p->value.padding;
|
||||||
} else {
|
} else {
|
||||||
Distance d = (Distance){p->value.i, PW_PX};
|
Distance d = (Distance){p->value.i, PW_PX, SOLID};
|
||||||
return (Padding){d,d,d,d};
|
return (Padding){d,d,d,d};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", widget->name, widget->state?widget->state:"", property );
|
||||||
return pad;
|
return pad;
|
||||||
}
|
}
|
||||||
int distance_get_pixel ( Distance d, Orientation ori )
|
int distance_get_pixel ( Distance d, Orientation ori )
|
||||||
|
@ -393,6 +392,14 @@ int distance_get_pixel ( Distance d, Orientation ori )
|
||||||
return d.distance;
|
return d.distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void distance_get_linestyle ( Distance d, cairo_t *draw )
|
||||||
|
{
|
||||||
|
if ( d.style == DASH ){
|
||||||
|
const double dashes[1] = { 4 };
|
||||||
|
cairo_set_dash ( draw, dashes, 1, 0.0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef THEME_CONVERTER
|
#ifdef THEME_CONVERTER
|
||||||
|
|
||||||
static Property* rofi_theme_convert_get_color ( const char *color, const char *name )
|
static Property* rofi_theme_convert_get_color ( const char *color, const char *name )
|
||||||
|
@ -422,6 +429,35 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
rofi_theme = (ThemeWidget*)g_malloc0 ( sizeof ( ThemeWidget ) );
|
rofi_theme = (ThemeWidget*)g_malloc0 ( sizeof ( ThemeWidget ) );
|
||||||
rofi_theme->name = g_strdup ( "Root" );
|
rofi_theme->name = g_strdup ( "Root" );
|
||||||
rofi_theme_convert_create_property_ht ( rofi_theme );
|
rofi_theme_convert_create_property_ht ( rofi_theme );
|
||||||
|
ThemeWidget *window_widget = rofi_theme_find_or_create_name ( rofi_theme , "window" );
|
||||||
|
rofi_theme_convert_create_property_ht ( window_widget );
|
||||||
|
ThemeWidget *mainbox_widget = rofi_theme_find_or_create_name ( window_widget, "mainbox" );
|
||||||
|
rofi_theme_convert_create_property_ht ( mainbox_widget );
|
||||||
|
ThemeWidget *message = rofi_theme_find_or_create_name ( mainbox_widget, "message" );
|
||||||
|
rofi_theme_convert_create_property_ht ( message );
|
||||||
|
ThemeWidget *listview_widget = rofi_theme_find_or_create_name ( mainbox_widget, "listview" );
|
||||||
|
rofi_theme_convert_create_property_ht ( listview_widget );
|
||||||
|
{
|
||||||
|
Property *p = rofi_theme_property_create ( P_INTEGER );
|
||||||
|
p->name = g_strdup ("border");
|
||||||
|
p->value.i = 0;
|
||||||
|
g_hash_table_replace ( mainbox_widget->properties, p->name, p);
|
||||||
|
|
||||||
|
p = rofi_theme_property_create ( P_INTEGER );
|
||||||
|
p->name = g_strdup ("padding");
|
||||||
|
p->value.i = config.padding;
|
||||||
|
g_hash_table_replace ( window_widget->properties, p->name, p);
|
||||||
|
|
||||||
|
p = rofi_theme_property_create ( P_INTEGER );
|
||||||
|
p->name = g_strdup ("padding");
|
||||||
|
p->value.i = 0;
|
||||||
|
g_hash_table_replace ( mainbox_widget->properties, p->name, p);
|
||||||
|
// Spacing
|
||||||
|
p = rofi_theme_property_create ( P_INTEGER );
|
||||||
|
p->name = g_strdup("spacing");
|
||||||
|
p->value.i = config.line_margin;
|
||||||
|
g_hash_table_replace ( rofi_theme->properties, p->name, p );
|
||||||
|
}
|
||||||
{
|
{
|
||||||
// Background
|
// Background
|
||||||
Property *p = rofi_theme_property_create ( P_COLOR );
|
Property *p = rofi_theme_property_create ( P_COLOR );
|
||||||
|
@ -431,33 +467,59 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
p->value.color.green= 0;
|
p->value.color.green= 0;
|
||||||
p->value.color.blue= 0;
|
p->value.color.blue= 0;
|
||||||
g_hash_table_replace ( rofi_theme->properties, p->name, p );
|
g_hash_table_replace ( rofi_theme->properties, p->name, p );
|
||||||
// Spacing
|
|
||||||
p = rofi_theme_property_create ( P_INTEGER );
|
|
||||||
p->name = g_strdup("spacing");
|
|
||||||
p->value.i = config.padding;
|
|
||||||
g_hash_table_replace ( rofi_theme->properties, p->name, p );
|
|
||||||
|
|
||||||
p = rofi_theme_property_create ( P_STRING );
|
ThemeWidget *inputbar_widget = rofi_theme_find_or_create_name ( mainbox_widget, "inputbar" );
|
||||||
p->name = g_strdup ( "line-style" );
|
|
||||||
p->value.s= g_strdup(config.separator_style);
|
|
||||||
g_hash_table_replace ( rofi_theme->properties, p->name, p );
|
|
||||||
|
|
||||||
ThemeWidget *inputbar_widget = rofi_theme_find_or_create_name ( rofi_theme , "inputbar" );
|
|
||||||
rofi_theme_convert_create_property_ht ( inputbar_widget );
|
rofi_theme_convert_create_property_ht ( inputbar_widget );
|
||||||
p = rofi_theme_property_create ( P_INTEGER );
|
p = rofi_theme_property_create ( P_INTEGER );
|
||||||
p->name = g_strdup("spacing");
|
p->name = g_strdup("spacing");
|
||||||
p->value.i = 0;
|
p->value.i = 0;
|
||||||
g_hash_table_replace ( inputbar_widget->properties, p->name, p );
|
g_hash_table_replace ( inputbar_widget->properties, p->name, p );
|
||||||
|
|
||||||
|
|
||||||
|
LineStyle style = (g_strcmp0(config.separator_style,"dash") == 0)?DASH:SOLID;
|
||||||
|
int place_end = ( config.location == WL_EAST_SOUTH || config.location == WL_SOUTH || config.location == WL_SOUTH_WEST );
|
||||||
|
p = rofi_theme_property_create ( P_PADDING );
|
||||||
|
p->name = g_strdup("border");
|
||||||
|
Distance d = (Distance){config.menu_bw, PW_PX, style};
|
||||||
|
if ( place_end ){
|
||||||
|
p->value.padding.bottom= d;
|
||||||
|
} else {
|
||||||
|
p->value.padding.top= d;
|
||||||
|
}
|
||||||
|
g_hash_table_replace ( listview_widget->properties, p->name, p );
|
||||||
|
|
||||||
|
p = rofi_theme_property_create ( P_PADDING );
|
||||||
|
p->name = g_strdup("border");
|
||||||
|
d = (Distance){config.menu_bw, PW_PX, style};
|
||||||
|
if ( place_end ){
|
||||||
|
p->value.padding.bottom= d;
|
||||||
|
} else {
|
||||||
|
p->value.padding.top= d;
|
||||||
|
}
|
||||||
|
g_hash_table_replace ( message->properties, p->name, p );
|
||||||
|
p = rofi_theme_property_create ( P_PADDING );
|
||||||
|
p->name = g_strdup("padding");
|
||||||
|
d = (Distance){config.line_margin, PW_PX, SOLID};
|
||||||
|
if ( place_end ){
|
||||||
|
p->value.padding.bottom= d;
|
||||||
|
} else {
|
||||||
|
p->value.padding.top= d;
|
||||||
|
}
|
||||||
|
g_hash_table_replace ( listview_widget->properties, p->name, p );
|
||||||
|
|
||||||
|
p = rofi_theme_property_create ( P_PADDING );
|
||||||
|
p->name = g_strdup("padding");
|
||||||
|
d = (Distance){config.line_margin, PW_PX, SOLID};
|
||||||
|
if ( place_end ){
|
||||||
|
p->value.padding.bottom= d;
|
||||||
|
} else {
|
||||||
|
p->value.padding.top= d;
|
||||||
|
}
|
||||||
|
g_hash_table_replace ( message->properties, p->name, p );
|
||||||
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Spacing
|
|
||||||
ThemeWidget *listview_widget = rofi_theme_find_or_create_name ( rofi_theme , "listview" );
|
|
||||||
rofi_theme_convert_create_property_ht ( listview_widget );
|
|
||||||
Property *p = rofi_theme_property_create ( P_INTEGER );
|
Property *p = rofi_theme_property_create ( P_INTEGER );
|
||||||
p->name = g_strdup("spacing");
|
|
||||||
p->value.i = config.padding;
|
|
||||||
g_hash_table_replace ( listview_widget->properties, p->name, p );
|
|
||||||
p = rofi_theme_property_create ( P_INTEGER );
|
|
||||||
p->name = g_strdup("columns");
|
p->name = g_strdup("columns");
|
||||||
p->value.i = config.menu_columns;
|
p->value.i = config.menu_columns;
|
||||||
g_hash_table_replace ( listview_widget->properties, p->name, p );
|
g_hash_table_replace ( listview_widget->properties, p->name, p );
|
||||||
|
@ -468,7 +530,6 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Border width.
|
// Border width.
|
||||||
ThemeWidget *window_widget = rofi_theme_find_or_create_name ( rofi_theme , "window" );
|
|
||||||
rofi_theme_convert_create_property_ht ( window_widget );
|
rofi_theme_convert_create_property_ht ( window_widget );
|
||||||
// Padding
|
// Padding
|
||||||
Property *p = rofi_theme_property_create ( P_INTEGER );
|
Property *p = rofi_theme_property_create ( P_INTEGER );
|
||||||
|
@ -485,24 +546,22 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
gchar **vals = g_strsplit ( config.color_window, ",", 3 );
|
gchar **vals = g_strsplit ( config.color_window, ",", 3 );
|
||||||
if ( vals != NULL ){
|
if ( vals != NULL ){
|
||||||
if ( vals[0] != NULL ) {
|
if ( vals[0] != NULL ) {
|
||||||
ThemeWidget *window = rofi_theme_find_or_create_name ( rofi_theme, "window" );
|
|
||||||
rofi_theme_convert_create_property_ht ( window );
|
|
||||||
Property *p = rofi_theme_convert_get_color ( vals[0], "background" );
|
Property *p = rofi_theme_convert_get_color ( vals[0], "background" );
|
||||||
g_hash_table_replace ( window->properties, p->name, p );
|
g_hash_table_replace ( window_widget->properties, p->name, p );
|
||||||
|
|
||||||
if ( vals[1] != NULL ) {
|
if ( vals[1] != NULL ) {
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
g_hash_table_replace ( window->properties, p->name, p );
|
g_hash_table_replace ( window_widget->properties, p->name, p );
|
||||||
|
|
||||||
ThemeWidget *inputbar = rofi_theme_find_or_create_name ( rofi_theme , "inputbar" );
|
ThemeWidget *inputbar = rofi_theme_find_or_create_name ( mainbox_widget, "inputbar" );
|
||||||
ThemeWidget *widget = rofi_theme_find_or_create_name ( inputbar, "separator" );
|
ThemeWidget *widget = rofi_theme_find_or_create_name ( inputbar, "box" );
|
||||||
rofi_theme_convert_create_property_ht ( widget );
|
rofi_theme_convert_create_property_ht ( widget );
|
||||||
if ( vals[2] != NULL ) {
|
if ( vals[2] != NULL ) {
|
||||||
p = rofi_theme_convert_get_color ( vals[2], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[2], "foreground" );
|
||||||
g_hash_table_replace ( widget->properties, p->name, p );
|
g_hash_table_replace ( window_widget->properties, p->name, p );
|
||||||
} else {
|
} else {
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
g_hash_table_replace ( widget->properties, p->name, p );
|
g_hash_table_replace ( window_widget->properties, p->name, p );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,13 +570,30 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
g_strfreev ( vals );
|
g_strfreev ( vals );
|
||||||
{
|
{
|
||||||
Property *p = NULL;
|
Property *p = NULL;
|
||||||
ThemeWidget *listview= rofi_theme_find_or_create_name ( rofi_theme , "listview" );
|
ThemeWidget *widget = rofi_theme_find_or_create_name ( listview_widget, "element" );
|
||||||
ThemeWidget *widget = rofi_theme_find_or_create_name ( listview , "element" );
|
ThemeWidget *scrollbar = rofi_theme_find_or_create_name ( listview_widget, "scrollbar" );
|
||||||
|
|
||||||
|
|
||||||
ThemeWidget *wnormal = rofi_theme_find_or_create_name ( widget, "normal" );
|
ThemeWidget *wnormal = rofi_theme_find_or_create_name ( widget, "normal" );
|
||||||
ThemeWidget *wselected = rofi_theme_find_or_create_name ( widget, "selected" );
|
ThemeWidget *wselected = rofi_theme_find_or_create_name ( widget, "selected" );
|
||||||
ThemeWidget *walternate = rofi_theme_find_or_create_name ( widget, "alternate" );
|
ThemeWidget *walternate = rofi_theme_find_or_create_name ( widget, "alternate" );
|
||||||
|
|
||||||
|
rofi_theme_convert_create_property_ht ( widget );
|
||||||
|
p = rofi_theme_property_create ( P_INTEGER );
|
||||||
|
p->name = g_strdup ("border");
|
||||||
|
p->value.i = 0;
|
||||||
|
g_hash_table_replace ( widget->properties, p->name, p);
|
||||||
|
|
||||||
|
rofi_theme_convert_create_property_ht ( scrollbar );
|
||||||
|
p = rofi_theme_property_create ( P_INTEGER );
|
||||||
|
p->name = g_strdup ("border");
|
||||||
|
p->value.i = 0;
|
||||||
|
g_hash_table_replace ( scrollbar->properties, p->name, p);
|
||||||
|
p = rofi_theme_property_create ( P_INTEGER );
|
||||||
|
p->name = g_strdup ("padding");
|
||||||
|
p->value.i = 0;
|
||||||
|
g_hash_table_replace ( scrollbar->properties, p->name, p);
|
||||||
|
|
||||||
|
|
||||||
gchar **vals = g_strsplit ( config.color_normal, ",", 5 );
|
gchar **vals = g_strsplit ( config.color_normal, ",", 5 );
|
||||||
if ( g_strv_length (vals) == 5 ) {
|
if ( g_strv_length (vals) == 5 ) {
|
||||||
|
@ -542,7 +618,7 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
g_hash_table_replace ( wal->properties, p->name, p );
|
g_hash_table_replace ( wal->properties, p->name, p );
|
||||||
|
|
||||||
ThemeWidget *inputbar = rofi_theme_find_or_create_name ( rofi_theme, "inputbar" );
|
ThemeWidget *inputbar = rofi_theme_find_or_create_name ( mainbox_widget, "inputbar" );
|
||||||
wnn = rofi_theme_find_or_create_name ( inputbar, "normal" );
|
wnn = rofi_theme_find_or_create_name ( inputbar, "normal" );
|
||||||
rofi_theme_convert_create_property_ht ( wnn );
|
rofi_theme_convert_create_property_ht ( wnn );
|
||||||
p = rofi_theme_convert_get_color ( vals[0], "background" );
|
p = rofi_theme_convert_get_color ( vals[0], "background" );
|
||||||
|
@ -550,7 +626,6 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
g_hash_table_replace ( wnn->properties, p->name, p );
|
g_hash_table_replace ( wnn->properties, p->name, p );
|
||||||
|
|
||||||
ThemeWidget *message = rofi_theme_find_or_create_name ( rofi_theme, "message" );
|
|
||||||
wnn = rofi_theme_find_or_create_name ( message, "normal" );
|
wnn = rofi_theme_find_or_create_name ( message, "normal" );
|
||||||
rofi_theme_convert_create_property_ht ( wnn );
|
rofi_theme_convert_create_property_ht ( wnn );
|
||||||
p = rofi_theme_convert_get_color ( vals[0], "background" );
|
p = rofi_theme_convert_get_color ( vals[0], "background" );
|
||||||
|
|
|
@ -612,7 +612,9 @@ void __create_window ( MenuFlags menu_flags )
|
||||||
pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, (double) config.dpi );
|
pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, (double) config.dpi );
|
||||||
}
|
}
|
||||||
// Setup font.
|
// Setup font.
|
||||||
char *font = rofi_theme_get_string ( "window", NULL, "font" , config.menu_font );
|
// Dummy widget.
|
||||||
|
window *win = window_create ( "window" );
|
||||||
|
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 );
|
||||||
pango_context_set_font_description ( p, pfd );
|
pango_context_set_font_description ( p, pfd );
|
||||||
|
@ -650,7 +652,7 @@ void __create_window ( MenuFlags menu_flags )
|
||||||
CacheState.flags = menu_flags;
|
CacheState.flags = menu_flags;
|
||||||
monitor_active ( &( CacheState.mon ) );
|
monitor_active ( &( CacheState.mon ) );
|
||||||
|
|
||||||
char *transparency = rofi_theme_get_string ( "window", NULL, "transparency", NULL);
|
char *transparency = rofi_theme_get_string ( WIDGET ( win ), "transparency", NULL);
|
||||||
if ( transparency == NULL && config.fake_transparency ){
|
if ( transparency == NULL && config.fake_transparency ){
|
||||||
transparency = config.fake_background;
|
transparency = config.fake_background;
|
||||||
}
|
}
|
||||||
|
@ -660,6 +662,7 @@ void __create_window ( MenuFlags menu_flags )
|
||||||
if ( xcb->sncontext != NULL ) {
|
if ( xcb->sncontext != NULL ) {
|
||||||
sn_launchee_context_setup_window ( xcb->sncontext, CacheState.main_window );
|
sn_launchee_context_setup_window ( xcb->sncontext, CacheState.main_window );
|
||||||
}
|
}
|
||||||
|
widget_free ( WIDGET ( win ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1450,24 +1453,21 @@ RofiViewState *rofi_view_create ( Mode *sw,
|
||||||
TICK_N ( "Get active monitor" );
|
TICK_N ( "Get active monitor" );
|
||||||
|
|
||||||
state->main_window = window_create ( "window" );
|
state->main_window = window_create ( "window" );
|
||||||
state->main_box = box_create ( "mainbox.box", BOX_VERTICAL );
|
state->main_box = box_create ( "window.mainbox.box", BOX_VERTICAL );
|
||||||
window_add ( state->main_window, WIDGET ( state->main_box ) );
|
window_add ( state->main_window, WIDGET ( state->main_box ) );
|
||||||
|
|
||||||
|
|
||||||
state->input_bar = box_create ( "inputbar.box", BOX_HORIZONTAL );
|
state->input_bar = box_create ( "window.mainbox.inputbar.box", BOX_HORIZONTAL );
|
||||||
state->input_bar_separator = separator_create ( "inputbar.separator", S_HORIZONTAL, 2 );
|
|
||||||
|
|
||||||
// Only enable widget when sidebar is enabled.
|
// Only enable widget when sidebar is enabled.
|
||||||
if ( config.sidebar_mode ) {
|
if ( config.sidebar_mode ) {
|
||||||
state->sidebar_bar = box_create ( "sidebar.box", BOX_HORIZONTAL );
|
state->sidebar_bar = box_create ( "window.mainbox.sidebar.box", BOX_HORIZONTAL );
|
||||||
separator *sep = separator_create ( "sidebar.separator", S_HORIZONTAL, 2 );
|
|
||||||
box_add ( state->main_box, WIDGET ( state->sidebar_bar ), FALSE, TRUE );
|
box_add ( state->main_box, WIDGET ( state->sidebar_bar ), FALSE, TRUE );
|
||||||
box_add ( state->main_box, WIDGET ( sep ), FALSE, TRUE );
|
|
||||||
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 ( "sidebar.button", TB_CENTER|TB_AUTOHEIGHT, ( mode == state->sw ) ? HIGHLIGHT : NORMAL,
|
state->modi[j] = textbox_create ( "window.mainbox.sidebar.button", TB_CENTER|TB_AUTOHEIGHT, ( mode == state->sw ) ? HIGHLIGHT : NORMAL,
|
||||||
mode_get_display_name ( mode ) );
|
mode_get_display_name ( mode ) );
|
||||||
box_add ( state->sidebar_bar, WIDGET ( state->modi[j] ), TRUE, FALSE );
|
box_add ( state->sidebar_bar, WIDGET ( state->modi[j] ), TRUE, FALSE );
|
||||||
widget_set_clicked_handler ( WIDGET ( state->modi[j] ), rofi_view_modi_clicked_cb, state );
|
widget_set_clicked_handler ( WIDGET ( state->modi[j] ), rofi_view_modi_clicked_cb, state );
|
||||||
|
@ -1477,35 +1477,32 @@ RofiViewState *rofi_view_create ( Mode *sw,
|
||||||
int end = ( config.location == WL_EAST_SOUTH || config.location == WL_SOUTH || config.location == WL_SOUTH_WEST );
|
int end = ( config.location == WL_EAST_SOUTH || config.location == WL_SOUTH || config.location == WL_SOUTH_WEST );
|
||||||
box_add ( state->main_box, WIDGET ( state->input_bar ), FALSE, end );
|
box_add ( state->main_box, WIDGET ( state->input_bar ), FALSE, end );
|
||||||
|
|
||||||
state->case_indicator = textbox_create ( "inputbar.case-indicator", TB_AUTOWIDTH|TB_AUTOHEIGHT, NORMAL, "*" );
|
state->case_indicator = textbox_create ( "window.mainbox.inputbar.case-indicator", TB_AUTOWIDTH|TB_AUTOHEIGHT, NORMAL, "*" );
|
||||||
// Add small separator between case indicator and text box.
|
// Add small separator between case indicator and text box.
|
||||||
box_add ( state->input_bar, WIDGET ( state->case_indicator ), FALSE, TRUE );
|
box_add ( state->input_bar, WIDGET ( state->case_indicator ), FALSE, TRUE );
|
||||||
|
|
||||||
// Prompt box.
|
// Prompt box.
|
||||||
state->prompt = textbox_create ( "inputbar.prompt",TB_AUTOWIDTH|TB_AUTOHEIGHT, NORMAL, "" );
|
state->prompt = textbox_create ( "window.mainbox.inputbar.prompt",TB_AUTOWIDTH|TB_AUTOHEIGHT, NORMAL, "" );
|
||||||
rofi_view_update_prompt ( state );
|
rofi_view_update_prompt ( state );
|
||||||
box_add ( state->input_bar, WIDGET ( state->prompt ), FALSE, FALSE );
|
box_add ( state->input_bar, WIDGET ( state->prompt ), FALSE, FALSE );
|
||||||
|
|
||||||
// Entry box
|
// Entry box
|
||||||
TextboxFlags tfl = TB_EDITABLE;
|
TextboxFlags tfl = TB_EDITABLE;
|
||||||
tfl |= ( ( menu_flags & MENU_PASSWORD ) == MENU_PASSWORD ) ? TB_PASSWORD : 0;
|
tfl |= ( ( menu_flags & MENU_PASSWORD ) == MENU_PASSWORD ) ? TB_PASSWORD : 0;
|
||||||
state->text = textbox_create ( "inputbar.entry", tfl|TB_AUTOHEIGHT, NORMAL, input );
|
state->text = textbox_create ( "window.mainbox.inputbar.entry", tfl|TB_AUTOHEIGHT, NORMAL, input );
|
||||||
|
|
||||||
box_add ( state->input_bar, WIDGET ( state->text ), TRUE, FALSE );
|
box_add ( state->input_bar, WIDGET ( state->text ), TRUE, FALSE );
|
||||||
|
|
||||||
textbox_text ( state->case_indicator, get_matching_state () );
|
textbox_text ( state->case_indicator, get_matching_state () );
|
||||||
if ( message ) {
|
if ( message ) {
|
||||||
textbox *message_tb = textbox_create ( "message.textbox", TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, message );
|
textbox *message_tb = textbox_create ( "window.mainbox.message.textbox", TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, message );
|
||||||
separator *sep = separator_create ( "message.separator", S_HORIZONTAL, 2 );
|
|
||||||
box_add ( state->main_box, WIDGET ( sep ), FALSE, end);
|
|
||||||
box_add ( state->main_box, WIDGET ( message_tb ), FALSE, end);
|
box_add ( state->main_box, WIDGET ( message_tb ), FALSE, end);
|
||||||
}
|
}
|
||||||
box_add ( state->main_box, WIDGET ( state->input_bar_separator ), FALSE, end );
|
|
||||||
|
|
||||||
state->overlay = textbox_create ( "overlay.textbox", TB_AUTOWIDTH|TB_AUTOHEIGHT, URGENT, "blaat" );
|
state->overlay = textbox_create ( "window.overlay", TB_AUTOWIDTH|TB_AUTOHEIGHT, URGENT, "blaat" );
|
||||||
widget_disable ( WIDGET ( state->overlay ) );
|
widget_disable ( WIDGET ( state->overlay ) );
|
||||||
|
|
||||||
state->list_view = listview_create ( "listview", update_callback, state, config.element_height, end );
|
state->list_view = listview_create ( "window.mainbox.listview", update_callback, state, config.element_height, end );
|
||||||
// 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 );
|
||||||
listview_set_scroll_type ( state->list_view, config.scroll_method );
|
listview_set_scroll_type ( state->list_view, config.scroll_method );
|
||||||
|
@ -1550,9 +1547,9 @@ int rofi_view_error_dialog ( const char *msg, int markup )
|
||||||
state->finalize = process_result;
|
state->finalize = process_result;
|
||||||
|
|
||||||
state->main_window = window_create ( "window" );
|
state->main_window = window_create ( "window" );
|
||||||
state->main_box = box_create ( "mainbox.box", BOX_VERTICAL);
|
state->main_box = box_create ( "window.mainbox", BOX_VERTICAL);
|
||||||
window_add ( state->main_window, WIDGET ( state->main_box ) );
|
window_add ( state->main_window, WIDGET ( state->main_box ) );
|
||||||
state->text = textbox_create ( "message", ( TB_AUTOHEIGHT | TB_WRAP ) + ( ( markup ) ? TB_MARKUP : 0 ),
|
state->text = textbox_create ( "window.mainbox.message", ( TB_AUTOHEIGHT | TB_WRAP ) + ( ( markup ) ? TB_MARKUP : 0 ),
|
||||||
NORMAL, ( msg != NULL ) ? msg : "" );
|
NORMAL, ( msg != NULL ) ? msg : "" );
|
||||||
box_add ( state->main_box, WIDGET ( state->text ), TRUE, FALSE );
|
box_add ( state->main_box, WIDGET ( state->text ), TRUE, FALSE );
|
||||||
|
|
||||||
|
|
|
@ -279,8 +279,8 @@ void box_add ( box *box, widget *child, gboolean expand, gboolean end )
|
||||||
height = MAX (height, child->h+widget_padding_get_padding_height ( WIDGET ( box )));
|
height = MAX (height, child->h+widget_padding_get_padding_height ( WIDGET ( box )));
|
||||||
box->widget.h = height;
|
box->widget.h = height;
|
||||||
}
|
}
|
||||||
child->expand = rofi_theme_get_boolean ( child->name, child->state, "expand", expand);
|
child->expand = rofi_theme_get_boolean ( child, "expand", expand);
|
||||||
child->end = rofi_theme_get_boolean ( child->name, child->state, "end", end);
|
child->end = rofi_theme_get_boolean ( child, "end", end);
|
||||||
child->parent = WIDGET ( box );
|
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 ) );
|
||||||
|
@ -346,7 +346,7 @@ box * box_create ( const char *name, boxType type )
|
||||||
b->widget.get_desired_height = box_get_desired_height;
|
b->widget.get_desired_height = box_get_desired_height;
|
||||||
b->widget.enabled = TRUE;
|
b->widget.enabled = TRUE;
|
||||||
|
|
||||||
b->spacing = rofi_theme_get_distance ( b->widget.name, NULL, "spacing",DEFAULT_SPACING );
|
b->spacing = rofi_theme_get_distance ( WIDGET(b), "spacing", DEFAULT_SPACING );
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -366,15 +366,14 @@ listview *listview_create ( const char *name, listview_update_callback cb, void
|
||||||
lv->udata = udata;
|
lv->udata = udata;
|
||||||
|
|
||||||
// Some settings.
|
// Some settings.
|
||||||
lv->spacing = rofi_theme_get_distance ( lv->widget.name, NULL, "spacing", DEFAULT_SPACING );
|
lv->spacing = rofi_theme_get_distance ( WIDGET ( lv ), "spacing", DEFAULT_SPACING );
|
||||||
lv->menu_columns = rofi_theme_get_integer ( lv->widget.name, NULL, "columns", config.menu_columns );
|
lv->menu_columns = rofi_theme_get_integer ( WIDGET ( lv ), "columns", config.menu_columns );
|
||||||
lv->fixed_num_lines = rofi_theme_get_boolean ( lv->widget.name, NULL, "fixed-height", config.fixed_num_lines );
|
lv->fixed_num_lines = rofi_theme_get_boolean ( WIDGET ( lv ), "fixed-height", config.fixed_num_lines );
|
||||||
lv->dynamic = rofi_theme_get_boolean ( lv->widget.name, NULL, "dynamic", TRUE );
|
lv->dynamic = rofi_theme_get_boolean ( WIDGET ( lv ), "dynamic", TRUE );
|
||||||
|
lv->reverse = rofi_theme_get_boolean ( WIDGET ( lv ), "reverse", reverse );
|
||||||
lv->reverse = rofi_theme_get_boolean ( lv->widget.name, NULL, "reverse", reverse );
|
listview_set_show_scrollbar ( lv, rofi_theme_get_boolean ( WIDGET ( lv ), "scrollbar", !config.hide_scrollbar ));
|
||||||
listview_set_show_scrollbar ( lv, rofi_theme_get_boolean ( lv->widget.name, NULL, "scrollbar", !config.hide_scrollbar ));
|
listview_set_scrollbar_width ( lv, rofi_theme_get_integer ( WIDGET ( lv ), "scrollbar-width", config.scrollbar_width ));
|
||||||
listview_set_scrollbar_width ( lv, rofi_theme_get_integer ( lv->widget.name, NULL, "scrollbar-width", config.scrollbar_width ));
|
lv->cycle = rofi_theme_get_boolean ( WIDGET ( lv ), "cycle", config.cycle );
|
||||||
lv->cycle = rofi_theme_get_boolean ( lv->widget.name, NULL, "cycle", config.cycle );
|
|
||||||
|
|
||||||
|
|
||||||
return lv;
|
return lv;
|
||||||
|
|
|
@ -45,6 +45,7 @@ scrollbar *scrollbar_create ( const char *name, int width )
|
||||||
{
|
{
|
||||||
scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
|
scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
|
||||||
widget_init ( WIDGET (sb), name );
|
widget_init ( WIDGET (sb), name );
|
||||||
|
sb->widget.state = g_strdup("handle");
|
||||||
sb->widget.x = 0;
|
sb->widget.x = 0;
|
||||||
sb->widget.y = 0;
|
sb->widget.y = 0;
|
||||||
sb->widget.w = widget_padding_get_padding_width ( WIDGET (sb) ) +width;
|
sb->widget.w = widget_padding_get_padding_width ( WIDGET (sb) ) +width;
|
||||||
|
@ -118,7 +119,7 @@ static void scrollbar_draw ( widget *wid, cairo_t *draw )
|
||||||
// Never go out of bar.
|
// Never go out of bar.
|
||||||
height = MAX ( 2, height );
|
height = MAX ( 2, height );
|
||||||
// Cap length;
|
// Cap length;
|
||||||
rofi_theme_get_color ( sb->widget.name, "handle", "foreground", draw );
|
rofi_theme_get_color ( WIDGET (sb ), "foreground", draw );
|
||||||
|
|
||||||
cairo_rectangle ( draw,
|
cairo_rectangle ( draw,
|
||||||
widget_padding_get_left ( wid ),
|
widget_padding_get_left ( wid ),
|
||||||
|
|
|
@ -98,7 +98,7 @@ separator *separator_create ( const char *name, separator_type type, short sw )
|
||||||
// Enabled by default
|
// Enabled by default
|
||||||
sb->widget.enabled = TRUE;
|
sb->widget.enabled = TRUE;
|
||||||
|
|
||||||
const char *line_style = rofi_theme_get_string ( sb->widget.name, NULL, "line-style", "solid");
|
const char *line_style = rofi_theme_get_string ( WIDGET (sb), "line-style", "solid");
|
||||||
separator_set_line_style_from_string ( sb, line_style );
|
separator_set_line_style_from_string ( sb, line_style );
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ static void separator_draw ( widget *wid, cairo_t *draw )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
color_separator ( draw );
|
color_separator ( draw );
|
||||||
rofi_theme_get_color ( wid->name, NULL, "foreground", draw );
|
rofi_theme_get_color ( wid, "foreground", draw );
|
||||||
if ( sep->line_style == S_LINE_DASH ) {
|
if ( sep->line_style == S_LINE_DASH ) {
|
||||||
const double dashes[1] = { 4 };
|
const double dashes[1] = { 4 };
|
||||||
cairo_set_dash ( draw, dashes, 1, 0.0 );
|
cairo_set_dash ( draw, dashes, 1, 0.0 );
|
||||||
|
|
|
@ -365,7 +365,7 @@ static void texbox_update ( textbox *tb )
|
||||||
//cairo_set_source_rgba ( tb->main_draw, 0,0,0,0.0);
|
//cairo_set_source_rgba ( tb->main_draw, 0,0,0,0.0);
|
||||||
//cairo_paint ( tb->main_draw );
|
//cairo_paint ( tb->main_draw );
|
||||||
|
|
||||||
rofi_theme_get_color ( tb->widget.name, tb->widget.state, "foreground", tb->main_draw);
|
rofi_theme_get_color ( WIDGET ( tb ), "foreground", tb->main_draw);
|
||||||
// draw the cursor
|
// draw the cursor
|
||||||
if ( tb->flags & TB_EDITABLE && tb->blink ) {
|
if ( tb->flags & TB_EDITABLE && tb->blink ) {
|
||||||
cairo_rectangle ( tb->main_draw, x + cursor_x, y+cursor_y, cursor_width, cursor_height);
|
cairo_rectangle ( tb->main_draw, x + cursor_x, y+cursor_y, cursor_width, cursor_height);
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
void widget_init ( widget *widget , const char *name )
|
void widget_init ( widget *widget , const char *name )
|
||||||
{
|
{
|
||||||
widget->name = g_strdup(name);
|
widget->name = g_strdup(name);
|
||||||
widget->padding = (Padding){ {0, PW_PX}, {0, PW_PX}, {0, PW_PX}, {0, PW_PX}};
|
widget->padding = (Padding){ {0, PW_PX, SOLID}, {0, PW_PX, SOLID}, {0, PW_PX, SOLID}, {0, PW_PX, SOLID}};
|
||||||
widget->padding = rofi_theme_get_padding ( widget->name, NULL, "padding", widget->padding);
|
widget->padding = rofi_theme_get_padding ( widget, "padding", widget->padding);
|
||||||
widget->border = (Padding){ {0, PW_PX}, {0, PW_PX}, {0, PW_PX}, {0, PW_PX}};
|
widget->border = (Padding){ {0, PW_PX, SOLID}, {0, PW_PX, SOLID}, {0, PW_PX, SOLID}, {0, PW_PX, SOLID}};
|
||||||
widget->border = rofi_theme_get_padding ( widget->name, NULL, "border", widget->border);
|
widget->border = rofi_theme_get_padding ( widget, "border", widget->border);
|
||||||
|
|
||||||
widget->margin = (Padding){ {0, PW_PX}, {0, PW_PX}, {0, PW_PX}, {0, PW_PX}};
|
widget->margin = (Padding){ {0, PW_PX, SOLID}, {0, PW_PX, SOLID}, {0, PW_PX, SOLID}, {0, PW_PX, SOLID}};
|
||||||
widget->margin = rofi_theme_get_padding ( widget->name, NULL, "margin", widget->margin);
|
widget->margin = rofi_theme_get_padding ( widget, "margin", widget->margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void widget_set_state ( widget *widget, const char *state )
|
void widget_set_state ( widget *widget, const char *state )
|
||||||
|
@ -107,7 +107,7 @@ void widget_draw ( widget *widget, cairo_t *d )
|
||||||
);
|
);
|
||||||
cairo_clip ( d );
|
cairo_clip ( d );
|
||||||
|
|
||||||
rofi_theme_get_color ( widget->name, widget->state, "background", d );
|
rofi_theme_get_color ( widget, "background", d );
|
||||||
cairo_paint( d ) ;
|
cairo_paint( d ) ;
|
||||||
|
|
||||||
// Set new x/y possition.
|
// Set new x/y possition.
|
||||||
|
@ -118,27 +118,31 @@ void widget_draw ( widget *widget, cairo_t *d )
|
||||||
int right = distance_get_pixel ( widget->border.right, ORIENTATION_VERTICAL );
|
int right = distance_get_pixel ( widget->border.right, ORIENTATION_VERTICAL );
|
||||||
int bottom = distance_get_pixel ( widget->border.bottom, ORIENTATION_VERTICAL );
|
int bottom = distance_get_pixel ( widget->border.bottom, ORIENTATION_VERTICAL );
|
||||||
if ( left || top || right || bottom ) {
|
if ( left || top || right || bottom ) {
|
||||||
rofi_theme_get_color ( widget->name, widget->state, "foreground", d );
|
rofi_theme_get_color ( widget, "foreground", d );
|
||||||
if ( left > 0 ) {
|
if ( left > 0 ) {
|
||||||
cairo_set_line_width ( d, left );
|
cairo_set_line_width ( d, left );
|
||||||
|
distance_get_linestyle ( widget->border.left, d);
|
||||||
cairo_move_to ( d, margin_left + left/2.0, margin_top );
|
cairo_move_to ( d, margin_left + left/2.0, margin_top );
|
||||||
cairo_line_to ( d, margin_left + left/2.0, widget->h-margin_bottom);
|
cairo_line_to ( d, margin_left + left/2.0, widget->h-margin_bottom);
|
||||||
cairo_stroke ( d );
|
cairo_stroke ( d );
|
||||||
}
|
}
|
||||||
if ( right > 0 ) {
|
if ( right > 0 ) {
|
||||||
cairo_set_line_width ( d, right );
|
cairo_set_line_width ( d, right );
|
||||||
|
distance_get_linestyle ( widget->border.right, d);
|
||||||
cairo_move_to ( d, widget->w - margin_right - right/2.0, 0 );
|
cairo_move_to ( d, widget->w - margin_right - right/2.0, 0 );
|
||||||
cairo_line_to ( d, widget->w - margin_right - right/2.0, widget->h-margin_bottom );
|
cairo_line_to ( d, widget->w - margin_right - right/2.0, widget->h-margin_bottom );
|
||||||
cairo_stroke ( d );
|
cairo_stroke ( d );
|
||||||
}
|
}
|
||||||
if ( top > 0 ) {
|
if ( top > 0 ) {
|
||||||
cairo_set_line_width ( d, top );
|
cairo_set_line_width ( d, top );
|
||||||
|
distance_get_linestyle ( widget->border.top, d);
|
||||||
cairo_move_to ( d, margin_left,margin_top+ top/2.0 );
|
cairo_move_to ( d, margin_left,margin_top+ top/2.0 );
|
||||||
cairo_line_to ( d, widget->w-margin_right, margin_top+top/2.0 );
|
cairo_line_to ( d, widget->w-margin_right, margin_top+top/2.0 );
|
||||||
cairo_stroke ( d );
|
cairo_stroke ( d );
|
||||||
}
|
}
|
||||||
if ( bottom > 0 ) {
|
if ( bottom > 0 ) {
|
||||||
cairo_set_line_width ( d, bottom );
|
cairo_set_line_width ( d, bottom );
|
||||||
|
distance_get_linestyle ( widget->border.bottom, d);
|
||||||
cairo_move_to ( d, margin_left, widget->h-bottom/2.0-margin_bottom);
|
cairo_move_to ( d, margin_left, widget->h-bottom/2.0-margin_bottom);
|
||||||
cairo_line_to ( d, widget->w-margin_right, widget->h-bottom/2.0-margin_bottom);
|
cairo_line_to ( d, widget->w-margin_right, widget->h-bottom/2.0-margin_bottom);
|
||||||
cairo_stroke ( d );
|
cairo_stroke ( d );
|
||||||
|
|
Loading…
Reference in New Issue