Audacity 3.2.0
Classes | Macros | Functions
gtk/FileDialogPrivate.cpp File Reference
#include <gtk/gtk.h>
#include "Internat.h"
#include "BasicUI.h"
#include "../FileDialog.h"
#include <wx/filename.h>
#include <wx/tokenzr.h>
#include <wx/filefn.h>
#include <wx/modalhook.h>
#include <wx/sizer.h>
Include dependency graph for gtk/FileDialogPrivate.cpp:

Go to the source code of this file.

Classes

class  wxGtkString
 

Macros

#define wxGTK_CONV(s)   (s).utf8_str()
 
#define wxGTK_CONV_FN(s)   (s).fn_str()
 

Functions

static void gtk_filedialog_ok_callback (GtkWidget *widget, FileDialog *dialog)
 
static void gtk_filedialog_cancel_callback (GtkWidget *WXUNUSED(w), FileDialog *dialog)
 
static void gtk_filedialog_response_callback (GtkWidget *w, gint response, FileDialog *dialog)
 
static void gtk_filedialog_selchanged_callback (GtkFileChooser *chooser, FileDialog *dialog)
 
static void gtk_filedialog_update_preview_callback (GtkFileChooser *chooser, gpointer user_data)
 
static void gtk_filedialog_folderchanged_callback (GtkFileChooser *chooser, FileDialog *dialog)
 
static void gtk_filedialog_filterchanged_callback (GtkFileChooser *chooser, GParamSpec *pspec, FileDialog *dialog)
 
static GtkWidget * find_widget (GtkWidget *parent, const gchar *name, int depth)
 

Macro Definition Documentation

◆ wxGTK_CONV

#define wxGTK_CONV (   s)    (s).utf8_str()

Definition at line 28 of file gtk/FileDialogPrivate.cpp.

◆ wxGTK_CONV_FN

#define wxGTK_CONV_FN (   s)    (s).fn_str()

Definition at line 29 of file gtk/FileDialogPrivate.cpp.

Function Documentation

◆ find_widget()

static GtkWidget * find_widget ( GtkWidget *  parent,
const gchar *  name,
int  depth 
)
static

Definition at line 182 of file gtk/FileDialogPrivate.cpp.

183{
184 // printf("%*.*c%s\n", depth, depth, ' ', gtk_widget_get_name(parent));
185
186 GtkWidget *widget = NULL;
187 if (g_ascii_strncasecmp(gtk_widget_get_name(parent), name, strlen(name)) == 0)
188 {
189 return parent;
190 }
191
192 if (GTK_IS_BIN(parent))
193 {
194 return find_widget(gtk_bin_get_child(GTK_BIN(parent)), name, depth + 1);
195 }
196
197 if (GTK_IS_CONTAINER(parent))
198 {
199 GList *list = gtk_container_get_children(GTK_CONTAINER(parent));
200 for (GList *node = list; node; node = node->next)
201 {
202 widget = find_widget(GTK_WIDGET(node->data), name, depth + 1);
203 if (widget)
204 {
205 break;
206 }
207 }
208 g_list_free(list);
209 }
210
211 return widget;
212}
const TranslatableString name
Definition: Distortion.cpp:76
static GtkWidget * find_widget(GtkWidget *parent, const gchar *name, int depth)

References find_widget(), and name.

Referenced by FileDialog::AddChildGTK(), find_widget(), FileDialog::GTKFilterChanged(), and FileDialog::SetFileExtension().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gtk_filedialog_cancel_callback()

static void gtk_filedialog_cancel_callback ( GtkWidget *  WXUNUSEDw,
FileDialog dialog 
)
static

Definition at line 124 of file gtk/FileDialogPrivate.cpp.

125{
126 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
127 event.SetEventObject(dialog);
128 dialog->HandleWindowEvent(event);
129}
wxEVT_COMMAND_BUTTON_CLICKED

References wxEVT_COMMAND_BUTTON_CLICKED.

Referenced by gtk_filedialog_response_callback().

Here is the caller graph for this function:

◆ gtk_filedialog_filterchanged_callback()

static void gtk_filedialog_filterchanged_callback ( GtkFileChooser *  chooser,
GParamSpec *  pspec,
FileDialog dialog 
)
static

Definition at line 175 of file gtk/FileDialogPrivate.cpp.

178{
179 dialog->GTKFilterChanged();
180}

References FileDialog::GTKFilterChanged().

Referenced by FileDialog::Create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gtk_filedialog_folderchanged_callback()

static void gtk_filedialog_folderchanged_callback ( GtkFileChooser *  chooser,
FileDialog dialog 
)
static

Definition at line 169 of file gtk/FileDialogPrivate.cpp.

171{
172 dialog->GTKFolderChanged();
173}

References FileDialog::GTKFolderChanged().

Referenced by FileDialog::Create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gtk_filedialog_ok_callback()

static void gtk_filedialog_ok_callback ( GtkWidget *  widget,
FileDialog dialog 
)
static

Definition at line 56 of file gtk/FileDialogPrivate.cpp.

57{
58 int style = dialog->GetWindowStyle();
59 wxGtkString filename(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)));
60
61 // gtk version numbers must be identical with the one in ctor (that calls set_do_overwrite_confirmation)
62#ifndef __WXGTK3__
63#if GTK_CHECK_VERSION(2,7,3)
64 if (gtk_check_version(2, 7, 3) != NULL)
65#endif
66 {
67 if ((style & wxFD_SAVE) && (style & wxFD_OVERWRITE_PROMPT))
68 {
69 if ( g_file_test(filename, G_FILE_TEST_EXISTS) )
70 {
71 using namespace BasicUI;
72 auto result = ShowMessageBox(
73 XO("File '%s' already exists, do you really want to overwrite it?")
74 .Format(wxString::FromUTF8(filename)),
76 .Caption( XO("Confirm") )
77 .IconStyle(Icon::Question)
78 .ButtonStyle(Button::YesNo));
79 if (result != MessageBoxResult::Yes)
80 {
81 return;
82 }
83 }
84 }
85 }
86#endif
87
88 if (style & wxFD_FILE_MUST_EXIST)
89 {
90 if ( !g_file_test(filename, G_FILE_TEST_EXISTS) )
91 {
92 using namespace BasicUI;
93 ShowMessageBox(XO("Please choose an existing file."),
95 .Caption(XO("Error"))
96 .ButtonStyle(Button::Ok)
97 .IconStyle(Icon::Error));
98 return;
99 }
100 }
101
102 // change to the directory where the user went if asked
103 if (style & wxFD_CHANGE_DIR)
104 {
105 // Use chdir to not care about filename encodings
106 wxGtkString folder(g_path_get_dirname(filename));
107 chdir(folder);
108 }
109
110 wxCommandEvent event(wxEVT_BUTTON, wxID_OK);
111 event.SetEventObject(dialog);
112 dialog->HandleWindowEvent(event);
113}
XO("Cut/Copy/Paste")
Abstract base class used in importing a file.
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
Definition: BasicUI.h:279
MessageBoxOptions && Caption(TranslatableString caption_) &&
Definition: BasicUI.h:101

References BasicUI::MessageBoxOptions::Caption(), BasicUI::ShowMessageBox(), anonymous_namespace{AudacityDontAskAgainMessageDialog.cpp}::style, and XO().

Referenced by gtk_filedialog_response_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gtk_filedialog_response_callback()

static void gtk_filedialog_response_callback ( GtkWidget *  w,
gint  response,
FileDialog dialog 
)
static

Definition at line 131 of file gtk/FileDialogPrivate.cpp.

134{
135 if (response == GTK_RESPONSE_ACCEPT)
137 else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE
139}
static void gtk_filedialog_ok_callback(GtkWidget *widget, FileDialog *dialog)
static void gtk_filedialog_cancel_callback(GtkWidget *WXUNUSED(w), FileDialog *dialog)

References gtk_filedialog_cancel_callback(), and gtk_filedialog_ok_callback().

Referenced by FileDialog::Create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gtk_filedialog_selchanged_callback()

static void gtk_filedialog_selchanged_callback ( GtkFileChooser *  chooser,
FileDialog dialog 
)
static

Definition at line 141 of file gtk/FileDialogPrivate.cpp.

143{
144 wxGtkString filename(gtk_file_chooser_get_preview_filename(chooser));
145
146 dialog->GTKSelectionChanged(wxString::FromUTF8(filename));
147}
void GTKSelectionChanged(const wxString &filename)

References FileDialog::GTKSelectionChanged().

Referenced by FileDialog::Create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gtk_filedialog_update_preview_callback()

static void gtk_filedialog_update_preview_callback ( GtkFileChooser *  chooser,
gpointer  user_data 
)
static

Definition at line 149 of file gtk/FileDialogPrivate.cpp.

151{
152 GtkWidget *preview = GTK_WIDGET(user_data);
153
154 wxGtkString filename(gtk_file_chooser_get_preview_filename(chooser));
155
156 if ( !filename )
157 return;
158
159 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size(filename, 128, 128, NULL);
160 gboolean have_preview = pixbuf != NULL;
161
162 gtk_image_set_from_pixbuf(GTK_IMAGE(preview), pixbuf);
163 if ( pixbuf )
164 g_object_unref (pixbuf);
165
166 gtk_file_chooser_set_preview_widget_active(chooser, have_preview);
167}

Referenced by FileDialog::Create().

Here is the caller graph for this function: