annotate src/skins/ui_playlist.c @ 2674:b84f2aca1675

Fixed js's commit, and few other things.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 01 Jun 2008 01:02:11 +0300
parents a1431a900f28
children 32e99af83a3e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
2 * Copyright (C) 2005-2006 Audacious development team.
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
3 *
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 * BMP - Cross-platform multimedia player
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2003-2004 BMP development team.
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 *
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * Based on XMMS:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 * Copyright (C) 1998-2003 XMMS development team.
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 *
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; under version 3 of the License.
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
13 *
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * GNU General Public License for more details.
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 *
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses>.
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
21 *
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
22 * The Audacious team does not consider modular code linking to
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
23 * Audacious or using our public API to be a derived work.
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
24 */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26 /* #define AUD_DEBUG 1 */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #include "ui_playlist.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
29
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30 #include <glib.h>
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31 #include <glib/gi18n.h>
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 #include <gdk/gdk.h>
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33 #include <gdk/gdkkeysyms.h>
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34 #include <gtk/gtk.h>
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35 #include <string.h>
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
37 #include "platform/smartinclude.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39 #include <unistd.h>
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
40 #include <errno.h>
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
41
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
42 #include "actions-playlist.h"
2629
2ce9e17525dc make dnd working in playlistwin
Tomasz Mon <desowin@gmail.com>
parents: 2621
diff changeset
43 #include "dnd.h"
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44 #if 0
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45 #include "input.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 #include "main.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
47 #include "playback.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
48 #include "playlist.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
49 #include "playlist_container.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50 #include "strings.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51 #endif
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 #include "ui_dock.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53 #include "ui_equalizer.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 #include "ui_main.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 #include "ui_manager.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56 #include "ui_playlist_evlisteners.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 #if 0
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 #include "ui_playlist_manager.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59 #endif
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60 #include "util.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 #include "ui_skinned_window.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63 #include "ui_skinned_button.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64 #include "ui_skinned_textbox.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65 #include "ui_skinned_playlist_slider.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 #include "ui_skinned_playlist.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 #include "icons-stock.h"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 #include "images/audacious_playlist.xpm"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
71 GtkWidget *playlistwin;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73 static GMutex *resize_mutex = NULL;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 static GtkWidget *playlistwin_list = NULL;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76 static GtkWidget *playlistwin_shade, *playlistwin_close;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 static gboolean playlistwin_hint_flag = FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80 static GtkWidget *playlistwin_slider;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81 static GtkWidget *playlistwin_time_min, *playlistwin_time_sec;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82 static GtkWidget *playlistwin_info, *playlistwin_sinfo;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83 static GtkWidget *playlistwin_srew, *playlistwin_splay;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84 static GtkWidget *playlistwin_spause, *playlistwin_sstop;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 static GtkWidget *playlistwin_sfwd, *playlistwin_seject;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86 static GtkWidget *playlistwin_sscroll_up, *playlistwin_sscroll_down;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88 static void playlistwin_select_search_cbt_cb(GtkWidget *called_cbt,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
89 gpointer other_cbt);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90 static gboolean playlistwin_select_search_kp_cb(GtkWidget *entry,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91 GdkEventKey *event,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 gpointer searchdlg_win);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94 static gboolean playlistwin_resizing = FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
95 static gint playlistwin_resize_x, playlistwin_resize_y;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97 gboolean
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 playlistwin_is_shaded(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100 return config.playlist_shaded;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 gint
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104 playlistwin_get_width(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 config.playlist_width /= PLAYLISTWIN_WIDTH_SNAP;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 config.playlist_width *= PLAYLISTWIN_WIDTH_SNAP;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108 return config.playlist_width;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 gint
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112 playlistwin_get_height_unshaded(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114 config.playlist_height /= PLAYLISTWIN_HEIGHT_SNAP;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
115 config.playlist_height *= PLAYLISTWIN_HEIGHT_SNAP;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116 return config.playlist_height;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
117 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119 gint
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120 playlistwin_get_height_shaded(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122 return PLAYLISTWIN_SHADED_HEIGHT;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
123 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125 gint
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 playlistwin_get_height(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128 if (playlistwin_is_shaded())
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
129 return playlistwin_get_height_shaded();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131 return playlistwin_get_height_unshaded();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 playlistwin_update_info(Playlist *playlist)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136 {
2634
43a07a0607da make playlistwin_update_info and playlistwin_update_sinfo working
Tomasz Mon <desowin@gmail.com>
parents: 2629
diff changeset
137 g_return_if_fail(playlist != NULL);
43a07a0607da make playlistwin_update_info and playlistwin_update_sinfo working
Tomasz Mon <desowin@gmail.com>
parents: 2629
diff changeset
138
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139 gchar *text, *sel_text, *tot_text;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 gulong selection, total;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141 gboolean selection_more, total_more;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 aud_playlist_get_total_time(playlist, &total, &selection, &total_more, &selection_more);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 if (selection > 0 || (selection == 0 && !selection_more)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146 if (selection > 3600)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147 sel_text =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
148 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", selection / 3600,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149 (selection / 60) % 60, selection % 60,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 (selection_more ? "+" : ""));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152 sel_text =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 g_strdup_printf("%lu:%-2.2lu%s", selection / 60,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154 selection % 60, (selection_more ? "+" : ""));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 sel_text = g_strdup("?");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 if (total > 0 || (total == 0 && !total_more)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159 if (total > 3600)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160 tot_text =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161 g_strdup_printf("%lu:%-2.2lu:%-2.2lu%s", total / 3600,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162 (total / 60) % 60, total % 60,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
163 total_more ? "+" : "");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165 tot_text =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166 g_strdup_printf("%lu:%-2.2lu%s", total / 60, total % 60,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 total_more ? "+" : "");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170 tot_text = g_strdup("?");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
171 text = g_strconcat(sel_text, "/", tot_text, NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
172 ui_skinned_textbox_set_text(playlistwin_info, text ? text : "");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
173 g_free(text);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174 g_free(tot_text);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
175 g_free(sel_text);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
176 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
177
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
178 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
179 playlistwin_update_sinfo(Playlist *playlist)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
180 {
2634
43a07a0607da make playlistwin_update_info and playlistwin_update_sinfo working
Tomasz Mon <desowin@gmail.com>
parents: 2629
diff changeset
181 g_return_if_fail(playlist != NULL);
43a07a0607da make playlistwin_update_info and playlistwin_update_sinfo working
Tomasz Mon <desowin@gmail.com>
parents: 2629
diff changeset
182
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
183 gchar *posstr, *timestr, *title, *info;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
184 gint pos, time;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
185
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
186 pos = aud_playlist_get_position(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
187 title = aud_playlist_get_songtitle(playlist, pos);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
188
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
189 if (!title) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
190 ui_skinned_textbox_set_text(playlistwin_sinfo, "");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
191 return;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
192 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
193
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
194 aud_convert_title_text(title);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
195
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
196 time = aud_playlist_get_songtime(playlist, pos);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
197
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
198 if (config.show_numbers_in_pl)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
199 posstr = g_strdup_printf("%d. ", pos + 1);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
200 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201 posstr = g_strdup("");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
202
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
203 if (time != -1) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
204 timestr = g_strdup_printf(" (%d:%-2.2d)", time / 60000,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
205 (time / 1000) % 60);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
206 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
207 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
208 timestr = g_strdup("");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
209
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
210 info = g_strdup_printf("%s%s%s", posstr, title, timestr);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212 g_free(posstr);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213 g_free(title);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
214 g_free(timestr);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
215
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
216 ui_skinned_textbox_set_text(playlistwin_sinfo, info ? info : "");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
217 g_free(info);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
218 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220 gboolean
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
221 playlistwin_item_visible(gint index)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
222 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223 g_return_val_if_fail(UI_SKINNED_IS_PLAYLIST(playlistwin_list), FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
224
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
225 if (index >= UI_SKINNED_PLAYLIST(playlistwin_list)->first &&
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
226 index < (UI_SKINNED_PLAYLIST(playlistwin_list)->first + UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible) ) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
227 return TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
228 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
229 return FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
230 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
231
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
232 gint
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233 playlistwin_list_get_visible_count(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
234 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
235 g_return_val_if_fail(UI_SKINNED_IS_PLAYLIST(playlistwin_list), -1);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
236
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
237 return UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
238 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
239
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
240 gint
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
241 playlistwin_list_get_first(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
242 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
243 g_return_val_if_fail(UI_SKINNED_IS_PLAYLIST(playlistwin_list), -1);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
244
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
245 return UI_SKINNED_PLAYLIST(playlistwin_list)->first;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
246 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
247
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
248 gint
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249 playlistwin_get_toprow(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
250 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
251 g_return_val_if_fail(UI_SKINNED_IS_PLAYLIST(playlistwin_list), -1);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
252
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
253 return (UI_SKINNED_PLAYLIST(playlistwin_list)->first);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
255
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
256 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
257 playlistwin_set_toprow(gint toprow)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
258 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
259 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
260 UI_SKINNED_PLAYLIST(playlistwin_list)->first = toprow;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
261 #if 0
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
262 g_cond_signal(cond_scan);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
263 #endif
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
264 playlistwin_update_list(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
265 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
266
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
267 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
268 playlistwin_update_list(Playlist *playlist)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
269 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
270 /* this can happen early on. just bail gracefully. */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
271 g_return_if_fail(playlistwin_list);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
272
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
273 playlistwin_update_info(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
274 playlistwin_update_sinfo(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
275 gtk_widget_queue_draw(playlistwin_list);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
276 gtk_widget_queue_draw(playlistwin_slider);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
277 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
278
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
279 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
280 playlistwin_set_geometry_hints(gboolean shaded)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
281 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
282 GdkGeometry geometry;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
283 GdkWindowHints mask;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
284
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
285 geometry.min_width = PLAYLISTWIN_MIN_WIDTH;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
286 geometry.max_width = G_MAXUINT16;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
287
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
288 geometry.width_inc = PLAYLISTWIN_WIDTH_SNAP;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
289 geometry.height_inc = PLAYLISTWIN_HEIGHT_SNAP;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
290
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
291 if (shaded) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
292 geometry.min_height = PLAYLISTWIN_SHADED_HEIGHT;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
293 geometry.max_height = PLAYLISTWIN_SHADED_HEIGHT;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
294 geometry.base_height = PLAYLISTWIN_SHADED_HEIGHT;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
295 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
296 else {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
297 geometry.min_height = PLAYLISTWIN_MIN_HEIGHT;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
298 geometry.max_height = G_MAXUINT16;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
299 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
300
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
301 mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_RESIZE_INC;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
302
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
303 gtk_window_set_geometry_hints(GTK_WINDOW(playlistwin),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
304 playlistwin, &geometry, mask);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
305 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
306
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
307 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
308 playlistwin_set_sinfo_font(gchar *font)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
309 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
310 gchar *tmp = NULL, *tmp2 = NULL;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
311
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
312 g_return_if_fail(font);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
313 AUDDBG("Attempt to set font \"%s\"\n", font);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
314
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
315 tmp = g_strdup(font);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
316 g_return_if_fail(tmp);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
317
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
318 *strrchr(tmp, ' ') = '\0';
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
319 tmp2 = g_strdup_printf("%s 8", tmp);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
320 g_return_if_fail(tmp2);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
321
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
322 ui_skinned_textbox_set_xfont(playlistwin_sinfo, !config.mainwin_use_bitmapfont, tmp2);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
323
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
324 g_free(tmp);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
325 g_free(tmp2);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
326 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
327
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
328 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
329 playlistwin_set_sinfo_scroll(gboolean scroll)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
330 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
331 if(playlistwin_is_shaded())
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
332 ui_skinned_textbox_set_scroll(playlistwin_sinfo, config.autoscroll);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
333 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
334 ui_skinned_textbox_set_scroll(playlistwin_sinfo, FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
335 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
336
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
337 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
338 playlistwin_set_shade(gboolean shaded)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
339 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
340 config.playlist_shaded = shaded;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
341
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
342 if (shaded) {
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2640
diff changeset
343 playlistwin_set_sinfo_font(config.playlist_font);
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
344 playlistwin_set_sinfo_scroll(config.autoscroll);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
345 gtk_widget_show(playlistwin_sinfo);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
346 ui_skinned_set_push_button_data(playlistwin_shade, 128, 45, 150, 42);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
347 ui_skinned_set_push_button_data(playlistwin_close, 138, 45, -1, -1);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
348 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
349 else {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
350 gtk_widget_hide(playlistwin_sinfo);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
351 playlistwin_set_sinfo_scroll(FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
352 ui_skinned_set_push_button_data(playlistwin_shade, 157, 3, 62, 42);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
353 ui_skinned_set_push_button_data(playlistwin_close, 167, 3, -1, -1);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
354 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
355
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
356 dock_shade(get_dock_window_list(), GTK_WINDOW(playlistwin),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
357 playlistwin_get_height());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
358
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
359 playlistwin_set_geometry_hints(config.playlist_shaded);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361 gtk_window_resize(GTK_WINDOW(playlistwin),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
362 playlistwin_get_width(),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
363 playlistwin_get_height());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
366 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
367 playlistwin_set_shade_menu(gboolean shaded)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
368 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
369 GtkAction *action = gtk_action_group_get_action(
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
370 toggleaction_group_others , "roll up playlist editor" );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
371 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
372
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
373 playlistwin_set_shade(shaded);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
374 playlistwin_update_list(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
375 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
376
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
377 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
378 playlistwin_shade_toggle(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
379 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
380 playlistwin_set_shade_menu(!config.playlist_shaded);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
381 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
382
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
383 static gboolean
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
384 playlistwin_release(GtkWidget * widget,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
385 GdkEventButton * event,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
386 gpointer callback_data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
387 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
388 playlistwin_resizing = FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
389 return FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
390 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
391
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
392 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
393 playlistwin_scroll(gint num)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
394 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
395 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
396 UI_SKINNED_PLAYLIST(playlistwin_list)->first += num;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
397 playlistwin_update_list(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
398 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
399
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
400 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
401 playlistwin_scroll_up_pushed(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
402 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
403 playlistwin_scroll(-3);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
404 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
405
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
406 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
407 playlistwin_scroll_down_pushed(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
408 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
409 playlistwin_scroll(3);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
410 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
411
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
412 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
413 playlistwin_select_all(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
414 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
415 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
416
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
417 aud_playlist_select_all(playlist, TRUE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
418 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
419 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected = 0;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
420 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_min = 0;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
421 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_max = aud_playlist_get_length(playlist) - 1;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
422 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
423 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
424 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
425
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
426 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
427 playlistwin_select_none(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
428 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
429 aud_playlist_select_all(aud_playlist_get_active(), FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
430 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
431 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected = -1;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
432 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_min = -1;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
433 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
434 playlistwin_update_list(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
435 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
436
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
437 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
438 playlistwin_select_search(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
439 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
440 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
441 GtkWidget *searchdlg_win, *searchdlg_table;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
442 GtkWidget *searchdlg_hbox, *searchdlg_logo, *searchdlg_helptext;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
443 GtkWidget *searchdlg_entry_title, *searchdlg_label_title;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
444 GtkWidget *searchdlg_entry_album, *searchdlg_label_album;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
445 GtkWidget *searchdlg_entry_file_name, *searchdlg_label_file_name;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
446 GtkWidget *searchdlg_entry_performer, *searchdlg_label_performer;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
447 GtkWidget *searchdlg_checkbt_clearprevsel;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
448 GtkWidget *searchdlg_checkbt_newplaylist;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
449 GtkWidget *searchdlg_checkbt_autoenqueue;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
450 gint result;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
451
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
452 /* create dialog */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
453 searchdlg_win = gtk_dialog_new_with_buttons(
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
454 _("Search entries in active playlist") , GTK_WINDOW(mainwin) ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
455 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
456 GTK_STOCK_CANCEL , GTK_RESPONSE_REJECT , GTK_STOCK_OK , GTK_RESPONSE_ACCEPT , NULL );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
457 gtk_window_set_position(GTK_WINDOW(searchdlg_win), GTK_WIN_POS_CENTER);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
458
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
459 /* help text and logo */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
460 searchdlg_hbox = gtk_hbox_new( FALSE , 4 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
461 searchdlg_logo = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_DIALOG );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
462 searchdlg_helptext = gtk_label_new( _("Select entries in playlist by filling one or more "
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
463 "fields. Fields use regular expressions syntax, case-insensitive. If you don't know how "
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
464 "regular expressions work, simply insert a literal portion of what you're searching for.") );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
465 gtk_label_set_line_wrap( GTK_LABEL(searchdlg_helptext) , TRUE );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
466 gtk_box_pack_start( GTK_BOX(searchdlg_hbox) , searchdlg_logo , FALSE , FALSE , 0 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
467 gtk_box_pack_start( GTK_BOX(searchdlg_hbox) , searchdlg_helptext , FALSE , FALSE , 0 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
468
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
469 /* title */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
470 searchdlg_label_title = gtk_label_new( _("Title: ") );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
471 searchdlg_entry_title = gtk_entry_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
472 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_title) , 0 , 0.5 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
473 g_signal_connect( G_OBJECT(searchdlg_entry_title) , "key-press-event" ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
474 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
475
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
476 /* album */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
477 searchdlg_label_album= gtk_label_new( _("Album: ") );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
478 searchdlg_entry_album= gtk_entry_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
479 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_album) , 0 , 0.5 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
480 g_signal_connect( G_OBJECT(searchdlg_entry_album) , "key-press-event" ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
481 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
482
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
483 /* artist */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
484 searchdlg_label_performer = gtk_label_new( _("Artist: ") );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
485 searchdlg_entry_performer = gtk_entry_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
486 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_performer) , 0 , 0.5 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
487 g_signal_connect( G_OBJECT(searchdlg_entry_performer) , "key-press-event" ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
488 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
489
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
490 /* file name */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
491 searchdlg_label_file_name = gtk_label_new( _("Filename: ") );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
492 searchdlg_entry_file_name = gtk_entry_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
493 gtk_misc_set_alignment( GTK_MISC(searchdlg_label_file_name) , 0 , 0.5 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
494 g_signal_connect( G_OBJECT(searchdlg_entry_file_name) , "key-press-event" ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
495 G_CALLBACK(playlistwin_select_search_kp_cb) , searchdlg_win );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
496
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
497 /* some options that control behaviour */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
498 searchdlg_checkbt_clearprevsel = gtk_check_button_new_with_label(
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
499 _("Clear previous selection before searching") );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
500 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_clearprevsel) , TRUE );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
501 searchdlg_checkbt_autoenqueue = gtk_check_button_new_with_label(
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
502 _("Automatically toggle queue for matching entries") );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
503 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_autoenqueue) , FALSE );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
504 searchdlg_checkbt_newplaylist = gtk_check_button_new_with_label(
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
505 _("Create a new playlist with matching entries") );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
506 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(searchdlg_checkbt_newplaylist) , FALSE );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
507 g_signal_connect( G_OBJECT(searchdlg_checkbt_autoenqueue) , "clicked" ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
508 G_CALLBACK(playlistwin_select_search_cbt_cb) , searchdlg_checkbt_newplaylist );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
509 g_signal_connect( G_OBJECT(searchdlg_checkbt_newplaylist) , "clicked" ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
510 G_CALLBACK(playlistwin_select_search_cbt_cb) , searchdlg_checkbt_autoenqueue );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
511
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
512 /* place fields in searchdlg_table */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
513 searchdlg_table = gtk_table_new( 8 , 2 , FALSE );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
514 gtk_table_set_row_spacing( GTK_TABLE(searchdlg_table) , 0 , 8 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
515 gtk_table_set_row_spacing( GTK_TABLE(searchdlg_table) , 4 , 8 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
516 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_hbox ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
517 0 , 2 , 0 , 1 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
518 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_title ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
519 0 , 1 , 1 , 2 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
520 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_title ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
521 1 , 2 , 1 , 2 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
522 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_album,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
523 0 , 1 , 2 , 3 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
524 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_album,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
525 1 , 2 , 2 , 3 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
526 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_performer ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
527 0 , 1 , 3 , 4 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
528 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_performer ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
529 1 , 2 , 3 , 4 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
530 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_label_file_name ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
531 0 , 1 , 4 , 5 , GTK_FILL , GTK_FILL | GTK_EXPAND , 0 , 2 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
532 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_entry_file_name ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
533 1 , 2 , 4 , 5 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 2 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
534 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_clearprevsel ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
535 0 , 2 , 5 , 6 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
536 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_autoenqueue ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
537 0 , 2 , 6 , 7 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
538 gtk_table_attach( GTK_TABLE(searchdlg_table) , searchdlg_checkbt_newplaylist ,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
539 0 , 2 , 7 , 8 , GTK_FILL | GTK_EXPAND , GTK_FILL | GTK_EXPAND , 0 , 1 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
540
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
541 gtk_container_set_border_width( GTK_CONTAINER(searchdlg_table) , 5 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
542 gtk_container_add( GTK_CONTAINER(GTK_DIALOG(searchdlg_win)->vbox) , searchdlg_table );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
543 gtk_widget_show_all( searchdlg_win );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
544 result = gtk_dialog_run( GTK_DIALOG(searchdlg_win) );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
545 switch(result)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
546 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
547 case GTK_RESPONSE_ACCEPT:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
548 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
549 gint matched_entries_num = 0;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
550 /* create a TitleInput tuple with user search data */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
551 Tuple *tuple = aud_tuple_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
552 gchar *searchdata = NULL;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
553
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
554 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_title) );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
555 AUDDBG("title=\"%s\"\n", searchdata);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
556 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, searchdata);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
557
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
558 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_album) );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
559 AUDDBG("album=\"%s\"\n", searchdata);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
560 aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, searchdata);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
561
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
562 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_performer) );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
563 AUDDBG("performer=\"%s\"\n", searchdata);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
564 aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, searchdata);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
565
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
566 searchdata = (gchar*)gtk_entry_get_text( GTK_ENTRY(searchdlg_entry_file_name) );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
567 AUDDBG("filename=\"%s\"\n", searchdata);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
568 aud_tuple_associate_string(tuple, FIELD_FILE_NAME, NULL, searchdata);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
569
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
570 /* check if previous selection should be cleared before searching */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
571 if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_clearprevsel)) == TRUE )
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
572 playlistwin_select_none();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
573 /* now send this tuple to the real search function */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
574 matched_entries_num = aud_playlist_select_search( playlist , tuple , 0 );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
575 /* we do not need the tuple and its data anymore */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
576 mowgli_object_unref(tuple);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
577 playlistwin_update_list(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
578 /* check if a new playlist should be created after searching */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
579 if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_newplaylist)) == TRUE )
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
580 aud_playlist_new_from_selected();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
581 /* check if matched entries should be queued */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
582 else if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(searchdlg_checkbt_autoenqueue)) == TRUE )
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
583 aud_playlist_queue(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
584 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
585 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
586 default:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
587 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
588 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
589 /* done here :) */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
590 gtk_widget_destroy( searchdlg_win );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
591 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
592
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
593 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
594 playlistwin_inverse_selection(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
595 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
596 aud_playlist_select_invert_all(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
597 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
598 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected = -1;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
599 UI_SKINNED_PLAYLIST(playlistwin_list)->prev_min = -1;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
600 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
601 playlistwin_update_list(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
602 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
603
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
604 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
605 playlistwin_resize(gint width, gint height)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
606 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
607 gint tx, ty;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
608 gint dx, dy;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
609
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
610 g_return_if_fail(width > 0 && height > 0);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
611
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
612 tx = (width - PLAYLISTWIN_MIN_WIDTH) / PLAYLISTWIN_WIDTH_SNAP;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
613 tx = (tx * PLAYLISTWIN_WIDTH_SNAP) + PLAYLISTWIN_MIN_WIDTH;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
614 if (tx < PLAYLISTWIN_MIN_WIDTH)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
615 tx = PLAYLISTWIN_MIN_WIDTH;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
616
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
617 if (!config.playlist_shaded)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
618 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
619 ty = (height - PLAYLISTWIN_MIN_HEIGHT) / PLAYLISTWIN_HEIGHT_SNAP;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
620 ty = (ty * PLAYLISTWIN_HEIGHT_SNAP) + PLAYLISTWIN_MIN_HEIGHT;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
621 if (ty < PLAYLISTWIN_MIN_HEIGHT)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
622 ty = PLAYLISTWIN_MIN_HEIGHT;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
623 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
624 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
625 ty = config.playlist_height;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
626
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
627 if (tx == config.playlist_width && ty == config.playlist_height)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
628 return;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
629
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
630 /* difference between previous size and new size */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
631 dx = tx - config.playlist_width;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
632 dy = ty - config.playlist_height;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
633
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
634 config.playlist_width = width = tx;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
635 config.playlist_height = height = ty;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
636
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
637 g_mutex_lock(resize_mutex);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
638 ui_skinned_playlist_resize_relative(playlistwin_list, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
639
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
640 ui_skinned_playlist_slider_move_relative(playlistwin_slider, dx);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
641 ui_skinned_playlist_slider_resize_relative(playlistwin_slider, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
642
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
643 playlistwin_update_sinfo(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
644
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
645 ui_skinned_button_move_relative(playlistwin_shade, dx, 0);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
646 ui_skinned_button_move_relative(playlistwin_close, dx, 0);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
647 ui_skinned_textbox_move_relative(playlistwin_time_min, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
648 ui_skinned_textbox_move_relative(playlistwin_time_sec, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
649 ui_skinned_textbox_move_relative(playlistwin_info, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
650 ui_skinned_button_move_relative(playlistwin_srew, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
651 ui_skinned_button_move_relative(playlistwin_splay, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
652 ui_skinned_button_move_relative(playlistwin_spause, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
653 ui_skinned_button_move_relative(playlistwin_sstop, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
654 ui_skinned_button_move_relative(playlistwin_sfwd, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
655 ui_skinned_button_move_relative(playlistwin_seject, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
656 ui_skinned_button_move_relative(playlistwin_sscroll_up, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
657 ui_skinned_button_move_relative(playlistwin_sscroll_down, dx, dy);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
658
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
659 gtk_widget_set_size_request(playlistwin_sinfo, playlistwin_get_width() - 35,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
660 aud_active_skin->properties.textbox_bitmap_font_height);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
661 GList *iter;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
662 for (iter = GTK_FIXED (SKINNED_WINDOW(playlistwin)->fixed)->children; iter; iter = g_list_next (iter)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
663 GtkFixedChild *child_data = (GtkFixedChild *) iter->data;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
664 GtkWidget *child = child_data->widget;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
665 g_signal_emit_by_name(child, "redraw");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
666 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
667 g_mutex_unlock(resize_mutex);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
668 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
669
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
670 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
671 playlistwin_motion(GtkWidget * widget,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
672 GdkEventMotion * event,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
673 gpointer callback_data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
674 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
675 /*
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
676 * GDK2's resize is broken and doesn't really play nice, so we have
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
677 * to do all of this stuff by hand.
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
678 */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
679 if (playlistwin_resizing == TRUE)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
680 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
681 if (event->x + playlistwin_resize_x != playlistwin_get_width() ||
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
682 event->y + playlistwin_resize_y != playlistwin_get_height())
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
683 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
684 playlistwin_resize(event->x + playlistwin_resize_x,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
685 event->y + playlistwin_resize_y);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
686 gdk_window_resize(playlistwin->window,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
687 config.playlist_width, playlistwin_get_height());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
688 gdk_flush();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
689 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
690 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
691 else if (dock_is_moving(GTK_WINDOW(playlistwin)))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
692 dock_move_motion(GTK_WINDOW(playlistwin), event);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
693 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
694
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
695 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
696 playlistwin_show_filebrowser(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
697 {
2640
dd255ad225f3 use more hooks
Tomasz Mon <desowin@gmail.com>
parents: 2639
diff changeset
698 action_playlist_add_files();
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
699 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
700
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
701 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
702 playlistwin_fileinfo(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
703 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
704 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
705
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
706 /* Show the first selected file, or the current file if nothing is
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
707 * selected */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
708 GList *list = aud_playlist_get_selected(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
709 if (list) {
2639
6a881c49db96 make use of ui_fileinfo
Tomasz Mon <desowin@gmail.com>
parents: 2634
diff changeset
710 aud_playlist_fileinfo(playlist, GPOINTER_TO_INT(list->data));
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
711 g_list_free(list);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
712 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
713 else
2639
6a881c49db96 make use of ui_fileinfo
Tomasz Mon <desowin@gmail.com>
parents: 2634
diff changeset
714 aud_playlist_fileinfo_current(playlist);
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
715 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
716
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
717 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
718 show_playlist_save_error(GtkWindow *parent,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
719 const gchar *filename)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
720 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
721 GtkWidget *dialog;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
722
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
723 g_return_if_fail(GTK_IS_WINDOW(parent));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
724 g_return_if_fail(filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
725
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
726 dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
727 GTK_DIALOG_DESTROY_WITH_PARENT,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
728 GTK_MESSAGE_ERROR,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
729 GTK_BUTTONS_OK,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
730 _("Error writing playlist \"%s\": %s"),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
731 filename, strerror(errno));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
732
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
733 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); /* centering */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
734 gtk_dialog_run(GTK_DIALOG(dialog));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
735 gtk_widget_destroy(dialog);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
736 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
737
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
738 static gboolean
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
739 show_playlist_overwrite_prompt(GtkWindow * parent,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
740 const gchar * filename)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
741 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
742 GtkWidget *dialog;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
743 gint result;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
744
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
745 g_return_val_if_fail(GTK_IS_WINDOW(parent), FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
746 g_return_val_if_fail(filename != NULL, FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
747
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
748 dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
749 GTK_DIALOG_DESTROY_WITH_PARENT,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
750 GTK_MESSAGE_QUESTION,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
751 GTK_BUTTONS_YES_NO,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
752 _("%s already exist. Continue?"),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
753 filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
754
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
755 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); /* centering */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
756 result = gtk_dialog_run(GTK_DIALOG(dialog));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
757 gtk_widget_destroy(dialog);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
758
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
759 return (result == GTK_RESPONSE_YES);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
760 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
761
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
762 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
763 show_playlist_save_format_error(GtkWindow * parent,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
764 const gchar * filename)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
765 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
766 const gchar *markup =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
767 N_("<b><big>Unable to save playlist.</big></b>\n\n"
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
768 "Unknown file type for '%s'.\n");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
769
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
770 GtkWidget *dialog;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
771
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
772 g_return_if_fail(GTK_IS_WINDOW(parent));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
773 g_return_if_fail(filename != NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
774
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
775 dialog =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
776 gtk_message_dialog_new_with_markup(GTK_WINDOW(parent),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
777 GTK_DIALOG_DESTROY_WITH_PARENT,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
778 GTK_MESSAGE_ERROR,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
779 GTK_BUTTONS_OK,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
780 _(markup),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
781 filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
782
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
783 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); /* centering */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
784 gtk_dialog_run(GTK_DIALOG(dialog));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
785 gtk_widget_destroy(dialog);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
786 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
787
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
788 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
789 playlistwin_save_playlist(const gchar * filename)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
790 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
791 PlaylistContainer *plc;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
792 gchar *ext = strrchr(filename, '.') + 1;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
793
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
794 plc = aud_playlist_container_find(ext);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
795 if (plc == NULL) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
796 show_playlist_save_format_error(GTK_WINDOW(playlistwin), filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
797 return;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
798 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
799
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
800 aud_str_replace_in(&aud_cfg->playlist_path, g_path_get_dirname(filename));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
801
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
802 if (g_file_test(filename, G_FILE_TEST_IS_REGULAR))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
803 if (!show_playlist_overwrite_prompt(GTK_WINDOW(playlistwin), filename))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
804 return;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
805
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
806 if (!aud_playlist_save(aud_playlist_get_active(), filename))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
807 show_playlist_save_error(GTK_WINDOW(playlistwin), filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
808 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
809
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
810 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
811 playlistwin_load_playlist(const gchar * filename)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
812 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
813 const gchar *title;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
814 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
815
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
816 g_return_if_fail(filename != NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
817
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
818 aud_str_replace_in(&aud_cfg->playlist_path, g_path_get_dirname(filename));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
819
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
820 aud_playlist_clear(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
821 mainwin_clear_song_info();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
822
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
823 aud_playlist_load(playlist, filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
824 title = aud_playlist_get_current_name(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
825 if(!title || !title[0])
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
826 aud_playlist_set_current_name(playlist, filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
827 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
828
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
829 static gchar *
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
830 playlist_file_selection_load(const gchar * title,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
831 const gchar * default_filename)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
832 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
833 GtkWidget *dialog;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
834 gchar *filename;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
835
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
836 g_return_val_if_fail(title != NULL, NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
837
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
838 dialog = make_filebrowser(title, FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
839 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), aud_cfg->playlist_path);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
840 if (default_filename)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
841 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), default_filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
842 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); /* centering */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
843
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
844 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
845 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
846 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
847 filename = NULL;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
848
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
849 gtk_widget_destroy(dialog);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
850 return filename;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
851 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
852
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
853 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
854 on_static_toggle(GtkToggleButton *button, gpointer data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
855 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
856 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
857
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
858 playlist->attribute =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
859 gtk_toggle_button_get_active(button) ?
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
860 playlist->attribute | PLAYLIST_STATIC :
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
861 playlist->attribute & ~PLAYLIST_STATIC;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
862 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
863
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
864 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
865 on_relative_toggle(GtkToggleButton *button, gpointer data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
866 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
867 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
868
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
869 playlist->attribute =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
870 gtk_toggle_button_get_active(button) ?
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
871 playlist->attribute | PLAYLIST_USE_RELATIVE :
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
872 playlist->attribute & ~PLAYLIST_USE_RELATIVE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
873 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
874
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
875 static gchar *
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
876 playlist_file_selection_save(const gchar * title,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
877 const gchar * default_filename)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
878 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
879 GtkWidget *dialog;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
880 gchar *filename;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
881 GtkWidget *hbox;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
882 GtkWidget *toggle, *toggle2;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
883
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
884 g_return_val_if_fail(title != NULL, NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
885
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
886 dialog = make_filebrowser(title, TRUE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
887 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), aud_cfg->playlist_path);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
888 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), default_filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
889
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
890 hbox = gtk_hbox_new(FALSE, 5);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
891
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
892 /* static playlist */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
893 toggle = gtk_check_button_new_with_label(_("Save as Static Playlist"));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
894 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
895 (aud_playlist_get_active()->attribute & PLAYLIST_STATIC) ? TRUE : FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
896 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(on_static_toggle), dialog);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
897 gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
898
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
899 /* use relative path */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
900 toggle2 = gtk_check_button_new_with_label(_("Use Relative Path"));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
901 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle2),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
902 (aud_playlist_get_active()->attribute & PLAYLIST_USE_RELATIVE) ? TRUE : FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
903 g_signal_connect(G_OBJECT(toggle2), "toggled", G_CALLBACK(on_relative_toggle), dialog);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
904 gtk_box_pack_start(GTK_BOX(hbox), toggle2, FALSE, FALSE, 0);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
905
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
906 gtk_widget_show_all(hbox);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
907 gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dialog), hbox);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
908
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
909 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
910 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
911 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
912 filename = NULL;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
913
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
914 gtk_widget_destroy(dialog);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
915 return filename;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
916 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
917
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
918 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
919 playlistwin_select_playlist_to_load(const gchar * default_filename)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
920 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
921 gchar *filename =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
922 playlist_file_selection_load(_("Load Playlist"), default_filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
923
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
924 if (filename) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
925 playlistwin_load_playlist(filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
926 g_free(filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
927 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
928 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
929
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
930 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
931 playlistwin_select_playlist_to_save(const gchar * default_filename)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
932 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
933 gchar *dot = NULL, *basename = NULL;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
934 gchar *filename =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
935 playlist_file_selection_save(_("Save Playlist"), default_filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
936
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
937 if (filename) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
938 /* Default extension */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
939 basename = g_path_get_basename(filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
940 dot = strrchr(basename, '.');
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
941 if( dot == NULL || dot == basename) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
942 gchar *oldname = filename;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
943 #ifdef HAVE_XSPF_PLAYLIST
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
944 filename = g_strconcat(oldname, ".xspf", NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
945 #else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
946 filename = g_strconcat(oldname, ".m3u", NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
947 #endif
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
948 g_free(oldname);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
949 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
950 g_free(basename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
951
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
952 playlistwin_save_playlist(filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
953 g_free(filename);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
954 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
955 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
956
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
957 #define REGION_L(x1,x2,y1,y2) \
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
958 (event->x >= (x1) && event->x < (x2) && \
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
959 event->y >= config.playlist_height - (y1) && \
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
960 event->y < config.playlist_height - (y2))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
961
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
962 #define REGION_R(x1,x2,y1,y2) \
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
963 (event->x >= playlistwin_get_width() - (x1) && \
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
964 event->x < playlistwin_get_width() - (x2) && \
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
965 event->y >= config.playlist_height - (y1) && \
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
966 event->y < config.playlist_height - (y2))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
967
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
968 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
969 playlistwin_scrolled(GtkWidget * widget,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
970 GdkEventScroll * event,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
971 gpointer callback_data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
972 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
973 if (event->direction == GDK_SCROLL_DOWN)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
974 playlistwin_scroll(config.scroll_pl_by);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
975
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
976 if (event->direction == GDK_SCROLL_UP)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
977 playlistwin_scroll(-config.scroll_pl_by);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
978 #if 0
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
979 g_cond_signal(cond_scan);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
980 #endif
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
981 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
982
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
983 static gboolean
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
984 playlistwin_press(GtkWidget * widget,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
985 GdkEventButton * event,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
986 gpointer callback_data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
987 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
988 gint xpos, ypos;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
989 GtkRequisition req;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
990
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
991 gtk_window_get_position(GTK_WINDOW(playlistwin), &xpos, &ypos);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
992
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
993 if (event->button == 1 && !config.show_wm_decorations &&
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
994 ((!config.playlist_shaded &&
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
995 event->x > playlistwin_get_width() - 20 &&
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
996 event->y > config.playlist_height - 20) ||
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
997 (config.playlist_shaded &&
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
998 event->x >= playlistwin_get_width() - 31 &&
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
999 event->x < playlistwin_get_width() - 22))) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1000
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1001 if (event->type != GDK_2BUTTON_PRESS &&
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1002 event->type != GDK_3BUTTON_PRESS) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1003 playlistwin_resizing = TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1004 playlistwin_resize_x = config.playlist_width - event->x;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1005 playlistwin_resize_y = config.playlist_height - event->y;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1006 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1007 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1008 else if (event->button == 1 && REGION_L(12, 37, 29, 11)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1009 /* ADD button menu */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1010 gtk_widget_size_request(playlistwin_pladd_menu, &req);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1011 ui_manager_popup_menu_show(GTK_MENU(playlistwin_pladd_menu),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1012 xpos + 12,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1013 (ypos + playlistwin_get_height()) - 8 - req.height,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1014 event->button,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1015 event->time);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1016 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1017 else if (event->button == 1 && REGION_L(41, 66, 29, 11)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1018 /* SUB button menu */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1019 gtk_widget_size_request(playlistwin_pldel_menu, &req);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1020 ui_manager_popup_menu_show(GTK_MENU(playlistwin_pldel_menu),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1021 xpos + 40,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1022 (ypos + playlistwin_get_height()) - 8 - req.height,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1023 event->button,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1024 event->time);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1025 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1026 else if (event->button == 1 && REGION_L(70, 95, 29, 11)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1027 /* SEL button menu */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1028 gtk_widget_size_request(playlistwin_plsel_menu, &req);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1029 ui_manager_popup_menu_show(GTK_MENU(playlistwin_plsel_menu),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1030 xpos + 68,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1031 (ypos + playlistwin_get_height()) - 8 - req.height,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1032 event->button,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1033 event->time);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1034 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1035 else if (event->button == 1 && REGION_L(99, 124, 29, 11)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1036 /* MISC button menu */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1037 gtk_widget_size_request(playlistwin_plsort_menu, &req);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1038 ui_manager_popup_menu_show(GTK_MENU(playlistwin_plsort_menu),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1039 xpos + 100,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1040 (ypos + playlistwin_get_height()) - 8 - req.height,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1041 event->button,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1042 event->time);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1043 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1044 else if (event->button == 1 && REGION_R(46, 23, 29, 11)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1045 /* LIST button menu */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1046 gtk_widget_size_request(playlistwin_pllist_menu, &req);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1047 ui_manager_popup_menu_show(GTK_MENU(playlistwin_pllist_menu),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1048 xpos + playlistwin_get_width() - req.width - 12,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1049 (ypos + playlistwin_get_height()) - 8 - req.height,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1050 event->button,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1051 event->time);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1052 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1053 else if (event->button == 1 && event->type == GDK_BUTTON_PRESS &&
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1054 (config.easy_move || event->y < 14))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1055 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1056 return FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1057 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1058 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1059 && event->y < 14) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1060 /* double click on title bar */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1061 playlistwin_shade_toggle();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1062 if (dock_is_moving(GTK_WINDOW(playlistwin)))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1063 dock_move_release(GTK_WINDOW(playlistwin));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1064 return TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1065 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1066 else if (event->button == 3) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1067 /*
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1068 * Pop up the main menu a few pixels down to avoid
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1069 * anything to be selected initially.
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1070 */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1071 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), event->x_root,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1072 event->y_root + 2, 3, event->time);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1073 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1074
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1075 return TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1076 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1077
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1078 static gboolean
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1079 playlistwin_delete(GtkWidget * w, gpointer data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1080 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1081 playlistwin_hide();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1082 return TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1083 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1084
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1085 static gboolean
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1086 playlistwin_keypress_up_down_handler(UiSkinnedPlaylist * pl,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1087 gboolean up, guint state)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1088 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1089 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1090 if ((!(pl->prev_selected || pl->first) && up) ||
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1091 ((pl->prev_selected >= aud_playlist_get_length(playlist) - 1) && !up))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1092 return FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1093
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1094 if ((state & GDK_MOD1_MASK) && (state & GDK_SHIFT_MASK))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1095 return FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1096 if (!(state & GDK_MOD1_MASK))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1097 aud_playlist_select_all(playlist, FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1098
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1099 if (pl->prev_selected == -1 ||
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1100 (!playlistwin_item_visible(pl->prev_selected) &&
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1101 !(state & GDK_SHIFT_MASK && pl->prev_min != -1))) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1102 pl->prev_selected = pl->first;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1103 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1104 else if (state & GDK_SHIFT_MASK) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1105 if (pl->prev_min == -1) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1106 pl->prev_max = pl->prev_selected;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1107 pl->prev_min = pl->prev_selected;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1108 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1109 pl->prev_max += (up ? -1 : 1);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1110 pl->prev_max =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1111 CLAMP(pl->prev_max, 0, aud_playlist_get_length(playlist) - 1);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1112
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1113 pl->first = MIN(pl->first, pl->prev_max);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1114 pl->first = MAX(pl->first, pl->prev_max -
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1115 pl->num_visible + 1);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1116 aud_playlist_select_range(playlist, pl->prev_min, pl->prev_max, TRUE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1117 return TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1118 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1119 else if (state & GDK_MOD1_MASK) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1120 if (up)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1121 ui_skinned_playlist_move_up(pl);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1122 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1123 ui_skinned_playlist_move_down(pl);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1124 if (pl->prev_min < pl->first)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1125 pl->first = pl->prev_min;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1126 else if (pl->prev_max >= (pl->first + pl->num_visible))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1127 pl->first = pl->prev_max - pl->num_visible + 1;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1128 return TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1129 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1130 else if (up)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1131 pl->prev_selected--;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1132 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1133 pl->prev_selected++;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1134
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1135 pl->prev_selected =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1136 CLAMP(pl->prev_selected, 0, aud_playlist_get_length(playlist) - 1);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1137
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1138 if (pl->prev_selected < pl->first)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1139 pl->first--;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1140 else if (pl->prev_selected >= (pl->first + pl->num_visible))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1141 pl->first++;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1142
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1143 aud_playlist_select_range(playlist, pl->prev_selected, pl->prev_selected, TRUE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1144 pl->prev_min = -1;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1145
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1146 return TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1147 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1148
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1149 /* FIXME: Handle the keys through menu */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1150
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1151 static gboolean
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1152 playlistwin_keypress(GtkWidget * w, GdkEventKey * event, gpointer data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1153 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1154 g_return_val_if_fail(UI_SKINNED_IS_PLAYLIST(playlistwin_list), FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1155 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1156
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1157 guint keyval;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1158 gboolean refresh = FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1159 guint cur_pos;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1160
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1161 if (config.playlist_shaded)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1162 return FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1163
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1164 switch (keyval = event->keyval) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1165 case GDK_KP_Up:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1166 case GDK_KP_Down:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1167 case GDK_Up:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1168 case GDK_Down:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1169 refresh = playlistwin_keypress_up_down_handler(UI_SKINNED_PLAYLIST(playlistwin_list),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1170 keyval == GDK_Up
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1171 || keyval == GDK_KP_Up,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1172 event->state);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1173 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1174 case GDK_Page_Up:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1175 playlistwin_scroll(-UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1176 refresh = TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1177 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1178 case GDK_Page_Down:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1179 playlistwin_scroll(UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1180 refresh = TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1181 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1182 case GDK_Home:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1183 UI_SKINNED_PLAYLIST(playlistwin_list)->first = 0;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1184 refresh = TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1185 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1186 case GDK_End:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1187 UI_SKINNED_PLAYLIST(playlistwin_list)->first =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1188 aud_playlist_get_length(playlist) - UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1189 refresh = TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1190 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1191 case GDK_Return:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1192 if (UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected > -1
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1193 && playlistwin_item_visible(UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1194 aud_playlist_set_position(playlist, UI_SKINNED_PLAYLIST(playlistwin_list)->prev_selected);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1195 if (!audacious_drct_get_playing())
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1196 audacious_drct_initiate();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1197 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1198 refresh = TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1199 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1200 case GDK_3:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1201 if (event->state & GDK_CONTROL_MASK)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1202 playlistwin_fileinfo();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1203 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1204 case GDK_Delete:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1205 if (event->state & GDK_CONTROL_MASK)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1206 aud_playlist_delete(playlist, TRUE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1207 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1208 aud_playlist_delete(playlist, FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1209 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1210 case GDK_Insert:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1211 if (event->state & GDK_MOD1_MASK)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1212 mainwin_show_add_url_window();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1213 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1214 playlistwin_show_filebrowser();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1215 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1216 case GDK_Left:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1217 case GDK_KP_Left:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1218 case GDK_KP_7:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1219 if (aud_playlist_get_current_length(playlist) != -1)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1220 audacious_drct_seek(CLAMP
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1221 (audacious_drct_get_time() - 5000, 0,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1222 aud_playlist_get_current_length(playlist)));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1223 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1224 case GDK_Right:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1225 case GDK_KP_Right:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1226 case GDK_KP_9:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1227 if (aud_playlist_get_current_length(playlist) != -1)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1228 audacious_drct_seek(CLAMP
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1229 (audacious_drct_get_time() + 5000, 0,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1230 aud_playlist_get_current_length(playlist)));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1231 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1232 case GDK_KP_4:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1233 aud_playlist_prev(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1234 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1235 case GDK_KP_6:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1236 aud_playlist_next(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1237 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1238
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1239 case GDK_Escape:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1240 mainwin_minimize_cb();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1241 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1242 case GDK_Tab:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1243 if (event->state & GDK_CONTROL_MASK) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1244 if (config.player_visible)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1245 gtk_window_present(GTK_WINDOW(mainwin));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1246 else if (config.equalizer_visible)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1247 gtk_window_present(GTK_WINDOW(equalizerwin));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1248 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1249 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1250 case GDK_space:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1251 cur_pos=aud_playlist_get_position(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1252 UI_SKINNED_PLAYLIST(playlistwin_list)->first =
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1253 cur_pos - (UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible >> 1);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1254 refresh = TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1255 break;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1256 default:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1257 return FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1258 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1259 #if 0
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1260 if (refresh) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1261 g_cond_signal(cond_scan);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1262 playlistwin_update_list(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1263 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1264 #endif
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1265 return TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1266 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1267
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1268 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1269 playlistwin_hide_timer(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1270 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1271 ui_skinned_textbox_set_text(playlistwin_time_min, " ");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1272 ui_skinned_textbox_set_text(playlistwin_time_sec, " ");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1273 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1274
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1275 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1276 playlistwin_set_time(gint time, gint length, TimerMode mode)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1277 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1278 gchar *text, sign;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1279
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1280 if (mode == TIMER_REMAINING && length != -1) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1281 time = length - time;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1282 sign = '-';
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1283 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1284 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1285 sign = ' ';
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1286
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1287 time /= 1000;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1288
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1289 if (time < 0)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1290 time = 0;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1291 if (time > 99 * 60)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1292 time /= 60;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1293
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1294 text = g_strdup_printf("%c%-2.2d", sign, time / 60);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1295 ui_skinned_textbox_set_text(playlistwin_time_min, text);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1296 g_free(text);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1297
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1298 text = g_strdup_printf("%-2.2d", time % 60);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1299 ui_skinned_textbox_set_text(playlistwin_time_sec, text);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1300 g_free(text);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1301 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1302
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1303 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1304 playlistwin_drag_motion(GtkWidget * widget,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1305 GdkDragContext * context,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1306 gint x, gint y,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1307 GtkSelectionData * selection_data,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1308 guint info, guint time, gpointer user_data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1309 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1310 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1311 UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion = TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1312 UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion_x = x;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1313 UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion_y = y;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1314 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1315 playlistwin_update_list(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1316 playlistwin_hint_flag = TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1317 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1318
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1319 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1320 playlistwin_drag_end(GtkWidget * widget,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1321 GdkDragContext * context, gpointer user_data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1322 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1323 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list))
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1324 UI_SKINNED_PLAYLIST(playlistwin_list)->drag_motion = FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1325 playlistwin_hint_flag = FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1326 playlistwin_update_list(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1327 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1328
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1329 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1330 playlistwin_drag_data_received(GtkWidget * widget,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1331 GdkDragContext * context,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1332 gint x, gint y,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1333 GtkSelectionData *
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1334 selection_data, guint info,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1335 guint time, gpointer user_data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1336 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1337 gint pos;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1338 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1339
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1340 g_return_if_fail(selection_data);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1341
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1342 if (!selection_data->data) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1343 g_message("Received no DND data!");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1344 return;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1345 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1346 if (UI_SKINNED_IS_PLAYLIST(playlistwin_list) &&
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1347 (x < playlistwin_get_width() - 20 || y < config.playlist_height - 38)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1348 pos = y / UI_SKINNED_PLAYLIST(playlistwin_list)->fheight + UI_SKINNED_PLAYLIST(playlistwin_list)->first;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1349
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1350 pos = MIN(pos, aud_playlist_get_length(playlist));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1351 aud_playlist_ins_url(playlist, (gchar *) selection_data->data, pos);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1352 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1353 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1354 aud_playlist_add_url(playlist, (gchar *) selection_data->data);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1355 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1356
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1357 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1358 local_playlist_prev(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1359 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1360 aud_playlist_prev(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1361 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1362
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1363 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1364 local_playlist_next(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1365 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1366 aud_playlist_next(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1367 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1368
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1369 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1370 playlistwin_create_widgets(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1371 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1372 /* This function creates the custom widgets used by the playlist editor */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1373
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1374 /* text box for displaying song title in shaded mode */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1375 playlistwin_sinfo = ui_skinned_textbox_new(SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1376 4, 4, playlistwin_get_width() - 35, TRUE, SKIN_TEXT);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1377
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2640
diff changeset
1378 playlistwin_set_sinfo_font(config.playlist_font);
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1379
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1380 playlistwin_shade = ui_skinned_button_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1381 /* shade/unshade window push button */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1382 if (config.playlist_shaded)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1383 ui_skinned_push_button_setup(playlistwin_shade, SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1384 playlistwin_get_width() - 21, 3,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1385 9, 9, 128, 45, 150, 42, SKIN_PLEDIT);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1386 else
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1387 ui_skinned_push_button_setup(playlistwin_shade, SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1388 playlistwin_get_width() - 21, 3,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1389 9, 9, 157, 3, 62, 42, SKIN_PLEDIT);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1390
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1391 g_signal_connect(playlistwin_shade, "clicked", playlistwin_shade_toggle, NULL );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1392
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1393 /* close window push button */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1394 playlistwin_close = ui_skinned_button_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1395 ui_skinned_push_button_setup(playlistwin_close, SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1396 playlistwin_get_width() - 11, 3, 9, 9,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1397 config.playlist_shaded ? 138 : 167,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1398 config.playlist_shaded ? 45 : 3, 52, 42, SKIN_PLEDIT);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1399
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1400 g_signal_connect(playlistwin_close, "clicked", playlistwin_hide, NULL );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1401
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1402 /* playlist list box */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1403 playlistwin_list = ui_skinned_playlist_new(SKINNED_WINDOW(playlistwin)->fixed, 12, 20,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1404 playlistwin_get_width() - 31,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1405 config.playlist_height - 58);
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2640
diff changeset
1406 ui_skinned_playlist_set_font(config.playlist_font);
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1407
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1408 /* playlist list box slider */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1409 playlistwin_slider = ui_skinned_playlist_slider_new(SKINNED_WINDOW(playlistwin)->fixed, playlistwin_get_width() - 15,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1410 20, config.playlist_height - 58);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1411
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1412 /* track time (minute) */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1413 playlistwin_time_min = ui_skinned_textbox_new(SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1414 playlistwin_get_width() - 82,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1415 config.playlist_height - 15, 15, FALSE, SKIN_TEXT);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1416 g_signal_connect(playlistwin_time_min, "button-press-event", G_CALLBACK(change_timer_mode_cb), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1417
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1418 /* track time (second) */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1419 playlistwin_time_sec = ui_skinned_textbox_new(SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1420 playlistwin_get_width() - 64,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1421 config.playlist_height - 15, 10, FALSE, SKIN_TEXT);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1422 g_signal_connect(playlistwin_time_sec, "button-press-event", G_CALLBACK(change_timer_mode_cb), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1423
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1424 /* playlist information (current track length / total track length) */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1425 playlistwin_info = ui_skinned_textbox_new(SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1426 playlistwin_get_width() - 143,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1427 config.playlist_height - 28, 90, FALSE, SKIN_TEXT);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1428
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1429 /* mini play control buttons at right bottom corner */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1430
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1431 /* rewind button */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1432 playlistwin_srew = ui_skinned_button_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1433 ui_skinned_small_button_setup(playlistwin_srew, SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1434 playlistwin_get_width() - 144,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1435 config.playlist_height - 16, 8, 7);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1436 g_signal_connect(playlistwin_srew, "clicked", local_playlist_prev, NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1437
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1438 /* play button */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1439 playlistwin_splay = ui_skinned_button_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1440 ui_skinned_small_button_setup(playlistwin_splay, SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1441 playlistwin_get_width() - 138,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1442 config.playlist_height - 16, 10, 7);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1443 g_signal_connect(playlistwin_splay, "clicked", mainwin_play_pushed, NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1444
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1445 /* pause button */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1446 playlistwin_spause = ui_skinned_button_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1447 ui_skinned_small_button_setup(playlistwin_spause, SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1448 playlistwin_get_width() - 128,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1449 config.playlist_height - 16, 10, 7);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1450 g_signal_connect(playlistwin_spause, "clicked", audacious_drct_pause, NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1451
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1452 /* stop button */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1453 playlistwin_sstop = ui_skinned_button_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1454 ui_skinned_small_button_setup(playlistwin_sstop, SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1455 playlistwin_get_width() - 118,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1456 config.playlist_height - 16, 9, 7);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1457 g_signal_connect(playlistwin_sstop, "clicked", mainwin_stop_pushed, NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1458
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1459 /* forward button */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1460 playlistwin_sfwd = ui_skinned_button_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1461 ui_skinned_small_button_setup(playlistwin_sfwd, SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1462 playlistwin_get_width() - 109,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1463 config.playlist_height - 16, 8, 7);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1464 g_signal_connect(playlistwin_sfwd, "clicked", local_playlist_next, NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1465
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1466 /* eject button */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1467 playlistwin_seject = ui_skinned_button_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1468 ui_skinned_small_button_setup(playlistwin_seject, SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1469 playlistwin_get_width() - 100,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1470 config.playlist_height - 16, 9, 7);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1471 g_signal_connect(playlistwin_seject, "clicked", mainwin_eject_pushed, NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1472
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1473 playlistwin_sscroll_up = ui_skinned_button_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1474 ui_skinned_small_button_setup(playlistwin_sscroll_up, SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1475 playlistwin_get_width() - 14,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1476 config.playlist_height - 35, 8, 5);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1477 g_signal_connect(playlistwin_sscroll_up, "clicked", playlistwin_scroll_up_pushed, NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1478
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1479 playlistwin_sscroll_down = ui_skinned_button_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1480 ui_skinned_small_button_setup(playlistwin_sscroll_down, SKINNED_WINDOW(playlistwin)->fixed,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1481 playlistwin_get_width() - 14,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1482 config.playlist_height - 30, 8, 5);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1483 g_signal_connect(playlistwin_sscroll_down, "clicked", playlistwin_scroll_down_pushed, NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1484
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1485 ui_playlist_evlistener_init();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1486 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1487
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1488 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1489 selection_received(GtkWidget * widget,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1490 GtkSelectionData * selection_data, gpointer data)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1491 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1492 if (selection_data->type == GDK_SELECTION_TYPE_STRING &&
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1493 selection_data->length > 0)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1494 aud_playlist_add_url(aud_playlist_get_active(), (gchar *) selection_data->data);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1495 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1496
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1497 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1498 playlistwin_create_window(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1499 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1500 GdkPixbuf *icon;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1501
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1502 playlistwin = ui_skinned_window_new("playlist");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1503 gtk_window_set_title(GTK_WINDOW(playlistwin), _("Audacious Playlist Editor"));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1504 gtk_window_set_role(GTK_WINDOW(playlistwin), "playlist");
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1505 gtk_window_set_default_size(GTK_WINDOW(playlistwin),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1506 playlistwin_get_width(),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1507 playlistwin_get_height());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1508 gtk_window_set_resizable(GTK_WINDOW(playlistwin), TRUE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1509 playlistwin_set_geometry_hints(config.playlist_shaded);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1510
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1511 gtk_window_set_transient_for(GTK_WINDOW(playlistwin),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1512 GTK_WINDOW(mainwin));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1513 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(playlistwin), TRUE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1514
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1515 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_playlist_icon);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1516 gtk_window_set_icon(GTK_WINDOW(playlistwin), icon);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1517 g_object_unref(icon);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1518
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1519 if (config.playlist_x != -1 && config.save_window_position)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1520 gtk_window_move(GTK_WINDOW(playlistwin),
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1521 config.playlist_x, config.playlist_y);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1522
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1523 gtk_widget_add_events(playlistwin, GDK_POINTER_MOTION_MASK |
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1524 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK |
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1525 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1526 GDK_SCROLL_MASK | GDK_VISIBILITY_NOTIFY_MASK);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1527 gtk_widget_realize(playlistwin);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1528
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1529 g_signal_connect(playlistwin, "delete_event",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1530 G_CALLBACK(playlistwin_delete), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1531 g_signal_connect(playlistwin, "button_press_event",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1532 G_CALLBACK(playlistwin_press), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1533 g_signal_connect(playlistwin, "button_release_event",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1534 G_CALLBACK(playlistwin_release), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1535 g_signal_connect(playlistwin, "scroll_event",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1536 G_CALLBACK(playlistwin_scrolled), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1537 g_signal_connect(playlistwin, "motion_notify_event",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1538 G_CALLBACK(playlistwin_motion), NULL);
2629
2ce9e17525dc make dnd working in playlistwin
Tomasz Mon <desowin@gmail.com>
parents: 2621
diff changeset
1539
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1540 aud_drag_dest_set(playlistwin);
2629
2ce9e17525dc make dnd working in playlistwin
Tomasz Mon <desowin@gmail.com>
parents: 2621
diff changeset
1541
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1542 /* DnD stuff */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1543 g_signal_connect(playlistwin, "drag-leave",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1544 G_CALLBACK(playlistwin_drag_end), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1545 g_signal_connect(playlistwin, "drag-data-delete",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1546 G_CALLBACK(playlistwin_drag_end), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1547 g_signal_connect(playlistwin, "drag-end",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1548 G_CALLBACK(playlistwin_drag_end), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1549 g_signal_connect(playlistwin, "drag-drop",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1550 G_CALLBACK(playlistwin_drag_end), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1551 g_signal_connect(playlistwin, "drag-data-received",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1552 G_CALLBACK(playlistwin_drag_data_received), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1553 g_signal_connect(playlistwin, "drag-motion",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1554 G_CALLBACK(playlistwin_drag_motion), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1555
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1556 g_signal_connect(playlistwin, "key_press_event",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1557 G_CALLBACK(playlistwin_keypress), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1558 g_signal_connect(playlistwin, "selection_received",
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1559 G_CALLBACK(selection_received), NULL);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1560 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1561
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1562 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1563 playlistwin_create(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1564 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1565 resize_mutex = g_mutex_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1566 playlistwin_create_window();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1567
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1568 playlistwin_create_widgets();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1569 playlistwin_update_info(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1570
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1571 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), ui_manager_get_accel_group());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1572 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1573
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1574
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1575 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1576 playlistwin_show(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1577 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1578 gtk_window_move(GTK_WINDOW(playlistwin), config.playlist_x, config.playlist_y);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1579 GtkAction *action = gtk_action_group_get_action(
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1580 toggleaction_group_others , "show playlist editor" );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1581 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , TRUE );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1582
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1583 config.playlist_visible = TRUE;
2668
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2658
diff changeset
1584 ui_skinned_button_set_inside(mainwin_pl, TRUE);
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1585
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1586 playlistwin_set_toprow(0);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1587 aud_playlist_check_pos_current(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1588
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1589 gtk_widget_show_all(playlistwin);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1590 if (!config.playlist_shaded)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1591 gtk_widget_hide(playlistwin_sinfo);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1592 gtk_window_present(GTK_WINDOW(playlistwin));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1593 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1594
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1595 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1596 playlistwin_hide(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1597 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1598 GtkAction *action = gtk_action_group_get_action(
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1599 toggleaction_group_others , "show playlist editor" );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1600 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , FALSE );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1601
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1602 gtk_widget_hide(playlistwin);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1603 config.playlist_visible = FALSE;
2668
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2658
diff changeset
1604 ui_skinned_button_set_inside(mainwin_pl, FALSE);
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1605
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1606 if ( config.player_visible )
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1607 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1608 gtk_window_present(GTK_WINDOW(mainwin));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1609 gtk_widget_grab_focus(mainwin);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1610 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1611 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1612
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1613 void action_playlist_track_info(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1614 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1615 playlistwin_fileinfo();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1616 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1617
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1618 void action_queue_toggle(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1619 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1620 aud_playlist_queue(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1621 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1622
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1623 void action_playlist_sort_by_playlist_entry(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1624 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1625 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1626
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1627 aud_playlist_sort(playlist, PLAYLIST_SORT_PLAYLIST);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1628 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1629 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1630
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1631 void action_playlist_sort_by_track_number(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1632 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1633 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1634
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1635 aud_playlist_sort(playlist, PLAYLIST_SORT_TRACK);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1636 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1637 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1638
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1639 void action_playlist_sort_by_title(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1640 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1641 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1642
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1643 aud_playlist_sort(playlist, PLAYLIST_SORT_TITLE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1644 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1645 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1646
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1647 void action_playlist_sort_by_artist(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1648 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1649 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1650
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1651 aud_playlist_sort(playlist, PLAYLIST_SORT_ARTIST);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1652 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1653 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1654
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1655 void action_playlist_sort_by_full_path(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1656 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1657 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1658
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1659 aud_playlist_sort(playlist, PLAYLIST_SORT_PATH);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1660 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1661 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1662
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1663 void action_playlist_sort_by_date(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1664 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1665 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1666
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1667 aud_playlist_sort(playlist, PLAYLIST_SORT_DATE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1668 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1669 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1670
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1671 void action_playlist_sort_by_filename(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1672 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1673 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1674
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1675 aud_playlist_sort(playlist, PLAYLIST_SORT_FILENAME);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1676 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1677 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1678
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1679 void action_playlist_sort_selected_by_playlist_entry(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1680 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1681 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1682
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1683 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_PLAYLIST);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1684 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1685 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1686
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1687 void action_playlist_sort_selected_by_track_number(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1688 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1689 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1690
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1691 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_TRACK);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1692 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1693 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1694
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1695 void action_playlist_sort_selected_by_title(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1696 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1697 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1698
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1699 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_TITLE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1700 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1701 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1702
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1703 void action_playlist_sort_selected_by_artist(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1704 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1705 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1706
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1707 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_ARTIST);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1708 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1709 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1710
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1711 void action_playlist_sort_selected_by_full_path(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1712 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1713 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1714
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1715 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_PATH);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1716 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1717 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1718
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1719 void action_playlist_sort_selected_by_date(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1720 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1721 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1722
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1723 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_DATE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1724 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1725 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1726
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1727 void action_playlist_sort_selected_by_filename(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1728 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1729 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1730
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1731 aud_playlist_sort_selected(playlist, PLAYLIST_SORT_FILENAME);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1732 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1733 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1734
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1735 void action_playlist_randomize_list(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1736 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1737 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1738
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1739 aud_playlist_random(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1740 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1741 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1742
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1743 void action_playlist_reverse_list(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1744 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1745 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1746
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1747 aud_playlist_reverse(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1748 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1749 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1750
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1751 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1752 action_playlist_clear_queue(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1753 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1754 aud_playlist_clear_queue(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1755 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1756
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1757 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1758 action_playlist_remove_unavailable(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1759 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1760 aud_playlist_remove_dead_files(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1761 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1762
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1763 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1764 action_playlist_remove_dupes_by_title(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1765 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1766 aud_playlist_remove_duplicates(aud_playlist_get_active(), PLAYLIST_DUPS_TITLE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1767 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1768
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1769 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1770 action_playlist_remove_dupes_by_filename(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1771 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1772 aud_playlist_remove_duplicates(aud_playlist_get_active(), PLAYLIST_DUPS_FILENAME);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1773 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1774
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1775 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1776 action_playlist_remove_dupes_by_full_path(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1777 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1778 aud_playlist_remove_duplicates(aud_playlist_get_active(), PLAYLIST_DUPS_PATH);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1779 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1780
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1781 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1782 action_playlist_remove_all(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1783 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1784 aud_playlist_clear(aud_playlist_get_active());
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1785
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1786 /* XXX -- should this really be coupled here? -nenolod */
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1787 mainwin_clear_song_info();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1788 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1789
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1790 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1791 action_playlist_remove_selected(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1792 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1793 aud_playlist_delete(aud_playlist_get_active(), FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1794 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1795
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1796 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1797 action_playlist_remove_unselected(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1798 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1799 aud_playlist_delete(aud_playlist_get_active(), TRUE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1800 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1801
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1802 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1803 action_playlist_add_files(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1804 {
2640
dd255ad225f3 use more hooks
Tomasz Mon <desowin@gmail.com>
parents: 2639
diff changeset
1805 gboolean button = FALSE; /* FALSE = NO_PLAY_BUTTON */
dd255ad225f3 use more hooks
Tomasz Mon <desowin@gmail.com>
parents: 2639
diff changeset
1806 aud_hook_call("filebrowser show", &button);
2620
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1807 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1808
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1809 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1810 action_playlist_add_url(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1811 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1812 mainwin_show_add_url_window();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1813 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1814
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1815 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1816 action_playlist_new( void )
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1817 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1818 Playlist *new_pl = aud_playlist_new();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1819 aud_playlist_add_playlist(new_pl);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1820 aud_playlist_select_playlist(new_pl);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1821 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1822
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1823 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1824 action_playlist_prev( void )
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1825 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1826 aud_playlist_select_prev();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1827 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1828
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1829 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1830 action_playlist_next( void )
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1831 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1832 aud_playlist_select_next();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1833 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1834
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1835 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1836 action_playlist_delete( void )
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1837 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1838 aud_playlist_remove_playlist( aud_playlist_get_active() );
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1839 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1840
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1841 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1842 action_playlist_save_list(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1843 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1844 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1845
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1846 playlistwin_select_playlist_to_save(aud_playlist_get_current_name(playlist));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1847 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1848
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1849 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1850 action_playlist_save_default_list(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1851 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1852 #if 0
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1853 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1854
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1855 aud_playlist_save(playlist, aud_paths[BMP_PATH_PLAYLIST_FILE]);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1856 #endif
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1857 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1858
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1859 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1860 action_playlist_load_list(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1861 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1862 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1863
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1864 playlistwin_select_playlist_to_load(aud_playlist_get_current_name(playlist));
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1865 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1866
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1867 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1868 action_playlist_refresh_list(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1869 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1870 Playlist *playlist = aud_playlist_get_active();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1871
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1872 aud_playlist_read_info_selection(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1873 playlistwin_update_list(playlist);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1874 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1875
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1876 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1877 action_open_list_manager(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1878 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1879 #if 0
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1880 playlist_manager_ui_show();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1881 #endif
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1882 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1883
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1884 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1885 action_playlist_search_and_select(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1886 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1887 playlistwin_select_search();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1888 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1889
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1890 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1891 action_playlist_invert_selection(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1892 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1893 playlistwin_inverse_selection();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1894 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1895
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1896 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1897 action_playlist_select_none(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1898 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1899 playlistwin_select_none();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1900 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1901
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1902 void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1903 action_playlist_select_all(void)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1904 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1905 playlistwin_select_all();
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1906 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1907
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1908
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1909 static void
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1910 playlistwin_select_search_cbt_cb(GtkWidget *called_cbt, gpointer other_cbt)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1911 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1912 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(called_cbt)) == TRUE)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1913 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(other_cbt), FALSE);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1914 return;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1915 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1916
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1917 static gboolean
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1918 playlistwin_select_search_kp_cb(GtkWidget *entry, GdkEventKey *event,
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1919 gpointer searchdlg_win)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1920 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1921 switch (event->keyval)
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1922 {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1923 case GDK_Return:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1924 if (gtk_im_context_filter_keypress (GTK_ENTRY (entry)->im_context, event)) {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1925 GTK_ENTRY (entry)->need_im_reset = TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1926 return TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1927 } else {
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1928 gtk_dialog_response(GTK_DIALOG(searchdlg_win), GTK_RESPONSE_ACCEPT);
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1929 return TRUE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1930 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1931 default:
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1932 return FALSE;
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1933 }
2d6e08c81c09 add playlistwindow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1934 }