diff -Nur thunar-shares-plugin-0.2.0/thunar-plugin/tsp-provider.c thunar-shares-plugin-0.2.0-addShareOptionMenuItem/thunar-plugin/tsp-provider.c --- thunar-shares-plugin-0.2.0/thunar-plugin/tsp-provider.c 2009-02-16 03:54:41.000000000 +0800 +++ thunar-shares-plugin-0.2.0-addShareOptionMenuItem/thunar-plugin/tsp-provider.c 2009-09-09 15:23:45.000000000 +0800 @@ -35,9 +35,13 @@ static void tsp_provider_page_provider_init (ThunarxPropertyPageProviderIface *iface); static void tsp_provider_prefs_provider_init (ThunarxPreferencesProviderIface *iface); +static void tsp_provider_menu_provider_init (ThunarxMenuProviderIface *iface); static GList *tsp_provider_get_pages (ThunarxPropertyPageProvider *provider, GList *files); +static GList *tsp_provider_get_menu (ThunarxMenuProvider *provider, + GtkWidget *window, + GList *files); struct _TspProviderClass { @@ -55,7 +59,9 @@ THUNARX_IMPLEMENT_INTERFACE (THUNARX_TYPE_PROPERTY_PAGE_PROVIDER, tsp_provider_page_provider_init) THUNARX_IMPLEMENT_INTERFACE (THUNARX_TYPE_PREFERENCES_PROVIDER, - tsp_provider_prefs_provider_init)); + tsp_provider_prefs_provider_init) + THUNARX_IMPLEMENT_INTERFACE (THUNARX_TYPE_MENU_PROVIDER, + tsp_provider_menu_provider_init));/* add a menu provider */ static void tsp_provider_class_init (TspProviderClass *klass) @@ -90,6 +96,13 @@ /* Bleh..! */ } +static void +tsp_provider_menu_provider_init (ThunarxMenuProviderIface *iface) +{ + /* add action to folder */ + iface->get_file_actions = tsp_provider_get_menu; +} + static GList* tsp_provider_get_pages (ThunarxPropertyPageProvider *property_page_provider, GList *files) @@ -102,3 +115,52 @@ return g_list_append (NULL, (gpointer)tsp_page_new (files->data)); } + +/* show share property page callback function */ +static void +share_this_folder_callback (GtkAction *action, gpointer user_data) +{ + GtkWidget * window; + GtkWidget * tsp_page; + + tsp_page = tsp_page_new(user_data); + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + gtk_container_add (GTK_CONTAINER (window), tsp_page); + gtk_widget_show (tsp_page); + gtk_widget_show (window); +} + +/* setup Sharing Option... to menu */ +static GList* +tsp_provider_get_menu (ThunarxMenuProvider *menu_provider, + GtkWidget *window, + GList *files) +{ + /* check if files can be shared */ + if (g_list_length (files) != 1){ + return NULL; + } else if (!libshares_is_shareable (THUNARX_FILE_INFO (files->data))){ + return NULL; + } + + GtkAction *action = NULL; + ThunarxFileInfo *file_info = files->data; + + /* check if file is a directory */ + if(thunarx_file_info_is_directory(file_info)){ + /* append the "Sharing Option" action */ + action = g_object_new (GTK_TYPE_ACTION, + "name", "TspProvider::share", + "label","Sharing Option...", +#if !GTK_CHECK_VERSION(2,9,0) + "stock-id", "gnome-fs-share", +#else + "icon-name", "gnome-fs-share", +#endif + "tooltip", "Share this Folder",NULL); + /* set callback function */ + g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (share_this_folder_callback), file_info); + } + return (action != NULL) ? g_list_prepend (NULL, action) : NULL; +} diff -Nur thunar-shares-plugin-0.2.0/libshares/libshares-util.c thunar-shares-plugin-0.2.0-dif/libshares/libshares-util.c --- thunar-shares-plugin-0.2.0/libshares/libshares-util.c 2009-02-16 03:54:41.000000000 +0800 +++ thunar-shares-plugin-0.2.0-dif/libshares/libshares-util.c 2009-10-12 16:32:29.000000000 +0800 @@ -22,6 +22,8 @@ #include #endif +#include + #include #include @@ -315,7 +317,7 @@ gboolean libshares_check_owner (ThunarxFileInfo *info) { - ThunarVfsInfo *vfsinfo; + // ThunarVfsInfo *vfsinfo; gboolean retval = TRUE; gboolean owner_only; @@ -323,11 +325,16 @@ { if (owner_only) { +#if 0 vfsinfo = thunarx_file_info_get_vfs_info (info); retval = (geteuid () == vfsinfo->uid); +#endif + guint32 uid = g_file_info_get_attribute_uint32 (thunarx_file_info_get_file_info(info), + G_FILE_ATTRIBUTE_UNIX_UID); + retval = (geteuid () == uid); - thunar_vfs_info_unref (vfsinfo); + // thunar_vfs_info_unref (vfsinfo); } }