aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-07-15 15:46:54 +0100
committerConor Curran <conor.curran@canonical.com>2010-07-15 15:46:54 +0100
commit42f71fbdeb2beb78a3c4381caaa75c66e5b1b6b4 (patch)
tree67d188d00f92f8c18b71bbb14a4a846356632a1a
parent858c43dbd4be74c8979bc778b83a1642784a7e02 (diff)
downloadayatana-indicator-sound-42f71fbdeb2beb78a3c4381caaa75c66e5b1b6b4.tar.gz
ayatana-indicator-sound-42f71fbdeb2beb78a3c4381caaa75c66e5b1b6b4.tar.bz2
ayatana-indicator-sound-42f71fbdeb2beb78a3c4381caaa75c66e5b1b6b4.zip
tidied up some enums using typedefs and some more bits and pieces
-rw-r--r--src/play-button.c48
-rw-r--r--src/play-button.h11
-rw-r--r--src/sound-service.c4
-rw-r--r--src/transport-widget.c10
4 files changed, 35 insertions, 38 deletions
diff --git a/src/play-button.c b/src/play-button.c
index bcb46f0..a488105 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -53,12 +53,6 @@ Uses code from ctk
#define PAUSE_X 77.0f
#define PAUSE_Y 15.0f
-// Transport Manual events
-enum {
- PREVIOUS,
- PLAY_PAUSE,
- NEXT
-};
// Transport updates
enum{
@@ -66,18 +60,16 @@ enum{
PLAY
};
-static const gint NO_COMMAND = -1;
-
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;
- gint current_command;
+ 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))
@@ -334,7 +326,7 @@ static void
play_button_init (PlayButton *self)
{
PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(self);
- priv->current_command = NO_COMMAND;
+ priv->current_command = TRANSPORT_NADA;
gtk_widget_set_size_request(GTK_WIDGET(self), 200, 80);
}
@@ -367,32 +359,30 @@ 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 = NO_COMMAND;
-
+ 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;
- }
-
- return result;
+ button_event = TRANSPORT_NEXT;
+ }
+ return button_event;
}
void
-play_button_react_to_button_press(GtkWidget* button, gint command)
+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);
@@ -417,7 +407,7 @@ 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 = NO_COMMAND;
+ priv->current_command = TRANSPORT_NADA;
cairo_t *cr;
cr = gdk_cairo_create (button->window);
/*cairo_rectangle (cr,
@@ -707,7 +697,7 @@ draw (GtkWidget* button, cairo_t *cr)
INNER_START,
INNER_END);
- if(priv->current_command == PREVIOUS){
+ if(priv->current_command == TRANSPORT_PREVIOUS){
draw_gradient (cr,
X,
Y + 2,
@@ -716,7 +706,7 @@ draw (GtkWidget* button, cairo_t *cr)
INNER_COMPRESSED_START,
INNER_COMPRESSED_END);
}
- else if(priv->current_command == NEXT){
+ else if(priv->current_command == TRANSPORT_NEXT){
draw_gradient (cr,
RECT_WIDTH / 2 + X,
Y + 2,
@@ -745,7 +735,7 @@ draw (GtkWidget* button, cairo_t *cr)
CIRCLE_RADIUS - 2.0f,
INNER_START,
INNER_END);
- if(priv->current_command == PLAY_PAUSE){
+ 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,
diff --git a/src/play-button.h b/src/play-button.h
index e82d59c..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,8 +50,8 @@ 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);
-void play_button_react_to_button_press(GtkWidget* button, gint command);
+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);
diff --git a/src/sound-service.c b/src/sound-service.c
index a5f3941..8f4e941 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -43,8 +43,8 @@ service_shutdown (IndicatorService *service, gpointer user_data)
if (mainloop != NULL) {
g_debug("Service shutdown !");
// TODO: uncomment for release !!
- //close_pulse_activites();
- //g_main_loop_quit(mainloop);
+ close_pulse_activites();
+ g_main_loop_quit(mainloop);
}
return;
}
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 17dfee1..3174afe 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -145,13 +145,13 @@ 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);
- if(result >= 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", result);
- g_value_set_int(&value, result);
+ 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);
}
@@ -181,7 +181,7 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
{
g_debug("transport_widget_update_state - with property %s", property);
TransportWidget* bar = (TransportWidget*)userdata;
- g_return_val_if_fail(IS_TRANSPORT_WIDGET(bar), FALSE);
+ g_return_if_fail(IS_TRANSPORT_WIDGET(bar));
TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
int update_value = g_value_get_int(value);