annotate audacious/widgets/sbutton.c @ 1614:9b4678a2efc9 trunk

[svn] - If transparency fails, disable it.
author nhjm449
date Sun, 03 Sep 2006 22:04:17 -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 #include <gtk/gtk.h>
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
26 #include <gdk/gdk.h>
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
27
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
28 void
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
29 sbutton_button_press_cb(GtkWidget * widget,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
30 GdkEventButton * event,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
31 SButton * button)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
32 {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
33 if (event->button != 1)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
34 return;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
35
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
36 if (widget_contains(&button->sb_widget, event->x, event->y)) {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
37 button->sb_pressed = 1;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
38 button->sb_inside = 1;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
39 }
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
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
42 void
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
43 sbutton_button_release_cb(GtkWidget * widget, GdkEventButton * event,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
44 SButton * button)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
45 {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
46 if (event->button != 1)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
47 return;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
48 if (button->sb_inside && button->sb_pressed) {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
49 button->sb_inside = 0;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
50 if (button->sb_push_cb)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
51 button->sb_push_cb();
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
52 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
53 if (button->sb_pressed)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
54 button->sb_pressed = 0;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
55 }
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
56
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
57 void
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
58 sbutton_motion_cb(GtkWidget * widget, GdkEventMotion * event,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
59 SButton * button)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
60 {
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
61 int inside;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
62
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
63 if (!button->sb_pressed)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
64 return;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
65
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
66 inside = widget_contains(&button->sb_widget, event->x, event->y);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
67
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
68 if (inside != button->sb_inside)
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
69 button->sb_inside = inside;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
70 }
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 SButton *
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
73 create_sbutton(GList ** wlist, GdkPixmap * parent, GdkGC * gc,
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
74 gint x, gint y, gint w, gint h, void (*cb) (void))
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 SButton *b;
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 b = g_new0(SButton, 1);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
79 widget_init(&b->sb_widget, parent, gc, x, y, w, h, 1);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
80 b->sb_widget.button_press_cb =
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
81 (void (*)(GtkWidget *, GdkEventButton *, gpointer))
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
82 sbutton_button_press_cb;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
83 b->sb_widget.button_release_cb =
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
84 (void (*)(GtkWidget *, GdkEventButton *, gpointer))
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
85 sbutton_button_release_cb;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
86 b->sb_widget.motion_cb =
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
87 (void (*)(GtkWidget *, GdkEventMotion *, gpointer))
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
88 sbutton_motion_cb;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
89 b->sb_push_cb = cb;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
90
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
91 widget_list_add(wlist, WIDGET(b));
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
92 return b;
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
93 }
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 void
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
96 free_sbutton(SButton * b)
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 g_free(b);
06329cbf186a [svn] this massive commit does the following:
nenolod
parents:
diff changeset
99 }