-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathFolderBrowserDialog.cpp
More file actions
47 lines (40 loc) · 1.3 KB
/
FolderBrowserDialog.cpp
File metadata and controls
47 lines (40 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <gtkmm.h>
using namespace Glib;
using namespace Gtk;
class Form : public Window {
public:
Form() {
add(scrolledWindow);
scrolledWindow.add(fixed);
button.set_label("Folder...");
fixed.add(button);
fixed.move(button, 10, 10);
button.signal_button_release_event().connect([&](GdkEventButton* event) {
FileChooserDialog folderBrowserDialog("", FILE_CHOOSER_ACTION_SELECT_FOLDER);
folderBrowserDialog.add_button("Cancel", RESPONSE_CANCEL);
folderBrowserDialog.add_button("Open", RESPONSE_OK);
folderBrowserDialog.set_current_folder(ustring::compose("%1/Desktop", ustring(getenv("HOME"))));
folderBrowserDialog.set_transient_for(*this);
if (folderBrowserDialog.run() == RESPONSE_OK)
label.set_text(ustring::compose("Path = %1", ustring(folderBrowserDialog.get_current_folder())));
return true;
});
label.set_text("Path = ");
fixed.add(label);
fixed.move(label, 10, 50);
set_title("FolderBrowserDialog example");
resize(300, 300);
show_all();
}
private:
Fixed fixed;
ScrolledWindow scrolledWindow;
Button button;
Label label;
};
int main(int argc, char* argv[]) {
RefPtr<Application> application = Application::create(argc, argv);
Form form;
return application->run(form);
}