Beispiel #1
0
static void
trash_bar_response_cb (GtkInfoBar *infobar,
		       gint response_id,
		       gpointer user_data)
{
	NemoTrashBar *bar;
	GtkWidget *window;
	GList *files;

	bar = NEMO_TRASH_BAR (infobar);
	window = gtk_widget_get_toplevel (GTK_WIDGET (bar));

	switch (response_id) {
	case TRASH_BAR_RESPONSE_EMPTY:
		nemo_file_operations_empty_trash (window);
		break;
	case TRASH_BAR_RESPONSE_RESTORE:
		files = nemo_view_get_selection (bar->priv->view);
		nemo_restore_files_from_trash (files, GTK_WINDOW (window));
		nemo_file_list_free (files);
		break;
	default:
		break;
	}
}
static void
fm_tree_model_finalize (GObject *object)
{
	FMTreeModel *model;
	TreeNode *root_node, *next_root;
	FMTreeModelRoot *root;

	model = FM_TREE_MODEL (object);

	for (root_node = model->details->root_node; root_node != NULL; root_node = next_root) {
		next_root = root_node->next;
		root = root_node->root;
		destroy_node_without_reporting (model, root_node);
		g_hash_table_destroy (root->file_to_node_map);
		g_free (root);
	}

	if (model->details->monitoring_update_idle_id != 0) {
		g_source_remove (model->details->monitoring_update_idle_id);
	}

	if (model->details->highlighted_files != NULL) {
		nemo_file_list_free (model->details->highlighted_files);
	}

	g_free (model->details);

	G_OBJECT_CLASS (fm_tree_model_parent_class)->finalize (object);
}
Beispiel #3
0
void
nemo_action_activate (NemoAction *action, GList *selection, NemoFile *parent)
{
    GList *l;
    GString *exec = g_string_new (action->exec);

    gchar *ptr;
    TokenType token_type;

    ptr = find_token_type (exec->str, &token_type);

    while (ptr != NULL) {
        gint shift = ptr - exec->str;

        gchar *insertion = get_insertion_string (token_type, selection, parent);
        exec = g_string_erase (exec, shift, 2);
        exec = g_string_insert (exec, shift, insertion);

        token_type = TOKEN_NONE;
        g_free  (insertion);
        ptr = find_token_type (exec->str, &token_type);
    }

    if (action->use_parent_dir) {
        exec = g_string_prepend (exec, G_DIR_SEPARATOR_S);
        exec = g_string_prepend (exec, action->parent_dir);
    }

    DEBUG ("Spawning: %s\n", exec->str);
    g_spawn_command_line_async (exec->str, NULL);

    nemo_file_list_free (selection);
    g_string_free (exec, TRUE);
}
Beispiel #4
0
static void
set_up_actions (NemoActionManager *action_manager)
{
    GList *dir, *file_list, *node;
    NemoFile *file;
    NemoDirectory *directory;

    if (g_list_length (action_manager->actions) > 0)
        void_action_list (action_manager);

    for (dir = action_manager->actions_directory_list; dir != NULL; dir = dir->next) {
        directory = dir->data;
        file_list = nemo_directory_get_file_list (directory);
        for (node = file_list; node != NULL; node = node->next) {
            file = node->data;
            if (!g_str_has_suffix (nemo_file_peek_name (file), ".nemo_action") ||
                !nemo_global_preferences_should_load_plugin (nemo_file_peek_name (file), NEMO_PLUGIN_PREFERENCES_DISABLED_ACTIONS))
                continue;
            add_action_to_action_list (action_manager, file);
        }
        nemo_file_list_free (file_list);
    }

    action_manager->action_list_dirty = FALSE;

    g_signal_emit (action_manager, signals[CHANGED], 0);
}
Beispiel #5
0
void
nemo_application_open_location (NemoApplication *application,
				    GFile *location,
				    GFile *selection,
				    const char *startup_id)
{
	NemoWindow *window;
	GList *sel_list = NULL;

	window = nemo_application_create_window (application, gdk_screen_get_default ());
	gtk_window_set_startup_id (GTK_WINDOW (window), startup_id);

	if (selection != NULL) {
		sel_list = g_list_prepend (sel_list, nemo_file_get (selection));
	}

	nemo_window_slot_open_location (nemo_window_get_active_slot (window),
					    location,
					    0,
					    sel_list);

	if (sel_list != NULL) {
		nemo_file_list_free (sel_list);
	}
}
Beispiel #6
0
void
nemo_file_queue_destroy (NemoFileQueue *queue)
{
	g_hash_table_destroy (queue->item_to_link_map);
	nemo_file_list_free (queue->head);
	g_free (queue);
}
Beispiel #7
0
void
nemo_directory_moved (const char *old_uri,
			  const char *new_uri)
{
	GList *list, *node;
	GHashTable *hash;
	NemoFile *file;
	GFile *old_location;
	GFile *new_location;

	hash = g_hash_table_new (NULL, NULL);

	old_location = g_file_new_for_uri (old_uri);
	new_location = g_file_new_for_uri (new_uri);
	
	list = nemo_directory_moved_internal (old_location, new_location);
	for (node = list; node != NULL; node = node->next) {
		file = NEMO_FILE (node->data);
		hash_table_list_prepend (hash,
					 file->details->directory,
					 nemo_file_ref (file));
	}
	nemo_file_list_free (list);
	
	g_object_unref (old_location);
	g_object_unref (new_location);

	g_hash_table_foreach (hash, call_files_changed_unref_free_list, NULL);
	g_hash_table_destroy (hash);
}
static void
reset_file_list (NemoSearchDirectory *search)
{
	GList *list, *monitor_list;
	NemoFile *file;
	SearchMonitor *monitor;

	/* Remove file connections */
	for (list = search->details->files; list != NULL; list = list->next) {
		file = list->data;

		/* Disconnect change handler */
		g_signal_handlers_disconnect_by_func (file, file_changed, search);

		/* Remove monitors */
		for (monitor_list = search->details->monitor_list; monitor_list; 
		     monitor_list = monitor_list->next) {
			monitor = monitor_list->data;
			nemo_file_monitor_remove (file, monitor);
		}
	}
	
	nemo_file_list_free (search->details->files);
	search->details->files = NULL;
}
Beispiel #9
0
GList *
nemo_directory_match_pattern (NemoDirectory *directory, const char *pattern)
{
	GList *files, *l, *ret;
	GPatternSpec *spec;


	ret = NULL;
	spec = g_pattern_spec_new (pattern);
	
	files = nemo_directory_get_file_list (directory);
	for (l = files; l; l = l->next) {
		NemoFile *file;
		char *name;
	       
	        file = NEMO_FILE (l->data);
		name = nemo_file_get_display_name (file);

		if (g_pattern_match_string (spec, name)) {
			ret = g_list_prepend(ret, nemo_file_ref (file));	
		}

		g_free (name);
	}

	g_pattern_spec_free (spec);
	nemo_file_list_free (files);

	return ret;
}
Beispiel #10
0
static void
call_files_changed_unref_free_list (gpointer key, gpointer value, gpointer user_data)
{
	g_assert (value != NULL);
	g_assert (user_data == NULL);

	call_files_changed_common (NEMO_DIRECTORY (key), value);
	nemo_file_list_free (value);
}
static void
merged_callback_destroy (MergedCallback *merged_callback)
{
	g_assert (merged_callback != NULL);
	g_assert (NEMO_IS_DESKTOP_DIRECTORY (merged_callback->desktop_dir));

	g_list_free (merged_callback->non_ready_directories);
	nemo_file_list_free (merged_callback->merged_file_list);
	g_free (merged_callback);
}
static void
search_callback_destroy (SearchCallback *search_callback)
{
	if (search_callback->non_ready_hash) {
		g_hash_table_foreach (search_callback->non_ready_hash, cancel_call_when_ready, search_callback);
		g_hash_table_destroy (search_callback->non_ready_hash);
	}

	nemo_file_list_free (search_callback->file_list);

	g_free (search_callback);
}
static void
desktop_monitor_add (NemoDirectory *directory,
		    gconstpointer client,
		    gboolean monitor_hidden_files,
		    NemoFileAttributes file_attributes,
		    NemoDirectoryCallback callback,
		    gpointer callback_data)
{
	NemoDesktopDirectory *desktop;
	MergedMonitor *monitor;
	GList *merged_callback_list;

	desktop = NEMO_DESKTOP_DIRECTORY (directory);

	/* Map the client to a unique value so this doesn't interfere
	 * with direct monitoring of the directory by the same client.
	 */
	monitor = g_hash_table_lookup (desktop->details->monitors, client);
	if (monitor != NULL) {
		g_assert (monitor->desktop_dir == desktop);
	} else {
		monitor = g_new0 (MergedMonitor, 1);
		monitor->desktop_dir = desktop;
		g_hash_table_insert (desktop->details->monitors,
				     (gpointer) client, monitor);
	}
	monitor->monitor_hidden_files = monitor_hidden_files;
	monitor->monitor_attributes = file_attributes;
	
	/* Call through to the real directory add calls. */
	merged_callback_list = NULL;

	/* Call up to real dir */
	nemo_directory_file_monitor_add
		(desktop->details->real_directory, monitor,
		 monitor_hidden_files,
		 file_attributes,
		 build_merged_callback_list, &merged_callback_list);
	
	/* Handle the desktop part */
	merged_callback_list = g_list_concat (merged_callback_list,
					      nemo_file_list_copy (directory->details->file_list));

	
	if (callback != NULL) {
		(* callback) (directory, merged_callback_list, callback_data);
	}
	nemo_file_list_free (merged_callback_list);
}
Beispiel #14
0
void
emit_change_signals_for_all_files (NemoDirectory *directory)
{
	GList *files;

	files = g_list_copy (directory->details->file_list);
	if (directory->details->as_file != NULL) {
		files = g_list_prepend (files, directory->details->as_file);
	}

	nemo_file_list_ref (files);
	nemo_directory_emit_change_signals (directory, files);

	nemo_file_list_free (files);
}
/* Create a monitor on each of the directories in the list. */
static void
merged_monitor_add (NemoDirectory *directory,
		    gconstpointer client,
		    gboolean monitor_hidden_files,
		    NemoFileAttributes file_attributes,
		    NemoDirectoryCallback callback,
		    gpointer callback_data)
{
	NemoMergedDirectory *merged;
	MergedMonitor *monitor;
	GList *node;
	GList *merged_callback_list;

	merged = NEMO_MERGED_DIRECTORY (directory);

	/* Map the client to a unique value so this doesn't interfere
	 * with direct monitoring of the directory by the same client.
	 */
	monitor = g_hash_table_lookup (merged->details->monitors, client);
	if (monitor != NULL) {
		g_assert (monitor->merged == merged);
	} else {
		monitor = g_new0 (MergedMonitor, 1);
		monitor->merged = merged;
		g_hash_table_insert (merged->details->monitors,
				     (gpointer) client, monitor);
	}
	monitor->monitor_hidden_files = monitor_hidden_files;
	monitor->monitor_attributes = file_attributes;

	/* Call through to the real directory add calls. */
	merged_callback_list = NULL;
	for (node = merged->details->directories; node != NULL; node = node->next) {
		nemo_directory_file_monitor_add
			(node->data, monitor,
			 monitor_hidden_files,
			 file_attributes,
			 build_merged_callback_list, &merged_callback_list);
	}
	if (callback != NULL) {
		(* callback) (directory, merged_callback_list, callback_data);
	}
	nemo_file_list_free (merged_callback_list);
}
static void
search_engine_hits_subtracted (NemoSearchEngine *engine, GList *hits, 
			       NemoSearchDirectory *search)
{
	GList *hit_list;
	GList *monitor_list;
	SearchMonitor *monitor;
	GList *file_list;
	char *uri;
	NemoFile *file;

	file_list = NULL;

	for (hit_list = hits; hit_list != NULL; hit_list = hit_list->next) {
		uri = hit_list->data;
		file = nemo_file_get_by_uri (uri);

		for (monitor_list = search->details->monitor_list; monitor_list; 
		     monitor_list = monitor_list->next) {
			monitor = monitor_list->data;
			/* Remove monitors */
			nemo_file_monitor_remove (file, monitor);
		}
		
		g_signal_handlers_disconnect_by_func (file, file_changed, search);

		search->details->files = g_list_remove (search->details->files, file);

		file_list = g_list_prepend (file_list, file);
	}
	
	nemo_directory_emit_files_changed (NEMO_DIRECTORY (search), file_list);

	nemo_file_list_free (file_list);

	file = nemo_directory_get_corresponding_file (NEMO_DIRECTORY (search));
	nemo_file_emit_changed (file);
	nemo_file_unref (file);
}
Beispiel #17
0
void
fm_tree_model_set_highlight_for_files (FMTreeModel *model,
                                       GList *files)
{
	GList *old_files;

	if (model->details->highlighted_files != NULL) {
		old_files = model->details->highlighted_files;
		model->details->highlighted_files = NULL;

		g_list_foreach (old_files,
		                (GFunc) do_update_node, model);

		nemo_file_list_free (old_files);
	}

	if (files != NULL) {
		model->details->highlighted_files = 
			nemo_file_list_copy (files);
		g_list_foreach (model->details->highlighted_files,
		                (GFunc) do_update_node, model);
	}
}
Beispiel #18
0
void
nemo_directory_notify_files_moved (GList *file_pairs)
{
	GList *p, *affected_files, *node;
	GFilePair *pair;
	NemoFile *file;
	NemoDirectory *old_directory, *new_directory;
	GHashTable *parent_directories;
	GList *new_files_list, *unref_list;
	GHashTable *added_lists, *changed_lists;
	char *name;
	NemoFileAttributes cancel_attributes;
	GFile *to_location, *from_location;
	
	/* Make a list of added and changed files in each directory. */
	new_files_list = NULL;
	added_lists = g_hash_table_new (NULL, NULL);
	changed_lists = g_hash_table_new (NULL, NULL);
	unref_list = NULL;

	/* Make a list of parent directories that will need their counts updated. */
	parent_directories = g_hash_table_new (NULL, NULL);

	cancel_attributes = nemo_file_get_all_attributes ();

	for (p = file_pairs; p != NULL; p = p->next) {
		pair = p->data;
		from_location = pair->from;
		to_location = pair->to;

		/* Handle overwriting a file. */
		file = nemo_file_get_existing (to_location);
		if (file != NULL) {
			/* Mark it gone and prepare to send the changed signal. */
			nemo_file_mark_gone (file);
			new_directory = file->details->directory;
			hash_table_list_prepend (changed_lists,
						 new_directory,
						 file);
			collect_parent_directories (parent_directories,
						    new_directory);
		}

		/* Update any directory objects that are affected. */
		affected_files = nemo_directory_moved_internal (from_location,
								    to_location);
		for (node = affected_files; node != NULL; node = node->next) {
			file = NEMO_FILE (node->data);
			hash_table_list_prepend (changed_lists,
						 file->details->directory,
						 file);
		}
		unref_list = g_list_concat (unref_list, affected_files);

		/* Move an existing file. */
		file = nemo_file_get_existing (from_location);
		if (file == NULL) {
			/* Handle this as if it was a new file. */
			new_files_list = g_list_prepend (new_files_list,
							 to_location);
		} else {
			/* Handle notification in the old directory. */
			old_directory = file->details->directory;
			collect_parent_directories (parent_directories, old_directory);

			/* Cancel loading of attributes in the old directory */
			nemo_directory_cancel_loading_file_attributes
				(old_directory, file, cancel_attributes);

			/* Locate the new directory. */
			new_directory = get_parent_directory (to_location);
			collect_parent_directories (parent_directories, new_directory);
			/* We can unref now -- new_directory is in the
			 * parent directories list so it will be
			 * around until the end of this function
			 * anyway.
			 */
			nemo_directory_unref (new_directory);

			/* Update the file's name and directory. */
			name = g_file_get_basename (to_location);
			nemo_file_update_name_and_directory 
				(file, name, new_directory);
			g_free (name);

			/* Update file attributes */
			nemo_file_invalidate_attributes (file, NEMO_FILE_ATTRIBUTE_INFO);

			hash_table_list_prepend (changed_lists,
						 old_directory,
						 file);
			if (old_directory != new_directory) {
				hash_table_list_prepend	(added_lists,
							 new_directory,
							 file);
			}

			/* Unref each file once to balance out nemo_file_get_by_uri. */
			unref_list = g_list_prepend (unref_list, file);
		}
	}

	/* Now send out the changed and added signals for existing file objects. */
	g_hash_table_foreach (changed_lists, call_files_changed_free_list, NULL);
	g_hash_table_destroy (changed_lists);
	g_hash_table_foreach (added_lists, call_files_added_free_list, NULL);
	g_hash_table_destroy (added_lists);

	/* Let the file objects go. */
	nemo_file_list_free (unref_list);

	/* Invalidate count for each parent directory. */
	g_hash_table_foreach (parent_directories, invalidate_count_and_unref, NULL);
	g_hash_table_destroy (parent_directories);

	/* Separate handling for brand new file objects. */
	nemo_directory_notify_files_added (new_files_list);
	g_list_free (new_files_list);
}