GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Oct 25, 2014 6:20 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: gtk_file_chooser_dialog error
PostPosted: Thu Oct 22, 2009 2:39 pm 
Offline
GTK+ Geek

Joined: Mon Mar 30, 2009 12:40 pm
Posts: 69
Location: España
Hello!

I'm trying to run this code:
Code:
gint doble_clic(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
GtkWidget *dialog = gtk_file_chooser_dialog_new (
                    "test",
                    GTK_WINDOW (widget->parent),
                    GTK_FILE_CHOOSER_ACTION_OPEN,
                    GTK_STOCK_CANCEL, // button text
                    GTK_RESPONSE_CANCEL, // response id
                    GTK_STOCK_OPEN, // button text
                    GTK_RESPONSE_ACCEPT, // response id
                    NULL); // end button/response list

if(gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
  {
  gchar *filename;
  filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
  printf("%s\n",filename);               
  g_free (filename);
  }
   
   
gtk_widget_destroy (dialog);

return FALSE;
}



but it returns:
GLib-GIO-WARNING **: Could not initialize inotify
Any help?.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 22, 2009 3:46 pm 
Offline
GTK+ Geek

Joined: Mon Mar 30, 2009 12:40 pm
Posts: 69
Location: España
Another warning:

Unable to find default local directory monitor type

What's wrong?


Top
 Profile  
 
 Post subject: Re: gtk_file_chooser_dialog error
PostPosted: Sat Oct 08, 2011 2:39 pm 
Offline
Familiar Face

Joined: Wed Sep 21, 2011 1:08 pm
Posts: 5
Gtk-WARNING **: Unable to find default local directory monitor type

I'm getting the same issue. Any help?


Top
 Profile  
 
 Post subject: Re: gtk_file_chooser_dialog error
PostPosted: Thu Jan 05, 2012 6:41 am 
Offline
Familiar Face

Joined: Wed Sep 21, 2011 1:08 pm
Posts: 5
Anyone?


Top
 Profile  
 
 Post subject: Re: gtk_file_chooser_dialog error
PostPosted: Thu Jan 05, 2012 7:42 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 764
Location: UK
Hi,

Without knowing what you are doing to reproduce the errors, I am sure no one would be able to help you fix the errors that have occurred. Just like with the first person on this very old thread.

The original code sample is too short and does not tell where or how the error happens.

_________________
E.


Top
 Profile  
 
 Post subject: Re: gtk_file_chooser_dialog error
PostPosted: Mon Jan 23, 2012 6:59 am 
Offline
Familiar Face

Joined: Wed Sep 21, 2011 1:08 pm
Posts: 5
Hi errol,

Please find below my code:

/**************
#include<iostream>
using namespace std;
#include<gtk/gtk.h>


GtkWidget *window=NULL;


void insertFromListCb( GtkWidget *insert)
{

GtkWidget *dialog;
char *fileName;
dialog = gtk_file_chooser_dialog_new ("Open File",
GTK_WINDOW(window),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
fileName = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
cout<<"fileName =" << fileName << endl;
}

gtk_widget_destroy (dialog);
}


int main( int argc, char *argv[])
{
gtk_init( &argc, &argv);

GtkBuilder *builder= gtk_builder_new();
GtkWidget *insert= NULL;

gtk_builder_add_from_file( builder, "temp.xml", NULL);

window= GTK_WIDGET(gtk_builder_get_object( builder, "window"));
insert= GTK_WIDGET(gtk_builder_get_object( builder, "insert"));


g_signal_connect( insert, "clicked", G_CALLBACK(insertFromListCb), NULL);
gtk_widget_show_all(window);
gtk_main();
return 1;
}

/*************

Compile command:

g++ `pkg-config --cflags --libs gtk+-2.0` chisr.C -o chisr


Top
 Profile  
 
 Post subject: Re: gtk_file_chooser_dialog error
PostPosted: Mon Jan 23, 2012 7:49 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 764
Location: UK
I was unable to reproduce your error on my system. May be you have something missing from your install which is not monitoring the changes in the file system.

Note in your original code you have done some possible errors. First you should return 0 from main unless you really want to indicate to the operating system that the application had an error. Try to avoid the use of "using namespace", this is considered bad practice and defeats the point of name spaces.

I have also re-written your code to use gtkmm, which is the C++ binding for GTK since you are using C++. This is just an example and does not have full error checking.
Use this to compile (I am using gtkmm 3, this should also work with gtkmm 2 if you substitute gtkmm-2.4 instead of gtkmm-3.0)
Code:
gcc chisr.cc `pkg-config --libs --cflags gtkmm-3.0` -o chisr

Code:
#include<iostream>

#include<gtkmm.h>


Gtk::Window *window;


void insertFromListCb()
{
    Gtk::FileChooserDialog dialog(*window, "Open File");
    dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);

    if (dialog.run() == Gtk::RESPONSE_ACCEPT) {
        std::cout << "filename = " << dialog.get_filename() << std::endl;
    }
}


int main(int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);

    Gtk::Button *insert;

    Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_file("temp.xml");
    builder->get_widget("window", window);
    builder->get_widget("insert", insert);

    insert->signal_clicked().connect(sigc::ptr_fun(&insertFromListCb));

    window->show_all();
    kit.run(*window);

    return 0;
}

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group