| Line | Revision | Contents |
| 1 | 448 | /* Calliope Music Player |
| 2 | * Copyright 2005-09 Sam Thursfield <ssssam gmail.com> | |
| 3 | * | |
| 4 | * This program is free software: you can redistribute it and/or modify | |
| 5 | * it under the terms of the GNU General Public License as published by | |
| 6 | * the Free Software Foundation, either version 3 of the License, or | |
| 7 | * (at your option) any later version. | |
| 8 | * | |
| 9 | * This program is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | * GNU General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU General Public License | |
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | */ | |
| 17 | ||
| 18 | #include <string.h> | |
| 19 | #include <gtk/gtk.h> | |
| 20 | #include "main.h" | |
| 21 | #include "gstreamer.h" | |
| 22 | #include "uimanager.h" | |
| 23 | #include "status-dialog.h" | |
| 24 | ||
| 25 | GtkListStore *create_module_store (void) { | |
| 26 | GtkListStore *model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); | |
| 27 | GtkTreeIter iter; | |
| 28 | ||
| 29 | const char **extension = audio_extensions_list; | |
| 30 | while (*extension != NULL) { | |
| 31 | gtk_list_store_append (model, &iter); | |
| 32 | ||
| 33 | gtk_list_store_set (model, &iter, 0, *extension, -1); | |
| 34 | ||
| 35 | GSList *list = g_hash_table_lookup (audio_extensions_modules, *extension); | |
| 36 | for (GSList *node=list; node; node=node->next) { | |
| 37 | GString *string = g_string_new (NULL); | |
| 38 | g_string_append (string, node->data); | |
| 39 | ||
| 40 | gtk_list_store_set (model, &iter, 1, string->str, -1); | |
| 41 | ||
| 42 | g_string_free (string, TRUE); | |
| 43 | ||
| 44 | if (node->next) | |
| 45 | gtk_list_store_append (model, &iter); | |
| 46 | }; | |
| 47 | ||
| 48 | extension ++; | |
| 49 | } | |
| 50 | ||
| 51 | return model; | |
| 52 | } | |
| 53 | ||
| 54 | void status_dialog_run (void) { | |
| 55 | char *path = ui_manager_locate_file ("status-dialog.ui"); | |
| 56 | g_return_if_fail (path != NULL); | |
| 57 | ||
| 58 | GError *error = NULL; | |
| 59 | GtkBuilder *builder = gtk_builder_new (); | |
| 60 | gtk_builder_add_from_file (builder, path, &error); | |
| 61 | g_assert_no_error (error); | |
| 62 | g_free (path); | |
| 63 | ||
| 64 | GtkListStore *module_store = create_module_store (); | |
| 65 | ||
| 66 | GtkWidget *modules_view = GTK_WIDGET(gtk_builder_get_object (builder, "modules-view")); | |
| 67 | GtkTreeViewColumn *column; | |
| 68 | ||
| 69 | column = gtk_tree_view_column_new_with_attributes ("module", gtk_cell_renderer_text_new (), | |
| 70 | "text", 0, NULL); | |
| 71 | gtk_tree_view_append_column (GTK_TREE_VIEW(modules_view), column); | |
| 72 | ||
| 73 | column = gtk_tree_view_column_new_with_attributes ("module", gtk_cell_renderer_text_new (), | |
| 74 | "text", 1, NULL); | |
| 75 | gtk_tree_view_append_column (GTK_TREE_VIEW(modules_view), column); | |
| 76 | ||
| 77 | gtk_tree_view_set_model (GTK_TREE_VIEW(modules_view), GTK_TREE_MODEL(module_store)); | |
| 78 | ||
| 79 | GtkWidget *dialog = GTK_WIDGET(gtk_builder_get_object (builder, "status-dialog")); | |
| 80 | gtk_dialog_run (GTK_DIALOG (dialog)); | |
| 81 | ||
| 82 | gtk_widget_destroy (dialog); | |
| 83 | g_object_unref (builder); | |
| 84 | }; |
Loggerhead is a web-based interface for Bazaar branches