gtkmm r1099 - in trunk: . gtk/src
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: gtkmm r1099 - in trunk: . gtk/src
- Date: Sun, 22 Feb 2009 00:44:50 +0000 (UTC)
Author: murrayc
Date: Sun Feb 22 00:44:50 2009
New Revision: 1099
URL: http://svn.gnome.org/viewvc/gtkmm?rev=1099&view=rev
Log:
2009-02-22 Murray Cumming <murrayc murrayc com>
* gtk/src/builder.[hg|ccg]: create_from_file(), add_from_file(),
create_from_string(), add_from_string(): Add method overloads that
take a char* for the object ID, to avoid ambiguity with the two
other overloads that take ustring or StringArrayHandle.
Modified:
trunk/ChangeLog
trunk/gtk/src/builder.ccg
trunk/gtk/src/builder.hg
Modified: trunk/gtk/src/builder.ccg
==============================================================================
--- trunk/gtk/src/builder.ccg (original)
+++ trunk/gtk/src/builder.ccg Sun Feb 22 00:44:50 2009
@@ -57,6 +57,16 @@
}
//static
+Glib::RefPtr<Builder> Builder::create_from_file(const std::string& filename, const char* object_id)
+{
+ Glib::RefPtr<Builder> builder = Builder::create();
+ if(builder->add_from_file(filename, object_id))
+ return builder;
+ else
+ return Glib::RefPtr<Builder>();
+}
+
+//static
Glib::RefPtr<Builder> Builder::create_from_file(const std::string& filename, const Glib::ustring& object_id)
{
Glib::RefPtr<Builder> builder = Builder::create();
@@ -87,6 +97,16 @@
}
//static
+Glib::RefPtr<Builder> Builder::create_from_string(const Glib::ustring& buffer, const char* object_id)
+{
+ Glib::RefPtr<Builder> builder = Builder::create();
+ if(builder->add_from_string(buffer, object_id))
+ return builder;
+ else
+ return Glib::RefPtr<Builder>();
+}
+
+//static
Glib::RefPtr<Builder> Builder::create_from_string(const Glib::ustring& buffer, const Glib::ustring& object_id)
{
Glib::RefPtr<Builder> builder = Builder::create();
@@ -107,6 +127,22 @@
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
+bool Builder::add_from_file(const std::string& filename, const char* object_id)
+#else
+bool Builder::add_from_file(const std::string& filename, const char* object_id, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ std::list<Glib::ustring> object_ids;
+ object_ids.push_back(object_id);
+
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ return add_from_file(filename, object_ids);
+ #else
+ return add_from_file(filename, object_ids, error);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool Builder::add_from_file(const std::string& filename, const Glib::ustring& object_id)
#else
bool Builder::add_from_file(const std::string& filename, const Glib::ustring& object_id, std::auto_ptr<Glib::Error>& error)
@@ -142,6 +178,23 @@
return retvalue;
}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+bool Builder::add_from_string(const Glib::ustring& buffer, const char* object_id)
+#else
+bool Builder::add_from_string(const Glib::ustring& buffer, const char* object_id, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ std::list<Glib::ustring> object_ids;
+ object_ids.push_back(object_id);
+
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ return add_from_string(buffer, object_ids);
+ #else
+ return add_from_string(buffer, object_ids, error);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+}
+
#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool Builder::add_from_string(const Glib::ustring& buffer, const Glib::ustring& object_id)
#else
Modified: trunk/gtk/src/builder.hg
==============================================================================
--- trunk/gtk/src/builder.hg (original)
+++ trunk/gtk/src/builder.hg Sun Feb 22 00:44:50 2009
@@ -77,6 +77,23 @@
*/
static Glib::RefPtr<Builder> create_from_file(const std::string& filename, const Glib::ustring& object_id);
+ //This is just to avoid the ambiguous call when using a string literal,
+ //caused by the overload that takes a StringArrayHandle.
+ /** Parses a file containing a GtkBuilder UI definition, building only the requested object.
+ *
+ * If you are adding an object that depends on an object that is not
+ * its child (for instance a GtkTreeView that depends on its
+ * GtkTreeModel), you have to explicitely list all of them.
+ *
+ * @param filename the name of the file to parse.
+ * @param object_id The object to build.
+ * @result A new Builder object, or a null pointer if an error occurred.
+ * @throws Glib::FileError, Glib::MarkupError
+ *
+ * @newin2p16
+ */
+ static Glib::RefPtr<Builder> create_from_file(const std::string& filename, const char* object_id);
+
/** Parses a file containing a GtkBuilder UI definition, building only the requested objects.
*
* If you are adding an object that depends on an object that is not
@@ -106,6 +123,19 @@
*/
static Glib::RefPtr<Builder> create_from_string(const Glib::ustring& buffer);
+ //This is just to avoid the ambiguous call when using a string literal,
+ //caused by the overload that takes a StringArrayHandle.
+ /** Parses a string containing a GtkBuilder UI definition building only the requested object.
+ *
+ * @param buffer The string to parse.
+ * @param object_id The object to build.
+ * @result A new Builder object, or a null pointer if an error occurred.
+ * @throws Glib::MarkupError
+ *
+ * @newin2p16
+ */
+ static Glib::RefPtr<Builder> create_from_string(const Glib::ustring& buffer, const char* object_id);
+
/** Parses a string containing a GtkBuilder UI definition building only the requested object.
*
* @param buffer The string to parse.
@@ -133,9 +163,31 @@
static Glib::RefPtr<Builder> create_from_string(const Glib::ustring& buffer, const Glib::StringArrayHandle& object_ids);
_IGNORE(gtk_builder_add_objects_from_file)
-
_WRAP_METHOD(bool add_from_file(const std::string& filename), gtk_builder_add_from_file, errthrow)
+ //This is just to avoid the ambiguous call when using a string literal,
+ //caused by the overload that takes a StringArrayHandle.
+ /** Parses a file containing a GtkBuilder UI definition,
+ * building only the requested object,
+ * and merges it with the current contents of the builder.
+ *
+ * If you are adding an object that depends on an object that is not
+ * its child (for instance a GtkTreeView that depends on its
+ * GtkTreeModel), you have to explicitely list all of them.
+ *
+ * @param buffer The file to parse.
+ * @param The object to build.
+ * @result true on success or false if an error occurred.
+ * @throws Glib::MarkupError
+ *
+ * @newin2p16
+ */
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ bool add_from_file(const std::string& filename, const char* object_id);
+ #else
+ bool add_from_file(const std::string& filename, const char* object_id, std::auto_ptr<Glib::Error>& error);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+
/** Parses a file containing a GtkBuilder UI definition,
* building only the requested object,
* and merges it with the current contents of the builder.
@@ -160,6 +212,8 @@
#m4 _CONVERSION(`const Glib::StringArrayHandle&',`gchar**',`const_cast<char**>(($3).data())')
_WRAP_METHOD(bool add_from_file(const std::string& filename, const Glib::StringArrayHandle& object_ids), gtk_builder_add_objects_from_file, errthrow)
+ //This is just to avoid the ambiguous call when using a string literal,
+ //caused by the overload that takes a StringArrayHandle.
/** Parses a string containing a GtkBuilder UI definition
* and merges it with the current contents of the builder.
*
@@ -184,6 +238,23 @@
* @result true on success or false if an error occurred.
* @throws Glib::MarkupError
*
+ * @newin2p16
+ */
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ bool add_from_string(const Glib::ustring& buffer, const char* object_id);
+ #else
+ bool add_from_string(const Glib::ustring& buffer, const char* object_id, std::auto_ptr<Glib::Error>& error);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ /** Parses a string containing a GtkBuilder UI definition,
+ * building only the requested object,
+ * and merges it with the current contents of the builder.
+ *
+ * @param buffer The string to parse.
+ * @param The object to build.
+ * @result true on success or false if an error occurred.
+ * @throws Glib::MarkupError
+ *
* @newin2p14
*/
#ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -268,7 +339,7 @@
// Initialize output parameter:
widget = 0;
- // Get the widget from the glade file.
+ // Get the widget from the GtkBuilder file.
typedef typename T_Widget::BaseObjectType cwidget_type;
cwidget_type* pCWidget = (cwidget_type*)get_cwidget(name);
@@ -325,7 +396,7 @@
#m4end
// TODO: Make sure this is actually invoked even with disabled vfuncs so
- // that glade creates gtkmm's GObjects.
+ // that GtkBuilder creates gtkmm's GObjects.
};
} // namespace Gtk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]