[tepl] App: add option to handle GApplication::activate
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] App: add option to handle GApplication::activate
- Date: Wed, 11 Oct 2017 14:29:29 +0000 (UTC)
commit fdaf3eb6ad5fd96f062aee94226af3284e2a078d
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Oct 11 16:25:03 2017 +0200
App: add option to handle GApplication::activate
docs/reference/tepl-3.0-sections.txt | 1 +
tepl/tepl-application.c | 42 ++++++++++++++++++++++++++++++++++
tepl/tepl-application.h | 2 +
3 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index 67dac21..64d1162 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -198,6 +198,7 @@ tepl_application_get_app_action_info_store
tepl_application_get_tepl_action_info_store
tepl_application_get_active_main_window
tepl_application_open_simple
+tepl_application_handle_activate
tepl_application_handle_open
<SUBSECTION Standard>
TEPL_APPLICATION
diff --git a/tepl/tepl-application.c b/tepl/tepl-application.c
index 915e2f5..332f780 100644
--- a/tepl/tepl-application.c
+++ b/tepl/tepl-application.c
@@ -42,6 +42,7 @@ struct _TeplApplicationPrivate
AmtkActionInfoStore *app_action_info_store;
AmtkActionInfoStore *tepl_action_info_store;
+ guint handle_activate : 1;
guint handle_open : 1;
};
@@ -376,6 +377,47 @@ tepl_application_open_simple (TeplApplication *tepl_app,
}
static void
+activate_cb (GApplication *g_app,
+ TeplApplication *tepl_app)
+{
+ TeplAbstractFactory *factory;
+ GtkApplicationWindow *main_window;
+
+ factory = tepl_abstract_factory_get_singleton ();
+ main_window = tepl_abstract_factory_create_main_window (factory, tepl_app->priv->gtk_app);
+ g_return_if_fail (main_window != NULL);
+
+ gtk_widget_show (GTK_WIDGET (main_window));
+}
+
+/**
+ * tepl_application_handle_activate:
+ * @tepl_app: a #TeplApplication.
+ *
+ * Connects a generic function handler for the #GApplication::activate signal.
+ *
+ * It creates a main window with tepl_abstract_factory_create_main_window().
+ *
+ * Since: 3.2
+ */
+void
+tepl_application_handle_activate (TeplApplication *tepl_app)
+{
+ g_return_if_fail (TEPL_IS_APPLICATION (tepl_app));
+
+ if (!tepl_app->priv->handle_activate)
+ {
+ g_signal_connect_object (tepl_app->priv->gtk_app,
+ "activate",
+ G_CALLBACK (activate_cb),
+ tepl_app,
+ 0);
+
+ tepl_app->priv->handle_activate = TRUE;
+ }
+}
+
+static void
open_cb (GApplication *g_app,
GFile **files,
gint n_files,
diff --git a/tepl/tepl-application.h b/tepl/tepl-application.h
index cc6e530..e79f82a 100644
--- a/tepl/tepl-application.h
+++ b/tepl/tepl-application.h
@@ -71,6 +71,8 @@ GtkApplicationWindow * tepl_application_get_active_main_window
(TeplApplication
void tepl_application_open_simple (TeplApplication *tepl_app,
GFile *file);
+void tepl_application_handle_activate (TeplApplication *tepl_app);
+
void tepl_application_handle_open (TeplApplication *tepl_app);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]