EXPORT gboolean init_text_attributes(GladeXML *xml) { extern GdkColor white; extern GdkColor black; GtkWidget *notebook = NULL; GtkWidget *child = NULL; notebook = glade_xml_get_widget(xml,"value_notebook"); child = glade_xml_get_widget(xml,"value_text_table"); gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(notebook),child,TRUE,TRUE,GTK_PACK_START); child = glade_xml_get_widget(xml,"value_font_table"); gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(notebook),child,TRUE,TRUE,GTK_PACK_START); child = glade_xml_get_widget(xml,"value_location_table"); gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(notebook),child,TRUE,TRUE,GTK_PACK_START); OBJ_SET((glade_xml_get_widget(xml,"precision_spin")),"handler",GINT_TO_POINTER(PRECISION)); OBJ_SET((glade_xml_get_widget(xml,"value_xpos_spin")),"handler",GINT_TO_POINTER(VALUE_XPOS)); OBJ_SET((glade_xml_get_widget(xml,"value_ypos_spin")),"handler",GINT_TO_POINTER(VALUE_YPOS)); OBJ_SET((glade_xml_get_widget(xml,"value_grab_button")),"x_spin",glade_xml_get_widget(xml,"value_xpos_spin")); OBJ_SET((glade_xml_get_widget(xml,"value_grab_button")),"y_spin",glade_xml_get_widget(xml,"value_ypos_spin")); OBJ_SET((glade_xml_get_widget(xml,"value_font_scale_spin")),"handler",GINT_TO_POINTER(VALUE_FONTSCALE)); OBJ_SET((glade_xml_get_widget(xml,"value_color_day_button")),"handler",GINT_TO_POINTER(GAUGE_COL_VALUE_FONT_DAY)); OBJ_SET((glade_xml_get_widget(xml,"value_color_nite_button")),"handler",GINT_TO_POINTER(GAUGE_COL_VALUE_FONT_NITE)); OBJ_SET((glade_xml_get_widget(xml,"show_value_check")),"handler",GINT_TO_POINTER(SHOW_VALUE)); gtk_color_button_set_color(GTK_COLOR_BUTTON(glade_xml_get_widget(xml,"value_color_day_button")),&white); gtk_color_button_set_color(GTK_COLOR_BUTTON(glade_xml_get_widget(xml,"value_color_nite_button")),&black); update_text_controls(); update_onscreen_tblocks(); return TRUE; }
/*! \brief bind_group_data() is called to bind data widget that is defined in a group. (saves from having to duplicate a large number of keys/values for a big group of widgets) This function will set the necessary data on the Gui object. \param cfg is the pointer to the config file object to read data from \param object is the widget to bind the data to \param groups is the hashtable that holds the group common data \param groupname is the textual name of the group to get the data for to be bound to the widget \returns the page of the group */ G_MODULE_EXPORT gint bind_group_data(ConfigFile *cfg, GObject *object, GHashTable *groups, const gchar *groupname) { gint i = 0; gint tmpi = 0; Group *group = NULL; DataType keytype = MTX_STRING; ENTER(); group = (Group *)g_hash_table_lookup(groups,groupname); if (!group) { MTXDBG(TABLOADER|CRITICAL,_("Group \"%s\" not found in file %s\n"),groupname,cfg->filename); EXIT(); return -1; } /* Copy data from the group object to the */ /* Grab hidden data if it exists */ if (OBJ_GET(group->object, "dep_object")) OBJ_SET(object,"dep_object",OBJ_GET(group->object, "dep_object")); for (i=0;i<group->num_keys;i++) { keytype = (DataType)translate_string(group->keys[i]); switch((DataType)keytype) { case MTX_INT: case MTX_BOOL: case MTX_ENUM: tmpi = (GINT)OBJ_GET(group->object,group->keys[i]); OBJ_SET(object,group->keys[i],GINT_TO_POINTER(tmpi)); if (strstr(group->keys[i], "temp_dep")) { OBJ_SET(object,"widget_temp",DATA_GET(global_data,"mtx_temp_units")); } break; case MTX_FLOAT: OBJ_SET_FULL(object,group->keys[i],g_memdup(OBJ_GET(group->object,group->keys[i]),sizeof(gfloat)),g_free); break; case MTX_STRING: OBJ_SET_FULL(object,group->keys[i],(gchar *)g_strdup((gchar *)OBJ_GET(group->object,group->keys[i])),g_free); if (OBJ_GET(object,"tooltip") != NULL) gtk_widget_set_tooltip_text((GtkWidget *)OBJ_GET(object,"self"),(gchar *)OBJ_GET(object,"tooltip")); if (OBJ_GET(group->object, "bind_to_list")) bind_to_lists((GtkWidget *)OBJ_GET(object,"self"),(gchar *)OBJ_GET(group->object, "bind_to_list")); break; default: break; } } EXIT(); return group->page; }
EXPORT gboolean grab_coords_event(GtkWidget *widget, gpointer data) { gdouble x = 0.0; gdouble y = 0.0; gtk_widget_set_sensitive(OBJ_GET(widget,"x_spin"),FALSE); gtk_widget_set_sensitive(OBJ_GET(widget,"y_spin"),FALSE); gtk_widget_set_sensitive(widget,FALSE); OBJ_SET(gauge,"x_spin",OBJ_GET(widget,"x_spin")); OBJ_SET(gauge,"y_spin",OBJ_GET(widget,"y_spin")); OBJ_SET(gauge,"edit_but",widget); return TRUE; }
/*! \brief Initializes the MS2_TTMon_Data structure and stores a pointer to it in the passed src_widget \param src_widget is where the pointer to the TM datastructure is stored \see MS2_TTMon_Data */ G_MODULE_EXPORT void ms2_setup_logger_display(GtkWidget * src_widget) { ENTER(); ttm_data = g_new0(MS2_TTMon_Data,1); ttm_data->page = -1; ttm_data->units = 1; ttm_data->pixmap = NULL; ttm_data->darea = src_widget; ttm_data->min_time = 65535; ttm_data->max_time = 0; ttm_data->est_teeth = 0; ttm_data->wrap_pt = 0; ttm_data->font_height = 0; ttm_data->usable_begin = 0; ttm_data->font_desc = NULL; ttm_data->sample_time = 0; ttm_data->current = g_new0(gulong,341); ttm_data->flags = g_new0(guchar,341); ttm_data->sync_loss = g_new0(gboolean,341); ttm_data->last = g_new0(gulong,341); ttm_data->zoom = 1.0; OBJ_SET(src_widget,"ttmon_data",(gpointer)ttm_data); EXIT(); return; }
/*! \brief trivial function to set the page variable of the ttm_data structure \see MS2_TTM_Data \param page is the page to store in the datastructure */ G_MODULE_EXPORT void bind_ttm_to_page(gint page) { ENTER(); ttm_data->page = page; OBJ_SET(ttm_data->darea,"page",GINT_TO_POINTER(page)); EXIT(); return; }
gboolean gauge_button(GtkWidget *widget, GdkEventButton *event, gpointer data) { GtkWidget * tmp = NULL; tmp = OBJ_GET(gauge,"x_spin"); if (GTK_IS_WIDGET(tmp)) gtk_widget_set_sensitive(tmp,TRUE); tmp = OBJ_GET(gauge,"y_spin"); if (GTK_IS_WIDGET(tmp)) gtk_widget_set_sensitive(tmp,TRUE); tmp = OBJ_GET(gauge,"edit_but"); if (GTK_IS_WIDGET(tmp)) gtk_widget_set_sensitive(tmp,TRUE); OBJ_SET(gauge,"x_spin",NULL); OBJ_SET(gauge,"y_spin",NULL); OBJ_SET(gauge,"edit_but",NULL); return FALSE; }
void load_defaults() { GtkBuilder *builder = NULL; ConfigFile *cfgfile; gchar * filename = NULL; gchar * tmpbuf = NULL; GtkFileFilter *filter = NULL; GObject *object = NULL; builder = (GtkBuilder *)DATA_GET(global_data,"builder"); g_return_if_fail(builder); filename = g_build_filename(HOME(),"mtx","default","config", NULL); cfgfile = cfg_open_file(filename); if (cfgfile) { if(cfg_read_string(cfgfile, (gchar *)"Serial", (gchar *)"override_port", &tmpbuf)) { gtk_entry_set_text(GTK_ENTRY(gtk_builder_get_object (builder, "port_entry")),tmpbuf); g_free(tmpbuf); } if(cfg_read_string(cfgfile, (gchar *)"MTXLoader", (gchar *)"last_file", &tmpbuf)) { gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(gtk_builder_get_object (builder, "filechooser_button")),tmpbuf); filter = gtk_file_filter_new(); gtk_file_filter_add_pattern(filter,"*.s19"); gtk_file_filter_add_pattern(filter,"*.S19"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(gtk_builder_get_object (builder, "filechooser_button")),filter); g_free(tmpbuf); } object = gtk_builder_get_object(builder,"ms1_rbutton"); if (G_IS_OBJECT(object)) OBJ_SET(object,"persona",GINT_TO_POINTER(MS1)); object = gtk_builder_get_object(builder,"ms2_rbutton"); if (G_IS_OBJECT(object)) OBJ_SET(object,"persona",GINT_TO_POINTER(MS2)); object = gtk_builder_get_object(builder,"freeems_rbutton"); if (G_IS_OBJECT(object)) OBJ_SET(object,"persona",GINT_TO_POINTER(FREEEMS)); cfg_free(cfgfile); g_free(filename); } }
EXPORT gboolean burn_all_helper(void *data, XmlCmdType type) { extern Firmware_Details *firmware; extern volatile gboolean offline; OutputData *output = NULL; Command *command = NULL; extern volatile gint last_page; gint i = 0; if (last_page == -1) { command = (Command *)data; io_cmd(NULL,command->post_functions); return TRUE; } /*printf("burn all helper\n");*/ if ((type != MS2) && (type != MS1)) return FALSE; if (!offline) { /* MS2 extra is slightly different as it's paged like MS1 */ if (((firmware->capabilities & MS2_E) || (firmware->capabilities & MS1) || (firmware->capabilities & MSNS_E))) { /* printf("paged burn\n");*/ output = initialize_outputdata(); OBJ_SET(output->object,"page",GINT_TO_POINTER(last_page)); OBJ_SET(output->object,"phys_ecu_page",GINT_TO_POINTER(firmware->page_params[last_page]->phys_ecu_page)); OBJ_SET(output->object,"canID",GINT_TO_POINTER(firmware->canID)); OBJ_SET(output->object,"mode", GINT_TO_POINTER(MTX_CMD_WRITE)); io_cmd(firmware->burn_command,output); } else if ((firmware->capabilities & MS2) && (!(firmware->capabilities & MS2_E))) { /* MS2 std allows all pages to be in ram at will*/ for (i=0;i<firmware->total_pages;i++) { if (!firmware->page_params[i]->dl_by_default) continue; output = initialize_outputdata(); OBJ_SET(output->object,"page",GINT_TO_POINTER(i)); OBJ_SET(output->object,"phys_ecu_page",GINT_TO_POINTER(firmware->page_params[i]->phys_ecu_page)); OBJ_SET(output->object,"canID",GINT_TO_POINTER(firmware->canID)); OBJ_SET(output->object,"mode", GINT_TO_POINTER(MTX_CMD_WRITE)); io_cmd(firmware->burn_command,output); } } } command = (Command *)data; io_cmd(NULL,command->post_functions); return TRUE; }
/*! \brief populate_master() stores a pointer to all of the glade loaded widgets into a master hashtable so that it can be recalled by name anywhere in the program. \param widget is the pointer to Widget \param user_data is the pointer to ConfigFile structure */ G_MODULE_EXPORT void populate_master(GtkWidget *widget, gpointer user_data ) { gchar *name = NULL; gchar *fullname = NULL; gchar *prefix = NULL; GHashTable *dynamic_widgets = NULL; ConfigFile *cfg = (ConfigFile *) user_data; /*! Populates a big master hashtable of all dynamic widgets so that various functions can do a lookup for the widgets name and get it's GtkWidget * for manipulation. We do NOT insert the topframe widgets from the XML tree as if more than 1 tab loads there will be a clash, and there's no need to store the top frame widget anyways... */ if (GTK_IS_CONTAINER(widget)) gtk_container_foreach(GTK_CONTAINER(widget),populate_master,user_data); if (!cfg_read_string(cfg,"global","id_prefix",&prefix)) prefix = g_strdup(""); name = (char *)glade_get_widget_name(widget); /*printf("name of widget stored is %s\n",name);*/ if (name == NULL) { g_free(prefix); return; } if (g_strrstr((gchar *)name,"topframe")) { g_free(prefix); return; } dynamic_widgets = DATA_GET(global_data,"dynamic_widgets"); if(!dynamic_widgets) { dynamic_widgets = g_hash_table_new_full(g_str_hash,g_str_equal,g_free,NULL); DATA_SET_FULL(global_data,"dynamic_widgets",dynamic_widgets,g_hash_table_destroy); } fullname = g_strdup_printf("%s%s",prefix,name); OBJ_SET_FULL(widget,"fullname",g_strdup(fullname),g_free); OBJ_SET(widget,"last_value",GINT_TO_POINTER(-G_MAXINT)); if (!g_hash_table_lookup(dynamic_widgets,fullname)) g_hash_table_insert(dynamic_widgets,g_strdup(fullname),(gpointer)widget); else MTXDBG(CRITICAL,_("Key %s for widget %s from file %s already exists in master table\n"),name,fullname,cfg->filename); g_free(prefix); g_free(fullname); }
EXPORT void startup_default_timeouts_pf() { gint source = 0; gint rate = 0; gdk_threads_enter(); set_title(g_strdup(_("Starting up data renderers..."))); gdk_threads_leave(); rate = (GINT)OBJ_GET(global_data,"rtslider_fps"); source = g_timeout_add((gint)(1000.0/(gfloat)rate),(GtkFunction)update_rtsliders,NULL); OBJ_SET(global_data,"rtslider_id", GINT_TO_POINTER(source)); rate = (GINT)OBJ_GET(global_data,"rttext_fps"); source = g_timeout_add((gint)(1000.0/(gfloat)rate),(GtkFunction)update_rttext,NULL); OBJ_SET(global_data,"rttext_id", GINT_TO_POINTER(source)); rate = (GINT)OBJ_GET(global_data,"dashboard_fps"); source = g_timeout_add((gint)(1000.0/(gfloat)rate),(GtkFunction)update_dashboards,NULL); OBJ_SET(global_data,"dashboard_id", GINT_TO_POINTER(source)); rate = (GINT)OBJ_GET(global_data,"ve3d_fps"); source = g_timeout_add((gint)(1000.0/(gfloat)rate),(GtkFunction)update_ve3ds,NULL); OBJ_SET(global_data,"ve3d_id", GINT_TO_POINTER(source)); }
void update_onscreen_tblocks() { GtkWidget *toptable = NULL; static GtkWidget *table = NULL; GtkWidget *subtable = NULL; GtkWidget *dummy = NULL; guint i = 0; gint y = 1; MtxTextBlock *tblock = NULL; GtkAdjustment *adj = NULL; GArray * array = NULL; extern GladeXML *topxml; if ((!topxml) || (!gauge)) return; array = mtx_gauge_face_get_text_blocks(MTX_GAUGE_FACE(gauge)); toptable = glade_xml_get_widget(topxml,"text_blocks_layout_table"); if (!GTK_IS_WIDGET(toptable)) { printf("toptable is NOT a valid widget!!\n"); return; } if (GTK_IS_WIDGET(table)) gtk_widget_destroy(table); table = gtk_table_new(2,1,FALSE); gtk_table_attach(GTK_TABLE(toptable),table,0,1,1,2,GTK_EXPAND|GTK_FILL,0,0,0); OBJ_SET((toptable),"layout_table",table); /* Repopulate the table with the current tblocks... */ y=1; for (i=0;i<array->len; i++) { tblock = g_array_index(array,MtxTextBlock *, i); subtable = build_tblock(tblock,i); gtk_table_attach(GTK_TABLE(table),subtable,0,1,y,y+1,GTK_EXPAND|GTK_FILL,GTK_SHRINK,0,0); gtk_widget_show_all(subtable); y+=1; } /* Scroll to end */ dummy = glade_xml_get_widget(topxml,"tblock_swin"); adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(dummy)); adj->value = adj->upper; gtk_widget_show_all(toptable); }
/*! \brief stop_datalogging() stops the datalog process. It DOES not stop realtime variable readback though */ G_MODULE_EXPORT void stop_datalogging(void) { ENTER(); GIOChannel *iochannel = NULL; if (!DATA_GET(global_data,"logging_active")) { EXIT(); return; } if (DATA_GET(global_data,"offline")) { EXIT(); return; } DATA_SET(global_data,"logging_active",NULL); if (lookup_widget("dlog_logable_vars_vbox1")) gtk_widget_set_sensitive(lookup_widget("dlog_logable_vars_vbox1"),TRUE); if (lookup_widget("dlog_format_delimit_hbox1")) gtk_widget_set_sensitive(lookup_widget("dlog_format_delimit_hbox1"),TRUE); if (lookup_widget("dlog_select_log_button")) gtk_widget_set_sensitive(lookup_widget("dlog_select_log_button"),TRUE); if (lookup_widget("dlog_stop_logging_button")) gtk_widget_set_sensitive(lookup_widget("dlog_stop_logging_button"),FALSE); if (lookup_widget("dlog_start_logging_button")) gtk_widget_set_sensitive(lookup_widget("dlog_start_logging_button"),FALSE); gtk_label_set_text(GTK_LABEL(lookup_widget("dlog_file_label")),"No Log Selected Yet"); update_logbar("dlog_view",NULL,_("DataLogging Stopped...\n"),FALSE,FALSE,FALSE); iochannel = (GIOChannel *) OBJ_GET(lookup_widget("dlog_select_log_button"),"data"); if (iochannel) { g_io_channel_shutdown(iochannel,TRUE,NULL); g_io_channel_unref(iochannel); } g_list_free(object_list); object_list = NULL; last_len = 0; OBJ_SET(lookup_widget("dlog_select_log_button"),"data",NULL); EXIT(); return; }
void update_onscreen_tgroups() { GtkWidget *toptable = NULL; GtkWidget *subtable = NULL; GtkWidget *table = NULL; GtkWidget *dummy = NULL; guint i = 0; MtxTickGroup *tgroup = NULL; const GArray * array = NULL; GtkAdjustment *adj = NULL; if ((!toplevel) || (!gauge)) return; array = mtx_gauge_face_get_tick_groups(MTX_GAUGE_FACE(gauge)); toptable = GTK_WIDGET(gtk_builder_get_object(toplevel,"tick_groups_layout_table")); if (!GTK_IS_WIDGET(toptable)) { printf("toptable is NOT a valid widget!!\n"); return; } /* Get it and blow it away for re-creation */ table = OBJ_GET((toptable), "layout_table"); if (GTK_IS_WIDGET(table)) gtk_widget_destroy(table); table = gtk_table_new(2,1,FALSE); gtk_table_set_row_spacings(GTK_TABLE(table),5); gtk_table_attach_defaults(GTK_TABLE(toptable),table,0,1,1,2); OBJ_SET((toptable),"layout_table",table); /* Repopulate the table with the current tgroups... */ for (i=0;i<array->len; i++) { tgroup = g_array_index(array,MtxTickGroup *, i); subtable = build_tgroup(tgroup,i); gtk_table_attach(GTK_TABLE(table),subtable,0,1,i,i+1,GTK_EXPAND|GTK_FILL,GTK_SHRINK,0,0); } /* Scroll to end */ dummy = GTK_WIDGET(gtk_builder_get_object(toplevel,"tgroup_swin")); adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(dummy)); gtk_adjustment_set_value(adj, gtk_adjustment_get_upper(adj)); gtk_widget_show_all(toptable); }
/*! \brief Enable log playback controls \param state whether to enable or disable the playback controls */ G_MODULE_EXPORT void enable_playback_controls(gboolean state) { static GtkWidget * playback_controls_window = NULL; gchar *fname = NULL; gchar * filename = NULL; GladeXML *xml = NULL; GtkWidget *widget = NULL; GtkAdjustment *adj = NULL; if (state) /* show the controls */ { if (!GTK_IS_WIDGET(playback_controls_window)) { fname = g_build_filename(GUI_DATA_DIR,"logviewer.glade",NULL); filename = get_file(g_strdup(fname),NULL); if (filename) { xml = glade_xml_new(filename, "logviewer_controls_window",NULL); g_free(filename); g_free(fname); glade_xml_signal_autoconnect(xml); playback_controls_window = glade_xml_get_widget(xml,"logviewer_controls_window"); OBJ_SET(glade_xml_get_widget(xml,"goto_start_button"),"handler",GINT_TO_POINTER(LV_GOTO_START)); OBJ_SET(glade_xml_get_widget(xml,"goto_end_button"),"handler",GINT_TO_POINTER(LV_GOTO_END)); OBJ_SET(glade_xml_get_widget(xml,"rewind_button"),"handler",GINT_TO_POINTER(LV_REWIND)); OBJ_SET(glade_xml_get_widget(xml,"fast_forward_button"),"handler",GINT_TO_POINTER(LV_FAST_FORWARD)); OBJ_SET(glade_xml_get_widget(xml,"play_button"),"handler",GINT_TO_POINTER(LV_PLAY)); OBJ_SET(glade_xml_get_widget(xml,"stop_button"),"handler",GINT_TO_POINTER(LV_STOP)); register_widget("logviewer_controls_hbox",glade_xml_get_widget(xml,"controls_hbox")); widget = lookup_widget("logviewer_scroll_hscale"); if (GTK_IS_WIDGET(widget)) { adj = gtk_range_get_adjustment(GTK_RANGE(widget)); gtk_range_set_adjustment(GTK_RANGE(glade_xml_get_widget(xml,"scroll_speed")),adj); } widget = lookup_widget("logviewer_log_position_hscale"); if (GTK_IS_WIDGET(widget)) { adj = gtk_range_get_adjustment(GTK_RANGE(widget)); gtk_range_set_adjustment(GTK_RANGE(glade_xml_get_widget(xml,"log_position_hscale")),adj); } } register_widget("playback_controls_window",playback_controls_window); } else gtk_widget_show_all(playback_controls_window); } else { if (GTK_IS_WIDGET(playback_controls_window)) gtk_widget_hide(playback_controls_window); } return; }
/*! \brief free's the data from the struct Group structure \param value is the pointer to the struct Group to be deallocated \see load_groups */ G_MODULE_EXPORT void group_free(gpointer value) { Group *group = (Group *)value; gint i = 0; DataType keytype = MTX_INT; ENTER(); for (i=0;i<group->num_keys;i++) { keytype = (DataType)translate_string(group->keys[i]); OBJ_SET(group->object,group->keys[i],NULL); } g_object_unref(group->object); g_strfreev(group->keys); g_free(group->keytypes); g_free(group); EXIT(); return; }
EXPORT void setup_logger_display(GtkWidget * src_widget) { ttm_data = g_new0(TTMon_Data,1); ttm_data->page = -1; ttm_data->pixmap = NULL; ttm_data->darea = src_widget; ttm_data->min_time = 65535; ttm_data->max_time = 0; ttm_data->est_teeth = 0; ttm_data->wrap_pt = 0; ttm_data->font_height = 0; ttm_data->usable_begin = 0; ttm_data->font_desc = NULL; ttm_data->missing = 0; ttm_data->sample_time = 0; ttm_data->captures = g_new0(gushort, 93); ttm_data->current = g_new0(gushort,93); ttm_data->last = g_new0(gushort,93); OBJ_SET(src_widget,"ttmon_data",(gpointer)ttm_data); return; }
/*! \brief logviewer_log_position_change() gets called when the log position slider is moved by the user to fast forware/rewind through a datalog \param widget is the widget that received the event \param data is unused \returns TRUE */ G_MODULE_EXPORT gboolean logviewer_log_position_change(GtkWidget * widget, gpointer data) { gfloat val = 0.0; GtkWidget *darea = NULL; /* If we pass "TRUE" as the widget data we just ignore this signal as * the redraw routine wil have to adjsut the slider as it scrolls * through the data... */ if ((GBOOLEAN)data) return TRUE; if (blocked) return TRUE; val = gtk_range_get_value(GTK_RANGE(widget)); darea = lookup_widget("logviewer_trace_darea"); if (GTK_IS_WIDGET(darea)) OBJ_SET(darea,"log_pos_x100",GINT_TO_POINTER((GINT)(val*100))); lv_configure_event(darea,NULL,NULL); scroll_logviewer_traces(); if ((val >= 100.0) && (DATA_GET(global_data,"playback_mode"))) stop_tickler(LV_PLAYBACK_TICKLER); return TRUE; }
void menu_setup(GtkBuilder *toplevel) { GtkWidget *bar = NULL; GtkWidget *vbox = NULL; GtkWidget *menubar = NULL; GtkWidget *menu = NULL; GtkWidget *item = NULL; GtkWidget *image = NULL; vbox = GTK_WIDGET (gtk_builder_get_object(toplevel,"menu_vbox")); menubar = gtk_menu_bar_new(); gtk_box_pack_end(GTK_BOX(vbox),menubar,FALSE,FALSE,0); item = gtk_menu_item_new_with_mnemonic("_Dashboard"); menu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),menu); gtk_menu_shell_append(GTK_MENU_SHELL(menubar),item); /* Dashboard Menu */ item = gtk_image_menu_item_new_with_mnemonic("_Add Gauge"); OBJ_SET(toplevel,"new_dash_menuitem",item); image = gtk_image_new_from_stock("gtk-add",GTK_ICON_SIZE_MENU); g_object_set(item,"image",image,NULL); if (gtk_minor_version >= 16) g_object_set(item,"always-show-image",TRUE,NULL); g_signal_connect(G_OBJECT(item),"activate",G_CALLBACK(create_preview_list),NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu),item); item = gtk_image_menu_item_new_with_mnemonic("_Load Dash"); OBJ_SET(toplevel,"load_dash_menuitem",item); image = gtk_image_new_from_stock("gtk-open",GTK_ICON_SIZE_MENU); g_object_set(item,"image",image,NULL); if (gtk_minor_version >= 16) g_object_set(item,"always-show-image",TRUE,NULL); g_signal_connect(G_OBJECT(item),"activate",G_CALLBACK(load_handler),NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu),item); item = gtk_image_menu_item_new_with_mnemonic("_Close Dash"); OBJ_SET(toplevel,"close_dash_menuitem",item); image = gtk_image_new_from_stock("gtk-close",GTK_ICON_SIZE_MENU); g_object_set(item,"image",image,NULL); if (gtk_minor_version >= 16) g_object_set(item,"always-show-image",TRUE,NULL); g_signal_connect(G_OBJECT(item),"activate",G_CALLBACK(close_current_dash),NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu),item); item = gtk_image_menu_item_new_with_mnemonic("_Save Dash"); OBJ_SET(toplevel,"save_dash_menuitem",item); image = gtk_image_new_from_stock("gtk-save",GTK_ICON_SIZE_MENU); g_object_set(item,"image",image,NULL); if (gtk_minor_version >= 16) g_object_set(item,"always-show-image",TRUE,NULL); g_signal_connect(G_OBJECT(item),"activate",G_CALLBACK(save_handler),NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu),item); item = gtk_image_menu_item_new_with_mnemonic("Save Dash _As"); OBJ_SET(toplevel,"save_dash_as_menuitem",item); image = gtk_image_new_from_stock("gtk-save-as",GTK_ICON_SIZE_MENU); g_object_set(item,"image",image,NULL); if (gtk_minor_version >= 16) g_object_set(item,"always-show-image",TRUE,NULL); g_signal_connect(G_OBJECT(item),"activate",G_CALLBACK(save_as_handler),NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu),item); item = gtk_image_menu_item_new_with_mnemonic("_Quit"); image = gtk_image_new_from_stock("gtk-quit",GTK_ICON_SIZE_MENU); g_object_set(item,"image",image,NULL); if (gtk_minor_version >= 16) g_object_set(item,"always-show-image",TRUE,NULL); g_signal_connect(G_OBJECT(item),"activate",G_CALLBACK(dashdesigner_quit),NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu),item); gtk_widget_show_all(menu); /* Edit Menu */ item = gtk_menu_item_new_with_mnemonic("_Edit"); menu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),menu); gtk_menu_shell_append(GTK_MENU_SHELL(menubar),item); item = gtk_image_menu_item_new_with_mnemonic("_Optimize Dash Size"); image = gtk_image_new_from_stock("gtk-zoom-in",GTK_ICON_SIZE_MENU); g_object_set(item,"image",image,NULL); if (gtk_minor_version >= 16) g_object_set(item,"always-show-image",TRUE,NULL); g_signal_connect(G_OBJECT(item),"activate",G_CALLBACK(optimize_dash_size),NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu),item); /* Help Menu */ item = gtk_menu_item_new_with_mnemonic("_Help"); menu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),menu); gtk_menu_shell_append(GTK_MENU_SHELL(menubar),item); item = gtk_image_menu_item_new_with_mnemonic("_About DashDesigner"); image = gtk_image_new_from_stock("gtk-about",GTK_ICON_SIZE_MENU); g_object_set(item,"image",image,NULL); if (gtk_minor_version >= 16) g_object_set(item,"always-show-image",TRUE,NULL); g_signal_connect(G_OBJECT(item),"activate",G_CALLBACK(dashdesigner_about),NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu),item); return; }
EXPORT gboolean init_general_attributes(GladeXML *xml) { OBJ_SET((glade_xml_get_widget(xml,"cw_rbutton")),"handler",GINT_TO_POINTER(ROTATION)); OBJ_SET((glade_xml_get_widget(xml,"cw_rbutton")),"special_value",GINT_TO_POINTER(MTX_ROT_CW)); OBJ_SET((glade_xml_get_widget(xml,"ccw_rbutton")),"handler",GINT_TO_POINTER(ROTATION)); OBJ_SET((glade_xml_get_widget(xml,"ccw_rbutton")),"special_value",GINT_TO_POINTER(MTX_ROT_CCW)); OBJ_SET((glade_xml_get_widget(xml,"antialiased_check")),"handler",GINT_TO_POINTER(ANTIALIAS)); OBJ_SET((glade_xml_get_widget(xml,"tattletale_check")),"handler",GINT_TO_POINTER(TATTLETALE)); OBJ_SET((glade_xml_get_widget(xml,"tattletale_alpha_spin")),"handler",GINT_TO_POINTER(TATTLETALE_ALPHA)); OBJ_SET((glade_xml_get_widget(xml,"needle_length_spin")),"handler",GINT_TO_POINTER(NEEDLE_LENGTH)); OBJ_SET((glade_xml_get_widget(xml,"needle_tail_spin")),"handler",GINT_TO_POINTER(NEEDLE_TAIL)); OBJ_SET((glade_xml_get_widget(xml,"needle_tip_width_spin")),"handler",GINT_TO_POINTER(NEEDLE_TIP_WIDTH)); OBJ_SET((glade_xml_get_widget(xml,"needle_tail_width_spin")),"handler",GINT_TO_POINTER(NEEDLE_TAIL_WIDTH)); OBJ_SET((glade_xml_get_widget(xml,"needle_width_spin")),"handler",GINT_TO_POINTER(NEEDLE_WIDTH)); OBJ_SET((glade_xml_get_widget(xml,"start_angle_spin")),"handler",GINT_TO_POINTER(START_ANGLE)); OBJ_SET((glade_xml_get_widget(xml,"sweep_angle_spin")),"handler",GINT_TO_POINTER(SWEEP_ANGLE)); OBJ_SET((glade_xml_get_widget(xml,"lbound_spin")),"handler",GINT_TO_POINTER(LBOUND)); OBJ_SET((glade_xml_get_widget(xml,"ubound_spin")),"handler",GINT_TO_POINTER(UBOUND)); OBJ_SET((glade_xml_get_widget(xml,"background_color_day_button")),"handler",GINT_TO_POINTER(GAUGE_COL_BG_DAY)); OBJ_SET((glade_xml_get_widget(xml,"background_color_nite_button")),"handler",GINT_TO_POINTER(GAUGE_COL_BG_NITE)); OBJ_SET((glade_xml_get_widget(xml,"needle_color_day_button")),"handler",GINT_TO_POINTER(GAUGE_COL_NEEDLE_DAY)); OBJ_SET((glade_xml_get_widget(xml,"needle_color_nite_button")),"handler",GINT_TO_POINTER(GAUGE_COL_NEEDLE_NITE)); OBJ_SET((glade_xml_get_widget(xml,"gradient_begin_color_day_button")),"handler",GINT_TO_POINTER(GAUGE_COL_GRADIENT_BEGIN_DAY)); OBJ_SET((glade_xml_get_widget(xml,"gradient_begin_color_nite_button")),"handler",GINT_TO_POINTER(GAUGE_COL_GRADIENT_BEGIN_NITE)); OBJ_SET((glade_xml_get_widget(xml,"gradient_end_color_day_button")),"handler",GINT_TO_POINTER(GAUGE_COL_GRADIENT_END_DAY)); OBJ_SET((glade_xml_get_widget(xml,"gradient_end_color_nite_button")),"handler",GINT_TO_POINTER(GAUGE_COL_GRADIENT_END_NITE)); update_general_controls(); return TRUE; }
G_MODULE_EXPORT gboolean create_warning_span_event(GtkWidget * widget, gpointer data) { GtkBuilder *warnings; GtkWidget *dialog = NULL; GtkWidget *spinner = NULL; GtkWidget *tmpwidget = NULL; GtkWidget *cbutton = NULL; MtxWarningRange *range = NULL; gfloat lbound = 0.0; gfloat ubound = 0.0; gchar * filename = NULL; gint result = 0; GError *error = NULL; gchar *pathstub = NULL; if (!GTK_IS_WIDGET(gauge)) return FALSE; pathstub = g_build_filename(GAUGEDESIGNER_GLADE_DIR,"w_range.ui",NULL); filename = get_file(NULL,pathstub,NULL); g_free(pathstub); if (filename) { warnings = gtk_builder_new(); if(!gtk_builder_add_from_file(warnings,filename,&error)) { g_warning ("Couldn't load builder file: %s", error->message); g_error_free(error); exit(-1); } g_free(filename); } else { printf("Can't locate primary ui file!!!!\n"); exit(-1); } gtk_builder_connect_signals(warnings,NULL); dialog = GTK_WIDGET (gtk_builder_get_object(warnings,"w_range_dialog")); cbutton = GTK_WIDGET (gtk_builder_get_object(warnings,"range_day_colorbutton")); gtk_color_button_set_color(GTK_COLOR_BUTTON(cbutton),&white); cbutton = GTK_WIDGET (gtk_builder_get_object(warnings,"range_nite_colorbutton")); gtk_color_button_set_color(GTK_COLOR_BUTTON(cbutton),&black); if (!GTK_IS_WIDGET(dialog)) { return FALSE; } /* Set the controls to sane ranges corresponding to the gauge */ mtx_gauge_face_get_attribute(MTX_GAUGE_FACE(gauge), LBOUND, &lbound); mtx_gauge_face_get_attribute(MTX_GAUGE_FACE(gauge), UBOUND, &ubound); spinner = GTK_WIDGET (gtk_builder_get_object(warnings,"range_lowpoint_spin")); OBJ_SET(spinner,"builder",warnings); gtk_spin_button_set_range(GTK_SPIN_BUTTON(spinner),lbound,ubound); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),(ubound-lbound)/2.0); spinner = GTK_WIDGET (gtk_builder_get_object(warnings,"range_highpoint_spin")); OBJ_SET(spinner,"builder",warnings); gtk_spin_button_set_range(GTK_SPIN_BUTTON(spinner),lbound,ubound); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),ubound); result = gtk_dialog_run(GTK_DIALOG(dialog)); switch (result) { case GTK_RESPONSE_APPLY: range = g_new0(MtxWarningRange, 1); range->lowpoint = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(warnings,"range_lowpoint_spin"))); range->highpoint = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(warnings,"range_highpoint_spin"))); range->inset = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(warnings,"range_inset_spin"))); range->lwidth = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(warnings,"range_lwidth_spin"))); gtk_color_button_get_color(GTK_COLOR_BUTTON(gtk_builder_get_object(warnings,"range_day_colorbutton")),&range->color[MTX_DAY]); gtk_color_button_get_color(GTK_COLOR_BUTTON(gtk_builder_get_object(warnings,"range_nite_colorbutton")),&range->color[MTX_NITE]); changed = TRUE; mtx_gauge_face_set_warning_range_struct(MTX_GAUGE_FACE(gauge),range); g_free(range); update_onscreen_w_ranges(); break; default: break; } if (GTK_IS_WIDGET(dialog)) gtk_widget_destroy(dialog); return (FALSE); }
/*! \brief General purpose handler to hide/show Sensor calibrate window \param widget is a pointer to the widget clicked \param data is unused \returns TRUE */ G_MODULE_EXPORT gboolean show_ms2_afr_calibrator_window(GtkWidget *widget, gpointer data) { static GtkWidget *window = NULL; GtkWidget *item = NULL; GtkWidget *item2 = NULL; GladeXML *main_xml = NULL; GladeXML *xml = NULL; Firmware_Details *firmware = NULL; gboolean (*populate_afr_calibrator_combo_f)(GtkWidget *) = NULL; ENTER(); firmware = (Firmware_Details *)DATA_GET(global_data,"firmware"); main_xml = (GladeXML *)DATA_GET(global_data,"main_xml"); if ((!main_xml) || (DATA_GET(global_data,"leaving"))) { EXIT(); return TRUE; } if (!GTK_IS_WIDGET(window)) { xml = glade_xml_new(main_xml->filename,"ms2_afr_calibrator_window",NULL); window = glade_xml_get_widget(xml,"ms2_afr_calibrator_window"); glade_xml_signal_autoconnect(xml); item = glade_xml_get_widget(xml,"ego_sensor_combo"); register_widget_f("afr_calibrate_ego_sensor_combo",item); if (get_symbol_f("populate_afr_calibrator_combo",(void **)&populate_afr_calibrator_combo_f)) populate_afr_calibrator_combo_f(item); item2 = glade_xml_get_widget(xml,"generic_wideband_frame"); OBJ_SET(item,"generic_controls",item2); item = glade_xml_get_widget(xml,"voltage1_entry"); register_widget_f("voltage1_entry",item); OBJ_SET_FULL(item,"raw_lower",g_strdup("0"),g_free); OBJ_SET_FULL(item,"raw_upper",g_strdup("5"),g_free); OBJ_SET(item,"precision",GINT_TO_POINTER(1)); item = glade_xml_get_widget(xml,"voltage2_entry"); register_widget_f("voltage2_entry",item); OBJ_SET_FULL(item,"raw_lower",g_strdup("0"),g_free); OBJ_SET_FULL(item,"raw_upper",g_strdup("5"),g_free); OBJ_SET(item,"precision",GINT_TO_POINTER(1)); item = glade_xml_get_widget(xml,"afr1_entry"); register_widget_f("afr1_entry",item); OBJ_SET_FULL(item,"raw_lower",g_strdup("0"),g_free); OBJ_SET_FULL(item,"raw_upper",g_strdup("99"),g_free); OBJ_SET(item,"precision",GINT_TO_POINTER(1)); item = glade_xml_get_widget(xml,"afr2_entry"); register_widget_f("afr2_entry",item); OBJ_SET_FULL(item,"raw_lower",g_strdup("0"),g_free); OBJ_SET_FULL(item,"raw_upper",g_strdup("99"),g_free); OBJ_SET(item,"precision",GINT_TO_POINTER(1)); gtk_window_set_transient_for(GTK_WINDOW(window),GTK_WINDOW(lookup_widget_f("main_window"))); gtk_widget_show(GTK_WIDGET(window)); EXIT(); return TRUE; } #if GTK_MINOR_VERSION >= 18 if (gtk_widget_get_visible(GTK_WIDGET(window))) #else if (GTK_WIDGET_VISIBLE(GTK_WIDGET(window))) #endif gtk_widget_hide(GTK_WIDGET(window)); else gtk_widget_show(GTK_WIDGET(window)); EXIT(); return TRUE; }
/*! \brief Creates a group of 2D Table Editors packed into a GtkNotebook \param button is a pointer to the widget the user click on, which has bound to is a list of the TE Table ID's which we need to create on-screen representations for \returns TRUE on success, FALSE otherwise */ G_MODULE_EXPORT gboolean create_2d_table_editor_group(GtkWidget *button) { GladeXML *main_xml = NULL; GladeXML *xml = NULL; GtkWidget *widget = NULL; GtkWidget *window = NULL; GtkWidget *notebook = NULL; GtkWidget *curve = NULL; GtkWidget *x_parent = NULL; GtkWidget *y_parent = NULL; GtkWidget *x_table = NULL; GtkWidget *y_table = NULL; GtkWidget *label = NULL; GtkWidget *entry = NULL; GtkWidget *dummy = NULL; GtkWidget *gauge = NULL; GtkWidget *parent = NULL; GtkWidget *curve_parent = NULL; CurveData *cdata = NULL; GArray *x_entries = NULL; GArray *y_entries = NULL; GList *widget_list = NULL; GList *curve_list = NULL; GList *gauge_list = NULL; gchar * tmpbuf = NULL; gchar * filename = NULL; gchar **vector = NULL; GList ***ecu_widgets = NULL; gint num_tabs = 0; gint x_mult = 0; gint y_mult = 0; gint page = 0; gint offset = 0; gint i = 0; gint j = 0; gfloat tmpf = 0.0; guint32 id = 0; gint rows = 0; gint table_num = 0; Firmware_Details *firmware = NULL; firmware = DATA_GET(global_data,"firmware"); ecu_widgets = DATA_GET(global_data,"ecu_widgets"); main_xml = (GladeXML *)DATA_GET(global_data,"main_xml"); if (!main_xml) return FALSE; xml = glade_xml_new(main_xml->filename,"table_editor_window",NULL); window = glade_xml_get_widget(xml,"table_editor_window"); glade_xml_signal_autoconnect(xml); g_signal_connect(G_OBJECT(window),"destroy_event", G_CALLBACK(close_2d_editor),NULL); g_signal_connect(G_OBJECT(window),"delete_event", G_CALLBACK(close_2d_editor),NULL); gtk_window_set_title(GTK_WINDOW(window),_("2D Table Group Editor")); gtk_window_resize(GTK_WINDOW(window),800,530); widget = glade_xml_get_widget(xml,"2d_close_button"); g_signal_connect_swapped(G_OBJECT(widget),"clicked", G_CALLBACK(close_2d_editor),window); widget = glade_xml_get_widget(xml,"get_data_button"); OBJ_SET(widget,"handler",GINT_TO_POINTER(READ_VE_CONST)); OBJ_SET_FULL(widget,"bind_to_list",g_strdup("get_data_buttons"),g_free); bind_to_lists_f(widget,"get_data_buttons"); widget_list = g_list_prepend(widget_list,(gpointer)widget); widget = glade_xml_get_widget(xml,"burn_data_button"); OBJ_SET(widget,"handler",GINT_TO_POINTER(BURN_FLASH)); OBJ_SET_FULL(widget,"bind_to_list",g_strdup("burners"),g_free); bind_to_lists_f(widget,"burners"); widget_list = g_list_prepend(widget_list,(gpointer)widget); /* widget = glade_xml_get_widget(xml,"curve_editor_menuitem"); gtk_widget_set_sensitive(GTK_WIDGET(widget), FALSE); */ widget = glade_xml_get_widget(xml,"close_menuitem"); OBJ_SET(widget,"window",(gpointer)window); widget = glade_xml_get_widget(xml,"te_layout_hbox1"); gtk_widget_destroy(widget); widget = glade_xml_get_widget(xml,"te_layout_vbox"); tmpbuf = OBJ_GET(button,"te_tables"); vector = parse_keys_f(tmpbuf,&num_tabs,","); notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook),GTK_POS_LEFT); gtk_box_pack_start(GTK_BOX(widget),notebook,TRUE,TRUE,0); for (j = 0;j < num_tabs;j++) { table_num = (gint)strtod(vector[j],NULL); if (table_num >= firmware->total_te_tables) { warn_user_f("Requested to create 2D table editor window for an undefined (out of range) table ID"); return FALSE; } if (!firmware->te_params) { warn_user_f("No 2D table Editor tables (te_tables) defined in interrogation profile, yet told to create a graph for a table... BUG detected!"); continue; } if (!firmware->te_params[table_num]) { warn_user_f("Requested to create a 2D table editor window for an undefined table!"); continue; } xml = glade_xml_new(main_xml->filename,"te_layout_hbox1",NULL); widget = glade_xml_get_widget(xml,"te_layout_hbox1"); label = gtk_label_new(firmware->te_params[table_num]->title); gtk_misc_set_alignment(GTK_MISC(label),0,0.5); if (firmware->te_params[table_num]->bind_to_list) { OBJ_SET_FULL(widget,"bind_to_list", g_strdup(firmware->te_params[table_num]->bind_to_list),g_free); OBJ_SET(widget,"match_type", GINT_TO_POINTER(firmware->te_params[table_num]->match_type)); bind_to_lists_f(widget,firmware->te_params[table_num]->bind_to_list); widget_list = g_list_prepend(widget_list,(gpointer)widget); OBJ_SET_FULL(label,"bind_to_list", g_strdup(firmware->te_params[table_num]->bind_to_list),g_free); OBJ_SET(label,"match_type", GINT_TO_POINTER(firmware->te_params[table_num]->match_type)); bind_to_lists_f(label,firmware->te_params[table_num]->bind_to_list); widget_list = g_list_prepend(widget_list,(gpointer)label); } if (firmware->te_params[table_num]->gauge || firmware->te_params[table_num]->c_gauge || firmware->te_params[table_num]->f_gauge) { parent = glade_xml_get_widget(xml,"te_gaugeframe"); gauge = mtx_gauge_face_new(); gauge_list = g_list_prepend(gauge_list,(gpointer)gauge); OBJ_SET(window,"gauge",gauge); if (firmware->te_params[table_num]->gauge_temp_dep) { if ((GINT)DATA_GET(global_data,"mtx_temp_units") == CELSIUS) tmpbuf = g_strdelimit(firmware->te_params[table_num]->c_gauge,"\\",'/'); else if ((GINT)DATA_GET(global_data,"mtx_temp_units") == KELVIN) tmpbuf = g_strdelimit(firmware->te_params[table_num]->c_gauge,"\\",'/'); else tmpbuf = g_strdelimit(firmware->te_params[table_num]->f_gauge,"\\",'/'); } else tmpbuf = g_strdelimit(firmware->te_params[table_num]->gauge,"\\",'/'); filename = get_file(g_strconcat(GAUGES_DATA_DIR,PSEP,tmpbuf,NULL),NULL); mtx_gauge_face_import_xml(MTX_GAUGE_FACE(gauge),filename); lookup_current_value_f(firmware->te_params[table_num]->gauge_datasource, &tmpf); mtx_gauge_face_set_value(MTX_GAUGE_FACE(gauge),tmpf); g_free(filename); id = create_rtv_value_change_watch_f(firmware->te_params[table_num]->gauge_datasource,FALSE,"update_misc_gauge",(gpointer)gauge); OBJ_SET(gauge,"gauge_id",GINT_TO_POINTER(id)); gtk_container_add(GTK_CONTAINER(parent),gauge); } gtk_notebook_append_page(GTK_NOTEBOOK(notebook),widget,label); curve_parent = glade_xml_get_widget(xml,"te_right_frame"); curve = mtx_curve_new(); curve_list = g_list_prepend(curve_list,(gpointer)curve); mtx_curve_set_title(MTX_CURVE(curve),_(firmware->te_params[table_num]->title)); mtx_curve_set_x_axis_label(MTX_CURVE(curve),_(firmware->te_params[table_num]->x_axis_label)); mtx_curve_set_y_axis_label(MTX_CURVE(curve),_(firmware->te_params[table_num]->y_axis_label)); cdata = g_new0(CurveData, 1); cdata->curve = curve; cdata->axis = _X_; cdata->source = firmware->te_params[table_num]->x_source; id = create_rtv_value_change_watch_f(cdata->source,FALSE,"update_curve_marker",(gpointer)cdata); mtx_curve_set_show_x_marker(MTX_CURVE(curve),TRUE); OBJ_SET(curve,"cdata",(gpointer)cdata); OBJ_SET(curve,"marker_id",GINT_TO_POINTER(id)); mtx_curve_set_auto_hide_vertexes(MTX_CURVE(curve),TRUE); g_signal_connect(G_OBJECT(curve),"coords-changed", G_CALLBACK(coords_changed), NULL); g_signal_connect(G_OBJECT(curve),"vertex-proximity", G_CALLBACK(vertex_proximity), NULL); g_signal_connect(G_OBJECT(curve),"marker-proximity", G_CALLBACK(marker_proximity), NULL); label = glade_xml_get_widget(xml,"x_units"); gtk_label_set_markup(GTK_LABEL(label),firmware->te_params[table_num]->x_units); label = glade_xml_get_widget(xml,"y_units"); gtk_label_set_markup(GTK_LABEL(label),firmware->te_params[table_num]->y_units); label = glade_xml_get_widget(xml,"x_title"); gtk_label_set_markup(GTK_LABEL(label),firmware->te_params[table_num]->x_name); label = glade_xml_get_widget(xml,"y_title"); gtk_label_set_markup(GTK_LABEL(label),firmware->te_params[table_num]->y_name); rows = firmware->te_params[table_num]->bincount; mtx_curve_set_empty_array(MTX_CURVE(curve),rows); x_table = gtk_table_new(rows+1,1,FALSE); y_table = gtk_table_new(rows+1,1,FALSE); x_parent = glade_xml_get_widget(xml,"te_x_frame"); y_parent = glade_xml_get_widget(xml,"te_y_frame"); gtk_container_set_border_width(GTK_CONTAINER(x_table),5); gtk_container_set_border_width(GTK_CONTAINER(y_table),5); gtk_container_add(GTK_CONTAINER(x_parent),x_table); gtk_container_add(GTK_CONTAINER(y_parent),y_table); x_mult = get_multiplier_f(firmware->te_params[table_num]->x_size); y_mult = get_multiplier_f(firmware->te_params[table_num]->y_size); x_entries = g_array_new(FALSE,TRUE,sizeof(GtkWidget *)); y_entries = g_array_new(FALSE,TRUE,sizeof(GtkWidget *)); for (i=0;i<rows;i++) { /* X Column */ entry = gtk_entry_new(); OBJ_SET(entry,"last_value",GINT_TO_POINTER(-G_MAXINT)); gtk_entry_set_width_chars(GTK_ENTRY(entry),7); OBJ_SET(entry,"curve_index",GINT_TO_POINTER(i)); g_array_insert_val(x_entries,i,entry); OBJ_SET(entry,"curve_axis",GINT_TO_POINTER(_X_)); OBJ_SET(entry,"dl_type",GINT_TO_POINTER(IMMEDIATE)); OBJ_SET(entry,"handler",GINT_TO_POINTER(GENERIC)); OBJ_SET_FULL(entry,"raw_lower",g_strdup_printf("%i",(firmware->te_params[table_num]->x_raw_lower)),g_free); OBJ_SET_FULL(entry,"raw_upper",g_strdup_printf("%i",(firmware->te_params[table_num]->x_raw_upper)),g_free); OBJ_SET(entry,"fromecu_mult",firmware->te_params[table_num]->x_fromecu_mult); OBJ_SET(entry,"fromecu_add",firmware->te_params[table_num]->x_fromecu_add); OBJ_SET(entry,"precision",GINT_TO_POINTER(firmware->te_params[table_num]->x_precision)); OBJ_SET(entry,"size",GINT_TO_POINTER(firmware->te_params[table_num]->x_size)); OBJ_SET(entry,"page",GINT_TO_POINTER(firmware->te_params[table_num]->x_page)); OBJ_SET(entry,"temp_dep",GINT_TO_POINTER(firmware->te_params[table_num]->x_temp_dep)); OBJ_SET(entry,"use_color",GINT_TO_POINTER(firmware->te_params[table_num]->x_use_color)); if(firmware->te_params[table_num]->x_temp_dep) { OBJ_SET(entry,"widget_temp",DATA_GET(global_data,"mtx_temp_units")); OBJ_SET_FULL(entry,"bind_to_list", g_strdup("temperature"),g_free); bind_to_lists_f(entry,"temperature"); } offset = (i*x_mult) + firmware->te_params[table_num]->x_base; OBJ_SET(entry,"offset",GINT_TO_POINTER(offset)); g_signal_connect(G_OBJECT(entry),"changed", G_CALLBACK(update_2d_curve),curve); g_signal_connect(G_OBJECT(entry),"changed", G_CALLBACK(entry_changed_handler_f),NULL); g_signal_connect(G_OBJECT(entry),"key_press_event", G_CALLBACK(key_event_f),NULL); g_signal_connect(G_OBJECT(entry),"key_release_event", G_CALLBACK(key_event_f),NULL); g_signal_connect(G_OBJECT(entry),"focus_out_event", G_CALLBACK(focus_out_handler_f),NULL); g_signal_connect(G_OBJECT(entry),"activate", G_CALLBACK(std_entry_handler_f),NULL); if (firmware->te_params[table_num]->reversed) gtk_table_attach(GTK_TABLE(x_table),entry, 0,1,rows-i-1,rows-i, GTK_SHRINK,GTK_SHRINK,0,0); else gtk_table_attach(GTK_TABLE(x_table),entry, 0,1,i,i+1, GTK_SHRINK,GTK_SHRINK,0,0); page = firmware->te_params[table_num]->x_page; ecu_widgets[page][offset] = g_list_prepend(ecu_widgets[page][offset],(gpointer)entry); widget_list = g_list_prepend(widget_list,(gpointer)entry); update_widget(G_OBJECT(entry),NULL); /* Y Column */ entry = gtk_entry_new(); OBJ_SET(entry,"last_value",GINT_TO_POINTER(-G_MAXINT)); gtk_entry_set_width_chars(GTK_ENTRY(entry),7); OBJ_SET(entry,"curve_index",GINT_TO_POINTER(i)); g_array_insert_val(y_entries,i,entry); OBJ_SET(entry,"curve_axis",GINT_TO_POINTER(_Y_)); OBJ_SET(entry,"dl_type",GINT_TO_POINTER(IMMEDIATE)); OBJ_SET(entry,"handler",GINT_TO_POINTER(GENERIC)); OBJ_SET_FULL(entry,"raw_lower",g_strdup_printf("%i",(firmware->te_params[table_num]->y_raw_lower)),g_free); OBJ_SET_FULL(entry,"raw_upper",g_strdup_printf("%i",(firmware->te_params[table_num]->y_raw_upper)),g_free); OBJ_SET(entry,"fromecu_mult",firmware->te_params[table_num]->y_fromecu_mult); OBJ_SET(entry,"fromecu_add",firmware->te_params[table_num]->y_fromecu_add); OBJ_SET(entry,"precision",GINT_TO_POINTER(firmware->te_params[table_num]->y_precision)); OBJ_SET(entry,"size",GINT_TO_POINTER(firmware->te_params[table_num]->y_size)); OBJ_SET(entry,"page",GINT_TO_POINTER(firmware->te_params[table_num]->y_page)); OBJ_SET(entry,"temp_dep",GINT_TO_POINTER(firmware->te_params[table_num]->y_temp_dep)); OBJ_SET(entry,"use_color",GINT_TO_POINTER(firmware->te_params[table_num]->y_use_color)); if(firmware->te_params[table_num]->y_temp_dep) { OBJ_SET(entry,"widget_temp",DATA_GET(global_data,"mtx_temp_units")); OBJ_SET_FULL(entry,"bind_to_list", g_strdup("temperature"),g_free); bind_to_lists_f(entry,"temperature"); } offset = (i*y_mult) + firmware->te_params[table_num]->y_base; OBJ_SET(entry,"offset",GINT_TO_POINTER(offset)); g_signal_connect(G_OBJECT(entry),"changed", G_CALLBACK(update_2d_curve),curve); g_signal_connect(G_OBJECT(entry),"changed", G_CALLBACK(entry_changed_handler_f),NULL); g_signal_connect(G_OBJECT(entry),"key_press_event", G_CALLBACK(key_event_f),NULL); g_signal_connect(G_OBJECT(entry),"key_release_event", G_CALLBACK(key_event_f),NULL); g_signal_connect(G_OBJECT(entry),"focus_out_event", G_CALLBACK(focus_out_handler_f),NULL); g_signal_connect(G_OBJECT(entry),"activate", G_CALLBACK(std_entry_handler_f),NULL); if (firmware->te_params[table_num]->reversed) gtk_table_attach(GTK_TABLE(y_table),entry, 0,1,rows-i-1,rows-i, GTK_SHRINK,GTK_SHRINK,0,0); else gtk_table_attach(GTK_TABLE(y_table),entry, 0,1,i,i+1, GTK_SHRINK,GTK_SHRINK,0,0); page = firmware->te_params[table_num]->y_page; ecu_widgets[page][offset] = g_list_prepend(ecu_widgets[page][offset],(gpointer)entry); widget_list = g_list_prepend(widget_list,(gpointer)entry); update_widget(G_OBJECT(entry),NULL); } /* Create the "LOCK" buttons */ dummy = gtk_toggle_button_new_with_label("Unlocked"); OBJ_SET(dummy,"axis",GINT_TO_POINTER(_X_)); g_signal_connect(G_OBJECT(dummy),"toggled", G_CALLBACK(set_axis_locking),curve); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dummy),firmware->te_params[table_num]->x_lock); gtk_table_attach(GTK_TABLE(x_table),dummy, 0,1,i,i+1, GTK_EXPAND|GTK_FILL,0,0,0); dummy = gtk_toggle_button_new_with_label("Unlocked"); OBJ_SET(dummy,"axis",GINT_TO_POINTER(_Y_)); g_signal_connect(G_OBJECT(dummy),"toggled", G_CALLBACK(set_axis_locking),curve); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dummy),firmware->te_params[table_num]->y_lock); gtk_table_attach(GTK_TABLE(y_table),dummy, 0,1,i,i+1, GTK_EXPAND|GTK_FILL,0,0,0); mtx_curve_set_x_precision(MTX_CURVE(curve),firmware->te_params[table_num]->x_precision); mtx_curve_set_y_precision(MTX_CURVE(curve),firmware->te_params[table_num]->y_precision); mtx_curve_set_hard_limits(MTX_CURVE(curve), (gfloat)firmware->te_params[table_num]->x_raw_lower, (gfloat)firmware->te_params[table_num]->x_raw_upper, (gfloat)firmware->te_params[table_num]->y_raw_lower, (gfloat)firmware->te_params[table_num]->y_raw_upper); OBJ_SET(curve,"x_entries",x_entries); OBJ_SET(curve,"y_entries",y_entries); if (firmware->te_params[table_num]->bind_to_list) g_list_foreach(get_list_f(firmware->te_params[table_num]->bind_to_list),alter_widget_state_f,NULL); create_rtv_value_change_watch_f(cdata->source,TRUE,"update_curve_marker",(gpointer)cdata); gtk_container_add(GTK_CONTAINER(curve_parent),curve); } OBJ_SET(window,"widget_list",widget_list); OBJ_SET(window,"curve_list",curve_list); OBJ_SET(window,"gauge_list",gauge_list); gtk_widget_show_all(window); return TRUE; }
EXPORT gboolean read_ve_const(void *data, XmlCmdType type) { extern Firmware_Details *firmware; extern volatile gboolean offline; extern volatile gboolean outstanding_data; extern volatile gint last_page; OutputData *output = NULL; Command *command = NULL; gint i = 0; switch (type) { case MS1_VECONST: if (!offline) { g_list_foreach(get_list("get_data_buttons"),set_widget_sensitive,GINT_TO_POINTER(FALSE)); if (outstanding_data) queue_burn_ecu_flash(last_page); for (i=0;i<firmware->total_pages;i++) { if (!firmware->page_params[i]->dl_by_default) continue; queue_ms1_page_change(i); output = initialize_outputdata(); OBJ_SET(output->object,"page",GINT_TO_POINTER(i)); OBJ_SET(output->object,"phys_ecu_page",GINT_TO_POINTER(firmware->page_params[i]->phys_ecu_page)); OBJ_SET(output->object,"mode", GINT_TO_POINTER(MTX_CMD_WRITE)); io_cmd(firmware->ve_command,output); } } command = (Command *)data; io_cmd(NULL,command->post_functions); break; case MS2_VECONST: if (!offline) { g_list_foreach(get_list("get_data_buttons"),set_widget_sensitive,GINT_TO_POINTER(FALSE)); if ((firmware->capabilities & MS2_E) && (outstanding_data)) queue_burn_ecu_flash(last_page); for (i=0;i<firmware->total_pages;i++) { if (!firmware->page_params[i]->dl_by_default) continue; output = initialize_outputdata(); OBJ_SET(output->object,"page",GINT_TO_POINTER(i)); OBJ_SET(output->object,"phys_ecu_page",GINT_TO_POINTER(firmware->page_params[i]->phys_ecu_page)); OBJ_SET(output->object,"canID",GINT_TO_POINTER(firmware->canID)); OBJ_SET(output->object,"offset", GINT_TO_POINTER(0)); OBJ_SET(output->object,"num_bytes", GINT_TO_POINTER(firmware->page_params[i]->length)); OBJ_SET(output->object,"mode", GINT_TO_POINTER(MTX_CMD_WRITE)); io_cmd(firmware->ve_command,output); } } command = (Command *)data; io_cmd(NULL,command->post_functions); break; case MS2_E_COMPOSITEMON: if (!offline) { if ((firmware->capabilities & MS2_E) && (outstanding_data)) queue_burn_ecu_flash(last_page); output = initialize_outputdata(); OBJ_SET(output->object,"page",GINT_TO_POINTER(firmware->compositemon_page)); OBJ_SET(output->object,"phys_ecu_page",GINT_TO_POINTER(firmware->page_params[firmware->compositemon_page]->phys_ecu_page)); OBJ_SET(output->object,"canID",GINT_TO_POINTER(firmware->canID)); OBJ_SET(output->object,"offset", GINT_TO_POINTER(0)); OBJ_SET(output->object,"num_bytes", GINT_TO_POINTER(firmware->page_params[firmware->compositemon_page]->length)); OBJ_SET(output->object,"mode", GINT_TO_POINTER(MTX_CMD_WRITE)); io_cmd(firmware->ve_command,output); } command = (Command *)data; io_cmd(NULL,command->post_functions); break; case MS2_E_TRIGMON: if (!offline) { if ((firmware->capabilities & MS2_E) && (outstanding_data)) queue_burn_ecu_flash(last_page); output = initialize_outputdata(); OBJ_SET(output->object,"page",GINT_TO_POINTER(firmware->trigmon_page)); OBJ_SET(output->object,"phys_ecu_page",GINT_TO_POINTER(firmware->page_params[firmware->trigmon_page]->phys_ecu_page)); OBJ_SET(output->object,"canID",GINT_TO_POINTER(firmware->canID)); OBJ_SET(output->object,"offset", GINT_TO_POINTER(0)); OBJ_SET(output->object,"num_bytes", GINT_TO_POINTER(firmware->page_params[firmware->trigmon_page]->length)); OBJ_SET(output->object,"mode", GINT_TO_POINTER(MTX_CMD_WRITE)); io_cmd(firmware->ve_command,output); } command = (Command *)data; io_cmd(NULL,command->post_functions); break; case MS2_E_TOOTHMON: if (!offline) { if ((firmware->capabilities & MS2_E) && (outstanding_data)) queue_burn_ecu_flash(last_page); output = initialize_outputdata(); OBJ_SET(output->object,"page",GINT_TO_POINTER(firmware->toothmon_page)); OBJ_SET(output->object,"phys_ecu_page",GINT_TO_POINTER(firmware->page_params[firmware->toothmon_page]->phys_ecu_page)); OBJ_SET(output->object,"canID",GINT_TO_POINTER(firmware->canID)); OBJ_SET(output->object,"offset", GINT_TO_POINTER(0)); OBJ_SET(output->object,"num_bytes", GINT_TO_POINTER(firmware->page_params[firmware->toothmon_page]->length)); OBJ_SET(output->object,"mode", GINT_TO_POINTER(MTX_CMD_WRITE)); io_cmd(firmware->ve_command,output); } command = (Command *)data; io_cmd(NULL,command->post_functions); break; case MS1_E_TRIGMON: if (!offline) { if (outstanding_data) queue_burn_ecu_flash(last_page); queue_ms1_page_change(firmware->trigmon_page); output = initialize_outputdata(); OBJ_SET(output->object,"page",GINT_TO_POINTER(firmware->trigmon_page)); OBJ_SET(output->object,"phys_ecu_page",GINT_TO_POINTER(firmware->page_params[firmware->trigmon_page]->phys_ecu_page)); OBJ_SET(output->object,"mode", GINT_TO_POINTER(MTX_CMD_WRITE)); io_cmd(firmware->ve_command,output); command = (Command *)data; io_cmd(NULL,command->post_functions); } break; case MS1_E_TOOTHMON: if (!offline) { if (outstanding_data) queue_burn_ecu_flash(last_page); queue_ms1_page_change(firmware->toothmon_page); output = initialize_outputdata(); OBJ_SET(output->object,"page",GINT_TO_POINTER(firmware->toothmon_page)); OBJ_SET(output->object,"phys_ecu_page",GINT_TO_POINTER(firmware->page_params[firmware->toothmon_page]->phys_ecu_page)); OBJ_SET(output->object,"mode", GINT_TO_POINTER(MTX_CMD_WRITE)); io_cmd(firmware->ve_command,output); command = (Command *)data; io_cmd(NULL,command->post_functions); } break; default: break; } return TRUE; }
/*! \brief General purpose handler to hide/show tps calibrate window \param widget is the pointer to the TPS caliobration window \param data is unused */ G_MODULE_EXPORT gboolean show_tps_calibrator_window(GtkWidget *widget, gpointer data) { static GtkWidget *window = NULL; GtkWidget *item = NULL; GladeXML *main_xml = NULL; GladeXML *xml = NULL; Firmware_Details *firmware = NULL; GList ***ecu_widgets = NULL; void (*update_widget_f)(gpointer, gpointer) = NULL; ENTER(); if (!update_widget_f) get_symbol_f("update_widget",(void **)&update_widget_f); ecu_widgets = (GList ***)DATA_GET(global_data,"ecu_widgets"); firmware = (Firmware_Details *)DATA_GET(global_data,"firmware"); main_xml = (GladeXML *)DATA_GET(global_data,"main_xml"); if ((!main_xml) || (DATA_GET(global_data,"leaving"))) { EXIT(); return TRUE; } if (!GTK_IS_WIDGET(window)) { xml = glade_xml_new(main_xml->filename,"calibrate_tps_window",NULL); window = glade_xml_get_widget(xml,"calibrate_tps_window"); glade_xml_signal_autoconnect(xml); item = glade_xml_get_widget(xml,"tpsMin_entry"); register_widget_f("tpsMin_entry",item); OBJ_SET(item,"handler",GINT_TO_POINTER(GENERIC)); OBJ_SET(item,"dl_type",GINT_TO_POINTER(IMMEDIATE)); OBJ_SET(item,"last_value",GINT_TO_POINTER(-G_MAXINT)); OBJ_SET(item,"page",GINT_TO_POINTER(0)); if (firmware->capabilities & PIS) OBJ_SET(item,"offset",GINT_TO_POINTER(2676)); else OBJ_SET(item,"offset",GINT_TO_POINTER(518)); OBJ_SET(item,"size",GINT_TO_POINTER(MTX_S16)); OBJ_SET_FULL(item,"raw_lower",g_strdup("0"),g_free); if (firmware->capabilities & PIS) { OBJ_SET_FULL(item,"raw_upper",g_strdup("255"),g_free); OBJ_SET(item,"precision",GINT_TO_POINTER(0)); ecu_widgets[0][2676] = g_list_prepend( ecu_widgets[0][2676], (gpointer)item); } else { OBJ_SET_FULL(item,"raw_upper",g_strdup("2047"),g_free); OBJ_SET(item,"precision",GINT_TO_POINTER(0)); ecu_widgets[0][518] = g_list_prepend( ecu_widgets[0][518], (gpointer)item); } item = glade_xml_get_widget(xml,"tpsMax_entry"); register_widget_f("tpsMax_entry",item); OBJ_SET(item,"handler",GINT_TO_POINTER(GENERIC)); OBJ_SET(item,"dl_type",GINT_TO_POINTER(IMMEDIATE)); OBJ_SET(item,"last_value",GINT_TO_POINTER(-G_MAXINT)); OBJ_SET(item,"page",GINT_TO_POINTER(0)); if (firmware->capabilities & PIS) OBJ_SET(item,"offset",GINT_TO_POINTER(2678)); else OBJ_SET(item,"offset",GINT_TO_POINTER(520)); OBJ_SET(item,"size",GINT_TO_POINTER(MTX_S16)); OBJ_SET_FULL(item,"raw_lower",g_strdup("0"),g_free); if (firmware->capabilities & PIS) { OBJ_SET_FULL(item,"raw_upper",g_strdup("255"),g_free); OBJ_SET(item,"precision",GINT_TO_POINTER(0)); ecu_widgets[0][2678] = g_list_prepend( ecu_widgets[0][2678], (gpointer)item); /* Force them to update */ g_list_foreach(ecu_widgets[0][2676],update_widget_f,NULL); g_list_foreach(ecu_widgets[0][2678],update_widget_f,NULL); } else { OBJ_SET_FULL(item,"raw_upper",g_strdup("2047"),g_free); OBJ_SET(item,"precision",GINT_TO_POINTER(0)); ecu_widgets[0][520] = g_list_prepend( ecu_widgets[0][520], (gpointer)item); /* Force them to update */ g_list_foreach(ecu_widgets[0][518],update_widget_f,NULL); g_list_foreach(ecu_widgets[0][520],update_widget_f,NULL); } item = glade_xml_get_widget(xml,"get_tps_button_min"); OBJ_SET(item,"handler",GINT_TO_POINTER(GET_CURR_TPS)); if (firmware->capabilities & PIS) OBJ_SET_FULL(item,"source",g_strdup("status_adc_tps"),g_free); else OBJ_SET_FULL(item,"source",g_strdup("tpsADC"),g_free); OBJ_SET_FULL(item,"dest_widget",g_strdup("tpsMin_entry"),g_free); item = glade_xml_get_widget(xml,"get_tps_button_max"); OBJ_SET(item,"handler",GINT_TO_POINTER(GET_CURR_TPS)); if (firmware->capabilities & PIS) OBJ_SET_FULL(item,"source",g_strdup("status_adc_tps"),g_free); else OBJ_SET_FULL(item,"source",g_strdup("tpsADC"),g_free); OBJ_SET_FULL(item,"dest_widget",g_strdup("tpsMax_entry"),g_free); gtk_window_set_transient_for(GTK_WINDOW(window),GTK_WINDOW(lookup_widget_f("main_window"))); gtk_widget_show(GTK_WIDGET(window)); EXIT(); return TRUE; } #if GTK_MINOR_VERSION >=18 if (gtk_widget_get_visible(GTK_WIDGET(window))) #else if (GTK_WIDGET_VISIBLE(GTK_WIDGET(window))) #endif gtk_widget_hide(GTK_WIDGET(window)); else gtk_widget_show(GTK_WIDGET(window)); EXIT(); return TRUE; }
/*! \brief General purpose handler to hide/show Battery calibrate window \param widget is a pointer to the widget clicked \param data is unused \returns TRUE */ G_MODULE_EXPORT gboolean show_battery_calibrator_window(GtkWidget *widget, gpointer data) { static GtkWidget *window = NULL; GtkWidget *item = NULL; GladeXML *main_xml = NULL; GladeXML *xml = NULL; gfloat *tmpf = NULL; Firmware_Details *firmware = NULL; GList ***ecu_widgets; void (*update_widget_f)(gpointer, gpointer) = NULL; ENTER(); if (!update_widget_f) get_symbol_f("update_widget",(void **)&update_widget_f); ecu_widgets = (GList ***)DATA_GET(global_data,"ecu_widgets"); firmware = (Firmware_Details *)DATA_GET(global_data,"firmware"); main_xml = (GladeXML *)DATA_GET(global_data,"main_xml"); if ((!main_xml) || (DATA_GET(global_data,"leaving"))) { EXIT(); return TRUE; } if (!GTK_IS_WIDGET(window)) { xml = glade_xml_new(main_xml->filename,"battery_calibration_window",NULL); window = glade_xml_get_widget(xml,"battery_calibration_window"); glade_xml_signal_autoconnect(xml); item = glade_xml_get_widget(xml,"batt0_entry"); register_widget_f("batt0_entry",item); OBJ_SET(item,"page",GINT_TO_POINTER(0)); OBJ_SET(item,"offset",GINT_TO_POINTER(522)); OBJ_SET(item,"handler",GINT_TO_POINTER(GENERIC)); OBJ_SET(item,"dl_type",GINT_TO_POINTER(IMMEDIATE)); OBJ_SET(item,"last_value",GINT_TO_POINTER(-G_MAXINT)); OBJ_SET(item,"precision",GINT_TO_POINTER(1)); OBJ_SET(item,"size",GINT_TO_POINTER(MTX_S16)); tmpf = g_new0(gfloat, 1); *tmpf = 0.1; OBJ_SET_FULL(item,"fromecu_mult",tmpf,g_free); ecu_widgets[0][522] = g_list_prepend( ecu_widgets[0][522], (gpointer)item); item = glade_xml_get_widget(xml,"battmax_entry"); register_widget_f("battmax_entry",item); OBJ_SET(item,"page",GINT_TO_POINTER(0)); OBJ_SET(item,"offset",GINT_TO_POINTER(524)); OBJ_SET(item,"handler",GINT_TO_POINTER(GENERIC)); OBJ_SET(item,"dl_type",GINT_TO_POINTER(IMMEDIATE)); OBJ_SET(item,"last_value",GINT_TO_POINTER(-G_MAXINT)); OBJ_SET(item,"precision",GINT_TO_POINTER(1)); OBJ_SET(item,"size",GINT_TO_POINTER(MTX_S16)); tmpf = g_new0(gfloat, 1); *tmpf = 0.1; OBJ_SET_FULL(item,"fromecu_mult",tmpf,g_free); ecu_widgets[0][524] = g_list_prepend( ecu_widgets[0][524], (gpointer)item); /* Force them to update */ g_list_foreach(ecu_widgets[0][522],update_widget_f,NULL); g_list_foreach(ecu_widgets[0][524],update_widget_f,NULL); item = glade_xml_get_widget(xml,"get_data_button"); OBJ_SET(item,"handler",GINT_TO_POINTER(READ_VE_CONST)); OBJ_SET_FULL(item,"bind_to_list",g_strdup("get_data_buttons"),g_free); item = glade_xml_get_widget(xml,"burn_data_button"); OBJ_SET(item,"handler",GINT_TO_POINTER(BURN_FLASH)); OBJ_SET_FULL(item,"bind_to_list",g_strdup("burners"),g_free); bind_to_lists_f(item,"burners"); gtk_window_set_transient_for(GTK_WINDOW(window),GTK_WINDOW(lookup_widget_f("main_window"))); gtk_widget_show(GTK_WIDGET(window)); EXIT(); return TRUE; } #if GTK_MINOR_VERSION >= 18 if (gtk_widget_get_visible(GTK_WIDGET(window))) #else if (GTK_WIDGET_VISIBLE(GTK_WIDGET(window))) #endif gtk_widget_hide(GTK_WIDGET(window)); else gtk_widget_show(GTK_WIDGET(window)); EXIT(); return TRUE; }
/*! \brief convert_temps() changes the values of controls based on the currently selected temperature scale. IT works for labels, spinbuttons, etc... \param widget (gpointer) pointer to the widget that contains the necessary paramaters re temp (Alt label, etc) \param units (gpointer) the temp scale selected */ G_MODULE_EXPORT void convert_temps(gpointer widget, gpointer units) { static void (*update_widget_f)(gpointer, gpointer); static gboolean (*check_deps)(gconstpointer *) = NULL; gconstpointer *dep_obj = NULL; gfloat upper = 0.0; gfloat lower = 0.0; gfloat value = 0.0; gchar * text = NULL; GtkAdjustment * adj = NULL; gboolean state = FALSE; gint widget_temp = -1; /*extern GdkColor black;*/ extern gconstpointer *global_data; /* If this widgt depends on anything call check_dependancy which will * return TRUE/FALSE. True if what it depends on is in the matching * state, FALSE otherwise... */ if ((!widget) || (DATA_GET(global_data,"leaving"))) return; if (!check_deps) if (!get_symbol("check_dependancies",(void *)&check_deps)) dbg_func(CRITICAL|CONVERSIONS,g_strdup_printf(__FILE__": convert_temps()\n\tCan NOT locate \"check_dependancies\" function pointer in plugins, BUG!\n")); if (!update_widget_f) if(!get_symbol("update_widget",(void *)&update_widget_f)) dbg_func(CRITICAL|CONVERSIONS,g_strdup_printf(__FILE__": convert_temps()\n\tCan NOT locate \"update_widget\" function pointer in plugins, BUG!\n")); dep_obj = (gconstpointer *)OBJ_GET(widget,"dep_object"); widget_temp = (GINT)OBJ_GET(widget,"widget_temp"); if (dep_obj) { if (check_deps) state = check_deps(dep_obj); else dbg_func(CRITICAL|CONVERSIONS,g_strdup_printf(__FILE__": convert_temps()\n\tWidget %s has dependant object bound but can't locate function ptr for \"check_dependancies\" from plugins, BUG!\n",glade_get_widget_name(widget))); } switch ((TempUnits)units) { case FAHRENHEIT: /*printf("fahr %s\n",glade_get_widget_name(widget));*/ if (GTK_IS_LABEL(widget)) { if ((dep_obj) && (state)) text = (gchar *)OBJ_GET(widget,"alt_f_label"); else text = (gchar *)OBJ_GET(widget,"f_label"); gtk_label_set_text(GTK_LABEL(widget),text); //gtk_widget_modify_text(widget,GTK_STATE_NORMAL,&black); OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); } if ((GTK_IS_SPIN_BUTTON(widget)) && (widget_temp != FAHRENHEIT)) { adj = (GtkAdjustment *) gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON(widget)); upper = adj->upper; value = adj->value; lower = adj->lower; if (widget_temp == CELSIUS) { adj->value = c_to_f(value); adj->lower = c_to_f(lower); adj->upper = c_to_f(upper); } else /* Previous is kelvin */ { adj->value = k_to_f(value); adj->lower = k_to_f(lower); adj->upper = k_to_f(upper); } gtk_adjustment_changed(adj); OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); update_widget_f(widget,NULL); } if ((GTK_IS_ENTRY(widget)) && (widget_temp != FAHRENHEIT)) { OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); update_widget_f(widget,NULL); } if ((GTK_IS_RANGE(widget)) && (widget_temp != FAHRENHEIT)) { adj = (GtkAdjustment *) gtk_range_get_adjustment( GTK_RANGE(widget)); upper = adj->upper; lower = adj->lower; value = adj->value; if (widget_temp == CELSIUS) { adj->value = c_to_f(value); adj->lower = c_to_f(lower); adj->upper = c_to_f(upper); } else /* Previous is kelvin */ { adj->value = k_to_f(value); adj->lower = k_to_f(lower); adj->upper = k_to_f(upper); } gtk_range_set_adjustment(GTK_RANGE(widget),adj); OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); } break; case CELSIUS: /*printf("fahr %s\n",glade_get_widget_name(widget));*/ if (GTK_IS_LABEL(widget)) { if ((dep_obj) && (state)) text = (gchar *)OBJ_GET(widget,"alt_c_label"); else text = (gchar *)OBJ_GET(widget,"c_label"); gtk_label_set_text(GTK_LABEL(widget),text); //gtk_widget_modify_text(widget,GTK_STATE_NORMAL,&black); OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); } if ((GTK_IS_SPIN_BUTTON(widget)) && (widget_temp != CELSIUS)) { adj = (GtkAdjustment *) gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON(widget)); upper = adj->upper; value = adj->value; lower = adj->lower; if (widget_temp == FAHRENHEIT) { adj->value = f_to_c(value); adj->lower = f_to_c(lower); adj->upper = f_to_c(upper); } else /* Previous is kelvin */ { adj->value = k_to_c(value); adj->lower = k_to_c(lower); adj->upper = k_to_c(upper); } gtk_adjustment_changed(adj); OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); update_widget_f(widget,NULL); } if ((GTK_IS_ENTRY(widget)) && (widget_temp != CELSIUS)) { OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); update_widget_f(widget,NULL); } if ((GTK_IS_RANGE(widget)) && (widget_temp != CELSIUS)) { adj = (GtkAdjustment *) gtk_range_get_adjustment( GTK_RANGE(widget)); upper = adj->upper; lower = adj->lower; value = adj->value; if (widget_temp == FAHRENHEIT) { adj->value = f_to_c(value); adj->lower = f_to_c(lower); adj->upper = f_to_c(upper); } else /* Previous is kelvin */ { adj->value = k_to_c(value); adj->lower = k_to_c(lower); adj->upper = k_to_c(upper); } gtk_range_set_adjustment(GTK_RANGE(widget),adj); OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); } break; case KELVIN: /*printf("fahr %s\n",glade_get_widget_name(widget));*/ if (GTK_IS_LABEL(widget)) { if ((dep_obj) && (state)) text = (gchar *)OBJ_GET(widget,"alt_k_label"); else text = (gchar *)OBJ_GET(widget,"k_label"); gtk_label_set_text(GTK_LABEL(widget),text); //gtk_widget_modify_text(widget,GTK_STATE_NORMAL,&black); OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); } if ((GTK_IS_SPIN_BUTTON(widget)) && (widget_temp != KELVIN)) { adj = (GtkAdjustment *) gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON(widget)); upper = adj->upper; value = adj->value; lower = adj->lower; if (widget_temp == FAHRENHEIT) { adj->value = f_to_k(value); adj->lower = f_to_k(lower); adj->upper = f_to_k(upper); } else /* Previous is celsius */ { adj->value = c_to_k(value); adj->lower = c_to_k(lower); adj->upper = c_to_k(upper); } gtk_adjustment_changed(adj); OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); update_widget_f(widget,NULL); } if ((GTK_IS_ENTRY(widget)) && (widget_temp != KELVIN)) { OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); update_widget_f(widget,NULL); } if ((GTK_IS_RANGE(widget)) && (widget_temp != KELVIN)) { adj = (GtkAdjustment *) gtk_range_get_adjustment( GTK_RANGE(widget)); upper = adj->upper; lower = adj->lower; value = adj->value; if (widget_temp == FAHRENHEIT) { adj->value = f_to_k(value); adj->lower = f_to_k(lower); adj->upper = f_to_k(upper); } else /* Previous is celsius */ { adj->value = c_to_k(value); adj->lower = c_to_k(lower); adj->upper = c_to_k(upper); } gtk_range_set_adjustment(GTK_RANGE(widget),adj); OBJ_SET(widget,"widget_temp",GINT_TO_POINTER(units)); } break; } }
GtkWidget * build_tblock(MtxTextBlock *tblock, gint index) { /* MUCH faster that the glade way unfortunately */ GtkWidget *notebook = NULL; GtkWidget *table = NULL; GtkWidget *subtable = NULL; GtkWidget *widget = NULL; GtkWidget *x_spin = NULL; GtkWidget *y_spin = NULL; GtkWidget *hbox = NULL; GtkWidget *img = NULL; GtkWidget *label = NULL; GtkWidget *minitable = NULL; gchar * tmpbuf = NULL; table = gtk_table_new(2,2,FALSE); /* Close button */ widget = gtk_button_new(); img = gtk_image_new_from_stock("gtk-close",GTK_ICON_SIZE_MENU); gtk_container_add(GTK_CONTAINER(widget),img); OBJ_SET((widget),"tblock_index",GINT_TO_POINTER(index)); g_signal_connect(G_OBJECT(widget),"clicked", G_CALLBACK(remove_tblock),NULL); gtk_table_attach(GTK_TABLE(table),widget,0,1,0,4,0,0,0,0); notebook = gtk_notebook_new(); gtk_table_attach(GTK_TABLE(table),notebook,1,2,0,1,GTK_EXPAND|GTK_FILL,0,0,0); /* text, color buttons */ subtable = gtk_table_new(1,4,FALSE); gtk_table_set_col_spacings(GTK_TABLE(subtable),5); label = gtk_label_new("Text & Color"); gtk_notebook_append_page(GTK_NOTEBOOK(notebook),subtable,label); gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(notebook),subtable,TRUE,TRUE,GTK_PACK_START); widget = gtk_label_new("Text:"); gtk_table_attach(GTK_TABLE(subtable),widget,0,1,0,1,GTK_FILL,0,0,0); widget = gtk_entry_new(); OBJ_SET(widget,"handler",GINT_TO_POINTER(TB_TEXT)); OBJ_SET(widget,"index",GINT_TO_POINTER(index)); gtk_entry_set_width_chars(GTK_ENTRY(widget),12); gtk_entry_set_text(GTK_ENTRY(widget),tblock->text); g_signal_connect(G_OBJECT(widget),"changed",G_CALLBACK(alter_tblock_data),NULL); gtk_table_attach(GTK_TABLE(subtable),widget,1,2,0,1,GTK_EXPAND|GTK_FILL,0,0,0); widget = gtk_color_button_new_with_color(&tblock->color[MTX_DAY]); OBJ_SET(widget,"handler",GINT_TO_POINTER(TB_COLOR_DAY)); OBJ_SET(widget,"index",GINT_TO_POINTER(index)); g_signal_connect(G_OBJECT(widget),"color_set",G_CALLBACK(alter_tblock_data),NULL); gtk_table_attach(GTK_TABLE(subtable),widget,2,3,0,1,GTK_FILL,0,0,0); widget = gtk_color_button_new_with_color(&tblock->color[MTX_NITE]); OBJ_SET(widget,"handler",GINT_TO_POINTER(TB_COLOR_NITE)); OBJ_SET(widget,"index",GINT_TO_POINTER(index)); g_signal_connect(G_OBJECT(widget),"color_set",G_CALLBACK(alter_tblock_data),NULL); gtk_table_attach(GTK_TABLE(subtable),widget,3,4,0,1,GTK_FILL,0,0,0); /* font, font scale spinner */ subtable = gtk_table_new(1,4,FALSE); gtk_table_set_col_spacings(GTK_TABLE(subtable),5); label = gtk_label_new("Font"); gtk_notebook_append_page(GTK_NOTEBOOK(notebook),subtable,label); gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(notebook),subtable,TRUE,TRUE,GTK_PACK_START); widget = gtk_label_new("Font:"); gtk_table_attach(GTK_TABLE(subtable),widget,0,1,0,1,GTK_FILL,0,0,0); widget = gtk_font_button_new(); OBJ_SET(widget,"handler",GINT_TO_POINTER(TB_FONT)); OBJ_SET(widget,"index",GINT_TO_POINTER(index)); tmpbuf = g_strdup_printf("%s 12",tblock->font); gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget),tmpbuf); gtk_font_button_set_show_size(GTK_FONT_BUTTON(widget),FALSE); gtk_font_button_set_use_size(GTK_FONT_BUTTON(widget),FALSE); gtk_font_button_set_use_font(GTK_FONT_BUTTON(widget),FALSE); g_free(tmpbuf); g_signal_connect(G_OBJECT(widget),"font_set",G_CALLBACK(alter_tblock_data),NULL); gtk_table_attach(GTK_TABLE(subtable),widget,1,2,0,1,GTK_EXPAND|GTK_FILL,0,0,0); widget = gtk_label_new("Font\nScale"); gtk_table_attach(GTK_TABLE(subtable),widget,2,3,0,1,0,0,0,0); widget = gtk_spin_button_new_with_range(0.001,1.0,0.001); OBJ_SET(widget,"handler",GINT_TO_POINTER(TB_FONT_SCALE)); OBJ_SET(widget,"index",GINT_TO_POINTER(index)); g_object_set(G_OBJECT(widget),"climb-rate", 0.001, "digits", 3, "numeric", TRUE, "value", tblock->font_scale, NULL); g_signal_connect(G_OBJECT(widget),"value-changed",G_CALLBACK(alter_tblock_data),NULL); gtk_table_attach(GTK_TABLE(subtable),widget,3,4,0,1,0,0,0,0); /* Location Tab: Edit button, X/Y position spinners */ subtable = gtk_table_new(1,4,FALSE); gtk_table_set_col_spacings(GTK_TABLE(subtable),5); label = gtk_label_new("Location"); gtk_notebook_append_page(GTK_NOTEBOOK(notebook),subtable,label); gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(notebook),subtable,TRUE,TRUE,GTK_PACK_START); widget = gtk_label_new("Position:"); gtk_table_attach(GTK_TABLE(subtable),widget,0,1,0,1,GTK_FILL,0,0,0); /* X position minilayout table */ minitable = gtk_table_new(1,2,FALSE); gtk_table_attach(GTK_TABLE(subtable),minitable,2,3,0,1,GTK_EXPAND,0,0,0); widget = gtk_label_new("X:"); gtk_table_attach(GTK_TABLE(minitable),widget,0,1,0,1,GTK_FILL,0,0,0); widget = gtk_spin_button_new_with_range(-1.0,1.0,0.001); OBJ_SET(widget,"handler",GINT_TO_POINTER(TB_X_POS)); OBJ_SET(widget,"index",GINT_TO_POINTER(index)); g_object_set(G_OBJECT(widget),"climb-rate", 0.001, "digits", 3, "numeric", TRUE, "value", tblock->x_pos, NULL); g_signal_connect(G_OBJECT(widget),"value-changed",G_CALLBACK(alter_tblock_data),NULL); gtk_table_attach(GTK_TABLE(minitable),widget,1,2,0,1,GTK_FILL,0,0,0); x_spin = widget; /* Y position minilayout table */ minitable = gtk_table_new(1,2,FALSE); gtk_table_attach(GTK_TABLE(subtable),minitable,3,4,0,1,GTK_FILL|GTK_EXPAND,0,0,0); widget = gtk_label_new("Y:"); gtk_table_attach(GTK_TABLE(minitable),widget,0,1,0,1,GTK_FILL,0,0,0); widget = gtk_spin_button_new_with_range(-1.0,1.0,0.001); OBJ_SET(widget,"handler",GINT_TO_POINTER(TB_Y_POS)); OBJ_SET(widget,"index",GINT_TO_POINTER(index)); g_object_set(G_OBJECT(widget),"climb-rate", 0.001, "digits", 3, "numeric", TRUE, "value", tblock->y_pos, NULL); g_signal_connect(G_OBJECT(widget),"value-changed",G_CALLBACK(alter_tblock_data),NULL); gtk_table_attach(GTK_TABLE(minitable),widget,1,2,0,1,GTK_FILL,0,0,0); y_spin = widget; widget = gtk_button_new(); OBJ_SET(widget,"x_spin",x_spin); OBJ_SET(widget,"y_spin",y_spin); hbox = gtk_hbox_new(FALSE,0); gtk_container_add(GTK_CONTAINER(widget),hbox); img = gtk_image_new_from_stock("gtk-edit",GTK_ICON_SIZE_MENU); gtk_box_pack_start(GTK_BOX(hbox),img,FALSE,FALSE,0); label = gtk_label_new("Edit"); gtk_box_pack_start(GTK_BOX(hbox),label,TRUE,TRUE,0); g_signal_connect(G_OBJECT(widget),"clicked",G_CALLBACK(grab_coords_event),NULL); gtk_table_attach(GTK_TABLE(subtable),widget,1,2,0,1,GTK_EXPAND|GTK_FILL,0,0,0); /* Layer Tab: Layer */ subtable = gtk_table_new(1,4,FALSE); gtk_table_set_col_spacings(GTK_TABLE(subtable),5); label = gtk_label_new("Layer"); gtk_notebook_append_page(GTK_NOTEBOOK(notebook),subtable,label); gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(notebook),subtable,TRUE,TRUE,GTK_PACK_START); widget = gtk_label_new("Layer:"); gtk_table_attach(GTK_TABLE(subtable),widget,0,1,0,1,GTK_FILL,0,0,0); widget = gtk_spin_button_new_with_range(0.0,10.0,1.0); OBJ_SET(widget,"handler",GINT_TO_POINTER(TB_LAYER)); OBJ_SET(widget,"index",GINT_TO_POINTER(index)); g_object_set(G_OBJECT(widget),"climb-rate", 1.0, "digits", 0, "numeric", TRUE, NULL); gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget),(gfloat)tblock->layer); g_signal_connect(G_OBJECT(widget),"value-changed",G_CALLBACK(alter_tblock_data),NULL); gtk_table_attach(GTK_TABLE(subtable),widget,1,2,0,1,GTK_FILL,0,0,0); widget = gtk_hseparator_new(); gtk_table_attach(GTK_TABLE(table),widget,0,2,1,2,GTK_FILL,0,0,0); return table; }
/*! \brief populate_dlog_choices_pf() is called when the datalogging tab is loaded by glade AFTER the realtime variable definitions have been loaded and processed. All of the logable variables are then placed here for user selecting during datalogging. */ G_MODULE_EXPORT void populate_dlog_choices(void) { guint i,j,k; GList *list = NULL; GtkWidget *vbox = NULL; GtkWidget *table = NULL; GtkWidget *button = NULL; GtkWidget *label = NULL; gint table_rows = 0; gconstpointer * object = NULL; gchar * dlog_name = NULL; gchar * tooltip = NULL; Rtv_Map *rtv_map = NULL; ENTER(); rtv_map = (Rtv_Map *)DATA_GET(global_data,"rtv_map"); if (DATA_GET(global_data,"leaving")) { EXIT(); return; } if (!((DATA_GET(global_data,"connected")) && (DATA_GET(global_data,"interrogated")))) { EXIT(); return; } if (!DATA_GET(global_data,"rtvars_loaded")) { MTXDBG(CRITICAL,_("CRITICAL ERROR, Realtime Variable definitions are NOT LOADED!!!\n")); EXIT(); return; } set_title(g_strdup(_("Populating Datalogger..."))); vbox = lookup_widget("dlog_logable_vars_vbox1"); if (!GTK_IS_WIDGET(vbox)) { printf(_("datalogger windows not present, returning\n")); EXIT(); return; } table_rows = ceil((float)rtv_map->derived_total/(float)TABLE_COLS); table = gtk_table_new(table_rows,TABLE_COLS,FALSE); gtk_table_set_row_spacings(GTK_TABLE(table),0); gtk_table_set_col_spacings(GTK_TABLE(table),0); gtk_container_set_border_width(GTK_CONTAINER(table),0); gtk_box_pack_start(GTK_BOX(vbox),table,TRUE,TRUE,0); /* Update status of the delimiter buttons... */ switch ((GINT)DATA_GET(global_data,"preferred_delimiter")) { case COMMA: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget("dlog_comma_delimit_radio_button")),TRUE); gtk_toggle_button_toggled(GTK_TOGGLE_BUTTON(lookup_widget("dlog_comma_delimit_radio_button"))); break; case TAB: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget("dlog_tab_delimit_radio_button")),TRUE); gtk_toggle_button_toggled(GTK_TOGGLE_BUTTON(lookup_widget("dlog_tab_delimit_radio_button"))); break; default: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget("dlog_comma_delimit_radio_button")),TRUE); gtk_toggle_button_toggled(GTK_TOGGLE_BUTTON(lookup_widget("dlog_comma_delimit_radio_button"))); break; } j = 0; k = 0; /* Put into GList and sort it */ for (i=0;i<rtv_map->derived_total;i++) list = g_list_prepend(list,(gpointer)g_ptr_array_index(rtv_map->rtv_list,i)); list = g_list_sort_with_data(list,list_object_sort,(gpointer)"dlog_gui_name"); for (i=0;i<rtv_map->derived_total;i++) { tooltip = NULL; dlog_name = NULL; //object = g_ptr_array_index(rtv_map->rtv_list,i); object = (gconstpointer *)g_list_nth_data(list,i); dlog_name = (gchar *)DATA_GET(object,"dlog_gui_name"); button = gtk_check_button_new(); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label),dlog_name); gtk_container_add(GTK_CONTAINER(button),label); tooltip = (gchar *)(DATA_GET(object,"tooltip")); if (tooltip) gtk_widget_set_tooltip_text(button,tooltip); /* Bind button to the object, Done so that we can set the state * of the buttons from elsewhere... */ DATA_SET(object,"dlog_button",(gpointer)button); /* Bind object to the button */ OBJ_SET(button,"object",(gpointer)object); g_signal_connect(G_OBJECT(button),"toggled", G_CALLBACK(log_value_set), NULL); if ((GINT)DATA_GET(object,"log_by_default") == 1) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),TRUE); gtk_table_attach (GTK_TABLE (table), button, j, j+1, k, k+1, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL|GTK_SHRINK), (GtkAttachOptions) (GTK_FILL|GTK_SHRINK), //(GtkAttachOptions) (GTK_FILL|GTK_SHRINK), //(GtkAttachOptions) (GTK_FILL|GTK_SHRINK), 0, 0); j++; if (j == TABLE_COLS) { k++; j = 0; } } g_list_free(list); gtk_widget_show_all(vbox); set_title(g_strdup(_("Datalogger Ready..."))); EXIT(); return; }
/*! \brief read_log_header() First we read the first line, try to determine if the delimiter is a COMMA, or a TAB. \param iochannel is the iochannel that represents the input file \param log_info is the the Log_Info structure */ G_MODULE_EXPORT void read_log_header(GIOChannel *iochannel, Log_Info *log_info ) { GString *a_line = g_string_new("\0"); GIOStatus status = G_IO_STATUS_ERROR; gchar *delimiter = NULL; gchar **fields = NULL; gint num_fields = 0; GArray *array = NULL; gconstpointer *object = NULL; gint i = 0; Rtv_Map *rtv_map; extern gconstpointer *global_data; rtv_map = DATA_GET(global_data,"rtv_map"); read_again: status = g_io_channel_read_line_string(iochannel,a_line,NULL,NULL); if (status == G_IO_STATUS_NORMAL) /* good read */ { /* This searched for a quoted string which should be the * ecu signature. pre 0.9.15 versions of megatunix shoved the * internal name of the firmware in there which is a problem as * it makes the logs locked to megatunix which is a bad thing * as it hurts interoperability. 0.9.16+ changes this to use * the REAL signature returned by the firmware. */ if (g_strrstr(a_line->str,"\"") != NULL) { log_info->signature = g_strdup(g_strstrip(g_strdelimit(a_line->str,"\"\n\r",' '))); /*printf(_("LOG signature is \"%s\"\n"),log_info->signature);*/ if (DATA_GET(global_data,"offline")) { printf("rtv_map->applicable_signatures is \"%s\"\n",rtv_map->applicable_signatures); if (rtv_map->applicable_signatures) { if (strstr(rtv_map->applicable_signatures,log_info->signature) != NULL) printf(_("Good this firmware is compatible with the firmware we're using\n")); else printf(_("mismatch between datalog and current firmware, playback via full gui will probably not work like you expected\n")); } } goto read_again; } if (g_strrstr(a_line->str,",") != NULL) delimiter = g_strdup(","); else if (g_strrstr(a_line->str,"\t") != NULL) delimiter = g_strdup("\t"); /* Store delimiter in structure */ log_info->delimiter = g_strdup(delimiter); /* Store field names as well... * log_info->fields is a string vector (char **) * that is NULL terminated thanks to g_strsplit(void) */ fields = parse_keys(a_line->str,&num_fields,delimiter); log_info->field_count = num_fields; /* Create objects, arrays and storage points... */ for (i=0;i<num_fields;i++) { array = NULL; object = g_new0(gconstpointer, 1); array = g_array_sized_new(FALSE,TRUE,sizeof(gfloat),4096); DATA_SET(object,"data_array",(gpointer)array); g_free(DATA_GET(object,"lview_name")); DATA_SET_FULL(object,"lview_name",g_strdup(g_strstrip(fields[i])),g_free); g_ptr_array_add(log_info->log_list,object); } /* Enable parameter selection button */ gtk_widget_set_sensitive(lookup_widget("logviewer_select_params_button"), TRUE); OBJ_SET(lookup_widget("logviewer_trace_darea"),"log_info",(gpointer)log_info); } g_free(delimiter); }
void update_onscreen_w_ranges() { GtkWidget *container = NULL; static GtkWidget *table = NULL; GtkWidget *dummy = NULL; GtkWidget *label = NULL; GtkWidget *button = NULL; GtkWidget *img = NULL; GtkAdjustment *adj = NULL; guint i = 0; gint y = 1; gfloat low = 0.0; gfloat high = 0.0; MtxWarningRange *range = NULL; GArray * array = NULL; if ((!toplevel) || (!GTK_IS_WIDGET(gauge))) return; array = (GArray *)mtx_gauge_face_get_warning_ranges(MTX_GAUGE_FACE(gauge)); container = GTK_WIDGET (gtk_builder_get_object(toplevel,"warning_range_viewport")); if (!GTK_IS_WIDGET(container)) { printf("color range viewport invalid!!\n"); return; } y=1; if (GTK_IS_WIDGET(table)) gtk_widget_destroy(table); table = gtk_table_new(2,7,FALSE); gtk_container_add(GTK_CONTAINER(container),table); if (array->len > 0) { /* Create headers */ label = gtk_label_new("Low"); gtk_table_attach(GTK_TABLE(table),label,1,2,0,1,GTK_EXPAND,GTK_SHRINK,0,0); label = gtk_label_new("High"); gtk_table_attach(GTK_TABLE(table),label,2,3,0,1,GTK_EXPAND,GTK_SHRINK,0,0); label = gtk_label_new("Inset"); gtk_table_attach(GTK_TABLE(table),label,3,4,0,1,GTK_EXPAND,GTK_SHRINK,0,0); label = gtk_label_new("LWidth"); gtk_table_attach(GTK_TABLE(table),label,4,5,0,1,GTK_EXPAND,GTK_SHRINK,0,0); label = gtk_label_new("Day Color"); gtk_table_attach(GTK_TABLE(table),label,5,6,0,1,GTK_EXPAND,GTK_SHRINK,0,0); label = gtk_label_new("Night Color"); gtk_table_attach(GTK_TABLE(table),label,6,7,0,1,GTK_EXPAND,GTK_SHRINK,0,0); } /* Repopulate the table with the current ranges... */ for (i=0;i<array->len; i++) { range = g_array_index(array,MtxWarningRange *, i); button = gtk_button_new(); img = gtk_image_new_from_stock("gtk-close",GTK_ICON_SIZE_MENU); gtk_container_add(GTK_CONTAINER(button),img); OBJ_SET((button),"range_index",GINT_TO_POINTER(i)); g_signal_connect(G_OBJECT(button),"clicked", G_CALLBACK(remove_w_range),NULL); gtk_table_attach(GTK_TABLE(table),button,0,1,y,y+1,(GtkAttachOptions)0,(GtkAttachOptions)0,0,0); mtx_gauge_face_get_attribute(MTX_GAUGE_FACE(gauge), LBOUND, &low); mtx_gauge_face_get_attribute(MTX_GAUGE_FACE(gauge), UBOUND, &high); dummy = gtk_spin_button_new_with_range(low,high,(high-low)/100); OBJ_SET(dummy,"index",GINT_TO_POINTER(i)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(dummy),range->lowpoint); g_signal_connect(G_OBJECT(dummy),"value_changed", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_LOWPOINT)); gtk_table_attach(GTK_TABLE(table),dummy,1,2,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0); dummy = gtk_spin_button_new_with_range(low,high,(high-low)/100); OBJ_SET(dummy,"index",GINT_TO_POINTER(i)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(dummy),range->highpoint); g_signal_connect(G_OBJECT(dummy),"value_changed", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_HIGHPOINT)); gtk_table_attach(GTK_TABLE(table),dummy,2,3,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0); dummy = gtk_spin_button_new_with_range(0,1,0.001); OBJ_SET(dummy,"index",GINT_TO_POINTER(i)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(dummy),range->inset); g_signal_connect(G_OBJECT(dummy),"value_changed", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_INSET)); gtk_table_attach(GTK_TABLE(table),dummy,3,4,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0); dummy = gtk_spin_button_new_with_range(0,1,0.001); OBJ_SET(dummy,"index",GINT_TO_POINTER(i)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(dummy),range->lwidth); g_signal_connect(G_OBJECT(dummy),"value_changed", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_LWIDTH)); gtk_table_attach(GTK_TABLE(table),dummy,4,5,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0); dummy = gtk_color_button_new_with_color(&range->color[MTX_DAY]); OBJ_SET(dummy,"index",GINT_TO_POINTER(i)); g_signal_connect(G_OBJECT(dummy),"color_set", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_COLOR_DAY)); gtk_table_attach(GTK_TABLE(table),dummy,5,6,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0); dummy = gtk_color_button_new_with_color(&range->color[MTX_NITE]); OBJ_SET(dummy,"index",GINT_TO_POINTER(i)); g_signal_connect(G_OBJECT(dummy),"color_set", G_CALLBACK(alter_w_range_data),GINT_TO_POINTER(WR_COLOR_NITE)); gtk_table_attach(GTK_TABLE(table),dummy,6,7,y,y+1,GTK_SHRINK,GTK_SHRINK,0,0); y++; } /* Scroll to end */ dummy = GTK_WIDGET (gtk_builder_get_object(toplevel,"crange_swin")); adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(dummy)); gtk_adjustment_set_value(adj,gtk_adjustment_get_upper(adj)); gtk_widget_show_all(container); }