Mercurial > audlegacy-plugins
annotate src/projectm-1.0/gtk_projectm_impl.cxx @ 2857:59727b85a091
Restart dialog
author | Paula Stanciu <paula.stanciu@gmail.com> |
---|---|
date | Fri, 01 Aug 2008 23:18:21 +0300 |
parents | 92c6459646fe |
children |
rev | line source |
---|---|
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
1 /* |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
2 * gtk_projectm_impl.cxx: GTK+ ProjectM Implementation. |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
3 * Copyright (c) 2008 William Pitcock <nenolod@sacredspiral.co.uk> |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
4 * Portions copyright (c) 2004-2006 Peter Sperl |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
5 * |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
6 * This program is free software; you may distribute it under the terms |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
7 * of the GNU General Public License; version 2. |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
8 */ |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
9 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
10 #include <stdio.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
11 #include <string.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
12 #include <string> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
13 #include <stdlib.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
14 #include <unistd.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
15 #include <fcntl.h> |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
16 #include <gtk/gtk.h> |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
17 #include <gtk/gtkgl.h> |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
18 |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
19 #include "gtk_projectm_impl.h" |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
20 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
21 #include <math.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
22 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
23 #include <libprojectM/projectM.hpp> |
2409
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
24 #include <libprojectM/event.h> |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
25 |
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
26 #include <GL/gl.h> |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
27 #define CONFIG_FILE "/share/projectM/config.inp" |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
28 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
29 // Forward declarations |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
30 static std::string read_config(); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
31 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
32 int SDLThreadWrapper(void *); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
33 void handle_playback_trigger(void *, void *); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
34 |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
35 static void _gtk_projectm_realize_impl(GtkWidget *widget, gpointer data); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
36 static gboolean _gtk_projectm_redraw_impl(GtkWidget *widget); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
37 static gboolean _gtk_projectm_expose_impl(GtkWidget *widget, GdkEventExpose *event, gpointer data); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
38 static gboolean _gtk_projectm_configure_impl(GtkWidget *widget, GdkEventConfigure *event, gpointer data); |
2408
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
39 static void _gtk_projectm_destroy_impl(GtkWidget *widget); |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
40 |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
41 struct _GtkProjectMPrivate { |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
42 projectM *pm; |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
43 GdkGLConfig *glconfig; |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
44 GtkWidget *drawing_area; |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
45 gint idle_id; |
2404 | 46 GTimer *timer; |
47 gint frames; | |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
48 }; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
49 |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
50 extern "C" GtkWidget * |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
51 gtk_projectm_new(void) |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
52 { |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
53 struct _GtkProjectMPrivate *priv = g_slice_new0(struct _GtkProjectMPrivate); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
54 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
55 gtk_gl_init(NULL, NULL); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
56 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
57 priv->glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode) (GDK_GL_MODE_RGBA | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE)); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
58 if (!priv->glconfig) |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
59 return NULL; |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
60 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
61 priv->drawing_area = gtk_drawing_area_new(); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
62 gtk_widget_set_size_request(priv->drawing_area, 512, 512); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
63 gtk_widget_set_gl_capability(priv->drawing_area, priv->glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
64 gtk_widget_add_events(priv->drawing_area, GDK_VISIBILITY_NOTIFY_MASK); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
65 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
66 g_signal_connect_after(G_OBJECT(priv->drawing_area), "realize", |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
67 G_CALLBACK(_gtk_projectm_realize_impl), priv); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
68 g_signal_connect(G_OBJECT(priv->drawing_area), "expose_event", |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
69 G_CALLBACK(_gtk_projectm_expose_impl), priv); |
2408
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
70 g_signal_connect(G_OBJECT(priv->drawing_area), "destroy", |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
71 G_CALLBACK(_gtk_projectm_destroy_impl), priv); |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
72 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
73 priv->timer = g_timer_new(); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
74 priv->frames = 0; |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
75 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
76 g_object_set_data(G_OBJECT(priv->drawing_area), "GtkProjectMPrivate", priv); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
77 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
78 return priv->drawing_area; |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
79 } |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
80 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
81 extern "C" void |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
82 gtk_projectm_add_pcm_data(GtkWidget *widget, gint16 pcm_data[2][512]) |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
83 { |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
84 struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) g_object_get_data(G_OBJECT(widget), "GtkProjectMPrivate"); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
85 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
86 g_return_if_fail(priv != NULL); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
87 g_return_if_fail(priv->pm != NULL); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
88 |
2493 | 89 priv->pm->pcm()->addPCM16(pcm_data); |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
90 } |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
91 |
2409
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
92 extern "C" void |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
93 gtk_projectm_toggle_preset_lock(GtkWidget *widget) |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
94 { |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
95 struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) g_object_get_data(G_OBJECT(widget), "GtkProjectMPrivate"); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
96 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
97 g_return_if_fail(priv != NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
98 g_return_if_fail(priv->pm != NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
99 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
100 priv->pm->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_l, PROJECTM_KMOD_LSHIFT); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
101 } |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
102 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
103 extern "C" void |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
104 gtk_projectm_preset_prev(GtkWidget *widget) |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
105 { |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
106 struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) g_object_get_data(G_OBJECT(widget), "GtkProjectMPrivate"); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
107 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
108 g_return_if_fail(priv != NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
109 g_return_if_fail(priv->pm != NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
110 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
111 priv->pm->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_p, PROJECTM_KMOD_LSHIFT); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
112 } |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
113 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
114 extern "C" void |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
115 gtk_projectm_preset_next(GtkWidget *widget) |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
116 { |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
117 struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) g_object_get_data(G_OBJECT(widget), "GtkProjectMPrivate"); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
118 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
119 g_return_if_fail(priv != NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
120 g_return_if_fail(priv->pm != NULL); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
121 |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
122 priv->pm->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_n, PROJECTM_KMOD_LSHIFT); |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
123 } |
f67bdd91620a
Add some UI niceities.
William Pitcock <nenolod@atheme.org>
parents:
2408
diff
changeset
|
124 |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
125 static void |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
126 _gtk_projectm_realize_impl(GtkWidget *widget, gpointer data) |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
127 { |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
128 GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
129 GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
130 struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) data; |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
131 |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
132 if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
133 return; |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
134 |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
135 std::string configFile = read_config(); |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
136 priv->pm = new projectM(configFile); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
137 priv->pm->projectM_resetGL(widget->allocation.width, widget->allocation.height); |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
138 |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
139 gdk_gl_drawable_swap_buffers(gldrawable); |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
140 gdk_gl_drawable_gl_end(gldrawable); |
2404 | 141 |
142 g_signal_connect(G_OBJECT(widget), "configure_event", | |
2407 | 143 G_CALLBACK(_gtk_projectm_configure_impl), priv); |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
144 |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
145 priv->idle_id = g_timeout_add (1000 / 30, |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
146 (GSourceFunc) _gtk_projectm_redraw_impl, |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
147 priv->drawing_area); |
2404 | 148 } |
149 | |
150 static gboolean | |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
151 _gtk_projectm_configure_impl(GtkWidget *widget, GdkEventConfigure *event, gpointer data) |
2404 | 152 { |
153 GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); | |
154 GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); | |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
155 struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) data; |
2404 | 156 |
157 if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) | |
158 return FALSE; | |
159 | |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
160 priv->pm->projectM_resetGL(widget->allocation.width, widget->allocation.height); |
2404 | 161 |
162 gdk_gl_drawable_swap_buffers(gldrawable); | |
163 gdk_gl_drawable_gl_end(gldrawable); | |
164 | |
165 return TRUE; | |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
166 } |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
167 |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
168 static gboolean |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
169 _gtk_projectm_expose_impl(GtkWidget *widget, GdkEventExpose *event, gpointer data) |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
170 { |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
171 GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
172 GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
173 struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) data; |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
174 |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
175 if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
176 return FALSE; |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
177 |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
178 priv->pm->renderFrame(); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
179 priv->frames++; |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
180 |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
181 gdk_gl_drawable_swap_buffers(gldrawable); |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
182 gdk_gl_drawable_gl_end(gldrawable); |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
183 |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
184 gdouble seconds = g_timer_elapsed (priv->timer, NULL); |
2404 | 185 if (seconds >= 5.0) |
186 { | |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
187 gdouble fps = priv->frames / seconds; |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
188 g_print ("%d frames in %6.3f seconds = %6.3f FPS\n", priv->frames, seconds, fps); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
189 g_timer_reset (priv->timer); |
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
190 priv->frames = 0; |
2404 | 191 } |
192 | |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
193 return TRUE; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
194 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
195 |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
196 static gboolean |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
197 _gtk_projectm_redraw_impl(GtkWidget *widget) |
2402
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
198 { |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
199 gdk_window_invalidate_rect(widget->window, &widget->allocation, FALSE); |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
200 |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
201 return TRUE; |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
202 } |
ace0b59f541a
First steps on GTK+ based projectM plugin.
William Pitcock <nenolod@atheme.org>
parents:
2248
diff
changeset
|
203 |
2408
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
204 static void |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
205 _gtk_projectm_destroy_impl(GtkWidget *widget) |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
206 { |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
207 struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) g_object_get_data(G_OBJECT(widget), "GtkProjectMPrivate"); |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
208 |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
209 if (priv->idle_id) |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
210 g_source_remove(priv->idle_id); |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
211 |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
212 delete priv->pm; |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
213 g_free(priv->timer); |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
214 g_slice_free(struct _GtkProjectMPrivate, priv); |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
215 } |
88168440e223
Add _gtk_projectm_destroy_impl().
William Pitcock <nenolod@atheme.org>
parents:
2407
diff
changeset
|
216 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
217 /******************************************************************************** |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
218 * XXX: This code is from projectM and still needs to be rewritten! * |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
219 ********************************************************************************/ |
2406
dff5709d36bf
Reimplement using a GTK+ widget.
William Pitcock <nenolod@atheme.org>
parents:
2405
diff
changeset
|
220 static std::string read_config() |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
221 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
222 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
223 // int n; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
224 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
225 char num[512]; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
226 FILE *in; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
227 FILE *out; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
228 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
229 char *home; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
230 char projectM_home[1024]; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
231 char projectM_config[1024]; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
232 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
233 strcpy(projectM_config, PROJECTM_PREFIX); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
234 strcpy(projectM_config + strlen(PROJECTM_PREFIX), CONFIG_FILE); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
235 projectM_config[strlen(PROJECTM_PREFIX) + strlen(CONFIG_FILE)] = '\0'; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
236 //printf("dir:%s \n",projectM_config); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
237 home = getenv("HOME"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
238 strcpy(projectM_home, home); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
239 strcpy(projectM_home + strlen(home), "/.projectM/config.inp"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
240 projectM_home[strlen(home) + strlen("/.projectM/config.inp")] = '\0'; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
241 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
242 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
243 if ((in = fopen(projectM_home, "r")) != 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
244 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
245 //printf("reading ~/.projectM/config.inp \n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
246 fclose(in); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
247 return std::string(projectM_home); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
248 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
249 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
250 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
251 printf("trying to create ~/.projectM/config.inp \n"); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
252 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
253 strcpy(projectM_home, home); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
254 strcpy(projectM_home + strlen(home), "/.projectM"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
255 projectM_home[strlen(home) + strlen("/.projectM")] = '\0'; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
256 mkdir(projectM_home, 0755); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
257 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
258 strcpy(projectM_home, home); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
259 strcpy(projectM_home + strlen(home), "/.projectM/config.inp"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
260 projectM_home[strlen(home) + strlen("/.projectM/config.inp")] = '\0'; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
261 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
262 if ((out = fopen(projectM_home, "w")) != 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
263 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
264 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
265 if ((in = fopen(projectM_config, "r")) != 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
266 { |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
267 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
268 while (fgets(num, 80, in) != NULL) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
269 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
270 fputs(num, out); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
271 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
272 fclose(in); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
273 fclose(out); |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
274 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
275 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
276 if ((in = fopen(projectM_home, "r")) != 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
277 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
278 printf("created ~/.projectM/config.inp successfully\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
279 fclose(in); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
280 return std::string(projectM_home); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
281 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
282 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
283 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
284 printf("This shouldn't happen, using implementation defualts\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
285 abort(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
286 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
287 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
288 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
289 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
290 printf("Cannot find projectM default config, using implementation defaults\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
291 abort(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
292 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
293 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
294 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
295 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
296 printf("Cannot create ~/.projectM/config.inp, using default config file\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
297 if ((in = fopen(projectM_config, "r")) != 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
298 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
299 printf("Successfully opened default config file\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
300 fclose(in); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
301 return std::string(projectM_config); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
302 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
303 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
304 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
305 printf("Using implementation defaults, your system is really messed up, I'm suprised we even got this far\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
306 abort(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
307 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
308 } |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
309 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
310 } |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
311 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
312 abort(); |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
313 } |