mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	theme: reset theme values on reconfigure
This commit is contained in:
		
							parent
							
								
									5e83ce6b46
								
							
						
					
					
						commit
						7bd2576138
					
				
					 1 changed files with 13 additions and 5 deletions
				
			
		
							
								
								
									
										18
									
								
								src/theme.c
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								src/theme.c
									
										
									
									
									
								
							| 
						 | 
					@ -45,7 +45,7 @@ hex_to_dec(char c)
 | 
				
			||||||
 * @hex: hex string to be parsed
 | 
					 * @hex: hex string to be parsed
 | 
				
			||||||
 * @rgba: pointer to float[4] for return value
 | 
					 * @rgba: pointer to float[4] for return value
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void
 | 
					static void
 | 
				
			||||||
parse_hexstr(const char *hex, float *rgba)
 | 
					parse_hexstr(const char *hex, float *rgba)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (!hex || hex[0] != '#' || strlen(hex) < 7) {
 | 
						if (!hex || hex[0] != '#' || strlen(hex) < 7) {
 | 
				
			||||||
| 
						 | 
					@ -73,7 +73,8 @@ parse_hexstr(const char *hex, float *rgba)
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * theme_builtin() applies a theme very similar to Clearlooks-3.4
 | 
					 * theme_builtin() applies a theme very similar to Clearlooks-3.4
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void theme_builtin(struct theme *theme)
 | 
					static void
 | 
				
			||||||
 | 
					theme_builtin(struct theme *theme)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	theme->border_width = 1;
 | 
						theme->border_width = 1;
 | 
				
			||||||
	theme->padding_height = 3;
 | 
						theme->padding_height = 3;
 | 
				
			||||||
| 
						 | 
					@ -99,7 +100,8 @@ match(const gchar *pattern, const gchar *string)
 | 
				
			||||||
	return (bool)g_pattern_match_simple(pattern, string);
 | 
						return (bool)g_pattern_match_simple(pattern, string);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void entry(struct theme *theme, const char *key, const char *value)
 | 
					static void
 | 
				
			||||||
 | 
					entry(struct theme *theme, const char *key, const char *value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (!key || !value) {
 | 
						if (!key || !value) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -192,7 +194,6 @@ theme_read(struct theme *theme, const char *theme_name)
 | 
				
			||||||
			info("cannot find theme (%s), using built-in",
 | 
								info("cannot find theme (%s), using built-in",
 | 
				
			||||||
			     theme_name);
 | 
								     theme_name);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		theme_builtin(theme);
 | 
					 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	info("read themerc (%s)", themerc);
 | 
						info("read themerc (%s)", themerc);
 | 
				
			||||||
| 
						 | 
					@ -220,7 +221,8 @@ struct rounded_corner_ctx {
 | 
				
			||||||
	} corner;
 | 
						} corner;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void set_source(cairo_t *cairo, float *c)
 | 
					static void
 | 
				
			||||||
 | 
					set_source(cairo_t *cairo, float *c)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	cairo_set_source_rgba(cairo, c[0], c[1], c[2], c[3]);
 | 
						cairo_set_source_rgba(cairo, c[0], c[1], c[2], c[3]);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -360,6 +362,12 @@ void
 | 
				
			||||||
theme_init(struct theme *theme, struct wlr_renderer *renderer,
 | 
					theme_init(struct theme *theme, struct wlr_renderer *renderer,
 | 
				
			||||||
		const char *theme_name)
 | 
							const char *theme_name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Set some default values. This is particularly important on
 | 
				
			||||||
 | 
						 * reconfigure as not all themes set all options
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						theme_builtin(theme);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	theme_read(theme, theme_name);
 | 
						theme_read(theme, theme_name);
 | 
				
			||||||
	post_processing(theme);
 | 
						post_processing(theme);
 | 
				
			||||||
	create_corners(theme, renderer);
 | 
						create_corners(theme, renderer);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue