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