After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 114867 - signal_format_value() does not work
signal_format_value() does not work
Status: RESOLVED NOTABUG
Product: gtkmm
Classification: Bindings
Component: general
2.2
Other Windows
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2003-06-10 18:17 UTC by Ferhat Ayaz
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
scale.cc (966 bytes, text/plain)
2003-07-13 12:53 UTC, Murray Cumming
Details

Description Ferhat Ayaz 2003-06-10 18:17:50 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);
}
Comment 1 Murray Cumming 2003-06-26 07:28:53 UTC
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.
Comment 2 Murray Cumming 2003-07-13 12:53:38 UTC
Created attachment 18256 [details]
scale.cc
Comment 3 Murray Cumming 2003-07-13 12:55:40 UTC
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.
Comment 4 Murray Cumming 2003-07-18 12:51:19 UTC
Please respond.
Comment 5 Murray Cumming 2003-07-23 09:14:43 UTC
Please reopen if this is actually a bug on Windows.