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