1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3
* Copyright (C) 2006-2007 William Jon McCann <mccann@jhu.edu>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
#include <glib/gi18n.h>
30
#include "gsd-media-keys-window.h"
32
#include "data/interfaces/acme_ui.h"
34
#define DIALOG_TIMEOUT 2000 /* dialog timeout in ms */
35
#define DIALOG_FADE_TIMEOUT 1500 /* timeout before fade starts */
36
#define FADE_TIMEOUT 10 /* timeout in ms between each frame of the fade */
41
#define GSD_MEDIA_KEYS_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_MEDIA_KEYS_WINDOW, GsdMediaKeysWindowPrivate))
43
struct GsdMediaKeysWindowPrivate
45
guint is_composited : 1;
46
guint hide_timeout_id;
47
guint fade_timeout_id;
48
double fade_out_alpha;
49
GsdMediaKeysWindowAction action;
53
guint volume_muted : 1;
60
G_DEFINE_TYPE (GsdMediaKeysWindow, gsd_media_keys_window, GTK_TYPE_WINDOW)
63
fade_timeout (GsdMediaKeysWindow *window)
65
if (window->priv->fade_out_alpha <= 0.0) {
66
gtk_widget_hide (GTK_WIDGET (window));
68
/* Reset it for the next time */
69
window->priv->fade_out_alpha = 1.0;
70
window->priv->fade_timeout_id = 0;
75
GtkWidget *win = GTK_WIDGET (window);
76
GtkAllocation allocation;
78
window->priv->fade_out_alpha -= 0.10;
82
gtk_widget_get_allocation (win, &allocation);
83
rect.width = allocation.width;
84
rect.height = allocation.height;
86
gtk_widget_realize (win);
87
gdk_window_invalidate_rect (gtk_widget_get_window (win), &rect, FALSE);
94
hide_timeout (GsdMediaKeysWindow *window)
96
if (window->priv->is_composited) {
97
window->priv->hide_timeout_id = 0;
98
window->priv->fade_timeout_id = g_timeout_add (FADE_TIMEOUT,
99
(GSourceFunc) fade_timeout,
102
gtk_widget_hide (GTK_WIDGET (window));
109
remove_hide_timeout (GsdMediaKeysWindow *window)
111
if (window->priv->hide_timeout_id != 0) {
112
g_source_remove (window->priv->hide_timeout_id);
113
window->priv->hide_timeout_id = 0;
116
if (window->priv->fade_timeout_id != 0) {
117
g_source_remove (window->priv->fade_timeout_id);
118
window->priv->fade_timeout_id = 0;
119
window->priv->fade_out_alpha = 1.0;
124
add_hide_timeout (GsdMediaKeysWindow *window)
128
if (window->priv->is_composited) {
129
timeout = DIALOG_FADE_TIMEOUT;
131
timeout = DIALOG_TIMEOUT;
133
window->priv->hide_timeout_id = g_timeout_add (timeout,
134
(GSourceFunc) hide_timeout,
139
update_window (GsdMediaKeysWindow *window)
141
remove_hide_timeout (window);
142
add_hide_timeout (window);
144
if (window->priv->is_composited) {
145
gtk_widget_queue_draw (GTK_WIDGET (window));
150
volume_controls_set_visible (GsdMediaKeysWindow *window,
153
if (window->priv->progress == NULL)
157
gtk_widget_show (window->priv->progress);
159
gtk_widget_hide (window->priv->progress);
164
window_set_icon_name (GsdMediaKeysWindow *window,
167
if (window->priv->image == NULL)
170
gtk_image_set_from_icon_name (window->priv->image,
171
name, GTK_ICON_SIZE_DIALOG);
175
action_changed (GsdMediaKeysWindow *window)
177
if (! window->priv->is_composited) {
178
switch (window->priv->action) {
179
case GSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME:
180
volume_controls_set_visible (window, TRUE);
182
if (window->priv->volume_muted) {
183
window_set_icon_name (window, "audio-volume-muted");
185
window_set_icon_name (window, "audio-volume-high");
189
case GSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM:
190
volume_controls_set_visible (window, window->priv->show_level);
191
window_set_icon_name (window, window->priv->icon_name);
194
g_assert_not_reached ();
199
update_window (window);
203
volume_level_changed (GsdMediaKeysWindow *window)
205
update_window (window);
207
if (!window->priv->is_composited && window->priv->progress != NULL) {
210
fraction = (double) window->priv->volume_level / 100.0;
212
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->progress),
218
volume_muted_changed (GsdMediaKeysWindow *window)
220
update_window (window);
222
if (! window->priv->is_composited) {
223
if (window->priv->volume_muted) {
224
window_set_icon_name (window, "audio-volume-muted");
226
window_set_icon_name (window, "audio-volume-high");
232
gsd_media_keys_window_set_action (GsdMediaKeysWindow *window,
233
GsdMediaKeysWindowAction action)
235
g_return_if_fail (GSD_IS_MEDIA_KEYS_WINDOW (window));
236
g_return_if_fail (action == GSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME);
238
if (window->priv->action != action) {
239
window->priv->action = action;
240
action_changed (window);
242
update_window (window);
247
gsd_media_keys_window_set_action_custom (GsdMediaKeysWindow *window,
248
const char *icon_name,
251
g_return_if_fail (GSD_IS_MEDIA_KEYS_WINDOW (window));
252
g_return_if_fail (icon_name != NULL);
254
if (window->priv->action != GSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM ||
255
g_strcmp0 (window->priv->icon_name, icon_name) != 0 ||
256
window->priv->show_level != show_level) {
257
window->priv->action = GSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM;
258
g_free (window->priv->icon_name);
259
window->priv->icon_name = g_strdup (icon_name);
260
window->priv->show_level = show_level;
261
action_changed (window);
263
update_window (window);
268
gsd_media_keys_window_set_volume_muted (GsdMediaKeysWindow *window,
271
g_return_if_fail (GSD_IS_MEDIA_KEYS_WINDOW (window));
273
if (window->priv->volume_muted != muted) {
274
window->priv->volume_muted = muted;
275
volume_muted_changed (window);
280
gsd_media_keys_window_set_volume_level (GsdMediaKeysWindow *window,
283
g_return_if_fail (GSD_IS_MEDIA_KEYS_WINDOW (window));
285
if (window->priv->volume_level != level) {
286
window->priv->volume_level = level;
287
volume_level_changed (window);
292
rounded_rectangle (cairo_t* cr,
296
gdouble corner_radius,
300
gdouble radius = corner_radius / aspect;
302
cairo_move_to (cr, x + radius, y);
311
-90.0f * G_PI / 180.0f,
312
0.0f * G_PI / 180.0f);
315
y + height - radius);
320
0.0f * G_PI / 180.0f,
321
90.0f * G_PI / 180.0f);
329
90.0f * G_PI / 180.0f,
330
180.0f * G_PI / 180.0f);
338
180.0f * G_PI / 180.0f,
339
270.0f * G_PI / 180.0f);
340
cairo_close_path (cr);
344
load_pixbuf (GsdMediaKeysWindow *window,
351
if (window != NULL && gtk_widget_has_screen (GTK_WIDGET (window))) {
352
theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
354
theme = gtk_icon_theme_get_default ();
357
pixbuf = gtk_icon_theme_load_icon (theme,
360
GTK_ICON_LOOKUP_FORCE_SVG,
363
/* make sure the pixbuf is close to the requested size
364
* this is necessary because GTK_ICON_LOOKUP_FORCE_SVG
365
* seems to be broken */
366
if (pixbuf != NULL) {
369
width = gdk_pixbuf_get_width (pixbuf);
370
if (width < (float)icon_size * 0.75) {
371
g_object_unref (pixbuf);
380
draw_eject (cairo_t *cr,
390
box_height = height * 0.2;
391
separation = box_height / 3;
392
tri_height = height - box_height - separation;
394
cairo_rectangle (cr, _x0, _y0 + height - box_height, width, box_height);
396
cairo_move_to (cr, _x0, _y0 + tri_height);
397
cairo_rel_line_to (cr, width, 0);
398
cairo_rel_line_to (cr, -width / 2, -tri_height);
399
cairo_rel_line_to (cr, -width / 2, tri_height);
400
cairo_close_path (cr);
401
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, FG_ALPHA);
402
cairo_fill_preserve (cr);
404
cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, FG_ALPHA / 2);
405
cairo_set_line_width (cr, 2);
410
draw_waves (cairo_t *cr,
416
const int n_waves = 3;
420
last_wave = n_waves * volume_level / 100;
422
for (i = 0; i < n_waves; i++) {
433
else if (i > last_wave)
435
else alpha = 0.1 + 0.9 * (n_waves * volume_level % 100) / 100.0;
437
radius = (i + 1) * (max_radius / n_waves);
438
cairo_arc (cr, cx, cy, radius, angle1, angle2);
439
cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, alpha / 2);
440
cairo_set_line_width (cr, 14);
441
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
442
cairo_stroke_preserve (cr);
444
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, alpha);
445
cairo_set_line_width (cr, 10);
446
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
452
draw_cross (cairo_t *cr,
457
cairo_move_to (cr, cx, cy - size/2.0);
458
cairo_rel_line_to (cr, size, size);
460
cairo_move_to (cr, cx, cy + size/2.0);
461
cairo_rel_line_to (cr, size, -size);
463
cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, FG_ALPHA / 2);
464
cairo_set_line_width (cr, 14);
465
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
466
cairo_stroke_preserve (cr);
468
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, FG_ALPHA);
469
cairo_set_line_width (cr, 10);
470
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
475
draw_speaker (cairo_t *cr,
486
box_width = width / 3;
487
box_height = height / 3;
489
_x0 = cx - (width / 2) + box_width;
490
_y0 = cy - box_height / 2;
492
cairo_move_to (cr, _x0, _y0);
493
cairo_rel_line_to (cr, - box_width, 0);
494
cairo_rel_line_to (cr, 0, box_height);
495
cairo_rel_line_to (cr, box_width, 0);
497
cairo_line_to (cr, cx + box_width, cy + height / 2);
498
cairo_rel_line_to (cr, 0, -height);
499
cairo_line_to (cr, _x0, _y0);
500
cairo_close_path (cr);
502
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, FG_ALPHA);
503
cairo_fill_preserve (cr);
505
cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, FG_ALPHA / 2);
506
cairo_set_line_width (cr, 2);
511
render_speaker (GsdMediaKeysWindow *window,
521
static const char *icon_names[] = {
522
"audio-volume-muted",
524
"audio-volume-medium",
529
if (window->priv->volume_muted) {
533
n = 3 * window->priv->volume_level / 100 + 1;
541
icon_size = (int)width;
543
pixbuf = load_pixbuf (window, icon_names[n], icon_size);
545
if (pixbuf == NULL) {
549
gdk_cairo_set_source_pixbuf (cr, pixbuf, _x0, _y0);
550
cairo_paint_with_alpha (cr, FG_ALPHA);
552
g_object_unref (pixbuf);
558
color_reverse (const GdkColor *a,
568
red = (gdouble) a->red / 65535.0;
569
green = (gdouble) a->green / 65535.0;
570
blue = (gdouble) a->blue / 65535.0;
572
gtk_rgb_to_hsv (red, green, blue, &h, &s, &v);
580
gtk_hsv_to_rgb (h, s, v, &red, &green, &blue);
582
b->red = red * 65535.0;
583
b->green = green * 65535.0;
584
b->blue = blue * 65535.0;
588
draw_volume_boxes (GsdMediaKeysWindow *window,
603
height = round (height) - 1;
604
width = round (width) - 1;
605
x1 = round ((width - 1) * percentage);
606
style = gtk_widget_get_style (GTK_WIDGET (window));
609
color_reverse (&style->dark[GTK_STATE_NORMAL], &color);
610
r = (float)color.red / 65535.0;
611
g = (float)color.green / 65535.0;
612
b = (float)color.blue / 65535.0;
613
rounded_rectangle (cr, 1.0, _x0, _y0, height / 6, width, height);
614
cairo_set_source_rgba (cr, r, g, b, FG_ALPHA / 2);
615
cairo_fill_preserve (cr);
618
color_reverse (&style->light[GTK_STATE_NORMAL], &color);
619
r = (float)color.red / 65535.0;
620
g = (float)color.green / 65535.0;
621
b = (float)color.blue / 65535.0;
622
cairo_set_source_rgba (cr, r, g, b, FG_ALPHA / 2);
623
cairo_set_line_width (cr, 1);
627
if (percentage < 0.01)
629
color = style->bg[GTK_STATE_NORMAL];
630
r = (float)color.red / 65535.0;
631
g = (float)color.green / 65535.0;
632
b = (float)color.blue / 65535.0;
633
rounded_rectangle (cr, 1.0, _x0 + 0.5, _y0 + 0.5, height / 6 - 0.5, x1, height - 1);
634
cairo_set_source_rgba (cr, r, g, b, FG_ALPHA);
639
draw_action_volume (GsdMediaKeysWindow *window,
644
double icon_box_width;
645
double icon_box_height;
648
double volume_box_x0;
649
double volume_box_y0;
650
double volume_box_width;
651
double volume_box_height;
654
gtk_window_get_size (GTK_WINDOW (window), &window_width, &window_height);
656
icon_box_width = round (window_width * 0.65);
657
icon_box_height = round (window_height * 0.65);
658
volume_box_width = icon_box_width;
659
volume_box_height = round (window_height * 0.05);
661
icon_box_x0 = (window_width - icon_box_width) / 2;
662
icon_box_y0 = (window_height - icon_box_height - volume_box_height) / 2;
663
volume_box_x0 = round (icon_box_x0);
664
volume_box_y0 = round (icon_box_height + icon_box_y0);
667
g_message ("icon box: w=%f h=%f _x0=%f _y0=%f",
672
g_message ("volume box: w=%f h=%f _x0=%f _y0=%f",
679
res = render_speaker (window,
681
icon_box_x0, icon_box_y0,
682
icon_box_width, icon_box_height);
684
double speaker_width;
685
double speaker_height;
689
speaker_width = icon_box_width * 0.5;
690
speaker_height = icon_box_height * 0.75;
691
speaker_cx = icon_box_x0 + speaker_width / 2;
692
speaker_cy = icon_box_y0 + speaker_height / 2;
695
g_message ("speaker box: w=%f h=%f cx=%f cy=%f",
702
/* draw speaker symbol */
703
draw_speaker (cr, speaker_cx, speaker_cy, speaker_width, speaker_height);
705
if (! window->priv->volume_muted) {
706
/* draw sound waves */
711
wave_x0 = window_width / 2;
712
wave_y0 = speaker_cy;
713
wave_radius = icon_box_width / 2;
715
draw_waves (cr, wave_x0, wave_y0, wave_radius, window->priv->volume_level);
717
/* draw 'mute' cross */
722
cross_size = speaker_width * 3 / 4;
723
cross_x0 = icon_box_x0 + icon_box_width - cross_size;
724
cross_y0 = speaker_cy;
726
draw_cross (cr, cross_x0, cross_y0, cross_size);
730
/* draw volume meter */
731
draw_volume_boxes (window,
733
(double)window->priv->volume_level / 100.0,
741
render_custom (GsdMediaKeysWindow *window,
751
icon_size = (int)width;
753
pixbuf = load_pixbuf (window, window->priv->icon_name, icon_size);
755
if (pixbuf == NULL) {
757
if (gtk_widget_get_direction (GTK_WIDGET (window)) == GTK_TEXT_DIR_RTL)
758
name = g_strdup_printf ("%s-rtl", window->priv->icon_name);
760
name = g_strdup_printf ("%s-ltr", window->priv->icon_name);
761
pixbuf = load_pixbuf (window, name, icon_size);
767
gdk_cairo_set_source_pixbuf (cr, pixbuf, _x0, _y0);
768
cairo_paint_with_alpha (cr, FG_ALPHA);
770
g_object_unref (pixbuf);
776
draw_action_custom (GsdMediaKeysWindow *window,
781
double icon_box_width;
782
double icon_box_height;
785
double bright_box_x0;
786
double bright_box_y0;
787
double bright_box_width;
788
double bright_box_height;
791
gtk_window_get_size (GTK_WINDOW (window), &window_width, &window_height);
793
icon_box_width = round (window_width * 0.65);
794
icon_box_height = round (window_height * 0.65);
795
bright_box_width = round (icon_box_width);
796
bright_box_height = round (window_height * 0.05);
798
icon_box_x0 = (window_width - icon_box_width) / 2;
799
icon_box_y0 = (window_height - icon_box_height - bright_box_height) / 2;
800
bright_box_x0 = round (icon_box_x0);
801
bright_box_y0 = round (icon_box_height + icon_box_y0);
804
g_message ("icon box: w=%f h=%f _x0=%f _y0=%f",
809
g_message ("brightness box: w=%f h=%f _x0=%f _y0=%f",
816
res = render_custom (window,
818
icon_box_x0, icon_box_y0,
819
icon_box_width, icon_box_height);
820
if (! res && g_strcmp0 (window->priv->icon_name, "media-eject") == 0) {
821
/* draw eject symbol */
823
icon_box_x0, icon_box_y0,
824
icon_box_width, icon_box_height);
827
if (window->priv->show_level != FALSE) {
828
/* draw volume meter */
829
draw_volume_boxes (window,
831
(double)window->priv->volume_level / 100.0,
840
draw_action (GsdMediaKeysWindow *window,
843
switch (window->priv->action) {
844
case GSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME:
845
draw_action_volume (window, cr);
847
case GSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM:
848
draw_action_custom (window, cr);
856
on_expose_event (GtkWidget *widget,
857
GdkEventExpose *event,
858
GsdMediaKeysWindow *window)
862
cairo_surface_t *surface;
869
context = gdk_cairo_create (gtk_widget_get_window (widget));
871
style = gtk_widget_get_style (widget);
872
cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
873
gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
875
surface = cairo_surface_create_similar (cairo_get_target (context),
876
CAIRO_CONTENT_COLOR_ALPHA,
880
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
884
cr = cairo_create (surface);
885
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
888
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
889
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
893
rounded_rectangle (cr, 1.0, 0.5, 0.5, height / 10, width-1, height-1);
894
color_reverse (&style->bg[GTK_STATE_NORMAL], &color);
895
r = (float)color.red / 65535.0;
896
g = (float)color.green / 65535.0;
897
b = (float)color.blue / 65535.0;
898
cairo_set_source_rgba (cr, r, g, b, BG_ALPHA);
899
cairo_fill_preserve (cr);
901
color_reverse (&style->text_aa[GTK_STATE_NORMAL], &color);
902
r = (float)color.red / 65535.0;
903
g = (float)color.green / 65535.0;
904
b = (float)color.blue / 65535.0;
905
cairo_set_source_rgba (cr, r, g, b, BG_ALPHA / 2);
906
cairo_set_line_width (cr, 1);
910
draw_action (window, cr);
914
/* Make sure we have a transparent background */
915
cairo_rectangle (context, 0, 0, width, height);
916
cairo_set_source_rgba (context, 0.0, 0.0, 0.0, 0.0);
917
cairo_fill (context);
919
cairo_set_source_surface (context, surface, 0, 0);
920
cairo_paint_with_alpha (context, window->priv->fade_out_alpha);
923
if (surface != NULL) {
924
cairo_surface_destroy (surface);
926
cairo_destroy (context);
932
gsd_media_keys_window_real_show (GtkWidget *widget)
934
GsdMediaKeysWindow *window;
936
if (GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->show) {
937
GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->show (widget);
940
window = GSD_MEDIA_KEYS_WINDOW (widget);
941
remove_hide_timeout (window);
942
add_hide_timeout (window);
946
gsd_media_keys_window_real_hide (GtkWidget *widget)
948
GsdMediaKeysWindow *window;
950
if (GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->hide) {
951
GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->hide (widget);
954
window = GSD_MEDIA_KEYS_WINDOW (widget);
955
remove_hide_timeout (window);
959
gsd_media_keys_window_real_realize (GtkWidget *widget)
961
GdkColormap *colormap;
962
GtkAllocation allocation;
966
colormap = gdk_screen_get_rgba_colormap (gtk_widget_get_screen (widget));
968
if (colormap != NULL) {
969
gtk_widget_set_colormap (widget, colormap);
972
if (GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->realize) {
973
GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->realize (widget);
976
gtk_widget_get_allocation (widget, &allocation);
977
mask = gdk_pixmap_new (gtk_widget_get_window (widget),
981
cr = gdk_cairo_create (mask);
983
cairo_set_source_rgba (cr, 1., 1., 1., 0.);
984
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
987
/* make the whole window ignore events */
988
gdk_window_input_shape_combine_mask (gtk_widget_get_window (widget), mask, 0, 0);
989
g_object_unref (mask);
994
gsd_media_keys_window_class_init (GsdMediaKeysWindowClass *klass)
996
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
998
widget_class->show = gsd_media_keys_window_real_show;
999
widget_class->hide = gsd_media_keys_window_real_hide;
1000
widget_class->realize = gsd_media_keys_window_real_realize;
1002
g_type_class_add_private (klass, sizeof (GsdMediaKeysWindowPrivate));
1006
gsd_media_keys_window_is_valid (GsdMediaKeysWindow *window)
1008
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (window));
1009
return gdk_screen_is_composited (screen) == window->priv->is_composited;
1013
gsd_media_keys_window_init (GsdMediaKeysWindow *window)
1017
window->priv = GSD_MEDIA_KEYS_WINDOW_GET_PRIVATE (window);
1019
screen = gtk_widget_get_screen (GTK_WIDGET (window));
1021
window->priv->is_composited = gdk_screen_is_composited (screen);
1023
if (window->priv->is_composited) {
1024
gdouble scalew, scaleh, scale;
1027
gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
1028
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
1030
/* assume 130x130 on a 640x480 display and scale from there */
1031
scalew = gdk_screen_get_width (screen) / 640.0;
1032
scaleh = gdk_screen_get_height (screen) / 480.0;
1033
scale = MIN (scalew, scaleh);
1034
size = 130 * MAX (1, scale);
1036
gtk_window_set_default_size (GTK_WINDOW (window), size, size);
1037
g_signal_connect (window, "expose-event", G_CALLBACK (on_expose_event), window);
1039
window->priv->fade_out_alpha = 1.0;
1041
GtkBuilder *builder;
1042
const gchar *objects[] = {"acme_frame", NULL};
1045
builder = gtk_builder_new ();
1046
gtk_builder_add_objects_from_string (builder, acme_ui, acme_ui_length, (char **)objects, NULL);
1048
window->priv->image = GTK_IMAGE (gtk_builder_get_object (builder, "acme_image"));
1049
window->priv->progress = GTK_WIDGET (gtk_builder_get_object (builder, "acme_volume_progressbar"));
1050
frame = GTK_WIDGET (gtk_builder_get_object (builder,
1053
if (frame != NULL) {
1054
gtk_container_add (GTK_CONTAINER (window), frame);
1055
gtk_widget_show_all (frame);
1058
/* The builder needs to stay alive until the window
1059
takes ownership of the frame (and its children) */
1060
g_object_unref (builder);
1065
gsd_media_keys_window_new (void)
1069
object = g_object_new (GSD_TYPE_MEDIA_KEYS_WINDOW,
1070
"type", GTK_WINDOW_POPUP,
1071
"type-hint", GDK_WINDOW_TYPE_HINT_NOTIFICATION,
1072
"skip-taskbar-hint", TRUE,
1073
"skip-pager-hint", TRUE,
1074
"focus-on-map", FALSE,
1077
return GTK_WIDGET (object);