summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-06-02 16:09:20 +0200
committerDave Davenport <qball@gmpclient.org>2017-06-02 16:09:20 +0200
commit48bf1709b6bcc316ad8019afc11d2cf8452817a0 (patch)
treec3b22e7a006df026f7bfab6411baf08e9898f766
parenteec5c6eadcc5de3c5285a5240db6da2e439d287a (diff)
Rename HL_ to ROFI_HL_ and fix box test.
-rw-r--r--include/theme.h18
-rw-r--r--lexer/theme-parser.y14
-rw-r--r--source/helper.c12
-rw-r--r--source/theme.c10
-rw-r--r--source/view.c2
-rw-r--r--source/widgets/widget.c4
-rw-r--r--test/box-test.c24
-rw-r--r--test/theme-parser-test.c26
8 files changed, 55 insertions, 55 deletions
diff --git a/include/theme.h b/include/theme.h
index 7c8f76a9..6912a594 100644
--- a/include/theme.h
+++ b/include/theme.h
@@ -37,20 +37,20 @@
typedef enum
{
/** no highlight */
- HL_NONE = 0,
+ ROFI_HL_NONE = 0,
/** bold */
- HL_BOLD = 1,
+ ROFI_HL_BOLD = 1,
/** underline */
- HL_UNDERLINE = 2,
+ ROFI_HL_UNDERLINE = 2,
/** strikethrough */
- HL_STRIKETHROUGH = 16,
+ ROFI_HL_STRIKETHROUGH = 16,
/** small caps */
- HL_SMALL_CAPS = 32,
+ ROFI_HL_SMALL_CAPS = 32,
/** italic */
- HL_ITALIC = 4,
+ ROFI_HL_ITALIC = 4,
/** color */
- HL_COLOR = 8
-} HighlightStyle;
+ ROFI_HL_COLOR = 8
+} RofiHighlightStyle;
/** Style of line */
typedef enum
@@ -156,7 +156,7 @@ typedef struct
typedef struct
{
/** style to display */
- HighlightStyle style;
+ RofiHighlightStyle style;
/** Color */
ThemeColor color;
} ThemeHighlight;
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index 0ed5391b..139c8354 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -358,7 +358,7 @@ t_property
| t_property_name T_PSEP t_property_highlight_styles t_property_color T_PCLOSE {
$$ = rofi_theme_property_create ( P_HIGHLIGHT );
$$->name = $1;
- $$->value.highlight.style = $3|HL_COLOR;
+ $$->value.highlight.style = $3|ROFI_HL_COLOR;
$$->value.highlight.color = $4;
}
| t_property_name T_PSEP t_property_highlight_styles T_PCLOSE {
@@ -422,12 +422,12 @@ t_property_highlight_styles
;
/** Single style. */
t_property_highlight_style
-: T_NONE { $$ = HL_NONE; }
-| T_BOLD { $$ = HL_BOLD; }
-| T_UNDERLINE { $$ = HL_UNDERLINE; }
-| T_STRIKETHROUGH { $$ = HL_STRIKETHROUGH; }
-| T_ITALIC { $$ = HL_ITALIC; }
-| T_SMALLCAPS { $$ = HL_SMALL_CAPS; }
+: T_NONE { $$ = ROFI_HL_NONE; }
+| T_BOLD { $$ = ROFI_HL_BOLD; }
+| T_UNDERLINE { $$ = ROFI_HL_UNDERLINE; }
+| T_STRIKETHROUGH { $$ = ROFI_HL_STRIKETHROUGH; }
+| T_ITALIC { $$ = ROFI_HL_ITALIC; }
+| T_SMALLCAPS { $$ = ROFI_HL_SMALL_CAPS; }
;
/** Distance. */
diff --git a/source/helper.c b/source/helper.c
index e0a0563e..a299e612 100644
--- a/source/helper.c
+++ b/source/helper.c
@@ -411,37 +411,37 @@ PangoAttrList *helper_token_match_get_pango_attr ( ThemeHighlight th, GRegex **t
for ( int index = ( count > 1 ) ? 1 : 0; index < count; index++ ) {
int start, end;
g_match_info_fetch_pos ( gmi, index, &start, &end );
- if ( th.style & HL_BOLD ) {
+ if ( th.style & ROFI_HL_BOLD ) {
PangoAttribute *pa = pango_attr_weight_new ( PANGO_WEIGHT_BOLD );
pa->start_index = start;
pa->end_index = end;
pango_attr_list_insert ( retv, pa );
}
- if ( th.style & HL_UNDERLINE ) {
+ if ( th.style & ROFI_HL_UNDERLINE ) {
PangoAttribute *pa = pango_attr_underline_new ( PANGO_UNDERLINE_SINGLE );
pa->start_index = start;
pa->end_index = end;
pango_attr_list_insert ( retv, pa );
}
- if ( th.style & HL_STRIKETHROUGH ) {
+ if ( th.style & ROFI_HL_STRIKETHROUGH ) {
PangoAttribute *pa = pango_attr_strikethrough_new ( TRUE );
pa->start_index = start;
pa->end_index = end;
pango_attr_list_insert ( retv, pa );
}
- if ( th.style & HL_SMALL_CAPS ) {
+ if ( th.style & ROFI_HL_SMALL_CAPS ) {
PangoAttribute *pa = pango_attr_variant_new ( PANGO_VARIANT_SMALL_CAPS );
pa->start_index = start;
pa->end_index = end;
pango_attr_list_insert ( retv, pa );
}
- if ( th.style & HL_ITALIC ) {
+ if ( th.style & ROFI_HL_ITALIC ) {
PangoAttribute *pa = pango_attr_style_new ( PANGO_STYLE_ITALIC );
pa->start_index = start;
pa->end_index = end;
pango_attr_list_insert ( retv, pa );
}
- if ( th.style & HL_COLOR ) {
+ if ( th.style & ROFI_HL_COLOR ) {
PangoAttribute *pa = pango_attr_foreground_new (
th.color.red * 65535,
th.color.green * 65535,
diff --git a/source/theme.c b/source/theme.c
index fc72307a..edfc4be5 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -164,19 +164,19 @@ static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p
switch ( p->type )
{
case P_HIGHLIGHT:
- if ( p->value.highlight.style & HL_BOLD ) {
+ if ( p->value.highlight.style & ROFI_HL_BOLD ) {
printf ( "bold " );
}
- if ( p->value.highlight.style & HL_UNDERLINE ) {
+ if ( p->value.highlight.style & ROFI_HL_UNDERLINE ) {
printf ( "underline " );
}
- if ( p->value.highlight.style & HL_STRIKETHROUGH ) {
+ if ( p->value.highlight.style & ROFI_HL_STRIKETHROUGH ) {
printf ( "strikethrough " );
}
- if ( p->value.highlight.style & HL_ITALIC ) {
+ if ( p->value.highlight.style & ROFI_HL_ITALIC ) {
printf ( "italic " );
}
- if ( p->value.highlight.style & HL_COLOR ) {
+ if ( p->value.highlight.style & ROFI_HL_COLOR ) {
printf ( "rgba ( %.0f, %.0f, %.0f, %.0f %% )",
( p->value.highlight.color.red * 255.0 ),
( p->value.highlight.color.green * 255.0 ),
diff --git a/source/view.c b/source/view.c
index 4d636191..9b7595da 100644
--- a/source/view.c
+++ b/source/view.c
@@ -911,7 +911,7 @@ static void update_callback ( textbox *t, unsigned int index, void *udata, TextB
textbox_icon ( t, icon );
if ( state->tokens && config.show_match ) {
- ThemeHighlight th = { HL_BOLD | HL_UNDERLINE, { 0.0, 0.0, 0.0, 0.0 } };
+ ThemeHighlight th = { ROFI_HL_BOLD | ROFI_HL_UNDERLINE, { 0.0, 0.0, 0.0, 0.0 } };
th = rofi_theme_get_highlight ( WIDGET ( t ), "highlight", th );
helper_token_match_get_pango_attr ( th, state->tokens, textbox_get_visible_text ( t ), list );
}
diff --git a/source/widgets/widget.c b/source/widgets/widget.c
index 1af1af54..e0e89374 100644
--- a/source/widgets/widget.c
+++ b/source/widgets/widget.c
@@ -554,12 +554,12 @@ int widget_get_desired_height ( widget *wid )
if ( wid && wid->get_desired_height ) {
return wid->get_desired_height ( wid );
}
- return 0;
+ return wid->h;
}
int widget_get_desired_width ( widget *wid )
{
if ( wid && wid->get_desired_width ) {
return wid->get_desired_width ( wid );
}
- return 0;
+ return wid->w;
}
diff --git a/test/box-test.c b/test/box-test.c
index e76459f9..ba0b3337 100644
--- a/test/box-test.c
+++ b/test/box-test.c
@@ -32,6 +32,7 @@
#include <assert.h>
#include <glib.h>
#include <string.h>
+#include <theme.h>
#include <widgets/box.h>
#include <widgets/widget.h>
#include <widgets/widget-internal.h>
@@ -91,7 +92,7 @@ void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
{
- box *b = box_create ( "box", BOX_HORIZONTAL );
+ box *b = box_create ( "box", ORIENTATION_HORIZONTAL );
//box_set_padding ( b, 5 );
widget_resize ( WIDGET (b), 100, 20);
@@ -153,7 +154,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
widget_free ( WIDGET ( b ) );
}
{
- box *b = box_create ( "box", BOX_VERTICAL );
+ box *b = box_create ( "box", ORIENTATION_VERTICAL );
widget_resize ( WIDGET (b), 20, 100);
//box_set_padding ( b, 5 );
@@ -187,35 +188,34 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
// TODO should this happen automagically?
widget_update ( WIDGET ( b ) ) ;
TASSERTE ( wid1->w, 20);
- TASSERTE ( wid1->h, 48);
+ TASSERTE ( wid1->h, 38);
TASSERTE ( wid2->w, 20);
- TASSERTE ( wid2->h, 48);
+ TASSERTE ( wid2->h, 38);
TASSERTE ( wid3->w, 20);
- TASSERTE ( wid3->h, 0);
+ TASSERTE ( wid3->h, 20);
widget_resize ( WIDGET (b ), 20, 200 );
TASSERTE ( wid1->w, 20);
- TASSERTE ( wid1->h, 98);
+ TASSERTE ( wid1->h, 88);
TASSERTE ( wid2->w, 20);
- TASSERTE ( wid2->h, 98);
+ TASSERTE ( wid2->h, 88);
TASSERTE ( wid3->w, 20);
- // has no height, gets no height.
- TASSERTE ( wid3->h, 0);
+ TASSERTE ( wid3->h, 20);
// TASSERTE ( box_get_fixed_pixels ( b ) , 4 );
widget *wid4 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid4 ) );
widget_resize ( WIDGET ( wid4 ), 20, 20 );
box_add ( b , WIDGET( wid4 ), FALSE, 5 );
- TASSERTE ( wid4->y, 200);
+ TASSERTE ( wid4->y, 180);
widget *wid5 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid5 ) );
widget_resize ( WIDGET ( wid5 ), 20, 20 );
box_add ( b , WIDGET( wid5 ), TRUE, 6 );
- TASSERTE ( wid5->y, 136);
+ TASSERTE ( wid5->y, 149);
widget_free ( WIDGET ( b ) );
}
{
- box *b = box_create ( "box", BOX_VERTICAL );
+ box *b = box_create ( "box", ORIENTATION_VERTICAL );
widget_resize ( WIDGET (b), 20, 90);
//box_set_padding ( b, 5 );
widget *wid1 = g_malloc0(sizeof(widget));
diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c
index 4707f8d3..e2fd9083 100644
--- a/test/theme-parser-test.c
+++ b/test/theme-parser-test.c
@@ -366,17 +366,17 @@ START_TEST ( test_properties_style)
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string ( "* { none: none; bold: bold; underline: underline; italic: italic; st: italic strikethrough;}");
- ThemeHighlight th = { HL_BOLD, {0.0,0.0,0.0,0.0}};
+ ThemeHighlight th = { ROFI_HL_BOLD, {0.0,0.0,0.0,0.0}};
th = rofi_theme_get_highlight ( &wid, "none", th);
- ck_assert_int_eq ( th.style , HL_NONE );
+ ck_assert_int_eq ( th.style , ROFI_HL_NONE );
th = rofi_theme_get_highlight ( &wid, "underline", th);
- ck_assert_int_eq ( th.style , HL_UNDERLINE);
+ ck_assert_int_eq ( th.style , ROFI_HL_UNDERLINE);
th = rofi_theme_get_highlight ( &wid, "italic", th);
- ck_assert_int_eq ( th.style , HL_ITALIC);
+ ck_assert_int_eq ( th.style , ROFI_HL_ITALIC);
th = rofi_theme_get_highlight ( &wid, "bold", th);
- ck_assert_int_eq ( th.style , HL_BOLD);
+ ck_assert_int_eq ( th.style , ROFI_HL_BOLD);
th = rofi_theme_get_highlight ( &wid, "st", th);
- ck_assert_int_eq ( th.style , HL_ITALIC|HL_STRIKETHROUGH);
+ ck_assert_int_eq ( th.style , ROFI_HL_ITALIC|ROFI_HL_STRIKETHROUGH);
}
END_TEST
START_TEST ( test_properties_style2 )
@@ -386,15 +386,15 @@ START_TEST ( test_properties_style2 )
wid.state = NULL;
rofi_theme_parse_string ( "* { boldu: bold underline ; boldi: bold italic; underlinei: underline italic; italicu: italic underline;}");
- ThemeHighlight th = { HL_BOLD, {0.0,0.0,0.0,0.0}};
+ ThemeHighlight th = { ROFI_HL_BOLD, {0.0,0.0,0.0,0.0}};
th = rofi_theme_get_highlight ( &wid, "boldu", th);
- ck_assert_int_eq ( th.style , (HL_UNDERLINE|HL_BOLD));
+ ck_assert_int_eq ( th.style , (ROFI_HL_UNDERLINE|ROFI_HL_BOLD));
th = rofi_theme_get_highlight ( &wid, "boldi", th);
- ck_assert_int_eq ( th.style , (HL_ITALIC|HL_BOLD));
+ ck_assert_int_eq ( th.style , (ROFI_HL_ITALIC|ROFI_HL_BOLD));
th = rofi_theme_get_highlight ( &wid, "underlinei", th);
- ck_assert_int_eq ( th.style , (HL_ITALIC|HL_UNDERLINE));
+ ck_assert_int_eq ( th.style , (ROFI_HL_ITALIC|ROFI_HL_UNDERLINE));
th = rofi_theme_get_highlight ( &wid, "italicu", th);
- ck_assert_int_eq ( th.style , (HL_ITALIC|HL_UNDERLINE));
+ ck_assert_int_eq ( th.style , (ROFI_HL_ITALIC|ROFI_HL_UNDERLINE));
}
END_TEST
START_TEST ( test_properties_style_color )
@@ -403,9 +403,9 @@ START_TEST ( test_properties_style_color )
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string ( "* { comb: bold #123; }");
- ThemeHighlight th = { HL_BOLD, {0.0,0.0,0.0,0.0}};
+ ThemeHighlight th = { ROFI_HL_BOLD, {0.0,0.0,0.0,0.0}};
th = rofi_theme_get_highlight ( &wid, "comb", th);
- ck_assert_int_eq ( th.style , (HL_BOLD|HL_COLOR));
+ ck_assert_int_eq ( th.style , (ROFI_HL_BOLD|ROFI_HL_COLOR));
ck_assert_double_eq ( th.color.red , (1/15.0));
ck_assert_double_eq ( th.color.green , (2/15.0));
ck_assert_double_eq ( th.color.blue , (3/15.0));