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