Commit 2ca0b1dd authored by Mike Engber's avatar Mike Engber

* libnautilus-extensions/nautilus-icon-container.c:

	(icon_is_positioned), (pending_icon_to_reveal_destroy_callback),
	(get_pending_icon_to_reveal), (set_pending_icon_to_reveal),
	(reveal_icon), (process_pending_icon_to_reveal),
	(lay_down_icons_tblr), (relayout):
	* libnautilus-extensions/nautilus-icon-private.h:
	* src/file-manager/fm-directory-view.c: (start_renaming_item),
	(reveal_newly_added_folder), (new_folder_done),
	(fm_directory_view_new_folder), (fm_directory_view_set_selection),
	(fm_directory_view_select_file):
parent abbb0518
2000-10-19 Michael Engber <engber@eazel.com>
* libnautilus-extensions/nautilus-icon-container.c:
(icon_is_positioned), (pending_icon_to_reveal_destroy_callback),
(get_pending_icon_to_reveal), (set_pending_icon_to_reveal),
(reveal_icon), (process_pending_icon_to_reveal),
(lay_down_icons_tblr), (relayout):
* libnautilus-extensions/nautilus-icon-private.h:
* src/file-manager/fm-directory-view.c: (start_renaming_item),
(reveal_newly_added_folder), (new_folder_done),
(fm_directory_view_new_folder), (fm_directory_view_set_selection),
(fm_directory_view_select_file):
Newly added folders are now revealed (bug 2208). Other cases
(e.g. duplicate) still remain. They will require adding new hooks
to nautilus-file-operations.
2000-10-19 J Shane Culpepper <pepper@eazel.com>
* components/services/summary/nautilus-view/nautilus-summary-view.c
......
......@@ -175,6 +175,12 @@ icon_free (NautilusIcon *icon)
g_free (icon);
}
static gboolean
icon_is_positioned (const NautilusIcon *icon)
{
return icon->x != ICON_UNPOSITIONED_VALUE && icon->y != ICON_UNPOSITIONED_VALUE;
}
static void
icon_set_position (NautilusIcon *icon,
double x, double y)
......@@ -361,6 +367,44 @@ nautilus_icon_container_scroll (NautilusIconContainer *container,
return hadj->value != old_h_value || vadj->value != old_v_value;
}
static void
pending_icon_to_reveal_destroy_callback (NautilusIconCanvasItem *item, NautilusIconContainer *container)
{
g_assert (container->details->pending_icon_to_reveal != NULL);
g_assert (container->details->pending_icon_to_reveal->item == item);
container->details->pending_icon_to_reveal = NULL;
}
static NautilusIcon*
get_pending_icon_to_reveal (NautilusIconContainer *container)
{
return container->details->pending_icon_to_reveal;
}
static void
set_pending_icon_to_reveal (NautilusIconContainer *container, NautilusIcon *icon)
{
NautilusIcon *cur_pending;
cur_pending = container->details->pending_icon_to_reveal;
if (icon == cur_pending) {
return;
}
if (cur_pending != NULL) {
gtk_signal_disconnect_by_func (GTK_OBJECT (cur_pending->item),
&pending_icon_to_reveal_destroy_callback,
container);
}
if (icon != NULL) {
gtk_signal_connect (GTK_OBJECT (icon->item), "destroy", &pending_icon_to_reveal_destroy_callback, container);
}
container->details->pending_icon_to_reveal = icon;
}
static void
reveal_icon (NautilusIconContainer *container,
NautilusIcon *icon)
......@@ -370,6 +414,13 @@ reveal_icon (NautilusIconContainer *container,
GtkAdjustment *hadj, *vadj;
int x1, y1, x2, y2;
if (!icon_is_positioned (icon)) {
set_pending_icon_to_reveal (container, icon);
return;
}
set_pending_icon_to_reveal (container, NULL);
details = container->details;
allocation = &GTK_WIDGET (container)->allocation;
......@@ -391,6 +442,18 @@ reveal_icon (NautilusIconContainer *container,
}
}
static void
process_pending_icon_to_reveal (NautilusIconContainer *container)
{
NautilusIcon *pending_icon_to_reveal;
pending_icon_to_reveal = get_pending_icon_to_reveal (container);
if (pending_icon_to_reveal != NULL) {
reveal_icon (container, pending_icon_to_reveal);
}
}
static gboolean
keyboard_icon_reveal_timeout_callback (gpointer data)
{
......@@ -882,7 +945,7 @@ lay_down_icons_tblr (NautilusIconContainer *container, GList *icons)
/* Add only placed icons in list */
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
if (icon->x != ICON_UNPOSITIONED_VALUE && icon->y != ICON_UNPOSITIONED_VALUE) {
if (icon_is_positioned (icon)) {
placed_icons = g_list_append (placed_icons, icon);
} else {
icon->x = 0;
......@@ -1008,6 +1071,9 @@ relayout (NautilusIconContainer *container)
resort (container);
lay_down_icons (container, container->details->icons, 0);
}
process_pending_icon_to_reveal (container);
nautilus_icon_container_update_scroll_region (container);
}
......
......@@ -122,6 +122,11 @@ struct NautilusIconContainerDetails {
guint keyboard_icon_reveal_timer_id;
NautilusIcon *keyboard_icon_to_reveal;
/* If a request is made to reveal an unpositioned icon we remember
* it and reveal it once it gets positioned (in relayout).
*/
NautilusIcon *pending_icon_to_reveal;
/* Remembered information about the start of the current event. */
guint32 button_down_time;
......
......@@ -175,6 +175,12 @@ icon_free (NautilusIcon *icon)
g_free (icon);
}
static gboolean
icon_is_positioned (const NautilusIcon *icon)
{
return icon->x != ICON_UNPOSITIONED_VALUE && icon->y != ICON_UNPOSITIONED_VALUE;
}
static void
icon_set_position (NautilusIcon *icon,
double x, double y)
......@@ -361,6 +367,44 @@ nautilus_icon_container_scroll (NautilusIconContainer *container,
return hadj->value != old_h_value || vadj->value != old_v_value;
}
static void
pending_icon_to_reveal_destroy_callback (NautilusIconCanvasItem *item, NautilusIconContainer *container)
{
g_assert (container->details->pending_icon_to_reveal != NULL);
g_assert (container->details->pending_icon_to_reveal->item == item);
container->details->pending_icon_to_reveal = NULL;
}
static NautilusIcon*
get_pending_icon_to_reveal (NautilusIconContainer *container)
{
return container->details->pending_icon_to_reveal;
}
static void
set_pending_icon_to_reveal (NautilusIconContainer *container, NautilusIcon *icon)
{
NautilusIcon *cur_pending;
cur_pending = container->details->pending_icon_to_reveal;
if (icon == cur_pending) {
return;
}
if (cur_pending != NULL) {
gtk_signal_disconnect_by_func (GTK_OBJECT (cur_pending->item),
&pending_icon_to_reveal_destroy_callback,
container);
}
if (icon != NULL) {
gtk_signal_connect (GTK_OBJECT (icon->item), "destroy", &pending_icon_to_reveal_destroy_callback, container);
}
container->details->pending_icon_to_reveal = icon;
}
static void
reveal_icon (NautilusIconContainer *container,
NautilusIcon *icon)
......@@ -370,6 +414,13 @@ reveal_icon (NautilusIconContainer *container,
GtkAdjustment *hadj, *vadj;
int x1, y1, x2, y2;
if (!icon_is_positioned (icon)) {
set_pending_icon_to_reveal (container, icon);
return;
}
set_pending_icon_to_reveal (container, NULL);
details = container->details;
allocation = &GTK_WIDGET (container)->allocation;
......@@ -391,6 +442,18 @@ reveal_icon (NautilusIconContainer *container,
}
}
static void
process_pending_icon_to_reveal (NautilusIconContainer *container)
{
NautilusIcon *pending_icon_to_reveal;
pending_icon_to_reveal = get_pending_icon_to_reveal (container);
if (pending_icon_to_reveal != NULL) {
reveal_icon (container, pending_icon_to_reveal);
}
}
static gboolean
keyboard_icon_reveal_timeout_callback (gpointer data)
{
......@@ -882,7 +945,7 @@ lay_down_icons_tblr (NautilusIconContainer *container, GList *icons)
/* Add only placed icons in list */
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
if (icon->x != ICON_UNPOSITIONED_VALUE && icon->y != ICON_UNPOSITIONED_VALUE) {
if (icon_is_positioned (icon)) {
placed_icons = g_list_append (placed_icons, icon);
} else {
icon->x = 0;
......@@ -1008,6 +1071,9 @@ relayout (NautilusIconContainer *container)
resort (container);
lay_down_icons (container, container->details->icons, 0);
}
process_pending_icon_to_reveal (container);
nautilus_icon_container_update_scroll_region (container);
}
......
......@@ -122,6 +122,11 @@ struct NautilusIconContainerDetails {
guint keyboard_icon_reveal_timer_id;
NautilusIcon *keyboard_icon_to_reveal;
/* If a request is made to reveal an unpositioned icon we remember
* it and reveal it once it gets positioned (in relayout).
*/
NautilusIcon *pending_icon_to_reveal;
/* Remembered information about the start of the current event. */
guint32 button_down_time;
......
......@@ -215,6 +215,9 @@ static void metadata_ready_callback
static void fm_directory_view_trash_state_changed_callback (NautilusTrashMonitor *trash,
gboolean state,
gpointer callback_data);
static void fm_directory_view_select_file (FMDirectoryView *view,
NautilusFile *file);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (FMDirectoryView, fm_directory_view, GTK_TYPE_SCROLLED_WINDOW)
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, add_file)
......@@ -2365,18 +2368,11 @@ fm_directory_view_trash_or_delete_files (FMDirectoryView *view, GList *files)
static void
start_renaming_item (FMDirectoryView *view, const char *uri)
{
GList *selection;
NautilusFile *file;
selection = NULL;
file = nautilus_file_get (uri);
if (file == NULL) {
return;
if (file != NULL) {
fm_directory_view_select_file (view, file);
}
selection = g_list_prepend (NULL, file);
fm_directory_view_set_selection (view, selection);
nautilus_file_list_free (selection);
}
typedef struct {
......@@ -2402,17 +2398,33 @@ new_folder_rename_later (void *callback_data)
}
static void
new_folder_done (const char *new_folder_uri, gpointer data)
reveal_newly_added_folder (FMDirectoryView *view, NautilusFile *new_file, char* target_uri)
{
FMDirectoryView *directory_view;
RenameLaterParameters *parameters;
directory_view = (FMDirectoryView *)data;
parameters = g_new0 (RenameLaterParameters, 1);
if (nautilus_file_matches_uri (new_file, target_uri)) {
gtk_signal_disconnect_by_func (GTK_OBJECT (view), &reveal_newly_added_folder, target_uri);
fm_directory_view_select_file (view, new_file);
fm_directory_view_reveal_selection (view);
}
}
parameters->uri = g_strdup (new_folder_uri);
parameters->view = directory_view;
static void
new_folder_done (const char *new_folder_uri, FMDirectoryView *directory_view)
{
RenameLaterParameters *parameters;
/* We need to run after the default handler adds the folder we want to
* operate on. The ADD_FILE signal is registered as GTK_RUN_LAST, so we
* must use connect_after.
*/
gtk_signal_connect_full (GTK_OBJECT (directory_view),
"add_file",
&reveal_newly_added_folder,
NULL,
g_strdup (new_folder_uri),
g_free,
FALSE,
TRUE);
/* FIXME bugzilla.eazel.com 1260:
* runing the start_renaming_item with a delay because at this point
* it's not in the icon container's icon list.
......@@ -2421,7 +2433,19 @@ new_folder_done (const char *new_folder_uri, gpointer data)
* is arbitrary, if the machine is loaded up, it may not be enough.
* Need to add a mechanism here that ensures synchronously that the item
* is added to the icon container instead.
*
* You might think we can fix this by simply moving this call into
* the "add_file" signal handler, but you'd be wrong. When "add_file"
* is emitted the icon will have been added, but not placed. Reveal
* (in nautilus_icon-container.c) had to be modified to handle
* this case (all the pending_icon_to_reveal stuff). A similar change
* will have to be done for renaming. Then, this can be fixed by doing
* it at "add_file" time.
*/
parameters = g_new0 (RenameLaterParameters, 1);
parameters->uri = g_strdup (new_folder_uri);
parameters->view = directory_view;
gtk_timeout_add (100, new_folder_rename_later, parameters);
}
......@@ -2431,7 +2455,7 @@ fm_directory_view_new_folder (FMDirectoryView *directory_view)
char *parent_uri;
parent_uri = fm_directory_view_get_uri (directory_view);
nautilus_file_operations_new_folder (GTK_WIDGET(directory_view), parent_uri, new_folder_done, directory_view);
nautilus_file_operations_new_folder (GTK_WIDGET(directory_view), parent_uri, (void (*)(const char *, gpointer)) new_folder_done, directory_view);
g_free (parent_uri);
}
......@@ -3904,6 +3928,15 @@ fm_directory_view_set_selection (FMDirectoryView *view, GList *selection)
set_selection, (view, selection));
}
static void
fm_directory_view_select_file (FMDirectoryView *view, NautilusFile *file)
{
GList file_list;
file_list.data = file;
file_list.next = NULL;
fm_directory_view_set_selection (view, &file_list);
}
/**
* fm_directory_view_reveal_selection:
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment