annotate audacious/sbutton.c @ 941:f923aa230a2a trunk

[svn] rewritten audiocompress aboutbox
author giacomo
date Sat, 15 Apr 2006 18:49:50 -0700
parents cb178e5ad177
children f12d7e208b43
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 "sbutton.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 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 sbutton_button_press_cb(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 GdkEventButton * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 SButton * button)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 if (event->button != 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 if (widget_contains(&button->sb_widget, event->x, event->y)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 button->sb_pressed = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 button->sb_inside = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 sbutton_button_release_cb(GtkWidget * widget, GdkEventButton * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 SButton * button)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 if (event->button != 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 if (button->sb_inside && button->sb_pressed) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 button->sb_inside = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 if (button->sb_push_cb)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 button->sb_push_cb();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 if (button->sb_pressed)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 button->sb_pressed = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 sbutton_motion_cb(GtkWidget * widget, GdkEventMotion * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 SButton * button)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 int inside;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 if (!button->sb_pressed)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 inside = widget_contains(&button->sb_widget, event->x, event->y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 if (inside != button->sb_inside)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 button->sb_inside = inside;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 SButton *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 create_sbutton(GList ** wlist, GdkPixmap * parent, GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 gint x, gint y, gint w, gint h, void (*cb) (void))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 SButton *b;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 b = g_new0(SButton, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 widget_init(&b->sb_widget, parent, gc, x, y, w, h, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 b->sb_widget.button_press_cb =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 (void (*)(GtkWidget *, GdkEventButton *, gpointer))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 sbutton_button_press_cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 b->sb_widget.button_release_cb =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 (void (*)(GtkWidget *, GdkEventButton *, gpointer))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 sbutton_button_release_cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 b->sb_widget.motion_cb =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 (void (*)(GtkWidget *, GdkEventMotion *, gpointer))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 sbutton_motion_cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 b->sb_push_cb = cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 widget_list_add(wlist, WIDGET(b));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 return b;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 free_sbutton(SButton * b)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 g_free(b);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 }