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