コード例 #1
0
ファイル: ms1-t-logger.c プロジェクト: Torture/MegaTunix
EXPORT gboolean ms1_tlogger_button_handler(GtkWidget * widget, gpointer data)
{
	gint handler = (GINT)OBJ_GET(widget, "handler");

	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
	{       /* It's pressed (or checked) */
		switch ((ToggleButton)handler)
		{

			case START_TOOTHMON_LOGGER:
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget("triggerlogger_buttons_table")),FALSE);
				bind_ttm_to_page((GINT)OBJ_GET(widget,"page"));
				start_tickler(TOOTHMON_TICKLER);
				break;
			case START_TRIGMON_LOGGER:
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget("toothlogger_buttons_table")),FALSE);
				bind_ttm_to_page((GINT)OBJ_GET(widget,"page"));
				start_tickler(TRIGMON_TICKLER);
				break;
			case STOP_TOOTHMON_LOGGER:
				stop_tickler(TOOTHMON_TICKLER);
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget("triggerlogger_buttons_table")),TRUE);
				break;
			case STOP_TRIGMON_LOGGER:
				stop_tickler(TRIGMON_TICKLER);
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget("toothlogger_buttons_table")),TRUE);
				break;
			default:
				break;
		}
	}
	return TRUE;
}
コード例 #2
0
ファイル: ms2_gui_handlers.c プロジェクト: JacobD10/MegaTunix
/*!
  \brief ECU specific toggle button handler
  \param widget is a pointer to the widget the user modified
  \param data is unused
  \returns TRUE
  */
G_MODULE_EXPORT gboolean ecu_toggle_button_handler(GtkWidget *widget, gpointer data)
{
	extern MS2_TTMon_Data *ttm_data;
	gint handler = -1;
	
	ENTER();
	handler = (GINT)OBJ_GET(widget,"handler");

	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
	{       /* It's pressed (or checked) */
		switch ((MS2ToggleHandler)handler)
		{

			case START_TOOTHMON_LOGGER:
				ttm_data->stop = FALSE;
				OBJ_SET(ttm_data->darea,"io_cmd_function",(gpointer)"ms2_e_read_toothmon");
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget_f("triggerlogger_buttons_table")),FALSE);
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget_f("compositelogger_buttons_table")),FALSE);
				bind_ttm_to_page((GINT)OBJ_GET(widget,"page"));
				io_cmd_f("ms2_e_read_toothmon",NULL);
				break;
			case START_TRIGMON_LOGGER:
				ttm_data->stop = FALSE;
				OBJ_SET(ttm_data->darea,"io_cmd_function",(gpointer)"ms2_e_read_trigmon");
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget_f("toothlogger_buttons_table")),FALSE);
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget_f("compositelogger_buttons_table")),FALSE);
				bind_ttm_to_page((GINT)OBJ_GET(widget,"page"));
				io_cmd_f("ms2_e_read_trigmon",NULL);
				break;
			case START_COMPOSITEMON_LOGGER:
				ttm_data->stop = FALSE;
				OBJ_SET(ttm_data->darea,"io_cmd_function",(gpointer)"ms2_e_read_compositemon");
				alter_widget_state_f(GTK_WIDGET(lookup_widget_f("toothlogger_buttons_table")),NULL);
				alter_widget_state_f(GTK_WIDGET(lookup_widget_f("triggerlogger_buttons_table")),NULL);
				bind_ttm_to_page((GINT)OBJ_GET(widget,"page"));
				io_cmd_f("ms2_e_read_compositemon",NULL);
				break;
			case STOP_TOOTHMON_LOGGER:
				ttm_data->stop = TRUE;
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget_f("triggerlogger_buttons_table")),TRUE);
				gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget_f("compositelogger_buttons_table")),TRUE);
				break;
			case STOP_TRIGMON_LOGGER:
				ttm_data->stop = TRUE;
				alter_widget_state_f(GTK_WIDGET(lookup_widget_f("toothlogger_buttons_table")),NULL);
				alter_widget_state_f(GTK_WIDGET(lookup_widget_f("compositelogger_buttons_table")),NULL);
				break;
			case STOP_COMPOSITEMON_LOGGER:
				ttm_data->stop = TRUE;
				alter_widget_state_f(GTK_WIDGET(lookup_widget_f("toothlogger_buttons_table")),NULL);
				alter_widget_state_f(GTK_WIDGET(lookup_widget_f("triggerlogger_buttons_table")),NULL);
				break;
			default:
				MTXDBG(CRITICAL,_("Default case reached,  i.e. handler not found in global, common or ECU plugins for widget %s, BUG!\n"),glade_get_widget_name(widget));
				break;
		}
	}
	EXIT();
	return TRUE;
}
コード例 #3
0
ファイル: events.c プロジェクト: Torture/MegaTunix
gboolean gauge_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
	GtkWidget *x_spin = NULL;
	GtkWidget *y_spin = NULL;
	GtkWidget *x_o_spin = NULL;
	GtkWidget *y_o_spin = NULL;
	gfloat x_origin = 0.0;
	gfloat y_origin = 0.0;
	x_spin = (GtkWidget *)OBJ_GET(widget,"x_spin");
	y_spin = (GtkWidget *)OBJ_GET(widget,"y_spin");
	if ((!GTK_IS_WIDGET(x_spin)) || (!GTK_IS_WIDGET(y_spin)))
		return FALSE;
	if ((GBOOLEAN)OBJ_GET(x_spin,"relative"))
	{
		x_o_spin = (GtkWidget *)OBJ_GET(x_spin,"x_o_spin");
		y_o_spin = (GtkWidget *)OBJ_GET(x_spin,"y_o_spin");
		x_origin = gtk_spin_button_get_value(GTK_SPIN_BUTTON(x_o_spin));
		y_origin = gtk_spin_button_get_value(GTK_SPIN_BUTTON(y_o_spin));
		if (GTK_IS_WIDGET(x_spin))
			gtk_spin_button_set_value(GTK_SPIN_BUTTON(x_spin),((event->x-(widget->allocation.width/2.0))/(widget->allocation.width/2.0))-x_origin);
		if (GTK_IS_WIDGET(y_spin))
			gtk_spin_button_set_value(GTK_SPIN_BUTTON(y_spin),((event->y-(widget->allocation.height/2.0))/(widget->allocation.height/2.0))-y_origin);
	}
	else
	{
		if (GTK_IS_WIDGET(x_spin))
			gtk_spin_button_set_value(GTK_SPIN_BUTTON(x_spin),(event->x-(widget->allocation.width/2.0))/(widget->allocation.width/2.0));
		if (GTK_IS_WIDGET(y_spin))
			gtk_spin_button_set_value(GTK_SPIN_BUTTON(y_spin),(event->y-(widget->allocation.height/2.0))/(widget->allocation.height/2.0));
	}
	return TRUE;
}
コード例 #4
0
ファイル: runtime_text.c プロジェクト: seank/MegaTunix
/*!
 \brief add_additional_rtt() is called as a post function for Tab loading
 to add an RTT on a normal widget tab. (AE wizard currently)
 \param widget, pointer to widget containing the data needed
 */
G_MODULE_EXPORT void add_additional_rtt(GtkWidget *widget)
{
	GHashTable *rtt_hash = NULL;
	gchar * ctrl_name = NULL;
	gchar * source = NULL;
	Rt_Text *rt_text = NULL;
	gboolean show_prefix = FALSE;

	rtt_hash = DATA_GET(global_data,"rtt_hash");
	ctrl_name = OBJ_GET(widget,"ctrl_name");
	source = OBJ_GET(widget,"source");
	show_prefix = (GBOOLEAN)OBJ_GET(widget,"show_prefix");

	if (!rtt_hash)
	{
		rtt_hash = g_hash_table_new_full(g_str_hash,g_str_equal,g_free,dealloc_rtt);
		DATA_SET_FULL(global_data,"rtt_hash",(gpointer)rtt_hash,g_hash_table_destroy);
	}

	if ((rtt_hash) && (ctrl_name) && (source))
		rt_text = add_rtt(widget,ctrl_name,source,show_prefix);

	if (rt_text)
	{
		if (!g_hash_table_lookup(rtt_hash,ctrl_name))
			g_hash_table_insert(rtt_hash,
					g_strdup(ctrl_name),
					(gpointer)rt_text);
	}
	return;
}
コード例 #5
0
/*!
  \brief Closes a 2-D table editor and deallocates any required resources
  \param widget is the 2D table editor window containing the widget list to
  be deallocated
  \param data is unused
  \returns FALSE
  */
G_MODULE_EXPORT gboolean close_2d_editor(GtkWidget * widget, gpointer data)
{
	GList *list = NULL;

	list = OBJ_GET(widget, "widget_list");
	if (list)
	{
		g_list_foreach(list,remove_widget,NULL);
		g_list_free(list);
		list = NULL;
	}
	list = OBJ_GET(widget, "curve_list");
	if (list)
	{
		g_list_foreach(list,clean_curve,NULL);
		g_list_free(list);
		list = NULL;
	}
	list = OBJ_GET(widget, "gauge_list");
	if (list)
	{
		g_list_foreach(list,gauge_cleanup,NULL);
		g_list_free(list);
		list = NULL;
	}
	gtk_widget_destroy(widget);
	return FALSE;
}
コード例 #6
0
ファイル: listmgmt.c プロジェクト: Torture/MegaTunix
gint list_object_sort(gconstpointer a, gconstpointer b, gpointer data)
{
	GObject *a1 = (GObject *)a;
	GObject *b1 = (GObject *)b;
	const gchar *key = (const gchar *)data;
	return g_ascii_strcasecmp((gchar *)OBJ_GET(a1,key),(gchar *)OBJ_GET(b1,key));
}
コード例 #7
0
ファイル: handlers.c プロジェクト: toxicgumbo/MegaTunix
G_MODULE_EXPORT gboolean generic_spin_button_handler(GtkWidget *widget, gpointer data)
{
	gfloat tmpf = 0.0;
	MtxGaugeFace *g = NULL;
	gint handler = 0;

	tmpf = (gfloat)gtk_spin_button_get_value((GtkSpinButton *)widget);
	if (!OBJ_GET((widget),"handler"))
	{
		printf("control %s has no handler\n",(gchar *)gtk_widget_get_name(widget));
		return FALSE;
	}
	handler = (GINT)OBJ_GET((widget),"handler");

	if (GTK_IS_WIDGET(gauge))
		g = MTX_GAUGE_FACE(gauge);
	else
		return FALSE;

	if (hold_handlers)
		return TRUE;
	changed = TRUE;
	mtx_gauge_face_set_attribute(g,handler,tmpf);
	if ((handler == UBOUND) || (handler == LBOUND))
		update_attributes();
	return TRUE;
}
コード例 #8
0
ファイル: ms2_gui_handlers.c プロジェクト: JacobD10/MegaTunix
/*!
  \brief ECU specific std button handler
  \param widget is a pointer to the widget the user modified
  \param data is unused
  \returns TRUE
  */
G_MODULE_EXPORT gboolean ecu_std_button_handler(GtkWidget *widget, gpointer data)
{
	gint handler = 0;
	gchar *tmpbuf = NULL;
	gfloat tmpf = 0.0;
	const gchar *dest = NULL;

	ENTER();
	handler = (MS2StdHandler)(GINT)OBJ_GET(widget,"handler");

	switch ((MS2StdHandler)handler)
	{
		case GET_CURR_TPS:
			tmpbuf = (gchar *)OBJ_GET(widget,"source");
			lookup_current_value_f(tmpbuf,&tmpf);
			dest = (const gchar *)OBJ_GET(widget,"dest_widget");
			tmpbuf = g_strdup_printf("%.0f",tmpf);
			gtk_entry_set_text(GTK_ENTRY(lookup_widget_f(dest)),tmpbuf);
			g_signal_emit_by_name(lookup_widget_f(dest),"activate",NULL);
			g_free(tmpbuf);
			break;
		default:
			MTXDBG(CRITICAL,_("ERROR handler NOT found for widget %s, command aborted! BUG!!!\n"),glade_get_widget_name(widget));
			break;
	}
	EXIT();
	return TRUE;
}
コード例 #9
0
ファイル: widgetmgmt.c プロジェクト: toxicgumbo/MegaTunix
/*!
  \brief  sets a widget sensitive or insensitive based on the status of
  dependant groups
  \param key is the pointer to Widget
  \param data is unused
  */
G_MODULE_EXPORT void alter_widget_state(gpointer key, gpointer data)
{
	GtkWidget * widget = key;
	gchar * tmpbuf = NULL;
	//const gchar * name = NULL;
	gchar ** groups = NULL;
	gint num_groups = 0;
	gint i = 0;
	gboolean value = FALSE;
	gboolean state = FALSE;
	MatchType type = AND;
	GHashTable *widget_group_states = NULL;

	if (!GTK_IS_WIDGET(widget))
		return;

	if (!OBJ_GET(widget,"bind_to_list"))
	{
		/* Not in a list, then enable it */
		gtk_widget_set_sensitive(GTK_WIDGET(widget),TRUE);
		/*name = glade_get_widget_name(widget);
		MTXDBG(CRITICAL,(_("alter_widget_state(): Error with widget \"%s\", bind_to_list is null\n"),(name == NULL ? "undefined":name)));*/
		return;
	}
	else
	        tmpbuf = (gchar *)OBJ_GET(widget,"bind_to_list");

	widget_group_states = DATA_GET(global_data,"widget_group_states");
	if (OBJ_GET(widget,"match_type"))
		type = (MatchType)OBJ_GET(widget,"match_type");
	groups = parse_keys(tmpbuf,&num_groups,",");
	state = TRUE;
	/*printf("setting state for %s in groups \"%s\" to:",(gchar *) OBJ_GET(widget,"name"),tmpbuf);*/
	for (i=0;i<num_groups;i++)
	{
		value = (GBOOLEAN)g_hash_table_lookup(widget_group_states,groups[i]);
		if (type == AND)
		{
			if (value == FALSE)
			{
				state = FALSE;
				break;
			}
		}
		else if (type == OR)
		{
			if (value == TRUE)
			{
				state = TRUE;
				break;
			}
			else
				state = FALSE;
		}
	}
	g_strfreev(groups);
	/*printf("%i\n",state);*/
	gtk_widget_set_sensitive(GTK_WIDGET(widget),state);
}
コード例 #10
0
/*!
  \brief  removes the watch that drives the gauge on the 2D editor winddow
  \param gauge_ptr is the pointer to the Gauge object
  \param data is unused
  */
G_MODULE_EXPORT void gauge_cleanup(gpointer gauge_ptr, gpointer data)
{
	gint id = 0;
	GtkWidget *widget = (GtkWidget *)gauge_ptr;
	if (OBJ_GET(widget, "gauge_id"))
	{
		id = (GINT)OBJ_GET(widget, "gauge_id");
		remove_rtv_watch_f(id);
	}
}
コード例 #11
0
ファイル: tgroups.c プロジェクト: toxicgumbo/MegaTunix
gboolean alter_tgroup_data(GtkWidget *widget, gpointer data)
{
	gint index = (GINT)OBJ_GET((widget),"index");
	gfloat value = 0.0;
	gchar * tmpbuf = NULL;
	GdkColor color;
	TgField field = (TgField)OBJ_GET(widget,"handler");
	if (!GTK_IS_WIDGET(gauge))
		return FALSE;

	switch (field)
	{
		case TG_FONT_SCALE:
		case TG_LAYER:
		case TG_TEXT_INSET:
		case TG_MAJ_TICK_INSET:
		case TG_MIN_TICK_INSET:
		case TG_MAJ_TICK_WIDTH:
		case TG_MAJ_TICK_LENGTH:
		case TG_MIN_TICK_WIDTH:
		case TG_MIN_TICK_LENGTH:
		case TG_START_ANGLE:
		case TG_SWEEP_ANGLE:
		case TG_NUM_MAJ_TICKS:
		case TG_NUM_MIN_TICKS:
			value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
			mtx_gauge_face_alter_tick_group(MTX_GAUGE_FACE(gauge),index,field,(void *)&value);
			break;
		case TG_MAJ_TICK_COLOR_DAY:
		case TG_MAJ_TICK_COLOR_NITE:
		case TG_MIN_TICK_COLOR_DAY:
		case TG_MIN_TICK_COLOR_NITE:
		case TG_TEXT_COLOR_DAY:
		case TG_TEXT_COLOR_NITE:
			gtk_color_button_get_color(GTK_COLOR_BUTTON(widget),&color);
			mtx_gauge_face_alter_tick_group(MTX_GAUGE_FACE(gauge),index,field,(void *)&color);
			break;
		case TG_FONT:
			tmpbuf = g_strdup(gtk_font_button_get_font_name (GTK_FONT_BUTTON(widget)));
			tmpbuf = g_strchomp(g_strdelimit(tmpbuf,"0123456789",' '));
			mtx_gauge_face_alter_tick_group(MTX_GAUGE_FACE(gauge),index,field,(void *)tmpbuf);
			g_free(tmpbuf);
			break;

		case TG_TEXT:
			tmpbuf = g_strdup(gtk_entry_get_text (GTK_ENTRY(widget)));
			mtx_gauge_face_alter_tick_group(MTX_GAUGE_FACE(gauge),index,field,(void *)tmpbuf);
			g_free(tmpbuf);
		default:
			break;

	}
	return TRUE;
}
コード例 #12
0
ファイル: main.c プロジェクト: toxicgumbo/MegaTunix
int main (int argc, char ** argv )
{
	GtkWidget *vbox;
	gchar *filename = NULL;
	gchar *tmpbuf = NULL;
	gchar *dirname = NULL;
	GError *error = NULL;

	gtk_init (&argc, &argv);

	filename = get_file(g_build_filename(DASHDESIGNER_GLADE_DIR,"main.ui",NULL),NULL);
	if (filename)
	{
		toplevel = gtk_builder_new();
		if(!gtk_builder_add_from_file(toplevel,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(toplevel,NULL);
	main_window = GTK_WIDGET (gtk_builder_get_object(toplevel,"main_window"));
	menu_setup(toplevel);
	gtk_window_set_resizable(GTK_WINDOW(main_window),TRUE);
        gtk_widget_set_sensitive(OBJ_GET(toplevel,"save_dash_menuitem"),FALSE);
        gtk_widget_set_sensitive(OBJ_GET(toplevel,"save_dash_as_menuitem"),FALSE);
        gtk_widget_set_sensitive(OBJ_GET(toplevel,"close_dash_menuitem"),FALSE);

	retrieve_rt_vars();
	gtk_widget_show_all(main_window);
	if (argc == 2)
	{
		tmpbuf = g_get_current_dir();
		dirname = g_path_get_dirname(argv[1]);
		cwd = g_strconcat(tmpbuf,PSEP,dirname,NULL);
		g_free(tmpbuf);
		g_free(dirname);
		if (g_file_test(argv[1],G_FILE_TEST_IS_REGULAR))
			import_dash_xml(argv[1]);
	}

	gtk_main();
	return (0);
}
コード例 #13
0
ファイル: events.c プロジェクト: Torture/MegaTunix
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;

}
コード例 #14
0
ファイル: logviewer_gui.c プロジェクト: toxicgumbo/MegaTunix
/*!
  \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;
}
コード例 #15
0
ファイル: logviewer_gui.c プロジェクト: toxicgumbo/MegaTunix
/*!
  \brief set_default_lview_choices_state() sets the default logviewer values
  */
G_MODULE_EXPORT void set_default_lview_choices_state(void)
{
	GList *defaults = NULL;
	GList *list = NULL;
	GtkWidget * widget = NULL;
	gint i = 0;
	gint j = 0;
	gchar * name;
	gchar * potential;
	gconstpointer *object;

	defaults = get_list("logviewer_defaults");
	list = get_list("viewables");
	for (i=0;i<g_list_length(defaults);i++)
	{
		name = g_list_nth_data(defaults,i);
		for (j=0;j<g_list_length(list);j++)
		{
			widget = g_list_nth_data(list,j);
			object = OBJ_GET(widget,"object");
			if (DATA_GET(global_data,"playback_mode"))
				potential = DATA_GET(object,"lview_name");
			else
				potential = DATA_GET(object,"dlog_gui_name");
			if (g_strcasecmp(name,potential) == 0)

				set_widget_active(GTK_WIDGET(widget),GINT_TO_POINTER(TRUE));
		}
	}
	return;
}
コード例 #16
0
/*!
  \brief ECU specific plugin handler for combo boxes
  \param widget is the pointer to the combo box 
  \param data is unused
  \returns TRUE
  */
G_MODULE_EXPORT gboolean ecu_update_combo(GtkWidget *widget, gpointer data)
{
	gfloat value = 0.0;
	GtkTreeModel *model = NULL;
	GtkTreeIter iter;
	JimStimStdHandler handler;
	GdkColor white = {0,65535,65535,65535};

	handler = (JimStimStdHandler)OBJ_GET(widget,"handler");
	if (handler == RPM_MODE)
	{
		value = convert_after_upload_f(widget);
		model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));

		/* If set to 65535, pick second choice, otherwise first one..
		   */
		gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model),&iter);
		if ((GINT)value == 65535)
			gtk_tree_model_iter_next (GTK_TREE_MODEL(model), &iter);
                g_signal_handlers_block_by_func(widget,(gpointer)std_combo_handler_f,NULL);

		gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter);
		gtk_widget_modify_base(gtk_bin_get_child(GTK_BIN(widget)),GTK_STATE_NORMAL,&white);
                g_signal_handlers_unblock_by_func(widget,(gpointer)std_combo_handler_f,NULL);
	}
	return TRUE;
}
コード例 #17
0
ファイル: warnings.c プロジェクト: BMWPower/MegaTunix
gboolean alter_w_range_data(GtkWidget *widget, gpointer data)
{
	gint index = (GINT)OBJ_GET((widget),"index");
	gfloat value = 0.0;
	GdkColor color;
	WrField field = (WrField)(GINT)data;
	if (!GTK_IS_WIDGET(gauge))
		return FALSE;

	switch (field)
	{
		case WR_LOWPOINT:
		case WR_HIGHPOINT:
		case WR_INSET:
		case WR_LWIDTH:
			value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
			mtx_gauge_face_alter_warning_range(MTX_GAUGE_FACE(gauge),index,field,(void *)&value);
			break;
		case WR_COLOR_DAY:
		case WR_COLOR_NITE:
			gtk_color_button_get_color(GTK_COLOR_BUTTON(widget),&color);
			mtx_gauge_face_alter_warning_range(MTX_GAUGE_FACE(gauge),index,field,(void *)&color);
			break;
		default:
			break;

	}
	return TRUE;
}
コード例 #18
0
ファイル: logviewer_events.c プロジェクト: bigamil/MegaTunix
/*!
  \brief logviewer generic button event handler
  \param widget is the pointer to button
  \param data is unused
  \returns TRUE
  */
G_MODULE_EXPORT gboolean logviewer_button_event(GtkWidget *widget, gpointer data)
{
	Lv_Handler handler;
	GtkWidget *tmpwidget = NULL;
	handler = (Lv_Handler)(GINT)OBJ_GET(widget,"handler");
	switch(handler)
	{
		case LV_GOTO_START:
			tmpwidget = lookup_widget("logviewer_log_position_hscale");
			if (GTK_IS_RANGE(tmpwidget))
				gtk_range_set_value(GTK_RANGE(tmpwidget),0.0);
			break;
		case LV_GOTO_END:
			tmpwidget = lookup_widget("logviewer_log_position_hscale");
			if (GTK_IS_RANGE(tmpwidget))
				gtk_range_set_value(GTK_RANGE(tmpwidget),100.0);
			break;
		case LV_PLAY:
			start_tickler(LV_PLAYBACK_TICKLER);
			break;
		case LV_STOP:
			stop_tickler(LV_PLAYBACK_TICKLER);
			break;
		case LV_REWIND:
			printf("rewind\n");
			break;
		case LV_FAST_FORWARD:
			printf("fast forward\n");
			break;
		default:
			break;

	}
	return TRUE;
}
コード例 #19
0
/*!
  \brief removes a widget pointer from the ecu_widgets list
  \param widget_ptr is the pointer to the widget to remove
  \param data is unused
  */
G_MODULE_EXPORT void remove_widget(gpointer widget_ptr, gpointer data)
{
	GList ***ecu_widgets = NULL;
	gint page = -1;
	gint offset = -1;

	ecu_widgets = DATA_GET(global_data,"ecu_widgets");
	remove_from_lists_f(OBJ_GET(widget_ptr,"bind_to_list"),widget_ptr);
	if (!GTK_IS_ENTRY(widget_ptr))
		return;
	page = (GINT)OBJ_GET(widget_ptr,"page");
	offset = (GINT)OBJ_GET(widget_ptr,"offset");
	if (( page >= 0 ) && (offset >= 0))
		ecu_widgets[page][offset] = g_list_remove(ecu_widgets[page][offset],widget_ptr);
	/*dealloc_widget(widget_ptr,NULL);*/
}
コード例 #20
0
ファイル: helpers.c プロジェクト: Torture/MegaTunix
EXPORT void reset_temps_pf(void)
{
	gdk_threads_enter();
	set_title(g_strdup(_("Adjusting for local Temp units...")));
	reset_temps(OBJ_GET(global_data,"temp_units"));
	gdk_threads_leave();
}
コード例 #21
0
ファイル: ms2_gui_handlers.c プロジェクト: JacobD10/MegaTunix
/*!
  \brief ECU specific combo update routine.  This is called from the common
  routine to handle any firmware specific stuff related to a ComboBoxEntry
  \param widget is the pointer to the GtkComboBox widget
  \returns TRUE
  */
G_MODULE_EXPORT gboolean ecu_update_combo(GtkWidget * widget)
{
	ENTER();
	if ((GINT)OBJ_GET(widget,"handler") == MS2_USER_OUTPUTS)
		update_ms2_user_outputs(widget);
	EXIT();
	return TRUE;
}
コード例 #22
0
ファイル: datamgmt.c プロジェクト: bigamil/MegaTunix
/*!
  \brief Sets the ECU data at the coordinates specified in the data pointer
  \param data is the pointer to either a GtkWidget pointer or a 
  gconstpointer object container the coordinate information as to where 
  to store the new data.
  \param new is the pointer to the new data to be stored
  */
G_MODULE_EXPORT void set_ecu_data(gpointer data, gint *new_data)
{
	gint canID = 0;
	gint page = 0;
	gint offset = 0;
	DataSize size = MTX_U08;
	gint value = 0;
	gconstpointer *container = NULL;
	GtkWidget *widget = NULL;
	Firmware_Details *firmware = NULL;
	static gint (*_set_sized_data)(guint8 *, gint, DataSize, gint, gboolean) = NULL;
	if (!_set_sized_data)
		get_symbol_f("_set_sized_data",(void **)&_set_sized_data);

	firmware = (Firmware_Details *)DATA_GET(global_data,"firmware");
	g_return_if_fail(firmware);
	g_return_if_fail(_set_sized_data);

	widget = (GtkWidget *)data;
	container = (gconstpointer *)data;
	if (GTK_IS_WIDGET(widget))
	{
		canID = (GINT)OBJ_GET(widget,"canID");
		page = (GINT)OBJ_GET(widget,"page");
		offset = (GINT)OBJ_GET(widget,"offset");
		size = (DataSize)(GINT)OBJ_GET(widget,"size");
		if (new_data)
			value = *new_data;
		else
			value = (GINT)OBJ_GET(widget,"value");
	}
	else
	{
		canID = (GINT)DATA_GET(container,"canID");
		page = (GINT)DATA_GET(container,"page");
		offset = (GINT)DATA_GET(container,"offset");
		size = (DataSize)(GINT)DATA_GET(container,"size");
		if (new_data)
			value = *new_data;
		else
			value = (GINT)DATA_GET(container,"value");
	}

	_set_sized_data(firmware->ecu_data[page],offset,size,value,firmware->bigendian);
}
コード例 #23
0
ファイル: lookuptables.c プロジェクト: JacobD10/MegaTunix
/*!
  \brief lookup_data_obj() returns the value represented by the lookuptable 
  associated with the passed object and offset
  \param object is the container of parameters we need to do the lookup
  \param offset is the offset into lookuptable
  \returns the value at that offset of the lookuptable
  */
G_MODULE_EXPORT gfloat lookup_data_obj(GObject *object, gint offset)
{
	gconstpointer *dep_obj = NULL;
	LookupTable *lookuptable = NULL;
	gchar *table = NULL;
	gchar *alt_table = NULL;
	gboolean state = FALSE;
	static gboolean (*check_deps)(gconstpointer *);

	ENTER();
	if (!check_deps)
		get_symbol("check_dependencies",(void **)&check_deps);

	table = (gchar *)OBJ_GET(object,"lookuptable");
	alt_table = (gchar *)OBJ_GET(object,"alt_lookuptable");
	dep_obj = (gconstpointer *)OBJ_GET(object,"dep_object");


	if (dep_obj) 
	{
		if (check_deps)
			state = check_deps(dep_obj);
		else
			MTXDBG(CRITICAL,_("Could NOT locate \"check_dependencies\" function in any of the plugins, BUG!\n"));
	}
	if (state)
	{
		/*printf("ALTERNATE\n");*/
		lookuptable = (LookupTable *)g_hash_table_lookup((GHashTable *)DATA_GET(global_data,"lookuptables"),alt_table);	
	}
	else
	{
		/*printf("NORMAL\n");*/
		lookuptable = (LookupTable *)g_hash_table_lookup((GHashTable *)DATA_GET(global_data,"lookuptables"),table);	
	}

	if (!lookuptable)
	{
		MTXDBG(CRITICAL,_("Lookuptable is NULL for control %s\n"),(gchar *) DATA_GET(object,"internal_names"));
		EXIT();
		return 0.0;
	}
	EXIT();
	return lookuptable->array[offset];
}
コード例 #24
0
ファイル: events.c プロジェクト: Torture/MegaTunix
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;
}
コード例 #25
0
ファイル: mtxloader.c プロジェクト: BMWPower/MegaTunix
G_MODULE_EXPORT gboolean persona_choice (GtkWidget *widget, gpointer data)
{
	gint persona = 0;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
	{
		DATA_SET(global_data,"persona",OBJ_GET(widget,"persona"));
		gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object((GtkBuilder *)DATA_GET(global_data,"builder"),"load_button")),TRUE);
	}
	return TRUE;
}
コード例 #26
0
ファイル: afr_calibrate.c プロジェクト: toxicgumbo/MegaTunix
/*!
  \brief Called when the user selects an AFR conversion combobox entry
  \param widget is the combobox the user touched
  \param data is unused
  */
G_MODULE_EXPORT void afr_combo_changed(GtkWidget *widget, gpointer data)
{
	gboolean state = FALSE;
	GtkTreeModel *model = NULL;
	GtkTreeIter iter;

	g_return_if_fail(GTK_IS_COMBO_BOX(widget));

	state = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget),&iter);
	model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));
	gtk_tree_model_get(model,&iter,0,&afr_name,1,&afr_enum,-1);
	
	if (afr_enum == genericWB)
		gtk_widget_set_sensitive(OBJ_GET(widget,"generic_controls"),TRUE);
	else
		gtk_widget_set_sensitive(OBJ_GET(widget,"generic_controls"),FALSE);

	return;
}
コード例 #27
0
ファイル: lookuptables.c プロジェクト: Torture/MegaTunix
/*!
 \brief lookup_data() returns the value represented by the lookuptable 
 associated with the passed object and offset
 \param object (GObject *) container of parameters we need to do the lookup
 \param offset (gint) offset into lookuptable
 \returns the value at that offset of the lookuptable
 */
gfloat lookup_data(GObject *object, gint offset)
{
	extern GHashTable *lookuptables;
	GObject *dep_obj = NULL;
	LookupTable *lookuptable = NULL;
	gchar *table = NULL;
	gchar *alt_table = NULL;
	gboolean state = FALSE;

	table = (gchar *)OBJ_GET(object,"lookuptable");
	alt_table = (gchar *)OBJ_GET(object,"alt_lookuptable");
	dep_obj = (GObject *)OBJ_GET(object,"dep_object");
	
	/*
	   if (GTK_IS_OBJECT(dep_obj))
	   printf("checking dependancy %s\n",OBJ_GET(object,"internal_names"));
	   else
	   printf("no dependancy\n");
	   */

	if (dep_obj)
	{
		state = check_dependancies(dep_obj);
	}
	if (state)
	{
		/*printf("ALTERNATE\n");*/
		lookuptable = (LookupTable *)g_hash_table_lookup(lookuptables,alt_table);	
	}
	else
	{
		/*printf("NORMAL\n");*/
		lookuptable = (LookupTable *)g_hash_table_lookup(lookuptables,table);	
	}

	if (!lookuptable)
	{
		dbg_func(CRITICAL,g_strdup_printf(__FILE__": lookup_data()\n\t Lookuptable is NULL for control %s\n",(gchar *) OBJ_GET(object,"internal_names")));
		return 0.0;
	}
	return lookuptable->array[offset];
}
コード例 #28
0
ファイル: datamgmt.c プロジェクト: toxicgumbo/MegaTunix
/*!
  \brief A generic function to returns the data from the representation of
  ECU memory. This will call an ECU specific function to do the heavy lifting
  \param data is either a GtkWidget pointer or a gconstpointer which contains
  name:value associations describng the location to return
  \returns the value requested or 0 if error
*/
G_MODULE_EXPORT gint get_ecu_data(gpointer data)
{
	gint canID = 0;
	gint page = 0;
	gint offset = 0;
	DataSize size = MTX_U08;
	gint value = 0 ;
	GtkWidget *widget = NULL;
	gconstpointer *container = NULL;
	Firmware_Details *firmware = NULL;
	static gint (*_get_sized_data)(guint8 *, gint, DataSize, gboolean) = NULL;
	if (!_get_sized_data)
		get_symbol_f("_get_sized_data",(void*)&_get_sized_data);
	g_return_val_if_fail(_get_sized_data,0);

	firmware = DATA_GET(global_data,"firmware");
	/* Sanity checking */
	g_return_val_if_fail(data,0);
	g_return_val_if_fail(firmware,0);
	g_return_val_if_fail(firmware->page_params,0);
	g_return_val_if_fail(firmware->page_params[page],0);
	g_return_val_if_fail(((offset >= 0 ) && (offset < firmware->page_params[page]->length)),0);

	widget = (GtkWidget *)data;
	container = (gconstpointer *)data;
	if (GTK_IS_WIDGET(widget))
	{
		canID = (GINT)OBJ_GET(widget,"canID");
		page = (GINT)OBJ_GET(widget,"page");
		offset = (GINT)OBJ_GET(widget,"offset");
		size = (DataSize)OBJ_GET(widget,"size");
	}
	else
	{
		canID = (GINT)DATA_GET(container,"canID");
		page = (GINT)DATA_GET(container,"page");
		offset = (GINT)DATA_GET(container,"offset");
		size = (DataSize)DATA_GET(container,"size");
	}

	return _get_sized_data(firmware->ecu_data[page],offset,size,firmware->bigendian);
}
コード例 #29
0
/*!
  \brief deallocates the data that was stored within the curve object including
  the X and Y entries, the cdata and gets rid of the marker_id watch
  \param curve_ptr is the pointer to the 2D curve widget
  \param data is unused
  */
G_MODULE_EXPORT void clean_curve(gpointer curve_ptr, gpointer data)
{
	GArray *array = NULL;
	guint32 id = 0;
	CurveData *cdata = NULL;
	GtkWidget *widget = (GtkWidget *)curve_ptr;

	array = OBJ_GET(widget, "x_entries");
	if (array)
		g_array_free(array,TRUE);
	array = OBJ_GET(widget, "y_entries");
	if (array)
		g_array_free(array,TRUE);
	cdata = OBJ_GET(widget, "cdata");
	if (cdata)
		g_free(cdata);
	id = (guint32)(GINT)OBJ_GET(widget, "marker_id");
	if (id > 0)
		remove_rtv_watch_f(id);
}
コード例 #30
0
ファイル: helpers.c プロジェクト: Torture/MegaTunix
EXPORT void startup_tcpip_sockets_pf(void)
{
	extern gboolean interrogated;
        extern volatile gboolean offline;
	CmdLineArgs *args = NULL;

	args = OBJ_GET(global_data,"args");
	if (args->network_mode)
		return;
	if ((interrogated) && (!offline))
		open_tcpip_sockets();
}