Commit ee1db88e2ef567fa77c433dce7a99d0c96daa749

Authored by perry.werneck@gmail.com
1 parent c03eb89e

Finalizando diálogo de configuração do host

Showing 1 changed file with 44 additions and 5 deletions   Show diff stats
src/pw3270/hostdialog.c
@@ -69,7 +69,39 @@ @@ -69,7 +69,39 @@
69 gtk_label_set_mnemonic_widget(GTK_LABEL(label),widget); 69 gtk_label_set_mnemonic_widget(GTK_LABEL(label),widget);
70 } 70 }
71 71
72 - void hostname_action(GtkAction *action, GtkWidget *widget) 72 + static void systype_changed(GtkComboBox *widget, int *iHostType)
  73 + {
  74 + GValue value = { 0, };
  75 + GtkTreeIter iter;
  76 +
  77 + if(!gtk_combo_box_get_active_iter(widget,&iter))
  78 + return;
  79 +
  80 + gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value);
  81 +
  82 + *iHostType = g_value_get_int(&value);
  83 +
  84 + trace("Selected host type: %s",host_type[*iHostType].name);
  85 +
  86 + }
  87 +
  88 + static void color_changed(GtkComboBox *widget, int *iColorTable)
  89 + {
  90 + GValue value = { 0, };
  91 + GtkTreeIter iter;
  92 +
  93 + if(!gtk_combo_box_get_active_iter(widget,&iter))
  94 + return;
  95 +
  96 + gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value);
  97 +
  98 + *iColorTable = g_value_get_int(&value);
  99 +
  100 + trace("Selected color type: %d",(int) colortable[*iColorTable].colors);
  101 +
  102 + }
  103 +
  104 + void hostname_action(GtkAction *action, GtkWidget *widget)
73 { 105 {
74 const gchar * title = g_object_get_data(G_OBJECT(action),"title"); 106 const gchar * title = g_object_get_data(G_OBJECT(action),"title");
75 gchar * cfghost = get_string_from_config("host","uri",""); 107 gchar * cfghost = get_string_from_config("host","uri","");
@@ -144,13 +176,15 @@ @@ -144,13 +176,15 @@
144 gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(host_type[f].description), 1, f, -1); 176 gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(host_type[f].description), 1, f, -1);
145 177
146 if(!g_ascii_strcasecmp(host_type[f].name,str)) 178 if(!g_ascii_strcasecmp(host_type[f].name,str))
147 - gtk_combo_box_set_active(GTK_COMBO_BOX(widget),f); 179 + gtk_combo_box_set_active(GTK_COMBO_BOX(widget),iHostType=f);
148 } 180 }
149 181
150 g_free(str); 182 g_free(str);
151 183
152 set_row(row++,widget,container,_("System _type:")); 184 set_row(row++,widget,container,_("System _type:"));
153 185
  186 + g_signal_connect(G_OBJECT(widget),"changed",G_CALLBACK(systype_changed),&iHostType);
  187 +
154 } 188 }
155 else 189 else
156 { 190 {
@@ -175,18 +209,20 @@ @@ -175,18 +209,20 @@
175 GtkTreeIter iter; 209 GtkTreeIter iter;
176 210
177 gtk_list_store_append((GtkListStore *) model,&iter); 211 gtk_list_store_append((GtkListStore *) model,&iter);
178 - gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(colortable[f].description), 1, (int) colortable[f].colors, -1); 212 + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(colortable[f].description), 1, (int) f, -1);
179 213
180 if(colortable[f].colors == colors) 214 if(colortable[f].colors == colors)
181 - gtk_combo_box_set_active(GTK_COMBO_BOX(widget),f); 215 + gtk_combo_box_set_active(GTK_COMBO_BOX(widget),iColorTable=f);
182 } 216 }
183 217
184 set_row(row++,widget,container,_("_Color table:")); 218 set_row(row++,widget,container,_("_Color table:"));
185 219
  220 + g_signal_connect(G_OBJECT(widget),"changed",G_CALLBACK(color_changed),&iColorTable);
  221 +
186 } 222 }
187 else 223 else
188 { 224 {
189 - #warning TODO: Configurar tabela de cores de acordo com systype 225 + #warning TODO: Configurar tabela de cores de acordo com colortype
190 } 226 }
191 227
192 gtk_container_add(GTK_CONTAINER(expander),GTK_WIDGET(container)); 228 gtk_container_add(GTK_CONTAINER(expander),GTK_WIDGET(container));
@@ -244,6 +280,9 @@ @@ -244,6 +280,9 @@
244 280
245 gtk_widget_set_visible(dialog,FALSE); 281 gtk_widget_set_visible(dialog,FALSE);
246 282
  283 + set_string_to_config("host","systype",host_type[iHostType].name);
  284 + set_integer_to_config("host","colortype",colortable[iColorTable].colors);
  285 +
247 v3270_set_session_options(widget,host_type[iHostType].option); 286 v3270_set_session_options(widget,host_type[iHostType].option);
248 v3270_set_session_color_type(widget,colortable[iColorTable].colors); 287 v3270_set_session_color_type(widget,colortable[iColorTable].colors);
249 288