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