Reputation: 3
I have a problem I need help with. I'm making a C program that will be able to encrypt and decrypt using either DES or RSA. For making a GUI mostly because the lack of a better option, I went with GTK, but I need some guidance on how to store text from an entry on pressing a button.
So if the user types in something to a given entry field and presses "Encrypt", I need to store what he wrote in somehow, as I need to make the actual encryption, but couldn't find a suitable command for this. The only thing I could do was to get it written to the console which is not really helpful, plus I need to get the actual encrypted message back to another Entry.
Upvotes: 0
Views: 3272
Reputation: 111
the best way to work with an editing widget like gtkTextView and this GtkEntry , use their buffer for getting data from user input and to send data from back end. For GtkEntry , you should use GtkEntryBuffer , there you can find functions to play with text.Whatever you insert in this buffer , will appear on GUI of GtkEntry. Use following functions for getting data and sending , To Get Data --> "gtk_entry_buffer_get_text ()" To Send Data --> "gtk_entry_buffer_set_text ()"
You can Add button labeled as send and add callback function in which you can get the data or send the data to or from GtkEntry.
Also for an encryption you can use input hints in GtkEntry where you can select password mode which help you to hide whatever you write or display in GtkEntry.
Upvotes: 2
Reputation: 2035
Easy, I understand that you know how to catch clicked signal for your button, in your callback:
1.- Grab the user input with gtk_label_get_text. Since the function returns a const string, you need to make a copy of it with functions like g_strdup or save it in another buffer to process the encryption.
2.- Encrypt the string.
3.- Send back the encrypted string with gtk_label_set_text
Upvotes: 0