aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-06-30 18:20:45 +0100
committerConor Curran <conor.curran@canonical.com>2010-06-30 18:20:45 +0100
commitf3fc28d63254fe90de5472352256e7df415ab886 (patch)
tree0f1ce71a25ee2862a59a0c530704a332982d0137
parent8dc783c9943dbb1a80579d6f7e70492769b67717 (diff)
downloadayatana-indicator-sound-f3fc28d63254fe90de5472352256e7df415ab886.tar.gz
ayatana-indicator-sound-f3fc28d63254fe90de5472352256e7df415ab886.tar.bz2
ayatana-indicator-sound-f3fc28d63254fe90de5472352256e7df415ab886.zip
highlighting sorted and a start towards the cairo stuff
-rw-r--r--src/metadata-widget.c13
-rw-r--r--src/play-button.c37
-rw-r--r--src/transport-widget.c21
3 files changed, 42 insertions, 29 deletions
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index ce3bcd1..28a3839 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -47,6 +47,8 @@ static void metadata_widget_class_init (MetadataWidgetClass *klass);
static void metadata_widget_init (MetadataWidget *self);
static void metadata_widget_dispose (GObject *object);
static void metadata_widget_finalize (GObject *object);
+static gboolean metadata_widget_expose_event(GtkWidget* widget, GdkEventExpose* event);
+
// keyevent consumers
static gboolean metadata_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event);
@@ -74,7 +76,7 @@ metadata_widget_class_init (MetadataWidgetClass *klass)
widget_class->button_press_event = metadata_widget_button_press_event;
widget_class->button_release_event = metadata_widget_button_release_event;
-
+ widget_class->expose_event = metadata_widget_expose_event;
g_type_class_add_private (klass, sizeof (MetadataWidgetPrivate));
gobject_class->dispose = metadata_widget_dispose;
@@ -152,6 +154,15 @@ metadata_widget_init (MetadataWidget *self)
}
+static gboolean
+metadata_widget_expose_event(GtkWidget* widget, GdkEventExpose* event)
+{
+ MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget);
+
+ gtk_container_propagate_expose(GTK_CONTAINER(widget), priv->hbox, event);
+ return TRUE;
+}
+
static void
metadata_widget_dispose (GObject *object)
{
diff --git a/src/play-button.c b/src/play-button.c
index e798668..d79161b 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -40,7 +40,7 @@ static void play_button_init (PlayButton *self);
static void play_button_dispose (GObject *object);
static void play_button_finalize (GObject *object);
-static gboolean play_button_expose (GtkWidget *button, GdkEventExpose *event, gpointer userdata);
+static gboolean play_button_expose (GtkWidget *button, GdkEventExpose *event);
static void draw (GtkWidget* button, cairo_t *cr);
G_DEFINE_TYPE (PlayButton, play_button, GTK_TYPE_DRAWING_AREA);
@@ -51,11 +51,11 @@ play_button_class_init (PlayButtonClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- //GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
+ GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
g_type_class_add_private (klass, sizeof (PlayButtonPrivate));
- //widget_class->expose_event = play_button_expose;
+ widget_class->expose_event = play_button_expose;
gobject_class->dispose = play_button_dispose;
gobject_class->finalize = play_button_finalize;
@@ -65,7 +65,7 @@ static void
play_button_init (PlayButton *self)
{
g_debug("PlayButton::play_button_init");
- g_signal_connect(GTK_WIDGET(self), "expose-event", G_CALLBACK (play_button_expose), NULL);
+ gtk_widget_set_size_request(GTK_WIDGET(self), 50, 50);
}
static void
@@ -81,18 +81,8 @@ play_button_finalize (GObject *object)
}
static gboolean
-play_button_expose (GtkWidget *button, GdkEventExpose *event, gpointer userdata)
+play_button_expose (GtkWidget *button, GdkEventExpose *event)
{
- GtkAllocation alloc;
-
- alloc.width = 200;
- alloc.height = 600;
- alloc.x = 10;
- alloc.y = 10;
-
- gtk_widget_set_allocation(GTK_WIDGET(button),
- &alloc);
-
cairo_t *cr;
cr = gdk_cairo_create (button->window);
@@ -110,14 +100,23 @@ play_button_expose (GtkWidget *button, GdkEventExpose *event, gpointer userdata)
return FALSE;
}
+
static void
draw (GtkWidget* button, cairo_t *cr)
{
- double x, y;
+ double x=50;
+ double y=30;
double radius;
- int i;
- x = button->allocation.x + button->allocation.width / 2;
+ int rect_width = 100;
+ int rect_height = 50;
+
+ cairo_move_to(cr, x+radius, y);
+ cairo_line_to(cr, x+rect_width-radius, y);
+ cairo_curve_to(cr, x+rect_width, y, x+rect_width, y, x+rect_width, y+radius);
+ cairo_line_to(x+w,y+h-r)
+ cairo_curve_to(cr,
+ x = button->allocation.x - button->allocation.width / 2;
y = button->allocation.y + button->allocation.height / 2;
radius = MIN (button->allocation.width / 2,
button->allocation.height / 2) - 5;
@@ -159,6 +158,8 @@ draw (GtkWidget* button, cairo_t *cr)
cairo_surface_write_to_png(cairo_get_target (cr), "/tmp/foobar.png");
}
+
+
/**
* play_button_new:
* @returns: a new #PlayButton.
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 6ff3c04..10c564b 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -45,6 +45,7 @@ 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,
@@ -68,6 +69,7 @@ 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->expose_event = transport_widget_expose_event;
g_type_class_add_private (klass, sizeof (TransportWidgetPrivate));
gobject_class->dispose = transport_widget_dispose;
@@ -89,16 +91,6 @@ transport_widget_init (TransportWidget *self)
priv->play_button = play_button_new();
- GtkAllocation alloc;
-
- alloc.width = 200;
- alloc.height = 600;
- alloc.x = 100;
- alloc.y = 0;
-
- gtk_widget_set_allocation(GTK_WIDGET(priv->play_button),
- &alloc);
-
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);
@@ -120,6 +112,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,