aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-audio.c
blob: 5d2dbdccf71d7326a0c5c21069451831be937283 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

#include <gtk/gtk.h>
#include "indicator-audio.h"

void
block_prelight (GtkWidget * widget, GtkStateType prev, gpointer data)
{
	if (GTK_WIDGET_STATE(widget) == GTK_STATE_PRELIGHT) {
		gtk_widget_set_state(widget, prev);
	}
	return;
}

GtkWidget *
create_output_menu_item (void)
{
	GtkWidget * menuitem = gtk_menu_item_new();
	g_signal_connect(G_OBJECT(menuitem), "state-changed", G_CALLBACK(block_prelight), NULL);

	GtkWidget * label_hbox = gtk_hbox_new(FALSE, 12);

	GtkWidget * label = gtk_label_new("Volume:");
	gtk_box_pack_start(GTK_BOX(label_hbox), label, TRUE, FALSE, 0);
	gtk_widget_show(label);

	GtkWidget * slider_hbox = gtk_hbox_new(FALSE, 3);

	GtkWidget * mute_button = gtk_button_new();
	GtkWidget * mute_icon = gtk_image_new_from_icon_name("audio-volume-low", GTK_ICON_SIZE_MENU);
	gtk_container_add(GTK_CONTAINER(mute_button), mute_icon);
	gtk_widget_show(mute_icon);
	gtk_box_pack_start(GTK_BOX(slider_hbox), mute_button, FALSE, FALSE, 3);
	gtk_widget_show(mute_button);

	GtkWidget * scale = gtk_hscale_new_with_range(0.0, 1.0, 0.1);
	gtk_scale_set_digits(GTK_SCALE(scale), 2);
	gtk_scale_set_draw_value(GTK_SCALE(scale), FALSE);
	gtk_box_pack_start(GTK_BOX(slider_hbox), scale, TRUE, TRUE, 3);
	gtk_widget_show(scale);

	GtkWidget * max_button = gtk_button_new();
	GtkWidget * max_icon = gtk_image_new_from_icon_name("audio-volume-high", GTK_ICON_SIZE_MENU);
	gtk_container_add(GTK_CONTAINER(max_button), max_icon);
	gtk_widget_show(max_icon);
	gtk_box_pack_start(GTK_BOX(slider_hbox), max_button, FALSE, FALSE, 3);
	gtk_widget_show(max_button);

	gtk_box_pack_start(GTK_BOX(label_hbox), slider_hbox, TRUE, TRUE, 0);
	gtk_widget_show(slider_hbox);

	gtk_container_add(GTK_CONTAINER(menuitem), label_hbox);
	gtk_widget_show(label_hbox);

	return menuitem;
}

GtkWidget *
indicator_audio_menuitem (void)
{
	GtkWidget * mainmenu = gtk_menu_item_new();

	GtkWidget * icon = gtk_image_new_from_icon_name("audio-volume-muted",
	                                                GTK_ICON_SIZE_MENU);

	gtk_container_add(GTK_CONTAINER(mainmenu), icon);
	gtk_widget_show(icon);

	GtkWidget * menu = gtk_menu_new();

	GtkWidget * item = create_output_menu_item();
	gtk_menu_append(GTK_MENU(menu), item);
	gtk_widget_show(item);

	gtk_menu_item_set_submenu(GTK_MENU_ITEM(mainmenu), menu);
	gtk_widget_show(menu);

	return mainmenu;
}