static void
action_connect_to_server_callback (GtkAction *action, 
				   gpointer user_data)
{
	NautilusWindow *window = NAUTILUS_WINDOW (user_data);
	NautilusWindowSlot *slot;
	GtkWidget *dialog;
	GFile *location;

	slot = nautilus_window_get_active_slot (window);
	location = nautilus_window_slot_get_location (slot);
	dialog = nautilus_connect_server_dialog_new (window, location);
	if (location) {
		g_object_unref (location);
	}

	gtk_widget_show (dialog);
}
예제 #2
0
static NautilusWindowSlot *
get_window_slot_for_location (NautilusApplication *application, GFile *location)
{
	NautilusWindowSlot *slot;
	GList *l, *sl;

	slot = NULL;

	if (g_file_query_file_type (location, G_FILE_QUERY_INFO_NONE, NULL) != G_FILE_TYPE_DIRECTORY) {
		location = g_file_get_parent (location);
	} else {
		g_object_ref (location);
	}

	for (l = gtk_application_get_windows (GTK_APPLICATION (application)); l; l = l->next) {
		NautilusWindow *win = NAUTILUS_WINDOW (l->data);

		if (NAUTILUS_IS_DESKTOP_WINDOW (win))
			continue;

		for (sl = nautilus_window_get_slots (win); sl; sl = sl->next) {
			NautilusWindowSlot *current = NAUTILUS_WINDOW_SLOT (sl->data);
			GFile *slot_location = nautilus_window_slot_get_location (current);

			if (g_file_equal (slot_location, location)) {
				slot = current;
				break;
			}
		}

		if (slot) {
			break;
		}
	}

	g_object_unref (location);

	return slot;
}
예제 #3
0
void
nautilus_notebook_sync_tab_label (NautilusNotebook *notebook,
				  NautilusWindowSlot *slot)
{
	GtkWidget *hbox, *label;
	char *location_name;
	GFile *location;
	const gchar *title_name;

	g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));
	g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));

	hbox = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), GTK_WIDGET (slot));
	g_return_if_fail (GTK_IS_WIDGET (hbox));

	label = GTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label"));
	g_return_if_fail (GTK_IS_WIDGET (label));

	gtk_label_set_text (GTK_LABEL (label), nautilus_window_slot_get_title (slot));
	location = nautilus_window_slot_get_location (slot);

	if (location != NULL) {
		/* Set the tooltip on the label's parent (the tab label hbox),
		 * so it covers all of the tab label.
		 */
		location_name = g_file_get_parse_name (location);
		title_name = nautilus_window_slot_get_title (slot);
		if (g_str_has_prefix (location_name, EEL_SEARCH_URI)) {
			gtk_widget_set_tooltip_text (gtk_widget_get_parent (label), title_name);
		} else {
			gtk_widget_set_tooltip_text (gtk_widget_get_parent (label), location_name);
		}
		g_free (location_name);
	} else {
		gtk_widget_set_tooltip_text (gtk_widget_get_parent (label), NULL);
	}
}
예제 #4
0
static void
slot_proxy_handle_drop (GtkWidget                *widget,
                        GdkDragContext           *context,
                        unsigned int              time,
                        NautilusDragSlotProxyInfo *drag_info)
{
    GtkWidget *window;
    NautilusWindowSlot *target_slot;
    NautilusFilesView *target_view;
    char *target_uri;
    GList *uri_list;
    GFile *location;

    if (!drag_info->have_data ||
            !drag_info->have_valid_data) {
        gtk_drag_finish (context, FALSE, FALSE, time);
        drag_info_clear (drag_info);
        return;
    }

    window = gtk_widget_get_toplevel (widget);
    g_assert (NAUTILUS_IS_WINDOW (window));

    if (drag_info->target_slot != NULL) {
        target_slot = drag_info->target_slot;
    } else {
        target_slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window));
    }

    target_uri = NULL;
    if (drag_info->target_file != NULL) {
        target_uri = nautilus_file_get_uri (drag_info->target_file);
    } else if (target_slot != NULL) {
        location = nautilus_window_slot_get_location (target_slot);
        target_uri = g_file_get_uri (location);
    }

    target_view = NULL;
    if (target_slot != NULL) {
        NautilusView *view;

        view = nautilus_window_slot_get_current_view (target_slot);

        if (view && NAUTILUS_IS_FILES_VIEW (view)) {
            target_view = NAUTILUS_FILES_VIEW (view);
        }
    }

    if (target_slot != NULL && target_view != NULL) {
        if (drag_info->info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
            uri_list = nautilus_drag_uri_list_from_selection_list (drag_info->data.selection_list);
            g_assert (uri_list != NULL);

            nautilus_files_view_drop_proxy_received_uris (target_view,
                    uri_list,
                    target_uri,
                    gdk_drag_context_get_selected_action (context));
            g_list_free_full (uri_list, g_free);
        } else if (drag_info->info == NAUTILUS_ICON_DND_URI_LIST) {
            nautilus_files_view_drop_proxy_received_uris (target_view,
                    drag_info->data.uri_list,
                    target_uri,
                    gdk_drag_context_get_selected_action (context));
        }
        if (drag_info->info == NAUTILUS_ICON_DND_NETSCAPE_URL) {
            nautilus_files_view_handle_netscape_url_drop (target_view,
                    drag_info->data.netscape_url,
                    target_uri,
                    gdk_drag_context_get_selected_action (context),
                    0, 0);
        }


        gtk_drag_finish (context, TRUE, FALSE, time);
    } else {
        gtk_drag_finish (context, FALSE, FALSE, time);
    }

    g_free (target_uri);

    drag_info_clear (drag_info);
}
예제 #5
0
static gboolean
slot_proxy_drag_motion (GtkWidget          *widget,
                        GdkDragContext     *context,
                        int                 x,
                        int                 y,
                        unsigned int        time,
                        gpointer            user_data)
{
    NautilusDragSlotProxyInfo *drag_info;
    NautilusWindowSlot *target_slot;
    GtkWidget *window;
    GdkAtom target;
    int action;
    char *target_uri;
    GFile *location;
    gboolean valid_text_drag;
    gboolean valid_xds_drag;

    drag_info = user_data;

    action = 0;
    valid_text_drag = FALSE;
    valid_xds_drag = FALSE;

    if (gtk_drag_get_source_widget (context) == widget) {
        goto out;
    }

    window = gtk_widget_get_toplevel (widget);
    g_assert (NAUTILUS_IS_WINDOW (window));

    if (!drag_info->have_data) {
        target = gtk_drag_dest_find_target (widget, context, NULL);

        if (target == GDK_NONE) {
            goto out;
        }

        gtk_drag_get_data (widget, context, target, time);
    }

    target_uri = NULL;
    if (drag_info->target_file != NULL) {
        target_uri = nautilus_file_get_uri (drag_info->target_file);
    } else {
        if (drag_info->target_slot != NULL) {
            target_slot = drag_info->target_slot;
        } else {
            target_slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window));
        }

        if (target_slot != NULL) {
            location = nautilus_window_slot_get_location (target_slot);
            target_uri = g_file_get_uri (location);
        }
    }

    if (target_uri != NULL) {
        NautilusFile *file;
        gboolean can;
        file = nautilus_file_get_existing_by_uri (target_uri);
        can = nautilus_file_can_write (file);
        g_object_unref (file);
        if (!can) {
            action = 0;
            goto out;
        }
    }

    if (drag_info->have_data &&
            drag_info->have_valid_data) {
        if (drag_info->info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
            nautilus_drag_default_drop_action_for_icons (context, target_uri,
                    drag_info->data.selection_list,
                    0,
                    &action);
        } else if (drag_info->info == NAUTILUS_ICON_DND_URI_LIST) {
            action = nautilus_drag_default_drop_action_for_uri_list (context, target_uri);
        } else if (drag_info->info == NAUTILUS_ICON_DND_NETSCAPE_URL) {
            action = nautilus_drag_default_drop_action_for_netscape_url (context);
        } else if (drag_info->info == NAUTILUS_ICON_DND_TEXT) {
            valid_text_drag = TRUE;
        } else if (drag_info->info == NAUTILUS_ICON_DND_XDNDDIRECTSAVE ||
                   drag_info->info == NAUTILUS_ICON_DND_RAW) {
            valid_xds_drag = TRUE;
        }
    }

    g_free (target_uri);

out:
    if (action != 0 || valid_text_drag || valid_xds_drag) {
        gtk_drag_highlight (widget);
        slot_proxy_check_switch_location_timer (drag_info, widget);
    } else {
        gtk_drag_unhighlight (widget);
        slot_proxy_remove_switch_location_timer (drag_info);
    }

    gdk_drag_status (context, action, time);

    return TRUE;
}