aboutsummaryrefslogtreecommitdiff
path: root/src/slidermenuitem.c
blob: 206ad630dd40edec458b6e38da3bc6f1d8fde87a (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
80
81
82

#include "slidermenuitem.h"

/* *** Enums *** */

enum {
  VALUE_CHANGED,
  LAST_SIGNAL
};

enum {
  PROP_0,
};

/* *** Prototypes *** */



/* *** globals *** */

static guint slider_menu_item_signals[LAST_SIGNAL] = {0};

G_DEFINE_TYPE (SliderMenuItem, slider_menu_item, TYPE_SLIDER_MENU_ITEM)

void
slider_menu_item_init (SliderMenuItem * smi)
{

	return;
}

static void
slider_menu_item_class_init (SliderMenuItemClass * klass)
{

	return;
}

GtkWidget *
slider_menu_item_new (const gchar * label, gdouble min, gdouble max, gdouble step)
{
	GtkWidget * smi;

	smi = g_object_new(TYPE_SLIDER_MENU_ITEM, NULL);

	GtkWidget * label_hbox = gtk_hbox_new(FALSE, 12);

	/* Note: look into gtk_accel_label */
	GtkWidget * wlabel = gtk_label_new(label);
	gtk_box_pack_start(GTK_BOX(label_hbox), wlabel, TRUE, FALSE, 0);
	gtk_widget_show(wlabel);

	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(min, max, step);
	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(smi), label_hbox);
	gtk_widget_show(label_hbox);

	return smi;
}