aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-06-11 18:17:22 +0100
committerConor Curran <conor.curran@canonical.com>2010-06-11 18:17:22 +0100
commit1a3e82434ad971872d5be3181b91071fccdc0fea (patch)
treee4d177ad02035a268d5e32341229a847fa844cd7
parent448e45e3fa53620804ab8ec9c5940946f45a8b62 (diff)
downloadayatana-indicator-sound-1a3e82434ad971872d5be3181b91071fccdc0fea.tar.gz
ayatana-indicator-sound-1a3e82434ad971872d5be3181b91071fccdc0fea.tar.bz2
ayatana-indicator-sound-1a3e82434ad971872d5be3181b91071fccdc0fea.zip
properties working
-rw-r--r--src/transport-bar.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/src/transport-bar.c b/src/transport-bar.c
index 02d9a45..96ae287 100644
--- a/src/transport-bar.c
+++ b/src/transport-bar.c
@@ -28,8 +28,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
// TODO: think about leakage: ted !
-
-
static DbusmenuMenuitem* twin_item;
typedef struct _TransportBarPrivate TransportBarPrivate;
@@ -54,13 +52,13 @@ static guint signals[LAST_SIGNAL] = { 0 };
#define TRANSPORT_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_BAR_TYPE, TransportBarPrivate))
-/* Prototypes */
+/* Gobject boiler plate */
static void transport_bar_class_init (TransportBarClass *klass);
static void transport_bar_init (TransportBar *self);
static void transport_bar_dispose (GObject *object);
static void transport_bar_finalize (GObject *object);
-
+/* UI and dbus callbacks */
static gboolean transport_bar_button_press_event (GtkWidget *menuitem,
GdkEventButton *event);
static gboolean transport_bar_button_release_event (GtkWidget *menuitem,
@@ -68,9 +66,12 @@ static gboolean transport_bar_button_release_event (GtkWidget *menui
static gboolean transport_bar_play_button_trigger (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
-static void transport_bar_update_state(gchar * property,
+static void transport_bar_update_state(DbusmenuMenuitem* item,
+ gchar * property,
GValue * value,
gpointer userdata);
+// utility methods
+static gchar* transport_bar_determine_play_label(gchar* state);
G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM);
@@ -194,39 +195,34 @@ transport_bar_play_button_trigger(GtkWidget* widget,
return FALSE;
}
-//TODO figure out why the userdata is not what I expect it to be.
-static void transport_bar_update_state(gchar *property, GValue *value, gpointer userdata)
+/**
+* transport_bar_update_state()
+* Callback for updates from the other side of dbus
+**/
+static void transport_bar_update_state(DbusmenuMenuitem* item, gchar* property,
+ GValue* value, gpointer userdata)
{
- //TransportBar* bar = (TransportBar*)userdata;
- // TODO problem line
- //if(IS_TRANSPORT_BAR(bar)){
- //g_debug("after line 1!!");
-
- //TransportBarPrivate *priv = TRANSPORT_BAR_GET_PRIVATE(bar);
- //g_debug("after line 2!!");
- //gchar* label = "changed";
- //g_debug("after line 3!!");
- //gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label));
- //}
- //if(GTK_IS_BUTTON(GTK_BUTTON(priv->play_button))){
-
- // gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label));
- // g_debug("its a button");
- //}
- //else{
- //g_debug("No Goddamn button!!");
- //}
- //}
g_debug("transport_bar_update_state - with property %s", property);
+ gchar* input = g_strdup(g_value_get_string(value));
+ g_debug("transport_bar_update_state - with value %s", input);
- if (value == NULL){
- g_debug("value is null");
- return;
- }
- // TODO problem line
- //gchar* input = g_strdup(g_value_get_string(value));
- //g_debug("transport_bar_update_state - with value %s", input);
+ TransportBar* bar = (TransportBar*)userdata;
+ TransportBarPrivate *priv = TRANSPORT_BAR_GET_PRIVATE(bar);
+
+ gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_bar_determine_play_label(property)));
+}
+// will be needed for image swapping
+static gchar* transport_bar_determine_play_label(gchar* state)
+{
+ gchar* label = ">";
+ if(g_strcmp0(state, "pause") == 0){
+ label = "||";
+ }
+ else if(g_strcmp0(state, "play") == 0){
+ label = ">";
+ }
+ return label;
}
/**