Beispiel #1
0
void add_item (gchar *label, gpointer data)
{
	GtkWidget *curve = lookup_widget(app,"curve");
	GtkWidget *clist = lookup_widget(app,"clist");
	list_entry_t *le;
	gint row;
	gchar *labels[2];

	if (label==NULL) return;

	le = g_new (list_entry_t,1);

	le->minx = gtk_spin_button_get_value_as_float (lookup_widget(app,"minx"));
	le->maxx = gtk_spin_button_get_value_as_float (lookup_widget(app,"maxx"));
	le->miny = gtk_spin_button_get_value_as_float (lookup_widget(app,"miny"));
	le->maxy = gtk_spin_button_get_value_as_float (lookup_widget(app,"maxy"));
	le->count = gtk_spin_button_get_value_as_int (lookup_widget(app,"count"));
	le->type = gtk_entry_get_text (lookup_widget(app,"typeentry"));
	le->name = g_strdup(label);

	labels[0] = "A+";
	labels[1] = le->name;
	row = gtk_clist_append (clist,labels);
	gtk_clist_set_row_data (clist,row,le); 
}
Beispiel #2
0
// make the shift increments match the grid settings
// the objective being that the shift+arrows shortcuts move the texture by the corresponding grid size
// this depends on the current texture scale used?
// we move the textures in pixels, not world units. (i.e. increment values are in pixel)
// depending on the texture scale it doesn't take the same amount of pixels to move of g_qeglobals.d_gridsize
// increment * scale = gridsize
static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){
	float hscale, vscale;
	hscale = gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( g_dlgSurface.GetDlgWidget( "hscale" ) ) );
	vscale = gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( g_dlgSurface.GetDlgWidget( "vscale" ) ) );
	if ( hscale == 0.0f || vscale == 0.0f ) {
		Sys_Printf( "ERROR: unexpected scale == 0.0f\n" );
		return;
	}
	DoSnapTToGrid( hscale, vscale );
}
Beispiel #3
0
void
on_maxy_changed                        (GtkEditable     *editable,
                                        gpointer         user_data)
{
	GtkWidget *curve = lookup_widget(app,"curve");
	gfloat minx, maxx, miny, maxy;
	minx = gtk_spin_button_get_value_as_float (lookup_widget(app,"minx"));
	maxx = gtk_spin_button_get_value_as_float (lookup_widget(app,"maxx"));
	miny = gtk_spin_button_get_value_as_float (lookup_widget(app,"miny"));
	maxy = gtk_spin_button_get_value_as_float (lookup_widget(app,"maxy"));
	gtk_curve_set_range (curve,minx,maxx,miny,maxy);

}
static void on_video_sync_changed(GtkWidget *widget, gpointer data) {

  startVideoAfter = gtk_spin_button_get_value_as_float((GtkSpinButton *)spinButton);

  calcCurrentPlayingTime();
  sendCurrentPlayingTime();
}
Beispiel #5
0
static ObjectChange *
bezierline_apply_properties(Bezierline *bezierline)
{
    ObjectState *old_state;

    if (bezierline != bezierline_properties_dialog->bezierline) {
        g_message("Bezierline dialog problem:  %p != %p",
                  bezierline, bezierline_properties_dialog->bezierline);
        bezierline = bezierline_properties_dialog->bezierline;
    }

    old_state = (ObjectState *)bezierline_get_state(bezierline);

    bezierline->line_width =
        gtk_spin_button_get_value_as_float(bezierline_properties_dialog->line_width);
    dia_color_selector_get_color(bezierline_properties_dialog->color,
                                 &bezierline->line_color);
    dia_line_style_selector_get_linestyle(bezierline_properties_dialog->line_style, &bezierline->line_style, &bezierline->dashlength);
    bezierline->start_arrow = dia_arrow_selector_get_arrow(bezierline_properties_dialog->start_arrow);
    bezierline->end_arrow = dia_arrow_selector_get_arrow(bezierline_properties_dialog->end_arrow);

    bezierline_update_data(bezierline);
    return new_object_state_change((Object *)bezierline, old_state,
                                   (GetStateFunc)bezierline_get_state,
                                   (SetStateFunc)bezierline_set_state);

}
Beispiel #6
0
static ObjectChange *
line_apply_properties(Line *line)
{
  ObjectState *old_state;

  if (line != line_properties_dialog->line) {
    printf("Dialog problem:  %p != %p\n", line, line_properties_dialog->line);
    line = line_properties_dialog->line;
  }

  old_state = (ObjectState *)line_get_state(line);

  line->line_width = gtk_spin_button_get_value_as_float(line_properties_dialog->line_width);
  dia_color_selector_get_color(line_properties_dialog->color, &line->line_color);
  dia_line_style_selector_get_linestyle(line_properties_dialog->line_style,
					&line->line_style, &line->dashlength);

  line->start_arrow = dia_arrow_selector_get_arrow(line_properties_dialog->start_arrow);
  line->end_arrow = dia_arrow_selector_get_arrow(line_properties_dialog->end_arrow);
  
  line_update_data(line);
  return new_object_state_change((Object *)line, old_state, 
				 (GetStateFunc)line_get_state,
				 (SetStateFunc)line_set_state);
}
Beispiel #7
0
static void apply_config(void) {
  int i;
  char *field = NULL;

  free_stations();
  nstations = gui_station_count;
  stations = malloc(sizeof(struct station) * nstations);

  for (i = 0; i < nstations; i++) {
    gtk_clist_get_text(GTK_CLIST(gui_station_list), i, 0, &field);
    stations[i].station_name = strdup(field);

    gtk_clist_get_text(GTK_CLIST(gui_station_list), i, 1, &field);
    stations[i].freq = atof(field);
  }

  mutetime = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(gui_mutetime_entry));

  set_text_freq(radio_getfreq()); /* reset the frequency display */

  attempt_reopen =
    gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui_reopen_toggle));

  close_atexit =
    gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui_close_toggle));
  /* recreate the frequency menu */
  create_freq_menu();
}
Beispiel #8
0
void close_and_add_station_editor(gpointer *userdata) {
  gint new_entry = (gint)userdata;
  gchar *f[3];
  gfloat freq;
  gchar fstr[32];

  f[0] = (gchar *) gtk_entry_get_text(GTK_ENTRY(gui_station_name_input));
  freq = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(gui_freq_input));
  sprintf(fstr, "%.2f", freq);
  f[1] = fstr;
  f[2] = "";

  if (new_entry) {
    gtk_clist_append(GTK_CLIST(gui_station_list), f);
    gui_station_count++;
  } else {
    assert(gui_station_selected != -1);
    gtk_clist_set_text(GTK_CLIST(gui_station_list),
		       gui_station_selected, 0,
		       f[0]);
    gtk_clist_set_text(GTK_CLIST(gui_station_list),
		       gui_station_selected, 1,
		       f[1]);
  }
  close_station_editor();
}
Beispiel #9
0
static void datasource_gc_get_cmd_string ( datasource_gc_widgets_t *widgets, gchar **cmd, gchar **input_file_type )
{
  //gchar *safe_string = g_shell_quote ( gtk_entry_get_text ( GTK_ENTRY(widgets->center_entry) ) );
  gchar *safe_user = g_shell_quote ( a_preferences_get ( VIKING_GC_PARAMS_NAMESPACE "username")->s );
  gchar *safe_pass = g_shell_quote ( a_preferences_get ( VIKING_GC_PARAMS_NAMESPACE "password")->s );
  gdouble lat, lon;
  if ( 2 != sscanf ( gtk_entry_get_text ( GTK_ENTRY(widgets->center_entry) ), "%lf,%lf", &lat, &lon ) ) {
    g_warning (_("Broken input - using some defaults"));
    lat = a_vik_get_default_lat();
    lon = a_vik_get_default_long();
  }

  // Unix specific shell commands
  // 1. Remove geocache webpages (maybe be from different location)
  // 2, Gets upto n geocaches as webpages for the specified user in radius r Miles
  // 3. Converts webpages into a single waypoint file, ignoring zero location waypoints '-z'
  //       Probably as they are premium member only geocaches and user is only a basic member
  //  Final output is piped into GPSbabel - hence removal of *html is done at beginning of the command sequence
  *cmd = g_strdup_printf( "rm -f ~/.geo/caches/*html ; %s -P -n%d -r%.1fM -u %s -p %s %.4f %.4f ; %s -z ~/.geo/caches/*html ",
			  GC_PROGRAM1,
			  gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(widgets->num_spin) ),
			  gtk_spin_button_get_value_as_float ( GTK_SPIN_BUTTON(widgets->miles_radius_spin) ),
			  safe_user,
			  safe_pass,
			  lat, lon,
			  GC_PROGRAM2 );
  *input_file_type = NULL;
  //g_free ( safe_string );
  g_free ( safe_user );
  g_free ( safe_pass );
}
Beispiel #10
0
static void on_video_time_tag_changed(GtkWidget *widget, gpointer data) {

  timeTagInVideo = gtk_spin_button_get_value_as_float((GtkSpinButton *)spinButtonVideo);

  calcCurrentPlayingTime();
  sendCurrentPlayingTime();
}
Beispiel #11
0
gfloat GetSpinButtonValue(const gchar *spin_button_name)
{
	GtkWidget *spin_button;

	spin_button = glade_xml_get_widget(g_cngplp_xml, spin_button_name);
	if(spin_button == NULL){
		return -1;
	}
	return gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spin_button));
}
Beispiel #12
0
static void datasource_gc_draw_circle ( datasource_gc_widgets_t *widgets )
{
  gdouble lat, lon;
  if ( widgets->circle_onscreen ) {
    vik_viewport_draw_arc ( widgets->vvp, widgets->circle_gc, FALSE,
		widgets->circle_x - widgets->circle_width/2,
		widgets->circle_y - widgets->circle_width/2,
		widgets->circle_width, widgets->circle_width, 0, 360*64 );
  }
  /* calculate widgets circle_x and circle_y */
  /* split up lat,lon into lat and lon */
  if ( 2 == sscanf ( gtk_entry_get_text ( GTK_ENTRY(widgets->center_entry) ), "%lf,%lf", &lat, &lon ) ) {
    struct LatLon ll;
    VikCoord c;
    gint x, y;

    ll.lat = lat; ll.lon = lon;
    vik_coord_load_from_latlon ( &c, vik_viewport_get_coord_mode ( widgets->vvp ), &ll );
    vik_viewport_coord_to_screen ( widgets->vvp, &c, &x, &y );
    /* TODO: real calculation */
    if ( x > -1000 && y > -1000 && x < (vik_viewport_get_width(widgets->vvp) + 1000) &&
	y < (vik_viewport_get_width(widgets->vvp) + 1000) ) {
      VikCoord c1, c2;
      gdouble pixels_per_meter;

      widgets->circle_x = x;
      widgets->circle_y = y;

      /* determine miles per pixel */
      vik_viewport_screen_to_coord ( widgets->vvp, 0, vik_viewport_get_height(widgets->vvp)/2, &c1 );
      vik_viewport_screen_to_coord ( widgets->vvp, vik_viewport_get_width(widgets->vvp), vik_viewport_get_height(widgets->vvp)/2, &c2 );
      pixels_per_meter = ((gdouble)vik_viewport_get_width(widgets->vvp)) / vik_coord_diff(&c1, &c2);

      /* this is approximate */
      widgets->circle_width = gtk_spin_button_get_value_as_float ( GTK_SPIN_BUTTON(widgets->miles_radius_spin) )
		* METERSPERMILE * pixels_per_meter * 2;

      vik_viewport_draw_arc ( widgets->vvp, widgets->circle_gc, FALSE,
		widgets->circle_x - widgets->circle_width/2,
		widgets->circle_y - widgets->circle_width/2,
		widgets->circle_width, widgets->circle_width, 0, 360*64 );

      widgets->circle_onscreen = TRUE;
    } else
      widgets->circle_onscreen = FALSE;
  }

  /* see if onscreen */
  /* okay */
  vik_viewport_sync ( widgets->vvp );
}
Beispiel #13
0
void on_buysell_propertybox_apply (GnomePropertyBox *property_box, gint page_num) {
	struct buysell_data *data=(struct buysell_data *)bs_global_ci->instance_data;

	if (page_num != -1) return;

	gnome_color_picker_get_i8(bs_cpick,&data->r,&data->g,&data->b,&data->a);
	data->price=gtk_spin_button_get_value_as_float(bs_pricespin);
	data->amount=gtk_spin_button_get_value_as_float(bs_numstocks);
	data->time=gnome_date_edit_get_date(bs_date);
	if (GTK_TOGGLE_BUTTON(bs_buybotton)->active) {
		data->buy=TRUE;
	} else {
		data->buy=FALSE;
	}

	gtk_object_destroy(GTK_OBJECT(bs_global_ci->fixed_group));

	bs_update_xml_node(bs_global_ci);
	create_buysell(bs_global_ci);
	if (data->buy) sprintf(data->i_name,"Buy (%.2f @ %.2f)",data->amount,data->price);
	else sprintf(data->i_name,"Sell (%.2f @ %.2f)",data->amount,data->price);
	bs_global_ci->instance_name=data->i_name;
}
Beispiel #14
0
void get_value( GtkWidget *widget,
		gpointer data )
{
  gchar buf[32];
  GtkLabel *label;
  GtkSpinButton *spin;

  spin = GTK_SPIN_BUTTON (spinner1);
  label = GTK_LABEL (gtk_object_get_user_data (GTK_OBJECT (widget)));
  if (GPOINTER_TO_INT (data) == 1)
    sprintf (buf, "%d", gtk_spin_button_get_value_as_int (spin));
  else
    sprintf (buf, "%0.*f", spin->digits,
             gtk_spin_button_get_value_as_float (spin));
  gtk_label_set_text (label, buf);
}
Beispiel #15
0
static void
on_TextEncoderDialog_response          (GtkDialog       *dialog,
                                        gint             response_id,
                                        gpointer         user_data)
{
    GtkWidget *wid;
    CTextProfile *ret_profile = NULL;
    if (GTK_RESPONSE_OK == response_id) {
        CTextProfile *tp = (CTextProfile *)user_data;
        if (tp == NULL) {
            wid = lookup_widget(GTK_WIDGET(dialog),
                                "TextProfileEntry");
            const char *name = gtk_entry_get_text(GTK_ENTRY(wid));
            if (name == NULL || *name == '\0') {
                ShowMessage("Error", "Must enter profile name");
                return;
            }
            if (AVFlow->m_text_profile_list->FindProfile(name) != NULL) {
                ShowMessage("Error", "Profile already exists");
                return;
            }
            if (AVFlow->m_text_profile_list->CreateConfig(name) == false) {
                ShowMessage("Error", "profile creation error");
                return;
            }
            tp = AVFlow->m_text_profile_list->FindProfile(name);
            ret_profile = tp;
        }
        wid = lookup_widget(GTK_WIDGET(dialog), "TextEncodingOptionMenu");

        tp->SetStringValue(CFG_TEXT_ENCODING,
                           text_encoder_table[gtk_option_menu_get_history(GTK_OPTION_MENU(wid))].text_encoding);
        wid = lookup_widget(GTK_WIDGET(dialog), "TextRepeatTimeSpinner");
        tp->SetFloatValue(CFG_TEXT_REPEAT_TIME_SECS,
                          gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(wid)));

        tp->Update();
    }
    free(encoderNames);
    OnTextProfileFinished(ret_profile);
    gtk_widget_destroy(GTK_WIDGET(dialog));
}
Beispiel #16
0
static ObjectChange *
arc_apply_properties(Arc *arc)
{
  ObjectState *old_state;

  old_state = (ObjectState *)arc_get_state(arc);
  
  arc->line_width = gtk_spin_button_get_value_as_float(arc_properties_dialog->line_width);
  dia_color_selector_get_color(arc_properties_dialog->color, &arc->arc_color);
  dia_line_style_selector_get_linestyle(arc_properties_dialog->line_style,
					&arc->line_style, &arc->dashlength);
  arc->start_arrow = dia_arrow_selector_get_arrow(arc_properties_dialog->start_arrow);
  arc->end_arrow = dia_arrow_selector_get_arrow(arc_properties_dialog->end_arrow);
  
  
  arc_update_data(arc);
  return new_object_state_change((Object *)arc, old_state, 
				 (GetStateFunc)arc_get_state,
				 (SetStateFunc)arc_set_state);
}
Beispiel #17
0
static ObjectChange *
image_apply_properties(Image *image)
{
  gchar *new_file;
  ObjectState *old_state;

  if (image != image_properties_dialog->image) {
    message_warning("Image dialog problem:  %p != %p\n", 
		    image, image_properties_dialog->image);
    image = image_properties_dialog->image;
  }

  old_state = (ObjectState *)image_get_state(image);

  image->border_width = gtk_spin_button_get_value_as_float(image_properties_dialog->border_width);
  dia_color_selector_get_color(image_properties_dialog->fg_color, &image->border_color);
  dia_line_style_selector_get_linestyle(image_properties_dialog->line_style, &image->line_style, NULL);

  image->draw_border = gtk_toggle_button_get_active(image_properties_dialog->draw_border);
  image->keep_aspect = gtk_toggle_button_get_active(image_properties_dialog->keep_aspect);
  
  new_file = dia_file_selector_get_file(image_properties_dialog->file);
  if (image->file) g_free(image->file);
  if (image->image) {
    dia_image_release(image->image);
  }
  image->image = dia_image_load(new_file);
  if ((image->image != NULL) && (image->keep_aspect)) {
    /* Must... keep... aspect... ratio... */
    float ratio = (float)dia_image_height(image->image)/
      (float)dia_image_width(image->image);
    image->element.height = image->element.width * ratio;
  }
  image->file = g_strdup(new_file);

  image_update_data(image);
  return new_object_state_change((Object *)image, old_state, 
				 (GetStateFunc)image_get_state,
				 (SetStateFunc)image_set_state);
}
Beispiel #18
0
void curve_save (gchar *filename, long int seekpos)
{
	GtkWidget *curve = lookup_widget(app,"curve");
	guint count, i;
	gfloat *vector;
	gchar *type;
	FILE *out;
	gfloat minx, maxx, miny, maxy;
	gfloat scale, f;
	guint base;

	minx = gtk_spin_button_get_value_as_float (lookup_widget(app,"minx"));
	maxx = gtk_spin_button_get_value_as_float (lookup_widget(app,"maxx"));
	miny = gtk_spin_button_get_value_as_float (lookup_widget(app,"miny"));
	maxy = gtk_spin_button_get_value_as_float (lookup_widget(app,"maxy"));

	scale = gtk_spin_button_get_value_as_float (lookup_widget(app,"scale"));
	base = gtk_spin_button_get_value_as_int (lookup_widget(app,"base"));
	count = gtk_spin_button_get_value_as_int (lookup_widget(app,"count"));
	type = gtk_entry_get_text (lookup_widget(app,"typeentry"));

	vector = g_new (gfloat,count);
	gtk_curve_get_vector (curve,count,vector);

	out = fopen(filename, "wb");
	if (out == NULL) return;

	if (seekpos) fseek (out,seekpos,0);

	if (strcmp(type,"u_char")==0)
	{
		u_char val;
		
		f = (gfloat)(scale) / (maxy - miny);
	
		for (i=0; i<count; i++)
		{
			val = base + (u_char) (vector[i] * f);
			fwrite(&val,sizeof(val),1,out);
		}
	}

	if (strcmp(type,"char")==0)
	{
		char val;
		
		f = (gfloat)(scale) / (maxy - miny);
	
		for (i=0; i<count; i++)
		{
			val = (char) (vector[i] * f);
			fwrite(&val,sizeof(val),1,out);
		}
	}

	if (strcmp(type,"u_short")==0)
	{
		u_short val;
		
		f = (gfloat)(scale) / (maxy - miny);
	
		for (i=0; i<count; i++)
		{
			val = (u_short) (vector[i] * f);
			fwrite(&val,sizeof(val),1,out);
		}
	}

	if (strcmp(type,"short")==0)
	{
		short val;
		
		f = (gfloat)(scale) / (maxy - miny);
		
		printf ("factor=%f scale=%f (%f)\n",f,scale,maxy-miny);
		
		for (i=0; i<count; i++)
		{
			val = (short) (vector[i] * f);
			fwrite(&val,sizeof(val),1,out);
		}
	}

	if (strcmp(type,"u_long")==0)
	{
		u_long val;
		
		f = (gfloat)(scale) / (maxy - miny);
	
		for (i=0; i<count; i++)
		{
			val = (u_long) (vector[i] * f);
			fwrite(&val,sizeof(val),1,out);
		}
	}

	if (strcmp(type,"long")==0)
	{
		long val;
		
		f = (gfloat)(scale) / (maxy - miny);
	
		for (i=0; i<count; i++)
		{
			val = (long) (vector[i] * f);
			fwrite(&val,sizeof(val),1,out);
		}
	}

	if (strcmp(type,"float")==0)
	{
		fwrite(vector,sizeof(gfloat),count,out);
	}

	if (strcmp(type,"double")==0)
	{
		gdouble val;
	
		for (i=0; i<count; i++)
		{
			val = (gdouble) vector[i];
			fwrite(&val,sizeof(val),1,out);
		}
	}

	if (strcmp(type,"fixed (4+12)")==0)
	{
		u_short val;
		
		f = (gfloat)(scale) / (maxy - miny);
	
		for (i=0; i<count; i++)
		{
			val = base + (u_char) (vector[i] * f);
			fwrite(&val,sizeof(val),1,out);
		}
	}
	
	fclose (out);
	
	g_free (vector);
}
void Dialog::UpdateData( bool retrieve ){
	DLG_DATA *data;
	GSList *lst;
	char buf[32];

	if ( retrieve ) {
		for ( lst = m_pDataList; lst != NULL; lst = g_slist_next( lst ) )
		{
			data = (DLG_DATA*)lst->data;

			switch ( data->type )
			{
			case DLG_CHECK_BOOL:
				*(bool*)data->buffer = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( data->object ) );
				break;
			case DLG_RADIO_INT:
			{
				GSList *radio = gtk_radio_button_group( GTK_RADIO_BUTTON( data->object ) );
				*(int*)data->buffer = g_slist_length( radio ) - 1;
				for (; radio; radio = g_slist_next( radio ) )
					if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio->data ) ) ) {
						break;
					}
					else{
						( *(int*)data->buffer )--;
					}
			} break;
			case DLG_ENTRY_TEXT:
			{
				const char *txt;
				Str* str;
				str = (Str*)data->buffer;
				txt = gtk_entry_get_text( GTK_ENTRY( data->object ) );
				*str = txt;
			} break;
			case DLG_ENTRY_FLOAT:
				*(float*)data->buffer = atof( gtk_entry_get_text( GTK_ENTRY( data->object ) ) );
				break;
			case DLG_ENTRY_INT:
				*(int*)data->buffer = atoi( gtk_entry_get_text( GTK_ENTRY( data->object ) ) );
				break;
			case DLG_SPIN_FLOAT:
				*(float*)data->buffer = gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( data->object ) );
				break;
			case DLG_SPIN_INT:
				*(int*)data->buffer = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( data->object ) );
				break;
			case DLG_ADJ_INT:
				*(int*)data->buffer = (int) GTK_ADJUSTMENT( data->object )->value;
				break;
			case DLG_COMBO_INT:
			{
				GList *lst = GTK_LIST( GTK_COMBO( data->object )->list )->children;
				char *label;
				const char *entry;
				int i;

				*(int*)data->buffer = -1;
				entry = gtk_entry_get_text( GTK_ENTRY( GTK_COMBO( data->object )->entry ) );

				for ( i = 0; lst != NULL; lst = g_list_next( lst ) )
				{
					gtk_label_get( GTK_LABEL( GTK_BIN( lst->data )->child ), &label );

					if ( strcmp( label, entry ) == 0 ) {
						*(int*)data->buffer = i;
						break;
					}
					i++;
				}
			}
			break;
			case DLG_COMBO_BOX_INT: {
				*(int*)data->buffer = gtk_combo_box_get_active( GTK_COMBO_BOX( data->object ) );
			}
			break;

			}
		}
	}
	else
	{
		for ( lst = m_pDataList; lst != NULL; lst = g_slist_next( lst ) )
		{
			data = (DLG_DATA*)lst->data;

			switch ( data->type )
			{
			case DLG_CHECK_BOOL:
				gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( data->object ), *(bool*)data->buffer );
				break;
			case DLG_RADIO_INT:
			{
				GSList *radio = gtk_radio_button_group( GTK_RADIO_BUTTON( data->object ) );
				gpointer btn =  g_slist_nth_data( radio, g_slist_length( radio ) - ( *(int*)data->buffer ) - 1 );
				gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( btn ), TRUE );
			} break;
			case DLG_ENTRY_TEXT:
			{
				Str* str;
				str = (Str*)data->buffer;
				const char *txt = str->GetBuffer();
				gtk_entry_set_text( GTK_ENTRY( data->object ), txt );
			} break;
			case DLG_ENTRY_FLOAT:
				sprintf( buf, "%g", ( *(float*)data->buffer ) );
				gtk_entry_set_text( GTK_ENTRY( data->object ), buf );
				break;
			case DLG_ENTRY_INT:
				sprintf( buf, "%d", ( *(int*)data->buffer ) );
				gtk_entry_set_text( GTK_ENTRY( data->object ), buf );
				break;
			case DLG_SPIN_FLOAT:
				gtk_spin_button_set_value( GTK_SPIN_BUTTON( data->object ), ( *(float*)data->buffer ) );
				break;
			case DLG_SPIN_INT:
				gtk_spin_button_set_value( GTK_SPIN_BUTTON( data->object ), ( *(int*)data->buffer ) );
				break;
			case DLG_ADJ_INT:
				gtk_adjustment_set_value( GTK_ADJUSTMENT( data->object ), ( *(int*)data->buffer ) );
				break;
			case DLG_COMBO_INT: {
				GList *lst = GTK_LIST( GTK_COMBO( data->object )->list )->children;
				char *entry = NULL;

				if ( *(int*)data->buffer != -1 ) {
					lst = g_list_nth( lst, *(int*)data->buffer );
					if ( lst != NULL ) {
						gtk_label_get( GTK_LABEL( GTK_BIN( lst->data )->child ), &entry );
					}
				}
				if ( entry ) {
					gtk_entry_set_text( GTK_ENTRY( GTK_COMBO( data->object )->entry ), entry );
				}
				else{
					gtk_entry_set_text( GTK_ENTRY( GTK_COMBO( data->object )->entry ), "" );
				}
			}
			break;
			case DLG_COMBO_BOX_INT: {
				gtk_combo_box_set_active( GTK_COMBO_BOX( data->object ), *(int*)data->buffer );
			}
			break;
			}
		}
	}
}
Beispiel #20
0
/* Create the network */
void 
new_do_cb()
{
	int i;
	int l[3];
	l[0] = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(input_spin));
	l[1] = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(hidden_spin));
	l[2] = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(output_spin));
	
	nn = mlp_new(l, 3);
	nn->transf_func = &heavyside;
	nn->transf_func_derivate = &heavyside_derivate;

	nn->learning_rate = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(learning_spin));
	gtk_mlp_set_network(GTK_MLP(mlp), nn);


	// Add the input boxes in the main window
	neural_input = (GtkWidget **) malloc(sizeof(GtkWidget *) * l[0]);
	neural_output = (GtkWidget **) malloc(sizeof(GtkWidget *) * l[2]);	

	gtk_box_pack_start(GTK_BOX(entry_box),gtk_label_new("Input values"),FALSE,FALSE,0);

	for(i = 0; i < l[0]; i++)
	{
		char str_c[16];
		sprintf(str_c, "Neuron %d ", i);
		GtkWidget *tmp_box = gtk_hbox_new(0, 0);
		neural_input[i] = gtk_spin_button_new(
			GTK_ADJUSTMENT(
				gtk_adjustment_new((nn->input[i]).value, 0.0, 1.0, 0.02, (nn->input)[i].value, 0.1)), 
				1.0, 2);

		gtk_box_pack_start(GTK_BOX(tmp_box),gtk_label_new(str_c),FALSE,FALSE,0);
		gtk_box_pack_start(GTK_BOX(tmp_box),neural_input[i],TRUE,TRUE,0);

		gtk_box_pack_start(GTK_BOX(entry_box),tmp_box,FALSE,FALSE,0);

		gtk_widget_show_all(window);
	}

	gtk_box_pack_start(GTK_BOX(entry_box),gtk_label_new("Output values"),FALSE,FALSE,0);

	for(i = 0; i < l[2]; i++)
	{
		char str_c[16];
		sprintf(str_c, "Neuron %d ", i);
		GtkWidget *tmp_box = gtk_hbox_new(0, 0);
		neural_output[i] = gtk_spin_button_new(
			GTK_ADJUSTMENT(
				gtk_adjustment_new((nn->output)[i].value, 0.0, 1.0, 0.02, (nn->output)[i].value, 0.1)), 
				1.0, 2);

		gtk_box_pack_start(GTK_BOX(tmp_box),gtk_label_new(str_c),FALSE,FALSE,0);
		gtk_box_pack_start(GTK_BOX(tmp_box),neural_output[i],TRUE,TRUE,0);

		gtk_box_pack_start(GTK_BOX(entry_box),tmp_box,FALSE,FALSE,0);

		gtk_widget_show_all(window);
	}

	gtk_statusbar_push(GTK_STATUSBAR(status_bar), 0, "Network created.");

	// Destroy the window
	gtk_widget_destroy(new_w);
}
Beispiel #21
0
/*
   ==============
   GetTexMods

   Reads the fields to get the current texdef (i.e. widgets -> MAP)
   in brush primitive mode, grab the fake shift scale rot and compute a new texture matrix
   ===============
 */
void SurfaceDlg::GetTexMods(){
	char buffer[1024];
	texdef_t *pt;

#ifdef DBG_SI
	Sys_Printf( "SurfaceDlg::GetTexMods\n" );
#endif

	if ( g_ptrSelectedFaces.GetSize() > 0 ) {
		//++timo just a test, we disable the undo when working on selected faces
		m_nUndoId = 0;
		face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
		g_qeglobals.d_texturewin.texdef = selFace->texdef;
#ifdef DBG_SI
		Sys_Printf( "g_qeglobals.d_texturewin.texdef = selFace->texdef\n" );
#endif
	}
//  else
//  {
	pt = &g_qeglobals.d_texturewin.texdef;
#ifdef DBG_SI
	Sys_Printf( "pt = &g_qeglobals.d_texturewin.texdef\n" );
#endif
//  }

	const char* text = gtk_entry_get_text( GTK_ENTRY( GetDlgWidget( "texture" ) ) );

#ifdef DBG_SI
	Sys_Printf( "pt->SetName(%s)\n", text );
#endif

	// TTimo: detect and refuse invalid texture names (at least the ones with spaces)
	if ( text[0] <= ' ' || strchr( text, ' ' ) ) {
		Sys_FPrintf( SYS_WRN, "WARNING: spaces in shader names are not allowed, ignoring '%s'\n", text );
		pt->SetName( SHADER_NOT_FOUND );
		gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "texture" ) ), pt->GetName() );
	}
	else
	{
		strcpy( buffer, "textures/" );
		strcpy( buffer + 9, text );
		pt->SetName( buffer );
	}


	( g_qeglobals.m_bBrushPrimitMode ? m_shift[0] : pt->shift[0] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "hshift" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_shift[1] : pt->shift[1] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "vshift" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_scale[0] : pt->scale[0] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "hscale" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_scale[1] : pt->scale[1] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "vscale" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_rotate : pt->rotate ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "rotate" ) ) );

	// a local copy of the texture matrix, given for a qtexture_t with width=2 height=2
	brushprimit_texdef_t local_bp;
	brushprimit_texdef_t  *bpt;
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		face_t *selFace = NULL;
		if ( g_ptrSelectedFaces.GetSize() > 0 ) {
			selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
			bpt = &selFace->brushprimit_texdef;
		}
		else
		{
			bpt = &g_qeglobals.d_texturewin.brushprimit_texdef;
		}
		// compute texture matrix
		// the matrix returned must be understood as a qtexture_t with width=2 height=2
		FakeTexCoordsToTexMat( m_shift, m_rotate, m_scale, local_bp.coords );
		// copy the texture matrix in the global struct
		// fit the qtexture if we have a face selected, otherwise g_qeglobals.d_texturewin.brushprimit_texdef uses the basic qtexture_t with width=2 height=2

		ConvertTexMatWithQTexture( &local_bp, NULL, bpt, ( ( selFace ) ? selFace->d_texture : NULL ) );
	}
	// we are gonna do stuff, if we own the last do we undo it first
	if ( m_nUndoId != 0 ) {
		// check the do we're about to undo is the one we pushed earlier
		if ( m_nUndoId == Undo_GetUndoId() ) {
#ifdef DBG_SI
			Sys_Printf( "GetTexMods calling Undo_Undo (silent)\n" );
#endif
			g_bListenUpdate = false;
			Undo_Undo( true );
			g_bListenUpdate = true;
		}
	}
	Select_SetTexture( pt,&local_bp );
	m_nUndoId = Undo_GetUndoId();
}
Beispiel #22
0
void FloatSpinnerExport(GtkSpinButton& widget, const FloatImportCallback& importCallback)
{
  importCallback(float(gtk_spin_button_get_value_as_float(&widget)));
}
Beispiel #23
0
void Calcul_pret ( GtkWidget *p_Widget, gpointer data )
{
   // Conversion des datas dans une structure ELEMENT
   ELEMENT *Recup = data;
   // Variables récupération des données
   gint i = 0;
   gint Paie_1 = 0;
   gint Paie_2 = 0;
   gfloat Taux_interet = 0;
   gint Duree_emprunt = 0;
   gint Somme_emprunt = 0;
   float Montant_mensualite = 0;
   float Montant = 0;
   float Mensualite_amortis = 0;
   float Mensualite_interet = 0;
   float Restant = 0;
   gchar *p_text_1 = NULL;

   // Récupération des informations
   Paie_1 = gtk_spin_button_get_value_as_int 
      (GTK_SPIN_BUTTON (Recup -> p_Selecteur[0]));
   Paie_2 = gtk_spin_button_get_value_as_int 
      (GTK_SPIN_BUTTON (Recup -> p_Selecteur[1]));
   Taux_interet = gtk_spin_button_get_value_as_float 
      (GTK_SPIN_BUTTON (Recup -> p_Selecteur[2]));
   Duree_emprunt = gtk_spin_button_get_value_as_int 
      (GTK_SPIN_BUTTON (Recup -> p_Selecteur[3]));
   Somme_emprunt = gtk_spin_button_get_value_as_int 
      (GTK_SPIN_BUTTON (Recup -> p_Selecteur[4]));
 
   // Calcule et affichae la mensualité
   Montant_mensualite = Mensualite(Somme_emprunt, Duree_emprunt,Taux_interet);
	p_text_1 = g_strdup_printf("%.2f €",Montant_mensualite);
	gtk_label_set_text(GTK_LABEL (Recup->p_Etiq[16]),p_text_1);
   // Calcule et affiche le montant maximal de la mensualité
   Montant = Mensualite_max(Paie_1, Paie_2, Duree_emprunt,
      Taux_interet);
	p_text_1 = g_strdup_printf("%.2f €",Montant);
	gtk_label_set_text(GTK_LABEL (Recup->p_Etiq[17]),p_text_1);
   // Calcule et affiche le pourcentage d'endettement
   Montant = Endettement(Paie_1, Paie_2, Somme_emprunt, 
      Duree_emprunt, Taux_interet);
	p_text_1 = g_strdup_printf("%.2f %%",Montant);
	gtk_label_set_text(GTK_LABEL (Recup->p_Etiq[18]),p_text_1);
   // Calcule et affiche la capacité d'emprunt
   Montant = Emprunt_max(Paie_1, Paie_2, Duree_emprunt,
      Taux_interet);
	p_text_1 = g_strdup_printf("%.0f €",Montant);
	gtk_label_set_text(GTK_LABEL (Recup->p_Etiq[19]),p_text_1);
   // Calcule et affiche Le montant des intérêts
   Montant = Interet(Somme_emprunt, Duree_emprunt,Taux_interet);
	p_text_1 = g_strdup_printf("%.0f €",Montant);
	gtk_label_set_text(GTK_LABEL (Recup->p_Etiq[20]),p_text_1);
   // Calcule le coût du crédit
	p_text_1 = g_strdup_printf("%.0f €",(Montant + Somme_emprunt) );
	gtk_label_set_text(GTK_LABEL (Recup->p_Etiq[21]),p_text_1);
   // Efface le tableau
	if (GTK_IS_LIST_STORE(Recup->p_Modele)) 
   {
      gtk_list_store_clear(GTK_LIST_STORE(Recup->p_Modele));
	}
// Remplit le tableau
   for( i = 1; i < ( Duree_emprunt * 12 ) + 1; i++ ) 
   {
   // Calcule l'amortissement
   Mensualite_amortis = Amortissement(Somme_emprunt, Duree_emprunt,
      Taux_interet,i);
   Mensualite_interet = Montant_mensualite - Mensualite_amortis;
   Restant = Capital_rembourser(Somme_emprunt, Duree_emprunt,
      Taux_interet,i);
      Ajout_list(
         Recup -> p_Modele,
			i,
			Montant_mensualite,
			Mensualite_interet,
         Mensualite_amortis,
         Somme_emprunt - Restant
      );
   }
   // Libére la mémoire
}
double pgin_read_double(char *name, char *label,
        double def, double min, double max, double inc, int digits){
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *action;
GtkWidget *lbl;
GtkWidget *spin_button;
GtkWidget *ok_button;
GtkObject *adj;
double d;

    /* Dialog */
    dialog = gtk_dialog_new();
    gtk_window_set_title(GTK_WINDOW(dialog), name);
    gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
    gtk_window_set_policy(GTK_WINDOW(dialog), TRUE, TRUE, FALSE);
    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
    gtk_signal_connect(GTK_OBJECT(dialog), "delete_event",
            GTK_SIGNAL_FUNC(gtk_iface_grab_end_click), NULL);

    /* Vbox */
    vbox = GTK_DIALOG(dialog)->vbox;
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
    gtk_widget_show(vbox);

    /* Label */
    lbl = gtk_label_new(label);
    gtk_widget_show(lbl);
    gtk_container_add(GTK_CONTAINER(vbox), lbl);

    /* Spin button */
    adj = gtk_adjustment_new(def, min, max, inc, inc, inc);
    spin_button = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0, digits);
    gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spin_button), TRUE);
    gtk_widget_show(spin_button);
    gtk_container_add(GTK_CONTAINER(vbox), spin_button);

    /* Action area */
    action = GTK_DIALOG(dialog)->action_area;
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
    gtk_widget_show(action);
    
    /* OK button */
    ok_button = gtk_button_new_with_label("  OK  ");
    gtk_widget_show(ok_button);
    gtk_container_add(GTK_CONTAINER(action), ok_button);
    gtk_signal_connect(GTK_OBJECT(ok_button), "clicked",
            GTK_SIGNAL_FUNC(gtk_iface_grab_end_click), NULL);

    /* Get input */
    gtk_widget_show(dialog);
    gtk_iface_grab_end = 0;

    while (!gtk_iface_grab_end){
        while (gtk_events_pending())
              gtk_main_iteration();
        usleep(10000);
    }

    /* Get value */
    d = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spin_button));
    
    /* Destroy */
    gtk_widget_destroy(lbl);
    gtk_widget_destroy(spin_button);
    gtk_widget_destroy(ok_button);
    gtk_widget_destroy(vbox);
    gtk_widget_destroy(dialog);
    //gtk_object_destroy(adj);

    return d;
}
Beispiel #25
0
void ChangeDoubleVal(GtkWidget *widget,gpointer data)
{
  *((gdouble *)data)=gtk_spin_button_get_value_as_float
    (GTK_SPIN_BUTTON(widget));
}