;+
;NAME:
; thm_ui_set_active_dset
;PURPOSE:
; sets active datasets in themis GUI to given tplot varnames, used in
; the call_tplot widget.
;CALLING SEQUENCE:
; ss = thm_ui_set_active_dset(gui_id, active_names)
;INPUT:
; gui_id = the widget id for the master widget
; active_names = the tplot variable names
;HISTORY:
; 22-jan-2007, jmm, jimm@ssl.berkeley.edu
; 27-feb-2007, jmm, removed call to set_state_ptrs routine
; 10-may-2007, jmm, changed argument list, to use the GUI_ID and not
;                   the state structure
;
;$LastChangedBy: kenb-mac $
;$LastChangedDate: 2007-01-26 15:52:34 -0800 (Fri, 26 Jan 2007) $
;$LastChangedRevision: 241 $
;$URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/thmsoc/trunk/idl/themis/common/thm_ui_set_active_dset.pro $
;
;-
Function thm_ui_set_active_dset, gui_id, varnames
  data_ss = -1
  temp_names = tnames()
  data_ss = sswhere_arr(temp_names, varnames)
  If(data_ss[0] Ne -1) Then Begin
    If(widget_valid(gui_id)) Then Begin
      widget_control, gui_id, get_uval = state, /no_copy
      If(ptr_valid(state.active_vnames)) Then ptr_free, state.active_vnames
      state.active_vnames = ptr_new(varnames)
      widget_control, gui_id, set_uval = state, /no_copy
    Endif Else message, 'Invalid GUI_ID?'
  Endif Else Begin
    widget_control, gui_id, get_uval = state, /no_copy
    If(ptr_valid(state.active_vnames)) Then ptr_free, state.active_vnames
    widget_control, gui_id, set_uval = state, /no_copy
    thm_ui_update_progress, gui_id, 'No Active Dataset'
  Endelse
  Return, data_ss
End