pidgin/pidgin

Parents a719f0f3c600
Children 31532581724a
Display the preferences window as a singleton from the application

This is how we handle displaying other dialogs and apparently the preferences
window just got missed. We also make it transient for whatever window is active
which means it won't fill an entire cell in a tiling window manager.

Testing Done:
Opened the preferences dialog in i3 and verified it was no longer a full tile and that everything worked as expected.

Reviewed at https://reviews.imfreedom.org/r/2242/
--- a/ChangeLog.API Mon Feb 20 09:50:04 2023 -0600
+++ b/ChangeLog.API Tue Feb 21 21:41:53 2023 -0600
@@ -1171,6 +1171,7 @@
* pidgin_pounces_manager_show
* pidgin_prefs_labeled_entry
* pidgin_prefs_labeled_password
+ * pidgin_prefs_show
* pidgin_privacy_dialog_hide
* pidgin_privacy_dialog_show
* pidgin_privacy_init
--- a/pidgin/pidginapplication.c Mon Feb 20 09:50:04 2023 -0600
+++ b/pidgin/pidginapplication.c Tue Feb 21 21:41:53 2023 -0600
@@ -479,9 +479,19 @@
static void
pidgin_application_preferences(G_GNUC_UNUSED GSimpleAction *simple,
G_GNUC_UNUSED GVariant *parameter,
- G_GNUC_UNUSED gpointer data)
+ gpointer data)
{
- pidgin_prefs_show();
+ PidginApplication *application = data;
+ static GtkWidget *preferences = NULL;
+
+ if(!GTK_IS_WIDGET(preferences)) {
+ preferences = g_object_new(PIDGIN_TYPE_PREFS_WINDOW, NULL);
+ g_object_add_weak_pointer(G_OBJECT(preferences), (gpointer)&preferences);
+ }
+
+ pidgin_application_present_transient_window(application,
+ GTK_WINDOW(preferences));
+
}
static void
--- a/pidgin/prefs/pidginprefs.c Mon Feb 20 09:50:04 2023 -0600
+++ b/pidgin/prefs/pidginprefs.c Tue Feb 21 21:41:53 2023 -0600
@@ -42,9 +42,6 @@
GtkDialog parent;
};
-/* Main dialog */
-static PidginPrefsWindow *prefs = NULL;
-
G_DEFINE_TYPE(PidginPrefsWindow, pidgin_prefs_window, GTK_TYPE_DIALOG);
/******************************************************************************
@@ -475,19 +472,6 @@
}
static void
-delete_prefs(G_GNUC_UNUSED GtkWidget *asdf, G_GNUC_UNUSED void *gdsa)
-{
- /* Close any request dialogs */
- purple_request_close_with_handle(prefs);
- purple_notify_close_with_handle(prefs);
-
- /* Unregister callbacks. */
- purple_prefs_disconnect_by_handle(prefs);
-
- prefs = NULL;
-}
-
-static void
vv_test_switch_page_cb(GtkStack *stack, G_GNUC_UNUSED GParamSpec *pspec,
gpointer data)
{
@@ -503,17 +487,26 @@
* GObject Implementation
*****************************************************************************/
static void
+pidgin_prefs_window_finalize(GObject *obj) {
+ purple_prefs_disconnect_by_handle(obj);
+
+ G_OBJECT_CLASS(pidgin_prefs_window_parent_class)->finalize(obj);
+}
+
+static void
pidgin_prefs_window_class_init(PidginPrefsWindowClass *klass)
{
+ GObjectClass *obj_class = G_OBJECT_CLASS(klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ obj_class->finalize = pidgin_prefs_window_finalize;
+
gtk_widget_class_set_template_from_resource(
widget_class,
"/im/pidgin/Pidgin3/Prefs/prefs.ui"
);
/* Main window */
- gtk_widget_class_bind_template_callback(widget_class, delete_prefs);
gtk_widget_class_bind_template_callback(widget_class,
vv_test_switch_page_cb);
}
@@ -528,17 +521,6 @@
* API
*****************************************************************************/
void
-pidgin_prefs_show(void)
-{
- if (prefs == NULL) {
- prefs = PIDGIN_PREFS_WINDOW(g_object_new(
- pidgin_prefs_window_get_type(), NULL));
- }
-
- gtk_window_present(GTK_WINDOW(prefs));
-}
-
-void
pidgin_prefs_init(void)
{
purple_prefs_add_none(PIDGIN_PREFS_ROOT "");
--- a/pidgin/prefs/pidginprefs.h Mon Feb 20 09:50:04 2023 -0600
+++ b/pidgin/prefs/pidginprefs.h Tue Feb 21 21:41:53 2023 -0600
@@ -45,13 +45,6 @@
void pidgin_prefs_init(void);
/**
- * pidgin_prefs_show:
- *
- * Shows the preferences dialog.
- */
-void pidgin_prefs_show(void);
-
-/**
* pidgin_prefs_checkbox:
* @title: The text to be displayed as the checkbox label
* @key: The key of the purple bool pref that will be represented by the checkbox
--- a/pidgin/resources/Prefs/prefs.ui Mon Feb 20 09:50:04 2023 -0600
+++ b/pidgin/resources/Prefs/prefs.ui Tue Feb 21 21:41:53 2023 -0600
@@ -28,7 +28,6 @@
<!-- interface-copyright Pidgin Developers <devel@pidgin.im> -->
<template class="PidginPrefsWindow" parent="GtkDialog">
<property name="title" translatable="1">Preferences</property>
- <signal name="destroy" handler="delete_prefs" swapped="no"/>
<child internal-child="content_area">
<object class="GtkBox">
<property name="vexpand">1</property>