tracker r2356 - in trunk: . src/tracker-search-tool
- From: jamiemcc svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2356 - in trunk: . src/tracker-search-tool
- Date: Mon, 13 Oct 2008 02:49:49 +0000 (UTC)
Author: jamiemcc
Date: Mon Oct 13 02:49:49 2008
New Revision: 2356
URL: http://svn.gnome.org/viewvc/tracker?rev=2356&view=rev
Log:
2008-10-12 Jamie McCracken <jamiemcc at gnome org>
* src/tracker-search-tool/tracker-search-tool.h
* src/tracker-search-tool/tracker-search-tool-support.c
* src/tracker-search-tool/tracker-search-tool-callbacks.c
* src/tracker-search-tool/Makefile.am
* src/tracker-search-tool/tracker-search-tool-support.h
* src/tracker-search-tool/tracker-search-tool.c
* src/tracker-search-tool/tracker-search-tool-callbacks.h
Patch from John Millikin <jmillikin gmail com>
Modified search tool to use GIO instead of Gnome VFS
Modified:
trunk/ChangeLog
trunk/src/tracker-search-tool/Makefile.am
trunk/src/tracker-search-tool/tracker-search-tool-callbacks.c
trunk/src/tracker-search-tool/tracker-search-tool-callbacks.h
trunk/src/tracker-search-tool/tracker-search-tool-support.c
trunk/src/tracker-search-tool/tracker-search-tool-support.h
trunk/src/tracker-search-tool/tracker-search-tool.c
trunk/src/tracker-search-tool/tracker-search-tool.h
Modified: trunk/src/tracker-search-tool/Makefile.am
==============================================================================
--- trunk/src/tracker-search-tool/Makefile.am (original)
+++ trunk/src/tracker-search-tool/Makefile.am Mon Oct 13 02:49:49 2008
@@ -9,7 +9,7 @@
-I$(top_srcdir)/src/libtracker \
$(GLIB2_CFLAGS) \
$(GNOME_UTILS_CFLAGS) \
- $(GNOMEVFS_CFLAGS) \
+ $(GIO_CFLAGS) \
$(GNOMEDESKTOP_CFLAGS) \
$(DBUS_CFLAGS) \
-DG_DISABLE_DEPRECATED \
@@ -33,7 +33,7 @@
tracker_search_tool_LDADD = \
$(GLIB2_LIBS) \
$(GNOME_UTILS_LIBS) \
- $(GNOMEVFS_LIBS) \
+ $(GIO_LIBS) \
$(GNOMEDESKTOP_LIBS) \
$(DBUS_LIBS) \
$(top_builddir)/src/libtracker-gtk/libtracker-gtk.la \
Modified: trunk/src/tracker-search-tool/tracker-search-tool-callbacks.c
==============================================================================
--- trunk/src/tracker-search-tool/tracker-search-tool-callbacks.c (original)
+++ trunk/src/tracker-search-tool/tracker-search-tool-callbacks.c Mon Oct 13 02:49:49 2008
@@ -37,9 +37,7 @@
#include <unistd.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-find-directory.h>
+#include <gio/gio.h>
#include <libgnome/gnome-desktop-item.h>
#include <gnome.h>
@@ -464,10 +462,10 @@
GdkPixbuf * temp = NULL;
if (is_local_file) {
- gchar *uri = gnome_vfs_get_uri_from_local_path (local_uri);
-
+ /* local_uri is actually a file path */
+ gchar *uri = g_filename_to_uri (local_uri, NULL, NULL);
+ g_return_val_if_fail (uri != NULL, NULL);
thumb_name = gnome_thumbnail_path_for_uri (uri, GNOME_THUMBNAIL_SIZE_NORMAL);
-
g_free (uri);
}
@@ -629,40 +627,31 @@
}
} else {
-
- gchar * file;
- gchar * locale_file;
-
- file = uri;
- locale_file = g_locale_from_utf8 (file, -1, NULL, NULL, NULL);
-
- if (!g_file_test (locale_file, G_FILE_TEST_EXISTS)) {
+ GFile * file;
+ file = g_file_new_for_path (uri);
+
+ if (!g_file_query_exists (file, NULL)) {
gtk_tree_selection_unselect_iter (GTK_TREE_SELECTION (gsearch->search_results_selection),
&iter);
display_dialog_could_not_open_file (gsearch->window, uri,
_("The document does not exist."));
- } else if (open_file_with_xdg_open (gsearch->window, locale_file) == FALSE) {
-
- if (open_file_with_application (gsearch->window, locale_file) == FALSE) {
-
- if (launch_file (locale_file) == FALSE) {
-
- if (g_file_test (locale_file, G_FILE_TEST_IS_DIR)) {
-
- if (open_file_with_nautilus (gsearch->window, locale_file) == FALSE) {
- display_dialog_could_not_open_folder (gsearch->window, uri);
- }
-
- } else {
- display_dialog_could_not_open_file (gsearch->window, uri,
- _("There is no installed viewer capable "
- "of displaying the document."));
+ } else if (open_file_with_xdg_open (gsearch->window, file) == FALSE) {
+ if (launch_file (file) == FALSE) {
+ GFileInfo *info = g_file_query_info (file, "standard::type", 0, NULL, NULL);
+ g_return_if_fail (info != NULL);
+ if (g_file_info_get_attribute_uint32 (info, "standard::type") == G_FILE_TYPE_DIRECTORY) {
+ if (open_file_with_nautilus (gsearch->window, file) == FALSE) {
+ display_dialog_could_not_open_folder (gsearch->window, uri);
}
+ } else {
+ display_dialog_could_not_open_file (gsearch->window, uri,
+ _("There is no installed viewer capable "
+ "of displaying the document."));
}
}
}
- g_free (locale_file);
+ g_object_unref (file);
}
g_free (uri);
@@ -746,8 +735,7 @@
}
for (tmp = list; tmp; tmp = tmp->next) {
-
- gchar * folder_locale;
+ GFile * folder;
gchar * folder_utf8;
GtkTreeIter iter;
@@ -757,20 +745,19 @@
COLUMN_PATH, &folder_utf8,
-1);
- folder_locale = g_filename_from_utf8 (folder_utf8, -1, NULL, NULL, NULL);
-
- if (open_file_with_xdg_open (gsearch->window, folder_locale) == FALSE) {
- if (open_file_with_nautilus (gsearch->window, folder_locale) == FALSE) {
+ folder = g_file_new_for_path (folder_utf8);
+ if (open_file_with_xdg_open (gsearch->window, folder) == FALSE) {
+ if (open_file_with_nautilus (gsearch->window, folder) == FALSE) {
display_dialog_could_not_open_folder (gsearch->window, folder_utf8);
}
g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
g_list_free (list);
- g_free (folder_locale);
+ g_object_unref (folder);
g_free (folder_utf8);
return;
}
- g_free (folder_locale);
+ g_object_unref (folder);
g_free (folder_utf8);
}
g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
@@ -806,109 +793,6 @@
g_free (primary);
}
-static gint
-display_dialog_delete_permanently (GtkWidget * window,
- const gchar * file)
-{
- GtkWidget * dialog;
- GtkWidget * button;
- gchar * primary;
- gchar * secondary;
- gint response;
-
- primary = g_strdup_printf (_("Do you want to delete \"%s\" permanently?"),
- g_path_get_basename (file));
-
- secondary = g_strdup_printf (_("Trash is unavailable. Could not move \"%s\" to the trash."),
- file);
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_CANCEL,
- primary);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- secondary);
-
- gtk_window_set_title (GTK_WINDOW (dialog), "");
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
-
- button = gtk_button_new_from_stock ("gtk-delete");
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
- gtk_widget_show (button);
-
- gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_OK);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (GTK_WIDGET(dialog));
- g_free (primary);
- g_free (secondary);
-
- return response;
-}
-
-static void
-display_dialog_could_not_delete (GtkWidget * window,
- const gchar * file,
- const gchar * message)
-{
- GtkWidget * dialog;
- gchar * primary;
-
- primary = g_strdup_printf (_("Could not delete \"%s\"."), file);
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- primary);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- message);
-
- gtk_window_set_title (GTK_WINDOW (dialog), "");
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
-
- g_signal_connect (G_OBJECT (dialog),
- "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_widget_show (dialog);
- g_free (primary);
-}
-
-static char *
-get_trash_path (const gchar * file)
-{
- GnomeVFSURI * trash_uri;
- GnomeVFSURI * uri;
- gchar * filename;
-
- filename = gnome_vfs_escape_path_string (file);
- uri = gnome_vfs_uri_new (filename);
- g_free (filename);
-
- gnome_vfs_find_directory (uri,
- GNOME_VFS_DIRECTORY_KIND_TRASH,
- &trash_uri,
- TRUE,
- TRUE,
- 0777);
- gnome_vfs_uri_unref (uri);
-
- if (trash_uri == NULL) {
- return NULL;
- }
- else {
- gchar * trash_path;
- trash_path = gnome_vfs_uri_to_string (trash_uri, GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD);
- gnome_vfs_uri_unref (trash_uri);
- return trash_path;
- }
-}
-
void
move_to_trash_cb (GtkAction * action,
gpointer data)
@@ -916,124 +800,58 @@
GSearchWindow * gsearch = data;
gint total;
gint index;
-
+
if (gtk_tree_selection_count_selected_rows (GTK_TREE_SELECTION (gsearch->search_results_selection)) == 0) {
return;
}
-
+
total = gtk_tree_selection_count_selected_rows (GTK_TREE_SELECTION (gsearch->search_results_selection));
-
+
for (index = 0; index < total; index++) {
gboolean no_files_found = FALSE;
GtkTreeModel * model;
GtkTreeIter iter;
GList * list;
- gchar * utf8_basename;
- gchar * utf8_basepath;
- gchar * utf8_filename;
- gchar * locale_filename;
- gchar * trash_path;
-
+ gchar * filename;
+ GFile * file;
+ GError * error = NULL;
+
list = gtk_tree_selection_get_selected_rows (GTK_TREE_SELECTION (gsearch->search_results_selection),
- &model);
-
+ &model);
+
gtk_tree_model_get_iter (GTK_TREE_MODEL (gsearch->search_results_list_store), &iter,
- g_list_nth (list, 0)->data);
-
+ g_list_nth (list, 0)->data);
+
gtk_tree_model_get (GTK_TREE_MODEL (gsearch->search_results_list_store), &iter,
- COLUMN_NAME, &utf8_basename,
- COLUMN_PATH, &utf8_basepath,
- COLUMN_NO_FILES_FOUND, &no_files_found,
- -1);
-
+ COLUMN_URI, &filename, /* COLUMN_URI stores file paths vOv */
+ COLUMN_NO_FILES_FOUND, &no_files_found,
+ -1);
+
if (no_files_found) {
- g_free (utf8_basename);
- g_free (utf8_basepath);
- return;
+ g_free (filename);
+ return; /* Shouldn't this be continue? */
}
-
- utf8_filename = g_build_filename (utf8_basepath, utf8_basename, NULL);
- locale_filename = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
- trash_path = get_trash_path (locale_filename);
-
- if ((!g_file_test (locale_filename, G_FILE_TEST_EXISTS)) &&
- (!g_file_test (locale_filename, G_FILE_TEST_IS_SYMLINK))) {
+ file = g_file_new_for_path (filename);
+ if (g_file_trash (file, NULL, &error)) {
gtk_tree_selection_unselect_iter (GTK_TREE_SELECTION (gsearch->search_results_selection), &iter);
- display_dialog_could_not_move_to_trash (gsearch->window, utf8_basename,
- _("The document does not exist."));
- }
- else if (trash_path != NULL) {
- GnomeVFSResult result;
- gchar * destination;
- gchar * basename;
- gchar * source_uri;;
-
- source_uri = g_filename_to_uri (locale_filename, NULL, NULL);
- basename = g_locale_from_utf8 (utf8_basename, -1, NULL, NULL, NULL);
- destination = g_build_filename (trash_path, basename, NULL);
-
- result = gnome_vfs_move (source_uri, destination, TRUE);
- gtk_tree_selection_unselect_iter (GTK_TREE_SELECTION (gsearch->search_results_selection), &iter);
-
- if (result == GNOME_VFS_OK) {
-
- gtk_list_store_remove (GTK_LIST_STORE (gsearch->search_results_list_store), &iter);
- }
- else {
- gchar * message;
-
- message = g_strdup_printf (_("Moving \"%s\" failed: %s."),
- utf8_filename,
- gnome_vfs_result_to_string (result));
- display_dialog_could_not_move_to_trash (gsearch->window, utf8_basename,
- message);
- g_free (message);
- }
- g_free (source_uri);
- g_free (basename);
- g_free (destination);
+ gtk_list_store_remove (GTK_LIST_STORE (gsearch->search_results_list_store), &iter);
}
else {
- gint response;
-
- gtk_tree_selection_unselect_iter (GTK_TREE_SELECTION (gsearch->search_results_selection), &iter);
- response = display_dialog_delete_permanently (gsearch->window, utf8_filename);
-
- if (response == GTK_RESPONSE_OK) {
- GnomeVFSResult result;
-
- if (!g_file_test (locale_filename, G_FILE_TEST_IS_DIR)) {
- result = gnome_vfs_unlink (locale_filename);
- }
- else {
- result = gnome_vfs_remove_directory (locale_filename);
- }
-
- if (result == GNOME_VFS_OK) {
-
- gtk_list_store_remove (GTK_LIST_STORE (gsearch->search_results_list_store), &iter);
- }
- else {
- gchar * message;
-
- message = g_strdup_printf (_("Deleting \"%s\" failed: %s."),
- utf8_filename, gnome_vfs_result_to_string (result));
-
- display_dialog_could_not_delete (gsearch->window, utf8_basename, message);
-
- g_free (message);
- }
- }
+ gchar * message;
+
+ message = g_strdup_printf (_("Moving \"%s\" failed: %s."),
+ filename, error->message);
+ display_dialog_could_not_move_to_trash (gsearch->window, filename,
+ message);
+ g_free (message);
+ g_error_free (error);
}
+
g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
g_list_free (list);
- g_free (locale_filename);
- g_free (utf8_filename);
- g_free (utf8_basename);
- g_free (utf8_basepath);
- g_free (trash_path);
+ g_free (filename);
}
-
+
if (gsearch->command_details->command_status != RUNNING) {
update_search_counts (gsearch);
}
@@ -1416,8 +1234,6 @@
gchar * desktop_item_name = NULL;
gchar * uri;
gchar * path;
- gchar * disk;
- gchar * scheme;
gint argc;
gint index;
@@ -1433,10 +1249,6 @@
}
command = g_string_append (command, "--start");
- disk = g_locale_from_utf8 (command->str, -1, NULL, NULL, NULL);
- uri = gnome_vfs_make_uri_from_input_with_dirs (disk, GNOME_VFS_MAKE_URI_DIR_HOMEDIR);
- scheme = gnome_vfs_get_uri_scheme (uri);
-
ditem = gnome_desktop_item_new ();
gnome_desktop_item_set_entry_type (ditem, GNOME_DESKTOP_ITEM_TYPE_APPLICATION);
@@ -1451,12 +1263,13 @@
g_string_free (command, TRUE);
g_free (desktop_item_name);
- g_free (uri);
path = tracker_search_get_unique_filename (g_get_tmp_dir (), ".desktop");
gnome_desktop_item_set_location (ditem, path);
+ g_return_if_fail (g_path_is_absolute (path));
- uri = gnome_vfs_get_uri_from_local_path (path);
+ uri = g_filename_to_uri (path, NULL, NULL);
+ g_return_if_fail (uri != NULL);
if (gnome_desktop_item_save (ditem, NULL, FALSE, NULL)) {
gtk_selection_data_set (selection_data,
@@ -1467,8 +1280,6 @@
g_free (uri);
g_free (path);
- g_free (disk);
- g_free (scheme);
}
void
Modified: trunk/src/tracker-search-tool/tracker-search-tool-callbacks.h
==============================================================================
--- trunk/src/tracker-search-tool/tracker-search-tool-callbacks.h (original)
+++ trunk/src/tracker-search-tool/tracker-search-tool-callbacks.h Mon Oct 13 02:49:49 2008
@@ -106,12 +106,6 @@
open_folder_cb (GtkAction * action,
gpointer data);
void
-file_changed_cb (GnomeVFSMonitorHandle * handle,
- const gchar * monitor_uri,
- const gchar * info_uri,
- GnomeVFSMonitorEventType event_type,
- gpointer data);
-void
move_to_trash_cb (GtkAction * action,
gpointer data);
void
Modified: trunk/src/tracker-search-tool/tracker-search-tool-support.c
==============================================================================
--- trunk/src/tracker-search-tool/tracker-search-tool-support.c (original)
+++ trunk/src/tracker-search-tool/tracker-search-tool-support.c Mon Oct 13 02:49:49 2008
@@ -35,10 +35,7 @@
#include <regex.h>
#include <gdk/gdkx.h>
#include <libart_lgpl/art_rgb.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio/gio.h>
#include <libgnome/gnome-desktop-item.h>
#include <libgnomeui/gnome-thumbnail.h>
@@ -824,52 +821,18 @@
}
gchar *
-get_file_type_description (const gchar * file,
- const char *mime,
- GnomeVFSFileInfo * file_info)
+get_file_type_description (GFile * file, GFileInfo * file_info)
{
- gchar * desc;
-
- if (file == NULL || mime == NULL) {
- return g_strdup (gnome_vfs_mime_get_description (GNOME_VFS_MIME_TYPE_UNKNOWN));
+ const gchar *content_type;
+ content_type = g_file_info_get_attribute_string (file_info, "standard::content-type");
+
+ if (content_type == NULL) {
+ content_type = "unknown";
}
-
- desc = g_strdup (gnome_vfs_mime_get_description (mime));
-
- if (file_info->symlink_name != NULL) {
-
- gchar * absolute_symlink = NULL;
- gchar * str = NULL;
-
- if (g_path_is_absolute (file_info->symlink_name) != TRUE) {
- gchar *dirname;
-
- dirname = g_path_get_dirname (file);
- absolute_symlink = g_strconcat (dirname, G_DIR_SEPARATOR_S, file_info->symlink_name, NULL);
- g_free (dirname);
- }
- else {
- absolute_symlink = g_strdup (file_info->symlink_name);
- }
-
- if (g_file_test (absolute_symlink, G_FILE_TEST_EXISTS) != TRUE) {
- if ((g_ascii_strcasecmp (mime, "x-special/socket") != 0) &&
- (g_ascii_strcasecmp (mime, "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 : mime);
- g_free (absolute_symlink);
- g_free (desc);
- return str;
- }
- return desc;
+
+ return g_content_type_get_description (content_type);
}
-
static GdkPixbuf *
tracker_search_load_thumbnail_frame (void)
{
@@ -1050,13 +1013,13 @@
}
static GdkPixbuf *
-tracker_search_get_thumbnail_image (const gchar * file)
+tracker_search_get_thumbnail_image (GFile * file)
{
GdkPixbuf * pixbuf = NULL;
gchar * thumbnail_path;
gchar * uri;
- uri = gnome_vfs_get_uri_from_local_path (file);
+ uri = g_file_get_uri (file);
thumbnail_path = gnome_thumbnail_path_for_uri (uri, GNOME_THUMBNAIL_SIZE_NORMAL);
if (thumbnail_path != NULL) {
@@ -1098,53 +1061,84 @@
static gchar *
tracker_search_icon_lookup (GSearchWindow * gsearch,
- const gchar * file,
- const gchar * mime,
- GnomeVFSFileInfo * file_info,
- gboolean enable_thumbnails)
+ GFile * file,
+ GFileInfo * file_info,
+ gboolean enable_thumbnails)
{
GnomeIconLookupFlags lookup_flags = GNOME_ICON_LOOKUP_FLAGS_NONE;
gchar * icon_name = NULL;
gchar * uri;
-
- uri = gnome_vfs_get_uri_from_local_path (file);
-
+ const gchar * content_type;
+ gchar *mime;
+ guint64 file_size;
+ GIcon *icon;
+ GtkIconTheme *icon_theme;
+
+ uri = g_file_get_uri (file);
+ file_size = g_file_info_get_attribute_uint64 (file_info, "standard::size");
+ content_type = g_file_info_get_attribute_string (file_info, "standard::content-type");
+ mime = g_content_type_get_mime_type (content_type);
+
if ((strncmp (mime, "image/", 6) != 0) ||
- ((int)file_info->size < (int)gsearch->show_thumbnails_file_size_limit)) {
+ ((int)file_size < (int)gsearch->show_thumbnails_file_size_limit)) {
if (gsearch->thumbnail_factory == NULL) {
gsearch->thumbnail_factory = gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL);
}
lookup_flags = GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES |
GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES;
+
}
-
- icon_name = gnome_icon_lookup (gtk_icon_theme_get_default (),
- gsearch->thumbnail_factory,
- uri,
- NULL,
- file_info,
- mime,
- lookup_flags,
- NULL);
+
+ icon_theme = gtk_icon_theme_get_default ();
+
+ icon = g_file_info_get_icon (file_info);
+ if (icon && G_IS_THEMED_ICON (icon)) {
+ GStrv names;
+ guint ii;
+ g_object_get (icon, "names", &names, NULL);
+ for (ii = 0; names[ii]; ii++)
+ {
+ if (gtk_icon_theme_has_icon (icon_theme, names[ii])) {
+ icon_name = names[ii];
+ break;
+ }
+ }
+ }
+
+ if (!icon_name) {
+ icon_name = gnome_icon_lookup (icon_theme,
+ gsearch->thumbnail_factory,
+ uri,
+ NULL,
+ NULL,
+ mime,
+ lookup_flags,
+ NULL);
+ }
+
+ g_free (mime);
g_free (uri);
return icon_name;
}
GdkPixbuf *
get_file_pixbuf (GSearchWindow * gsearch,
- const gchar * file,
- const char *mime,
- GnomeVFSFileInfo * file_info)
+ GFile * file,
+ GFileInfo * file_info)
{
GdkPixbuf * pixbuf = NULL;
gchar * icon_name = NULL;
+ const gchar *content_type;
+ gchar *mime;
+ content_type = g_file_info_get_attribute_string (file_info, "standard::content-type");
+ mime = g_content_type_get_mime_type (content_type);
if (file == NULL || mime == NULL) {
icon_name = g_strdup (ICON_THEME_REGULAR_ICON);
}
- else if ((g_file_test (file, G_FILE_TEST_IS_EXECUTABLE)) &&
- (g_ascii_strcasecmp (mime, "application/x-executable-binary") == 0)) {
+ else if (g_file_info_get_attribute_boolean (file_info, "access::can-execute") &&
+ g_ascii_strcasecmp (mime, "application/x-executable-binary") == 0) {
icon_name = g_strdup (ICON_THEME_EXECUTABLE_ICON);
}
else if (g_ascii_strcasecmp (mime, "x-special/device-char") == 0) {
@@ -1164,6 +1158,7 @@
GdkPixbuf *thumbnail_pixbuf = tracker_search_get_thumbnail_image (file);
if (thumbnail_pixbuf != NULL) {
+ g_free (mime);
if ((gdk_pixbuf_get_width (thumbnail_pixbuf) > ICON_SIZE) ||
(gdk_pixbuf_get_height (thumbnail_pixbuf) > ICON_SIZE)) {
@@ -1203,13 +1198,16 @@
/* check if image can be generated from file */
if ((strncmp (mime, "image/", 6) == 0)) {
- pixbuf = gdk_pixbuf_new_from_file_at_scale (file, ICON_SIZE, ICON_SIZE, TRUE, NULL);
+ gchar *path = g_file_get_path (file);
+ pixbuf = gdk_pixbuf_new_from_file_at_scale (path, ICON_SIZE, ICON_SIZE, TRUE, NULL);
+ g_free (path);
}
if (pixbuf) {
+ g_free (mime);
return pixbuf;
} else {
- icon_name = tracker_search_icon_lookup (gsearch, file, mime, file_info, TRUE);
+ icon_name = tracker_search_icon_lookup (gsearch, file, file_info, TRUE);
}
@@ -1225,17 +1223,19 @@
g_free (icon_name);
+ g_free (mime);
return pixbuf;
}
gboolean
-open_file_with_xdg_open (GtkWidget * window,
- const gchar * file)
+open_file_with_xdg_open (GtkWidget * window, GFile * file)
{
gboolean result;
- gchar *quoted_filename = g_shell_quote (file);
+ gchar *filename = g_file_get_path (file);
+ gchar *quoted_filename = g_shell_quote (filename);
gchar *command = g_strconcat ("xdg-open ", quoted_filename, NULL);
+ g_free (filename);
g_free (quoted_filename);
result = g_spawn_command_line_async (command, NULL);
g_free (command);
@@ -1244,8 +1244,7 @@
}
gboolean
-open_file_with_nautilus (GtkWidget * window,
- const gchar * file)
+open_file_with_nautilus (GtkWidget * window, GFile * file)
{
GnomeDesktopItem * ditem;
GdkScreen * screen;
@@ -1253,8 +1252,10 @@
gchar * command;
gchar * contents;
gchar * escaped;
+ gchar * filename = g_file_get_path (file);
- escaped = g_shell_quote (file);
+ escaped = g_shell_quote (filename);
+ g_free (filename);
command = g_strconcat ("nautilus ",
"--sm-disable ",
@@ -1307,73 +1308,25 @@
}
gboolean
-open_file_with_application (GtkWidget * window,
- const gchar * file)
+launch_file (GFile * file)
{
- GnomeVFSMimeApplication * application;
- const char * mime;
-
- mime = gnome_vfs_get_file_mime_type (file, NULL, FALSE);
- application = gnome_vfs_mime_get_default_application (mime);
-
- if (!g_file_test (file, G_FILE_TEST_IS_DIR)) {
- if (application) {
- const char *desktop_file;
- GnomeDesktopItem *ditem;
- GdkScreen *screen;
- GError *error = NULL;
- GList *uris = NULL;
- gboolean result;
- char *uri;
-
- desktop_file = gnome_vfs_mime_application_get_desktop_file_path (application);
-
- uri = gnome_vfs_get_uri_from_local_path (file);
- uris = g_list_append (uris, uri);
-
- if (!g_file_test (desktop_file, G_FILE_TEST_EXISTS)) {
- result = (gnome_vfs_mime_application_launch (application, uris) == GNOME_VFS_OK);
- }
- else {
- result = TRUE;
- ditem = gnome_desktop_item_new_from_file (desktop_file, 0, &error);
- if (error) {
- result = FALSE;
- g_error_free (error);
- }
- else {
- screen = gtk_widget_get_screen (window);
- gnome_desktop_item_set_launch_time (ditem, gtk_get_current_event_time ());
- gnome_desktop_item_launch_on_screen (ditem, uris,
- GNOME_DESKTOP_ITEM_LAUNCH_APPEND_PATHS, screen, -1, &error);
- if (error) {
- result = FALSE;
- g_error_free (error);
- }
- }
- gnome_desktop_item_unref (ditem);
- }
- gnome_vfs_mime_application_free (application);
- g_list_free (uris);
- g_free (uri);
-
- return result;
- }
- }
- return FALSE;
-}
-
-gboolean
-launch_file (const gchar * file)
-{
- const char * mime = gnome_vfs_get_file_mime_type (file, NULL, FALSE);
+ GFileInfo *info;
+ const gchar *content_type;
+ gchar *mime;
+
+ info = g_file_query_info (file, "standard::content-type,access::*", 0, NULL, NULL);
+ content_type = g_file_info_get_attribute_string (info, "standard::content-type");
+ mime = g_content_type_get_mime_type (content_type);
gboolean result = FALSE;
-
- if ((g_file_test (file, G_FILE_TEST_IS_EXECUTABLE)) &&
- (g_ascii_strcasecmp (mime, BINARY_EXEC_MIME_TYPE) == 0)) {
- result = g_spawn_command_line_async (file, NULL);
+
+ if (g_file_info_get_attribute_boolean (info, "access::can-execute") &&
+ g_ascii_strcasecmp (mime, BINARY_EXEC_MIME_TYPE) == 0) {
+ gchar *path = g_file_get_path (file);
+ result = g_spawn_command_line_async (path, NULL);
+ g_free (path);
}
-
+ g_free (mime);
+
return result;
}
Modified: trunk/src/tracker-search-tool/tracker-search-tool-support.h
==============================================================================
--- trunk/src/tracker-search-tool/tracker-search-tool-support.h (original)
+++ trunk/src/tracker-search-tool/tracker-search-tool-support.h Mon Oct 13 02:49:49 2008
@@ -124,31 +124,25 @@
struct tm * time_pieces);
gchar *
-get_file_type_description (const gchar * file,
- const char *mime,
- GnomeVFSFileInfo * file_info);
+get_file_type_description (GFile * file,
+ GFileInfo * file_info);
GdkPixbuf *
get_file_pixbuf (GSearchWindow * gsearch,
- const gchar * file,
- const char * mime,
- GnomeVFSFileInfo * file_info);
+ GFile * file,
+ GFileInfo * file_info);
gboolean
open_file_with_xdg_open (GtkWidget * window,
- const gchar * file);
+ GFile * file);
gboolean
open_file_with_nautilus (GtkWidget * window,
- const gchar * file);
+ GFile * file);
gboolean
-open_file_with_application (GtkWidget * window,
- const gchar * file);
-
-gboolean
-launch_file (const gchar * file);
+launch_file (GFile * file);
gchar *
tracker_search_get_unique_filename (const gchar * path,
Modified: trunk/src/tracker-search-tool/tracker-search-tool.c
==============================================================================
--- trunk/src/tracker-search-tool/tracker-search-tool.c (original)
+++ trunk/src/tracker-search-tool/tracker-search-tool.c Mon Oct 13 02:49:49 2008
@@ -37,10 +37,8 @@
#include <sys/wait.h>
#include <glib/gi18n.h>
#include <gdk/gdkcursor.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <gtk/gtk.h>
+#include <gio/gio.h>
@@ -413,6 +411,11 @@
gchar *snippet_markup;
GtkTreeIter iter;
SnippetRow *snippet_row = user_data;
+
+ if (error)
+ {
+ g_warning ("set_snippet got error: %s", error->message);
+ }
g_return_if_fail (error == NULL);
@@ -493,7 +496,7 @@
}
static void
-add_file_to_search_results (const gchar * file,
+add_file_to_search_results (const gchar * file_path,
ServiceType service_type,
const gchar * mime,
GtkListStore * store,
@@ -501,84 +504,70 @@
GSearchWindow * gsearch)
{
GdkPixbuf * pixbuf;
- GnomeVFSFileInfo * vfs_file_info;
+ GFile * file;
+ GFileInfo * file_info;
+ GError * error = NULL;
gchar * description;
gchar * base_name;
gchar * dir_name;
- gchar * escape_path_string;
- gchar * uri;
-
- uri = g_filename_from_utf8 (file, -1, NULL, NULL, NULL);
-
- if (!g_file_test (uri, G_FILE_TEST_EXISTS)) {
- g_warning ("file %s does not exist", file);
- g_free (uri);
+
+ file = g_file_new_for_path (file_path);
+ file_info = g_file_query_info (file, "standard::*,access::*",
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL, &error);
+ if (!file_info) {
+ g_warning ("Error querying info for file %s: %s", file_path,
+ error->message);
+ g_error_free (error);
+ g_object_unref (file);
return;
}
-
+
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (gsearch->search_results_tree_view), FALSE);
- vfs_file_info = gnome_vfs_file_info_new ();
-
- escape_path_string = gnome_vfs_escape_path_string (uri);
-
- gnome_vfs_get_file_info (escape_path_string, vfs_file_info,
- GNOME_VFS_FILE_INFO_DEFAULT |
- GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
-
-
- pixbuf = get_file_pixbuf (gsearch, uri, mime, vfs_file_info);
-
- description = get_file_type_description (uri, mime, vfs_file_info);
-
+ pixbuf = get_file_pixbuf (gsearch, file, file_info);
+ description = get_file_type_description (file, file_info);
if (!description) {
description = g_strdup (mime);
}
-
- base_name = g_path_get_basename (file);
- dir_name = g_path_get_dirname (file);
-
- gchar * search_term;
-
- if (gsearch->search_term) {
- search_term = gsearch->search_term;
- } else {
- search_term = NULL;
- }
-
+
+ g_return_if_fail (description != NULL);
+
+ base_name = g_path_get_basename (file_path);
+ dir_name = g_path_get_dirname (file_path);
+
gtk_list_store_append (GTK_LIST_STORE (store), iter);
gtk_list_store_set (GTK_LIST_STORE (store), iter,
- COLUMN_ICON, pixbuf,
- COLUMN_URI, file,
- COLUMN_NAME, base_name,
- COLUMN_PATH, dir_name,
- COLUMN_MIME, (description != NULL) ? description : mime,
- COLUMN_TYPE, service_type,
- COLUMN_NO_FILES_FOUND, FALSE,
- -1);
-
- if (search_term &&
+ COLUMN_ICON, pixbuf,
+ COLUMN_URI, file_path,
+ COLUMN_NAME, base_name,
+ COLUMN_PATH, dir_name,
+ COLUMN_MIME, description,
+ COLUMN_TYPE, service_type,
+ COLUMN_NO_FILES_FOUND, FALSE,
+ -1);
+
+ if (gsearch->search_term &&
(service_type == SERVICE_DOCUMENTS ||
service_type == SERVICE_TEXT_FILES ||
service_type == SERVICE_DEVELOPMENT_FILES ||
gsearch->type == SERVICE_CONVERSATIONS)) {
-
+
SnippetRow * snippet_row;
-
+
snippet_row = g_new (SnippetRow, 1);
snippet_row->gsearch = gsearch;
- snippet_row->uri = g_strdup (uri);
+ snippet_row->uri = g_file_get_path (file);
snippet_row->type = service_type;
-
+
g_queue_push_tail (gsearch->snippet_queue, snippet_row);
}
-
- gnome_vfs_file_info_unref (vfs_file_info);
+
+ g_object_unref (file);
+ g_object_unref (file_info);
g_free (base_name);
g_free (dir_name);
- g_free (uri);
- g_free (escape_path_string);
g_free (description);
}
Modified: trunk/src/tracker-search-tool/tracker-search-tool.h
==============================================================================
--- trunk/src/tracker-search-tool/tracker-search-tool.h (original)
+++ trunk/src/tracker-search-tool/tracker-search-tool.h Mon Oct 13 02:49:49 2008
@@ -42,10 +42,6 @@
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-
#include <libgnomeui/libgnomeui.h>
#include "../libtracker/tracker.h"
@@ -115,7 +111,6 @@
typedef struct _GSearchWindowClass GSearchWindowClass;
typedef struct _GSearchCommandDetails GSearchCommandDetails;
typedef struct _GSearchConstraint GSearchConstraint;
-typedef struct _GSearchMonitor GSearchMonitor;
struct _GSearchWindow {
GtkWindow parent_instance;
@@ -225,12 +220,6 @@
GtkWindowClass parent_class;
};
-struct _GSearchMonitor {
- GSearchWindow * gsearch;
- GtkTreeRowReference * reference;
- GnomeVFSMonitorHandle * handle;
-};
-
GType
gsearch_window_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]