Mercurial > audlegacy
annotate audacious/glade.c @ 2169:0934eeabc0ed trunk
[svn] Added subsampling and nonlinear transfer function to the voiceprint
visualizer. Also increased the intensity range.
author | marvin |
---|---|
date | Mon, 18 Dec 2006 14:01:29 -0800 |
parents | f18a5b617c34 |
children | 4bc65cec8f7a |
rev | line source |
---|---|
0 | 1 /* BMP - Cross-platform multimedia player |
2 * Copyright (C) 2003-2004 BMP development team. | |
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 | |
2105
f18a5b617c34
[svn] - move to GPLv2-only. Based on my interpretation of the license, we are
nenolod
parents:
1459
diff
changeset
|
6 * the Free Software Foundation; under version 2 of the License. |
0 | 7 * |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * You should have received a copy of the GNU General Public License | |
14 * along with this program; if not, write to the Free Software | |
1459 | 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
0 | 16 */ |
17 | |
18 #ifndef HAVE_CONFIG_H | |
19 # include "config.h" | |
20 #endif | |
21 | |
22 #include <glib.h> | |
23 #include <glib/gi18n.h> | |
24 #include <gmodule.h> | |
25 #include <gtk/gtk.h> | |
26 #include <glade/glade.h> | |
27 | |
28 #include <stdlib.h> | |
29 | |
30 #include "glade.h" | |
31 | |
32 | |
33 GladeXML * | |
34 glade_xml_new_or_die(const gchar * name, | |
35 const gchar * path, | |
36 const gchar * root, | |
37 const gchar * domain) | |
38 { | |
39 const gchar *markup = | |
40 N_("<b><big>Unable to create %s.</big></b>\n" | |
41 "\n" | |
42 "Could not open glade file (%s). Please check your " | |
43 "installation.\n"); | |
44 | |
45 GladeXML *xml = glade_xml_new(path, root, domain); | |
46 | |
47 if (!xml) { | |
48 GtkWidget *dialog = | |
49 gtk_message_dialog_new_with_markup(NULL, | |
50 GTK_DIALOG_MODAL, | |
51 GTK_MESSAGE_ERROR, | |
52 GTK_BUTTONS_CLOSE, | |
53 _(markup), | |
54 name, path); | |
55 gtk_dialog_run(GTK_DIALOG(dialog)); | |
56 gtk_widget_destroy(dialog); | |
57 | |
58 exit(EXIT_FAILURE); | |
59 } | |
60 | |
61 return xml; | |
62 } | |
63 | |
64 GtkWidget * | |
65 glade_xml_get_widget_warn(GladeXML * xml, const gchar * name) | |
66 { | |
67 GtkWidget *widget = glade_xml_get_widget(xml, name); | |
68 | |
69 if (!widget) { | |
70 g_warning("Widget not found (%s)", name); | |
71 return NULL; | |
72 } | |
73 | |
74 return widget; | |
75 } | |
76 | |
77 | |
78 static GCallback | |
79 self_symbol_lookup(const gchar * symbol_name) | |
80 { | |
81 static GModule *module = NULL; | |
82 gpointer symbol = NULL; | |
83 | |
84 if (!module) | |
85 module = g_module_open(NULL, 0); | |
86 | |
87 g_module_symbol(module, symbol_name, &symbol); | |
88 return (GCallback) symbol; | |
89 } | |
90 | |
91 static GHashTable * | |
92 func_map_to_hash(FuncMap * map) | |
93 { | |
94 GHashTable *hash; | |
95 FuncMap *current; | |
96 | |
97 g_return_val_if_fail(map != NULL, NULL); | |
98 | |
99 hash = g_hash_table_new(g_str_hash, g_str_equal); | |
100 | |
101 for (current = map; current->name; current++) | |
102 g_hash_table_insert(hash, current->name, (gpointer) current->function); | |
103 | |
104 return hash; | |
105 } | |
106 | |
107 static void | |
108 map_connect_func(const gchar * handler_name, | |
109 GObject * object, | |
110 const gchar * signal_name, | |
111 const gchar * signal_data, | |
112 GObject * connect_object, | |
113 gboolean after, | |
114 gpointer data) | |
115 { | |
116 GHashTable *hash = data; | |
117 GCallback callback; | |
118 | |
119 g_return_if_fail(object != NULL); | |
120 g_return_if_fail(handler_name != NULL); | |
121 g_return_if_fail(signal_name != NULL); | |
122 | |
123 if (!(callback = self_symbol_lookup(handler_name))) | |
124 callback = (GCallback) g_hash_table_lookup(hash, handler_name); | |
125 | |
126 if (!callback) { | |
127 g_message("Signal handler (%s) not found", handler_name); | |
128 return; | |
129 } | |
130 | |
131 if (connect_object) { | |
132 g_signal_connect_object(object, signal_name, callback, | |
133 connect_object, | |
134 (after ? G_CONNECT_AFTER : 0) | | |
135 G_CONNECT_SWAPPED); | |
136 } | |
137 else { | |
138 if (after) | |
139 g_signal_connect_after(object, signal_name, callback, NULL); | |
140 else | |
141 g_signal_connect(object, signal_name, callback, NULL); | |
142 } | |
143 } | |
144 | |
145 void | |
146 glade_xml_signal_autoconnect_map(GladeXML * xml, | |
147 FuncMap * map) | |
148 { | |
149 GHashTable *hash; | |
150 | |
151 g_return_if_fail(xml != NULL); | |
152 g_return_if_fail(map != NULL); | |
153 | |
154 hash = func_map_to_hash(map); | |
155 glade_xml_signal_autoconnect_full(xml, map_connect_func, hash); | |
156 g_hash_table_destroy(hash); | |
157 } |