static const char * _icon_cache_get_icon_key (GIcon * icon) { const char * key = NULL; if (G_IS_THEMED_ICON (icon)) { char ** icon_names; char * name; g_object_get (icon, "names", &icon_names, NULL); name = g_strjoinv (",", icon_names); key = get_static_string (name); g_free (name); g_strfreev (icon_names); } else if (G_IS_FILE_ICON (icon)) { GFile * file; char * filename; file = g_file_icon_get_file (G_FILE_ICON (icon)); filename = g_file_get_path (file); key = get_static_string (filename); g_free (filename); g_object_unref (file); } return key; }
static void gth_metadata_provider_file_read (GthMetadataProvider *self, GthFileData *file_data, const char *attributes) { GFileAttributeMatcher *matcher; char *value; GTimeVal *timeval_p; const char *value_s; matcher = g_file_attribute_matcher_new (attributes); value = g_format_size_for_display (g_file_info_get_size (file_data->info)); g_file_info_set_attribute_string (file_data->info, "gth::file::display-size", value); g_free (value); timeval_p = gth_file_data_get_modification_time (file_data); value = _g_time_val_strftime (timeval_p, "%x %X"); g_file_info_set_attribute_string (file_data->info, "gth::file::display-mtime", value); g_free (value); value = g_file_get_parse_name (file_data->file); g_file_info_set_attribute_string (file_data->info, "gth::file::full-name", value); g_free (value); value_s = get_static_string (g_file_info_get_content_type (file_data->info)); if (value_s != NULL) g_file_info_set_attribute_string (file_data->info, "gth::file::content-type", value_s); g_file_attribute_matcher_unref (matcher); }
FileData * file_data_dup (FileData *source) { FileData *fd; if (source == NULL) return NULL; fd = g_new0 (FileData, 1); fd->ref = 1; fd->path = g_strdup (source->path); fd->name = file_name_from_path (fd->path); fd->display_name = g_strdup (source->display_name); fd->mime_type = get_static_string (source->mime_type); fd->size = source->size; fd->ctime = source->ctime; fd->mtime = source->mtime; fd->exif_data_loaded = source->exif_data_loaded; fd->exif_time = source->exif_time; fd->error = source->error; fd->thumb_loaded = source->thumb_loaded; fd->thumb_created = source->thumb_created; fd->comment = (source->comment != NULL) ? g_strdup (source->comment) : NULL; fd->comment_data = comment_data_dup (source->comment_data); return fd; }
static void base_fr_command_set_mime_type (FrCommand *comm, const char *mime_type) { comm->mime_type = get_static_string (mime_type); fr_command_update_capabilities (comm); }
const char * gtr_get_mime_type_from_filename (const char * file) { char * tmp = g_content_type_guess (file, NULL, 0, NULL); const char * ret = get_static_string (tmp); g_free (tmp); return ret; }
const char * get_mime_type_from_extension (const char *ext) { int i; if (ext == NULL) return NULL; for (i = G_N_ELEMENTS (file_ext_type) - 1; i >= 0; i--) { if (file_ext_type[i].ext == NULL) continue; if (strcasecmp (ext, file_ext_type[i].ext) == 0) return get_static_string (file_ext_type[i].mime_type); } return NULL; }
FileData * file_data_new (const char *path, GnomeVFSFileInfo *info) { FileData *fd; fd = g_new0 (FileData, 1); fd->ref = 1; fd->path = add_scheme_if_absent (path); fd->name = file_name_from_path (fd->path); fd->display_name = gnome_vfs_unescape_string_for_display (fd->name); if (info != NULL) { if (info->valid_fields | GNOME_VFS_FILE_INFO_FIELDS_SIZE) fd->size = info->size; if (info->valid_fields | GNOME_VFS_FILE_INFO_FIELDS_CTIME) fd->ctime = info->ctime; if (info->valid_fields | GNOME_VFS_FILE_INFO_FIELDS_MTIME) fd->mtime = info->mtime; if (info->valid_fields | GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE) fd->mime_type = get_static_string (info->mime_type); } else { fd->size = (GnomeVFSFileSize) 0; fd->ctime = (time_t) 0; fd->mtime = (time_t) 0; } /* The Exif DateTime tag is only recorded on an as-needed basis during DateTime sorts. The tag in memory is refreshed if the file mtime has changed, so it is recorded as well. */ fd->exif_data_loaded = FALSE; fd->exif_time = 0; fd->error = FALSE; fd->thumb_loaded = FALSE; fd->thumb_created = FALSE; fd->comment = g_strdup (""); return fd; }
void file_data_update (FileData *fd) { GnomeVFSFileInfo *info; GnomeVFSResult result; g_return_if_fail (fd != NULL); fd->error = FALSE; fd->thumb_loaded = FALSE; fd->thumb_created = FALSE; info = gnome_vfs_file_info_new (); result = gnome_vfs_get_file_info (fd->path, info, (GNOME_VFS_FILE_INFO_FOLLOW_LINKS | GNOME_VFS_FILE_INFO_GET_MIME_TYPE | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE)); if (result != GNOME_VFS_OK) { fd->error = TRUE; fd->size = 0L; fd->mtime = 0; fd->ctime = 0; fd->exif_data_loaded = FALSE; fd->mime_type = NULL; return; } fd->name = file_name_from_path (fd->path); g_free (fd->display_name); fd->display_name = gnome_vfs_unescape_string_for_display (fd->name); fd->mime_type = get_static_string (info->mime_type); fd->size = info->size; fd->mtime = info->mtime; fd->ctime = info->ctime; fd->exif_data_loaded = FALSE; gnome_vfs_file_info_unref (info); }
FrRegisteredCommand * fr_registered_command_new (GType command_type) { FrRegisteredCommand *reg_com; FrCommand *command; const char **mime_types; int i; reg_com = g_new0 (FrRegisteredCommand, 1); reg_com->ref = 1; reg_com->type = command_type; reg_com->caps = g_ptr_array_new (); reg_com->packages = g_ptr_array_new (); command = (FrCommand*) g_object_new (reg_com->type, NULL); mime_types = fr_command_get_mime_types (command); for (i = 0; mime_types[i] != NULL; i++) { const char *mime_type; FrMimeTypeCap *cap; FrMimeTypePackages *packages; mime_type = get_static_string (mime_types[i]); cap = g_new0 (FrMimeTypeCap, 1); cap->mime_type = mime_type; cap->current_capabilities = fr_command_get_capabilities (command, mime_type, TRUE); cap->potential_capabilities = fr_command_get_capabilities (command, mime_type, FALSE); g_ptr_array_add (reg_com->caps, cap); packages = g_new0 (FrMimeTypePackages, 1); packages->mime_type = mime_type; packages->packages = fr_command_get_packages (command, mime_type); g_ptr_array_add (reg_com->packages, packages); } g_object_unref (command); return reg_com; }
switch ( icon_size ) { case GTK_ICON_SIZE_MENU: n = 1; break; case GTK_ICON_SIZE_SMALL_TOOLBAR: n = 2; break; case GTK_ICON_SIZE_LARGE_TOOLBAR: n = 3; break; case GTK_ICON_SIZE_BUTTON: n = 4; break; case GTK_ICON_SIZE_DND: n = 5; break; case GTK_ICON_SIZE_DIALOG: n = 6; break; default /*GTK_ICON_SIZE_INVALID*/: n = 0; break; } if( icon_cache[n] == NULL ) icon_cache[n] = icon_cache_new( for_widget, icon_size ); return icon_cache_get_mime_type_icon( icon_cache[n], mime_type ); } const char * gtr_get_mime_type_from_filename( const char * file G_GNUC_UNUSED ) { #ifdef USE_GIO_ICONS char * tmp = g_content_type_guess( file, NULL, 0, NULL ); const char * ret = get_static_string( tmp ); g_free( tmp ); return ret; #else return "uncertain"; #endif }