Example #1
0
static void
sync_search_directory (NemoWindowSlot *slot)
{
	NemoDirectory *directory;
	NemoQuery *query;

	g_assert (NEMO_IS_FILE (slot->viewed_file));

	directory = nemo_directory_get_for_file (slot->viewed_file);
	g_assert (NEMO_IS_SEARCH_DIRECTORY (directory));

	query = nemo_query_editor_get_query (slot->query_editor);
	nemo_search_directory_set_query (NEMO_SEARCH_DIRECTORY (directory),
					     query);
	g_object_unref (query);
	nemo_window_slot_reload (slot);

	nemo_directory_unref (directory);
}
Example #2
0
static void
action_show_hide_search_callback (GtkAction *action,
				  gpointer user_data)
{
	NemoWindowPane *pane = user_data;
	NemoWindow *window = pane->window;

	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
		nemo_window_pane_ensure_search_bar (pane);
	} else {
		NemoWindowSlot *slot;
		GFile *location = NULL;

		slot = pane->active_slot;
		nemo_window_pane_hide_search_bar (pane);

		/* Use the location bar as the return location */
		if (slot->query_editor != NULL) {
			NemoQuery *query;
			char *uri;

			query = nemo_query_editor_get_query (slot->query_editor);
			if (query != NULL) {
				uri = nemo_query_get_location (query);
				if (uri != NULL) {
					location = g_file_new_for_uri (uri);
					g_free (uri);
				}
				g_object_unref (query);
			}

			/* Last try: use the home directory as the return location */
			if (location == NULL) {
				location = g_file_new_for_path (g_get_home_dir ());
			}

			nemo_window_go_to (window, location);
			g_object_unref (location);
		}
	}
}