[gnome-db] Patch - cvs HEAD - gnome_db_combo.[ch]
- From: Stephane Wirtel <stephane wirtel brutele be>
- To: gnome-db-list gnome org
- Subject: [gnome-db] Patch - cvs HEAD - gnome_db_combo.[ch]
- Date: Wed, 17 Dec 2003 18:29:09 +0100
This patch add a new function in the API of gnome_db_combo.
Now it's possible to create a new gnome_db_combo widget with a model.
GtkWidget *gnome_db_combo_new_with_model(GdaDataModel *model, gint col);
This function works on my laptop : Gentoo 1.4 - gcc 3.3.2 - libgnomedb
1.0.2 && gnome-2.4.1
Bye.
matrixise
Index: libgnomedb/gnome-db-combo.c
===================================================================
RCS file: /cvs/gnome/libgnomedb/libgnomedb/gnome-db-combo.c,v
retrieving revision 1.4
diff -u -r1.4 gnome-db-combo.c
--- libgnomedb/gnome-db-combo.c 29 Nov 2003 15:39:58 -0000 1.4
+++ libgnomedb/gnome-db-combo.c 17 Dec 2003 17:24:43 -0000
@@ -185,6 +185,42 @@
return GTK_WIDGET (combo);
}
+/**
+ * gnome_db_combo_new_with_model
+ * @model: a #GdaDataModel object.
+ * @col: column in the model to be shown
+ *
+ * Create a new GnomeDbCombo widget with a GdaDataModel.
+ *
+ * Returns: the newly-created widget.
+ */
+GtkWidget *
+gnome_db_combo_new_with_model (GdaDataModel *model, gint col)
+{
+ GnomeDbCombo *combo;
+ GList *list;
+
+ g_return_val_if_fail (model == NULL || GDA_IS_DATA_MODEL (model), NULL);
+ g_return_val_if_fail (col >= 0, NULL);
+
+ combo = g_object_new(GNOME_DB_TYPE_COMBO, NULL);
+
+ combo->priv->model = model;
+ if (model != NULL) {
+ g_object_ref (G_OBJECT (model));
+ g_signal_connect (G_OBJECT (combo->priv->model), "changed",
+ G_CALLBACK (model_changed_cb), combo);
+ combo->priv->col = col;
+ model_changed_cb (model, combo);
+ } else {
+ list = g_list_append (list, "");
+ gtk_combo_set_popdown_strings (GTK_COMBO (combo), list);
+ g_list_free (list);
+ }
+
+ return GTK_WIDGET(combo);
+}
+
static void
model_changed_cb (GdaDataModel *model, gpointer user_data)
{
Index: libgnomedb/gnome-db-combo.h
===================================================================
RCS file: /cvs/gnome/libgnomedb/libgnomedb/gnome-db-combo.h,v
retrieving revision 1.1
diff -u -r1.1 gnome-db-combo.h
--- libgnomedb/gnome-db-combo.h 13 Jan 2002 19:11:55 -0000 1.1
+++ libgnomedb/gnome-db-combo.h 17 Dec 2003 17:24:43 -0000
@@ -49,6 +49,7 @@
GType gnome_db_combo_get_type (void);
GtkWidget *gnome_db_combo_new (void);
+GtkWidget *gnome_db_combo_new_with_model (GdaDataModel *model, gint pos);
void gnome_db_combo_set_model (GnomeDbCombo *combo, GdaDataModel *model, gint pos);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]