aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-07-15 17:08:36 +0100
committerConor Curran <conor.curran@canonical.com>2010-07-15 17:08:36 +0100
commit4643e1d7c2569e28f50cabe6262b61fff98e595b (patch)
tree1eca723221d7b76312924e647403b551c638bd13 /src
parent0358622a18d0dbf2d1b413a708e248db974f97a8 (diff)
parent05b905d4712ed4064d82401621eacbdfbcb54312 (diff)
downloadayatana-indicator-sound-4643e1d7c2569e28f50cabe6262b61fff98e595b.tar.gz
ayatana-indicator-sound-4643e1d7c2569e28f50cabe6262b61fff98e595b.tar.bz2
ayatana-indicator-sound-4643e1d7c2569e28f50cabe6262b61fff98e595b.zip
merged the button press effect branch plus changes for the ido and bumped release version for 0.3.7
Diffstat (limited to 'src')
-rw-r--r--src/indicator-sound.c2
-rw-r--r--src/play-button.c148
-rw-r--r--src/play-button.h12
-rw-r--r--src/scrub-widget.c2
-rw-r--r--src/transport-widget.c37
5 files changed, 145 insertions, 56 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index e18125a..1c6041b 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -277,7 +277,7 @@ new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuC
io = g_object_get_data (G_OBJECT (client), "indicator");
- volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 1);
+ volume_slider = ido_scale_menu_item_new_with_range ("Volume", IDO_RANGE_STYLE_DEFAULT, initial_volume_percent, 0, 100, 1);
ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM (volume_slider), IDO_SCALE_MENU_ITEM_STYLE_IMAGE);
g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL);
diff --git a/src/play-button.c b/src/play-button.c
index d6d243c..cac2bc3 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -53,22 +53,23 @@ Uses code from ctk
#define PAUSE_X 77.0f
#define PAUSE_Y 15.0f
-// Transport events
-enum {
- PREVIOUS,
- PLAY_PAUSE,
- NEXT
+
+// Transport updates
+enum{
+ PAUSE,
+ PLAY
};
typedef struct _PlayButtonPrivate PlayButtonPrivate;
struct _PlayButtonPrivate
{
- GdkColor background_colour_fg;
- GdkColor background_colour_bg_dark;
- GdkColor background_colour_bg_light;
- GdkColor foreground_colour_fg;
- GdkColor foreground_colour_bg;
+ GdkColor background_colour_fg;
+ GdkColor background_colour_bg_dark;
+ GdkColor background_colour_bg_light;
+ GdkColor foreground_colour_fg;
+ GdkColor foreground_colour_bg;
+ PlayButtonEvent current_command;
};
#define PLAY_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PLAY_BUTTON_TYPE, PlayButtonPrivate))
@@ -324,6 +325,8 @@ play_button_class_init (PlayButtonClass *klass)
static void
play_button_init (PlayButton *self)
{
+ PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(self);
+ priv->current_command = TRANSPORT_NADA;
gtk_widget_set_size_request(GTK_WIDGET(self), 200, 80);
}
@@ -356,29 +359,73 @@ play_button_expose (GtkWidget *button, GdkEventExpose *event)
}
-gint
+PlayButtonEvent
determine_button_event(GtkWidget* button, GdkEventButton* event)
{
g_debug("event x coordinate = %f", event->x);
g_debug("event y coordinate = %f", event->y);
- gint result = 0;
+ PlayButtonEvent button_event = TRANSPORT_NADA;
// For now very simple rectangular collision detection
if(event->x > 55 && event->x < 95
&& event->y > 22 && event->y < 46){
- result = PREVIOUS;
+ button_event = TRANSPORT_PREVIOUS;
}
else if(event->x > 101 && event->x < 133
&& event->y > 20 && event->y < 47){
- result = PLAY_PAUSE;
+ button_event = TRANSPORT_PLAY_PAUSE;
}
else if(event->x > 137 && event->x < 179
&& event->y > 22 && event->y < 46){
- result = NEXT;
- }
+ button_event = TRANSPORT_NEXT;
+ }
+ return button_event;
+}
+
+void
+play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command)
+{
+ g_return_if_fail(IS_PLAY_BUTTON(button));
+ PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
+ priv->current_command = command;
- return result;
+ cairo_t *cr;
+ cr = gdk_cairo_create (button->window);
+
+
+ /*cairo_rectangle (cr,
+ event->area.x, event->area.y,
+ event->area.width, event->area.height);
+
+ cairo_clip(cr);*/
+ draw (button, cr);
+ cairo_destroy (cr);
}
+
+void
+play_button_react_to_button_release(GtkWidget* button)
+{
+ g_return_if_fail(IS_PLAY_BUTTON(button));
+ PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
+ priv->current_command = TRANSPORT_NADA;
+ cairo_t *cr;
+ cr = gdk_cairo_create (button->window);
+ /*cairo_rectangle (cr,
+ event->area.x, event->area.y,
+ event->area.width, event->area.height);
+
+ cairo_clip(cr);*/
+ draw (button, cr);
+ cairo_destroy (cr);
+
+}
+
+void
+play_button_toggle_play_pause(GtkWidget* button, int update)
+{
+}
+
+
void
play_button_set_style(GtkWidget* button, GtkStyle* style)
{
@@ -615,6 +662,9 @@ _finalize (cairo_t* cr,
static void
draw (GtkWidget* button, cairo_t *cr)
{
+ g_return_if_fail(IS_PLAY_BUTTON(button));
+ PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
+
cairo_surface_t* surf = NULL;
cairo_t* cr_surf = NULL;
@@ -627,7 +677,8 @@ draw (GtkWidget* button, cairo_t *cr)
double BUTTON_START[] = {252.0f / 255.0f, 251.0f / 255.0f, 251.0f / 255.0f,1.0f};
double BUTTON_END[] = {186.0f / 255.0f,180.0f / 255.0f, 170.0f / 255.0f, 1.0f};
double BUTTON_SHADOW[] = {0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 0.75f};
-
+ double INNER_COMPRESSED_END[] = {61.0f / 255.0f, 60.0f / 255.0f, 57.0f / 255.0f, 1.0f};
+ double INNER_COMPRESSED_START[] = {36.0f / 255.0f, 35.0f / 255.0f, 33.0f / 255.0f, 1.0f};
// prev/next-background
draw_gradient (cr,
@@ -644,13 +695,32 @@ draw (GtkWidget* button, cairo_t *cr)
MIDDLE_RADIUS,
MIDDLE_START,
MIDDLE_END);
- draw_gradient (cr,
- X,
- Y + 2,
- RECT_WIDTH - 4,
- INNER_RADIUS,
- INNER_START,
- INNER_END);
+ draw_gradient (cr,
+ X,
+ Y + 2,
+ RECT_WIDTH - 4,
+ INNER_RADIUS,
+ INNER_START,
+ INNER_END);
+
+ if(priv->current_command == TRANSPORT_PREVIOUS){
+ draw_gradient (cr,
+ X,
+ Y + 2,
+ RECT_WIDTH/2,
+ INNER_RADIUS,
+ INNER_COMPRESSED_START,
+ INNER_COMPRESSED_END);
+ }
+ else if(priv->current_command == TRANSPORT_NEXT){
+ draw_gradient (cr,
+ RECT_WIDTH / 2 + X,
+ Y + 2,
+ (RECT_WIDTH - 7)/2,
+ INNER_RADIUS,
+ INNER_COMPRESSED_START,
+ INNER_COMPRESSED_END);
+ }
// play/pause-background
draw_circle (cr,
@@ -670,7 +740,16 @@ draw (GtkWidget* button, cairo_t *cr)
Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 2.0f,
CIRCLE_RADIUS - 2.0f,
INNER_START,
- INNER_END);
+ INNER_END);
+ if(priv->current_command == TRANSPORT_PLAY_PAUSE){
+ draw_circle (cr,
+ X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 4.5f + 2.0f,
+ Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 2.0f,
+ CIRCLE_RADIUS - 2.0f,
+ INNER_COMPRESSED_START,
+ INNER_COMPRESSED_END);
+ }
+
// draw previous-button drop-shadow
_setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT);
@@ -700,13 +779,13 @@ draw (GtkWidget* button, cairo_t *cr)
TRI_HEIGHT,
TRI_OFFSET);
_fill (cr_surf,
- (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (PREV_HEIGHT - TRI_HEIGHT) / 2.0f,
- (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
- (double) TRI_HEIGHT,
- BUTTON_START,
- BUTTON_END,
- FALSE);
+ (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (PREV_HEIGHT - TRI_HEIGHT) / 2.0f,
+ (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f,
+ (double) TRI_HEIGHT,
+ BUTTON_START,
+ BUTTON_END,
+ FALSE);
_finalize (cr, &cr_surf, &surf, PREV_X, PREV_Y);
// draw next-button drop-shadow
@@ -791,8 +870,7 @@ draw (GtkWidget* button, cairo_t *cr)
**/
GtkWidget*
play_button_new()
-{
-
+{
GtkWidget* widget = g_object_new(PLAY_BUTTON_TYPE, NULL);
gtk_widget_set_app_paintable (widget, TRUE);
return widget;
diff --git a/src/play-button.h b/src/play-button.h
index 3eaabcc..6f646b5 100644
--- a/src/play-button.h
+++ b/src/play-button.h
@@ -33,6 +33,13 @@ G_BEGIN_DECLS
typedef struct _PlayButton PlayButton;
typedef struct _PlayButtonClass PlayButtonClass;
+typedef enum {
+ TRANSPORT_PREVIOUS,
+ TRANSPORT_PLAY_PAUSE,
+ TRANSPORT_NEXT,
+ TRANSPORT_NADA
+}PlayButtonEvent;
+
struct _PlayButtonClass {
GtkDrawingAreaClass parent_class;
};
@@ -43,7 +50,10 @@ struct _PlayButton {
GType play_button_get_type (void);
void play_button_set_style(GtkWidget* button, GtkStyle* style);
-gint determine_button_event(GtkWidget* button, GdkEventButton* event);
+PlayButtonEvent determine_button_event(GtkWidget* button, GdkEventButton* event);
+void play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command);
+void play_button_react_to_button_release(GtkWidget* button);
+void play_button_toggle_play_pause(GtkWidget* button, int update);
GtkWidget* play_button_new();
diff --git a/src/scrub-widget.c b/src/scrub-widget.c
index 799f81e..dbbbdf3 100644
--- a/src/scrub-widget.c
+++ b/src/scrub-widget.c
@@ -75,7 +75,7 @@ scrub_widget_init (ScrubWidget *self)
g_debug("ScrubWidget::scrub_widget_init");
ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(self);
- priv->ido_scrub_bar = ido_scale_menu_item_new_with_range ("Scrub", 0, 0, 100, 1);
+ priv->ido_scrub_bar = ido_scale_menu_item_new_with_range ("Scrub", IDO_RANGE_STYLE_SMALL, 0, 0, 100, 1);
ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), IDO_SCALE_MENU_ITEM_STYLE_LABEL);
g_object_set(priv->ido_scrub_bar, "reverse-scroll-events", TRUE, NULL);
diff --git a/src/transport-widget.c b/src/transport-widget.c
index f02200e..3174afe 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -137,9 +137,7 @@ static gboolean
transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- if(IS_TRANSPORT_WIDGET(menuitem) == FALSE){
- return FALSE;
- }
+ g_return_val_if_fail(IS_TRANSPORT_WIDGET(menuitem), FALSE);
TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
@@ -147,14 +145,16 @@ transport_widget_button_press_event (GtkWidget *menuitem,
parent = gtk_widget_get_parent (GTK_WIDGET (menuitem));
- gint result = determine_button_event(priv->play_button, event);
+ PlayButtonEvent result = determine_button_event(priv->play_button, event);
- GValue value = {0};
- g_value_init(&value, G_TYPE_INT);
- g_debug("TransportWidget::menu_press_event - going to send value %i", result);
- g_value_set_int(&value, result);
- dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
-
+ if(result != TRANSPORT_NADA){
+ GValue value = {0};
+ g_value_init(&value, G_TYPE_INT);
+ g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
+ g_value_set_int(&value, (int)result);
+ dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
+ play_button_react_to_button_press(priv->play_button, result);
+ }
return TRUE;
}
@@ -164,9 +164,9 @@ transport_widget_button_release_event (GtkWidget *menuitem,
GdkEventButton *event)
{
g_debug("TransportWidget::menu_release_event");
- if(IS_TRANSPORT_WIDGET(menuitem) == FALSE){
- return FALSE;
- }
+ g_return_val_if_fail(IS_TRANSPORT_WIDGET(menuitem), FALSE);
+ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
+ play_button_react_to_button_release(priv->play_button);
return TRUE;
}
@@ -180,12 +180,13 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
GValue* value, gpointer userdata)
{
g_debug("transport_widget_update_state - with property %s", property);
- //int update_value = g_value_get_int(value);
- //g_debug("transport_widget_update_state - with value %i", update_value);
-
- //TransportWidget* bar = (TransportWidget*)userdata;
- //TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
+ TransportWidget* bar = (TransportWidget*)userdata;
+ g_return_if_fail(IS_TRANSPORT_WIDGET(bar));
+ TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
+ int update_value = g_value_get_int(value);
+ g_debug("transport_widget_update_state - with value %i", update_value);
+ play_button_toggle_play_pause(priv->play_button, update_value);
}
/**