static void _cd_do_show_file_location (CDEntry *pEntry)
{
	g_print ("%s (%s)\n", __func__, pEntry->cPath);
	gchar *cPathUp = g_path_get_dirname (pEntry->cPath);
	g_return_if_fail (cPathUp != NULL);
	cairo_dock_fm_launch_uri (cPathUp);
	g_free (cPathUp);
}
static void _cd_open_parent (GtkMenuItem *pMenuItem, CDQuickBrowserItem *pItem)
{
	gchar *cUri = g_filename_to_uri (pItem->cPath, NULL, NULL);
	gchar *cFolder = g_path_get_dirname (cUri);
	cairo_dock_fm_launch_uri (cFolder);
	g_free (cFolder);
	g_free (cUri);

	cd_quick_browser_destroy_menu (pItem->pApplet);
}
static void _cd_do_web_search (CDEntry *pEntry)
{
	gchar *cEscapedText = g_uri_escape_string (myData.cSearchText ? myData.cSearchText : myData.sCurrentText->str,
		"",
		TRUE);
	cd_debug ("cEscapedText : %s", cEscapedText);
	gchar *cURI = g_strdup_printf (pEntry->cPath, cEscapedText);
	cairo_dock_fm_launch_uri (cURI);
	g_free (cURI);
	g_free (cEscapedText);
}
static void _show_local_file (GtkMenuItem *menu_item, CDUploadedItem *pItem)
{
	if (pItem->iFileType == CD_TYPE_TEXT)
	{
		cd_dnd2share_copy_url_to_clipboard (pItem->cLocalPath);
		if (myConfig.bEnableDialogs)
		{
			cairo_dock_remove_dialog_if_any (myIcon);
			cairo_dock_show_temporary_dialog_with_icon (D_("The text has been pasted in the clipboard.\nYou can retrieve it with CTRL+v."),
				myIcon,
				myContainer,
				myConfig.dTimeDialogs,
				MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE);
		}
	}
	else
	{
		if (g_file_test (pItem->cLocalPath, G_FILE_TEST_EXISTS))
			cairo_dock_fm_launch_uri (pItem->cLocalPath);
		else
		{
			gchar *cPreviewPath = g_strdup_printf ("%s/%s", myData.cWorkingDirPath, pItem->cItemName);
			if (g_file_test (cPreviewPath, G_FILE_TEST_EXISTS))
			{
				cairo_dock_fm_launch_uri (cPreviewPath);
			}
			else
			{
				cd_warning ("couldn't find the orignial file nor a preview of it");
				cairo_dock_remove_dialog_if_any (myIcon);
				cairo_dock_show_temporary_dialog_with_icon (D_("Sorry, couldn't find the orignial file nor a preview of it."),
					myIcon,
					myContainer,
					myConfig.dTimeDialogs,
					MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE);
			}
			g_free (cPreviewPath);
		}
	}
}
static void _on_activate_item (GtkWidget *pMenuItem, CDQuickBrowserItem *pItem)
{
	g_return_if_fail (pItem != NULL);
	GldiModuleInstance *myApplet = pItem->pApplet;
	CD_APPLET_ENTER;
	if (pItem->pSubMenu != NULL)
	{
		if (! pItem->bMenuBuilt)
		{
			if (myData.iSidFillDirIdle != 0)
				g_source_remove (myData.iSidFillDirIdle);
			myData.iSidFillDirIdle = g_idle_add ((GSourceFunc) _fill_submenu_idle, pItem);
		}
	}
	else // left click, no drag
	{
		cairo_dock_fm_launch_uri (pItem->cPath);
		cd_quick_browser_destroy_menu (myApplet);
	}
	CD_APPLET_LEAVE ();
}
static void _cd_open_parent (GtkMenuItem *pMenuItem, gpointer data)
{
    gchar *cFolder = g_path_get_dirname (myData.cCurrentUri);
    cairo_dock_fm_launch_uri (cFolder);
    g_free (cFolder);
}
static void _cd_open (GtkMenuItem *pMenuItem, gpointer data)
{
    cairo_dock_fm_launch_uri (myData.cCurrentUri);
}
static void _cd_do_launch_file (CDEntry *pEntry)
{
	g_print ("%s (%s)\n", __func__, pEntry->cPath);
	cairo_dock_fm_launch_uri (pEntry->cPath);
}
static gboolean _on_click_module_tree_view (GtkTreeView *pTreeView, GdkEventButton* pButton, gpointer data)
{
	//g_print ("%s ()\n", __func__);
	if ((pButton->button == 3 && pButton->type == GDK_BUTTON_RELEASE)  // right-click
	|| (pButton->button == 1 && pButton->type == GDK_2BUTTON_PRESS))  // double-click
	{
		cd_debug ("%s ()", __func__);
		// get the current selected line.
		GtkTreeSelection *pSelection = gtk_tree_view_get_selection (pTreeView);
		GtkTreeModel *pModel;
		GtkTreeIter iter;
		if (! gtk_tree_selection_get_selected (pSelection, &pModel, &iter))
			return FALSE;
		
		gchar *cName = NULL, *cUri = NULL;
		guint id = 0;
		gtk_tree_model_get (pModel, &iter,
			CD_MODEL_NAME, &cName,
			CD_MODEL_URI, &cUri,
			CD_MODEL_ID, &id, -1);
		
		//launch or build the menu.
		gboolean bIsAppli = (strncmp (cUri, "application://", 14) == 0);
		if (pButton->button == 1)  // double-click
		{
			if (bIsAppli)  // an appli -> run it
			{
				gchar *tmp = strrchr (cUri, '.');  // remove the '.desktop'
				if (tmp)
					*tmp = '\0';
				cairo_dock_launch_command (cUri+14);
			}
			else  // a file -> open it
			{
				cairo_dock_fm_launch_uri (cUri);
			}
			g_free (cUri);
		}
		else  // right-click
		{
			GtkWidget *pMenu = gldi_menu_new (NULL);
			g_free (myData.cCurrentUri);
			myData.cCurrentUri = cUri;
			
			if (!bIsAppli)
			{
				GList *pApps = cairo_dock_fm_list_apps_for_file (cUri);
				if (pApps != NULL)
				{
					GtkWidget *pSubMenu = CD_APPLET_ADD_SUB_MENU_WITH_IMAGE (D_("Open with"), pMenu, GLDI_ICON_NAME_OPEN);
					
					cd_folders_free_apps_list (myApplet);
					
					GList *a;
					gchar **pAppInfo;
					gchar *cIconPath;
					for (a = pApps; a != NULL; a = a->next)
					{
						pAppInfo = a->data;
						myData.pAppList = g_list_prepend (myData.pAppList, pAppInfo[1]);
						
						if (pAppInfo[2] != NULL)
							cIconPath = cairo_dock_search_icon_s_path (pAppInfo[2], cairo_dock_search_icon_size (GTK_ICON_SIZE_MENU));
						else
							cIconPath = NULL;
						CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (pAppInfo[0], cIconPath, _cd_launch_with, pSubMenu, pAppInfo[1]);
						g_free (cIconPath);
						g_free (pAppInfo[0]);
						g_free (pAppInfo[2]);
						g_free (pAppInfo);
					}
					g_list_free (pApps);
				}
				CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Open parent folder"), GLDI_ICON_NAME_DIRECTORY, _cd_open_parent, pMenu, NULL);
				
				CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Copy the location"), GLDI_ICON_NAME_COPY, _cd_copy_location, pMenu, NULL);
			}
			
			CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Delete this event"), GLDI_ICON_NAME_REMOVE, _cd_delete_event, pMenu, GUINT_TO_POINTER (id));
			
			gtk_widget_show_all (pMenu);
			gtk_menu_popup (GTK_MENU (pMenu),
				NULL,
				NULL,
				NULL,  // popup on mouse.
				NULL,
				1,
				gtk_get_current_event_time ());
		}
	}
	return FALSE;
}