我正在运行 Ubuntu 14.10,我发现可以更改用于通知的默认图标(基本上通过添加notification-audio-volume-high.svg
等到当前主题(见截图))
虽然这很棒,但我想知道是否可以改变栏的外观(显示通知气泡中亮度/音量的值),以使其更像左边的图标。
是否有某个地方存储了此栏的图标?是否有某个地方的 XML 文件描述了其外观?
谢谢
答案1
通过查看其软件包内容,它似乎是在守护进程中硬编码的。它被称为测量。您需要重建它。
获取源码:
apt-get source notify-osd sudo apt-get build-dep notify-osd cd notify-osd-0.9.35+14.04.20140213/
修改您需要的东西
src/default.c
、尺寸和尺寸限制#define DEFAULT_GAUGE_SIZE 0.625f #define DEFAULT_GAUGE_OUTLINE_WIDTH 0.125f [...] property_gauge_size = g_param_spec_double ( "gauge-size", "gauge-size", "Size/height (in em) of gauge/indicator", 0.5f, 1.0f, [...] property_gauge_outline_width = g_param_spec_double ( "gauge-outline-width", "gauge-outline-width", "Width/thickness (in em) of gauge-outline", 0.1f, 0.2f,
src/bubble.c
,绘制它的函数。// color-, alpha-, radius-, width-, height- and gradient-values were determined // by very close obvervation of a SVG-mockup from the design-team static void _draw_value_indicator (cairo_t* cr, gint value, // value to render: 0 - 100 gint start_x, // top of surrounding rect gint start_y, // left of surrounding rect gint width, // width of surrounding rect gint height, // height of surrounding rect gint outline_thickness) // outline-thickness { [...]
重建 deb 包
debuild -us -uc sudo dpkg --force-depends -i ../notify-osd_0.9.35+14.04.20140213-0ubuntu1_amd64.deb
例子:
颜色,试试这个例子安静的红色,渐变点:RGB (0.9f,0.6f,0.6f),(0.5f,0.3f,0.3f) & (0.4f,0.2f,0.2f)
在
bubble.c
,_draw_value_indicator()
功能如下// draw value-bar
:gradient = cairo_pattern_create_linear (0.0f, start_y + outline_thickness, 0.0f, start_y + outline_height - 2 * outline_thickness); cairo_pattern_add_color_stop_rgba (gradient, 0.0f, 0.9f, 0.6f, 0.6f, 1.0f); cairo_pattern_add_color_stop_rgba (gradient, 0.75f, 0.5f, 0.3f, 0.3f, 1.0f); cairo_pattern_add_color_stop_rgba (gradient, 1.0f, 0.4f, 0.2f, 0.2f, 1.0f); cairo_set_source (cr, gradient); cairo_fill (cr);
看cairo_pattern_add_color_stop_rgba ()在开罗文档中。
评论轮廓绘图说明使用
/*
&*/
因此没有黑色轮廓,bar_radius = outline_height / 2;
以获得圆形的条形。// draw bar-background /* cairo_set_line_width (cr, outline_thickness); cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.5f); draw_round_rect (cr, [...] cairo_fill (cr); cairo_pattern_destroy (gradient); */ //bar_radius = outline_radius; bar_radius = outline_height / 2; bar_width = outline_width - 2 * outline_radius; //bar_height = outline_height - outline_radius; // draw value-bar
大小适合
1.2f
,与图标相配#define DEFAULT_GAUGE_SIZE 1.2f [...] property_gauge_size = g_param_spec_double ( "gauge-size", "gauge-size", "Size/height (in em) of gauge/indicator", 0.5f, 5.0f,
这里是为什么它被裁剪的原因,这应该是一个错误。
在 中
bubble.c
,EM2PIXELS (defaults_get_icon_size (d), d) / 5.0f
它应该用来EM2PIXELS (defaults_get_gauge_size (d), d)
设置仪表绘图区域的高度。将该行替换为:
void _refresh_indicator (Bubble* self) { [...] // create temp. scratch surface normal = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, EM2PIXELS (defaults_get_bubble_width (d), d) - 3 * EM2PIXELS (defaults_get_margin_size (d), d) - EM2PIXELS (defaults_get_icon_size (d), d) + 2 * BUBBLE_CONTENT_BLUR_RADIUS, EM2PIXELS (defaults_get_icon_size (d), d) / 5.0f + 2 * BUBBLE_CONTENT_BLUR_RADIUS);
到:
void _refresh_indicator (Bubble* self) { [...] // create temp. scratch surface normal = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, EM2PIXELS (defaults_get_bubble_width (d), d) - 3 * EM2PIXELS (defaults_get_margin_size (d), d) - EM2PIXELS (defaults_get_icon_size (d), d) + 2 * BUBBLE_CONTENT_BLUR_RADIUS, EM2PIXELS (defaults_get_gauge_size (d), d) + 2 * BUBBLE_CONTENT_BLUR_RADIUS);