- Added GTK+-based clipboard support for Linux.

- Fixed: Most Linux filesystems do not fill in d_type for scandir(), so we
  cannot rely on it to detect directories.
- Added NicePath() function to perform shell-style ~ substitution on path
  names.
- Changed the default screenshot directory on Unix to ~/.zdoom/screenshots/.
- Added -shotdir command line option to temporarily override the
  screenshot_dir cvar.



SVN r1413 (trunk)
This commit is contained in:
Randy Heit 2009-02-08 02:52:43 +00:00
commit be165578ea
7 changed files with 199 additions and 69 deletions

View file

@ -30,6 +30,7 @@
#include <stdarg.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#ifndef NO_GTK
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
@ -509,11 +510,7 @@ bool I_WriteIniFailed ()
static const char *pattern;
#ifdef OSF1
static int matchfile (struct dirent *ent)
#else
static int matchfile (const struct dirent *ent)
#endif
{
return fnmatch (pattern, ent->d_name, FNM_NOESCAPE) == 0;
}
@ -568,21 +565,54 @@ int I_FindClose (void *handle)
int I_FindAttr (findstate_t *fileinfo)
{
struct dirent *ent = fileinfo->namelist[fileinfo->current];
dirent *ent = fileinfo->namelist[fileinfo->current];
struct stat buf;
#ifdef OSF1
return 0; // I don't know how to detect dirs under OSF/1
#else
return (ent->d_type == DT_DIR) ? FA_DIREC : 0;
#endif
if (stat(ent->d_name, &buf) == 0)
{
return S_ISDIR(buf.st_mode) ? FA_DIREC : 0;
}
return 0;
}
// No clipboard support for Linux
// Clipboard support requires GTK+
// TODO: GTK+ uses UTF-8. We don't, so some conversions would be appropriate.
void I_PutInClipboard (const char *str)
{
#ifndef NO_GTK
if (GtkAvailable)
{
GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
if (clipboard != NULL)
{
gtk_clipboard_set_text(clipboard, str, -1);
}
clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
if (clipboard != NULL)
{
gtk_clipboard_set_text(clipboard, str, -1);
}
}
#endif
}
char *I_GetFromClipboard ()
{
#ifndef NO_GTK
if (GtkAvailable)
{
GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
if (clipboard != NULL)
{
gchar *text = gtk_clipboard_wait_for_text(clipboard);
if (text != NULL)
{
char *copy = copystring(text);
g_free(text);
return copy;
}
}
}
#endif
return NULL;
}