]> Pileus Git - ~andy/gtk/commitdiff
Don't handle the event if we have no children.
authorJonathan Blandford <jrb@gnome.org>
Wed, 25 Aug 2004 19:10:38 +0000 (19:10 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Wed, 25 Aug 2004 19:10:38 +0000 (19:10 +0000)
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>

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooserdefault.c
gtk/gtktreeview.c

index 3c437a2b5973ccd4cfb84003d4203b2e256b61dd..efeefa73fd18df802a230652d763a9ea40c60792 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+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>
+
 2004-08-25  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkfilechooserdefault.c (check_is_folder): Use get_file_info() rather 
index 3c437a2b5973ccd4cfb84003d4203b2e256b61dd..efeefa73fd18df802a230652d763a9ea40c60792 100644 (file)
@@ -1,3 +1,20 @@
+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>
+
 2004-08-25  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkfilechooserdefault.c (check_is_folder): Use get_file_info() rather 
index 3c437a2b5973ccd4cfb84003d4203b2e256b61dd..efeefa73fd18df802a230652d763a9ea40c60792 100644 (file)
@@ -1,3 +1,20 @@
+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>
+
 2004-08-25  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkfilechooserdefault.c (check_is_folder): Use get_file_info() rather 
index 3c437a2b5973ccd4cfb84003d4203b2e256b61dd..efeefa73fd18df802a230652d763a9ea40c60792 100644 (file)
@@ -1,3 +1,20 @@
+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>
+
 2004-08-25  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkfilechooserdefault.c (check_is_folder): Use get_file_info() rather 
index 2163a7a8322ad239d1e0d05d87195e4e91263f95..7f84e5feb2d3914218ef6e0bb4253ac541c6f697 100644 (file)
@@ -72,6 +72,7 @@
 #include "gtkfilesystemwin32.h"
 #endif
 
+#include <errno.h>
 #include <string.h>
 #include <time.h>
 
@@ -542,6 +543,11 @@ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
                                "location-popup",
                                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",
@@ -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 ();
 
index de8634cc41813e5f39aa1323a84ccd140ca927a9..7dec98261acbda637dfd7f0a1d04d1f1339539d6 100644 (file)
@@ -8716,9 +8716,10 @@ gtk_tree_view_real_expand_collapse_cursor_row (GtkTreeView *tree_view,
 
   if (_gtk_tree_view_find_node (tree_view, cursor_path, &tree, &node))
     return FALSE;
-  
-  gtk_widget_grab_focus (GTK_WIDGET (tree_view));
-  gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL);
+
+  /* Don't handle the event if we aren't an expander */
+  if (!((node->flags & GTK_RBNODE_IS_PARENT) == GTK_RBNODE_IS_PARENT))
+    return FALSE;
 
   if (!logical
       && gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL)