2009-05-23 05:15:03 +00:00
|
|
|
/* FWnull
|
|
|
|
* Copyright (C) 2004-2009 PCSX2 Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include "Pad.h"
|
|
|
|
#include "Config.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "support.h"
|
|
|
|
#include "callbacks.h"
|
|
|
|
#include "interface.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
GtkWidget *MsgDlg, *About, *Conf;
|
|
|
|
extern string s_strIniPath;
|
2010-06-10 16:30:08 +00:00
|
|
|
PluginConf Ini;
|
2009-05-23 05:15:03 +00:00
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
void OnMsg_Ok()
|
2009-05-23 05:15:03 +00:00
|
|
|
{
|
|
|
|
gtk_widget_destroy(MsgDlg);
|
|
|
|
gtk_main_quit();
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
void SysMessage(char *fmt, ...)
|
2009-05-23 05:15:03 +00:00
|
|
|
{
|
|
|
|
GtkWidget *Ok,*Txt;
|
|
|
|
GtkWidget *Box,*Box1;
|
|
|
|
va_list list;
|
|
|
|
char msg[512];
|
|
|
|
|
|
|
|
va_start(list, fmt);
|
|
|
|
vsprintf(msg, fmt, list);
|
|
|
|
va_end(list);
|
|
|
|
|
|
|
|
if (msg[strlen(msg) - 1] == '\n') msg[strlen(msg)-1] = 0;
|
|
|
|
|
|
|
|
MsgDlg = gtk_window_new (GTK_WINDOW_POPUP);
|
|
|
|
gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(MsgDlg), "FireWire Msg");
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5);
|
|
|
|
|
|
|
|
Box = gtk_vbox_new(5, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(MsgDlg), Box);
|
|
|
|
gtk_widget_show(Box);
|
|
|
|
|
|
|
|
Txt = gtk_label_new(msg);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-23 05:15:03 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5);
|
|
|
|
gtk_widget_show(Txt);
|
|
|
|
|
|
|
|
Box1 = gtk_hbutton_box_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(Box1);
|
|
|
|
|
|
|
|
Ok = gtk_button_new_with_label("Ok");
|
|
|
|
gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL);
|
|
|
|
gtk_container_add(GTK_CONTAINER(Box1), Ok);
|
|
|
|
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
|
|
|
|
gtk_widget_show(Ok);
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
gtk_widget_show(MsgDlg);
|
2009-05-23 05:15:03 +00:00
|
|
|
|
|
|
|
gtk_main();
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
|
|
|
void OnAbout_Ok(GtkButton *button, gpointer user_data)
|
2009-05-23 05:15:03 +00:00
|
|
|
{
|
|
|
|
gtk_widget_destroy(About);
|
|
|
|
gtk_main_quit();
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(void) PADabout()
|
2009-05-23 05:15:03 +00:00
|
|
|
{
|
|
|
|
About = create_About();
|
|
|
|
gtk_widget_show_all(About);
|
|
|
|
gtk_main();
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
void OnConf_Ok(GtkButton *button, gpointer user_data)
|
2009-05-23 05:15:03 +00:00
|
|
|
{
|
|
|
|
conf.Log = is_checked(Conf, "check_logging");
|
|
|
|
SaveConfig();
|
|
|
|
|
|
|
|
gtk_widget_destroy(Conf);
|
|
|
|
gtk_main_quit();
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
void OnConf_Cancel(GtkButton *button, gpointer user_data)
|
2009-05-23 05:15:03 +00:00
|
|
|
{
|
|
|
|
gtk_widget_destroy(Conf);
|
|
|
|
gtk_main_quit();
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(void) PADconfigure()
|
2009-05-23 05:15:03 +00:00
|
|
|
{
|
|
|
|
LoadConfig();
|
2010-06-10 16:30:08 +00:00
|
|
|
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
|
|
|
|
SaveConfig();
|
2009-05-23 05:15:03 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
void LoadConfig()
|
2009-05-23 05:15:03 +00:00
|
|
|
{
|
2010-06-10 16:30:08 +00:00
|
|
|
const std::string iniFile(s_strIniPath + "/Padnull.ini");
|
2009-05-23 05:15:03 +00:00
|
|
|
|
2010-06-10 16:30:08 +00:00
|
|
|
if (!Ini.Open(iniFile, READ_FILE))
|
2009-05-23 05:15:03 +00:00
|
|
|
{
|
2010-06-10 16:30:08 +00:00
|
|
|
printf("failed to open %s\n", iniFile.c_str());
|
2009-05-23 05:15:03 +00:00
|
|
|
SaveConfig();//save and return
|
|
|
|
return;
|
|
|
|
}
|
2010-06-10 16:30:08 +00:00
|
|
|
|
|
|
|
conf.Log = Ini.ReadInt("logging", 0);
|
|
|
|
Ini.Close();
|
2009-05-23 05:15:03 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
void SaveConfig()
|
2009-05-23 05:15:03 +00:00
|
|
|
{
|
2010-06-10 16:30:08 +00:00
|
|
|
const std::string iniFile(s_strIniPath + "/Padnull.ini");
|
2009-05-23 05:15:03 +00:00
|
|
|
|
2010-06-10 16:30:08 +00:00
|
|
|
if (!Ini.Open(iniFile, WRITE_FILE))
|
2009-05-23 05:15:03 +00:00
|
|
|
{
|
2010-06-10 16:30:08 +00:00
|
|
|
printf("failed to open %s\n", iniFile.c_str());
|
2009-05-23 05:15:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-06-10 16:30:08 +00:00
|
|
|
|
|
|
|
Ini.WriteInt("logging", conf.Log);
|
|
|
|
Ini.Close();
|
2009-05-23 05:15:03 +00:00
|
|
|
}
|
|
|
|
|