From 7d16d1a55269e58e3d9068685524a220cec360e6 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 1 Jan 2017 15:39:02 +0100 Subject: [PATCH] Slowly move more settings to the configuration convert. --- source/theme.c | 36 ++++++++++++++++++++++++++++++++---- source/widgets/box.c | 5 +++-- source/widgets/listview.c | 4 +++- source/widgets/scrollbar.c | 1 - source/widgets/separator.c | 1 - source/widgets/textbox.c | 1 - source/widgets/window.c | 5 +++-- 7 files changed, 41 insertions(+), 12 deletions(-) diff --git a/source/theme.c b/source/theme.c index 96ce7817..187436a4 100644 --- a/source/theme.c +++ b/source/theme.c @@ -400,16 +400,44 @@ void rofi_theme_convert_old_theme ( void ) rofi_theme = (Widget*)g_malloc0 ( sizeof ( Widget ) ); 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" ); + box_widget->properties = rofi_theme_convert_create_property_ht ( ); + Property *p = rofi_theme_property_create ( P_INTEGER ); + p->name = g_strdup("spacing"); + p->value.i = config.padding; + g_hash_table_replace ( box_widget->properties, p->name, p ); + } + { + // Spacing + Widget *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"); + p->value.i = config.padding; + g_hash_table_replace ( listview_widget->properties, p->name, p ); + } + { + // Border width. + Widget *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"); + p->value.i = config.menu_bw; + g_hash_table_replace ( window_widget->properties, p->name, p ); + // Padding + p = rofi_theme_property_create ( P_INTEGER ); + p->name = g_strdup("padding"); + p->value.i = config.padding; + g_hash_table_replace ( window_widget->properties, p->name, p ); + } { gchar **vals = g_strsplit ( config.color_window, ",", 3 ); if ( vals != NULL ){ if ( vals[0] != NULL ) { Property *p = rofi_theme_convert_get_color ( vals[0], "background" ); g_hash_table_replace ( rofi_theme->properties, p->name, p ); - p = rofi_theme_property_create ( P_INTEGER ); - p->name = g_strdup("padding"); - p->value.i = config.padding; - g_hash_table_replace ( rofi_theme->properties, p->name, p ); if ( vals[1] != NULL ) { p = rofi_theme_convert_get_color ( vals[1], "foreground" ); diff --git a/source/widgets/box.c b/source/widgets/box.c index 255f9b43..8a33984f 100644 --- a/source/widgets/box.c +++ b/source/widgets/box.c @@ -30,11 +30,12 @@ #include "widgets/widget-internal.h" #include "widgets/box.h" #include "theme.h" -#include "settings.h" #define LOG_DOMAIN "Widgets.Box" const char *BOX_CLASS_NAME = "@box"; +#define DEFAULT_SPACING 2 + /** * @param box Handle to the box widget. * @param spacing The spacing to apply. @@ -351,7 +352,7 @@ box * box_create ( const char *name, boxType type ) b->widget.get_desired_height = box_get_desired_height; b->widget.enabled = TRUE; - box_set_spacing ( b, distance_get_pixel (rofi_theme_get_distance ( b->widget.class_name, b->widget.name, NULL, "spacing",config.line_margin ))); + box_set_spacing ( b, distance_get_pixel (rofi_theme_get_distance ( b->widget.class_name, b->widget.name, NULL, "spacing",DEFAULT_SPACING ))); return b; } diff --git a/source/widgets/listview.c b/source/widgets/listview.c index 19f3f305..70abce55 100644 --- a/source/widgets/listview.c +++ b/source/widgets/listview.c @@ -32,6 +32,8 @@ #include "settings.h" #include "theme.h" +#define DEFAULT_SPACING 2 + struct _listview { widget widget; @@ -349,7 +351,7 @@ listview *listview_create ( const char *name, listview_update_callback cb, void lv->udata = udata; // Some settings. - lv->spacing = distance_get_pixel (rofi_theme_get_distance (lv->widget.class_name, lv->widget.name, NULL, "spacing", config.line_margin )); + lv->spacing = distance_get_pixel (rofi_theme_get_distance (lv->widget.class_name, lv->widget.name, NULL, "spacing", DEFAULT_SPACING )); lv->menu_lines = rofi_theme_get_integer (lv->widget.class_name, lv->widget.name, NULL, "lines", config.menu_lines ); lv->menu_columns = rofi_theme_get_integer (lv->widget.class_name, lv->widget.name, NULL, "columns", config.menu_columns); lv->fixed_num_lines = rofi_theme_get_boolean (lv->widget.class_name, lv->widget.name, NULL, "fixed-height", config.fixed_num_lines ); diff --git a/source/widgets/scrollbar.c b/source/widgets/scrollbar.c index a4b859dc..b3127245 100644 --- a/source/widgets/scrollbar.c +++ b/source/widgets/scrollbar.c @@ -27,7 +27,6 @@ #include #include "widgets/scrollbar.h" #include "x11-helper.h" -#include "settings.h" #include "theme.h" diff --git a/source/widgets/separator.c b/source/widgets/separator.c index b2324cf6..642733f7 100644 --- a/source/widgets/separator.c +++ b/source/widgets/separator.c @@ -30,7 +30,6 @@ #include "widgets/widget-internal.h" #include "widgets/separator.h" #include "x11-helper.h" -#include "settings.h" #include "theme.h" const char *SEPARATOR_CLASS_NAME = "@separator"; diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index 3ca15d20..69b73473 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -29,7 +29,6 @@ #include #include #include -#include "settings.h" #include "widgets/textbox.h" #include "keyb.h" #include "x11-helper.h" diff --git a/source/widgets/window.c b/source/widgets/window.c index d73d23ea..657999c7 100644 --- a/source/widgets/window.c +++ b/source/widgets/window.c @@ -30,9 +30,10 @@ #include "widgets/widget-internal.h" #include "widgets/window.h" #include "theme.h" -#include "settings.h" #define LOG_DOMAIN "Widgets.Window" + +#define DEFAULT_BORDER_WIDTH 2 const char *WINDOW_CLASS_NAME = "@window"; /** @@ -147,7 +148,7 @@ window * window_create ( const char *name ) b->widget.get_desired_height = window_get_desired_height; b->widget.enabled = TRUE; b->border_width = rofi_theme_get_integer ( - b->widget.class_name, b->widget.name, NULL, "border-width" , config.menu_bw); + b->widget.class_name, b->widget.name, NULL, "border-width" , DEFAULT_BORDER_WIDTH); return b; }