STORAGE_SET *resetStore (RESET_DATA *reset) { STORAGE_SET *set = new_storage_set(); store_int (set, "type", reset->type); store_int (set, "times", reset->times); store_int (set, "chance", reset->chance); store_int (set, "max", reset->max); store_int (set, "room_max", reset->room_max); store_string(set, "arg", bufferString(reset->arg)); store_list (set, "in", gen_store_list(reset->in, resetStore)); store_list (set, "on", gen_store_list(reset->on, resetStore)); store_list (set, "then", gen_store_list(reset->then, resetStore)); return set; }
// // store a list in the set PyObject *PyStorageSet_storeList (PyObject *self, PyObject *args) { PyStorageList *val = NULL; char *key = NULL; PYSTORE_PARSE(args, key, val, "sO"); store_list(((PyStorageSet *)self)->set, key, val->list); return Py_BuildValue("i", 1); }
/*! \brief Saves the default loggable choices \param widget is unused \returns FALSE */ G_MODULE_EXPORT gboolean save_default_choices(GtkWidget *widget) { GtkWidget *tmpwidget = NULL; GList * list = NULL; GList * defaults = NULL; gconstpointer *object = NULL; gchar *name = NULL; gint i = 0; defaults = get_list("logviewer_defaults"); if (defaults) { g_list_foreach(defaults,(GFunc)g_free,NULL); g_list_free(defaults); defaults = NULL; remove_list("logviewer_defaults"); } list = get_list("viewables"); for (i=0;i<g_list_length(list);i++) { tmpwidget = g_list_nth_data(list,i); object = OBJ_GET(tmpwidget,"object"); if ((GBOOLEAN)DATA_GET(object,"being_viewed")) { if (DATA_GET(global_data,"playback_mode")) name = DATA_GET(object,"lview_name"); else name = DATA_GET(object,"dlog_gui_name"); defaults = g_list_append(defaults,g_strdup(name)); } } store_list("logviewer_defaults",defaults); return FALSE; }
/*! \brief Removed a pointer/widget from a list of lists \param lists is the comma separated list of list names \param data is the pointer to the item to remove from each list */ G_MODULE_EXPORT void remove_from_lists(const gchar * lists, gpointer data) { gint i = 0; gint bind_num_keys = 0; gchar **tmpvector = NULL; GList *list = NULL; ENTER(); if (!lists) { EXIT(); return; } tmpvector = parse_keys(lists,&bind_num_keys,","); for (i=0;i<bind_num_keys;i++) { list = get_list(tmpvector[i]); list = g_list_remove(list,(gpointer)data); store_list(tmpvector[i],list); } g_strfreev(tmpvector); EXIT(); return; }
/*! \brief bind_to_lists() binds a widget to any number of string named lists. \param widget is the widget to bind to lists \param lists is the command seperated string list of lists to bind this widget into. */ G_MODULE_EXPORT void bind_to_lists(GtkWidget * widget, const gchar * lists) { gint bind_num_keys = 0; gchar **tmpvector = NULL; GList *dest_list = NULL; gint i = 0; ENTER(); if (!lists) { printf(_("Error, bind_to_lists(), lists is NULL\n")); EXIT(); return; } tmpvector = parse_keys(lists,&bind_num_keys,","); /* This looks convoluted, but it allows for an arbritrary * number of lists, that are indexed by a keyword. * The get_list function looks the list up in a hashtable, if * it isn't found (i.e. new list) it returns NULL which is OK * as g_list_prepend() uses that to create a new list, that * returned list is used to store back into the hashtable so * that the list is always stored and up to date... */ for (i=0;i<bind_num_keys;i++) { dest_list = get_list(tmpvector[i]); dest_list = g_list_prepend(dest_list,(gpointer)widget); store_list(tmpvector[i],dest_list); } g_strfreev(tmpvector); EXIT(); return; }
STORAGE_SET *aliasAuxDataStore(ALIAS_AUX_DATA *data) { // if we have no hashtable, return an empty set if(data->aliases == NULL || hashSize(data->aliases) == 0) return new_storage_set(); STORAGE_SET *set = new_storage_set(); STORAGE_SET_LIST *list = new_storage_list(); HASH_ITERATOR *hash_i = newHashIterator(data->aliases); const char *name = NULL; const char *cmd = NULL; store_list(set, "aliases", list); ITERATE_HASH(name, cmd, hash_i) { STORAGE_SET *alias_set = new_storage_set(); store_string(alias_set, "key", name); store_string(alias_set, "val", hashIteratorCurrentVal(hash_i)); storage_list_put(list, alias_set); }
/*! \brief read logviewer defaults from file \param cfgfile is the pointer to ConfigFile structure to read the settings from */ G_MODULE_EXPORT void read_logviewer_defaults(ConfigFile *cfgfile) { gchar *tmpbuf = NULL; GList *defaults = NULL; gchar **vector = NULL; gint i = 0; cfg_read_string(cfgfile,"Logviewer","defaults",&tmpbuf); if (!tmpbuf) return; vector = g_strsplit(tmpbuf,",",-1); g_free(tmpbuf); for (i=0;i<g_strv_length(vector);i++) defaults = g_list_append(defaults,g_strdup(vector[i])); g_strfreev(vector); if (defaults) store_list("logviewer_defaults",defaults); }
// // save all of the socials to disk // void save_socials() { STORAGE_SET *set = new_storage_set(); LIST *soc_list = newList(); // iterate across the social table and save all of the unique socials HASH_ITERATOR *hash_i = newHashIterator(social_table); const char *cmd = NULL; SOCIAL_DATA *data = NULL; ITERATE_HASH(cmd, data, hash_i) listPut(soc_list, data); deleteHashIterator(hash_i); store_list(set, "socials", gen_store_list(soc_list, socialStore)); deleteList(soc_list); // write the set storage_write(set, SOCIALS_FILE); // close the set storage_close(set); }
/*! \brief present_viewer_choices() presents the user with the a list of variables from EITHER the realtime vars (if in realtime mode) or from a datalog (playback mode) */ void present_viewer_choices(void) { GtkWidget *window = NULL; GtkWidget *table = NULL; GtkWidget *frame = NULL; GtkWidget *vbox = NULL; GtkWidget *hbox = NULL; GtkWidget *button = NULL; GtkWidget *label = NULL; GtkWidget *sep = NULL; GtkWidget *darea = NULL; GList *list = NULL; GObject * object = NULL; extern GtkTooltips *tip; gint i = 0; gint j = 0; gint k = 0; gint table_rows = 0; gint table_cols = 5; gchar * name = NULL; gchar * tooltip = NULL; extern Rtv_Map *rtv_map; darea = lookup_widget("logviewer_trace_darea"); lv_data->darea = darea; if (!darea) { dbg_func(CRITICAL,g_strdup(__FILE__": present_viewer_choices()\n\tpointer to drawing area was NULL, returning!!!\n")); return; } window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_resizable(GTK_WINDOW(window),FALSE); /* Playback mode..... */ if (playback_mode) { gtk_window_set_title(GTK_WINDOW(window), _("Playback Mode: Logviewer Choices")); frame = gtk_frame_new(_("Select Variables to playback from the list below...")); max_viewables = log_info->field_count; } else { /* Realtime Viewing mode... */ gtk_window_set_title(GTK_WINDOW(window), _("Realtime Mode: Logviewer Choices")); frame = gtk_frame_new(_("Select Realtime Variables to view from the list below...")); max_viewables = rtv_map->derived_total; } g_signal_connect_swapped(G_OBJECT(window),"destroy_event", G_CALLBACK(reenable_select_params_button), NULL); g_signal_connect_swapped(G_OBJECT(window),"destroy_event", G_CALLBACK(save_default_choices), NULL); g_signal_connect_swapped(G_OBJECT(window),"destroy_event", G_CALLBACK(gtk_widget_destroy), (gpointer)window); g_signal_connect_swapped(G_OBJECT(window),"delete_event", G_CALLBACK(reenable_select_params_button), NULL); g_signal_connect_swapped(G_OBJECT(window),"delete_event", G_CALLBACK(save_default_choices), NULL); g_signal_connect_swapped(G_OBJECT(window),"delete_event", G_CALLBACK(gtk_widget_destroy), (gpointer)window); gtk_container_set_border_width(GTK_CONTAINER(window),5); gtk_container_add(GTK_CONTAINER(window),frame); vbox = gtk_vbox_new(FALSE,0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); gtk_container_add(GTK_CONTAINER(frame),vbox); table_rows = ceil((float)max_viewables/(float)table_cols); table = gtk_table_new(table_rows,table_cols,TRUE); gtk_table_set_row_spacings(GTK_TABLE(table),2); gtk_table_set_col_spacings(GTK_TABLE(table),5); gtk_container_set_border_width(GTK_CONTAINER(table),0); gtk_box_pack_start(GTK_BOX(vbox),table,FALSE,FALSE,0); j = 0; k = 0; if(get_list("viewables")) { g_list_free(get_list("viewables")); store_list("viewables",NULL); } for (i=0;i<max_viewables;i++) { if (playback_mode) list = g_list_prepend(list,(gpointer)g_array_index(log_info->log_list,GObject *,i)); else list = g_list_prepend(list,(gpointer)g_array_index(rtv_map->rtv_list,GObject *,i)); }
STORAGE_SET *resetListStore(RESET_LIST *list) { STORAGE_SET *set = new_storage_set(); store_list(set, "resets", gen_store_list(list->resets, resetStore)); return set; }
/*! \brief present_viewer_choices() presents the user with the a list of variables from EITHER the realtime vars (if in realtime mode) or from a datalog (playback mode) */ G_MODULE_EXPORT void present_viewer_choices(void) { GtkWidget *window = NULL; GtkWidget *table = NULL; GtkWidget *frame = NULL; GtkWidget *vbox = NULL; GtkWidget *hbox = NULL; GtkWidget *button = NULL; GtkWidget *label = NULL; GtkWidget *sep = NULL; GtkWidget *darea = NULL; GList *list = NULL; gconstpointer * object = NULL; gint i = 0; gint j = 0; gint k = 0; gint table_rows = 0; gint table_cols = 5; gchar * name = NULL; gchar * tooltip = NULL; gboolean playback = FALSE; Rtv_Map *rtv_map = NULL; Log_Info *log_info; log_info = DATA_GET(global_data,"log_info"); rtv_map = DATA_GET(global_data,"rtv_map"); darea = lookup_widget("logviewer_trace_darea"); lv_data->darea = darea; playback = (GBOOLEAN)DATA_GET(global_data,"playback_mode"); if (!darea) { MTXDBG(CRITICAL,_("Pointer to drawing area was NULL, returning!!!\n")); return; } window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_transient_for(GTK_WINDOW(window),GTK_WINDOW(lookup_widget("main_window"))); gtk_window_set_resizable(GTK_WINDOW(window),FALSE); /* Playback mode..... */ if (playback) { gtk_window_set_title(GTK_WINDOW(window), _("Playback Mode: Logviewer Choices")); frame = gtk_frame_new(_("Select Variables to playback from the list below...")); max_viewables = log_info->field_count; } else { /* Realtime Viewing mode... */ gtk_window_set_title(GTK_WINDOW(window), _("Realtime Mode: Logviewer Choices")); frame = gtk_frame_new(_("Select Realtime Variables to view from the list below...")); max_viewables = rtv_map->derived_total; } g_signal_connect_swapped(G_OBJECT(window),"destroy_event", G_CALLBACK(reenable_select_params_button), NULL); g_signal_connect_swapped(G_OBJECT(window),"destroy_event", G_CALLBACK(save_default_choices), NULL); g_signal_connect_swapped(G_OBJECT(window),"destroy_event", G_CALLBACK(gtk_widget_destroy), (gpointer)window); g_signal_connect_swapped(G_OBJECT(window),"delete_event", G_CALLBACK(reenable_select_params_button), NULL); g_signal_connect_swapped(G_OBJECT(window),"delete_event", G_CALLBACK(save_default_choices), NULL); g_signal_connect_swapped(G_OBJECT(window),"delete_event", G_CALLBACK(gtk_widget_destroy), (gpointer)window); gtk_container_set_border_width(GTK_CONTAINER(window),5); gtk_container_add(GTK_CONTAINER(window),frame); vbox = gtk_vbox_new(FALSE,0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); gtk_container_add(GTK_CONTAINER(frame),vbox); table_rows = ceil((float)max_viewables/(float)table_cols); table = gtk_table_new(table_rows,table_cols,TRUE); gtk_table_set_row_spacings(GTK_TABLE(table),2); gtk_table_set_col_spacings(GTK_TABLE(table),5); gtk_container_set_border_width(GTK_CONTAINER(table),0); gtk_box_pack_start(GTK_BOX(vbox),table,FALSE,FALSE,0); j = 0; k = 0; if(get_list("viewables")) { g_list_free(get_list("viewables")); remove_list("viewables"); } for (i=0;i<max_viewables;i++) { if (playback) list = g_list_prepend(list,(gpointer)g_ptr_array_index(log_info->log_list,i)); else list = g_list_prepend(list,(gpointer)g_ptr_array_index(rtv_map->rtv_list,i)); } if (playback) list=g_list_sort_with_data(list,list_object_sort,(gpointer)"lview_name"); else list=g_list_sort_with_data(list,list_object_sort,(gpointer)"dlog_gui_name"); for (i=0;i<max_viewables;i++) { object = NULL; name = NULL; tooltip = NULL; object = g_list_nth_data(list,i); if (playback) name = g_strdup(DATA_GET(object,"lview_name")); else { name = g_strdup(DATA_GET(object,"dlog_gui_name")); tooltip = g_strdup(DATA_GET(object,"tooltip")); } button = gtk_check_button_new(); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label),name); gtk_container_add(GTK_CONTAINER(button),label); store_list("viewables",g_list_prepend( get_list("viewables"),(gpointer)button)); if (tooltip) gtk_widget_set_tooltip_text(button,tooltip); if (object) { OBJ_SET(button,"object",(gpointer)object); /* so we can set the state from elsewhere...*/ DATA_SET(object,"lview_button",(gpointer)button); if ((GBOOLEAN)DATA_GET(object,"being_viewed")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),TRUE); } g_signal_connect(G_OBJECT(button),"toggled", G_CALLBACK(view_value_set), NULL); gtk_table_attach (GTK_TABLE (table), button, j, j+1, k, k+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); j++; if (j == table_cols) { k++; j = 0; } g_free(name); } g_list_free(list); sep = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vbox),sep,FALSE,TRUE,20); hbox = gtk_hbox_new(FALSE,20); gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,TRUE,0); button = gtk_button_new_with_label("Select All"); gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,15); OBJ_SET(button,"state",GINT_TO_POINTER(TRUE)); g_signal_connect(G_OBJECT(button),"clicked", G_CALLBACK(set_all_lview_choices_state), GINT_TO_POINTER(TRUE)); button = gtk_button_new_with_label("De-select All"); gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,15); OBJ_SET(button,"state",GINT_TO_POINTER(FALSE)); g_signal_connect(G_OBJECT(button),"clicked", G_CALLBACK(set_all_lview_choices_state), GINT_TO_POINTER(FALSE)); button = gtk_button_new_with_label("Close"); gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,TRUE,0); g_signal_connect_swapped(G_OBJECT(button),"clicked", G_CALLBACK(reenable_select_params_button), NULL); g_signal_connect_swapped(G_OBJECT(button),"clicked", G_CALLBACK(save_default_choices), NULL); g_signal_connect_swapped(G_OBJECT(button),"clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window); set_default_lview_choices_state(); gtk_widget_show_all(window); return; }
STORAGE_SET *triggerAuxDataStore(TRIGGER_AUX_DATA *data) { STORAGE_SET *set = new_storage_set(); store_list(set, "triggers", gen_store_list(data->triggers,store_one_trigger)); return set; }