static void
nautilus_window_slot_active (NautilusWindowSlot *slot)
{
	NautilusWindow *window;

	g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));

	window = NAUTILUS_WINDOW (slot->window);
	g_assert (g_list_find (window->details->slots, slot) != NULL);
	g_assert (slot == window->details->active_slot);

	EEL_CALL_METHOD (NAUTILUS_WINDOW_SLOT_CLASS, slot,
			 active, (slot));
}
static void
action_go_to_templates_callback (GtkAction *action,
                                 gpointer user_data)
{
    char *path;
    GFile *location;

    path = nautilus_get_templates_directory ();
    location = g_file_new_for_path (path);
    g_free (path);
    nautilus_window_go_to (NAUTILUS_WINDOW (user_data),
                           location);
    g_object_unref (location);
}
Esempio n. 3
0
static void
action_nautilus_manual_callback (GtkAction *action, 
				 gpointer user_data)
{
	NautilusWindow *window;
	GError *error;
	GtkWidget *dialog;
	const char* helpuri;
	const char* name = gtk_action_get_name (action);

	error = NULL;
	window = NAUTILUS_WINDOW (user_data);

	if (g_str_equal (name, "NautilusHelpSearch")) {
		helpuri = "help:gnome-help/files-search";
	} else if (g_str_equal (name,"NautilusHelpSort")) {
		helpuri = "help:gnome-help/files-sort";
	} else if (g_str_equal (name, "NautilusHelpLost")) {
		helpuri = "help:gnome-help/files-lost";
	} else if (g_str_equal (name, "NautilusHelpShare")) {
		helpuri = "help:gnome-help/files-share";
	} else {
		helpuri = "help:gnome-help/files";
	}

	if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
		nautilus_launch_application_from_command (gtk_window_get_screen (GTK_WINDOW (window)), "gnome-help", FALSE, NULL);
	} else {
		gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (window)),
			      helpuri,
			      gtk_get_current_event_time (), &error);
	}

	if (error) {
		dialog = gtk_message_dialog_new (GTK_WINDOW (window),
						 GTK_DIALOG_MODAL,
						 GTK_MESSAGE_ERROR,
						 GTK_BUTTONS_OK,
						 _("There was an error displaying help: \n%s"),
						 error->message);
		g_signal_connect (G_OBJECT (dialog), "response",
				  G_CALLBACK (gtk_widget_destroy),
				  NULL);

		gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
		gtk_widget_show (dialog);
		g_error_free (error);
	}
}
static void
action_connect_to_server_callback (GtkAction *action,
                                   gpointer user_data)
{
    NautilusWindow *window = NAUTILUS_WINDOW (user_data);
    GtkWidget *dialog;
    GFile *location;
    location = nautilus_window_get_location (window);
    dialog = nautilus_connect_server_dialog_new (window, location);
    if (location) {
        g_object_unref (location);
    }

    gtk_widget_show (dialog);
}
gboolean
nautilus_navigation_window_is_in_temporary_search_bar (GtkWidget *widget,
			    NautilusNavigationWindow *window)
{
	GList *walk;
	gboolean is_in_any = FALSE;

	for (walk = NAUTILUS_WINDOW(window)->details->panes; walk; walk = walk->next) {
		NautilusNavigationWindowPane *pane = walk->data;
		if(gtk_widget_get_ancestor (widget, NAUTILUS_TYPE_SEARCH_BAR) != NULL &&
				       pane->temporary_search_bar)
			is_in_any = TRUE;
	}
	return is_in_any;
}
static void
always_use_location_entry_changed (gpointer callback_data)
{
	NautilusNavigationWindow *window;
	GList *walk;
	gboolean use_entry;

	window = NAUTILUS_NAVIGATION_WINDOW (callback_data);

	use_entry = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY);

	for (walk = NAUTILUS_WINDOW(window)->details->panes; walk; walk = walk->next) {
		nautilus_navigation_window_pane_always_use_location_entry (walk->data, use_entry);
	}
}
Esempio n. 7
0
static void
action_go_to_trash_callback (GtkAction *action, 
			     gpointer user_data) 
{
	NautilusWindow *window;
	NautilusWindowSlot *slot;
	GFile *trash;

	window = NAUTILUS_WINDOW (user_data);
	slot = nautilus_window_get_active_slot (window);

	trash = g_file_new_for_uri ("trash:///");
	nautilus_window_slot_open_location (slot, trash,
					    nautilus_event_get_window_open_flags ());
	g_object_unref (trash);
}
Esempio n. 8
0
static void
action_go_to_network_callback (GtkAction *action, 
				gpointer user_data) 
{
	NautilusWindow *window;
	NautilusWindowSlot *slot;
	GFile *network;

	window = NAUTILUS_WINDOW (user_data);
	slot = nautilus_window_get_active_slot (window);

	network = g_file_new_for_uri (NETWORK_URI);
	nautilus_window_slot_open_location (slot, network,
					    nautilus_event_get_window_open_flags ());
	g_object_unref (network);
}
/**
 * nautilus_window_initialize_menus
 * 
 * Create and install the set of menus for this window.
 * @window: A recently-created NautilusWindow.
 */
void 
nautilus_navigation_window_initialize_menus (NautilusNavigationWindow *window)
{
	GtkUIManager *ui_manager;
	const char *ui;

	ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window));

	ui = nautilus_ui_string_get ("nautilus-navigation-window-ui.xml");
	gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);

	nautilus_navigation_window_update_show_hide_menu_items (window);
	nautilus_navigation_window_update_spatial_menu_item (window);

        nautilus_navigation_window_initialize_go_menu (window);
}
static void
action_show_hidden_files_callback (GtkAction *action, 
				   gpointer callback_data)
{
	NautilusWindow *window;
	NautilusWindowShowHiddenFilesMode mode;

	window = NAUTILUS_WINDOW (callback_data);

	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
		mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_ENABLE;
	} else {
		mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DISABLE;
	}

	nautilus_window_info_set_hidden_files_mode (window, mode);
}
void
nautilus_navigation_window_remove_go_menu_items (NautilusNavigationWindow *window)
{
	GtkUIManager *ui_manager;
	
	ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window));
	if (window->details->go_menu_merge_id != 0) {
		gtk_ui_manager_remove_ui (ui_manager,
					  window->details->go_menu_merge_id);
		window->details->go_menu_merge_id = 0;
	}
	if (window->details->go_menu_action_group != NULL) {
		gtk_ui_manager_remove_action_group (ui_manager,
						    window->details->go_menu_action_group);
		window->details->go_menu_action_group = NULL;
	}
}
static void
side_panel_image_changed_callback (NautilusSidebar *side_panel,
                                   gpointer callback_data)
{
        NautilusWindow *window;
	GdkPixbuf *icon;

        window = NAUTILUS_WINDOW (callback_data);

	icon = nautilus_sidebar_get_tab_icon (side_panel);
        nautilus_side_pane_set_panel_image (NAUTILUS_NAVIGATION_WINDOW (window)->sidebar,
                                            GTK_WIDGET (side_panel),
                                            icon);
	if (icon != NULL) {
		g_object_unref (icon);
	}
}
void 
nautilus_navigation_window_show_search (NautilusNavigationWindow *window)
{
	NautilusNavigationWindowPane *pane;

	pane = NAUTILUS_NAVIGATION_WINDOW_PANE (NAUTILUS_WINDOW (window)->details->active_pane);
	if (!nautilus_navigation_window_pane_search_bar_showing (pane)) {
		remember_focus_widget (window);

		nautilus_navigation_window_pane_show_location_bar_temporarily (pane);
		nautilus_navigation_window_pane_set_bar_mode (pane, NAUTILUS_BAR_SEARCH);
		pane->temporary_search_bar = TRUE;
		nautilus_search_bar_clear (NAUTILUS_SEARCH_BAR (pane->search_bar));
	}

	nautilus_search_bar_grab_focus (NAUTILUS_SEARCH_BAR (pane->search_bar));
}
static void
action_go_to_computer_callback (GtkAction *action, 
				gpointer user_data) 
{
	NautilusWindow *window;
	NautilusWindowSlot *slot;
	GFile *computer;

	window = NAUTILUS_WINDOW (user_data);
	slot = nautilus_window_get_active_slot (window);

	computer = g_file_new_for_uri (COMPUTER_URI);
	nautilus_window_slot_go_to (slot,
				    computer,
				    should_open_in_new_tab ());
	g_object_unref (computer);
}
Esempio n. 15
0
/**
 * refresh_go_menu:
 * 
 * Refresh list of bookmarks at end of Go menu to match centralized history list.
 * @window: The NautilusWindow whose Go menu will be refreshed.
 **/
static void
nautilus_window_initialize_go_menu (NautilusWindow *window)
{
	GtkUIManager *ui_manager;
	GtkWidget *menuitem;
	int i;

	ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window));

	for (i = 0; i < G_N_ELEMENTS (icon_entries); i++) {
		menuitem = gtk_ui_manager_get_widget (
				ui_manager,
				icon_entries[i]);

		gtk_image_menu_item_set_always_show_image (
				GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
	}
}
static void
open_selected_bookmark (gpointer user_data, GdkScreen *screen)
{
	NautilusBookmark *selected;
	NautilusWindow *window;
	GFile *location;
	
	selected = get_selected_bookmark ();

	if (!selected) {
		return;
	}

	location = nautilus_bookmark_get_location (selected);
	if (location == NULL) { 
		return;
	}

	if (NAUTILUS_IS_NAVIGATION_WINDOW (user_data)) {
		nautilus_window_go_to (NAUTILUS_WINDOW (user_data), location);
	} else if (NAUTILUS_IS_SPATIAL_WINDOW (user_data)) {
		window = nautilus_application_present_spatial_window (application, 
								      NULL,
								      NULL,
								      location,
								      screen);
	} else { /* window that opened bookmarks window has been closed */
		if (parent_is_browser_window || eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
			window = nautilus_application_create_navigation_window (application, 
										NULL,
										screen);
			nautilus_window_go_to (window, location);
		} else {
			window = nautilus_application_present_spatial_window (application, 
									      NULL,
									      NULL,
									      location,
									      screen);
		}
	}

	g_object_unref (location);
}
static void
action_folder_window_callback (GtkAction *action,
			       gpointer user_data)
{
	NautilusWindow *current_window;
	GFile *current_location;

	current_window = NAUTILUS_WINDOW (user_data);
	current_location = nautilus_window_get_location (current_window);
	nautilus_application_present_spatial_window (
			current_window->application,
			current_window,
			NULL,
			current_location,
			gtk_window_get_screen (GTK_WINDOW (current_window)));
	if (current_location != NULL) {
		g_object_unref (current_location);
	}
}
Esempio n. 18
0
static void
switch_location (NautilusDragSlotProxyInfo *drag_info)
{
    GFile *location;
    GtkWidget *window;

    if (drag_info->target_file == NULL) {
        return;
    }

    window = gtk_widget_get_toplevel (drag_info->widget);
    g_assert (NAUTILUS_IS_WINDOW (window));

    location = nautilus_file_get_location (drag_info->target_file);
    nautilus_application_open_location_full (NAUTILUS_APPLICATION (g_application_get_default ()),
            location, NAUTILUS_WINDOW_OPEN_FLAG_DONT_MAKE_ACTIVE,
            NULL, NAUTILUS_WINDOW (window), NULL);
    g_object_unref (location);
}
Esempio n. 19
0
static void
action_go_to_templates_callback (GtkAction *action,
				 gpointer user_data) 
{
	NautilusWindow *window;
	NautilusWindowSlot *slot;
	char *path;
	GFile *location;

	window = NAUTILUS_WINDOW (user_data);
	slot = nautilus_window_get_active_slot (window);

	path = nautilus_get_templates_directory ();
	location = g_file_new_for_path (path);
	g_free (path);
	nautilus_window_slot_open_location (slot, location,
					    nautilus_event_get_window_open_flags ());
	g_object_unref (location);
}
static void
action_location_properties_callback (GtkAction *action,
                                     gpointer   user_data)
{
    NautilusWindowSlot *slot;
    GList              *files;
    NautilusView       *view;
    NautilusFile       *file;

    slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (user_data));
    view = nautilus_window_slot_get_current_view (slot);
    file = nautilus_view_get_directory_as_file (view);

    files = g_list_append (NULL, file);

    nautilus_properties_window_present (files, GTK_WIDGET (view), NULL);

    g_list_free (files);
}
Esempio n. 21
0
static void
on_connect_server_response (GtkDialog      *dialog,
			    int             response,
			    GtkApplication *application)
{
	if (response == GTK_RESPONSE_OK) {
		GFile *location;
		NautilusWindow *window = NAUTILUS_WINDOW (gtk_application_get_active_window (application));

		location = nautilus_connect_server_dialog_get_location (NAUTILUS_CONNECT_SERVER_DIALOG (dialog));
		if (location != NULL) {
			nautilus_window_slot_open_location_full (nautilus_window_get_active_slot (window),
								 location,
								 NAUTILUS_WINDOW_OPEN_FLAG_USE_DEFAULT_LOCATION,
								 NULL, go_to_server_cb, application);
		}
	}

	gtk_widget_destroy (GTK_WIDGET (dialog));
}
/**
 * nautilus_navigation_window_get_base_page_index:
 * @window:	Window to get index from
 *
 * Returns the index of the base page in the history list.
 * Base page is not the currently displayed page, but the page
 * that acts as the base from which the back and forward commands
 * navigate from.
 */
gint 
nautilus_navigation_window_get_base_page_index (NautilusNavigationWindow *window)
{
	NautilusNavigationWindowSlot *slot;
	gint forward_count;

	slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (NAUTILUS_WINDOW (window)->details->active_pane->active_slot);

	forward_count = g_list_length (slot->forward_list); 

	/* If forward is empty, the base it at the top of the list */
	if (forward_count == 0) {
		return 0;
	}

	/* The forward count indicate the relative postion of the base page
	 * in the history list
	 */ 
	return forward_count;
}
Esempio n. 23
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;
}
static void
show_hidden_files_preference_callback (gpointer callback_data)
{
	NautilusWindow *window;
	GtkAction *action;

	window = NAUTILUS_WINDOW (callback_data);

	if (window->details->show_hidden_files_mode == NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) {
		action = gtk_action_group_get_action (window->details->main_action_group, NAUTILUS_ACTION_SHOW_HIDDEN_FILES);
		g_assert (GTK_IS_ACTION (action));

		/* update button */
		g_signal_handlers_block_by_func (action, action_show_hidden_files_callback, window);
		gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
					      eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES));
		g_signal_handlers_unblock_by_func (action, action_show_hidden_files_callback, window);

		/* inform views */
		nautilus_window_info_set_hidden_files_mode (window, NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT);

	}
}
static void
action_nautilus_manual_callback (GtkAction *action, 
				 gpointer user_data)
{
	NautilusWindow *window;
	GError *error;
	GtkWidget *dialog;

	error = NULL;
	window = NAUTILUS_WINDOW (user_data);

	if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
		gdk_spawn_command_line_on_screen (
			gtk_window_get_screen (GTK_WINDOW (window)),
			"gnome-help", &error);
	} else {
		gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (window)),
			      "ghelp:user-guide#gosnautilus-1",
			      gtk_get_current_event_time (), &error);
	}

	if (error) {
		dialog = gtk_message_dialog_new (GTK_WINDOW (window),
						 GTK_DIALOG_MODAL,
						 GTK_MESSAGE_ERROR,
						 GTK_BUTTONS_OK,
						 _("There was an error displaying help: \n%s"),
						 error->message);
		g_signal_connect (G_OBJECT (dialog), "response",
				  G_CALLBACK (gtk_widget_destroy),
				  NULL);

		gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
		gtk_widget_show (dialog);
		g_error_free (error);
	}
}
static void
action_up_callback (GtkAction *action, 
		     gpointer user_data) 
{
	nautilus_window_go_up (NAUTILUS_WINDOW (user_data), FALSE, should_open_in_new_tab ());
}
static void
action_edit_bookmarks_callback (GtkAction *action, 
				gpointer user_data)
{
        nautilus_window_edit_bookmarks (NAUTILUS_WINDOW (user_data));
}
static void
action_zoom_normal_callback (GtkAction *action, 
			     gpointer user_data) 
{
	nautilus_window_zoom_to_default (NAUTILUS_WINDOW (user_data));
}
static void
action_zoom_out_callback (GtkAction *action, 
			  gpointer user_data) 
{
	nautilus_window_zoom_out (NAUTILUS_WINDOW (user_data));
}
static void
action_reload_callback (GtkAction *action, 
			gpointer user_data) 
{
	nautilus_window_reload (NAUTILUS_WINDOW (user_data));
}