Update comments, rename Widget to ThemeWidget.

This commit is contained in:
Dave Davenport 2017-01-01 18:08:49 +01:00
parent 62bfeafb1a
commit ccf3f23d9b
13 changed files with 370 additions and 67 deletions

View file

@ -2,27 +2,48 @@
#define THEME_H
#include <glib.h>
#include <cairo.h>
typedef enum {
PW_PX,
PW_EM,
/**
* Distance unit type.
*/
typedef enum {
/** PixelWidth in pixels. */
PW_PX,
/** PixelWidth in EM. */
PW_EM,
} PixelWidth;
/**
* Structure representing a distance.
*/
typedef struct {
/** Distance */
double distance;
/** Unit type of the distance */
PixelWidth type;
} Distance;
/**
* Type of property
*/
typedef enum {
/** Integer */
P_INTEGER,
/** Double */
P_DOUBLE,
/** String */
P_STRING,
/** Boolean */
P_BOOLEAN,
/** Color */
P_COLOR,
// Used in padding.
/** Padding */
P_PADDING,
} PropertyType;
/**
* Represent the color in theme.
*/
typedef struct
{
/** red channel */
@ -35,6 +56,9 @@ typedef struct
double alpha;
} ThemeColor;
/**
* Padding
*/
typedef struct
{
Distance top;
@ -55,45 +79,189 @@ typedef struct {
Padding padding;
} value;
} Property;
typedef struct _Widget {
/**
* ThemeWidget.
*/
typedef struct ThemeWidget {
int set;
char *name;
unsigned int num_widgets;
struct _Widget **widgets;
struct ThemeWidget **widgets;
GHashTable *properties;
struct _Widget *parent;
} Widget;
struct ThemeWidget *parent;
} ThemeWidget;
extern Widget *rofi_theme;
/**
* Global pointer to the current active theme.
*/
extern ThemeWidget *rofi_theme;
Widget *rofi_theme_find_or_create_class ( Widget *base, const char *class );
/**
* @param base Handle to the current level in the theme.
* @param class Name of the new element.
*
* Create a new element in the theme structure.
*
* @returns handle to the new entry.
*/
ThemeWidget *rofi_theme_find_or_create_class ( ThemeWidget *base, const char *class );
/**
* @param widget The widget handle.
*
* Print out the widget to the commandline.
*/
void rofi_theme_print ( ThemeWidget *widget );
void rofi_theme_print ( Widget *widget );
/**
* @param type The type of the property to create.
*
* Create a theme property of type.
*
* @returns a new property.
*/
Property *rofi_theme_property_create ( PropertyType type );
/**
* @param p The property to free.
*
* Free the content of the property.
*/
void rofi_theme_property_free ( Property *p );
void rofi_theme_free ( Widget * );
/**
* @param wid
*
* Free the widget and alll children.
*/
void rofi_theme_free ( ThemeWidget * );
/**
* @param file filename to parse.
*
* Parse the input theme file.
*/
void rofi_theme_parse_file ( const char *file );
void rofi_theme_widget_add_properties ( Widget *widget, GHashTable *table );
/**
* @param widget The widget handle.
* @param table HashTable containing properties set.
*
* Merge properties with widgets current property.
*/
void rofi_theme_widget_add_properties ( ThemeWidget *widget, GHashTable *table );
/**
* Public API
*/
/**
* @param wclass The widget class
* @param name The name class
* @param state The widget current state
* @param property The property to query.
* @param def The default value.
*
* Obtain the distance of the widget.
*
* @returns The distance value of this property for this widget.
*/
Distance rofi_theme_get_distance ( const char *wclass, const char *name, const char *state, const char *property, int def );
/**
* @param wclass The widget class
* @param name The name class
* @param state The widget current state
* @param property The property to query.
* @param def The default value.
*
* Obtain the integer of the widget.
*
* @returns The integer value of this property for this widget.
*/
int rofi_theme_get_integer ( const char *wclass, const char *name, const char *state, const char *property, int def );
/**
* @param wclass The widget class
* @param name The name class
* @param state The widget current state
* @param property The property to query.
* @param def The default value.
*
* Obtain the boolean of the widget.
*
* @returns The boolean value of this property for this widget.
*/
int rofi_theme_get_boolean ( const char *wclass, const char *name, const char *state, const char *property, int def );
/**
* @param wclass The widget class
* @param name The name class
* @param state The widget current state
* @param property The property to query.
* @param def The default value.
*
* Obtain the string of the widget.
*
* @returns The string value of this property for this widget.
*/
char *rofi_theme_get_string ( const char *wclass, const char *name, const char *state, const char *property, char *def );
/**
* @param wclass The widget class
* @param name The name class
* @param state The widget current state
* @param property The property to query.
* @param def The default value.
*
* Obtain the padding of the widget.
*
* @returns The double value of this property for this widget.
*/
double rofi_theme_get_double ( const char *wclass, const char *name, const char *state, const char *property, double def );
/**
* @param wclass The widget class
* @param name The name class
* @param state The widget current state
* @param property The property to query.
* @param def The default value.
*
* Obtain the color of the widget.
*
* @returns The color value of this property for this widget.
*/
void rofi_theme_get_color ( const char *wclass, const char *name, const char *state, const char *property, cairo_t *d);
/**
* @param wclass The widget class
* @param name The name class
* @param state The widget current state
* @param property The property to query.
* @param def The default value.
*
* Obtain the padding of the widget.
*
* @returns The padding of this property for this widget.
*/
Padding rofi_theme_get_padding ( const char *wclass, const char *name, const char *state, const char *property, Padding pad );
/**
* @param d The distance handle.
*
* Convert Distance into pixels.
* @returns the number of pixels this distance represents.
*/
int distance_get_pixel ( Distance d );
#ifdef THEME_CONVERTER
/**
* Function to convert old theme into new theme format.
*/
void rofi_theme_convert_old_theme ( void );
#endif
#endif

View file

@ -24,7 +24,7 @@ struct RofiViewState
/** Flag indicating if view needs to be refiltered. */
int refilter;
/** Widget representing the main window. */
window *main_window;
/** Main #box widget holding different elements. */
box *main_box;

View file

@ -63,6 +63,12 @@ void scrollbar_set_max_value ( scrollbar *sb, unsigned int max );
*/
unsigned int scrollbar_clicked ( const scrollbar *sb, int y );
/**
* @param sb scrollbar object
* @param width width of the scrollbar
*
* Set the width of the scrollbar handle.
*/
void scrollbar_set_width ( scrollbar *sb, int width );
/*@}*/
#endif // ROFI_SCROLLBAR_H

View file

@ -196,6 +196,12 @@ int textbox_get_font_width ( const textbox *tb );
* @returns the width of a character in pixels.
*/
double textbox_get_estimated_char_width ( void );
/**
* Estimate the height of a character.
*
* @returns the height of a character in pixels.
*/
double textbox_get_estimated_char_height ( void );
/**
@ -255,6 +261,5 @@ PangoAttrList *textbox_get_pango_attributes ( textbox *tb );
* @returns the visible text.
*/
const char *textbox_get_visible_text ( const textbox *tb );
int distance_get_pixel ( Distance d );
/*@}*/
#endif //ROFI_TEXTBOX_H

View file

@ -57,15 +57,90 @@ struct _widget
const char *state;
};
/**
* @param widget The widget to initialize.
* @param name The name of the widget.
* @param class The class of the widget.
*
* Initializes the @widget structure.
*
*/
void widget_init ( widget *widget , const char *name, const char *class_name );
/**
* @param widget The widget handle.
* @param state The state of the widget.
*
* Set the state of the widget.
*/
void widget_set_state ( widget *widget, const char *state );
/**
* @param wid The widget handle.
*
* Get the left padding of the widget.
*
* @returns the left padding in pixels.
*/
int widget_padding_get_left ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get the right padding of the widget.
*
* @returns the right padding in pixels.
*/
int widget_padding_get_right ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get the top padding of the widget.
*
* @returns the top padding in pixels.
*/
int widget_padding_get_top ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get the bottom padding of the widget.
*
* @returns the bottom padding in pixels.
*/
int widget_padding_get_bottom ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get width of the content of the widget
*
* @returns the widget width, excluding padding.
*/
int widget_padding_get_remaining_width ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get height of the content of the widget
*
* @returns the widget height, excluding padding.
*/
int widget_padding_get_remaining_height ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get the combined top and bottom padding.
*
* @returns the top and bottom padding of the widget in pixels.
*/
int widget_padding_get_padding_height ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get the combined left and right padding.
*
* @returns the left and right padding of the widget in pixels.
*/
int widget_padding_get_padding_width ( const widget *wid );
#endif // WIDGET_INTERNAL_H

View file

@ -175,7 +175,22 @@ void widget_set_clicked_handler ( widget *wid, widget_clicked_cb cb, void *udata
gboolean widget_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme );
/**
* @param wid The widget handle
* @param name The name of the widget.
*
* Set name on widget.
*/
void widget_set_name ( widget *wid, const char *name );
/**
* @param wid The widget handle
*
* Get the desired height of this widget recursively.
*
* @returns the desired height of the widget in pixels.
*/
int widget_get_desired_height ( widget *wid );
/*@}*/
#endif // ROFI_WIDGET_H

View file

@ -32,6 +32,13 @@ window * window_create ( const char *name );
*/
void window_add ( window *window, widget *child );
/**
* @param window Handle to the window widget.
*
* Get the border width of the widget.
*
* @returns the border width (times 2) of the widget.
*/
int window_get_border_width ( const window *window );
/*@}*/
#endif // ROFI_WINDOW_H

View file

@ -16,7 +16,7 @@
#include "theme.h"
#include "lexer/theme-parser.h"
Widget *rofi_theme = NULL;
ThemeWidget *rofi_theme = NULL;
void yyerror(YYLTYPE *yylloc, const char* s);
int yylex (YYSTYPE *, YYLTYPE *);
%}
@ -27,7 +27,7 @@ int yylex (YYSTYPE *, YYLTYPE *);
char *sval;
int bval;
ThemeColor colorval;
Widget *theme;
ThemeWidget *theme;
GList *name_path;
Property *property;
GHashTable *property_list;
@ -79,7 +79,7 @@ start:
entries:
%empty {
// There is always a base widget.
$$ = rofi_theme = (Widget*)g_malloc0 (sizeof(Widget));
$$ = rofi_theme = (ThemeWidget*)g_malloc0 (sizeof(ThemeWidget));
rofi_theme->name = g_strdup ( "Root" );
}
| entries
@ -94,7 +94,7 @@ entry:
CLASS_PREFIX class_name state_path BOPEN optional_properties BCLOSE
{
gchar *classn = g_strconcat ( "@", $2, NULL);
Widget *widget = rofi_theme_find_or_create_class ( rofi_theme , classn );
ThemeWidget *widget = rofi_theme_find_or_create_class ( rofi_theme , classn );
g_free(classn);
widget->set = TRUE;
for ( GList *iter = g_list_first ( $3 ); iter ; iter = g_list_next ( iter ) ) {
@ -107,7 +107,7 @@ CLASS_PREFIX class_name state_path BOPEN optional_properties BCLOSE
}
| NAME_PREFIX name_path state_path BOPEN optional_properties BCLOSE
{
Widget *widget = rofi_theme;
ThemeWidget *widget = rofi_theme;
for ( GList *iter = g_list_first ( $2 ); iter ; iter = g_list_next ( iter ) ) {
widget = rofi_theme_find_or_create_class ( widget, iter->data );
}

View file

@ -10,7 +10,7 @@
void yyerror ( YYLTYPE *ylloc, const char *);
Widget *rofi_theme_find_or_create_class ( Widget *base, const char *class )
ThemeWidget *rofi_theme_find_or_create_class ( ThemeWidget *base, const char *class )
{
for ( unsigned int i = 0; i < base->num_widgets;i++){
if ( g_strcmp0(base->widgets[i]->name, class) == 0 ){
@ -18,9 +18,9 @@ Widget *rofi_theme_find_or_create_class ( Widget *base, const char *class )
}
}
base->widgets = g_realloc ( base->widgets, sizeof(Widget*)*(base->num_widgets+1));
base->widgets[base->num_widgets] = g_malloc0(sizeof(Widget));
Widget *retv = base->widgets[base->num_widgets];
base->widgets = g_realloc ( base->widgets, sizeof(ThemeWidget*)*(base->num_widgets+1));
base->widgets[base->num_widgets] = g_malloc0(sizeof(ThemeWidget));
ThemeWidget *retv = base->widgets[base->num_widgets];
retv->parent = base;
retv->name = g_strdup(class);
base->num_widgets++;
@ -47,7 +47,7 @@ void rofi_theme_property_free ( Property *p )
g_free(p);
}
void rofi_theme_free ( Widget *widget )
void rofi_theme_free ( ThemeWidget *widget )
{
if ( widget == NULL ){
return;
@ -116,14 +116,14 @@ static void rofi_theme_print_property_index ( int depth, Property *p )
putchar ( '\n' );
}
static void rofi_theme_print_index ( Widget *widget )
static void rofi_theme_print_index ( ThemeWidget *widget )
{
GHashTableIter iter;
gpointer key, value;
if ( widget->properties ){
int index = 0;
GList *list = NULL;
Widget *w = widget;
ThemeWidget *w = widget;
while ( w){
if ( g_strcmp0(w->name,"Root") == 0 ) {
break;
@ -164,16 +164,32 @@ static void rofi_theme_print_index ( Widget *widget )
rofi_theme_print_index ( widget->widgets[i] );
}
}
void rofi_theme_print ( Widget *widget )
void rofi_theme_print ( ThemeWidget *widget )
{
rofi_theme_print_index ( widget );
}
/**
* Main lex parser.
*/
int yyparse();
void yylex_destroy( void );
extern FILE* yyin;
extern Widget *rofi_theme;
/**
* Destroy the internal of lex parser.
*/
void yylex_destroy( void );
/**
* Global handle input file to flex parser.
*/
extern FILE* yyin;
/**
* @param yylloc The file location.
* @param s Error message string.
*
* Error handler for the lex parser.
*/
void yyerror(YYLTYPE *yylloc, const char* s) {
fprintf(stderr, "Parse error: %s\n", s);
fprintf(stderr, "From line %d column %d to line %d column %d\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column);
@ -186,7 +202,7 @@ static gboolean rofi_theme_steal_property_int ( gpointer key, gpointer value, gp
g_hash_table_replace ( table, key, value);
return TRUE;
}
void rofi_theme_widget_add_properties ( Widget *widget, GHashTable *table )
void rofi_theme_widget_add_properties ( ThemeWidget *widget, GHashTable *table )
{
if ( table == NULL ) {
return;
@ -204,7 +220,7 @@ void rofi_theme_widget_add_properties ( Widget *widget, GHashTable *table )
* Public API
*/
static Widget *rofi_theme_find_single ( Widget *widget, const char *name)
static ThemeWidget *rofi_theme_find_single ( ThemeWidget *widget, const char *name)
{
for ( unsigned int j = 0; j < widget->num_widgets;j++){
if ( g_strcmp0(widget->widgets[j]->name, name ) == 0 ){
@ -214,7 +230,7 @@ static Widget *rofi_theme_find_single ( Widget *widget, const char *name)
return widget;
}
static Widget *rofi_theme_find ( Widget *widget , const char *name, const gboolean exact )
static ThemeWidget *rofi_theme_find ( ThemeWidget *widget , const char *name, const gboolean exact )
{
if ( widget == NULL || name == NULL ) {
return widget;
@ -223,7 +239,7 @@ static Widget *rofi_theme_find ( Widget *widget , const char *name, const gboole
int found = TRUE;
for ( unsigned int i = 0; found && names && names[i]; i++ ){
found = FALSE;
Widget *f = rofi_theme_find_single ( widget, names[i]);
ThemeWidget *f = rofi_theme_find_single ( widget, names[i]);
if ( f != widget ){
widget = f;
found = TRUE;
@ -237,7 +253,7 @@ static Widget *rofi_theme_find ( Widget *widget , const char *name, const gboole
}
}
static Property *rofi_theme_find_property ( Widget *widget, PropertyType type, const char *property )
static Property *rofi_theme_find_property ( ThemeWidget *widget, PropertyType type, const char *property )
{
while ( widget ) {
if ( widget->properties && g_hash_table_contains ( widget->properties, property) ) {
@ -250,10 +266,10 @@ static Property *rofi_theme_find_property ( Widget *widget, PropertyType type, c
}
return NULL;
}
static Widget *rofi_theme_find_widget ( const char *wclass, const char *name, const char *state )
static ThemeWidget *rofi_theme_find_widget ( const char *wclass, const char *name, const char *state )
{
// First find exact match based on name.
Widget *widget = rofi_theme_find ( rofi_theme, name, TRUE );
ThemeWidget *widget = rofi_theme_find ( rofi_theme, name, TRUE );
widget = rofi_theme_find ( widget, state, TRUE );
if ( widget == NULL ){
@ -274,7 +290,7 @@ static Widget *rofi_theme_find_widget ( const char *wclass, const char *name, co
int rofi_theme_get_integer ( const char *wclass, const char *name, const char *state, const char *property, int def )
{
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_INTEGER, property );
if ( p ){
return p->value.i;
@ -283,7 +299,7 @@ int rofi_theme_get_integer ( const char *wclass, const char *name, const char *
}
Distance rofi_theme_get_distance ( const char *wclass, const char *name, const char *state, const char *property, int def )
{
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_PADDING, property );
if ( p ){
return p->value.padding.left;
@ -298,7 +314,7 @@ Distance rofi_theme_get_distance ( const char *wclass, const char *name, const
int rofi_theme_get_boolean ( const char *wclass, const char *name, const char *state, const char *property, int def )
{
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_BOOLEAN, property );
if ( p ){
return p->value.b;
@ -308,7 +324,7 @@ int rofi_theme_get_boolean ( const char *wclass, const char *name, const char *
char *rofi_theme_get_string ( const char *wclass, const char *name, const char *state, const char *property, char *def )
{
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_STRING, property );
if ( p ){
return p->value.s;
@ -317,7 +333,7 @@ char *rofi_theme_get_string ( const char *wclass, const char *name, const char
}
double rofi_theme_get_double ( const char *wclass, const char *name, const char *state, const char *property, double def )
{
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_DOUBLE, property );
if ( p ){
return p->value.b;
@ -326,7 +342,7 @@ double rofi_theme_get_double ( const char *wclass, const char *name, const char
}
void rofi_theme_get_color ( const char *wclass, const char *name, const char *state, const char *property, cairo_t *d)
{
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_COLOR, property );
if ( p ){
cairo_set_source_rgba ( d,
@ -340,7 +356,7 @@ void rofi_theme_get_color ( const char *wclass, const char *name, const char *s
}
Padding rofi_theme_get_padding ( const char *wclass, const char *name, const char *state, const char *property, Padding pad )
{
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_PADDING, property );
if ( p ){
pad = p->value.padding;
@ -385,12 +401,12 @@ void rofi_theme_convert_old_theme ( void )
if ( rofi_theme != NULL ){
return;
}
rofi_theme = (Widget*)g_malloc0 ( sizeof ( Widget ) );
rofi_theme = (ThemeWidget*)g_malloc0 ( sizeof ( ThemeWidget ) );
rofi_theme->name = g_strdup ( "Root" );
rofi_theme->properties = rofi_theme_convert_create_property_ht ( );
{
// Spacing
Widget *box_widget = rofi_theme_find_or_create_class ( rofi_theme , "@box" );
ThemeWidget *box_widget = rofi_theme_find_or_create_class ( rofi_theme , "@box" );
box_widget->properties = rofi_theme_convert_create_property_ht ( );
Property *p = rofi_theme_property_create ( P_INTEGER );
p->name = g_strdup("spacing");
@ -399,7 +415,7 @@ void rofi_theme_convert_old_theme ( void )
}
{
// Spacing
Widget *listview_widget = rofi_theme_find_or_create_class ( rofi_theme , "@listview" );
ThemeWidget *listview_widget = rofi_theme_find_or_create_class ( rofi_theme , "@listview" );
listview_widget->properties = rofi_theme_convert_create_property_ht ( );
Property *p = rofi_theme_property_create ( P_INTEGER );
p->name = g_strdup("spacing");
@ -408,7 +424,7 @@ void rofi_theme_convert_old_theme ( void )
}
{
// Border width.
Widget *window_widget = rofi_theme_find_or_create_class ( rofi_theme , "@window" );
ThemeWidget *window_widget = rofi_theme_find_or_create_class ( rofi_theme , "@window" );
window_widget->properties = rofi_theme_convert_create_property_ht ( );
Property *p = rofi_theme_property_create ( P_INTEGER );
p->name = g_strdup("border-width");
@ -432,7 +448,7 @@ void rofi_theme_convert_old_theme ( void )
g_hash_table_replace ( rofi_theme->properties, p->name, p );
if ( vals[2] != NULL ) {
Widget *widget = rofi_theme_find_or_create_class ( rofi_theme , "@separator" );
ThemeWidget *widget = rofi_theme_find_or_create_class ( rofi_theme , "@separator" );
widget->properties = rofi_theme_convert_create_property_ht ();
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
g_hash_table_replace ( widget->properties, p->name, p );
@ -444,30 +460,30 @@ void rofi_theme_convert_old_theme ( void )
g_strfreev ( vals );
{
Property *p = NULL;
Widget *widget = rofi_theme_find_or_create_class ( rofi_theme , "@textbox" );
ThemeWidget *widget = rofi_theme_find_or_create_class ( rofi_theme , "@textbox" );
Widget *wnormal = rofi_theme_find_or_create_class ( widget, "normal" );
Widget *wselected = rofi_theme_find_or_create_class ( widget, "selected" );
Widget *walternate = rofi_theme_find_or_create_class ( widget, "alternate" );
ThemeWidget *wnormal = rofi_theme_find_or_create_class ( widget, "normal" );
ThemeWidget *wselected = rofi_theme_find_or_create_class ( widget, "selected" );
ThemeWidget *walternate = rofi_theme_find_or_create_class ( widget, "alternate" );
gchar **vals = g_strsplit ( config.color_normal, ",", 5 );
if ( g_strv_length (vals) == 5 ) {
Widget *wnn = rofi_theme_find_or_create_class ( wnormal, "normal" );
ThemeWidget *wnn = rofi_theme_find_or_create_class ( wnormal, "normal" );
wnn->properties = rofi_theme_convert_create_property_ht ();
p = rofi_theme_convert_get_color ( vals[0], "background" );
g_hash_table_replace ( wnn->properties, p->name, p );
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
g_hash_table_replace ( wnn->properties, p->name, p );
Widget *wsl = rofi_theme_find_or_create_class ( wselected, "normal" );
ThemeWidget *wsl = rofi_theme_find_or_create_class ( wselected, "normal" );
wsl->properties = rofi_theme_convert_create_property_ht ();
p = rofi_theme_convert_get_color ( vals[3], "background" );
g_hash_table_replace ( wsl->properties, p->name, p );
p = rofi_theme_convert_get_color ( vals[4], "foreground" );
g_hash_table_replace ( wsl->properties, p->name, p );
Widget *wal = rofi_theme_find_or_create_class ( walternate, "normal" );
ThemeWidget *wal = rofi_theme_find_or_create_class ( walternate, "normal" );
wal->properties = rofi_theme_convert_create_property_ht ();
p = rofi_theme_convert_get_color ( vals[2], "background" );
g_hash_table_replace ( wal->properties, p->name, p );
@ -478,21 +494,21 @@ void rofi_theme_convert_old_theme ( void )
vals = g_strsplit ( config.color_urgent, ",", 5 );
if ( g_strv_length (vals) == 5 ) {
Widget *wnn = rofi_theme_find_or_create_class ( wnormal, "urgent" );
ThemeWidget *wnn = rofi_theme_find_or_create_class ( wnormal, "urgent" );
wnn->properties = rofi_theme_convert_create_property_ht ();
p = rofi_theme_convert_get_color ( vals[0], "background" );
g_hash_table_replace ( wnn->properties, p->name, p );
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
g_hash_table_replace ( wnn->properties, p->name, p );
Widget *wsl = rofi_theme_find_or_create_class ( wselected, "urgent" );
ThemeWidget *wsl = rofi_theme_find_or_create_class ( wselected, "urgent" );
wsl->properties = rofi_theme_convert_create_property_ht ();
p = rofi_theme_convert_get_color ( vals[3], "background" );
g_hash_table_replace ( wsl->properties, p->name, p );
p = rofi_theme_convert_get_color ( vals[4], "foreground" );
g_hash_table_replace ( wsl->properties, p->name, p );
Widget *wal = rofi_theme_find_or_create_class ( walternate, "urgent" );
ThemeWidget *wal = rofi_theme_find_or_create_class ( walternate, "urgent" );
wal->properties = rofi_theme_convert_create_property_ht ();
p = rofi_theme_convert_get_color ( vals[2], "background" );
g_hash_table_replace ( wal->properties, p->name, p );
@ -503,21 +519,21 @@ void rofi_theme_convert_old_theme ( void )
vals = g_strsplit ( config.color_active, ",", 5 );
if ( g_strv_length (vals) == 5 ) {
Widget *wnn = rofi_theme_find_or_create_class ( wnormal, "active" );
ThemeWidget *wnn = rofi_theme_find_or_create_class ( wnormal, "active" );
wnn->properties = rofi_theme_convert_create_property_ht ();
p = rofi_theme_convert_get_color ( vals[0], "background" );
g_hash_table_replace ( wnn->properties, p->name, p );
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
g_hash_table_replace ( wnn->properties, p->name, p );
Widget *wsl = rofi_theme_find_or_create_class ( wselected, "active" );
ThemeWidget *wsl = rofi_theme_find_or_create_class ( wselected, "active" );
wsl->properties = rofi_theme_convert_create_property_ht ();
p = rofi_theme_convert_get_color ( vals[3], "background" );
g_hash_table_replace ( wsl->properties, p->name, p );
p = rofi_theme_convert_get_color ( vals[4], "foreground" );
g_hash_table_replace ( wsl->properties, p->name, p );
Widget *wal = rofi_theme_find_or_create_class ( walternate, "active" );
ThemeWidget *wal = rofi_theme_find_or_create_class ( walternate, "active" );
wal->properties = rofi_theme_convert_create_property_ht ();
p = rofi_theme_convert_get_color ( vals[2], "background" );
g_hash_table_replace ( wal->properties, p->name, p );

View file

@ -32,8 +32,11 @@
#include "theme.h"
#define LOG_DOMAIN "Widgets.Box"
/** Class name of box widget */
const char *BOX_CLASS_NAME = "@box";
/** Default spacing used in the box*/
#define DEFAULT_SPACING 2
/**

View file

@ -127,9 +127,15 @@ textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType
return tb;
}
/**
* State names used for theming.
*/
const char const *const theme_prop_names[][3] = {
/** Normal row */
{"normal.normal", "selected.normal", "alternate.normal"},
/** Urgent row */
{"normal.urgent", "selected.urgent", "alternate.urgent"},
/** Active row */
{"normal.active", "selected.active", "alternate.active"},
};
@ -758,6 +764,7 @@ int textbox_get_font_width ( const textbox *tb )
return width;
}
/** Caching for the expected character height. */
static double char_height = -1;
double textbox_get_estimated_char_height ( void )
{
@ -768,6 +775,7 @@ double textbox_get_estimated_char_height ( void )
return char_height;
}
/** Caching for the expected character width. */
static double char_width = -1;
double textbox_get_estimated_char_width ( void )
{

View file

@ -213,8 +213,6 @@ void widget_set_name ( widget *wid, const char *name )
wid->name = g_strdup ( name );
}
// External
double textbox_get_estimated_char_height ( void );
int widget_padding_get_left ( const widget *wid )
{
return distance_get_pixel ( wid->pad.left );

View file

@ -33,7 +33,9 @@
#define LOG_DOMAIN "Widgets.Window"
/** The default border width of the window */
#define DEFAULT_BORDER_WIDTH 2
/** The class name of the window */
const char *WINDOW_CLASS_NAME = "@window";
/**