GNOME Bugzilla – Bug 114867
signal_format_value() does not work
Last modified: 2004-12-22 21:47:04 UTC
I tryed to run a simple example. I create a simple window with only one HScale widget. I wonder why the signal_format_value() does not work properly. I'm receiving allways the 'value' 0. Any idea? I'm using Windows2000 and WindowsXP. I downloaded the GTKmm installer for MinGW. (GTK+ Runtime, GTK+ dev., GTKmm) Here is the code: class ScaleWindow : public Gtk::Window { public: ScaleWindow(); protected: // Signals virtual Glib::ustring on_format_value(double value); // Widgets Gtk::VScale m_vscale; }; ScaleWindow::ScaleWindow() { set_title("scale example"); add(m_vscale); m_vscale.set_draw_value(); m_vscale.set_range(0.0, 5.0); m_vscale.set_value_pos(Gtk::POS_RIGHT); m_vscale.signal_format_value().connect( SigC::slot(*this, &ScaleWindow::on_format_value) ); show_all_children(); } Glib::ustring ScaleWindow::on_format_value(double value) { char buffer[10]; sprintf(buffer, "You choose '%d'", value); printf("Value is %d\n", value); return Glib::ustring(buffer); }
Someone needs to check that the value is correct when the signal is emmitted by GTK+. If it is, the next step would be to try rewriting the example in GTK+ C code to see if it is correct then. If it is not, then we need to find out why by exploring the callbacks in gtkmm, all of which should be in the scalewindow.cc file.
Created attachment 18256 [details] scale.cc
The uploaded (scale.cc) test case shows that this works without problems, at least on linux. Please try it on Windows. I do see some 0 values, but they are not the ones actually used to display the value. I think it just asks how to represent to min and max often. But your use of %d in the printf does seem wrong for the double type. std::cout does it properly, and %f seems to be an improvement. A std::stringstream would probably do this best.
Please respond.
Please reopen if this is actually a bug on Windows.