1 // $Id: Configuration.hh,v 1.53 2004/05/07 07:04:47 christof Exp $
2 /*  glade--: C++ frontend for glade (Gtk+ User Interface Builder)
3  *  Copyright (C) 1998  Christof Petig
4  *  Copyright (C) 1999-2002 Adolf Petig GmbH & Co. KG, written by Christof Petig
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef CONFIGURATION_HH
22 #define CONFIGURATION_HH
23 #include <config.h>
24 #include <iostream>
25 #include "Naming.hh"
26 #include <Tag.hh>
27 
28 // Be careful, glibc-2.1 defines major and minor
29 
30 struct Pkg_Version
31 {
32 public:
33    enum Source // precedence as follows (later values overwrite former)
34    {  Not_Available, Unknown,
35    	Glademm_Compile_Time,
36    	Gtk_Config, Gtkmm_Config, Gnome_Config, Pkg_Config, MMVersion,
37    	Command_Line
38    };
39 
40    int mymajor;
41    int myminor;
42    int mymicro;
43    Source source;
44 
45 public:
Pkg_VersionPkg_Version46    Pkg_Version() : mymajor(0), myminor(0), mymicro(0), source(Not_Available) {}
Pkg_VersionPkg_Version47    Pkg_Version(int j,int n,int c,Source s=Unknown)
48    	: mymajor(j), myminor(n), mymicro(c), source(s)
49    	{}
operator ==Pkg_Version50    bool operator==(const Pkg_Version &b) const
51    {  return mymajor==b.mymajor && myminor==b.myminor && mymicro==b.mymicro; }
operator <Pkg_Version52    bool operator<(const Pkg_Version &b) const
53    {  if (mymajor!=b.mymajor) return mymajor<b.mymajor;
54       if (myminor!=b.myminor) return myminor<b.myminor;
55       return mymicro<b.mymicro;
56    }
operator >=Pkg_Version57    bool operator>=(const Pkg_Version &b) const
58    {  return !(*this<b); }
operator !=Pkg_Version59    bool operator!=(const Pkg_Version &b) const
60    {  return !(*this==b); }
getSourcePkg_Version61    Source getSource() const { return source; }
operator !Pkg_Version62    bool operator!() const
63    {  return source==Not_Available || (mymajor==0 && myminor==0 && mymicro==0); }
64 
set_if_more_specificPkg_Version65    void set_if_more_specific(const Pkg_Version &b)
66    {  if (b.source >= source)
67          *this=b;
68    }
69 };
70 
71 std::ostream &operator<<(std::ostream &o, const Pkg_Version &v);
72 std::ostream &operator<<(std::ostream &o, const Pkg_Version::Source s);
73 
74 struct Configuration : public Naming
75 {  enum gettext_source_e { GT_NONE, GT_GNOME, GT_GLIB, GT_GNU };
76 
77    std::string destination_directory;
78    std::string source_directory;
79    std::string main_filename;
80    std::string in_filename;
81    std::string pixmap_dir;
82    std::string commandline;
83    std::string pixmap_dir_relative_to_src;
84    std::string author_name;
85    std::string author_email;
86    bool debug:1;
87    bool sample_code:1;
88    bool bare_bones:1;
89    bool no_autoconf:1;
90    bool gtk_ostream:1;
91    bool lookup_table:1;
92    bool gnome_support:1;
93    bool gettext_support:1;
94    bool use_libglade:1;
95    bool has_accelerators:1;
96    bool widget_names:1;
97    bool optionmenu_strings:1;
98    bool optionmenu_create_enum:1;
99    bool do_case_conversion:1;
100    bool uppercase_enums:1;
101    bool mixedcase_defines:1;
102    bool lookup_table_compat:1;
103    bool glade2:1;
104    bool embed_images:1;
105    bool baseclass:1;
106    bool non_virtual_callbacks:1;
107    bool need_notebook_hack:1;
108    bool gnome2:1;
109    bool libglade_support:1;
110    bool only_private_widgets:1; // this is used to print out a warning
111    bool use_autoreconf:1; // use autoreconf
112    bool ship_libintl:1; // install libintl
113    bool drop_gtkmm22_support:1; // whether to drop support for 2.2 in 2.4 projects
114    int verbose;
115    Pkg_Version pc_version;
116    Pkg_Version gtk_version;
117    Pkg_Version gtkmm_version;
118    Pkg_Version libgnomemm_version;
119    Pkg_Version libgnomeuimm_version;
120    Pkg_Version libbonobomm_version;
121    Pkg_Version libbonobouimm_version;
122    Pkg_Version automake_version;
123    std::string automake_name;
124    Pkg_Version autoconf_version;
125    Pkg_Version gettext_version; // does this menace never end?
126    std::string autoconf_name;
127    std::string template_postfix;
128    std::string source_suffix, header_suffix;
129    std::string image_provider;
130    enum gettext_source_e gettext_source;
131 
132    Tag custom_signal_args;
133 
ConfigurationConfiguration134    Configuration()
135    : debug(), sample_code(), bare_bones(),
136      no_autoconf(), gtk_ostream(), lookup_table(), gnome_support(),
137      gettext_support(), use_libglade(), has_accelerators(), widget_names(),
138      optionmenu_strings(), optionmenu_create_enum(true),
139      do_case_conversion(), uppercase_enums(), mixedcase_defines(),
140      lookup_table_compat(), glade2(),
141      embed_images(true), baseclass(), non_virtual_callbacks(),
142      need_notebook_hack(), gnome2(), libglade_support(),
143      only_private_widgets(true), use_autoreconf(), ship_libintl(),
144      drop_gtkmm22_support(),
145      verbose(),
146      // had been "_glade"
147      template_postfix("_new"),
148      source_suffix(".cc"), header_suffix(".hh"),  gettext_source(GT_NONE),
149      custom_signal_args("")
150    {  if (gnome2) select_Gnome2();
151       else select_Gnome1();
152    }
153 
154    void select_Gnome1();
155    void select_Gnome2();
156 
Gtkmm2Configuration157    bool Gtkmm2() const
158    {  return gtkmm_version>=Pkg_Version(1,3,0);
159    }
Gtkmm1Configuration160    bool Gtkmm1() const
161    {  return gtkmm_version<Pkg_Version(1,3,0);
162    }
Gnome2Configuration163    bool Gnome2() const
164    {  return libgnomemm_version>=Pkg_Version(1,3,0);
165    }
Gnome1Configuration166    bool Gnome1() const
167    {  return libgnomemm_version<Pkg_Version(1,3,0);
168    }
169 
170 	// this belongs to Naming, but it is Configuration dependant
171 	const std::string GtkmmIncludePath() const throw();
172 	const std::string GnomemmIncludePath() const throw();
173 	const std::string GnomeUImmIncludePath() const throw();
174 	const std::string BonobommIncludePath() const throw();
175 	const std::string BonoboUImmIncludePath() const throw();
176 };
177 
178 extern struct Configuration Configuration;
179 
180 // note: replace these macros soon? (they are short!)
181 #define GTKMM1 (Configuration.Gtkmm1())
182 #define GTKMM2 (Configuration.Gtkmm2())
183 #define GTKMM24 (Configuration.gtkmm_version>=Pkg_Version(2,4,0))
184 #define GNOME1 (Configuration.Gnome1())
185 #define GNOME2 (Configuration.Gnome2())
186 #endif
187