pidgin/pidgin

Parents 8befd71928c2
Children 84e92cf6f64a
Move the singleton handling of the about dialog to the action handler.

Testing Done:
Ran and made sure a second dialog wasn't created when opening the dialog with one already opened.

Reviewed at https://reviews.imfreedom.org/r/1359/
--- a/pidgin/pidginabout.c Mon Mar 21 20:25:43 2022 -0500
+++ b/pidgin/pidginabout.c Mon Mar 21 20:31:15 2022 -0500
@@ -67,11 +67,6 @@
};
/******************************************************************************
- * Globals
- *****************************************************************************/
-static GtkWidget *about_dialog = NULL;
-
-/******************************************************************************
* Helpers
*****************************************************************************/
static void
@@ -580,19 +575,9 @@
*****************************************************************************/
GtkWidget *
pidgin_about_dialog_new(void) {
- if(GTK_IS_WIDGET(about_dialog)) {
- return about_dialog;
- }
-
- about_dialog = g_object_new(
+ return g_object_new(
PIDGIN_TYPE_ABOUT_DIALOG,
"title", "About Pidgin",
NULL
);
-
- g_object_add_weak_pointer(G_OBJECT(about_dialog),
- (gpointer)&about_dialog);
-
- return about_dialog;
}
-
--- a/pidgin/pidginabout.h Mon Mar 21 20:25:43 2022 -0500
+++ b/pidgin/pidginabout.h Mon Mar 21 20:31:15 2022 -0500
@@ -35,6 +35,15 @@
G_DECLARE_FINAL_TYPE(PidginAboutDialog, pidgin_about_dialog, PIDGIN,
ABOUT_DIALOG, GtkDialog)
+/**
+ * pidgin_about_dialog_new:
+ *
+ * Creates a new about window.
+ *
+ * Returns: (transfer full): A new instance of the about dialog.
+ *
+ * Since: 3.0.0
+ */
GtkWidget *pidgin_about_dialog_new(void);
G_END_DECLS
--- a/pidgin/pidginapplication.c Mon Mar 21 20:25:43 2022 -0500
+++ b/pidgin/pidginapplication.c Mon Mar 21 20:31:15 2022 -0500
@@ -217,12 +217,12 @@
pidgin_application_about(GSimpleAction *simple, GVariant *parameter,
gpointer data)
{
- GtkWidget *about = pidgin_about_dialog_new();
+ static GtkWidget *about = NULL;
- /* fix me? */
-#if 0
- gtk_window_set_transient_for(GTK_WINDOW(about), GTK_WINDOW(window));
-#endif
+ if(!GTK_IS_WIDGET(about)) {
+ about = pidgin_about_dialog_new();
+ g_object_add_weak_pointer(G_OBJECT(about), (gpointer)&about);
+ }
gtk_widget_show_all(about);
}