mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Add converter back for old theme format.
This commit is contained in:
parent
c28dd35f3d
commit
a754815d14
12 changed files with 147 additions and 30 deletions
|
@ -111,4 +111,8 @@ Settings config = {
|
|||
.click_to_exit = TRUE,
|
||||
.show_match = TRUE,
|
||||
.theme = NULL,
|
||||
.color_normal = NULL,
|
||||
.color_active = NULL,
|
||||
.color_urgent = NULL,
|
||||
.color_window = NULL,
|
||||
};
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
const char *default_theme =
|
||||
"* {"
|
||||
" spacing: 2;"
|
||||
" background: #FFFDF6E3;"
|
||||
" foreground: #FF002B36;"
|
||||
" bordercolor: @foreground;"
|
||||
" red: #FFDC322F;"
|
||||
" blue: #FF268BD2;"
|
||||
" lightbg: #FFEEE8D5;"
|
||||
" lightfg: #FF586875;"
|
||||
" background: #FFFDF6E3;"
|
||||
" foreground: #FF002B36;"
|
||||
" bordercolor: @foreground;"
|
||||
" red: #FFDC322F;"
|
||||
" blue: #FF268BD2;"
|
||||
" lightbg: #FFEEE8D5;"
|
||||
" lightfg: #FF586875;"
|
||||
" normal-foreground: @foreground;"
|
||||
" normal-background: @background;"
|
||||
" urgent-foreground: @red;"
|
||||
|
|
|
@ -64,6 +64,12 @@ typedef struct
|
|||
/** Font string (pango format) */
|
||||
char * menu_font;
|
||||
|
||||
/** New row colors */
|
||||
char * color_normal;
|
||||
char * color_active;
|
||||
char * color_urgent;
|
||||
char * color_window;
|
||||
|
||||
/** Terminal to use */
|
||||
char * terminal_emulator;
|
||||
/** SSH client to use */
|
||||
|
|
|
@ -409,4 +409,9 @@ Property *rofi_theme_find_property ( ThemeWidget *widget, PropertyType type, con
|
|||
* @returns TRUE when empty.
|
||||
*/
|
||||
gboolean rofi_theme_is_empty ( void );
|
||||
|
||||
/**
|
||||
* Convert old theme colors into default one.
|
||||
*/
|
||||
void rofi_theme_convert_old ( void );
|
||||
#endif
|
||||
|
|
|
@ -45,16 +45,16 @@ typedef struct
|
|||
*/
|
||||
typedef enum
|
||||
{
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_LEFT = 1 << 16,
|
||||
TB_RIGHT = 1 << 17,
|
||||
TB_CENTER = 1 << 18,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
TB_WRAP = 1 << 21,
|
||||
TB_PASSWORD = 1 << 22,
|
||||
TB_INDICATOR = 1 << 23,
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_LEFT = 1 << 16,
|
||||
TB_RIGHT = 1 << 17,
|
||||
TB_CENTER = 1 << 18,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
TB_WRAP = 1 << 21,
|
||||
TB_PASSWORD = 1 << 22,
|
||||
TB_INDICATOR = 1 << 23,
|
||||
} TextboxFlags;
|
||||
/**
|
||||
* Flags indicating current state of the textbox.
|
||||
|
|
|
@ -408,6 +408,15 @@ if ( queue == NULL ){
|
|||
yylval->colorval.alpha = 1.0;
|
||||
return T_COLOR;
|
||||
}
|
||||
<PROPERTIES>argb:{HEX}{1,8} {
|
||||
union { unsigned int val; struct { unsigned char b,g,r,a;};} val;
|
||||
val.val = (unsigned int)strtoull ( &yytext[5], NULL, 16);
|
||||
yylval->colorval.alpha = val.a/255.0;
|
||||
yylval->colorval.red = val.r/255.0;
|
||||
yylval->colorval.green = val.g/255.0;
|
||||
yylval->colorval.blue = val.b/255.0;
|
||||
return T_COLOR;
|
||||
}
|
||||
|
||||
<PROPERTIES>{CENTER} {
|
||||
yylval->ival = WL_CENTER;
|
||||
|
|
|
@ -206,7 +206,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
|
|||
// Reading one line per time.
|
||||
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
|
||||
// Evaluate one line.
|
||||
unsigned int index = 0, ti = 0;
|
||||
unsigned int index = 0, ti = 0;
|
||||
char *token = buffer;
|
||||
|
||||
// Tokenize it.
|
||||
|
|
|
@ -255,7 +255,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
|
|||
}
|
||||
|
||||
char *saveptr = NULL, *token;
|
||||
GRegex **retv = NULL;
|
||||
GRegex **retv = NULL;
|
||||
if ( !config.tokenize ) {
|
||||
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
|
||||
retv[0] = (GRegex *) create_regex ( input, case_sensitive );
|
||||
|
@ -866,8 +866,8 @@ int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *st
|
|||
// uleft: value of the upper left cell; ulefts: maximum value of uleft and cells on the left. The arbitrary initial
|
||||
// values suppress warnings.
|
||||
int uleft = 0, ulefts = 0, left, lefts;
|
||||
const gchar *pit = pattern, *sit;
|
||||
enum CharClass prev = NON_WORD, cur;
|
||||
const gchar *pit = pattern, *sit;
|
||||
enum CharClass prev = NON_WORD, cur;
|
||||
for ( si = 0, sit = str; si < slen; si++, sit = g_utf8_next_char ( sit ) ) {
|
||||
cur = rofi_scorer_get_character_class ( g_utf8_get_char ( sit ) );
|
||||
score[si] = rofi_scorer_get_score_for ( prev, cur );
|
||||
|
|
|
@ -197,12 +197,12 @@ static void run_switcher ( ModeMode mode )
|
|||
// Otherwise check if requested mode is enabled.
|
||||
for ( unsigned int i = 0; i < num_modi; i++ ) {
|
||||
if ( !mode_init ( modi[i] ) ) {
|
||||
GString *str= g_string_new ( "Failed to initialize the mode: ");
|
||||
GString *str = g_string_new ( "Failed to initialize the mode: " );
|
||||
g_string_append ( str, modi[i]->name );
|
||||
g_string_append ( str, "\n");
|
||||
g_string_append ( str, "\n" );
|
||||
|
||||
rofi_view_error_dialog ( str->str, ERROR_MSG_MARKUP );
|
||||
g_string_free (str, FALSE);
|
||||
g_string_free ( str, FALSE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -350,12 +350,12 @@ static void help_print_disabled_mode ( const char *mode )
|
|||
// Only output to terminal
|
||||
if ( is_term ) {
|
||||
fprintf ( stderr, "Mode %s%s%s is not enabled. I have enabled it for now.\n",
|
||||
color_red, mode, color_reset);
|
||||
color_red, mode, color_reset );
|
||||
fprintf ( stderr, "Please consider adding %s%s%s to the list of enabled modi: %smodi: %s%s%s,%s%s.\n",
|
||||
color_red, mode, color_reset,
|
||||
color_green, config.modi,color_reset,
|
||||
color_red, mode, color_reset
|
||||
);
|
||||
color_red, mode, color_reset,
|
||||
color_green, config.modi, color_reset,
|
||||
color_red, mode, color_reset
|
||||
);
|
||||
}
|
||||
}
|
||||
static void help_print_no_arguments ( void )
|
||||
|
@ -391,7 +391,7 @@ static void help_print_no_arguments ( void )
|
|||
}
|
||||
}
|
||||
fprintf ( stderr, "\nTo activate a mode, add it to the list of modi in the %smodi%s setting.",
|
||||
is_term?color_green:"",is_term?color_reset:"" );
|
||||
is_term ? color_green : "", is_term ? color_reset : "" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1140,10 +1140,18 @@ int main ( int argc, char *argv[] )
|
|||
if ( rofi_theme_is_empty ( ) ) {
|
||||
if ( rofi_theme_parse_string ( default_theme ) ) {
|
||||
fprintf ( stderr, "Failed to parse default theme. Giving up..\n" );
|
||||
if ( list_of_error_msgs ) {
|
||||
for ( GList *iter = g_list_first ( list_of_error_msgs );
|
||||
iter != NULL; iter = g_list_next ( iter ) ) {
|
||||
fprintf ( stderr, "Error: %s%s%s\n",
|
||||
color_bold, ( (GString *) iter->data )->str, color_reset );
|
||||
}
|
||||
}
|
||||
rofi_theme = NULL;
|
||||
cleanup ();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
rofi_theme_convert_old ();
|
||||
}
|
||||
|
||||
if ( find_arg ( "-dump-theme" ) >= 0 ) {
|
||||
|
|
|
@ -574,3 +574,68 @@ gboolean rofi_theme_is_empty ( void )
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void rofi_theme_convert_old ( void )
|
||||
{
|
||||
if ( config.color_window ) {
|
||||
char **retv = g_strsplit ( config.color_window, ",", -1 );
|
||||
const char const *conf[] = {
|
||||
"* { background: %s; }",
|
||||
"* { bordercolor: %s; }",
|
||||
"* { separatorcolor: %s; }"
|
||||
};
|
||||
for ( int i = 0; retv && retv[i]; i++ ) {
|
||||
char *str = g_strdup_printf ( conf[i], retv[i] );
|
||||
rofi_theme_parse_string ( str );
|
||||
g_free ( str );
|
||||
}
|
||||
g_strfreev ( retv );
|
||||
}
|
||||
if ( config.color_normal ) {
|
||||
char **retv = g_strsplit ( config.color_normal, ",", -1 );
|
||||
const char const *conf[] = {
|
||||
"* { normal-background: %s; }",
|
||||
"* { foreground: %s; normal-foreground: @foreground; alternate-normal-foreground: @foreground; }",
|
||||
"* { alternate-normal-background: %s; }",
|
||||
"* { selected-normal-background: %s; }",
|
||||
"* { selected-normal-foreground: %s; }"
|
||||
};
|
||||
for ( int i = 0; retv && retv[i]; i++ ) {
|
||||
char *str = g_strdup_printf ( conf[i], retv[i] );
|
||||
rofi_theme_parse_string ( str );
|
||||
g_free ( str );
|
||||
}
|
||||
g_strfreev ( retv );
|
||||
}
|
||||
if ( config.color_urgent ) {
|
||||
char **retv = g_strsplit ( config.color_urgent, ",", -1 );
|
||||
const char const *conf[] = {
|
||||
"* { urgent-background: %s; }",
|
||||
"* { urgent-foreground: %s; alternate-urgent-foreground: @urgent-foreground;}",
|
||||
"* { alternate-urgent-background: %s; }",
|
||||
"* { selected-urgent-background: %s; }",
|
||||
"* { selected-urgent-foreground: %s; }"
|
||||
};
|
||||
for ( int i = 0; retv && retv[i]; i++ ) {
|
||||
char *str = g_strdup_printf ( conf[i], retv[i] );
|
||||
rofi_theme_parse_string ( str );
|
||||
g_free ( str );
|
||||
}
|
||||
g_strfreev ( retv );
|
||||
}
|
||||
if ( config.color_active ) {
|
||||
char **retv = g_strsplit ( config.color_active, ",", -1 );
|
||||
const char const *conf[] = {
|
||||
"* { active-background: %s; }",
|
||||
"* { active-foreground: %s; alternate-active-foreground: @active-foreground;}",
|
||||
"* { alternate-active-background: %s; }",
|
||||
"* { selected-active-background: %s; }",
|
||||
"* { selected-active-foreground: %s; }"
|
||||
};
|
||||
for ( int i = 0; retv && retv[i]; i++ ) {
|
||||
char *str = g_strdup_printf ( conf[i], retv[i] );
|
||||
rofi_theme_parse_string ( str );
|
||||
g_free ( str );
|
||||
}
|
||||
g_strfreev ( retv );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -433,6 +433,9 @@ static void listview_nav_down_int ( listview *lv )
|
|||
|
||||
void listview_nav_up ( listview *lv )
|
||||
{
|
||||
if ( lv == NULL ) {
|
||||
return;
|
||||
}
|
||||
if ( lv->reverse ) {
|
||||
listview_nav_down_int ( lv );
|
||||
}
|
||||
|
@ -442,6 +445,9 @@ void listview_nav_up ( listview *lv )
|
|||
}
|
||||
void listview_nav_down ( listview *lv )
|
||||
{
|
||||
if ( lv == NULL ) {
|
||||
return;
|
||||
}
|
||||
if ( lv->reverse ) {
|
||||
listview_nav_up_int ( lv );
|
||||
}
|
||||
|
@ -514,6 +520,9 @@ static void listview_nav_page_next_int ( listview *lv )
|
|||
|
||||
void listview_nav_page_prev ( listview *lv )
|
||||
{
|
||||
if ( lv == NULL ) {
|
||||
return;
|
||||
}
|
||||
if ( lv->reverse ) {
|
||||
listview_nav_page_next_int ( lv );
|
||||
}
|
||||
|
@ -523,6 +532,9 @@ void listview_nav_page_prev ( listview *lv )
|
|||
}
|
||||
void listview_nav_page_next ( listview *lv )
|
||||
{
|
||||
if ( lv == NULL ) {
|
||||
return;
|
||||
}
|
||||
if ( lv->reverse ) {
|
||||
listview_nav_page_prev_int ( lv );
|
||||
}
|
||||
|
|
|
@ -171,6 +171,14 @@ static XrmOption xrmOptions[] = {
|
|||
"Indicate how it match by underlining it.", CONFIG_DEFAULT },
|
||||
{ xrm_String, "theme", { .str = &config.theme }, NULL,
|
||||
"New style theme file", CONFIG_DEFAULT },
|
||||
{ xrm_String, "color-normal", { .str = &config.color_normal }, NULL,
|
||||
"Color scheme for normal row", CONFIG_DEFAULT },
|
||||
{ xrm_String, "color-urgent", { .str = &config.color_urgent }, NULL,
|
||||
"Color scheme for urgent row", CONFIG_DEFAULT },
|
||||
{ xrm_String, "color-active", { .str = &config.color_active }, NULL,
|
||||
"Color scheme for active row", CONFIG_DEFAULT },
|
||||
{ xrm_String, "color-window", { .str = &config.color_window }, NULL,
|
||||
"Color scheme window", CONFIG_DEFAULT },
|
||||
};
|
||||
|
||||
/** Dynamic array of extra options */
|
||||
|
|
Loading…
Reference in a new issue