static GtkTreePath * get_drop_path (NemoTreeViewDragDest *dest, GtkTreePath *path) { NemoFile *file; GtkTreePath *ret; if (!path || !dest->details->have_drag_data) { return NULL; } ret = gtk_tree_path_copy (path); file = file_for_path (dest, ret); /* Go up the tree until we find a file that can accept a drop */ while (file == NULL /* dummy row */ || !nemo_drag_can_accept_info (file, dest->details->drag_type, dest->details->drag_list)) { if (gtk_tree_path_get_depth (ret) == 1) { gtk_tree_path_free (ret); ret = NULL; break; } else { gtk_tree_path_up (ret); nemo_file_unref (file); file = file_for_path (dest, ret); } } nemo_file_unref (file); return ret; }
void fm_tree_model_add_root_uri (FMTreeModel *model, const char *root_uri, const char *display_name, GIcon *icon, GMount *mount) { NemoFile *file; TreeNode *node, *cnode; FMTreeModelRoot *newroot; file = nemo_file_get_by_uri (root_uri); newroot = tree_model_root_new (model); node = create_node_for_file (newroot, file); node->display_name = g_strdup (display_name); node->icon = g_object_ref (icon); if (mount) { node->mount = g_object_ref (mount); } newroot->root_node = node; node->parent = NULL; if (model->details->root_node == NULL) { model->details->root_node = node; } else { /* append it */ for (cnode = model->details->root_node; cnode->next != NULL; cnode = cnode->next); cnode->next = node; node->prev = cnode; } nemo_file_unref (file); update_node_without_reporting (model, node); report_node_inserted (model, node); }
void nemo_directory_remove_file (NemoDirectory *directory, NemoFile *file) { GList *node; g_assert (NEMO_IS_DIRECTORY (directory)); g_assert (NEMO_IS_FILE (file)); g_assert (file->details->name != NULL); /* Find the list node in the hash table. */ node = extract_from_hash_table (directory, file); g_assert (node != NULL); g_assert (node->data == file); /* Remove the item from the list. */ directory->details->file_list = g_list_remove_link (directory->details->file_list, node); g_list_free_1 (node); nemo_directory_remove_file_from_work_queue (directory, file); if (!file->details->unconfirmed) { directory->details->confirmed_file_count--; } /* Unref if we are monitoring. */ if (nemo_directory_is_file_list_monitored (directory)) { nemo_file_unref (file); } }
static void done_loading_callback (NemoDirectory *directory, FMTreeModelRoot *root) { NemoFile *file; TreeNode *node; GtkTreeIter iter; file = nemo_directory_get_corresponding_file (directory); node = get_node_from_file (root, file); if (node == NULL) { /* This can happen for non-existing files as tree roots, * since the directory <-> file object relation gets * broken due to nemo_directory_remove_file() * getting called when i/o fails. */ return; } set_done_loading (root->model, node, TRUE); nemo_file_unref (file); make_iter_for_node (node, &iter, root->model->details->stamp); g_signal_emit (root->model, tree_model_signals[ROW_LOADED], 0, &iter); }
char * nemo_compute_title_for_location (GFile *location) { NemoFile *file; char *title; char *builder; /* TODO-gio: This doesn't really work all that great if the info about the file isn't known atm... */ if (nemo_is_home_directory (location)) { return g_strdup (_("Home")); } builder = NULL; if (location) { file = nemo_file_get (location); builder = nemo_file_get_description (file); if (builder == NULL) { builder = nemo_file_get_display_name (file); } nemo_file_unref (file); } if (builder == NULL) { builder = g_file_get_basename (location); } if (g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_FULL_PATH_TITLES)) { file = nemo_file_get (location); char *path = g_filename_from_uri (nemo_file_get_uri (file), NULL, NULL); if (path != NULL) { title = g_strdup_printf("%s - %s", builder, path); } else { title = g_strdup(builder); } nemo_file_unref (file); g_free (path); g_free (builder); } else { title = g_strdup(builder); g_free (builder); } return title; }
static TreeNode * get_parent_node_from_file (FMTreeModelRoot *root, NemoFile *file) { NemoFile *parent_file; TreeNode *parent_node; parent_file = nemo_file_get_parent (file); parent_node = get_node_from_file (root, parent_file); nemo_file_unref (parent_file); return parent_node; }
static void nemo_desktop_item_properties_exec_drag_data_received (GtkWidget *widget, GdkDragContext *context, int x, int y, GtkSelectionData *selection_data, guint info, guint time, GtkEntry *entry) { char **uris; gboolean exactly_one; NemoFile *file; GKeyFile *key_file; char *uri, *type, *exec; uris = g_strsplit (gtk_selection_data_get_data (selection_data), "\r\n", 0); exactly_one = uris[0] != NULL && (uris[1] == NULL || uris[1][0] == '\0'); if (!exactly_one) { g_strfreev (uris); return; } file = nemo_file_get_by_uri (uris[0]); g_return_if_fail (file != NULL); uri = nemo_file_get_uri (file); if (nemo_file_is_mime_type (file, "application/x-desktop")) { key_file = _g_key_file_new_from_uri (uri, G_KEY_FILE_NONE, NULL); if (key_file != NULL) { type = g_key_file_get_string (key_file, MAIN_GROUP, "Type", NULL); if (type != NULL && strcmp (type, "Application") == 0) { exec = g_key_file_get_string (key_file, MAIN_GROUP, "Exec", NULL); if (exec != NULL) { g_free (uri); uri = exec; } } g_free (type); g_key_file_free (key_file); } } gtk_entry_set_text (entry, uri?uri:""); gtk_widget_grab_focus (GTK_WIDGET (entry)); g_free (uri); nemo_file_unref (file); g_strfreev (uris); }
void nemo_directory_schedule_position_set (GList *position_setting_list) { GList *p; const NemoFileChangesQueuePosition *item; NemoFile *file; char str[64]; time_t now; time (&now); for (p = position_setting_list; p != NULL; p = p->next) { item = (NemoFileChangesQueuePosition *) p->data; file = nemo_file_get (item->location); if (item->set) { g_snprintf (str, sizeof (str), "%d,%d", item->point.x, item->point.y); } else { str[0] = 0; } nemo_file_set_metadata (file, NEMO_METADATA_KEY_ICON_POSITION, NULL, str); if (item->set) { nemo_file_set_time_metadata (file, NEMO_METADATA_KEY_ICON_POSITION_TIMESTAMP, now); } else { nemo_file_set_time_metadata (file, NEMO_METADATA_KEY_ICON_POSITION_TIMESTAMP, UNDEFINED_TIME); } if (item->set) { g_snprintf (str, sizeof (str), "%d", item->monitor); } else { str[0] = 0; } nemo_file_set_metadata (file, NEMO_METADATA_KEY_MONITOR, NULL, str); nemo_file_unref (file); } }
void fm_tree_model_remove_root_uri (FMTreeModel *model, const char *uri) { TreeNode *node; GtkTreePath *path; FMTreeModelRoot *root; NemoFile *file; file = nemo_file_get_by_uri (uri); for (node = model->details->root_node; node != NULL; node = node->next) { if (file == node->file) { break; } } nemo_file_unref (file); if (node) { /* remove the node */ if (node->mount) { g_object_unref (node->mount); node->mount = NULL; } nemo_file_monitor_remove (node->file, model); path = get_node_path (model, node); /* Report row_deleted before actually deleting */ gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path); gtk_tree_path_free (path); if (node->prev) { node->prev->next = node->next; } if (node->next) { node->next->prev = node->prev; } if (node == model->details->root_node) { model->details->root_node = node->next; } /* destroy the root identifier */ root = node->root; destroy_node_without_reporting (model, node); g_hash_table_destroy (root->file_to_node_map); g_free (root); } }
static void each_path_get_data_binder (NemoDragEachSelectedItemDataGet data_get, gpointer context, gpointer data) { DragDataGetInfo *info; GList *l; NemoFile *file; GtkTreeRowReference *row; GtkTreePath *path; char *uri; GdkRectangle cell_area; GtkTreeViewColumn *column; info = context; g_return_if_fail (info->model->details->drag_view); column = gtk_tree_view_get_column (info->model->details->drag_view, 0); for (l = info->path_list; l != NULL; l = l->next) { row = l->data; path = gtk_tree_row_reference_get_path (row); file = nemo_list_model_file_for_path (info->model, path); if (file) { gtk_tree_view_get_cell_area (info->model->details->drag_view, path, column, &cell_area); uri = nemo_file_get_uri (file); (*data_get) (uri, 0, cell_area.y - info->model->details->drag_begin_y, cell_area.width, cell_area.height, data); g_free (uri); nemo_file_unref (file); } gtk_tree_path_free (path); } }
static void file_entry_free (FileEntry *file_entry) { nemo_file_unref (file_entry->file); if (file_entry->reverse_map) { g_hash_table_destroy (file_entry->reverse_map); file_entry->reverse_map = NULL; } if (file_entry->subdirectory != NULL) { nemo_directory_unref (file_entry->subdirectory); } if (file_entry->files != NULL) { g_sequence_free (file_entry->files); } g_free (file_entry); }
void nemo_directory_notify_files_removed (GList *files) { GHashTable *changed_lists; GList *p; NemoDirectory *directory; GHashTable *parent_directories; NemoFile *file; GFile *location; /* Make a list of changed files in each directory. */ changed_lists = g_hash_table_new (NULL, NULL); /* Make a list of parent directories that will need their counts updated. */ parent_directories = g_hash_table_new (NULL, NULL); /* Go through all the notifications. */ for (p = files; p != NULL; p = p->next) { location = p->data; /* Update file count for parent directory if anyone might care. */ directory = get_parent_directory_if_exists (location); if (directory != NULL) { collect_parent_directories (parent_directories, directory); nemo_directory_unref (directory); } /* Find the file. */ file = nemo_file_get_existing (location); if (file != NULL && !nemo_file_rename_in_progress (file)) { /* Mark it gone and prepare to send the changed signal. */ nemo_file_mark_gone (file); hash_table_list_prepend (changed_lists, file->details->directory, nemo_file_ref (file)); } nemo_file_unref (file); } /* Now send out the changed signals. */ g_hash_table_foreach (changed_lists, call_files_changed_unref_free_list, NULL); g_hash_table_destroy (changed_lists); /* Invalidate count for each parent directory. */ g_hash_table_foreach (parent_directories, invalidate_count_and_unref, NULL); g_hash_table_destroy (parent_directories); }
/* "." for the directory-as-file, otherwise the filename */ NemoFile * nemo_directory_find_file_by_internal_filename (NemoDirectory *directory, const char *internal_filename) { NemoFile *result; if (g_strcmp0 (internal_filename, ".") == 0) { result = nemo_directory_get_existing_corresponding_file (directory); if (result != NULL) { nemo_file_unref (result); } } else { result = nemo_directory_find_file_by_name (directory, internal_filename); } return result; }
static char * get_drop_target_uri_for_path (NemoTreeViewDragDest *dest, GtkTreePath *path) { NemoFile *file; char *target; file = file_for_path (dest, path); if (file == NULL) { return NULL; } target = nemo_file_get_drop_target_uri (file); nemo_file_unref (file); return target; }
static void search_engine_hits_added (NemoSearchEngine *engine, GList *hits, NemoSearchDirectory *search) { GList *hit_list; GList *file_list; NemoFile *file; char *uri; SearchMonitor *monitor; GList *monitor_list; file_list = NULL; for (hit_list = hits; hit_list != NULL; hit_list = hit_list->next) { uri = hit_list->data; if (g_str_has_suffix (uri, NEMO_SAVED_SEARCH_EXTENSION)) { /* Never return saved searches themselves as hits */ continue; } 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; /* Add monitors */ nemo_file_monitor_add (file, monitor, monitor->monitor_attributes); } g_signal_connect (file, "changed", G_CALLBACK (file_changed), search), file_list = g_list_prepend (file_list, file); } search->details->files = g_list_concat (search->details->files, file_list); nemo_directory_emit_files_added (NEMO_DIRECTORY (search), file_list); file = nemo_directory_get_corresponding_file (NEMO_DIRECTORY (search)); nemo_file_emit_changed (file); nemo_file_unref (file); }
/* This is a one-shot idle callback called from the main loop to call notify_file_changed() for a thumbnail. It frees the uri afterwards. We do this in an idle callback as I don't think nemo_file_changed() is thread-safe. */ static gboolean thumbnail_thread_notify_file_changed (gpointer image_uri) { NemoFile *file; file = nemo_file_get_by_uri ((char *) image_uri); #ifdef DEBUG_THUMBNAILS g_message ("(Thumbnail Thread) Notifying file changed file:%p uri: %s\n", file, (char*) image_uri); #endif if (file != NULL) { nemo_file_set_is_thumbnailing (file, FALSE); nemo_file_invalidate_attributes (file, NEMO_FILE_ATTRIBUTE_THUMBNAIL | NEMO_FILE_ATTRIBUTE_INFO); nemo_file_unref (file); } g_free (image_uri); return FALSE; }
static void nemo_icon_dnd_update_drop_target (NemoIconContainer *container, GdkDragContext *context, int x, int y) { NemoIcon *icon; NemoFile *file; double world_x, world_y; char *uri; g_assert (NEMO_IS_ICON_CONTAINER (container)); canvas_widget_to_world (EEL_CANVAS (container), x, y, &world_x, &world_y); /* Find the item we hit with our drop, if any. */ icon = nemo_icon_container_item_at (container, world_x, world_y); /* FIXME bugzilla.gnome.org 42485: * These "can_accept_items" tests need to be done by * the icon view, not here. This file is not supposed to know * that the target is a file. */ /* Find if target icon accepts our drop. */ if (icon != NULL) { uri = nemo_icon_container_get_icon_uri (container, icon); file = nemo_file_get_by_uri (uri); g_free (uri); if (!nemo_drag_can_accept_info (file, container->details->dnd_info->drag_info.data_type, container->details->dnd_info->drag_info.selection_list)) { icon = NULL; } nemo_file_unref (file); } set_drop_target (container, icon); }
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); }
static void real_directory_notify_files_removed (NemoDirectory *real_directory) { GList *files, *l; files = nemo_directory_get_file_list (real_directory); for (l = files; l; l = l->next) { NemoFile *file; char *uri; file = NEMO_FILE (l->data); uri = nemo_file_get_uri (file); nemo_file_unref (file); l->data = uri; } if (files) { nemo_directory_notify_files_removed_by_uri (files); } g_list_free_full (files, g_free); }
void nemo_file_queue_remove (NemoFileQueue *queue, NemoFile *file) { GList *link; link = g_hash_table_lookup (queue->item_to_link_map, file); if (link == NULL) { /* It's not on the queue */ return; } if (link == queue->tail) { /* Need to special-case removing the tail. */ queue->tail = queue->tail->prev; } queue->head = g_list_remove_link (queue->head, link); g_list_free (link); g_hash_table_remove (queue->item_to_link_map, file); nemo_file_unref (file); }
static char * nemo_icon_container_find_drop_target (NemoIconContainer *container, GdkDragContext *context, int x, int y, gboolean *icon_hit, gboolean rewrite_desktop) { NemoIcon *drop_target_icon; double world_x, world_y; NemoFile *file; char *icon_uri; char *container_uri; if (icon_hit) { *icon_hit = FALSE; } if (!container->details->dnd_info->drag_info.got_drop_data_type) { return NULL; } canvas_widget_to_world (EEL_CANVAS (container), x, y, &world_x, &world_y); /* FIXME bugzilla.gnome.org 42485: * These "can_accept_items" tests need to be done by * the icon view, not here. This file is not supposed to know * that the target is a file. */ /* Find the item we hit with our drop, if any */ drop_target_icon = nemo_icon_container_item_at (container, world_x, world_y); if (drop_target_icon != NULL) { icon_uri = nemo_icon_container_get_icon_uri (container, drop_target_icon); if (icon_uri != NULL) { file = nemo_file_get_by_uri (icon_uri); if (!nemo_drag_can_accept_info (file, container->details->dnd_info->drag_info.data_type, container->details->dnd_info->drag_info.selection_list)) { /* the item we dropped our selection on cannot accept the items, * do the same thing as if we just dropped the items on the canvas */ drop_target_icon = NULL; } g_free (icon_uri); nemo_file_unref (file); } } if (drop_target_icon == NULL) { if (icon_hit) { *icon_hit = FALSE; } container_uri = get_container_uri (container); if (rewrite_desktop && container_uri != NULL && eel_uri_is_desktop (container_uri)) { g_free (container_uri); container_uri = nemo_get_desktop_directory_uri (); } return container_uri; } if (icon_hit) { *icon_hit = TRUE; } return nemo_icon_container_get_icon_drop_target_uri (container, drop_target_icon); }
void nemo_self_check_directory (void) { NemoDirectory *directory; NemoFile *file; directory = nemo_directory_get_by_uri ("file:///etc"); file = nemo_file_get_by_uri ("file:///etc/passwd"); EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 1); nemo_directory_file_monitor_add (directory, &data_dummy, TRUE, 0, NULL, NULL); /* FIXME: these need to be updated to the new metadata infrastructure * as make check doesn't pass. nemo_file_set_metadata (file, "test", "default", "value"); EEL_CHECK_STRING_RESULT (nemo_file_get_metadata (file, "test", "default"), "value"); nemo_file_set_boolean_metadata (file, "test_boolean", TRUE, TRUE); EEL_CHECK_BOOLEAN_RESULT (nemo_file_get_boolean_metadata (file, "test_boolean", TRUE), TRUE); nemo_file_set_boolean_metadata (file, "test_boolean", TRUE, FALSE); EEL_CHECK_BOOLEAN_RESULT (nemo_file_get_boolean_metadata (file, "test_boolean", TRUE), FALSE); EEL_CHECK_BOOLEAN_RESULT (nemo_file_get_boolean_metadata (NULL, "test_boolean", TRUE), TRUE); nemo_file_set_integer_metadata (file, "test_integer", 0, 17); EEL_CHECK_INTEGER_RESULT (nemo_file_get_integer_metadata (file, "test_integer", 0), 17); nemo_file_set_integer_metadata (file, "test_integer", 0, -1); EEL_CHECK_INTEGER_RESULT (nemo_file_get_integer_metadata (file, "test_integer", 0), -1); nemo_file_set_integer_metadata (file, "test_integer", 42, 42); EEL_CHECK_INTEGER_RESULT (nemo_file_get_integer_metadata (file, "test_integer", 42), 42); EEL_CHECK_INTEGER_RESULT (nemo_file_get_integer_metadata (NULL, "test_integer", 42), 42); EEL_CHECK_INTEGER_RESULT (nemo_file_get_integer_metadata (file, "nonexistent_key", 42), 42); */ EEL_CHECK_BOOLEAN_RESULT (nemo_directory_get_by_uri ("file:///etc") == directory, TRUE); nemo_directory_unref (directory); EEL_CHECK_BOOLEAN_RESULT (nemo_directory_get_by_uri ("file:///etc/") == directory, TRUE); nemo_directory_unref (directory); EEL_CHECK_BOOLEAN_RESULT (nemo_directory_get_by_uri ("file:///etc////") == directory, TRUE); nemo_directory_unref (directory); nemo_file_unref (file); nemo_directory_file_monitor_remove (directory, &data_dummy); nemo_directory_unref (directory); while (g_hash_table_size (directories) != 0) { gtk_main_iteration (); } EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 0); directory = nemo_directory_get_by_uri ("file:///etc"); got_files_flag = FALSE; nemo_directory_call_when_ready (directory, NEMO_FILE_ATTRIBUTE_INFO | NEMO_FILE_ATTRIBUTE_DEEP_COUNTS, TRUE, got_files_callback, &data_dummy); while (!got_files_flag) { gtk_main_iteration (); } EEL_CHECK_BOOLEAN_RESULT (directory->details->file_list == NULL, TRUE); EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 1); file = nemo_file_get_by_uri ("file:///etc/passwd"); /* EEL_CHECK_STRING_RESULT (nemo_file_get_metadata (file, "test", "default"), "value"); */ nemo_file_unref (file); nemo_directory_unref (directory); EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 0); }
void nemo_launch_application_by_uri (GAppInfo *application, GList *uris, GtkWindow *parent_window) { char *uri; GList *locations, *l; GFile *location; NemoFile *file; gboolean result; GError *error; GdkDisplay *display; GdkAppLaunchContext *launch_context; NemoIconInfo *icon; int count, total; g_assert (uris != NULL); /* count the number of uris with local paths */ count = 0; total = g_list_length (uris); locations = NULL; for (l = uris; l != NULL; l = l->next) { uri = l->data; location = g_file_new_for_uri (uri); if (g_file_is_native (location)) { count++; } locations = g_list_prepend (locations, location); } locations = g_list_reverse (locations); if (parent_window != NULL) { display = gtk_widget_get_display (GTK_WIDGET (parent_window)); } else { display = gdk_display_get_default (); } launch_context = gdk_display_get_app_launch_context (display); if (parent_window != NULL) { gdk_app_launch_context_set_screen (launch_context, gtk_window_get_screen (parent_window)); } file = nemo_file_get_by_uri (uris->data); icon = nemo_file_get_icon (file, 48, gtk_widget_get_scale_factor (GTK_WIDGET (parent_window)), 0); nemo_file_unref (file); if (icon) { gdk_app_launch_context_set_icon_name (launch_context, nemo_icon_info_get_used_name (icon)); g_object_unref (icon); } error = NULL; if (count == total) { /* All files are local, so we can use g_app_info_launch () with * the file list we constructed before. */ result = g_app_info_launch (application, locations, G_APP_LAUNCH_CONTEXT (launch_context), &error); } else { /* Some files are non local, better use g_app_info_launch_uris (). */ result = g_app_info_launch_uris (application, uris, G_APP_LAUNCH_CONTEXT (launch_context), &error); } g_object_unref (launch_context); if (result) { for (l = uris; l != NULL; l = l->next) { file = nemo_file_get_by_uri (l->data); nemo_recent_add_file (file, application); nemo_file_unref (file); } } g_list_free_full (locations, g_object_unref); }
static void nemo_window_slot_dispose (GObject *object) { NemoWindowSlot *slot; GtkWidget *widget; slot = NEMO_WINDOW_SLOT (object); nemo_window_slot_clear_forward_list (slot); nemo_window_slot_clear_back_list (slot); nemo_window_slot_remove_extra_location_widgets (slot); if (slot->content_view) { widget = GTK_WIDGET (slot->content_view); gtk_widget_destroy (widget); g_object_unref (slot->content_view); slot->content_view = NULL; } if (slot->new_content_view) { widget = GTK_WIDGET (slot->new_content_view); gtk_widget_destroy (widget); g_object_unref (slot->new_content_view); slot->new_content_view = NULL; } if (slot->set_status_timeout_id != 0) { g_source_remove (slot->set_status_timeout_id); slot->set_status_timeout_id = 0; } if (slot->loading_timeout_id != 0) { g_source_remove (slot->loading_timeout_id); slot->loading_timeout_id = 0; } nemo_window_slot_set_viewed_file (slot, NULL); /* TODO? why do we unref here? the file is NULL. * It was already here before the slot move, though */ nemo_file_unref (slot->viewed_file); if (slot->location) { /* TODO? why do we ref here, instead of unreffing? * It was already here before the slot migration, though */ g_object_ref (slot->location); } g_list_free_full (slot->pending_selection, g_object_unref); slot->pending_selection = NULL; g_clear_object (&slot->current_location_bookmark); g_clear_object (&slot->last_location_bookmark); if (slot->find_mount_cancellable != NULL) { g_cancellable_cancel (slot->find_mount_cancellable); slot->find_mount_cancellable = NULL; } slot->pane = NULL; g_free (slot->title); slot->title = NULL; g_free (slot->status_text); slot->status_text = NULL; G_OBJECT_CLASS (nemo_window_slot_parent_class)->dispose (object); }
void nemo_directory_notify_files_added (GList *files) { GHashTable *added_lists; GList *p; NemoDirectory *directory; GHashTable *parent_directories; NemoFile *file; GFile *location, *parent; /* Make a list of added files in each directory. */ added_lists = g_hash_table_new (NULL, NULL); /* Make a list of parent directories that will need their counts updated. */ parent_directories = g_hash_table_new (NULL, NULL); for (p = files; p != NULL; p = p->next) { location = p->data; /* See if the directory is already known. */ directory = get_parent_directory_if_exists (location); if (directory == NULL) { /* In case the directory is not being * monitored, but the corresponding file is, * we must invalidate it's item count. */ file = NULL; parent = g_file_get_parent (location); if (parent) { file = nemo_file_get_existing (parent); g_object_unref (parent); } if (file != NULL) { nemo_file_invalidate_count_and_mime_list (file); nemo_file_unref (file); } continue; } collect_parent_directories (parent_directories, directory); /* If no one is monitoring files in the directory, nothing to do. */ if (!nemo_directory_is_file_list_monitored (directory)) { nemo_directory_unref (directory); continue; } file = nemo_file_get_existing (location); /* We check is_added here, because the file could have been added * to the directory by a nemo_file_get() but not gotten * files_added emitted */ if (file && file->details->is_added) { /* A file already exists, it was probably renamed. * If it was renamed this could be ignored, but * queue a change just in case */ nemo_file_changed (file); nemo_file_unref (file); } else { hash_table_list_prepend (added_lists, directory, g_object_ref (location)); } nemo_directory_unref (directory); } /* Now get file info for the new files. This creates NemoFile * objects for the new files, and sends out a files_added signal. */ g_hash_table_foreach (added_lists, call_get_file_info_free_list, NULL); g_hash_table_destroy (added_lists); /* Invalidate count for each parent directory. */ g_hash_table_foreach (parent_directories, invalidate_count_and_unref, NULL); g_hash_table_destroy (parent_directories); }
static void nemo_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column, GValue *value) { NemoListModel *model; FileEntry *file_entry; NemoFile *file; char *str; GdkPixbuf *icon, *rendered_icon; GIcon *gicon, *emblemed_icon, *emblem_icon; NemoIconInfo *icon_info; GEmblem *emblem; GList *emblem_icons, *l; int icon_size; NemoZoomLevel zoom_level; NemoFile *parent_file; char *emblems_to_ignore[3]; int i; NemoFileIconFlags flags; model = (NemoListModel *)tree_model; g_return_if_fail (model->details->stamp == iter->stamp); g_return_if_fail (!g_sequence_iter_is_end (iter->user_data)); file_entry = g_sequence_get (iter->user_data); file = file_entry->file; switch (column) { case NEMO_LIST_MODEL_FILE_COLUMN: g_value_init (value, NEMO_TYPE_FILE); g_value_set_object (value, file); break; case NEMO_LIST_MODEL_SUBDIRECTORY_COLUMN: g_value_init (value, NEMO_TYPE_DIRECTORY); g_value_set_object (value, file_entry->subdirectory); break; case NEMO_LIST_MODEL_SMALLEST_ICON_COLUMN: case NEMO_LIST_MODEL_SMALLER_ICON_COLUMN: case NEMO_LIST_MODEL_SMALL_ICON_COLUMN: case NEMO_LIST_MODEL_STANDARD_ICON_COLUMN: case NEMO_LIST_MODEL_LARGE_ICON_COLUMN: case NEMO_LIST_MODEL_LARGER_ICON_COLUMN: case NEMO_LIST_MODEL_LARGEST_ICON_COLUMN: g_value_init (value, GDK_TYPE_PIXBUF); if (file != NULL) { zoom_level = nemo_list_model_get_zoom_level_from_column_id (column); icon_size = nemo_get_icon_size_for_zoom_level (zoom_level); flags = NEMO_FILE_ICON_FLAGS_USE_THUMBNAILS | NEMO_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE | NEMO_FILE_ICON_FLAGS_USE_MOUNT_ICON_AS_EMBLEM; if (model->details->drag_view != NULL) { GtkTreePath *path_a, *path_b; gtk_tree_view_get_drag_dest_row (model->details->drag_view, &path_a, NULL); if (path_a != NULL) { path_b = gtk_tree_model_get_path (tree_model, iter); if (gtk_tree_path_compare (path_a, path_b) == 0) { flags |= NEMO_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT; } gtk_tree_path_free (path_a); gtk_tree_path_free (path_b); } } gicon = G_ICON (nemo_file_get_icon_pixbuf (file, icon_size, TRUE, flags)); /* render emblems with GEmblemedIcon */ parent_file = nemo_file_get_parent (file); i = 0; emblems_to_ignore[i++] = NEMO_FILE_EMBLEM_NAME_TRASH; if (parent_file) { if (!nemo_file_can_write (parent_file)) { emblems_to_ignore[i++] = NEMO_FILE_EMBLEM_NAME_CANT_WRITE; } nemo_file_unref (parent_file); } emblems_to_ignore[i++] = NULL; emblem_icons = nemo_file_get_emblem_icons (file, emblems_to_ignore); /* pick only the first emblem we can render for the list view */ for (l = emblem_icons; l != NULL; l = l->next) { emblem_icon = l->data; if (nemo_icon_theme_can_render (G_THEMED_ICON (emblem_icon))) { emblem = g_emblem_new (emblem_icon); emblemed_icon = g_emblemed_icon_new (gicon, emblem); g_object_unref (gicon); g_object_unref (emblem); gicon = emblemed_icon; break; } } g_list_free_full (emblem_icons, g_object_unref); icon_info = nemo_icon_info_lookup (gicon, icon_size); icon = nemo_icon_info_get_pixbuf_at_size (icon_info, icon_size); g_object_unref (icon_info); g_object_unref (gicon); if (model->details->highlight_files != NULL && g_list_find_custom (model->details->highlight_files, file, (GCompareFunc) nemo_file_compare_location)) { rendered_icon = eel_create_spotlight_pixbuf (icon); if (rendered_icon != NULL) { g_object_unref (icon); icon = rendered_icon; } } g_value_set_object (value, icon); g_object_unref (icon); } break; case NEMO_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN: g_value_init (value, G_TYPE_BOOLEAN); g_value_set_boolean (value, file != NULL && nemo_file_can_rename (file)); break; default: if (column >= NEMO_LIST_MODEL_NUM_COLUMNS || column < NEMO_LIST_MODEL_NUM_COLUMNS + model->details->columns->len) { NemoColumn *nemo_column; GQuark attribute; nemo_column = model->details->columns->pdata[column - NEMO_LIST_MODEL_NUM_COLUMNS]; g_value_init (value, G_TYPE_STRING); g_object_get (nemo_column, "attribute_q", &attribute, NULL); if (file != NULL) { str = nemo_file_get_string_attribute_with_default_q (file, attribute); g_value_take_string (value, str); } else if (attribute == attribute_name_q) { if (file_entry->parent->loaded) { g_value_set_string (value, _("(Empty)")); } else { g_value_set_string (value, _("Loading...")); } } } else { g_assert_not_reached (); } } }