aboutsummaryrefslogtreecommitdiff
path: root/src/transport-widget.c
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-07-12 14:46:13 +0100
committerConor Curran <conor.curran@canonical.com>2010-07-12 14:46:13 +0100
commitc653012e7a55de1a6ecabf798a7d86e87d4affc6 (patch)
tree7fae59d6256f8b6713db9b477c92f18dd0f73532 /src/transport-widget.c
parenta96e011314ea03b04768681b724958f6688f06dc (diff)
downloadayatana-indicator-sound-c653012e7a55de1a6ecabf798a7d86e87d4affc6.tar.gz
ayatana-indicator-sound-c653012e7a55de1a6ecabf798a7d86e87d4affc6.tar.bz2
ayatana-indicator-sound-c653012e7a55de1a6ecabf798a7d86e87d4affc6.zip
caught by static scopeness - update bug fixed
Diffstat (limited to 'src/transport-widget.c')
-rw-r--r--src/transport-widget.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 9852b50..f02200e 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -27,15 +27,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <gtk/gtk.h>
#include "play-button.h"
-
-static DbusmenuMenuitem* twin_item;
-
typedef struct _TransportWidgetPrivate TransportWidgetPrivate;
struct _TransportWidgetPrivate
{
GtkWidget* hbox;
GtkWidget* play_button;
+ DbusmenuMenuitem* twin_item;
};
#define TRANSPORT_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_WIDGET_TYPE, TransportWidgetPrivate))
@@ -45,18 +43,24 @@ 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);
+
+static void transport_widget_set_twin_item(TransportWidget* self,
+ DbusmenuMenuitem* twin_item);
+
+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 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_property_update(DbusmenuMenuitem* item,
gchar * property,
GValue * value,
gpointer userdata);
+
G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM);
static void
@@ -93,8 +97,6 @@ transport_widget_init (TransportWidget *self)
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);
gtk_container_add (GTK_CONTAINER (self), priv->hbox);
@@ -120,14 +122,21 @@ transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event)
//gtk_container_propagate_expose(GTK_CONTAINER(widget),priv->play_button, event);
return TRUE;
}
-
+
+static void transport_widget_set_twin_item(TransportWidget* self,
+ DbusmenuMenuitem* twin_item)
+{
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(self);
+ priv->twin_item = twin_item;
+ g_signal_connect(G_OBJECT(priv->twin_item), "property-changed",
+ G_CALLBACK(transport_widget_property_update), self);
+}
/* keyevents */
static gboolean
transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- g_debug("TransportWidget::menu_press_event");
if(IS_TRANSPORT_WIDGET(menuitem) == FALSE){
return FALSE;
}
@@ -136,20 +145,15 @@ transport_widget_button_press_event (GtkWidget *menuitem,
GtkWidget *parent;
- // can we block emissions of "grab-notify" on parent??
parent = gtk_widget_get_parent (GTK_WIDGET (menuitem));
- gint result = determine_button_event(priv->play_button, event);
- //GTK_OBJECT_FLAGS (scale) |= GTK_HAS_GRAB;
- //gtk_widget_event (scale,
- //((GdkEvent *)(void*)(event)));
- //GTK_OBJECT_FLAGS (scale) &= ~(GTK_HAS_GRAB);
+ gint result = determine_button_event(priv->play_button, event);
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);
- dbusmenu_menuitem_handle_event (twin_item, "Transport state change", &value, 0);
+ dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
return TRUE;
}
@@ -191,7 +195,8 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
GtkWidget*
transport_widget_new(DbusmenuMenuitem *item)
{
- twin_item = item;
- return g_object_new(TRANSPORT_WIDGET_TYPE, NULL);
+ GtkWidget* widget = g_object_new(TRANSPORT_WIDGET_TYPE, NULL);
+ transport_widget_set_twin_item((TransportWidget*)widget, item);
+ return widget;
}