Mercurial > audlegacy
annotate audacious/ui_playlist.c @ 1282:e80a7a0b1065 trunk
[svn] - update Makefile
author | nenolod |
---|---|
date | Sat, 17 Jun 2006 19:50:11 -0700 |
parents | 02c2480ca1d5 |
children | f8c976466f60 |
rev | line source |
---|---|
1068 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2006 Audacious development team. | |
3 * | |
4 * BMP - Cross-platform multimedia player | |
0 | 5 * Copyright (C) 2003-2004 BMP development team. |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
23 */ | |
24 | |
383 | 25 #include "ui_playlist.h" |
0 | 26 |
27 #include <glib.h> | |
28 #include <glib/gi18n.h> | |
29 #include <gdk/gdk.h> | |
30 #include <gdk/gdkkeysyms.h> | |
31 #include <gtk/gtk.h> | |
32 #include <string.h> | |
33 | |
34 #include <gdk/gdkx.h> | |
35 | |
36 #include <X11/Xlib.h> | |
37 #include <unistd.h> | |
38 #include <errno.h> | |
39 | |
40 #include "libaudacious/util.h" | |
41 | |
42 #include "dnd.h" | |
1064 | 43 #include "dock.h" |
0 | 44 #include "equalizer.h" |
45 #include "hints.h" | |
46 #include "input.h" | |
47 #include "main.h" | |
48 #include "mainwin.h" | |
538
e4e897d20791
[svn] remove libaudcore, we never did anything with it
nenolod
parents:
489
diff
changeset
|
49 #include "playback.h" |
0 | 50 #include "playlist.h" |
51 #include "playlist_list.h" | |
52 #include "playlist_slider.h" | |
53 #include "pbutton.h" | |
54 #include "sbutton.h" | |
55 #include "skin.h" | |
56 #include "textbox.h" | |
57 #include "util.h" | |
58 | |
59 #include "pixmaps.h" | |
120 | 60 #include "images/audacious_playlist.xpm" |
0 | 61 |
62 | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
63 #define ITEM_SEPARATOR {"/-", NULL, NULL, 0, "<Separator>", NULL} |
0 | 64 |
65 | |
66 enum { | |
67 ADD_URL, ADD_DIR, ADD_FILES, | |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
68 SUB_MISC, SUB_ALL, SUB_CROP, SUB_SELECTED, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
69 SUB_DUPLICATE_BYTITLE, SUB_DUPLICATE_BYFILENAME, SUB_DUPLICATE_BYPATH, |
0 | 70 SEL_INV, SEL_ZERO, SEL_ALL, |
71 MISC_SORT, MISC_FILEINFO, MISC_MISCOPTS, | |
72 PLIST_NEW, PLIST_SAVE_AS, PLIST_LOAD, | |
73 SEL_LOOKUP, CLOSE_PL_WINDOW, MOVE_UP, PLIST_SAVE, | |
74 MISC_QUEUE, PLIST_CQUEUE, PLIST_JTF, PLIST_JTT, | |
75 PLAYLISTWIN_REMOVE_DEAD_FILES, | |
1062
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
76 PLAYLISTWIN_REFRESH, PLIST_DEFAULTSAVE |
0 | 77 }; |
78 | |
79 enum { | |
80 PLAYLISTWIN_SORT_BYTITLE, PLAYLISTWIN_SORT_BYFILENAME, | |
81 PLAYLISTWIN_SORT_BYPATH, PLAYLISTWIN_SORT_BYDATE, | |
1251 | 82 PLAYLISTWIN_SORT_BYARTIST, PLAYLISTWIN_SORT_SEL_BYARTIST, |
0 | 83 PLAYLISTWIN_SORT_SEL_BYTITLE, PLAYLISTWIN_SORT_SEL_BYFILENAME, |
84 PLAYLISTWIN_SORT_SEL_BYPATH, PLAYLISTWIN_SORT_SEL_BYDATE, | |
85 PLAYLISTWIN_SORT_RANDOMIZE, PLAYLISTWIN_SORT_REVERSE | |
86 }; | |
87 | |
88 GtkWidget *playlistwin; | |
89 | |
90 PlayList_List *playlistwin_list = NULL; | |
91 PButton *playlistwin_shade, *playlistwin_close; | |
92 | |
93 static gboolean playlistwin_resizing = FALSE; | |
94 | |
95 static GtkItemFactory *playlistwin_popup_menu; | |
96 static GtkItemFactory *pladd_menu, *pldel_menu; | |
97 static GtkItemFactory *plsel_menu, *plsort_menu; | |
98 static GtkItemFactory *pllist_menu; | |
99 | |
100 static GdkPixmap *playlistwin_bg; | |
101 static GdkBitmap *playlistwin_mask = NULL; | |
102 static GdkGC *playlistwin_gc; | |
103 | |
104 static GtkAccelGroup *playlistwin_accel; | |
105 | |
106 static gboolean playlistwin_hint_flag = FALSE; | |
107 | |
108 static PlaylistSlider *playlistwin_slider = NULL; | |
109 static TextBox *playlistwin_time_min, *playlistwin_time_sec; | |
110 static TextBox *playlistwin_info, *playlistwin_sinfo; | |
111 static SButton *playlistwin_srew, *playlistwin_splay; | |
112 static SButton *playlistwin_spause, *playlistwin_sstop; | |
113 static SButton *playlistwin_sfwd, *playlistwin_seject; | |
114 static SButton *playlistwin_sscroll_up, *playlistwin_sscroll_down; | |
115 | |
116 static GList *playlistwin_wlist = NULL; | |
117 | |
118 static void plsort_menu_callback(gpointer cb_data, guint action, | |
119 GtkWidget * w); | |
120 static void playlistwin_sub_menu_callback(gpointer cb_data, guint action, | |
121 GtkWidget * w); | |
122 static void playlistwin_popup_menu_callback(gpointer cb_data, guint action, | |
123 GtkWidget * w); | |
124 | |
125 static GtkItemFactoryEntry playlistwin_popup_menu_entries[] = { | |
126 {N_("/View Track Details"), NULL, | |
127 playlistwin_popup_menu_callback, | |
128 MISC_FILEINFO, "<ImageItem>", my_pixbuf}, | |
129 | |
130 ITEM_SEPARATOR, | |
131 | |
132 {N_("/Remove Selected"), "Delete", | |
133 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
134 SUB_SELECTED, "<StockItem>", GTK_STOCK_REMOVE}, |
0 | 135 |
136 {N_("/Remove Unselected"), NULL, | |
137 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
138 SUB_CROP, "<StockItem>", GTK_STOCK_REMOVE}, |
0 | 139 |
140 {N_("/Remove All"), NULL, | |
141 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
142 SUB_ALL, "<StockItem>", GTK_STOCK_CLEAR}, |
0 | 143 |
144 ITEM_SEPARATOR, | |
145 | |
146 {N_("/Queue Toggle"), "q", | |
147 playlistwin_popup_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
148 MISC_QUEUE, "<ImageItem>", queuetoggle_pixbuf}, |
0 | 149 }; |
150 | |
151 static GtkItemFactoryEntry pladd_menu_entries[] = { | |
152 {N_("/Add CD..."), "<shift>c", | |
153 mainwin_general_menu_callback, | |
154 MAINWIN_GENERAL_ADDCD, "<StockItem>", GTK_STOCK_CDROM}, | |
155 | |
156 {N_("/Add Internet Address..."), "<control>h", | |
157 mainwin_general_menu_callback, | |
158 MAINWIN_GENERAL_PLAYLOCATION, "<StockItem>", GTK_STOCK_NETWORK}, | |
159 | |
160 {N_("/Add Files..."), "f", | |
161 mainwin_general_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
162 MAINWIN_GENERAL_PLAYFILE, "<StockItem>", GTK_STOCK_ADD}, |
0 | 163 }; |
164 | |
165 static GtkItemFactoryEntry pldel_menu_entries[] = { | |
166 {N_("/Clear Queue"), "<shift>Q", | |
167 playlistwin_popup_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
168 PLIST_CQUEUE, "<StockItem>", GTK_STOCK_CANCEL}, |
0 | 169 |
170 ITEM_SEPARATOR, | |
171 | |
172 {N_("/Remove Unavailable Files"), NULL, | |
173 playlistwin_sub_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
174 PLAYLISTWIN_REMOVE_DEAD_FILES, "<ImageItem>", removeunavail_pixbuf}, |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
175 |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
176 {N_("/Remove Duplicates"), NULL, NULL, 0, "<Branch>", NULL}, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
177 {N_("/Remove Duplicates/By Title"), NULL, |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
178 playlistwin_sub_menu_callback, |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
179 SUB_DUPLICATE_BYTITLE, "<ImageItem>", removedups_pixbuf}, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
180 {N_("/Remove Duplicates/By Filename"), NULL, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
181 playlistwin_sub_menu_callback, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
182 SUB_DUPLICATE_BYFILENAME, "<ImageItem>", removedups_pixbuf}, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
183 {N_("/Remove Duplicates/By Path + Filename"), NULL, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
184 playlistwin_sub_menu_callback, |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
185 SUB_DUPLICATE_BYPATH, "<ImageItem>", removedups_pixbuf}, |
0 | 186 |
187 ITEM_SEPARATOR, | |
188 | |
189 {N_("/Remove All"), NULL, | |
190 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
191 SUB_ALL, "<StockItem>", GTK_STOCK_CLEAR}, |
0 | 192 |
193 {N_("/Remove Unselected"), NULL, | |
194 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
195 SUB_CROP, "<StockItem>", GTK_STOCK_REMOVE}, |
0 | 196 |
197 {N_("/Remove Selected"), "Delete", | |
198 playlistwin_sub_menu_callback, | |
841
b2e62b6c452b
[svn] started to add more icons for the playlist menu entries; others are going to be drawn and added
giacomo
parents:
840
diff
changeset
|
199 SUB_SELECTED, "<StockItem>", GTK_STOCK_REMOVE} |
0 | 200 }; |
201 | |
202 static GtkItemFactoryEntry pllist_menu_entries[] = { | |
1001
9189b80b6bea
[svn] Assign new shortcuts that no longer conflict. Patch by mokoshi, closes bug #478.
chainsaw
parents:
999
diff
changeset
|
203 {N_("/New List"), "<shift>N", |
0 | 204 playlistwin_sub_menu_callback, |
205 PLIST_NEW, "<StockItem>", GTK_STOCK_NEW}, | |
206 | |
207 ITEM_SEPARATOR, | |
208 | |
209 {N_("/Load List"), "o", | |
210 playlistwin_sub_menu_callback, | |
211 PLIST_LOAD, "<StockItem>", GTK_STOCK_OPEN}, | |
212 | |
1001
9189b80b6bea
[svn] Assign new shortcuts that no longer conflict. Patch by mokoshi, closes bug #478.
chainsaw
parents:
999
diff
changeset
|
213 {N_("/Save List"), "<shift>S", |
0 | 214 playlistwin_sub_menu_callback, |
215 PLIST_SAVE, "<StockItem>", GTK_STOCK_SAVE}, | |
216 | |
1062
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
217 {N_("/Save Default List"), "<alt>S", |
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
218 playlistwin_sub_menu_callback, |
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
219 PLIST_DEFAULTSAVE, "<StockItem>", GTK_STOCK_SAVE}, |
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
220 |
0 | 221 ITEM_SEPARATOR, |
222 | |
223 {N_("/Update View"), "F5", | |
224 playlistwin_sub_menu_callback, | |
225 PLAYLISTWIN_REFRESH, "<StockItem>", GTK_STOCK_REFRESH} | |
226 }; | |
227 | |
228 static GtkItemFactoryEntry plsel_menu_entries[] = { | |
229 {N_("/Invert Selection"), NULL, | |
230 playlistwin_sub_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
231 SEL_INV, "<ImageItem>", selectinvert_pixbuf}, |
0 | 232 |
233 ITEM_SEPARATOR, | |
234 | |
235 {N_("/Select None"),"<Ctrl><Shift>A", | |
236 playlistwin_sub_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
237 SEL_ZERO, "<ImageItem>", selectnone_pixbuf}, |
0 | 238 |
239 {N_("/Select All"), "<Ctrl>A", | |
240 playlistwin_sub_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
241 SEL_ALL, "<ImageItem>", selectall_pixbuf}, |
0 | 242 }; |
243 | |
244 static GtkItemFactoryEntry plsort_menu_entries[] = { | |
245 {N_("/Randomize List"), NULL, plsort_menu_callback, | |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
246 PLAYLISTWIN_SORT_RANDOMIZE, "<ImageItem>", randomizepl_pixbuf}, |
0 | 247 {N_("/Reverse List"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
248 PLAYLISTWIN_SORT_REVERSE, "<ImageItem>", invertpl_pixbuf}, |
0 | 249 ITEM_SEPARATOR, |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
250 {N_("/Sort List"), NULL, NULL, 0, "<Branch>", NULL}, |
0 | 251 {N_("/Sort List/By Title"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
252 PLAYLISTWIN_SORT_BYTITLE, "<ImageItem>", sortbytitle_pixbuf}, |
1251 | 253 {N_("/Sort List/By Artist"), NULL, plsort_menu_callback, |
254 PLAYLISTWIN_SORT_BYARTIST, "<ImageItem>", sortbytitle_pixbuf}, | |
0 | 255 {N_("/Sort List/By Filename"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
256 PLAYLISTWIN_SORT_BYFILENAME, "<ImageItem>", sortbyfilename_pixbuf}, |
0 | 257 {N_("/Sort List/By Path + Filename"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
258 PLAYLISTWIN_SORT_BYPATH, "<ImageItem>", sortbypathfile_pixbuf}, |
0 | 259 {N_("/Sort List/By Date"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
260 PLAYLISTWIN_SORT_BYDATE, "<ImageItem>", sortbydate_pixbuf}, |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
261 {N_("/Sort Selection"), NULL, NULL, 0, "<Branch>", NULL}, |
0 | 262 {N_("/Sort Selection/By Title"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
263 PLAYLISTWIN_SORT_SEL_BYTITLE, "<ImageItem>", sortbytitle_pixbuf}, |
1251 | 264 {N_("/Sort Selection/By Artist"), NULL, plsort_menu_callback, |
265 PLAYLISTWIN_SORT_SEL_BYARTIST, "<ImageItem>", sortbytitle_pixbuf}, | |
0 | 266 {N_("/Sort Selection/By Filename"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
267 PLAYLISTWIN_SORT_SEL_BYFILENAME, "<ImageItem>", sortbyfilename_pixbuf}, |
0 | 268 {N_("/Sort Selection/By Path + Filename"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
269 PLAYLISTWIN_SORT_SEL_BYPATH, "<ImageItem>", sortbypathfile_pixbuf}, |
0 | 270 {N_("/Sort Selection/By Date"), NULL, plsort_menu_callback, |
846
3344dd3f2bf6
[svn] added many new icons for the playlist menus (some drawn from scratch and others derived from the gtk stock ones)
giacomo
parents:
841
diff
changeset
|
271 PLAYLISTWIN_SORT_SEL_BYDATE, "<ImageItem>", sortbydate_pixbuf} |
0 | 272 }; |
273 | |
274 | |
275 static void playlistwin_draw_frame(void); | |
276 | |
277 | |
278 gboolean | |
279 playlistwin_is_shaded(void) | |
280 { | |
281 return cfg.playlist_shaded; | |
282 } | |
283 | |
284 gint | |
285 playlistwin_get_width(void) | |
286 { | |
287 return cfg.playlist_width; | |
288 } | |
289 | |
290 gint | |
291 playlistwin_get_height_unshaded(void) | |
292 { | |
293 gint height = cfg.playlist_height; | |
294 return height; | |
295 } | |
296 | |
297 gint | |
298 playlistwin_get_height_shaded(void) | |
299 { | |
300 return PLAYLISTWIN_SHADED_HEIGHT; | |
301 } | |
302 | |
303 gint | |
304 playlistwin_get_height(void) | |
305 { | |
306 if (playlistwin_is_shaded()) | |
307 return playlistwin_get_height_shaded(); | |
308 else | |
309 return playlistwin_get_height_unshaded(); | |
310 } | |
311 | |
312 void | |
313 playlistwin_get_size(gint * width, gint * height) | |
314 { | |
315 if (width) | |
316 *width = playlistwin_get_width(); | |
317 | |
318 if (height) | |
319 *height = playlistwin_get_height(); | |
320 } | |
321 | |
322 static void | |
323 playlistwin_update_info(void) | |
324 { | |
325 gchar *text, *sel_text, *tot_text; | |
326 gulong selection, total; | |
327 gboolean selection_more, total_more; | |
328 | |
329 playlist_get_total_time(&total, &selection, &total_more, &selection_more); | |
330 | |
331 if (selection > 0 || (selection == 0 && !selection_more)) { | |
332 if (selection > 3600) | |
333 sel_text = | |
334 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", selection / 3600, | |
335 (selection / 60) % 60, selection % 60, | |
336 (selection_more ? "+" : "")); | |
337 else | |
338 sel_text = | |
339 g_strdup_printf("%lu:%-2.2lu%s", selection / 60, | |
340 selection % 60, (selection_more ? "+" : "")); | |
341 } | |
342 else | |
343 sel_text = g_strdup("?"); | |
344 if (total > 0 || (total == 0 && !total_more)) { | |
345 if (total > 3600) | |
346 tot_text = | |
347 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", total / 3600, | |
348 (total / 60) % 60, total % 60, | |
349 total_more ? "+" : ""); | |
350 else | |
351 tot_text = | |
352 g_strdup_printf("%lu:%-2.2lu%s", total / 60, total % 60, | |
353 total_more ? "+" : ""); | |
354 } | |
355 else | |
356 tot_text = g_strdup("?"); | |
357 text = g_strconcat(sel_text, "/", tot_text, NULL); | |
358 textbox_set_text(playlistwin_info, text); | |
359 g_free(text); | |
360 g_free(tot_text); | |
361 g_free(sel_text); | |
362 } | |
363 | |
364 static void | |
365 playlistwin_update_sinfo(void) | |
366 { | |
367 gchar *posstr, *timestr, *title, *info, *dots; | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
368 gint pos, time; |
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
369 guint max_len; |
0 | 370 |
371 pos = playlist_get_position(); | |
372 title = playlist_get_songtitle(pos); | |
373 time = playlist_get_songtime(pos); | |
374 | |
375 if (!title) { | |
376 textbox_set_text(playlistwin_sinfo, ""); | |
377 return; | |
378 } | |
379 | |
380 if (cfg.show_numbers_in_pl) | |
381 posstr = g_strdup_printf("%d. ", pos + 1); | |
382 else | |
383 posstr = g_strdup(""); | |
384 | |
385 max_len = (playlistwin_get_width() - 35) / 5 - strlen(posstr); | |
386 | |
387 if (time != -1) { | |
388 timestr = g_strdup_printf(" %d:%-2.2d", time / 60000, | |
389 (time / 1000) % 60); | |
390 max_len -= strlen(timestr); | |
391 } | |
392 else | |
393 timestr = g_strdup(""); | |
394 | |
395 convert_title_text(title); | |
396 | |
397 if (strlen(title) > max_len) { | |
1222
09a96847fa53
[svn] - There's an ellipsis character in text.png. Let's use it like we should.
nhjm449
parents:
1085
diff
changeset
|
398 max_len -= 1; |
09a96847fa53
[svn] - There's an ellipsis character in text.png. Let's use it like we should.
nhjm449
parents:
1085
diff
changeset
|
399 dots = "\r"; |
09a96847fa53
[svn] - There's an ellipsis character in text.png. Let's use it like we should.
nhjm449
parents:
1085
diff
changeset
|
400 /* textbox.c interprets \r as the ellipsis character, as there |
09a96847fa53
[svn] - There's an ellipsis character in text.png. Let's use it like we should.
nhjm449
parents:
1085
diff
changeset
|
401 is none in ASCII. */ |
0 | 402 } |
403 else | |
404 dots = ""; | |
405 | |
406 info = g_strdup_printf("%s%-*.*s%s%s", posstr, max_len, max_len, | |
407 title, dots, timestr); | |
408 g_free(posstr); | |
409 g_free(title); | |
410 g_free(timestr); | |
411 | |
412 textbox_set_text(playlistwin_sinfo, info); | |
413 g_free(info); | |
414 } | |
415 | |
416 gboolean | |
417 playlistwin_item_visible(gint index) | |
418 { | |
419 if (index >= playlistwin_list->pl_first | |
420 && index < | |
421 (playlistwin_list->pl_first + playlistwin_list->pl_num_visible)) | |
422 return TRUE; | |
423 return FALSE; | |
424 } | |
425 | |
426 gint | |
427 playlistwin_get_toprow(void) | |
428 { | |
429 if (playlistwin_list) | |
430 return (playlistwin_list->pl_first); | |
431 return (-1); | |
432 } | |
433 | |
434 void | |
435 playlistwin_set_toprow(gint toprow) | |
436 { | |
437 if (playlistwin_list) | |
438 playlistwin_list->pl_first = toprow; | |
439 playlistwin_update_list(); | |
440 } | |
441 | |
442 void | |
443 playlistwin_update_list(void) | |
444 { | |
445 g_return_if_fail(playlistwin_list != NULL); | |
446 | |
239
ac4c3da7c263
[svn] Don't use widget_draw_quick() in playlistwin_update_list().
nenolod
parents:
238
diff
changeset
|
447 widget_draw(WIDGET(playlistwin_list)); |
ac4c3da7c263
[svn] Don't use widget_draw_quick() in playlistwin_update_list().
nenolod
parents:
238
diff
changeset
|
448 widget_draw(WIDGET(playlistwin_slider)); |
0 | 449 playlistwin_update_info(); |
450 playlistwin_update_sinfo(); | |
451 /* mainwin_update_jtf(); */ | |
452 } | |
453 | |
454 #if 0 | |
455 static void | |
456 playlistwin_redraw_list(void) | |
457 { | |
458 g_return_if_fail(playlistwin_list != NULL); | |
459 | |
460 draw_widget(playlistwin_list); | |
461 draw_widget(playlistwin_slider); | |
462 } | |
463 #endif | |
464 | |
465 static void | |
466 playlistwin_set_mask(void) | |
467 { | |
468 GdkGC *gc; | |
469 GdkColor pattern; | |
470 | |
471 if (playlistwin_mask) | |
472 g_object_unref(playlistwin_mask); | |
473 | |
474 playlistwin_mask = | |
475 gdk_pixmap_new(playlistwin->window, playlistwin_get_width(), | |
476 playlistwin_get_height(), 1); | |
477 gc = gdk_gc_new(playlistwin_mask); | |
478 pattern.pixel = 1; | |
479 gdk_gc_set_foreground(gc, &pattern); | |
480 gdk_draw_rectangle(playlistwin_mask, gc, TRUE, 0, 0, | |
481 playlistwin_get_width(), playlistwin_get_height()); | |
482 gdk_gc_destroy(gc); | |
483 | |
484 gtk_widget_shape_combine_mask(playlistwin, playlistwin_mask, 0, 0); | |
485 } | |
486 | |
487 static void | |
488 playlistwin_set_geometry_hints(gboolean shaded) | |
489 { | |
490 GdkGeometry geometry; | |
491 GdkWindowHints mask; | |
492 | |
493 geometry.min_width = PLAYLISTWIN_MIN_WIDTH; | |
494 geometry.max_width = G_MAXUINT16; | |
495 geometry.base_width = cfg.playlist_width; | |
496 | |
497 geometry.width_inc = PLAYLISTWIN_WIDTH_SNAP; | |
498 geometry.height_inc = PLAYLISTWIN_HEIGHT_SNAP; | |
499 | |
500 if (shaded) { | |
501 geometry.min_height = PLAYLISTWIN_SHADED_HEIGHT; | |
502 geometry.max_height = PLAYLISTWIN_SHADED_HEIGHT; | |
503 geometry.base_height = PLAYLISTWIN_SHADED_HEIGHT; | |
504 } | |
505 else { | |
506 geometry.min_height = PLAYLISTWIN_MIN_HEIGHT; | |
507 geometry.max_height = G_MAXUINT16; | |
508 geometry.base_height = cfg.playlist_height; | |
509 } | |
510 | |
511 mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_RESIZE_INC | | |
512 GDK_HINT_BASE_SIZE; | |
513 | |
514 gtk_window_set_geometry_hints(GTK_WINDOW(playlistwin), | |
515 playlistwin, &geometry, mask); | |
516 } | |
517 | |
518 void | |
519 playlistwin_set_shade(gboolean shaded) | |
520 { | |
521 cfg.playlist_shaded = shaded; | |
522 | |
523 if (shaded) { | |
524 widget_show(WIDGET(playlistwin_sinfo)); | |
525 playlistwin_shade->pb_nx = 128; | |
526 playlistwin_shade->pb_ny = 45; | |
527 playlistwin_shade->pb_px = 150; | |
528 playlistwin_shade->pb_py = 42; | |
529 playlistwin_close->pb_nx = 138; | |
530 playlistwin_close->pb_ny = 45; | |
531 } | |
532 else { | |
533 widget_hide(WIDGET(playlistwin_sinfo)); | |
534 playlistwin_shade->pb_nx = 157; | |
535 playlistwin_shade->pb_ny = 3; | |
536 playlistwin_shade->pb_px = 62; | |
537 playlistwin_shade->pb_py = 42; | |
538 playlistwin_close->pb_nx = 167; | |
539 playlistwin_close->pb_ny = 3; | |
540 } | |
541 | |
1064 | 542 dock_shade(dock_window_list, GTK_WINDOW(playlistwin), |
543 playlistwin_get_height()); | |
544 | |
0 | 545 playlistwin_set_geometry_hints(cfg.playlist_shaded); |
546 | |
547 gtk_window_resize(GTK_WINDOW(playlistwin), | |
548 cfg.playlist_width, | |
549 playlistwin_get_height()); | |
550 | |
79
38ddde5b0f13
[svn] Fix #129 by using playlistwin_set_mask() in playlistwin_set_shade()
msameer
parents:
0
diff
changeset
|
551 playlistwin_set_mask(); |
237
02c17a5c99e3
[svn] - Implement widget_draw_quick(widget_t *) for doing an immediate draw
nenolod
parents:
236
diff
changeset
|
552 |
242 | 553 widget_draw(WIDGET(playlistwin_list)); |
554 widget_draw(WIDGET(playlistwin_slider)); | |
555 | |
0 | 556 draw_playlist_window(TRUE); |
557 } | |
558 | |
559 static void | |
560 playlistwin_set_shade_menu(gboolean shaded) | |
561 { | |
562 GtkWidget *item; | |
563 | |
564 item = gtk_item_factory_get_widget(mainwin_view_menu, | |
565 "/Roll up Playlist Editor"); | |
566 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), shaded); | |
567 | |
568 playlistwin_set_shade(shaded); | |
569 } | |
570 | |
571 void | |
572 playlistwin_shade_toggle(void) | |
573 { | |
574 playlistwin_set_shade_menu(!cfg.playlist_shaded); | |
575 } | |
576 | |
577 static void | |
578 playlistwin_release(GtkWidget * widget, | |
579 GdkEventButton * event, | |
580 gpointer callback_data) | |
581 { | |
582 if (event->button == 3) | |
583 return; | |
584 | |
585 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
586 playlistwin_resizing = FALSE; | |
587 gdk_flush(); | |
1068 | 588 |
589 if (dock_is_moving(GTK_WINDOW(playlistwin))) | |
590 { | |
591 dock_move_release(GTK_WINDOW(playlistwin)); | |
1047
91f6db060a8b
[svn] - initial playlist_transparent patch. (you will need to edit your audacious config manually, either by gconf or texteditor to enable)
nenolod
parents:
1046
diff
changeset
|
592 |
1068 | 593 if (cfg.playlist_transparent) |
594 playlistwin_update_list(); | |
595 } | |
596 else | |
597 { | |
598 handle_release_cb(playlistwin_wlist, widget, event); | |
599 draw_playlist_window(FALSE); | |
600 } | |
0 | 601 } |
602 | |
603 void | |
604 playlistwin_scroll(gint num) | |
605 { | |
606 playlistwin_list->pl_first += num; | |
607 playlistwin_update_list(); | |
608 } | |
609 | |
610 void | |
611 playlistwin_scroll_up_pushed(void) | |
612 { | |
613 playlistwin_list->pl_first -= 3; | |
614 playlistwin_update_list(); | |
615 } | |
616 | |
617 void | |
618 playlistwin_scroll_down_pushed(void) | |
619 { | |
620 playlistwin_list->pl_first += 3; | |
621 playlistwin_update_list(); | |
622 } | |
623 | |
624 static void | |
625 playlistwin_select_all(void) | |
626 { | |
627 playlist_select_all(TRUE); | |
628 playlistwin_list->pl_prev_selected = 0; | |
629 playlistwin_list->pl_prev_min = 0; | |
630 playlistwin_list->pl_prev_max = playlist_get_length() - 1; | |
631 playlistwin_update_list(); | |
632 } | |
633 | |
634 static void | |
635 playlistwin_select_none(void) | |
636 { | |
637 playlist_select_all(FALSE); | |
638 playlistwin_list->pl_prev_selected = -1; | |
639 playlistwin_list->pl_prev_min = -1; | |
640 playlistwin_update_list(); | |
641 } | |
642 | |
643 static void | |
644 playlistwin_inverse_selection(void) | |
645 { | |
646 playlist_select_invert_all(); | |
647 playlistwin_list->pl_prev_selected = -1; | |
648 playlistwin_list->pl_prev_min = -1; | |
649 playlistwin_update_list(); | |
650 } | |
651 | |
652 static void | |
653 playlistwin_resize(gint width, gint height) | |
654 { | |
655 gboolean redraw; | |
656 | |
657 g_return_if_fail(width > 0 && height > 0); | |
658 | |
659 cfg.playlist_width = width; | |
660 | |
661 if (!cfg.playlist_shaded) | |
662 cfg.playlist_height = height; | |
663 else | |
664 height = cfg.playlist_height; | |
665 | |
666 /* FIXME: why the fsck are we doing this manually? */ | |
667 /* adjust widget positions and sizes */ | |
668 | |
669 widget_resize(WIDGET(playlistwin_list), width - 31, height - 58); | |
670 | |
671 widget_move(WIDGET(playlistwin_slider), width - 15, 20); | |
672 widget_resize(WIDGET(playlistwin_slider), 8, height - 58); | |
673 | |
674 widget_resize(WIDGET(playlistwin_sinfo), width - 35, 14); | |
675 playlistwin_update_sinfo(); | |
676 | |
677 widget_move(WIDGET(playlistwin_shade), width - 21, 3); | |
678 widget_move(WIDGET(playlistwin_close), width - 11, 3); | |
679 widget_move(WIDGET(playlistwin_time_min), width - 82, height - 15); | |
680 widget_move(WIDGET(playlistwin_time_sec), width - 64, height - 15); | |
681 widget_move(WIDGET(playlistwin_info), width - 143, height - 28); | |
682 widget_move(WIDGET(playlistwin_srew), width - 144, height - 16); | |
683 widget_move(WIDGET(playlistwin_splay), width - 138, height - 16); | |
684 widget_move(WIDGET(playlistwin_spause), width - 128, height - 16); | |
685 widget_move(WIDGET(playlistwin_sstop), width - 118, height - 16); | |
686 widget_move(WIDGET(playlistwin_sfwd), width - 109, height - 16); | |
687 widget_move(WIDGET(playlistwin_seject), width - 100, height - 16); | |
688 widget_move(WIDGET(playlistwin_sscroll_up), width - 14, height - 35); | |
689 widget_move(WIDGET(playlistwin_sscroll_down), width - 14, height - 30); | |
690 | |
691 g_object_unref(playlistwin_bg); | |
692 playlistwin_bg = gdk_pixmap_new(playlistwin->window, width, height, -1); | |
693 playlistwin_set_mask(); | |
694 | |
695 widget_list_lock(playlistwin_wlist); | |
696 | |
697 widget_list_change_pixmap(playlistwin_wlist, playlistwin_bg); | |
698 playlistwin_draw_frame(); | |
699 widget_list_draw(playlistwin_wlist, &redraw, TRUE); | |
700 widget_list_clear_redraw(playlistwin_wlist); | |
701 | |
702 widget_list_unlock(playlistwin_wlist); | |
703 | |
704 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
705 gdk_window_clear(playlistwin->window); | |
706 } | |
707 | |
708 | |
709 | |
710 static void | |
711 playlistwin_motion(GtkWidget * widget, | |
712 GdkEventMotion * event, | |
713 gpointer callback_data) | |
714 { | |
489
e0ee28a14570
[svn] Do not process redundant XEvents... just throw them away. Crude
nenolod
parents:
484
diff
changeset
|
715 GdkEvent *gevent; |
e0ee28a14570
[svn] Do not process redundant XEvents... just throw them away. Crude
nenolod
parents:
484
diff
changeset
|
716 |
1064 | 717 if (dock_is_moving(GTK_WINDOW(playlistwin))) { |
718 dock_move_motion(GTK_WINDOW(playlistwin), event); | |
719 } | |
720 else { | |
721 handle_motion_cb(playlistwin_wlist, widget, event); | |
722 draw_playlist_window(FALSE); | |
723 } | |
0 | 724 gdk_flush(); |
489
e0ee28a14570
[svn] Do not process redundant XEvents... just throw them away. Crude
nenolod
parents:
484
diff
changeset
|
725 |
e0ee28a14570
[svn] Do not process redundant XEvents... just throw them away. Crude
nenolod
parents:
484
diff
changeset
|
726 while ((gevent = gdk_event_get()) != NULL) gdk_event_free(gevent); |
0 | 727 } |
728 | |
729 static void | |
730 playlistwin_show_filebrowser(void) | |
731 { | |
732 util_run_filebrowser(NO_PLAY_BUTTON); | |
733 } | |
734 | |
735 #if 0 | |
736 static void | |
737 playlistwin_add_dir_handler(const gchar * dir) | |
738 { | |
739 g_free(cfg.filesel_path); | |
740 cfg.filesel_path = g_strdup(dir); | |
741 playlist_add_dir(dir); | |
742 } | |
743 #endif | |
744 | |
745 static void | |
746 playlistwin_fileinfo(void) | |
747 { | |
748 /* Show the first selected file, or the current file if nothing is | |
749 * selected */ | |
750 GList *list = playlist_get_selected(); | |
751 if (list) { | |
752 playlist_fileinfo(GPOINTER_TO_INT(list->data)); | |
753 g_list_free(list); | |
754 } | |
755 else | |
756 playlist_fileinfo_current(); | |
757 } | |
758 | |
759 static void | |
760 menu_set_item_sensitive(GtkItemFactory * item_factory, | |
761 const gchar * path, | |
762 gboolean sensitive) | |
763 { | |
764 GtkWidget *item = gtk_item_factory_get_widget(item_factory, path); | |
765 gtk_widget_set_sensitive(item, sensitive); | |
766 } | |
767 | |
768 /* FIXME: broken */ | |
769 static void | |
770 playlistwin_set_sensitive_sortmenu(void) | |
771 { | |
772 gboolean set = playlist_get_num_selected() > 1; | |
773 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Title", set); | |
774 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Filename", set); | |
775 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Path + Filename", set); | |
776 menu_set_item_sensitive(plsort_menu, "/Sort Selection/By Date", set); | |
777 } | |
778 | |
779 static void | |
780 show_playlist_save_error(GtkWindow * parent, | |
781 const gchar * filename) | |
782 { | |
783 GtkWidget *dialog; | |
784 | |
785 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
786 g_return_if_fail(filename != NULL); | |
787 | |
788 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
789 GTK_DIALOG_DESTROY_WITH_PARENT, | |
790 GTK_MESSAGE_ERROR, | |
791 GTK_BUTTONS_OK, | |
792 _("Error writing playlist \"%s\": %s"), | |
793 filename, strerror(errno)); | |
794 | |
795 gtk_dialog_run(GTK_DIALOG(dialog)); | |
796 gtk_widget_destroy(dialog); | |
797 } | |
798 | |
799 static gboolean | |
800 show_playlist_overwrite_prompt(GtkWindow * parent, | |
801 const gchar * filename) | |
802 { | |
803 GtkWidget *dialog; | |
804 gint result; | |
805 | |
806 g_return_val_if_fail(GTK_IS_WINDOW(parent), FALSE); | |
807 g_return_val_if_fail(filename != NULL, FALSE); | |
808 | |
809 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
810 GTK_DIALOG_DESTROY_WITH_PARENT, | |
811 GTK_MESSAGE_QUESTION, | |
812 GTK_BUTTONS_YES_NO, | |
813 _("%s already exist. Continue?"), | |
814 filename); | |
815 | |
816 result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
817 gtk_widget_destroy(dialog); | |
818 | |
819 return (result == GTK_RESPONSE_YES); | |
820 } | |
821 | |
822 static void | |
823 show_playlist_save_format_error(GtkWindow * parent, | |
824 const gchar * filename) | |
825 { | |
826 const gchar *markup = | |
827 N_("<b><big>Unable to save playlist.</big></b>\n\n" | |
828 "Unknown file type for '%s'.\n"); | |
829 | |
830 GtkWidget *dialog; | |
831 | |
832 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
833 g_return_if_fail(filename != NULL); | |
834 | |
835 dialog = | |
836 gtk_message_dialog_new_with_markup(GTK_WINDOW(parent), | |
837 GTK_DIALOG_DESTROY_WITH_PARENT, | |
838 GTK_MESSAGE_ERROR, | |
839 GTK_BUTTONS_OK, | |
840 _(markup), | |
841 filename); | |
842 gtk_dialog_run(GTK_DIALOG(dialog)); | |
843 gtk_widget_destroy(dialog); | |
844 } | |
845 | |
846 static void | |
847 playlistwin_save_playlist(const gchar * filename) | |
848 { | |
849 PlaylistFormat format; | |
850 | |
851 format = playlist_format_get_from_name(filename); | |
852 if (format == PLAYLIST_FORMAT_UNKNOWN) { | |
853 show_playlist_save_format_error(GTK_WINDOW(playlistwin), filename); | |
854 return; | |
855 } | |
856 | |
857 str_replace_in(&cfg.playlist_path, g_path_get_dirname(filename)); | |
858 | |
859 if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) | |
860 if (!show_playlist_overwrite_prompt(GTK_WINDOW(playlistwin), filename)) | |
861 return; | |
862 | |
863 if (!playlist_save(filename, format)) | |
864 show_playlist_save_error(GTK_WINDOW(playlistwin), filename); | |
865 } | |
866 | |
867 #if 0 | |
868 static void | |
869 playlistwin_save_current(void) | |
870 { | |
871 const gchar *filename; | |
872 | |
873 if (!(filename = playlist_get_current_name())) | |
874 return; | |
875 | |
876 playlistwin_save_playlist(filename); | |
877 } | |
878 #endif | |
879 | |
880 static void | |
881 playlistwin_load_playlist(const gchar * filename) | |
882 { | |
883 g_return_if_fail(filename != NULL); | |
884 | |
885 str_replace_in(&cfg.playlist_path, g_strdup(filename)); | |
886 | |
887 playlist_clear(); | |
888 mainwin_clear_song_info(); | |
889 mainwin_set_info_text(); | |
890 | |
891 playlist_load(filename); | |
892 playlist_set_current_name(filename); | |
893 } | |
894 | |
895 static gchar * | |
896 playlist_file_selection(const gchar * title, | |
897 gboolean save, | |
898 const gchar * default_filename) | |
899 { | |
900 GtkWidget *dialog, *button; | |
901 gchar *filename; | |
902 | |
903 g_return_val_if_fail(title != NULL, NULL); | |
904 | |
905 dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin), | |
906 save ? GTK_FILE_CHOOSER_ACTION_SAVE : | |
376 | 907 GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL); |
0 | 908 if (default_filename) |
909 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | |
910 default_filename); | |
911 | |
912 button = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, | |
913 GTK_RESPONSE_REJECT); | |
914 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); | |
915 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
916 | |
917 button = gtk_dialog_add_button(GTK_DIALOG(dialog), | |
918 save ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, | |
919 GTK_RESPONSE_ACCEPT); | |
920 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); | |
921 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
922 | |
923 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
924 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
925 else | |
926 filename = NULL; | |
927 | |
928 gtk_widget_destroy(dialog); | |
929 | |
930 return filename; | |
931 } | |
932 | |
933 void | |
934 playlistwin_select_playlist_to_load(const gchar * default_filename) | |
935 { | |
936 gchar *filename = | |
937 playlist_file_selection(_("Load Playlist"), FALSE, default_filename); | |
938 | |
939 if (filename) { | |
940 playlistwin_load_playlist(filename); | |
941 g_free(filename); | |
942 } | |
943 } | |
944 | |
945 static void | |
946 playlistwin_select_playlist_to_save(const gchar * default_filename) | |
947 { | |
948 gchar *filename = | |
949 playlist_file_selection(_("Save Playlist"), TRUE, default_filename); | |
950 | |
951 if (filename) { | |
952 /* Default to M3U if no filename has extension */ | |
953 | |
954 /* NOTE: This doesn't work correctly for hidden files | |
955 - descender */ | |
956 if (!strchr(filename, '.')) { | |
957 gchar *tmpstr = filename; | |
958 filename = g_strconcat(filename, ".m3u", NULL); | |
959 g_free(tmpstr); | |
960 } | |
961 | |
962 playlistwin_save_playlist(filename); | |
963 g_free(filename); | |
964 } | |
965 } | |
966 | |
967 static gboolean | |
968 inside_sensitive_widgets(gint x, gint y) | |
969 { | |
970 return (widget_contains(WIDGET(playlistwin_list), x, y) || | |
971 widget_contains(WIDGET(playlistwin_slider), x, y) || | |
972 widget_contains(WIDGET(playlistwin_close), x, y) || | |
973 widget_contains(WIDGET(playlistwin_shade), x, y) || | |
974 widget_contains(WIDGET(playlistwin_time_min), x, y) || | |
975 widget_contains(WIDGET(playlistwin_time_sec), x, y) || | |
976 widget_contains(WIDGET(playlistwin_info), x, y) || | |
977 widget_contains(WIDGET(playlistwin_srew), x, y) || | |
978 widget_contains(WIDGET(playlistwin_splay), x, y) || | |
979 widget_contains(WIDGET(playlistwin_spause), x, y) || | |
980 widget_contains(WIDGET(playlistwin_sstop), x, y) || | |
981 widget_contains(WIDGET(playlistwin_sfwd), x, y) || | |
982 widget_contains(WIDGET(playlistwin_seject), x, y) || | |
983 widget_contains(WIDGET(playlistwin_sscroll_up), x, y) || | |
984 widget_contains(WIDGET(playlistwin_sscroll_down), x, y)); | |
985 } | |
986 | |
987 #define REGION_L(x1,x2,y1,y2) \ | |
988 (event->x >= (x1) && event->x < (x2) && \ | |
989 event->y >= cfg.playlist_height - (y1) && \ | |
990 event->y < cfg.playlist_height - (y2)) | |
991 | |
992 #define REGION_R(x1,x2,y1,y2) \ | |
993 (event->x >= playlistwin_get_width() - (x1) && \ | |
994 event->x < playlistwin_get_width() - (x2) && \ | |
995 event->y >= cfg.playlist_height - (y1) && \ | |
996 event->y < cfg.playlist_height - (y2)) | |
997 | |
998 static void | |
999 playlistwin_scrolled(GtkWidget * widget, | |
1000 GdkEventScroll * event, | |
1001 gpointer callback_data) | |
1002 { | |
1003 | |
1004 if (event->direction == GDK_SCROLL_DOWN) | |
1005 playlistwin_scroll(cfg.scroll_pl_by); | |
1006 | |
1007 if (event->direction == GDK_SCROLL_UP) | |
1008 playlistwin_scroll(-cfg.scroll_pl_by); | |
1009 | |
1010 } | |
1011 | |
1012 | |
1013 | |
1014 | |
1015 static gboolean | |
1016 playlistwin_press(GtkWidget * widget, | |
1017 GdkEventButton * event, | |
1018 gpointer callback_data) | |
1019 { | |
1020 gboolean grab = TRUE; | |
1021 gint xpos, ypos; | |
1022 GtkWidget *_menu; | |
1023 GtkRequisition req; | |
1024 | |
1025 gtk_window_get_position(GTK_WINDOW(playlistwin), &xpos, &ypos); | |
1026 | |
1027 if (event->button == 1 && !cfg.show_wm_decorations && | |
1028 ((!cfg.playlist_shaded && | |
1029 event->x > playlistwin_get_width() - 20 && | |
1030 event->y > cfg.playlist_height - 20) || | |
1031 (cfg.playlist_shaded && | |
1032 event->x >= playlistwin_get_width() - 31 && | |
1033 event->x < playlistwin_get_width() - 22))) { | |
1034 | |
1035 /* NOTE: Workaround for bug #214 */ | |
1036 if (event->type != GDK_2BUTTON_PRESS && | |
1037 event->type != GDK_3BUTTON_PRESS) { | |
1038 /* resize area */ | |
1039 playlistwin_resizing = TRUE; | |
1040 gtk_window_begin_resize_drag(GTK_WINDOW(widget), | |
1041 GDK_WINDOW_EDGE_SOUTH_EAST, | |
1042 event->button, | |
1043 event->x + xpos, event->y + ypos, | |
1044 event->time); | |
1045 } | |
1046 grab = FALSE; | |
1047 } | |
1048 else if (event->button == 1 && REGION_L(12, 37, 29, 11)) { | |
1049 /* ADD button menu */ | |
1050 | |
1051 _menu = GTK_WIDGET(pladd_menu->widget); | |
1052 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1053 gtk_widget_size_request(_menu, &req); | |
1054 gtk_item_factory_popup_with_data(pladd_menu, | |
1055 NULL, NULL, | |
1056 xpos+12, | |
1057 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1058 grab = FALSE; | |
1059 } | |
1060 else if (event->button == 1 && REGION_L(41, 66, 29, 11)) { | |
1061 /* SUB button menu */ | |
1062 _menu = GTK_WIDGET(pldel_menu->widget); | |
1063 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1064 gtk_widget_size_request(_menu, &req); | |
1065 gtk_item_factory_popup_with_data(pldel_menu, | |
1066 NULL, NULL, | |
1067 xpos+40, | |
1068 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1069 grab = FALSE; | |
1070 } | |
1071 else if (event->button == 1 && REGION_L(70, 95, 29, 11)) { | |
1072 /* SEL button menu */ | |
1073 _menu = GTK_WIDGET(plsel_menu->widget); | |
1074 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1075 gtk_widget_size_request(_menu, &req); | |
1076 gtk_item_factory_popup_with_data(plsel_menu, | |
1077 NULL, NULL, | |
1078 xpos+68, | |
1079 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1080 | |
1081 grab = FALSE; | |
1082 } | |
1083 else if (event->button == 1 && REGION_L(99, 124, 29, 11)) { | |
1084 /* MISC button menu */ | |
1085 _menu = GTK_WIDGET(plsort_menu->widget); | |
1086 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1087 gtk_widget_size_request(_menu, &req); | |
1088 gtk_item_factory_popup_with_data(plsort_menu, | |
1089 NULL, NULL, | |
1090 xpos+100, | |
1091 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1092 grab = FALSE; | |
1093 } | |
1094 else if (event->button == 1 && REGION_R(46, 23, 29, 11)) { | |
1095 /* LIST button menu */ | |
1096 _menu = GTK_WIDGET(pllist_menu->widget); | |
1097 if (!GTK_WIDGET_REALIZED(_menu)) gtk_widget_realize(_menu); | |
1098 gtk_widget_size_request(_menu, &req); | |
1099 gtk_item_factory_popup_with_data(pllist_menu, | |
1100 NULL, NULL, | |
1101 xpos + playlistwin_get_width() - req.width - 12, | |
1102 (ypos + playlistwin_get_height()) - 8 - req.height, 1, event->time); | |
1103 grab = FALSE; | |
1104 } | |
1105 else if (event->button == 1 && REGION_R(82, 54, 15, 9)) { | |
1106 if (cfg.timer_mode == TIMER_ELAPSED) | |
1107 cfg.timer_mode = TIMER_REMAINING; | |
1108 else | |
1109 cfg.timer_mode = TIMER_ELAPSED; | |
1110 } | |
1111 else if (event->button == 2 && (event->type == GDK_BUTTON_PRESS) && | |
1112 widget_contains(WIDGET(playlistwin_list), event->x, event->y)) { | |
1113 gtk_selection_convert(widget, GDK_SELECTION_PRIMARY, | |
1114 GDK_TARGET_STRING, event->time); | |
1115 } | |
1116 else if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
1045 | 1117 !inside_sensitive_widgets(event->x, event->y) && event->y < 14) |
1118 { | |
1066 | 1119 dock_move_press(dock_window_list, GTK_WINDOW(playlistwin), event, |
1120 FALSE); | |
1045 | 1121 gtk_window_present(GTK_WINDOW(playlistwin)); |
0 | 1122 } |
1123 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1124 !inside_sensitive_widgets(event->x, event->y) | |
1125 && event->y < 14) { | |
1126 /* double click on title bar */ | |
1127 playlistwin_shade_toggle(); | |
1068 | 1128 if (dock_is_moving(GTK_WINDOW(playlistwin))) |
1129 dock_move_release(GTK_WINDOW(playlistwin)); | |
0 | 1130 return TRUE; |
1131 } | |
1132 else if (event->button == 3 && | |
1133 !(widget_contains(WIDGET(playlistwin_list), event->x, event->y) || | |
1134 (event->y >= cfg.playlist_height - 29 && | |
1135 event->y < cfg.playlist_height - 11 && | |
1136 ((event->x >= 12 && event->x < 37) || | |
1137 (event->x >= 41 && event->x < 66) || | |
1138 (event->x >= 70 && event->x < 95) || | |
1139 (event->x >= 99 && event->x < 124) || | |
1140 (event->x >= playlistwin_get_width() - 46 && | |
1141 event->x < playlistwin_get_width() - 23))))) { | |
1142 /* | |
1143 * Pop up the main menu a few pixels down to avoid | |
1144 * anything to be selected initially. | |
1145 */ | |
1146 util_item_factory_popup(mainwin_general_menu, event->x_root, | |
1147 event->y_root + 2, 3, event->time); | |
1148 grab = FALSE; | |
1149 } | |
1150 else if (event->button == 3 && | |
1151 widget_contains(WIDGET(playlistwin_list), event->x, event->y)) { | |
1152 /* popup menu */ | |
1153 playlistwin_set_sensitive_sortmenu(); | |
1154 gtk_item_factory_popup(playlistwin_popup_menu, | |
1155 event->x_root, event->y_root + 5, | |
1156 3, event->time); | |
1157 grab = FALSE; | |
1158 } | |
1159 else { | |
1160 handle_press_cb(playlistwin_wlist, widget, event); | |
1161 draw_playlist_window(FALSE); | |
1162 } | |
1163 | |
1164 if (grab) | |
1165 gdk_pointer_grab(playlistwin->window, FALSE, | |
1166 GDK_BUTTON_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | | |
1167 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
1168 GDK_BUTTON1_MOTION_MASK, NULL, NULL, | |
1169 GDK_CURRENT_TIME); | |
1170 | |
1171 return FALSE; | |
1172 } | |
1173 | |
1174 static gboolean | |
1175 playlistwin_focus_in(GtkWidget * widget, GdkEvent * event, gpointer data) | |
1176 { | |
1177 playlistwin_close->pb_allow_draw = TRUE; | |
1178 playlistwin_shade->pb_allow_draw = TRUE; | |
1179 draw_playlist_window(TRUE); | |
1180 return FALSE; | |
1181 } | |
1182 | |
1183 static gboolean | |
1184 playlistwin_focus_out(GtkWidget * widget, | |
1185 GdkEventButton * event, gpointer data) | |
1186 { | |
1187 playlistwin_close->pb_allow_draw = FALSE; | |
1188 playlistwin_shade->pb_allow_draw = FALSE; | |
1189 draw_playlist_window(TRUE); | |
1190 return FALSE; | |
1191 } | |
1192 | |
1193 static gboolean | |
1194 playlistwin_configure(GtkWidget * window, | |
1195 GdkEventConfigure * event, gpointer data) | |
1196 { | |
1197 if (!GTK_WIDGET_VISIBLE(window)) | |
1198 return FALSE; | |
1199 | |
1200 cfg.playlist_x = event->x; | |
1201 cfg.playlist_y = event->y; | |
1202 | |
1203 if (playlistwin_resizing) { | |
1204 if (event->width != playlistwin_get_width() || | |
1205 event->height != playlistwin_get_height()) | |
1206 playlistwin_resize(event->width, event->height); | |
1207 } | |
1208 return TRUE; | |
1209 } | |
1210 | |
1211 void | |
1212 playlistwin_set_back_pixmap(void) | |
1213 { | |
1214 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
1215 gdk_window_clear(playlistwin->window); | |
1216 } | |
1217 | |
1218 static gboolean | |
1219 playlistwin_delete(GtkWidget * w, gpointer data) | |
1220 { | |
1221 playlistwin_hide(); | |
1222 return TRUE; | |
1223 } | |
1224 | |
1225 static void | |
1226 playlistwin_keypress_up_down_handler(PlayList_List * pl, | |
1227 gboolean up, guint state) | |
1228 { | |
1229 if ((state & GDK_MOD1_MASK) && (state & GDK_SHIFT_MASK)) | |
1230 return; | |
1231 if (!(state & GDK_MOD1_MASK)) | |
1232 playlist_select_all(FALSE); | |
1233 | |
1234 if (pl->pl_prev_selected == -1 || | |
1235 (!playlistwin_item_visible(pl->pl_prev_selected) && | |
1236 !(state & GDK_SHIFT_MASK && pl->pl_prev_min != -1))) { | |
1237 pl->pl_prev_selected = pl->pl_first; | |
1238 } | |
1239 else if (state & GDK_SHIFT_MASK) { | |
1240 if (pl->pl_prev_min == -1) { | |
1241 pl->pl_prev_max = pl->pl_prev_selected; | |
1242 pl->pl_prev_min = pl->pl_prev_selected; | |
1243 } | |
1244 pl->pl_prev_max += (up ? -1 : 1); | |
1245 pl->pl_prev_max = | |
1246 CLAMP(pl->pl_prev_max, 0, playlist_get_length() - 1); | |
1247 | |
1248 pl->pl_first = MIN(pl->pl_first, pl->pl_prev_max); | |
1249 pl->pl_first = MAX(pl->pl_first, pl->pl_prev_max - | |
1250 pl->pl_num_visible + 1); | |
1251 playlist_select_range(pl->pl_prev_min, pl->pl_prev_max, TRUE); | |
1252 return; | |
1253 } | |
1254 else if (state & GDK_MOD1_MASK) { | |
1255 if (up) | |
1256 playlist_list_move_up(pl); | |
1257 else | |
1258 playlist_list_move_down(pl); | |
1259 if (pl->pl_prev_min < pl->pl_first) | |
1260 pl->pl_first = pl->pl_prev_min; | |
1261 else if (pl->pl_prev_max >= (pl->pl_first + pl->pl_num_visible)) | |
1262 pl->pl_first = pl->pl_prev_max - pl->pl_num_visible + 1; | |
1263 return; | |
1264 } | |
1265 else if (up) | |
1266 pl->pl_prev_selected--; | |
1267 else | |
1268 pl->pl_prev_selected++; | |
1269 | |
1270 pl->pl_prev_selected = | |
1271 CLAMP(pl->pl_prev_selected, 0, playlist_get_length() - 1); | |
1272 | |
1273 if (pl->pl_prev_selected < pl->pl_first) | |
1274 pl->pl_first--; | |
1275 else if (pl->pl_prev_selected >= (pl->pl_first + pl->pl_num_visible)) | |
1276 pl->pl_first++; | |
1277 | |
1278 playlist_select_range(pl->pl_prev_selected, pl->pl_prev_selected, TRUE); | |
1279 pl->pl_prev_min = -1; | |
1280 | |
1281 } | |
1282 | |
1283 /* FIXME: Handle the keys through menu */ | |
1284 | |
1285 static gboolean | |
1286 playlistwin_keypress(GtkWidget * w, GdkEventKey * event, gpointer data) | |
1287 { | |
1288 guint keyval; | |
1289 gboolean refresh = FALSE; | |
1290 | |
1291 if (cfg.playlist_shaded) | |
1292 return FALSE; | |
1293 | |
1294 switch (keyval = event->keyval) { | |
1295 case GDK_KP_Up: | |
1296 case GDK_KP_Down: | |
1297 case GDK_Up: | |
1298 case GDK_Down: | |
1299 playlistwin_keypress_up_down_handler(playlistwin_list, | |
1300 keyval == GDK_Up | |
1301 || keyval == GDK_KP_Up, | |
1302 event->state); | |
1303 refresh = TRUE; | |
1304 break; | |
1305 case GDK_Page_Up: | |
1306 playlistwin_scroll(-playlistwin_list->pl_num_visible); | |
1307 refresh = TRUE; | |
1308 break; | |
1309 case GDK_Page_Down: | |
1310 playlistwin_scroll(playlistwin_list->pl_num_visible); | |
1311 refresh = TRUE; | |
1312 break; | |
1313 case GDK_Home: | |
1314 playlistwin_list->pl_first = 0; | |
1315 refresh = TRUE; | |
1316 break; | |
1317 case GDK_End: | |
1318 playlistwin_list->pl_first = | |
1319 playlist_get_length() - playlistwin_list->pl_num_visible; | |
1320 refresh = TRUE; | |
1321 break; | |
1322 case GDK_Return: | |
1323 if (playlistwin_list->pl_prev_selected > -1 | |
1324 && playlistwin_item_visible(playlistwin_list->pl_prev_selected)) { | |
1325 playlist_set_position(playlistwin_list->pl_prev_selected); | |
1326 if (!bmp_playback_get_playing()) | |
1327 bmp_playback_initiate(); | |
1328 } | |
1329 break; | |
1330 case GDK_3: | |
1331 if (event->state & GDK_CONTROL_MASK) | |
1332 playlistwin_fileinfo(); | |
1333 break; | |
1334 case GDK_Delete: | |
1335 if (event->state & GDK_CONTROL_MASK) | |
1336 playlist_delete(TRUE); | |
1337 else | |
1338 playlist_delete(FALSE); | |
1339 break; | |
1340 case GDK_Insert: | |
331
ac6389064cf9
[svn] Remove Add Directory option as it is broken. Patch by laci, closes bug #377.
chainsaw
parents:
284
diff
changeset
|
1341 if (event->state & GDK_MOD1_MASK) |
0 | 1342 mainwin_show_add_url_window(); |
1343 else | |
1344 playlistwin_show_filebrowser(); | |
1345 break; | |
226
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1346 case GDK_Left: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1347 case GDK_KP_Left: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1348 case GDK_KP_7: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1349 if (playlist_get_current_length() != -1) |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1350 bmp_playback_seek(CLAMP |
436 | 1351 (bmp_playback_get_time() - 1000, 0, |
226
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1352 playlist_get_current_length()) / 1000); |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1353 break; |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1354 case GDK_Right: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1355 case GDK_KP_Right: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1356 case GDK_KP_9: |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1357 if (playlist_get_current_length() != -1) |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1358 bmp_playback_seek(CLAMP |
436 | 1359 (bmp_playback_get_time() + 1000, 0, |
226
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1360 playlist_get_current_length()) / 1000); |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1361 break; |
f6ad670bb500
[svn] Make the left and right keys work when the playlist window has focus.
nenolod
parents:
224
diff
changeset
|
1362 |
0 | 1363 case GDK_Escape: |
1364 mainwin_minimize_cb(); | |
1365 break; | |
1366 default: | |
1367 return FALSE; | |
1368 } | |
1369 | |
1370 if (refresh) | |
1371 playlistwin_update_list(); | |
1372 | |
1373 return TRUE; | |
1374 } | |
1375 | |
1376 static void | |
1377 playlistwin_draw_frame(void) | |
1378 { | |
1379 gboolean focus = | |
1380 gtk_window_has_toplevel_focus(GTK_WINDOW(playlistwin)) || | |
1381 !cfg.dim_titlebar; | |
1382 | |
1383 if (cfg.playlist_shaded) { | |
1384 skin_draw_playlistwin_shaded(bmp_active_skin, | |
1385 playlistwin_bg, playlistwin_gc, | |
1386 playlistwin_get_width(), focus); | |
1387 } | |
1388 else { | |
1389 skin_draw_playlistwin_frame(bmp_active_skin, | |
1390 playlistwin_bg, playlistwin_gc, | |
1391 playlistwin_get_width(), | |
1392 cfg.playlist_height, focus); | |
1393 } | |
1394 } | |
1395 | |
1396 void | |
1397 draw_playlist_window(gboolean force) | |
1398 { | |
1399 gboolean redraw; | |
1400 GList *wl; | |
1401 Widget *w; | |
1402 | |
1403 if (force) | |
1404 playlistwin_draw_frame(); | |
1405 | |
1406 widget_list_lock(playlistwin_wlist); | |
1407 widget_list_draw(playlistwin_wlist, &redraw, force); | |
1408 | |
1409 if (redraw || force) { | |
1410 if (force) { | |
1411 gdk_window_clear(playlistwin->window); | |
1412 } | |
1413 else { | |
1414 for (wl = playlistwin_wlist; wl; wl = g_list_next(wl)) { | |
1415 w = WIDGET(wl->data); | |
1416 if (w->redraw && w->visible) { | |
1417 gdk_window_clear_area(playlistwin->window, w->x, w->y, | |
1418 w->width, w->height); | |
1419 w->redraw = FALSE; | |
1420 } | |
1421 } | |
1422 } | |
1423 | |
1424 gdk_flush(); | |
1425 } | |
1426 | |
1427 widget_list_unlock(playlistwin_wlist); | |
1428 } | |
1429 | |
1430 | |
1431 void | |
1432 playlistwin_hide_timer(void) | |
1433 { | |
1434 textbox_set_text(playlistwin_time_min, " "); | |
1435 textbox_set_text(playlistwin_time_sec, " "); | |
1436 } | |
1437 | |
1438 void | |
1439 playlistwin_set_time(gint time, gint length, TimerMode mode) | |
1440 { | |
1441 gchar *text, sign; | |
1442 | |
1443 if (mode == TIMER_REMAINING && length != -1) { | |
1444 time = length - time; | |
1445 sign = '-'; | |
1446 } | |
1447 else | |
1448 sign = ' '; | |
1449 | |
1450 time /= 1000; | |
1451 | |
1452 if (time < 0) | |
1453 time = 0; | |
1454 if (time > 99 * 60) | |
1455 time /= 60; | |
1456 | |
1457 text = g_strdup_printf("%c%-2.2d", sign, time / 60); | |
1458 textbox_set_text(playlistwin_time_min, text); | |
1459 g_free(text); | |
1460 | |
1461 text = g_strdup_printf("%-2.2d", time % 60); | |
1462 textbox_set_text(playlistwin_time_sec, text); | |
1463 g_free(text); | |
1464 } | |
1465 | |
1466 static void | |
1467 playlistwin_drag_motion(GtkWidget * widget, | |
1468 GdkDragContext * context, | |
1469 gint x, gint y, | |
1470 GtkSelectionData * selection_data, | |
1471 guint info, guint time, gpointer user_data) | |
1472 { | |
1473 playlistwin_list->pl_drag_motion = TRUE; | |
1474 playlistwin_list->drag_motion_x = x; | |
1475 playlistwin_list->drag_motion_y = y; | |
1476 playlistwin_update_list(); | |
1477 playlistwin_hint_flag = TRUE; | |
1478 } | |
1479 | |
1480 static void | |
1481 playlistwin_drag_end(GtkWidget * widget, | |
1482 GdkDragContext * context, gpointer user_data) | |
1483 { | |
1484 playlistwin_list->pl_drag_motion = FALSE; | |
1485 playlistwin_hint_flag = FALSE; | |
1486 playlistwin_update_list(); | |
1487 } | |
1488 | |
1489 static void | |
1490 playlistwin_drag_data_received(GtkWidget * widget, | |
1491 GdkDragContext * context, | |
1492 gint x, gint y, | |
1493 GtkSelectionData * | |
1494 selection_data, guint info, | |
1495 guint time, gpointer user_data) | |
1496 { | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
1497 gint pos; |
0 | 1498 |
1499 g_return_if_fail(selection_data != NULL); | |
1500 | |
1501 if (!selection_data->data) { | |
1502 g_message("Received no DND data!"); | |
1503 return; | |
1504 } | |
1505 | |
1506 if (widget_contains(WIDGET(playlistwin_list), x, y)) { | |
1507 pos = (y - WIDGET(playlistwin_list)->y) / | |
1508 playlistwin_list->pl_fheight + playlistwin_list->pl_first; | |
1509 | |
1510 pos = MIN(pos, playlist_get_length()); | |
1511 playlist_ins_url((gchar *) selection_data->data, pos); | |
1512 } | |
1513 else | |
1514 playlist_add_url((gchar *) selection_data->data); | |
1515 } | |
1516 | |
1517 static void | |
1518 playlistwin_create_widgets(void) | |
1519 { | |
1520 /* This function creates the custom widgets used by the playlist editor */ | |
1521 | |
1522 /* text box for displaying song title in shaded mode */ | |
1523 playlistwin_sinfo = | |
1524 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1525 4, 4, playlistwin_get_width() - 35, FALSE, SKIN_TEXT); | |
1526 | |
1527 if (!cfg.playlist_shaded) | |
1528 widget_hide(WIDGET(playlistwin_sinfo)); | |
1529 | |
1530 /* shade/unshade window push button */ | |
1531 if (cfg.playlist_shaded) | |
1532 playlistwin_shade = | |
1533 create_pbutton(&playlistwin_wlist, playlistwin_bg, | |
1534 playlistwin_gc, playlistwin_get_width() - 21, 3, | |
1535 9, 9, 128, 45, 150, 42, | |
1536 playlistwin_shade_toggle, SKIN_PLEDIT); | |
1537 else | |
1538 playlistwin_shade = | |
1539 create_pbutton(&playlistwin_wlist, playlistwin_bg, | |
1540 playlistwin_gc, playlistwin_get_width() - 21, 3, | |
1541 9, 9, 157, 3, 62, 42, playlistwin_shade_toggle, | |
1542 SKIN_PLEDIT); | |
1543 | |
1544 playlistwin_shade->pb_allow_draw = FALSE; | |
1545 | |
1546 /* close window push button */ | |
1547 playlistwin_close = | |
1548 create_pbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1549 playlistwin_get_width() - 11, 3, 9, 9, | |
1550 cfg.playlist_shaded ? 138 : 167, | |
1551 cfg.playlist_shaded ? 45 : 3, 52, 42, | |
1552 playlistwin_hide, SKIN_PLEDIT); | |
1553 playlistwin_close->pb_allow_draw = FALSE; | |
1554 | |
1555 /* playlist list box */ | |
1556 playlistwin_list = | |
1557 create_playlist_list(&playlistwin_wlist, playlistwin_bg, | |
1558 playlistwin_gc, 12, 20, | |
1559 playlistwin_get_width() - 31, | |
1560 cfg.playlist_height - 58); | |
1561 playlist_list_set_font(cfg.playlist_font); | |
1562 | |
1563 /* playlist list box slider */ | |
1564 playlistwin_slider = | |
1565 create_playlistslider(&playlistwin_wlist, playlistwin_bg, | |
1566 playlistwin_gc, playlistwin_get_width() - 15, | |
1567 20, cfg.playlist_height - 58, playlistwin_list); | |
1568 /* track time (minute) */ | |
1569 playlistwin_time_min = | |
1570 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1571 playlistwin_get_width() - 82, | |
1572 cfg.playlist_height - 15, 15, FALSE, SKIN_TEXT); | |
1573 | |
1574 /* track time (second) */ | |
1575 playlistwin_time_sec = | |
1576 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1577 playlistwin_get_width() - 64, | |
1578 cfg.playlist_height - 15, 10, FALSE, SKIN_TEXT); | |
1579 | |
1580 /* playlist information (current track length / total track length) */ | |
1581 playlistwin_info = | |
1582 create_textbox(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1583 playlistwin_get_width() - 143, | |
1040 | 1584 cfg.playlist_height - 28, 90, FALSE, SKIN_TEXT); |
0 | 1585 |
1586 /* mini play control buttons at right bottom corner */ | |
1587 | |
1588 /* rewind button */ | |
1589 playlistwin_srew = | |
1590 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1591 playlistwin_get_width() - 144, | |
1592 cfg.playlist_height - 16, 8, 7, playlist_prev); | |
1593 | |
1594 /* play button */ | |
1595 playlistwin_splay = | |
1596 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1597 playlistwin_get_width() - 138, | |
1598 cfg.playlist_height - 16, 10, 7, mainwin_play_pushed); | |
1599 | |
1600 /* pause button */ | |
1601 playlistwin_spause = | |
1602 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1603 playlistwin_get_width() - 128, | |
1604 cfg.playlist_height - 16, 10, 7, bmp_playback_pause); | |
1605 | |
1606 /* stop button */ | |
1607 playlistwin_sstop = | |
1608 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1609 playlistwin_get_width() - 118, | |
1610 cfg.playlist_height - 16, 9, 7, mainwin_stop_pushed); | |
1611 | |
1612 /* forward button */ | |
1613 playlistwin_sfwd = | |
1614 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1615 playlistwin_get_width() - 109, | |
1616 cfg.playlist_height - 16, 8, 7, playlist_next); | |
1617 | |
1618 /* eject button */ | |
1619 playlistwin_seject = | |
1620 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1621 playlistwin_get_width() - 100, | |
1622 cfg.playlist_height - 16, 9, 7, mainwin_eject_pushed); | |
1623 | |
1624 | |
1625 playlistwin_sscroll_up = | |
1626 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1627 playlistwin_get_width() - 14, | |
1628 cfg.playlist_height - 35, 8, 5, | |
1629 playlistwin_scroll_up_pushed); | |
1630 playlistwin_sscroll_down = | |
1631 create_sbutton(&playlistwin_wlist, playlistwin_bg, playlistwin_gc, | |
1632 playlistwin_get_width() - 14, | |
1633 cfg.playlist_height - 30, 8, 5, | |
1634 playlistwin_scroll_down_pushed); | |
1635 | |
1636 } | |
1637 | |
1638 static void | |
1639 selection_received(GtkWidget * widget, | |
1640 GtkSelectionData * selection_data, gpointer data) | |
1641 { | |
1642 if (selection_data->type == GDK_SELECTION_TYPE_STRING && | |
1643 selection_data->length > 0) | |
1644 playlist_add_url((gchar *) selection_data->data); | |
1645 } | |
1646 | |
1647 static void | |
1648 playlistwin_create_window(void) | |
1649 { | |
1650 GdkPixbuf *icon; | |
1651 | |
1652 playlistwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
187 | 1653 gtk_window_set_title(GTK_WINDOW(playlistwin), _("Audacious Playlist Editor")); |
999
386cda529c28
[svn] Add wmclass information to the playlist and equalizer. Patch by cha0smaster, closes bug #481.
chainsaw
parents:
852
diff
changeset
|
1654 gtk_window_set_wmclass(GTK_WINDOW(playlistwin), "playlist", "Audacious"); |
0 | 1655 gtk_window_set_role(GTK_WINDOW(playlistwin), "playlist"); |
1656 gtk_window_set_default_size(GTK_WINDOW(playlistwin), | |
1657 playlistwin_get_width(), | |
1658 playlistwin_get_height()); | |
1659 gtk_window_set_resizable(GTK_WINDOW(playlistwin), TRUE); | |
1660 playlistwin_set_geometry_hints(cfg.playlist_shaded); | |
1068 | 1661 dock_window_list = dock_window_set_decorated(dock_window_list, |
1662 GTK_WINDOW(playlistwin), | |
1663 cfg.show_wm_decorations); | |
1069 | 1664 |
1085 | 1665 gtk_window_set_transient_for(GTK_WINDOW(playlistwin), |
1666 GTK_WINDOW(mainwin)); | |
1667 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(playlistwin), TRUE); | |
1668 | |
0 | 1669 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) bmp_playlist_icon); |
1670 gtk_window_set_icon(GTK_WINDOW(playlistwin), icon); | |
1671 g_object_unref(icon); | |
1672 | |
1673 gtk_widget_set_app_paintable(playlistwin, TRUE); | |
1674 | |
1675 if (cfg.playlist_x != -1 && cfg.save_window_position) | |
1676 gtk_window_move(GTK_WINDOW(playlistwin), | |
1677 cfg.playlist_x, cfg.playlist_y); | |
1678 | |
1679 gtk_widget_add_events(playlistwin, | |
1680 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
1681 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
1682 GDK_SCROLL_MASK | GDK_VISIBILITY_NOTIFY_MASK); | |
1683 gtk_widget_realize(playlistwin); | |
1684 | |
1685 util_set_cursor(playlistwin); | |
1686 | |
1687 g_signal_connect(playlistwin, "delete_event", | |
1688 G_CALLBACK(playlistwin_delete), NULL); | |
1689 g_signal_connect(playlistwin, "button_press_event", | |
1690 G_CALLBACK(playlistwin_press), NULL); | |
1691 g_signal_connect(playlistwin, "button_release_event", | |
1692 G_CALLBACK(playlistwin_release), NULL); | |
1693 g_signal_connect(playlistwin, "scroll_event", | |
1694 G_CALLBACK(playlistwin_scrolled), NULL); | |
1695 g_signal_connect(playlistwin, "motion_notify_event", | |
1696 G_CALLBACK(playlistwin_motion), NULL); | |
1697 g_signal_connect_after(playlistwin, "focus_in_event", | |
1698 G_CALLBACK(playlistwin_focus_in), NULL); | |
1699 g_signal_connect_after(playlistwin, "focus_out_event", | |
1700 G_CALLBACK(playlistwin_focus_out), NULL); | |
1701 g_signal_connect(playlistwin, "configure_event", | |
1702 G_CALLBACK(playlistwin_configure), NULL); | |
1703 g_signal_connect(playlistwin, "style_set", | |
1704 G_CALLBACK(playlistwin_set_back_pixmap), NULL); | |
1705 | |
1706 bmp_drag_dest_set(playlistwin); | |
1707 | |
1708 /* DnD stuff */ | |
1709 g_signal_connect(playlistwin, "drag-leave", | |
1710 G_CALLBACK(playlistwin_drag_end), NULL); | |
1711 g_signal_connect(playlistwin, "drag-data-delete", | |
1712 G_CALLBACK(playlistwin_drag_end), NULL); | |
1713 g_signal_connect(playlistwin, "drag-end", | |
1714 G_CALLBACK(playlistwin_drag_end), NULL); | |
1715 g_signal_connect(playlistwin, "drag-drop", | |
1716 G_CALLBACK(playlistwin_drag_end), NULL); | |
1717 g_signal_connect(playlistwin, "drag-data-received", | |
1718 G_CALLBACK(playlistwin_drag_data_received), NULL); | |
1719 g_signal_connect(playlistwin, "drag-motion", | |
1720 G_CALLBACK(playlistwin_drag_motion), NULL); | |
1721 | |
1722 g_signal_connect(playlistwin, "key_press_event", | |
1723 G_CALLBACK(playlistwin_keypress), NULL); | |
1724 g_signal_connect(playlistwin, "selection_received", | |
1725 G_CALLBACK(selection_received), NULL); | |
1726 | |
1727 playlistwin_set_mask(); | |
1728 } | |
1729 | |
1730 void | |
1731 playlistwin_create_popup_menus(void) | |
1732 { | |
1733 playlistwin_accel = gtk_accel_group_new(); | |
1734 | |
1735 /* playlist window popup menu */ | |
1736 playlistwin_popup_menu = create_menu(playlistwin_popup_menu_entries, | |
1737 G_N_ELEMENTS(playlistwin_popup_menu_entries), | |
1738 playlistwin_accel); | |
1739 | |
1740 pladd_menu = create_menu(pladd_menu_entries, G_N_ELEMENTS(pladd_menu_entries), | |
1741 playlistwin_accel); | |
1742 pldel_menu = create_menu(pldel_menu_entries, G_N_ELEMENTS(pldel_menu_entries), | |
1743 playlistwin_accel); | |
1744 plsel_menu = create_menu(plsel_menu_entries, G_N_ELEMENTS(plsel_menu_entries), | |
1745 playlistwin_accel); | |
1746 plsort_menu = create_menu(plsort_menu_entries, | |
1747 G_N_ELEMENTS(plsort_menu_entries), | |
1748 playlistwin_accel); | |
1749 pllist_menu = create_menu(pllist_menu_entries, G_N_ELEMENTS(pllist_menu_entries), | |
1750 playlistwin_accel); | |
1751 | |
1752 #if 0 | |
1753 make_submenu(playlistwin_popup_menu, "/Playlist", | |
1754 playlistwin_playlist_menu); | |
1755 make_submenu(playlistwin_popup_menu, "/Playback", | |
1756 playlistwin_playback_menu); | |
1757 make_submenu(playlistwin_popup_menu, "/Add", | |
1758 pladd_menu); | |
1759 #endif | |
1760 } | |
1761 | |
1762 void | |
1763 playlistwin_create(void) | |
1764 { | |
1765 playlistwin_create_window(); | |
1766 playlistwin_create_popup_menus(); | |
1767 | |
1768 /* create GC and back pixmap for custom widget to draw on */ | |
1769 playlistwin_gc = gdk_gc_new(playlistwin->window); | |
1770 playlistwin_bg = gdk_pixmap_new(playlistwin->window, | |
1771 playlistwin_get_width(), | |
1772 playlistwin_get_height_unshaded(), -1); | |
1773 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
1774 | |
1775 playlistwin_create_widgets(); | |
1776 playlistwin_update_info(); | |
1777 | |
1778 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), playlistwin_accel); | |
1779 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), mainwin_accel); | |
1780 } | |
1781 | |
1782 | |
1783 void | |
1784 playlistwin_show(void) | |
1785 { | |
1786 GtkWidget *item; | |
1787 | |
1788 item = gtk_item_factory_get_widget(mainwin_view_menu, | |
1789 "/Show Playlist Editor"); | |
1790 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); | |
1791 | |
1792 tbutton_set_toggled(mainwin_pl, TRUE); | |
1793 cfg.playlist_visible = TRUE; | |
1794 | |
1795 playlistwin_set_toprow(0); | |
1796 playlist_check_pos_current(); | |
1797 | |
1798 gtk_widget_show(playlistwin); | |
1799 } | |
1800 | |
1801 void | |
1802 playlistwin_hide(void) | |
1803 { | |
1804 GtkWidget *item; | |
1805 | |
1806 item = gtk_item_factory_get_widget(mainwin_view_menu, | |
1807 "/Show Playlist Editor"); | |
1808 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), FALSE); | |
1809 | |
1810 gtk_widget_hide(playlistwin); | |
1811 tbutton_set_toggled(mainwin_pl, FALSE); | |
1812 cfg.playlist_visible = FALSE; | |
1813 | |
1814 gtk_window_present(GTK_WINDOW(mainwin)); | |
1815 gtk_widget_grab_focus(mainwin); | |
1816 } | |
1817 | |
1818 | |
1819 static void | |
1820 plsort_menu_callback(gpointer data, | |
1821 guint action, | |
1822 GtkWidget * widget) | |
1823 { | |
1824 switch (action) { | |
1825 case PLAYLISTWIN_SORT_BYTITLE: | |
1826 playlist_sort(PLAYLIST_SORT_TITLE); | |
1827 playlistwin_update_list(); | |
1828 break; | |
1251 | 1829 case PLAYLISTWIN_SORT_BYARTIST: |
1830 playlist_sort(PLAYLIST_SORT_ARTIST); | |
1831 playlistwin_update_list(); | |
1832 break; | |
0 | 1833 case PLAYLISTWIN_SORT_BYPATH: |
1834 playlist_sort(PLAYLIST_SORT_PATH); | |
1835 playlistwin_update_list(); | |
1836 break; | |
1837 case PLAYLISTWIN_SORT_BYDATE: | |
1838 playlist_sort(PLAYLIST_SORT_DATE); | |
1839 playlistwin_update_list(); | |
1840 break; | |
1841 case PLAYLISTWIN_SORT_BYFILENAME: | |
1842 playlist_sort(PLAYLIST_SORT_FILENAME); | |
1843 playlistwin_update_list(); | |
1844 break; | |
1845 case PLAYLISTWIN_SORT_SEL_BYTITLE: | |
1846 playlist_sort_selected(PLAYLIST_SORT_TITLE); | |
1847 playlistwin_update_list(); | |
1848 break; | |
1251 | 1849 case PLAYLISTWIN_SORT_SEL_BYARTIST: |
1850 playlist_sort_selected(PLAYLIST_SORT_ARTIST); | |
1851 playlistwin_update_list(); | |
1852 break; | |
0 | 1853 case PLAYLISTWIN_SORT_SEL_BYFILENAME: |
1854 playlist_sort_selected(PLAYLIST_SORT_FILENAME); | |
1855 playlistwin_update_list(); | |
1856 break; | |
1857 case PLAYLISTWIN_SORT_SEL_BYPATH: | |
1858 playlist_sort_selected(PLAYLIST_SORT_PATH); | |
1859 playlistwin_update_list(); | |
1860 break; | |
1861 case PLAYLISTWIN_SORT_SEL_BYDATE: | |
1862 playlist_sort_selected(PLAYLIST_SORT_DATE); | |
1863 playlistwin_update_list(); | |
1864 break; | |
1865 case PLAYLISTWIN_SORT_REVERSE: | |
1866 playlist_reverse(); | |
1867 playlistwin_update_list(); | |
1868 break; | |
1869 case PLAYLISTWIN_SORT_RANDOMIZE: | |
1870 playlist_random(); | |
1871 playlistwin_update_list(); | |
1872 break; | |
1873 } | |
1874 } | |
1875 | |
1876 static void | |
1877 playlistwin_sub_menu_callback(gpointer data, | |
1878 guint action, | |
1879 GtkWidget * widget) | |
1880 { | |
1881 switch (action) { | |
1882 case PLIST_NEW: | |
1883 playlist_set_current_name(NULL); | |
1884 playlist_clear(); | |
1885 mainwin_clear_song_info(); | |
1886 mainwin_set_info_text(); | |
1887 break; | |
1888 case PLIST_SAVE: | |
1889 playlistwin_select_playlist_to_save(playlist_get_current_name()); | |
1890 break; | |
1062
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
1891 case PLIST_DEFAULTSAVE: |
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
1892 playlist_save(bmp_paths[BMP_PATH_PLAYLIST_FILE], FALSE); |
b727849e2128
[svn] - Add the ability to easily save to playlist.m3u from the list menu. (For
nhjm449
parents:
1047
diff
changeset
|
1893 break; |
0 | 1894 case PLIST_SAVE_AS: |
1895 playlistwin_select_playlist_to_save(playlist_get_current_name()); | |
1896 break; | |
1897 case PLIST_LOAD: | |
1898 playlistwin_select_playlist_to_load(playlist_get_current_name()); | |
1899 break; | |
1900 case SEL_INV: | |
1901 playlistwin_inverse_selection(); | |
1902 break; | |
1903 case SEL_ZERO: | |
1904 playlistwin_select_none(); | |
1905 break; | |
1906 case SEL_ALL: | |
1907 playlistwin_select_all(); | |
1908 break; | |
1909 case SUB_ALL: | |
1910 playlist_clear(); | |
1911 mainwin_clear_song_info(); | |
1912 mainwin_set_info_text(); | |
1913 break; | |
1914 case SUB_CROP: | |
1915 playlist_delete(TRUE); | |
1916 break; | |
1917 case SUB_SELECTED: | |
1918 playlist_delete(FALSE); | |
1919 break; | |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1920 case SUB_DUPLICATE_BYTITLE: |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1921 playlist_remove_duplicates(PLAYLIST_DUPS_TITLE); |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1922 break; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1923 case SUB_DUPLICATE_BYFILENAME: |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1924 playlist_remove_duplicates(PLAYLIST_DUPS_FILENAME); |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1925 break; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1926 case SUB_DUPLICATE_BYPATH: |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
846
diff
changeset
|
1927 playlist_remove_duplicates(PLAYLIST_DUPS_PATH); |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
625
diff
changeset
|
1928 break; |
0 | 1929 case PLAYLISTWIN_REMOVE_DEAD_FILES: |
1930 playlist_remove_dead_files(); | |
1931 break; | |
1932 case PLAYLISTWIN_REFRESH: | |
1933 playlist_read_info_selection(); | |
1934 playlistwin_update_list(); | |
1935 break; | |
1936 } | |
1937 } | |
1938 | |
1939 static void | |
1940 playlistwin_popup_menu_callback(gpointer data, | |
1941 guint action, | |
1942 GtkWidget * widget) | |
1943 { | |
1944 switch (action) { | |
1945 case ADD_FILES: | |
1946 playlistwin_show_filebrowser(); | |
1947 break; | |
1948 case CLOSE_PL_WINDOW: | |
1949 playlistwin_hide(); | |
1950 break; | |
1951 case MISC_FILEINFO: | |
1952 playlistwin_fileinfo(); | |
1953 break; | |
1954 case SEL_LOOKUP: | |
1955 playlist_read_info_selection(); | |
1956 break; | |
1957 case MISC_QUEUE: | |
1958 playlist_queue(); | |
1959 break; | |
1960 case PLIST_CQUEUE: | |
1961 playlist_clear_queue(); | |
1962 break; | |
1963 case PLIST_JTT: | |
1964 mainwin_jump_to_time(); | |
1965 break; | |
1966 case PLIST_JTF: | |
1967 mainwin_jump_to_file(); | |
1968 break; | |
1969 } | |
1970 } |