<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
- <object class="GtkTreeStore" id="tstore_fields">
- <columns>
- <!-- column-name table_name -->
- <column type="gchararray"/>
- <!-- column-name name -->
- <column type="gchararray"/>
- <!-- column-name name_visible -->
- <column type="gchararray"/>
- <!-- column-name description -->
- <column type="gchararray"/>
- </columns>
- </object>
<object class="GtkListStore" id="lstore_show">
<columns>
<!-- column-name table_name -->
<column type="gchararray"/>
</columns>
</object>
+ <object class="GtkTreeStore" id="tstore_fields">
+ <columns>
+ <!-- column-name table_name -->
+ <column type="gchararray"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ <!-- column-name name_visible -->
+ <column type="gchararray"/>
+ <!-- column-name description -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="diag_query_editor">
<property name="border_width">5</property>
<property name="title" translatable="yes">Query Editor</property>
static void gdaex_query_editor_on_sel_fields_changed (GtkTreeSelection *treeselection,
gpointer user_data);
+static void gdaex_query_editor_show_add_iter (GdaExQueryEditor *qe, GtkTreeIter *iter);
+
static void gdaex_query_editor_on_btn_show_add_clicked (GtkButton *button,
gpointer user_data);
static void gdaex_query_editor_on_btn_show_remove_clicked (GtkButton *button,
gpointer user_data);
static void gdaex_query_editor_on_btn_show_down_clicked (GtkButton *button,
gpointer user_data);
+static void gdaex_query_editor_on_sel_show_changed (GtkTreeSelection *treeselection,
+ gpointer user_data);
static void gdaex_query_editor_on_btn_where_add_clicked (GtkButton *button,
gpointer user_data);
G_CALLBACK (gdaex_query_editor_on_btn_show_up_clicked), (gpointer)gdaex_query_editor);
g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button6"), "clicked",
G_CALLBACK (gdaex_query_editor_on_btn_show_down_clicked), (gpointer)gdaex_query_editor);
+ g_signal_connect (priv->sel_show, "changed",
+ G_CALLBACK (gdaex_query_editor_on_sel_show_changed), (gpointer)gdaex_query_editor);
g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button7"), "clicked",
G_CALLBACK (gdaex_query_editor_on_btn_where_add_clicked), (gpointer)gdaex_query_editor);
COL_FIELDS_VISIBLE_NAME, field->name_visible,
COL_FIELDS_DESCRIPTION, field->description,
-1);
+
+ if (field->always_showed)
+ {
+ gdaex_query_editor_show_add_iter (qe, &iter);
+ }
}
}
table = g_hash_table_lookup (priv->tables, table_name);
field = g_hash_table_lookup (table->fields, field_name);
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "button3")), TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "button7")), TRUE);
+ if (!field->always_showed && field->for_show)
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "button3")), TRUE);
+ }
+
+ if (field->for_where)
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "button7")), TRUE);
+ }
table_field = g_strconcat (table->name_visible, " - ", field->name_visible, NULL);
v_table_field = gda_value_new (G_TYPE_STRING);
gtk_widget_hide (priv->vbx_values_container);
}
+static void
+gdaex_query_editor_show_add_iter (GdaExQueryEditor *qe, GtkTreeIter *iter)
+{
+ GdaExQueryEditorPrivate *priv;
+
+ gchar *table_name;
+ gchar *field_name;
+ GdaExQueryEditorTable *table;
+ GdaExQueryEditorField *field;
+
+ priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe);
+
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_fields), iter,
+ COL_FIELDS_TABLE_NAME, &table_name,
+ COL_FIELDS_NAME, &field_name,
+ -1);
+
+ table = g_hash_table_lookup (priv->tables, table_name);
+ field = g_hash_table_lookup (table->fields, field_name);
+
+ gtk_list_store_append (priv->lstore_show, iter);
+ gtk_list_store_set (priv->lstore_show, iter,
+ COL_SHOW_TABLE_NAME, field->table_name,
+ COL_SHOW_NAME, field_name,
+ COL_SHOW_VISIBLE_NAME, g_strconcat (table->name_visible, " - ", field->name_visible, NULL),
+ -1);
+}
+
static void
gdaex_query_editor_on_btn_show_add_clicked (GtkButton *button,
gpointer user_data)
GtkTreeIter iter;
GtkWidget *dialog;
- gchar *table_name;
- gchar *field_name;
- GdaExQueryEditorTable *table;
- GdaExQueryEditorField *field;
-
qe = (GdaExQueryEditor *)user_data;
priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe);
if (gtk_tree_selection_get_selected (priv->sel_fields, NULL, &iter))
{
- gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_fields), &iter,
- COL_FIELDS_TABLE_NAME, &table_name,
- COL_FIELDS_NAME, &field_name,
- -1);
-
- table = g_hash_table_lookup (priv->tables, table_name);
- field = g_hash_table_lookup (table->fields, field_name);
-
- gtk_list_store_append (priv->lstore_show, &iter);
- gtk_list_store_set (priv->lstore_show, &iter,
- COL_SHOW_TABLE_NAME, field->table_name,
- COL_SHOW_NAME, field_name,
- COL_SHOW_VISIBLE_NAME, g_strconcat (table->name_visible, " - ", field->name_visible, NULL),
- -1);
+ gdaex_query_editor_show_add_iter (qe, &iter);
}
else
{
FALSE);
}
+static void
+gdaex_query_editor_on_sel_show_changed (GtkTreeSelection *treeselection,
+ gpointer user_data)
+{
+ GtkTreeIter iter;
+
+ gchar *table_name;
+ gchar *field_name;
+ GdaExQueryEditorTable *table;
+ GdaExQueryEditorField *field;
+
+ GdaExQueryEditor *qe = (GdaExQueryEditor *)user_data;
+ GdaExQueryEditorPrivate *priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe);
+
+ if (gtk_tree_selection_get_selected (priv->sel_show, NULL, &iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_show), &iter,
+ COL_SHOW_TABLE_NAME, &table_name,
+ COL_SHOW_NAME, &field_name,
+ -1);
+
+ table = g_hash_table_lookup (priv->tables, table_name);
+ field = g_hash_table_lookup (table->fields, field_name);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "button4")), !field->always_showed);
+ }
+}
+
static void
gdaex_query_editor_on_btn_where_add_clicked (GtkButton *button,
gpointer user_data)
field = g_new0 (GdaExQueryEditorField, 1);
field->name = g_strdup ("id");
field->name_visible = g_strdup ("ID");
+ field->for_show = TRUE;
+ field->always_showed = TRUE;
+ field->for_where = TRUE;
gdaex_query_editor_table_add_field (qe, "clients", *field);
g_free (field);
field->name = g_strdup ("name");
field->name_visible = g_strdup ("Name");
field->description = g_strdup ("The client's name");
+ field->for_show = TRUE;
+ field->for_where = TRUE;
gdaex_query_editor_table_add_field (qe, "clients", *field);
g_free (field);
field->name = g_strdup ("surname");
field->name_visible = g_strdup ("Surname");
field->description = g_strdup ("The client's surname");
+ field->for_show = TRUE;
+ field->for_where = TRUE;
gdaex_query_editor_table_add_field (qe, "clients", *field);
g_free (field);
field->name = g_strdup ("age");
field->name_visible = g_strdup ("Age");
field->description = g_strdup ("The client's age");
+ field->for_show = TRUE;
+ field->for_where = FALSE;
gdaex_query_editor_table_add_field (qe, "clients", *field);
g_free (field);
field->name = g_strdup ("id_cities");
field->name_visible = g_strdup ("City");
field->description = g_strdup ("The client's city");
+ field->for_show = TRUE;
+ field->for_where = TRUE;
field->decode_table2 = g_strdup ("cities");
/*field->decode_fields1 = g_slist_append (field->decode_fields1, "id_cities");
field->decode_fields2 = g_slist_append (field->decode_fields2, "id");*/