diff --git a/Makefile.am b/Makefile.am index 94c8f3eb..bd2a6e96 100644 --- a/Makefile.am +++ b/Makefile.am @@ -79,7 +79,9 @@ appdata_DATA = $(appdata_in_files:.xml.in=.xml) appdata_in_files = org.xfce.thunar.appdata.xml.in servicedir = $(datadir)/dbus-1/services -service_in_files = org.xfce.FileManager.service.in org.xfce.Thunar.service.in +service_in_files = org.xfce.FileManager.service.in \ + org.xfce.Thunar.service.in \ + org.freedesktop.FileManager1.service.in service_DATA = $(service_in_files:.service.in=.service) systemd_userdir = $(prefix)/lib/systemd/user diff --git a/org.freedesktop.FileManager1.service.in b/org.freedesktop.FileManager1.service.in new file mode 100644 index 00000000..e0b3fade --- /dev/null +++ b/org.freedesktop.FileManager1.service.in @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=org.freedesktop.FileManager1 +Exec=@bindir@/Thunar --gapplication-service +SystemdService=thunar.service diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c index c5ea2868..bc845ddc 100644 --- a/thunar/thunar-application.c +++ b/thunar/thunar-application.c @@ -208,7 +208,8 @@ struct _ThunarApplication GList *files_to_launch; - guint dbus_owner_id; + guint dbus_owner_id_xfce; + guint dbus_owner_id_fdo; }; @@ -324,14 +325,23 @@ thunar_application_dbus_init (ThunarApplication *application) if (geteuid() == 0) return; - application->dbus_owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, - "org.xfce.FileManager", - G_BUS_NAME_OWNER_FLAGS_NONE, - thunar_application_dbus_acquired_cb, - thunar_application_name_acquired_cb, - thunar_application_dbus_name_lost_cb, - application, - NULL); + application->dbus_owner_id_xfce = g_bus_own_name (G_BUS_TYPE_SESSION, + "org.xfce.FileManager", + G_BUS_NAME_OWNER_FLAGS_NONE, + thunar_application_dbus_acquired_cb, + thunar_application_name_acquired_cb, + thunar_application_dbus_name_lost_cb, + application, + NULL); + + application->dbus_owner_id_fdo = g_bus_own_name (G_BUS_TYPE_SESSION, + "org.freedesktop.FileManager1", + G_BUS_NAME_OWNER_FLAGS_NONE, + thunar_application_dbus_acquired_cb, + thunar_application_name_acquired_cb, + thunar_application_dbus_name_lost_cb, + application, + NULL); } diff --git a/thunar/thunar-dbus-service-infos.xml b/thunar/thunar-dbus-service-infos.xml index 572447f5..97ce97fb 100644 --- a/thunar/thunar-dbus-service-infos.xml +++ b/thunar/thunar-dbus-service-infos.xml @@ -483,6 +483,22 @@ + + + + + + + + + + + + + + + + diff --git a/thunar/thunar-dbus-service.c b/thunar/thunar-dbus-service.c index 66c104b7..e38dbad0 100644 --- a/thunar/thunar-dbus-service.c +++ b/thunar/thunar-dbus-service.c @@ -220,6 +220,21 @@ static gboolean thunar_dbus_service_terminate (ThunarDBusThuna GDBusMethodInvocation *invocation, ThunarDBusService *dbus_service); +static gboolean thunar_dbus_show_folders (ThunarOrgFreedesktopFileManager1 *object, + GDBusMethodInvocation *invocation, + gchar **uris, + const gchar *startup_id, + ThunarDBusService *dbus_service); +static gboolean thunar_dbus_show_items (ThunarOrgFreedesktopFileManager1 *object, + GDBusMethodInvocation *invocation, + gchar **uris, + const gchar *startup_id, + ThunarDBusService *dbus_service); +static gboolean thunar_dbus_show_item_properties (ThunarOrgFreedesktopFileManager1 *object, + GDBusMethodInvocation *invocation, + gchar **uris, + const gchar *startup_id, + ThunarDBusService *dbus_service); struct _ThunarDBusServiceClass @@ -231,9 +246,10 @@ struct _ThunarDBusService { GObject __parent__; - ThunarDBusFileManager *file_manager; - ThunarDBusTrash *trash; - ThunarDBusThunar *thunar; + ThunarDBusFileManager *file_manager; + ThunarDBusTrash *trash; + ThunarDBusThunar *thunar; + ThunarOrgFreedesktopFileManager1 *file_manager_fdo; ThunarFile *trash_bin; }; @@ -281,9 +297,10 @@ static void connect_signals_multiple (gpointer object, static void thunar_dbus_service_init (ThunarDBusService *dbus_service) { - dbus_service->file_manager = thunar_dbus_file_manager_skeleton_new (); - dbus_service->trash = thunar_dbus_trash_skeleton_new (); - dbus_service->thunar = thunar_dbus_thunar_skeleton_new (); + dbus_service->file_manager = thunar_dbus_file_manager_skeleton_new (); + dbus_service->trash = thunar_dbus_trash_skeleton_new (); + dbus_service->thunar = thunar_dbus_thunar_skeleton_new (); + dbus_service->file_manager_fdo = thunar_org_freedesktop_file_manager1_skeleton_new (); connect_signals_multiple (dbus_service->file_manager, dbus_service, "handle-display-chooser-dialog", thunar_dbus_service_display_chooser_dialog, @@ -315,6 +332,12 @@ thunar_dbus_service_init (ThunarDBusService *dbus_service) "handle-bulk-rename", thunar_dbus_service_bulk_rename, "handle-terminate", thunar_dbus_service_terminate, NULL); + + connect_signals_multiple (dbus_service->file_manager_fdo, dbus_service, + "handle-show-folders", thunar_dbus_show_folders, + "handle-show-items", thunar_dbus_show_items, + "handle-show-item-properties", thunar_dbus_show_item_properties, + NULL); } @@ -327,6 +350,7 @@ thunar_dbus_service_finalize (GObject *object) g_object_unref (dbus_service->file_manager); g_object_unref (dbus_service->trash); g_object_unref (dbus_service->thunar); + g_object_unref (dbus_service->file_manager_fdo); if (dbus_service->trash_bin) g_object_unref (dbus_service->trash_bin); @@ -1475,6 +1499,91 @@ thunar_dbus_service_terminate (ThunarDBusThunar *object, +static gboolean +thunar_dbus_show_folders (ThunarOrgFreedesktopFileManager1 *object, + GDBusMethodInvocation *invocation, + gchar **uris, + const gchar *startup_id, + ThunarDBusService *dbus_service) +{ + g_spawn_command_line_async ("notify-send Implement show folder!", NULL); + + thunar_org_freedesktop_file_manager1_complete_show_folders (object, invocation); + + return TRUE; +} + + + +static gboolean +thunar_dbus_show_items (ThunarOrgFreedesktopFileManager1 *object, + GDBusMethodInvocation *invocation, + gchar **uris, + const gchar *startup_id, + ThunarDBusService *dbus_service) +{ + ThunarApplication *application; + GtkWidget *window; + GdkScreen *screen; + gint n; + GFile *file, *parent; + ThunarFile *thunar_folder, *thunar_file; + + screen = gdk_screen_get_default (); + application = thunar_application_get (); + + for (n = 0; uris[n] != NULL; ++n) + { + file = g_file_new_for_uri (uris[n]); + parent = g_file_get_parent (file); + + if (G_LIKELY (parent != NULL)) + { + thunar_folder = thunar_file_get (parent, NULL); + thunar_file = thunar_file_get (file, NULL); + + window = thunar_application_open_window (application, thunar_folder, screen, startup_id, FALSE); + + if (G_LIKELY (file != NULL)) + thunar_window_scroll_to_file (THUNAR_WINDOW (window), thunar_file, TRUE, TRUE, 0.5f, 0.5f); + + g_object_unref (parent); + g_object_unref (thunar_folder); + g_object_unref (thunar_file); + } + else + { + // TODO implement me! + } + + g_object_unref (file); + } + + g_object_unref (application); + + thunar_org_freedesktop_file_manager1_complete_show_items (object, invocation); + + return TRUE; +} + + + +static gboolean +thunar_dbus_show_item_properties (ThunarOrgFreedesktopFileManager1 *object, + GDBusMethodInvocation *invocation, + gchar **uris, + const gchar *startup_id, + ThunarDBusService *dbus_service) +{ + g_spawn_command_line_async ("notify-send Implement show item property!", NULL); + + thunar_org_freedesktop_file_manager1_complete_show_item_properties (object, invocation); + + return TRUE; +} + + + gboolean thunar_dbus_service_export_on_connection (ThunarDBusService *service, GDBusConnection *connection, GError **error) @@ -1497,6 +1606,12 @@ gboolean thunar_dbus_service_export_on_connection (ThunarDBusService *service, error)) goto fail; + if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (service->file_manager_fdo), + connection, + "/org/freedesktop/FileManager1", + error)) + goto fail; + return TRUE; fail: @@ -1504,5 +1619,6 @@ fail: g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (service->file_manager), connection); g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (service->trash), connection); g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (service->thunar), connection); + g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (service->file_manager_fdo), connection); return FALSE; }