</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">etched-in</property>
+ <property name="spacing">5</property>
<child>
- <object class="GtkTreeView" id="treeview1">
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="model">lstore_fields</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">etched-in</property>
<child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn2">
- <property name="title">Fields</property>
+ <object class="GtkTreeView" id="treeview1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">lstore_fields</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
<child>
- <object class="GtkCellRendererText" id="cellrenderertext2"/>
- <attributes>
- <attribute name="text">1</attribute>
- </attributes>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+ <property name="title">Fields</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext2"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <property name="title">Under audit</property>
+ <child>
+ <object class="GtkCellRendererToggle" id="cellrenderertoggle1"/>
+ <attributes>
+ <attribute name="active">2</attribute>
+ </attributes>
+ </child>
+ </object>
</child>
</object>
</child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVButtonBox" id="vbuttonbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">5</property>
+ <property name="layout_style">spread</property>
<child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn1">
- <property name="title">Under audit</property>
- <child>
- <object class="GtkCellRendererToggle" id="cellrenderertoggle1"/>
- <attributes>
- <attribute name="active">2</attribute>
- </attributes>
- </child>
+ <object class="GtkButton" id="button11">
+ <property name="label" translatable="yes">_Select all</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button12">
+ <property name="label" translatable="yes">_Unselect all</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
static void table_on_cb_tables_changed (GtkComboBox *widget,
gpointer user_data);
+static void table_on_btn_select_all_clicked (GtkButton *button,
+ gpointer user_data);
+static void table_on_btn_unselect_all_clicked (GtkButton *button,
+ gpointer user_data);
+
static void table_on_btn_cancel_clicked (GtkButton *button,
gpointer user_data);
static void table_on_btn_save_clicked (GtkButton *button,
"toggled", G_CALLBACK (fixed_toggled),
priv->lstore_fields);
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button11"),
+ "clicked", G_CALLBACK (table_on_btn_select_all_clicked), (gpointer *)a);
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button12"),
+ "clicked", G_CALLBACK (table_on_btn_unselect_all_clicked), (gpointer *)a);
+
g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button5"),
"clicked", G_CALLBACK (table_on_btn_cancel_clicked), (gpointer *)a);
g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button6"),
new_id++;
sql = g_strdup_printf ("INSERT INTO %stables"
- " (id, name)"
- " VALUES (%d, '%s')",
+ " (id, name, id_datasources)"
+ " VALUES (%d, '%s', %d)",
priv->commons->prefix,
new_id,
- table_name);
+ table_name,
+ strtol (gtk_label_get_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label8"))), NULL, 10));
stmt = gda_sql_parser_parse_string (priv->commons->gdaparser, sql, NULL, NULL);
}
else
if (id_field == 0)
{
error = NULL;
- sql = g_strdup_printf ("SELECT COALESCE (MAX (id), 0) FROM %sfields"
- " WHERE id_tables = %d",
- priv->commons->prefix,
- priv->id);
+ sql = g_strdup_printf ("SELECT COALESCE (MAX (id), 0) FROM %sfields",
+ priv->commons->prefix);
stmt = gda_sql_parser_parse_string (priv->commons->gdaparser, sql, NULL, NULL);
dm = gda_connection_statement_execute_select (priv->commons->gdacon, stmt, NULL, &error);
if (dm != NULL && gda_data_model_get_n_rows (dm) == 1)
gda_connection_statement_execute_non_select (priv->commons->gdacon, stmt, NULL, NULL, &error);
if (error != NULL)
{
- g_warning ("Error save new field: %s",
+ g_warning ("Error saving new field: %s",
(error->message != NULL ? error->message : "No details."));
}
g_object_unref (stmt);
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->lstore_fields), &iter));
}
- if (g_strcmp0 (id_saved, "") != 0)
+ /* removing fields not saved */
+ error = NULL;
+ id_saved[strlen (id_saved) - 1] = '\0';
+ sql = g_strdup_printf ("DELETE FROM %sfields"
+ " WHERE id_tables = %d"
+ "%s",
+ priv->commons->prefix,
+ priv->id,
+ (g_strcmp0 (id_saved, "") != 0 ? g_strdup_printf (" AND id NOT IN (%s)", id_saved) : ""));
+ stmt = gda_sql_parser_parse_string (priv->commons->gdaparser, sql, NULL, NULL);
+ gda_connection_statement_execute_non_select (priv->commons->gdacon, stmt, NULL, NULL, &error);
+ if (error != NULL)
{
- /* removing fields not saved */
- error = NULL;
- id_saved[strlen (id_saved) - 1] = '\0';
- sql = g_strdup_printf ("DELETE FROM %sfields"
- " WHERE id_tables = %d"
- " AND id NOT IN (%s)",
- priv->commons->prefix,
- priv->id,
- id_saved);
- stmt = gda_sql_parser_parse_string (priv->commons->gdaparser, sql, NULL, NULL);
- gda_connection_statement_execute_non_select (priv->commons->gdacon, stmt, NULL, NULL, &error);
- if (error != NULL)
- {
- g_warning ("Error removing old fields: %s",
- (error->message != NULL ? error->message : "No details."));
- }
- g_object_unref (stmt);
+ g_warning ("Error removing old fields: %s",
+ (error->message != NULL ? error->message : "No details."));
}
+ g_object_unref (stmt);
g_signal_emit (table, klass->updated_signal_id, 0);
}
+static void
+table_on_btn_select_all_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ Table *table = (Table *)user_data;
+
+ TablePrivate *priv = TABLE_GET_PRIVATE (table);
+
+ GtkTreeIter iter;
+
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->lstore_fields), &iter))
+ {
+ do
+ {
+ gtk_list_store_set (priv->lstore_fields, &iter,
+ 2, TRUE,
+ -1);
+ } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->lstore_fields), &iter));
+ }
+}
+
+static void
+table_on_btn_unselect_all_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ Table *table = (Table *)user_data;
+
+ TablePrivate *priv = TABLE_GET_PRIVATE (table);
+
+ GtkTreeIter iter;
+
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->lstore_fields), &iter))
+ {
+ do
+ {
+ gtk_list_store_set (priv->lstore_fields, &iter,
+ 2, FALSE,
+ -1);
+ } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->lstore_fields), &iter));
+ }
+}
+
static void
table_on_btn_cancel_clicked (GtkButton *button,
gpointer user_data)