[nautilus/wip/csoriano/destktop-split2] desktop: move to a different binary
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/destktop-split2] desktop: move to a different binary
- Date: Tue, 15 Mar 2016 21:39:51 +0000 (UTC)
commit ed0e27cbefc3c91720c0fd7104dda640c2e8fe48
Author: Carlos Soriano <csoriano gnome org>
Date: Tue Mar 15 22:20:27 2016 +0100
desktop: move to a different binary
We wanted to do this for long time. This will allow to handle the
desktop process in a different binary.
The ultimate goal is to make the desktop code completely split from
nautilus code.
This is the first and minimal step towards that goal.
In this patch we create a desktop application separated from nautilus
application, and remove the desktop handling in nautilus application.
data/nautilus-autostart.desktop.in | 2 +-
src/Makefile.am | 20 ++++-
src/main-desktop.c | 41 ++++++++
src/nautilus-application.c | 76 ---------------
src/nautilus-desktop-application.c | 181 ++++++++++++++++++++++++++++++++++++
src/nautilus-desktop-application.h | 36 +++++++
6 files changed, 277 insertions(+), 79 deletions(-)
---
diff --git a/data/nautilus-autostart.desktop.in b/data/nautilus-autostart.desktop.in
index 7252f87..d161ffe 100644
--- a/data/nautilus-autostart.desktop.in
+++ b/data/nautilus-autostart.desktop.in
@@ -1,6 +1,6 @@
[Desktop Entry]
Type=Application
Name=Files
-Exec=nautilus -n
+Exec=nautilus-desktop
OnlyShowIn=GNOME;Unity;
AutostartCondition=GSettings org.gnome.desktop.background show-desktop-icons
diff --git a/src/Makefile.am b/src/Makefile.am
index 608e6a6..6445aa0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,6 +2,7 @@ include $(top_srcdir)/Makefile.shared
bin_PROGRAMS= \
nautilus \
+ nautilus-desktop \
nautilus-autorun-software \
$(NULL)
@@ -134,7 +135,7 @@ nautilus_built_sources = \
nautilus-enum-types.c \
$(NULL)
-nautilus_SOURCES = \
+nautilus_no_main_sources = \
gtk/nautilusgtkplacesview.c \
gtk/nautilusgtkplacesviewprivate.h \
gtk/nautilusgtkplacesviewrow.c \
@@ -178,7 +179,6 @@ nautilus_SOURCES = \
nautilus-list-view-dnd.h \
nautilus-location-entry.c \
nautilus-location-entry.h \
- nautilus-main.c \
nautilus-mime-actions.c \
nautilus-mime-actions.h \
nautilus-notebook.c \
@@ -221,10 +221,26 @@ nautilus_SOURCES = \
nautilus-x-content-bar.h \
$(NULL)
+nautilus_SOURCES = \
+ $(nautilus_no_main_sources) \
+ nautilus-main.c \
+ $(NULL)
+
+nautilus_desktop_SOURCES= \
+ $(nautilus_no_main_sources) \
+ main-desktop.c \
+ nautilus-desktop-application.c \
+ nautilus-desktop-application.h \
+ $(NULL)
+
nodist_nautilus_SOURCES = \
$(nautilus_built_sources) \
$(NULL)
+nodist_nautilus_desktop_SOURCES = \
+ $(nautilus_built_sources) \
+ $(NULL)
+
EMPTY_VIEW_SOURCES = \
nautilus-empty-view.c \
nautilus-empty-view.h
diff --git a/src/main-desktop.c b/src/main-desktop.c
new file mode 100644
index 0000000..27202ef
--- /dev/null
+++ b/src/main-desktop.c
@@ -0,0 +1,41 @@
+#include <config.h>
+
+#include "nautilus-desktop-application.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <gio/gdesktopappinfo.h>
+
+#include <libxml/parser.h>
+
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int
+main (int argc, char *argv[])
+{
+ NautilusDesktopApplication *application;
+ int retval;
+
+ /* Initialize gettext support */
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ g_set_prgname ("nautilus-desktop");
+ g_print ("main desktop\n");
+
+ /* Run the nautilus application. */
+ application = nautilus_desktop_application_new ();
+
+ retval = g_application_run (G_APPLICATION (application),
+ argc, argv);
+
+ g_object_unref (application);
+
+ return retval;
+}
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 6bec5fd..4320fa4 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -728,27 +728,6 @@ action_help (GSimpleAction *action,
}
static void
-action_open_desktop (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- nautilus_desktop_window_ensure ();
-}
-
-static void
-action_close_desktop (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- GtkWidget *desktop_window;
-
- desktop_window = nautilus_desktop_window_get ();
- if (desktop_window != NULL) {
- gtk_widget_destroy (desktop_window);
- }
-}
-
-static void
action_kill (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -818,8 +797,6 @@ static GActionEntry app_entries[] = {
{ "help", action_help, NULL, NULL, NULL },
{ "quit", action_quit, NULL, NULL, NULL },
{ "kill", action_kill, NULL, NULL, NULL },
- { "open-desktop", action_open_desktop, NULL, NULL, NULL },
- { "close-desktop", action_close_desktop, NULL, NULL, NULL },
{ "show-help-overlay", action_show_help_overlay, NULL, NULL, NULL },
};
@@ -1037,58 +1014,6 @@ nautilus_application_init (NautilusApplication *self)
}
static void
-nautilus_application_set_desktop_visible (NautilusApplication *self,
- gboolean visible)
-{
- const gchar *action_name;
-
- action_name = visible ? "open-desktop" : "close-desktop";
- g_action_group_activate_action (G_ACTION_GROUP (self),
- action_name, NULL);
-}
-
-static void
-update_desktop_from_gsettings (NautilusApplication *self)
-{
- NautilusApplicationPrivate *priv;
- GdkDisplay *display;
- gboolean visible;
-
- priv = nautilus_application_get_instance_private (self);
- /* desktop GSetting was overridden - don't do anything */
- if (priv->desktop_override) {
- return;
- }
-
-#ifdef GDK_WINDOWING_X11
- display = gdk_display_get_default ();
- visible = g_settings_get_boolean (gnome_background_preferences,
- NAUTILUS_PREFERENCES_SHOW_DESKTOP);
- if (!GDK_IS_X11_DISPLAY (display)) {
- if (visible)
- g_warning ("Desktop icons only supported on X11. Desktop not created");
-
- return;
- }
-
- nautilus_application_set_desktop_visible (self, visible);
-
- return;
-#endif
-
- g_warning ("Desktop icons only supported on X11. Desktop not created");
-}
-
-static void
-init_desktop (NautilusApplication *self)
-{
- g_signal_connect_swapped (gnome_background_preferences, "changed::" NAUTILUS_PREFERENCES_SHOW_DESKTOP,
- G_CALLBACK (update_desktop_from_gsettings),
- self);
- update_desktop_from_gsettings (self);
-}
-
-static void
theme_changed (GtkSettings *settings)
{
static GtkCssProvider *provider = NULL;
@@ -1262,7 +1187,6 @@ real_startup (GApplication *app)
check_required_directories (self);
nautilus_init_application_actions (self);
- init_desktop (self);
nautilus_profile_end (NULL);
diff --git a/src/nautilus-desktop-application.c b/src/nautilus-desktop-application.c
new file mode 100644
index 0000000..b1e2361
--- /dev/null
+++ b/src/nautilus-desktop-application.c
@@ -0,0 +1,181 @@
+/* nautilus-desktop-application.c
+ *
+ * Copyright (C) 2016 Carlos Soriano <csoriano gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "nautilus-desktop-application.h"
+#include "nautilus-desktop-window.h"
+
+#include <libnautilus-private/nautilus-global-preferences.h>
+#include <gdk/gdkx.h>
+
+struct _NautilusDesktopApplication
+{
+ NautilusApplication parent_instance;
+};
+
+G_DEFINE_TYPE (NautilusDesktopApplication, nautilus_desktop_application, NAUTILUS_TYPE_APPLICATION)
+
+
+static void
+open_location_full (NautilusApplication *self,
+ GFile *location,
+ NautilusWindowOpenFlags flags,
+ GList *selection,
+ NautilusWindow *target_window,
+ NautilusWindowSlot *target_slot)
+{
+ gchar *uri;
+
+ g_print ("open location full %s\n", g_file_get_uri (location));
+ uri = g_file_get_uri (location);
+ if (eel_uri_is_desktop (uri) && target_window && NAUTILUS_IS_DESKTOP_WINDOW (target_window))
+ {
+ nautilus_window_open_location_full (target_window, location, 0, selection, NULL);
+ }
+ else
+ {
+ g_print ("other location, use dbus to communicate with nautilus. This process is only for the
desktop\n");
+ }
+ g_free (uri);
+}
+
+static void
+nautilus_application_set_desktop_visible (NautilusApplication *self,
+ gboolean visible)
+{
+ GtkWidget *desktop_window;
+
+ if (visible)
+ {
+ g_print ("set desktop visible\n");
+ nautilus_desktop_window_ensure ();
+ }
+ else
+ {
+ desktop_window = nautilus_desktop_window_get ();
+ if (desktop_window != NULL) {
+ gtk_widget_destroy (desktop_window);
+ }
+ }
+}
+
+static void
+update_desktop_from_gsettings (NautilusApplication *self)
+{
+ GdkDisplay *display;
+ gboolean visible;
+
+#ifdef GDK_WINDOWING_X11
+ display = gdk_display_get_default ();
+ visible = g_settings_get_boolean (gnome_background_preferences,
+ NAUTILUS_PREFERENCES_SHOW_DESKTOP);
+ if (!GDK_IS_X11_DISPLAY (display)) {
+ if (visible)
+ g_warning ("Desktop icons only supported on X11. Desktop not created");
+
+ return;
+ }
+
+ nautilus_application_set_desktop_visible (self, visible);
+
+ return;
+#endif
+
+ g_warning ("Desktop icons only supported on X11. Desktop not created");
+}
+
+static void
+init_desktop (NautilusApplication *self)
+{
+ g_signal_connect_swapped (gnome_background_preferences, "changed::" NAUTILUS_PREFERENCES_SHOW_DESKTOP,
+ G_CALLBACK (update_desktop_from_gsettings),
+ self);
+ update_desktop_from_gsettings (self);
+}
+
+#if 0
+static void
+command_line ()
+{
+
+ if (g_variant_dict_contains (options, "force-desktop")) {
+ DEBUG ("Forcing desktop, as requested");
+ priv->desktop_override = TRUE;
+ g_action_group_activate_action (G_ACTION_GROUP (application),
+ "open-desktop", NULL);
+ } else if (g_variant_dict_contains (options, "no-desktop")) {
+ if (g_application_get_is_remote (application)) {
+ DEBUG ("Not primary instance. Ignoring --no-desktop.");
+ } else {
+ DEBUG ("Forcing desktop off, as requested");
+ priv->desktop_override = TRUE;
+ g_action_group_activate_action (G_ACTION_GROUP (application),
+ "close-desktop", NULL);
+ }
+ }
+
+}
+
+#endif
+
+static void
+nautilus_desktop_application_activate (GApplication *app)
+{
+}
+
+static void
+nautilus_desktop_application_startup (GApplication *app)
+{
+ NautilusDesktopApplication *self = NAUTILUS_DESKTOP_APPLICATION (app);
+
+ g_print ("startup desktop\n");
+ NAUTILUS_APPLICATION_CLASS (nautilus_desktop_application_parent_class)->startup (app);
+
+ init_desktop (self);
+}
+
+static void
+nautilus_desktop_application_class_init (NautilusDesktopApplicationClass *klass)
+{
+ GApplicationClass *application_class = G_APPLICATION_CLASS (klass);
+ NautilusApplicationClass *parent_class = NAUTILUS_APPLICATION_CLASS (klass);
+
+ g_print ("desktop application class init\n");
+
+ parent_class->open_location_full = open_location_full;
+
+ application_class->startup = nautilus_desktop_application_startup;
+ application_class->activate = nautilus_desktop_application_activate;
+}
+
+static void
+nautilus_desktop_application_init (NautilusDesktopApplication *self)
+{
+ g_print ("desktop application init\n");
+}
+
+NautilusDesktopApplication *
+nautilus_desktop_application_new (void)
+{
+ g_print ("desktop application new\n");
+ return g_object_new (NAUTILUS_TYPE_DESKTOP_APPLICATION,
+ "application-id", "org.gnome.NautilusDesktop",
+ NULL);
+}
+
diff --git a/src/nautilus-desktop-application.h b/src/nautilus-desktop-application.h
new file mode 100644
index 0000000..4f4c62c
--- /dev/null
+++ b/src/nautilus-desktop-application.h
@@ -0,0 +1,36 @@
+/* nautilus-desktop-application.h
+ *
+ * Copyright (C) 2016 Carlos Soriano <csoriano gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NAUTILUS_DESKTOP_APPLICATION_H
+#define NAUTILUS_DESKTOP_APPLICATION_H
+
+#include <glib.h>
+#include "nautilus-application.h"
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_DESKTOP_APPLICATION (nautilus_desktop_application_get_type())
+
+G_DECLARE_FINAL_TYPE (NautilusDesktopApplication, nautilus_desktop_application, NAUTILUS,
DESKTOP_APPLICATION, NautilusApplication)
+
+NautilusDesktopApplication *nautilus_desktop_application_new (void);
+
+G_END_DECLS
+
+#endif /* NAUTILUS_DESKTOP_APPLICATION_H */
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]