From 348caa1b80baec7f0778c17c908762d7eb83e4b2 Mon Sep 17 00:00:00 2001 From: bgk Date: Fri, 25 Apr 2008 09:34:16 +0000 Subject: [PATCH] GTK GUI : Added a menu to select the video output module --- src/gtk/vba.glade | 35 +++++++++++++++++++++++++++++++++++ src/gtk/window.cpp | 37 +++++++++++++++++++++++++++++++------ src/gtk/window.h | 3 ++- src/gtk/windowcallbacks.cpp | 12 ++++++++++++ 4 files changed, 80 insertions(+), 7 deletions(-) diff --git a/src/gtk/vba.glade b/src/gtk/vba.glade index a965936d..49eef515 100644 --- a/src/gtk/vba.glade +++ b/src/gtk/vba.glade @@ -598,6 +598,41 @@ True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _OpenGL + True + True + True + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Cairo + True + True + VideoOpenGL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Xvideo + True + True + VideoOpenGL + + + + + True + + True diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 91c568fd..6445dd9b 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -124,8 +124,6 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : vSaveConfig(m_sConfigFile); } - vInitScreenArea(); - vCreateFileOpenDialog(); vLoadHistoryFromConfig(); vLoadJoypadsFromConfig(); @@ -133,6 +131,33 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : Gtk::MenuItem * poMI; Gtk::CheckMenuItem * poCMI; + // Video output menu + // + struct + { + const char * m_csName; + const EVideoOutput m_eVideoOutput; + } + astVideoOutput[] = + { + { "VideoOpenGL", OutputOpenGL }, + { "VideoCairo", OutputGtk }, + { "VideoXv", OutputXvideo } + }; + EVideoOutput eDefaultVideoOutput = (EVideoOutput)m_poDisplayConfig->oGetKey("output"); + for (guint i = 0; i < G_N_ELEMENTS(astVideoOutput); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astVideoOutput[i].m_csName)); + if (astVideoOutput[i].m_eVideoOutput == eDefaultVideoOutput) + { + poCMI->set_active(); + vOnVideoOutputToggled(poCMI, eDefaultVideoOutput); + } + poCMI->signal_toggled().connect(sigc::bind( + sigc::mem_fun(*this, &Window::vOnVideoOutputToggled), + poCMI, astVideoOutput[i].m_eVideoOutput)); + } + // File menu // poMI = dynamic_cast(_poXml->get_widget("FileOpen")); @@ -861,17 +886,17 @@ Window::~Window() m_poInstance = NULL; } -void Window::vInitScreenArea() +void Window::vInitScreenArea(EVideoOutput _eVideoOutput) { Gtk::Alignment * poC; poC = dynamic_cast(m_poXml->get_widget("ScreenContainer")); + poC->remove(); poC->set(Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER, 0.0, 0.0); - EVideoOutput eVideoOutput = (EVideoOutput)m_poDisplayConfig->oGetKey("output"); - + try { - switch (eVideoOutput) + switch (_eVideoOutput) { #ifdef USE_OPENGL case OutputOpenGL: diff --git a/src/gtk/window.h b/src/gtk/window.h index 23f29a90..a1d71993 100644 --- a/src/gtk/window.h +++ b/src/gtk/window.h @@ -159,6 +159,7 @@ protected: virtual void vOnFrameskipToggled(Gtk::CheckMenuItem * _poCMI, int _iValue); virtual void vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent); virtual void vOnThrottleOther(Gtk::CheckMenuItem * _poCMI); + virtual void vOnVideoOutputToggled(Gtk::CheckMenuItem * _poCMI, int _iOutput); virtual void vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale); virtual void vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer); virtual void vOnDirectories(); @@ -291,7 +292,7 @@ private: void vUnInitSystem(); void vInitConfig(); void vCheckConfig(); - void vInitScreenArea(); + void vInitScreenArea(EVideoOutput _eVideoOutput); void vLoadConfig(const std::string & _rsFile); void vSaveConfig(const std::string & _rsFile); void vLoadHistoryFromConfig(); diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp index b81fa3f7..e0e09f5d 100644 --- a/src/gtk/windowcallbacks.cpp +++ b/src/gtk/windowcallbacks.cpp @@ -590,6 +590,18 @@ void Window::vOnThrottleOther(Gtk::CheckMenuItem * _poCMI) vSelectBestThrottleItem(); } +void Window::vOnVideoOutputToggled(Gtk::CheckMenuItem * _poCMI, int _iOutput) +{ + if (! _poCMI->get_active()) + { + return; + } + + m_poDisplayConfig->vSetKey("output", _iOutput); + + vInitScreenArea((EVideoOutput)_iOutput); +} + void Window::vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale) { if (! _poCMI->get_active())