diff options
-rw-r--r-- | include/helper-theme.h | 4 | ||||
-rw-r--r-- | include/theme.h | 155 | ||||
-rw-r--r-- | include/view-internal.h | 6 | ||||
-rw-r--r-- | include/widgets/box.h | 16 | ||||
-rw-r--r-- | include/widgets/scrollbar.h | 2 | ||||
-rw-r--r-- | include/widgets/textbox.h | 2 | ||||
-rw-r--r-- | include/widgets/widget-internal.h | 23 | ||||
-rw-r--r-- | include/widgets/widget.h | 8 | ||||
-rw-r--r-- | lexer/theme-lexer.l | 36 | ||||
-rw-r--r-- | lexer/theme-parser.y | 71 | ||||
-rw-r--r-- | source/dialogs/drun.c | 95 | ||||
-rw-r--r-- | source/helper.c | 14 | ||||
-rw-r--r-- | source/theme.c | 101 | ||||
-rw-r--r-- | source/view.c | 241 | ||||
-rw-r--r-- | source/widgets/box.c | 77 | ||||
-rw-r--r-- | source/widgets/listview.c | 193 | ||||
-rw-r--r-- | source/widgets/scrollbar.c | 2 | ||||
-rw-r--r-- | source/widgets/textbox.c | 94 | ||||
-rw-r--r-- | source/widgets/widget.c | 77 | ||||
-rw-r--r-- | test/box-test.c | 50 | ||||
-rw-r--r-- | test/theme-parser-test.c | 140 |
21 files changed, 950 insertions, 457 deletions
diff --git a/include/helper-theme.h b/include/helper-theme.h index 472ca1b0..b2ed659b 100644 --- a/include/helper-theme.h +++ b/include/helper-theme.h @@ -34,7 +34,7 @@ * @{ */ /** - * @param th The ThemeHighlight + * @param th The RofiHighlightColorStyle * @param tokens Array of regexes used for matching * @param input The input string to find the matches on * @param retv The Attribute list to update with matches @@ -43,7 +43,7 @@ * * @returns the updated retv list. */ -PangoAttrList *helper_token_match_get_pango_attr ( ThemeHighlight th, GRegex **tokens, const char *input, PangoAttrList *retv ); +PangoAttrList *helper_token_match_get_pango_attr ( RofiHighlightColorStyle th, GRegex **tokens, const char *input, PangoAttrList *retv ); /** * @param pfd Pango font description to validate. diff --git a/include/theme.h b/include/theme.h index 9b03b32c..5afa982d 100644 --- a/include/theme.h +++ b/include/theme.h @@ -37,29 +37,29 @@ 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 { /** Solid line */ - SOLID, + ROFI_HL_SOLID, /** Dashed line */ - DASH -} LineStyle; + ROFI_HL_DASH +} RofiLineStyle; /** * Distance unit type. @@ -67,12 +67,12 @@ typedef enum typedef enum { /** PixelWidth in pixels. */ - PW_PX, + ROFI_PU_PX, /** PixelWidth in EM. */ - PW_EM, + ROFI_PU_EM, /** PixelWidget in percentage */ - PW_PERCENT, -} PixelWidth; + ROFI_PU_PERCENT, +} RofiPixelUnit; /** * Structure representing a distance. @@ -82,19 +82,19 @@ typedef struct /** Distance */ double distance; /** Unit type of the distance */ - PixelWidth type; - /** Style of the line */ - LineStyle style; -} Distance; + RofiPixelUnit type; + /** Style of the line (optional)*/ + RofiLineStyle style; +} RofiDistance; /** * Type of orientation. */ typedef enum { - ORIENTATION_VERTICAL, - ORIENTATION_HORIZONTAL -} Orientation; + ROFI_ORIENTATION_VERTICAL, + ROFI_ORIENTATION_HORIZONTAL +} RofiOrientation; /** * Type of property */ @@ -110,7 +110,7 @@ typedef enum P_BOOLEAN, /** Color */ P_COLOR, - /** Padding */ + /** RofiPadding */ P_PADDING, /** Link to global setting */ P_LINK, @@ -118,6 +118,10 @@ typedef enum P_POSITION, /** Highlight */ P_HIGHLIGHT, + /** List */ + P_LIST, + /** Orientation */ + P_ORIENTATION, } PropertyType; /** @@ -136,15 +140,15 @@ typedef struct } ThemeColor; /** - * Padding + * RofiPadding */ typedef struct { - Distance top; - Distance right; - Distance bottom; - Distance left; -} Padding; + RofiDistance top; + RofiDistance right; + RofiDistance bottom; + RofiDistance left; +} RofiPadding; /** * Theme highlight. @@ -152,10 +156,38 @@ typedef struct typedef struct { /** style to display */ - HighlightStyle style; + RofiHighlightStyle style; /** Color */ ThemeColor color; -} ThemeHighlight; +} RofiHighlightColorStyle; + +typedef union { + /** integer */ + int i; + /** Double */ + double f; + /** String */ + char *s; + /** boolean */ + gboolean b; + /** Color */ + ThemeColor color; + /** RofiPadding */ + RofiPadding padding; + /** Reference */ + struct + { + /** Name */ + char *name; + /** Cached looked up ref */ + struct Property *ref; + } link; + /** Highlight Style */ + RofiHighlightColorStyle highlight; + /** List */ + GList *list; +} PropertyValue; + /** * Property structure. */ @@ -166,31 +198,7 @@ typedef struct Property /** Type of property. */ PropertyType type; /** Value */ - union - { - /** integer */ - int i; - /** Double */ - double f; - /** String */ - char *s; - /** boolean */ - gboolean b; - /** Color */ - ThemeColor color; - /** Padding */ - Padding padding; - /** Reference */ - struct - { - /** Name */ - char *name; - /** Cached looked up ref */ - struct Property *ref; - } link; - /** Highlight Style */ - ThemeHighlight highlight; - } value; + PropertyValue value; } Property; /** * ThemeWidget. @@ -292,7 +300,17 @@ void rofi_theme_widget_add_properties ( ThemeWidget *widget, GHashTable *table ) * * @returns The distance value of this property for this widget. */ -Distance rofi_theme_get_distance ( const widget *widget, const char *property, int def ); +RofiDistance rofi_theme_get_distance ( const widget *widget, const char *property, int def ); +/** + * @param widget The widget to query + * @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. + */ +RofiDistance rofi_theme_get_distance_exact ( const widget *widget, const char *property, int def ); /** * @param widget The widget to query @@ -343,6 +361,16 @@ int rofi_theme_get_boolean ( const widget *widget, const char *property, int * @param property The property to query. * @param def The default value. * + * Obtain the orientation indicated by %property of the widget. + * + * @returns The orientation of this property for this widget or %def not found. + */ +RofiOrientation rofi_theme_get_orientation ( const widget *widget, const char *property, RofiOrientation def ); +/** + * @param widget The widget to query + * @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. @@ -354,7 +382,7 @@ const char *rofi_theme_get_string ( const widget *widget, const char *property * @param property The property to query. * @param def The default value. * - * Obtain the padding of the widget. + * Obtain the double of the widget. * * @returns The double value of this property for this widget. */ @@ -379,7 +407,7 @@ void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t * * @returns The padding of this property for this widget. */ -Padding rofi_theme_get_padding ( const widget *widget, const char *property, Padding pad ); +RofiPadding rofi_theme_get_padding ( const widget *widget, const char *property, RofiPadding pad ); /** * @param widget The widget to query @@ -390,23 +418,23 @@ Padding rofi_theme_get_padding ( const widget *widget, const char *property, Pad * * @returns The highlight of this property for this widget. */ -ThemeHighlight rofi_theme_get_highlight ( widget *widget, const char *property, ThemeHighlight th ); +RofiHighlightColorStyle rofi_theme_get_highlight ( widget *widget, const char *property, RofiHighlightColorStyle th ); /** * @param d The distance handle. * @param ori The orientation. * - * Convert Distance into pixels. + * Convert RofiDistance into pixels. * @returns the number of pixels this distance represents. */ -int distance_get_pixel ( Distance d, Orientation ori ); +int distance_get_pixel ( RofiDistance d, RofiOrientation ori ); /** * @param d The distance handle. * @param draw The cairo drawable. * * Set linestyle. */ -void distance_get_linestyle ( Distance d, cairo_t *draw ); +void distance_get_linestyle ( RofiDistance d, cairo_t *draw ); /** * Low-level functions. @@ -435,6 +463,7 @@ ThemeWidget *rofi_theme_find_widget ( const char *name, const char *state, gbool */ Property *rofi_theme_find_property ( ThemeWidget *widget, PropertyType type, const char *property, gboolean exact ); +GList *rofi_theme_get_list ( const widget *widget, const char * property, const char *defaults); /** * Checks if a theme is set, or is empty. * @returns TRUE when empty. diff --git a/include/view-internal.h b/include/view-internal.h index 5b1582b2..23d3ea71 100644 --- a/include/view-internal.h +++ b/include/view-internal.h @@ -51,11 +51,7 @@ struct RofiViewState /** Flag indicating if view needs to be refiltered. */ int refilter; /** Widget representing the main container. */ - container *main_window; - /** Main #box widget holding different elements. */ - box *main_box; - /** #box widget packing the input bar widgets. */ - box *input_bar; + box *main_window; /** #textbox showing the prompt in the input bar. */ textbox *prompt; /** #textbox with the user input in the input bar. */ diff --git a/include/widgets/box.h b/include/widgets/box.h index b698e026..21724b1a 100644 --- a/include/widgets/box.h +++ b/include/widgets/box.h @@ -48,32 +48,20 @@ typedef struct _box box; /** - * The packing direction of the box - */ -typedef enum -{ - /** Pack widgets horizontal */ - BOX_HORIZONTAL, - /** Pack widgets vertical */ - BOX_VERTICAL -} boxType; - -/** * @param name The name of the widget. * @param type The packing direction of the newly created box. * * @returns a newly created box, free with #widget_free */ -box * box_create ( const char *name, boxType type ); +box * box_create ( const char *name, RofiOrientation type ); /** * @param box Handle to the box widget. * @param child Handle to the child widget to pack. * @param expand If the child widget should expand and use all available space. - * @param index The position index. * * Add a widget to the box. */ -void box_add ( box *box, widget *child, gboolean expand, int index ); +void box_add ( box *box, widget *child, gboolean expand ); /*@}*/ #endif // ROFI_HBOX_H diff --git a/include/widgets/scrollbar.h b/include/widgets/scrollbar.h index 7bf97cc1..2806bc3f 100644 --- a/include/widgets/scrollbar.h +++ b/include/widgets/scrollbar.h @@ -46,7 +46,7 @@ typedef struct _scrollbar unsigned int length; unsigned int pos; unsigned int pos_length; - Distance width; + RofiDistance width; } scrollbar; /** diff --git a/include/widgets/textbox.h b/include/widgets/textbox.h index f63c7d74..5ce93855 100644 --- a/include/widgets/textbox.h +++ b/include/widgets/textbox.h @@ -64,6 +64,8 @@ typedef struct int blink; guint blink_timeout; + double yalign ; + PangoFontMetrics *metrics; int left_offset; // diff --git a/include/widgets/widget-internal.h b/include/widgets/widget-internal.h index b2b2d3ea..08c910af 100644 --- a/include/widgets/widget-internal.h +++ b/include/widgets/widget-internal.h @@ -44,22 +44,20 @@ struct _widget short w; /** Height of the widget */ short h; - /** Padding */ - Padding def_margin; - Padding def_padding; - Padding def_border; - Padding def_border_radius; - Padding margin; - Padding padding; - Padding border; - Padding border_radius; + /** RofiPadding */ + RofiPadding def_margin; + RofiPadding def_padding; + RofiPadding def_border; + RofiPadding def_border_radius; + RofiPadding margin; + RofiPadding padding; + RofiPadding border; + RofiPadding border_radius; /** enabled or not */ gboolean enabled; /** Expand the widget when packed */ gboolean expand; - /*** The packing index */ - int index; /** Place widget at end of parent */ gboolean end; /** Parent widget */ @@ -80,7 +78,8 @@ struct _widget /** Handle mouse motion, used for dragging */ gboolean ( *motion_notify )( struct _widget *, gint x, gint y ); - int ( *get_desired_height )( struct _widget * ); + int ( *get_desired_height )( struct _widget * ); + int ( *get_desired_width )( struct _widget * ); /** widget find_mouse_target callback */ widget_find_mouse_target_cb find_mouse_target; diff --git a/include/widgets/widget.h b/include/widgets/widget.h index e7da9f73..8fce3a43 100644 --- a/include/widgets/widget.h +++ b/include/widgets/widget.h @@ -296,5 +296,13 @@ gboolean widget_motion_notify ( widget *wid, gint x, gint y ); */ int widget_get_desired_height ( widget *wid ); +/** + * @param wid The widget handle + * + * Get the desired width of this widget recursively. + * + * @returns the desired width of the widget in pixels. + */ +int widget_get_desired_width ( widget *wid ); /*@}*/ #endif // ROFI_WIDGET_H diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index c834ee89..38647f60 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -199,6 +199,12 @@ ANGLE_GRAD "grad" ANGLE_RAD "rad" ANGLE_TURN "turn" + +/* Orientation */ + +ORIENTATION_HORI "horizontal" +ORIENTATION_VERT "vertical" + /* Color schema */ RGBA rgb[a]? HWB "hwb" @@ -212,6 +218,9 @@ S_T_PARENT_RIGHT \) COMMA , FORWARD_SLASH \/ +LIST_OPEN \[ +LIST_CLOSE \] + LS_DASH "dash" LS_SOLID "solid" @@ -221,6 +230,7 @@ CONFIGURATION "configuration" %x INCLUDE %x PROPERTIES +%x PROPERTIES_LIST %x NAMESTR %x SECTION %x DEFAULTS @@ -383,14 +393,15 @@ if ( queue == NULL ){ /* After Namestr/Classstr we want to go to state str, then to { */ <INITIAL,SECTION>{WHITESPACE}+ ; // ignore all whitespace -<PROPERTIES>{WHITESPACE}+ ; // ignore all whitespace +<PROPERTIES,PROPERTIES_LIST>{WHITESPACE}+ ; // ignore all whitespace <SECTION>":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return T_PSEP; } <PROPERTIES>";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return T_PCLOSE;} <PROPERTIES>(true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;} <PROPERTIES>{PNNUMBER}\.{NUMBER}+ { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;} <PROPERTIES>{PNNUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;} -<PROPERTIES>\"{STRING}\" { yytext[yyleng-1] = '\0'; yylval->sval = g_strdup(&yytext[1]); return T_STRING;} +<PROPERTIES>\"{STRING}\" { yytext[yyleng-1] = '\0'; yylval->sval = g_strcompress(&yytext[1]); return T_STRING;} + <PROPERTIES>@{WORD} { yylval->sval = g_strdup(yytext); return T_LINK; @@ -449,7 +460,16 @@ if ( queue == NULL ){ /* Fluff */ <PROPERTIES>{S_T_PARENT_LEFT} { return T_PARENT_LEFT; } <PROPERTIES>{S_T_PARENT_RIGHT} { return T_PARENT_RIGHT; } -<PROPERTIES>{COMMA} { return T_COMMA; } +<PROPERTIES,PROPERTIES_LIST>{COMMA} { return T_COMMA; } +<PROPERTIES>{LIST_OPEN} { + g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); + BEGIN(PROPERTIES_LIST); + return T_LIST_OPEN; +} +<PROPERTIES_LIST>{LIST_CLOSE} { + BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue ))); + return T_LIST_CLOSE; +} <PROPERTIES>{FORWARD_SLASH} { return T_FORWARD_SLASH; } /* Position */ <PROPERTIES>{CENTER} { return T_POS_CENTER; } @@ -470,6 +490,9 @@ if ( queue == NULL ){ <PROPERTIES>{ANGLE_GRAD} { return T_ANGLE_GRAD; } <PROPERTIES>{ANGLE_TURN} { return T_ANGLE_TURN; } +<PROPERTIES>{ORIENTATION_HORI} { return ORIENTATION_HORI; } +<PROPERTIES>{ORIENTATION_VERT} { return ORIENTATION_VERT; } + <PROPERTIES>{COLOR_TRANSPARENT} { return T_COLOR_TRANSPARENT; } @@ -522,7 +545,12 @@ if ( queue == NULL ){ <SECTION>. { return T_ERROR_SECTION; } -<PROPERTIES>. { +<PROPERTIES_LIST>{WORD} { + yylval->sval = g_strdup(yytext); + return T_ELEMENT; +} + +<PROPERTIES,PROPERTIES_LIST>. { return T_ERROR_PROPERTY; } <NAMESTR>. { diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index d66b7cc4..94e0cceb 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -141,10 +141,10 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b) WindowLocation wloc; ThemeColor colorval; ThemeWidget *theme; - GList *name_path; + GList *list; Property *property; GHashTable *property_list; - Distance distance; + RofiDistance distance; } %token <ival> T_END 0 "end of file" @@ -163,6 +163,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b) %token <bval> T_BOOLEAN "Boolean value (true or false)" %token <colorval> T_COLOR "Hexidecimal color value" %token <sval> T_LINK "Reference" +%token <sval> T_ELEMENT "Name of element" %token T_POS_CENTER "Center" %token T_POS_EAST "East" %token T_POS_WEST "West" @@ -187,6 +188,9 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b) %token T_ANGLE_RAD "Radians" %token T_ANGLE_TURN "Turns" +%token ORIENTATION_HORI "Horizontal" +%token ORIENTATION_VERT "Vertical" + %token T_COL_RGBA "rgb[a] colorscheme" %token T_COL_HSL "hsl colorscheme" %token T_COL_HWB "hwb colorscheme" @@ -198,6 +202,8 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b) %token T_OPTIONAL_COMMA "Optional comma separator (',')" %token T_FORWARD_SLASH "forward slash ('/')" %token T_PERCENT "Percent sign ('%')" +%token T_LIST_OPEN "List open ('[')" +%token T_LIST_CLOSE "List close (']')" %token T_BOPEN "bracket open ('{')" %token T_BCLOSE "bracket close ('}')" @@ -213,7 +219,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b) %type <sval> t_entry %type <theme> t_entry_list -%type <name_path> t_entry_name_path +%type <list> t_entry_name_path %type <property> t_property %type <property_list> t_property_list %type <property_list> t_property_list_optional @@ -232,6 +238,8 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b) %type <ival> t_property_highlight_styles %type <ival> t_property_highlight_style %type <ival> t_property_line_style +%type <list> t_property_element_list +%type <ival> t_property_orientation %start t_entry_list %% @@ -325,22 +333,22 @@ t_property | t_property_name T_PSEP t_property_distance T_PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; - $$->value.padding = (Padding){ $3, $3, $3, $3 }; + $$->value.padding = (RofiPadding){ $3, $3, $3, $3 }; } | t_property_name T_PSEP t_property_distance t_property_distance T_PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; - $$->value.padding = (Padding){ $3, $4, $3, $4 }; + $$->value.padding = (RofiPadding){ $3, $4, $3, $4 }; } | t_property_name T_PSEP t_property_distance t_property_distance t_property_distance T_PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; - $$->value.padding = (Padding){ $3, $4, $5, $4 }; + $$->value.padding = (RofiPadding){ $3, $4, $5, $4 }; } | t_property_name T_PSEP t_property_distance t_property_distance t_property_distance t_property_distance T_PCLOSE { $$ = rofi_theme_property_create ( P_PADDING ); $$->name = $1; - $$->value.padding = (Padding){ $3, $4, $5, $6 }; + $$->value.padding = (RofiPadding){ $3, $4, $5, $6 }; } | t_property_name T_PSEP t_property_position T_PCLOSE{ $$ = rofi_theme_property_create ( P_POSITION ); @@ -350,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 { @@ -363,6 +371,24 @@ t_property $$->name = $1; $$->value.color = $3; } +| t_property_name T_PSEP T_LIST_OPEN t_property_element_list T_LIST_CLOSE T_PCLOSE { + $$ = rofi_theme_property_create ( P_LIST ); + $$->name = $1; + $$->value.list = $4; +} +| t_property_name T_PSEP t_property_orientation T_PCLOSE { + $$ = rofi_theme_property_create ( P_ORIENTATION ); + $$->name = $1; + $$->value.i = $3; +} +; + +/** List of elements */ +t_property_element_list +: T_ELEMENT { $$ = g_list_append ( NULL, $1); } +| t_property_element_list T_COMMA T_ELEMENT { + $$ = g_list_append ( $1, $3 ); +} ; /** @@ -396,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. */ @@ -421,18 +447,18 @@ t_property_distance /** distance unit. px, em, % */ t_property_unit -: T_UNIT_PX { $$ = PW_PX; } -| T_UNIT_EM { $$ = PW_EM; } -| T_PERCENT { $$ = PW_PERCENT; } +: T_UNIT_PX { $$ = ROFI_PU_PX; } +| T_UNIT_EM { $$ = ROFI_PU_EM; } +| T_PERCENT { $$ = ROFI_PU_PERCENT; } ; /****** * Line style * If not set, solid. */ t_property_line_style -: %empty { $$ = SOLID; } -| T_SOLID { $$ = SOLID; } -| T_DASH { $$ = DASH; } +: %empty { $$ = ROFI_HL_SOLID; } +| T_SOLID { $$ = ROFI_HL_SOLID; } +| T_DASH { $$ = ROFI_HL_DASH; } ; /** @@ -552,6 +578,11 @@ t_property_color_value | T_INT { $$ = $1; } ; +t_property_orientation +: ORIENTATION_HORI { $$ = ROFI_ORIENTATION_HORIZONTAL; } +| ORIENTATION_VERT { $$ = ROFI_ORIENTATION_VERTICAL; } +; + /** Property name */ t_property_name : T_PROP_NAME { $$ = $1; } diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index 5360356c..046adb26 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -54,7 +54,6 @@ #define DRUN_CACHE_FILE "rofi2.druncache" -#define GET_CAT_PARSE_TIME /** * Store extra information about the entry. @@ -69,6 +68,7 @@ typedef struct /* Application id (.desktop filename) */ char *app_id; /* Icon stuff */ + int icon_size; char *icon_name; cairo_surface_t *icon; /* Executable */ @@ -77,9 +77,7 @@ typedef struct char *name; /* Generic Name */ char *generic_name; -#ifdef GET_CAT_PARSE_TIME char **categories; -#endif GKeyFile *key_file; } DRunModeEntry; @@ -95,6 +93,12 @@ typedef struct GHashTable *disabled_entries; unsigned int disabled_entries_length; GThread *thread; + GAsyncQueue *icon_fetch_queue; + + unsigned int expected_line_height; + DRunModeEntry quit_entry; + // Theme + const gchar *icon_theme; } DRunModePrivateData; struct RegexEvalArg @@ -289,6 +293,7 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c pd->cmd_list_length_actual += 256; pd->entry_list = g_realloc ( pd->entry_list, pd->cmd_list_length_actual * sizeof ( *( pd->entry_list ) ) ); } + pd->entry_list[pd->cmd_list_length].icon_size = 0; pd->entry_list[pd->cmd_list_length].root = g_strdup ( root ); pd->entry_list[pd->cmd_list_length].path = g_strdup ( path ); pd->entry_list[pd->cmd_list_length].app_id = g_strndup ( basename, strlen ( basename ) - strlen ( ".desktop" ) ); @@ -296,9 +301,7 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c pd->entry_list[pd->cmd_list_length].name = n; gchar *gn = g_key_file_get_locale_string ( kf, "Desktop Entry", "GenericName", NULL, NULL ); pd->entry_list[pd->cmd_list_length].generic_name = gn; -#ifdef GET_CAT_PARSE_TIME pd->entry_list[pd->cmd_list_length].categories = g_key_file_get_locale_string_list ( kf, "Desktop Entry", "Categories", NULL, NULL, NULL ); -#endif pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, "Desktop Entry", "Exec", NULL ); if ( config.show_icons ) { @@ -324,7 +327,7 @@ static void walk_dir ( DRunModePrivateData *pd, const char *root, const char *di { DIR *dir; - g_debug ( "Checking directory %s for desktop files.", root ); + g_debug ( "Checking directory %s for desktop files.", dirname ); dir = opendir ( dirname ); if ( dir == NULL ) { return; @@ -428,10 +431,20 @@ static void get_apps ( DRunModePrivateData *pd ) TICK_N ( "Get Desktop apps (user dir)" ); // Then read thee system data dirs. const gchar * const * sys = g_get_system_data_dirs (); - for (; *sys != NULL; ++sys ) { - dir = g_build_filename ( *sys, "applications", NULL ); - walk_dir ( pd, dir, dir ); - g_free ( dir ); + for (const gchar * const *iter = sys ; *iter != NULL; ++iter ) { + gboolean unique = TRUE; + // Stupid duplicate detection, better then walking dir. + for ( const gchar *const *iterd = sys ; iterd != iter; ++iterd ){ + if ( g_strcmp0 ( *iter, *iterd ) == 0 ) { + unique = FALSE; + } + } + // Check, we seem to be getting empty string... + if ( unique && (**iter) != '\0') { + dir = g_build_filename ( *iter, "applications", NULL ); + walk_dir ( pd, dir, dir ); + g_free ( dir ); + } } TICK_N ( "Get Desktop apps (system dirs)" ); } @@ -440,41 +453,39 @@ static gpointer drun_icon_fetch ( gpointer data ) { // as long as dr->icon is updated atomicly.. (is a pointer write atomic?) // this should be fine running in another thread. - GTimer *t = g_timer_new (); DRunModePrivateData *pd = (DRunModePrivateData *) data; - for ( size_t i = 0; i < pd->cmd_list_length; i++ ) { - DRunModeEntry *dr = &( pd->entry_list[i] ); + DRunModeEntry *dr; + while ( ( dr = g_async_queue_pop ( pd->icon_fetc |