Re: 2.16 API freeze / checking new API



Murray Cumming wrote:
Why must I search the archive to have a clue what you are asking?
From this message:
  http://mail.gnome.org/archives/gtkmm-list/2008-May/msg00139.html

  On Fri, 2008-05-16 at 17:57 -0400, Damon Register wrote:
  [snip]
  > It seems logical (at least to me) that
  > there should be a signal to tell me after that the selection is
  > complete
  > but I haven't found the method to do that.
  [snip]

  I vaguely remember seeing a bug report about that, or maybe a new signal
  being added for that. But I can't find it now. Does anyone know what I
  mean?

In that thread from last year I had asked about getting a notification
from a FileChooserButton when I have returned from the dialog with a
valid file selection (double clicking on the file or clicking open).
If I remember correctly, Gtk::FileChooser::signal_file_activated()
didn't work then (May 16, 2008).  Perhaps I am using incorrectly but
it seems that Gtk::FileChooser::signal_file_activated() still doesn't
work.

The gtk doc
http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1FileChooserButton-members.html
lists signal_file_activated() as a member function and says this:

  This signal is emitted when the user "activates" a file in the file chooser.

  This can happen by double-clicking on a file in the file list, or by pressing
  <keycap>Enter</keycap>.

  Normally you do not need to connect to this signal. It is used internally by
  FileChooserDialog to know when to activate the default button in the dialog.

I am curious about why it says that normally I don't need to connect
to that signal.  What is normal?  How should I be expected to know when
a file has been chosen?

Considering the above, I made a hello world example with a
Gtk::FileChooserButton.  In my example hello constructor I have

  refXml->get_widget("filechooserbutton1", filechooserbutton1);
  filechooserbutton1->signal_file_activated().connect(
     sigc::mem_fun(*this, &hello::on_my_file_activated  ) );

The function on_my_file_activated() is never called when I double
click on a file or click the open button.

Damon Register
#include <gtkmm.h>
#include <iostream>

class hello : public Gtk::Window
{
public:
    hello();
    virtual ~hello();

protected:

    Glib::RefPtr<Gtk::Builder>  refXml;
    Gtk::FileChooserButton* filechooserbutton1;
    Gtk::Layout *layout1;

    virtual void on_my_file_activated();
    virtual bool quitmethod();
};

hello::hello()
{
    std::cout << "hello()" << std::endl;
    refXml = Gtk::Builder::create_from_file("../hello.xml");
    refXml->get_widget("layout1", layout1);
    layout1->reparent(*this);

    refXml->get_widget("filechooserbutton1", filechooserbutton1);
    filechooserbutton1->signal_file_activated().connect( sigc::mem_fun(*this, &hello::on_my_file_activated  ) );

    Gtk::Main::signal_quit().connect(sigc::mem_fun(*this, &hello::quitmethod));
    std::cout << "hello() end" << std::endl;
}

hello::~hello()
{
    std::cout << "~hello()" << std::endl;
}

bool hello::quitmethod()
{
    std::cout << "quitmethod()" << std::endl;
    remove();
    return false;
}

void hello::on_my_file_activated()
{
    std::cout << "on_my_file_activated()" << std::endl;
}

int main(int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);
    hello window;
    kit.run(window);
    std::cout << "main() end" << std::endl;
    return 0;
}

/*
(hello.exe:2684): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
*/
<?xml version="1.0"?>
<!--*- mode: xml -*-->
<interface>
  <object class="GtkWindow" id="hello_main_window">
    <child>
      <object class="GtkLayout" id="layout1">
        <property name="width_request">450</property>
        <property name="height_request">450</property>
        <property name="visible">True</property>
        <property name="width">450</property>
        <property name="height">450</property>
        <child>
          <object class="GtkFileChooserButton" id="filechooserbutton1">
            <property name="width_request">100</property>
            <property name="height_request">80</property>
            <property name="visible">True</property>
          </object>
          <packing>
            <property name="x">108</property>
            <property name="y">294</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
</interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]