+2000-02-04 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkfont-win32.c (logfont_to_xlfd): Use
+ g_filename_to_utf8 to convert the font names Windows gives us from
+ whatever is the default codepage to UTF-8.
+ (gdk_font_load_internal) Use g_filename_from_utf8 for conversion
+ in the other direction.
+
+ * gdk/win32/gdkgc-win32.c (gdk_win32_gc_set_values): Fix cut&paste
+ error in debugging output.
+
+2000-02-02 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkwindow-win32.c (gdk_window_clear): Pass zero width
+ and height parameters to gdk_window_clear_area(). Not minus one.
+
Wed Feb 2 11:58:05 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_selection_received): Add some sanity
checks if the widget passed to gtk_drag_get_data() was not the
dest widget.
+2000-02-01 Tor Lillqvist <tml@iki.fi>
+
+ * gtk/gtkfilesel.c: Use the g_filename_to_utf8 and
+ g_filename_from_utf8 functions (which were added a moment ago to
+ GLib). Some cleanups: Use gbooleans. Use GStrings instead of fixed
+ size buffers.
+
+ * gtk/gtkfilesel.h: Add comment about
+ gtk_file_selection_get_filename returning the filename in the C
+ runtime's encoding.
+
+ * README.win32
+ * gdk/gdk.def
+ * gdk/makefile.{cygwin,msc}
+ * gtk/gtk.def: Updates.
+
+ * gdk/gdkcursor-win32.c: Initialise refcount.
+
2000-01-31 Yuan-Chung Cheng <platin@linux.org.tw>
* configure.in: Added "zh_CN.GB2312" to ALL_LINGUAS.
+2000-02-04 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkfont-win32.c (logfont_to_xlfd): Use
+ g_filename_to_utf8 to convert the font names Windows gives us from
+ whatever is the default codepage to UTF-8.
+ (gdk_font_load_internal) Use g_filename_from_utf8 for conversion
+ in the other direction.
+
+ * gdk/win32/gdkgc-win32.c (gdk_win32_gc_set_values): Fix cut&paste
+ error in debugging output.
+
+2000-02-02 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkwindow-win32.c (gdk_window_clear): Pass zero width
+ and height parameters to gdk_window_clear_area(). Not minus one.
+
Wed Feb 2 11:58:05 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_selection_received): Add some sanity
checks if the widget passed to gtk_drag_get_data() was not the
dest widget.
+2000-02-01 Tor Lillqvist <tml@iki.fi>
+
+ * gtk/gtkfilesel.c: Use the g_filename_to_utf8 and
+ g_filename_from_utf8 functions (which were added a moment ago to
+ GLib). Some cleanups: Use gbooleans. Use GStrings instead of fixed
+ size buffers.
+
+ * gtk/gtkfilesel.h: Add comment about
+ gtk_file_selection_get_filename returning the filename in the C
+ runtime's encoding.
+
+ * README.win32
+ * gdk/gdk.def
+ * gdk/makefile.{cygwin,msc}
+ * gtk/gtk.def: Updates.
+
+ * gdk/gdkcursor-win32.c: Initialise refcount.
+
2000-01-31 Yuan-Chung Cheng <platin@linux.org.tw>
* configure.in: Added "zh_CN.GB2312" to ALL_LINGUAS.
+2000-02-04 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkfont-win32.c (logfont_to_xlfd): Use
+ g_filename_to_utf8 to convert the font names Windows gives us from
+ whatever is the default codepage to UTF-8.
+ (gdk_font_load_internal) Use g_filename_from_utf8 for conversion
+ in the other direction.
+
+ * gdk/win32/gdkgc-win32.c (gdk_win32_gc_set_values): Fix cut&paste
+ error in debugging output.
+
+2000-02-02 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkwindow-win32.c (gdk_window_clear): Pass zero width
+ and height parameters to gdk_window_clear_area(). Not minus one.
+
Wed Feb 2 11:58:05 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_selection_received): Add some sanity
checks if the widget passed to gtk_drag_get_data() was not the
dest widget.
+2000-02-01 Tor Lillqvist <tml@iki.fi>
+
+ * gtk/gtkfilesel.c: Use the g_filename_to_utf8 and
+ g_filename_from_utf8 functions (which were added a moment ago to
+ GLib). Some cleanups: Use gbooleans. Use GStrings instead of fixed
+ size buffers.
+
+ * gtk/gtkfilesel.h: Add comment about
+ gtk_file_selection_get_filename returning the filename in the C
+ runtime's encoding.
+
+ * README.win32
+ * gdk/gdk.def
+ * gdk/makefile.{cygwin,msc}
+ * gtk/gtk.def: Updates.
+
+ * gdk/gdkcursor-win32.c: Initialise refcount.
+
2000-01-31 Yuan-Chung Cheng <platin@linux.org.tw>
* configure.in: Added "zh_CN.GB2312" to ALL_LINGUAS.
+2000-02-04 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkfont-win32.c (logfont_to_xlfd): Use
+ g_filename_to_utf8 to convert the font names Windows gives us from
+ whatever is the default codepage to UTF-8.
+ (gdk_font_load_internal) Use g_filename_from_utf8 for conversion
+ in the other direction.
+
+ * gdk/win32/gdkgc-win32.c (gdk_win32_gc_set_values): Fix cut&paste
+ error in debugging output.
+
+2000-02-02 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkwindow-win32.c (gdk_window_clear): Pass zero width
+ and height parameters to gdk_window_clear_area(). Not minus one.
+
Wed Feb 2 11:58:05 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_selection_received): Add some sanity
checks if the widget passed to gtk_drag_get_data() was not the
dest widget.
+2000-02-01 Tor Lillqvist <tml@iki.fi>
+
+ * gtk/gtkfilesel.c: Use the g_filename_to_utf8 and
+ g_filename_from_utf8 functions (which were added a moment ago to
+ GLib). Some cleanups: Use gbooleans. Use GStrings instead of fixed
+ size buffers.
+
+ * gtk/gtkfilesel.h: Add comment about
+ gtk_file_selection_get_filename returning the filename in the C
+ runtime's encoding.
+
+ * README.win32
+ * gdk/gdk.def
+ * gdk/makefile.{cygwin,msc}
+ * gtk/gtk.def: Updates.
+
+ * gdk/gdkcursor-win32.c: Initialise refcount.
+
2000-01-31 Yuan-Chung Cheng <platin@linux.org.tw>
* configure.in: Added "zh_CN.GB2312" to ALL_LINGUAS.
+2000-02-04 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkfont-win32.c (logfont_to_xlfd): Use
+ g_filename_to_utf8 to convert the font names Windows gives us from
+ whatever is the default codepage to UTF-8.
+ (gdk_font_load_internal) Use g_filename_from_utf8 for conversion
+ in the other direction.
+
+ * gdk/win32/gdkgc-win32.c (gdk_win32_gc_set_values): Fix cut&paste
+ error in debugging output.
+
+2000-02-02 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkwindow-win32.c (gdk_window_clear): Pass zero width
+ and height parameters to gdk_window_clear_area(). Not minus one.
+
Wed Feb 2 11:58:05 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_selection_received): Add some sanity
checks if the widget passed to gtk_drag_get_data() was not the
dest widget.
+2000-02-01 Tor Lillqvist <tml@iki.fi>
+
+ * gtk/gtkfilesel.c: Use the g_filename_to_utf8 and
+ g_filename_from_utf8 functions (which were added a moment ago to
+ GLib). Some cleanups: Use gbooleans. Use GStrings instead of fixed
+ size buffers.
+
+ * gtk/gtkfilesel.h: Add comment about
+ gtk_file_selection_get_filename returning the filename in the C
+ runtime's encoding.
+
+ * README.win32
+ * gdk/gdk.def
+ * gdk/makefile.{cygwin,msc}
+ * gtk/gtk.def: Updates.
+
+ * gdk/gdkcursor-win32.c: Initialise refcount.
+
2000-01-31 Yuan-Chung Cheng <platin@linux.org.tw>
* configure.in: Added "zh_CN.GB2312" to ALL_LINGUAS.
+2000-02-04 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkfont-win32.c (logfont_to_xlfd): Use
+ g_filename_to_utf8 to convert the font names Windows gives us from
+ whatever is the default codepage to UTF-8.
+ (gdk_font_load_internal) Use g_filename_from_utf8 for conversion
+ in the other direction.
+
+ * gdk/win32/gdkgc-win32.c (gdk_win32_gc_set_values): Fix cut&paste
+ error in debugging output.
+
+2000-02-02 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkwindow-win32.c (gdk_window_clear): Pass zero width
+ and height parameters to gdk_window_clear_area(). Not minus one.
+
Wed Feb 2 11:58:05 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_selection_received): Add some sanity
checks if the widget passed to gtk_drag_get_data() was not the
dest widget.
+2000-02-01 Tor Lillqvist <tml@iki.fi>
+
+ * gtk/gtkfilesel.c: Use the g_filename_to_utf8 and
+ g_filename_from_utf8 functions (which were added a moment ago to
+ GLib). Some cleanups: Use gbooleans. Use GStrings instead of fixed
+ size buffers.
+
+ * gtk/gtkfilesel.h: Add comment about
+ gtk_file_selection_get_filename returning the filename in the C
+ runtime's encoding.
+
+ * README.win32
+ * gdk/gdk.def
+ * gdk/makefile.{cygwin,msc}
+ * gtk/gtk.def: Updates.
+
+ * gdk/gdkcursor-win32.c: Initialise refcount.
+
2000-01-31 Yuan-Chung Cheng <platin@linux.org.tw>
* configure.in: Added "zh_CN.GB2312" to ALL_LINGUAS.
+2000-02-04 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkfont-win32.c (logfont_to_xlfd): Use
+ g_filename_to_utf8 to convert the font names Windows gives us from
+ whatever is the default codepage to UTF-8.
+ (gdk_font_load_internal) Use g_filename_from_utf8 for conversion
+ in the other direction.
+
+ * gdk/win32/gdkgc-win32.c (gdk_win32_gc_set_values): Fix cut&paste
+ error in debugging output.
+
+2000-02-02 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkwindow-win32.c (gdk_window_clear): Pass zero width
+ and height parameters to gdk_window_clear_area(). Not minus one.
+
Wed Feb 2 11:58:05 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_selection_received): Add some sanity
checks if the widget passed to gtk_drag_get_data() was not the
dest widget.
+2000-02-01 Tor Lillqvist <tml@iki.fi>
+
+ * gtk/gtkfilesel.c: Use the g_filename_to_utf8 and
+ g_filename_from_utf8 functions (which were added a moment ago to
+ GLib). Some cleanups: Use gbooleans. Use GStrings instead of fixed
+ size buffers.
+
+ * gtk/gtkfilesel.h: Add comment about
+ gtk_file_selection_get_filename returning the filename in the C
+ runtime's encoding.
+
+ * README.win32
+ * gdk/gdk.def
+ * gdk/makefile.{cygwin,msc}
+ * gtk/gtk.def: Updates.
+
+ * gdk/gdkcursor-win32.c: Initialise refcount.
+
2000-01-31 Yuan-Chung Cheng <platin@linux.org.tw>
* configure.in: Added "zh_CN.GB2312" to ALL_LINGUAS.
See the README.win32 file in the GLib distribution for instructions
how to build with gcc.
-The same instructions are also useful if you want to build
-applications that use GTk+ on Win32.
+To use GTk+ on Win32, you also need either of the above mentioned
+compilers. Other compilers might work, but don't count on it. The
+same instructions on how to set up a correct version of gcc should
+also be followed if you want to build applications that use GTk+ with
+gcc.
The tablet support uses the Wintab API. The Wintab development kit can
be downloaded from http://www.pointing.com. If you don't care for
gdk_color_alloc
gdk_color_black
gdk_color_change
- gdk_color_copy
- gdk_color_equal
- gdk_color_free
- gdk_color_hash
- gdk_color_parse
- gdk_color_white
gdk_color_context_add_palette
gdk_color_context_free
gdk_color_context_free_dither
gdk_color_context_new_mono
gdk_color_context_query_color
gdk_color_context_query_colors
+ gdk_color_copy
+ gdk_color_equal
+ gdk_color_free
+ gdk_color_hash
+ gdk_color_parse
+ gdk_color_white
gdk_colormap_alloc_color
gdk_colormap_alloc_colors
gdk_colormap_change
gdk_colors_alloc
gdk_colors_free
gdk_colors_store
- gdk_cursor_destroy
gdk_cursor_new
gdk_cursor_new_from_pixmap
+ gdk_cursor_ref
+ gdk_cursor_unref
gdk_dnd_init
gdk_drag_abort
gdk_drag_begin
gdk_exit
gdk_flush
gdk_font_equal
+ gdk_font_full_name_free
+ gdk_font_full_name_get
gdk_font_id
gdk_font_list_free
gdk_font_list_new
gdk_font_load
gdk_font_ref
gdk_font_unref
- gdk_font_full_name_get
- gdk_font_full_name_free
gdk_fontset_load
gdk_free_compound_text
gdk_free_text_list
gdk_OBJECTS = \
gdk.o \
gdkcolor.o \
+ gdkcursor.o \
gdkdraw.o \
gdkevents.o \
gdkfont.o \
gdk_OBJECTS = \
gdk.obj \
gdkcolor.obj \
+ gdkcursor.obj \
gdkdraw.obj \
gdkevents.obj \
gdkfont.obj \
private->xcursor = xcursor;
cursor = (GdkCursor*) private;
cursor->type = cursor_type;
+ cursor->refcount = 1;
return cursor;
}
g_return_if_fail (cursor != NULL);
private = (GdkCursorPrivate *) cursor;
- GDK_NOTE (MISC, g_print ("gdk_cursor_destroy: %#x\n",
+ GDK_NOTE (MISC, g_print ("_gdk_cursor_destroy: %#x\n",
(cursor->type == GDK_CURSOR_IS_PIXMAP) ? private->xcursor : 0));
if (cursor->type == GDK_CURSOR_IS_PIXMAP)
if (!DestroyIcon (private->xcursor))
- g_warning ("gdk_cursor_destroy: DestroyIcon failed");
+ g_warning ("_gdk_cursor_destroy: DestroyIcon failed");
g_free (private);
}
const gchar *registry, *encoding;
int point_size;
static int logpixelsy = 0;
- gchar facename[LF_FACESIZE*3];
+ gchar facename[LF_FACESIZE*5];
+ gchar *utf8_facename;
gchar *p;
const gchar *q;
if (res == -1)
res = logpixelsy;
- /* Replace illegal characters with hex escapes. */
+ /* Convert the facename Windows fives us from the locale-dependent
+ * codepage to UTF-8.
+ */
+ utf8_facename = g_filename_to_utf8 (lfp->lfFaceName);
+
+ /* Replace characters illegal in an XLFD with hex escapes. */
p = facename;
- q = lfp->lfFaceName;
+ q = utf8_facename;
while (*q)
{
if (*q == '-' || *q == '*' || *q == '?' || *q == '%')
q++;
}
*p = '\0';
+ g_free (utf8_facename);
- return g_strdup_printf
+ return g_strdup_printf
("-%s-%s-%s-%s-%s-%s-%d-%d-%d-%d-%s-%d-%s-%s",
"unknown",
facename,
GSList *list;
GString *string;
gchar *result;
+ gchar *xlfd;
LOGFONT logfont;
g_return_val_if_fail (font != NULL, NULL);
return NULL;
}
- string =
- g_string_append (string,
- logfont_to_xlfd (&logfont, logfont.lfHeight, -1, 0));
+ xlfd = logfont_to_xlfd (&logfont, logfont.lfHeight, -1, 0);
+ string = g_string_append (string, xlfd);
+ g_free (xlfd);
list = list->next;
if (list)
string = g_string_append_c (string, ',');
DWORD fdwItalic, fdwUnderline, fdwStrikeOut, fdwCharSet,
fdwOutputPrecision, fdwClipPrecision, fdwQuality, fdwPitchAndFamily;
HGDIOBJ oldfont;
- const char *lpszFace;
+ char *lpszFace;
gchar face[100];
int numfields, n1, n2, tries;
fdwClipPrecision = CLIP_DEFAULT_PRECIS;
fdwQuality = PROOF_QUALITY;
fdwPitchAndFamily = DEFAULT_PITCH;
- lpszFace = font_name;
+ lpszFace = g_filename_from_utf8 (font_name);
}
else if (numfields != 5)
{
/* It must be a XLFD name */
/* Check for hex escapes in the font family,
- * put in there by gtkfontsel.
+ * put in there by logfont_to_xlfd. Convert them in-place.
*/
p = family;
while (*p)
fdwPitchAndFamily = VARIABLE_PITCH;
else
fdwPitchAndFamily = DEFAULT_PITCH;
- lpszFace = family;
+ lpszFace = g_filename_from_utf8 (family);
}
for (tries = 0; ; tries++)
fnWeight, fdwItalic, fdwUnderline, fdwStrikeOut,
fdwCharSet, fdwOutputPrecision, fdwClipPrecision,
fdwQuality, fdwPitchAndFamily, lpszFace));
- if ((hfont =
- CreateFont (nHeight, nWidth, nEscapement, nOrientation,
- fnWeight, fdwItalic, fdwUnderline, fdwStrikeOut,
- fdwCharSet, fdwOutputPrecision, fdwClipPrecision,
- fdwQuality, fdwPitchAndFamily, lpszFace)) != NULL)
+ hfont = CreateFont (nHeight, nWidth, nEscapement, nOrientation,
+ fnWeight, fdwItalic, fdwUnderline, fdwStrikeOut,
+ fdwCharSet, fdwOutputPrecision, fdwClipPrecision,
+ fdwQuality, fdwPitchAndFamily, lpszFace);
+ /* After the first try lpszFace contains a return value
+ * from g_filename_from_utf8(), so free it.
+ */
+ if (tries == 0)
+ g_free (lpszFace);
+
+ if (hfont != NULL)
break;
/* If we fail, try some similar fonts often found on Windows. */
-
if (tries == 0)
{
if (g_strcasecmp (family, "helvetica") == 0)
if (values_mask & GDK_GC_BACKGROUND)
{
GDK_NOTE (MISC, g_print ("bg = %s ",
- gdk_color_to_string (&values->foreground)));
+ gdk_color_to_string (&values->background)));
data->background = values->background;
data->values_mask |= GDK_GC_BACKGROUND;
}
* must be null-terminated. If the conversion is failed, it returns
* -1.
*
- * On Win32, thr string is assumed to be in UTF-8. Also note that
+ * On Win32, the string is assumed to be in UTF-8. Also note that
* GdkWChar is 32 bits, while wchar_t, and the wide characters the
* Windows API uses, are 16 bits!
*/
return n;
}
-
g_return_if_fail (GDK_IS_WINDOW (window));
if (!GDK_DRAWABLE_DESTROYED (window))
- gdk_window_clear_area (window, 0, 0, -1, -1);
+ gdk_window_clear_area (window, 0, 0, 0, 0);
}
gtk_container_forall
gtk_container_foreach
gtk_container_foreach_full
+ gtk_container_get_toplevels
gtk_container_get_type
gtk_container_query_child_args
gtk_container_queue_resize
gtk_container_set_focus_child
gtk_container_set_focus_hadjustment
gtk_container_set_focus_vadjustment
+ gtk_container_set_reallocate_redraws
gtk_container_set_resize_mode
gtk_container_unregister_toplevel
gtk_ctree_collapse
gtk_ctree_export_to_gnode
gtk_ctree_find
gtk_ctree_find_all_by_row_data
+ gtk_ctree_find_all_by_row_data_custom
gtk_ctree_find_by_row_data
gtk_ctree_find_by_row_data_custom
gtk_ctree_find_node_ptr
gtk_list_unselect_child
gtk_list_unselect_item
gtk_main
+ gtk_main_do_event
gtk_main_iteration
gtk_main_iteration_do
gtk_main_level
gtk_object_ref
gtk_object_remove_data
gtk_object_remove_data_by_id
+ gtk_object_remove_no_notify
gtk_object_remove_no_notify_by_id
gtk_object_set
gtk_object_set_data
gtk_widget_newv
gtk_widget_path
gtk_widget_pop_colormap
+ gtk_widget_pop_composite_child
gtk_widget_pop_style
gtk_widget_pop_visual
gtk_widget_popup
gtk_widget_push_colormap
+ gtk_widget_push_composite_child
gtk_widget_push_style
gtk_widget_push_visual
gtk_widget_queue_clear
#include "config.h"
-#include <glib.h> /* To get stat->_stat redefinition
- * for mingw32
- */
-
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
dev_t device;
gint entry_count;
- gchar *name_buffer; /* memory segment containing names of all entries */
-
struct _CompletionDirEntry *entries;
};
*/
struct _CompletionDirEntry
{
- gint is_dir;
+ gboolean is_dir;
gchar *entry_name;
};
*/
gchar *text;
gint is_a_completion;
- gint is_directory;
+ gboolean is_directory;
/* Private fields
*/
gchar *updated_text;
gint updated_text_len;
gint updated_text_alloc;
- gint re_complete;
+ gboolean re_complete;
gchar *user_dir_name_buffer;
gint user_directories_len;
/* True if the completion is a directory
*/
-static gint cmpl_is_directory (PossibleCompletion*);
+static gboolean cmpl_is_directory (PossibleCompletion*);
/* Obtains the next completion, or NULL
*/
/* After updating, to see if the completion was a directory, call
* this. If it was, you should consider re-calling completion_matches.
*/
-static gint cmpl_updated_dir (CompletionState* cmpl_state);
+static gboolean cmpl_updated_dir (CompletionState* cmpl_state);
/* Current location: if using file completion, return the current
* directory, from which file completion begins. More specifically,
gtk_file_selection_set_filename (GtkFileSelection *filesel,
const gchar *filename)
{
- char buf[MAXPATHLEN];
+ gchar *buf;
const char *name, *last_slash;
g_return_if_fail (filesel != NULL);
if (!last_slash)
{
- buf[0] = 0;
+ buf = g_strdup ("");
name = filename;
}
else
{
- gint len = MIN (MAXPATHLEN - 1, last_slash - filename + 1);
-
- strncpy (buf, filename, len);
- buf[len] = 0;
-
+ buf = g_strdup (filename);
+ buf[last_slash - filename + 1] = 0;
name = last_slash + 1;
}
if (filesel->selection_entry)
gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), name);
+ g_free (buf);
}
gchar*
if (text)
{
filename = cmpl_completion_fullname (text, filesel->cmpl_state);
- return filename;
+ return g_filename_from_utf8 (filename);
}
return nothing;
return cmpl_state->updated_text;
}
-static gint
+static gboolean
cmpl_updated_dir (CompletionState* cmpl_state)
{
return cmpl_state->re_complete;
return pc->text;
}
-static gint
+static gboolean
cmpl_is_directory (PossibleCompletion* pc)
{
return pc->is_directory;
static void
free_dir_sent(CompletionDirSent* sent)
{
- g_free(sent->name_buffer);
+ gint i;
+ for (i = 0; i < sent->entry_count; i++)
+ g_free(sent->entries[i].entry_name);
g_free(sent->entries);
g_free(sent);
}
CompletionDir* dir,
CompletionState *cmpl_state)
{
- gchar path_buf[2*MAXPATHLEN];
+ CompletionDir *result;
+ GString *path;
- if(dir->fullname_len + strlen(dir_name) + 2 >= MAXPATHLEN)
- {
- cmpl_errno = CMPL_ERRNO_TOO_LONG;
- return NULL;
- }
+ path = g_string_sized_new (dir->fullname_len + strlen (dir_name) + 10);
+ g_string_assign (path, dir->fullname);
- strcpy(path_buf, dir->fullname);
+ if(dir->fullname_len > 1
+ && path->str[dir->fullname_len - 1] != G_DIR_SEPARATOR)
+ g_string_append_c (path, G_DIR_SEPARATOR);
+ g_string_append (path, dir_name);
- if(dir->fullname_len > 1)
- {
- if (path_buf[dir->fullname_len - 1] != G_DIR_SEPARATOR)
- {
- path_buf[dir->fullname_len] = G_DIR_SEPARATOR;
- strcpy (path_buf + dir->fullname_len + 1, dir_name);
- }
- else
- strcpy (path_buf + dir->fullname_len, dir_name);
- }
- else
- {
- strcpy(path_buf + dir->fullname_len, dir_name);
- }
+ result = open_dir(path->str, cmpl_state);
+
+ g_string_free (path, TRUE);
- return open_dir(path_buf, cmpl_state);
+ return result;
}
/* after the cache lookup fails, really open a new directory */
DIR* directory;
gchar *buffer_ptr;
struct dirent *dirent_ptr;
- gint buffer_size = 0;
gint entry_count = 0;
gint i;
struct stat ent_sbuf;
- char path_buf[MAXPATHLEN*2];
- gint path_buf_len;
+ GString *path;
+ gchar *xdir, *xname;
+ int entry_len;
sent = g_new(CompletionDirSent, 1);
sent->mtime = sbuf->st_mtime;
sent->inode = sbuf->st_ino;
sent->device = sbuf->st_dev;
- path_buf_len = strlen(dir_name);
+ path = g_string_sized_new (2*MAXPATHLEN + 10);
- if (path_buf_len > MAXPATHLEN)
- {
- cmpl_errno = CMPL_ERRNO_TOO_LONG;
- return NULL;
- }
-
- strcpy(path_buf, dir_name);
-
- directory = opendir(dir_name);
+ xdir = g_filename_from_utf8 (dir_name);
+ directory = opendir(xdir);
+ g_free (xdir);
if(!directory)
{
while((dirent_ptr = readdir(directory)) != NULL)
{
- int entry_len = strlen(dirent_ptr->d_name);
- buffer_size += entry_len + 1;
- entry_count += 1;
-
- if(path_buf_len + entry_len + 2 >= MAXPATHLEN)
- {
- cmpl_errno = CMPL_ERRNO_TOO_LONG;
- closedir(directory);
- return NULL;
- }
+ entry_count++;
}
- sent->name_buffer = g_new(gchar, buffer_size);
sent->entries = g_new(CompletionDirEntry, entry_count);
sent->entry_count = entry_count;
- buffer_ptr = sent->name_buffer;
-
rewinddir(directory);
for(i = 0; i < entry_count; i += 1)
return NULL;
}
- strcpy(buffer_ptr, dirent_ptr->d_name);
- sent->entries[i].entry_name = buffer_ptr;
- buffer_ptr += strlen(dirent_ptr->d_name);
- *buffer_ptr = 0;
- buffer_ptr += 1;
+ sent->entries[i].entry_name = g_filename_to_utf8 (dirent_ptr->d_name);
- if (path_buf[path_buf_len-1] != G_DIR_SEPARATOR)
+ g_string_assign (path, dir_name);
+ if (path->str[path->len-1] != G_DIR_SEPARATOR)
{
- path_buf[path_buf_len] = G_DIR_SEPARATOR;
- strcpy(path_buf + path_buf_len + 1, dirent_ptr->d_name);
+ g_string_append_c (path, G_DIR_SEPARATOR);
}
- else
- strcpy(path_buf + path_buf_len, dirent_ptr->d_name);
+ g_string_append (path, dirent_ptr->d_name);
if (stat_subdirs)
{
- if(stat(path_buf, &ent_sbuf) >= 0 && S_ISDIR(ent_sbuf.st_mode))
- sent->entries[i].is_dir = 1;
+ if(stat(path->str, &ent_sbuf) >= 0 && S_ISDIR(ent_sbuf.st_mode))
+ sent->entries[i].is_dir = TRUE;
else
/* stat may fail, and we don't mind, since it could be a
* dangling symlink. */
- sent->entries[i].is_dir = 0;
+ sent->entries[i].is_dir = FALSE;
}
else
sent->entries[i].is_dir = 1;
}
+ g_string_free (path, TRUE);
qsort(sent->entries, sent->entry_count, sizeof(CompletionDirEntry), compare_cmpl_dir);
closedir(directory);
}
cmpl_state->the_completion.is_a_completion = 1;
- cmpl_state->the_completion.is_directory = 1;
+ cmpl_state->the_completion.is_directory = TRUE;
append_completion_text("~", cmpl_state);
{
cmpl_state->user_completion_index += 1;
cmpl_state->the_completion.is_a_completion = 1;
- cmpl_state->the_completion.is_directory = 1;
+ cmpl_state->the_completion.is_directory = TRUE;
return append_completion_text("~" G_DIR_SEPARATOR_S, cmpl_state);
}
GtkWidget* gtk_file_selection_new (const gchar *title);
void gtk_file_selection_set_filename (GtkFileSelection *filesel,
const gchar *filename);
+/* This function returns the selected filename in the C runtime's
+ * multibyte string encoding, which may or may not be the same as that
+ * used by GDK (UTF-8). To convert to UTF-8, call g_filename_to_utf8().
+ * The returned string should be deallocated with g_free().
+ */
gchar* gtk_file_selection_get_filename (GtkFileSelection *filesel);
+
void gtk_file_selection_complete (GtkFileSelection *filesel,
const gchar *pattern);
void gtk_file_selection_show_fileop_buttons (GtkFileSelection *filesel);