gnome-file-entry and gtk_file_selection
- From: "Daniel M. German" <dmg csg uwaterloo ca>
- To: gnome-devel-list gnome org
- Subject: gnome-file-entry and gtk_file_selection
- Date: Fri, 16 Jul 1999 12:20:40 -0400
Hi fellow Gnomes,
I took over the task to document gnome-file-entry.
While investigating how it works and from my own experience with ggv
(which I have been helping to develop) and other gnome applications
there is something I find particularly annoying and I'd like to
fix. let me explain.
Every time you open a gtk_file_selection dialog, if you specify a
directory it returns with the name of that directory. Fine, sometimes
you want a directory. However, most of the times I want a file, so I'd
like it to rescan the directory. If you use the mouse, it does
that. But if you use the keyboard, it does not. Also, I'd like to be
able to specify masks in the entry box (for instance type /tmp/*.ps
and only see the files that match that).
Do people thing this is the way to go? x11amp does the rescanning.
gnumeric (0.26) crashes.
The code at the end is something I wrote to do what I described
above. I am including it here so you see what I have in mind. It is
not a patch :) It is the callback from the file_selection dialog. It
checkes whether the file is a directory and if so, rescans.
So the question is, should this be done is gtk or gnome. If in gnome,
should we define a new widget? What about gnome_file_entry? Should it
be fixed?
If it is fixed, what is proper procedure? Where should it be added?
What would be the ideal API so it does not affect current code?
This will affect many people, I am sure. And it is a feature that many
people will like, I am sure too.
static void file_open_ok_callback(GtkWidget *widget, gpointer data)
{
ggv_window *ggv = (ggv_window *)data;
gchar *file;
gchar *baseFileName;
char *ErrorMessage;
struct stat StatRecord;
file = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(ggv->file_sel)));
/* We have to verify that this file exists */
if (stat(file,&StatRecord) == 0) {
if (S_ISDIR(StatRecord.st_mode)) {
/* This is a directory, reset window and
try again */
if (strlen(file) > 0 && file[strlen(file)-1] != '/')
strcat(file,"/");
gtk_file_selection_set_filename(GTK_FILE_SELECTION(ggv->file_sel),
file);
return;
}
}
else {
/* We have to check if there is a wildcard in the directory name
*/
baseFileName = g_basename(file);
if (strchr(baseFileName, '?' ) != NULL ||
strchr(baseFileName, '*' ) != NULL) {
gtk_file_selection_complete(GTK_FILE_SELECTION(ggv->file_sel),
file);
}
/* FIXME: currently , if the file does not exist,
the window does not close, and it does not send a
message. it justs does nothing.
If we send a message (code below), the focus does
not return to the File window after the user clicks
on it
ErrorMessage = g_strdup_printf(_("File does not exist %s."), file);
error_message(ggv,ErrorMessage);
*/
return;
}
gtk_widget_destroy(ggv->file_sel);
ggv->file_sel = NULL;
ggv->loaded = load_gs(ggv, file);
g_free(file);
}
--
Daniel M. German "Language alone protects us from the scariness
of things with no names.
Toni Morrison -> Language alone is meditation. "
http://csgwww.uwaterloo.ca/~dmg/home.html
dmg@csg.uwaterloo.ca
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]