Hello!
I have 2 questions:
1) I have a dialog with a entry.
In this entry the operator should enter only digits (0-9)
Is it possible to set a filter over the entry? or should I use the "focus-out-event"?
I would rather just activate num keys.
2) I have another dialog, made by the function ts_get_user_entry. It is a modal dialog
When I call it with the commands
Code:
char newFolderName[50];
ts_get_user_entry("Name of the new folder", newFolderName);
if (strlen(newFolderName) > 0) ....
the next command "if (strlen(newFolderName) > 0) " is executed before the operator ckicked on the OK button of the dialog.
I thought that modal dialogs holds the execution until the operator close it.
Can you see my error in the next code? Isn't it a modal dialog?
Thanks a lot in advance for your help
MBoerner
Code:
/**
* instead of the deprecated gtk_input_dialog
* @param message message to show in the dialog
* @param text text that the user will enter
*
*/
void ts_get_user_entry(const char *message, char *text)
{
GtkWidget *inputDialog;
GtkWidget *entry;
GtkEntryBuffer *entryBuffer;
GtkWidget *vbox;
entryBuffer = gtk_entry_buffer_new (NULL, 0);
entry = gtk_entry_new_with_buffer(GTK_ENTRY_BUFFER(entryBuffer));
gtk_entry_set_text(GTK_ENTRY(entry),"new folder");
inputDialog = gtk_dialog_new_with_buttons(message, NULL, GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT , NULL);
vbox = gtk_dialog_get_content_area (GTK_DIALOG(inputDialog));
gtk_dialog_add_button( (GtkDialog*)inputDialog,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL );
gtk_dialog_add_button( (GtkDialog*)inputDialog,
GTK_STOCK_OK, GTK_RESPONSE_OK );
gtk_box_pack_end(GTK_BOX(vbox), entry, FALSE, TRUE, 10);
gtk_dialog_set_default_response(GTK_DIALOG(inputDialog), GTK_RESPONSE_CANCEL);
gtk_widget_show_all(GTK_WIDGET(inputDialog));
gint result = gtk_dialog_run (GTK_DIALOG (inputDialog));
switch (result)
{
case GTK_RESPONSE_OK:
strcpy(text, gtk_entry_get_text(GTK_ENTRY(entry)));
break;
default:
text = NULL;
break;
}
gtk_widget_destroy (GTK_WIDGET(inputDialog));
}