Пример #1
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);*/
}
Пример #2
0
/*!
  \brief updates the ms2 user_outputs controls which are a bit special purpose
  \param widget is the pointer to the widget to update
  */
G_MODULE_EXPORT void update_ms2_user_outputs(GtkWidget *widget)
{
	GtkTreeModel *model = NULL;
	DataSize size = MTX_U08;
	GtkTreeIter iter;
	gint tmpi = 0;
	gint t_bitval = 0;
	gboolean valid = FALSE;
	gfloat * multiplier = NULL;
	gfloat * adder = NULL;
	gchar *lower = NULL;
	gchar *upper = NULL;
	gchar *range = NULL;
	gchar *tempc_range = NULL;
	gchar *tempf_range = NULL;
	gchar *tempk_range = NULL;
	gchar *tmpbuf = NULL;
	gchar *tmpstr = NULL;
	gint bitmask = 0;
	gint bitshift = 0;
	gfloat tmpf = 0.0;
	gfloat tmpf2 = 0.0;
	gfloat value = 0.0;
	gboolean temp_dep = FALSE;
	gint i = 0;
	gint precision = 0;
	void *eval = NULL;
	GtkWidget *tmpwidget = NULL;

	ENTER();
	/*printf("update_ms2_user_outputs widget %s %p\n",glade_get_widget_name(widget),(void *)widget);*/
	get_essential_bits_f(widget, NULL, NULL, NULL, NULL, &bitmask, &bitshift);

	value = convert_after_upload_f(widget);
	tmpi = ((GINT)value & bitmask) >> bitshift;
	model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));
	valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model),&iter);
	i = 0;
	while (valid)
	{
		gtk_tree_model_get(GTK_TREE_MODEL(model),&iter,UO_BITVAL_COL,&t_bitval,-1);
		if (tmpi == t_bitval)
		{
			/* Get the rest of the data from the combo */
			gtk_tree_model_get(GTK_TREE_MODEL(model),&iter,
					UO_TEMP_DEP_COL,&temp_dep,
					UO_SIZE_COL,&size,
					UO_RAW_LOWER_COL,&lower,
					UO_RAW_UPPER_COL,&upper,
					UO_RANGE_COL,&range,
					UO_RANGE_TEMPC_COL,&tempc_range,
					UO_RANGE_TEMPF_COL,&tempf_range,
					UO_RANGE_TEMPK_COL,&tempk_range,
					UO_PRECISION_COL,&precision,
					UO_FROMECU_MULT_COL,&multiplier,
					UO_FROMECU_ADD_COL,&adder,-1);
			/*
			if (temp_dep)
			{
				printf("THIS WIDGET IS TEMP DEPENDENT\n");
				printf("raw_lower %s, raw_upper %s in treemodel\n",lower,upper);
				if (multiplier)
					printf("multiplier %f\n",*multiplier);
				if (adder)
					printf("adder %f\n",*adder);
				printf("size %i, precision %i, temp_dep %i\n",(gint)size,precision,(gint)temp_dep);
			}
			*/
			tmpbuf = (gchar *)OBJ_GET(widget,"range_label");
			if (tmpbuf)
				tmpwidget = lookup_widget_f(tmpbuf);
			if (GTK_IS_LABEL(tmpwidget))
			{
				if (temp_dep)
				{
					OBJ_SET(tmpwidget,"widget_temp",DATA_GET(global_data,"mtx_temp_units"));
					OBJ_SET(tmpwidget,"c_label",tempc_range);
					OBJ_SET(tmpwidget,"f_label",tempf_range);
					OBJ_SET(tmpwidget,"k_label",tempk_range);
					bind_to_lists_f(tmpwidget,"temperature");
					gtk_label_set_text(GTK_LABEL(tmpwidget),tempf_range);
					convert_temps_f(tmpwidget,DATA_GET(global_data,"mtx_temp_units"));
				}
				else
				{
					remove_from_lists_f("temperature",tmpwidget);
					OBJ_SET(tmpwidget,"widget_temp",NULL);
					OBJ_SET(tmpwidget,"temp_dep",NULL);
					/*OBJ_SET(tmpwidget,"c_label",NULL);
					  OBJ_SET(tmpwidget,"f_label",NULL);
					  OBJ_SET(tmpwidget,"k_label",NULL);
					  */
					gtk_label_set_text(GTK_LABEL(tmpwidget),range);
				}
			}
			tmpbuf = (gchar *)OBJ_GET(widget,"thresh_widget");
			if (tmpbuf)
				tmpwidget = lookup_widget_f(tmpbuf);
			if (GTK_IS_WIDGET(tmpwidget))
			{
				if (temp_dep)
				{
					OBJ_SET(tmpwidget,"widget_temp",DATA_GET(global_data,"mtx_temp_units"));
					OBJ_SET(tmpwidget,"temp_dep",GINT_TO_POINTER(temp_dep));
					bind_to_lists_f(tmpwidget,"temperature");
				}
				else
				{
					OBJ_SET(tmpwidget,"widget_temp",NULL);
					OBJ_SET(tmpwidget,"temp_dep",NULL);
					remove_from_lists_f("temperature",tmpwidget);
				}
				OBJ_SET(tmpwidget,"size",GINT_TO_POINTER(size));
				OBJ_SET(tmpwidget,"precision",GINT_TO_POINTER(precision));
				OBJ_SET(tmpwidget,"raw_lower",lower);
				OBJ_SET(tmpwidget,"raw_upper",upper);
				if (multiplier)
					OBJ_SET(tmpwidget,"fromecu_mult",multiplier);
				else
					OBJ_SET(tmpwidget,"fromecu_mult",NULL);
				if (adder)
					OBJ_SET(tmpwidget,"fromecu_add",adder);
				else
					OBJ_SET(tmpwidget,"fromecu_add",NULL);
				//convert_temps_f(tmpwidget,DATA_GET(global_data,"mtx_temp_units"));
				update_widget_f(tmpwidget,NULL);
			}
			tmpbuf = (gchar *)OBJ_GET(widget,"hyst_widget");
			if (tmpbuf)
				tmpwidget = lookup_widget_f(tmpbuf);
			if (GTK_IS_WIDGET(tmpwidget))
			{
				OBJ_SET(tmpwidget,"size",GINT_TO_POINTER(size));
				OBJ_SET(tmpwidget,"precision",GINT_TO_POINTER(precision));
				OBJ_SET(tmpwidget,"raw_lower",lower);
				OBJ_SET(tmpwidget,"raw_upper",upper);
				if (multiplier)
					OBJ_SET(tmpwidget,"fromecu_mult",multiplier);
				else
					OBJ_SET(tmpwidget,"fromecu_mult",NULL);
				if (adder)
					OBJ_SET(tmpwidget,"fromecu_add",adder);
				else
					OBJ_SET(tmpwidget,"fromecu_add",NULL);
				update_widget_f(tmpwidget,NULL);
			}
			g_free(range);
		}
		valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
		i++;
	}
	EXIT();
	return;
}