aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2008-11-20 17:04:30 -0600
committerTed Gould <ted@canonical.com>2008-11-20 17:04:30 -0600
commita29584a83acfabcfe173441ebe8e3a2369c39e80 (patch)
treedac18cd9405718e26b3e03c7bbe00cd052fddb58 /src
parent712bddcdd12a7f4ee16bf9b1e2bdce9fe35bde46 (diff)
downloadlibayatana-indicator-a29584a83acfabcfe173441ebe8e3a2369c39e80.tar.gz
libayatana-indicator-a29584a83acfabcfe173441ebe8e3a2369c39e80.tar.bz2
libayatana-indicator-a29584a83acfabcfe173441ebe8e3a2369c39e80.zip
Clean compile, but something is broken in the _init function. Not sure what.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/indicator-audio.c38
-rw-r--r--src/slidermenuitem.c82
-rw-r--r--src/slidermenuitem.h59
4 files changed, 146 insertions, 37 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ab1089d..d378011 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,7 +19,9 @@ indicator_applet_SOURCES = \
indicator-system.c \
indicator-system.h \
menu-dbus.c \
- menu-dbus.h
+ menu-dbus.h \
+ slidermenuitem.c \
+ slidermenuitem.h
indicator_applet_LDADD = \
$(APPLET_LIBS)
diff --git a/src/indicator-audio.c b/src/indicator-audio.c
index 5d2dbdc..48acaa3 100644
--- a/src/indicator-audio.c
+++ b/src/indicator-audio.c
@@ -1,5 +1,6 @@
#include <gtk/gtk.h>
+#include "slidermenuitem.h"
#include "indicator-audio.h"
void
@@ -14,42 +15,7 @@ block_prelight (GtkWidget * widget, GtkStateType prev, gpointer data)
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);
+ GtkWidget * menuitem = slider_menu_item_new("Volume:", 0.0, 1.0, 0.02);
return menuitem;
}
diff --git a/src/slidermenuitem.c b/src/slidermenuitem.c
new file mode 100644
index 0000000..206ad63
--- /dev/null
+++ b/src/slidermenuitem.c
@@ -0,0 +1,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;
+}
diff --git a/src/slidermenuitem.h b/src/slidermenuitem.h
new file mode 100644
index 0000000..7a560d2
--- /dev/null
+++ b/src/slidermenuitem.h
@@ -0,0 +1,59 @@
+
+#ifndef SLIDER_MENU_ITEM_H__
+#define SLIDER_MENU_ITEM_H__
+
+#include <gtk/gtk.h>
+#include <gtk/gtkmenuitem.h>
+
+G_BEGIN_DECLS
+
+#define TYPE_SLIDER_MENU_ITEM (slider_menu_item_get_type())
+#define SLIDER_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST((o), TYPE_SLIDER_MENU_ITEM), SliderMenuItem)
+#define SLIDER_MENU_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TYPE_SLIDER_MENU_ITEM), SliderMenuItemClass)
+#define IS_SLIDER_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), TYPE_SLIDER_MENU_ITEM))
+#define IS_SLIDER_MENU_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), TYPE_SLIDER_MENU_ITEM))
+#define SLIDER_MENU_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_SLIDER_MENU_ITEM), SliderMenuItemClass)
+
+typedef struct _SliderMenuItem SliderMenuItem;
+typedef struct _SliderMenuItemClass SliderMenuItemClass;
+
+struct _SliderMenuItem
+{
+ GtkMenuItem menu_item;
+
+ GtkWidget * label;
+ GtkWidget * slider;
+ GtkWidget * button_up;
+ GtkWidget * button_down;
+};
+
+struct _SliderMenuItemClass
+{
+ GtkMenuItemClass parent_class;
+
+ /* Everyone else does this :) */
+ void (*_gtk_reserved1) (void);
+ void (*_gtk_reserved2) (void);
+ void (*_gtk_reserved3) (void);
+ void (*_gtk_reserved4) (void);
+};
+
+
+GType slider_menu_item_get_type (void) G_GNUC_CONST;
+GtkWidget * slider_menu_item_new (const gchar * label,
+ gdouble min,
+ gdouble max,
+ gdouble step);
+GtkWidget * slider_menu_get_plus_button (SliderMenuItem * smi);
+GtkWidget * slider_menu_get_minus_button (SliderMenuItem * smi);
+GtkAdjustment * slider_menu_get_adjustment (SliderMenuItem * smi);
+gdouble slider_menu_get_value (SliderMenuItem * smi);
+void slider_menu_set_value (SliderMenuItem * smi,
+ gdouble value);
+void slider_menu_slider_size_group (SliderMenuItem * smi,
+ GtkSizeGroup * size_group);
+
+G_END_DECLS
+
+#endif /* GTK_SLIDER_MENU_ITEM_H__ */
+