Hi,
This looks like it should work OK. If you are using C++ there is also the option of using the C++ bindings which may be useful if you prefer that way of programming. It is called gtkmm and you sample code would look like this if I used it
Code:
void show_entry_dialog()
{
Gtk::Dialog dialog;
Gtk::Entry entry;
dialog.add_button(Gtk::StockID(Gtk::Stock::OK), Gtk::RESPONSE_OK);
dialog.add_button(Gtk::StockID(Gtk::Stock::CANCEL), Gtk::RESPONSE_CANCEL);
dialog.get_content_area()->add(entry);
dialog.show_all();
string entry_line; // variable for entered text
switch(dialog.run())
{
case Gtk::RESPONSE_OK:
std::cout << "OK was clicked\n";
entry_line = entry.get_text();
// TODO: validation for entry_line
if(entry_line.length() == 0)
{
std::cout << "Line is to short. Nothing to passing\n";
break;
}
std::cout << "Contact dialog passed text from entry: "
<< entry_line << endl;
contact_list_add_item(contactlist, entry_line.c_str());
break;
case Gtk::RESPONSE_CANCEL:
std::cout << "CANCEL was clicked\n"; break;
default:
std::cout << "Undefined. Perhaps dialog was closed\n"; break;
}
}