aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-09-30 11:48:24 +0100
committerConor Curran <conor.curran@canonical.com>2010-09-30 11:48:24 +0100
commit28727032a4878897a30b3a81d6e2110f929d26ae (patch)
tree6a30ef49ad7e56c832f483659647789932cb458b /src
parent108d5224399eb4bbca6ebe50fa90b63847e8d130 (diff)
downloadayatana-indicator-sound-28727032a4878897a30b3a81d6e2110f929d26ae.tar.gz
ayatana-indicator-sound-28727032a4878897a30b3a81d6e2110f929d26ae.tar.bz2
ayatana-indicator-sound-28727032a4878897a30b3a81d6e2110f929d26ae.zip
moving things around in the playbutton
Diffstat (limited to 'src')
-rw-r--r--src/play-button.c422
-rw-r--r--src/title-widget.c27
-rw-r--r--src/transport-widget.c8
3 files changed, 229 insertions, 228 deletions
diff --git a/src/play-button.c b/src/play-button.c
index 35b1dc8..2ee304a 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -20,7 +20,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
Uses code from ctk
*/
-#ifdef HAVE_CONFIG_H int x = button->allocation.x + X;
+#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -104,215 +104,6 @@ static void draw (GtkWidget* button, cairo_t *cr);
G_DEFINE_TYPE (PlayButton, play_button, GTK_TYPE_MENU_ITEM);
-/// internal helper functions //////////////////////////////////////////////////
-
-
-static inline void
-_blurinner (guchar* pixel,
- gint* zR,
- gint* zG,
- gint* zB,
- gint* zA,
- gint alpha,
- gint aprec,
- gint zprec)
-{
- gint R;
- gint G;
- gint B;
- guchar A;
-
- R = *pixel;
- G = *(pixel + 1);
- B = *(pixel + 2);
- A = *(pixel + 3);
-
- *zR += (alpha * ((R << zprec) - *zR)) >> aprec;
- *zG += (alpha * ((G << zprec) - *zG)) >> aprec;
- *zB += (alpha * ((B << zprec) - *zB)) >> aprec;
- *zA += (alpha * ((A << zprec) - *zA)) >> aprec;
-
- *pixel = *zR >> zprec;
- *(pixel + 1) = *zG >> zprec;
- *(pixel + 2) = *zB >> zprec;
- *(pixel + 3) = *zA >> zprec;
-}
-
-static inline void
-_blurrow (guchar* pixels,
- gint width,
- gint height,
- gint channels,
- gint line,
- gint alpha,
- gint aprec,
- gint zprec)
-{
- gint zR;
- gint zG;
- gint zB;
- gint zA;
- gint index;
- guchar* scanline;
-
- scanline = &(pixels[line * width * channels]);
-
- zR = *scanline << zprec;
- zG = *(scanline + 1) << zprec;
- zB = *(scanline + 2) << zprec;
- zA = *(scanline + 3) << zprec;
-
- for (index = 0; index < width; index ++)
- _blurinner (&scanline[index * channels],
- &zR,
- &zG,
- &zB,
- &zA,
- alpha,
- aprec,
- zprec);
-
- for (index = width - 2; index >= 0; index--)
- _blurinner (&scanline[index * channels],
- &zR,
- &zG,
- &zB,
- &zA,
- alpha,
- aprec,
- zprec);
-}
-
-static inline void
-_blurcol (guchar* pixels,
- gint width,
- gint height,
- gint channels,
- gint x,
- gint alpha,
- gint aprec,
- gint zprec)
-{
- gint zR;
- gint zG;
- gint zB;
- gint zA;
- gint index;
- guchar* ptr;
-
- ptr = pixels;
-
- ptr += x * channels;
-
- zR = *((guchar*) ptr ) << zprec;
- zG = *((guchar*) ptr + 1) << zprec;
- zB = *((guchar*) ptr + 2) << zprec;
- zA = *((guchar*) ptr + 3) << zprec;
-
- for (index = width; index < (height - 1) * width; index += width)
- _blurinner ((guchar*) &ptr[index * channels],
- &zR,
- &zG,
- &zB,
- &zA,
- alpha,
- aprec,
- zprec);
-
- for (index = (height - 2) * width; index >= 0; index -= width)
- _blurinner ((guchar*) &ptr[index * channels],
- &zR,
- &zG,
- &zB,
- &zA,
- alpha,
- aprec,
- zprec);
-}
-
-void
-_expblur (guchar* pixels,
- gint width,
- gint height,
- gint channels,
- gint radius,
- gint aprec,
- gint zprec)
-{
- gint alpha;
- gint row = 0;
- gint col = 0;
-
- if (radius < 1)
- return;
-
- // calculate the alpha such that 90% of
- // the kernel is within the radius.
- // (Kernel extends to infinity)
- alpha = (gint) ((1 << aprec) * (1.0f - expf (-2.3f / (radius + 1.f))));
-
- for (; row < height; row++)
- _blurrow (pixels,
- width,
- height,
- channels,
- row,
- alpha,
- aprec,
- zprec);
-
- for(; col < width; col++)
- _blurcol (pixels,
- width,
- height,
- channels,
- col,
- alpha,
- aprec,
- zprec);
-
- return;
-}
-
-void
-_surface_blur (cairo_surface_t* surface,
- guint radius)
-{
- guchar* pixels;
- guint width;
- guint height;
- cairo_format_t format;
-
- // before we mess with the surface execute any pending drawing
- cairo_surface_flush (surface);
-
- pixels = cairo_image_surface_get_data (surface);
- width = cairo_image_surface_get_width (surface);
- height = cairo_image_surface_get_height (surface);
- format = cairo_image_surface_get_format (surface);
-
- switch (format)
- {
- case CAIRO_FORMAT_ARGB32:
- _expblur (pixels, width, height, 4, radius, 16, 7);
- break;
-
- case CAIRO_FORMAT_RGB24:
- _expblur (pixels, width, height, 3, radius, 16, 7);
- break;
-
- case CAIRO_FORMAT_A8:
- _expblur (pixels, width, height, 1, radius, 16, 7);
- break;
-
- default :
- // do nothing
- break;
- }
-
- // inform cairo we altered the surfaces contents
- cairo_surface_mark_dirty (surface);
-}
/// GObject functions //////////////////////////////////////////////////////////
@@ -491,6 +282,8 @@ play_button_set_style(GtkWidget* button, GtkStyle* style)
priv->foreground_colour_bg = style->bg[GTK_STATE_NORMAL];
}
+/// internal helper functions //////////////////////////////////////////////////
+
static void
draw_gradient (cairo_t* cr,
double x,
@@ -926,6 +719,213 @@ _color_shade (const CairoColorRGB *a, float k, CairoColorRGB *b)
b->b = blue;
}
+static inline void
+_blurinner (guchar* pixel,
+ gint* zR,
+ gint* zG,
+ gint* zB,
+ gint* zA,
+ gint alpha,
+ gint aprec,
+ gint zprec)
+{
+ gint R;
+ gint G;
+ gint B;
+ guchar A;
+
+ R = *pixel;
+ G = *(pixel + 1);
+ B = *(pixel + 2);
+ A = *(pixel + 3);
+
+ *zR += (alpha * ((R << zprec) - *zR)) >> aprec;
+ *zG += (alpha * ((G << zprec) - *zG)) >> aprec;
+ *zB += (alpha * ((B << zprec) - *zB)) >> aprec;
+ *zA += (alpha * ((A << zprec) - *zA)) >> aprec;
+
+ *pixel = *zR >> zprec;
+ *(pixel + 1) = *zG >> zprec;
+ *(pixel + 2) = *zB >> zprec;
+ *(pixel + 3) = *zA >> zprec;
+}
+
+static inline void
+_blurrow (guchar* pixels,
+ gint width,
+ gint height,
+ gint channels,
+ gint line,
+ gint alpha,
+ gint aprec,
+ gint zprec)
+{
+ gint zR;
+ gint zG;
+ gint zB;
+ gint zA;
+ gint index;
+ guchar* scanline;
+
+ scanline = &(pixels[line * width * channels]);
+
+ zR = *scanline << zprec;
+ zG = *(scanline + 1) << zprec;
+ zB = *(scanline + 2) << zprec;
+ zA = *(scanline + 3) << zprec;
+
+ for (index = 0; index < width; index ++)
+ _blurinner (&scanline[index * channels],
+ &zR,
+ &zG,
+ &zB,
+ &zA,
+ alpha,
+ aprec,
+ zprec);
+
+ for (index = width - 2; index >= 0; index--)
+ _blurinner (&scanline[index * channels],
+ &zR,
+ &zG,
+ &zB,
+ &zA,
+ alpha,
+ aprec,
+ zprec);
+}
+
+static inline void
+_blurcol (guchar* pixels,
+ gint width,
+ gint height,
+ gint channels,
+ gint x,
+ gint alpha,
+ gint aprec,
+ gint zprec)
+{
+ gint zR;
+ gint zG;
+ gint zB;
+ gint zA;
+ gint index;
+ guchar* ptr;
+
+ ptr = pixels;
+
+ ptr += x * channels;
+
+ zR = *((guchar*) ptr ) << zprec;
+ zG = *((guchar*) ptr + 1) << zprec;
+ zB = *((guchar*) ptr + 2) << zprec;
+ zA = *((guchar*) ptr + 3) << zprec;
+
+ for (index = width; index < (height - 1) * width; index += width)
+ _blurinner ((guchar*) &ptr[index * channels],
+ &zR,
+ &zG,
+ &zB,
+ &zA,
+ alpha,
+ aprec,
+ zprec);
+
+ for (index = (height - 2) * width; index >= 0; index -= width)
+ _blurinner ((guchar*) &ptr[index * channels],
+ &zR,
+ &zG,
+ &zB,
+ &zA,
+ alpha,
+ aprec,
+ zprec);
+}
+
+void
+_expblur (guchar* pixels,
+ gint width,
+ gint height,
+ gint channels,
+ gint radius,
+ gint aprec,
+ gint zprec)
+{
+ gint alpha;
+ gint row = 0;
+ gint col = 0;
+
+ if (radius < 1)
+ return;
+
+ // calculate the alpha such that 90% of
+ // the kernel is within the radius.
+ // (Kernel extends to infinity)
+ alpha = (gint) ((1 << aprec) * (1.0f - expf (-2.3f / (radius + 1.f))));
+
+ for (; row < height; row++)
+ _blurrow (pixels,
+ width,
+ height,
+ channels,
+ row,
+ alpha,
+ aprec,
+ zprec);
+
+ for(; col < width; col++)
+ _blurcol (pixels,
+ width,
+ height,
+ channels,
+ col,
+ alpha,
+ aprec,
+ zprec);
+
+ return;
+}
+
+void
+_surface_blur (cairo_surface_t* surface,
+ guint radius)
+{
+ guchar* pixels;
+ guint width;
+ guint height;
+ cairo_format_t format;
+
+ // before we mess with the surface execute any pending drawing
+ cairo_surface_flush (surface);
+
+ pixels = cairo_image_surface_get_data (surface);
+ width = cairo_image_surface_get_width (surface);
+ height = cairo_image_surface_get_height (surface);
+ format = cairo_image_surface_get_format (surface);
+
+ switch (format)
+ {
+ case CAIRO_FORMAT_ARGB32:
+ _expblur (pixels, width, height, 4, radius, 16, 7);
+ break;
+
+ case CAIRO_FORMAT_RGB24:
+ _expblur (pixels, width, height, 3, radius, 16, 7);
+ break;
+
+ case CAIRO_FORMAT_A8:
+ _expblur (pixels, width, height, 1, radius, 16, 7);
+ break;
+
+ default :
+ // do nothing
+ break;
+ }
+
+ // inform cairo we altered the surfaces contents
+ cairo_surface_mark_dirty (surface);
+}
+
static void
draw (GtkWidget* button, cairo_t *cr)
{
@@ -1200,6 +1200,8 @@ draw (GtkWidget* button, cairo_t *cr)
}
}
+
+
/**
* play_button_new:
* @returns: a new #PlayButton.
diff --git a/src/title-widget.c b/src/title-widget.c
index bc1d453..3baeb19 100644
--- a/src/title-widget.c
+++ b/src/title-widget.c
@@ -63,15 +63,15 @@ G_DEFINE_TYPE (TitleWidget, title_widget, GTK_TYPE_IMAGE_MENU_ITEM);
static void
title_widget_class_init (TitleWidgetClass *klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->button_press_event = title_widget_button_press_event;
-
- g_type_class_add_private (klass, sizeof (TitleWidgetPrivate));
+ widget_class->button_press_event = title_widget_button_press_event;
+
+ g_type_class_add_private (klass, sizeof (TitleWidgetPrivate));
- gobject_class->dispose = title_widget_dispose;
- gobject_class->finalize = title_widget_finalize;
+ gobject_class->dispose = title_widget_dispose;
+ gobject_class->finalize = title_widget_finalize;
}
static void
@@ -92,7 +92,7 @@ title_widget_init (TitleWidget *self)
+ 1 /* padding */,
height);
gtk_misc_set_alignment(GTK_MISC(icon), 0.5 /* right aligned */, 0);
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon));
+ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon));
gtk_widget_show(icon);
}
@@ -118,7 +118,7 @@ title_widget_button_press_event (GtkWidget *menuitem,
TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(menuitem);
GValue value = {0};
- g_value_init(&value, G_TYPE_BOOLEAN);
+ g_value_init(&value, G_TYPE_BOOLEAN);
g_value_set_boolean(&value, TRUE);
dbusmenu_menuitem_handle_event (priv->twin_item, "Title menu event", &value, 0);
@@ -134,8 +134,8 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property,
TitleWidget* mitem = TITLE_WIDGET(userdata);
if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){
- gtk_menu_item_set_label (GTK_MENU_ITEM(mitem),
- g_value_get_string(value));
+ gtk_menu_item_set_label (GTK_MENU_ITEM(mitem),
+ g_value_get_string(value));
}
}
@@ -158,8 +158,7 @@ title_widget_set_twin_item(TitleWidget* self,
gtk_menu_item_set_label (GTK_MENU_ITEM(self),
dbusmenu_menuitem_property_get(priv->twin_item,
- DBUSMENU_TITLE_MENUITEM_NAME));
-
+ DBUSMENU_TITLE_MENUITEM_NAME));
}
static gboolean
@@ -218,7 +217,7 @@ title_widget_new(DbusmenuMenuitem *item)
{
GtkWidget* widget = g_object_new (TITLE_WIDGET_TYPE,
NULL);
- gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (widget), TRUE);
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (widget), TRUE);
title_widget_set_twin_item((TitleWidget*)widget, item);
return widget;
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 37ea874..ed27a07 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -229,10 +229,10 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
}
}
- /**
- * transport_new:
- * @returns: a new #TransportWidget.
- **/
+/**
+* transport_new:
+* @returns: a new #TransportWidget.
+**/
GtkWidget*
transport_widget_new(DbusmenuMenuitem *item)
{