Enhancements to Nautilus to support search by emblem



 Dear All,
             In continuation to our previous mails, we are hereby sending you
the patch for the recent version of nautilus ie nautilus-2.30.0.
This patch will provide the search by emblems feature.

 * Searching on tags - just click on a tag/emblem on emblem left sidepane in the
nautilus file browser window and get the files tagged   by the corresponding
tag/emblem.

   Please find the attachment. Please provide your feedback.

With warm regards,
Accessibility Team,
CDAC Mumbai.






> Dear all,
>
>       In continuation with our previous mail, we are now making  the nautilus
> source code along with external tag application which supports tagged file
> system available to all. We realise that such a system will be useful for
> any kind of users, hence this email. If anyone wants to use this system,
> the enhanced nautilus is available for download from the following link :
>
> http://202.141.152.14/~access/
>
>        The enclosed Instruction file (Instruction
> _to_install_tag_application.pdf) gives the instructions and requirements
> to install and run the  application - currently it runs on Ubuntu 8.04.
> In Ubuntu 9.10 there are some issues and we are working on it and will
> make it available soon.
>
> Quick Feature list
>
>     * Tag creation - graphical tag or textual tag, when a new file is created
>     * Searching on tags - just click on a tag/emblem on emblem sidepane in the
> nautilus file browser window
>       and get the  files tagged   by the corresponding tag/emblem.
>     * Set/Modify tags of existing files - right click on the file and choose the
> set tag option to do this.
>
> The enclosed screen shots may give you a better feel of the system.
>
> If you have any query, please let us know. We are eagerly waiting for your
> feedback.
>
> Note : If your system contains large number of files the external tag file
> application will take some time to start
>        after your system starts.
>
>
> With warm regards,
> Aparna Ramamurthy, Kamini Kashyap, Arun Magar, Shiv Nath Kumar, Meena Pokhriyal
> (for CDAC Mumbai team)
>
>
>> Dear all,
>>
>>      We at C-DAC Mumbai are working on a project to enhance the accessibility
>> of
>> GNOME desktops for cognitively disabled users. As a part of this work, we
>> enhanced Nautilus to support tagged file system. Thus, for any new file
>> created, the user can set tags to the files - this will help users easily
>> locate files. The enhancement helps adding/editing tags at the time of
>> creating a file, adding/editing tags for already created files, searching
>> on tags. The enclosed screenshots show these capabilities. The tags can be
>> either images or text labels. We have enhanced  the emblem capability of
>> Nautilus to support these features - hence now the enhanced Nautilus can
>> support emblem search feature also.
>>
>> We have worked on
>>
>> Ubuntu 8.04
>>
>> nautilus-2.22.5.1
>>
>> to make these enhancements. We would like to know your
>> thoughts/comments/suggestions on this work. We would also like to give this
>> work
>> back to Nautilus community for people to download and install. Please note
>> that
>> in order to use enhancement, users will need to install a small application
>> that
>> we developed to add tags to files. However, searching is directly on Nautilus.
>>
>> --
>> With warm regards,
>> Arun Magar
>> (for CDAC Mumbai team)
>>
>> :: Disclaimer ::
>> The information contained in this e-mail message is intended only for the use
>> of
>> the individual or entity to which it is addressed. If you are not the intended
>> recipient, you should return it to the sender immediately. Please note that
>> while we scan all e-mails for viruses we cannot guarantee that any e-mail is
>> virus-free and accept no liability for any damage caused by any virus
>> transmitted by this email.
>>
>


-- 
Arun P. Magar
Senior Technical Associate
CDAC Mumbai.
:: Disclaimer ::
The information contained in this e-mail message is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you should return it to the sender immediately. Please note that while we scan all e-mails for viruses we cannot guarantee that any e-mail is virus-free and accept no liability for any damage caused by any virus transmitted by this email.

diff -cBr nautilus-2.30.0_original/libnautilus-private/nautilus-file.c nautilus-2.30.0_changed/libnautilus-private/nautilus-file.c
*** nautilus-2.30.0_original/libnautilus-private/nautilus-file.c	2010-03-10 18:58:38.000000000 +0530
--- nautilus-2.30.0_changed/libnautilus-private/nautilus-file.c	2010-07-23 16:39:29.894315000 +0530
***************
*** 68,73 ****
--- 68,80 ----
  #include <unistd.h>
  #include <sys/stat.h>
  
+ /*
+ * Added by CDAC,Mumbai Accessibility Team
+  */
+ #include <string.h>
+ #include <malloc.h>
+ #include <stdio.h>
+ 
  #ifdef HAVE_SELINUX
  #include <selinux/selinux.h>
  #endif
***************
*** 6500,6505 ****
--- 6507,6613 ----
  	return sort_keyword_list_and_remove_duplicates (keywords);
  }
  
+ 
+ 
+ /**
+ Added By CDAC Accessibility
+ **/
+ 
+ GList *
+ get_keywords(const char *file_uri)
+ {
+ 
+ 	 GList *key_list=NULL;
+ 	 FILE *fpipe;
+          char *command=NULL;
+ 
+ 	// char *command="gvfs-info -a metadata::emblems /home/arun/Music/sdsdsd | grep emblem";
+ 	command = (char *)malloc(60+strlen(file_uri));
+ 	strcpy(command,"gvfs-info -a metadata::emblems ");
+ 	strcat(command,file_uri);
+ 	strcat(command," | grep emblem");
+        
+    	// g_print("Command =%s \n",command);
+      
+ 
+ 	   char command_op[512];
+ 	   char keyword[256];
+ 	   char *keyword_array[10];
+ 	   if ( (fpipe = (FILE*)popen(command,"r"))==NULL )
+ 	   {  // If fpipe is NULL
+ 	      g_print("Problems with pipe.\n");
+ 	      return NULL;
+ 	   }
+ 	   g_free (command);        
+ 	  int count_check =0;	             
+ 	   while ( fgets( command_op, sizeof(command_op), fpipe))
+ 	   {
+ 		count_check++;
+ 	   }
+ 		if (count_check==0)
+ 		{
+ 		g_free (key_list);
+ 		pclose(fpipe);
+ 		return NULL;
+ 		}
+ 		pclose(fpipe);
+ 
+ 		if(command_op[0] == '\0'){
+ 		g_free (key_list);
+ 		pclose(fpipe);
+ 		return NULL;
+ 	} 
+ 
+ 	
+ 
+ 	int i,j;
+ 	int keyword_index=0;
+ 	int keyword_array_index=0;
+ 
+ 	for(i=22;command_op[i]!='\0';i++)
+ 	{
+ 
+ 	 	if(command_op[i]==']')
+ 	  	{
+ 	     		break;
+ 	   	}
+ 	    
+ 
+ 	   	if(command_op[i]==' ')
+ 	    	{		}
+ 	    	else
+ 	    	{ 
+ 		keyword_index=0;
+ 		 	for(j=i;command_op[j]!=',';j++)
+ 		  	{
+ 				if(command_op[j]==']')
+ 		  		{
+ 		     		  break;
+ 		   		}
+ 				else
+ 				 {
+ 			      		keyword[keyword_index]=command_op[j];
+ 			      		
+ 			      		keyword_index++;
+ 				 }
+ 		 	}
+ 		keyword[keyword_index]='\0';
+ 	    	}
+ 		keyword_array[keyword_array_index]=(char *)malloc(strlen(keyword)+1);
+ 		strcpy(keyword_array[keyword_array_index],keyword);
+ 		key_list=g_list_prepend(key_list,keyword_array[keyword_array_index]);
+ 		keyword_array_index++;
+ 		
+ 		 i=j+1;
+ 	}  
+ 	keyword_array[keyword_array_index]=NULL;
+ 	return key_list;
+ }
+ 
+ 
+ 
+ 
+ 
  /**
   * nautilus_file_set_keywords
   * 
diff -cBr nautilus-2.30.0_original/libnautilus-private/nautilus-file.h nautilus-2.30.0_changed/libnautilus-private/nautilus-file.h
*** nautilus-2.30.0_original/libnautilus-private/nautilus-file.h	2009-12-09 16:33:51.000000000 +0530
--- nautilus-2.30.0_changed/libnautilus-private/nautilus-file.h	2010-07-23 16:41:22.930314000 +0530
***************
*** 203,208 ****
--- 203,215 ----
  gboolean                nautilus_file_should_show_directory_item_count  (NautilusFile                   *file);
  gboolean                nautilus_file_should_show_type                  (NautilusFile                   *file);
  GList *                 nautilus_file_get_keywords                      (NautilusFile                   *file);
+ 
+ 
+ /**
+ Added By CDAC Accessibility
+ **/
+ GList *                 get_keywords                      		(const char                     *uri);
+ 
  void                    nautilus_file_set_keywords                      (NautilusFile                   *file,
  									 GList                          *keywords);
  GList *                 nautilus_file_get_emblem_icons                  (NautilusFile                   *file,
diff -cBr nautilus-2.30.0_original/libnautilus-private/nautilus-search-engine-simple.c nautilus-2.30.0_changed/libnautilus-private/nautilus-search-engine-simple.c
*** nautilus-2.30.0_original/libnautilus-private/nautilus-search-engine-simple.c	2009-04-20 16:27:19.000000000 +0530
--- nautilus-2.30.0_changed/libnautilus-private/nautilus-search-engine-simple.c	2010-07-23 16:43:50.655313000 +0530
***************
*** 23,35 ****
  
  #include <config.h>
  #include "nautilus-search-engine-simple.h"
! 
  #include <string.h>
  #include <glib.h>
  #include <eel/eel-gtk-macros.h>
  #include <eel/eel-glib-extensions.h>
  #include <gio/gio.h>
  
  #define BATCH_SIZE 500
  
  typedef struct {
--- 23,42 ----
  
  #include <config.h>
  #include "nautilus-search-engine-simple.h"
! #include "nautilus-metadata.h"
  #include <string.h>
  #include <glib.h>
  #include <eel/eel-gtk-macros.h>
  #include <eel/eel-glib-extensions.h>
  #include <gio/gio.h>
  
+ /* Added By CDAC Accessibility Team (www.cdacmumbai.in)*/
+ #include "nautilus-file.h"
+ #include "nautilus-directory.h"
+ //#include "nautilus-metafile.h"
+ //-------------------------------------------------------
+ 
+ 
  #define BATCH_SIZE 500
  
  typedef struct {
***************
*** 61,66 ****
--- 68,80 ----
  static void  nautilus_search_engine_simple_class_init       (NautilusSearchEngineSimpleClass *class);
  static void  nautilus_search_engine_simple_init             (NautilusSearchEngineSimple      *engine);
  
+ /* Added By CDAC Accessibility Team (www.cdacmumbai.in)*/
+ static gboolean is_search_emblem_click = FALSE;
+ //---------------------------------------------------------
+ 
+ 
+ 
+ 
  G_DEFINE_TYPE (NautilusSearchEngineSimple,
  	       nautilus_search_engine_simple,
  	       NAUTILUS_TYPE_SEARCH_ENGINE);
***************
*** 201,206 ****
--- 215,328 ----
  	G_FILE_ATTRIBUTE_STANDARD_TYPE "," \
  	G_FILE_ATTRIBUTE_ID_FILE
  
+ 
+ 
+ /** Added by "Accessibility Team" CDAC,Mumbai (www.cdacmumbai.in) 
+   * New Function to perform searching on emblem specific file.
+  **/
+ static void
+ visit_emblem_directory (GFile *dir, SearchThreadData *data)
+ {
+ 	
+ 	GFileEnumerator *enumerator;
+ 	GFileInfo *info;
+ 	GFile *child,*my_file,*location;
+         NautilusDirectory *directory;
+ 	const char *mime_type, *display_name,*child_uri;
+ 	char *lower_name, *normalized;
+ 	gboolean hit;
+ 	int i;
+ 	GList *l,*keyword_list;
+ 	const char *id;
+ 	gboolean visited;
+ 	char *dir_path = g_file_get_uri (dir);	
+ 
+ 	
+ 	enumerator = g_file_enumerate_children (dir,
+ 						data->mime_types != NULL ?
+ 						STD_ATTRIBUTES ","
+ 						G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE
+ 						:
+ 						STD_ATTRIBUTES
+ 						,
+ 						0, data->cancellable, NULL);
+ 
+ 	
+ 	if (enumerator == NULL) {
+ 		return;
+ 	}
+ 
+ 	while ((info = g_file_enumerator_next_file (enumerator, data->cancellable, NULL)) != NULL) {
+ 		//g_print("File NAme:--- %s",g_file_info_get_display_name(info));
+ 		if (g_file_info_get_is_hidden (info)) {
+ 			goto next;
+ 		}
+               
+ 		display_name = g_file_info_get_display_name (info);
+ 		if (display_name == NULL) {
+ 			goto next;
+ 		}
+ 		
+              child = g_file_get_child (dir, g_file_info_get_name (info));
+             
+             
+                         child_uri= g_file_get_uri(child);
+                        
+ 			keyword_list = get_keywords(child_uri);
+ 
+ 
+                         GList *item = keyword_list;
+                         while (item)
+                         {
+                            
+                                 for(i=0;data->words[i]!=NULL;i++)
+                                 {
+                                  if(strcmp(item->data,data->words[i])==0)
+                                  {data->uri_hits = g_list_prepend (data->uri_hits, g_file_get_uri (child));
+                                
+                                  }
+                                 }//end of for
+                               item = item->next;
+                         }
+                         g_free(item);
+ 
+                         
+ 		
+ 		data->n_processed_files++;
+ 		if (data->n_processed_files > BATCH_SIZE) {
+ 			send_batch (data);
+ 		}
+ 
+ 		if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ 			id = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_ID_FILE);
+ 			visited = FALSE;
+ 			if (id) {
+ 				if (g_hash_table_lookup_extended (data->visited,
+ 								  id, NULL, NULL)) {
+ 					visited = TRUE;
+ 				} else {
+ 					g_hash_table_insert (data->visited, g_strdup (id), NULL);
+ 				}
+ 			}
+ 			
+ 			if (!visited) {
+ 				g_queue_push_tail (data->directories, g_object_ref (child));
+ 			}
+ 		}
+ 		
+ 		g_object_unref (child);
+ 	next:
+ 		g_object_unref (info);
+ 	}
+ 
+ 	g_object_unref (enumerator);
+ }
+ 
+ //----------------------------------------------------------------------------------------------
+ 
+ 
+ 
+ 
  static void
  visit_directory (GFile *dir, SearchThreadData *data)
  {
***************
*** 323,338 ****
  	
  	while (!g_cancellable_is_cancelled (data->cancellable) &&
  	       (dir = g_queue_pop_head (data->directories)) != NULL) {
! 		visit_directory (dir, data);
! 		g_object_unref (dir);
  	}
  	send_batch (data);
  
  	g_idle_add (search_thread_done_idle, data);
  	
  	return NULL;
  }
  
  static void
  nautilus_search_engine_simple_start (NautilusSearchEngine *engine)
  {
--- 445,493 ----
  	
  	while (!g_cancellable_is_cancelled (data->cancellable) &&
  	       (dir = g_queue_pop_head (data->directories)) != NULL) {
! 		//visit_directory (dir, data);
! 		//g_object_unref (dir);
! 
! 		/* Added by "Accessibility Team" CDAC,Mumbai (www.cdacmumbai.in) */
!  
! 
! 		if(is_search_emblem_click == TRUE){
! 			visit_emblem_directory (dir, data);
! 		}else{
! 
! 			
! 			visit_directory (dir, data);
! 		}
! 		
! 		//--------------------------------------------------------------------
! 
! 
  	}
  	send_batch (data);
+ 	/** Added by "Accessibility Team" CDAC,Mumbai (www.cdacmumbai.in) */
+ 	is_search_emblem_click =FALSE;
+ 	//-----------------------------------------------------------------
  
  	g_idle_add (search_thread_done_idle, data);
  	
  	return NULL;
  }
  
+ 
+ /** Added by "Accessibility Team" CDAC,Mumbai (www.cdacmumbai.in) 
+   * New Function to be called when emblem is clicked on sidepane for search. 
+  **/
+ 
+ void emblem_click_done(gboolean click_done){
+ 	
+ 	is_search_emblem_click = click_done;
+ }
+ 
+ //---------------------------------------------------------------------------
+ 
+ 
+ 
+ 
  static void
  nautilus_search_engine_simple_start (NautilusSearchEngine *engine)
  {
diff -cBr nautilus-2.30.0_original/libnautilus-private/nautilus-search-engine-simple.h nautilus-2.30.0_changed/libnautilus-private/nautilus-search-engine-simple.h
*** nautilus-2.30.0_original/libnautilus-private/nautilus-search-engine-simple.h	2009-04-20 16:27:19.000000000 +0530
--- nautilus-2.30.0_changed/libnautilus-private/nautilus-search-engine-simple.h	2010-06-10 12:39:08.481045000 +0530
***************
*** 48,51 ****
--- 48,55 ----
  
  NautilusSearchEngine* nautilus_search_engine_simple_new       (void);
  
+ 
+ //Added
+ void    emblem_click_done                   (gboolean click_done);
+ 
  #endif /* NAUTILUS_SEARCH_ENGINE_SIMPLE_H */
diff -cBr nautilus-2.30.0_original/src/nautilus-emblem-sidebar.c nautilus-2.30.0_changed/src/nautilus-emblem-sidebar.c
*** nautilus-2.30.0_original/src/nautilus-emblem-sidebar.c	2009-12-15 15:52:12.000000000 +0530
--- nautilus-2.30.0_changed/src/nautilus-emblem-sidebar.c	2010-06-10 12:44:41.424044000 +0530
***************
*** 50,56 ****
  #include <libnautilus-private/nautilus-sidebar-provider.h>
  #include <libnautilus-private/nautilus-module.h>
  #include <libnautilus-private/nautilus-signaller.h>
! 
  struct NautilusEmblemSidebarDetails {
  	NautilusWindowInfo *window;
  	GConfClient *client;
--- 49,59 ----
  #include <libnautilus-private/nautilus-sidebar-provider.h>
  #include <libnautilus-private/nautilus-module.h>
  #include <libnautilus-private/nautilus-signaller.h>
! #include <libnautilus-private/nautilus-file.h>
! //Added by CDAC Accessibility Team
! #include <libnautilus-private/nautilus-file.h>
! #include "nautilus-window.h"
! //----------------------------
  struct NautilusEmblemSidebarDetails {
  	NautilusWindowInfo *window;
  	GConfClient *client;
***************
*** 75,80 ****
--- 78,85 ----
  static void nautilus_emblem_sidebar_iface_init        (NautilusSidebarIface         *iface);
  static void sidebar_provider_iface_init               (NautilusSidebarProviderIface *iface);
  static GType nautilus_emblem_sidebar_provider_get_type (void);
+ static void open_search_directory(char *,NautilusWindow *);
+ 
  
  static const GtkTargetEntry drag_types[] = {
  	{"property/keyword", 0, 0 }
***************
*** 163,168 ****
--- 168,256 ----
  	eel_labeled_image_set_pixbuf (EEL_LABELED_IMAGE (image), pixbuf);
  }
  
+ 
+ 
+ 
+ 
+ 
+ 
+ //Added by CDAC Team
+ 
+ /*This function will create search engine for file search by emblems*/
+         
+ static void  open_search_directory(char *keyword,NautilusWindow *window)
+      {
+         char *uri, *current_uri;
+ 	NautilusDirectory *directory;
+ 	NautilusSearchDirectory *search_directory;
+ 	NautilusQuery *query;
+ 	GFile *location;
+         uri = nautilus_search_directory_generate_new_uri ();
+ 
+ 	location = g_file_new_for_uri (uri);
+ 	g_free (uri);
+ 
+ 	directory = nautilus_directory_get (location);
+ 
+ 	g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory));
+ 
+ 	search_directory = NAUTILUS_SEARCH_DIRECTORY (directory);
+ 
+         query= nautilus_query_new();
+ 
+         nautilus_query_set_text(query,keyword);
+ 
+ 	
+ 	if (query != NULL) {
+ 		if (!nautilus_search_directory_is_indexed (search_directory)) {
+ 			current_uri=nautilus_get_home_directory_uri ();
+ 			nautilus_query_set_location (query,current_uri);
+ 			g_free (current_uri);
+ 		}
+ 		nautilus_search_directory_set_query (search_directory, query);
+ 		g_object_unref (query);
+ 	}
+ 
+ 	nautilus_window_go_to (window, location);
+ 
+ 	nautilus_directory_unref (directory);
+ 	g_object_unref (location);
+ 
+ }
+ 	
+ 
+ /*
+  This function captures the click event on emblem. 
+  Keyword of the emblem clicked is extracted and passed on to the search function*/
+ 
+ 
+ static gboolean
+   nautilus_emblem_sidebar_button_release_cb (GtkWidget *widget,
+ 					 GdkEventButton *event,
+ 					 NautilusEmblemSidebar *emblem_sidebar)
+   {
+ 	char *keyword, *name,*homedir,*uri,*path,*str1,*str2,*str3,*str4,*file_name;
+ 	GdkPixbuf *pixbuf;
+ 	GFile *g_files,*child_file;
+ 		keyword = g_object_get_data (G_OBJECT (widget),"emblem-keyword");
+ 		name = g_object_get_data (G_OBJECT (widget),"emblem-display-name");
+ 	if(!((event->x==0) && (event->y==0)))
+ 	 {
+ 
+ 		gboolean my_emblem_clicked = TRUE;
+ 		emblem_click_done(my_emblem_clicked);
+ 
+ 	open_search_directory(keyword,	NAUTILUS_WINDOW(emblem_sidebar->details->window));
+  	}
+     /* Returning TRUE means we handled the event, so the signal
+      * emission should be stopped (don't call any further
+      * callbacks that may be connected). Return FALSE
+      * to continue invoking callbacks.
+      */
+    return TRUE;
+   }
+ 
+ 
  static gboolean
  nautilus_emblem_sidebar_button_press_cb (GtkWidget *widget,
  					 GdkEventButton *event,
***************
*** 404,409 ****
--- 493,506 ----
  	g_signal_connect (event_box, "button_press_event",
  			  G_CALLBACK (nautilus_emblem_sidebar_button_press_cb),
  			  emblem_sidebar);
+ 
+ 	//Added by CDAC TEAM
+ 	/*emblem is made clickable*/
+ 	g_signal_connect (event_box, "button_release_event",
+ 			  G_CALLBACK (nautilus_emblem_sidebar_button_release_cb),
+ 			  emblem_sidebar);
+ 
+ 
  	g_signal_connect (event_box, "drag-data-get",
  			  G_CALLBACK (nautilus_emblem_sidebar_drag_data_get_cb),
  			  emblem_sidebar);


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