annotate audacious/menurow.c @ 1263:ccf616f86fb4 trunk

[svn] some minor tweaks
author nenolod
date Thu, 15 Jun 2006 21:55:45 -0700
parents 0a73d1faeb4e
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 "menurow.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 <gdk/gdk.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 #include "main.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include "menurow.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 menurow_draw(Widget * widget)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 MenuRow *mr = MENU_ROW(widget);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 GdkPixmap *obj = mr->mr_widget.parent;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 if (mr->mr_selected == MENUROW_NONE) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 if (cfg.always_show_cb || mr->mr_bpushed)
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 mr->mr_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 mr->mr_skin_index,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 mr->mr_nx, mr->mr_ny,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 mr->mr_widget.x, mr->mr_widget.y, 8, 43);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 skin_draw_pixmap(bmp_active_skin, obj,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 mr->mr_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 mr->mr_skin_index,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 mr->mr_nx + 8, mr->mr_ny,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 mr->mr_widget.x, mr->mr_widget.y, 8, 43);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 skin_draw_pixmap(bmp_active_skin, obj,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 mr->mr_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 mr->mr_skin_index,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 mr->mr_sx + ((mr->mr_selected - 1) * 8),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 mr->mr_sy, mr->mr_widget.x, mr->mr_widget.y, 8, 43);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 if (cfg.always_show_cb || mr->mr_bpushed) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 if (mr->mr_always_selected)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 skin_draw_pixmap(bmp_active_skin, obj,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 mr->mr_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 mr->mr_skin_index,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 mr->mr_sx + 8, mr->mr_sy + 10,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 mr->mr_widget.x, mr->mr_widget.y + 10, 8, 8);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 if (mr->mr_doublesize_selected)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 skin_draw_pixmap(bmp_active_skin, obj,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 mr->mr_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 mr->mr_skin_index,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 mr->mr_sx + 24, mr->mr_sy + 26,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 mr->mr_widget.x, mr->mr_widget.y + 26, 8, 8);
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
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 MenuRowItem
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 menurow_find_selected(MenuRow * mr, gint x, gint y)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 MenuRowItem ret = MENUROW_NONE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 x -= mr->mr_widget.x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 y -= mr->mr_widget.y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 if (x > 0 && x < 8) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 if (y >= 0 && y <= 10)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 ret = MENUROW_OPTIONS;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 if (y >= 10 && y <= 17)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 ret = MENUROW_ALWAYS;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 if (y >= 18 && y <= 25)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 ret = MENUROW_FILEINFOBOX;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 if (y >= 26 && y <= 33)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 ret = MENUROW_DOUBLESIZE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 if (y >= 34 && y <= 42)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 ret = MENUROW_VISUALIZATION;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 menurow_button_press(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 GdkEventButton * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 MenuRow *mr = MENU_ROW(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 if (event->button != 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 if (widget_contains(&mr->mr_widget, event->x, event->y)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 mr->mr_bpushed = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 mr->mr_selected = menurow_find_selected(mr, event->x, event->y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 widget_draw(WIDGET(mr));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 if (mr->mr_change_callback)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 mr->mr_change_callback(mr->mr_selected);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 menurow_motion(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 GdkEventMotion * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 MenuRow *mr = MENU_ROW(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 if (mr->mr_bpushed) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 mr->mr_selected = menurow_find_selected(mr, event->x, event->y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 widget_draw(WIDGET(mr));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 if (mr->mr_change_callback)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 mr->mr_change_callback(mr->mr_selected);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 menurow_button_release(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 GdkEventButton * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 MenuRow *mr = MENU_ROW(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 if (mr->mr_bpushed) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 mr->mr_bpushed = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 if (mr->mr_selected == MENUROW_ALWAYS)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 mr->mr_always_selected = !mr->mr_always_selected;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 if (mr->mr_selected == MENUROW_DOUBLESIZE)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 mr->mr_doublesize_selected = !mr->mr_doublesize_selected;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 0
diff changeset
152 if ((int)(mr->mr_selected) != -1 && mr->mr_release_callback)
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 mr->mr_release_callback(mr->mr_selected);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 mr->mr_selected = MENUROW_NONE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 widget_draw(WIDGET(mr));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 MenuRow *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 create_menurow(GList ** wlist, GdkPixmap * parent, GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 gint x, gint y, gint nx, gint ny, gint sx, gint sy,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 void (*ccb) (MenuRowItem),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 void (*rcb) (MenuRowItem), SkinPixmapId si)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 MenuRow *mr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 mr = g_new0(MenuRow, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 widget_init(&mr->mr_widget, parent, gc, x, y, 8, 43, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 mr->mr_widget.draw = menurow_draw;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 mr->mr_widget.button_press_cb = menurow_button_press;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 mr->mr_widget.motion_cb = menurow_motion;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 mr->mr_widget.button_release_cb = menurow_button_release;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 mr->mr_nx = nx;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 mr->mr_ny = ny;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 mr->mr_sx = sx;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 mr->mr_sy = sy;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 mr->mr_selected = MENUROW_NONE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 mr->mr_change_callback = ccb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 mr->mr_release_callback = rcb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 mr->mr_skin_index = si;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184 widget_list_add(wlist, WIDGET(mr));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185 return mr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 }