annotate audacious/pbutton.c @ 289:8eab873f20a8 trunk

[svn] possible DND fix for konqueror. (cleaned up version of fixed version of my cleanups... i will NOT code at 3 AM again.).
author nenolod
date Wed, 14 Dec 2005 11:36:27 -0800
parents cb178e5ad177
children d7d70779c074
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Based on XMMS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 * (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 #include "pbutton.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 #include <gtk/gtk.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #include <gdk/gdk.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include "skin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include "widget.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 pbutton_draw(PButton * button)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 GdkPixmap *obj;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 if (button->pb_allow_draw) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 obj = button->pb_widget.parent;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 if (button->pb_pressed && button->pb_inside) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 skin_draw_pixmap(bmp_active_skin, obj,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 button->pb_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 button->pb_skin_index2, button->pb_px,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 button->pb_py, button->pb_widget.x,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 button->pb_widget.y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 button->pb_widget.width,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 button->pb_widget.height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 skin_draw_pixmap(bmp_active_skin, obj,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 button->pb_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 button->pb_skin_index1,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 button->pb_nx, button->pb_ny,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 button->pb_widget.x, button->pb_widget.y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 button->pb_widget.width,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 button->pb_widget.height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 pbutton_button_press_cb(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 GdkEventButton * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 PButton * button)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 if (event->button != 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 if (widget_contains(&button->pb_widget, event->x, event->y)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 button->pb_pressed = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 button->pb_inside = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 widget_draw(WIDGET(button));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 pbutton_button_release_cb(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 GdkEventButton * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 PButton * button)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 if (event->button != 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 if (button->pb_inside && button->pb_pressed) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 button->pb_inside = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 widget_draw(WIDGET(button));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 if (button->pb_push_cb)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 button->pb_push_cb();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 if (button->pb_pressed)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 button->pb_pressed = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 pbutton_motion_cb(GtkWidget * widget, GdkEventMotion * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 PButton * button)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 gint inside;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 if (!button->pb_pressed)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 inside = widget_contains(&button->pb_widget, event->x, event->y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 if (inside != button->pb_inside) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 button->pb_inside = inside;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 widget_draw(WIDGET(button));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 pbutton_set_skin_index(PButton * b, SkinPixmapId si)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 b->pb_skin_index1 = b->pb_skin_index2 = si;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 pbutton_set_skin_index1(PButton * b, SkinPixmapId si)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 b->pb_skin_index1 = si;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 pbutton_set_skin_index2(PButton * b, SkinPixmapId si)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 b->pb_skin_index2 = si;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 pbutton_set_button_data(PButton * b, gint nx, gint ny, gint px, gint py)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 if (nx > -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 b->pb_nx = nx;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 if (ny > -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 b->pb_ny = ny;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 if (px > -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 b->pb_px = px;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 if (py > -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 b->pb_py = py;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 PButton *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 create_pbutton_ex(GList ** wlist, GdkPixmap * parent, GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 gint x, gint y, gint w, gint h, gint nx,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 gint ny, gint px, gint py, void (*cb) (void),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 SkinPixmapId si1, SkinPixmapId si2)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 PButton *b;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 b = g_new0(PButton, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 widget_init(&b->pb_widget, parent, gc, x, y, w, h, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 b->pb_widget.button_press_cb =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 (void (*)(GtkWidget *, GdkEventButton *, gpointer))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 pbutton_button_press_cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 b->pb_widget.button_release_cb =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 (void (*)(GtkWidget *, GdkEventButton *, gpointer))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 pbutton_button_release_cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 b->pb_widget.motion_cb =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 (void (*)(GtkWidget *, GdkEventMotion *, gpointer))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 pbutton_motion_cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 b->pb_widget.draw = (void (*)(Widget *)) pbutton_draw;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 b->pb_nx = nx;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 b->pb_ny = ny;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 b->pb_px = px;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 b->pb_py = py;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 b->pb_push_cb = cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 b->pb_skin_index1 = si1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 b->pb_skin_index2 = si2;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 b->pb_allow_draw = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 b->pb_inside = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 b->pb_pressed = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 widget_list_add(wlist, WIDGET(b));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 return b;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 PButton *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 create_pbutton(GList ** wlist, GdkPixmap * parent, GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 gint x, gint y, gint w, gint h, gint nx, gint ny,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 gint px, gint py, void (*cb) (void), SkinPixmapId si)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 return create_pbutton_ex(wlist, parent, gc, x, y, w, h, nx, ny, px, py,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 cb, si, si);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 free_pbutton(PButton * b)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 g_free(b);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189 }