aboutsummaryrefslogtreecommitdiff
path: root/src/transport-widget.c
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-06-28 21:12:07 +0100
committerConor Curran <conor.curran@canonical.com>2010-06-28 21:12:07 +0100
commit0e616c323a678732dbd593d0d430507e099fda9f (patch)
treea0ff25cb5b4f98d0c4ea2eb8a25a89248909f647 /src/transport-widget.c
parent33395ee8bff3e3d4b42bc40823eb9efe88f1611d (diff)
downloadayatana-indicator-sound-0e616c323a678732dbd593d0d430507e099fda9f.tar.gz
ayatana-indicator-sound-0e616c323a678732dbd593d0d430507e099fda9f.tar.bz2
ayatana-indicator-sound-0e616c323a678732dbd593d0d430507e099fda9f.zip
moving in the right direction
Diffstat (limited to 'src/transport-widget.c')
-rw-r--r--src/transport-widget.c123
1 files changed, 23 insertions, 100 deletions
diff --git a/src/transport-widget.c b/src/transport-widget.c
index a86e37b..07e7402 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -25,8 +25,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "transport-widget.h"
#include "common-defs.h"
#include <gtk/gtk.h>
+#include "play-button.h"
-// TODO: think about leakage: ted !
static DbusmenuMenuitem* twin_item;
@@ -34,20 +34,10 @@ typedef struct _TransportWidgetPrivate TransportWidgetPrivate;
struct _TransportWidgetPrivate
{
- //GtkWidget* hbox;
- //GtkWidget* play_button;
+ GtkWidget* hbox;
+ GtkWidget* play_button;
};
-enum {
- PLAY,
- PAUSE,
- NEXT,
- PREVIOUS,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
#define TRANSPORT_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_WIDGET_TYPE, TransportWidgetPrivate))
/* Gobject boiler plate */
@@ -60,21 +50,14 @@ static void transport_widget_finalize (GObject *object);
static gboolean transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event);
static gboolean transport_widget_button_release_event (GtkWidget *menuitem,
- GdkEventButton *event);
-static void transport_widget_play_clicked (GtkWidget* button,
- TransportWidget* self);
-
+ GdkEventButton *event);
static void transport_widget_property_update(DbusmenuMenuitem* item,
- gchar * property,
- GValue * value,
- gpointer userdata);
-// utility methods
-static gchar* transport_widget_toggle_play_label(gint state);
+ gchar * property,
+ GValue * value,
+ gpointer userdata);
G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM);
-
-
static void
transport_widget_class_init (TransportWidgetClass *klass)
{
@@ -84,45 +67,12 @@ transport_widget_class_init (TransportWidgetClass *klass)
menu_item_class->hide_on_activate = FALSE;
widget_class->button_press_event = transport_widget_button_press_event;
- widget_class->button_release_event = transport_widget_button_release_event;
-
+ widget_class->button_release_event = transport_widget_button_release_event;
g_type_class_add_private (klass, sizeof (TransportWidgetPrivate));
gobject_class->dispose = transport_widget_dispose;
gobject_class->finalize = transport_widget_finalize;
- signals[PLAY] = g_signal_new ("play",
- G_OBJECT_CLASS_TYPE (gobject_class),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[PAUSE] = g_signal_new ("pause",
- G_OBJECT_CLASS_TYPE (gobject_class),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
-
- signals[NEXT] = g_signal_new ("next",
- G_OBJECT_CLASS_TYPE (gobject_class),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[PREVIOUS] = g_signal_new ("previous",
- G_OBJECT_CLASS_TYPE (gobject_class),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
}
static void
@@ -131,19 +81,17 @@ transport_widget_init (TransportWidget *self)
g_debug("TransportWidget::transport_widget_init");
TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(self);
- GtkWidget *hbox;
+ GtkWidget* hbox;
hbox = gtk_hbox_new(TRUE, 2);
- gchar* symbol = transport_widget_toggle_play_label(dbusmenu_menuitem_property_get_int(twin_item, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE));
- priv->play_button = gtk_button_new_with_label(symbol);
- //g_free(symbol);
- gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0);
priv->hbox = hbox;
+
+ priv->play_button = play_button_new();
+
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->play_button, FALSE, FALSE, 0);
g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_property_update), self);
-
- g_signal_connect(priv->play_button, "clicked", G_CALLBACK(transport_widget_play_clicked), self);
gtk_container_add (GTK_CONTAINER (self), priv->hbox);
@@ -172,28 +120,17 @@ transport_widget_button_press_event (GtkWidget *menuitem,
return FALSE;
}
- TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
-
- gtk_widget_event (priv->hbox, (GdkEvent*)event);
- gboolean state = g_ascii_strcasecmp(gtk_button_get_label(GTK_BUTTON(priv->play_button)), ">") == 0;
+ //TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
- gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label((gint)state));
- GValue value = {0};
- g_value_init(&value, G_TYPE_BOOLEAN);
- g_debug("TransportWidget::menu_press_event - going to send value %i", state);
-
- g_value_set_boolean(&value, state);
- dbusmenu_menuitem_handle_event (twin_item, "Transport state change", &value, 0);
+ //GValue value = {0};
+ //g_value_init(&value, G_TYPE_BOOLEAN);
+ //g_debug("TransportWidget::menu_press_event - going to send value %i", state);
+ //g_value_set_boolean(&value, state);
+ //dbusmenu_menuitem_handle_event (twin_item, "Transport state change", &value, 0);
return TRUE;
}
-static void
-transport_widget_play_clicked(GtkWidget* button,
- TransportWidget* self)
-{
- g_debug("Transport_widget_play_clicked");
-}
static gboolean
transport_widget_button_release_event (GtkWidget *menuitem,
@@ -203,9 +140,6 @@ transport_widget_button_release_event (GtkWidget *menuitem,
if(IS_TRANSPORT_WIDGET(menuitem) == FALSE){
return FALSE;
}
-
- TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
- gtk_widget_event (priv->hbox, (GdkEvent*)event);
return TRUE;
}
@@ -219,23 +153,12 @@ 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);
+ //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;
+ //TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
- gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(update_value));
-}
-
-// will be needed for image swapping
-static gchar* transport_widget_toggle_play_label(int play_state)
-{
- gchar* label = ">";
- if(play_state == 1){
- label = "||";
- }
- return label;
}
/**