Mercurial > audlegacy
annotate src/audacious/ui_playlist.c @ 2574:40407b7363f3 trunk
[svn] - enforce playback stop when clearing the playlist to load new files in. closes #808.
| author | nenolod |
|---|---|
| date | Sun, 25 Feb 2007 00:53:19 -0800 |
| parents | 7c6ce705adda |
| children | 50098faf1cdf |
| rev | line source |
|---|---|
| 2313 | 1 /* Audacious - Cross-platform multimedia player |
| 2 * Copyright (C) 2005-2006 Audacious development team. | |
| 3 * | |
| 4 * BMP - Cross-platform multimedia player | |
| 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; under version 2 of the License. | |
| 13 * | |
| 14 * This program is distributed in the hope that it will be useful, | |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 * GNU General Public License for more details. | |
| 18 * | |
| 19 * You should have received a copy of the GNU General Public License | |
| 20 * along with this program; if not, write to the Free Software | |
| 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| 22 */ | |
| 23 | |
| 24 #include "ui_playlist.h" | |
| 25 | |
| 26 #include <glib.h> | |
| 27 #include <glib/gi18n.h> | |
| 28 #include <gdk/gdk.h> | |
| 29 #include <gdk/gdkkeysyms.h> | |
| 30 #include <gtk/gtk.h> | |
| 31 #include <string.h> | |
| 32 | |
| 33 #include "platform/smartinclude.h" | |
| 34 | |
| 35 #include <unistd.h> | |
| 36 #include <errno.h> | |
| 37 | |
|
2416
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2373
diff
changeset
|
38 #include "actions-playlist.h" |
| 2313 | 39 #include "dnd.h" |
| 40 #include "dock.h" | |
| 41 #include "hints.h" | |
| 42 #include "input.h" | |
| 43 #include "main.h" | |
| 44 #include "playback.h" | |
| 45 #include "playlist.h" | |
| 46 #include "playlist_container.h" | |
|
2499
15a1f5ee4d1c
[svn] - playlist_manager -> ui_playlist_manager, since it's a UI component.
nenolod
parents:
2495
diff
changeset
|
47 #include "ui_playlist_manager.h" |
|
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2363
diff
changeset
|
48 #include "strings.h" |
|
2416
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2373
diff
changeset
|
49 #include "ui_equalizer.h" |
|
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2373
diff
changeset
|
50 #include "ui_fileopener.h" |
|
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2373
diff
changeset
|
51 #include "ui_fileinfopopup.h" |
|
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2373
diff
changeset
|
52 #include "ui_main.h" |
|
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2373
diff
changeset
|
53 #include "ui_manager.h" |
|
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2373
diff
changeset
|
54 #include "util.h" |
| 2313 | 55 |
|
2494
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2492
diff
changeset
|
56 #include "ui_skinned_window.h" |
|
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2492
diff
changeset
|
57 |
| 2313 | 58 #include "icons-stock.h" |
| 59 #include "images/audacious_playlist.xpm" | |
| 60 | |
| 61 GtkWidget *playlistwin; | |
| 62 | |
| 63 PlayList_List *playlistwin_list = NULL; | |
| 64 PButton *playlistwin_shade, *playlistwin_close; | |
| 65 | |
| 66 static GdkPixmap *playlistwin_bg; | |
| 67 static GdkBitmap *playlistwin_mask = NULL; | |
| 68 | |
| 69 static gboolean playlistwin_hint_flag = FALSE; | |
| 70 | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
71 static GtkWidget *playlistwin_infopopup = NULL; |
|
2351
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
72 static guint playlistwin_infopopup_sid = 0; |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
73 |
| 2313 | 74 static PlaylistSlider *playlistwin_slider = NULL; |
| 75 static TextBox *playlistwin_time_min, *playlistwin_time_sec; | |
| 76 static TextBox *playlistwin_info, *playlistwin_sinfo; | |
| 77 static SButton *playlistwin_srew, *playlistwin_splay; | |
| 78 static SButton *playlistwin_spause, *playlistwin_sstop; | |
| 79 static SButton *playlistwin_sfwd, *playlistwin_seject; | |
| 80 static SButton *playlistwin_sscroll_up, *playlistwin_sscroll_down; | |
| 81 | |
| 82 static GList *playlistwin_wlist = NULL; | |
| 83 | |
| 84 void playlistwin_select_search_cbt_cb( GtkWidget *called_cbt , | |
| 85 gpointer other_cbt ); | |
| 86 static gboolean playlistwin_select_search_kp_cb( GtkWidget *entry , GdkEventKey *event , | |
| 87 gpointer searchdlg_win ); | |
| 88 | |
| 89 static void playlistwin_draw_frame(void); | |
| 90 | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
91 static gboolean playlistwin_fileinfopopup_probe(gpointer * filepopup_win); |
|
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
92 |
|
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
93 static gboolean playlistwin_resizing = FALSE; |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
94 static gint playlistwin_resize_x, playlistwin_resize_y; |
| 2313 | 95 |
| 96 gboolean | |
| 97 playlistwin_is_shaded(void) | |
| 98 { | |
| 99 return cfg.playlist_shaded; | |
| 100 } | |
| 101 | |
| 102 gint | |
| 103 playlistwin_get_width(void) | |
| 104 { | |
| 105 cfg.playlist_width /= PLAYLISTWIN_WIDTH_SNAP; | |
| 106 cfg.playlist_width *= PLAYLISTWIN_WIDTH_SNAP; | |
| 107 return cfg.playlist_width; | |
| 108 } | |
| 109 | |
| 110 gint | |
| 111 playlistwin_get_height_unshaded(void) | |
| 112 { | |
| 113 gint height; | |
| 114 cfg.playlist_height /= PLAYLISTWIN_HEIGHT_SNAP; | |
| 115 cfg.playlist_height *= PLAYLISTWIN_HEIGHT_SNAP; | |
| 116 height = cfg.playlist_height; | |
| 117 return height; | |
| 118 } | |
| 119 | |
| 120 gint | |
| 121 playlistwin_get_height_shaded(void) | |
| 122 { | |
| 123 return PLAYLISTWIN_SHADED_HEIGHT; | |
| 124 } | |
| 125 | |
| 126 gint | |
| 127 playlistwin_get_height(void) | |
| 128 { | |
| 129 if (playlistwin_is_shaded()) | |
| 130 return playlistwin_get_height_shaded(); | |
| 131 else | |
| 132 return playlistwin_get_height_unshaded(); | |
| 133 } | |
| 134 | |
| 135 void | |
| 136 playlistwin_get_size(gint * width, gint * height) | |
| 137 { | |
| 138 if (width) | |
| 139 *width = playlistwin_get_width(); | |
| 140 | |
| 141 if (height) | |
| 142 *height = playlistwin_get_height(); | |
| 143 } | |
| 144 | |
| 145 static void | |
| 146 playlistwin_update_info(Playlist *playlist) | |
| 147 { | |
| 148 gchar *text, *sel_text, *tot_text; | |
| 149 gulong selection, total; | |
| 150 gboolean selection_more, total_more; | |
| 151 | |
| 152 playlist_get_total_time(playlist, &total, &selection, &total_more, &selection_more); | |
| 153 | |
| 154 if (selection > 0 || (selection == 0 && !selection_more)) { | |
| 155 if (selection > 3600) | |
| 156 sel_text = | |
| 157 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", selection / 3600, | |
| 158 (selection / 60) % 60, selection % 60, | |
| 159 (selection_more ? "+" : "")); | |
| 160 else | |
| 161 sel_text = | |
| 162 g_strdup_printf("%lu:%-2.2lu%s", selection / 60, | |
| 163 selection % 60, (selection_more ? "+" : "")); | |
| 164 } | |
| 165 else | |
| 166 sel_text = g_strdup("?"); | |
| 167 if (total > 0 || (total == 0 && !total_more)) { | |
| 168 if (total > 3600) | |
| 169 tot_text = | |
| 170 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", total / 3600, | |
| 171 (total / 60) % 60, total % 60, | |
| 172 total_more ? "+" : ""); | |
| 173 else | |
| 174 tot_text = | |
| 175 g_strdup_printf("%lu:%-2.2lu%s", total / 60, total % 60, | |
| 176 total_more ? "+" : ""); | |
| 177 } | |
| 178 else | |
| 179 tot_text = g_strdup("?"); | |
| 180 text = g_strconcat(sel_text, "/", tot_text, NULL); | |
| 181 textbox_set_text(playlistwin_info, text ? text : ""); | |
| 182 g_free(text); | |
| 183 g_free(tot_text); | |
| 184 g_free(sel_text); | |
| 185 } | |
| 186 | |
| 187 static void | |
| 188 playlistwin_update_sinfo(Playlist *playlist) | |
| 189 { | |
| 190 gchar *posstr, *timestr, *title, *info; | |
| 191 gint pos, time; | |
| 192 | |
| 193 pos = playlist_get_position(playlist); | |
| 194 title = playlist_get_songtitle(playlist, pos); | |
| 195 | |
| 196 if (!title) { | |
| 197 textbox_set_text(playlistwin_sinfo, ""); | |
| 198 return; | |
| 199 } | |
| 200 | |
| 201 convert_title_text(title); | |
| 202 | |
| 203 time = playlist_get_songtime(playlist, pos); | |
| 204 | |
| 205 if (cfg.show_numbers_in_pl) | |
| 206 posstr = g_strdup_printf("%d. ", pos + 1); | |
| 207 else | |
| 208 posstr = g_strdup(""); | |
| 209 | |
| 210 if (time != -1) { | |
| 211 timestr = g_strdup_printf(" (%d:%-2.2d)", time / 60000, | |
| 212 (time / 1000) % 60); | |
| 213 } | |
| 214 else | |
| 215 timestr = g_strdup(""); | |
| 216 | |
| 217 info = g_strdup_printf("%s%s%s", posstr, title, timestr); | |
| 218 | |
| 219 g_free(posstr); | |
| 220 g_free(title); | |
| 221 g_free(timestr); | |
| 222 | |
| 223 textbox_set_text(playlistwin_sinfo, info ? info : ""); | |
| 224 g_free(info); | |
| 225 } | |
| 226 | |
| 227 gboolean | |
| 228 playlistwin_item_visible(gint index) | |
| 229 { | |
| 230 if (index >= playlistwin_list->pl_first | |
| 231 && index < | |
| 232 (playlistwin_list->pl_first + playlistwin_list->pl_num_visible)) | |
| 233 return TRUE; | |
| 234 return FALSE; | |
| 235 } | |
| 236 | |
| 237 gint | |
| 238 playlistwin_get_toprow(void) | |
| 239 { | |
| 240 if (playlistwin_list) | |
| 241 return (playlistwin_list->pl_first); | |
| 242 return (-1); | |
| 243 } | |
| 244 | |
| 245 void | |
| 246 playlistwin_set_toprow(gint toprow) | |
| 247 { | |
| 248 if (playlistwin_list) | |
| 249 playlistwin_list->pl_first = toprow; | |
| 250 playlistwin_update_list(playlist_get_active()); | |
| 251 } | |
| 252 | |
| 253 void | |
| 254 playlistwin_update_list(Playlist *playlist) | |
| 255 { | |
| 256 /* this can happen early on. just bail gracefully. */ | |
| 2363 | 257 g_return_if_fail(playlistwin_list); |
| 2313 | 258 |
| 259 widget_draw(WIDGET(playlistwin_list)); | |
| 260 widget_draw(WIDGET(playlistwin_slider)); | |
| 261 playlistwin_update_info(playlist); | |
| 262 playlistwin_update_sinfo(playlist); | |
| 263 } | |
| 264 | |
| 265 static void | |
| 266 playlistwin_set_mask(void) | |
| 267 { | |
| 268 GdkGC *gc; | |
| 269 GdkColor pattern; | |
| 270 | |
| 271 if (playlistwin_mask) | |
| 272 g_object_unref(playlistwin_mask); | |
| 273 | |
| 274 playlistwin_mask = | |
| 275 gdk_pixmap_new(playlistwin->window, playlistwin_get_width(), | |
| 276 playlistwin_get_height(), 1); | |
| 277 gc = gdk_gc_new(playlistwin_mask); | |
| 278 pattern.pixel = 1; | |
| 279 gdk_gc_set_foreground(gc, &pattern); | |
| 280 gdk_draw_rectangle(playlistwin_mask, gc, TRUE, 0, 0, | |
| 281 playlistwin_get_width(), playlistwin_get_height()); | |
| 282 g_object_unref(gc); | |
| 283 | |
| 284 gtk_widget_shape_combine_mask(playlistwin, playlistwin_mask, 0, 0); | |
| 285 } | |
| 286 | |
| 287 static void | |
| 288 playlistwin_set_geometry_hints(gboolean shaded) | |
| 289 { | |
| 290 GdkGeometry geometry; | |
| 291 GdkWindowHints mask; | |
| 292 | |
| 293 geometry.min_width = PLAYLISTWIN_MIN_WIDTH; | |
| 294 geometry.max_width = G_MAXUINT16; | |
| 295 | |
| 296 geometry.width_inc = PLAYLISTWIN_WIDTH_SNAP; | |
| 297 geometry.height_inc = PLAYLISTWIN_HEIGHT_SNAP; | |
| 298 | |
| 299 if (shaded) { | |
| 300 geometry.min_height = PLAYLISTWIN_SHADED_HEIGHT; | |
| 301 geometry.max_height = PLAYLISTWIN_SHADED_HEIGHT; | |
| 302 geometry.base_height = PLAYLISTWIN_SHADED_HEIGHT; | |
| 303 } | |
| 304 else { | |
| 305 geometry.min_height = PLAYLISTWIN_MIN_HEIGHT; | |
| 306 geometry.max_height = G_MAXUINT16; | |
| 307 } | |
| 308 | |
| 309 mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_RESIZE_INC; | |
| 310 | |
| 311 gtk_window_set_geometry_hints(GTK_WINDOW(playlistwin), | |
| 312 playlistwin, &geometry, mask); | |
| 313 } | |
| 314 | |
| 315 void | |
| 316 playlistwin_set_sinfo_font(gchar *font) | |
| 317 { | |
| 318 gchar *tmp = NULL, *tmp2 = NULL; | |
| 319 | |
| 2363 | 320 g_return_if_fail(font); |
| 2313 | 321 |
| 322 tmp = g_strdup(font); | |
| 2363 | 323 g_return_if_fail(tmp); |
| 2313 | 324 |
| 325 *strrchr(tmp, ' ') = '\0'; | |
| 326 tmp2 = g_strdup_printf("%s 8", tmp); | |
| 2363 | 327 g_return_if_fail(tmp2); |
| 328 | |
| 2313 | 329 textbox_set_xfont(playlistwin_sinfo, cfg.mainwin_use_xfont, tmp2); |
| 330 | |
| 2363 | 331 g_free(tmp); |
| 332 g_free(tmp2); | |
| 2313 | 333 } |
| 334 | |
| 335 void | |
| 336 playlistwin_set_sinfo_scroll(gboolean scroll) | |
| 337 { | |
| 338 if(playlistwin_is_shaded()) | |
| 339 textbox_set_scroll(playlistwin_sinfo, cfg.autoscroll); | |
| 340 else | |
| 341 textbox_set_scroll(playlistwin_sinfo, FALSE); | |
| 342 } | |
| 343 | |
| 344 void | |
| 345 playlistwin_set_shade(gboolean shaded) | |
| 346 { | |
| 347 cfg.playlist_shaded = shaded; | |
| 348 | |
| 349 if (shaded) { | |
| 350 playlistwin_set_sinfo_font(cfg.playlist_font); | |
| 351 playlistwin_set_sinfo_scroll(cfg.autoscroll); | |
| 352 widget_show(WIDGET(playlistwin_sinfo)); | |
| 353 playlistwin_shade->pb_nx = 128; | |
| 354 playlistwin_shade->pb_ny = 45; | |
| 355 playlistwin_shade->pb_px = 150; | |
| 356 playlistwin_shade->pb_py = 42; | |
| 357 playlistwin_close->pb_nx = 138; | |
| 358 playlistwin_close->pb_ny = 45; | |
| 359 } | |
| 360 else { | |
| 361 widget_hide(WIDGET(playlistwin_sinfo)); | |
| 362 playlistwin_set_sinfo_scroll(FALSE); | |
| 363 playlistwin_shade->pb_nx = 157; | |
| 364 playlistwin_shade->pb_ny = 3; | |
| 365 playlistwin_shade->pb_px = 62; | |
| 366 playlistwin_shade->pb_py = 42; | |
| 367 playlistwin_close->pb_nx = 167; | |
| 368 playlistwin_close->pb_ny = 3; | |
| 369 } | |
| 370 | |
| 371 dock_shade(dock_window_list, GTK_WINDOW(playlistwin), | |
| 372 playlistwin_get_height()); | |
| 373 | |
| 374 playlistwin_set_geometry_hints(cfg.playlist_shaded); | |
| 375 | |
| 376 gtk_window_resize(GTK_WINDOW(playlistwin), | |
| 377 playlistwin_get_width(), | |
| 378 playlistwin_get_height()); | |
| 379 | |
| 380 playlistwin_set_mask(); | |
| 381 | |
| 382 widget_draw(WIDGET(playlistwin_list)); | |
| 383 widget_draw(WIDGET(playlistwin_slider)); | |
| 384 | |
| 385 draw_playlist_window(TRUE); | |
| 386 } | |
| 387 | |
| 388 static void | |
| 389 playlistwin_set_shade_menu(gboolean shaded) | |
| 390 { | |
| 391 GtkAction *action = gtk_action_group_get_action( | |
| 392 toggleaction_group_others , "roll up playlist editor" ); | |
| 393 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded ); | |
| 394 | |
| 395 playlistwin_set_shade(shaded); | |
| 396 playlistwin_update_list(playlist_get_active()); | |
| 397 } | |
| 398 | |
| 399 void | |
| 400 playlistwin_shade_toggle(void) | |
| 401 { | |
| 402 playlistwin_set_shade_menu(!cfg.playlist_shaded); | |
| 403 } | |
| 404 | |
| 405 static void | |
| 406 playlistwin_release(GtkWidget * widget, | |
| 407 GdkEventButton * event, | |
| 408 gpointer callback_data) | |
| 409 { | |
| 410 if (event->button == 3) | |
| 411 return; | |
| 412 | |
| 413 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
| 414 playlistwin_resizing = FALSE; | |
| 415 gdk_flush(); | |
| 416 | |
| 417 if (dock_is_moving(GTK_WINDOW(playlistwin))) | |
| 418 dock_move_release(GTK_WINDOW(playlistwin)); | |
| 419 else | |
| 420 { | |
| 421 handle_release_cb(playlistwin_wlist, widget, event); | |
| 422 draw_playlist_window(FALSE); | |
| 423 } | |
| 424 } | |
| 425 | |
| 426 void | |
| 427 playlistwin_scroll(gint num) | |
| 428 { | |
| 429 playlistwin_list->pl_first += num; | |
| 430 playlistwin_update_list(playlist_get_active()); | |
| 431 } | |
| 432 | |
| 433 void | |
| 434 playlistwin_scroll_up_pushed(void) | |
| 435 { | |
| 436 playlistwin_scroll(-3); | |
| 437 } | |
| 438 | |
| 439 void | |
| 440 playlistwin_scroll_down_pushed(void) | |
| 441 { | |
| 442 playlistwin_scroll(3); | |
| 443 } | |
| 444 | |
| 445 static void | |
| 446 playlistwin_select_all(void) | |
| 447 { | |
| 448 Playlist *playlist = playlist_get_active(); | |
| 449 | |
| 450 playlist_select_all(playlist, TRUE); | |
| 451 playlistwin_list->pl_prev_selected = 0; | |
| 452 playlistwin_list->pl_prev_min = 0; | |
| 453 playlistwin_list->pl_prev_max = playlist_get_length(playlist) - 1; | |
| 454 playlistwin_update_list(playlist); | |
| 455 } | |
| 456 | |
| 457 static void | |
| 458 playlistwin_select_none(void) | |
| 459 { | |
| 460 playlist_select_all(playlist_get_active(), FALSE); | |
| 461 playlistwin_list->pl_prev_selected = -1; | |
| 462 playlistwin_list->pl_prev_min = -1; | |
| 463 playlistwin_update_list(playlist_get_active()); | |
| 464 } | |
| 465 | |
| 466 static void | |
| 467 playlistwin_select_search(void) | |
| 468 { | |
| 469 Playlist *playlist = playlist_get_active(); | |
| 470 GtkWidget *searchdlg_win, *searchdlg_table; | |
| 471 GtkWidget *searchdlg_hbox, *searchdlg_logo, *searchdlg_helptext; | |
| 472 GtkWidget *searchdlg_entry_track_name, *searchdlg_label_track_name; | |
| 473 GtkWidget *searchdlg_entry_album_name, *searchdlg_label_album_name; | |
| 474 GtkWidget *searchdlg_entry_file_name, *searchdlg_label_file_name; | |
| 475 GtkWidget *searchdlg_entry_performer, *searchdlg_label_performer; | |
| 476 GtkWidget *searchdlg_checkbt_clearprevsel; | |
| 477 GtkWidget *searchdlg_checkbt_newplaylist; | |
| 478 GtkWidget *searchdlg_checkbt_autoenqueue; | |
| 479 gint result; | |
| 480 | |
| 481 /* create dialog */ | |
| 482 searchdlg_win = gtk_dialog_new_with_buttons( | |
| 483 _("Search entries in active playlist") , GTK_WINDOW(mainwin) , | |
| 484 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT , | |
| 485 GTK_STOCK_CANCEL , GTK_RESPONSE_REJECT , GTK_STOCK_OK , GTK_RESPONSE_ACCEPT , NULL ); | |
| 486 /* help text and logo */ | |
| 487 searchdlg_hbox = gtk_hbox_new( FALSE , 4 ); | |
| 488 searchdlg_logo = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_DIALOG ); | |
| 489 searchdlg_helptext = gtk_label_new( _("Select entries in playlist by filling one or more " | |
| 490 "fields. Fields use regular expressions syntax, case-insensitive. If you don't know how " | |
| 491 "regular expressions work, simply insert a literal portion of what you're searching for.") ); | |
| 492 gtk_label_set_line_wrap( GTK_LABEL(searchdlg_helptext) , TRUE ); | |
| 493 gtk_box_pack_start( GTK_BOX(searchdlg_hbox) , searchdlg_logo , FALSE , FALSE , 0 ); | |
| 494 gtk_box_pack_start( GTK_BOX(searchdlg_hbox) , searchdlg_helptext , FALSE , FALSE , 0 ); | |
| 495 /* track name */ | |
| 496 searchdlg_label_track_name = gtk_label_new( _("Track name: ") ); | |
| 497 searchdlg_entry_track_name = gtk_entry_new(); | |
| 498 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_track_name) , 0 , 0.5 ); | |
| 499 g_signal_connect( G_OBJECT(searchdlg_entry_track_name) , "key-press-event" , | |
| 500 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
| 501 /* album name */ | |
| 502 searchdlg_label_album_name = gtk_label_new( _("Album name: ") ); | |
| 503 searchdlg_entry_album_name = gtk_entry_new(); | |
| 504 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_album_name) , 0 , 0.5 ); | |
| 505 g_signal_connect( G_OBJECT(searchdlg_entry_album_name) , "key-press-event" , | |
| 506 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
| 507 /* artist */ | |
| 508 searchdlg_label_performer = gtk_label_new( _("Artist: ") ); | |
| 509 searchdlg_entry_performer = gtk_entry_new(); | |
| 510 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_performer) , 0 , 0.5 ); | |
| 511 g_signal_connect( G_OBJECT(searchdlg_entry_performer) , "key-press-event" , | |
| 512 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
| 513 /* file name */ | |
| 514 searchdlg_label_file_name = gtk_label_new( _("Filename: ") ); | |
| 515 searchdlg_entry_file_name = gtk_entry_new(); | |
| 516 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_file_name) , 0 , 0.5 ); | |
| 517 g_signal_connect( G_OBJECT(searchdlg_entry_file_name) , "key-press-event" , | |
| 518 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win ); | |
| 519 /* some options that control behaviour */ | |
| 520 searchdlg_checkbt_clearprevsel = gtk_check_button_new_with_label( | |
| 521 _("Clear previous selection before searching") ); | |
| 522 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_clearprevsel) , TRUE ); | |
| 523 searchdlg_checkbt_autoenqueue = gtk_check_button_new_with_label( | |
| 524 _("Automatically toggle queue for matching entries") ); | |
| 525 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_autoenqueue) , FALSE ); | |
| 526 searchdlg_checkbt_newplaylist = gtk_check_button_new_with_label( | |
| 527 _("Create a new playlist with matching entries") ); | |
| 528 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_newplaylist) , FALSE ); | |
| 529 g_signal_connect( G_OBJECT(searchdlg_checkbt_autoenqueue) , "clicked" , | |
| 530 G_CALLBACK(playlistwin_select_search_cbt_cb) , searchdlg_checkbt_newplaylist ); | |
| 531 g_signal_connect( G_OBJECT(searchdlg_checkbt_newplaylist) , "clicked" , | |
| 532 G_CALLBACK(playlistwin_select_search_cbt_cb) , searchdlg_checkbt_autoenqueue ); | |
| 533 /* place fields in searchdlg_table */ | |
| 534 searchdlg_table = gtk_table_new( 8 , 2 , FALSE ); | |
| 535 gtk_table_set_row_spacing( GTK_TABLE(searchdlg_table) , 0 , 8 ); | |
| 536 gtk_table_set_row_spacing( GTK_TABLE(searchdlg_table) , 4 , 8 ); | |
| 537 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_hbox , | |
| 538 0 , 2 , 0 , 1 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
| 539 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_track_name , | |
| 540 0 , 1 , 1 , 2 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
| 541 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_track_name , | |
| 542 1 , 2 , 1 , 2 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
| 543 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_album_name , | |
| 544 0 , 1 , 2 , 3 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
| 545 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_album_name , | |
| 546 1 , 2 , 2 , 3 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
| 547 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_performer , | |
| 548 0 , 1 , 3 , 4 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
| 549 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_performer , | |
| 550 1 , 2 , 3 , 4 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
| 551 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_file_name , | |
| 552 0 , 1 , 4 , 5 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
| 553 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_file_name , | |
| 554 1 , 2 , 4 , 5 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 ); | |
| 555 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_clearprevsel , | |
| 556 0 , 2 , 5 , 6 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); | |
| 557 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_autoenqueue , | |
| 558 0 , 2 , 6 , 7 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); | |
| 559 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_newplaylist , | |
| 560 0 , 2 , 7 , 8 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 ); | |
| 561 | |
| 562 gtk_container_set_border_width( GTK_CONTAINER(searchdlg_table) , 5 ); | |
| 563 gtk_container_add( GTK_CONTAINER(GTK_DIALOG(searchdlg_win)->vbox) , searchdlg_table ); | |
| 564 gtk_widget_show_all( searchdlg_win ); | |
| 565 result = gtk_dialog_run( GTK_DIALOG(searchdlg_win) ); | |
| 566 switch(result) | |
| 567 { | |
| 568 case GTK_RESPONSE_ACCEPT: | |
| 569 { | |
| 570 gint matched_entries_num = 0; | |
| 571 /* create a TitleInput tuple with user search data */ | |
| 572 TitleInput *tuple = g_malloc(sizeof(TitleInput)); | |
| 573 gchar *searchdata = NULL; | |
| 574 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_track_name) ); | |
| 575 tuple->track_name = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; | |
| 576 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_album_name) ); | |
| 577 tuple->album_name = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; | |
| 578 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_performer) ); | |
| 579 tuple->performer = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; | |
| 580 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_file_name) ); | |
| 581 tuple->file_name = ( strcmp(searchdata,"") ) ? g_strdup(searchdata) : NULL; | |
| 582 /* check if previous selection should be cleared before searching */ | |
| 583 if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_clearprevsel)) == TRUE ) | |
| 584 playlistwin_select_none(); | |
| 585 /* now send this tuple to the real search function */ | |
| 586 matched_entries_num = playlist_select_search( playlist , tuple , 0 ); | |
| 587 /* we do not need the tuple and its data anymore */ | |
| 588 if ( tuple->track_name != NULL ) g_free( tuple->track_name ); | |
| 589 if ( tuple->album_name != NULL ) g_free( tuple->album_name ); | |
| 590 if ( tuple->performer != NULL ) g_free( tuple->performer ); | |
| 591 if ( tuple->file_name != NULL ) g_free( tuple->file_name ); | |
| 592 g_free( tuple ); | |
| 593 playlistwin_update_list(playlist_get_active()); | |
| 594 /* check if a new playlist should be created after searching */ | |
| 595 if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_newplaylist)) == TRUE ) | |
| 596 playlist_new_from_selected(); | |
| 597 /* check if matched entries should be queued */ | |
| 598 else if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_autoenqueue)) == TRUE ) | |
| 599 playlist_queue(playlist_get_active()); | |
| 600 break; | |
| 601 } | |
| 602 default: | |
| 603 break; | |
| 604 } | |
| 605 /* done here :) */ | |
| 606 gtk_widget_destroy( searchdlg_win ); | |
| 607 } | |
| 608 | |
| 609 static void | |
| 610 playlistwin_inverse_selection(void) | |
| 611 { | |
| 612 playlist_select_invert_all(playlist_get_active()); | |
| 613 playlistwin_list->pl_prev_selected = -1; | |
| 614 playlistwin_list->pl_prev_min = -1; | |
| 615 playlistwin_update_list(playlist_get_active()); | |
| 616 } | |
| 617 | |
| 618 static void | |
| 619 playlistwin_resize(gint width, gint height) | |
| 620 { | |
|
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
621 gint tx, ty; |
|
2507
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
622 gint dx, dy; |
| 2313 | 623 gboolean redraw; |
| 624 | |
| 625 g_return_if_fail(width > 0 && height > 0); | |
| 626 | |
|
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
627 tx = (width - PLAYLISTWIN_MIN_WIDTH) / PLAYLISTWIN_WIDTH_SNAP; |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
628 tx = (tx * PLAYLISTWIN_WIDTH_SNAP) + PLAYLISTWIN_MIN_WIDTH; |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
629 if (tx < PLAYLISTWIN_MIN_WIDTH) |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
630 tx = PLAYLISTWIN_MIN_WIDTH; |
| 2313 | 631 |
| 632 if (!cfg.playlist_shaded) | |
|
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
633 { |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
634 ty = (height - PLAYLISTWIN_MIN_HEIGHT) / PLAYLISTWIN_HEIGHT_SNAP; |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
635 ty = (ty * PLAYLISTWIN_HEIGHT_SNAP) + PLAYLISTWIN_MIN_HEIGHT; |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
636 if (ty < PLAYLISTWIN_MIN_HEIGHT) |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
637 ty = PLAYLISTWIN_MIN_HEIGHT; |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
638 } |
| 2313 | 639 else |
|
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
640 ty = cfg.playlist_height; |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
641 |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
642 if (tx == cfg.playlist_width && ty == cfg.playlist_height) |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
643 return; |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
644 |
|
2507
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
645 /* difference between previous size and new size */ |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
646 dx = tx - cfg.playlist_width; |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
647 dy = ty - cfg.playlist_height; |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
648 |
|
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
649 cfg.playlist_width = width = tx; |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
650 cfg.playlist_height = height = ty; |
| 2313 | 651 |
| 652 | |
|
2507
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
653 widget_resize_relative(WIDGET(playlistwin_list), dx, dy); |
| 2313 | 654 |
|
2507
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
655 widget_move_relative(WIDGET(playlistwin_slider), dx, 0); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
656 widget_resize_relative(WIDGET(playlistwin_slider), 0, dy); |
| 2313 | 657 |
|
2507
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
658 widget_resize_relative(WIDGET(playlistwin_sinfo), dx, 0); |
| 2313 | 659 playlistwin_update_sinfo(playlist_get_active()); |
| 660 | |
|
2507
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
661 widget_move_relative(WIDGET(playlistwin_shade), dx, 0); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
662 widget_move_relative(WIDGET(playlistwin_close), dx, 0); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
663 widget_move_relative(WIDGET(playlistwin_time_min), dx, dy); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
664 widget_move_relative(WIDGET(playlistwin_time_sec), dx, dy); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
665 widget_move_relative(WIDGET(playlistwin_info), dx, dy); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
666 widget_move_relative(WIDGET(playlistwin_srew), dx, dy); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
667 widget_move_relative(WIDGET(playlistwin_splay), dx, dy); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
668 widget_move_relative(WIDGET(playlistwin_spause), dx, dy); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
669 widget_move_relative(WIDGET(playlistwin_sstop), dx, dy); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
670 widget_move_relative(WIDGET(playlistwin_sfwd), dx, dy); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
671 widget_move_relative(WIDGET(playlistwin_seject), dx, dy); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
672 widget_move_relative(WIDGET(playlistwin_sscroll_up), dx, dy); |
|
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
673 widget_move_relative(WIDGET(playlistwin_sscroll_down), dx, dy); |
| 2313 | 674 |
| 675 g_object_unref(playlistwin_bg); | |
| 676 playlistwin_bg = gdk_pixmap_new(playlistwin->window, width, height, -1); | |
| 677 playlistwin_set_mask(); | |
| 678 | |
| 679 widget_list_lock(playlistwin_wlist); | |
| 680 | |
| 681 widget_list_change_pixmap(playlistwin_wlist, playlistwin_bg); | |
| 682 playlistwin_draw_frame(); | |
| 683 widget_list_draw(playlistwin_wlist, &redraw, TRUE); | |
| 684 widget_list_clear_redraw(playlistwin_wlist); | |
| 685 | |
| 686 widget_list_unlock(playlistwin_wlist); | |
| 687 | |
| 688 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
| 689 gdk_window_clear(playlistwin->window); | |
| 690 } | |
| 691 | |
| 692 static void | |
| 693 playlistwin_motion(GtkWidget * widget, | |
| 694 GdkEventMotion * event, | |
| 695 gpointer callback_data) | |
| 696 { | |
| 697 GdkEvent *gevent; | |
| 698 | |
|
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
699 /* |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
700 * GDK2's resize is broken and doesn't really play nice, so we have |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
701 * to do all of this stuff by hand. |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
702 */ |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
703 if (playlistwin_resizing == TRUE) |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
704 { |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
705 if (event->x + playlistwin_resize_x != playlistwin_get_width() || |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
706 event->y + playlistwin_resize_y != playlistwin_get_height()) |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
707 { |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
708 playlistwin_resize(event->x + playlistwin_resize_x, |
|
2507
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
709 event->y + playlistwin_resize_y); |
|
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
710 } |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
711 gdk_window_resize(playlistwin->window, |
|
2507
e07c141dd326
[svn] - made new functions: widget_move_relative and widget_resize_relative
mf0102
parents:
2499
diff
changeset
|
712 cfg.playlist_width, cfg.playlist_height); |
|
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
713 } |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
714 else if (dock_is_moving(GTK_WINDOW(playlistwin))) |
| 2313 | 715 dock_move_motion(GTK_WINDOW(playlistwin), event); |
|
2491
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
716 else |
|
2aeea41ef023
[svn] - using ConfigureNotify for resizing is wrong per ICCCM guideline,
nenolod
parents:
2461
diff
changeset
|
717 { |
| 2313 | 718 handle_motion_cb(playlistwin_wlist, widget, event); |
| 719 draw_playlist_window(FALSE); | |
| 720 } | |
| 721 gdk_flush(); | |
| 722 | |
| 723 while ((gevent = gdk_event_get()) != NULL) gdk_event_free(gevent); | |
| 724 } | |
| 725 | |
| 726 static void | |
| 727 playlistwin_enter(GtkWidget * widget, | |
| 728 GdkEventMotion * event, | |
| 729 gpointer callback_data) | |
| 730 { | |
| 731 playlistwin_list->pl_tooltips = TRUE; | |
| 732 } | |
| 733 | |
| 734 static void | |
| 735 playlistwin_leave(GtkWidget * widget, | |
| 736 GdkEventMotion * event, | |
| 737 gpointer callback_data) | |
| 738 { | |
| 739 playlistwin_list->pl_tooltips = FALSE; | |
| 740 } | |
| 741 | |
| 742 static void | |
| 743 playlistwin_show_filebrowser(void) | |
| 744 { | |
|
2416
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2373
diff
changeset
|
745 run_filebrowser(NO_PLAY_BUTTON); |
| 2313 | 746 } |
| 747 | |
| 748 static void | |
| 749 playlistwin_fileinfo(void) | |
| 750 { | |
| 751 Playlist *playlist = playlist_get_active(); | |
| 752 | |
| 753 /* Show the first selected file, or the current file if nothing is | |
| 754 * selected */ | |
| 755 GList *list = playlist_get_selected(playlist); | |
| 756 if (list) { | |
| 757 playlist_fileinfo(playlist, GPOINTER_TO_INT(list->data)); | |
| 758 g_list_free(list); | |
| 759 } | |
| 760 else | |
| 761 playlist_fileinfo_current(playlist); | |
| 762 } | |
| 763 | |
| 764 static void | |
| 2363 | 765 show_playlist_save_error(GtkWindow *parent, |
| 766 const gchar *filename) | |
| 2313 | 767 { |
| 768 GtkWidget *dialog; | |
| 769 | |
| 770 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
| 2363 | 771 g_return_if_fail(filename); |
| 2313 | 772 |
| 773 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
| 774 GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 775 GTK_MESSAGE_ERROR, | |
| 776 GTK_BUTTONS_OK, | |
| 777 _("Error writing playlist \"%s\": %s"), | |
| 778 filename, strerror(errno)); | |
| 779 | |
| 780 gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 781 gtk_widget_destroy(dialog); | |
| 782 } | |
| 783 | |
| 784 static gboolean | |
| 785 show_playlist_overwrite_prompt(GtkWindow * parent, | |
| 786 const gchar * filename) | |
| 787 { | |
| 788 GtkWidget *dialog; | |
| 789 gint result; | |
| 790 | |
| 791 g_return_val_if_fail(GTK_IS_WINDOW(parent), FALSE); | |
| 792 g_return_val_if_fail(filename != NULL, FALSE); | |
| 793 | |
| 794 dialog = gtk_message_dialog_new(GTK_WINDOW(parent), | |
| 795 GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 796 GTK_MESSAGE_QUESTION, | |
| 797 GTK_BUTTONS_YES_NO, | |
| 798 _("%s already exist. Continue?"), | |
| 799 filename); | |
| 800 | |
| 801 result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 802 gtk_widget_destroy(dialog); | |
| 803 | |
| 804 return (result == GTK_RESPONSE_YES); | |
| 805 } | |
| 806 | |
| 807 static void | |
| 808 show_playlist_save_format_error(GtkWindow * parent, | |
| 809 const gchar * filename) | |
| 810 { | |
| 811 const gchar *markup = | |
| 812 N_("<b><big>Unable to save playlist.</big></b>\n\n" | |
| 813 "Unknown file type for '%s'.\n"); | |
| 814 | |
| 815 GtkWidget *dialog; | |
| 816 | |
| 817 g_return_if_fail(GTK_IS_WINDOW(parent)); | |
| 818 g_return_if_fail(filename != NULL); | |
| 819 | |
| 820 dialog = | |
| 821 gtk_message_dialog_new_with_markup(GTK_WINDOW(parent), | |
| 822 GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 823 GTK_MESSAGE_ERROR, | |
| 824 GTK_BUTTONS_OK, | |
| 825 _(markup), | |
| 826 filename); | |
| 827 gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 828 gtk_widget_destroy(dialog); | |
| 829 } | |
| 830 | |
| 831 static void | |
| 832 playlistwin_save_playlist(const gchar * filename) | |
| 833 { | |
| 834 PlaylistContainer *plc; | |
| 835 gchar *ext = strrchr(filename, '.') + 1; | |
| 836 | |
| 837 plc = playlist_container_find(ext); | |
| 838 if (plc == NULL) { | |
| 839 show_playlist_save_format_error(GTK_WINDOW(playlistwin), filename); | |
| 840 return; | |
| 841 } | |
| 842 | |
| 843 str_replace_in(&cfg.playlist_path, g_path_get_dirname(filename)); | |
| 844 | |
| 845 if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) | |
| 846 if (!show_playlist_overwrite_prompt(GTK_WINDOW(playlistwin), filename)) | |
| 847 return; | |
| 848 | |
| 849 if (!playlist_save(playlist_get_active(), filename)) | |
| 850 show_playlist_save_error(GTK_WINDOW(playlistwin), filename); | |
| 851 } | |
| 852 | |
| 853 static void | |
| 854 playlistwin_load_playlist(const gchar * filename) | |
| 855 { | |
| 856 Playlist *playlist = playlist_get_active(); | |
| 857 | |
| 858 g_return_if_fail(filename != NULL); | |
| 859 | |
| 860 str_replace_in(&cfg.playlist_path, g_strdup(filename)); | |
| 861 | |
| 862 playlist_clear(playlist); | |
| 863 mainwin_clear_song_info(); | |
| 864 mainwin_set_info_text(); | |
| 865 | |
| 866 playlist_load(playlist, filename); | |
| 867 playlist_set_current_name(playlist, filename); | |
| 868 } | |
| 869 | |
| 870 static gchar * | |
| 871 playlist_file_selection_load(const gchar * title, | |
| 872 const gchar * default_filename) | |
| 873 { | |
|
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2508
diff
changeset
|
874 GtkWidget *dialog; |
| 2313 | 875 gchar *filename; |
| 876 | |
| 877 g_return_val_if_fail(title != NULL, NULL); | |
| 878 | |
|
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2508
diff
changeset
|
879 dialog = make_filebrowser(title, FALSE); |
|
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2508
diff
changeset
|
880 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), default_filename); |
| 2313 | 881 |
| 882 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
| 883 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
| 884 else | |
| 885 filename = NULL; | |
| 886 | |
|
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2508
diff
changeset
|
887 gtk_widget_destroy(dialog); |
| 2313 | 888 return filename; |
| 889 } | |
| 890 | |
| 891 static gchar * | |
| 892 playlist_file_selection_save(const gchar * title, | |
| 893 const gchar * default_filename) | |
| 894 { | |
|
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2508
diff
changeset
|
895 GtkWidget *dialog; |
| 2313 | 896 gchar *filename; |
| 897 | |
| 898 g_return_val_if_fail(title != NULL, NULL); | |
| 899 | |
|
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2508
diff
changeset
|
900 dialog = make_filebrowser(title, TRUE); |
|
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2508
diff
changeset
|
901 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), default_filename); |
|
2508
ecdfed7b1861
[svn] - more playlist cleanups (generalized code for playlist loading/saving
mf0102
parents:
2507
diff
changeset
|
902 |
| 2313 | 903 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
| 904 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
| 905 else | |
| 906 filename = NULL; | |
| 907 | |
|
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2508
diff
changeset
|
908 gtk_widget_destroy(dialog); |
| 2313 | 909 return filename; |
| 910 } | |
| 911 | |
| 912 void | |
| 913 playlistwin_select_playlist_to_load(const gchar * default_filename) | |
| 914 { | |
| 915 gchar *filename = | |
| 916 playlist_file_selection_load(_("Load Playlist"), default_filename); | |
| 917 | |
| 918 if (filename) { | |
| 919 playlistwin_load_playlist(filename); | |
| 920 g_free(filename); | |
| 921 } | |
| 922 } | |
| 923 | |
| 924 static void | |
| 925 playlistwin_select_playlist_to_save(const gchar * default_filename) | |
| 926 { | |
| 927 gchar *dot = NULL, *basename = NULL; | |
| 928 gchar *filename = | |
| 929 playlist_file_selection_save(_("Save Playlist"), default_filename); | |
| 930 | |
| 931 if (filename) { | |
| 932 /* Default to xspf if no filename has extension */ | |
| 933 basename = g_path_get_basename(filename); | |
| 934 dot = strrchr(basename, '.'); | |
| 935 if( dot == NULL || dot == basename) { | |
| 936 gchar *oldname = filename; | |
| 937 filename = g_strconcat(oldname, ".xspf", NULL); | |
| 938 g_free(oldname); | |
| 939 } | |
| 940 g_free(basename); | |
| 941 | |
| 942 playlistwin_save_playlist(filename); | |
| 943 g_free(filename); | |
| 944 } | |
| 945 } | |
| 946 | |
| 947 #define REGION_L(x1,x2,y1,y2) \ | |
| 948 (event->x >= (x1) && event->x < (x2) && \ | |
| 949 event->y >= cfg.playlist_height - (y1) && \ | |
| 950 event->y < cfg.playlist_height - (y2)) | |
| 951 | |
| 952 #define REGION_R(x1,x2,y1,y2) \ | |
| 953 (event->x >= playlistwin_get_width() - (x1) && \ | |
| 954 event->x < playlistwin_get_width() - (x2) && \ | |
| 955 event->y >= cfg.playlist_height - (y1) && \ | |
| 956 event->y < cfg.playlist_height - (y2)) | |
| 957 | |
| 958 static void | |
| 959 playlistwin_scrolled(GtkWidget * widget, | |
| 960 GdkEventScroll * event, | |
| 961 gpointer callback_data) | |
| 962 { | |
| 963 | |
| 964 if (event->direction == GDK_SCROLL_DOWN) | |
| 965 playlistwin_scroll(cfg.scroll_pl_by); | |
| 966 | |
| 967 if (event->direction == GDK_SCROLL_UP) | |
| 968 playlistwin_scroll(-cfg.scroll_pl_by); | |
| 969 | |
| 970 g_cond_signal(cond_scan); | |
| 971 | |
| 972 } | |
| 973 | |
| 974 static gboolean | |
| 975 playlistwin_press(GtkWidget * widget, | |
| 976 GdkEventButton * event, | |
| 977 gpointer callback_data) | |
| 978 { | |
| 979 gboolean grab = TRUE; | |
| 980 gint xpos, ypos; | |
| 981 GtkRequisition req; | |
| 982 | |
| 983 gtk_window_get_position(GTK_WINDOW(playlistwin), &xpos, &ypos); | |
| 984 | |
| 985 if (event->button == 1 && !cfg.show_wm_decorations && | |
| 986 ((!cfg.playlist_shaded && | |
| 987 event->x > playlistwin_get_width() - 20 && | |
| 988 event->y > cfg.playlist_height - 20) || | |
| 989 (cfg.playlist_shaded && | |
| 990 event->x >= playlistwin_get_width() - 31 && | |
| 991 event->x < playlistwin_get_width() - 22))) { | |
| 992 | |
| 993 if (event->type != GDK_2BUTTON_PRESS && | |
| 994 event->type != GDK_3BUTTON_PRESS) { | |
| 995 playlistwin_resizing = TRUE; | |
|
2492
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
996 playlistwin_resize_x = cfg.playlist_width - event->x; |
|
ea80fe9c3ba4
[svn] - use ConfigureNotify to set playlist location, a proper use of ICCCM.
nenolod
parents:
2491
diff
changeset
|
997 playlistwin_resize_y = cfg.playlist_height - event->y; |
| 2313 | 998 } |
| 999 } | |
| 1000 else if (event->button == 1 && REGION_L(12, 37, 29, 11)) { | |
| 1001 /* ADD button menu */ | |
| 1002 gtk_widget_size_request(playlistwin_pladd_menu, &req); | |
| 1003 ui_manager_popup_menu_show(GTK_MENU(playlistwin_pladd_menu), | |
| 1004 xpos + 12, | |
| 1005 (ypos + playlistwin_get_height()) - 8 - req.height, | |
| 1006 event->button, | |
| 1007 event->time); | |
| 1008 grab = FALSE; | |
| 1009 } | |
| 1010 else if (event->button == 1 && REGION_L(41, 66, 29, 11)) { | |
| 1011 /* SUB button menu */ | |
| 1012 gtk_widget_size_request(playlistwin_pldel_menu, &req); | |
| 1013 ui_manager_popup_menu_show(GTK_MENU(playlistwin_pldel_menu), | |
| 1014 xpos + 40, | |
| 1015 (ypos + playlistwin_get_height()) - 8 - req.height, | |
| 1016 event->button, | |
| 1017 event->time); | |
| 1018 grab = FALSE; | |
| 1019 } | |
| 1020 else if (event->button == 1 && REGION_L(70, 95, 29, 11)) { | |
| 1021 /* SEL button menu */ | |
| 1022 gtk_widget_size_request(playlistwin_plsel_menu, &req); | |
| 1023 ui_manager_popup_menu_show(GTK_MENU(playlistwin_plsel_menu), | |
| 1024 xpos + 68, | |
| 1025 (ypos + playlistwin_get_height()) - 8 - req.height, | |
| 1026 event->button, | |
| 1027 event->time); | |
| 1028 grab = FALSE; | |
| 1029 } | |
| 1030 else if (event->button == 1 && REGION_L(99, 124, 29, 11)) { | |
| 1031 /* MISC button menu */ | |
| 1032 gtk_widget_size_request(playlistwin_plsort_menu, &req); | |
| 1033 ui_manager_popup_menu_show(GTK_MENU(playlistwin_plsort_menu), | |
| 1034 xpos + 100, | |
| 1035 (ypos + playlistwin_get_height()) - 8 - req.height, | |
| 1036 event->button, | |
| 1037 event->time); | |
| 1038 grab = FALSE; | |
| 1039 } | |
| 1040 else if (event->button == 1 && REGION_R(46, 23, 29, 11)) { | |
| 1041 /* LIST button menu */ | |
| 1042 gtk_widget_size_request(playlistwin_pllist_menu, &req); | |
| 1043 ui_manager_popup_menu_show(GTK_MENU(playlistwin_pllist_menu), | |
| 1044 xpos + playlistwin_get_width() - req.width - 12, | |
| 1045 (ypos + playlistwin_get_height()) - 8 - req.height, | |
| 1046 event->button, | |
| 1047 event->time); | |
| 1048 grab = FALSE; | |
| 1049 } | |
| 1050 else if (event->button == 1 && REGION_R(82, 54, 15, 9)) { | |
| 1051 if (cfg.timer_mode == TIMER_ELAPSED) | |
| 1052 cfg.timer_mode = TIMER_REMAINING; | |
| 1053 else | |
| 1054 cfg.timer_mode = TIMER_ELAPSED; | |
| 1055 } | |
| 1056 else if (event->button == 2 && (event->type == GDK_BUTTON_PRESS) && | |
| 1057 widget_contains(WIDGET(playlistwin_list), event->x, event->y)) { | |
| 1058 gtk_selection_convert(widget, GDK_SELECTION_PRIMARY, | |
| 1059 GDK_TARGET_STRING, event->time); | |
| 1060 } | |
| 1061 else if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1062 !ui_skinned_window_widgetlist_contained(playlistwin, event->x, |
|
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1063 event->y) && (cfg.easy_move || event->y < 14)) |
| 2313 | 1064 { |
| 1065 dock_move_press(dock_window_list, GTK_WINDOW(playlistwin), event, | |
| 1066 FALSE); | |
| 1067 gtk_window_present(GTK_WINDOW(playlistwin)); | |
| 1068 } | |
| 1069 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1070 !ui_skinned_window_widgetlist_contained(playlistwin, event->x, event->y) |
| 2313 | 1071 && event->y < 14) { |
| 1072 /* double click on title bar */ | |
| 1073 playlistwin_shade_toggle(); | |
| 1074 if (dock_is_moving(GTK_WINDOW(playlistwin))) | |
| 1075 dock_move_release(GTK_WINDOW(playlistwin)); | |
| 1076 return TRUE; | |
| 1077 } | |
| 1078 else if (event->button == 3 && | |
| 1079 !(widget_contains(WIDGET(playlistwin_list), event->x, event->y) || | |
| 1080 (event->y >= cfg.playlist_height - 29 && | |
| 1081 event->y < cfg.playlist_height - 11 && | |
| 1082 ((event->x >= 12 && event->x < 37) || | |
| 1083 (event->x >= 41 && event->x < 66) || | |
| 1084 (event->x >= 70 && event->x < 95) || | |
| 1085 (event->x >= 99 && event->x < 124) || | |
| 1086 (event->x >= playlistwin_get_width() - 46 && | |
| 1087 event->x < playlistwin_get_width() - 23))))) { | |
| 1088 /* | |
| 1089 * Pop up the main menu a few pixels down to avoid | |
| 1090 * anything to be selected initially. | |
| 1091 */ | |
| 1092 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), event->x_root, | |
| 1093 event->y_root + 2, 3, event->time); | |
| 1094 grab = FALSE; | |
| 1095 } | |
| 1096 else if (event->button == 3 && | |
| 1097 widget_contains(WIDGET(playlistwin_list), event->x, event->y)) { | |
|
2356
4b2c7d9523e7
[svn] right-clicking on playlist entry automatically selects the entry if it was unselected before, closes #728
mf0102
parents:
2351
diff
changeset
|
1098 handle_press_cb(playlistwin_wlist, widget, event); |
| 2313 | 1099 ui_manager_popup_menu_show(GTK_MENU(playlistwin_popup_menu), |
| 1100 event->x_root, event->y_root + 5, | |
| 1101 event->button, event->time); | |
| 1102 grab = FALSE; | |
| 1103 } | |
| 1104 else { | |
| 1105 handle_press_cb(playlistwin_wlist, widget, event); | |
| 1106 draw_playlist_window(FALSE); | |
| 1107 } | |
| 1108 | |
| 1109 if (grab) | |
| 1110 gdk_pointer_grab(playlistwin->window, FALSE, | |
| 1111 GDK_BUTTON_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | | |
| 1112 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
| 1113 GDK_BUTTON1_MOTION_MASK, NULL, NULL, | |
| 1114 GDK_CURRENT_TIME); | |
| 1115 | |
| 1116 return FALSE; | |
| 1117 } | |
| 1118 | |
| 1119 static gboolean | |
| 1120 playlistwin_focus_in(GtkWidget * widget, GdkEvent * event, gpointer data) | |
| 1121 { | |
| 1122 playlistwin_close->pb_allow_draw = TRUE; | |
| 1123 playlistwin_shade->pb_allow_draw = TRUE; | |
| 1124 draw_playlist_window(TRUE); | |
| 1125 return FALSE; | |
| 1126 } | |
| 1127 | |
| 1128 static gboolean | |
| 1129 playlistwin_focus_out(GtkWidget * widget, | |
| 1130 GdkEventButton * event, gpointer data) | |
| 1131 { | |
| 1132 playlistwin_close->pb_allow_draw = FALSE; | |
| 1133 playlistwin_shade->pb_allow_draw = FALSE; | |
| 1134 draw_playlist_window(TRUE); | |
| 1135 return FALSE; | |
| 1136 } | |
| 1137 | |
| 1138 void | |
| 1139 playlistwin_set_back_pixmap(void) | |
| 1140 { | |
| 1141 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
| 1142 gdk_window_clear(playlistwin->window); | |
| 1143 } | |
| 1144 | |
| 1145 static gboolean | |
| 1146 playlistwin_delete(GtkWidget * w, gpointer data) | |
| 1147 { | |
| 1148 playlistwin_hide(); | |
| 1149 return TRUE; | |
| 1150 } | |
| 1151 | |
| 1152 static void | |
| 1153 playlistwin_keypress_up_down_handler(PlayList_List * pl, | |
| 1154 gboolean up, guint state) | |
| 1155 { | |
| 1156 Playlist *playlist = playlist_get_active(); | |
| 1157 | |
| 1158 if ((state & GDK_MOD1_MASK) && (state & GDK_SHIFT_MASK)) | |
| 1159 return; | |
| 1160 if (!(state & GDK_MOD1_MASK)) | |
| 1161 playlist_select_all(playlist, FALSE); | |
| 1162 | |
| 1163 if (pl->pl_prev_selected == -1 || | |
| 1164 (!playlistwin_item_visible(pl->pl_prev_selected) && | |
| 1165 !(state & GDK_SHIFT_MASK && pl->pl_prev_min != -1))) { | |
| 1166 pl->pl_prev_selected = pl->pl_first; | |
| 1167 } | |
| 1168 else if (state & GDK_SHIFT_MASK) { | |
| 1169 if (pl->pl_prev_min == -1) { | |
| 1170 pl->pl_prev_max = pl->pl_prev_selected; | |
| 1171 pl->pl_prev_min = pl->pl_prev_selected; | |
| 1172 } | |
| 1173 pl->pl_prev_max += (up ? -1 : 1); | |
| 1174 pl->pl_prev_max = | |
| 1175 CLAMP(pl->pl_prev_max, 0, playlist_get_length(playlist) - 1); | |
| 1176 | |
| 1177 pl->pl_first = MIN(pl->pl_first, pl->pl_prev_max); | |
| 1178 pl->pl_first = MAX(pl->pl_first, pl->pl_prev_max - | |
| 1179 pl->pl_num_visible + 1); | |
| 1180 playlist_select_range(playlist, pl->pl_prev_min, pl->pl_prev_max, TRUE); | |
| 1181 return; | |
| 1182 } | |
| 1183 else if (state & GDK_MOD1_MASK) { | |
| 1184 if (up) | |
| 1185 playlist_list_move_up(pl); | |
| 1186 else | |
| 1187 playlist_list_move_down(pl); | |
| 1188 if (pl->pl_prev_min < pl->pl_first) | |
| 1189 pl->pl_first = pl->pl_prev_min; | |
| 1190 else if (pl->pl_prev_max >= (pl->pl_first + pl->pl_num_visible)) | |
| 1191 pl->pl_first = pl->pl_prev_max - pl->pl_num_visible + 1; | |
| 1192 return; | |
| 1193 } | |
| 1194 else if (up) | |
| 1195 pl->pl_prev_selected--; | |
| 1196 else | |
| 1197 pl->pl_prev_selected++; | |
| 1198 | |
| 1199 pl->pl_prev_selected = | |
| 1200 CLAMP(pl->pl_prev_selected, 0, playlist_get_length(playlist) - 1); | |
| 1201 | |
| 1202 if (pl->pl_prev_selected < pl->pl_first) | |
| 1203 pl->pl_first--; | |
| 1204 else if (pl->pl_prev_selected >= (pl->pl_first + pl->pl_num_visible)) | |
| 1205 pl->pl_first++; | |
| 1206 | |
| 1207 playlist_select_range(playlist, pl->pl_prev_selected, pl->pl_prev_selected, TRUE); | |
| 1208 pl->pl_prev_min = -1; | |
| 1209 } | |
| 1210 | |
| 1211 /* FIXME: Handle the keys through menu */ | |
| 1212 | |
| 1213 static gboolean | |
| 1214 playlistwin_keypress(GtkWidget * w, GdkEventKey * event, gpointer data) | |
| 1215 { | |
| 1216 Playlist *playlist = playlist_get_active(); | |
| 1217 | |
| 1218 guint keyval; | |
| 1219 gboolean refresh = FALSE; | |
| 1220 | |
| 1221 if (cfg.playlist_shaded) | |
| 1222 return FALSE; | |
| 1223 | |
| 1224 switch (keyval = event->keyval) { | |
| 1225 case GDK_KP_Up: | |
| 1226 case GDK_KP_Down: | |
| 1227 case GDK_Up: | |
| 1228 case GDK_Down: | |
| 1229 playlistwin_keypress_up_down_handler(playlistwin_list, | |
| 1230 keyval == GDK_Up | |
| 1231 || keyval == GDK_KP_Up, | |
| 1232 event->state); | |
| 1233 refresh = TRUE; | |
| 1234 break; | |
| 1235 case GDK_Page_Up: | |
| 1236 playlistwin_scroll(-playlistwin_list->pl_num_visible); | |
| 1237 refresh = TRUE; | |
| 1238 break; | |
| 1239 case GDK_Page_Down: | |
| 1240 playlistwin_scroll(playlistwin_list->pl_num_visible); | |
| 1241 refresh = TRUE; | |
| 1242 break; | |
| 1243 case GDK_Home: | |
| 1244 playlistwin_list->pl_first = 0; | |
| 1245 refresh = TRUE; | |
| 1246 break; | |
| 1247 case GDK_End: | |
| 1248 playlistwin_list->pl_first = | |
| 1249 playlist_get_length(playlist) - playlistwin_list->pl_num_visible; | |
| 1250 refresh = TRUE; | |
| 1251 break; | |
| 1252 case GDK_Return: | |
| 1253 if (playlistwin_list->pl_prev_selected > -1 | |
| 1254 && playlistwin_item_visible(playlistwin_list->pl_prev_selected)) { | |
| 1255 playlist_set_position(playlist, playlistwin_list->pl_prev_selected); | |
| 1256 if (!playback_get_playing()) | |
| 1257 playback_initiate(); | |
| 1258 } | |
| 1259 break; | |
| 1260 case GDK_3: | |
| 1261 if (event->state & GDK_CONTROL_MASK) | |
| 1262 playlistwin_fileinfo(); | |
| 1263 break; | |
| 1264 case GDK_Delete: | |
| 1265 if (event->state & GDK_CONTROL_MASK) | |
| 1266 playlist_delete(playlist, TRUE); | |
| 1267 else | |
| 1268 playlist_delete(playlist, FALSE); | |
| 1269 break; | |
| 1270 case GDK_Insert: | |
| 1271 if (event->state & GDK_MOD1_MASK) | |
| 1272 mainwin_show_add_url_window(); | |
| 1273 else | |
| 1274 playlistwin_show_filebrowser(); | |
| 1275 break; | |
| 1276 case GDK_Left: | |
| 1277 case GDK_KP_Left: | |
| 1278 case GDK_KP_7: | |
| 1279 if (playlist_get_current_length(playlist) != -1) | |
| 1280 playback_seek(CLAMP | |
| 1281 (playback_get_time() - 5000, 0, | |
| 1282 playlist_get_current_length(playlist)) / 1000); | |
| 1283 break; | |
| 1284 case GDK_Right: | |
| 1285 case GDK_KP_Right: | |
| 1286 case GDK_KP_9: | |
| 1287 if (playlist_get_current_length(playlist) != -1) | |
| 1288 playback_seek(CLAMP | |
| 1289 (playback_get_time() + 5000, 0, | |
| 1290 playlist_get_current_length(playlist)) / 1000); | |
| 1291 break; | |
| 1292 case GDK_KP_4: | |
| 1293 playlist_prev(playlist); | |
| 1294 break; | |
| 1295 case GDK_KP_6: | |
| 1296 playlist_next(playlist); | |
| 1297 break; | |
| 1298 | |
| 1299 case GDK_Escape: | |
| 1300 mainwin_minimize_cb(); | |
| 1301 break; | |
| 1302 default: | |
| 1303 return FALSE; | |
| 1304 } | |
| 1305 | |
| 1306 if (refresh) { | |
| 1307 g_cond_signal(cond_scan); | |
| 1308 playlistwin_update_list(playlist_get_active()); | |
| 1309 } | |
| 1310 | |
| 1311 return TRUE; | |
| 1312 } | |
| 1313 | |
| 1314 static void | |
| 1315 playlistwin_draw_frame(void) | |
| 1316 { | |
| 1317 gboolean focus = | |
| 1318 gtk_window_has_toplevel_focus(GTK_WINDOW(playlistwin)) || | |
| 1319 !cfg.dim_titlebar; | |
| 1320 | |
| 1321 if (cfg.playlist_shaded) { | |
| 1322 skin_draw_playlistwin_shaded(bmp_active_skin, | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1323 playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1324 playlistwin_get_width(), focus); |
| 1325 } | |
| 1326 else { | |
| 1327 skin_draw_playlistwin_frame(bmp_active_skin, | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1328 playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1329 playlistwin_get_width(), |
| 1330 cfg.playlist_height, focus); | |
| 1331 } | |
| 1332 } | |
| 1333 | |
| 1334 void | |
| 1335 draw_playlist_window(gboolean force) | |
| 1336 { | |
| 1337 gboolean redraw; | |
| 1338 GList *wl; | |
| 1339 Widget *w; | |
| 1340 | |
| 1341 if (force) | |
| 1342 playlistwin_draw_frame(); | |
| 1343 | |
| 1344 widget_list_lock(playlistwin_wlist); | |
| 1345 widget_list_draw(playlistwin_wlist, &redraw, force); | |
| 1346 | |
| 1347 if (redraw || force) { | |
| 1348 if (force) { | |
| 1349 gdk_window_clear(playlistwin->window); | |
| 1350 } | |
| 1351 else { | |
| 1352 for (wl = playlistwin_wlist; wl; wl = g_list_next(wl)) { | |
| 1353 w = WIDGET(wl->data); | |
| 1354 if (w->redraw && w->visible) { | |
| 1355 gdk_window_clear_area(playlistwin->window, w->x, w->y, | |
| 1356 w->width, w->height); | |
| 1357 w->redraw = FALSE; | |
| 1358 } | |
| 1359 } | |
| 1360 } | |
| 1361 | |
| 1362 gdk_flush(); | |
| 1363 } | |
| 1364 | |
| 1365 widget_list_unlock(playlistwin_wlist); | |
| 1366 } | |
| 1367 | |
| 1368 | |
| 1369 void | |
| 1370 playlistwin_hide_timer(void) | |
| 1371 { | |
| 1372 textbox_set_text(playlistwin_time_min, " "); | |
| 1373 textbox_set_text(playlistwin_time_sec, " "); | |
| 1374 } | |
| 1375 | |
| 1376 void | |
| 1377 playlistwin_set_time(gint time, gint length, TimerMode mode) | |
| 1378 { | |
| 1379 gchar *text, sign; | |
| 1380 | |
| 1381 if (mode == TIMER_REMAINING && length != -1) { | |
| 1382 time = length - time; | |
| 1383 sign = '-'; | |
| 1384 } | |
| 1385 else | |
| 1386 sign = ' '; | |
| 1387 | |
| 1388 time /= 1000; | |
| 1389 | |
| 1390 if (time < 0) | |
| 1391 time = 0; | |
| 1392 if (time > 99 * 60) | |
| 1393 time /= 60; | |
| 1394 | |
| 1395 text = g_strdup_printf("%c%-2.2d", sign, time / 60); | |
| 1396 textbox_set_text(playlistwin_time_min, text); | |
| 1397 g_free(text); | |
| 1398 | |
| 1399 text = g_strdup_printf("%-2.2d", time % 60); | |
| 1400 textbox_set_text(playlistwin_time_sec, text); | |
| 1401 g_free(text); | |
| 1402 } | |
| 1403 | |
| 1404 static void | |
| 1405 playlistwin_drag_motion(GtkWidget * widget, | |
| 1406 GdkDragContext * context, | |
| 1407 gint x, gint y, | |
| 1408 GtkSelectionData * selection_data, | |
| 1409 guint info, guint time, gpointer user_data) | |
| 1410 { | |
| 1411 playlistwin_list->pl_drag_motion = TRUE; | |
| 1412 playlistwin_list->drag_motion_x = x; | |
| 1413 playlistwin_list->drag_motion_y = y; | |
| 1414 playlistwin_update_list(playlist_get_active()); | |
| 1415 playlistwin_hint_flag = TRUE; | |
| 1416 } | |
| 1417 | |
| 1418 static void | |
| 1419 playlistwin_drag_end(GtkWidget * widget, | |
| 1420 GdkDragContext * context, gpointer user_data) | |
| 1421 { | |
| 1422 playlistwin_list->pl_drag_motion = FALSE; | |
| 1423 playlistwin_hint_flag = FALSE; | |
| 1424 playlistwin_update_list(playlist_get_active()); | |
| 1425 } | |
| 1426 | |
| 1427 static void | |
| 1428 playlistwin_drag_data_received(GtkWidget * widget, | |
| 1429 GdkDragContext * context, | |
| 1430 gint x, gint y, | |
| 1431 GtkSelectionData * | |
| 1432 selection_data, guint info, | |
| 1433 guint time, gpointer user_data) | |
| 1434 { | |
| 1435 gint pos; | |
| 1436 Playlist *playlist = playlist_get_active(); | |
| 1437 | |
| 2363 | 1438 g_return_if_fail(selection_data); |
| 2313 | 1439 |
| 1440 if (!selection_data->data) { | |
| 1441 g_message("Received no DND data!"); | |
| 1442 return; | |
| 1443 } | |
| 1444 | |
| 1445 if (widget_contains(WIDGET(playlistwin_list), x, y)) { | |
| 1446 pos = (y - WIDGET(playlistwin_list)->y) / | |
| 1447 playlistwin_list->pl_fheight + playlistwin_list->pl_first; | |
| 1448 | |
| 1449 pos = MIN(pos, playlist_get_length(playlist)); | |
| 1450 playlist_ins_url(playlist, (gchar *) selection_data->data, pos); | |
| 1451 } | |
| 1452 else | |
| 1453 playlist_add_url(playlist, (gchar *) selection_data->data); | |
| 1454 } | |
| 1455 | |
| 1456 static void | |
| 1457 local_playlist_prev(void) | |
| 1458 { | |
| 1459 playlist_prev(playlist_get_active()); | |
| 1460 } | |
| 1461 | |
| 1462 static void | |
| 1463 local_playlist_next(void) | |
| 1464 { | |
| 1465 playlist_next(playlist_get_active()); | |
| 1466 } | |
| 1467 | |
| 1468 static void | |
| 1469 playlistwin_create_widgets(void) | |
| 1470 { | |
| 1471 /* This function creates the custom widgets used by the playlist editor */ | |
| 1472 | |
| 1473 /* text box for displaying song title in shaded mode */ | |
| 1474 playlistwin_sinfo = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1475 create_textbox(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1476 4, 4, playlistwin_get_width() - 35, TRUE, SKIN_TEXT); |
| 1477 | |
| 1478 playlistwin_set_sinfo_font(cfg.playlist_font); | |
| 1479 | |
| 1480 if (!cfg.playlist_shaded) | |
| 1481 widget_hide(WIDGET(playlistwin_sinfo)); | |
| 1482 | |
| 1483 /* shade/unshade window push button */ | |
| 1484 if (cfg.playlist_shaded) | |
| 1485 playlistwin_shade = | |
| 1486 create_pbutton(&playlistwin_wlist, playlistwin_bg, | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1487 SKINNED_WINDOW(playlistwin)->gc, playlistwin_get_width() - 21, 3, |
| 2313 | 1488 9, 9, 128, 45, 150, 42, |
| 1489 playlistwin_shade_toggle, SKIN_PLEDIT); | |
| 1490 else | |
| 1491 playlistwin_shade = | |
| 1492 create_pbutton(&playlistwin_wlist, playlistwin_bg, | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1493 SKINNED_WINDOW(playlistwin)->gc, playlistwin_get_width() - 21, 3, |
| 2313 | 1494 9, 9, 157, 3, 62, 42, playlistwin_shade_toggle, |
| 1495 SKIN_PLEDIT); | |
| 1496 | |
| 1497 playlistwin_shade->pb_allow_draw = FALSE; | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1498 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_shade)); |
| 2313 | 1499 |
| 1500 /* close window push button */ | |
| 1501 playlistwin_close = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1502 create_pbutton(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1503 playlistwin_get_width() - 11, 3, 9, 9, |
| 1504 cfg.playlist_shaded ? 138 : 167, | |
| 1505 cfg.playlist_shaded ? 45 : 3, 52, 42, | |
| 1506 playlistwin_hide, SKIN_PLEDIT); | |
| 1507 playlistwin_close->pb_allow_draw = FALSE; | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1508 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_close)); |
| 2313 | 1509 |
| 1510 /* playlist list box */ | |
| 1511 playlistwin_list = | |
| 1512 create_playlist_list(&playlistwin_wlist, playlistwin_bg, | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1513 SKINNED_WINDOW(playlistwin)->gc, 12, 20, |
| 2313 | 1514 playlistwin_get_width() - 31, |
| 1515 cfg.playlist_height - 58); | |
| 1516 playlist_list_set_font(cfg.playlist_font); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1517 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_list)); |
| 2313 | 1518 |
| 1519 /* playlist list box slider */ | |
| 1520 playlistwin_slider = | |
| 1521 create_playlistslider(&playlistwin_wlist, playlistwin_bg, | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1522 SKINNED_WINDOW(playlistwin)->gc, playlistwin_get_width() - 15, |
| 2313 | 1523 20, cfg.playlist_height - 58, playlistwin_list); |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1524 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_slider)); |
|
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1525 |
| 2313 | 1526 /* track time (minute) */ |
| 1527 playlistwin_time_min = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1528 create_textbox(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1529 playlistwin_get_width() - 82, |
| 1530 cfg.playlist_height - 15, 15, FALSE, SKIN_TEXT); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1531 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_time_min)); |
| 2313 | 1532 |
| 1533 /* track time (second) */ | |
| 1534 playlistwin_time_sec = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1535 create_textbox(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1536 playlistwin_get_width() - 64, |
| 1537 cfg.playlist_height - 15, 10, FALSE, SKIN_TEXT); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1538 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_time_sec)); |
| 2313 | 1539 |
| 1540 /* playlist information (current track length / total track length) */ | |
| 1541 playlistwin_info = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1542 create_textbox(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1543 playlistwin_get_width() - 143, |
| 1544 cfg.playlist_height - 28, 90, FALSE, SKIN_TEXT); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1545 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_info)); |
| 2313 | 1546 |
| 1547 /* mini play control buttons at right bottom corner */ | |
| 1548 | |
| 1549 /* rewind button */ | |
| 1550 playlistwin_srew = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1551 create_sbutton(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1552 playlistwin_get_width() - 144, |
| 1553 cfg.playlist_height - 16, 8, 7, local_playlist_prev); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1554 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_srew)); |
| 2313 | 1555 |
| 1556 /* play button */ | |
| 1557 playlistwin_splay = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1558 create_sbutton(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1559 playlistwin_get_width() - 138, |
| 1560 cfg.playlist_height - 16, 10, 7, mainwin_play_pushed); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1561 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_splay)); |
| 2313 | 1562 |
| 1563 /* pause button */ | |
| 1564 playlistwin_spause = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1565 create_sbutton(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1566 playlistwin_get_width() - 128, |
| 1567 cfg.playlist_height - 16, 10, 7, playback_pause); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1568 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_spause)); |
| 2313 | 1569 |
| 1570 /* stop button */ | |
| 1571 playlistwin_sstop = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1572 create_sbutton(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1573 playlistwin_get_width() - 118, |
| 1574 cfg.playlist_height - 16, 9, 7, mainwin_stop_pushed); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1575 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_sstop)); |
| 2313 | 1576 |
| 1577 /* forward button */ | |
| 1578 playlistwin_sfwd = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1579 create_sbutton(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1580 playlistwin_get_width() - 109, |
| 1581 cfg.playlist_height - 16, 8, 7, local_playlist_next); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1582 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_sfwd)); |
| 2313 | 1583 |
| 1584 /* eject button */ | |
| 1585 playlistwin_seject = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1586 create_sbutton(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1587 playlistwin_get_width() - 100, |
| 1588 cfg.playlist_height - 16, 9, 7, mainwin_eject_pushed); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1589 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_seject)); |
| 2313 | 1590 |
| 1591 playlistwin_sscroll_up = | |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1592 create_sbutton(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1593 playlistwin_get_width() - 14, |
| 1594 cfg.playlist_height - 35, 8, 5, | |
| 1595 playlistwin_scroll_up_pushed); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1596 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_sscroll_up)); |
|
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1597 |
| 2313 | 1598 playlistwin_sscroll_down = |
|
2527
05c841971f9f
[svn] - playlist editor: use SkinnedWindow provided GC.
nenolod
parents:
2515
diff
changeset
|
1599 create_sbutton(&playlistwin_wlist, playlistwin_bg, SKINNED_WINDOW(playlistwin)->gc, |
| 2313 | 1600 playlistwin_get_width() - 14, |
| 1601 cfg.playlist_height - 30, 8, 5, | |
| 1602 playlistwin_scroll_down_pushed); | |
|
2528
60f2787cc7fd
[svn] - playlist editor: use SkinnedWindow widgetlist
nenolod
parents:
2527
diff
changeset
|
1603 ui_skinned_window_widgetlist_associate(playlistwin, WIDGET(playlistwin_sscroll_down)); |
| 2313 | 1604 } |
| 1605 | |
| 1606 static void | |
| 1607 selection_received(GtkWidget * widget, | |
| 1608 GtkSelectionData * selection_data, gpointer data) | |
| 1609 { | |
| 1610 if (selection_data->type == GDK_SELECTION_TYPE_STRING && | |
| 1611 selection_data->length > 0) | |
| 1612 playlist_add_url(playlist_get_active(), (gchar *) selection_data->data); | |
| 1613 } | |
| 1614 | |
| 1615 static void | |
| 1616 playlistwin_create_window(void) | |
| 1617 { | |
| 1618 GdkPixbuf *icon; | |
| 1619 | |
|
2515
319b10203d7c
[svn] gtk_window_set_wmclass() has to be called before gtk_widget_realize(). Patched by Christian "Joker" Birchinger from Gentoo.
chainsaw
parents:
2514
diff
changeset
|
1620 playlistwin = ui_skinned_window_new(GTK_WINDOW_TOPLEVEL, "playlist"); |
| 2313 | 1621 gtk_window_set_title(GTK_WINDOW(playlistwin), _("Audacious Playlist Editor")); |
| 1622 gtk_window_set_role(GTK_WINDOW(playlistwin), "playlist"); | |
| 1623 gtk_window_set_default_size(GTK_WINDOW(playlistwin), | |
| 1624 playlistwin_get_width(), | |
| 1625 playlistwin_get_height()); | |
| 1626 gtk_window_set_resizable(GTK_WINDOW(playlistwin), TRUE); | |
| 1627 playlistwin_set_geometry_hints(cfg.playlist_shaded); | |
| 1628 | |
| 1629 gtk_window_set_transient_for(GTK_WINDOW(playlistwin), | |
| 1630 GTK_WINDOW(mainwin)); | |
| 1631 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(playlistwin), TRUE); | |
| 1632 | |
| 1633 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) bmp_playlist_icon); | |
| 1634 gtk_window_set_icon(GTK_WINDOW(playlistwin), icon); | |
| 1635 g_object_unref(icon); | |
| 1636 | |
| 1637 gtk_widget_set_app_paintable(playlistwin, TRUE); | |
| 1638 | |
| 1639 if (cfg.playlist_x != -1 && cfg.save_window_position) | |
| 1640 gtk_window_move(GTK_WINDOW(playlistwin), | |
| 1641 cfg.playlist_x, cfg.playlist_y); | |
| 1642 | |
| 1643 gtk_widget_add_events(playlistwin, GDK_POINTER_MOTION_MASK | | |
| 1644 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
| 1645 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
| 1646 GDK_SCROLL_MASK | GDK_VISIBILITY_NOTIFY_MASK); | |
| 1647 gtk_widget_realize(playlistwin); | |
| 1648 | |
| 1649 g_signal_connect(playlistwin, "delete_event", | |
| 1650 G_CALLBACK(playlistwin_delete), NULL); | |
| 1651 g_signal_connect(playlistwin, "button_press_event", | |
| 1652 G_CALLBACK(playlistwin_press), NULL); | |
| 1653 g_signal_connect(playlistwin, "button_release_event", | |
| 1654 G_CALLBACK(playlistwin_release), NULL); | |
| 1655 g_signal_connect(playlistwin, "scroll_event", | |
| 1656 G_CALLBACK(playlistwin_scrolled), NULL); | |
| 1657 g_signal_connect(playlistwin, "motion_notify_event", | |
| 1658 G_CALLBACK(playlistwin_motion), NULL); | |
| 1659 g_signal_connect(playlistwin, "enter_notify_event", | |
| 1660 G_CALLBACK(playlistwin_enter), NULL); | |
| 1661 g_signal_connect(playlistwin, "leave_notify_event", | |
| 1662 G_CALLBACK(playlistwin_leave), NULL); | |
| 1663 g_signal_connect_after(playlistwin, "focus_in_event", | |
| 1664 G_CALLBACK(playlistwin_focus_in), NULL); | |
| 1665 g_signal_connect_after(playlistwin, "focus_out_event", | |
| 1666 G_CALLBACK(playlistwin_focus_out), NULL); | |
| 1667 g_signal_connect(playlistwin, "style_set", | |
| 1668 G_CALLBACK(playlistwin_set_back_pixmap), NULL); | |
| 1669 | |
| 1670 bmp_drag_dest_set(playlistwin); | |
| 1671 | |
| 1672 /* DnD stuff */ | |
| 1673 g_signal_connect(playlistwin, "drag-leave", | |
| 1674 G_CALLBACK(playlistwin_drag_end), NULL); | |
| 1675 g_signal_connect(playlistwin, "drag-data-delete", | |
| 1676 G_CALLBACK(playlistwin_drag_end), NULL); | |
| 1677 g_signal_connect(playlistwin, "drag-end", | |
| 1678 G_CALLBACK(playlistwin_drag_end), NULL); | |
| 1679 g_signal_connect(playlistwin, "drag-drop", | |
| 1680 G_CALLBACK(playlistwin_drag_end), NULL); | |
| 1681 g_signal_connect(playlistwin, "drag-data-received", | |
| 1682 G_CALLBACK(playlistwin_drag_data_received), NULL); | |
| 1683 g_signal_connect(playlistwin, "drag-motion", | |
| 1684 G_CALLBACK(playlistwin_drag_motion), NULL); | |
| 1685 | |
| 1686 g_signal_connect(playlistwin, "key_press_event", | |
| 1687 G_CALLBACK(playlistwin_keypress), NULL); | |
| 1688 g_signal_connect(playlistwin, "selection_received", | |
| 1689 G_CALLBACK(selection_received), NULL); | |
| 1690 | |
| 1691 playlistwin_set_mask(); | |
| 1692 } | |
| 1693 | |
| 1694 void | |
| 1695 playlistwin_create(void) | |
| 1696 { | |
| 1697 playlistwin_create_window(); | |
| 1698 | |
| 1699 /* create GC and back pixmap for custom widget to draw on */ | |
| 1700 playlistwin_bg = gdk_pixmap_new(playlistwin->window, | |
| 1701 playlistwin_get_width(), | |
| 1702 playlistwin_get_height_unshaded(), -1); | |
| 1703 gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0); | |
| 1704 | |
| 1705 playlistwin_create_widgets(); | |
| 1706 playlistwin_update_info(playlist_get_active()); | |
| 1707 | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
1708 playlistwin_infopopup = audacious_fileinfopopup_create(); |
|
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
1709 |
| 2313 | 1710 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), ui_manager_get_accel_group()); |
| 1711 } | |
| 1712 | |
| 1713 | |
| 1714 void | |
| 1715 playlistwin_show(void) | |
| 1716 { | |
| 1717 GtkAction *action = gtk_action_group_get_action( | |
| 1718 toggleaction_group_others , "show playlist editor" ); | |
| 1719 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , TRUE ); | |
| 1720 | |
| 1721 tbutton_set_toggled(mainwin_pl, TRUE); | |
| 1722 cfg.playlist_visible = TRUE; | |
| 1723 | |
| 1724 playlistwin_set_toprow(0); | |
| 1725 playlist_check_pos_current(playlist_get_active()); | |
| 1726 | |
|
2351
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1727 if ( playlistwin_infopopup_sid == 0 ) |
|
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1728 playlistwin_infopopup_sid = g_timeout_add( |
|
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1729 50 , (GSourceFunc)playlistwin_fileinfopopup_probe , playlistwin_infopopup ); |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
1730 |
| 2313 | 1731 gtk_widget_show(playlistwin); |
| 1732 } | |
| 1733 | |
| 1734 void | |
| 1735 playlistwin_hide(void) | |
| 1736 { | |
| 1737 GtkAction *action = gtk_action_group_get_action( | |
| 1738 toggleaction_group_others , "show playlist editor" ); | |
| 1739 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , FALSE ); | |
| 1740 | |
| 1741 gtk_widget_hide(playlistwin); | |
| 1742 tbutton_set_toggled(mainwin_pl, FALSE); | |
| 1743 cfg.playlist_visible = FALSE; | |
| 1744 | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
1745 /* no point in probing for playlistwin_infopopup trigger when the playlistwin is hidden */ |
|
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
1746 if ( playlistwin_infopopup_sid != 0 ) |
|
2351
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1747 { |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
1748 g_source_remove( playlistwin_infopopup_sid ); |
|
2351
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1749 playlistwin_infopopup_sid = 0; |
|
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
1750 } |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
1751 |
|
2338
d0a04f1ee732
[svn] - in playlistwin_hide(), pass focus to the player main window only if it's visible
giacomo
parents:
2328
diff
changeset
|
1752 if ( cfg.player_visible ) |
|
d0a04f1ee732
[svn] - in playlistwin_hide(), pass focus to the player main window only if it's visible
giacomo
parents:
2328
diff
changeset
|
1753 { |
|
d0a04f1ee732
[svn] - in playlistwin_hide(), pass focus to the player main window only if it's visible
giacomo
parents:
2328
diff
changeset
|
1754 gtk_window_present(GTK_WINDOW(mainwin)); |
|
d0a04f1ee732
[svn] - in playlistwin_hide(), pass focus to the player main window only if it's visible
giacomo
parents:
2328
diff
changeset
|
1755 gtk_widget_grab_focus(mainwin); |
|
d0a04f1ee732
[svn] - in playlistwin_hide(), pass focus to the player main window only if it's visible
giacomo
parents:
2328
diff
changeset
|
1756 } |
| 2313 | 1757 } |
| 1758 | |
| 1759 void action_playlist_track_info(void) | |
| 1760 { | |
| 1761 playlistwin_fileinfo(); | |
| 1762 } | |
| 1763 | |
| 1764 void action_queue_toggle(void) | |
| 1765 { | |
| 1766 playlist_queue(playlist_get_active()); | |
| 1767 } | |
| 1768 | |
| 1769 void action_playlist_sort_by_playlist_entry(void) | |
| 1770 { | |
| 1771 Playlist *playlist = playlist_get_active(); | |
| 1772 | |
| 1773 playlist_sort(playlist, PLAYLIST_SORT_PLAYLIST); | |
| 1774 playlistwin_update_list(playlist); | |
| 1775 } | |
| 1776 | |
| 1777 void action_playlist_sort_by_track_number(void) | |
| 1778 { | |
| 1779 Playlist *playlist = playlist_get_active(); | |
| 1780 | |
| 1781 playlist_sort(playlist, PLAYLIST_SORT_TRACK); | |
| 1782 playlistwin_update_list(playlist); | |
| 1783 } | |
| 1784 | |
| 1785 void action_playlist_sort_by_title(void) | |
| 1786 { | |
| 1787 Playlist *playlist = playlist_get_active(); | |
| 1788 | |
| 1789 playlist_sort(playlist, PLAYLIST_SORT_TITLE); | |
| 1790 playlistwin_update_list(playlist); | |
| 1791 } | |
| 1792 | |
| 1793 void action_playlist_sort_by_artist(void) | |
| 1794 { | |
| 1795 Playlist *playlist = playlist_get_active(); | |
| 1796 | |
| 1797 playlist_sort(playlist, PLAYLIST_SORT_ARTIST); | |
| 1798 playlistwin_update_list(playlist); | |
| 1799 } | |
| 1800 | |
| 1801 void action_playlist_sort_by_full_path(void) | |
| 1802 { | |
| 1803 Playlist *playlist = playlist_get_active(); | |
| 1804 | |
| 1805 playlist_sort(playlist, PLAYLIST_SORT_PATH); | |
| 1806 playlistwin_update_list(playlist); | |
| 1807 } | |
| 1808 | |
| 1809 void action_playlist_sort_by_date(void) | |
| 1810 { | |
| 1811 Playlist *playlist = playlist_get_active(); | |
| 1812 | |
| 1813 playlist_sort(playlist, PLAYLIST_SORT_DATE); | |
| 1814 playlistwin_update_list(playlist); | |
| 1815 } | |
| 1816 | |
| 1817 void action_playlist_sort_by_filename(void) | |
| 1818 { | |
| 1819 Playlist *playlist = playlist_get_active(); | |
| 1820 | |
| 1821 playlist_sort(playlist, PLAYLIST_SORT_FILENAME); | |
| 1822 playlistwin_update_list(playlist); | |
| 1823 } | |
| 1824 | |
| 1825 void action_playlist_sort_selected_by_playlist_entry(void) | |
| 1826 { | |
| 1827 Playlist *playlist = playlist_get_active(); | |
| 1828 | |
| 1829 playlist_sort_selected(playlist, PLAYLIST_SORT_PLAYLIST); | |
| 1830 playlistwin_update_list(playlist); | |
| 1831 } | |
| 1832 | |
| 1833 void action_playlist_sort_selected_by_track_number(void) | |
| 1834 { | |
| 1835 Playlist *playlist = playlist_get_active(); | |
| 1836 | |
| 1837 playlist_sort_selected(playlist, PLAYLIST_SORT_TRACK); | |
| 1838 playlistwin_update_list(playlist); | |
| 1839 } | |
| 1840 | |
| 1841 void action_playlist_sort_selected_by_title(void) | |
| 1842 { | |
| 1843 Playlist *playlist = playlist_get_active(); | |
| 1844 | |
| 1845 playlist_sort_selected(playlist, PLAYLIST_SORT_TITLE); | |
| 1846 playlistwin_update_list(playlist); | |
| 1847 } | |
| 1848 | |
| 1849 void action_playlist_sort_selected_by_artist(void) | |
| 1850 { | |
| 1851 Playlist *playlist = playlist_get_active(); | |
| 1852 | |
| 1853 playlist_sort_selected(playlist, PLAYLIST_SORT_ARTIST); | |
| 1854 playlistwin_update_list(playlist); | |
| 1855 } | |
| 1856 | |
| 1857 void action_playlist_sort_selected_by_full_path(void) | |
| 1858 { | |
| 1859 Playlist *playlist = playlist_get_active(); | |
| 1860 | |
| 1861 playlist_sort_selected(playlist, PLAYLIST_SORT_PATH); | |
| 1862 playlistwin_update_list(playlist); | |
| 1863 } | |
| 1864 | |
| 1865 void action_playlist_sort_selected_by_date(void) | |
| 1866 { | |
| 1867 Playlist *playlist = playlist_get_active(); | |
| 1868 | |
| 1869 playlist_sort_selected(playlist, PLAYLIST_SORT_DATE); | |
| 1870 playlistwin_update_list(playlist); | |
| 1871 } | |
| 1872 | |
| 1873 void action_playlist_sort_selected_by_filename(void) | |
| 1874 { | |
| 1875 Playlist *playlist = playlist_get_active(); | |
| 1876 | |
| 1877 playlist_sort_selected(playlist, PLAYLIST_SORT_FILENAME); | |
| 1878 playlistwin_update_list(playlist); | |
| 1879 } | |
| 1880 | |
| 1881 void action_playlist_randomize_list(void) | |
| 1882 { | |
| 1883 Playlist *playlist = playlist_get_active(); | |
| 1884 | |
| 1885 playlist_random(playlist); | |
| 1886 playlistwin_update_list(playlist); | |
| 1887 } | |
| 1888 | |
| 1889 void action_playlist_reverse_list(void) | |
| 1890 { | |
| 1891 Playlist *playlist = playlist_get_active(); | |
| 1892 | |
| 1893 playlist_reverse(playlist); | |
| 1894 playlistwin_update_list(playlist); | |
| 1895 } | |
| 1896 | |
| 1897 void | |
| 1898 action_playlist_clear_queue(void) | |
| 1899 { | |
| 1900 playlist_clear_queue(playlist_get_active()); | |
| 1901 } | |
| 1902 | |
| 1903 void | |
| 1904 action_playlist_remove_unavailable(void) | |
| 1905 { | |
| 1906 playlist_remove_dead_files(playlist_get_active()); | |
| 1907 } | |
| 1908 | |
| 1909 void | |
| 1910 action_playlist_remove_dupes_by_title(void) | |
| 1911 { | |
| 1912 playlist_remove_duplicates(playlist_get_active(), PLAYLIST_DUPS_TITLE); | |
| 1913 } | |
| 1914 | |
| 1915 void | |
| 1916 action_playlist_remove_dupes_by_filename(void) | |
| 1917 { | |
| 1918 playlist_remove_duplicates(playlist_get_active(), PLAYLIST_DUPS_FILENAME); | |
| 1919 } | |
| 1920 | |
| 1921 void | |
| 1922 action_playlist_remove_dupes_by_full_path(void) | |
| 1923 { | |
| 1924 playlist_remove_duplicates(playlist_get_active(), PLAYLIST_DUPS_PATH); | |
| 1925 } | |
| 1926 | |
| 1927 void | |
| 1928 action_playlist_remove_all(void) | |
| 1929 { | |
| 1930 playlist_clear(playlist_get_active()); | |
| 1931 | |
| 1932 /* XXX -- should this really be coupled here? -nenolod */ | |
| 1933 mainwin_clear_song_info(); | |
| 1934 mainwin_set_info_text(); | |
| 1935 } | |
| 1936 | |
| 1937 void | |
| 1938 action_playlist_remove_selected(void) | |
| 1939 { | |
| 1940 playlist_delete(playlist_get_active(), FALSE); | |
| 1941 } | |
| 1942 | |
| 1943 void | |
| 1944 action_playlist_remove_unselected(void) | |
| 1945 { | |
| 1946 playlist_delete(playlist_get_active(), TRUE); | |
| 1947 } | |
| 1948 | |
| 1949 void | |
| 1950 action_playlist_add_files(void) | |
| 1951 { | |
|
2416
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2373
diff
changeset
|
1952 run_filebrowser(NO_PLAY_BUTTON); |
| 2313 | 1953 } |
| 1954 | |
| 1955 void add_medium(void); /* XXX */ | |
| 1956 | |
| 1957 void | |
| 1958 action_playlist_add_cd(void) | |
| 1959 { | |
| 1960 add_medium(); | |
| 1961 } | |
| 1962 | |
| 1963 void | |
| 1964 action_playlist_add_url(void) | |
| 1965 { | |
| 1966 mainwin_show_add_url_window(); | |
| 1967 } | |
| 1968 | |
| 1969 void | |
| 1970 action_playlist_new( void ) | |
| 1971 { | |
| 1972 Playlist *new_pl = playlist_new(); | |
| 1973 playlist_add_playlist(new_pl); | |
| 1974 playlist_select_playlist(new_pl); | |
| 1975 } | |
| 1976 | |
| 1977 void | |
| 1978 action_playlist_prev( void ) | |
| 1979 { | |
| 1980 playlist_select_prev(); | |
| 1981 } | |
| 1982 | |
| 1983 void | |
| 1984 action_playlist_next( void ) | |
| 1985 { | |
| 1986 playlist_select_next(); | |
| 1987 } | |
| 1988 | |
| 1989 void | |
| 1990 action_playlist_delete( void ) | |
| 1991 { | |
| 1992 playlist_remove_playlist( playlist_get_active() ); | |
| 1993 } | |
| 1994 | |
| 1995 void | |
| 1996 action_playlist_save_list(void) | |
| 1997 { | |
| 1998 Playlist *playlist = playlist_get_active(); | |
| 1999 | |
| 2000 playlistwin_select_playlist_to_save(playlist_get_current_name(playlist)); | |
| 2001 } | |
| 2002 | |
| 2003 void | |
| 2004 action_playlist_save_default_list(void) | |
| 2005 { | |
| 2006 Playlist *playlist = playlist_get_active(); | |
| 2007 | |
| 2008 playlist_save(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); | |
| 2009 } | |
| 2010 | |
| 2011 void | |
| 2012 action_playlist_load_list(void) | |
| 2013 { | |
| 2014 Playlist *playlist = playlist_get_active(); | |
| 2015 | |
| 2016 playlistwin_select_playlist_to_load(playlist_get_current_name(playlist)); | |
| 2017 } | |
| 2018 | |
| 2019 void | |
| 2020 action_playlist_refresh_list(void) | |
| 2021 { | |
| 2022 Playlist *playlist = playlist_get_active(); | |
| 2023 | |
| 2024 playlist_read_info_selection(playlist); | |
| 2025 playlistwin_update_list(playlist); | |
| 2026 } | |
| 2027 | |
| 2028 void | |
| 2029 action_open_list_manager(void) | |
| 2030 { | |
| 2031 playlist_manager_ui_show(); | |
| 2032 } | |
| 2033 | |
| 2034 void | |
| 2035 action_playlist_search_and_select(void) | |
| 2036 { | |
| 2037 playlistwin_select_search(); | |
| 2038 } | |
| 2039 | |
| 2040 void | |
| 2041 action_playlist_invert_selection(void) | |
| 2042 { | |
| 2043 playlistwin_inverse_selection(); | |
| 2044 } | |
| 2045 | |
| 2046 void | |
| 2047 action_playlist_select_none(void) | |
| 2048 { | |
| 2049 playlistwin_select_none(); | |
| 2050 } | |
| 2051 | |
| 2052 void | |
| 2053 action_playlist_select_all(void) | |
| 2054 { | |
| 2055 playlistwin_select_all(); | |
| 2056 } | |
| 2057 | |
| 2058 | |
| 2059 | |
| 2060 /* playlistwin_select_search callback functions | |
| 2061 placed here to avoid making the code messier :) */ | |
| 2062 void | |
| 2363 | 2063 playlistwin_select_search_cbt_cb(GtkWidget *called_cbt, gpointer other_cbt) |
| 2313 | 2064 { |
| 2363 | 2065 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(called_cbt)) == TRUE) |
| 2066 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(other_cbt), FALSE); | |
| 2313 | 2067 return; |
| 2068 } | |
| 2069 | |
| 2070 static gboolean | |
| 2363 | 2071 playlistwin_select_search_kp_cb(GtkWidget *entry, GdkEventKey *event, |
| 2072 gpointer searchdlg_win) | |
| 2313 | 2073 { |
| 2074 switch (event->keyval) | |
| 2075 { | |
| 2076 case GDK_Return: | |
| 2363 | 2077 gtk_dialog_response(GTK_DIALOG(searchdlg_win), GTK_RESPONSE_ACCEPT); |
| 2313 | 2078 return TRUE; |
| 2079 default: | |
| 2080 return FALSE; | |
| 2081 } | |
| 2082 } | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2083 |
|
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2084 |
|
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2085 /* fileinfopopup callback for playlistwin */ |
|
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2086 static gboolean |
|
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2087 playlistwin_fileinfopopup_probe(gpointer * filepopup_win) |
|
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2088 { |
| 2363 | 2089 gint x, y, pos; |
| 2090 TitleInput *tuple; | |
| 2091 static gint prev_x = 0, prev_y = 0, ctr = 0, prev_pos = -1; | |
| 2092 static gint shaded_pos = -1, shaded_prev_pos = -1; | |
| 2093 gboolean skip = FALSE; | |
| 2094 GdkWindow *win; | |
| 2095 Playlist *playlist = playlist_get_active(); | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2096 |
| 2363 | 2097 win = gdk_window_at_pointer(NULL, NULL); |
| 2098 gdk_window_get_pointer(GDK_WINDOW(playlistwin->window), &x, &y, NULL); | |
| 2099 pos = playlist_list_get_playlist_position(playlistwin_list, x, y); | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2100 |
| 2363 | 2101 if (win == NULL |
| 2102 || cfg.show_filepopup_for_tuple == FALSE | |
| 2103 || playlistwin_list->pl_tooltips == FALSE | |
| 2104 || pos != prev_pos | |
| 2105 || win != GDK_WINDOW(playlistwin->window)) | |
| 2106 { | |
| 2107 prev_pos = pos; | |
| 2108 ctr = 0; | |
| 2109 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
| 2110 return TRUE; | |
| 2111 } | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2112 |
| 2363 | 2113 if (prev_x == x && prev_y == y) |
| 2114 ctr++; | |
| 2115 else | |
| 2116 { | |
| 2117 ctr = 0; | |
| 2118 prev_x = x; | |
| 2119 prev_y = y; | |
| 2120 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
| 2121 return TRUE; | |
| 2122 } | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2123 |
| 2363 | 2124 if (playlistwin_is_shaded()) |
| 2125 { | |
| 2126 shaded_pos = playlist_get_position(playlist); | |
| 2127 if (shaded_prev_pos != shaded_pos) | |
| 2128 skip = TRUE; | |
| 2129 } | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2130 |
|
2351
911743d27aba
[svn] - simplify and optimize the metadata tooltip trigger function
giacomo
parents:
2348
diff
changeset
|
2131 if (ctr >= cfg.filepopup_delay && (skip == TRUE || GTK_WIDGET_VISIBLE(GTK_WIDGET(filepopup_win)) != TRUE)) { |
| 2363 | 2132 if (pos == -1 && !playlistwin_is_shaded()) |
| 2133 { | |
| 2134 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
| 2135 return TRUE; | |
| 2136 } | |
| 2137 /* shaded mode */ | |
| 2138 else | |
| 2139 { | |
| 2140 tuple = playlist_get_tuple(playlist, shaded_pos); | |
| 2141 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
| 2142 audacious_fileinfopopup_show_from_tuple(GTK_WIDGET(filepopup_win), tuple); | |
| 2143 shaded_prev_pos = shaded_pos; | |
| 2144 } | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2145 |
| 2363 | 2146 prev_pos = pos; |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2147 |
| 2363 | 2148 tuple = playlist_get_tuple(playlist, pos); |
| 2149 audacious_fileinfopopup_show_from_tuple(GTK_WIDGET(filepopup_win), tuple); | |
| 2150 } | |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2151 |
| 2363 | 2152 return TRUE; |
|
2348
564e8a1fe09a
[svn] - made a public API for fileinfopopup (popup that displays metadata, the same used in playlist); now plugins can include ui_fileinfopopup.h to display metadata popups (i.e. statusicon and libnotify plugins)
giacomo
parents:
2338
diff
changeset
|
2153 } |
