gnome-settings-daemon r564 - in trunk: . plugins/media-keys
- From: jensg svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-settings-daemon r564 - in trunk: . plugins/media-keys
- Date: Thu, 23 Oct 2008 18:31:35 +0000 (UTC)
Author: jensg
Date: Thu Oct 23 18:31:35 2008
New Revision: 564
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=564&view=rev
Log:
2008-10-23 Jens Granseuer <jensgr gmx net>
Based on a patch by: Bogdan Butnaru <bogdanb gmail com>
* plugins/media-keys/gsd-media-keys-window.c: (draw_waves),
(draw_cross), (draw_action_volume): make the composited volume images
more clear: draw waves matching current volume and show a cross when
muted (bug #557307)
Modified:
trunk/ChangeLog
trunk/plugins/media-keys/gsd-media-keys-window.c
Modified: trunk/plugins/media-keys/gsd-media-keys-window.c
==============================================================================
--- trunk/plugins/media-keys/gsd-media-keys-window.c (original)
+++ trunk/plugins/media-keys/gsd-media-keys-window.c Thu Oct 23 18:31:35 2008
@@ -465,29 +465,38 @@
draw_waves (cairo_t *cr,
double cx,
double cy,
- double max_radius)
+ double max_radius,
+ int volume_level)
{
- int n_waves;
- int i;
+ const int n_waves = 3;
+ int last_wave;
+ int i;
- n_waves = 3;
+ last_wave = n_waves * volume_level / 100;
for (i = 0; i < n_waves; i++) {
double angle1;
double angle2;
double radius;
+ double alpha;
angle1 = -M_PI / 4;
angle2 = M_PI / 4;
+ if (i < last_wave)
+ alpha = 1.0;
+ else if (i > last_wave)
+ alpha = 0.1;
+ else alpha = 0.1 + 0.9 * (n_waves * volume_level % 100) / 100.0;
+
radius = (i + 1) * (max_radius / n_waves);
cairo_arc (cr, cx, cy, radius, angle1, angle2);
- cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, FG_ALPHA / 2);
+ cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, alpha / 2);
cairo_set_line_width (cr, 14);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_stroke_preserve (cr);
- cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, FG_ALPHA);
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, alpha);
cairo_set_line_width (cr, 10);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_stroke (cr);
@@ -495,6 +504,29 @@
}
static void
+draw_cross (cairo_t *cr,
+ double cx,
+ double cy,
+ double size)
+{
+ cairo_move_to (cr, cx, cy - size/2.0);
+ cairo_rel_line_to (cr, size, size);
+
+ cairo_move_to (cr, cx, cy + size/2.0);
+ cairo_rel_line_to (cr, size, -size);
+
+ cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, FG_ALPHA / 2);
+ cairo_set_line_width (cr, 14);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_stroke_preserve (cr);
+
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, FG_ALPHA);
+ cairo_set_line_width (cr, 10);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_stroke (cr);
+}
+
+static void
draw_speaker (cairo_t *cr,
double cx,
double cy,
@@ -671,19 +703,12 @@
double speaker_height;
double speaker_cx;
double speaker_cy;
- double wave_x0;
- double wave_y0;
- double wave_radius;
speaker_width = icon_box_width * 0.5;
speaker_height = icon_box_height * 0.75;
speaker_cx = icon_box_x0 + speaker_width / 2;
speaker_cy = icon_box_y0 + speaker_height / 2;
- wave_x0 = window_width / 2;
- wave_y0 = speaker_cy;
- wave_radius = icon_box_width / 2;
-
#if 0
g_message ("speaker box: w=%f h=%f cx=%f cy=%f",
speaker_width,
@@ -694,9 +719,29 @@
/* draw speaker symbol */
draw_speaker (cr, speaker_cx, speaker_cy, speaker_width, speaker_height);
- /* draw sound waves */
+
if (! window->priv->volume_muted) {
- draw_waves (cr, wave_x0, wave_y0, wave_radius);
+ /* draw sound waves */
+ double wave_x0;
+ double wave_y0;
+ double wave_radius;
+
+ wave_x0 = window_width / 2;
+ wave_y0 = speaker_cy;
+ wave_radius = icon_box_width / 2;
+
+ draw_waves (cr, wave_x0, wave_y0, wave_radius, window->priv->volume_level);
+ } else {
+ /* draw 'mute' cross */
+ double cross_x0;
+ double cross_y0;
+ double cross_size;
+
+ cross_size = speaker_width * 3 / 4;
+ cross_x0 = icon_box_x0 + icon_box_width - cross_size;
+ cross_y0 = speaker_cy;
+
+ draw_cross (cr, cross_x0, cross_y0, cross_size);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]