/* NB: assumes gui_mode_switchl() will call gui_relation_update() */ GtkWidget *gui_auto_spin(gchar *text, gdouble *value, gdouble min, gdouble max, gdouble step, gpointer callback, gpointer arg, GtkWidget *box) { GtkWidget *spin; struct model_pak *model; model = sysenv.active_model; g_assert(model != NULL); /* create the text/spinner combo */ spin = new_spinner(text, min, max, step, callback, arg, box); /* set up a relationship */ gui_relation_submit(spin, AUTO_SPIN, value, FALSE, model); /* callback to set the variable to match the widget */ g_signal_connect(GTK_OBJECT(spin), "value-changed", (gpointer) gui_relation_set_value, NULL); /* callback to remove the variable <-> widget relation */ g_signal_connect(GTK_OBJECT(spin), "destroy", GTK_SIGNAL_FUNC(gui_relation_destroy), NULL); return(spin); }
void space_image_widget_setup(GtkWidget *box) { gint i; GtkWidget *table, *label; /* use table for nice spacing */ table = gtk_table_new(3, 4, FALSE); gtk_box_pack_start(GTK_BOX(box), table, FALSE, FALSE, 0); /* image directions */ label = gtk_label_new ("-"); gtk_table_attach_defaults(GTK_TABLE(table),label,1,2,0,1); label = gtk_label_new ("+"); gtk_table_attach_defaults(GTK_TABLE(table),label,2,3,0,1); /* labels and spinners */ for (i=0 ; i<3 ; i++) { /* negative direction */ image_spin[2*i] = new_spinner(NULL, 0, 10, 1, cb_space_image_spinner, GINT_TO_POINTER(2*i), NULL); /* TODO - set these to 1, when fractional periodic images are working */ gtk_spin_button_set_digits(GTK_SPIN_BUTTON(image_spin[2*i]), 0); gtk_table_attach_defaults(GTK_TABLE(table), image_spin[2*i], 1, 2, i+1, i+2); /* positive direction */ image_spin[2*i+1] = new_spinner(NULL, 1, 10, 1, cb_space_image_spinner, GINT_TO_POINTER(2*i+1), NULL); /* TODO - set these to 1, when fractional periodic images are working */ gtk_spin_button_set_digits(GTK_SPIN_BUTTON(image_spin[2*i+1]), 0); gtk_table_attach_defaults(GTK_TABLE(table), image_spin[2*i+1], 2, 3, i+1, i+2); } /* set the spinner values */ gui_refresh(GUI_MODEL_PROPERTIES); }
/* direct correlation between value and spinner */ GtkWidget *gui_direct_spin(gchar *text, gdouble *value, gdouble min, gdouble max, gdouble step, gpointer callback, gpointer arg, GtkWidget *box) { gint size=0; gdouble digits; GtkWidget *spin; struct model_pak *model; model = sysenv.active_model; /* create the text/spinner combo */ spin = new_spinner(text, min, max, step, NULL, NULL, box); /* HACK - cope with GTK underestimating the size needed to display spin values */ /* TODO - examine sig fig of *value to get dp */ digits = log10(step); if (digits < 0.0) { digits -= 0.9; size = 3 + fabs(digits); } if (size < 5) size = 5; gtk_widget_set_size_request(spin, sysenv.gtk_fontsize*size, -1); /* printf("%f : %f -> %f (%d)\n", max, step, digits, size); gtk_widget_set_size_request(spin, sysenv.gtk_fontsize*5, -1); */ /* set up a relationship */ gui_relation_submit(spin, AUTO_SPIN, value, TRUE, model); /* callback to set the variable to match the widget */ g_signal_connect(GTK_OBJECT(spin), "value-changed", GTK_SIGNAL_FUNC(gui_relation_set_value), model); /* callback to remove the variable <-> widget relation */ g_signal_connect(GTK_OBJECT(spin), "destroy", GTK_SIGNAL_FUNC(gui_relation_destroy), NULL); /* connect after, so all updates done before user callback is invoked */ if (callback) g_signal_connect_after(GTK_OBJECT(spin), "value-changed", GTK_SIGNAL_FUNC(callback), arg); return(spin); }
void siesta_animation_dialog(GtkWidget *w, struct model_pak *model) { GList *list; GtkWidget *window, *box, *hbox, *hbox2, *vbox, *label, *hscale, *entry, *button, *spin; gpointer dialog; g_assert(model != NULL); /* don't recalculate modes if already done */ if (!model->siesta.vibration_calc_complete) if (siesta_phonon_calc(model)) return; /* request a dialog */ dialog = dialog_request(100, "Vibrational viewer", NULL, NULL, model); if (!dialog) return; window = dialog_window(dialog); box = gtk_vbox_new(TRUE, 0); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), box); /* phonon selection */ vbox = gui_frame_vbox(NULL, FALSE, FALSE, box); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); /* phonon frequency */ label = gtk_label_new("Frequency "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); entry = gtk_entry_new_with_max_length(LINELEN); gtk_entry_set_text(GTK_ENTRY(entry), " "); gtk_entry_set_editable(GTK_ENTRY(entry), FALSE); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); dialog_child_set(dialog, "phonon_entry", entry); gui_button(" < ", gui_siesta_mode_prev, dialog, hbox, FF); gui_button(" > ", gui_siesta_mode_next, dialog, hbox, FF); /* phonon slider */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); hscale = gtk_hscale_new_with_range(1.0, model->siesta.num_animations, 1.0); gtk_box_pack_start(GTK_BOX(hbox), hscale, TRUE, TRUE, 0); dialog_child_set(dialog, "phonon_slider", hscale); g_signal_connect(GTK_OBJECT(hscale), "value_changed", GTK_SIGNAL_FUNC(gui_siesta_slider_changed), dialog); /* phonon display options */ vbox = gui_frame_vbox(NULL, FALSE, FALSE, box); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); button = new_check_button("Show eigenvectors", gui_siesta_mode_show, dialog, FALSE, hbox); dialog_child_set(dialog, "phonon_toggle", button); spin = new_spinner("Eigenvector scaling", 0.1, 9.9, 0.1, gui_siesta_mode_show, dialog, vbox); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), 4.0); dialog_child_set(dialog, "phonon_scaling", spin); spin = new_spinner("Animation resolution", 5.0, 50.0, 1.0, NULL, NULL, vbox); dialog_child_set(dialog, "phonon_resolution", spin); /* phonon mode animation */ vbox = gui_frame_vbox(NULL, FALSE, FALSE, box); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new("Animate mode "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); hbox2 = gtk_hbox_new(FALSE, 0); gtk_box_pack_end(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0); gui_icon_button("GDIS_PLAY", NULL, siesta_phonon_start, dialog, hbox2); gui_icon_button("GDIS_STOP", NULL, siesta_phonon_stop, dialog, hbox2); /* phonon mode movie generation */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new("Create movie "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); entry = gtk_entry_new_with_max_length(LINELEN); gtk_entry_set_text(GTK_ENTRY(entry), "movie_name"); gtk_entry_set_editable(GTK_ENTRY(entry), TRUE); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); dialog_child_set(dialog, "phonon_movie_name", entry); /* movie type */ list = NULL; list = g_list_append(list, "gif"); list = g_list_append(list, "mpg"); entry = gui_pulldown_new(NULL, list, FALSE, hbox); dialog_child_set(dialog, "phonon_movie_type", entry); gui_button_x(NULL, siesta_phonon_movie, dialog, hbox); /* init and display */ gui_siesta_frequency_set(dialog); gtk_widget_show_all(window); }