Esempio n. 1
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;
}
Esempio n. 2
0
note_data * 
fill_note_data_from_page(_notetype notetype)
{
    note_data *note;
    gchar     *l_ptr;
    
    note = (note_data *) malloc(sizeof (note_data));
    if (note == NULL)
    {
        g_warning(_("Error while allocating memory for note (0)"));
        return (NULL);
    }
    note->notetype = notetype;
    note->title = g_strdup(gtk_entry_get_text(GTK_ENTRY(sp->title_entry)));
    if (note->title == NULL)
    {
        g_warning(_("Error while allocating memory for note (1)"));
        return (NULL);
    }
    note->text = gtk_editable_get_chars(GTK_EDITABLE(sp->text_entry), 0,
                                        gtk_text_get_length(GTK_TEXT(
                                            sp->text_entry)));
    if (note->text == NULL)
    {
        g_warning(_("Error while allocating memory for note (2)"));
        return (NULL);
    }
    if (notetype == CheckNote || notetype == TodoNote)
    {
        note->todo = gtk_toggle_button_get_active(
            GTK_TOGGLE_BUTTON(sp->todo_check));
    }
    else
    {
        note->todo = 0;
    }
    
    note->expire = time_label_get_time(TIME_LABEL(sp->tlabel_expire));
    note->created = time_label_get_time(TIME_LABEL(sp->tlabel_created));
    note->changed = time(NULL);
    time_label_set_time(TIME_LABEL(sp->tlabel_changed), note->changed);

    gtk_label_get(GTK_LABEL(sp->label_changes), &l_ptr);
    note->changes = atoi(l_ptr);
    note->changes++;
    l_ptr = g_strdup_printf("%ld", note->changes);
    gtk_label_set_text(GTK_LABEL(sp->label_changes), l_ptr);
    g_free(l_ptr);
    
    note->id = g_strdup(gtk_entry_get_text(GTK_ENTRY(sp->note_id_entry)));
    if (note->id == NULL)
    {
        g_warning(_("Error while allocating memory for note (3)"));
        return (NULL);
    }
    
    if (notetype == TodoNote)
    {
        note->deadline = gnome_date_edit_get_date(
            GNOME_DATE_EDIT(sp->de_deadline));
        note->prio = gtk_spin_button_get_value_as_int(
            GTK_SPIN_BUTTON(sp->prio_entry));
        note->complete = GTK_ADJUSTMENT(sp->ad_complete)->value;

    }
    else
    {
        note->deadline = 0;
        note->prio = 0;
        note->complete = 0;
    }
    
    return (note);
}