--- /dev/null
+<?xml version="1.0"?>
+<anjuta>
+ <plugin name="Git" mandatory="no">
+ <require group="Anjuta Plugin"
+ attribute="Location"
+ value="anjuta-git:Git"/>
+ </plugin>
+</anjuta>
--- /dev/null
+<?xml version="1.0"?>
+<anjuta>
+ <plugin name="GBF Project Manager"
+ url="http://anjuta.org/plugins/"
+ mandatory="yes">
+ <require group="Anjuta Plugin"
+ attribute="Interfaces"
+ value="IAnjutaProjectManager"/>
+ </plugin>
+ <plugin name= "Autotools backend"
+ mandatory="yes">
+ <require group="Anjuta Plugin"
+ attribute="Location"
+ value="am-project:AmpPlugin"/>
+ <require group="Anjuta Plugin"
+ attribute="Interfaces"
+ value="IAnjutaProjectBackend"/>
+ </plugin>
+ <plugin name="Symbol Browser"
+ url="http://anjuta.org/plugins/"
+ mandatory="yes">
+ <require group="Anjuta Plugin"
+ attribute="Interfaces"
+ value="IAnjutaSymbolManager"/>
+ </plugin>
+ <plugin name="Make Build System"
+ url="http://anjuta.org/plugins/"
+ mandatory="yes">
+ <require group="Anjuta Plugin"
+ attribute="Interfaces"
+ value="IAnjutaBuildable"/>
+ <require group="Build"
+ attribute="Supported-Build-Types"
+ value="make"/>
+ </plugin>
+ <plugin name="Task Manager"
+ url="http://anjuta.org/plugins/"
+ mandatory="no">
+ <require group="Anjuta Plugin"
+ attribute="Interfaces"
+ value="IAnjutaTodo"/>
+ </plugin>
+ <plugin name="Debug Manager"
+ url="http://anjuta.org/plugins/"
+ mandatory="no">
+ <require group="Anjuta Plugin"
+ attribute="Interfaces"
+ value="IAnjutaDebugManager"/>
+ </plugin>
+</anjuta>
if (gtk_form_field_is_auto_increment (field))
{
gchar *field_name;
+ GString *key_where;
guint new_val;
g_return_val_if_fail (IS_GDAEX (priv->gdaex), NULL);
- g_object_get (field, "field", &field_name, NULL);
+ where = NULL;
+ if (IS_GTK_FORM_KEY (priv->key)
+ && gtk_form_key_field_is_key (priv->key, field))
+ {
+ /* it depends on other key fields value */
+ GSList *key_fields;
+ GtkFormField *kffield;
+
+ key_fields = gtk_form_key_get_fields (priv->key);
+ if (key_fields != NULL)
+ {
+ key_where = g_string_new ("");
+ }
+ while (key_fields)
+ {
+ kffield = (GtkFormField *)key_fields->data;
+ if (g_strcmp0 (gtk_form_field_get_field_name (field),
+ gtk_form_field_get_field_name (kffield)) != 0)
+ {
+ g_string_append (key_where,
+ gtk_form_key_get_field_sql (priv->key, kffield));
+ }
+
+ key_fields = g_slist_next (key_fields);
+ }
+ }
+
+ if (g_strcmp0 (key_where->str, "") != 0)
+ {
+ g_string_erase (key_where, 0, 5);
+ }
+
+ g_object_get (field, "field", &field_name, key_where->str);
new_val = gdaex_get_new_id (priv->gdaex, priv->table, field_name, NULL);
gtk_form_widget_set_value_stringify (gtk_form_field_get_form_widget (field), g_strdup_printf ("%d", new_val));
+
+ g_string_free (key_where, TRUE);
}
-
+
value = gtk_form_field_get_value_sql (field);
if (value != NULL)
{
case GTK_FORM_SQL_UPDATE:
if (gtk_form_field_is_to_save (field)
- && (!IS_GTK_FORM_KEY (priv->key) ||
- !gtk_form_key_field_is_key (priv->key, field)))
+ && (!IS_GTK_FORM_KEY (priv->key)
+ || !gtk_form_key_field_is_key (priv->key, field)))
{
value = gtk_form_field_get_value_sql (field);
if (value != NULL)
{
sql = g_strconcat (sql, where, NULL);
}
+ if (where != NULL)
+ {
+ g_free (where);
+ }
}
g_string_free (fields_names, TRUE);
/*
- * Copyright (C) 2005-2009 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2013 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
gboolean
gtk_form_key_add_field (GtkFormKey *gtk_form_key, GtkFormField *field)
{
- gboolean ret = FALSE;
-
- GtkFormKeyPrivate *priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
+ GtkFormKeyPrivate *priv;
g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
+ priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
priv->fields = g_slist_append (priv->fields, field);
- ret = TRUE;
-
- return ret;
+ return TRUE;
}
/**
gboolean
gtk_form_key_remove_field (GtkFormKey *gtk_form_key, GtkFormField *field)
{
- gboolean ret = FALSE;
-
- GtkFormKeyPrivate *priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
+ GtkFormKeyPrivate *priv;
g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
+ priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
priv->fields = g_slist_remove (priv->fields, field);
- ret = TRUE;
-
- return ret;
+ return TRUE;
}
/**
{
GtkFormField *field;
+ g_return_val_if_fail (IS_GTK_FORM_KEY (gtk_form_key), FALSE);
+
va_list vargs;
va_start (vargs, gtk_form_key);
}
va_end (vargs);
+
+ return TRUE;
+}
+
+/**
+ * gtk_form_key_get_fields:
+ * @gtk_form_key: a #GtkFormKey object.
+ *
+ */
+GSList
+*gtk_form_key_get_fields (GtkFormKey *gtk_form_key)
+{
+ GtkFormKeyPrivate *priv;
+
+ g_return_val_if_fail (IS_GTK_FORM_KEY (gtk_form_key), NULL);
+
+ priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
+
+ return priv->fields;
}
/**
return ret;
}
+/**
+ * gtk_form_key_get_field_sql:
+ * @gtk_form_key:
+ * @gtk_form_field:
+ *
+ */
+gchar
+*gtk_form_key_get_field_sql (GtkFormKey *gtk_form_key, GtkFormField *gtk_form_field)
+{
+ gchar *ret;
+
+ gchar *field_name;
+
+ g_return_val_if_fail (IS_GTK_FORM_KEY (gtk_form_key), "");
+ g_return_val_if_fail (IS_GTK_FORM_FIELD (gtk_form_field), "");
+
+ g_object_get (G_OBJECT (gtk_form_field),
+ "field", &field_name,
+ NULL);
+
+ ret = g_strdup_printf (" AND %s = %s",
+ field_name,
+ gtk_form_field_get_value_sql (gtk_form_field));
+
+ return ret;
+}
+
/**
* gtk_form_key_get_sql:
* @gtk_form_key: a #GtkFormKey object.
*gtk_form_key_get_sql (GtkFormKey *gtk_form_key)
{
GtkFormField *field;
- gchar *sql = "";
- gchar *field_name;
+ GString *sql;
GtkFormKeyPrivate *priv;
GSList *fields;
- g_return_val_if_fail (IS_GTK_FORM_KEY (gtk_form_key), sql);
+ g_return_val_if_fail (IS_GTK_FORM_KEY (gtk_form_key), "");
priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
fields = priv->fields;
+ sql = g_string_new ("");
while (fields != NULL)
{
field = (GtkFormField *)fields->data;
- g_object_get (G_OBJECT (field),
- "field", &field_name,
- NULL);
-
- sql = g_strconcat (sql, " AND ", field_name, " = ",
- gtk_form_field_get_value_sql (field), NULL);
+ g_string_append (sql, gtk_form_key_get_field_sql (gtk_form_key, field));
fields = g_slist_next (fields);
}
- if (strcmp (sql, "") != 0)
+ if (g_strcmp0 (sql->str, "") != 0)
{
- sql = g_strconcat (" WHERE ", g_strdup (sql + 5), NULL);
+ g_string_erase (sql, 0, 5);
+ g_string_printf (sql, " WHERE %s", sql->str);
}
- g_free (field_name);
-
- return sql;
+ return sql->str;
}
/**
gboolean gtk_form_key_add_fields (GtkFormKey *gtk_form_key, ...);
+GSList *gtk_form_key_get_fields (GtkFormKey *gtk_form_key);
+
gboolean gtk_form_key_check (GtkFormKey *gtk_form_key, GtkFormWidget **form_widget);
+gchar *gtk_form_key_get_field_sql (GtkFormKey *gtk_form_key, GtkFormField *gtk_form_field);
gchar *gtk_form_key_get_sql (GtkFormKey *gtk_form_key);
GHashTable *gtk_form_key_get_values_as_hashtable (GtkFormKey *gtk_form_key);