|
Post by konaexpress on Mar 26, 2014 22:22:47 GMT 1
I'm trying to use a fialdialog and I keep getting this error message:
(conkyscripter:1967): Gtk-WARNING **: Can't set a parent on a toplevel widget
** Gtk:ERROR:/build/buildd/gtk+2.0-2.24.20/gtk/gtkcontainer.c:2743:IA__gtk_container_propagate_expose: assertion failed: (child->parent == GTK_WIDGET (container)) Aborted (core dumped)
Can anyone tell me what this is?
Here is the code I'm using:
Add_btn = FILEDIALOG("Select file...", "gtk-open", 75, 30, 0) ATTACH(Mainwin, Add_btn, 150, 405)
Thanks,
John
|
|
airr
New Member
Posts: 47
|
Post by airr on Mar 27, 2014 0:49:15 GMT 1
Basically, a FILEDIALOG is not an object that can be added to your form. It's a "standalone" window, if you will.
|
|
|
Post by konaexpress on Mar 27, 2014 7:30:34 GMT 1
So I can't add it to the Mainwin? Strange little widget don't ya think?
Well..................if I can't do that then can I use a button and then use a CALLBACK linked to a SUB and do it that way? Have the SUB open the FILEDIALOG? Or can I put it in a CALLBACK?
Strange little world........
John
|
|
|
Post by SunBurnt on Mar 27, 2014 7:44:29 GMT 1
John; The FileDialog is a window of it`s own of course, not a widget to attach to a window.
If you want a file dialog that you can call from Bash, I have an exec. made from FileDialog. I also has the GTK MessageDialog too. So it does FileOpen, FileSave, DirOpen, and Messages.
|
|
|
Post by konaexpress on Mar 27, 2014 16:34:58 GMT 1
Yea, I think we have established that FIALDIALOG is its own window.
I tried to put it in a SUB to see if I could pull it up that way, I tried to use SHOW with it. This does not work at all.
Has anyone here ever tried to use it before with your app and not just by itself? Do I need to make a FIALDIALOG.bac and use it that way? So that when you click on the "Add" button it will make the filedialog popup?
There has to be something I am missing as the Doc's don't tell much about it.
Back to the drawing board....
John
|
|
|
Post by alexfish on Mar 27, 2014 19:30:11 GMT 1
Hi John
there are extra thing that need to be pulled in to get some of the bits working
here is a simple setup.
HTH Alex
INCLUDE "hug.bac", INIT, SHOW, HIDE, GRAB$, WINDOW, FILEDIALOG, CALLBACK, STOCK, ATTACH, QUIT, DISPLAY, HUGLIB$
INIT
' Get the GTK library used by HUG lib$ = HUGLIB$("gtk")
' Import the GTK functions for file filters IMPORT "gtk_file_chooser_add_filter(long,long)" FROM lib$ TYPE long IMPORT "gtk_file_filter_add_pattern(long,char*)" FROM lib$ TYPE long IMPORT "gtk_file_filter_new" FROM lib$ TYPE long IMPORT "gtk_file_filter_set_name(long,char*)" FROM lib$ TYPE void
' Setup first filter filter1 = gtk_file_filter_new() gtk_file_filter_set_name(filter1, "BaCon source files (*.bac)") gtk_file_filter_add_pattern(filter1, "*.bac")
' Setup second filter filter2 = gtk_file_filter_new() gtk_file_filter_set_name(filter2, "All files (*)") gtk_file_filter_add_pattern(filter2, "*")
SUB Show_Dialog
SHOW(handle)
END SUB
SUB File_Dialog(NUMBER dialog, int button)
HIDE(dialog) IF button != GTK_RESPONSE_CANCEL THEN PRINT GRAB$(dialog)
END SUB
mainwin = WINDOW("File select test", 450, 200)
handle = FILEDIALOG("Pick a file", "Select file", 600, 400, 0) CALLBACK(handle, File_Dialog)
' Apply file filters to the created FILEDIALOG gtk_file_chooser_add_filter(handle, filter1) gtk_file_chooser_add_filter(handle, filter2)
open_btn = STOCK("gtk-open", 120, 40) ATTACH(mainwin, open_btn, 10, 150) CALLBACK(open_btn, Show_Dialog)
cancel_btn = STOCK("gtk-quit", 120, 40) ATTACH(mainwin, cancel_btn, 320, 150) CALLBACK(cancel_btn, QUIT)
DISPLAY
|
|
|
Post by konaexpress on Mar 27, 2014 20:09:04 GMT 1
Thanks Alex, That is the info I needed to see, as in how do I set it up and then I can change it for my own needs. Just needed to see it first and recognize that it is what I need and not what I think I need but don't. Now that I see what is involved in this, maybe I will just make the conky manager for users to play with and throw up the code for them to use but not make a tutorial out of it. What I am trying to do is way to involved for a new programmer to digest. Thanks for the help, had no idea what I was getting into. John P.S. That is genius by the way! I will have to save that code for future projects or I will never figure it out. LOL
|
|
|
Post by konaexpress on Mar 28, 2014 16:06:49 GMT 1
I have been thinking about how this code works and I was wondering.........do you have to use filters?
John
EDIT:
Just had a chance to run this and it is so cool!!!!! I see why you have filters so thanks for that and please ignore my question.
|
|