Some adjustments.
<property name="has_separator">True</property>
<property name="program_name">Autoz GUI</property>
<property name="version">0.0.1</property>
- <property name="copyright" translatable="yes">Andrea Zagli 2011</property>
+ <property name="copyright" translatable="yes">Andrea Zagli 2011-2012</property>
<property name="authors">Andrea Zagli <azagli@libero.it></property>
<property name="wrap_license">True</property>
<child internal-child="vbox">
/*
- * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2011-2012 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
new_id = g_value_get_int (gda_data_model_get_value_at (dm, 0, 0, NULL));
}
new_id++;
+ g_object_unref (dm);
sql = g_strdup_printf ("INSERT INTO %sresources (id, resource_id)"
- " VALUES (%d, '%s',)",
+ " VALUES (%d, '%s')",
priv->commons->prefix,
new_id,
gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (priv->commons->gtkbuilder, "entry2"))));
/*
- * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2011-2012 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
GTK_BUTTONS_YES_NO,
"Are you sure to want to delete the selected resource?");
risp = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
if (risp == GTK_RESPONSE_YES)
{
GError *error;
error = NULL;
stmt = gda_sql_parser_parse_string (priv->commons->gdaparser,
- g_strdup_printf ("DELETE %sresources WHERE id = %d", priv->commons->prefix, id),
- NULL, NULL);
+ g_strdup_printf ("DELETE FROM %sresources WHERE id = %d", priv->commons->prefix, id),
+ NULL, &error);
- if (stmt != NULL)
+ if (stmt == NULL || error != NULL)
{
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
- "You must select a resource.");
+ "You must select a resource.%s",
+ error != NULL && error->message != NULL ? g_strdup_printf ("\n\n", error->message) : "");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
return;
}
+ error = NULL;
if (gda_connection_statement_execute_non_select (priv->commons->gdacon, stmt, NULL, NULL, &error) <= 0)
{
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
GTK_BUTTONS_OK,
"Error on saving.\n\n%s",
(error != NULL && error->message != NULL ? error->message : "No details."));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
}
resources_load (resources);
}
- gtk_widget_destroy (dialog);
}
else
{
/*
- * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2011-2012 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
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
+ g_object_unref (dm);
}
static void
new_id = g_value_get_int (gda_data_model_get_value_at (dm, 0, 0, NULL));
}
new_id++;
+ g_object_unref (dm);
sql = g_strdup_printf ("INSERT INTO %sroles (id, role_id)"
- " VALUES (%d, '%s',)",
+ " VALUES (%d, '%s')",
priv->commons->prefix,
new_id,
gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (priv->commons->gtkbuilder, "entry1"))));
/*
- * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2011-2012 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
GTK_BUTTONS_YES_NO,
"Are you sure to want to delete the selected role?");
risp = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
if (risp == GTK_RESPONSE_YES)
{
GError *error;
error = NULL;
stmt = gda_sql_parser_parse_string (priv->commons->gdaparser,
- g_strdup_printf ("DELETE %sroles WHERE id = %d", priv->commons->prefix, id),
- NULL, NULL);
+ g_strdup_printf ("DELETE FROM %sroles WHERE id = %d", priv->commons->prefix, id),
+ NULL, &error);
- if (stmt != NULL)
+ if (stmt == NULL || error != NULL)
{
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
- "You must select a role.");
+ "You must select a role.%s",
+ error != NULL && error->message != NULL ? g_strdup_printf ("\n\n%s", error->message) : "");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
return;
}
+ error = NULL;
if (gda_connection_statement_execute_non_select (priv->commons->gdacon, stmt, NULL, NULL, &error) <= 0)
{
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
GTK_BUTTONS_OK,
"Error on saving.\n\n%s",
(error != NULL && error->message != NULL ? error->message : "No details."));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
}
roles_load (roles);
}
- gtk_widget_destroy (dialog);
}
else
{