Mercurial > audlegacy
annotate src/audacious/widgets/playlist_slider.c @ 3123:f1c756f39e6c trunk audacious-1.4.0-DR1
Invoke "Plugins are not derived work" clause provided by GPL3.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 20 Jul 2007 09:09:58 -0500 |
parents | 3b6d316f8b09 |
children |
rev | line source |
---|---|
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3056
diff
changeset
|
1 /* Audacious |
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3056
diff
changeset
|
2 * Copyright (C) 2005-2007 Audacious development team. |
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3056
diff
changeset
|
3 * |
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3056
diff
changeset
|
4 * BMP - Cross-platform multimedia player |
2313 | 5 * Copyright (C) 2003-2004 BMP development team. |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3056
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
2313 | 13 * |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3056
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
21 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
23 * Audacious or using our public API to be a derived work. |
2313 | 24 */ |
25 | |
26 #include "widgetcore.h" | |
27 | |
28 #include <glib.h> | |
29 | |
30 #include "playlist.h" | |
31 #include "ui_playlist.h" | |
32 #include "skin.h" | |
33 #include "widget.h" | |
34 | |
35 extern GCond *cond_scan; | |
36 | |
37 void | |
38 playlistslider_draw(Widget * w) | |
39 { | |
40 PlaylistSlider *ps = (PlaylistSlider *) w; | |
41 GdkPixmap *obj; | |
42 gint y, skinx; | |
43 Playlist *playlist = playlist_get_active(); | |
44 | |
45 g_return_if_fail(ps != NULL); | |
46 g_return_if_fail(ps->ps_list != NULL); | |
47 | |
48 if (playlist_get_length(playlist) > ps->ps_list->pl_num_visible) | |
49 y = (ps->ps_list->pl_first * (ps->ps_widget.height - 19)) / | |
50 (playlist_get_length(playlist) - ps->ps_list->pl_num_visible); | |
51 else | |
52 y = 0; | |
53 | |
54 obj = ps->ps_widget.parent; | |
55 | |
56 if (ps->ps_back_image) { | |
57 if (skin_get_id() != ps->ps_skin_id) | |
58 ps->ps_skin_id = skin_get_id(); | |
59 else if (ps->ps_widget.height == ps->ps_prev_height) | |
60 gdk_draw_image(obj, ps->ps_widget.gc, | |
61 ps->ps_back_image, 0, 0, | |
62 ps->ps_widget.x, | |
63 ps->ps_widget.y + ps->ps_prev_y, 8, 18); | |
64 g_object_unref(ps->ps_back_image); | |
65 } | |
66 | |
67 ps->ps_prev_y = y; | |
68 ps->ps_prev_height = ps->ps_widget.height; | |
69 ps->ps_back_image = gdk_drawable_get_image(obj, ps->ps_widget.x, | |
70 ps->ps_widget.y + y, 8, 18); | |
71 if (ps->ps_is_draging) | |
72 skinx = 61; | |
73 else | |
74 skinx = 52; | |
75 | |
76 skin_draw_pixmap(bmp_active_skin, obj, ps->ps_widget.gc, SKIN_PLEDIT, | |
77 skinx, 53, ps->ps_widget.x, ps->ps_widget.y + y, 8, 18); | |
78 } | |
79 | |
80 static void | |
81 playlistslider_set_pos(PlaylistSlider * ps, gint y) | |
82 { | |
83 gint pos; | |
84 Playlist *playlist = playlist_get_active(); | |
85 | |
86 y = CLAMP(y, 0, ps->ps_widget.height - 19); | |
87 | |
88 pos = (y * (playlist_get_length(playlist) - ps->ps_list->pl_num_visible)) / | |
89 (ps->ps_widget.height - 19); | |
90 playlistwin_set_toprow(pos); | |
91 } | |
92 | |
93 void | |
94 playlistslider_button_press_cb(GtkWidget * widget, | |
95 GdkEventButton * event, PlaylistSlider * ps) | |
96 { | |
97 gint y = event->y - ps->ps_widget.y; | |
98 | |
99 if (!widget_contains(&ps->ps_widget, event->x, event->y)) | |
100 return; | |
101 | |
102 if (event->button != 1 && event->button != 2) | |
103 return; | |
104 | |
105 if ((y >= ps->ps_prev_y && y < ps->ps_prev_y + 18)) { | |
106 ps->ps_is_draging |= event->button; | |
107 ps->ps_drag_y = y - ps->ps_prev_y; | |
108 widget_draw(WIDGET(ps)); | |
109 } | |
110 else if (event->button == 2) { | |
111 playlistslider_set_pos(ps, y); | |
112 ps->ps_is_draging |= event->button; | |
113 ps->ps_drag_y = 0; | |
114 widget_draw(WIDGET(ps)); | |
115 } | |
116 else { | |
117 gint n = ps->ps_list->pl_num_visible / 2; | |
118 if (y < ps->ps_prev_y) | |
119 n *= -1; | |
120 playlistwin_scroll(n); | |
121 } | |
122 g_cond_signal(cond_scan); | |
123 } | |
124 | |
125 void | |
126 playlistslider_button_release_cb(GtkWidget * widget, | |
127 GdkEventButton * event, | |
128 PlaylistSlider * ps) | |
129 { | |
130 if (ps->ps_is_draging) { | |
131 ps->ps_is_draging &= ~event->button; | |
132 widget_draw(WIDGET(ps)); | |
133 } | |
134 } | |
135 | |
136 void | |
137 playlistslider_motion_cb(GtkWidget * widget, GdkEventMotion * event, | |
138 PlaylistSlider * ps) | |
139 { | |
140 gint y; | |
141 | |
142 if (!ps->ps_is_draging) | |
143 return; | |
144 | |
145 y = event->y - ps->ps_widget.y - ps->ps_drag_y; | |
146 playlistslider_set_pos(ps, y); | |
147 g_cond_signal(cond_scan); | |
148 } | |
149 | |
150 PlaylistSlider * | |
151 create_playlistslider(GList ** wlist, GdkPixmap * parent, | |
152 GdkGC * gc, gint x, gint y, gint h, | |
153 PlayList_List * list) | |
154 { | |
155 PlaylistSlider *ps; | |
156 | |
157 ps = g_new0(PlaylistSlider, 1); | |
158 widget_init(&ps->ps_widget, parent, gc, x, y, 8, h, 1); | |
159 | |
160 ps->ps_widget.button_press_cb = | |
161 (void (*)(GtkWidget *, GdkEventButton *, gpointer)) | |
162 playlistslider_button_press_cb; | |
163 | |
164 ps->ps_widget.button_release_cb = | |
165 (void (*)(GtkWidget *, GdkEventButton *, gpointer)) | |
166 playlistslider_button_release_cb; | |
167 | |
168 ps->ps_widget.motion_cb = | |
169 (void (*)(GtkWidget *, GdkEventMotion *, gpointer)) | |
170 playlistslider_motion_cb; | |
171 | |
172 ps->ps_widget.draw = playlistslider_draw; | |
173 ps->ps_list = list; | |
174 | |
175 widget_list_add(wlist, WIDGET(ps)); | |
176 return ps; | |
177 } |