2
* gtk.cpp - GTK interface plugin main file
3
* Copyright (C) 2001 Andy Lo A Foe <andy@alsaplayer.org>
4
* Copyright (C) 2007 Madej
6
* This file is part of AlsaPlayer.
8
* AlsaPlayer is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 3 of the License, or
11
* (at your option) any later version.
13
* AlsaPlayer is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, see <http://www.gnu.org/licenses/>.
29
#include <sys/types.h>
33
#include <sys/ioctl.h>
41
#include "AlsaPlayer.h"
42
#include "SampleBuffer.h"
43
#include "CorePlayer.h"
45
#include "ScopesWindow.h"
46
#include "gtk_interface.h"
47
#include "utilities.h"
48
#include "interface_plugin.h"
49
#include "alsaplayer_error.h"
51
static char addon_dir[1024];
53
static AlsaSubscriber *scopes = NULL;
55
static CorePlayer *the_coreplayer = NULL;
57
void unload_scope_addons()
61
apUnregiserScopePlugins();
64
void load_scope_addons()
70
scope_plugin_info_type scope_plugin_info;
72
snprintf(path, sizeof(path)-1, "%s/scopes2", addon_dir);
74
DIR *dir = opendir(path);
78
while ((entry = readdir(dir)) != NULL) { // For each file in scopes
79
if (strcmp(entry->d_name, ".") == 0 ||
80
strcmp(entry->d_name, "..") == 0) {
83
sprintf(path, "%s/scopes2/%s", addon_dir, entry->d_name);
84
//alsaplayer_error(path);
85
if (stat(path, &buf)) continue;
86
if (S_ISREG(buf.st_mode)) {
89
char *ext = strrchr(path, '.');
93
if (strcasecmp(ext, "so"))
95
if ((handle = dlopen(path, RTLD_NOW |RTLD_GLOBAL))) {
96
scope_plugin_info = (scope_plugin_info_type) dlsym(handle, "scope_plugin_info");
97
if (scope_plugin_info) {
99
alsaplayer_error("Loading scope addon: %s\n", path);
101
tmp = scope_plugin_info();
103
tmp->handle = handle;
104
if (apRegisterScopePlugin(tmp) == -1) {
105
alsaplayer_error("%s is deprecated", path);
112
printf("%s\n", dlerror());
120
int interface_gtk_init()
122
strcpy(addon_dir, ADDON_DIR);
127
int interface_gtk_running()
133
int interface_gtk_stop()
140
gtk_exit(0); // This is *NOT* clean :-(
145
void interface_gtk_close()
151
void dl_close_scopes();
153
int interface_gtk_start(Playlist *playlist, int argc, char **argv)
158
the_coreplayer = playlist->GetCorePlayer();
161
if (!g_thread_supported()) {
162
alsaplayer_error("Sorry - this interface requires working threads.\n");
169
scopes = new AlsaSubscriber();
170
scopes->Subscribe(the_coreplayer->GetNode(), POS_END);
171
scopes->EnterStream(scope_feeder_func, the_coreplayer);
174
gtk_init(&argc, &argv);
177
home = getenv("HOME");
179
snprintf(path, 255, "%s/.gtkrc-2.0", home);
186
init_main_window(playlist);
192
unload_scope_addons();
193
destroy_scopes_window();
205
interface_plugin default_plugin =
207
INTERFACE_PLUGIN_VERSION,
208
"GTK+-2.x interface",
209
"Andy Lo A Foe/Madej",
213
interface_gtk_running,
220
interface_plugin *interface_plugin_info()
222
return &default_plugin;