Re: [Bug 161797] Save as... fails in win32 when curdir is on server



Owen Taylor writes:
 > Can we use/extend the GtkFileSystem abstraction here rather than
 > introducing #ifdef's?

You mean like this: Adding the methods:

  int  (*path_compare) (GtkFileSystem *file_system,
			const gchar   *path1,
			const gchar   *path2);
  char (*get_desktop)  (GtkFileSystem *file_system);

to the GtkFileSystemIface struct, and adding the functions:

int      gtk_file_system_path_compare    (GtkFileSystem     *file_system,
					  const GtkFilePath *path1,
					  const GtkFilePath *path2);

GtkFilePath *gtk_file_system_get_desktop (GtkFileSystem     *file_system);

But what should be done with the gtk_file_path_compare(path1,path2)
macro? Should that be made into a function in gtkfilesystem.c that
uses an internal static GtkFileSystem object (of either the "Unix" or
"Win32" variant) and calls gtk_file_system_path_compare()? Like this:

int
gtk_file_path_compare (const GtkFilePath *path1,
                       const GtkFilePath *path2)
{
  static GtkFileSystem *fs = NULL;

  if (fs == NULL)
    {
#ifdef G_OS_WIN32
      fs = gtk_file_system_win32_new ();
#else
      fs = gtk_file_system_unix_new ();
#endif
    }

  return gtk_file_system_path_compare (fs, path1, path2);
}

Why BTW can there be several instances of GtkFileSystemUnix (and
GtkFileSystemWin32)? Shouldn't these ideally be singletons? Or am I
(very likely) missing something?

--tml





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]