aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-06-15 11:33:07 +0100
committerConor Curran <conor.curran@canonical.com>2010-06-15 11:33:07 +0100
commit50bea3ce0fad1e36d0a657430a96567986a46638 (patch)
treef527f4cc3c3791ec7a3d2ad65e5d2ac558661c39
parentca99bae318b2768e721c2fa0834e8d12c196b245 (diff)
downloadayatana-indicator-sound-50bea3ce0fad1e36d0a657430a96567986a46638.tar.gz
ayatana-indicator-sound-50bea3ce0fad1e36d0a657430a96567986a46638.tar.bz2
ayatana-indicator-sound-50bea3ce0fad1e36d0a657430a96567986a46638.zip
for now activated one button due to gtk button press oddness
-rw-r--r--src/transport-widget.c111
1 files changed, 59 insertions, 52 deletions
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 7e26c68..b3f2ee1 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -35,9 +35,9 @@ typedef struct _TransportWidgetPrivate TransportWidgetPrivate;
struct _TransportWidgetPrivate
{
GtkWidget* hbox;
- GtkWidget* previous_button;
+ //GtkWidget* previous_button;
GtkWidget* play_button;
- GtkWidget* next_button;
+ //GtkWidget* next_button;
};
enum {
@@ -63,22 +63,22 @@ static gboolean transport_widget_button_press_event (GtkWidget *men
GdkEventButton *event);
static gboolean transport_widget_button_release_event (GtkWidget *menuitem,
GdkEventButton *event);
-static gboolean transport_widget_play_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data);
-static gboolean transport_widget_previous_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data);
-static gboolean transport_widget_next_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data);
+//static gboolean transport_widget_play_button_press_event (GtkWidget *widget,
+// GdkEventButton *event,
+// gpointer user_data);
+//static gboolean transport_widget_previous_button_press_event (GtkWidget *widget,
+// GdkEventButton *event,
+// gpointer user_data);
+//static gboolean transport_widget_next_button_press_event (GtkWidget *widget,
+// GdkEventButton *event,
+// gpointer user_data);
static void transport_widget_update_state(DbusmenuMenuitem* item,
gchar * property,
GValue * value,
gpointer userdata);
// utility methods
-static gchar* transport_widget_determine_play_label(gchar* state);
+static gchar* transport_widget_determine_play_label(const gchar* state);
G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM);
@@ -141,24 +141,29 @@ transport_widget_init (TransportWidget *self)
GtkWidget *hbox;
hbox = gtk_hbox_new(TRUE, 2);
- priv->previous_button = gtk_button_new_with_label("<<");
- priv->next_button = gtk_button_new_with_label(">>");
+ //priv->previous_button = gtk_button_new_with_label("<<");
+ //priv->next_button = gtk_button_new_with_label(">>");
priv->play_button = gtk_button_new_with_label(">");
- gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, TRUE, 0);
+ //gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, TRUE, 0);
+ //gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, TRUE, 0);
- g_signal_connect(GTK_OBJECT(priv->play_button), "button-press-event", G_CALLBACK(transport_widget_play_button_press_event), priv->play_button);
- g_signal_connect(GTK_OBJECT(priv->previous_button), "button-press-event", G_CALLBACK(transport_widget_previous_button_press_event), NULL);
- g_signal_connect(GTK_OBJECT(priv->next_button), "button-press-event", G_CALLBACK(transport_widget_next_button_press_event), NULL);
+ //g_signal_connect(GTK_OBJECT(priv->play_button), "button-press-event", G_CALLBACK(transport_widget_play_button_press_event), priv->play_button);
+ //g_signal_connect(GTK_OBJECT(priv->previous_button), "button-press-event", G_CALLBACK(transport_widget_previous_button_press_event), NULL);
+ //g_signal_connect(GTK_OBJECT(priv->next_button), "button-press-event", G_CALLBACK(transport_widget_next_button_press_event), NULL);
priv->hbox = hbox;
g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_update_state), self);
gtk_container_add (GTK_CONTAINER (self), priv->hbox);
-
+
+ //GtkWidget* parent = gtk_widget_get_parent(GTK_WIDGET(priv->hbox));
+ //if (GTK_IS_MENU_ITEM(parent)){
+ // g_debug("as expected the transport item is the parent");
+ //}
+ //gtk_widget_set_parent(GTK_WIDGET(priv->hbox), GTK_WIDGET(self));
gtk_widget_show_all (priv->hbox);
}
@@ -180,7 +185,9 @@ transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
g_debug("TransportWidget::menu_press_event");
- //TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
+ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
+ gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_determine_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button)))));
+
//gtk_button_pressed(GTK_BUTTON(priv->play_button));
//gtk_button_pressed(GTK_BUTTON(priv->previous_button));
//gtk_button_pressed(GTK_BUTTON(priv->next_button));
@@ -207,32 +214,32 @@ transport_widget_button_release_event (GtkWidget *menuitem,
}
/* Individual keyevents on the buttons */
-static gboolean
-transport_widget_play_button_press_event( GtkWidget* widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- g_debug("!!!!! TransportWidget::PLAY button_press_event");
- return TRUE;
-}
-
-static gboolean
-transport_widget_previous_button_press_event( GtkWidget* widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- g_debug("!!!!! TransportWidget::PREVIOUS button_press_event");
- return TRUE;
-}
-
-static gboolean
-transport_widget_next_button_press_event( GtkWidget* widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- g_debug("!!!!! TransportWidget::NEXT button_press_event");
- return TRUE;
-}
+//static gboolean
+//transport_widget_play_button_press_event( GtkWidget* widget,
+// GdkEventButton *event,
+// gpointer user_data)
+//{
+// g_debug("!!!!! TransportWidget::PLAY button_press_event");
+// return TRUE;
+//}
+
+//static gboolean
+//transport_widget_previous_button_press_event( GtkWidget* widget,
+// GdkEventButton *event,
+// gpointer user_data)
+//{
+// g_debug("!!!!! TransportWidget::PREVIOUS button_press_event");
+// return TRUE;
+//}
+
+//static gboolean
+//transport_widget_next_button_press_event( GtkWidget* widget,
+// GdkEventButton *event,
+// gpointer user_data)
+//{
+// g_debug("!!!!! TransportWidget::NEXT button_press_event");
+// return TRUE;
+//}
/**
* transport_widget_update_state()
@@ -252,15 +259,15 @@ static void transport_widget_update_state(DbusmenuMenuitem* item, gchar* propert
}
// will be needed for image swapping
-static gchar* transport_widget_determine_play_label(gchar* state)
+static gchar* transport_widget_determine_play_label(const gchar* state)
{
gchar* label = ">";
- if(g_strcmp0(state, "pause") == 0){
+ //if(g_strcmp0(state, "||") == 0){
+ // label = "||";
+ //}
+ if(g_strcmp0(state, ">") == 0){
label = "||";
}
- else if(g_strcmp0(state, "play") == 0){
- label = ">";
- }
return label;
}