static void file_view_show_extended_data (AnjutaFileView* view, GtkTreeIter* iter) { AnjutaFileViewPrivate* priv = ANJUTA_FILE_VIEW_GET_PRIVATE (view); GtkTreeModel* file_model = GTK_TREE_MODEL (priv->model); gboolean is_dummy, is_dir; GFile* file; GFileInfo* file_info; time_t time; gchar* display; gchar time_str[128]; AnjutaVcsStatus status; gtk_tree_model_get (file_model, iter, COLUMN_DUMMY, &is_dummy, COLUMN_IS_DIR, &is_dir, -1); if (is_dummy || is_dir) return; gtk_tree_model_get (file_model, iter, COLUMN_FILE, &file, COLUMN_STATUS, &status, -1); file_info = g_file_query_info (file, "standard::*,time::changed", G_FILE_QUERY_INFO_NONE, NULL, NULL); g_object_unref (file); if (!file_info) return; time = g_file_info_get_attribute_uint64(file_info, "time::changed"); strftime(time_str, 127, "%x %X", localtime(&time)); if (get_status_string(status)) { display = g_markup_printf_escaped("%s\n" "<small><tt>%s</tt></small>\n" "<small>%s</small>", g_file_info_get_display_name(file_info), time_str, get_status_string(status)); } else { display = g_markup_printf_escaped("%s\n" "<small><tt>%s</tt></small>", g_file_info_get_display_name(file_info), time_str); } gtk_tree_store_set (GTK_TREE_STORE(file_model), iter, COLUMN_DISPLAY, display, -1); g_object_unref (file_info); g_free(display); }
gboolean populate_files (gpointer data) //TODO:: show an spinner while loading { FilebrowserBackend *filebackend= FILEBROWSER_BACKEND(data); FilebrowserBackendDetails *directory = FILEBROWSER_BACKEND_GET_PRIVATE(filebackend); GDK_THREADS_ENTER(); if (g_cancellable_is_cancelled (directory->cancellable)){ GDK_THREADS_LEAVE(); return FALSE; /* remove source */ } GError *error=NULL; GFileInfo *info = g_file_enumerator_next_file (directory->enumerator, directory->cancellable, &error); if (info){ const gchar *mime= g_file_info_get_content_type (info); if (!g_file_info_get_is_hidden (info) && !g_file_info_get_is_backup (info)){ if (MIME_ISDIR(mime)){ //if has dot in name pos 0 don't process const gchar *folder=g_file_info_get_display_name(info); if(folder[0]!='.'){ FOLDERFILE *current; current=new_folderfile(); current->mime=g_strdup(mime); GIcon *icon =g_file_info_get_icon(info); current->icon= g_icon_to_string (icon); current->display_name=g_strdup(folder); /* add to list */ directory->filesinfolder = g_slist_append(directory->filesinfolder, current); } } else { if (IS_TEXT(mime) && !IS_APPLICATION(mime)){ //files FOLDERFILE *current; current=new_folderfile(); current->mime=g_strdup(mime); GIcon *icon =g_file_info_get_icon(info); current->icon= g_icon_to_string (icon); current->display_name=g_strdup(g_file_info_get_display_name(info)); /* add to list */ directory->filesinfolder = g_slist_append(directory->filesinfolder, current); } } } g_object_unref(info); } else { if (error){ g_print(_("Error::%s"),error->message); g_error_free (error); } GDK_THREADS_LEAVE(); return FALSE; /* remove source */ } GDK_THREADS_LEAVE(); return TRUE; }
static void pixbuf_task_progress_cb (GthTask *task, const char *description, const char *details, gboolean pulse, double fraction, gpointer user_data) { GthPixbufListTask *self = user_data; double total_fraction; double file_fraction; total_fraction = ((double) self->priv->n_current + 1) / (self->priv->n_files + 1); if (pulse) file_fraction = 0.5; else file_fraction = fraction; if (details == NULL) { GthFileData *file_data; file_data = self->priv->current->data; details = g_file_info_get_display_name (file_data->info); } gth_task_progress (GTH_TASK (self), description, details, FALSE, total_fraction + (file_fraction / (self->priv->n_files + 1))); }
const gchar * rstto_file_get_display_name ( RsttoFile *r_file ) { GFileInfo *file_info = NULL; const gchar *display_name; if ( NULL == r_file->priv->display_name ) { file_info = g_file_query_info ( r_file->priv->file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, 0, NULL, NULL ); if ( NULL != file_info ) { display_name = g_file_info_get_display_name (file_info); if ( NULL != display_name ) { r_file->priv->display_name = g_strdup (display_name); } g_object_unref (file_info); } } return (const gchar *)r_file->priv->display_name; }
static gboolean _fm_file_ops_job_check_paths(FmFileOpsJob* job, GFile* src, GFileInfo* src_inf, GFile* dest) { GError* err = NULL; FmJob* fmjob = FM_JOB(job); if(job->type == FM_FILE_OP_MOVE && g_file_equal(src, dest)) { err = g_error_new_literal(G_IO_ERROR, G_IO_ERROR_FAILED, _("Source and destination are the same.")); } else if(g_file_info_get_file_type(src_inf) == G_FILE_TYPE_DIRECTORY && g_file_has_prefix(dest, src) ) { const char* msg = NULL; if(job->type == FM_FILE_OP_MOVE) msg = _("Cannot move a folder into its sub folder"); else if(job->type == FM_FILE_OP_COPY) msg = _("Cannot copy a folder into its sub folder"); else msg = _("Destination is a sub folder of source"); err = g_error_new_literal(G_IO_ERROR, G_IO_ERROR_FAILED, msg); } if(err) { if(!fm_job_is_cancelled(fmjob)) { fm_file_ops_job_emit_cur_file(job, g_file_info_get_display_name(src_inf)); fm_job_emit_error(fmjob, err, FM_JOB_ERROR_CRITICAL); } g_error_free(err); } return (err == NULL); }
static void upload_photo_wrote_body_data_cb (SoupMessage *msg, SoupBuffer *chunk, gpointer user_data) { PicasaWebService *self = user_data; GthFileData *file_data; char *details; double current_file_fraction; if (self->priv->post_photos->current == NULL) return; self->priv->post_photos->wrote_body_data_size += chunk->length; if (self->priv->post_photos->wrote_body_data_size > msg->request_body->length) return; file_data = self->priv->post_photos->current->data; /* Translators: %s is a filename */ details = g_strdup_printf (_("Uploading '%s'"), g_file_info_get_display_name (file_data->info)); current_file_fraction = (double) self->priv->post_photos->wrote_body_data_size / msg->request_body->length; gth_task_progress (GTH_TASK (self), NULL, details, FALSE, (double) (self->priv->post_photos->uploaded_size + (g_file_info_get_size (file_data->info) * current_file_fraction)) / self->priv->post_photos->total_size); g_free (details); }
static char * shell_util_get_file_display_name (GFile *file, gboolean use_fallback) { GFileInfo *info; char *ret; ret = NULL; info = g_file_query_info (file, "standard::display-name", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL); if (info) { ret = g_strdup (g_file_info_get_display_name (info)); g_object_unref (info); } if (!ret && use_fallback) { /* can happen with URI schemes non supported by gvfs */ char *basename; basename = g_file_get_basename (file); ret = g_filename_display_name (basename); g_free (basename); } return ret; }
static void _gth_media_viewer_page_update_caption (GthMediaViewerPage *self) { if (self->priv->caption_layout == NULL) return; if (self->priv->file_data != NULL) { const char *text; GthMetadata *metadata; text = NULL; metadata = (GthMetadata *) g_file_info_get_attribute_object (self->priv->file_data->info, "general::title"); if (metadata != NULL) text = gth_metadata_get_formatted (metadata); else text = g_file_info_get_display_name (self->priv->file_data->info); if (text != NULL) pango_layout_set_text (self->priv->caption_layout, text, -1); } else pango_layout_set_text (self->priv->caption_layout, "", -1); gtk_widget_queue_draw (GTK_WIDGET (self->priv->area)); }
static char * get_display_name (GFile *file) { GFileInfo *info; char *name, *tmp; /* This does sync I/O, which isn't ideal. * It should probably use the NautilusFile machinery */ name = NULL; info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, 0, NULL, NULL); if (info) { name = g_strdup (g_file_info_get_display_name (info)); g_object_unref (info); } if (name == NULL) { name = g_file_get_basename (file); if (!g_utf8_validate (name, -1, NULL)) { tmp = name; name = g_uri_escape_string (name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE); g_free (tmp); } } return name; }
void _gtk_css_section_print (const GtkCssSection *section, GString *string) { if (section->file) { GFileInfo *info; info = g_file_query_info (section->file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, 0, NULL, NULL); if (info) { g_string_append (string, g_file_info_get_display_name (info)); g_object_unref (info); } else { g_string_append (string, "<broken file>"); } } else { g_string_append (string, "<data>"); } g_string_append_printf (string, ":%u:%u", gtk_css_section_get_end_line (section) + 1, gtk_css_section_get_end_position (section)); }
void gth_browser_activate_action_catalog_remove (GtkAction *action, GthBrowser *browser) { GthFileData *file_data; GSettings *settings; file_data = gth_browser_get_folder_popup_file_data (browser); settings = g_settings_new (GTHUMB_MESSAGES_SCHEMA); if (g_settings_get_boolean (settings, PREF_MSG_CONFIRM_DELETION)) { char *prompt; GtkWidget *d; prompt = g_strdup_printf (_("Are you sure you want to remove \"%s\"?"), g_file_info_get_display_name (file_data->info)); d = _gtk_message_dialog_new (GTK_WINDOW (browser), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_QUESTION, prompt, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_REMOVE, GTK_RESPONSE_YES, NULL); g_signal_connect (d, "response", G_CALLBACK (remove_catalog_response_cb), file_data); gtk_widget_show (d); g_free (prompt); } else { remove_catalog (GTK_WINDOW (browser), file_data); g_object_unref (file_data); } g_object_unref (settings); }
static MediaInfo* media_from_file(gchar *path, GFileInfo *file_info, const gchar *file_mime) { MediaInfo* media; ID3Tag *tag = NULL; media = malloc(sizeof(MediaInfo)); memset(media, 0, sizeof(MediaInfo)); tag = ID3Tag_New(); ID3Tag_Link(tag, path); if (tag) { set_field(&(media->title), tag, ID3FN_TEXT, ID3FID_TITLE); set_field(&(media->artist), tag, ID3FN_TEXT, ID3FID_LEADARTIST); set_field(&(media->album), tag, ID3FN_TEXT, ID3FID_ALBUM); set_field(&(media->genre), tag, ID3FN_TEXT, ID3FID_CONTENTTYPE); } if (!media->title) media->title = g_strdup(g_file_info_get_display_name(file_info)); media->path = g_strdup(path); media->mime = g_strdup(file_mime); if (tag) ID3Tag_Delete(tag); return media; }
/* * Called for each file in a directory. Checks if the file is some * sort of image. If so, it creates an image object and adds it to the * list. */ static void directory_visit (GFile *directory, GFileInfo *children_info, EogListStore *store) { GFile *child; gboolean load_uri = FALSE; const char *mime_type, *name; mime_type = g_file_info_get_content_type (children_info); name = g_file_info_get_name (children_info); if (!g_str_has_prefix (name, ".")) { if (eog_image_is_supported_mime_type (mime_type)) { load_uri = TRUE; } } if (load_uri) { const gchar *caption; child = g_file_get_child (directory, name); caption = g_file_info_get_display_name (children_info); eog_list_store_append_image_from_file (store, child, caption); } }
static void iterate_contacts (TpChannel *channel, GArray *handles, char **argv) { GError *error = NULL; int i; for (i = 0; i < handles->len; i++) { int handle = g_array_index (handles, int, i); /* FIXME: we should check that our client has the * FT capability */ /* begin ex.filetransfer.sending.gfileinfo */ GFile *file = g_file_new_for_commandline_arg (argv[3]); GFileInfo *info = g_file_query_info (file, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, &error); handle_error (error); GHashTable *props = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, handle, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_FILENAME, G_TYPE_STRING, g_file_info_get_display_name (info), TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_TYPE, G_TYPE_STRING, g_file_info_get_content_type (info), TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_SIZE, G_TYPE_UINT64, g_file_info_get_size (info), NULL); tp_cli_connection_interface_requests_call_create_channel ( conn, -1, props, create_ft_channel_cb, NULL, NULL, NULL); g_hash_table_destroy (props); g_object_unref (info); g_object_unref (file); /* end ex.filetransfer.sending.gfileinfo */ } }
static SoupBuffer * webkit_soup_directory_input_stream_parse_info (WebKitSoupDirectoryInputStream * stream, GFileInfo * info) { SoupBuffer *buffer; GString *string; const char *s; char *escaped, *path, *xml_string; if (!g_file_info_get_name (info)) return NULL; s = g_file_info_get_display_name (info); if (!s) { s = g_file_info_get_name (info); /* FIXME: convert somehow? */ if (!g_utf8_validate (s, -1, NULL)) return NULL; } string = g_string_new ("<tr>"); xml_string = g_markup_escape_text (s, -1); escaped = g_uri_escape_string (g_file_info_get_name (info), NULL, FALSE); path = g_strconcat (stream->uri, "/", escaped, NULL); g_free (escaped); g_string_append_printf (string, "<td><a href=\"%s\">%s</a></td>", path, xml_string); g_free (path); g_free (xml_string); g_string_append (string, "</tr>"); buffer = soup_buffer_new (SOUP_MEMORY_TAKE, string->str, string->len); g_string_free (string, FALSE); return buffer; }
static void upload_photos_done (FacebookService *self, GError *error) { GSimpleAsyncResult *result; result = facebook_connection_get_result (self->priv->conn); if (error == NULL) { self->priv->post_photos->ids = g_list_reverse (self->priv->post_photos->ids); g_simple_async_result_set_op_res_gpointer (result, self->priv->post_photos->ids, (GDestroyNotify) _g_string_list_free); self->priv->post_photos->ids = NULL; } else { if (self->priv->post_photos->current != NULL) { GthFileData *file_data = self->priv->post_photos->current->data; char *msg; msg = g_strdup_printf (_("Could not upload '%s': %s"), g_file_info_get_display_name (file_data->info), error->message); g_free (error->message); error->message = msg; } g_simple_async_result_set_from_error (result, error); } g_simple_async_result_complete_in_idle (result); }
static void _gth_media_viewer_page_update_caption (GthMediaViewerPage *self) { if (self->priv->caption_layout == NULL) return; if (self->priv->file_data != NULL) { GString *description; GthMetadata *metadata; description = g_string_new (""); metadata = (GthMetadata *) g_file_info_get_attribute_object (self->priv->file_data->info, "general::title"); if (metadata != NULL) { g_string_append (description, gth_metadata_get_formatted (metadata)); metadata = (GthMetadata *) g_file_info_get_attribute_object (self->priv->file_data->info, "audio-video::general::artist"); if (metadata != NULL) { g_string_append (description, "\n"); g_string_append (description, gth_metadata_get_formatted (metadata)); } } else g_string_append (description, g_file_info_get_display_name (self->priv->file_data->info)); pango_layout_set_text (self->priv->caption_layout, description->str, -1); g_string_free (description, TRUE); } else pango_layout_set_text (self->priv->caption_layout, "", -1); gtk_widget_queue_draw (GTK_WIDGET (self->priv->area)); }
static void ft_handler_gfile_ready_cb (GObject *source, GAsyncResult *res, CallbacksData *cb_data) { GFileInfo *info; GError *error = NULL; GTimeVal mtime; EmpathyFTHandlerPriv *priv = GET_PRIV (cb_data->handler); DEBUG ("Got GFileInfo."); info = g_file_query_info_finish (priv->gfile, res, &error); if (error != NULL) goto out; if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR) { error = g_error_new_literal (EMPATHY_FT_ERROR_QUARK, EMPATHY_FT_ERROR_INVALID_SOURCE_FILE, _("The selected file is not a regular file")); goto out; } priv->total_bytes = g_file_info_get_size (info); if (priv->total_bytes == 0) { error = g_error_new_literal (EMPATHY_FT_ERROR_QUARK, EMPATHY_FT_ERROR_EMPTY_SOURCE_FILE, _("The selected file is empty")); goto out; } priv->content_type = g_strdup (g_file_info_get_content_type (info)); priv->filename = g_strdup (g_file_info_get_display_name (info)); g_file_info_get_modification_time (info, &mtime); priv->mtime = mtime.tv_sec; priv->transferred_bytes = 0; priv->description = NULL; g_object_unref (info); out: if (error != NULL) { if (!g_cancellable_is_cancelled (priv->cancellable)) g_cancellable_cancel (priv->cancellable); cb_data->callback (cb_data->handler, error, cb_data->user_data); g_error_free (error); callbacks_data_free (cb_data); } else { /* see if FT/hashing are allowed */ check_hashing (cb_data); } }
static GArray * _get_ref_frame_cache (GstValidateSsim * self, const gchar * ref_file) { GFile *ref_dir_file = NULL; GFileInfo *info; GFileEnumerator *fenum; GArray *frames = NULL; gchar *ref_dir = NULL; ref_dir = g_path_get_dirname (ref_file); frames = g_hash_table_lookup (self->priv->ref_frames_cache, ref_file); if (frames) goto done; ref_dir_file = g_file_new_for_path (ref_dir); if (!(fenum = g_file_enumerate_children (ref_dir_file, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, NULL))) { GST_INFO ("%s is not a folder", ref_dir); goto done; } for (info = g_file_enumerator_next_file (fenum, NULL, NULL); info; info = g_file_enumerator_next_file (fenum, NULL, NULL)) { Frame iframe; const gchar *display_name = g_file_info_get_display_name (info); if (!_filename_get_timestamp (self, display_name, &iframe.ts)) { g_object_unref (info); continue; } iframe.path = g_build_path (G_DIR_SEPARATOR_S, ref_dir, g_file_info_get_name (info), NULL); g_object_unref (info); if (!frames) { frames = g_array_new (TRUE, TRUE, sizeof (Frame)); g_array_set_clear_func (frames, (GDestroyNotify) _free_frame); } g_array_append_val (frames, iframe); } if (frames) { g_array_sort (frames, (GCompareFunc) _sort_frames); g_hash_table_insert (self->priv->ref_frames_cache, g_strdup (ref_dir), frames); } done: g_clear_object (&ref_dir_file); g_free (ref_dir); return frames; }
/* Search the documentation pages for the string 'text', building the index if necessary */ void i7_search_window_search_documentation(I7SearchWindow *self) { GError *err; if(doc_index == NULL) { /* documentation index hasn't been built yet */ GFile *doc_file = i7_app_get_data_file_va(i7_app_get(), "Documentation", NULL); GFileEnumerator *docdir; if((docdir = g_file_enumerate_children(doc_file, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, &err)) == NULL) { IO_ERROR_DIALOG(GTK_WINDOW(self), doc_file, err, _("opening documentation directory")); g_object_unref(doc_file); return; } start_spinner(self); GFileInfo *info; while((info = g_file_enumerator_next_file(docdir, NULL, &err)) != NULL) { const char *basename = g_file_info_get_name(info); const char *displayname = g_file_info_get_display_name(info); if(!g_str_has_suffix(basename, ".html") || (!g_str_has_prefix(basename, "doc") && !g_str_has_prefix(basename, "Rdoc"))) continue; char *label = g_strdup_printf(_("Please be patient, indexing %s..."), displayname); gtk_label_set_text(GTK_LABEL(self->search_text), label); g_free(label); while(gtk_events_pending()) gtk_main_iteration(); GFile *file = g_file_get_child(doc_file, basename); GSList *doctexts = html_to_ascii(file, g_str_has_prefix(basename, "R")); g_object_unref(file); if(doctexts != NULL) { GSList *iter; /* Append the entries to the documentation index and search them right now while we're at it */ for(iter = doctexts; iter != NULL; iter = g_slist_next(iter)) { doc_index = g_list_prepend(doc_index, iter->data); search_documentation(iter->data, self); } g_slist_free(doctexts); } } g_object_unref(doc_file); stop_spinner(self); update_label(self); } else { start_spinner(self); g_list_foreach(doc_index, (GFunc)search_documentation, self); stop_spinner(self); } return; }
void locke_appmanager_scan_for_deploys(LockeAppManager *lam, GFile *deployDir) { if (g_file_query_file_type(deployDir, G_FILE_QUERY_INFO_NONE, NULL) != G_FILE_TYPE_DIRECTORY) { g_log(LSVR_DOMAIN, G_LOG_LEVEL_WARNING, "Hey, autodeploy dir '%s' does not exist!! Create it to be able to make deploys. ", g_file_get_path(deployDir)); return; } g_log(LSVR_DOMAIN, G_LOG_LEVEL_INFO, "Scanning folder '%s' for application deployments", g_file_get_path(deployDir)); /* Get file enumerator */ GError *err = NULL; GFileEnumerator *files = g_file_enumerate_children(deployDir, "*", G_FILE_QUERY_INFO_NONE, NULL, &err); if (err != NULL) { /* Report error to user, and free error */ g_log(LSVR_DOMAIN, G_LOG_LEVEL_ERROR, "Unable to get file list for directory '%s': %s", g_file_get_path(deployDir), err->message); g_error_free(err); goto scan_for_deploys_finally; } /* process each file individually */ GFileInfo *fileInfo = NULL; do { fileInfo = g_file_enumerator_next_file(files, NULL, &err); if (err != NULL) { /* Report error to user, and free error */ g_log(LSVR_DOMAIN, G_LOG_LEVEL_ERROR, "Unable to get file for directory '%s': %s", g_file_get_path(deployDir), err->message); g_error_free(err); goto scan_for_deploys_finally; } /* stop condition */ if (fileInfo == NULL) break; /* finally, process the file */ g_log(LSVR_DOMAIN, G_LOG_LEVEL_INFO, " =========> Processing file '%s'", g_file_info_get_display_name(fileInfo)); locke_appmanager_add_application(lam, g_file_get_path(deployDir), g_file_info_get_name(fileInfo)); } while (TRUE); /* Close open things */ g_file_enumerator_close(files, NULL, &err); if (err != NULL) { /* Report error to user, and free error */ g_log(LSVR_DOMAIN, G_LOG_LEVEL_ERROR, "Error closing file enumerator for directory '%s': %s", g_file_get_path(deployDir), err->message); g_error_free(err); goto scan_for_deploys_finally; } /* Free allocated memory */ scan_for_deploys_finally: g_object_unref(files); }
const gchar * ide_project_file_get_name (IdeProjectFile *self) { IdeProjectFilePrivate *priv = ide_project_file_get_instance_private (self); const gchar *name; g_return_val_if_fail (IDE_IS_PROJECT_FILE (self), NULL); name = g_file_info_get_display_name (priv->file_info); if (name == NULL) name = g_file_info_get_name (priv->file_info); return name; }
static void add_themes_from_dir (DialogData *data, GFile *dir) { GFileEnumerator *enumerator; GFileInfo *file_info; enumerator = g_file_enumerate_children (dir, (G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME), G_FILE_QUERY_INFO_NONE, NULL, NULL); if (enumerator == NULL) return; while ((file_info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) { GFile *file; char *filename; GdkPixbuf *preview; if (g_file_info_get_file_type (file_info) != G_FILE_TYPE_DIRECTORY) { g_object_unref (file_info); continue; } file = _g_file_get_child (dir, g_file_info_get_name (file_info), "preview.png", NULL); filename = g_file_get_path (file); preview = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL); if (preview != NULL) { GtkTreeIter iter; gtk_list_store_append (GTK_LIST_STORE (GET_WIDGET ("theme_liststore")), &iter); gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("theme_liststore")), &iter, THEME_COLUMN_ID, g_file_info_get_name (file_info), THEME_COLUMN_NAME, g_file_info_get_display_name (file_info), THEME_COLUMN_PREVIEW, preview, -1); } g_object_unref (preview); g_free (filename); g_object_unref (file); g_object_unref (file_info); } g_object_unref (enumerator); }
static void set_current_destination_file (GthPixbufListTask *self) { GthFileData *file_data; char *display_name; GFile *parent; GFile *destination; file_data = self->priv->current->data; if (self->priv->mime_type != NULL) { char *no_ext; GthPixbufSaver *saver; no_ext = _g_uri_remove_extension (g_file_info_get_display_name (file_data->info)); saver = gth_main_get_pixbuf_saver (self->priv->mime_type); g_return_if_fail (saver != NULL); display_name = g_strconcat (no_ext, ".", gth_pixbuf_saver_get_default_ext (saver), NULL); gth_file_data_set_mime_type (file_data, self->priv->mime_type); g_object_unref (saver); g_free (no_ext); } else display_name = g_strdup (g_file_info_get_display_name (file_data->info)); if (self->priv->destination_folder != NULL) parent = g_object_ref (self->priv->destination_folder); else parent = g_file_get_parent (file_data->file); destination = g_file_get_child_for_display_name (parent, display_name, NULL); gth_file_data_set_file (file_data, destination); g_object_unref (destination); g_object_unref (parent); g_free (display_name); }
static const gchar * xfdesktop_special_file_icon_peek_label(XfdesktopIcon *icon) { XfdesktopSpecialFileIcon *special_file_icon = XFDESKTOP_SPECIAL_FILE_ICON(icon); GFileInfo *info = special_file_icon->priv->file_info; if(XFDESKTOP_SPECIAL_FILE_ICON_HOME == special_file_icon->priv->type) return _("Home"); else if(XFDESKTOP_SPECIAL_FILE_ICON_FILESYSTEM == special_file_icon->priv->type) return _("File System"); else if(XFDESKTOP_SPECIAL_FILE_ICON_TRASH == special_file_icon->priv->type) return _("Trash"); else return info ? g_file_info_get_display_name(info) : NULL; }
static void update_entry_point_list (GthLocationChooser *self) { int first_position; int position; GList *entry_points; GList *scan; self->priv->update_entry_list_id = 0; clear_entry_point_list (self); if (! get_nth_separator_pos (self, 1, &first_position)) { GtkTreeIter iter; GtkTreePath *path; gtk_tree_store_append (self->priv->model, &iter, NULL); gtk_tree_store_set (self->priv->model, &iter, TYPE_COLUMN, ITEM_TYPE_SEPARATOR, -1); path = gtk_tree_model_get_path (GTK_TREE_MODEL (self->priv->model), &iter); if (path == NULL) return; first_position = gtk_tree_path_get_indices(path)[0]; gtk_tree_path_free (path); } position = first_position + 1; entry_points = gth_main_get_all_entry_points (); for (scan = entry_points; scan; scan = scan->next) { GthFileData *file_data = scan->data; add_file_source_entries (self, file_data->file, g_file_info_get_display_name (file_data->info), g_file_info_get_symbolic_icon (file_data->info), position++, FALSE, ITEM_TYPE_ENTRY_POINT); } _g_object_list_unref (entry_points); }
static void update_location_list (gpointer user_data) { GthLocationChooser *self = user_data; GtkTreeIter iter; self->priv->update_location_list_id = 0; if (self->priv->location == NULL) return; if (get_iter_from_current_file_entries (self, self->priv->location, &iter)) { g_signal_handlers_block_by_func (self->priv->combo, combo_changed_cb, self); gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->priv->combo), &iter); g_signal_handlers_unblock_by_func (self->priv->combo, combo_changed_cb, self); } else { GList *list; GList *scan; int position = 0; delete_current_file_entries (self); list = gth_file_source_get_current_list (self->priv->file_source, self->priv->location); for (scan = list; scan; scan = scan->next) { GFile *file = scan->data; GFileInfo *info; info = gth_file_source_get_file_info (self->priv->file_source, file, GFILE_DISPLAY_ATTRIBUTES); if (info == NULL) continue; add_file_source_entries (self, file, g_file_info_get_display_name (info), g_file_info_get_symbolic_icon (info), position++, TRUE, ITEM_TYPE_LOCATION); g_object_unref (info); } _g_object_list_unref (list); } }
ChupaData * chupa_data_new_from_file(GFile *file, ChupaMetadata *metadata, GError **error) { ChupaData *data; GInputStream *stream; GFileInfo *info; stream = G_INPUT_STREAM(g_file_read(file, NULL, error)); if (!stream) return NULL; if (!metadata) metadata = chupa_metadata_new(); info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, NULL, NULL); if (info) { chupa_metadata_set_content_length(metadata, g_file_info_get_size(info)); g_object_unref(info); } info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, 0, NULL, NULL); if (info) { chupa_metadata_set_string(metadata, meta_filename, g_file_info_get_display_name(info)); g_object_unref(info); } if (!chupa_metadata_get_path(metadata)) { gchar *path; path = g_file_get_path(file); if (path) { chupa_metadata_set_path(metadata, path); g_free(path); } } data = chupa_data_new(stream, metadata); g_object_unref(stream); g_object_unref(metadata); return data; }
static void set_display_name (SourceviewIO* sio) { GFileInfo* file_info = g_file_query_info (sio->file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (file_info) { g_free (sio->filename); sio->filename = g_strdup(g_file_info_get_display_name (file_info)); } else { g_free (sio->filename); sio->filename = NULL; } g_object_unref (file_info); }
static void progress_cb (gpgme_data_t data, goffset pos, FilesCtx *ctx) { gdouble total, done, size, portion; goffset fsize; g_assert (ctx && ctx->cur); total = ctx->total > ONE_GIGABYTE ? ctx->total / 1000 : ctx->total; done = ctx->total > ONE_GIGABYTE ? ctx->done / 1000 : ctx->done; fsize = g_file_info_get_size (ctx->cur->info); size = ctx->total > ONE_GIGABYTE ? fsize / 1000 : fsize; portion = ctx->total > ONE_GIGABYTE ? pos / 1000 : pos; total = total <= 0 ? 1 : total; size = size <= 0 ? 1 : size; /* The cancel check is done elsewhere */ seahorse_tool_progress_update ((done / total) + ((size / total) * (portion / size)), seahorse_util_uri_get_last (g_file_info_get_display_name (ctx->cur->info))); }