annotate audacious/widgets/playlist_slider.c @ 1557:dc3ae578e7b6 trunk

[svn] - make it compile
author nenolod
date Thu, 10 Aug 2006 19:21:37 -0700
parents ec4d858524fa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1541
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
3 *
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
4 * Based on XMMS:
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
6 *
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
10 * (at your option) any later version.
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
11 *
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
16 *
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
20 */
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
21
1556
ec4d858524fa [svn] - cleanup
nenolod
parents: 1541
diff changeset
22 #include "widgetcore.h"
1541
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
23
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
24 #include <glib.h>
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
25
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
26 #include "playlist.h"
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
27 #include "ui_playlist.h"
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
28 #include "skin.h"
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
29 #include "widget.h"
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
30
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
31 void
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
32 playlistslider_draw(Widget * w)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
33 {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
34 PlaylistSlider *ps = (PlaylistSlider *) w;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
35 GdkPixmap *obj;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
36 gint y, skinx;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
37
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
38 g_return_if_fail(ps != NULL);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
39 g_return_if_fail(ps->ps_list != NULL);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
40
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
41 if (playlist_get_length() > ps->ps_list->pl_num_visible)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
42 y = (ps->ps_list->pl_first * (ps->ps_widget.height - 19)) /
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
43 (playlist_get_length() - ps->ps_list->pl_num_visible);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
44 else
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
45 y = 0;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
46
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
47 obj = ps->ps_widget.parent;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
48
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
49 if (ps->ps_back_image) {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
50 if (skin_get_id() != ps->ps_skin_id)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
51 ps->ps_skin_id = skin_get_id();
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
52 else if (ps->ps_widget.height == ps->ps_prev_height)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
53 gdk_draw_image(obj, ps->ps_widget.gc,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
54 ps->ps_back_image, 0, 0,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
55 ps->ps_widget.x,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
56 ps->ps_widget.y + ps->ps_prev_y, 8, 18);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
57 gdk_image_destroy(ps->ps_back_image);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
58 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
59
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
60 ps->ps_prev_y = y;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
61 ps->ps_prev_height = ps->ps_widget.height;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
62 ps->ps_back_image = gdk_drawable_get_image(obj, ps->ps_widget.x,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
63 ps->ps_widget.y + y, 8, 18);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
64 if (ps->ps_is_draging)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
65 skinx = 61;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
66 else
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
67 skinx = 52;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
68
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
69 skin_draw_pixmap(bmp_active_skin, obj, ps->ps_widget.gc, SKIN_PLEDIT,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
70 skinx, 53, ps->ps_widget.x, ps->ps_widget.y + y, 8, 18);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
71 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
72
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
73 static void
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
74 playlistslider_set_pos(PlaylistSlider * ps, gint y)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
75 {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
76 gint pos;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
77
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
78 y = CLAMP(y, 0, ps->ps_widget.height - 19);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
79
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
80 pos = (y * (playlist_get_length() - ps->ps_list->pl_num_visible)) /
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
81 (ps->ps_widget.height - 19);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
82 playlistwin_set_toprow(pos);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
83 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
84
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
85
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
86 void
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
87 playlistslider_button_press_cb(GtkWidget * widget,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
88 GdkEventButton * event, PlaylistSlider * ps)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
89 {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
90 gint y = event->y - ps->ps_widget.y;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
91
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
92 if (!widget_contains(&ps->ps_widget, event->x, event->y))
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
93 return;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
94
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
95 if (event->button != 1 && event->button != 2)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
96 return;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
97
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
98 if ((y >= ps->ps_prev_y && y < ps->ps_prev_y + 18)) {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
99 ps->ps_is_draging |= event->button;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
100 ps->ps_drag_y = y - ps->ps_prev_y;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
101 widget_draw(WIDGET(ps));
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
102 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
103 else if (event->button == 2) {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
104 playlistslider_set_pos(ps, y);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
105 ps->ps_is_draging |= event->button;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
106 ps->ps_drag_y = 0;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
107 widget_draw(WIDGET(ps));
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
108 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
109 else {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
110 gint n = ps->ps_list->pl_num_visible / 2;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
111 if (y < ps->ps_prev_y)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
112 n *= -1;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
113 playlistwin_scroll(n);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
114 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
115 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
116
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
117 void
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
118 playlistslider_button_release_cb(GtkWidget * widget,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
119 GdkEventButton * event,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
120 PlaylistSlider * ps)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
121 {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
122 if (ps->ps_is_draging) {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
123 ps->ps_is_draging &= ~event->button;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
124 widget_draw(WIDGET(ps));
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
125 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
126 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
127
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
128 void
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
129 playlistslider_motion_cb(GtkWidget * widget, GdkEventMotion * event,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
130 PlaylistSlider * ps)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
131 {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
132 gint y;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
133
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
134 if (!ps->ps_is_draging)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
135 return;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
136
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
137 y = event->y - ps->ps_widget.y - ps->ps_drag_y;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
138 playlistslider_set_pos(ps, y);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
139 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
140
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
141 PlaylistSlider *
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
142 create_playlistslider(GList ** wlist, GdkPixmap * parent,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
143 GdkGC * gc, gint x, gint y, gint h,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
144 PlayList_List * list)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
145 {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
146 PlaylistSlider *ps;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
147
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
148 ps = g_new0(PlaylistSlider, 1);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
149 widget_init(&ps->ps_widget, parent, gc, x, y, 8, h, 1);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
150
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
151 ps->ps_widget.button_press_cb =
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
152 (void (*)(GtkWidget *, GdkEventButton *, gpointer))
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
153 playlistslider_button_press_cb;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
154
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
155 ps->ps_widget.button_release_cb =
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
156 (void (*)(GtkWidget *, GdkEventButton *, gpointer))
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
157 playlistslider_button_release_cb;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
158
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
159 ps->ps_widget.motion_cb =
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
160 (void (*)(GtkWidget *, GdkEventMotion *, gpointer))
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
161 playlistslider_motion_cb;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
162
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
163 ps->ps_widget.draw = playlistslider_draw;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
164 ps->ps_list = list;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
165
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
166 widget_list_add(wlist, WIDGET(ps));
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
167 return ps;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
168 }