aboutsummaryrefslogtreecommitdiff
path: root/src/transport-widget.c
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-07-08 11:08:39 +0100
committerConor Curran <conor.curran@canonical.com>2010-07-08 11:08:39 +0100
commit41747b032d2032c97fd7f1766157e2d846626880 (patch)
treeab92fae42cab6df8364efc5f210281095cf3525a /src/transport-widget.c
parent3a06565090107aef0ab7bc22b9ab5c965a729746 (diff)
parent5d8d12718e518a8bc695e57c071760720de4329e (diff)
downloadayatana-indicator-sound-41747b032d2032c97fd7f1766157e2d846626880.tar.gz
ayatana-indicator-sound-41747b032d2032c97fd7f1766157e2d846626880.tar.bz2
ayatana-indicator-sound-41747b032d2032c97fd7f1766157e2d846626880.zip
merge with new transport bar branch
Diffstat (limited to 'src/transport-widget.c')
-rw-r--r--src/transport-widget.c133
1 files changed, 35 insertions, 98 deletions
diff --git a/src/transport-widget.c b/src/transport-widget.c
index e7b8e4f..6d39a03 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -25,6 +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"
+
static DbusmenuMenuitem* twin_item;
@@ -36,16 +38,6 @@ struct _TransportWidgetPrivate
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 */
@@ -53,26 +45,20 @@ static void transport_widget_class_init (TransportWidgetClass *klass);
static void transport_widget_init (TransportWidget *self);
static void transport_widget_dispose (GObject *object);
static void transport_widget_finalize (GObject *object);
+static gboolean transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event);
/* UI and dbusmenu callbacks */
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)
{
@@ -82,45 +68,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;
+ widget_class->expose_event = transport_widget_expose_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
@@ -129,19 +82,19 @@ 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);
-
- gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0);
+ GtkStyle* style = gtk_rc_get_style(GTK_WIDGET(self));
+
priv->hbox = hbox;
+ priv->play_button = play_button_new();
+ play_button_set_style(priv->play_button, style);
+
+ 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);
@@ -160,6 +113,15 @@ transport_widget_finalize (GObject *object)
G_OBJECT_CLASS (transport_widget_parent_class)->finalize (object);
}
+static gboolean
+transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event)
+{
+ //TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(widget);
+ //gtk_container_propagate_expose(GTK_CONTAINER(widget),priv->play_button, event);
+ return TRUE;
+}
+
+
/* keyevents */
static gboolean
transport_widget_button_press_event (GtkWidget *menuitem,
@@ -170,28 +132,17 @@ transport_widget_button_press_event (GtkWidget *menuitem,
return FALSE;
}
- TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
+ //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;
-
- 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,
@@ -201,9 +152,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;
}
@@ -217,23 +165,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;
}
/**