[gtk+] application: Put shared code into a common function



commit 4cce109e16f71b0e844dab304e97f61bef2a5580
Author: Benjamin Otte <otte redhat com>
Date:   Thu Nov 30 00:09:37 2017 +0100

    application: Put shared code into a common function

 gtk/gtkapplication.c |    9 ++-------
 gtk/gtkmain.c        |   16 +++++++++-------
 gtk/gtkprivate.h     |    2 ++
 3 files changed, 13 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index b96980f..0954d83 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -38,6 +38,7 @@
 #include "gtkbuilder.h"
 #include "gtkshortcutswindow.h"
 #include "gtkintl.h"
+#include "gtkprivate.h"
 
 /* NB: please do not add backend-specific GDK headers here.  This should
  * be abstracted via GtkApplicationImpl.
@@ -311,13 +312,7 @@ gtk_application_shutdown (GApplication *g_application)
 
   gtk_action_muxer_remove (application->priv->muxer, "app");
 
-  /* Keep this section in sync with gtk_main() */
-
-  /* Try storing all clipboard data we have */
-  _gtk_clipboard_store_all ();
-
-  /* Synchronize the recent manager singleton */
-  _gtk_recent_manager_sync ();
+  gtk_main_sync ();
 
   G_APPLICATION_CLASS (gtk_application_parent_class)->shutdown (g_application);
 }
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index a80201c..c71637f 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -995,15 +995,17 @@ gtk_main (void)
   gtk_main_loop_level--;
 
   if (gtk_main_loop_level == 0)
-    {
-      /* Keep this section in sync with gtk_application_shutdown() */
+    gtk_main_sync ();
+}
 
-      /* Try storing all clipboard data we have */
-      _gtk_clipboard_store_all ();
+void
+gtk_main_sync (void)
+{
+  /* Try storing all clipboard data we have */
+  _gtk_clipboard_store_all ();
 
-      /* Synchronize the recent manager singleton */
-      _gtk_recent_manager_sync ();
-    }
+  /* Synchronize the recent manager singleton */
+  _gtk_recent_manager_sync ();
 }
 
 /**
diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h
index 01b71d1..71a5162 100644
--- a/gtk/gtkprivate.h
+++ b/gtk/gtkprivate.h
@@ -63,6 +63,8 @@ gchar       * _gtk_get_lc_ctype           (void);
 
 void          _gtk_ensure_resources       (void);
 
+void          gtk_main_sync               (void);
+
 gboolean _gtk_boolean_handled_accumulator (GSignalInvocationHint *ihint,
                                            GValue                *return_accu,
                                            const GValue          *handler_return,


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