Skip to content

Commit

Permalink
Fix GUI with wxGTK < 3.x
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Gervais <gervais.maxime@gmail.com>
  • Loading branch information
g-maxime committed Jun 27, 2024
1 parent c45073d commit 3f2d673
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 10 deletions.
5 changes: 4 additions & 1 deletion Project/GNU/GUI/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ mediainfo_gui_SOURCES = \
../../../Source/GUI/WxWidgets/GUI_Main_Sheet.cpp \
../../../Source/GUI/WxWidgets/GUI_Main_Text.cpp \
../../../Source/GUI/WxWidgets/GUI_Main_Tree.cpp \
../../../Source/GUI/WxWidgets/GUI_Preferences.cpp \
../../../Source/CLI/CommandLine_Parser.cpp \
../../../Source/CLI/Help.cpp \
../../../Source/Common/Core.cpp

if WX_PREFERENCES
mediainfo_gui_SOURCES += ../../../Source/GUI/WxWidgets/GUI_Preferences.cpp
endif

#mediainfo_gui_LDFLAGS = -no-undefined -version-info 0:0:0

AM_CXXFLAGS = -std=c++11
Expand Down
4 changes: 4 additions & 0 deletions Project/GNU/GUI/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ if test "$with_wx" != "no"; then
CFLAGS="$CFLAGS $($ZenLib_Wx_Config --unicode=$enable_unicode --cflags)"
CXXFLAGS="$CXXFLAGS $($ZenLib_Wx_Config --unicode=$enable_unicode --cxxflags)"
LIBS="$LIBS $($ZenLib_Wx_Config --unicode=$enable_unicode --libs)"
if test "$(echo $WX_VERSION | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/')" -ge 3; then
CXXFLAGS="$CXXFLAGS -DWX_PREFERENCES"
fi
fi
AM_CONDITIONAL([WX_PREFERENCES], [test "$with_wx" != "no" -a "$(echo $WX_VERSION | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/')" -ge 3])

dnl #########################################################################
dnl ### C/C++ compiler options used to compile
Expand Down
4 changes: 2 additions & 2 deletions Project/GNU/mediainfo.spec
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ BuildRequires: libopenssl-devel
BuildRequires: wxWidgets-devel
%else
%if 0%{?mageia}
BuildRequires: wxgtk2.8-devel
BuildRequires: wxgtk3.0-devel
%else
%if (0%{?fedora_version} && 0%{?fedora_version} <= 38) || 0%{?rhel} >= 8
BuildRequires: wxGTK3-devel
Expand Down Expand Up @@ -136,7 +136,7 @@ Requires: %{libmediainfo_name}%{?_isa} >= %{libmediainfo_version}
Requires: wxWidgets
%else
%if 0%{?mageia}
Requires: wxgtk2.8
Requires: wxgtk3.0
%else
%if (0%{?fedora_version} && 0%{?fedora_version} >= 29) || 0%{?rhel} >= 8
Requires: wxGTK3
Expand Down
8 changes: 6 additions & 2 deletions Source/GUI/WxWidgets/GUI_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

//---------------------------------------------------------------------------
#include "wx/wxprec.h"
#include "wx/preferences.h"
#ifdef WX_PREFERENCES
#include "wx/preferences.h"
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
Expand Down Expand Up @@ -79,7 +81,9 @@ GUI_Main::GUI_Main(int argc, MediaInfoNameSpace::Char** argv_ansi, const wxPoint

//GUI
View=NULL;
PreferencesEditor=NULL;
#ifdef WX_PREFERENCES
PreferencesEditor=NULL;
#endif
CenterOnScreen();

//Drag and Drop
Expand Down
12 changes: 10 additions & 2 deletions Source/GUI/WxWidgets/GUI_Main.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

//---------------------------------------------------------------------------
#include "GUI/Common/GUI_Main_Common_Core.h"
#include "wx/preferences.h"
#ifdef WX_PREFERENCES
#include "wx/preferences.h"
#endif
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -63,7 +65,9 @@ class GUI_Main : public wxFrame
wxMenu* Menu_File_Open;
wxMenuItem* Menu_File_Open_Files;
wxMenuItem* Menu_File_Open_Directory;
#ifdef WX_PREFERENCES
wxMenuItem* Menu_File_Preferences;
#endif
wxMenuItem* Menu_File_Quit;
wxMenu* Menu_View;
wxMenuItem* Menu_View_Easy;
Expand Down Expand Up @@ -107,7 +111,9 @@ class GUI_Main : public wxFrame
void Menu_Create();
void OnMenu_File_Open_Files (wxCommandEvent &event);
void OnMenu_File_Open_Directory (wxCommandEvent &event);
#ifdef WX_PREFERENCES
void OnMenu_File_Preferences (wxCommandEvent &event);
#endif
void OnMenu_File_Quit (wxCommandEvent &event);
void OnMenu_View_Easy (wxCommandEvent &event);
void OnMenu_View_Sheet (wxCommandEvent &event);
Expand Down Expand Up @@ -159,7 +165,9 @@ class GUI_Main : public wxFrame
//GUI
GUI_Main_Common_Core* View;

wxPreferencesEditor* PreferencesEditor;
#ifdef WX_PREFERENCES
wxPreferencesEditor* PreferencesEditor;
#endif

//wxWidgets
DECLARE_EVENT_TABLE() //Any class wishing to process wxWindows events must use this macro
Expand Down
16 changes: 13 additions & 3 deletions Source/GUI/WxWidgets/GUI_Main_Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include "GUI/WxWidgets/GUI_Main_Tree.h"
#include "GUI/WxWidgets/GUI_Main_HTML.h"
#include "GUI/WxWidgets/GUI_Main_Text.h"
#include "GUI/WxWidgets/GUI_Preferences.h"
#ifdef WX_PREFERENCES
#include "GUI/WxWidgets/GUI_Preferences.h"
#endif
#include "Common/Core.h"
#include <wx/image.h>
//---------------------------------------------------------------------------
Expand All @@ -34,7 +36,9 @@ enum
ID_Menu_File_Open,
ID_Menu_File_Open_Files,
ID_Menu_File_Open_Directory,
#ifdef WX_PREFERENCES
ID_Menu_File_Preferences,
#endif
ID_Menu_File_Quit,
ID_Menu_View_Easy,
ID_Menu_View_Sheet,
Expand Down Expand Up @@ -75,7 +79,9 @@ BEGIN_EVENT_TABLE(GUI_Main, wxFrame)
//Menu
EVT_MENU(ID_Menu_File_Open_Files, GUI_Main::OnMenu_File_Open_Files)
EVT_MENU(ID_Menu_File_Open_Directory, GUI_Main::OnMenu_File_Open_Directory)
EVT_MENU(ID_Menu_File_Preferences, GUI_Main::OnMenu_File_Preferences)
#ifdef WX_PREFERENCES
EVT_MENU(ID_Menu_File_Preferences, GUI_Main::OnMenu_File_Preferences)
#endif
EVT_MENU(wxID_EXIT, GUI_Main::OnMenu_File_Quit)
EVT_MENU(ID_Menu_View_Easy, GUI_Main::OnMenu_View_Easy)
EVT_MENU(ID_Menu_View_Sheet, GUI_Main::OnMenu_View_Sheet)
Expand Down Expand Up @@ -136,7 +142,9 @@ void GUI_Main::Menu_Create()
//File
Menu_File=new wxMenu;
Menu_File->Append(ID_Menu_File_Open, __T("Open"), Menu_File_Open);
Menu_File_Preferences =Menu_File->Append(ID_Menu_File_Preferences, __T("&Preferences"));
#ifdef WX_PREFERENCES
Menu_File_Preferences =Menu_File->Append(ID_Menu_File_Preferences, __T("&Preferences"));
#endif
Menu_File->AppendSeparator();
Menu_File_Quit =Menu_File->Append(wxID_EXIT, __T("E&xit\tAlt-X"), __T("Quit this program"));

Expand Down Expand Up @@ -228,6 +236,7 @@ void GUI_Main::OnMenu_File_Open_Files(wxCommandEvent& WXUNUSED(event))


//---------------------------------------------------------------------------
#ifdef WX_PREFERENCES
void GUI_Main::OnMenu_File_Preferences(wxCommandEvent& WXUNUSED(event))
{
if (!PreferencesEditor)
Expand All @@ -238,6 +247,7 @@ void GUI_Main::OnMenu_File_Preferences(wxCommandEvent& WXUNUSED(event))

PreferencesEditor->Show(this);
}
#endif

//---------------------------------------------------------------------------
void GUI_Main::OnMenu_File_Open_Directory(wxCommandEvent& WXUNUSED(event))
Expand Down
2 changes: 2 additions & 0 deletions Source/GUI/WxWidgets/GUI_Main_Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ GUI_Main_Text::~GUI_Main_Text()
//---------------------------------------------------------------------------
void GUI_Main_Text::GUI_Refresh()
{
#ifdef WX_PREFERENCES
wxConfigBase* Config=wxConfigBase::Get();
long TextSize=Config->ReadLong(wxT("/TextSize"), 0);
if (TextSize>(long)wxFONTSIZE_XX_LARGE)
Expand All @@ -60,6 +61,7 @@ void GUI_Main_Text::GUI_Refresh()
wxTextAttr Attr;
Attr.SetFont(Font);
SetDefaultStyle(Attr);
#endif //WX_PREFERENCES

Clear();
WriteText(C->Inform_Get().c_str());
Expand Down

0 comments on commit 3f2d673

Please sign in to comment.