Logo Search packages:      
Sourcecode: ygraph version File versions  Download package

gboolean file_select_read ( GtkObject *  ok_button,
GtkFileSelection *  fs 
)

Act on the result of a file selection.

Gets the filename returned by a file selection dialog and reads the specified file. Any new datasets are appended to the existing list and the plot is redrawn.

Parameters:
ok_button The button which initiated the callback.
fs The file selection dialog.
Returns:
TRUE if successful.

Definition at line 309 of file callbacks.c.

References _Plot::current_directory, dataset_read_from_file(), option_read_skip_step, plot_data_append(), plot_data_init(), plot_window_display_all(), and plot_window_show().

Referenced by file_select(), and file_select_new_window().

{
  GArray* new_data_array;
  Plot* plot;
  gint new_data_set_idx;
  gchar* filename;

  UNUSED(ok_button);
  filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs));

  new_data_set_idx = dataset_read_from_file(filename, option_read_skip_step);
  if (new_data_set_idx == FAIL)
    return TRUE;

  plot = gtk_object_get_data(GTK_OBJECT(fs), "plot");
  
  if (plot == NULL)
    {
      new_data_array = g_array_new(FALSE, FALSE, sizeof(gint));
      g_array_append_val(new_data_array, new_data_set_idx);
      plot = plot_data_init(new_data_array);
      plot_window_show();
    }
  else
    plot_data_append(plot, new_data_set_idx);

  if (plot->current_directory)
    g_free(plot->current_directory);
  plot->current_directory = g_strdup_printf("%s/", g_dirname(filename));

  plot_window_display_all(plot);
  return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index