added missing GFileInfo declaration.
2008-11-18 Rodrigo Moya <rodrigo@gnome-db.org> * font-viewer/font-view.c (set_icon): added missing GFileInfo declaration. 2008-11-18 Rodrigo Moya <rodrigo@gnome-db.org> Bug 561319 – Remove gnome-vfs dependency from font-viewer Patch from Saleem Abdulrasool <compnerd@compnerd.org> * font-viewer/*: * configure.in: Remove gnome-vfs dependency for font-viewer. svn path=/trunk/; revision=9142
This commit is contained in:
parent
f4efa053da
commit
8cff6042ab
5 changed files with 129 additions and 76 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2008-11-18 Rodrigo Moya <rodrigo@gnome-db.org>
|
||||
|
||||
* font-viewer/font-view.c (set_icon): added missing
|
||||
GFileInfo declaration.
|
||||
|
||||
2008-11-18 Rodrigo Moya <rodrigo@gnome-db.org>
|
||||
|
||||
Bug 561319 – Remove gnome-vfs dependency from font-viewer
|
||||
|
||||
Patch from Saleem Abdulrasool <compnerd@compnerd.org>
|
||||
|
||||
* font-viewer/*:
|
||||
* configure.in: Remove gnome-vfs dependency for font-viewer.
|
||||
|
||||
2008-11-09 Kjartan Maraas <kmaraas@gnome.org>
|
||||
|
||||
* configure.in: Add libgnomeui back to LIBSLAB FLAGS.
|
||||
|
|
|
@ -119,7 +119,7 @@ if $PKG_CONFIG --exists xft ; then
|
|||
fi
|
||||
|
||||
PKG_CHECK_MODULES(FONT_CAPPLET, $COMMON_MODULES $xft_modules)
|
||||
PKG_CHECK_MODULES(FONT_VIEWER, $COMMON_MODULES $xft_modules gnome-vfs-2.0 libgnomeui-2.0)
|
||||
PKG_CHECK_MODULES(FONT_VIEWER, $COMMON_MODULES $xft_modules libgnomeui-2.0)
|
||||
|
||||
PKG_CHECK_MODULES(AT_CAPPLET, $COMMON_MODULES)
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
static const gchar *
|
||||
|
@ -224,6 +224,7 @@ main(int argc, char **argv)
|
|||
FT_Library library;
|
||||
FT_Face face;
|
||||
FT_UInt glyph_index1, glyph_index2;
|
||||
GFile *file;
|
||||
gchar *uri;
|
||||
GdkPixbuf *pixbuf;
|
||||
guchar *buffer;
|
||||
|
@ -285,18 +286,16 @@ main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
if (!gnome_vfs_init()) {
|
||||
g_printerr("could not initialise gnome-vfs\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
error = FT_Init_FreeType(&library);
|
||||
if (error) {
|
||||
g_printerr("could not initialise freetype: %s\n", get_ft_error(error));
|
||||
goto out;
|
||||
}
|
||||
|
||||
uri = gnome_vfs_make_uri_from_shell_arg (arguments[0]);
|
||||
file = g_file_new_for_commandline_arg (arguments[0]);
|
||||
uri = g_file_get_uri (file);
|
||||
g_object_unref (file);
|
||||
|
||||
error = FT_New_Face_From_URI(library, uri, 0, &face);
|
||||
if (error) {
|
||||
g_printerr("could not load face '%s': %s\n", uri,
|
||||
|
@ -304,6 +303,7 @@ main(int argc, char **argv)
|
|||
g_free (uri);
|
||||
goto out;
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
|
||||
error = FT_Set_Pixel_Sizes(face, 0, font_size);
|
||||
|
|
|
@ -29,12 +29,10 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gio/gio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
|
||||
#include <libgnomeui/gnome-icon-lookup.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
FT_Error FT_New_Face_From_URI(FT_Library library,
|
||||
const gchar *uri,
|
||||
|
@ -269,8 +267,9 @@ add_row(GtkWidget *table, gint *row_p,
|
|||
static void
|
||||
add_face_info(GtkWidget *table, gint *row_p, const gchar *uri, FT_Face face)
|
||||
{
|
||||
GnomeVFSFileInfo *file_info;
|
||||
GnomeVFSResult res;
|
||||
gchar *s;
|
||||
GFile *file;
|
||||
GFileInfo *info;
|
||||
PS_FontInfoRec ps_info;
|
||||
|
||||
add_row(table, row_p, _("Name:"), face->family_name, FALSE);
|
||||
|
@ -278,25 +277,27 @@ add_face_info(GtkWidget *table, gint *row_p, const gchar *uri, FT_Face face)
|
|||
if (face->style_name)
|
||||
add_row(table, row_p, _("Style:"), face->style_name, FALSE);
|
||||
|
||||
file_info = gnome_vfs_file_info_new();
|
||||
res = gnome_vfs_get_file_info(uri, file_info,
|
||||
GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
|
||||
GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
|
||||
if (res == GNOME_VFS_OK) {
|
||||
if ((file_info->valid_fields&GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE)!=0){
|
||||
const gchar *type = gnome_vfs_mime_get_description(file_info->mime_type);
|
||||
file = g_file_new_for_uri (uri);
|
||||
|
||||
add_row(table, row_p, _("Type:"),
|
||||
type ? type : file_info->mime_type, FALSE);
|
||||
info = g_file_query_info (file,
|
||||
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
|
||||
G_FILE_ATTRIBUTE_STANDARD_SIZE,
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
NULL, NULL);
|
||||
|
||||
if (info) {
|
||||
s = g_content_type_get_description (g_file_info_get_content_type (info));
|
||||
add_row (table, row_p, _("Type:"), s, FALSE);
|
||||
g_free (s);
|
||||
|
||||
s = g_format_size_for_display (g_file_info_get_size (info));
|
||||
add_row (table, row_p, _("Size:"), s, FALSE);
|
||||
g_free (s);
|
||||
|
||||
g_object_unref (info);
|
||||
}
|
||||
if ((file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
|
||||
gchar *size;
|
||||
size = gnome_vfs_format_file_size_for_display(file_info->size);
|
||||
add_row(table, row_p, _("Size:"), size, FALSE);
|
||||
g_free(size);
|
||||
}
|
||||
}
|
||||
gnome_vfs_file_info_unref(file_info);
|
||||
|
||||
g_object_unref (file);
|
||||
|
||||
if (FT_IS_SFNT(face)) {
|
||||
gint i, len;
|
||||
|
@ -370,20 +371,49 @@ expose_event(GtkWidget *widget, GdkEventExpose *event, GdkPixmap *pixmap)
|
|||
static void
|
||||
set_icon(GtkWindow *window, const gchar *uri)
|
||||
{
|
||||
GFile *file;
|
||||
GIcon *icon;
|
||||
GFileInfo *info;
|
||||
GdkScreen *screen;
|
||||
GtkIconTheme *icon_theme;
|
||||
gchar *icon_name = NULL;
|
||||
gchar *icon_name = NULL, *content_type = NULL;
|
||||
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (window));
|
||||
icon_theme = gtk_icon_theme_get_for_screen (screen);
|
||||
|
||||
icon_name = gnome_icon_lookup_sync(icon_theme, NULL, uri, NULL,
|
||||
GNOME_ICON_LOOKUP_FLAGS_NONE, NULL);
|
||||
if (!icon_name) goto end;
|
||||
file = g_file_new_for_uri (uri);
|
||||
|
||||
info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
|
||||
G_FILE_QUERY_INFO_NONE, NULL, NULL);
|
||||
if (! info)
|
||||
goto end;
|
||||
|
||||
content_type = g_file_info_get_content_type (info);
|
||||
icon = g_content_type_get_icon (content_type);
|
||||
|
||||
if (G_IS_THEMED_ICON (icon)) {
|
||||
const gchar * const *names = NULL;
|
||||
|
||||
names = g_themed_icon_get_names (G_THEMED_ICON (icon));
|
||||
if (names) {
|
||||
gint i;
|
||||
for (i = 0; names[i]; i++)
|
||||
if (gtk_icon_theme_has_icon (icon_theme, names[i]))
|
||||
icon_name = g_strdup (names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (icon_name)
|
||||
gtk_window_set_icon_name (window, icon_name);
|
||||
|
||||
g_object_unref (icon);
|
||||
g_free (content_type);
|
||||
|
||||
end:
|
||||
if (icon_name)
|
||||
g_free(icon_name);
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -392,6 +422,7 @@ main(int argc, char **argv)
|
|||
FT_Error error;
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
GFile *file;
|
||||
gchar *font_file, *title;
|
||||
gint row;
|
||||
GtkWidget *window, *vbox, *table, *swin, *drawing_area;
|
||||
|
@ -409,11 +440,6 @@ main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (!gnome_vfs_init()) {
|
||||
g_printerr("could not initialise gnome-vfs\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!XftInitFtLibrary()) {
|
||||
g_printerr("could not initialise freetype library\n");
|
||||
return 1;
|
||||
|
@ -425,7 +451,10 @@ main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
font_file = gnome_vfs_make_uri_from_shell_arg (argv[1]);
|
||||
file = g_file_new_for_commandline_arg (argv[1]);
|
||||
font_file = g_file_get_uri (file);
|
||||
g_object_unref (file);
|
||||
|
||||
if (!font_file) {
|
||||
g_printerr("could not parse argument into a URI\n");
|
||||
return 1;
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
static unsigned long
|
||||
vfs_stream_read(FT_Stream stream,
|
||||
|
@ -32,26 +33,31 @@ vfs_stream_read(FT_Stream stream,
|
|||
unsigned char *buffer,
|
||||
unsigned long count)
|
||||
{
|
||||
GnomeVFSHandle *handle = (GnomeVFSHandle *)stream->descriptor.pointer;
|
||||
GnomeVFSFileSize bytes_read = 0;
|
||||
GFileInputStream *handle = (GFileInputStream *)stream->descriptor.pointer;
|
||||
gssize bytes_read = 0;
|
||||
|
||||
if (gnome_vfs_seek(handle, GNOME_VFS_SEEK_START, offset) != GNOME_VFS_OK)
|
||||
if (! g_seekable_seek (G_SEEKABLE (handle), offset, G_SEEK_SET, NULL, NULL))
|
||||
return 0;
|
||||
|
||||
if (count > 0) {
|
||||
if (gnome_vfs_read(handle, buffer, count, &bytes_read) != GNOME_VFS_OK)
|
||||
bytes_read = g_input_stream_read (G_INPUT_STREAM (handle), buffer, count, NULL, NULL);
|
||||
|
||||
if (bytes_read == -1)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
static void
|
||||
vfs_stream_close(FT_Stream stream)
|
||||
{
|
||||
GnomeVFSHandle *handle = (GnomeVFSHandle *)stream->descriptor.pointer;
|
||||
GFileInputStream *handle = (GFileInputStream *)stream->descriptor.pointer;
|
||||
|
||||
if (! handle)
|
||||
return;
|
||||
gnome_vfs_close(handle);
|
||||
|
||||
g_object_unref (handle);
|
||||
|
||||
stream->descriptor.pointer = NULL;
|
||||
stream->size = 0;
|
||||
|
@ -62,34 +68,38 @@ static FT_Error
|
|||
vfs_stream_open(FT_Stream stream,
|
||||
const char *uri)
|
||||
{
|
||||
GnomeVFSHandle *handle;
|
||||
GnomeVFSFileInfo *finfo;
|
||||
GFile *file = NULL;
|
||||
GError *error = NULL;
|
||||
GFileInfo *info = NULL;
|
||||
GFileInputStream *handle = NULL;
|
||||
|
||||
if (!stream)
|
||||
return FT_Err_Invalid_Stream_Handle;
|
||||
|
||||
if (gnome_vfs_open(&handle, uri,
|
||||
GNOME_VFS_OPEN_READ | GNOME_VFS_OPEN_RANDOM) != GNOME_VFS_OK) {
|
||||
g_message("could not open URI");
|
||||
file = g_file_new_for_uri (uri);
|
||||
|
||||
handle = g_file_read (file, NULL, &error);
|
||||
if (! handle) {
|
||||
g_message (error->message);
|
||||
|
||||
g_error_free (error);
|
||||
return FT_Err_Cannot_Open_Resource;
|
||||
}
|
||||
|
||||
finfo = gnome_vfs_file_info_new();
|
||||
if (gnome_vfs_get_file_info_from_handle(handle, finfo,0) != GNOME_VFS_OK) {
|
||||
g_warning("could not get file info");
|
||||
gnome_vfs_file_info_unref(finfo);
|
||||
gnome_vfs_close(handle);
|
||||
info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE,
|
||||
G_FILE_QUERY_INFO_NONE, NULL, &error);
|
||||
if (! info) {
|
||||
g_warning (error->message);
|
||||
|
||||
g_error_free (error);
|
||||
g_object_unref (file);
|
||||
return FT_Err_Cannot_Open_Resource;
|
||||
}
|
||||
|
||||
if ((finfo->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) == 0) {
|
||||
g_warning("file info did not include file size");
|
||||
gnome_vfs_file_info_unref(finfo);
|
||||
gnome_vfs_close(handle);
|
||||
return FT_Err_Cannot_Open_Resource;
|
||||
}
|
||||
stream->size = finfo->size;
|
||||
gnome_vfs_file_info_unref(finfo);
|
||||
stream->size = g_file_info_get_size (info);
|
||||
|
||||
g_object_unref (file);
|
||||
g_object_unref (info);
|
||||
|
||||
stream->descriptor.pointer = handle;
|
||||
stream->pathname.pointer = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue