void gui_job_dialog(void) { gpointer dialog; GtkWidget *window, *notebook, *page, *label; dialog = dialog_request(777, "Remote job manager", NULL, NULL, NULL); if (!dialog) return; window = dialog_window(dialog); gtk_widget_set_size_request(window, 400, 400); notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), notebook); gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE); /* run type page */ page = gtk_vbox_new(FALSE, 0); label = gtk_label_new(" Hosts "); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label); gui_host_page(page, dialog); /* run type page */ page = gtk_vbox_new(FALSE, 0); label = gtk_label_new(" Jobs "); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label); gui_job_page(page); gtk_widget_show_all(window); /* FIXME - active host */ if (sysenv.host_list) gui_host_update(sysenv.host_list->data, dialog); }
void file_dialog(gchar *title, gchar *name, gint type, gpointer secondary_handler(gchar *, struct model_pak *), gint filter) { gpointer dialog; GSList *flist; GList *elist; GtkWidget *window, *swin, *hbox, *combo, *label; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeSelection *select; struct model_pak *data=NULL; struct file_pak *fdata; /* if save type, check we have a loaded model */ if (secondary_handler == (gpointer) file_save_as) { data = sysenv.active_model; if (!data) return; } /* get a dialog if possible */ dialog = dialog_request(FILE_SELECT, "File dialog", NULL, NULL, NULL); if (!dialog) return; window = dialog_window(dialog); /* make and set up the dialog window */ gtk_window_set_title(GTK_WINDOW(window), title); gtk_window_set_default_size(GTK_WINDOW(window), 600, 400); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_container_set_border_width(GTK_CONTAINER(GTK_BOX(GTK_DIALOG(window)->vbox)),10); /* TOP ROW - cwd printed */ hbox = gtk_hbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),hbox,FALSE,FALSE,0); label = gtk_label_new("Current path: "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); curr_path = gtk_label_new("dummy"); gtk_box_pack_start(GTK_BOX(hbox), curr_path, FALSE, FALSE, 0); /* option to save as cartesian or fractional coords */ if (secondary_handler == (gpointer) file_save_as) { g_assert(data != NULL); if (data->periodic) { hbox = gtk_hbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), hbox,FALSE,FALSE,0); new_check_button("Save as cartesian coordinates", toggle_save_type, data, !data->fractional, hbox); } } /* SECOND ROW - sub directory & file listings */ hbox = gtk_hbox_new(FALSE, PANEL_SPACING); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), hbox, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox), PANEL_SPACING); /* scrolled model pane */ swin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(hbox), swin, TRUE, TRUE, 0); /* path treestore/treeview */ file_path_ts = gtk_list_store_new(FILE_PATH_NCOLS, G_TYPE_STRING); file_path_tv = gtk_tree_view_new_with_model(GTK_TREE_MODEL(file_path_ts)); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), file_path_tv); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes("Tree", renderer, "text", FILE_PATH, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(file_path_tv), column); /* NB: use this method instead of selections to handle events */ /* as selections will core dump if the handler clears the store */ g_signal_connect(file_path_tv, "row_activated", G_CALLBACK(file_path_activate), NULL); /* scrolled model pane */ swin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(hbox), swin, TRUE, TRUE, 0); /* filename treestore/treeview */ file_name_ts = gtk_list_store_new(FILE_NAME_NCOLS, G_TYPE_STRING); file_name_tv = gtk_tree_view_new_with_model(GTK_TREE_MODEL(file_name_ts)); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), file_name_tv); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes("Files", renderer, "text", FILE_NAME, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(file_name_tv), column); /* setup the selection handler */ select = gtk_tree_view_get_selection(GTK_TREE_VIEW(file_name_tv)); gtk_tree_selection_set_mode(select, GTK_SELECTION_BROWSE); /* single click - update entry */ g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(cb_file_name_changed), NULL); /* double click - automatic load */ if (secondary_handler == (gpointer) file_load) g_signal_connect(file_name_tv, "row_activated", G_CALLBACK(file_name_activate), NULL); /* THIRD ROW - filename currently selected & file extension filter */ hbox = gtk_hbox_new(FALSE, PANEL_SPACING); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), hbox, FALSE, FALSE, 0); /* filename */ file_name = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), file_name, TRUE, TRUE, 0); if (name) gtk_entry_set_text(GTK_ENTRY(file_name), name); gtk_entry_set_editable(GTK_ENTRY(file_name), TRUE); /* hook a <CR> event to the load action */ g_signal_connect(GTK_OBJECT(file_name), "activate", GTK_SIGNAL_FUNC(file_event_handler), secondary_handler); /* build the recognized extension list */ elist = NULL; flist = sysenv.file_list; while(flist != NULL) { fdata = flist->data; /* include in menu? */ if (fdata->menu) elist = g_list_append(elist, fdata->label); flist = g_slist_next(flist); } /* combo box for file filter */ combo = gtk_combo_new(); gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo)->entry), FALSE); gtk_combo_set_popdown_strings(GTK_COMBO(combo), elist); /* set the currently selected type (BEFORE the changed event is connected) */ fdata = get_file_info(GINT_TO_POINTER(filter), BY_FILE_ID); if (fdata) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), fdata->label); gtk_box_pack_start(GTK_BOX (hbox), combo, TRUE, TRUE, 0); g_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed", GTK_SIGNAL_FUNC(type_change), NULL); gtk_widget_set_size_request(combo, 6*sysenv.gtk_fontsize, -1); /* terminating buttons */ switch (type) { case FILE_LOAD: gui_stock_button(GTK_STOCK_OPEN, file_event_handler, secondary_handler, GTK_DIALOG(window)->action_area); break; case FILE_SAVE: gui_stock_button(GTK_STOCK_SAVE, file_event_handler, secondary_handler, GTK_DIALOG(window)->action_area); break; } gui_stock_button(GTK_STOCK_CANCEL, dialog_destroy, dialog, GTK_DIALOG(window)->action_area); /* all done */ gtk_widget_show_all(window); sysenv.file_type = filter; update_file_pane(); }
void gui_help_dialog(void) { gpointer dialog; GtkCellRenderer *r; GtkTreeViewColumn *c; GtkListStore *list; GtkTreeSelection *select; GtkWidget *window, *swin, *hbox, *tree, *view; /* create dialog */ dialog = dialog_request(MANUAL, "Manual", NULL, NULL, NULL); if (!dialog) return; window = dialog_window(dialog); gtk_window_set_default_size(GTK_WINDOW(window), 800, 500); /* split pane display */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), hbox, TRUE, TRUE, 1); /* left pane - topics browser */ swin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_NEVER, GTK_POLICY_NEVER); gtk_box_pack_start(GTK_BOX(hbox), swin, FALSE, TRUE, 0); /* list */ list = gtk_list_store_new(1, G_TYPE_STRING); tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list)); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), tree); r = gtk_cell_renderer_text_new(); c = gtk_tree_view_column_new_with_attributes(" ", r, "text", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), c); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE); /* auto sort the topic list */ gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(GTK_TREE_MODEL(list)), help_sort_topics, NULL, NULL); gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(GTK_TREE_MODEL(list)), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING); /* set the width of the topics pane */ gtk_widget_set_size_request(swin, 15*sysenv.gtk_fontsize, -1); /* right pane - text */ swin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(hbox), swin, TRUE, TRUE, 0); view = gtk_text_view_new(); gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE); gtk_container_add(GTK_CONTAINER(swin), view); /* configure the text viewing area */ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD); /* NB: GTK_JUSTIFY_FILL was not supported at the time this was written */ /* gtk_text_view_set_justification(GTK_TEXT_VIEW(view), GTK_JUSTIFY_FILL); */ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), PANEL_SPACING); gtk_text_view_set_right_margin(GTK_TEXT_VIEW(view), PANEL_SPACING); /* NB: these are associated with the text buffer and must be reallocated each */ /* time a new text buffer is created */ help_tag_bold=NULL; help_tag_italic=NULL; help_tag_invisible=NULL; help_tag_fixed=NULL; /* topic selection handler */ select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(gui_help_topic_selected), view); /* terminating button */ gui_stock_button(GTK_STOCK_CLOSE, dialog_destroy, dialog, GTK_DIALOG(window)->action_area); /* populate the manual page */ gui_help_refresh(list); /* expose the dialog */ gtk_widget_show_all(window); }
void gui_dock_dialog(void) { gchar *text; gpointer dialog; GtkWidget *window, *label, *spin; GtkWidget *frame, *vbox, *vbox1, *hbox, *hbox2, *vbox_left, *vbox_right; struct model_pak *model; /* checks */ model = sysenv.active_model; if (!model) { gui_text_show(ERROR, "Please load a surface first.\n"); return; } if (model->periodic != 2) { gui_text_show(ERROR, "Your model is not a surface.\n"); return; } /* request a dialog */ dialog = dialog_request(DOCKING, "Docking setup", NULL, NULL, model); if (!dialog) return; window = dialog_window(dialog); /* title display */ frame = gtk_frame_new(NULL); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), frame, FALSE, FALSE, 0); vbox = gtk_vbox_new(TRUE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_container_set_border_width(GTK_CONTAINER(vbox), PANEL_SPACING); hbox = gtk_hbox_new(FALSE, PANEL_SPACING); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); text = g_strdup_printf("Docking setup: %s", model->basename); label = gtk_label_new(text); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); g_free(text); /* NEW - split pane display */ hbox2 = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), hbox2, TRUE, TRUE, 0); vbox_left = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox2), vbox_left, FALSE, FALSE, PANEL_SPACING); vbox_right = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox2), vbox_right, FALSE, FALSE, PANEL_SPACING); /* translational sampling */ frame = gtk_frame_new(NULL); gtk_box_pack_start(GTK_BOX(vbox_left), frame, FALSE, FALSE, 0); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox); vbox1 = gtk_vbox_new(FALSE, 0); gui_direct_check("Translational sampling", &dock_grid_on, dock_toggle_refresh, vbox1, vbox); gtk_box_pack_start(GTK_BOX(vbox), vbox1, FALSE, FALSE, PANEL_SPACING); /* axes sampling fraction */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, PANEL_SPACING); label = gtk_label_new("axes fractions"); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, PANEL_SPACING); spin = gui_direct_spin(NULL, &dock_cell[0], 0.0, 1.0, 0.05, NULL, NULL, NULL); gtk_box_pack_end(GTK_BOX(hbox), spin, FALSE, FALSE, PANEL_SPACING); spin = gui_direct_spin(NULL, &dock_cell[1], 0.0, 1.0, 0.05, NULL, NULL, NULL); gtk_box_pack_end(GTK_BOX(hbox), spin, FALSE, FALSE, PANEL_SPACING); /* grid points */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, PANEL_SPACING); label = gtk_label_new("grid size"); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, PANEL_SPACING); spin = gui_direct_spin(NULL, &dock_grid[0], 1, 10, 1, NULL, NULL, NULL); gtk_box_pack_end(GTK_BOX(hbox), spin, FALSE, FALSE, PANEL_SPACING); spin = gui_direct_spin(NULL, &dock_grid[1], 1, 10, 1, NULL, NULL, NULL); gtk_box_pack_end(GTK_BOX(hbox), spin, FALSE, FALSE, PANEL_SPACING); /* rotational sampling */ frame = gtk_frame_new(NULL); gtk_box_pack_start(GTK_BOX(vbox_left), frame, TRUE, TRUE, 0); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox); vbox1 = gtk_vbox_new(TRUE, PANEL_SPACING); gui_direct_check("Rotational sampling", &dock_rotate_on, dock_toggle_refresh, vbox1, vbox); gtk_box_pack_start(GTK_BOX(vbox), vbox1, FALSE, FALSE, PANEL_SPACING); gui_direct_spin(" x axis ", &dock_rotate[0], 1, 60, 1, NULL, NULL, vbox1); gui_direct_spin(" y axis ", &dock_rotate[1], 1, 60, 1, NULL, NULL, vbox1); gui_direct_spin(" z axis ", &dock_rotate[2], 1, 60, 1, NULL, NULL, vbox1); /* rigid body docking */ frame = gtk_frame_new(NULL); gtk_box_pack_start(GTK_BOX(vbox_right), frame, FALSE, FALSE, 0); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox); vbox1 = gtk_vbox_new(TRUE, PANEL_SPACING); gui_direct_check("Treat as a rigid body", &dock_rigid_on, dock_toggle_refresh, vbox1, vbox); gtk_box_pack_start(GTK_BOX(vbox), vbox1, FALSE, FALSE, PANEL_SPACING); gui_direct_check("Allow translation in x", &dock_rigid_x, NULL, NULL, vbox1); gui_direct_check("Allow translation in y", &dock_rigid_y, NULL, NULL, vbox1); gui_direct_check("Allow translation in z", &dock_rigid_z, NULL, NULL, vbox1); /* control options */ frame = gtk_frame_new(NULL); gtk_box_pack_start(GTK_BOX(vbox_right), frame, FALSE, FALSE, 0); vbox = gtk_vbox_new(TRUE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox); hbox = gtk_hbox_new(FALSE, PANEL_SPACING); gui_direct_check("Create project files then stop", &dock_no_execute, NULL, NULL, vbox); /* CURRRENT - executing the project has not been implemented yet */ gtk_widget_set_sensitive(GTK_WIDGET(vbox), FALSE); /* control buttons */ gui_stock_button(GTK_STOCK_EXECUTE, docking_project_create, model, GTK_DIALOG(window)->action_area); gui_stock_button(GTK_STOCK_CLOSE, dialog_destroy, dialog, GTK_DIALOG(window)->action_area); gtk_widget_show_all(window); }
void gui_analysis_dialog(void) { gpointer dialog; GtkWidget *window, *combo, *label; GtkWidget *frame, *main_hbox, *main_vbox, *hbox, *vbox; GtkWidget *gui_menu_calc, *gui_vbox_rdf; GSList *list, *item; GList *match_list=NULL, *calc_list=NULL; struct model_pak *model; struct analysis_pak *analysis; /* checks and setup */ model = sysenv.active_model; if (!model) return; if (!model->animation) return; if (analysis_init(model)) return; analysis = model->analysis; /* create new dialog */ dialog = dialog_request(MD_ANALYSIS, "MD analysis", NULL, NULL, model); if (!dialog) return; window = dialog_window(dialog); /* --- main box */ main_hbox = gtk_hbox_new(TRUE, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), main_hbox, TRUE, TRUE, 0); /* --- left pane */ main_vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(main_hbox), main_vbox, TRUE, TRUE, 0); /* --- analysis dialogs are specific to the active model when initiated */ frame = gtk_frame_new("Model"); gtk_box_pack_start(GTK_BOX(main_vbox), frame, FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(frame), PANEL_SPACING); hbox = gtk_hbox_new(TRUE, PANEL_SPACING); gtk_container_add(GTK_CONTAINER(frame), hbox); label = gtk_label_new(model->basename); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); /* --- calculation menu */ frame = gtk_frame_new("Calculate"); gtk_box_pack_start(GTK_BOX(main_vbox), frame, FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(frame), PANEL_SPACING); vbox = gtk_vbox_new(TRUE, PANEL_SPACING); gtk_container_add(GTK_CONTAINER(frame), vbox); /* --- menu items */ if (g_file_test(model->gulp.trj_file, G_FILE_TEST_EXISTS)) { calc_list = g_list_prepend(calc_list, "Potential E"); calc_list = g_list_prepend(calc_list, "Kinetic E"); calc_list = g_list_prepend(calc_list, "Temperature"); calc_list = g_list_prepend(calc_list, "VACF"); } else { calc_list = g_list_prepend(calc_list, "Measurements"); } calc_list = g_list_prepend(calc_list, "RDF"); calc_list = g_list_prepend(calc_list, "Pair count"); gui_menu_calc = gui_pulldown_new("Perform ", calc_list, FALSE, vbox); dialog_child_set(dialog, "gui_menu_calc", gui_menu_calc); /* --- right pane */ gui_vbox_rdf = gtk_vbox_new(FALSE, 0); dialog_child_set(dialog, "gui_vbox_rdf", gui_vbox_rdf); gtk_box_pack_start(GTK_BOX(main_hbox), gui_vbox_rdf, TRUE, TRUE, 0); /* --- interval setup */ frame = gtk_frame_new("Analysis Interval"); gtk_box_pack_start(GTK_BOX(gui_vbox_rdf), frame, FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(frame), PANEL_SPACING); vbox = gtk_vbox_new(TRUE, PANEL_SPACING); gtk_container_add(GTK_CONTAINER(frame), vbox); /* TODO - some warning about the RDF being valid only for < L/2? */ /* see Allan & Tildesley pg 199 */ gui_direct_spin("Start", &analysis->start, 0.0, 10.0*model->rmax, 0.1, NULL, NULL, vbox); gui_direct_spin("Stop", &analysis->stop, 0.1, 10.0*model->rmax, 0.1, NULL, NULL, vbox); gui_direct_spin("Step", &analysis->step, 0.1, model->rmax, 0.1, NULL, NULL, vbox); /* --- RDF atom setup */ frame = gtk_frame_new("Analysis Atoms"); gtk_box_pack_start(GTK_BOX(gui_vbox_rdf), frame, FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(frame), PANEL_SPACING); vbox = gtk_vbox_new(TRUE, PANEL_SPACING); gtk_container_add(GTK_CONTAINER(frame), vbox); /* setup unique element label list */ list = find_unique(LABEL, model); match_list = g_list_append(match_list, "Any"); for (item=list ; item ; item=g_slist_next(item)) { match_list = g_list_append(match_list, item->data); } g_slist_free(list); /* match 1 */ combo = gtk_combo_new(); gtk_combo_set_popdown_strings(GTK_COMBO(combo), match_list); gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo)->entry), TRUE); gtk_box_pack_start(GTK_BOX(vbox), combo, TRUE, TRUE, 0); g_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed", GTK_SIGNAL_FUNC(md_atom_changed), (gpointer) &analysis->atom1); /* match 2 */ combo = gtk_combo_new(); gtk_combo_set_popdown_strings(GTK_COMBO(combo), match_list); gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo)->entry), TRUE); gtk_box_pack_start(GTK_BOX(vbox), combo, TRUE, TRUE, 0); g_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed", GTK_SIGNAL_FUNC(md_atom_changed), (gpointer) &analysis->atom2); /* terminating buttons */ gui_stock_button(GTK_STOCK_EXECUTE, exec_analysis_task, dialog, GTK_DIALOG(window)->action_area); gui_stock_button(GTK_STOCK_CLOSE, dialog_destroy, dialog, GTK_DIALOG(window)->action_area); gtk_widget_show_all(window); }
void gui_animate_dialog(void) { gpointer dialog; GtkWidget *window, *main_vbox, *table, *vbox, *hbox; GtkWidget *notebook, *page, *label, *entry, *scale; GList *list; /* prevent recording whilst in animation */ gui_mode_switch(FREE); /* dialog setup */ dialog = dialog_request(ANIM, "Animation and Rendering", NULL, NULL, NULL); if (!dialog) return; window = dialog_window(dialog); gtk_widget_set_size_request(window, 350, -1); /* notebook frame */ main_vbox = gtk_vbox_new(FALSE, PANEL_SPACING); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), main_vbox); /* create notebook */ vbox = gui_frame_vbox(NULL, FALSE, FALSE, main_vbox); notebook = gtk_notebook_new(); gtk_box_pack_start(GTK_BOX(vbox),notebook,FALSE,TRUE,0); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP); gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), TRUE); /* page */ page = gtk_vbox_new(FALSE, PANEL_SPACING); label = gtk_label_new("Control"); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label); vbox = gtk_vbox_new(FALSE, PANEL_SPACING); gtk_box_pack_start(GTK_BOX(page),vbox,FALSE,FALSE,0); /* format pulldown */ animate_phonons=FALSE; list = NULL; list = g_list_append(list, "Frames"); list = g_list_append(list, "Phonons"); hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new("Display "); gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0); entry = gui_pulldown_new(NULL, list, 0, hbox); g_list_free(list); g_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(gui_animate_type_change), (gpointer) entry); gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0); /* phonon options */ box_phonon_options = gtk_vbox_new(FALSE, PANEL_SPACING); gtk_box_pack_start(GTK_BOX(vbox),box_phonon_options,FALSE,FALSE,0); gui_direct_spin("Phonon scaling ", &sysenv.render.phonon_scaling, 0.1, 9.9, 0.1, NULL, NULL, box_phonon_options); gui_direct_spin("Phonon resolution ", &sysenv.render.phonon_resolution, 10.0, 100.0, 1.0, NULL, NULL, box_phonon_options); gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0); /* CURRENT - FPS */ gui_direct_spin("Apparent FPS for animation ", &gui_animate_fps, 1, 50, 1, NULL, NULL, vbox); /* connectivity options */ gui_direct_check("Recalculate connectivity", &sysenv.render.connect_redo, NULL, NULL, vbox); /* gui_checkbox("Don't recalculate scale", NULL, vbox); gui_checkbox("Loop", NULL, vbox); */ /* actions at start of each cycle */ /* new_radio_group(0, vbox, FF); button = add_radio_button("Confine atoms to PBC", (gpointer) atom_pbc, data); if (data->anim_confine == PBC_CONFINE_ATOMS) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); button = add_radio_button("Confine mols to PBC", (gpointer) mol_pbc, data); if (data->anim_confine == PBC_CONFINE_MOLS) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); button = add_radio_button("Cell confinement off", (gpointer) no_pbc, data); if (data->anim_confine == PBC_CONFINE_NONE) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); */ /* page */ page = gtk_vbox_new(FALSE, PANEL_SPACING); label = gtk_label_new("Render"); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label); vbox = gtk_vbox_new(FALSE, PANEL_SPACING); gtk_box_pack_start(GTK_BOX(page),vbox,FALSE,FALSE,0); gui_direct_spin("Width", &sysenv.render.width, 100, 2000, 100, NULL, NULL, vbox); gui_direct_spin("Height", &sysenv.render.height, 100, 2000, 100, NULL, NULL, vbox); gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0); gui_direct_check("Shadowless", &sysenv.render.shadowless, NULL, NULL, vbox); gui_direct_check("Create povray input then stop", &sysenv.render.no_povray_exec, NULL, NULL, vbox); gui_direct_check("Cleanup temporary files", &sysenv.render.no_keep_tempfiles, NULL, NULL, vbox); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0); gui_button(" Render ", gui_animate_render, NULL, hbox, TF); /* page */ page = gtk_vbox_new(FALSE, PANEL_SPACING); label = gtk_label_new("Movie"); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label); vbox = gtk_vbox_new(FALSE, PANEL_SPACING); gtk_box_pack_start(GTK_BOX(page),vbox,FALSE,FALSE,0); table = gtk_table_new(4, 4, FALSE); gtk_box_pack_start(GTK_BOX(vbox),table,FALSE,FALSE,0); /* name label */ label = gtk_label_new("Filename"); gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,1); /* name entry */ /* entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entry), sysenv.render.animate_file); */ entry = gui_text_entry(NULL, &sysenv.render.animate_file, TRUE, FALSE, NULL); gtk_table_attach_defaults(GTK_TABLE(table),entry,1,2,0,1); /* format label */ label = gtk_label_new("Format"); gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2); /* format pulldown */ list=NULL; list = g_list_append(list, "mpg"); list = g_list_append(list, "mp4"); list = g_list_append(list, "flv"); list = g_list_append(list, "avi"); hbox = gtk_hbox_new(FALSE, 0); entry_movie_type = gui_pulldown_new(NULL, list, 0, hbox); g_list_free(list); g_signal_connect(GTK_OBJECT(entry_movie_type), "changed", GTK_SIGNAL_FUNC(gui_animate_movie_type_change), (gpointer) entry); gtk_table_attach_defaults(GTK_TABLE(table),hbox,1,2,1,2); /* update hook */ g_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(event_render_modify), (gpointer) entry); g_object_set_data(G_OBJECT(entry), "id", (gpointer) ANIM_NAME); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0); gui_button(" Create ", gui_animate_movie, NULL, hbox, TF); /* slider for current frame */ vbox = gui_frame_vbox(NULL, FALSE, FALSE, main_vbox); scale = gtk_hscale_new_with_range(1.0, 100.0, 1.0); gtk_range_set_update_policy(GTK_RANGE(scale), GTK_UPDATE_CONTINUOUS); gtk_box_pack_start(GTK_BOX(vbox), scale, TRUE, TRUE, 0); g_signal_connect(GTK_OBJECT(scale), "value_changed", GTK_SIGNAL_FUNC(gui_animate_frame_select), NULL); gtk_scale_set_draw_value(GTK_SCALE(scale), FALSE); /* animation limits */ vbox = gui_frame_vbox(NULL, FALSE, FALSE, main_vbox); gui_text_entry("First ", &entry_frame_start, TRUE, FALSE, vbox); gui_text_entry("Last ", &entry_frame_stop, TRUE, FALSE, vbox); gui_text_entry("Step ", &entry_frame_step, TRUE, FALSE, vbox); /* control buttons */ hbox = gtk_hbox_new(TRUE, PANEL_SPACING); gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 0); gui_icon_button("GDIS_REWIND", NULL, gui_animate_first, NULL, hbox); gui_icon_button("GDIS_STEP_BACKWARD", NULL, gui_animate_back, NULL, hbox); gui_icon_button("GDIS_PLAY", NULL, gui_animate_play, NULL, hbox); gui_icon_button("GDIS_PAUSE", NULL, gui_animate_stop, NULL, hbox); gui_icon_button("GDIS_STEP_FORWARD", NULL, gui_animate_next, NULL, hbox); gui_icon_button("GDIS_FASTFORWARD", NULL, gui_animate_last, NULL, hbox); gui_stock_button(GTK_STOCK_HELP, gui_help_show, "Animation and Rendering", GTK_DIALOG(window)->action_area); /* terminating button */ gui_stock_button(GTK_STOCK_CLOSE, dialog_destroy, dialog, GTK_DIALOG(window)->action_area); /* display the dialog */ gtk_widget_show_all(window); gtk_widget_hide(box_phonon_options); }
void gui_animate_dialog(void) { gchar *tmp, *title; gpointer dialog; GtkWidget *window, *frame, *vbox, *hbox, *hbox2, *anim_box; GtkWidget *notebook, *page, *button, *label, *entry, *scale; GSList *group=NULL; struct model_pak *data; /* checks */ data = sysenv.active_model; if (!data) return; if (!data->animation) return; /* CURRENT */ /* anim_read_all_frames(data); */ /* prevent recording whilst in animation */ gui_mode_switch(FREE); /* dialog setup */ title = g_strdup_printf("Animation: %s", data->basename); dialog = dialog_request(ANIM, title, NULL, animate_cleanup, data); g_free(title); if (!dialog) return; window = dialog_window(dialog); /* notebook frame */ frame = gtk_frame_new(NULL); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), frame, FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(frame), PANEL_SPACING); /* create notebook */ notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP); gtk_container_add(GTK_CONTAINER(frame), notebook); gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), TRUE); /* page 1 */ page = gtk_vbox_new(FALSE, PANEL_SPACING); label = gtk_label_new("Control"); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label); /* general animation stuff */ frame = gtk_frame_new(NULL); gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); /* create a vbox in the frame */ vbox = gtk_vbox_new(TRUE, PANEL_SPACING); gtk_container_add(GTK_CONTAINER(frame), vbox); /* num frames */ hbox = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox), PANEL_SPACING); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new("Number of frames:"); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); tmp = g_strdup_printf("%9d", data->num_frames); label = gtk_label_new(tmp); g_free(tmp); gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0); /* desired delay */ gui_direct_spin("Animation delay", &data->anim_speed, 1.0, 40.0, 1.0, NULL, NULL, vbox); gui_direct_spin("Animation step size ", &data->anim_step, 1.0, data->num_frames, 1.0, NULL, NULL, vbox); gui_direct_check("Don't recalculate connectivity", &data->anim_fix, NULL, NULL, vbox); gui_direct_check("Don't recalculate scale", &data->anim_noscale, NULL, NULL, vbox); gui_direct_check("Loop", &data->anim_loop, NULL, NULL, vbox); /* page 2 */ page = gtk_vbox_new(FALSE, PANEL_SPACING); label = gtk_label_new("Processing"); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label); /* cycle options */ frame = gtk_frame_new(NULL); gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_container_set_border_width(GTK_CONTAINER(vbox), PANEL_SPACING); /* actions at start of each cycle */ new_radio_group(0, vbox, FF); button = add_radio_button("Confine atoms to PBC", (gpointer) atom_pbc, data); if (data->anim_confine == PBC_CONFINE_ATOMS) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); button = add_radio_button("Confine mols to PBC", (gpointer) mol_pbc, data); if (data->anim_confine == PBC_CONFINE_MOLS) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); button = add_radio_button("Cell confinement off", (gpointer) no_pbc, data); if (data->anim_confine == PBC_CONFINE_NONE) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); /* page 3 */ page = gtk_vbox_new(FALSE, PANEL_SPACING); label = gtk_label_new("Rendering"); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label); /* cycle options */ frame = gtk_frame_new(NULL); gtk_box_pack_start(GTK_BOX(page), frame, FALSE, FALSE, 0); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_container_set_border_width(GTK_CONTAINER(vbox), PANEL_SPACING); anim_box = gtk_vbox_new(TRUE, 0); gui_direct_check("Create movie", &sysenv.render.animate, anim_render, anim_box, vbox); gtk_box_pack_end(GTK_BOX(vbox), anim_box, TRUE, TRUE, 0); /* sensitive box */ vbox = gtk_vbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(anim_box), vbox, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), PANEL_SPACING); /* start off with a button */ button = gtk_radio_button_new_with_label (NULL, "Animated GIF"); g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(event_render_modify), (gpointer) button); gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, TRUE, 0); g_object_set_data(G_OBJECT(button), "id", (gpointer) ANIM_GIF); /* make a radio group */ group = gtk_radio_button_group(GTK_RADIO_BUTTON(button)); /* do the rest of the buttons */ button = gtk_radio_button_new_with_label(group, "MPEG"); g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(event_render_modify), (gpointer) button); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, TRUE, 0); g_object_set_data(G_OBJECT(button), "id", (gpointer) ANIM_MPEG); /* movie creation parameters */ gui_direct_spin("MPEG quality", &sysenv.render.mpeg_quality, 1, 100, 1, NULL, NULL, vbox); gui_direct_spin("Delay (ms)", &sysenv.render.delay, 0, 100, 5, NULL, NULL, vbox); /* file entry */ hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,TRUE,0); label = gtk_label_new("Filename "); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); entry = gtk_entry_new(); gtk_box_pack_end(GTK_BOX (hbox), entry, FALSE, TRUE, 0); gtk_entry_set_text(GTK_ENTRY(entry), sysenv.render.animate_file); /* update hook */ g_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(event_render_modify), (gpointer) entry); g_object_set_data(G_OBJECT(entry), "id", (gpointer) ANIM_NAME); /* misc options */ /* gui_direct_check("Create povray input files then stop", &sysenv.render.no_povray_exec, NULL, NULL, vbox); gui_direct_check("Delete intermediate input/image files", &sysenv.render.no_keep_tempfiles, NULL, NULL, vbox); */ /* set initial state */ if (!sysenv.render.animate) gtk_widget_set_sensitive(anim_box, FALSE); /* NEW - slider for current frame */ frame = gtk_frame_new(NULL); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), frame, FALSE, FALSE, 0); vbox = gtk_vbox_new(FALSE, PANEL_SPACING); gtk_container_add(GTK_CONTAINER(frame), vbox); scale = gui_direct_hscale(0, data->num_frames-1, 1, &data->cur_frame, select_frame, data, vbox); gtk_range_set_update_policy(GTK_RANGE(scale), GTK_UPDATE_DISCONTINUOUS); /* control buttons */ hbox2 = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, PANEL_SPACING); hbox = gtk_hbox_new(TRUE, PANEL_SPACING); gtk_box_pack_start(GTK_BOX(hbox2), hbox, TRUE, FALSE, 0); gui_icon_button("GDIS_REWIND", NULL, anim_rewind, dialog, hbox); gui_icon_button("GDIS_STEP_BACKWARD", NULL, anim_step_backward, dialog, hbox); gui_icon_button("GDIS_PLAY", NULL, anim_start, dialog, hbox); gui_icon_button("GDIS_PAUSE", NULL, anim_stop, dialog, hbox); gui_icon_button("GDIS_STEP_FORWARD", NULL, anim_step_forward, dialog, hbox); gui_icon_button("GDIS_FASTFORWARD", NULL, anim_fastforward, dialog, hbox); gui_stock_button(GTK_STOCK_CLOSE, dialog_destroy, dialog, GTK_DIALOG(window)->action_area); /* display the dialog */ gtk_widget_show_all(window); gui_relation_update(data); }
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); }