I solve the first problem (the spinbutton one) setting the values in code as follow:
Code:
m_refBuilder->get_widget("spinbutton1", spinbutton1);
double f = 50;
double t = 1000;
spinbutton1->set_range(f,t);
spinbutton1->set_increments(f,f);
if (button1 && spinbutton1){
button1->signal_clicked().connect(sigc::mem_fun(*this, &Miwindow::on_button1_clicked));
}
}
For the second problem ... the dialog.get_filename().c_str() return a const char *, I need a char * in my on_button1_clicked(). I tried some possibilities, all envolving creating a new class variable.
I tried for this variable a char * path, char path[] ... and tried to convert the const char * in that, but for most i got a memory crash and for others i was not obtaining the value in on_button1_clicked().
This last one i don't know what is wrong with it:
Miwindow.h
Code:
#ifndef MIWINDOW_H
#define MIWINDOW_H
#include <gtkmm.h>
class Miwindow : public Gtk::Window {
public:
Miwindow(BaseObjectType* cobject, Glib::RefPtr<Gtk::Builder> refBuilder);
virtual ~Miwindow();
protected:
//same stuff
char * path;
//same stuff
};
#endif
Miwindow.cc
Code:
//same includes
Miwindow::Miwindow(BaseObjectType * cobject, Glib::RefPtr<Gtk::Builder> refBuilder)
: Gtk::Window(cobject), m_refBuilder(refBuilder)
{
//same stuff
Miwindow::~Miwindow() {
}
void Miwindow::on_button1_clicked() {
int spinvalue = spinbutton1->get_value_as_int();
std::cout << "Parameter 1 = " << spinvalue << std::endl;
std::cout << path << std::endl;
}
void Miwindow::on_imagemenuitem2_activate()
{
//same stuff
path = const_cast<char*> ( dialog.get_filename().c_str() );
std::cout << "pathImagen = " << path << std::endl;
//same stuff
}
void Miwindow::on_imagemenuitem5_activate() {
//same stuff
}
void Miwindow::on_imagemenuitem6_activate() {
//same stuff
}
When i run those parts, i got the following:
1 pathImagen = /home/myhome/pathToImage/image.jpg
2 Parameter 1 = 50
3 �6� �
The 1, is the cout just after the const_cast<char*>, the 2 is the spinbutton working and the 3 is some random garbage :S
Anyone know what i'm doing wrong or know the way to do what i want? any lead/hint/help will be appreciated.
Thx in advance for all!