gnome-control-center r9142 - in trunk: . font-viewer
- From: rodrigo svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-control-center r9142 - in trunk: . font-viewer
- Date: Tue, 18 Nov 2008 17:46:12 +0000 (UTC)
Author: rodrigo
Date: Tue Nov 18 17:46:12 2008
New Revision: 9142
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=9142&view=rev
Log:
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.
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/font-viewer/font-thumbnailer.c
trunk/font-viewer/font-view.c
trunk/font-viewer/ftstream-vfs.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Tue Nov 18 17:46:12 2008
@@ -119,7 +119,7 @@
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)
Modified: trunk/font-viewer/font-thumbnailer.c
==============================================================================
--- trunk/font-viewer/font-thumbnailer.c (original)
+++ trunk/font-viewer/font-thumbnailer.c Tue Nov 18 17:46:12 2008
@@ -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 @@
FT_Library library;
FT_Face face;
FT_UInt glyph_index1, glyph_index2;
+ GFile *file;
gchar *uri;
GdkPixbuf *pixbuf;
guchar *buffer;
@@ -285,18 +286,16 @@
}
}
- 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 @@
g_free (uri);
goto out;
}
+
g_free (uri);
error = FT_Set_Pixel_Sizes(face, 0, font_size);
Modified: trunk/font-viewer/font-view.c
==============================================================================
--- trunk/font-viewer/font-view.c (original)
+++ trunk/font-viewer/font-view.c Tue Nov 18 17:46:12 2008
@@ -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 @@
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 @@
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);
- }
- 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);
- }
+ 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);
}
- gnome_vfs_file_info_unref(file_info);
+
+ g_object_unref (file);
if (FT_IS_SFNT(face)) {
gint i, len;
@@ -370,20 +371,49 @@
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);
- gtk_window_set_icon_name (window, icon_name);
end:
- g_free(icon_name);
+ if (icon_name)
+ g_free(icon_name);
+
+ g_object_unref (file);
}
int
@@ -392,6 +422,7 @@
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 @@
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 @@
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;
Modified: trunk/font-viewer/ftstream-vfs.c
==============================================================================
--- trunk/font-viewer/ftstream-vfs.c (original)
+++ trunk/font-viewer/ftstream-vfs.c Tue Nov 18 17:46:12 2008
@@ -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,64 +33,73 @@
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 (! g_seekable_seek (G_SEEKABLE (handle), offset, G_SEEK_SET, NULL, NULL))
+ return 0;
- if (gnome_vfs_seek(handle, GNOME_VFS_SEEK_START, offset) != GNOME_VFS_OK)
- return 0;
if (count > 0) {
- if (gnome_vfs_read(handle, buffer, count, &bytes_read) != GNOME_VFS_OK)
- return 0;
+ 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);
+ if (! handle)
+ return;
+
+ g_object_unref (handle);
stream->descriptor.pointer = NULL;
stream->size = 0;
- stream->base = NULL;
+ stream->base = NULL;
}
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;
+ return FT_Err_Invalid_Stream_Handle;
+
+ file = g_file_new_for_uri (uri);
- if (gnome_vfs_open(&handle, uri,
- GNOME_VFS_OPEN_READ | GNOME_VFS_OPEN_RANDOM) != GNOME_VFS_OK) {
- g_message("could not open URI");
- return FT_Err_Cannot_Open_Resource;
+ 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);
- return FT_Err_Cannot_Open_Resource;
+ 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]