aboutsummaryrefslogtreecommitdiff
path: root/src/transport-widget.c
diff options
context:
space:
mode:
authorMichael Terry <michael.terry@canonical.com>2011-06-22 15:19:49 -0400
committerMichael Terry <michael.terry@canonical.com>2011-06-22 15:19:49 -0400
commit41416ba7f8944ac60a6c1d84409d05a2d9e4d787 (patch)
treeab8893a878c38e7f383df787ca148d2f105ed489 /src/transport-widget.c
parent808a7108ec6c8cca9423b25269c846b5c6e2461d (diff)
downloadayatana-indicator-sound-41416ba7f8944ac60a6c1d84409d05a2d9e4d787.tar.gz
ayatana-indicator-sound-41416ba7f8944ac60a6c1d84409d05a2d9e4d787.tar.bz2
ayatana-indicator-sound-41416ba7f8944ac60a6c1d84409d05a2d9e4d787.zip
port to gtk3
Diffstat (limited to 'src/transport-widget.c')
-rw-r--r--src/transport-widget.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/transport-widget.c b/src/transport-widget.c
index f05c4c1..f9b5319 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -104,8 +104,10 @@ G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM);
/* essentials */
static void transport_widget_set_twin_item ( TransportWidget* self,
DbusmenuMenuitem* twin_item);
+#if ! GTK_CHECK_VERSION(3, 0, 0)
static gboolean transport_widget_expose ( GtkWidget *button, GdkEventExpose *event);
-static void draw (GtkWidget* button, cairo_t *cr);
+#endif
+static gboolean draw (GtkWidget* button, cairo_t *cr);
/* UI and dbusmenu callbacks */
static gboolean transport_widget_button_press_event (GtkWidget *menuitem,
@@ -133,8 +135,8 @@ static void transport_widget_react_to_button_release ( TransportWidget* button,
TransportAction command);
static void transport_widget_toggle_play_pause ( TransportWidget* button,
TransportState update);
-static void transport_widget_select (GtkItem* menu, gpointer Userdata);
-static void transport_widget_deselect (GtkItem* menu, gpointer Userdata);
+static void transport_widget_select (GtkWidget* menu, gpointer Userdata);
+static void transport_widget_deselect (GtkWidget* menu, gpointer Userdata);
static TransportAction transport_widget_collision_detection (gint x, gint y);
static void transport_widget_start_timing (TransportWidget* widget);
static gboolean transport_widget_trigger_seek (gpointer userdata);
@@ -155,7 +157,11 @@ transport_widget_class_init (TransportWidgetClass *klass)
widget_class->button_release_event = transport_widget_button_release_event;
widget_class->motion_notify_event = transport_widget_motion_notify_event;
widget_class->leave_notify_event = transport_widget_leave_notify_event;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ widget_class->draw = draw;
+#else
widget_class->expose_event = transport_widget_expose;
+#endif
gobject_class->dispose = transport_widget_dispose;
gobject_class->finalize = transport_widget_finalize;
@@ -212,11 +218,11 @@ transport_widget_init (TransportWidget *self)
"notify",
G_CALLBACK (transport_widget_notify),
NULL);
- g_signal_connect (GTK_ITEM(self),
+ g_signal_connect (G_OBJECT(self),
"select",
G_CALLBACK (transport_widget_select),
NULL);
- g_signal_connect (GTK_ITEM(self),
+ g_signal_connect (G_OBJECT(self),
"deselect",
G_CALLBACK (transport_widget_deselect),
NULL);
@@ -236,11 +242,12 @@ transport_widget_finalize (GObject *object)
G_OBJECT_CLASS (transport_widget_parent_class)->finalize (object);
}
+#if ! GTK_CHECK_VERSION(3, 0, 0)
static gboolean
transport_widget_expose (GtkWidget *button, GdkEventExpose *event)
{
cairo_t *cr;
- cr = gdk_cairo_create (button->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (button));
//g_debug("In the playbutton's expose method, x = %i, y=%i and width: %i and height: %i'");
cairo_rectangle (cr,
@@ -253,6 +260,7 @@ transport_widget_expose (GtkWidget *button, GdkEventExpose *event)
cairo_destroy (cr);
return FALSE;
}
+#endif
gboolean
transport_widget_is_selected ( TransportWidget* widget )
@@ -434,7 +442,7 @@ transport_widget_button_release_event (GtkWidget *menuitem,
}
static void
-transport_widget_select (GtkItem* item, gpointer Userdata)
+transport_widget_select (GtkWidget* item, gpointer Userdata)
{
TransportWidget* transport = TRANSPORT_WIDGET(item);
TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport );
@@ -442,7 +450,7 @@ transport_widget_select (GtkItem* item, gpointer Userdata)
}
static void
-transport_widget_deselect (GtkItem* item, gpointer Userdata)
+transport_widget_deselect (GtkWidget* item, gpointer Userdata)
{
TransportWidget* transport = TRANSPORT_WIDGET(item);
TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport );
@@ -1214,20 +1222,22 @@ _surface_blur (cairo_surface_t* surface,
cairo_surface_mark_dirty (surface);
}
-static void
+static gboolean
draw (GtkWidget* button, cairo_t *cr)
{
- g_return_if_fail(IS_TRANSPORT_WIDGET(button));
- g_return_if_fail( cr != NULL );
+ g_return_val_if_fail(IS_TRANSPORT_WIDGET(button), FALSE);
+ g_return_val_if_fail(cr != NULL, FALSE);
TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(button);
cairo_surface_t* surf = NULL;
cairo_t* cr_surf = NULL;
- cairo_translate (cr, button->allocation.x, button->allocation.y);
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (button, &allocation);
+ cairo_translate (cr, allocation.x, allocation.y);
- //g_debug("button x allocation = %i", button->allocation.x);
- //g_debug("button y allocation = %i", button->allocation.y);
+ //g_debug("button x allocation = %i", allocation.x);
+ //g_debug("button y allocation = %i", allocation.y);
GtkStyle *style;
@@ -1795,6 +1805,8 @@ draw (GtkWidget* button, cairo_t *cr)
FALSE);
_finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y);
}
+
+ return FALSE;
}
static void