Commit 41541619 authored by Sebastien Granjoux's avatar Sebastien Granjoux

#511589 – Anjuta uses GNOME-VFS

	* plugins/profiler/plugin.c, 
	plugins/profiler/plugin.h,
	plugins/profiler/gprof-profile-data.c: 
	#511589 – Anjuta uses GNOME-VFS

svn path=/trunk/; revision=4459
parent 9b33052d
2008-12-19 Jens Georg <mail@jensge.org>
reviewed by: Sébastien Granjoux <seb.sfo@free.fr>
* plugins/profiler/plugin.c,
plugins/profiler/plugin.h,
plugins/profiler/gprof-profile-data.c:
#511589 – Anjuta uses GNOME-VFS
2008-12-19 Jens Georg <jens@einstein>
reviewed by: Sébastien Granjoux <seb.sfo@free.fr>
......@@ -21,8 +21,8 @@
* Boston, MA 02110-1301, USA.
*/
#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include "gprof-profile-data.h"
#include <gio/gio.h>
struct _GProfProfileDataPriv
{
......@@ -110,28 +110,29 @@ gprof_profile_data_init_profile (GProfProfileData *self, gchar *path,
FILE *stdout_stream;
gchar *program_dir;
gchar *profile_data_path;
gchar *profile_data_uri;
gchar *profile_data_mime_type;
gchar *path_uri;
GPtrArray *gprof_args;
gchar *target_mime_type;
gboolean is_libtool_target = FALSE;
GPid gprof_pid;
gint gprof_status;
/* Determine target mime type */
path_uri = gnome_vfs_get_uri_from_local_path (path);
target_mime_type = gnome_vfs_get_mime_type (path_uri);
if (target_mime_type)
GFile *file = g_file_new_for_path (path);
GFileInfo *fi = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
G_FILE_QUERY_INFO_NONE,
NULL,
NULL);
if (fi)
{
if (strcmp (target_mime_type, "application/x-shellscript") == 0)
if (strcmp (g_file_info_get_content_type (fi),
"application/x-shellscript") == 0)
is_libtool_target = TRUE;
g_free (target_mime_type);
g_object_unref (fi);
}
g_free (path_uri);
g_object_unref (file);
/* If the user gave us a path to a data file, check the mime type to make
* sure the user gave us an actual profile dump, or else we could hang
......@@ -139,18 +140,29 @@ gprof_profile_data_init_profile (GProfProfileData *self, gchar *path,
* memory until it sucks the system dry. */
if (alternate_profile_data_path)
{
profile_data_uri = gnome_vfs_get_uri_from_local_path (alternate_profile_data_path);
profile_data_mime_type = gnome_vfs_get_mime_type (profile_data_uri);
if (strcmp (profile_data_mime_type, "application/x-profile") != 0)
file = g_file_new_for_path (alternate_profile_data_path);
fi = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
G_FILE_QUERY_INFO_NONE,
NULL,
NULL);
if (fi == NULL)
{
g_object_unref (file);
return FALSE;
}
if (strcmp (g_file_info_get_content_type (fi),
"application/x-profile") != 0)
{
g_free (profile_data_uri);
g_free (profile_data_mime_type);
g_object_unref (fi);
g_object_unref (file);
return FALSE;
}
g_free (profile_data_uri);
g_free (profile_data_mime_type);
g_object_unref (fi);
g_object_unref (file);
}
......
......@@ -138,7 +138,8 @@ setup_options (Profiler *profiler)
{
if (!gprof_options_get_int (profiler->options, "automatic_refresh"))
{
gnome_vfs_monitor_cancel (profiler->profile_data_monitor);
g_file_monitor_cancel (profiler->profile_data_monitor);
g_object_unref (profiler->profile_data_monitor);
profiler->profile_data_monitor = NULL;
}
}
......@@ -191,27 +192,30 @@ profiler_get_data (Profiler *profiler)
}
static void
on_profile_data_changed (GnomeVFSMonitorHandle *handle,
const gchar *monitor_uri, const gchar *info_uri,
GnomeVFSMonitorEventType event,
gpointer user_data)
on_profile_data_changed (GFileMonitor *monitor,
GFile *file,
GFile *other_file,
GFileMonitorEvent event_type,
gpointer user_data)
{
DEBUG_PRINT ("%s", "Data changed called");
Profiler *profiler;
profiler = PROFILER (user_data);
switch (event)
switch (event_type)
{
case GNOME_VFS_MONITOR_EVENT_CHANGED:
case G_FILE_MONITOR_EVENT_CHANGED:
if (profiler_get_data (profiler))
gprof_view_manager_refresh_views (profiler->view_manager);
break;
case GNOME_VFS_MONITOR_EVENT_DELETED:
gnome_vfs_monitor_cancel (handle);
case G_FILE_MONITOR_EVENT_DELETED:
g_file_monitor_cancel (monitor);
g_object_unref (profiler->profile_data_monitor);
profiler->profile_data_monitor = NULL;
break;
default:
break;
break;
}
}
......@@ -223,6 +227,7 @@ profiler_set_target (Profiler *profiler, const gchar *profile_target_uri)
gchar *profile_data_path;
gchar *profile_data_path_from_options;
gchar *profile_data_uri;
GFile *file;
if (profiler->profile_target_path)
{
......@@ -232,7 +237,7 @@ profiler_set_target (Profiler *profiler, const gchar *profile_target_uri)
if (profile_target_uri)
{
profile_target_path = gnome_vfs_get_local_path_from_uri (profile_target_uri);
profile_target_path = anjuta_util_get_local_path_from_uri (profile_target_uri);
profile_data_path_from_options = gprof_options_get_string (profiler->options,
"profile_data_file");
......@@ -251,7 +256,9 @@ profiler_set_target (Profiler *profiler, const gchar *profile_target_uri)
g_free (profile_data_path_from_options);
profile_data_uri = gnome_vfs_get_uri_from_local_path (profile_data_path);
file = g_file_new_for_path (profile_data_path);
profile_data_uri = g_file_get_uri (file);
g_object_unref (file);
if (g_file_test (profile_data_path, G_FILE_TEST_EXISTS))
{
......@@ -264,12 +271,13 @@ profiler_set_target (Profiler *profiler, const gchar *profile_target_uri)
{
/* Cancel any existing monitor */
if (profiler->profile_data_monitor)
gnome_vfs_monitor_cancel (profiler->profile_data_monitor);
gnome_vfs_monitor_add (&profiler->profile_data_monitor,
profile_data_uri, GNOME_VFS_MONITOR_FILE,
on_profile_data_changed,
(gpointer) profiler);
g_file_monitor_cancel (profiler->profile_data_monitor);
file = g_file_new_for_uri (profile_data_uri);
profiler->profile_data_monitor =
g_file_monitor (file, G_FILE_MONITOR_NONE, NULL, NULL);
g_signal_connect (G_OBJECT (profiler->profile_data_monitor),
"changed", G_CALLBACK (on_profile_data_changed),
profiler);
}
/* Show user the profiler views if they aren't visible so they
......@@ -429,6 +437,7 @@ on_select_other_target_button_clicked (GtkButton *button,
gchar *selected_target_uri;
GtkTreeSelection *selection;
GtkTreePath *new_target_path;
GFile *file;
model = gtk_tree_view_get_model (targets_list_view);
target_chooser_dialog = gtk_file_chooser_dialog_new ("Select Target",
......@@ -443,7 +452,10 @@ on_select_other_target_button_clicked (GtkButton *button,
if (gtk_dialog_run (GTK_DIALOG (target_chooser_dialog)) == GTK_RESPONSE_ACCEPT)
{
selected_target_path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (target_chooser_dialog));
selected_target_uri = gnome_vfs_get_uri_from_local_path (selected_target_path);
file = g_file_new_for_path (selected_target_path);
selected_target_uri = g_file_get_uri (file);
g_object_unref (file);
selection = gtk_tree_view_get_selection (targets_list_view);
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
......@@ -902,7 +914,7 @@ profiler_deactivate (AnjutaPlugin *plugin)
g_free (profiler->project_root_uri);
if (profiler->profile_data_monitor)
gnome_vfs_monitor_cancel (profiler->profile_data_monitor);
g_file_monitor_cancel (profiler->profile_data_monitor);
return TRUE;
}
......
......@@ -68,7 +68,7 @@ struct _Profiler
gint project_watch_id;
gchar *project_root_uri;
gchar *profile_target_path;
GnomeVFSMonitorHandle *profile_data_monitor;
GFileMonitor *profile_data_monitor;
};
struct _ProfilerClass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment