Mercurial > audlegacy-plugins
annotate src/streambrowser/gui/streambrowser_win.c @ 3174:8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 15 May 2009 16:12:30 -0500 |
parents | 113454baecf8 |
children |
rev | line source |
---|---|
2735 | 1 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
2 #include <stdlib.h> |
2735 | 3 #include <string.h> |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
4 #include <ctype.h> |
2735 | 5 #include <glib.h> |
6 #include <gtk/gtk.h> | |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
7 #include <gdk/gdkkeysyms.h> |
2735 | 8 |
9 #include "../streambrowser.h" | |
10 #include "streambrowser_win.h" | |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
11 #include "../bookmarks.h" |
2735 | 12 |
13 | |
14 typedef struct { | |
15 | |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
16 streamdir_t* streamdir; |
2735 | 17 GtkWidget* table; |
18 GtkWidget* tree_view; | |
19 | |
20 } streamdir_gui_t; | |
21 | |
22 | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
23 void (* update_function) (streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo, gboolean add_to_playlist); |
2735 | 24 |
25 static GtkWidget* gtk_label_new_with_icon(gchar *icon_filename, gchar *label_text); | |
26 static GtkWidget* gtk_streamdir_tree_view_new(); | |
27 static GtkWidget* gtk_streamdir_table_new(GtkWidget *tree_view); | |
28 | |
29 static gboolean on_notebook_switch_page(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data); | |
30 static gboolean on_tree_view_cursor_changed(GtkTreeView *tree_view, gpointer data); | |
31 static gboolean on_add_button_clicked(GtkButton *button, gpointer data); | |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
32 static gboolean on_bookmark_button_clicked(GtkButton *button, gpointer data); |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
33 static gboolean on_search_entry_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data); |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
34 static gboolean on_tree_view_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data); |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
35 static gboolean on_tree_view_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer data); |
2735 | 36 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
37 static streamdir_gui_t* find_streamdir_gui_by_name(gchar *name); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
38 static streamdir_gui_t* find_streamdir_gui_by_table(GtkTable *table); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
39 static streamdir_gui_t* find_streamdir_gui_by_streamdir(streamdir_t *streamdir); |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
40 static gboolean tree_view_search_equal_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer data); |
2735 | 41 |
42 static GtkWidget* notebook; | |
43 static GtkWidget* search_entry; | |
44 static GtkWidget* add_button; | |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
45 static GtkWidget* bookmark_button; |
2735 | 46 static GtkWidget* streambrowser_window; |
47 static GList* streamdir_gui_list; | |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
48 static GtkCellRenderer* cell_renderer_pixbuf; |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
49 static GtkCellRenderer* cell_renderer_text; |
2735 | 50 |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
51 static gboolean tree_view_button_pressed = FALSE; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
52 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
53 |
2735 | 54 |
55 void streambrowser_win_init() | |
56 { | |
57 /* notebook */ | |
58 notebook = gtk_notebook_new(); | |
59 g_signal_connect(G_OBJECT(notebook), "switch-page", G_CALLBACK(on_notebook_switch_page), NULL); | |
60 gtk_widget_show(notebook); | |
61 | |
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2757
diff
changeset
|
62 GtkWidget *search_label = gtk_label_new(_("Search:")); |
2735 | 63 gtk_widget_show(search_label); |
64 | |
65 /* search entry */ | |
66 search_entry = gtk_entry_new(); | |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
67 g_signal_connect(G_OBJECT(search_entry), "key-press-event", G_CALLBACK(on_search_entry_key_pressed), NULL); |
2735 | 68 gtk_widget_show(search_entry); |
69 | |
70 GtkWidget *hbox1 = gtk_hbox_new(FALSE, 0); | |
71 gtk_box_pack_start(GTK_BOX(hbox1), search_label, FALSE, TRUE, 3); | |
72 gtk_box_pack_start(GTK_BOX(hbox1), search_entry, TRUE, TRUE, 3); | |
73 gtk_widget_show(hbox1); | |
74 | |
75 /* add button */ | |
76 add_button = gtk_button_new_from_stock(GTK_STOCK_ADD); | |
77 g_signal_connect(G_OBJECT(add_button), "clicked", G_CALLBACK(on_add_button_clicked), NULL); | |
78 gtk_widget_show(add_button); | |
79 | |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
80 /* bookmark button */ |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
81 bookmark_button = gtk_button_new_with_label(_("Add Bookmark")); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
82 gtk_button_set_image(GTK_BUTTON(bookmark_button), gtk_image_new_from_file(BOOKMARKS_ICON)); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
83 g_signal_connect(G_OBJECT(bookmark_button), "clicked", G_CALLBACK(on_bookmark_button_clicked), NULL); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
84 gtk_widget_show(bookmark_button); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
85 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
86 GtkWidget *vbox1 = gtk_vbox_new(FALSE, 4); |
2735 | 87 gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0); |
88 gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, TRUE, 0); | |
89 gtk_box_pack_start(GTK_BOX(vbox1), add_button, FALSE, TRUE, 0); | |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
90 gtk_box_pack_start(GTK_BOX(vbox1), bookmark_button, FALSE, TRUE, 0); |
2735 | 91 gtk_widget_show(vbox1); |
92 | |
93 /* streambrowser window */ | |
94 streambrowser_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2757
diff
changeset
|
95 gtk_window_set_title(GTK_WINDOW(streambrowser_window), _("Stream browser")); |
2735 | 96 gtk_window_set_position(GTK_WINDOW(streambrowser_window), GTK_WIN_POS_CENTER); |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
97 gtk_window_set_default_size(GTK_WINDOW(streambrowser_window), 1000, 700); |
2791
f9c6a9cb442e
streambrowser has now an icon
Calin Crisan ccrisan@gmail.com
parents:
2790
diff
changeset
|
98 gtk_window_set_icon_from_file(GTK_WINDOW(streambrowser_window), STREAMBROWSER_ICON, NULL); |
2735 | 99 g_signal_connect(G_OBJECT(streambrowser_window), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), streambrowser_window); |
100 gtk_container_add(GTK_CONTAINER(streambrowser_window), vbox1); | |
101 | |
102 /* others */ | |
103 cell_renderer_pixbuf = gtk_cell_renderer_pixbuf_new(); | |
104 cell_renderer_text = gtk_cell_renderer_text_new(); | |
105 } | |
106 | |
107 void streambrowser_win_done() | |
108 { | |
109 } | |
110 | |
111 void streambrowser_win_show() | |
112 { | |
113 gtk_widget_show(streambrowser_window); | |
114 } | |
115 | |
116 void streambrowser_win_hide() | |
117 { | |
118 gtk_widget_hide(streambrowser_window); | |
119 } | |
120 | |
121 void streambrowser_win_set_streamdir(streamdir_t *streamdir, gchar *icon_filename) | |
122 { | |
123 GtkWidget *tree_view = NULL; | |
124 | |
125 /* search for an old instance of this streamdir and replace it */ | |
126 streamdir_gui_t *streamdir_gui = find_streamdir_gui_by_name(streamdir->name); | |
127 if (streamdir_gui != NULL) { | |
128 streamdir_delete(streamdir_gui->streamdir); | |
129 streamdir_gui->streamdir = streamdir; | |
130 tree_view = streamdir_gui->tree_view; | |
131 } | |
132 /* if no older instance of this streamdir has been found, we add a brand new one */ | |
133 else { | |
134 streamdir_gui = g_malloc(sizeof(streamdir_gui_t)); | |
135 | |
136 tree_view = gtk_streamdir_tree_view_new(); | |
137 | |
138 GtkWidget *table = gtk_streamdir_table_new(tree_view); | |
139 gtk_widget_show_all(table); | |
140 | |
141 GtkWidget *label = gtk_label_new_with_icon(icon_filename, streamdir->name); | |
142 gtk_widget_show_all(label); | |
143 | |
144 streamdir_gui->streamdir = streamdir; | |
145 streamdir_gui->tree_view = tree_view; | |
146 streamdir_gui->table = table; | |
147 | |
148 streamdir_gui_list = g_list_append(streamdir_gui_list, streamdir_gui); | |
149 | |
150 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label); | |
151 } | |
152 | |
153 /* fill the tree with categories */ | |
154 GtkTreeIter iter; | |
155 GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view))); | |
156 | |
157 gtk_tree_store_clear(store); | |
158 | |
159 int i, count = category_get_count(streamdir); | |
160 category_t *category; | |
161 for (i = 0; i < count; i++) { | |
162 category = category_get_by_index(streamdir, i); | |
163 | |
164 gtk_tree_store_append(store, &iter, NULL); | |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
165 gtk_tree_store_set(store, &iter, 0, "gtk-directory", 1, category->name, 2, "", 3, PANGO_WEIGHT_NORMAL, -1); |
2735 | 166 } |
167 } | |
168 | |
169 void streambrowser_win_set_category(streamdir_t *streamdir, category_t *category) | |
170 { | |
171 streamdir_gui_t *streamdir_gui = find_streamdir_gui_by_name(streamdir->name); | |
172 if (streamdir_gui == NULL) { | |
173 failure("gui: streambrowser_win_set_category() called with non-existent streamdir\n"); | |
174 return; | |
175 } | |
176 | |
177 GtkTreeView *tree_view = GTK_TREE_VIEW(streamdir_gui->tree_view); | |
178 GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view))); | |
179 GtkTreePath *path; | |
180 GtkTreeIter iter, new_iter; | |
181 | |
182 /* clear all the previously added streaminfo in this category */ | |
183 path = gtk_tree_path_new_from_indices(category_get_index(streamdir, category), 0, -1); | |
184 if (gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path)) { | |
185 while (gtk_tree_store_remove(store, &iter)) | |
186 ; | |
187 } | |
188 | |
189 /* find the corresponding category tree iter */ | |
190 path = gtk_tree_path_new_from_indices(category_get_index(streamdir, category), -1); | |
191 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path)) | |
192 return; | |
193 | |
194 /* append the new streaminfos to the current category / iter */ | |
195 int i, count = streaminfo_get_count(category); | |
196 streaminfo_t *streaminfo; | |
197 for (i = 0; i < count; i++) { | |
198 streaminfo = streaminfo_get_by_index(category, i); | |
199 | |
200 gtk_tree_store_append(store, &new_iter, &iter); | |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
201 gtk_tree_store_set(store, &new_iter, 0, "gtk-media-play", 1, streaminfo->name, 2, streaminfo->current_track, 3, PANGO_WEIGHT_NORMAL, -1); |
2735 | 202 } |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
203 |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
204 gtk_tree_path_free(path); |
2735 | 205 } |
206 | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
207 void streambrowser_win_set_streaminfo(streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo) |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
208 { |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
209 streamdir_gui_t *streamdir_gui = find_streamdir_gui_by_name(streamdir->name); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
210 if (streamdir_gui == NULL) { |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
211 failure("gui: streambrowser_win_set_category() called with non-existent streamdir\n"); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
212 return; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
213 } |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
214 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
215 GtkTreeView *tree_view = GTK_TREE_VIEW(streamdir_gui->tree_view); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
216 GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view))); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
217 GtkTreePath *path; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
218 GtkTreeIter iter, new_iter; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
219 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
220 /* find the corresponding streaminfo tree iter */ |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
221 path = gtk_tree_path_new_from_indices(category_get_index(streamdir, category), streaminfo_get_index(category, streaminfo), -1); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
222 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path)) |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
223 return; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
224 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
225 /* update the streaminfo*/ |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
226 gtk_tree_store_set(store, &new_iter, 0, "gtk-media-play", 1, streaminfo->name, 2, streaminfo->current_track, 3, PANGO_WEIGHT_NORMAL -1); |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
227 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
228 gtk_tree_path_free(path); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
229 } |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
230 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
231 void streambrowser_win_set_update_function(void (*function) (streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo, gboolean add_to_playlist)) |
2735 | 232 { |
233 update_function = function; | |
234 } | |
235 | |
2790
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
236 void streambrowser_win_set_category_state(streamdir_t *streamdir, category_t *category, gboolean fetching) |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
237 { |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
238 streamdir_gui_t *streamdir_gui = find_streamdir_gui_by_streamdir(streamdir); |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
239 GtkTreeView *tree_view = GTK_TREE_VIEW(streamdir_gui->tree_view); |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
240 GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(tree_view)); |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
241 GtkTreePath *path; |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
242 GtkTreeIter iter; |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
243 |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
244 /* find the corresponding category tree iter */ |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
245 path = gtk_tree_path_new_from_indices(category_get_index(streamdir, category), -1); |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
246 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path)) |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
247 return; |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
248 |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
249 if (fetching) { |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
250 gtk_tree_store_set(store, &iter, 0, "gtk-refresh", 1, category->name, 2, "", 3, PANGO_WEIGHT_BOLD, -1); |
2790
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
251 } |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
252 else { |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
253 gtk_tree_store_set(store, &iter, 0, "gtk-directory", 1, category->name, 2, "", 3, PANGO_WEIGHT_NORMAL, -1); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
254 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
255 /* we also expand the corresponding category tree element in the treeview */ |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
256 gtk_tree_view_expand_row(tree_view, path, FALSE); |
2790
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
257 } |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
258 } |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
259 |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
260 void streambrowser_win_set_streaminfo_state(streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo, gboolean fetching) |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
261 { |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
262 streamdir_gui_t *streamdir_gui = find_streamdir_gui_by_streamdir(streamdir); |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
263 GtkTreeView *tree_view = GTK_TREE_VIEW(streamdir_gui->tree_view); |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
264 GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(tree_view)); |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
265 GtkTreePath *path; |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
266 GtkTreeIter iter; |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
267 |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
268 /* find the corresponding category tree iter */ |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
269 path = gtk_tree_path_new_from_indices(category_get_index(streamdir, category), streaminfo_get_index(category, streaminfo), -1); |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
270 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path)) |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
271 return; |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
272 |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
273 if (fetching) { |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
274 gtk_tree_store_set(store, &iter, 0, "gtk-media-play", 1, streaminfo->name, 2, streaminfo->current_track, 3, PANGO_WEIGHT_BOLD, -1); |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
275 } |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
276 else { |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
277 gtk_tree_store_set(store, &iter, 0, "gtk-media-play", 1, streaminfo->name, 2, streaminfo->current_track, 3, PANGO_WEIGHT_NORMAL, -1); |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
278 } |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
279 } |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
280 |
2735 | 281 static GtkWidget* gtk_label_new_with_icon(gchar *icon_filename, gchar *label_text) |
282 { | |
283 GtkWidget *hbox = gtk_hbox_new(FALSE, 1); | |
284 GtkWidget *label = gtk_label_new(label_text); | |
285 GtkWidget *icon = gtk_image_new_from_file(icon_filename); | |
286 | |
287 gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, TRUE, 0); | |
288 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | |
289 | |
290 return hbox; | |
291 } | |
292 | |
293 static GtkWidget *gtk_streamdir_tree_view_new() | |
294 { | |
295 GtkWidget *tree_view = gtk_tree_view_new(); | |
2757
4ec0e13208de
added shoutcast icon; fixed some small bugs
Calin Crisan ccrisan@gmail.com
parents:
2735
diff
changeset
|
296 |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
297 GtkTreeStore *store = gtk_tree_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT); |
2735 | 298 gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), GTK_TREE_MODEL(store)); |
299 | |
2757
4ec0e13208de
added shoutcast icon; fixed some small bugs
Calin Crisan ccrisan@gmail.com
parents:
2735
diff
changeset
|
300 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view), TRUE); |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
301 gtk_tree_view_set_search_entry(GTK_TREE_VIEW(tree_view), GTK_ENTRY(search_entry)); |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
302 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(tree_view), tree_view_search_equal_func, NULL, NULL); |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
303 gtk_tree_view_set_search_column(GTK_TREE_VIEW(tree_view), 1); |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
304 g_signal_connect(G_OBJECT(tree_view), "key-press-event", G_CALLBACK(on_tree_view_key_pressed), NULL); |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
305 g_signal_connect(G_OBJECT(tree_view), "cursor-changed", G_CALLBACK(on_tree_view_cursor_changed), NULL); |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
306 g_signal_connect(G_OBJECT(tree_view), "button-press-event", G_CALLBACK(on_tree_view_button_pressed), NULL); |
2735 | 307 |
2783
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
308 GtkTreeViewColumn *column = gtk_tree_view_column_new(); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
309 gtk_tree_view_column_pack_start(column, cell_renderer_pixbuf, TRUE); |
2790
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
310 gtk_tree_view_column_add_attribute(column, cell_renderer_pixbuf, "stock-id", 0); |
2783
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
311 gtk_tree_view_column_set_resizable(column, TRUE); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
312 gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
313 |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
314 column = gtk_tree_view_column_new(); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
315 gtk_tree_view_column_pack_start(column, cell_renderer_text, TRUE); |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
316 gtk_tree_view_column_add_attribute(column, cell_renderer_text, "text", 1); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
317 gtk_tree_view_column_add_attribute(column, cell_renderer_text, "weight", 3); |
2783
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
318 gtk_tree_view_column_set_resizable(column, TRUE); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
319 gtk_tree_view_column_set_title(column, _("Stream name")); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
320 gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
321 |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
322 column = gtk_tree_view_column_new(); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
323 gtk_tree_view_column_pack_start(column, cell_renderer_text, TRUE); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
324 gtk_tree_view_column_add_attribute(column, cell_renderer_text, "text", 2); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
325 gtk_tree_view_column_set_resizable(column, TRUE); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
326 gtk_tree_view_column_set_title(column, _("Now playing")); |
8be380729806
made columns resizable in streambrowser's main win
Calin Crisan ccrisan@gmail.com
parents:
2782
diff
changeset
|
327 gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); |
2757
4ec0e13208de
added shoutcast icon; fixed some small bugs
Calin Crisan ccrisan@gmail.com
parents:
2735
diff
changeset
|
328 |
2735 | 329 return tree_view; |
330 } | |
331 | |
332 static GtkWidget* gtk_streamdir_table_new(GtkWidget *tree_view) | |
333 { | |
334 GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); | |
335 gtk_container_add(GTK_CONTAINER(scrolled_window), tree_view); | |
336 | |
337 GtkWidget *table = gtk_table_new(1, 1, FALSE); | |
338 gtk_table_attach(GTK_TABLE(table), scrolled_window, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); | |
339 | |
340 return table; | |
341 } | |
342 | |
343 static gboolean on_notebook_switch_page(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data) | |
344 { | |
345 if (page_num < 0) | |
346 return FALSE; | |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
347 |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
348 /* only enable searching in the current tree (tab) */ |
2735 | 349 |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
350 streamdir_gui_t *streamdir_gui; |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
351 int i; |
2757
4ec0e13208de
added shoutcast icon; fixed some small bugs
Calin Crisan ccrisan@gmail.com
parents:
2735
diff
changeset
|
352 |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
353 for (i = 0; i < g_list_length(streamdir_gui_list); i++) { |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
354 streamdir_gui = g_list_nth_data(streamdir_gui_list, i); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
355 |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
356 if (i == page_num) |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
357 gtk_tree_view_set_search_column(GTK_TREE_VIEW(streamdir_gui->tree_view), 1); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
358 else |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
359 gtk_tree_view_set_search_column(GTK_TREE_VIEW(streamdir_gui->tree_view), -1); |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
360 } |
2757
4ec0e13208de
added shoutcast icon; fixed some small bugs
Calin Crisan ccrisan@gmail.com
parents:
2735
diff
changeset
|
361 |
4ec0e13208de
added shoutcast icon; fixed some small bugs
Calin Crisan ccrisan@gmail.com
parents:
2735
diff
changeset
|
362 /* clear the search box */ |
4ec0e13208de
added shoutcast icon; fixed some small bugs
Calin Crisan ccrisan@gmail.com
parents:
2735
diff
changeset
|
363 gtk_entry_set_text(GTK_ENTRY(search_entry), ""); |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
364 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
365 /* if this is the last page, aka the bookmarks page, bookmark button has to say "Remove bookmark", instead of "Add bookmark"0 */ |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
366 if (page_num == gtk_notebook_get_n_pages(notebook) - 1) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
367 gtk_button_set_label(GTK_BUTTON(bookmark_button), _("Remove Bookmark")); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
368 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
369 else { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
370 gtk_button_set_label(GTK_BUTTON(bookmark_button), _("Add Bookmark")); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
371 } |
2735 | 372 |
373 return TRUE; | |
374 } | |
375 | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
376 |
2735 | 377 static gboolean on_tree_view_cursor_changed(GtkTreeView *tree_view, gpointer data) |
378 { | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
379 /* only do the refresh if this cursor change occured due to a mouse click */ |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
380 if (!tree_view_button_pressed) |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
381 return FALSE; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
382 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
383 tree_view_button_pressed = FALSE; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
384 |
2735 | 385 GtkTreePath *path; |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
386 GtkTreeViewColumn *focus_column; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
387 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
388 /* get the currently selected tree view */ |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
389 GtkWidget *table = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
390 streamdir_gui_t *streamdir_gui = find_streamdir_gui_by_table(GTK_TABLE(table)); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
391 if (streamdir_gui == NULL) |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
392 return FALSE; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
393 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
394 /* get the currently selected path in the tree */ |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
395 gtk_tree_view_get_cursor(tree_view, &path, &focus_column); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
396 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
397 if (path == NULL || gtk_tree_path_get_depth(path) == 0) |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
398 return FALSE; |
2735 | 399 |
400 gint *indices = gtk_tree_path_get_indices(path); | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
401 int category_index = indices[0]; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
402 streamdir_t *streamdir = streamdir_gui->streamdir; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
403 category_t *category = category_get_by_index(streamdir_gui->streamdir, category_index); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
404 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
405 /* if the selected item is a category */ |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
406 if (gtk_tree_path_get_depth(path) == 1) { |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
407 if (!gtk_tree_view_row_expanded(tree_view, path)) { |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
408 gtk_entry_set_text(GTK_ENTRY(search_entry), ""); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
409 update_function(streamdir, category, NULL, FALSE); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
410 } |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
411 |
2735 | 412 gtk_tree_path_free(path); |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
413 } |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
414 /* if the selected item is a streaminfo */ |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
415 else { |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
416 int streaminfo_index = indices[1]; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
417 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
418 gtk_tree_path_free(path); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
419 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
420 /* get the currently selected stream (info) */ |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
421 streaminfo_t *streaminfo = streaminfo_get_by_index(category, streaminfo_index); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
422 |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
423 gtk_entry_set_text(GTK_ENTRY(search_entry), ""); |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
424 update_function(streamdir, category, streaminfo, FALSE); |
2735 | 425 } |
426 | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
427 return FALSE; |
2735 | 428 } |
429 | |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
430 static gboolean on_tree_view_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer data) |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
431 { |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
432 /* double click adds the currently selected stream to the playlist */ |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
433 if (event->type == GDK_2BUTTON_PRESS) { |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
434 tree_view_button_pressed = FALSE; |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
435 on_add_button_clicked(NULL, NULL); |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
436 } |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
437 /* single click triggers a refresh of the selected item */ |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
438 else { |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
439 tree_view_button_pressed = TRUE; |
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
440 } |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
441 |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
442 return FALSE; |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
443 } |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
444 |
2735 | 445 static gboolean on_add_button_clicked(GtkButton *button, gpointer data) |
446 { | |
447 GtkTreePath *path; | |
448 GtkTreeViewColumn *focus_column; | |
449 | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
450 /* get the currently selected tree view */ |
2735 | 451 GtkWidget *table = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
452 streamdir_gui_t *streamdir_gui = find_streamdir_gui_by_table(GTK_TABLE(table)); | |
453 if (streamdir_gui == NULL) | |
454 return TRUE; | |
455 | |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
456 GtkTreeView *tree_view = GTK_TREE_VIEW(streamdir_gui->tree_view); |
2735 | 457 |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
458 /* get the currently selected path in the tree */ |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
459 gtk_tree_view_get_cursor(tree_view, &path, &focus_column); |
2735 | 460 |
461 if (path == NULL) | |
462 return TRUE; | |
463 | |
464 gint *indices = gtk_tree_path_get_indices(path); | |
2797
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
465 if (gtk_tree_path_get_depth(path) == 1) { |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
466 if (gtk_tree_view_row_expanded(tree_view, path)) |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
467 gtk_tree_view_collapse_row(tree_view, path); |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
468 else |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
469 gtk_tree_view_expand_row(tree_view, path, FALSE); |
11fb1503ee4b
double click adds stream to playlist; visual feedback when adding streams
Calin Crisan ccrisan@gmail.com
parents:
2795
diff
changeset
|
470 |
2735 | 471 gtk_tree_path_free(path); |
472 return TRUE; | |
473 } | |
474 | |
475 int category_index = indices[0]; | |
476 int streaminfo_index = indices[1]; | |
477 | |
478 gtk_tree_path_free(path); | |
479 | |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
480 /* get the currently selected stream (info) */ |
2735 | 481 streamdir_t *streamdir = streamdir_gui->streamdir; |
482 category_t *category = category_get_by_index(streamdir_gui->streamdir, category_index); | |
483 streaminfo_t *streaminfo = streaminfo_get_by_index(category, streaminfo_index); | |
484 | |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
485 gtk_entry_set_text(GTK_ENTRY(search_entry), ""); |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2822
diff
changeset
|
486 update_function(streamdir, category, streaminfo, TRUE); |
2735 | 487 |
488 return TRUE; | |
489 } | |
490 | |
2913
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
491 static gboolean on_bookmark_button_clicked(GtkButton *button, gpointer data) |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
492 { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
493 GtkTreePath *path; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
494 GtkTreeViewColumn *focus_column; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
495 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
496 /* get the currently selected tree view */ |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
497 GtkWidget *table = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
498 streamdir_gui_t *streamdir_gui = find_streamdir_gui_by_table(GTK_TABLE(table)); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
499 if (streamdir_gui == NULL) |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
500 return TRUE; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
501 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
502 GtkTreeView *tree_view = GTK_TREE_VIEW(streamdir_gui->tree_view); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
503 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
504 /* get the currently selected path in the tree */ |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
505 gtk_tree_view_get_cursor(tree_view, &path, &focus_column); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
506 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
507 if (path == NULL) |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
508 return TRUE; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
509 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
510 gint *indices = gtk_tree_path_get_indices(path); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
511 if (gtk_tree_path_get_depth(path) == 1) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
512 gtk_tree_path_free(path); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
513 return TRUE; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
514 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
515 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
516 int category_index = indices[0]; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
517 int streaminfo_index = indices[1]; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
518 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
519 gtk_tree_path_free(path); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
520 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
521 /* get the currently selected stream (info) */ |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
522 streamdir_t *streamdir = streamdir_gui->streamdir; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
523 category_t *category = category_get_by_index(streamdir_gui->streamdir, category_index); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
524 streaminfo_t *streaminfo = streaminfo_get_by_index(category, streaminfo_index); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
525 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
526 /* if we have the bookmarks tab focused, we remove the stream, rather than add it. otherwise we simply add it */ |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
527 if (strcmp(streamdir->name, BOOKMARKS_NAME) == 0) { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
528 bookmark_remove(streaminfo->name); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
529 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
530 update_function(streamdir, category, NULL, FALSE); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
531 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
532 else { |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
533 bookmark_t bookmark; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
534 strncpy(bookmark.streamdir_name, streamdir->name, DEF_STRING_LEN); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
535 strncpy(bookmark.name, streaminfo->name, DEF_STRING_LEN); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
536 strncpy(bookmark.playlist_url, streaminfo->playlist_url, DEF_STRING_LEN); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
537 strncpy(bookmark.url, streaminfo->url, DEF_STRING_LEN); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
538 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
539 bookmark_add(&bookmark); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
540 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
541 /* find the corresponding category (having the current streamdir name) in the bookmarks */ |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
542 streamdir_t *bookmarks_streamdir = find_streamdir_gui_by_name(BOOKMARKS_NAME)->streamdir; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
543 category_t *bookmarks_category = category_get_by_name(bookmarks_streamdir, streamdir->name); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
544 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
545 update_function(bookmarks_streamdir, bookmarks_category, NULL, FALSE); |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
546 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
547 |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
548 return TRUE; |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
549 } |
113454baecf8
lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents:
2889
diff
changeset
|
550 |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
551 static gboolean on_search_entry_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data) |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
552 { |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
553 if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter) { |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
554 on_add_button_clicked(GTK_BUTTON(add_button), NULL); |
2822
e883536cefe0
implemented xiph categories/genres, xiph is now usable
Calin Crisan ccrisan@gmail.com
parents:
2819
diff
changeset
|
555 return TRUE; |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
556 } |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
557 |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
558 if (event->keyval == GDK_Escape) { |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
559 gtk_entry_set_text(GTK_ENTRY(search_entry), ""); |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
560 return FALSE; |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
561 } |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
562 |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
563 return FALSE; |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
564 } |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
565 |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
566 static gboolean on_tree_view_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data) |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
567 { |
2817
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
568 if (event->keyval == GDK_Down || event->keyval == GDK_Up) |
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
569 return FALSE; |
2822
e883536cefe0
implemented xiph categories/genres, xiph is now usable
Calin Crisan ccrisan@gmail.com
parents:
2819
diff
changeset
|
570 else |
e883536cefe0
implemented xiph categories/genres, xiph is now usable
Calin Crisan ccrisan@gmail.com
parents:
2819
diff
changeset
|
571 if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter) { |
e883536cefe0
implemented xiph categories/genres, xiph is now usable
Calin Crisan ccrisan@gmail.com
parents:
2819
diff
changeset
|
572 on_add_button_clicked(GTK_BUTTON(add_button), NULL); |
e883536cefe0
implemented xiph categories/genres, xiph is now usable
Calin Crisan ccrisan@gmail.com
parents:
2819
diff
changeset
|
573 return FALSE; |
e883536cefe0
implemented xiph categories/genres, xiph is now usable
Calin Crisan ccrisan@gmail.com
parents:
2819
diff
changeset
|
574 } |
2817
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
575 |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
576 gtk_widget_grab_focus(search_entry); |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
577 on_search_entry_key_pressed(widget, event, data); |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
578 |
2817
779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
Calin Crisan ccrisan@gmail.com
parents:
2815
diff
changeset
|
579 return TRUE; |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
580 } |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
581 |
2735 | 582 static streamdir_gui_t *find_streamdir_gui_by_name(gchar *name) |
583 { | |
584 GList *iterator; | |
585 streamdir_gui_t *streamdir_gui; | |
586 | |
587 for (iterator = g_list_first(streamdir_gui_list); iterator != NULL; iterator = g_list_next(iterator)) { | |
588 streamdir_gui = iterator->data; | |
589 | |
590 if (strcmp(streamdir_gui->streamdir->name, name) == 0) | |
591 return streamdir_gui; | |
592 } | |
593 | |
594 return NULL; | |
595 } | |
596 | |
597 static streamdir_gui_t *find_streamdir_gui_by_table(GtkTable *table) | |
598 { | |
599 GList *iterator; | |
600 streamdir_gui_t *streamdir_gui; | |
601 | |
602 for (iterator = g_list_first(streamdir_gui_list); iterator != NULL; iterator = g_list_next(iterator)) { | |
603 streamdir_gui = iterator->data; | |
604 | |
605 if ((void *) streamdir_gui->table == (void *) table) | |
606 return streamdir_gui; | |
607 } | |
608 | |
609 return NULL; | |
610 } | |
611 | |
2790
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
612 static streamdir_gui_t* find_streamdir_gui_by_streamdir(streamdir_t *streamdir) |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
613 { |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
614 GList *iterator; |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
615 streamdir_gui_t *streamdir_gui; |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
616 |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
617 for (iterator = g_list_first(streamdir_gui_list); iterator != NULL; iterator = g_list_next(iterator)) { |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
618 streamdir_gui = iterator->data; |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
619 |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
620 if ((void *) streamdir_gui->streamdir == (void *) streamdir) |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
621 return streamdir_gui; |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
622 } |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
623 |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
624 return NULL; |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
625 } |
c156102069ae
background fetching of streaming info is now indicated in gui
Calin Crisan ccrisan@gmail.com
parents:
2783
diff
changeset
|
626 |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
627 static gboolean tree_view_search_equal_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer data) |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
628 { |
2815
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
629 if (column == -1) |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
630 return TRUE; |
cc6f02424609
added initial support for xiph streaming directory; small bug fixes & code cleanups
Calin Crisan ccrisan@gmail.com
parents:
2797
diff
changeset
|
631 |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
632 GValue value = {0, }; |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
633 gboolean ret; |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
634 |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
635 gtk_tree_model_get_value(model, iter, column, &value); |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
636 const gchar *string = g_value_get_string(&value); |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
637 |
2795
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
638 if (string == NULL || string[0] == '\0' || key == NULL || key[0] == '\0') |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
639 ret = TRUE; |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
640 |
4c9db0b2194f
added strcasestr implementation; improved searching and updating
Calin Crisan ccrisan@gmail.com
parents:
2791
diff
changeset
|
641 ret = !mystrcasestr(string, key); |
2782
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
642 |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
643 g_value_unset(&value); |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
644 |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
645 return ret; |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
646 } |
c5005707a575
added basic search functionality
Calin Crisan ccrisan@gmail.com
parents:
2764
diff
changeset
|
647 |