Mercurial > audlegacy-plugins
annotate src/projectm-1.0/main.c @ 3047:4434b4c4a715
ported EsounD plugin
author | Andrew O. Shadoura <bugzilla@tut.by> |
---|---|
date | Fri, 17 Apr 2009 16:17:10 +0300 |
parents | 3134a0987162 |
children |
rev | line source |
---|---|
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
1 /* |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
2 * main.cxx: plugin glue to libprojectm |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
3 * Copyright (c) 2008 William Pitcock <nenolod@sacredspiral.co.uk> |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
4 * |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
5 * This program is free software; you may distribute it under the terms |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
6 * of the GNU General Public License; version 2. |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
7 */ |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
8 |
2409
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
9 #include "config.h" |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
10 |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2411
diff
changeset
|
11 #include <audlegacy/plugin.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2411
diff
changeset
|
12 #include <audlegacy/i18n.h> |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
13 |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
14 #include "gtk_projectm_impl.h" |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
15 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
16 GtkWidget *projectm = NULL; |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
17 GtkWidget *window = NULL; |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
18 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
19 void |
2409
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
20 projectM_toggle_random(GtkToggleButton *button, gpointer unused) |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
21 { |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
22 g_return_if_fail(projectm != NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
23 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
24 gtk_projectm_toggle_preset_lock(projectm); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
25 } |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
26 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
27 void |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
28 projectM_preset_prev(void) |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
29 { |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
30 g_return_if_fail(projectm != NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
31 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
32 gtk_projectm_preset_prev(projectm); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
33 } |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
34 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
35 void |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
36 projectM_preset_next(void) |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
37 { |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
38 g_return_if_fail(projectm != NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
39 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
40 gtk_projectm_preset_next(projectm); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
41 } |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
42 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
43 void |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
44 projectM_init(void) |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
45 { |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
46 GtkWidget *vbox; |
2409
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
47 GtkWidget *bbox; |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
48 GtkWidget *button; |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
49 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
50 if (window) |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
51 return; |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
52 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
53 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
54 gtk_window_set_title(GTK_WINDOW(window), "ProjectM"); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
55 gtk_container_set_reallocate_redraws(GTK_CONTAINER(window), TRUE); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
56 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
57 vbox = gtk_vbox_new(FALSE, 0); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
58 gtk_container_add(GTK_CONTAINER(window), vbox); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
59 gtk_widget_show(vbox); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
60 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
61 projectm = gtk_projectm_new(); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
62 gtk_box_pack_start(GTK_BOX(vbox), projectm, TRUE, TRUE, 0); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
63 gtk_widget_show(projectm); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
64 |
2409
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
65 bbox = gtk_hbutton_box_new(); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
66 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_START); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
67 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 0); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
68 gtk_widget_show(bbox); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
69 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
70 button = gtk_toggle_button_new_with_mnemonic(_("_Random")); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
71 gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
72 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
73 g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(projectM_toggle_random), NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
74 gtk_widget_show(button); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
75 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
76 button = gtk_button_new_from_stock(GTK_STOCK_GO_BACK); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
77 gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
78 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(projectM_preset_prev), NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
79 gtk_widget_show(button); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
80 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
81 button = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
82 gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
83 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(projectM_preset_next), NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
84 gtk_widget_show(button); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
85 |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
86 gtk_widget_show(window); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
87 } |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
88 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
89 void |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
90 projectM_cleanup(void) |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
91 { |
2411
c69b1d1d47a3
Set window to NULL after it's destroyed.
William Pitcock <nenolod@atheme.org>
parents:
2409
diff
changeset
|
92 g_return_if_fail(window != NULL); |
c69b1d1d47a3
Set window to NULL after it's destroyed.
William Pitcock <nenolod@atheme.org>
parents:
2409
diff
changeset
|
93 |
2408
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2406
diff
changeset
|
94 gtk_widget_destroy(window); |
2411
c69b1d1d47a3
Set window to NULL after it's destroyed.
William Pitcock <nenolod@atheme.org>
parents:
2409
diff
changeset
|
95 window = NULL; |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
96 } |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
97 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
98 void |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
99 projectM_render_pcm(gint16 pcm_data[2][512]) |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
100 { |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
101 g_return_if_fail(projectm != NULL); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
102 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
103 gtk_projectm_add_pcm_data(projectm, pcm_data); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
104 } |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
105 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
106 VisPlugin projectM_vtable = { |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
107 .description = "projectM", |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
108 .num_pcm_chs_wanted = 2, |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2245
diff
changeset
|
109 .init = projectM_init, |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
110 .cleanup = projectM_cleanup, |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
111 .render_pcm = projectM_render_pcm, |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
112 }; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
113 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
114 VisPlugin *projectM_vplist[] = { &projectM_vtable, NULL }; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
115 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
116 DECLARE_PLUGIN(projectm, NULL, NULL, NULL, NULL, NULL, NULL, |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
117 projectM_vplist, NULL); |