gchar * get_file_type_description (const gchar * file, GFileInfo * file_info) { const char * content_type = NULL; gchar * desc; if (file != NULL) { content_type = g_file_info_get_content_type (file_info); } if (content_type == NULL || g_content_type_is_unknown (content_type) == TRUE) { return g_strdup (g_content_type_get_description ("application/octet-stream")); } desc = g_strdup (g_content_type_get_description (content_type)); if (g_file_info_get_is_symlink (file_info) == TRUE) { const gchar * symlink_target; gchar * absolute_symlink = NULL; gchar * str = NULL; symlink_target = g_file_info_get_symlink_target (file_info); if (g_path_is_absolute (symlink_target) != TRUE) { gchar *dirname; dirname = g_path_get_dirname (file); absolute_symlink = g_strconcat (dirname, G_DIR_SEPARATOR_S, symlink_target, NULL); g_free (dirname); } else { absolute_symlink = g_strdup (symlink_target); } if (g_file_test (absolute_symlink, G_FILE_TEST_EXISTS) != TRUE) { if ((g_ascii_strcasecmp (content_type, "x-special/socket") != 0) && (g_ascii_strcasecmp (content_type, "x-special/fifo") != 0)) { g_free (absolute_symlink); g_free (desc); return g_strdup (_("link (broken)")); } } str = g_strdup_printf (_("link to %s"), (desc != NULL) ? desc : content_type); g_free (absolute_symlink); g_free (desc); return str; } return desc; }
static void nemo_mime_application_chooser_apply_labels (NemoMimeApplicationChooser *chooser) { gchar *label, *extension = NULL, *description = NULL; if (chooser->details->files != NULL) { /* here we assume all files are of the same content type */ if (g_content_type_is_unknown (chooser->details->content_type)) { extension = get_extension_from_file (NEMO_FILE (chooser->details->files->data)); /* the %s here is a file extension */ description = g_strdup_printf (_("%s document"), extension); } else { description = g_content_type_get_description (chooser->details->content_type); } label = g_strdup_printf (_("Open all files of type \"%s\" with"), description); } else { GFile *file; gchar *basename, *emname; file = g_file_new_for_uri (chooser->details->uri); basename = g_file_get_basename (file); if (g_content_type_is_unknown (chooser->details->content_type)) { extension = get_extension (basename); /* the %s here is a file extension */ description = g_strdup_printf (_("%s document"), extension); } else { description = g_content_type_get_description (chooser->details->content_type); } /* first %s is filename, second %s is mime-type description */ emname = g_strdup_printf ("<i>%s</i>", basename); label = g_strdup_printf (_("Select an application in the list to open %s and other files of type \"%s\""), emname, description); g_free (emname); g_free (basename); g_object_unref (file); } gtk_label_set_markup (GTK_LABEL (chooser->details->label), label); g_free (label); g_free (extension); g_free (description); }
static void add_no_applications_label (GtkAppChooserWidget *self) { gchar *text = NULL, *desc = NULL; const gchar *string; GtkTreeIter iter; if (self->priv->default_text == NULL) { if (self->priv->content_type) desc = g_content_type_get_description (self->priv->content_type); string = text = g_strdup_printf (_("No applications available to open \"%s\""), desc); g_free (desc); } else { string = self->priv->default_text; } gtk_list_store_append (self->priv->program_list_store, &iter); gtk_list_store_set (self->priv->program_list_store, &iter, COLUMN_HEADING_TEXT, string, COLUMN_HEADING, TRUE, -1); g_free (text); }
void dlg_package_installer (FrWindow *window, FrArchive *archive, FrAction action) { InstallerData *idata; GType command_type; FrCommand *command; idata = g_new0 (InstallerData, 1); idata->window = g_object_ref (window); idata->archive = g_object_ref (archive); idata->action = action; command_type = get_preferred_command_for_mime_type (idata->archive->content_type, FR_COMMAND_CAN_READ_WRITE); if (command_type == 0) command_type = get_preferred_command_for_mime_type (idata->archive->content_type, FR_COMMAND_CAN_READ); if (command_type == 0) { package_installer_terminated (idata, FR_PROC_ERROR_GENERIC, _("Archive type not supported.")); return; } command = g_object_new (command_type, 0); idata->packages = fr_command_get_packages (command, idata->archive->content_type); g_object_unref (command); if (idata->packages == NULL) { package_installer_terminated (idata, FR_PROC_ERROR_GENERIC, _("Archive type not supported.")); return; } #ifdef ENABLE_PACKAGEKIT { char *secondary_text; GtkWidget *dialog; secondary_text = g_strdup_printf (_("There is no command installed for %s files.\nDo you want to search for a command to open this file?"), g_content_type_get_description (idata->archive->content_type)); dialog = _gtk_message_dialog_new (GTK_WINDOW (idata->window), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_ERROR, _("Could not open this file type"), secondary_text, GTK_STOCK_CANCEL, GTK_RESPONSE_NO, _("_Search Command"), GTK_RESPONSE_YES, NULL); g_signal_connect (dialog, "response", G_CALLBACK (confirm_search_dialog_response_cb), idata); gtk_widget_show (dialog); g_free (secondary_text); } #else /* ! ENABLE_PACKAGEKIT */ package_installer_terminated (idata, FR_PROC_ERROR_GENERIC, _("Archive type not supported.")); #endif /* ENABLE_PACKAGEKIT */ }
QString File_list_model::get_mime_description(QString mime_type) { if (mime_type.isEmpty()) return tr("Unknown"); if (mime_descriptions.contains(mime_type)) return mime_descriptions[mime_type]; gchar* mime_description = g_content_type_get_description(mime_type.toLocal8Bit()); QString r = QString::fromLocal8Bit(mime_description); g_free(mime_description); mime_descriptions.insert(mime_type, r); return r; }
static void on_content_type_finished(GObject* src_obj, GAsyncResult* res, gpointer user_data) { AutoRun* data = (AutoRun*)user_data; GMount* mount = G_MOUNT(src_obj); char** types; char* desc = NULL; types = g_mount_guess_content_type_finish(mount, res, NULL); if(types) { GtkTreeIter it; GList* apps = NULL, *l; char** type; if(types[0]) { for(type=types;*type;++type) { l = g_app_info_get_all_for_type(*type); if(l) apps = g_list_concat(apps, l); } desc = g_content_type_get_description(types[0]); } g_strfreev(types); if(apps) { int pos = 0; GtkTreePath* tp; for(l = apps; l; l=l->next, ++pos) { GAppInfo* app = G_APP_INFO(l->data); gtk_list_store_insert_with_values(data->store, &it, pos, 0, g_app_info_get_icon(app), 1, g_app_info_get_name(app), 2, app, -1); g_object_unref(app); } g_list_free(apps); gtk_tree_model_get_iter_first(GTK_TREE_MODEL(data->store), &it); gtk_tree_selection_select_iter(gtk_tree_view_get_selection(data->view), &it); tp = gtk_tree_path_new_first(); gtk_tree_view_set_cursor(data->view, tp, NULL, FALSE); gtk_tree_path_free(tp); } } if(desc) { gtk_label_set_text(data->type, desc); g_free(desc); } else gtk_label_set_text(data->type, _("Removable Disk")); }
char* rb_mime_get_friendly_name (const char *mime_type) { gchar *name = NULL; if (name == NULL && mime_type) name = g_content_type_get_description (mime_type); if (name == NULL) name = _("Unknown"); return name; }
static void photos_base_item_default_update_type_description (PhotosBaseItem *self) { PhotosBaseItemPrivate *priv = self->priv; gchar *description = NULL; if (priv->collection) description = g_strdup (_("Album")); else if (priv->mime_type != NULL) description = g_content_type_get_description (priv->mime_type); priv->type_description = description; }
void rejilla_mime_filter_add_mime (RejillaMimeFilter *filter, const gchar *mime) { GtkFileFilter *item; item = g_hash_table_lookup (filter->priv->table, mime); if (!item) { GIcon *icon; GtkTreeIter row; gchar *description; GtkTreeModel *model; description = g_content_type_get_description (mime); icon = g_content_type_get_icon (mime); /* create the GtkFileFilter */ item = gtk_file_filter_new (); gtk_file_filter_set_name (item, mime); gtk_file_filter_add_mime_type (item, mime); g_hash_table_insert (filter->priv->table, g_strdup (mime), item); g_object_add_toggle_ref (G_OBJECT (item), (GToggleNotify) rejilla_mime_filter_destroy_item_cb, filter); model = gtk_combo_box_get_model (GTK_COMBO_BOX (filter->combo)); gtk_list_store_append (GTK_LIST_STORE (model), &row); g_object_ref_sink (item); gtk_list_store_set (GTK_LIST_STORE (model), &row, REJILLA_MIME_FILTER_DISPLAY_COL, description, REJILLA_MIME_FILTER_ICON_COL, icon, REJILLA_MIME_FILTER_FILTER_COL, item, -1); g_object_unref (icon); g_free (description); /* we check that the first entry at least is visible */ if (gtk_combo_box_get_active (GTK_COMBO_BOX (filter->combo)) == -1 && gtk_tree_model_get_iter_first (model, &row) == TRUE) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (filter->combo), &row); } else g_object_ref (item); }
static char * nautilus_canvas_view_container_get_icon_description (NautilusCanvasContainer *container, NautilusCanvasIconData *data) { NautilusFile *file; char *mime_type; const char *description; file = NAUTILUS_FILE (data); g_assert (NAUTILUS_IS_FILE (file)); mime_type = nautilus_file_get_mime_type (file); description = g_content_type_get_description (mime_type); g_free (mime_type); return g_strdup (description); }
static char * nemo_icon_view_container_get_icon_description (NemoIconContainer *container, NemoIconData *data) { NemoFile *file; char *mime_type; const char *description; file = NEMO_FILE (data); g_assert (NEMO_IS_FILE (file)); if (NEMO_IS_DESKTOP_ICON_FILE (file)) { return NULL; } mime_type = nemo_file_get_mime_type (file); description = g_content_type_get_description (mime_type); g_free (mime_type); return g_strdup (description); }
NS_IMETHODIMP nsGIOService::GetDescriptionForMimeType(const nsACString& aMimeType, nsACString& aDescription) { char *content_type = get_content_type_from_mime_type(PromiseFlatCString(aMimeType).get()); if (!content_type) return NS_ERROR_FAILURE; char *desc = g_content_type_get_description(content_type); if (!desc) { g_free(content_type); return NS_ERROR_FAILURE; } aDescription.Assign(desc); g_free(content_type); g_free(desc); return NS_OK; }
static void nautilus_mime_application_chooser_apply_labels (NautilusMimeApplicationChooser *chooser) { gchar *label, *extension = NULL, *description = NULL; gint num_files; NautilusFile *file; num_files = g_list_length (chooser->details->files); file = chooser->details->files->data; /* here we assume all files are of the same content type */ if (g_content_type_is_unknown (chooser->details->content_type)) { extension = nautilus_file_get_extension (file); /* Translators: the %s here is a file extension */ description = g_strdup_printf (_("%s document"), extension); } else { description = g_content_type_get_description (chooser->details->content_type); } if (num_files > 1) { /* Translators; %s here is a mime-type description */ label = g_strdup_printf (_("Open all files of type “%s” with"), description); } else { gchar *display_name; display_name = nautilus_file_get_display_name (file); /* Translators: first %s is filename, second %s is mime-type description */ label = g_strdup_printf (_("Select an application to open “%s” and other files of type “%s”"), display_name, description); g_free (display_name); } gtk_label_set_markup (GTK_LABEL (chooser->details->label), label); g_free (label); g_free (extension); g_free (description); }
static char * fm_icon_container_get_icon_description (CajaIconContainer *container, CajaIconData *data) { CajaFile *file; char *mime_type; const char *description; file = CAJA_FILE (data); g_assert (CAJA_IS_FILE (file)); if (CAJA_IS_DESKTOP_ICON_FILE (file)) { return NULL; } mime_type = caja_file_get_mime_type (file); description = g_content_type_get_description (mime_type); g_free (mime_type); return g_strdup (description); }
static void update_no_applications_label (GtkAppChooserWidget *self) { gchar *text = NULL, *desc = NULL; const gchar *string; if (self->priv->default_text == NULL) { if (self->priv->content_type) desc = g_content_type_get_description (self->priv->content_type); string = text = g_strdup_printf (_("No applications found for “%s”."), desc); g_free (desc); } else { string = self->priv->default_text; } gtk_label_set_text (GTK_LABEL (self->priv->no_apps_label), string); g_free (text); }
void vnr_properties_dialog_update(VnrPropertiesDialog *dialog) { const gchar *filetype = NULL; goffset filesize = 0; gchar *filetype_desc = NULL; gchar *filesize_str = NULL; get_file_info ((gchar*)VNR_FILE(dialog->vnr_win->file_list->data)->path, &filesize, &filetype); if(filetype == NULL && filesize == 0) { vnr_properties_dialog_clear(dialog); return; } vnr_properties_dialog_update_image(dialog); vnr_properties_dialog_update_metadata(dialog); filesize_str = g_format_size (filesize); filetype_desc = g_content_type_get_description (filetype); gtk_label_set_text(GTK_LABEL(dialog->name_label), (gchar*)VNR_FILE(dialog->vnr_win->file_list->data)->display_name); gtk_label_set_text(GTK_LABEL(dialog->location_label), (gchar*)VNR_FILE(dialog->vnr_win->file_list->data)->path); gtk_label_set_text(GTK_LABEL(dialog->type_label), filetype_desc); gtk_label_set_text(GTK_LABEL(dialog->size_label), filesize_str); g_free(filesize_str); g_free((gchar*)filetype); g_free(filetype_desc); }
static void nautilus_file_management_properties_dialog_setup_media_page (GladeXML *xml_dialog) { unsigned int n; GList *l; GList *content_types; GtkWidget *other_type_combo_box; GtkListStore *other_type_list_store; GtkCellRenderer *renderer; GtkTreeIter iter; const char *s[] = {"media_audio_cdda_combobox", "x-content/audio-cdda", "media_video_dvd_combobox", "x-content/video-dvd", "media_music_player_combobox", "x-content/audio-player", "media_dcf_combobox", "x-content/image-dcf", "media_software_combobox", "x-content/software", NULL}; for (n = 0; s[n*2] != NULL; n++) { nautilus_autorun_prepare_combo_box (glade_xml_get_widget (xml_dialog, s[n*2]), s[n*2 + 1], TRUE, TRUE, NULL, NULL); } other_type_combo_box = glade_xml_get_widget (xml_dialog, "media_other_type_combobox"); other_type_list_store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (other_type_list_store), 1, GTK_SORT_ASCENDING); content_types = g_content_types_get_registered (); for (l = content_types; l != NULL; l = l->next) { char *content_type = l->data; char *description; GIcon *icon; NautilusIconInfo *icon_info; GdkPixbuf *pixbuf; int icon_size; if (!g_str_has_prefix (content_type, "x-content/")) continue; for (n = 0; s[n*2] != NULL; n++) { if (strcmp (content_type, s[n*2 + 1]) == 0) { goto skip; } } icon_size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); description = g_content_type_get_description (content_type); gtk_list_store_append (other_type_list_store, &iter); icon = g_content_type_get_icon (content_type); if (icon != NULL) { icon_info = nautilus_icon_info_lookup (icon, icon_size); g_object_unref (icon); pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (icon_info, icon_size); g_object_unref (icon_info); } else { pixbuf = NULL; } gtk_list_store_set (other_type_list_store, &iter, 0, pixbuf, 1, description, 2, content_type, -1); if (pixbuf != NULL) g_object_unref (pixbuf); g_free (description); skip: ; } g_list_foreach (content_types, (GFunc) g_free, NULL); g_list_free (content_types); gtk_combo_box_set_model (GTK_COMBO_BOX (other_type_combo_box), GTK_TREE_MODEL (other_type_list_store)); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (other_type_combo_box), renderer, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (other_type_combo_box), renderer, "pixbuf", 0, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (other_type_combo_box), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (other_type_combo_box), renderer, "text", 1, NULL); g_signal_connect (G_OBJECT (other_type_combo_box), "changed", G_CALLBACK (other_type_combo_box_changed), glade_xml_get_widget (xml_dialog, "media_other_action_combobox")); gtk_combo_box_set_active (GTK_COMBO_BOX (other_type_combo_box), 0); nautilus_file_management_properties_dialog_update_media_sensitivity (xml_dialog); }
/* * get_document_from_uri: * @uri: the document URI * @fast: whether to use fast MIME type detection * @compression: a location to store the document's compression type * @error: a #GError location to store an error, or %NULL * * Creates a #EvDocument instance for the document at @uri, using either * fast or slow MIME type detection. If a document could be created, * @compression is filled in with the document's compression type. * On error, %NULL is returned and @error filled in. * * Returns: a new #EvDocument instance, or %NULL on error with @error filled in */ static EvDocument * get_document_from_uri (const char *uri, gboolean fast, EvCompressionType *compression, GError **error) { EvDocument *document = NULL; gchar *mime_type = NULL; GError *err = NULL; *compression = EV_COMPRESSION_NONE; mime_type = ev_file_get_mime_type (uri, fast, &err); if (mime_type == NULL) { g_free (mime_type); if (err == NULL) { g_set_error_literal (error, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, _("Unknown MIME Type")); } else { g_propagate_error (error, err); } return NULL; } document = ev_backends_manager_get_document (mime_type); #ifdef ENABLE_PIXBUF if (!document && mime_type_supported_by_gdk_pixbuf (mime_type)) document = ev_backends_manager_get_document ("image/*"); #endif /* ENABLE_PIXBUF */ if (document == NULL) { gchar *content_type, *mime_desc = NULL; content_type = g_content_type_from_mime_type (mime_type); if (content_type) mime_desc = g_content_type_get_description (content_type); g_set_error (error, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, _("File type %s (%s) is not supported"), mime_desc ? mime_desc : "-", mime_type); g_free (mime_desc); g_free (content_type); g_free (mime_type); return NULL; } *compression = get_compression_from_mime_type (mime_type); g_free (mime_type); return document; }
void xfburn_directory_browser_load_path (XfburnDirectoryBrowser * browser, const gchar * path) { XfburnDirectoryBrowserPrivate *priv = XFBURN_DIRECTORY_BROWSER_GET_PRIVATE (browser); GtkTreeModel *model; GDir *dir; GError *error = NULL; GdkPixbuf *icon_directory, *icon_file; const gchar *dir_entry; int x, y; gchar *temp; GdkScreen *screen; GtkIconTheme *icon_theme; gboolean show_hidden; dir = g_dir_open (path, 0, &error); if (!dir) { g_warning ("unable to open the %s directory : %s", path, error->message); g_error_free (error); return; } temp = g_strdup (path); g_free (priv->current_path); priv->current_path = temp; model = gtk_tree_view_get_model (GTK_TREE_VIEW (browser)); gtk_list_store_clear (GTK_LIST_STORE (model)); screen = gtk_widget_get_screen (GTK_WIDGET (browser)); icon_theme = gtk_icon_theme_get_for_screen (screen); gtk_icon_size_lookup (GTK_ICON_SIZE_SMALL_TOOLBAR, &x, &y); icon_directory = gtk_icon_theme_load_icon (icon_theme, "gnome-fs-directory", x, 0, NULL); icon_file = gtk_icon_theme_load_icon (icon_theme, "gnome-fs-regular", x, 0, NULL); show_hidden = xfburn_settings_get_boolean ("show-hidden-files", FALSE); while ((dir_entry = g_dir_read_name (dir))) { gchar *full_path; struct stat s; if (dir_entry[0] == '.') { /* skip . and .. */ if (dir_entry[1] == '\0' || (dir_entry[1] == '.' && dir_entry[2] == '\0')) continue; if (!show_hidden) continue; } full_path = g_build_filename (path, dir_entry, NULL); #if 0 if (g_file_test (full_path, G_FILE_TEST_IS_SYMLINK)) { g_free (full_path); continue; } #endif if (stat (full_path, &s) == 0) { gchar *humansize; gchar *path_utf8; GError *conv_error = NULL; /* from the g_dir_read_name () docs: most of the time Linux stores filenames in utf8, but older versions might not, so convert here */ path_utf8 = g_filename_to_utf8 (full_path, -1, NULL, NULL, &conv_error); if (!path_utf8 || conv_error) { g_warning ("Failed to convert filename '%s' to utf8: %s. Falling back to native encoding.", full_path, conv_error->message); path_utf8 = g_strdup (full_path); if (conv_error) g_error_free (conv_error); } humansize = xfburn_humanreadable_filesize (s.st_size); if ((s.st_mode & S_IFDIR)) { GtkTreeIter iter; gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, DIRECTORY_BROWSER_COLUMN_ICON, icon_directory, DIRECTORY_BROWSER_COLUMN_FILE, dir_entry, DIRECTORY_BROWSER_COLUMN_HUMANSIZE, humansize, DIRECTORY_BROWSER_COLUMN_SIZE, (guint64) s.st_size, DIRECTORY_BROWSER_COLUMN_TYPE, _(DIRECTORY), DIRECTORY_BROWSER_COLUMN_PATH, path_utf8, -1); } else if ((s.st_mode & S_IFREG)) { GtkTreeIter iter; GFileInfo *mime_info = NULL; GIcon *mime_icon = NULL; GdkPixbuf *mime_icon_pixbuf = NULL; const gchar *mime_str = NULL; GFile *file = NULL; const gchar *content_type = NULL; gtk_list_store_append (GTK_LIST_STORE (model), &iter); file = g_file_new_for_path(path_utf8); mime_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); content_type = g_file_info_get_content_type (mime_info); mime_str = g_content_type_get_description (content_type); mime_icon = g_content_type_get_icon (content_type); if (mime_icon != NULL) { GtkIconInfo *icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, mime_icon, x, GTK_ICON_LOOKUP_USE_BUILTIN); if (icon_info != NULL) { mime_icon_pixbuf = gtk_icon_info_load_icon (icon_info, NULL); gtk_icon_info_free (icon_info); } g_object_unref (mime_icon); } gtk_list_store_set (GTK_LIST_STORE (model), &iter, DIRECTORY_BROWSER_COLUMN_ICON, (G_IS_OBJECT (mime_icon_pixbuf) ? mime_icon_pixbuf : icon_file), DIRECTORY_BROWSER_COLUMN_FILE, dir_entry, DIRECTORY_BROWSER_COLUMN_HUMANSIZE, humansize, DIRECTORY_BROWSER_COLUMN_SIZE, (guint64) s.st_size, DIRECTORY_BROWSER_COLUMN_TYPE, mime_str, DIRECTORY_BROWSER_COLUMN_PATH, path_utf8, -1); g_object_unref(file); } g_free (humansize); g_free (path_utf8); } g_free (full_path); } if (icon_directory) g_object_unref (icon_directory); if (icon_file) g_object_unref (icon_file); g_dir_close (dir); }
static void set_dialog_properties (GtkAppChooserDialog *self) { gchar *label; gchar *name; gchar *extension; gchar *description; gchar *default_text; gchar *string; gboolean unknown; PangoFontDescription *font_desc; name = NULL; extension = NULL; label = NULL; description = NULL; unknown = TRUE; if (self->priv->gfile != NULL) { name = g_file_get_basename (self->priv->gfile); extension = get_extension (name); } if (self->priv->content_type) { description = g_content_type_get_description (self->priv->content_type); unknown = g_content_type_is_unknown (self->priv->content_type); } gtk_window_set_title (GTK_WINDOW (self), ""); if (name != NULL) { /* Translators: %s is a filename */ label = g_strdup_printf (_("Select an application to open \"%s\""), name); string = g_strdup_printf (_("No applications available to open \"%s\""), name); } else { /* Translators: %s is a file type description */ label = g_strdup_printf (_("Select an application for \"%s\" files"), unknown ? self->priv->content_type : description); string = g_strdup_printf (_("No applications available to open \"%s\" files"), unknown ? self->priv->content_type : description); } font_desc = pango_font_description_new (); pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD); gtk_widget_override_font (self->priv->label, font_desc); pango_font_description_free (font_desc); if (self->priv->heading != NULL) gtk_label_set_markup (GTK_LABEL (self->priv->label), self->priv->heading); else gtk_label_set_markup (GTK_LABEL (self->priv->label), label); default_text = g_strdup_printf ("<big><b>%s</b></big>\n%s", string, _("Click \"Show other applications\", for more options, or " "\"Find applications online\" to install a new application")); gtk_app_chooser_widget_set_default_text (GTK_APP_CHOOSER_WIDGET (self->priv->app_chooser_widget), default_text); g_free (label); g_free (name); g_free (extension); g_free (description); g_free (string); g_free (default_text); }
static void set_dialog_properties (GtkAppChooserDialog *self) { gchar *name; gchar *extension; gchar *description; gchar *string; gboolean unknown; gchar *title; gchar *subtitle; gboolean use_header; GtkWidget *header; name = NULL; extension = NULL; description = NULL; unknown = TRUE; if (self->priv->gfile != NULL) { name = g_file_get_basename (self->priv->gfile); extension = get_extension (name); } if (self->priv->content_type) { description = g_content_type_get_description (self->priv->content_type); unknown = g_content_type_is_unknown (self->priv->content_type); } if (name != NULL) { title = g_strdup (_("Select Application")); /* Translators: %s is a filename */ subtitle = g_strdup_printf (_("Opening “%s”."), name); string = g_strdup_printf (_("No applications found for “%s”"), name); } else { title = g_strdup (_("Select Application")); /* Translators: %s is a file type description */ subtitle = g_strdup_printf (_("Opening “%s” files."), unknown ? self->priv->content_type : description); string = g_strdup_printf (_("No applications found for “%s” files"), unknown ? self->priv->content_type : description); } g_object_get (self, "use-header-bar", &use_header, NULL); if (use_header) { header = gtk_dialog_get_header_bar (GTK_DIALOG (self)); gtk_header_bar_set_title (GTK_HEADER_BAR (header), title); gtk_header_bar_set_subtitle (GTK_HEADER_BAR (header), subtitle); } else { gtk_window_set_title (GTK_WINDOW (self), _("Select Application")); } if (self->priv->heading != NULL) { gtk_label_set_markup (GTK_LABEL (self->priv->label), self->priv->heading); gtk_widget_show (self->priv->label); } else { gtk_widget_hide (self->priv->label); } gtk_app_chooser_widget_set_default_text (GTK_APP_CHOOSER_WIDGET (self->priv->app_chooser_widget), string); g_free (title); g_free (subtitle); g_free (name); g_free (extension); g_free (description); g_free (string); }
static EvDocument * ev_document_factory_new_document_for_mime_type (const gchar *mime_type, GError **error) { EvDocument *document; EvBackendInfo *info; GTypeModule *module = NULL; g_return_val_if_fail (mime_type != NULL, NULL); info = get_backend_info_for_mime_type (mime_type); if (info == NULL) { char *content_type, *mime_desc = NULL; content_type = g_content_type_from_mime_type (mime_type); if (content_type) mime_desc = g_content_type_get_description (content_type); g_set_error (error, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, _("File type %s (%s) is not supported"), mime_desc ? mime_desc : "(unknown)", mime_type); g_free (mime_desc); g_free (content_type); return NULL; } if (ev_module_hash != NULL) { module = g_hash_table_lookup (ev_module_hash, info->module_name); } if (module == NULL) { gchar *path; path = g_module_build_path (ev_backends_dir, info->module_name); module = G_TYPE_MODULE (_ev_module_new (path, info->resident)); g_free (path); if (ev_module_hash == NULL) { ev_module_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL /* leaked on purpose */); } g_hash_table_insert (ev_module_hash, g_strdup (info->module_name), module); } if (!g_type_module_use (module)) { const char *err; err = g_module_error (); g_set_error (error, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, "Failed to load backend for '%s': %s", mime_type, err ? err : "unknown error"); return NULL; } document = EV_DOCUMENT (_ev_module_new_object (EV_MODULE (module))); g_type_module_unuse (module); g_object_set_data_full (G_OBJECT (document), BACKEND_DATA_KEY, _ev_backend_info_ref (info), (GDestroyNotify) _ev_backend_info_unref); return document; }
static void add_face_info(GtkWidget *table, gint *row_p, const gchar *uri, FT_Face face) { gchar *s; GFile *file; GFileInfo *info; PS_FontInfoRec ps_info; add_row(table, row_p, _("Name:"), face->family_name, FALSE, FALSE); if (face->style_name) add_row(table, row_p, _("Style:"), face->style_name, FALSE, FALSE); file = g_file_new_for_uri (uri); info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE, NULL, NULL); g_object_unref (file); if (info) { s = g_content_type_get_description (g_file_info_get_content_type (info)); add_row (table, row_p, _("Type:"), s, FALSE, FALSE); g_free (s); s = g_format_size (g_file_info_get_size (info)); add_row (table, row_p, _("Size:"), s, FALSE, FALSE); g_free (s); g_object_unref (info); } if (FT_IS_SFNT(face)) { gint i, len; gchar *version = NULL, *copyright = NULL, *description = NULL; len = FT_Get_Sfnt_Name_Count(face); for (i = 0; i < len; i++) { FT_SfntName sname; if (FT_Get_Sfnt_Name(face, i, &sname) != 0) continue; /* only handle the unicode names for US langid */ if (!(sname.platform_id == TT_PLATFORM_MICROSOFT && sname.encoding_id == TT_MS_ID_UNICODE_CS && sname.language_id == TT_MS_LANGID_ENGLISH_UNITED_STATES)) continue; switch (sname.name_id) { case TT_NAME_ID_COPYRIGHT: g_free(copyright); copyright = g_convert((gchar *)sname.string, sname.string_len, "UTF-8", "UTF-16BE", NULL, NULL, NULL); break; case TT_NAME_ID_VERSION_STRING: g_free(version); version = g_convert((gchar *)sname.string, sname.string_len, "UTF-8", "UTF-16BE", NULL, NULL, NULL); break; case TT_NAME_ID_DESCRIPTION: g_free(description); description = g_convert((gchar *)sname.string, sname.string_len, "UTF-8", "UTF-16BE", NULL, NULL, NULL); break; default: break; } } if (version) { add_row(table, row_p, _("Version:"), version, FALSE, FALSE); g_free(version); } if (copyright) { add_row(table, row_p, _("Copyright:"), copyright, TRUE, TRUE); g_free(copyright); } if (description) { add_row(table, row_p, _("Description:"), description, TRUE, TRUE); g_free(description); } } else if (FT_Get_PS_Font_Info(face, &ps_info) == 0) { if (ps_info.version && g_utf8_validate(ps_info.version, -1, NULL)) add_row(table, row_p, _("Version:"), ps_info.version, FALSE, FALSE); if (ps_info.notice && g_utf8_validate(ps_info.notice, -1, NULL)) add_row(table, row_p, _("Copyright:"), ps_info.notice, TRUE, FALSE); } }
/* returns TRUE if a folder window should be opened */ static gboolean do_autorun_for_content_type (GMount *mount, const char *x_content_type, CajaAutorunOpenWindow open_window_func, gpointer user_data) { AutorunDialogData *data; GtkWidget *dialog; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *label; GtkWidget *combo_box; GtkWidget *always_check_button; GtkWidget *eject_button; GtkWidget *image; char *markup; char *content_description; char *mount_name; GIcon *icon; GdkPixbuf *pixbuf; CajaIconInfo *icon_info; int icon_size; gboolean user_forced_dialog; gboolean pref_ask; gboolean pref_start_app; gboolean pref_ignore; gboolean pref_open_folder; char *media_greeting; gboolean ret; ret = FALSE; mount_name = NULL; if (g_content_type_is_a (x_content_type, "x-content/win32-software")) { /* don't pop up the dialog anyway if the content type says * windows software. */ goto out; } user_forced_dialog = is_shift_pressed (); caja_autorun_get_preferences (x_content_type, &pref_start_app, &pref_ignore, &pref_open_folder); pref_ask = !pref_start_app && !pref_ignore && !pref_open_folder; if (user_forced_dialog) { goto show_dialog; } if (!pref_ask && !pref_ignore && !pref_open_folder) { GAppInfo *app_info; app_info = g_app_info_get_default_for_type (x_content_type, FALSE); if (app_info != NULL) { caja_autorun_launch_for_mount (mount, app_info); } goto out; } if (pref_open_folder) { ret = TRUE; goto out; } if (pref_ignore) { goto out; } show_dialog: mount_name = g_mount_get_name (mount); dialog = gtk_dialog_new (); hbox = gtk_hbox_new (FALSE, 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); icon = g_mount_get_icon (mount); icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_DIALOG); icon_info = caja_icon_info_lookup (icon, icon_size); pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size); g_object_unref (icon_info); g_object_unref (icon); image = gtk_image_new_from_pixbuf (pixbuf); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, 0); /* also use the icon on the dialog */ gtk_window_set_title (GTK_WINDOW (dialog), mount_name); gtk_window_set_icon (GTK_WINDOW (dialog), pixbuf); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); g_object_unref (pixbuf); vbox = gtk_vbox_new (FALSE, 12); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); label = gtk_label_new (NULL); /* Customize greeting for well-known x-content types */ if (strcmp (x_content_type, "x-content/audio-cdda") == 0) { media_greeting = _("You have just inserted an Audio CD."); } else if (strcmp (x_content_type, "x-content/audio-dvd") == 0) { media_greeting = _("You have just inserted an Audio DVD."); } else if (strcmp (x_content_type, "x-content/video-dvd") == 0) { media_greeting = _("You have just inserted a Video DVD."); } else if (strcmp (x_content_type, "x-content/video-vcd") == 0) { media_greeting = _("You have just inserted a Video CD."); } else if (strcmp (x_content_type, "x-content/video-svcd") == 0) { media_greeting = _("You have just inserted a Super Video CD."); } else if (strcmp (x_content_type, "x-content/blank-cd") == 0) { media_greeting = _("You have just inserted a blank CD."); } else if (strcmp (x_content_type, "x-content/blank-dvd") == 0) { media_greeting = _("You have just inserted a blank DVD."); } else if (strcmp (x_content_type, "x-content/blank-cd") == 0) { media_greeting = _("You have just inserted a blank Blu-Ray disc."); } else if (strcmp (x_content_type, "x-content/blank-cd") == 0) { media_greeting = _("You have just inserted a blank HD DVD."); } else if (strcmp (x_content_type, "x-content/image-photocd") == 0) { media_greeting = _("You have just inserted a Photo CD."); } else if (strcmp (x_content_type, "x-content/image-picturecd") == 0) { media_greeting = _("You have just inserted a Picture CD."); } else if (strcmp (x_content_type, "x-content/image-dcf") == 0) { media_greeting = _("You have just inserted a medium with digital photos."); } else if (strcmp (x_content_type, "x-content/audio-player") == 0) { media_greeting = _("You have just inserted a digital audio player."); } else if (g_content_type_is_a (x_content_type, "x-content/software")) { media_greeting = _("You have just inserted a medium with software intended to be automatically started."); } else { /* fallback to generic greeting */ media_greeting = _("You have just inserted a medium."); } markup = g_strdup_printf ("<big><b>%s %s</b></big>", media_greeting, _("Choose what application to launch.")); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); label = gtk_label_new (NULL); content_description = g_content_type_get_description (x_content_type); markup = g_strdup_printf (_("Select how to open \"%s\" and whether to perform this action in the future for other media of type \"%s\"."), mount_name, content_description); g_free (content_description); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); data = g_new0 (AutorunDialogData, 1); data->dialog = dialog; data->mount = g_object_ref (mount); data->remember = !pref_ask; data->selected_ignore = pref_ignore; data->x_content_type = g_strdup (x_content_type); data->selected_app = g_app_info_get_default_for_type (x_content_type, FALSE); data->open_window_func = open_window_func; data->user_data = user_data; combo_box = gtk_combo_box_new (); caja_autorun_prepare_combo_box (combo_box, x_content_type, FALSE, TRUE, FALSE, autorun_combo_changed, data); g_signal_connect (G_OBJECT (combo_box), "key-press-event", G_CALLBACK (combo_box_enter_ok), dialog); gtk_box_pack_start (GTK_BOX (vbox), combo_box, TRUE, TRUE, 0); always_check_button = gtk_check_button_new_with_mnemonic (_("_Always perform this action")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (always_check_button), data->remember); g_signal_connect (G_OBJECT (always_check_button), "toggled", G_CALLBACK (autorun_always_toggled), data); gtk_box_pack_start (GTK_BOX (vbox), always_check_button, TRUE, TRUE, 0); gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); if (g_mount_can_eject (mount)) { GtkWidget *eject_image; eject_button = gtk_button_new_with_mnemonic (_("_Eject")); pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "media-eject", caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_BUTTON), 0, NULL); eject_image = gtk_image_new_from_pixbuf (pixbuf); g_object_unref (pixbuf); gtk_button_set_image (GTK_BUTTON (eject_button), eject_image); data->should_eject = TRUE; } else { eject_button = gtk_button_new_with_mnemonic (_("_Unmount")); data->should_eject = FALSE; } gtk_dialog_add_action_widget (GTK_DIALOG (dialog), eject_button, AUTORUN_DIALOG_RESPONSE_EJECT); gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), eject_button, TRUE); /* show the dialog */ gtk_widget_show_all (dialog); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (autorun_dialog_response), data); g_signal_connect (G_OBJECT (data->mount), "unmounted", G_CALLBACK (autorun_dialog_mount_unmounted), data); out: g_free (mount_name); return ret; }
void nautilus_x_content_bar_set_x_content_type (NautilusXContentBar *bar, const char *x_content_type) { char *message; char *description; GAppInfo *default_app; g_free (bar->priv->x_content_type); bar->priv->x_content_type = g_strdup (x_content_type); description = g_content_type_get_description (x_content_type); /* Customize greeting for well-known x-content types */ if (strcmp (x_content_type, "x-content/audio-cdda") == 0) { message = g_strdup (_("These files are on an Audio CD.")); } else if (strcmp (x_content_type, "x-content/audio-dvd") == 0) { message = g_strdup (_("These files are on an Audio DVD.")); } else if (strcmp (x_content_type, "x-content/video-dvd") == 0) { message = g_strdup (_("These files are on a Video DVD.")); } else if (strcmp (x_content_type, "x-content/video-vcd") == 0) { message = g_strdup (_("These files are on a Video CD.")); } else if (strcmp (x_content_type, "x-content/video-svcd") == 0) { message = g_strdup (_("These files are on a Super Video CD.")); } else if (strcmp (x_content_type, "x-content/image-photocd") == 0) { message = g_strdup (_("These files are on a Photo CD.")); } else if (strcmp (x_content_type, "x-content/image-picturecd") == 0) { message = g_strdup (_("These files are on a Picture CD.")); } else if (strcmp (x_content_type, "x-content/image-dcf") == 0) { message = g_strdup (_("The media contains digital photos.")); } else if (strcmp (x_content_type, "x-content/audio-player") == 0) { message = g_strdup (_("These files are on a digital audio player.")); } else if (strcmp (x_content_type, "x-content/software") == 0) { message = g_strdup (_("The media contains software.")); } else { /* fallback to generic greeting */ message = g_strdup_printf (_("The media has been detected as \"%s\"."), description); } gtk_label_set_text (GTK_LABEL (bar->priv->label), message); gtk_widget_show (bar->priv->label); /* TODO: We really need a GtkBrowserBackButton-ish widget here.. until then, we only * show the default application. */ default_app = g_app_info_get_default_for_type (x_content_type, FALSE); if (default_app != NULL) { char *button_text; const char *name; GIcon *icon; GtkWidget *image; icon = g_app_info_get_icon (default_app); if (icon != NULL) { GdkPixbuf *pixbuf; int icon_size; NautilusIconInfo *icon_info; icon_size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_BUTTON); icon_info = nautilus_icon_info_lookup (icon, icon_size); pixbuf = nautilus_icon_info_get_pixbuf_at_size (icon_info, icon_size); image = gtk_image_new_from_pixbuf (pixbuf); g_object_unref (pixbuf); g_object_unref (icon_info); } else { image = NULL; } name = g_app_info_get_name (default_app); button_text = g_strdup_printf (_("Open %s"), name); gtk_button_set_image (GTK_BUTTON (bar->priv->button), image); gtk_button_set_label (GTK_BUTTON (bar->priv->button), button_text); gtk_widget_show (bar->priv->button); g_free (button_text); g_object_unref (default_app); } else { gtk_widget_hide (bar->priv->button); } g_free (message); g_free (description); }
static void pd_update_general_tab (XviewerPropertiesDialog *prop_dlg, XviewerImage *image) { gchar *bytes_str, *dir_str; gchar *width_str, *height_str; GFile *file, *parent_file; GFileInfo *file_info; const char *mime_str; char *type_str; gint width, height; goffset bytes; g_object_set (G_OBJECT (prop_dlg->priv->thumbnail_image), "pixbuf", xviewer_image_get_thumbnail (image), NULL); gtk_label_set_text (GTK_LABEL (prop_dlg->priv->name_label), xviewer_image_get_caption (image)); xviewer_image_get_size (image, &width, &height); width_str = g_strdup_printf ("%d %s", width, ngettext ("pixel", "pixels", width)); height_str = g_strdup_printf ("%d %s", height, ngettext ("pixel", "pixels", height)); gtk_label_set_text (GTK_LABEL (prop_dlg->priv->width_label), width_str); gtk_label_set_text (GTK_LABEL (prop_dlg->priv->height_label), height_str); g_free (height_str); g_free (width_str); file = xviewer_image_get_file (image); file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0, NULL, NULL); if (file_info == NULL) { type_str = g_strdup (_("Unknown")); } else { mime_str = g_file_info_get_content_type (file_info); type_str = g_content_type_get_description (mime_str); g_object_unref (file_info); } gtk_label_set_text (GTK_LABEL (prop_dlg->priv->type_label), type_str); bytes = xviewer_image_get_bytes (image); bytes_str = g_format_size (bytes); gtk_label_set_text (GTK_LABEL (prop_dlg->priv->bytes_label), bytes_str); parent_file = g_file_get_parent (file); if (parent_file == NULL) { /* file is root directory itself */ parent_file = g_object_ref (file); } dir_str = g_file_get_basename (parent_file); gtk_button_set_label (GTK_BUTTON (prop_dlg->priv->folder_button), dir_str); g_free (prop_dlg->priv->folder_button_uri); prop_dlg->priv->folder_button_uri = g_file_get_uri (parent_file); g_object_unref (parent_file); g_free (type_str); g_free (bytes_str); g_free (dir_str); }
void mate_wp_item_update_description (MateWPItem * item) { g_free (item->description); if (!strcmp (item->filename, "(none)")) { item->description = g_strdup (item->name); } else { const gchar *description; gchar *size; gchar *dirname = g_path_get_dirname (item->filename); description = NULL; size = NULL; if (strcmp (item->fileinfo->mime_type, "application/xml") == 0) { if (mate_bg_changes_with_time (item->bg)) description = _("Slide Show"); else if (item->width > 0 && item->height > 0) description = _("Image"); } else description = g_content_type_get_description (item->fileinfo->mime_type); if (mate_bg_has_multiple_sizes (item->bg)) size = g_strdup (_("multiple sizes")); else if (item->width > 0 && item->height > 0) { /* translators: x pixel(s) by y pixel(s) */ size = g_strdup_printf (_("%d %s by %d %s"), item->width, ngettext ("pixel", "pixels", item->width), item->height, ngettext ("pixel", "pixels", item->height)); } if (description && size) { /* translators: <b>wallpaper name</b> * mime type, size * Folder: /path/to/file */ item->description = g_markup_printf_escaped (_("<b>%s</b>\n" "%s, %s\n" "Folder: %s"), item->name, description, size, dirname); } else { /* translators: <b>wallpaper name</b> * Image missing * Folder: /path/to/file */ item->description = g_markup_printf_escaped (_("<b>%s</b>\n" "%s\n" "Folder: %s"), item->name, _("Image missing"), dirname); } g_free (size); g_free (dirname); } }
static void pd_update_general_tab (EomPropertiesDialog *prop_dlg, EomImage *image) { gchar *bytes_str, *dir_str, *uri_str; gchar *width_str, *height_str; GFile *file; GFileInfo *file_info; const char *mime_str; char *type_str; gint width, height; goffset bytes; g_object_set (G_OBJECT (prop_dlg->priv->thumbnail_image), "pixbuf", eom_image_get_thumbnail (image), NULL); gtk_label_set_text (GTK_LABEL (prop_dlg->priv->name_label), eom_image_get_caption (image)); eom_image_get_size (image, &width, &height); width_str = g_strdup_printf ("%d %s", width, ngettext ("pixel", "pixels", width)); height_str = g_strdup_printf ("%d %s", height, ngettext ("pixel", "pixels", height)); gtk_label_set_text (GTK_LABEL (prop_dlg->priv->width_label), width_str); gtk_label_set_text (GTK_LABEL (prop_dlg->priv->height_label), height_str); g_free (height_str); g_free (width_str); file = eom_image_get_file (image); file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0, NULL, NULL); if (file_info == NULL) { type_str = g_strdup (_("Unknown")); } else { mime_str = g_file_info_get_content_type (file_info); type_str = g_content_type_get_description (mime_str); g_object_unref (file_info); } gtk_label_set_text (GTK_LABEL (prop_dlg->priv->type_label), type_str); bytes = eom_image_get_bytes (image); bytes_str = g_format_size_for_display (bytes); gtk_label_set_text (GTK_LABEL (prop_dlg->priv->bytes_label), bytes_str); uri_str = eom_image_get_uri_for_display (image); dir_str = g_path_get_dirname (uri_str); gtk_label_set_text (GTK_LABEL (prop_dlg->priv->location_label), dir_str); g_free (type_str); g_free (bytes_str); g_free (dir_str); g_free (uri_str); }
static VALUE rg_s_get_description(G_GNUC_UNUSED VALUE type) { return CSTR2RVAL_FREE(g_content_type_get_description(RVAL2CSTR(type))); }
static const gchar * xfdesktop_regular_file_icon_peek_tooltip(XfdesktopIcon *icon) { XfdesktopRegularFileIcon *regular_file_icon = XFDESKTOP_REGULAR_FILE_ICON(icon); if(!regular_file_icon->priv->tooltip) { GFileInfo *info = xfdesktop_file_icon_peek_file_info(XFDESKTOP_FILE_ICON(icon)); const gchar *content_type, *comment = NULL; gchar *description, *size_string, *time_string; guint64 size, mtime; gboolean is_desktop_file = FALSE; if(!info) return NULL; if(g_content_type_equals(g_file_info_get_content_type(info), "application/x-desktop")) { is_desktop_file = TRUE; } else { gchar *uri = g_file_get_uri(regular_file_icon->priv->file); if(g_str_has_suffix(uri, ".desktop")) is_desktop_file = TRUE; g_free(uri); } content_type = g_file_info_get_content_type(info); description = g_content_type_get_description(content_type); size = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_STANDARD_SIZE); size_string = g_format_size(size); mtime = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_TIME_MODIFIED); time_string = xfdesktop_file_utils_format_time_for_display(mtime); regular_file_icon->priv->tooltip = g_strdup_printf(_("Type: %s\nSize: %s\nLast modified: %s"), description, size_string, time_string); /* Extract the Comment entry from the .desktop file */ if(is_desktop_file) { gchar *path = g_file_get_path(regular_file_icon->priv->file); XfceRc *rcfile = xfce_rc_simple_open(path, TRUE); g_free(path); if(rcfile) { xfce_rc_set_group(rcfile, "Desktop Entry"); comment = xfce_rc_read_entry(rcfile, "Comment", NULL); } /* Prepend the comment to the tooltip */ if(comment != NULL && *comment != '\0') { gchar *tooltip = regular_file_icon->priv->tooltip; regular_file_icon->priv->tooltip = g_strdup_printf("%s\n%s", comment, tooltip); g_free(tooltip); } xfce_rc_close(rcfile); } g_free(time_string); g_free(size_string); g_free(description); } return regular_file_icon->priv->tooltip; }