Permalink
Browse files

Add support for freedesktop.org File Manager DBus Interface

  • Loading branch information...
1 parent e99cd96 commit d1715e4fdef385cea4eda116090311dcff9fcd18 @stefano-k stefano-k committed Feb 23, 2013
View
@@ -19,6 +19,14 @@ desktop_in_files = \
mimedir = $(datadir)/mime/packages
mime_DATA = $(xml_files)
+servicedir = $(datadir)/dbus-1/services
+service_DATA = $(service_in_files:.service.in=.service)
+service_in_files = \
+ org.mate.freedesktop.FileManager1.service.in
+
+org.mate.freedesktop.FileManager1.service: org.mate.freedesktop.FileManager1.service.in Makefile
+ $(AM_V_GEN) sed -e "s|\@bindir\@|$(bindir)|" $< > $@
+
cajadatadir = $(datadir)/caja
cajadata_DATA = \
@@ -30,6 +38,7 @@ cajadata_DATA = \
EXTRA_DIST = $(cajadata_DATA) \
caja.desktop \
caja.desktop.in \
+ freedesktop-dbus-interfaces.xml \
$(xml_in_files) \
$(desktop_in_files) \
$(NULL)
@@ -0,0 +1,36 @@
+<!DOCTYPE node PUBLIC
+"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+
+<!--
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+-->
+<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
+ <interface name='org.freedesktop.FileManager1'>
+ <method name='ShowFolders'>
+ <arg type='as' name='URIs' direction='in'/>
+ <arg type='s' name='StartupId' direction='in'/>
+ </method>
+ <method name='ShowItems'>
+ <arg type='as' name='URIs' direction='in'/>
+ <arg type='s' name='StartupId' direction='in'/>
+ </method>
+ <method name='ShowItemProperties'>
+ <arg type='as' name='URIs' direction='in'/>
+ <arg type='s' name='StartupId' direction='in'/>
+ </method>
+ </interface>
+</node>
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.freedesktop.FileManager1
+Exec=@bindir@/caja --no-default-window
View
@@ -43,6 +43,19 @@ LDADD = \
$(POPT_LIBS) \
$(NULL)
+dbus_freedesktop_built_sources = \
+ caja-freedesktop-generated.c \
+ caja-freedesktop-generated.h
+
+$(dbus_freedesktop_built_sources) : Makefile.am $(top_srcdir)/data/freedesktop-dbus-interfaces.xml
+ gdbus-codegen \
+ --interface-prefix org.freedesktop. \
+ --c-namespace CajaFreedesktop \
+ --c-generate-object-manager \
+ --generate-c-code caja-freedesktop-generated \
+ $(top_srcdir)/data/freedesktop-dbus-interfaces.xml \
+ $(NULL)
+
@INTLTOOL_DESKTOP_RULE@
desktop_in_files=mate-network-scheme.desktop.in
@@ -55,6 +68,7 @@ scheme_DATA = mate-network-scheme.desktop
BUILT_SOURCES = \
caja-src-marshal.c \
caja-src-marshal.h \
+ $(dbus_freedesktop_built_sources) \
$(NULL)
caja_SOURCES = \
@@ -76,6 +90,8 @@ caja_SOURCES = \
caja-emblem-sidebar.h \
caja-file-management-properties.c \
caja-file-management-properties.h \
+ caja-freedesktop-dbus.c \
+ caja-freedesktop-dbus.h \
caja-history-sidebar.c \
caja-history-sidebar.h \
caja-image-properties-page.c \
View
@@ -55,6 +55,7 @@
#include "libcaja-private/caja-file-operations.h"
#include "caja-window-private.h"
#include "caja-window-manage-views.h"
+#include "caja-freedesktop-dbus.h"
#include <unistd.h>
#include <libxml/xmlsave.h>
#include <glib/gstdio.h>
@@ -107,6 +108,9 @@ static GList *caja_application_spatial_window_list;
/* The saving of the accelerator map was requested */
static gboolean save_of_accel_map_requested = FALSE;
+/* File Manager DBus Interface */
+static CajaFreedesktopDBus *fdb_manager = NULL;
+
static void desktop_changed_callback (gpointer user_data);
static void desktop_location_changed_callback (gpointer user_data);
static void mount_removed_callback (GVolumeMonitor *monitor,
@@ -370,6 +374,12 @@ caja_application_finalize (GObject *object)
application->proxy = NULL;
}
+ if (fdb_manager != NULL)
+ {
+ g_object_unref (fdb_manager);
+ fdb_manager = NULL;
+ }
+
G_OBJECT_CLASS (caja_application_parent_class)->finalize (object);
}
@@ -846,6 +856,29 @@ open_windows (CajaApplication *application,
}
}
+void
+caja_application_open_location (CajaApplication *application,
+ GFile *location,
+ GFile *selection,
+ const char *startup_id)
+{
+ CajaWindow *window;
+ GList *sel_list = NULL;
+
+ window = caja_application_create_navigation_window (application, startup_id, gdk_screen_get_default ());
+
+ if (selection != NULL) {
+ sel_list = g_list_prepend (NULL, g_object_ref (selection));
+ }
+
+ caja_window_slot_open_location_full (caja_window_get_active_slot (window), location,
+ 0, CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW, sel_list, NULL, NULL);
+
+ if (sel_list != NULL) {
+ caja_file_list_free (sel_list);
+ }
+}
+
static UniqueResponse
message_received_cb (UniqueApp *unique_app,
gint command,
@@ -985,6 +1018,9 @@ caja_application_startup (CajaApplication *application,
g_signal_connect (application->unique_app, "message-received", G_CALLBACK (message_received_cb), application);
}
+ /* Start the File Manager DBus Interface */
+ fdb_manager = caja_freedesktop_dbus_new (application);
+
/* Monitor the preference to show or hide the desktop */
g_signal_connect_swapped (mate_background_preferences,
"changed::" MATE_BG_KEY_SHOW_DESKTOP,
View
@@ -105,6 +105,9 @@ void caja_application_close_all_spatial_windows (void);
void caja_application_open_desktop (CajaApplication *application);
void caja_application_close_desktop (void);
gboolean caja_application_save_accel_map (gpointer data);
-
+void caja_application_open_location (CajaApplication *application,
+ GFile *location,
+ GFile *selection,
+ const char *startup_id);
#endif /* CAJA_APPLICATION_H */
Oops, something went wrong.

0 comments on commit d1715e4

Please sign in to comment.