[buoh] Clean up passing GApplication
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [buoh] Clean up passing GApplication
- Date: Mon, 21 Feb 2022 15:33:45 +0000 (UTC)
commit f4759e9104aa9811fd64553e2f6b2ed37f67eae5
Author: Jan Tojnar <jtojnar gmail com>
Date: Mon Nov 1 09:19:00 2021 +0100
Clean up passing GApplication
BuohWindow is GtkApplicationWindow so we should just pass GApplication to the constructor.
Also do some related clean-ups.
src/buoh-application.c | 7 +++----
src/buoh-window.c | 10 ++++++----
src/buoh-window.h | 2 +-
src/main.c | 9 ++-------
4 files changed, 12 insertions(+), 16 deletions(-)
---
diff --git a/src/buoh-application.c b/src/buoh-application.c
index 24607cb..4deaded 100644
--- a/src/buoh-application.c
+++ b/src/buoh-application.c
@@ -456,16 +456,15 @@ buoh_application_activate (GApplication *buoh)
g_return_if_fail (BUOH_IS_APPLICATION (buoh));
GList *list;
- GtkWidget *window;
+ BuohWindow *window;
list = gtk_application_get_windows (GTK_APPLICATION (buoh));
if (list) {
gtk_window_present (GTK_WINDOW (list->data));
} else {
- window = buoh_window_new ();
- gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (buoh));
- gtk_widget_show (window);
+ window = buoh_window_new (BUOH_APPLICATION (buoh));
+ gtk_widget_show (GTK_WIDGET (window));
}
}
diff --git a/src/buoh-window.c b/src/buoh-window.c
index 2539d87..a795ab1 100644
--- a/src/buoh-window.c
+++ b/src/buoh-window.c
@@ -332,12 +332,14 @@ buoh_window_finalize (GObject *object)
}
}
-GtkWidget *
-buoh_window_new (void)
+BuohWindow *
+buoh_window_new (BuohApplication *application)
{
- GtkWidget *buoh_window;
+ BuohWindow *buoh_window;
- buoh_window = GTK_WIDGET (g_object_new (BUOH_TYPE_WINDOW, NULL));
+ buoh_window = g_object_new (BUOH_TYPE_WINDOW,
+ "application", GTK_APPLICATION (application),
+ NULL);
return buoh_window;
}
diff --git a/src/buoh-window.h b/src/buoh-window.h
index f8b31e7..4e5b620 100644
--- a/src/buoh-window.h
+++ b/src/buoh-window.h
@@ -27,7 +27,7 @@ G_BEGIN_DECLS
#define BUOH_TYPE_WINDOW buoh_window_get_type()
G_DECLARE_FINAL_TYPE (BuohWindow, buoh_window, BUOH, WINDOW, GtkApplicationWindow)
-GtkWidget *buoh_window_new (void);
+BuohWindow *buoh_window_new (BuohApplication *application);
G_END_DECLS
diff --git a/src/main.c b/src/main.c
index c591472..c568175 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,8 +28,7 @@
int
main (int argc, char *argv[])
{
- BuohApplication *buoh;
- gint status;
+ g_autoptr (BuohApplication) buoh;
bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -37,9 +36,5 @@ main (int argc, char *argv[])
buoh = buoh_application_new ();
- status = g_application_run (G_APPLICATION (buoh), argc, argv);
-
- g_object_unref (buoh);
-
- return status;
+ return g_application_run (G_APPLICATION (buoh), argc, argv);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]