|
Post by ptitjoz on Apr 23, 2019 14:11:35 GMT 1
Hello I'm trying to do a program In the file explorer, when I click on a file with an extension (zip for example), I can display a window via my bacon program I wish I could get the name of the file (file name) I clicked. It's possible ?
sorry for my English.
Best regards
|
|
|
Post by vovchik on Apr 23, 2019 17:03:06 GMT 1
Dear ptitjoz, If you want help with a problem, I would recommend always posting the source, so that we can see where the problem might be. A line of code is usually more valuable that a paragraph of approximate description. This is an example that works for me: ' *********************** ' INITIALIZATION ' ***********************
INCLUDE "hug.bac"
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
' *********************** ' END INITIALIZATION ' ***********************
' *********************** ' SUBS & FUNCTIONS ' ***********************
' ------------------ SUB MK_FILTERS() ' ------------------ ' 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, "*") END SUB
' ------------------ 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) TEXT(myfile, "<span color='crimson'>" & GRAB$(dialog) & "</span>") END IF END SUB
' ------------------ SUB MK_GUI() ' ------------------ mainwin = WINDOW("File select test", 450, 200) handle = FILEDIALOG("Pick a file", "Select file", 600, 400, 0) CALLBACK(handle, FILE_DIALOG) MK_FILTERS() ' Apply file filters to the created FILEDIALOG gtk_file_chooser_add_filter(handle, filter1) gtk_file_chooser_add_filter(handle, filter2) open_btn = BUTTON("Open", 90, 30) myfile = MARK("", 430, 40) SETPROPERTY(myfile, "xalign", 0.5) FONT(myfile, "DejaVu Sans Mono Bold 12") ATTACH(mainwin, myfile, 10, 100) ATTACH(mainwin, open_btn, 10, 160) CALLBACK(open_btn, SHOW_DIALOG) cancel_btn = BUTTON("Quit", 90, 30) ATTACH(mainwin, cancel_btn, 350, 160) CALLBACK(cancel_btn, QUIT) END SUB
' *********************** ' END SUBS & FUNCTIONS ' ***********************
' *********************** ' MAIN ' ***********************
MK_GUI() DISPLAY
' *********************** ' END MAIN ' *********************** With kind regards, vovchik
|
|
|
Post by ptitjoz on Apr 23, 2019 19:57:33 GMT 1
Dear Vovchik
I understand your message and generally I put code or illustrations so I apologize for the inconvenience. For now I have not written code and my idea is very poorly explained because I am even more zero in English. Sorry... Thank you for your program code, I will try to understand it and adapt it to my idea Best regards
|
|