[libgda-uimm] Add Cloud widget.



commit c609a0def4e68184da0dd05f06ad8a04abbf8f4c
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Wed Mar 3 19:02:20 2010 -0500

    	Add Cloud widget.
    
    	* libgda-ui/libgda-uimm.h:
    	* libgda-ui/src/filelist.am:
    	* libgda-ui/src/cloud.ccg:
    	* libgda-ui/src/cloud.hg: Add new Cloud widget.
    
    	* libgda-ui/src/login.hg:
    	* libgda-ui/src/rawgrid.hg: Correct signal parameter names.

 ChangeLog                 |   12 +++++
 libgda-ui/libgda-uimm.h   |    1 +
 libgda-ui/src/cloud.ccg   |   81 +++++++++++++++++++++++++++++++++++
 libgda-ui/src/cloud.hg    |  104 +++++++++++++++++++++++++++++++++++++++++++++
 libgda-ui/src/filelist.am |    1 +
 libgda-ui/src/login.hg    |    2 +-
 libgda-ui/src/rawgrid.hg  |    4 +-
 7 files changed, 202 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 38c4de5..d8444c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2010-03-03  José Alburquerque  <jaalburqu svn gnome org>
 
+	Add Cloud widget.
+
+	* libgda-ui/libgda-uimm.h:
+	* libgda-ui/src/filelist.am:
+	* libgda-ui/src/cloud.ccg:
+	* libgda-ui/src/cloud.hg: Add new Cloud widget.
+
+	* libgda-ui/src/login.hg:
+	* libgda-ui/src/rawgrid.hg: Correct signal parameter names.
+
+2010-03-03  José Alburquerque  <jaalburqu svn gnome org>
+
 	Add Grid and RawGrid classes.
 
 	* libgda-ui/libgda-uimm.h:
diff --git a/libgda-ui/libgda-uimm.h b/libgda-ui/libgda-uimm.h
index bfa1a5c..551d6aa 100644
--- a/libgda-ui/libgda-uimm.h
+++ b/libgda-ui/libgda-uimm.h
@@ -21,6 +21,7 @@
 #define _LIBGDA_UIMM_H
 
 #include <basicform.h>
+#include <cloud.h>
 #include <combo.h>
 #include <dataproxy.h>
 #include <dataproxyinfo.h>
diff --git a/libgda-ui/src/cloud.ccg b/libgda-ui/src/cloud.ccg
new file mode 100644
index 0000000..09c4e85
--- /dev/null
+++ b/libgda-ui/src/cloud.ccg
@@ -0,0 +1,81 @@
+/* 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-cloud.h>
+#include <libgdamm/datamodel.h>
+
+namespace
+{
+
+extern "C"
+{
+
+static gdouble Cloud_Weight_libgda_uimm_callback(GdaDataModel *model,
+  gint row, gpointer data)
+{
+  Gnome::GdaUI::Cloud::SlotWeight* the_slot =
+    static_cast<Gnome::GdaUI::Cloud::SlotWeight*>(data);
+
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  try
+  {
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
+    return (*the_slot)(Glib::wrap(model, true), row);
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  }
+  catch(...)
+  {
+    Glib::exception_handlers_invoke();
+  }
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  return 0;
+}
+
+} // extern "C"
+
+} // anonymous namespace
+
+namespace Gnome
+{
+
+namespace GdaUI
+{
+
+void Cloud::set_weight_slot(const SlotWeight& slot)
+{
+  // Create a copy of the slot.  A pointer to this copy will be passed through
+  // the call back's data parameter.  It will be destroyed with the
+  // std::auto_ptr<>.
+  m_slot.reset(new SlotWeight(slot));
+
+  gdaui_cloud_set_weight_func(gobj(), &Cloud_Weight_libgda_uimm_callback,
+    m_slot.get());
+}
+
+void Cloud::unset_weight_slot()
+{
+  // The docs say to use NULL for the callback which will remove the weight
+  // callback.
+  gdaui_cloud_set_weight_func(gobj(), 0, 0);
+}
+
+} /* namespace GdaUI */
+
+} /* namespace Gnome */
diff --git a/libgda-ui/src/cloud.hg b/libgda-ui/src/cloud.hg
new file mode 100644
index 0000000..bb07c1a
--- /dev/null
+++ b/libgda-ui/src/cloud.hg
@@ -0,0 +1,104 @@
+/* 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 <gtkmm/box.h>
+#include <gtkmm/enums.h>
+#include <libgda-uimm/dataproxy.h>
+#include <libgda-uimm/dataselector.h>
+#include <memory>
+
+_DEFS(libgda-uimm,libgda_ui)
+_PINCLUDE(gtkmm/private/box_p.h)
+
+namespace Gnome
+{
+
+// Gnome::Gda class forward declarations.
+namespace Gda
+{
+
+class DataModel;
+
+}
+
+namespace GdaUI
+{
+
+/** Cloud - Cloud widget.
+ * The Cloud widget displays a string for each row in a Gnome::Gda::DataModel
+ * for which the size is variable (determined either by some data in the data
+ * model, or by a function provided by the programmer).
+ *
+ * Depending on the selection mode of the widget, each string can be selected
+ * by the user and the signal_selection_changed() is emitted.
+ */
+class Cloud :
+  public Gtk::VBox,
+  public DataSelector
+{
+  _CLASS_GTKOBJECT(Cloud, GdauiCloud, GDAUI_CLOUD, Gtk::VBox, GtkVBox)
+  _IMPLEMENTS_INTERFACE(DataSelector)
+
+public:
+  _WRAP_METHOD_DOCS_ONLY(gdaui_cloud_new)
+  _WRAP_CTOR(Cloud(const Glib::RefPtr<Gnome::Gda::DataModel>& model, int label_column, int weight_column), gdaui_cloud_new)
+
+public:
+/** For example,
+ * double on_weight(const Glib::RefPtr<Gnome::Gda::DataModel>& model, int
+ * row);.
+ */
+typedef sigc::slot<double, const Glib::RefPtr<Gnome::Gda::DataModel>&, int> SlotWeight;
+
+  _WRAP_METHOD(void set_selection_mode(Gtk::SelectionMode mode), gdaui_cloud_set_selection_mode)
+  _WRAP_METHOD(void filter(const Glib::ustring& filter), gdaui_cloud_filter)
+  _WRAP_METHOD(Gtk::Widget* create_filter_widget(), gdaui_cloud_create_filter_widget)
+  _WRAP_METHOD(const Gtk::Widget* create_filter_widget() const, gdaui_cloud_create_filter_widget, constversion)
+
+  /** Specifies a slot called to compute each row's respective weight.
+   * @param func a slot which computes weights.
+   * @newin{4,2}
+   */
+  void set_weight_slot(const SlotWeight& slot);
+
+  /** Unsets a previously set weight computing slot.
+   * @newin{4,2}
+   */
+  void unset_weight_slot();
+
+  _WRAP_SIGNAL(void activate(int column), "activate")
+
+  _WRAP_PROPERTY("label-column", int)
+  _WRAP_PROPERTY("max-scale", double)
+  _WRAP_PROPERTY("min-scale", double)
+  _WRAP_PROPERTY("model", Glib::RefPtr<Gnome::Gda::DataModel>)
+  _WRAP_PROPERTY("weight-column", int)
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+private:
+  // Private variable to save the weight calculating slot until it is not
+  // necessary.  If the C API would provide a way for destroy notification,
+  // this private member would not be necessary.
+  std::auto_ptr<SlotWeight> m_slot;
+#endif
+};
+
+} // namespace GdaUI
+
+} // namespace Gnome
diff --git a/libgda-ui/src/filelist.am b/libgda-ui/src/filelist.am
index 249f38b..8a50b54 100644
--- a/libgda-ui/src/filelist.am
+++ b/libgda-ui/src/filelist.am
@@ -10,6 +10,7 @@ files_defs =                            \
 
 files_hg =                              \
         basicform.hg                    \
+        cloud.hg                        \
         combo.hg                        \
         dataproxy.hg                    \
         dataproxyinfo.hg                \
diff --git a/libgda-ui/src/login.hg b/libgda-ui/src/login.hg
index d28ba36..ed1a2c7 100644
--- a/libgda-ui/src/login.hg
+++ b/libgda-ui/src/login.hg
@@ -56,7 +56,7 @@ public:
   _WRAP_METHOD(void set_dsn(const Glib::ustring& dsn), gdaui_login_set_dsn)
   _WRAP_METHOD(void set_connection_information(const GdaDsnInfo *cinfo), gdaui_login_set_connection_information)
 
-  _WRAP_SIGNAL(void changed(bool arg1), "changed")
+  _WRAP_SIGNAL(void changed(bool is_valid), "changed")
 
   _WRAP_PROPERTY("dsn", Glib::ustring)
   _WRAP_PROPERTY("mode", LoginMode)
diff --git a/libgda-ui/src/rawgrid.hg b/libgda-ui/src/rawgrid.hg
index 2dbab5a..9b6cc60 100644
--- a/libgda-ui/src/rawgrid.hg
+++ b/libgda-ui/src/rawgrid.hg
@@ -58,8 +58,8 @@ public:
   _WRAP_METHOD(void set_sample_start(int sample_start), gdaui_raw_grid_set_sample_start)
   _WRAP_METHOD(void set_layout_from_file(const std::string& file_name, const Glib::ustring& grid_name), gdaui_raw_grid_set_layout_from_file)
 
-  _WRAP_SIGNAL(void double_clicked(int arg1), "double-clicked")
-  _WRAP_SIGNAL(void populate_popup(Gtk::Menu* arg1), "populate-popup")
+  _WRAP_SIGNAL(void double_clicked(int row), "double-clicked")
+  _WRAP_SIGNAL(void populate_popup(Gtk::Menu* menu), "populate-popup")
 
   _WRAP_PROPERTY("global-actions-visible", bool)
   _WRAP_PROPERTY("info-cell-visible", bool)



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