[libgda-uimm] Wrap DataSelector Interface.



commit 3a25365aae549d6b32a1bc2b5a82edd46b3bbdc7
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Sun Feb 21 18:51:46 2010 -0500

    	Wrap DataSelector Interface.
    
    	* libgda-ui/libgda-uimm.h:
    	* libgda-ui/src/filelist.am:
    	* libgda-ui/src/dataselector.ccg:
    	* libgda-ui/src/dataselector.hg: Added new DataSelector interface.
    
    	* tools/extra_defs_gen/generate_defs_libgda_ui.cc: Added
    	GDAUI_TYPE_DATA_SELECTOR to the list of types for which properties and
    	signals are generated.
    	* libgda-ui/src/libgda_ui_signals.defs: Regenerated with
    	generate_defs_libgda_ui to get the GdauiDataSelector
    	"selection-changed" signal.
    	* libgda-ui/src/libgda_ui_vfuncs.defs: Handwrote the GdauiDataSelector
    	virtual functions.
    	* libgda-ui/src/libgda_ui.defs: Included the signal definitions in the
    	main defs file.
    
    	* libgda-ui/src/combo.ccg:
    	* libgda-ui/src/combo.hg: Made Combo implement the DataSelector
    	interface.  Wrapped properties.  Also corrected the
    	Gnome::Gda::DataModel* parameters to be embedded Glib::RefPtr<>'s (I
    	got confused with the Gtk::ComboBox derived newly wrapped Combo class
    	which is not embedded in a Glib::RefPtr<>). Const corrections.
    
    	* tools/m4/convert_libgda_uimm.m4: Included GdaDataModel and
    	GdaDataModelIter conversions.

 ChangeLog                                       |   30 +++++++++
 libgda-ui/libgda-uimm.h                         |    4 +-
 libgda-ui/src/combo.ccg                         |    2 -
 libgda-ui/src/combo.hg                          |   17 ++++--
 libgda-ui/src/dataselector.ccg                  |   28 +++++++++
 libgda-ui/src/dataselector.hg                   |   72 +++++++++++++++++++++++
 libgda-ui/src/filelist.am                       |    4 +-
 libgda-ui/src/libgda_ui.defs                    |    3 +-
 libgda-ui/src/libgda_ui_signals.defs            |   10 +++
 libgda-ui/src/libgda_ui_vfuncs.defs             |   50 ++++++++++++++++
 tools/extra_defs_gen/generate_defs_libgda_ui.cc |    4 +-
 tools/m4/convert_libgda_uimm.m4                 |    8 ++-
 12 files changed, 220 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fa65f0d..0da6d2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2010-02-21  José Alburquerque  <jaalburqu svn gnome org>
+
+	Wrap DataSelector Interface.
+
+	* libgda-ui/libgda-uimm.h:
+	* libgda-ui/src/filelist.am:
+	* libgda-ui/src/dataselector.ccg:
+	* libgda-ui/src/dataselector.hg: Added new DataSelector interface.
+
+	* tools/extra_defs_gen/generate_defs_libgda_ui.cc: Added
+	GDAUI_TYPE_DATA_SELECTOR to the list of types for which properties and
+	signals are generated.
+	* libgda-ui/src/libgda_ui_signals.defs: Regenerated with
+	generate_defs_libgda_ui to get the GdauiDataSelector
+	"selection-changed" signal.
+	* libgda-ui/src/libgda_ui_vfuncs.defs: Handwrote the GdauiDataSelector
+	virtual functions.
+	* libgda-ui/src/libgda_ui.defs: Included the signal definitions in the
+	main defs file.
+
+	* libgda-ui/src/combo.ccg:
+	* libgda-ui/src/combo.hg: Made Combo implement the DataSelector
+	interface.  Wrapped properties.  Also corrected the
+	Gnome::Gda::DataModel* parameters to be embedded Glib::RefPtr<>'s (I
+	got confused with the Gtk::ComboBox derived newly wrapped Combo class
+	which is not embedded in a Glib::RefPtr<>). Const corrections.
+
+	* tools/m4/convert_libgda_uimm.m4: Included GdaDataModel and
+	GdaDataModelIter conversions.
+
 2010-02-19  José Alburquerque  <jaalburqu svn gnome org>
 
 	Combo: Wrap methods.
diff --git a/libgda-ui/libgda-uimm.h b/libgda-ui/libgda-uimm.h
index 7e76545..a831847 100644
--- a/libgda-ui/libgda-uimm.h
+++ b/libgda-ui/libgda-uimm.h
@@ -20,5 +20,7 @@
 #ifndef _LIBGDA_UIMM_H
 #define _LIBGDA_UIMM_H
 
-#endif /* _LIBGDA_UIMM_H */
+#include <combo.h>
+#include <dataselector.h>
 
+#endif /* _LIBGDA_UIMM_H */
diff --git a/libgda-ui/src/combo.ccg b/libgda-ui/src/combo.ccg
index 2d24d00..1e56919 100644
--- a/libgda-ui/src/combo.ccg
+++ b/libgda-ui/src/combo.ccg
@@ -25,8 +25,6 @@ namespace Gnome
 namespace GdaUI
 {
 
-
 } /* namespace GdaUI */
 
 } /* namespace Gnome */
-
diff --git a/libgda-ui/src/combo.hg b/libgda-ui/src/combo.hg
index 0b633e3..1d23e8b 100644
--- a/libgda-ui/src/combo.hg
+++ b/libgda-ui/src/combo.hg
@@ -19,6 +19,7 @@
 
 #include <gtkmm/combobox.h>
 #include <libgdamm/datamodel.h>
+#include <libgda-uimm/dataselector.h>
 
 _DEFS(libgda-uimm,libgda_ui)
 _PINCLUDE(gtkmm/private/combobox_p.h)
@@ -29,21 +30,27 @@ namespace Gnome
 namespace GdaUI
 {
 
-/** Combo â?? Combo box to choose from the contents of a Gnome::Gda::DataModel.
+/** Combo - Combo box to choose from the contents of a Gnome::Gda::DataModel.
  */
-class Combo : public Gtk::ComboBox
+class Combo :
+  public Gtk::ComboBox,
+  public DataSelector
 {
   _CLASS_GTKOBJECT(Combo, GdauiCombo, GDAUI_COMBO, Gtk::ComboBox, GtkComboBox)
+  _IMPLEMENTS_INTERFACE(DataSelector)
 
 public:
 #m4 _CONVERSION(`const Glib::ArrayHandle<int>&', `gint*', `const_cast<gint*>($3.data())')
   _WRAP_METHOD_DOCS_ONLY(gdaui_combo_new_with_model)
-  _WRAP_CTOR(Combo(Gnome::Gda::DataModel* model, int n_cols, const Glib::ArrayHandle<int>& cols_index), gdaui_combo_new_with_model)
+  _WRAP_CTOR(Combo(const Glib::RefPtr<Gnome::Gda::DataModel>& model, int n_cols, const Glib::ArrayHandle<int>& cols_index), gdaui_combo_new_with_model)
 
 public:
-  _WRAP_METHOD(void set_model(Gnome::Gda::DataModel* model, int n_cols, const Glib::ArrayHandle<int>& cols_index), gdaui_combo_set_model)
+  _WRAP_METHOD(void set_model(const Glib::RefPtr<Gnome::Gda::DataModel>& model, int n_cols, const Glib::ArrayHandle<int>& cols_index), gdaui_combo_set_model)
   _WRAP_METHOD(void add_null(bool add_null), gdaui_combo_add_null)
-  _WRAP_METHOD(bool is_null_selected(), gdaui_combo_is_null_selected)
+  _WRAP_METHOD(bool is_null_selected() const, gdaui_combo_is_null_selected)
+
+  _WRAP_PROPERTY("as-list", bool)
+  _WRAP_PROPERTY("model", Glib::RefPtr<Gnome::Gda::DataModel>)
 };
 
 } // namespace GdaUI
diff --git a/libgda-ui/src/dataselector.ccg b/libgda-ui/src/dataselector.ccg
new file mode 100644
index 0000000..31d166a
--- /dev/null
+++ b/libgda-ui/src/dataselector.ccg
@@ -0,0 +1,28 @@
+/* dataselector.cc
+ * 
+ * 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.
+ */
+
+namespace Gnome
+{
+
+namespace GdaUI
+{
+
+} /* namespace GdaUI */
+
+} /* namespace Gnome */
diff --git a/libgda-ui/src/dataselector.hg b/libgda-ui/src/dataselector.hg
new file mode 100644
index 0000000..f811908
--- /dev/null
+++ b/libgda-ui/src/dataselector.hg
@@ -0,0 +1,72 @@
+/* dataselector.h
+ *
+ * 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-selector.h>
+#include <glibmm/interface.h>
+#include <libgdamm/datamodel.h>
+
+_DEFS(libgda-uimm,libgda_ui)
+
+namespace Gnome
+{
+
+namespace GdaUI
+{
+
+/** DataSelector - Selecting data in a Gnome::Gda::DataModel.
+ */
+class DataSelector :
+  public Glib::Interface
+{
+  _CLASS_INTERFACE(DataSelector, GdauiDataSelector, GDAUI_DATA_SELECTOR, GdauiDataSelectorIface)
+
+public:
+  _WRAP_METHOD(Glib::RefPtr<Gnome::Gda::DataModel> get_model(), gdaui_data_selector_get_model)
+  _WRAP_METHOD(Glib::RefPtr<const Gnome::Gda::DataModel> get_model() const, gdaui_data_selector_get_model, constversion)
+  _WRAP_METHOD(void set_model(const Glib::RefPtr<Gnome::Gda::DataModel>& model), gdaui_data_selector_set_model)
+
+//TODO: Docs say that the GArray* should be freed after use.  Freeing the underlying data is possible with Glib::ArrayHandle<> but how should the GArray* be freed?
+//#m4 _CONVERSION(`GArray*', `Glib::ArrayHandle<int>', `$2($3->data, $3->len, Glib::OWNERSHIP_DEEEP)')
+  //_WRAP_METHOD(Glib::ArrayHandle<int> get_selected_rows(), gdaui_data_selector_get_selected_rows)
+
+  _WRAP_METHOD(Glib::RefPtr<Gnome::Gda::DataModelIter> get_data_set(), gdaui_data_selector_get_data_set)
+  _WRAP_METHOD(Glib::RefPtr<const Gnome::Gda::DataModelIter> get_data_set() const, gdaui_data_selector_get_data_set, constversion)
+  _WRAP_METHOD(bool select_row(int row), gdaui_data_selector_select_row)
+  _WRAP_METHOD(void unselect_row(int row), gdaui_data_selector_unselect_row)
+  _WRAP_METHOD(void set_column_visible(int column, bool visible), gdaui_data_selector_set_column_visible)
+
+  _WRAP_SIGNAL(void selection_changed(), "selection-changed")
+
+  _WRAP_VFUNC(Glib::RefPtr<Gnome::Gda::DataModel> get_model() const, "get_model")
+
+#m4 _CONVERSION(`GdaDataModel*', `const Glib::RefPtr<Gnome::Gda::DataModel>&', `Glib::wrap($3, true)')
+  _WRAP_VFUNC(void set_model(const Glib::RefPtr<Gnome::Gda::DataModel>& model), "set_model")
+
+  //TODO: Wrapping GArray is difficult.
+  //_WRAP_VFUNC(GArray* get_selected_rows(), "get_selected_rows")
+
+  _WRAP_VFUNC(Glib::RefPtr<Gnome::Gda::DataModelIter> get_data_set() const, "get_data_set")
+  _WRAP_VFUNC(bool select_row(int row), "select_row")
+  _WRAP_VFUNC(void unselect_row(int row), "unselect_row")
+  _WRAP_VFUNC(void set_column_visible(int column, bool visible), "set_column_visible")
+};
+
+} // namespace GdaUI
+
+} // namespace Gnome
diff --git a/libgda-ui/src/filelist.am b/libgda-ui/src/filelist.am
index 73475c9..cc4f615 100644
--- a/libgda-ui/src/filelist.am
+++ b/libgda-ui/src/filelist.am
@@ -9,6 +9,8 @@ files_defs =                            \
         libgda_ui_docs_override.xml
 
 files_hg =                              \
-        combo.hg
+        combo.hg                        \
+        dataselector.hg
+
 
 files_ccg = $(files_hg:.hg=.ccg)
diff --git a/libgda-ui/src/libgda_ui.defs b/libgda-ui/src/libgda_ui.defs
index 2b77880..f7b53bc 100644
--- a/libgda-ui/src/libgda_ui.defs
+++ b/libgda-ui/src/libgda_ui.defs
@@ -1,3 +1,4 @@
 (include libgda_ui_methods.defs)
-(include libgda_ui_vfuncs.defs)
+(include libgda_ui_signals.defs)
 (include libgda_ui_enums.defs)
+(include libgda_ui_vfuncs.defs)
diff --git a/libgda-ui/src/libgda_ui_signals.defs b/libgda-ui/src/libgda_ui_signals.defs
index 886e7da..501a58f 100644
--- a/libgda-ui/src/libgda_ui_signals.defs
+++ b/libgda-ui/src/libgda_ui_signals.defs
@@ -361,3 +361,13 @@
 )
 
 
+;; From GdauiDataSelector
+
+(define-signal selection-changed
+  (of-object "GdauiDataSelector")
+  (return-type "void")
+  (when "first")
+)
+
+;; Warning: g_object_interface_list_properties() returned NULL for GdauiDataSelector
+
diff --git a/libgda-ui/src/libgda_ui_vfuncs.defs b/libgda-ui/src/libgda_ui_vfuncs.defs
index bb1a740..55ef1b8 100644
--- a/libgda-ui/src/libgda_ui_vfuncs.defs
+++ b/libgda-ui/src/libgda_ui_vfuncs.defs
@@ -1,3 +1,53 @@
 ;; -*- scheme -*-
 ; virtual function definitions
 ; define-vfunc is gtkmm-specific
+
+; GdauiDataSelector
+
+(define-vfunc get_model
+  (of-object "GdauiDataSelector")
+  (return-type "GdaDataModel*")
+)
+
+(define-vfunc set_model
+  (of-object "GdauiDataSelector")
+  (return-type "void")
+  (parameters
+   '("GdaDataModel*" "model")
+  )
+)
+
+(define-vfunc get_selected_rows
+  (of-object "GdauiDataSelector")
+  (return-type "GArray*")
+)
+
+(define-vfunc get_data_set
+  (of-object "GdauiDataSelector")
+  (return-type "GdaDataModelIter*")
+)
+
+(define-vfunc select_row
+  (of-object "GdauiDataSelector")
+  (return-type "gboolean")
+  (parameters
+   '("gint" "row")
+  )
+)
+
+(define-vfunc unselect_row
+  (of-object "GdauiDataSelector")
+  (return-type "void")
+  (parameters
+   '("gint" "row")
+  )
+)
+
+(define-vfunc set_column_visible
+  (of-object "GdauiDataSelector")
+  (return-type "void")
+  (parameters
+   '("gint" "column")
+   '("gboolean" "visible")
+  )
+)
diff --git a/tools/extra_defs_gen/generate_defs_libgda_ui.cc b/tools/extra_defs_gen/generate_defs_libgda_ui.cc
index 00418c8..e180a6b 100644
--- a/tools/extra_defs_gen/generate_defs_libgda_ui.cc
+++ b/tools/extra_defs_gen/generate_defs_libgda_ui.cc
@@ -19,13 +19,15 @@
 
 #include <glibmm_generate_extra_defs/generate_extra_defs.h>
 #include <libgda-ui/gdaui-combo.h>
+#include <libgda-ui/gdaui-data-selector.h>
 #include <iostream>
 
 int main(int, char**)
 {
   g_type_init();
 
-  std::cout << get_defs(GDAUI_TYPE_COMBO)        << std::endl
+  std::cout << get_defs(GDAUI_TYPE_COMBO)               << std::endl
+            << get_defs(GDAUI_TYPE_DATA_SELECTOR)       << std::endl
             ;
   return 0;
 }
diff --git a/tools/m4/convert_libgda_uimm.m4 b/tools/m4/convert_libgda_uimm.m4
index 6d990d1..8546517 100644
--- a/tools/m4/convert_libgda_uimm.m4
+++ b/tools/m4/convert_libgda_uimm.m4
@@ -4,6 +4,12 @@ dnl Enums:
 _CONV_ENUM(Gda,ExampleEnum)
 
 dnl DataModel:
-_CONVERSION(`Gnome::Gda::DataModel*', `GdaDataModel*', `Glib::unwrap($3)')
+_CONVERSION(`const Glib::RefPtr<Gnome::Gda::DataModel>&', `GdaDataModel*', `Glib::unwrap($3)')
+_CONVERSION(`GdaDataModel*', `Glib::RefPtr<Gnome::Gda::DataModel>', `Glib::wrap($3)')
+_CONVERSION(`Glib::RefPtr<Gnome::Gda::DataModel>', `GdaDataModel*', `Glib::unwrap($3)')
+
+dnl DataModelIter:
+_CONVERSION(`GdaDataModelIter*', `Glib::RefPtr<Gnome::Gda::DataModelIter>', `Glib::wrap($3)')
+_CONVERSION(`Glib::RefPtr<Gnome::Gda::DataModelIter>', `GdaDataModelIter*', `Glib::unwrap($3)')
 
 dnl General conversions:



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