/*open up a dialog for adding a contact.*/ extern void popup_add_contact(void) { GtkWidget *dialog_content_area = NULL, *contact_entry_field = NULL; GtkEntryBuffer *field_buffer = NULL; /*dialog*/ dialog_add_contact = gtk_dialog_new(); gtk_window_set_transient_for(GTK_WINDOW(dialog_add_contact), GTK_WINDOW(window) ); dialog_content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_add_contact)); /*entry*/ contact_entry_field = gtk_entry_new(); field_buffer = gtk_entry_buffer_new( NULL, 0 ); gtk_entry_set_buffer( GTK_ENTRY(contact_entry_field), GTK_ENTRY_BUFFER(field_buffer) ); /*start packing (buttons emit the "response" signal when clicked since they are in the action area)*/ gtk_box_pack_start( GTK_BOX(dialog_content_area), contact_entry_field, FALSE, FALSE, 0 ); gtk_dialog_add_button( GTK_DIALOG(dialog_add_contact), "Cancel", GTK_RESPONSE_CANCEL ); gtk_dialog_add_button( GTK_DIALOG(dialog_add_contact), "OK/Add...", GTK_RESPONSE_OK ); /*connect the "response" signal*/ g_signal_connect(GTK_DIALOG(dialog_add_contact), "response", G_CALLBACK(add_contact_cb), NULL); g_signal_connect_swapped(GTK_DIALOG(dialog_add_contact), "response", G_CALLBACK(gtk_widget_destroy), dialog_add_contact); /*I forgot it again... show the widgets*/ gtk_widget_show(dialog_add_contact); gtk_widget_show(contact_entry_field); return; }
void comma_clicked(GtkButton*w, GtkEntry *entry){ GtkEntryBuffer *buffer = gtk_entry_get_buffer(entry); gtk_entry_buffer_insert_text (buffer, -1,",", 1); gtk_entry_set_buffer(entry, buffer); }
/** * entry: the entry to set the buffer for * * Adds the secure egg_entry_buffer to the entry * **/ static void prepare_password_entry (GtkEntry *entry) { GtkEntryBuffer *buffer = egg_entry_buffer_new (); g_return_if_fail (entry); gtk_entry_set_buffer (entry, buffer); g_object_unref (buffer); }
void num6_clicked(GtkButton*w, GtkEntry *entry){ if(sign){ gtk_entry_set_text(entry, ""); } GtkEntryBuffer *buffer = gtk_entry_get_buffer(entry); gtk_entry_buffer_insert_text (buffer, -1,"6", 1); gtk_entry_set_buffer(entry, buffer); sign = 0; }
/* Get entry box text */ static void get_entry_text(struct elyapp *app, char **str) { GtkEntryBuffer *buf = gtk_entry_get_buffer(GTK_ENTRY(app->gui.widg)); const gchar *text = gtk_entry_buffer_get_text(buf); printf("~%s~\n", text); buf = gtk_entry_buffer_new(0, -1); gtk_entry_buffer_set_max_length(buf, app->text.maxchars); gtk_entry_set_buffer(GTK_ENTRY(app->gui.widg), buf); gtk_widget_destroy(app->gui.widg); *str = (char*)text; }
/* *************************** * ***** SETUP ENTRY BOX ***** * *************************** */ static void setup_entry(struct elyapp *app, char *tag) { TRACE(stdout, "Setting up %s entry box...", tag); if ( app->text.invis != NULL ) { gtk_entry_set_visibility(GTK_ENTRY(app->gui.widg), FALSE); gtk_entry_set_invisible_char(GTK_ENTRY(app->gui.widg), *app->text.invis); } GtkEntryBuffer *buf = gtk_entry_buffer_new(0, -1); gtk_entry_buffer_set_max_length(buf, app->text.maxchars); gtk_entry_set_buffer(GTK_ENTRY(app->gui.widg), buf); gtk_entry_set_placeholder_text(GTK_ENTRY(app->gui.widg), tag); TRACE(stdout, "Done setting up %s entry box.", tag); }