Mercurial > audlegacy
annotate src/audacious/ui_playlist_manager.c @ 4454:a7bf5b979a05
Remove duplicated path separator conversion (backslash to slash).
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 13 Apr 2008 07:15:07 +0300 |
parents | a3fc19130dce |
children |
rev | line source |
---|---|
2894
062324422c40
Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents:
2862
diff
changeset
|
1 /* Audacious - Cross-platform multimedia player |
062324422c40
Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents:
2862
diff
changeset
|
2 * Copyright (C) 2005-2007 Audacious development team. |
2313 | 3 * |
2894
062324422c40
Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents:
2862
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
062324422c40
Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents:
2862
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2894
diff
changeset
|
6 * the Free Software Foundation; under version 3 of the License. |
2313 | 7 * |
2894
062324422c40
Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents:
2862
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
062324422c40
Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents:
2862
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
062324422c40
Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents:
2862
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
062324422c40
Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents:
2862
diff
changeset
|
11 * GNU General Public License for more details. |
2313 | 12 * |
2894
062324422c40
Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents:
2862
diff
changeset
|
13 * You should have received a copy of the GNU General Public License |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2894
diff
changeset
|
14 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
15 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
16 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
17 * Audacious or using our public API to be a derived work. |
2313 | 18 */ |
19 | |
2499
15a1f5ee4d1c
[svn] - playlist_manager -> ui_playlist_manager, since it's a UI component.
nenolod
parents:
2313
diff
changeset
|
20 #include "ui_playlist_manager.h" |
2313 | 21 #include "ui_playlist.h" |
22 #include "playlist.h" | |
23 #include "ui_main.h" | |
24 | |
25 #include <glib.h> | |
26 #include <glib/gi18n.h> | |
27 #include <gtk/gtk.h> | |
28 #include <gdk/gdkkeysyms.h> | |
29 | |
30 | |
31 #define DISABLE_MANAGER_UPDATE() g_object_set_data(G_OBJECT(listview),"opt1",GINT_TO_POINTER(1)) | |
32 #define ENABLE_MANAGER_UPDATE() g_object_set_data(G_OBJECT(listview),"opt1",GINT_TO_POINTER(0)) | |
33 | |
34 | |
35 static GtkWidget *playman_win = NULL; | |
36 | |
37 | |
38 /* in this enum, place the columns according to visualization order | |
39 (information not displayed in columns should be placed right before PLLIST_NUMCOLS) */ | |
40 enum | |
41 { | |
2808 | 42 PLLIST_COL_NAME = 0, |
43 PLLIST_COL_ENTRIESNUM, | |
3623
3625e0085d7f
Change PLLIST_COL_PLPOINTER to PLLIST_PLPOINTER for consistency
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3622
diff
changeset
|
44 PLLIST_PLPOINTER, |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
45 PLLIST_TEXT_WEIGHT, |
2808 | 46 PLLIST_NUMCOLS |
2313 | 47 }; |
48 | |
49 | |
3625
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
50 static GtkTreeIter |
2313 | 51 playlist_manager_populate ( GtkListStore * store ) |
52 { | |
2808 | 53 GList *playlists = NULL; |
3624
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
54 Playlist *active, *iter_playlist, *next_playlist; |
3625
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
55 GtkTreeIter iter, insert, next, active_iter; |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
56 gboolean valid, have_active_iter; |
2313 | 57 |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
58 active = playlist_get_active(); |
2808 | 59 playlists = playlist_get_playlists(); |
3624
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
60 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(store) , &iter ); |
3625
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
61 have_active_iter = FALSE; |
2808 | 62 while ( playlists != NULL ) |
63 { | |
64 GList *entries = NULL; | |
65 gint entriesnum = 0; | |
66 gchar *pl_name = NULL; | |
67 Playlist *playlist = (Playlist*)playlists->data; | |
2313 | 68 |
4092
a3fc19130dce
add workaround to deadlock which occurs when "create a new playlist with matching entries" is checked in search and select dialog.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3625
diff
changeset
|
69 if(playlist != active) //XXX the active playlist has been locked in playlist_new_from_selected() |
a3fc19130dce
add workaround to deadlock which occurs when "create a new playlist with matching entries" is checked in search and select dialog.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3625
diff
changeset
|
70 PLAYLIST_LOCK(playlist); |
a3fc19130dce
add workaround to deadlock which occurs when "create a new playlist with matching entries" is checked in search and select dialog.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3625
diff
changeset
|
71 |
2808 | 72 /* for each playlist, pick name and number of entries */ |
73 pl_name = (gchar*)playlist_get_current_name( playlist ); | |
74 for (entries = playlist->entries; entries; entries = g_list_next(entries)) | |
75 entriesnum++; | |
4092
a3fc19130dce
add workaround to deadlock which occurs when "create a new playlist with matching entries" is checked in search and select dialog.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3625
diff
changeset
|
76 |
a3fc19130dce
add workaround to deadlock which occurs when "create a new playlist with matching entries" is checked in search and select dialog.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3625
diff
changeset
|
77 if(playlist != active) |
a3fc19130dce
add workaround to deadlock which occurs when "create a new playlist with matching entries" is checked in search and select dialog.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3625
diff
changeset
|
78 PLAYLIST_UNLOCK(playlist); |
2313 | 79 |
3624
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
80 /* update the tree model conservatively */ |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
81 |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
82 if ( !valid ) |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
83 { |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
84 /* append */ |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
85 gtk_list_store_append( store , &insert ); |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
86 goto store_set; |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
87 } |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
88 |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
89 gtk_tree_model_get( GTK_TREE_MODEL(store) , &iter , |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
90 PLLIST_PLPOINTER , &iter_playlist , -1 ); |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
91 |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
92 if ( playlist == iter_playlist ) |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
93 { |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
94 /* already have - just update */ |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
95 insert = iter; |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
96 valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(store) , &iter ); |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
97 goto store_set; |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
98 } |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
99 |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
100 /* handle movement/deletion/insertion of single elements */ |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
101 if ( gtk_tree_model_iter_next( GTK_TREE_MODEL(store) , &next ) ) |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
102 { |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
103 gtk_tree_model_get( GTK_TREE_MODEL(store) , &next , |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
104 PLLIST_PLPOINTER , &next_playlist , -1 ); |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
105 if ( playlist == next_playlist ) |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
106 { |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
107 /* remove */ |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
108 gtk_list_store_remove( store , &iter ); |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
109 iter = next; |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
110 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
111 goto next_playlist; |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
112 } |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
113 } |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
114 |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
115 /* insert */ |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
116 gtk_list_store_insert_before( store , &insert , &iter ); |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
117 |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
118 store_set: |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
119 gtk_list_store_set( store, &insert, |
2808 | 120 PLLIST_COL_NAME , pl_name , |
121 PLLIST_COL_ENTRIESNUM , entriesnum , | |
3623
3625e0085d7f
Change PLLIST_COL_PLPOINTER to PLLIST_PLPOINTER for consistency
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3622
diff
changeset
|
122 PLLIST_PLPOINTER , playlist , |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
123 PLLIST_TEXT_WEIGHT , playlist == active ? |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
124 PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
125 -1 ); |
3625
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
126 if ( !have_active_iter && playlist == active ) |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
127 { |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
128 active_iter = insert; |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
129 have_active_iter = TRUE; |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
130 } |
3624
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
131 |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
132 next_playlist: |
2808 | 133 playlists = g_list_next(playlists); |
134 } | |
3624
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
135 |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
136 while (valid) |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
137 { |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
138 /* remove any other elements */ |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
139 next = iter; |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
140 valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(store) , &next ); |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
141 gtk_list_store_remove( store , &iter ); |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
142 iter = next; |
a4e559e0c61e
Handle playlist movement/insertion/removal better in manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3623
diff
changeset
|
143 } |
3625
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
144 |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
145 if ( !have_active_iter ) |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
146 gtk_tree_model_get_iter_first( GTK_TREE_MODEL(store) , &active_iter ); |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
147 |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
148 return active_iter; |
2313 | 149 } |
150 | |
151 | |
152 static void | |
153 playlist_manager_cb_new ( gpointer listview ) | |
154 { | |
2808 | 155 GList *playlists = NULL; |
156 Playlist *newpl = NULL; | |
157 GtkTreeIter iter; | |
158 GtkListStore *store; | |
159 gchar *pl_name = NULL; | |
2313 | 160 |
2808 | 161 /* this ensures that playlist_manager_update() will |
162 not perform update, since we're already doing it here */ | |
163 DISABLE_MANAGER_UPDATE(); | |
2313 | 164 |
2808 | 165 newpl = playlist_new(); |
166 pl_name = (gchar*)playlist_get_current_name( newpl ); | |
167 playlists = playlist_get_playlists(); | |
168 playlist_add_playlist( newpl ); | |
2313 | 169 |
2808 | 170 store = (GtkListStore*)gtk_tree_view_get_model( GTK_TREE_VIEW(listview) ); |
171 gtk_list_store_append( store , &iter ); | |
172 gtk_list_store_set( store, &iter, | |
173 PLLIST_COL_NAME , pl_name , | |
174 PLLIST_COL_ENTRIESNUM , 0 , | |
3623
3625e0085d7f
Change PLLIST_COL_PLPOINTER to PLLIST_PLPOINTER for consistency
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3622
diff
changeset
|
175 PLLIST_PLPOINTER , newpl , |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
176 PLLIST_TEXT_WEIGHT , PANGO_WEIGHT_NORMAL , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
177 -1 ); |
2313 | 178 |
2808 | 179 ENABLE_MANAGER_UPDATE(); |
2313 | 180 |
2808 | 181 return; |
2313 | 182 } |
183 | |
184 | |
185 static void | |
186 playlist_manager_cb_del ( gpointer listview ) | |
187 { | |
2808 | 188 GtkTreeSelection *listsel = gtk_tree_view_get_selection( GTK_TREE_VIEW(listview) ); |
189 GtkTreeModel *store; | |
190 GtkTreeIter iter; | |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
191 Playlist *active; |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
192 gboolean was_active; |
2313 | 193 |
2808 | 194 if ( gtk_tree_selection_get_selected( listsel , &store , &iter ) == TRUE ) |
2313 | 195 { |
2808 | 196 Playlist *playlist = NULL; |
3623
3625e0085d7f
Change PLLIST_COL_PLPOINTER to PLLIST_PLPOINTER for consistency
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3622
diff
changeset
|
197 gtk_tree_model_get( store, &iter, PLLIST_PLPOINTER , &playlist , -1 ); |
2808 | 198 |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
199 active = playlist_get_active(); |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
200 was_active = ( playlist == active ); |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
201 |
2808 | 202 if ( gtk_tree_model_iter_n_children( store , NULL ) < 2 ) |
203 { | |
204 /* let playlist_manager_update() handle the deletion of the last playlist */ | |
205 playlist_remove_playlist( playlist ); | |
206 } | |
207 else | |
208 { | |
209 gtk_list_store_remove( (GtkListStore*)store , &iter ); | |
210 /* this ensures that playlist_manager_update() will | |
211 not perform update, since we're already doing it here */ | |
212 DISABLE_MANAGER_UPDATE(); | |
213 playlist_remove_playlist( playlist ); | |
214 ENABLE_MANAGER_UPDATE(); | |
215 } | |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
216 |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
217 if ( was_active && gtk_tree_model_get_iter_first( store , &iter ) ) |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
218 { |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
219 /* update bolded playlist */ |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
220 active = playlist_get_active(); |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
221 do { |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
222 gtk_tree_model_get( store , &iter , |
3623
3625e0085d7f
Change PLLIST_COL_PLPOINTER to PLLIST_PLPOINTER for consistency
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3622
diff
changeset
|
223 PLLIST_PLPOINTER , &playlist , -1 ); |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
224 gtk_list_store_set( GTK_LIST_STORE(store) , &iter , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
225 PLLIST_TEXT_WEIGHT , playlist == active ? |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
226 PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
227 -1 ); |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
228 } while ( gtk_tree_model_iter_next( store , &iter ) ); |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
229 } |
2313 | 230 } |
231 | |
2808 | 232 return; |
2313 | 233 } |
234 | |
235 | |
236 static void | |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
237 playlist_manager_cb_lv_dclick ( GtkTreeView * listview , GtkTreePath * path , |
2313 | 238 GtkTreeViewColumn * col , gpointer userdata ) |
239 { | |
2808 | 240 GtkTreeModel *store; |
241 GtkTreeIter iter; | |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
242 Playlist *playlist = NULL, *active; |
2313 | 243 |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
244 store = gtk_tree_view_get_model( GTK_TREE_VIEW(listview) ); |
2808 | 245 if ( gtk_tree_model_get_iter( store , &iter , path ) == TRUE ) |
246 { | |
3623
3625e0085d7f
Change PLLIST_COL_PLPOINTER to PLLIST_PLPOINTER for consistency
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3622
diff
changeset
|
247 gtk_tree_model_get( store , &iter , PLLIST_PLPOINTER , &playlist , -1 ); |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
248 DISABLE_MANAGER_UPDATE(); |
2808 | 249 playlist_select_playlist( playlist ); |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
250 ENABLE_MANAGER_UPDATE(); |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
251 } |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
252 |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
253 if ( gtk_tree_model_get_iter_first( store , &iter ) ) |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
254 { |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
255 /* update bolded playlist */ |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
256 active = playlist_get_active(); |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
257 do { |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
258 gtk_tree_model_get( store , &iter , |
3623
3625e0085d7f
Change PLLIST_COL_PLPOINTER to PLLIST_PLPOINTER for consistency
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3622
diff
changeset
|
259 PLLIST_PLPOINTER , &playlist , -1 ); |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
260 gtk_list_store_set( GTK_LIST_STORE(store) , &iter , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
261 PLLIST_TEXT_WEIGHT , playlist == active ? |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
262 PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
263 -1 ); |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
264 } while ( gtk_tree_model_iter_next( store , &iter ) ); |
2808 | 265 } |
2313 | 266 |
2808 | 267 return; |
2313 | 268 } |
269 | |
270 | |
271 static void | |
272 playlist_manager_cb_lv_pmenu_rename ( GtkMenuItem *menuitem , gpointer lv ) | |
273 { | |
2808 | 274 GtkTreeSelection *listsel = gtk_tree_view_get_selection( GTK_TREE_VIEW(lv) ); |
275 GtkTreeModel *store; | |
276 GtkTreeIter iter; | |
2313 | 277 |
2808 | 278 if ( gtk_tree_selection_get_selected( listsel , &store , &iter ) == TRUE ) |
279 { | |
280 GtkTreePath *path = gtk_tree_model_get_path( GTK_TREE_MODEL(store) , &iter ); | |
281 GtkCellRenderer *rndrname = g_object_get_data( G_OBJECT(lv) , "rn" ); | |
282 /* set the name renderer to editable and start editing */ | |
283 g_object_set( G_OBJECT(rndrname) , "editable" , TRUE , NULL ); | |
284 gtk_tree_view_set_cursor_on_cell( GTK_TREE_VIEW(lv) , path , | |
285 gtk_tree_view_get_column( GTK_TREE_VIEW(lv) , PLLIST_COL_NAME ) , rndrname , TRUE ); | |
286 gtk_tree_path_free( path ); | |
287 } | |
2313 | 288 } |
289 | |
290 static void | |
291 playlist_manager_cb_lv_name_edited ( GtkCellRendererText *cell , gchar *path_string , | |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
292 gchar *new_text , gpointer listview ) |
2313 | 293 { |
2808 | 294 /* this is currently used to change playlist names */ |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
295 GtkTreeModel *store = gtk_tree_view_get_model( GTK_TREE_VIEW(listview) ); |
2808 | 296 GtkTreeIter iter; |
2313 | 297 |
2808 | 298 if ( gtk_tree_model_get_iter_from_string( store , &iter , path_string ) == TRUE ) |
299 { | |
300 Playlist *playlist = NULL; | |
3623
3625e0085d7f
Change PLLIST_COL_PLPOINTER to PLLIST_PLPOINTER for consistency
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3622
diff
changeset
|
301 gtk_tree_model_get( GTK_TREE_MODEL(store), &iter, PLLIST_PLPOINTER , &playlist , -1 ); |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
302 DISABLE_MANAGER_UPDATE(); |
2808 | 303 playlist_set_current_name( playlist , new_text ); |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
304 ENABLE_MANAGER_UPDATE(); |
2808 | 305 gtk_list_store_set( GTK_LIST_STORE(store), &iter, PLLIST_COL_NAME , new_text , -1 ); |
306 } | |
307 /* set the renderer uneditable again */ | |
308 g_object_set( G_OBJECT(cell) , "editable" , FALSE , NULL ); | |
2313 | 309 } |
310 | |
311 | |
312 static gboolean | |
313 playlist_manager_cb_lv_btpress ( GtkWidget *lv , GdkEventButton *event ) | |
314 { | |
2808 | 315 if (( event->type == GDK_BUTTON_PRESS ) && ( event->button == 3 )) |
316 { | |
317 GtkWidget *pmenu = (GtkWidget*)g_object_get_data( G_OBJECT(lv) , "menu" ); | |
318 gtk_menu_popup( GTK_MENU(pmenu) , NULL , NULL , NULL , NULL , | |
319 (event != NULL) ? event->button : 0, | |
3465
0dd74d0da472
the less gdk calls, the better
Tomasz Mon <desowin@gmail.com>
parents:
3123
diff
changeset
|
320 event->time); |
2808 | 321 return TRUE; |
322 } | |
2313 | 323 |
2808 | 324 return FALSE; |
2313 | 325 } |
326 | |
327 | |
328 static gboolean | |
329 playlist_manager_cb_keypress ( GtkWidget *win , GdkEventKey *event ) | |
330 { | |
331 switch (event->keyval) | |
332 { | |
333 case GDK_Escape: | |
334 gtk_widget_destroy( playman_win ); | |
335 return TRUE; | |
336 default: | |
337 return FALSE; | |
338 } | |
339 } | |
340 | |
341 | |
342 void | |
343 playlist_manager_ui_show ( void ) | |
344 { | |
2808 | 345 GtkWidget *playman_vbox; |
346 GtkWidget *playman_pl_lv, *playman_pl_lv_frame, *playman_pl_lv_sw; | |
347 GtkCellRenderer *playman_pl_lv_textrndr_name, *playman_pl_lv_textrndr_entriesnum; | |
348 GtkTreeViewColumn *playman_pl_lv_col_name, *playman_pl_lv_col_entriesnum; | |
349 GtkListStore *pl_store; | |
350 GtkWidget *playman_pl_lv_pmenu, *playman_pl_lv_pmenu_rename; | |
351 GtkWidget *playman_bbar_hbbox; | |
352 GtkWidget *playman_bbar_bt_new, *playman_bbar_bt_del, *playman_bbar_bt_close; | |
353 GdkGeometry playman_win_hints; | |
3625
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
354 GtkTreeIter active_iter; |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
355 GtkTreePath *active_path; |
2313 | 356 |
2808 | 357 if ( playman_win != NULL ) |
358 { | |
359 gtk_window_present( GTK_WINDOW(playman_win) ); | |
360 return; | |
361 } | |
2313 | 362 |
2808 | 363 playman_win = gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
364 gtk_window_set_type_hint( GTK_WINDOW(playman_win), GDK_WINDOW_TYPE_HINT_DIALOG ); | |
365 gtk_window_set_transient_for( GTK_WINDOW(playman_win) , GTK_WINDOW(mainwin) ); | |
366 gtk_window_set_position( GTK_WINDOW(playman_win), GTK_WIN_POS_CENTER ); | |
367 gtk_window_set_title( GTK_WINDOW(playman_win), _("Playlist Manager") ); | |
368 gtk_container_set_border_width( GTK_CONTAINER(playman_win), 10 ); | |
369 g_signal_connect( G_OBJECT(playman_win) , "destroy" , | |
370 G_CALLBACK(gtk_widget_destroyed) , &playman_win ); | |
371 g_signal_connect( G_OBJECT(playman_win) , "key-press-event" , | |
372 G_CALLBACK(playlist_manager_cb_keypress) , NULL ); | |
373 playman_win_hints.min_width = 400; | |
374 playman_win_hints.min_height = 250; | |
375 gtk_window_set_geometry_hints( GTK_WINDOW(playman_win) , GTK_WIDGET(playman_win) , | |
376 &playman_win_hints , GDK_HINT_MIN_SIZE ); | |
2313 | 377 |
2809 | 378 playman_vbox = gtk_vbox_new( FALSE , 10 ); |
2808 | 379 gtk_container_add( GTK_CONTAINER(playman_win) , playman_vbox ); |
2313 | 380 |
2808 | 381 /* current liststore model |
382 ---------------------------------------------- | |
383 G_TYPE_STRING -> playlist name | |
384 G_TYPE_UINT -> number of entries in playlist | |
385 G_TYPE_POINTER -> playlist pointer (Playlist*) | |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
386 PANGO_TYPE_WEIGHT -> font weight |
2808 | 387 ---------------------------------------------- |
388 */ | |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
389 pl_store = gtk_list_store_new( PLLIST_NUMCOLS , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
390 G_TYPE_STRING , G_TYPE_UINT , G_TYPE_POINTER , PANGO_TYPE_WEIGHT ); |
3625
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
391 active_iter = playlist_manager_populate( pl_store ); |
2313 | 392 |
2808 | 393 playman_pl_lv_frame = gtk_frame_new( NULL ); |
394 playman_pl_lv = gtk_tree_view_new_with_model( GTK_TREE_MODEL(pl_store) ); | |
3625
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
395 |
2808 | 396 g_object_set_data( G_OBJECT(playman_win) , "lv" , playman_pl_lv ); |
397 g_object_set_data( G_OBJECT(playman_pl_lv) , "opt1" , GINT_TO_POINTER(0) ); | |
398 playman_pl_lv_textrndr_entriesnum = gtk_cell_renderer_text_new(); /* uneditable */ | |
399 playman_pl_lv_textrndr_name = gtk_cell_renderer_text_new(); /* can become editable */ | |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
400 g_object_set( G_OBJECT(playman_pl_lv_textrndr_entriesnum) , "weight-set" , TRUE , NULL ); |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
401 g_object_set( G_OBJECT(playman_pl_lv_textrndr_name) , "weight-set" , TRUE , NULL ); |
2808 | 402 g_signal_connect( G_OBJECT(playman_pl_lv_textrndr_name) , "edited" , |
403 G_CALLBACK(playlist_manager_cb_lv_name_edited) , playman_pl_lv ); | |
404 g_object_set_data( G_OBJECT(playman_pl_lv) , "rn" , playman_pl_lv_textrndr_name ); | |
405 playman_pl_lv_col_name = gtk_tree_view_column_new_with_attributes( | |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
406 _("Playlist") , playman_pl_lv_textrndr_name , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
407 "text" , PLLIST_COL_NAME , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
408 "weight", PLLIST_TEXT_WEIGHT , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
409 NULL ); |
2808 | 410 gtk_tree_view_column_set_expand( GTK_TREE_VIEW_COLUMN(playman_pl_lv_col_name) , TRUE ); |
411 gtk_tree_view_append_column( GTK_TREE_VIEW(playman_pl_lv), playman_pl_lv_col_name ); | |
412 playman_pl_lv_col_entriesnum = gtk_tree_view_column_new_with_attributes( | |
3622
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
413 _("Entries") , playman_pl_lv_textrndr_entriesnum , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
414 "text" , PLLIST_COL_ENTRIESNUM , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
415 "weight", PLLIST_TEXT_WEIGHT , |
3f6d23bc3f8d
Make active playlist bold in playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3471
diff
changeset
|
416 NULL ); |
2808 | 417 gtk_tree_view_column_set_expand( GTK_TREE_VIEW_COLUMN(playman_pl_lv_col_entriesnum) , FALSE ); |
418 gtk_tree_view_append_column( GTK_TREE_VIEW(playman_pl_lv), playman_pl_lv_col_entriesnum ); | |
419 playman_pl_lv_sw = gtk_scrolled_window_new( NULL , NULL ); | |
420 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(playman_pl_lv_sw) , | |
421 GTK_POLICY_NEVER , GTK_POLICY_ALWAYS ); | |
422 gtk_container_add( GTK_CONTAINER(playman_pl_lv_sw) , playman_pl_lv ); | |
423 gtk_container_add( GTK_CONTAINER(playman_pl_lv_frame) , playman_pl_lv_sw ); | |
424 gtk_box_pack_start( GTK_BOX(playman_vbox) , playman_pl_lv_frame , TRUE , TRUE , 0 ); | |
2313 | 425 |
2808 | 426 /* listview popup menu */ |
427 playman_pl_lv_pmenu = gtk_menu_new(); | |
428 playman_pl_lv_pmenu_rename = gtk_menu_item_new_with_mnemonic( _( "_Rename" ) ); | |
429 g_signal_connect( G_OBJECT(playman_pl_lv_pmenu_rename) , "activate" , | |
430 G_CALLBACK(playlist_manager_cb_lv_pmenu_rename) , playman_pl_lv ); | |
431 gtk_menu_shell_append( GTK_MENU_SHELL(playman_pl_lv_pmenu) , playman_pl_lv_pmenu_rename ); | |
432 gtk_widget_show_all( playman_pl_lv_pmenu ); | |
433 g_object_set_data( G_OBJECT(playman_pl_lv) , "menu" , playman_pl_lv_pmenu ); | |
434 g_signal_connect_swapped( G_OBJECT(playman_win) , "destroy" , | |
435 G_CALLBACK(gtk_widget_destroy) , playman_pl_lv_pmenu ); | |
2313 | 436 |
2808 | 437 /* button bar */ |
438 playman_bbar_hbbox = gtk_hbutton_box_new(); | |
439 gtk_button_box_set_layout( GTK_BUTTON_BOX(playman_bbar_hbbox) , GTK_BUTTONBOX_END ); | |
2809 | 440 gtk_button_box_set_spacing(GTK_BUTTON_BOX(playman_bbar_hbbox), 5); |
2808 | 441 playman_bbar_bt_close = gtk_button_new_from_stock( GTK_STOCK_CLOSE ); |
442 playman_bbar_bt_del = gtk_button_new_from_stock( GTK_STOCK_DELETE ); | |
443 playman_bbar_bt_new = gtk_button_new_from_stock( GTK_STOCK_NEW ); | |
444 gtk_container_add( GTK_CONTAINER(playman_bbar_hbbox) , playman_bbar_bt_close ); | |
445 gtk_container_add( GTK_CONTAINER(playman_bbar_hbbox) , playman_bbar_bt_del ); | |
446 gtk_container_add( GTK_CONTAINER(playman_bbar_hbbox) , playman_bbar_bt_new ); | |
447 gtk_button_box_set_child_secondary( GTK_BUTTON_BOX(playman_bbar_hbbox) , | |
448 playman_bbar_bt_close , TRUE ); | |
449 gtk_box_pack_start( GTK_BOX(playman_vbox) , playman_bbar_hbbox , FALSE , FALSE , 0 ); | |
2313 | 450 |
2808 | 451 g_signal_connect( G_OBJECT(playman_pl_lv) , "button-press-event" , |
452 G_CALLBACK(playlist_manager_cb_lv_btpress) , NULL ); | |
453 g_signal_connect( G_OBJECT(playman_pl_lv) , "row-activated" , | |
454 G_CALLBACK(playlist_manager_cb_lv_dclick) , NULL ); | |
455 g_signal_connect_swapped( G_OBJECT(playman_bbar_bt_new) , "clicked" , | |
456 G_CALLBACK(playlist_manager_cb_new) , playman_pl_lv ); | |
457 g_signal_connect_swapped( G_OBJECT(playman_bbar_bt_del) , "clicked" , | |
458 G_CALLBACK(playlist_manager_cb_del) , playman_pl_lv ); | |
459 g_signal_connect_swapped( G_OBJECT(playman_bbar_bt_close) , "clicked" , | |
460 G_CALLBACK(gtk_widget_destroy) , playman_win ); | |
2313 | 461 |
3625
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
462 /* have active playlist selected and scrolled to */ |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
463 active_path = gtk_tree_model_get_path( GTK_TREE_MODEL(pl_store) , |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
464 &active_iter ); |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
465 gtk_tree_view_set_cursor( GTK_TREE_VIEW(playman_pl_lv) , |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
466 active_path , NULL , FALSE ); |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
467 gtk_tree_view_scroll_to_cell( GTK_TREE_VIEW(playman_pl_lv) , |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
468 active_path , NULL , TRUE , 0.5 , 0.0 ); |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
469 gtk_tree_path_free( active_path ); |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
470 |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
471 g_object_unref( pl_store ); |
8d7775f48a4d
Select and scroll to active playlist when opening playlist manager
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3624
diff
changeset
|
472 |
2808 | 473 gtk_widget_show_all( playman_win ); |
2313 | 474 } |
475 | |
476 | |
477 void | |
478 playlist_manager_update ( void ) | |
479 { | |
2808 | 480 /* this function is called whenever there is a change in playlist, such as |
481 playlist created/deleted or entry added/deleted in a playlist; if the playlist | |
482 manager is active, it should be updated to keep consistency of information */ | |
2313 | 483 |
2808 | 484 /* CAREFUL! this currently locks/unlocks all the playlists */ |
2313 | 485 |
2808 | 486 if ( playman_win != NULL ) |
2313 | 487 { |
2808 | 488 GtkWidget *lv = (GtkWidget*)g_object_get_data( G_OBJECT(playman_win) , "lv" ); |
489 if ( GPOINTER_TO_INT(g_object_get_data(G_OBJECT(lv),"opt1")) == 0 ) | |
490 { | |
491 GtkListStore *store = (GtkListStore*)gtk_tree_view_get_model( GTK_TREE_VIEW(lv) ); | |
492 playlist_manager_populate( store ); | |
493 } | |
494 return; | |
2313 | 495 } |
2808 | 496 else |
497 return; /* if the playlist manager is not active, simply return */ | |
2313 | 498 } |