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