<property name="position">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkButtonBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">5</property>
+ <property name="layout_style">center</property>
+ <child>
+ <object class="GtkToggleButton" id="togglebutton1">
+ <property name="label" translatable="yes">Disable validators</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="togglebutton2">
+ <property name="label" translatable="yes">Disable filters</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
</object>
/*
- * Copyright (C) 2016 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2016-2017 Andrea Zagli <azagli@libero.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <libzakformgtk/libzakformgtk.h>
#include <libzakformini/libzakformini.h>
+GtkBuilder *builder;
+
GtkWidget *w;
ZakFormGtkForm *form;
insert_clicked (GtkButton *button,
gpointer user_data)
{
- zak_form_form_insert (ZAK_FORM_FORM (form), ZAK_FORM_IPROVIDER (provider));
+ if (zak_form_gtk_form_is_valid (form, w))
+ {
+ zak_form_form_insert (ZAK_FORM_FORM (form), ZAK_FORM_IPROVIDER (provider));
+ }
}
void
update_clicked (GtkButton *button,
gpointer user_data)
{
- zak_form_form_update (ZAK_FORM_FORM (form), ZAK_FORM_IPROVIDER (provider));
+ if (zak_form_gtk_form_is_valid (form, w))
+ {
+ zak_form_form_update (ZAK_FORM_FORM (form), ZAK_FORM_IPROVIDER (provider));
+ }
}
void
}
}
+void
+validators_toggled (GtkToggleButton *button,
+ gpointer user_data)
+{
+ GPtrArray *ar;
+ guint i;
+
+ GPtrArray *ar_el;
+ guint j;
+
+ ar = zak_form_form_get_validators (ZAK_FORM_FORM (form));
+ for (i = 0; i < ar->len; i++)
+ {
+ zak_form_validator_set_enabled ((ZakFormValidator *)g_ptr_array_index (ar, i),
+ !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton1"))));
+ }
+
+ ar_el = zak_form_form_get_elements (ZAK_FORM_FORM (form));
+ for (i = 0; i < ar_el->len; i++)
+ {
+ ar = zak_form_element_get_validators (ZAK_FORM_ELEMENT ((ZakFormElement *)g_ptr_array_index (ar_el, i)));
+ for (j = 0; j < ar->len; j++)
+ {
+ zak_form_element_validator_set_enabled ((ZakFormElementValidator *)g_ptr_array_index (ar, j),
+ !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton1"))));
+ }
+
+ ar = zak_form_element_get_filters (ZAK_FORM_ELEMENT ((ZakFormElement *)g_ptr_array_index (ar_el, i)));
+ for (j = 0; j < ar->len; j++)
+ {
+ zak_form_element_filter_set_enabled ((ZakFormElementFilter *)g_ptr_array_index (ar, j),
+ !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton2"))));
+ }
+ }
+}
+
+void
+filters_toggled (GtkToggleButton *button,
+ gpointer user_data)
+{
+ GPtrArray *ar;
+ guint i;
+
+ GPtrArray *ar_el;
+ guint j;
+
+ ar_el = zak_form_form_get_elements (ZAK_FORM_FORM (form));
+ for (i = 0; i < ar_el->len; i++)
+ {
+ ar = zak_form_element_get_filters (ZAK_FORM_ELEMENT ((ZakFormElement *)g_ptr_array_index (ar_el, i)));
+ for (j = 0; j < ar->len; j++)
+ {
+ zak_form_element_filter_set_enabled ((ZakFormElementFilter *)g_ptr_array_index (ar, j),
+ !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton2"))));
+ }
+ }
+}
+
int
main (int argc, char *argv[])
{
- GtkBuilder *builder;
-
gtk_init (&argc, &argv);
builder = gtk_builder_new ();
G_CALLBACK (is_valid_clicked), NULL);
g_signal_connect (gtk_builder_get_object (builder, "button5"), "clicked",
G_CALLBACK (is_changed_clicked), NULL);
+ g_signal_connect (gtk_builder_get_object (builder, "togglebutton1"), "toggled",
+ G_CALLBACK (validators_toggled), NULL);
+ g_signal_connect (gtk_builder_get_object (builder, "togglebutton2"), "toggled",
+ G_CALLBACK (filters_toggled), NULL);
form = zak_form_gtk_form_new ();
zak_form_gtk_form_set_gtkbuilder (form, builder);