forms: Use GtkGrid instead deprecated GtkTable/GtkAlignment

This commit is contained in:
Javier Jardón 2015-03-22 08:05:26 +00:00
parent 7c4cd1fc42
commit fcb28a3a14
2 changed files with 20 additions and 152 deletions

View File

@ -173,13 +173,12 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data)
{ {
GtkBuilder *builder = NULL; GtkBuilder *builder = NULL;
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *table; GtkWidget *grid;
GtkWidget *text; GtkWidget *text;
GtkWidget *button; GtkWidget *button;
GSList *tmp; GSList *tmp;
gint number_of_widgets = g_slist_length (forms_data->list);
int list_count = 0; int list_count = 0;
int combo_count = 0; int combo_count = 0;
int i = 0; int i = 0;
@ -221,123 +220,52 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data)
if (forms_data->dialog_text) if (forms_data->dialog_text)
gtk_label_set_markup (GTK_LABEL (text), g_strcompress (forms_data->dialog_text)); gtk_label_set_markup (GTK_LABEL (text), g_strcompress (forms_data->dialog_text));
table = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_table")); grid = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_grid"));
gtk_table_resize (GTK_TABLE (table), number_of_widgets, 2);
for (tmp = forms_data->list; tmp; tmp = tmp->next) { for (tmp = forms_data->list; tmp; tmp = tmp->next) {
ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data;
GtkWidget *label; GtkWidget *label;
GtkWidget *align;
label = gtk_label_new(zenity_value->option_value); label = gtk_label_new(zenity_value->option_value);
gtk_widget_set_halign (label, GTK_ALIGN_START);
align = gtk_alignment_new (0.0, 0.5, 0.0, 0.0); gtk_grid_attach (GTK_GRID (grid),
gtk_container_add (GTK_CONTAINER (align), label); label,
0, i,
gtk_table_attach (GTK_TABLE (table), 1, 1);
GTK_WIDGET (align),
0,
1,
i,
i+1,
GTK_FILL,
GTK_FILL,
0,
0);
switch(zenity_value->type) switch(zenity_value->type)
{ {
case ZENITY_FORMS_ENTRY: case ZENITY_FORMS_ENTRY:
zenity_value->forms_widget = gtk_entry_new(); zenity_value->forms_widget = gtk_entry_new();
gtk_table_attach (GTK_TABLE (table),
GTK_WIDGET (zenity_value->forms_widget),
1,
2,
i,
i+1,
GTK_EXPAND | GTK_FILL,
GTK_EXPAND | GTK_FILL,
0,
0);
break; break;
case ZENITY_FORMS_PASSWORD: case ZENITY_FORMS_PASSWORD:
zenity_value->forms_widget = gtk_entry_new(); zenity_value->forms_widget = gtk_entry_new();
gtk_entry_set_visibility(GTK_ENTRY(zenity_value->forms_widget), gtk_entry_set_visibility(GTK_ENTRY(zenity_value->forms_widget),
FALSE); FALSE);
gtk_table_attach (GTK_TABLE (table),
GTK_WIDGET (zenity_value->forms_widget),
1,
2,
i,
i+1,
GTK_EXPAND | GTK_FILL,
GTK_EXPAND | GTK_FILL,
0,
0);
break; break;
case ZENITY_FORMS_CALENDAR: case ZENITY_FORMS_CALENDAR:
zenity_value->forms_widget = gtk_calendar_new(); zenity_value->forms_widget = gtk_calendar_new();
gtk_alignment_set (GTK_ALIGNMENT (align), 0.0, 0.02, 0.0, 0.0);
align = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), zenity_value->forms_widget);
gtk_table_attach (GTK_TABLE (table),
GTK_WIDGET (align),
1,
2,
i,
i+1,
GTK_FILL,
GTK_FILL,
0,
0);
break; break;
case ZENITY_FORMS_LIST: case ZENITY_FORMS_LIST:
zenity_value->forms_widget = zenity_forms_create_and_fill_list (forms_data, list_count, zenity_value->forms_widget = zenity_forms_create_and_fill_list (forms_data, list_count,
zenity_value->option_value); zenity_value->option_value);
gtk_alignment_set (GTK_ALIGNMENT (align), 0.0, 0.02, 0.0, 0.0);
gtk_table_attach (GTK_TABLE (table),
GTK_WIDGET (zenity_value->forms_widget),
1,
2,
i,
i+1,
GTK_EXPAND | GTK_FILL,
GTK_EXPAND | GTK_FILL,
0,
0);
list_count++; list_count++;
break; break;
case ZENITY_FORMS_COMBO: case ZENITY_FORMS_COMBO:
zenity_value->forms_widget = zenity_forms_create_and_fill_combo (forms_data, combo_count); zenity_value->forms_widget = zenity_forms_create_and_fill_combo (forms_data, combo_count);
gtk_alignment_set (GTK_ALIGNMENT (align), 0.0, 0.02, 0.0, 0.0);
gtk_table_attach (GTK_TABLE (table),
GTK_WIDGET (zenity_value->forms_widget),
1,
2,
i,
i+1,
GTK_EXPAND | GTK_FILL,
GTK_EXPAND | GTK_FILL,
0,
0);
combo_count++; combo_count++;
break; break;
default: default:
zenity_value->forms_widget = gtk_entry_new(); zenity_value->forms_widget = gtk_entry_new();
gtk_table_attach (GTK_TABLE (table),
GTK_WIDGET (zenity_value->forms_widget),
1,
2,
i,
i+1,
GTK_EXPAND | GTK_FILL,
GTK_EXPAND | GTK_FILL,
0,
0);
break; break;
} }
gtk_grid_attach_next_to (GTK_GRID (grid),
GTK_WIDGET (zenity_value->forms_widget),
label,
GTK_POS_RIGHT,
1, 1);
i++; i++;
} }

View File

@ -606,75 +606,15 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label_xalign">0</property> <property name="label_xalign">0</property>
<child> <child>
<object class="GtkAlignment" id="alignment1"> <object class="GtkGrid" id="zenity_forms_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="top_padding">12</property> <property name="margin_left">12</property>
<property name="left_padding">12</property> <property name="margin_right">6</property>
<property name="right_padding">6</property> <property name="margin_top">12</property>
<child> <property name="margin_bottom">6</property>
<object class="GtkTable" id="zenity_forms_table"> <property name="row_spacing">6</property>
<property name="visible">True</property> <property name="column_spacing">10</property>
<property name="can_focus">False</property>
<property name="n_columns">2</property>
<property name="column_spacing">10</property>
<property name="row_spacing">6</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object> </object>
</child> </child>
<child type="label"> <child type="label">