summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechooserdefault.c
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@gnome.org>2004-08-25 19:10:38 +0000
committerJonathan Blandford <jrb@src.gnome.org>2004-08-25 19:10:38 +0000
commit8bc41273f609db8f603a0659fbc56014956c8b79 (patch)
tree93af19a44bbf6d1c143bf7b9e2716c6146d4144b /gtk/gtkfilechooserdefault.c
parent8a833f775063c69f47825bd30897213a27a9abea (diff)
downloadgtk+-8bc41273f609db8f603a0659fbc56014956c8b79.tar.gz
Don't handle the event if we have no children.
Tue Aug 24 02:06:37 2004 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreeview.c (gtk_tree_view_real_expand_collapse_cursor_row): Don't handle the event if we have no children. * gtk/gtkfilechooserdefault.c (trap_activate_cb): (tree_view_keybinding_cb):Since GtkTreeView has a keybinding attached to '/', we need to catch keypresses before the TreeView gets them. (gtk_file_chooser_default_class_init): add '/' to be a keybinding to the C-l dialog. (location_entry_create): Clear the text to "" when loading a file. This has a much better feel than putting the currently selected in. * #include <errno.h>
Diffstat (limited to 'gtk/gtkfilechooserdefault.c')
-rw-r--r--gtk/gtkfilechooserdefault.c84
1 files changed, 40 insertions, 44 deletions
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 2163a7a832..7f84e5feb2 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -72,6 +72,7 @@
#include "gtkfilesystemwin32.h"
#endif
+#include <errno.h>
#include <string.h>
#include <time.h>
@@ -543,6 +544,11 @@ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
0);
gtk_binding_entry_add_signal (binding_set,
+ GDK_slash, 0,
+ "location-popup",
+ 0);
+
+ gtk_binding_entry_add_signal (binding_set,
GDK_Up, GDK_MOD1_MASK,
"up-folder",
0);
@@ -2603,6 +2609,25 @@ shortcuts_row_separator_func (GtkTreeModel *model,
return FALSE;
}
+/* Since GtkTreeView has a keybinding attached to '/', we need to catch
+ * keypresses before the TreeView gets them.
+ */
+static gboolean
+tree_view_keybinding_cb (GtkWidget *tree_view,
+ GdkEventKey *event,
+ GtkFileChooserDefault *impl)
+{
+ if (event->keyval == GDK_slash &&
+ ! (event->state & gtk_accelerator_get_default_mod_mask ()))
+ {
+ location_popup_handler (impl);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
/* Creates the widgets for the shortcuts and bookmarks tree */
static GtkWidget *
shortcuts_list_create (GtkFileChooserDefault *impl)
@@ -2624,6 +2649,9 @@ shortcuts_list_create (GtkFileChooserDefault *impl)
/* Tree */
impl->browse_shortcuts_tree_view = gtk_tree_view_new ();
+ g_signal_connect (impl->browse_shortcuts_tree_view,
+ "key-press-event", tree_view_keybinding_cb,
+ impl);
atk_object_set_name (gtk_widget_get_accessible (impl->browse_shortcuts_tree_view), _("Shortcuts"));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), FALSE);
@@ -2751,7 +2779,8 @@ shortcuts_pane_create (GtkFileChooserDefault *impl,
}
/* Handles key press events on the file list, so that we can trap Enter to
- * activate the default button on our own.
+ * activate the default button on our own. Also, checks to see if '/' has been
+ * pressed. See comment by tree_view_keybinding_cb() for more details.
*/
static gboolean
trap_activate_cb (GtkWidget *widget,
@@ -2761,6 +2790,13 @@ trap_activate_cb (GtkWidget *widget,
GtkFileChooserDefault *impl;
impl = (GtkFileChooserDefault *) data;
+
+ if (event->keyval == GDK_slash &&
+ ! (event->state & gtk_accelerator_get_default_mod_mask ()))
+ {
+ location_popup_handler (impl);
+ return TRUE;
+ }
if (event->keyval == GDK_Return
|| event->keyval == GDK_ISO_Enter
@@ -5454,47 +5490,6 @@ _gtk_file_chooser_default_new (const char *file_system)
NULL);
}
-/* Sets the file part of a file chooser entry from the file under the cursor */
-static void
-location_entry_set_from_list (GtkFileChooserDefault *impl,
- GtkFileChooserEntry *entry)
-{
- GtkTreePath *tree_path;
- GtkTreeIter iter, child_iter;
- const GtkFileInfo *info;
- const char *name;
-
- g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
- || impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
-
- gtk_tree_view_get_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), &tree_path, NULL);
- if (!tree_path)
- return;
-
- gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->sort_model), &iter, tree_path);
- gtk_tree_path_free (tree_path);
-
- gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, &iter);
-
- info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
- if (!info)
- return;
-
- name = gtk_file_info_get_display_name (info);
- _gtk_file_chooser_entry_set_file_part (entry, name);
-}
-
-/* Sets the file part of a file chooser entry from the Name entry in save mode */
-static void
-location_entry_set_from_save_name (GtkFileChooserDefault *impl,
- GtkFileChooserEntry *entry)
-{
- g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
- || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
-
- _gtk_file_chooser_entry_set_file_part (entry, gtk_entry_get_text (GTK_ENTRY (impl->save_file_name_entry)));
-}
-
static GtkWidget *
location_entry_create (GtkFileChooserDefault *impl)
{
@@ -5509,10 +5504,11 @@ location_entry_create (GtkFileChooserDefault *impl)
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
|| impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
- location_entry_set_from_list (impl, GTK_FILE_CHOOSER_ENTRY (entry));
+ _gtk_file_chooser_entry_set_file_part (entry, "");
else if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
- location_entry_set_from_save_name (impl, GTK_FILE_CHOOSER_ENTRY (entry));
+ _gtk_file_chooser_entry_set_file_part (entry,
+ gtk_entry_get_text (GTK_ENTRY (impl->save_file_name_entry)));
else
g_assert_not_reached ();