gtk_file_selection patch: Home directory button
- From: Lars Clausen <lrclause cs uiuc edu>
- To: gtk-devel-list gnome org
- Subject: gtk_file_selection patch: Home directory button
- Date: 14 Sep 2000 15:32:24 -0500
Hi!
We're a couple people in SigUnix at UIUC (http://www.acm.uiuc.edu/sigunix)
that are looking at improving the default GTK file selection dialog. Not
trying to come up with a new API or a new look, for we feel that the basic
dialog is ok. Below is the first patch: Adding a 'Home' button at the
top. We're aware that you can do ~/-expansion, but that's not intuitive at
all -- I didn't even know it until I looked at the code.
Next we're planning to avoid the filename disappearing when you move around
directories, and then add some 'recent files' to the history menu.
-Lars
--
Lars Clausen (http://shasta.cs.uiuc.edu/~lrclause) | Hårdgrim of Numenor
"I do not agree with a word that you say, but I | Retainer of Sir Kegg
will defend to the death your right to say it." | of Westfield
--Evelyn Beatrice Hall paraphrasing Voltaire | Chaos Berserker of Khorne
===File ~/gtk_file_sel_home.diff============================
diff -rubB gtk+-1.2.6-old/gtk/gtkfilesel.c gtk+-1.2.6/gtk/gtkfilesel.c
--- gtk+-1.2.6-old/gtk/gtkfilesel.c Thu Oct 7 12:26:25 1999
+++ gtk+-1.2.6/gtk/gtkfilesel.c Wed Sep 13 21:44:13 2000
@@ -322,6 +322,7 @@
static void gtk_file_selection_create_dir (GtkWidget *widget, gpointer data);
static void gtk_file_selection_delete_file (GtkWidget *widget, gpointer data);
static void gtk_file_selection_rename_file (GtkWidget *widget, gpointer data);
+static void gtk_file_selection_home (GtkWidget *widget, gpointer data);
@@ -567,6 +568,17 @@
gtk_widget_show (filesel->fileop_ren_file);
}
+ if (!filesel->fileop_home)
+ {
+ filesel->fileop_home = gtk_button_new_with_label (_("Home"));
+ gtk_signal_connect (GTK_OBJECT (filesel->fileop_home), "clicked",
+ (GtkSignalFunc) gtk_file_selection_home,
+ (gpointer) filesel);
+ gtk_box_pack_start (GTK_BOX (filesel->button_area),
+ filesel->fileop_home, TRUE, TRUE, 0);
+ gtk_widget_show (filesel->fileop_home);
+ }
+
gtk_widget_queue_resize(GTK_WIDGET(filesel));
}
@@ -576,6 +588,11 @@
g_return_if_fail (filesel != NULL);
g_return_if_fail (GTK_IS_FILE_SELECTION (filesel));
+ if (filesel->fileop_home)
+ {
+ gtk_widget_destroy (filesel->fileop_home);
+ filesel->fileop_home = NULL;
+ }
if (filesel->fileop_ren_file)
{
gtk_widget_destroy (filesel->fileop_ren_file);
@@ -1081,6 +1099,28 @@
gtk_widget_show (dialog);
}
+
+static void
+gtk_file_selection_home (GtkWidget *widget, gpointer data)
+{
+ GtkFileSelection *fs = data;
+ char *home_dir = getenv("HOME");
+
+ g_return_if_fail (fs != NULL);
+ g_return_if_fail (GTK_IS_FILE_SELECTION (fs));
+
+ if (home_dir == NULL) {
+ /* Pop up error dialog */
+ gtk_file_selection_fileop_error (fs, "No home directory found.");
+ return;
+ }
+
+ home_dir = g_strconcat(home_dir, "/", NULL);
+
+ gtk_file_selection_populate (fs, home_dir, FALSE);
+
+ g_free(home_dir); /* Does gtk_file_selection_populate keep it? */
+}
static gint
gtk_file_selection_key_press (GtkWidget *widget,
diff -rubB gtk+-1.2.6-old/gtk/gtkfilesel.h gtk+-1.2.6/gtk/gtkfilesel.h
--- gtk+-1.2.6-old/gtk/gtkfilesel.h Wed Feb 24 04:15:08 1999
+++ gtk+-1.2.6/gtk/gtkfilesel.h Wed Sep 13 21:12:53 2000
@@ -74,6 +74,7 @@
GtkWidget *button_area;
GtkWidget *action_area;
+ GtkWidget *fileop_home;
};
struct _GtkFileSelectionClass
============================================================
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]