MCPcopy Create free account
hub / github.com/cztomczak/cefpython / OnFileDialog

Method OnFileDialog

src/client_handler/dialog_handler_gtk.cpp:138–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136ClientDialogHandlerGtk::ClientDialogHandlerGtk() : gtk_dialog_(NULL) {}
137
138bool ClientDialogHandlerGtk::OnFileDialog(
139 CefRefPtr<CefBrowser> browser,
140 FileDialogMode mode,
141 const CefString& title,
142 const CefString& default_file_path,
143 const std::vector<CefString>& accept_filters,
144 int selected_accept_filter,
145 CefRefPtr<CefFileDialogCallback> callback) {
146 std::vector<CefString> files;
147
148 GtkFileChooserAction action;
149 const gchar* accept_button;
150
151 // Remove any modifier flags.
152 FileDialogMode mode_type =
153 static_cast<FileDialogMode>(mode & FILE_DIALOG_TYPE_MASK);
154
155 if (mode_type == FILE_DIALOG_OPEN || mode_type == FILE_DIALOG_OPEN_MULTIPLE) {
156 action = GTK_FILE_CHOOSER_ACTION_OPEN;
157 accept_button = GTK_STOCK_OPEN;
158 } else if (mode_type == FILE_DIALOG_OPEN_FOLDER) {
159 action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
160 accept_button = GTK_STOCK_OPEN;
161 } else if (mode_type == FILE_DIALOG_SAVE) {
162 action = GTK_FILE_CHOOSER_ACTION_SAVE;
163 accept_button = GTK_STOCK_SAVE;
164 } else {
165 NOTREACHED();
166 return false;
167 }
168
169 std::string title_str;
170 if (!title.empty()) {
171 title_str = title;
172 } else {
173 switch (mode_type) {
174 case FILE_DIALOG_OPEN:
175 title_str = "Open File";
176 break;
177 case FILE_DIALOG_OPEN_MULTIPLE:
178 title_str = "Open Files";
179 break;
180 case FILE_DIALOG_OPEN_FOLDER:
181 title_str = "Open Folder";
182 break;
183 case FILE_DIALOG_SAVE:
184 title_str = "Save File";
185 break;
186 default:
187 break;
188 }
189 }
190
191 GtkWindow* window = CefBrowser_GetGtkWindow(browser);
192 if (!window)
193 return false;
194
195 GtkWidget* dialog = gtk_file_chooser_dialog_new(

Callers

nothing calls this directly

Calls 7

CefBrowser_GetGtkWindowFunction · 0.85
statClass · 0.85
AddFiltersFunction · 0.85
c_strMethod · 0.80
sizeMethod · 0.80
emptyMethod · 0.45
CancelMethod · 0.45

Tested by

no test coverage detected