Updating branch refs/heads/master to 6b6fa16607d5b29924a5037f427b6bee280fc763 (commit) from cd2a0e1195bed46054a34c2954a0c1cc4850b2f8 (commit)
commit 6b6fa16607d5b29924a5037f427b6bee280fc763 Author: Bo Lorentsen <b...@lue.dk> Date: Thu Jan 26 22:35:07 2012 +0100 possibility to add parent widget in builder, and clear function in GtkComboBoxText, and more documentation, thanks to Jürgen Eder INSTALL | 220 +---------------------------------------- ui/xfc/gtk/builder.hh | 50 +++++++++ ui/xfc/gtk/combobox.cc | 16 +++- ui/xfc/gtk/combobox.hh | 18 ++++ ui/xfc/gtk/inline/builder.inl | 45 +++++++++ 5 files changed, 133 insertions(+), 216 deletions(-) diff --git a/INSTALL b/INSTALL index 54caf7c..a93c7ca 100644 --- a/INSTALL +++ b/INSTALL @@ -9,221 +9,11 @@ Basic Installation These are generic installation instructions. - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). +To initialize the building system, the following command will do the needed : - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is -disabled by default to prevent problems with accidental use of stale -cache files.) + cmake . - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -will cause the specified gcc to be used as the C compiler (unless it is -overridden in the site shell script). - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. +This will use pkg-config to find the needed header filers, and setup the build +system. +After that a simple make will build the rest. \ No newline at end of file diff --git a/ui/xfc/gtk/builder.hh b/ui/xfc/gtk/builder.hh index b2136de..0bd73bd 100644 --- a/ui/xfc/gtk/builder.hh +++ b/ui/xfc/gtk/builder.hh @@ -17,6 +17,10 @@ #include <xfc/gtk/widget.hh> #endif +#ifndef XFC_GTK_WINDOW_HH +#include <xfc/gtk/window.hh> +#endif + #ifndef __GTK_BUILDER_H__ #include <gtk/gtkbuilder.h> #endif @@ -117,6 +121,27 @@ public: template<typename WidgetType> bool get_widget(const String& name, WidgetType *&widget) const; + /** + Gets a pointer to the Gtk::Widget corresponding to <EM>name</EM> in the interface description. + @param parrent Parent window. + @param name The name of the widget in the XML description. + @param widget A reference to a pointer to hold the widget matching <EM>name</EM>, or null if none exists. + @return <EM>true</EM> if successful, <EM>false</EM> if no widget exists. + + To use this method <EM>WidgetType</EM> must be one of the standard XFC widgets. + + <B>Example:</B> Connecting a "clicked" signal handler to a Gtk::Button. + @code + Gtk::Button *button; + if (xml->get_widget(parentWindow, "my_button", button)) + { + button->signal_clicked().connect(sigc::mem_fun(this, &MyWindow::on_my_button_clicked)); + } + @endcode + */ + template<typename WidgetType> + bool get_widget(Xfc::Gtk::Window *parent, const String& name, WidgetType *&widget) const; + /** Gets a pointer to the Gtk::Widget corresponding to <EM>name</EM> in the interface description. @param name The name of the widget in the XML description. @@ -142,6 +167,31 @@ public: bool get_widget_derived(const String& name, DerivedType *&widget) const; /** + Gets a pointer to the Gtk::Widget corresponding to <EM>name</EM> in the interface description. + @param parrent Parent window. + @param name The name of the widget in the XML description. + @param widget A reference to a pointer to hold the widget matching <EM>name</EM>, or null if none exists. + @return <EM>true</EM> if successful, <EM>false</EM> if no widget exists. + + To use this method <EM>DerivedType</EM> must be a user-defined widget class + that derives from one of the standard XFC widgets. The derived widget class + must declare it's constructor with the following signature: + + <B>Example:</B> Instantiating a main application window from an XML description. + @code + MyWindow *window; + if (xml->get_widget_derived(parentWindow, "MyWindow", window)) + { + window->signal_destroy().connect(sigc::ptr_fun(&Xfc::Main::quit)); + window->show(); + run(); + } + @endcode + */ + template<typename DerivedType> + bool get_widget_derived(Xfc::Gtk::Window *parent, const String& name, DerivedType *&widget) const; + + /** Gets all objects that have been constructed by builder. @note that this function does not increment the reference diff --git a/ui/xfc/gtk/combobox.cc b/ui/xfc/gtk/combobox.cc index 395422d..1504ffc 100644 --- a/ui/xfc/gtk/combobox.cc +++ b/ui/xfc/gtk/combobox.cc @@ -195,7 +195,12 @@ Gtk::ComboBoxText::ComboBoxText() pack_start(*cell_renderer); add_attribute(*cell_renderer, "text", 0); } - + +Gtk::ComboBoxText::ComboBoxText(GtkComboBoxText *combo_box, bool owns_reference) +: ComboBox((GtkComboBox*)combo_box, owns_reference) +{ +} + Gtk::ComboBoxText::~ComboBoxText() { } @@ -227,3 +232,12 @@ Gtk::ComboBoxText::insert(int position, const String& text) insert(position, text.c_str()); } +void +Gtk::ComboBoxText::clear() +{ + Gtk::ListStore *store = dynamic_cast<Gtk::ListStore*>(get_model()); + if (store) + { + store->clear(); + } +} diff --git a/ui/xfc/gtk/combobox.hh b/ui/xfc/gtk/combobox.hh index 9710f71..e637e45 100644 --- a/ui/xfc/gtk/combobox.hh +++ b/ui/xfc/gtk/combobox.hh @@ -34,6 +34,7 @@ #ifndef __GTK_COMBO_BOX_H__ #include <gtk/gtkcombobox.h> +#include <gtk/gtkcomboboxtext.h> #endif namespace Xfc { @@ -266,6 +267,20 @@ public: /// @name Constructors /// @{ + explicit ComboBoxText(GtkComboBoxText *combo_box, bool owns_reference = false); + ///< Construct a new ComboBox from an existing GtkComboBox. + ///< @param combo_box A pointer to a GtkComboBox. + ///< @param owns_reference Set false if the initial reference count is floating, set true if it's not. + ///< + ///< The <EM>combo_box</EM> can be a newly created GtkComboBox or an existing + ///< GtkComboBox (see G::Object::Object). + +public: + typedef GtkComboBoxText CObjectType; + +/// @name Constructors +/// @{ + ComboBoxText(); ///< Constructs a new text combo box. @@ -304,6 +319,9 @@ public: ///< Removes the string at <EM>position</EM> from the combo box. ///< @param position The index of the item to remove. + void clear(); + ///< Removes all entries from the combo box + /// @} }; diff --git a/ui/xfc/gtk/inline/builder.inl b/ui/xfc/gtk/inline/builder.inl index 3fea8b9..cff2858 100644 --- a/ui/xfc/gtk/inline/builder.inl +++ b/ui/xfc/gtk/inline/builder.inl @@ -22,6 +22,24 @@ Xfc::Gtk::Builder::get_widget(const String& name, WidgetType *&widget) const return widget != 0; } +template<typename WidgetType> +inline bool +Xfc::Gtk::Builder::get_widget(Xfc::Gtk::Window *parent, const String& name, WidgetType *&widget) const +{ + widget = 0; + GtkWidget *tmp_widget = GTK_WIDGET(gtk_builder_get_object(gtk_builder(), name.c_str())); + if (tmp_widget) + { + typedef typename WidgetType::CObjectType GtkWidgetType; + widget = G::Object::wrap<WidgetType>((GtkWidgetType*)tmp_widget); + } + if ((widget != 0) && (parent != 0)) + { + widget->set_transient_for(parent); + } + return widget != 0; +} + template<typename DerivedType> inline bool Xfc::Gtk::Builder::get_widget_derived(const String& name, DerivedType *&widget) const @@ -45,3 +63,30 @@ Xfc::Gtk::Builder::get_widget_derived(const String& name, DerivedType *&widget) } return widget != 0; } +template<typename DerivedType> +inline bool +Xfc::Gtk::Builder::get_widget_derived(Xfc::Gtk::Window *parent, const String& name, DerivedType *&widget) const +{ + widget = 0; + GtkWidget *tmp_widget = GTK_WIDGET(gtk_builder_get_object(gtk_builder(), name.c_str())); + if (tmp_widget) + { + G::Object *object = G::Object::pointer((GObject*)tmp_widget); + if (object) + { + widget = dynamic_cast<DerivedType*>(object); + if (!widget) + g_error("Wrong derived widget argument type passed for \"%s\"\n", name.c_str()); + } + else + { + typedef typename DerivedType::CObjectType GtkWidgetType; + widget = new DerivedType((GtkWidgetType*)tmp_widget, *this); + } + } + if ((widget != 0) && (parent != 0)) + { + widget->set_transient_for(parent); + } + return widget != 0; +} _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits