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