anjuta r4459 - in trunk: . plugins/profiler



Author: sgranjoux
Date: Fri Dec 19 21:37:59 2008
New Revision: 4459
URL: http://svn.gnome.org/viewvc/anjuta?rev=4459&view=rev

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


Modified:
   trunk/ChangeLog
   trunk/plugins/profiler/gprof-profile-data.c
   trunk/plugins/profiler/plugin.c
   trunk/plugins/profiler/plugin.h

Modified: trunk/plugins/profiler/gprof-profile-data.c
==============================================================================
--- trunk/plugins/profiler/gprof-profile-data.c	(original)
+++ trunk/plugins/profiler/gprof-profile-data.c	Fri Dec 19 21:37:59 2008
@@ -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 @@
 	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 @@
 	 * 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);
 	}
 	
 	

Modified: trunk/plugins/profiler/plugin.c
==============================================================================
--- trunk/plugins/profiler/plugin.c	(original)
+++ trunk/plugins/profiler/plugin.c	Fri Dec 19 21:37:59 2008
@@ -138,7 +138,8 @@
 	 {
 	 	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 @@
 }
 
 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 @@
 	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 @@
 	
 	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 @@
 		
 		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 @@
 			{
 				/* 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 @@
 	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 @@
 	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 @@
 	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;
 }

Modified: trunk/plugins/profiler/plugin.h
==============================================================================
--- trunk/plugins/profiler/plugin.h	(original)
+++ trunk/plugins/profiler/plugin.h	Fri Dec 19 21:37:59 2008
@@ -68,7 +68,7 @@
 	gint project_watch_id;
 	gchar *project_root_uri;
 	gchar *profile_target_path;
-	GnomeVFSMonitorHandle *profile_data_monitor;
+	GFileMonitor *profile_data_monitor;
 };
 
 struct _ProfilerClass



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]