[tepl/wip/file-loading: 3/4] App: add get_active_main_window()



commit b86cf1c81017ec7fee5389d46de3801584b5afea
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Oct 8 15:23:22 2017 +0200

    App: add get_active_main_window()

 docs/reference/tepl-3.0-sections.txt |    1 +
 tepl/tepl-application.c              |   36 ++++++++++++++++++++++++++++++++++
 tepl/tepl-application.h              |    2 +
 3 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index e3f6884..7f978ee 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -196,6 +196,7 @@ tepl_application_get_default
 tepl_application_get_application
 tepl_application_get_app_action_info_store
 tepl_application_get_tepl_action_info_store
+tepl_application_get_active_main_window
 tepl_application_open_simple
 <SUBSECTION Standard>
 TEPL_APPLICATION
diff --git a/tepl/tepl-application.c b/tepl/tepl-application.c
index d90bb7b..4a9f3b2 100644
--- a/tepl/tepl-application.c
+++ b/tepl/tepl-application.c
@@ -20,6 +20,7 @@
 #include "config.h"
 #include "tepl-application.h"
 #include <glib/gi18n-lib.h>
+#include "tepl-application-window.h"
 
 /**
  * SECTION:application
@@ -315,6 +316,41 @@ tepl_application_get_tepl_action_info_store (TeplApplication *tepl_app)
 }
 
 /**
+ * tepl_application_get_active_main_window:
+ * @tepl_app: a #TeplApplication.
+ *
+ * Like gtk_application_get_active_window(), but returns the main window in the
+ * sense of tepl_application_window_is_main_window().
+ *
+ * Returns: (transfer none) (nullable): the active main #GtkApplicationWindow,
+ * or %NULL.
+ * Since: 3.2
+ */
+GtkApplicationWindow *
+tepl_application_get_active_main_window (TeplApplication *tepl_app)
+{
+       GList *windows;
+       GList *l;
+
+       g_return_val_if_fail (TEPL_IS_APPLICATION (tepl_app), NULL);
+
+       windows = gtk_application_get_windows (tepl_app->priv->gtk_app);
+
+       for (l = windows; l != NULL; l = l->next)
+       {
+               GtkWindow *window = l->data;
+
+               if (GTK_IS_APPLICATION_WINDOW (window) &&
+                   tepl_application_window_is_main_window (GTK_APPLICATION_WINDOW (window)))
+               {
+                       return GTK_APPLICATION_WINDOW (window);
+               }
+       }
+
+       return NULL;
+}
+
+/**
  * tepl_application_open_simple:
  * @tepl_app: a #TeplApplication.
  * @file: a #GFile.
diff --git a/tepl/tepl-application.h b/tepl/tepl-application.h
index d401a4f..2ed7c7e 100644
--- a/tepl/tepl-application.h
+++ b/tepl/tepl-application.h
@@ -66,6 +66,8 @@ AmtkActionInfoStore * tepl_application_get_app_action_info_store      (TeplApplicatio
 
 AmtkActionInfoStore *  tepl_application_get_tepl_action_info_store     (TeplApplication *tepl_app);
 
+GtkApplicationWindow * tepl_application_get_active_main_window         (TeplApplication *tepl_app);
+
 void                   tepl_application_open_simple                    (TeplApplication *tepl_app,
                                                                         GFile           *file);
 


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