Skip to content

Commit

Permalink
Use more consistent naming for derived classes of Fl_Native_File_Choo…
Browse files Browse the repository at this point in the history
…ser_Driver.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11628 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Apr 16, 2016
1 parent 62a0bfb commit f810452
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 107 deletions.
8 changes: 4 additions & 4 deletions FL/Fl_Native_File_Chooser.H
Expand Up @@ -28,12 +28,12 @@
this API has a do-nothing default implementation
class Fl_Native_File_Chooser_FLTK_Driver <== this API implementation is the default FLTK file chooser
class Fl_Native_File_Chooser_GTK_Driver <== this API implementation runs a GTK file chooser
class Fl_GTK_Native_File_Chooser_Driver <== this API implementation runs a GTK file chooser
it is determined at run-time if the GTK dynamic libraries are available
class Fl_Native_File_Chooser_Darwin_Driver <== this API implementation runs a Mac OS X file chooser
class Fl_Quartz_Native_File_Chooser_Driver <== this API implementation runs a Mac OS X file chooser
class Fl_Native_File_Chooser_WinAPI_Driver <== this API implementation runs a MSWindows file chooser
class Fl_WinAPI_Native_File_Chooser_Driver <== this API implementation runs a MSWindows file chooser
Each platform must implement the constructor of the Fl_Native_File_Chooser class.
Expand All @@ -47,7 +47,7 @@
No more code is required. The cross-platform Fl_Native_File_Chooser_FLTK.cxx file must be compiled in libfltk,
and the default FLTK file chooser will be used.
This other implementation
This other implementation:
Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
platform_fnfc = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fl_Native_File_Chooser.cxx
Expand Up @@ -20,7 +20,7 @@
#include <FL/Fl_Native_File_Chooser.H>

#ifdef FL_PORTING
# pragma message "Implement a native file chooser (see Fl_Native_File_Chooser_Driver), or use FLTK's chooser"
# pragma message "Implement a native file chooser (see Fl_Native_File_Chooser_Driver), or use FLTK's chooser, or don't use any chooser"
Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
platform_fnfc = new Fl_Native_File_Chooser_FLTK_Driver(val);
}
Expand Down
58 changes: 29 additions & 29 deletions src/Fl_Native_File_Chooser_GTK.cxx
Expand Up @@ -96,16 +96,16 @@ typedef void (*GClosureNotify)(gpointer data, GClosure *closure);
/* --------------------- End of Type definitions from GLIB and GTK --------------------- */


class FL_EXPORT Fl_Native_File_Chooser_GTK_Driver : public Fl_Native_File_Chooser_FLTK_Driver {
class FL_EXPORT Fl_GTK_Native_File_Chooser_Driver : public Fl_Native_File_Chooser_FLTK_Driver {
friend class Fl_Native_File_Chooser;
private:
static int have_looked_for_GTK_libs;
typedef struct _GtkWidget GtkWidget;
typedef struct _GtkFileFilterInfo GtkFileFilterInfo;
struct pair {
Fl_Native_File_Chooser_GTK_Driver* running; // the running Fl_GTK_File_Chooser
Fl_GTK_Native_File_Chooser_Driver* running; // the running Fl_GTK_File_Chooser
const char *filter; // a filter string of the chooser
pair(Fl_Native_File_Chooser_GTK_Driver* c, const char *f) {
pair(Fl_GTK_Native_File_Chooser_Driver* c, const char *f) {
running = c;
filter = strdup(f);
};
Expand All @@ -121,8 +121,8 @@ class FL_EXPORT Fl_Native_File_Chooser_GTK_Driver : public Fl_Native_File_Choose
const char *previous_filter;

int fl_gtk_chooser_wrapper(); // method that wraps the GTK widget
Fl_Native_File_Chooser_GTK_Driver(int val);
virtual ~Fl_Native_File_Chooser_GTK_Driver();
Fl_GTK_Native_File_Chooser_Driver(int val);
virtual ~Fl_GTK_Native_File_Chooser_Driver();
static int did_find_GTK_libs;
static void probe_for_GTK_libs(void);
virtual void type(int);
Expand All @@ -134,12 +134,12 @@ class FL_EXPORT Fl_Native_File_Chooser_GTK_Driver : public Fl_Native_File_Choose
virtual int show();
void changed_output_type(const char *filter);

static int custom_gtk_filter_function(const GtkFileFilterInfo*, Fl_Native_File_Chooser_GTK_Driver::pair*);
static int custom_gtk_filter_function(const GtkFileFilterInfo*, Fl_GTK_Native_File_Chooser_Driver::pair*);
static void free_pair(pair *p);
};


int Fl_Native_File_Chooser_GTK_Driver::did_find_GTK_libs = 0;
int Fl_GTK_Native_File_Chooser_Driver::did_find_GTK_libs = 0;

/* These are the GTK/GLib methods we want to load, but not call by name...! */

Expand Down Expand Up @@ -291,26 +291,26 @@ typedef void (*XX_gtk_toggle_button_set_active)(GtkToggleButton *, gboolean);
static XX_gtk_toggle_button_set_active fl_gtk_toggle_button_set_active = NULL;


int Fl_Native_File_Chooser_GTK_Driver::have_looked_for_GTK_libs = 0;
int Fl_GTK_Native_File_Chooser_Driver::have_looked_for_GTK_libs = 0;


Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
if (Fl_Native_File_Chooser_GTK_Driver::have_looked_for_GTK_libs == 0) {
if (Fl_GTK_Native_File_Chooser_Driver::have_looked_for_GTK_libs == 0) {
// First Time here, try to find the GTK libs if they are installed
#if HAVE_DLSYM && HAVE_DLFCN_H
if (Fl::option(Fl::OPTION_FNFC_USES_GTK)) {
Fl_Native_File_Chooser_GTK_Driver::probe_for_GTK_libs();
Fl_GTK_Native_File_Chooser_Driver::probe_for_GTK_libs();
}
#endif
Fl_Native_File_Chooser_GTK_Driver::have_looked_for_GTK_libs = -1;
Fl_GTK_Native_File_Chooser_Driver::have_looked_for_GTK_libs = -1;
}
// if we found all the GTK functions we need, we will use the GtkFileChooserDialog
if (Fl_Native_File_Chooser_GTK_Driver::did_find_GTK_libs) platform_fnfc = new Fl_Native_File_Chooser_GTK_Driver(val);
if (Fl_GTK_Native_File_Chooser_Driver::did_find_GTK_libs) platform_fnfc = new Fl_GTK_Native_File_Chooser_Driver(val);
else platform_fnfc = new Fl_Native_File_Chooser_FLTK_Driver(val);
}


Fl_Native_File_Chooser_GTK_Driver::Fl_Native_File_Chooser_GTK_Driver(int val) : Fl_Native_File_Chooser_FLTK_Driver(-1)
Fl_GTK_Native_File_Chooser_Driver::Fl_GTK_Native_File_Chooser_Driver(int val) : Fl_Native_File_Chooser_FLTK_Driver(-1)
{
gtkw_ptr = NULL; // used to hold a GtkWidget*
gtkw_slist = NULL; // will hold the returned file names in a multi-selection...
Expand All @@ -321,7 +321,7 @@ Fl_Native_File_Chooser_GTK_Driver::Fl_Native_File_Chooser_GTK_Driver(int val) :
previous_filter = NULL;
}

Fl_Native_File_Chooser_GTK_Driver::~Fl_Native_File_Chooser_GTK_Driver()
Fl_GTK_Native_File_Chooser_Driver::~Fl_GTK_Native_File_Chooser_Driver()
{
// Should free up resources taken for...
if(gtkw_ptr) {
Expand All @@ -345,15 +345,15 @@ Fl_Native_File_Chooser_GTK_Driver::~Fl_Native_File_Chooser_GTK_Driver()
gtkw_title = strfree(gtkw_title);
}

void Fl_Native_File_Chooser_GTK_Driver::type(int val) {
void Fl_GTK_Native_File_Chooser_Driver::type(int val) {
_btype = val;
}

int Fl_Native_File_Chooser_GTK_Driver::count() const {
int Fl_GTK_Native_File_Chooser_Driver::count() const {
return gtkw_count;
}

const char *Fl_Native_File_Chooser_GTK_Driver::filename() const
const char *Fl_GTK_Native_File_Chooser_Driver::filename() const
{
if(gtkw_ptr) {
if(fl_gtk_file_chooser_get_select_multiple((GtkFileChooser *)gtkw_ptr) == FALSE) {
Expand All @@ -368,7 +368,7 @@ const char *Fl_Native_File_Chooser_GTK_Driver::filename() const
return("");
}

const char *Fl_Native_File_Chooser_GTK_Driver::filename(int i) const
const char *Fl_GTK_Native_File_Chooser_Driver::filename(int i) const
{
if(fl_gtk_file_chooser_get_select_multiple((GtkFileChooser *)gtkw_ptr) == FALSE) {
return gtkw_filename;
Expand All @@ -383,19 +383,19 @@ const char *Fl_Native_File_Chooser_GTK_Driver::filename(int i) const
return("");
}

void Fl_Native_File_Chooser_GTK_Driver::title(const char *val)
void Fl_GTK_Native_File_Chooser_Driver::title(const char *val)
{
strfree(gtkw_title);
gtkw_title = strnew(val);
}

const char* Fl_Native_File_Chooser_GTK_Driver::title() const
const char* Fl_GTK_Native_File_Chooser_Driver::title() const
{
return gtkw_title;
}

/* changes the extension of the outfile in the chooser according to newly selected filter */
void Fl_Native_File_Chooser_GTK_Driver::changed_output_type(const char *filter)
void Fl_GTK_Native_File_Chooser_Driver::changed_output_type(const char *filter)
{
if ( !(options()&Fl_Native_File_Chooser::USE_FILTER_EXT) ) return;
if (strchr(filter, '(') || strchr(filter, '{') || strchr(filter+1, '*') || strncmp(filter, "*.", 2)) return;
Expand All @@ -413,7 +413,7 @@ void Fl_Native_File_Chooser_GTK_Driver::changed_output_type(const char *filter)

/* Filters files before display in chooser.
Also used to detect when the filter just changed */
gboolean Fl_Native_File_Chooser_GTK_Driver::custom_gtk_filter_function(const GtkFileFilterInfo *info, Fl_Native_File_Chooser_GTK_Driver::pair* p)
gboolean Fl_GTK_Native_File_Chooser_Driver::custom_gtk_filter_function(const GtkFileFilterInfo *info, Fl_GTK_Native_File_Chooser_Driver::pair* p)
{
if (p->running->previous_filter != p->filter) {
p->running->changed_output_type(p->filter);
Expand All @@ -422,7 +422,7 @@ gboolean Fl_Native_File_Chooser_GTK_Driver::custom_gtk_filter_function(const Gtk
return (gboolean)fl_filename_match(fl_filename_name(info->filename), p->filter);
}

void Fl_Native_File_Chooser_GTK_Driver::free_pair(Fl_Native_File_Chooser_GTK_Driver::pair *p)
void Fl_GTK_Native_File_Chooser_Driver::free_pair(Fl_GTK_Native_File_Chooser_Driver::pair *p)
{
delete p;
}
Expand All @@ -433,7 +433,7 @@ static void hidden_files_cb(GtkToggleButton *togglebutton, gpointer user_data)
fl_gtk_file_chooser_set_show_hidden((GtkFileChooser*)user_data, state);
}

int Fl_Native_File_Chooser_GTK_Driver::show()
int Fl_GTK_Native_File_Chooser_Driver::show()
{
// The point here is that after running a GTK dialog, the calling program's current locale is modified.
// To avoid that, we memorize the calling program's current locale, and the locale as modified
Expand Down Expand Up @@ -489,7 +489,7 @@ static void run_response_handler(GtkDialog *dialog, gint response_id, gpointer d
}


int Fl_Native_File_Chooser_GTK_Driver::fl_gtk_chooser_wrapper()
int Fl_GTK_Native_File_Chooser_Driver::fl_gtk_chooser_wrapper()
{
int result = 1;
static int have_gtk_init = 0;
Expand Down Expand Up @@ -586,9 +586,9 @@ int Fl_Native_File_Chooser_GTK_Driver::fl_gtk_chooser_wrapper()
char *q = strchr(p, ')'); *q = 0;
fl_gtk_file_filter_add_custom(filter_tab[count],
GTK_FILE_FILTER_FILENAME,
(GtkFileFilterFunc)Fl_Native_File_Chooser_GTK_Driver::custom_gtk_filter_function,
new Fl_Native_File_Chooser_GTK_Driver::pair(this, p),
(GDestroyNotify)Fl_Native_File_Chooser_GTK_Driver::free_pair);
(GtkFileFilterFunc)Fl_GTK_Native_File_Chooser_Driver::custom_gtk_filter_function,
new Fl_GTK_Native_File_Chooser_Driver::pair(this, p),
(GDestroyNotify)Fl_GTK_Native_File_Chooser_Driver::free_pair);
fl_gtk_file_chooser_add_filter((GtkFileChooser *)gtkw_ptr, filter_tab[count]);
p = strtok(NULL, "\t");
count++;
Expand Down Expand Up @@ -714,7 +714,7 @@ static void* fl_dlopen(const char *filename1, const char *filename2)
* will allow us to create a GtkFileChooserDialog() on the fly,
* without linking to the GTK libs at compile time.
*/
void Fl_Native_File_Chooser_GTK_Driver::probe_for_GTK_libs(void) {
void Fl_GTK_Native_File_Chooser_Driver::probe_for_GTK_libs(void) {
#if HAVE_DLSYM && HAVE_DLFCN_H
void *ptr_glib = NULL;
void *ptr_gtk = NULL;
Expand Down

0 comments on commit f810452

Please sign in to comment.