From 467abd2edf4f4bcba47463bd278fab9c171028bb Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 26 Aug 2010 17:26:34 +0200 Subject: [PATCH] Make default_gauge_{width,height} lua settings --- doc/config_settings.xml | 18 +++++++++++++----- extras/nano/conky.nanorc | 2 +- extras/vim/syntax/conkyrc.vim | 2 +- src/conky.cc | 15 --------------- src/specials.cc | 10 +++++++--- src/specials.h | 5 ----- 6 files changed, 22 insertions(+), 30 deletions(-) diff --git a/doc/config_settings.xml b/doc/config_settings.xml index 8dd20897..4e537c25 100644 --- a/doc/config_settings.xml +++ b/doc/config_settings.xml @@ -126,13 +126,21 @@ - + - Specify a default width and height for gauges. - Example: 'default_gauge_size 25 25'. This is particularly - useful for execgauge and execigauge as they do not take - size arguments + Specify a default height for gauges. This is particularly useful for execgauge + and execigauge as they do not take size arguments + + + + + + + + + Specify a default width for gauges. This is particularly useful for execgauge + and execigauge as they do not take size arguments diff --git a/extras/nano/conky.nanorc b/extras/nano/conky.nanorc index 8e110e17..7b2631c6 100644 --- a/extras/nano/conky.nanorc +++ b/extras/nano/conky.nanorc @@ -5,7 +5,7 @@ syntax "conky" "(\.*conkyrc.*$|conky.conf)" ## Configuration items -color green "\<(alignment|append_file|background|border_inner_margin|border_outer_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_height|default_bar_width|default_color|default_gauge_size|default_graph_height|default_graph_width|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|extra_newline|font|format_human_readable|gap_x|gap_y|http_refresh|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_draw_hook_post|lua_draw_hook_pre|lua_load|lua_shutdown_hook|lua_startup_hook|mail_spool|max_port_monitor_connections|max_text_width|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|mysql_host|mysql_port|mysql_user|mysql_password|mysql_db|net_avg_samples|no_buffers|nvidia_display|out_to_console|out_to_http|out_to_ncurses|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|times_in_seconds|top_cpu_separate|top_name_width|total_run_times|update_interval|update_interval_on_battery|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>" +color green "\<(alignment|append_file|background|border_inner_margin|border_outer_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_height|default_bar_width|default_color|default_gauge_height|default_gauge_width|default_graph_height|default_graph_width|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|extra_newline|font|format_human_readable|gap_x|gap_y|http_refresh|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_draw_hook_post|lua_draw_hook_pre|lua_load|lua_shutdown_hook|lua_startup_hook|mail_spool|max_port_monitor_connections|max_text_width|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|mysql_host|mysql_port|mysql_user|mysql_password|mysql_db|net_avg_samples|no_buffers|nvidia_display|out_to_console|out_to_http|out_to_ncurses|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|times_in_seconds|top_cpu_separate|top_name_width|total_run_times|update_interval|update_interval_on_battery|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>" ## Configuration item constants color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|middle_middle|undecorated|yes)\>" diff --git a/extras/vim/syntax/conkyrc.vim b/extras/vim/syntax/conkyrc.vim index cb22cfb5..bec6fc58 100644 --- a/extras/vim/syntax/conkyrc.vim +++ b/extras/vim/syntax/conkyrc.vim @@ -12,7 +12,7 @@ endif syn region ConkyrcComment start=/^\s*#/ end=/$/ -syn keyword ConkyrcSetting alignment append_file background border_inner_margin border_outer_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_height default_bar_width default_color default_gauge_size default_graph_height default_graph_width default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades extra_newline font format_human_readable gap_x gap_y http_refresh if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_draw_hook_post lua_draw_hook_pre lua_load lua_shutdown_hook lua_startup_hook mail_spool max_port_monitor_connections max_text_width max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval mysql_host mysql_port mysql_user mysql_password mysql_db net_avg_samples no_buffers nvidia_display out_to_console out_to_http out_to_ncurses out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size times_in_seconds top_cpu_separate top_name_width total_run_times update_interval update_interval_on_battery uppercase use_spacer use_xft xftalpha xftfont +syn keyword ConkyrcSetting alignment append_file background border_inner_margin border_outer_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_height default_bar_width default_color default_gauge_height default_gauge_width default_graph_height default_graph_width default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades extra_newline font format_human_readable gap_x gap_y http_refresh if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_draw_hook_post lua_draw_hook_pre lua_load lua_shutdown_hook lua_startup_hook mail_spool max_port_monitor_connections max_text_width max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval mysql_host mysql_port mysql_user mysql_password mysql_db net_avg_samples no_buffers nvidia_display out_to_console out_to_http out_to_ncurses out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size times_in_seconds top_cpu_separate top_name_width total_run_times update_interval update_interval_on_battery uppercase use_spacer use_xft xftalpha xftfont syn keyword ConkyrcConstant \ above diff --git a/src/conky.cc b/src/conky.cc index 506ab4b9..a51afed8 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -2797,21 +2797,6 @@ char load_config_file(const char *f) CONF_ERR; } } -#ifdef BUILD_X11 - CONF("default_gauge_size") { - char err = 0; - if (value) { - if (sscanf(value, "%d %d", &default_gauge_width, &default_gauge_height) != 2) { - err = 1; - } - } else { - err = 1; - } - if (err) { - CONF_ERR2("default_gauge_size takes 2 integer arguments (ie. 'default_gauge_size 0 6')") - } - } -#endif CONF("music_player_interval") { if (value) { info.music_player_interval = strtod(value, 0); diff --git a/src/specials.cc b/src/specials.cc index ca144bae..62dd3981 100644 --- a/src/specials.cc +++ b/src/specials.cc @@ -56,9 +56,13 @@ namespace { std::numeric_limits::max(), 0, false); conky::range_config_setting default_graph_height("default_graph_height", 0, std::numeric_limits::max(), 25, false); + + conky::range_config_setting default_gauge_width("default_gauge_width", 0, + std::numeric_limits::max(), 40, false); + conky::range_config_setting default_gauge_height("default_gauge_height", 0, + std::numeric_limits::max(), 25, false); #endif /* BUILD_X11 */ } -int default_gauge_width = 40, default_gauge_height = 25; /* special data types flags */ #define SF_SCALED (1 << 0) @@ -108,8 +112,8 @@ const char *scan_gauge(struct text_object *obj, const char *args, double scale) memset(g, 0, sizeof(struct gauge)); /*width and height*/ - g->width = default_gauge_width; - g->height = default_gauge_height; + g->width = default_gauge_width.get(*state); + g->height = default_gauge_height.get(*state); if (scale) g->scale = scale; diff --git a/src/specials.h b/src/specials.h index 73093b0b..d5f5c967 100644 --- a/src/specials.h +++ b/src/specials.h @@ -80,11 +80,6 @@ struct special_t { extern struct special_t *specials; extern int special_count; -#ifdef BUILD_X11 -extern int default_gauge_width; -extern int default_gauge_height; -#endif /* BUILD_X11 */ - /* forward declare to avoid mutual inclusion between specials.h and text_object.h */ struct text_object;