Re: GtkFileChooserButton::file-set



Il Wed, 3 Oct 2012 23:28:23 +0200 RafaÅ MuÅyÅo
<galtgendo gmail com> scrisse:

On Wed, Oct 03, 2012 at 10:23:12PM +0200, Nicola Fontana wrote:
I need to catch when the file has changed in a
GtkFileChooserButton. I thought connecting to "file-set" was
enough but this signal is not emitted when the user cancels
(although bug 555351 does not agree [1]). Here is the proof:


#include <gtk/gtk.h>

int main(int argc, char **argv)
{
    GtkWidget *window, *chooser;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    chooser = gtk_file_chooser_button_new(NULL,
                                          GTK_FILE_CHOOSER_ACTION_OPEN);
    gtk_container_add(GTK_CONTAINER(window), chooser);

    g_signal_connect_swapped(chooser, "file-set",
                             G_CALLBACK(g_print), "file-set\n");

    gtk_widget_show_all(window);
    gtk_main();

    return 0;
}


What am I supposed to do? I can provide my custom dialog to
GtkFileChooserButton but checking when the file has changed in a
file chooser seems a too natural request for requiring such
effort.

Well, I'm not 100% sure what you mean (and that "callback" of yours
looks like it's only working by chance)

No, this is valid GTK+ code.

but the change on cancel was
recently fixed in bug . in regard of gtk 3.4 and 3.6 (unfortunately, not in 2.24 though, even if it seems 
to be only a matter of a cherry-pick).

What I mean is pressing ESC or clicking cancel unset the file name
and I didn't find a way to catch it: this is not the same issue.

I'm using gtk 3.4.4 but I don't think it is relevant.

Ciao.
-- 
Nicola



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