[libgda-uimm] Add DataEntry interface.



commit 85914b1a3dfb8a75fa96a55bf5a5476f054ede14
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Wed Mar 10 18:03:47 2010 -0500

    	Add DataEntry interface.
    
    	* libgda-ui/libgda-uimm.h:
    	* libgda-ui/src/filelist.am:
    	* libgda-ui/src/dataentry.ccg:
    	* libgda-ui/src/dataentry.hg: Add the new DataEntry interface.
    	* tools/m4/convert_libgda_uimm.m4: Add conversions for DataEntry.
    	* libgda-ui/src/dataproxy.hg: Typo.

 ChangeLog                       |   11 ++
 libgda-ui/libgda-uimm.h         |    1 +
 libgda-ui/src/dataentry.ccg     |   45 ++++++++
 libgda-ui/src/dataentry.hg      |  237 +++++++++++++++++++++++++++++++++++++++
 libgda-ui/src/dataproxy.hg      |    2 +-
 libgda-ui/src/filelist.am       |    1 +
 tools/m4/convert_libgda_uimm.m4 |   10 ++
 7 files changed, 306 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d8444c6..24a695f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2010-03-10  José Alburquerque  <jaalburqu svn gnome org>
+
+	Add DataEntry interface.
+
+	* libgda-ui/libgda-uimm.h:
+	* libgda-ui/src/filelist.am:
+	* libgda-ui/src/dataentry.ccg:
+	* libgda-ui/src/dataentry.hg: Add the new DataEntry interface.
+	* tools/m4/convert_libgda_uimm.m4: Add conversions for DataEntry.
+	* libgda-ui/src/dataproxy.hg: Typo.
+
 2010-03-03  José Alburquerque  <jaalburqu svn gnome org>
 
 	Add Cloud widget.
diff --git a/libgda-ui/libgda-uimm.h b/libgda-ui/libgda-uimm.h
index 551d6aa..b95dc0e 100644
--- a/libgda-ui/libgda-uimm.h
+++ b/libgda-ui/libgda-uimm.h
@@ -23,6 +23,7 @@
 #include <basicform.h>
 #include <cloud.h>
 #include <combo.h>
+#include <dataentry.h>
 #include <dataproxy.h>
 #include <dataproxyinfo.h>
 #include <dataselector.h>
diff --git a/libgda-ui/src/dataentry.ccg b/libgda-ui/src/dataentry.ccg
new file mode 100644
index 0000000..3e79b9f
--- /dev/null
+++ b/libgda-ui/src/dataentry.ccg
@@ -0,0 +1,45 @@
+/* libgda-uimm - a C++ wrapper for libgda-ui
+ * 
+ * Copyright (c) 2010 libgda-uimm Development Team
+ *
+ * This library 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 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <libgda-ui/gdaui-easy.h>
+#include <libgdamm/datahandler.h>
+
+namespace Gnome
+{
+
+namespace GdaUI
+{
+
+void DataEntry::get_value(Glib::ValueBase& value) const
+{
+  const GValue* gvalue =
+    gdaui_data_entry_get_value(const_cast<GdauiDataEntry*>(gobj()));
+  value.init(gvalue);
+}
+
+void DataEntry::get_original_value(Glib::ValueBase& value) const
+{
+  const GValue* gvalue =
+    gdaui_data_entry_get_original_value(const_cast<GdauiDataEntry*>(gobj()));
+  value.init(gvalue);
+}
+
+} /* namespace GdaUI */
+
+} /* namespace Gnome */
diff --git a/libgda-ui/src/dataentry.hg b/libgda-ui/src/dataentry.hg
new file mode 100644
index 0000000..6d2743f
--- /dev/null
+++ b/libgda-ui/src/dataentry.hg
@@ -0,0 +1,237 @@
+/* libgda-uimm - a C++ wrapper for libgda-ui
+ *
+ * Copyright (c) 2010 libgda-uimm Development Team
+ *
+ * This library 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 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <libgda-ui/gdaui-data-entry.h>
+#include <glibmm/interface.h>
+#include <libgdamm/datamodel.h>
+
+_DEFS(libgda-uimm,libgda_ui)
+
+namespace Gnome
+{
+
+// Gnome::Gda class forward declarations.
+namespace Gda
+{
+
+class DataHandler;
+
+}
+
+namespace GdaUI
+{
+
+/** DataEntry - Data entry widget.
+ * The DataEntry is an interface for widgets (simple or complex) which lets
+ * the user view and/or modify a GValue.
+ *
+* This interface is implemented by widgets which feature data editing (usually
+* composed of an editing area and a button to have some more control on the
+* value being edited). The interface allows to control how the widget works
+* and to query the value and the attributes of the data held by the widget.
+ *
+* The widget can store the original value (to be able to tell if the value has
+* been changed by the user) and a default value (which will be returned if the
+* user explicitly forces the widget to be set to the default value). Control
+* methods allow to set the type of value to be edited (the requested type must
+* be compatible with what the widget can handle), set the value (which
+* replaces the currently edited value), set the value and the original value
+* (the value passed as argument is set and is also considered to be the
+* original value).
+ *
+* DataEntry widgets are normally created using the create_data_entry() method.
+ */
+
+class DataEntry :
+  public Glib::Interface
+{
+  _CLASS_INTERFACE(DataEntry, GdauiDataEntry, GDAUI_DATA_ENTRY, GdauiDataEntryIface)
+
+public:
+  _WRAP_METHOD(static Glib::RefPtr<DataEntry> create_data_entry(GType type, const Glib::ustring& plugin_name = Glib::ustring()), gdaui_new_data_entry)
+
+  _WRAP_METHOD(void set_value_type(GType type), gdaui_data_entry_set_value_type)
+  _WRAP_METHOD(GType get_value_type() const, gdaui_data_entry_get_value_type)
+  _WRAP_METHOD(void set_value(const Glib::ValueBase& value), gdaui_data_entry_set_value)
+
+  /** Push a value into the DataEntry. The value parameter must be of the type
+   * specified using set_value_type().
+   *
+   * @param value The value to set.
+   *
+   * @newin{4,2}
+   */
+  template <class DataType>
+  void set_value(const DataType& value);
+
+  /** Fetch the value held in the DataEntry widget. If the value is set to
+   * NULL, the returned value is of type GDA_TYPE_NULL. If the value is set to
+   * default, then the returned value is of type GDA_TYPE_NULL or is the
+   * default value if it has been provided to the widget (and is of the same
+   * type as the one provided by the data entry).
+   *
+   * @param value A place in which to store the value.  The value must be
+   * uninitialized.
+   *
+   * @newin{4,2}
+   */
+  void get_value(Glib::ValueBase& value) const;
+  _IGNORE(gdaui_data_entry_get_value)
+
+  /** Fetch the value held in the DataEntry widget. If the value is set to
+   * NULL, the returned value is of type GDA_TYPE_NULL. If the value is set to
+   * default, then the returned value is of type GDA_TYPE_NULL or is the
+   * default value if it has been provided to the widget (and is of the same
+   * type as the one provided by the data entry).
+   *
+   * @param value A place in which to store the value.  The value must be
+   * uninitialized.
+   *
+   * @newin{4,2}
+   */
+  template<class DataType>
+  void get_value(DataType& value) const;
+
+  _WRAP_METHOD(bool content_is_valid(), gdaui_data_entry_content_is_valid, errthrow)
+  _WRAP_METHOD(void set_reference_value(const Glib::ValueBase& value), gdaui_data_entry_set_reference_value)
+
+  /** Push a value into the DataEntry in the same way as set_value() but also
+   * sets this value as the original value.
+   *
+   * @param value The value to set.
+   *
+   * @newin{4,2}
+   */
+  template <class DataType>
+  void set_reference_value(const DataType& value);
+
+  /** Fetch the original value held in the GdauiDataEntry widget.
+   *
+   * @param value A place in which to store the value.  The value must be
+   * uninitialized and should not be modified.
+   *
+   * @newin{4,2}
+   */
+  void get_original_value(Glib::ValueBase& value) const;
+  _IGNORE(gdaui_data_entry_get_original_value)
+
+  /** Fetch the original value held in the GdauiDataEntry widget.
+   *
+   * @param value A place in which to store the value.  The value must be
+   * uninitialized and should not be modified.
+   *
+   * @newin{4,2}
+   */
+  template<class DataType>
+  void get_original_value(DataType& value) const;
+
+  _WRAP_METHOD(void reset(), gdaui_data_entry_reset)
+  _WRAP_METHOD(void set_value_default(const Glib::ValueBase& value), gdaui_data_entry_set_value_default)
+
+  /** Sets the default value for the DataEntry which gets displayed when the
+   * user forces the default value. If it is not set then it is set to type
+   * GDA_TYPE_NULL.  The value parameter must be of the type specified using
+   * set_value_type().
+   *
+   * @param value The value to set.
+   *
+   * @newin{4,2}
+   */
+  template <class DataType>
+  void set_value_default(const DataType& value);
+
+  _WRAP_METHOD(void set_attributes(Gnome::Gda::ValueAttribute attrs, Gnome::Gda::ValueAttribute mask), gdaui_data_entry_set_attributes)
+  _WRAP_METHOD(Gnome::Gda::ValueAttribute get_attributes() const, gdaui_data_entry_get_attributes)
+  _WRAP_METHOD(Glib::RefPtr<Gnome::Gda::DataHandler> get_handler(), gdaui_data_entry_get_handler)
+  _WRAP_METHOD(Glib::RefPtr<const Gnome::Gda::DataHandler> get_handler() const, gdaui_data_entry_get_handler, constversion)
+  _WRAP_METHOD(bool expand_in_layout() const, gdaui_data_entry_expand_in_layout)
+  _WRAP_METHOD(void set_editable(bool editable), gdaui_data_entry_set_editable)
+  _WRAP_METHOD(bool get_editable() const, gdaui_data_entry_get_editable)
+  _WRAP_METHOD(void grab_focus(), gdaui_data_entry_grab_focus)
+
+  _WRAP_SIGNAL(void contents_activated(), "contents-activated")
+  _WRAP_SIGNAL(void contents_modified(), "contents-modified")
+
+  //TODO: The class declaration seems to suggest that this signal throws a
+  //GError.
+  //_WRAP_SIGNAL(void contents_valid(), "contents-valid", errthrow)
+
+  _WRAP_SIGNAL(void status_changed(), "status-changed")
+
+  //TODO: Wrap vfuncs.
+};
+
+/***************************** DataEntry *****************************/
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+template <class DataType>
+void DataEntry::set_value(const DataType& value)
+{
+  typedef Glib::Value<DataType> ValueType;
+
+  ValueType temp;
+  temp.init(ValueType::value_type());
+  temp.set(value);
+  this->set_value(temp);
+}
+
+template<class DataType>
+void DataEntry::get_value(DataType& value) const
+{
+  Glib::Value<DataType> temp;
+  this->get_value(temp);
+  value = temp.get();
+}
+
+template <class DataType>
+void DataEntry::set_reference_value(const DataType& value)
+{
+  typedef Glib::Value<DataType> ValueType;
+
+  ValueType temp;
+  temp.init(ValueType::value_type());
+  temp.set(value);
+  this->set_reference_value(temp);
+}
+
+template<class DataType>
+void DataEntry::get_original_value(DataType& value) const
+{
+  Glib::Value<DataType> temp;
+  this->get_original_value(temp);
+  value = temp.get();
+}
+
+template <class DataType>
+void DataEntry::set_value_default(const DataType& value)
+{
+  typedef Glib::Value<DataType> ValueType;
+
+  ValueType temp;
+  temp.init(ValueType::value_type());
+  temp.set(value);
+  this->set_value_default(temp);
+}
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+} // namespace GdaUI
+
+} // namespace Gnome
diff --git a/libgda-ui/src/dataproxy.hg b/libgda-ui/src/dataproxy.hg
index 64beb3d..a2556af 100644
--- a/libgda-ui/src/dataproxy.hg
+++ b/libgda-ui/src/dataproxy.hg
@@ -47,7 +47,7 @@ namespace GdaUI
 _WRAP_ENUM(Action, GdauiAction)
 _WRAP_ENUM(DataProxyWriteMode, GdauiDataProxyWriteMode)
 
-/** DataProxy â?? Modifying data in a Gome::Gda::DataModel.
+/** DataProxy - Modifying data in a Gome::Gda::DataModel.
  * The DataProxy interface is implemented by widgets which allow modifications
  * to a Gnome::Gda::DataModel  (through a Gnome::Gda::DataProxy  to actually
  * proxy the changes before they are written to the data model).
diff --git a/libgda-ui/src/filelist.am b/libgda-ui/src/filelist.am
index 8a50b54..bf79a17 100644
--- a/libgda-ui/src/filelist.am
+++ b/libgda-ui/src/filelist.am
@@ -12,6 +12,7 @@ files_hg =                              \
         basicform.hg                    \
         cloud.hg                        \
         combo.hg                        \
+        dataentry.hg                    \
         dataproxy.hg                    \
         dataproxyinfo.hg                \
         dataselector.hg                 \
diff --git a/tools/m4/convert_libgda_uimm.m4 b/tools/m4/convert_libgda_uimm.m4
index 20f130f..fd6e4ca 100644
--- a/tools/m4/convert_libgda_uimm.m4
+++ b/tools/m4/convert_libgda_uimm.m4
@@ -10,6 +10,12 @@ dnl ActionGroup:
 _CONVERSION(`GtkActionGroup*', `Glib::RefPtr<Gtk::ActionGroup>', `Glib::wrap($3)')
 _CONVERSION(`Glib::RefPtr<Gtk::ActionGroup>', `GtkActionGroup*', `Glib::unwrap($3)')
 
+dnl DataEntry:
+_CONVERSION(`GdauiDataEntry*', `Glib::RefPtr<DataEntry>', `Glib::wrap($3)')
+
+dnl Gnome::Gda::DataHandler:
+_CONVERSION(`GdaDataHandler*', `Glib::RefPtr<Gnome::Gda::DataHandler>', `Glib::wrap($3)')
+
 dnl Gnome::Gda::DataProxy:
 _CONVERSION(`GdaDataProxy*', `Glib::RefPtr<Gnome::Gda::DataProxy>', `Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<Gnome::Gda::DataProxy>&', `GdaDataProxy*', `Glib::unwrap($3)')
@@ -45,4 +51,8 @@ _CONVERSION(`GdaSet*', `Glib::RefPtr<Gnome::Gda::Set>', `Glib::wrap($3)')
 dnl Window:
 _CONVERSION(`Gtk::Window*', `GtkWindow*', `Glib::unwrap($3)')
 
+dnl Gnome::Gda::ValueAttribute:
+_CONVERSION(`Gnome::Gda::ValueAttribute', `GdaValueAttribute', `$3')
+_CONVERSION(`GdaValueAttribute', `Gnome::Gda::ValueAttribute', `$3')
+
 dnl General conversions:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]