fixed bug 620, when multiple files are selected, they all should be

fixed bug 620, when multiple files are selected, they all should be
	activated when any are clicked.  Accomplished this by making the
	activate signal take a list, and adding code to maintain the list, which
	was a bit tricky to get double-clicks right.
This commit is contained in:
Andy Hertzfeld 2000-05-13 08:38:00 +00:00
parent dd77489e7f
commit c4363bd96b
6 changed files with 149 additions and 47 deletions

View file

@ -1,8 +1,26 @@
2000-05-13 Andy Hertzfeld <set EMAIL_ADDRESS environment variable>
2000-05-12 Andy Hertzfeld <andy@eazel.com>
fixed bug 620, when multiple files are selected, they all should be opened when the
user single or double click.
* libnautilus-extensions/nautilus-icon-private.h:
added last_selected_files field to icon_container details, so the selection can be
remembered through the double click process
* libnautilus-extensions/nautilus-icon-container.c: (destroy),
(forget_selected_files), (remember_selected_files),
(nautilus_icon_container_almost_drag), (handle_icon_button_press),
(activate_selected_items):
changed the activate signal to take a list of file objects instead of a single one;
added routines remember_selected_files and forget_selected_files to build and release the list;
called remember and forget when appropriate, and used the list to pass to the signal.
* src/file-manager/fm-icon-view.c (icon_container_activate_callback):
made the signal handler activate all the files in the list
2000-05-12 Andy Hertzfeld <andy@eazel.com>
* src/file-manager/fm-directory-view.c:
(notify_selection_change_callback), (display_pending_files):
some of Darin's recent changes wouldn't compile, so I fixed it
some of Darin's recent changes wouldn't compile, so I fixed them
2000-05-12 Eskil Heyn Olsen <eskil@eazel.om>

View file

@ -93,6 +93,9 @@ static void hide_rename_widget (NautilusIconConta
NautilusIcon *icon);
static void click_policy_changed_callback (gpointer user_data);
static void remember_selected_files (NautilusIconContainer *container);
static void forget_selected_files (NautilusIconContainer *container);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconContainer, nautilus_icon_container, GNOME_TYPE_CANVAS)
@ -1598,6 +1601,7 @@ destroy (GtkObject *object)
int i;
container = NAUTILUS_ICON_CONTAINER (object);
forget_selected_files(container);
nautilus_icon_dnd_fini (container);
nautilus_icon_container_clear (container);
@ -1625,6 +1629,7 @@ destroy (GtkObject *object)
container);
nautilus_icon_container_flush_typeselect_state (container);
g_free (container->details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
@ -1762,14 +1767,47 @@ button_press_event (GtkWidget *widget,
return return_value;
}
/* deallocate the list of selected files */
static void
forget_selected_files (NautilusIconContainer *container)
{
if (container->details->last_selected_files) {
g_list_free(container->details->last_selected_files);
container->details->last_selected_files = NULL;
}
}
/* remember the selected files in a list for later access */
static void
remember_selected_files (NautilusIconContainer *container)
{
NautilusIcon *icon;
GList *p;
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
forget_selected_files(container);
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
if (icon->is_selected) {
container->details->last_selected_files = g_list_prepend
(container->details->last_selected_files, icon->data);
}
}
}
static void
nautilus_icon_container_almost_drag (NautilusIconContainer *container,
GdkEventButton *event)
{
NautilusIconContainerDetails *details;
details = container->details;
/* build list of selected icons before we blow away the selection */
if (event->type != GDK_2BUTTON_PRESS)
remember_selected_files(container);
if (!button_event_modifies_selection (event)) {
gboolean selection_changed;
@ -1791,12 +1829,10 @@ nautilus_icon_container_almost_drag (NautilusIconContainer *container,
&& event->time - details->button_down_time < MAX_CLICK_TIME
&& ! button_event_modifies_selection (event)) {
/* FIXME bugzilla.eazel.com 620: This should activate all
* selected icons, not just one.
*/
gtk_signal_emit (GTK_OBJECT (container),
signals[ACTIVATE],
details->drag_icon->data);
container->details->last_selected_files);
forget_selected_files(container);
}
}
}
@ -2454,7 +2490,7 @@ handle_icon_button_press (NautilusIconContainer *container,
GdkEventButton *event)
{
NautilusIconContainerDetails *details;
if (event->button != DRAG_BUTTON
&& event->button != CONTEXTUAL_MENU_BUTTON) {
return TRUE;
@ -2479,7 +2515,11 @@ handle_icon_button_press (NautilusIconContainer *container,
}
}
}
/* build list of selected icons before we blow away the selection */
if ((event->type != GDK_2BUTTON_PRESS) && button_event_modifies_selection (event))
remember_selected_files(container);
/* Modify the selection as appropriate. Selection is modified
* the same way for contextual menu as it would be without.
*/
@ -2511,18 +2551,15 @@ handle_icon_button_press (NautilusIconContainer *container,
gtk_signal_emit (GTK_OBJECT (container),
signals[CONTEXT_CLICK_SELECTION]);
return TRUE;
} else if (event->type == GDK_2BUTTON_PRESS) {
/* Double clicking does not trigger a D&D action. */
details->drag_button = 0;
details->drag_icon = NULL;
/* FIXME bugzilla.eazel.com 620:
* This should activate all selected icons, not just one
*/
gtk_signal_emit (GTK_OBJECT (container),
signals[ACTIVATE],
icon->data);
container->details->last_selected_files);
forget_selected_files(container);
}
return TRUE;
@ -2636,22 +2673,21 @@ icon_destroy (NautilusIconContainer *container,
}
}
/* activate any selected items in the container */
static void
activate_selected_items (NautilusIconContainer *container)
{
NautilusIcon *icon;
GList *p;
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
if (icon->is_selected) {
gtk_signal_emit (GTK_OBJECT (container),
signals[ACTIVATE],
icon->data);
}
remember_selected_files(container);
if (container->details->last_selected_files != NULL) {
gtk_signal_emit (GTK_OBJECT (container),
signals[ACTIVATE],
container->details->last_selected_files);
forget_selected_files(container);
}
}

View file

@ -129,6 +129,9 @@ struct NautilusIconContainerDetails {
/* Remembered information about the start of the current event. */
guint32 button_down_time;
/* list of selected files remembered between clicks so double-click can activate the entire selection */
GList* last_selected_files;
/* Drag state. Valid only if drag_button is non-zero. */
guint drag_button;
NautilusIcon *drag_icon;

View file

@ -93,6 +93,9 @@ static void hide_rename_widget (NautilusIconConta
NautilusIcon *icon);
static void click_policy_changed_callback (gpointer user_data);
static void remember_selected_files (NautilusIconContainer *container);
static void forget_selected_files (NautilusIconContainer *container);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconContainer, nautilus_icon_container, GNOME_TYPE_CANVAS)
@ -1598,6 +1601,7 @@ destroy (GtkObject *object)
int i;
container = NAUTILUS_ICON_CONTAINER (object);
forget_selected_files(container);
nautilus_icon_dnd_fini (container);
nautilus_icon_container_clear (container);
@ -1625,6 +1629,7 @@ destroy (GtkObject *object)
container);
nautilus_icon_container_flush_typeselect_state (container);
g_free (container->details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
@ -1762,14 +1767,47 @@ button_press_event (GtkWidget *widget,
return return_value;
}
/* deallocate the list of selected files */
static void
forget_selected_files (NautilusIconContainer *container)
{
if (container->details->last_selected_files) {
g_list_free(container->details->last_selected_files);
container->details->last_selected_files = NULL;
}
}
/* remember the selected files in a list for later access */
static void
remember_selected_files (NautilusIconContainer *container)
{
NautilusIcon *icon;
GList *p;
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
forget_selected_files(container);
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
if (icon->is_selected) {
container->details->last_selected_files = g_list_prepend
(container->details->last_selected_files, icon->data);
}
}
}
static void
nautilus_icon_container_almost_drag (NautilusIconContainer *container,
GdkEventButton *event)
{
NautilusIconContainerDetails *details;
details = container->details;
/* build list of selected icons before we blow away the selection */
if (event->type != GDK_2BUTTON_PRESS)
remember_selected_files(container);
if (!button_event_modifies_selection (event)) {
gboolean selection_changed;
@ -1791,12 +1829,10 @@ nautilus_icon_container_almost_drag (NautilusIconContainer *container,
&& event->time - details->button_down_time < MAX_CLICK_TIME
&& ! button_event_modifies_selection (event)) {
/* FIXME bugzilla.eazel.com 620: This should activate all
* selected icons, not just one.
*/
gtk_signal_emit (GTK_OBJECT (container),
signals[ACTIVATE],
details->drag_icon->data);
container->details->last_selected_files);
forget_selected_files(container);
}
}
}
@ -2454,7 +2490,7 @@ handle_icon_button_press (NautilusIconContainer *container,
GdkEventButton *event)
{
NautilusIconContainerDetails *details;
if (event->button != DRAG_BUTTON
&& event->button != CONTEXTUAL_MENU_BUTTON) {
return TRUE;
@ -2479,7 +2515,11 @@ handle_icon_button_press (NautilusIconContainer *container,
}
}
}
/* build list of selected icons before we blow away the selection */
if ((event->type != GDK_2BUTTON_PRESS) && button_event_modifies_selection (event))
remember_selected_files(container);
/* Modify the selection as appropriate. Selection is modified
* the same way for contextual menu as it would be without.
*/
@ -2511,18 +2551,15 @@ handle_icon_button_press (NautilusIconContainer *container,
gtk_signal_emit (GTK_OBJECT (container),
signals[CONTEXT_CLICK_SELECTION]);
return TRUE;
} else if (event->type == GDK_2BUTTON_PRESS) {
/* Double clicking does not trigger a D&D action. */
details->drag_button = 0;
details->drag_icon = NULL;
/* FIXME bugzilla.eazel.com 620:
* This should activate all selected icons, not just one
*/
gtk_signal_emit (GTK_OBJECT (container),
signals[ACTIVATE],
icon->data);
container->details->last_selected_files);
forget_selected_files(container);
}
return TRUE;
@ -2636,22 +2673,21 @@ icon_destroy (NautilusIconContainer *container,
}
}
/* activate any selected items in the container */
static void
activate_selected_items (NautilusIconContainer *container)
{
NautilusIcon *icon;
GList *p;
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
if (icon->is_selected) {
gtk_signal_emit (GTK_OBJECT (container),
signals[ACTIVATE],
icon->data);
}
remember_selected_files(container);
if (container->details->last_selected_files != NULL) {
gtk_signal_emit (GTK_OBJECT (container),
signals[ACTIVATE],
container->details->last_selected_files);
forget_selected_files(container);
}
}

View file

@ -129,6 +129,9 @@ struct NautilusIconContainerDetails {
/* Remembered information about the start of the current event. */
guint32 button_down_time;
/* list of selected files remembered between clicks so double-click can activate the entire selection */
GList* last_selected_files;
/* Drag state. Valid only if drag_button is non-zero. */
guint drag_button;
NautilusIcon *drag_icon;

View file

@ -955,16 +955,22 @@ fm_icon_view_set_selection (FMDirectoryView *view, GList *selection)
nautilus_icon_container_set_selection (icon_container, selection);
}
/* activate the passed-in list of files. Open the first one potentially in the original window,
and subsequent ones in new windows */
static void
icon_container_activate_callback (NautilusIconContainer *container,
NautilusFile *file,
GList *file_list,
FMIconView *icon_view)
{
int count;
GList *p;
g_assert (FM_IS_ICON_VIEW (icon_view));
g_assert (container == get_icon_container (icon_view));
g_assert (NAUTILUS_IS_FILE (file));
fm_directory_view_activate_file (FM_DIRECTORY_VIEW (icon_view), file, FALSE);
count = 0;
for (p = file_list; p != NULL; p = p->next) {
fm_directory_view_activate_file (FM_DIRECTORY_VIEW (icon_view), p->data, count++ > 0);
}
}
static int