// FIXME_pcm: maybe we can support different encoding for different mount points? char *fm_path_display_basename (FmPath *path) { if (G_UNLIKELY (!path->parent)) // root_path element { if (!fm_path_is_native (path) && fm_path_is_virtual (path)) { if (fm_path_is_root (path) && fm_path_is_trash (path)) return g_strdup (_("Trash Can")); //~ if (g_str_has_prefix (path->name, "computer:/")) //~ return g_strdup (_("My Computer")); if (fm_path_is_computer (path)) return g_strdup (_("My Computer")); if (g_str_has_prefix (path->name, "menu:/")) { // FIXME_pcm: this should be more flexible const char *p = path->name + 5; while (p[0] == '/') ++p; if (g_str_has_prefix (p, "applications.menu")) return g_strdup (_("Applications")); } if (g_str_has_prefix (path->name, "network:/")) return g_strdup (_("Network")); } } return g_filename_display_name (path->name); }
/* FIXME: maybe we can support different encoding for different mount points? */ char* fm_path_display_basename(FmPath* path) { if(G_UNLIKELY(!path->parent)) /* root element */ { if( !fm_path_is_native(path) && fm_path_is_virtual(path) ) { if(fm_path_is_trash_root(path)) return g_strdup(_("Trash Can")); if(g_str_has_prefix(path->name, "computer:/")) return g_strdup(_("My Computer")); if(g_str_has_prefix(path->name, "applications:/")) return g_strdup(_("Applications")); if(g_str_has_prefix(path->name, "network:/")) return g_strdup(_("Network")); } } return g_filename_display_name(path->name); }
/** * fm_dnd_dest_get_default_action * @dd FmDndDest object * @target GdkTarget of the target data type * @dest FmFileInfo of the destination file at drop site. * * Returns the default action to take for the dragged files. */ GdkDragAction fm_dnd_dest_get_default_action(FmDndDest* dd, GdkDragContext* drag_context, GdkTarget target) { GdkDragAction action; FmFileInfo* dest = dd->dest_file; if(!dest || !dest->path) return FALSE; /* this is XDirectSave */ if(target == xds_target_atom) return GDK_ACTION_COPY; if(dd->src_files) /* we have got drag source files */ { FmPath* dest_path = dest->path; if(fm_path_is_trash(dest_path)) { if(fm_path_is_trash_root(dest_path)) /* we can only move files to trash can */ action = GDK_ACTION_MOVE; else /* files inside trash are read only */ action = 0; } else if(fm_path_is_virtual(dest_path)) { /* computer:/// and network:/// shouldn't received dropped files. */ /* FIXME: some special handling can be done with menu:// */ action = 0; } else if(list_contains_path(dd->src_files, dest_path)) { /* don't allow dropping files into themselves */ action = 0; } else /* dest is a ordinary path */ { /* determine if the dragged files are on the same device as destination file */ /* Here we only check the first dragged file since checking all of them can * make the operation very slow. */ gboolean same_fs; if(dd->src_dev || dd->src_fs_id) /* we know the device of dragged source files */ { /* compare the device/filesystem id against that of destination file */ if(fm_path_is_native(dest_path)) same_fs = dd->src_dev && (dd->src_dev == dest->dev); else /* FIXME: can we use direct comparison here? */ same_fs = dd->src_fs_id && (0 == g_strcmp0(dd->src_fs_id, dest->fs_id)); action = same_fs ? GDK_ACTION_MOVE : GDK_ACTION_COPY; } else /* we don't know on which device the dragged source files are. */ action = 0; } } else /* we didn't have any data */ { action = 0; if(!dd->waiting_data) /* we're still waiting for "drag-data-received" signal */ { /* retrieve the source files */ gtk_drag_get_data(dd->widget, drag_context, target, time); dd->waiting_data = TRUE; } } if( action && 0 == (drag_context->actions & action) ) action = drag_context->suggested_action; return action; }
/********************************************************************* * ... * * ********************************************************************/ gboolean fm_file_info_job_run (FmJob *fmjob) { FmFileInfoJob *job = (FmFileInfoJob*) fmjob; GError *err = NULL; GList *l; for (l = fm_list_peek_head_link (job->file_infos); !fm_job_is_cancelled (fmjob) && l; ) { FmFileInfo *file_info = (FmFileInfo*) l->data; GList *next = l->next; job->current = file_info->path; if (fm_path_is_native (file_info->path)) { char *path_str = fm_path_to_str (file_info->path); // FileInfo rework: new function for testing... // this one is not cancellable and doesn't handle errors... // if (!fm_file_info_job_get_info_for_native_file (FM_JOB (job), file_info, path_str, &err)) if (!fm_file_info_set_for_native_file (file_info, path_str)) { //~ FmJobErrorAction act = fm_job_emit_error (FM_JOB(job), err, FM_JOB_ERROR_MILD); //~ //~ g_error_free (err); //~ err = NULL; //~ //~ if (act == FM_JOB_RETRY) //~ continue; DEBUG ("fm_file_info_set_for_native_file: error reading %s\n", path_str); next = l->next; fm_list_delete_link (job->file_infos, l); // Also calls unref... } g_free (path_str); } else { GFile *gf; if (fm_path_is_virtual (file_info->path)) { // This is a xdg menu if (fm_path_is_xdg_menu (file_info->path)) { MenuCache *mc; MenuCacheDir *dir; char *path_str = fm_path_to_str (file_info->path); char *menu_name = path_str + 5, ch; char *dir_name; while (*menu_name == '/') ++menu_name; dir_name = menu_name; while (*dir_name && *dir_name != '/') ++dir_name; ch = *dir_name; *dir_name = '\0'; menu_name = g_strconcat (menu_name, ".menu", NULL); mc = menu_cache_lookup_sync (menu_name); g_free (menu_name); if (*dir_name && !(*dir_name == '/' && dir_name[1] == '\0')) { char *tmp = g_strconcat ("/", menu_cache_item_get_id (MENU_CACHE_ITEM(menu_cache_get_root_dir (mc))), dir_name, NULL); dir = menu_cache_get_dir_from_path (mc, tmp); g_free (tmp); } else { dir = menu_cache_get_root_dir (mc); } if (dir) { fm_file_info_set_from_menu_cache_item (file_info, (MenuCacheItem*) dir); } else { next = l->next; fm_list_delete_link (job->file_infos, l); // Also calls unref... } g_free (path_str); menu_cache_unref (mc); l = l->next; continue; } } gf = fm_path_to_gfile (file_info->path); if (!fm_file_info_job_get_info_for_gfile (FM_JOB (job), file_info, gf, &err)) { FmJobErrorAction act = fm_job_emit_error (FM_JOB (job), err, FM_JOB_ERROR_MILD); g_error_free (err); err = NULL; if (act == FM_JOB_RETRY) continue; next = l->next; fm_list_delete_link (job->file_infos, l); // Also calls unref... } g_object_unref (gf); } l = next; } return TRUE; }