Andreas Tscharner avatar Andreas Tscharner committed ff198d9

gui: Build gui only if dependencies are met and user allows it

* Check for dependencies and use it in test for AM_CONDITIONAL
* Add subdirectory if GUI should be built
+ Add Makefile.am for GUI as well as first (main) source file

Comments (0)

Files changed (4)

 PKG_CHECK_EXISTS([tinyxml], [TINYXML_ok="yes"], [TINYXML_ok="no (using internal)"])
 PKG_CHECK_EXISTS([libcryptopp], [CRYPTOPP_ok="yes"], [CRYPTOPP_ok="no (using internal)"])
 PKG_CHECK_EXISTS([libcrypto++], [PPCRYPTO_ok="yes"], [PPCRYPTO_ok="no (using internal)"])
+PKG_CHECK_MODULES([GUI_DEPS],
+                  [glibmm-2.4 >= 2.32.0 gtkmm-2.4 >= 2.24.2 libglademm-2.4 >= 2.6.7],
+                  [GUI_DEPS_ok="yes"],
+                  [GUI_DEPS_ok="no (do not build the gui"])
 
 #
 # Check for header files
   AC_DEFINE([NO_ENCRYPTION], [], [Disable encryption])
 fi
 AC_ARG_ENABLE(gui,
-              AC_HELP_STRING([--no-gui], [Don\'t build the gui]),,
-              [LRC_GUI="no"])
-AM_CONDITIONAL([NO_GUI], [test "$LRC_GUI" = no])
+              AC_HELP_STRING([--disable-gui], [Do not build the lrc Resource Editor]),
+              [LRC_GUI="no"],)
+AM_CONDITIONAL([NO_GUI], [test "$LRC_GUI" = no || test "$GUI_DEPS_ok" != yes])
 
 AM_CONDITIONAL(HAVE_DOXYGEN, test "$doxy_ok" = yes)
 AM_CONDITIONAL(HAVE_ALL_SDL, test "$SDL_ok" = yes && test "$SDLIMAGE_ok" = yes)
                 src/compiler/Makefile         \
                 src/compiler/tinyxml/Makefile \
                 src/example/Makefile          \
+                src/gui/Makefile              \
                 src/lib/Makefile              \
                 src/strategies/Makefile       \
                 man/Makefile                  \
 # Define all subdirectories
 SUBDIRS = strategies compiler lib example
 
+if !NO_GUI
+SUBDIRS += gui
+endif
+
 #
 # Add header files for compression and encryption classes
 noinst_HEADERS = include/CompressDecompress.hxx include/EncryptDecrypt.hxx

src/gui/Makefile.am

+#      Makefile.am
+#
+#      Copyright 2012 Andreas Tscharner <andy@vis.ethz.ch>
+#
+#      This program is free software; you can redistribute it and/or modify
+#      it under the terms of the GNU Lesser General Public License as
+#      published by the Free Software Foundation; either version 3 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 Lesser General Public
+#      License along with this program; if not, write to the Free Software
+#      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+#      MA 02110-1301, USA.
+
+
+#
+# Check for DEBUG mode
+if DEBUG
+DEBUG_CFLAGS = -D__DEBUG__
+DEBUG_CXXFLAGS = -D__DEBUG__
+else
+DEBUG_CFLAGS = -O2
+DEBUG_CXXFLAGS = -O2
+endif
+
+#
+# Define C/C++ compiler flags for libraries
+
+
+#
+# Define compiler flags
+AM_CFLAGS = $(DEBUG_CFLAGS) $(GUI_DEPS_CFLAGS)
+AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(GUI_DEPS_CFLAGS) -std=c++0x
+
+#
+# Define main program
+bin_PROGRAMS = lrcResourceEditor
+
+#
+# Define source files for main program
+lrcResourceEditor_SOURCES = lrcResourceEditor.cxx
+
+#
+# Library flags for main program
+lrcResourceEditor_LDADD = $(GUI_DEPS_LIBS)
+lrcResourceEditor_LDFLAGS = -export-dynamic

src/gui/lrcResourceEditor.cxx

+/*
+ * lrcResourceEditor.cxx
+ *
+ * Copyright 2012 Andreas Tscharner <andy@vis.ethz.ch>
+ *
+ * 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 3 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+
+#include <libglademm/xml.h>
+#include <gtkmm/main.h>
+#include <gtkmm/window.h>
+
+int main(int argc, char **argv)
+{
+	Glib::RefPtr<Gnome::Glade::Xml> xmlRef;
+	Gtk::Window *mainWin = nullptr;
+
+
+	Gtk::Main mainPrg(argc, argv);
+
+	xmlRef = Gnome::Glade::Xml::create("ResourceEditor.glade");
+	mainWin = xmlRef->get_widget("MainWindow", mainWin);
+
+	//TODO: Create new class to handle GUI
+
+	mainPrg.run(*mainWin);
+	mainWin->hide_all();
+
+	return 0;
+}
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.