annotate audacious/playlist_manager.c @ 2201:39e9c8e2745d trunk

[svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
author giacomo
date Fri, 22 Dec 2006 16:29:35 -0800
parents
children d1804718c5cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2201
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
2 * Copyright (C) 2005-2006 Audacious development team.
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
3 *
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
6 * the Free Software Foundation; under version 2 of the License.
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
7 *
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
11 * GNU General Public License for more details.
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
12 *
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
13 * You should have received a copy of the GNU General Public License
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
14 * along with this program; if not, write to the Free Software
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
16 */
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
17
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
18 #include "playlist_manager.h"
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
19 #include "ui_playlist.h"
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
20 #include "playlist.h"
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
21 #include "mainwin.h"
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
22
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
23 #include <glib.h>
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
24 #include <glib/gi18n.h>
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
25 #include <gtk/gtk.h>
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
26
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
27
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
28 /* TODO: we're accessing playlist_ stuff directly here, and storing a pointer to
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
29 each Playlist. Data consistency should be always checked, cause playlists could
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
30 be deleted by user without using the playlist manager, while the latter is active */
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
31
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
32
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
33 enum
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
34 {
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
35 PLLIST_COL_NAME = 0,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
36 PLLIST_COL_ENTRIESNUM,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
37 PLLIST_COL_PLPOINTER,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
38 PLLIST_NUMCOLS
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
39 };
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
40
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
41
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
42 static void
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
43 playlist_manager_populate ( GtkListStore * store )
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
44 {
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
45 GList *playlists = NULL;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
46 GtkTreeIter iter;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
47
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
48 playlists = playlist_get_playlists();
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
49 while ( playlists != NULL )
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
50 {
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
51 GList *entries = NULL;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
52 gint entriesnum = 0;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
53 gchar *pl_name = NULL;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
54 Playlist *playlist = (Playlist*)playlists->data;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
55
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
56 PLAYLIST_LOCK(playlist->mutex);
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
57 /* for each playlist, pick name and number of entries */
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
58 pl_name = (gchar*)playlist_get_current_name( playlist );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
59 for (entries = playlist->entries; entries; entries = g_list_next(entries))
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
60 entriesnum++;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
61 PLAYLIST_UNLOCK(playlist->mutex);
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
62
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
63 gtk_list_store_append( store , &iter );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
64 gtk_list_store_set( store, &iter,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
65 PLLIST_COL_NAME , pl_name ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
66 PLLIST_COL_ENTRIESNUM , entriesnum ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
67 PLLIST_COL_PLPOINTER , playlist , -1 );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
68 playlists = g_list_next(playlists);
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
69 }
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
70 return;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
71 }
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
72
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
73
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
74 static void
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
75 playlist_manager_cb_new ( gpointer listview )
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
76 {
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
77 GList *playlists = NULL;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
78 Playlist *newpl = NULL;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
79 GtkTreeIter iter;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
80 GtkListStore *store;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
81 gchar *pl_name = NULL;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
82
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
83 newpl = playlist_new();
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
84 playlists = playlist_get_playlists();
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
85 playlist_add_playlist( newpl );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
86 pl_name = (gchar*)playlist_get_current_name( newpl );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
87
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
88 store = (GtkListStore*)gtk_tree_view_get_model( GTK_TREE_VIEW(listview) );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
89 gtk_list_store_append( store , &iter );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
90 gtk_list_store_set( store, &iter,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
91 PLLIST_COL_NAME , pl_name ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
92 PLLIST_COL_ENTRIESNUM , 0 ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
93 PLLIST_COL_PLPOINTER , newpl , -1 );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
94 return;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
95 }
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
96
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
97
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
98 static void
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
99 playlist_manager_cb_del ( gpointer listview )
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
100 {
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
101 GtkTreeSelection *listsel = gtk_tree_view_get_selection( GTK_TREE_VIEW(listview) );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
102 GtkTreeModel *store;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
103 GtkTreeIter iter;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
104
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
105 if ( gtk_tree_selection_get_selected( listsel , &store , &iter ) == TRUE )
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
106 {
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
107 Playlist *playlist = NULL;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
108 gtk_tree_model_get( store, &iter, PLLIST_COL_PLPOINTER , &playlist , -1 );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
109
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
110 if ( gtk_tree_model_iter_n_children( store , NULL ) < 2 )
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
111 return; /* do not delete the last playlist available */
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
112
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
113 gtk_list_store_remove( (GtkListStore*)store , &iter );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
114
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
115 /* if the playlist removed is the active one, switch to the next */
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
116 if ( playlist == playlist_get_active() )
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
117 playlist_select_next();
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
118
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
119 /* TODO: check that playlist has not been freed already!! */
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
120 playlist_remove_playlist( playlist );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
121 }
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
122
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
123 return;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
124 }
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
125
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
126
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
127 void
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
128 playlist_manager_cb_lv_dclick ( GtkTreeView * lv , GtkTreePath * path ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
129 GtkTreeViewColumn * col , gpointer userdata )
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
130 {
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
131 GtkTreeModel *store;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
132 GtkTreeIter iter;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
133
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
134 store = gtk_tree_view_get_model( GTK_TREE_VIEW(lv) );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
135 if ( gtk_tree_model_get_iter( store , &iter , path ) == TRUE )
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
136 {
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
137 Playlist *playlist = NULL;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
138 gtk_tree_model_get( store , &iter , PLLIST_COL_PLPOINTER , &playlist , -1 );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
139 /* TODO: check that playlist has not been freed already!! */
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
140 playlist_select_playlist( playlist );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
141 }
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
142
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
143 return;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
144 }
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
145
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
146
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
147 void
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
148 playlist_manager_ui_show ( void )
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
149 {
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
150 static GtkWidget *playman_win = NULL;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
151 GtkWidget *playman_vbox;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
152 GtkWidget *playman_pl_lv, *playman_pl_lv_frame, *playman_pl_lv_sw;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
153 GtkCellRenderer *playman_pl_lv_textrndr;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
154 GtkTreeViewColumn *playman_pl_lv_col_name, *playman_pl_lv_col_entriesnum;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
155 GtkListStore *pl_store;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
156 GtkWidget *playman_bbar_hbbox;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
157 GtkWidget *playman_bbar_bt_new, *playman_bbar_bt_del, *playman_bbar_bt_close;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
158 GdkGeometry playman_win_hints;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
159
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
160 if ( playman_win != NULL )
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
161 {
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
162 gtk_window_present( GTK_WINDOW(playman_win) );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
163 return;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
164 }
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
165
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
166 playman_win = gtk_window_new( GTK_WINDOW_TOPLEVEL );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
167 gtk_window_set_type_hint( GTK_WINDOW(playman_win), GDK_WINDOW_TYPE_HINT_DIALOG );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
168 gtk_window_set_transient_for( GTK_WINDOW(playman_win) , GTK_WINDOW(mainwin) );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
169 gtk_window_set_title( GTK_WINDOW(playman_win), _("Playlist Manager") );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
170 gtk_container_set_border_width( GTK_CONTAINER(playman_win), 10 );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
171 g_signal_connect( G_OBJECT(playman_win) , "destroy" ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
172 G_CALLBACK(gtk_widget_destroyed) , &playman_win );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
173 playman_win_hints.min_width = 400;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
174 playman_win_hints.min_height = 250;
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
175 gtk_window_set_geometry_hints( GTK_WINDOW(playman_win) , GTK_WIDGET(playman_win) ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
176 &playman_win_hints , GDK_HINT_MIN_SIZE );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
177
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
178 playman_vbox = gtk_vbox_new( FALSE , 0 );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
179 gtk_container_add( GTK_CONTAINER(playman_win) , playman_vbox );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
180
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
181 /* current liststore model
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
182 ----------------------------------------------
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
183 G_TYPE_STRING -> playlist name
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
184 G_TYPE_UINT -> number of entries in playlist
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
185 G_TYPE_POINTER -> playlist pointer (Playlist*)
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
186 ----------------------------------------------
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
187 */
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
188 pl_store = gtk_list_store_new( PLLIST_NUMCOLS , G_TYPE_STRING , G_TYPE_UINT , G_TYPE_POINTER );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
189 playlist_manager_populate( pl_store );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
190
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
191 playman_pl_lv_frame = gtk_frame_new( NULL );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
192 playman_pl_lv = gtk_tree_view_new_with_model( GTK_TREE_MODEL(pl_store) );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
193 g_object_unref( pl_store );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
194 playman_pl_lv_textrndr = gtk_cell_renderer_text_new();
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
195 playman_pl_lv_col_name = gtk_tree_view_column_new_with_attributes(
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
196 _("Playlist") , playman_pl_lv_textrndr , "text" , PLLIST_COL_NAME , NULL );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
197 gtk_tree_view_column_set_expand( GTK_TREE_VIEW_COLUMN(playman_pl_lv_col_name) , TRUE );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
198 gtk_tree_view_append_column( GTK_TREE_VIEW(playman_pl_lv), playman_pl_lv_col_name );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
199 playman_pl_lv_col_entriesnum = gtk_tree_view_column_new_with_attributes(
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
200 _("Entries") , playman_pl_lv_textrndr , "text" , PLLIST_COL_ENTRIESNUM , NULL );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
201 gtk_tree_view_column_set_expand( GTK_TREE_VIEW_COLUMN(playman_pl_lv_col_entriesnum) , FALSE );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
202 gtk_tree_view_append_column( GTK_TREE_VIEW(playman_pl_lv), playman_pl_lv_col_entriesnum );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
203 playman_pl_lv_sw = gtk_scrolled_window_new( NULL , NULL );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
204 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(playman_pl_lv_sw) ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
205 GTK_POLICY_NEVER , GTK_POLICY_ALWAYS );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
206 gtk_container_add( GTK_CONTAINER(playman_pl_lv_sw) , playman_pl_lv );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
207 gtk_container_add( GTK_CONTAINER(playman_pl_lv_frame) , playman_pl_lv_sw );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
208 gtk_box_pack_start( GTK_BOX(playman_vbox) , playman_pl_lv_frame , TRUE , TRUE , 0 );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
209
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
210 gtk_box_pack_start( GTK_BOX(playman_vbox) , gtk_hseparator_new() , FALSE , FALSE , 4 );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
211
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
212 /* button bar */
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
213 playman_bbar_hbbox = gtk_hbutton_box_new();
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
214 gtk_button_box_set_layout( GTK_BUTTON_BOX(playman_bbar_hbbox) , GTK_BUTTONBOX_START );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
215 playman_bbar_bt_new = gtk_button_new_from_stock( GTK_STOCK_NEW );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
216 playman_bbar_bt_del = gtk_button_new_from_stock( GTK_STOCK_DELETE );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
217 playman_bbar_bt_close = gtk_button_new_from_stock( GTK_STOCK_CLOSE );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
218 gtk_container_add( GTK_CONTAINER(playman_bbar_hbbox) , playman_bbar_bt_new );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
219 gtk_container_add( GTK_CONTAINER(playman_bbar_hbbox) , playman_bbar_bt_del );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
220 gtk_container_add( GTK_CONTAINER(playman_bbar_hbbox) , playman_bbar_bt_close );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
221 gtk_button_box_set_child_secondary( GTK_BUTTON_BOX(playman_bbar_hbbox) ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
222 playman_bbar_bt_close , TRUE );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
223 gtk_box_pack_start( GTK_BOX(playman_vbox) , playman_bbar_hbbox , FALSE , FALSE , 0 );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
224
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
225 g_signal_connect( G_OBJECT(playman_pl_lv) , "row-activated" ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
226 G_CALLBACK(playlist_manager_cb_lv_dclick) , NULL );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
227 g_signal_connect_swapped( G_OBJECT(playman_bbar_bt_new) , "clicked" ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
228 G_CALLBACK(playlist_manager_cb_new) , playman_pl_lv );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
229 g_signal_connect_swapped( G_OBJECT(playman_bbar_bt_del) , "clicked" ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
230 G_CALLBACK(playlist_manager_cb_del) , playman_pl_lv );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
231 g_signal_connect_swapped( G_OBJECT(playman_bbar_bt_close) , "clicked" ,
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
232 G_CALLBACK(gtk_widget_destroy) , playman_win );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
233
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
234 gtk_widget_show_all( playman_win );
39e9c8e2745d [svn] - added initial code for playlist manager, that allows to create, delete and switch playlists
giacomo
parents:
diff changeset
235 }