Add a configuration dialog box to the Linux version of ZeroSPU2.

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@485 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
arcum42 2008-12-23 20:37:28 +00:00 committed by Gregory Hainaut
parent 53ef8d1ea4
commit 661c529443
10 changed files with 807 additions and 168 deletions

View File

@ -15,6 +15,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Modified by arcum42@gmail.com
#include "zerospu2.h"
#include <assert.h>
@ -25,110 +28,124 @@
#include <sys/soundcard.h>
#include <unistd.h>
#include <gtk/gtk.h>
extern "C" {
#include "interface.h"
#include "support.h"
#include "callbacks.h"
}
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
GtkWidget *MsgDlg, *ConfDlg;
#ifdef ZEROSPU2_OSS
static int oss_audio_fd = -1;
extern int errno;
#define OSS_MODE_STEREO 1
// use OSS for sound
int SetupSound()
{
int pspeed=48000;
int pstereo;
int format;
int fragsize = 0;
int myfrag;
int oss_speed, oss_stereo;
int pspeed=48000;
int pstereo;
int format;
int fragsize = 0;
int myfrag;
int oss_speed, oss_stereo;
pstereo=OSS_MODE_STEREO;
pstereo=OSS_MODE_STEREO;
oss_speed = pspeed;
oss_stereo = pstereo;
oss_speed = pspeed;
oss_stereo = pstereo;
if((oss_audio_fd=open("/dev/dsp",O_WRONLY,0))==-1) {
printf("Sound device not available!\n");
return -1;
}
if((oss_audio_fd=open("/dev/dsp",O_WRONLY,0))==-1) {
printf("Sound device not available!\n");
return -1;
}
if(ioctl(oss_audio_fd,SNDCTL_DSP_RESET,0)==-1) {
printf("Sound reset failed\n");
return -1;
}
if(ioctl(oss_audio_fd,SNDCTL_DSP_RESET,0)==-1) {
printf("Sound reset failed\n");
return -1;
}
// we use 64 fragments with 1024 bytes each
fragsize=10;
myfrag=(63<<16)|fragsize;
// we use 64 fragments with 1024 bytes each
fragsize=10;
myfrag=(63<<16)|fragsize;
if(ioctl(oss_audio_fd,SNDCTL_DSP_SETFRAGMENT,&myfrag)==-1) {
printf("Sound set fragment failed!\n");
return -1;
}
if(ioctl(oss_audio_fd,SNDCTL_DSP_SETFRAGMENT,&myfrag)==-1) {
printf("Sound set fragment failed!\n");
return -1;
}
format = AFMT_S16_LE;
format = AFMT_S16_LE;
if(ioctl(oss_audio_fd,SNDCTL_DSP_SETFMT,&format) == -1) {
printf("Sound format not supported!\n");
return -1;
}
if(ioctl(oss_audio_fd,SNDCTL_DSP_SETFMT,&format) == -1) {
printf("Sound format not supported!\n");
return -1;
}
if(format!=AFMT_S16_LE) {
printf("Sound format not supported!\n");
return -1;
}
if(format!=AFMT_S16_LE) {
printf("Sound format not supported!\n");
return -1;
}
if(ioctl(oss_audio_fd,SNDCTL_DSP_STEREO,&oss_stereo)==-1) {
printf("Stereo mode not supported!\n");
return -1;
}
if(ioctl(oss_audio_fd,SNDCTL_DSP_STEREO,&oss_stereo)==-1) {
printf("Stereo mode not supported!\n");
return -1;
}
if(ioctl(oss_audio_fd,SNDCTL_DSP_SPEED,&oss_speed)==-1) {
printf("Sound frequency not supported\n");
return -1;
}
if(ioctl(oss_audio_fd,SNDCTL_DSP_SPEED,&oss_speed)==-1) {
printf("Sound frequency not supported\n");
return -1;
}
if(oss_speed!=pspeed) {
printf("Sound frequency not supported\n");
return -1;
}
if(oss_speed!=pspeed) {
printf("Sound frequency not supported\n");
return -1;
}
return 0;
return 0;
}
// REMOVE SOUND
void RemoveSound()
{
if(oss_audio_fd != -1 ) {
close(oss_audio_fd);
oss_audio_fd = -1;
}
if(oss_audio_fd != -1 ) {
close(oss_audio_fd);
oss_audio_fd = -1;
}
}
#define SOUNDSIZE 76800
int SoundGetBytesBuffered()
{
audio_buf_info info;
unsigned long l;
audio_buf_info info;
unsigned long l;
if(oss_audio_fd == -1)
return SOUNDSIZE;
if(ioctl(oss_audio_fd,SNDCTL_DSP_GETOSPACE,&info)==-1)
return 0;
else {
if(oss_audio_fd == -1)
return SOUNDSIZE;
if(ioctl(oss_audio_fd,SNDCTL_DSP_GETOSPACE,&info)==-1)
return 0;
else {
// can we write in at least the half of fragments?
if(info.fragments<(info.fragstotal>>1))
return SOUNDSIZE;
}
if(info.fragments<(info.fragstotal>>1))
return SOUNDSIZE;
}
return 0;
return 0;
}
// FEED SOUND DATA
void SoundFeedVoiceData(unsigned char* pSound,long lBytes)
{
if(oss_audio_fd == -1) return;
write(oss_audio_fd,pSound,lBytes);
if(oss_audio_fd == -1) return;
write(oss_audio_fd,pSound,lBytes);
}
#else
@ -152,123 +169,120 @@ static snd_pcm_uframes_t buffer_size;
int SetupSound(void)
{
snd_pcm_hw_params_t *hwparams;
snd_pcm_sw_params_t *swparams;
snd_pcm_status_t *status;
unsigned int pspeed;
int pchannels;
snd_pcm_format_t format;
unsigned int buffer_time, period_time;
int err;
snd_pcm_hw_params_t *hwparams;
snd_pcm_sw_params_t *swparams;
snd_pcm_status_t *status;
unsigned int pspeed;
int pchannels;
snd_pcm_format_t format;
unsigned int buffer_time, period_time;
int err;
pchannels=2;
pchannels=2;
pspeed=48000;
format=SND_PCM_FORMAT_S16_LE;
buffer_time=SOUNDSIZE;
period_time=buffer_time/4;
pspeed=48000;
format=SND_PCM_FORMAT_S16_LE;
buffer_time=SOUNDSIZE;
period_time=buffer_time/4;
if((err=snd_pcm_open(&handle, "default",
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK))<0) {
printf("Audio open error: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK))<0) {
printf("Audio open error: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_nonblock(handle, 0))<0) {
printf("Can't set blocking moded: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_nonblock(handle, 0))<0) {
printf("Can't set blocking moded: %s\n", snd_strerror(err));
return -1;
}
snd_pcm_hw_params_alloca(&hwparams);
snd_pcm_sw_params_alloca(&swparams);
if((err=snd_pcm_hw_params_any(handle, hwparams))<0) {
printf("Broken configuration for this PCM: %s\n", snd_strerror(err));
return -1;
}
snd_pcm_hw_params_alloca(&hwparams);
snd_pcm_sw_params_alloca(&swparams);
if((err=snd_pcm_hw_params_any(handle, hwparams))<0) {
printf("Broken configuration for this PCM: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED))<0) {
printf("Access type not available: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED))<0) {
printf("Access type not available: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_hw_params_set_format(handle, hwparams, format))<0) {
printf("Sample format not available: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_hw_params_set_format(handle, hwparams, format))<0) {
printf("Sample format not available: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_hw_params_set_channels(handle, hwparams, pchannels))<0) {
printf("Channels count not available: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_hw_params_set_channels(handle, hwparams, pchannels))<0) {
printf("Channels count not available: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_hw_params_set_rate_near(handle, hwparams, &pspeed, 0))<0) {
printf("Rate not available: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_hw_params_set_rate_near(handle, hwparams, &pspeed, 0))<0) {
printf("Rate not available: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_hw_params_set_buffer_time_near(handle, hwparams, &buffer_time, 0))<0) {
printf("Buffer time error: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_hw_params_set_period_time_near(handle, hwparams, &period_time, 0))<0) {
printf("Period time error: %s\n", snd_strerror(err));
return -1;
if((err=snd_pcm_hw_params_set_period_time_near(handle, hwparams, &period_time, 0))<0) {
printf("Period time error: %s\n", snd_strerror(err));
return -1;
}
if((err=snd_pcm_hw_params(handle, hwparams))<0) {
printf("Unable to install hw params: %s\n", snd_strerror(err));
return -1;
if((err=snd_pcm_hw_params(handle, hwparams))<0) {
printf("Unable to install hw params: %s\n", snd_strerror(err));
return -1;
}
snd_pcm_status_alloca(&status);
if((err=snd_pcm_status(handle, status))<0) {
printf("Unable to get status: %s\n", snd_strerror(err));
return -1;
}
snd_pcm_status_alloca(&status);
if((err=snd_pcm_status(handle, status))<0) {
printf("Unable to get status: %s\n", snd_strerror(err));
return -1;
}
buffer_size=snd_pcm_status_get_avail(status);
buffer_size=snd_pcm_status_get_avail(status);
return 0;
return 0;
}
void RemoveSound()
{
if(handle != NULL) {
snd_pcm_drop(handle);
snd_pcm_close(handle);
handle = NULL;
}
if(handle != NULL) {
snd_pcm_drop(handle);
snd_pcm_close(handle);
handle = NULL;
}
}
int SoundGetBytesBuffered()
{
int l;
int l;
if(handle == NULL) // failed to open?
return SOUNDSIZE;
l = snd_pcm_avail_update(handle);
if(l<0) return 0;
if(l<buffer_size/2) // can we write in at least the half of fragments?
l=SOUNDSIZE; // -> no? wait
else l=0; // -> else go on
if(handle == NULL) // failed to open?
return SOUNDSIZE;
l = snd_pcm_avail_update(handle);
if(l<0) return 0;
if(l<buffer_size/2) // can we write in at least the half of fragments?
l=SOUNDSIZE; // -> no? wait
else l=0; // -> else go on
return l;
return l;
}
void SoundFeedVoiceData(unsigned char* pSound,long lBytes)
{
if(handle == NULL) return;
if(handle == NULL) return;
if(snd_pcm_state(handle) == SND_PCM_STATE_XRUN)
snd_pcm_prepare(handle);
snd_pcm_writei(handle,pSound, lBytes/4);
if(snd_pcm_state(handle) == SND_PCM_STATE_XRUN)
snd_pcm_prepare(handle);
snd_pcm_writei(handle,pSound, lBytes/4);
}
#endif
GtkWidget *MsgDlg;
void OnMsg_Ok() {
gtk_widget_destroy(MsgDlg);
gtk_main_quit();
@ -316,7 +330,43 @@ void SysMessage(char *fmt, ...) {
}
void CALLBACK SPU2configure() {
SysMessage("Nothing to Configure");
ConfDlg = create_Config();
LoadConfig();
set_checked(ConfDlg, "timescalingbutton", (conf.options & OPTION_TIMESTRETCH));
set_checked(ConfDlg, "realtimebutton", (conf.options & OPTION_REALTIME));
set_checked(ConfDlg, "recordingbutton", (conf.options & OPTION_RECORDING));
set_checked(ConfDlg, "mutebutton", (conf.options & OPTION_MUTE));
set_checked(ConfDlg, "loggingbutton", (conf.Log));
gtk_widget_show_all(ConfDlg);
gtk_main();
}
void on_Conf_Ok (GtkButton *button, gpointer user_data)
{
conf.options = 0;
if (is_checked(ConfDlg, "realtimebutton"))
conf.options |= OPTION_REALTIME;
if (is_checked(ConfDlg, "timescalingbutton"))
conf.options |= OPTION_TIMESTRETCH;
if (is_checked(ConfDlg, "recordingbutton"))
conf.options |= OPTION_RECORDING;
if (is_checked(ConfDlg, "mutebutton"))
conf.options |= OPTION_MUTE;
conf.Log = is_checked(ConfDlg, "loggingbutton");
SaveConfig();
gtk_widget_destroy(ConfDlg);
gtk_main_quit();
}
void on_Conf_Cancel (GtkButton *button, gpointer user_data)
{
gtk_widget_destroy(ConfDlg);
gtk_main_quit();
}
extern char* libraryName;
@ -327,36 +377,36 @@ void CALLBACK SPU2about() {
}
void SaveConfig() {
FILE *f;
char cfg[255];
FILE *f;
char cfg[255];
strcpy(cfg, s_strIniPath.c_str());
f = fopen(cfg,"w");
if (f == NULL) {
printf("Failed to open %s\n", s_strIniPath.c_str());
return;
}
fprintf(f, "log = %d\n", conf.Log);
fprintf(f, "options = %d\n", conf.options);
fclose(f);
strcpy(cfg, s_strIniPath.c_str());
f = fopen(cfg,"w");
if (f == NULL) {
printf("Failed to open %s\n", s_strIniPath.c_str());
return;
}
fprintf(f, "log = %d\n", conf.Log);
fprintf(f, "options = %d\n", conf.options);
fclose(f);
}
void LoadConfig() {
FILE *f;
char cfg[255];
FILE *f;
char cfg[255];
memset(&conf, 0, sizeof(conf));
memset(&conf, 0, sizeof(conf));
strcpy(cfg, s_strIniPath.c_str());
f = fopen(cfg, "r");
if (f == NULL) {
printf("Failed to open %s\n", s_strIniPath.c_str());
conf.Log = 0;//default value
conf.options = 0;//OPTION_TIMESTRETCH;
SaveConfig();//save and return
return;
}
strcpy(cfg, s_strIniPath.c_str());
f = fopen(cfg, "r");
if (f == NULL) {
printf("Failed to open %s\n", s_strIniPath.c_str());
conf.Log = 0;//default value
conf.options = 0;//OPTION_TIMESTRETCH;
SaveConfig();//save and return
return;
}
fscanf(f, "log = %d\n", &conf.Log);
fscanf(f, "options = %d\n", &conf.options);
fclose(f);
fscanf(f, "options = %d\n", &conf.options);
fclose(f);
}

View File

@ -26,6 +26,6 @@ libZeroSPU2_LDFLAGS= @SHARED_LDFLAGS@
libZeroSPU2_LDFLAGS+=-Wl,-soname,@ZEROSPU2_SONAME@
libZeroSPU2_LDADD=$(libZeroSPU2_a_OBJECTS) SoundTouch/libSoundTouch.a
libZeroSPU2_a_SOURCES = zerospu2.cpp Linux.cpp
libZeroSPU2_a_SOURCES = zerospu2.cpp interface.c Linux.cpp support.c
SUBDIRS = SoundTouch .
SUBDIRS = SoundTouch

View File

@ -0,0 +1,9 @@
# builds the GUI C classes
mkdir temp
cp zerospu2.glade temp/
cd temp
glade-2 --write-source zerospu2.glade
rm src/main.c
cp src/*.h src/*.c ../
cd ..
/bin/rm -rf temp

View File

@ -0,0 +1,26 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
void
on_Conf_Ok (GtkButton *button,
gpointer user_data)
{
}
void
on_Conf_Cancel (GtkButton *button,
gpointer user_data)
{
}

View File

@ -0,0 +1,10 @@
#include <gtk/gtk.h>
void
on_Conf_Ok (GtkButton *button,
gpointer user_data);
void
on_Conf_Cancel (GtkButton *button,
gpointer user_data);

View File

@ -0,0 +1,130 @@
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
#define GLADE_HOOKUP_OBJECT(component,widget,name) \
g_object_set_data_full (G_OBJECT (component), name, \
gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
g_object_set_data (G_OBJECT (component), name, widget)
GtkWidget*
create_About (void)
{
GtkWidget *About;
/* TRANSLATORS: Replace this string with your names, one name per line. */
gchar *translators = _("translator-credits");
About = gtk_about_dialog_new ();
gtk_container_set_border_width (GTK_CONTAINER (About), 5);
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (About), VERSION);
gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (About), _("ZeroSPU2"));
gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (About), translators);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (About, About, "About");
return About;
}
GtkWidget*
create_Config (void)
{
GtkWidget *Config;
GtkWidget *dialog_vbox1;
GtkWidget *vbox1;
GtkWidget *timescalingbutton;
GtkWidget *realtimebutton;
GtkWidget *recordingbutton;
GtkWidget *mutebutton;
GtkWidget *loggingbutton;
GtkWidget *dialog_action_area1;
GtkWidget *Conf_Ok;
GtkWidget *Conf_Cancel;
Config = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (Config), _("ZeroSPU2 Config"));
gtk_window_set_type_hint (GTK_WINDOW (Config), GDK_WINDOW_TYPE_HINT_DIALOG);
dialog_vbox1 = GTK_DIALOG (Config)->vbox;
gtk_widget_show (dialog_vbox1);
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);
timescalingbutton = gtk_check_button_new_with_mnemonic (_("Time Scaling (recommended) \nSlows down or speeds up sound with respect to game's real speed. \nEnabling this produces higher quality sound with less cracking, but can reduce speed."));
gtk_widget_show (timescalingbutton);
gtk_box_pack_start (GTK_BOX (vbox1), timescalingbutton, FALSE, FALSE, 0);
realtimebutton = gtk_check_button_new_with_mnemonic (_("Real Time mode \nTries to reduce delays in music as much possible. \nUse when game is already fast and need sound tightly synchronized.\n(like in DDR, Guitar Hero, Guitaroo Man)"));
gtk_widget_show (realtimebutton);
gtk_box_pack_start (GTK_BOX (vbox1), realtimebutton, FALSE, FALSE, 0);
recordingbutton = gtk_check_button_new_with_mnemonic (_("Recording - Saves the raw 16bit stereo wav data to zerospu2.wav. Timed to ps2 time."));
gtk_widget_show (recordingbutton);
gtk_box_pack_start (GTK_BOX (vbox1), recordingbutton, FALSE, FALSE, 0);
mutebutton = gtk_check_button_new_with_mnemonic (_("Mute - ZeroSPU2 will not output any sound (fast)."));
gtk_widget_show (mutebutton);
gtk_box_pack_start (GTK_BOX (vbox1), mutebutton, FALSE, FALSE, 0);
loggingbutton = gtk_check_button_new_with_mnemonic (_("Enable logging(for development use only)"));
gtk_widget_show (loggingbutton);
gtk_box_pack_start (GTK_BOX (vbox1), loggingbutton, FALSE, FALSE, 0);
dialog_action_area1 = GTK_DIALOG (Config)->action_area;
gtk_widget_show (dialog_action_area1);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
Conf_Ok = gtk_button_new_from_stock ("gtk-ok");
gtk_widget_show (Conf_Ok);
gtk_dialog_add_action_widget (GTK_DIALOG (Config), Conf_Ok, GTK_RESPONSE_OK);
GTK_WIDGET_SET_FLAGS (Conf_Ok, GTK_CAN_DEFAULT);
Conf_Cancel = gtk_button_new_from_stock ("gtk-cancel");
gtk_widget_show (Conf_Cancel);
gtk_dialog_add_action_widget (GTK_DIALOG (Config), Conf_Cancel, GTK_RESPONSE_CANCEL);
GTK_WIDGET_SET_FLAGS (Conf_Cancel, GTK_CAN_DEFAULT);
g_signal_connect ((gpointer) Conf_Ok, "clicked",
G_CALLBACK (on_Conf_Ok),
NULL);
g_signal_connect ((gpointer) Conf_Cancel, "clicked",
G_CALLBACK (on_Conf_Cancel),
NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (Config, Config, "Config");
GLADE_HOOKUP_OBJECT_NO_REF (Config, dialog_vbox1, "dialog_vbox1");
GLADE_HOOKUP_OBJECT (Config, vbox1, "vbox1");
GLADE_HOOKUP_OBJECT (Config, timescalingbutton, "timescalingbutton");
GLADE_HOOKUP_OBJECT (Config, realtimebutton, "realtimebutton");
GLADE_HOOKUP_OBJECT (Config, recordingbutton, "recordingbutton");
GLADE_HOOKUP_OBJECT (Config, mutebutton, "mutebutton");
GLADE_HOOKUP_OBJECT (Config, loggingbutton, "loggingbutton");
GLADE_HOOKUP_OBJECT_NO_REF (Config, dialog_action_area1, "dialog_action_area1");
GLADE_HOOKUP_OBJECT (Config, Conf_Ok, "Conf_Ok");
GLADE_HOOKUP_OBJECT (Config, Conf_Cancel, "Conf_Cancel");
return Config;
}

View File

@ -0,0 +1,6 @@
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
GtkWidget* create_About (void);
GtkWidget* create_Config (void);

144
plugins/zerospu2/support.c Normal file
View File

@ -0,0 +1,144 @@
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include "support.h"
GtkWidget*
lookup_widget (GtkWidget *widget,
const gchar *widget_name)
{
GtkWidget *parent, *found_widget;
for (;;)
{
if (GTK_IS_MENU (widget))
parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
else
parent = widget->parent;
if (!parent)
parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
if (parent == NULL)
break;
widget = parent;
}
found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
widget_name);
if (!found_widget)
g_warning ("Widget not found: %s", widget_name);
return found_widget;
}
static GList *pixmaps_directories = NULL;
/* Use this function to set the directory containing installed pixmaps. */
void
add_pixmap_directory (const gchar *directory)
{
pixmaps_directories = g_list_prepend (pixmaps_directories,
g_strdup (directory));
}
/* This is an internally used function to find pixmap files. */
static gchar*
find_pixmap_file (const gchar *filename)
{
GList *elem;
/* We step through each of the pixmaps directory to find it. */
elem = pixmaps_directories;
while (elem)
{
gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
G_DIR_SEPARATOR_S, filename);
if (g_file_test (pathname, G_FILE_TEST_EXISTS))
return pathname;
g_free (pathname);
elem = elem->next;
}
return NULL;
}
/* This is an internally used function to create pixmaps. */
GtkWidget*
create_pixmap (GtkWidget *widget,
const gchar *filename)
{
gchar *pathname = NULL;
GtkWidget *pixmap;
if (!filename || !filename[0])
return gtk_image_new ();
pathname = find_pixmap_file (filename);
if (!pathname)
{
g_warning (_("Couldn't find pixmap file: %s"), filename);
return gtk_image_new ();
}
pixmap = gtk_image_new_from_file (pathname);
g_free (pathname);
return pixmap;
}
/* This is an internally used function to create pixmaps. */
GdkPixbuf*
create_pixbuf (const gchar *filename)
{
gchar *pathname = NULL;
GdkPixbuf *pixbuf;
GError *error = NULL;
if (!filename || !filename[0])
return NULL;
pathname = find_pixmap_file (filename);
if (!pathname)
{
g_warning (_("Couldn't find pixmap file: %s"), filename);
return NULL;
}
pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
if (!pixbuf)
{
fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
pathname, error->message);
g_error_free (error);
}
g_free (pathname);
return pixbuf;
}
/* This is used to set ATK action descriptions. */
void
glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description)
{
gint n_actions, i;
n_actions = atk_action_get_n_actions (action);
for (i = 0; i < n_actions; i++)
{
if (!strcmp (atk_action_get_name (action, i), action_name))
atk_action_set_description (action, i, description);
}
}

View File

@ -0,0 +1,69 @@
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
/*
* Standard gettext macros.
*/
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
# define _(String) dgettext (PACKAGE, String)
# define Q_(String) g_strip_context ((String), gettext (String))
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define Q_(String) g_strip_context ((String), (String))
# define N_(String) (String)
#endif
/*
* Public Functions.
*/
/*
* This function returns a widget in a component created by Glade.
* Call it with the toplevel widget in the component (i.e. a window/dialog),
* or alternatively any widget in the component, and the name of the widget
* you want returned.
*/
GtkWidget* lookup_widget (GtkWidget *widget,
const gchar *widget_name);
/* Use this function to set the directory containing installed pixmaps. */
void add_pixmap_directory (const gchar *directory);
/*
* Private Functions.
*/
/* This is used to create the pixmaps used in the interface. */
GtkWidget* create_pixmap (GtkWidget *widget,
const gchar *filename);
/* This is used to create the pixbufs used in the interface. */
GdkPixbuf* create_pixbuf (const gchar *filename);
/* This is used to set ATK action descriptions. */
void glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description);

View File

@ -0,0 +1,195 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkAboutDialog" id="About">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="destroy_with_parent">False</property>
<property name="name" translatable="yes">ZeroSPU2</property>
<property name="wrap_license">False</property>
<property name="translator_credits" translatable="yes" comments="TRANSLATORS: Replace this string with your names, one name per line.">translator-credits</property>
</widget>
<widget class="GtkDialog" id="Config">
<property name="visible">True</property>
<property name="title" translatable="yes">ZeroSPU2 Config</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">True</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="Conf_Ok">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
<signal name="clicked" handler="on_Conf_Ok" last_modification_time="Sat, 18 Oct 2008 14:31:53 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="Conf_Cancel">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="on_Conf_Cancel" last_modification_time="Sat, 18 Oct 2008 14:32:05 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkCheckButton" id="timescalingbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Time Scaling (recommended)
Slows down or speeds up sound with respect to game's real speed.
Enabling this produces higher quality sound with less cracking, but can reduce speed.</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="realtimebutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Real Time mode
Tries to reduce delays in music as much possible.
Use when game is already fast and need sound tightly synchronized.
(like in DDR, Guitar Hero, Guitaroo Man)</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="recordingbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Recording - Saves the raw 16bit stereo wav data to zerospu2.wav. Timed to ps2 time.</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="mutebutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Mute - ZeroSPU2 will not output any sound (fast).</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="loggingbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Enable logging(for development use only)</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>