[nautilus/wip/csoriano/destktop-split2: 6/7] application: allow overriding startup



commit 58da6fdf42d7df9ba84eff96e87135f498332d3f
Author: Carlos Soriano <csoriano gnome org>
Date:   Tue Mar 15 22:16:56 2016 +0100

    application: allow overriding startup
    
    The startup vfunc comes from GApplication, and therefore any children
    of a GApplication that overrides this function cannot call the
    application parent code that handles the startup.
    
    We would like to be able of subclassing nautilus application, and doing
    custom handling in the startup vfunc, but still use the code of the
    nautilus application that already deals with it.
    
    For that, we need to create a new vfunc in nautilus application that
    will be called when the GApplication startup vfunc is called, so
    children can override it and still use the nautilus application code
    handling.
    
    This will be needed for upcoming patches when we will create a
    desktop application.

 src/nautilus-application.c |    7 +++++++
 src/nautilus-application.h |    1 +
 2 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index c0296e7..6bec5fd 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -1212,6 +1212,12 @@ on_application_shutdown (GApplication *application,
 static void
 nautilus_application_startup (GApplication *app)
 {
+        NAUTILUS_APPLICATION_CLASS (G_OBJECT_GET_CLASS (app))->startup (app);
+}
+
+static void
+real_startup (GApplication *app)
+{
        NautilusApplication *self = NAUTILUS_APPLICATION (app);
         NautilusApplicationPrivate *priv;
 
@@ -1475,6 +1481,7 @@ nautilus_application_class_init (NautilusApplicationClass *class)
        application_class->handle_local_options = nautilus_application_handle_local_options;
 
        class->open_location_full = real_open_location_full;
+        class->startup = real_startup;
 
        gtkapp_class = GTK_APPLICATION_CLASS (class);
        gtkapp_class->window_added = nautilus_application_window_added;
diff --git a/src/nautilus-application.h b/src/nautilus-application.h
index f6f8b8c..c40cdef 100644
--- a/src/nautilus-application.h
+++ b/src/nautilus-application.h
@@ -42,6 +42,7 @@ struct _NautilusApplicationClass {
                                      GList                   *selection,
                                      NautilusWindow          *target_window,
                                      NautilusWindowSlot      *target_slot);
+        void (*startup) (GApplication *app);
 };
 
 NautilusApplication * nautilus_application_new (void);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]