Exemple #1
0
static GtkWidget	*init_effect(t_wid *wid)
{
  GtkWidget		*frame[4];

  frame[0] = gtk_frame_new("Effect");
  frame[1] = gtk_frame_new("Shiny");
  frame[2] = gtk_frame_new("Other");
  frame[3] = gtk_frame_new("Color");
  wid->surface->effect_but = new_button("None", NULL,
					G_CALLBACK(objeffect), wid);
  gtk_container_add(GTK_CONTAINER(frame[0]),
		    wid->surface->effect_but);
  wid->surface->brillance =
    new_hscale(1, 300, G_CALLBACK(change_brillance), wid);
  gtk_container_add(GTK_CONTAINER(frame[1]),
		    wid->surface->brillance);
  wid->surface->def = new_check_button("Normal's distortion", 0,
				       G_CALLBACK(change_def), wid);
  gtk_container_add(GTK_CONTAINER(frame[2]),
		    wid->surface->def);
  wid->surface->color[0] = new_spin(0, 255, G_CALLBACK(change_red), wid);
  wid->surface->color[1] = new_spin(0, 255, G_CALLBACK(change_green), wid);
  wid->surface->color[2] = new_spin(0, 255, G_CALLBACK(change_blue), wid);
  gtk_container_add(GTK_CONTAINER(frame[3]),
		    unit_hbox(wid->surface->color, 3, TRUE, 0));
  return (unit_vbox(frame, 4, FALSE, 0));
}
Exemple #2
0
BoolFilterParam::BoolFilterParam(const char* name,
                                 const char* label,
                                 Properties* prop,
                                 bool value)
    : prop_(prop)
    , name_(name)
    , iniValue_(value)
    , btn_(manage (new_check_button(label)))
{
    if (prop)
    {
        iniValue_ = prop->get_word(name, value);
    }
    btn_->set_active(iniValue_);
}
Exemple #3
0
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 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);
}