annotate src/dockalbumart/dockalbumart.c @ 2512:1f6b5f5768e2

Remove some completely useless null-pointer checks, g_free() checks the pointer anyway.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 02 Apr 2008 22:58:35 +0300
parents 7b284f323ad8
children bd3a24b39058
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1710
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
1 /*
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
2 * dockalbumart: An audacious plugin to change the MacOS dock tile to the
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
3 * album art.
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
4 * dockalbumart.c: Plugin implementation
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
5 *
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
6 * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
7 *
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
8 * Permission to use, copy, modify, and/or distribute this software for any
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
9 * purpose with or without fee is hereby granted, provided that the above
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
10 * copyright notice and this permission notice is present in all copies.
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
11 *
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
12 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
13 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
15 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
16 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
17 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
18 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
19 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
20 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
21 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
22 * POSSIBILITY OF SUCH DAMAGE.
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
23 */
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
24
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
25 #include <glib.h>
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
26 #include <audacious/i18n.h>
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
27
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
28 #include <Carbon/Carbon.h>
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
29
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
30 #include <audacious/plugin.h>
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
31 #include <audacious/util.h>
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
32
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
33 #include "audacious_player.xpm"
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
34
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
35 extern gchar *fileinfo_recursive_get_image(const gchar* path, const gchar* file_name, gint depth);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
36
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
37 /* utility functions */
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
38 static void
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
39 dock_set_icon_from_pixbuf(const GdkPixbuf *in)
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
40 {
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
41 GdkPixbuf *pixbuf;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
42 CGColorSpaceRef colorspace;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
43 CGDataProviderRef data_provider;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
44 CGImageRef image;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
45 gpointer data;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
46 gint rowstride, pixbuf_width, pixbuf_height;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
47 gboolean has_alpha;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
48
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
49 pixbuf = gdk_pixbuf_scale_simple(in, 128, 128, GDK_INTERP_BILINEAR);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
50
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
51 data = gdk_pixbuf_get_pixels(pixbuf);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
52 pixbuf_width = gdk_pixbuf_get_width(pixbuf);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
53 pixbuf_height = gdk_pixbuf_get_height(pixbuf);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
54 rowstride = gdk_pixbuf_get_rowstride(pixbuf);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
55 has_alpha = gdk_pixbuf_get_has_alpha(pixbuf);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
56
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
57 /* create the colourspace for the CGImage. */
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
58 colorspace = CGColorSpaceCreateDeviceRGB();
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
59 data_provider = CGDataProviderCreateWithData(NULL, data, pixbuf_height * rowstride, NULL);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
60 image = CGImageCreate(pixbuf_width, pixbuf_height, 8,
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
61 has_alpha ? 32 : 24, rowstride, colorspace,
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
62 has_alpha ? kCGImageAlphaLast : 0,
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
63 data_provider, NULL, FALSE,
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
64 kCGRenderingIntentDefault);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
65
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
66 /* release the colourspace and data provider, we have what we want. */
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
67 CGDataProviderRelease(data_provider);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
68 CGColorSpaceRelease(colorspace);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
69
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
70 /* set the dock tile images */
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
71 SetApplicationDockTileImage(image);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
72
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
73 /* and release */
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
74 CGImageRelease(image);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
75 g_object_unref(pixbuf);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
76 }
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
77
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
78 static void
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
79 pixbuf_find_and_load(Tuple *tuple)
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
80 {
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
81 GdkPixbuf *out;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
82 gchar *tmp;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
83 const gchar *file_path, *file_name;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
84
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
85 file_name = aud_tuple_get_string(tuple, FIELD_FILE_NAME, NULL);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
86 file_path = aud_tuple_get_string(tuple, FIELD_FILE_PATH, NULL);
1710
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
87
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
88 if (file_name != NULL && file_path != NULL)
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
89 {
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
90 tmp = fileinfo_recursive_get_image(file_path, file_name, 0);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
91 if (tmp)
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
92 {
1715
bd269f6e26b2 remove caching code, it's pointless.
William Pitcock <nenolod@atheme.org>
parents: 1710
diff changeset
93 GdkPixbuf *new = gdk_pixbuf_new_from_file(tmp, NULL);
bd269f6e26b2 remove caching code, it's pointless.
William Pitcock <nenolod@atheme.org>
parents: 1710
diff changeset
94 dock_set_icon_from_pixbuf(new);
bd269f6e26b2 remove caching code, it's pointless.
William Pitcock <nenolod@atheme.org>
parents: 1710
diff changeset
95 g_object_unref(new);
1710
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
96 }
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
97 else
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
98 {
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
99 GdkPixbuf *new = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
100 dock_set_icon_from_pixbuf(new);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
101 g_object_unref(new);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
102 }
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
103 }
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
104 }
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
105
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
106 /* trigger functions */
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
107
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
108 static void
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
109 dockart_trigger_func_pb_start_cb(gpointer plentry_p, gpointer unused)
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
110 {
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
111 PlaylistEntry *entry = (PlaylistEntry *) plentry_p;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
112 Tuple *tuple;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
113
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
114 if (entry == NULL)
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
115 return;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
116
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
117 tuple = entry->tuple;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
118
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
119 if (tuple == NULL)
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
120 return;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
121
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
122 pixbuf_find_and_load(tuple);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
123 }
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
124
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
125 static void
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
126 dockart_trigger_func_pb_end_cb(gpointer plentry_p, gpointer unused)
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
127 {
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
128 GdkPixbuf *new;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
129
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
130 new = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
131 dock_set_icon_from_pixbuf(new);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
132 g_object_unref(new);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
133 }
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
134
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
135 static void
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
136 dockart_init(void)
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
137 {
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
138 aud_hook_associate("playback begin", dockart_trigger_func_pb_start_cb, NULL);
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
139 aud_hook_associate("playback end", dockart_trigger_func_pb_end_cb, NULL);
1710
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
140 }
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
141
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
142 static void
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
143 dockart_cleanup(void)
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
144 {
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
145 GdkPixbuf *new;
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
146
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
147 aud_hook_dissociate("playback begin", dockart_trigger_func_pb_start_cb);
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
148 aud_hook_dissociate("playback end", dockart_trigger_func_pb_end_cb);
1710
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
149
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
150 /* reset dock tile */
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
151 new = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
152 dock_set_icon_from_pixbuf(new);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
153 g_object_unref(new);
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
154 }
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
155
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
156 GeneralPlugin dockart_gp =
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
157 {
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
158 .description = "Dock Album Art",
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
159 .init = dockart_init,
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
160 .cleanup = dockart_cleanup
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
161 };
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
162
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
163 GeneralPlugin *dockart_gplist[] = { &dockart_gp, NULL };
5dfa4fc721b0 Add dockalbumart plugin for MacOS. (this could also be ported to GNOME's AWN too.)
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
164 SIMPLE_GENERAL_PLUGIN(dockart, dockart_gplist);