pidgin/pidgin

fb13b6986266
Parents 9051db7ca046
Children c22448f50d5d
Make the debug window transient for whatever window created it.

Testing Done:
Opened the debug window in i3wm and verified it didn't take a full tile and worked as expected.

Bugs closed: PIDGIN-17675

Reviewed at https://reviews.imfreedom.org/r/1845/
--- a/pidgin/pidginapplication.c Tue Sep 27 01:39:29 2022 -0500
+++ b/pidgin/pidginapplication.c Tue Sep 27 02:36:20 2022 -0500
@@ -95,33 +95,6 @@
*****************************************************************************/
/*
- * pidgin_application_get_active_window:
- *
- * Calls gtk_application_get_active_window to get the active window. If that
- * returns NULL, fallback to the first window of gtk_application_get_windows,
- * and if that fails, returns NULL.
- */
-static GtkWindow *
-pidgin_application_get_active_window(PidginApplication *application) {
- GtkApplication *gtk_application = NULL;
- GtkWindow *window = NULL;
-
- gtk_application = GTK_APPLICATION(application);
-
- window = gtk_application_get_active_window(gtk_application);
- if(!GTK_IS_WINDOW(window)) {
- GList *windows = NULL;
-
- windows = gtk_application_get_windows(gtk_application);
- if(windows != NULL) {
- window = windows->data;
- }
- }
-
- return window;
-}
-
-/*
* pidgin_application_present_transient_window:
* @application: The application instance.
* @window: The [class@Gtk.Window] to present.
@@ -1052,3 +1025,25 @@
windows = windows->next;
}
}
+
+GtkWindow *
+pidgin_application_get_active_window(PidginApplication *application) {
+ GtkApplication *gtk_application = NULL;
+ GtkWindow *window = NULL;
+
+ g_return_val_if_fail(PIDGIN_IS_APPLICATION(application), NULL);
+
+ gtk_application = GTK_APPLICATION(application);
+
+ window = gtk_application_get_active_window(gtk_application);
+ if(!GTK_IS_WINDOW(window)) {
+ GList *windows = NULL;
+
+ windows = gtk_application_get_windows(gtk_application);
+ if(windows != NULL) {
+ window = windows->data;
+ }
+ }
+
+ return window;
+}
--- a/pidgin/pidginapplication.h Tue Sep 27 01:39:29 2022 -0500
+++ b/pidgin/pidginapplication.h Tue Sep 27 02:36:20 2022 -0500
@@ -73,6 +73,21 @@
*/
void pidgin_application_add_action_group(PidginApplication *application, const gchar *prefix, GActionGroup *action_group);
+/**
+ * pidgin_application_get_active_window:
+ * @application: The instance.
+ *
+ * Calls [method@Gtk.Application.get_active_window] to get the active window.
+ * If that returns %NULL, fallback to the first window of
+ * [method@Gtk.Application.get_windows], and if that fails, return %NULL.
+ *
+ * Returns: (transfer none) (nullable): The active window or %NULL if one could
+ * not be found.
+ *
+ * Since: 3.0.0
+ */
+GtkWindow *pidgin_application_get_active_window(PidginApplication *application);
+
G_END_DECLS
#endif /* PIDGIN_APPLICATION_H */
--- a/pidgin/pidgindebug.c Tue Sep 27 01:39:29 2022 -0500
+++ b/pidgin/pidgindebug.c Tue Sep 27 02:36:20 2022 -0500
@@ -32,12 +32,12 @@
#include "gtkdialogs.h"
#include "gtkutils.h"
+#include "pidginapplication.h"
#include "pidgincore.h"
#include "pidgindebug.h"
#include <gdk/gdkkeysyms.h>
-#include "pidginresources.h"
struct _PidginDebugWindow {
GtkWindow parent;
@@ -838,11 +838,21 @@
pidgin_debug_window_show(void)
{
if (debug_win == NULL) {
+ GApplication *application = NULL;
+ PidginApplication *pidgin_application = NULL;
+ GtkWindow *parent = NULL;
+
+ application = g_application_get_default();
+ pidgin_application = PIDGIN_APPLICATION(application);
+ parent = pidgin_application_get_active_window(pidgin_application);
+
debug_win = PIDGIN_DEBUG_WINDOW(
g_object_new(PIDGIN_TYPE_DEBUG_WINDOW, NULL));
+
+ gtk_window_set_transient_for(GTK_WINDOW(debug_win), parent);
}
- gtk_widget_show(GTK_WIDGET(debug_win));
+ gtk_window_present_with_time(GTK_WINDOW(debug_win), GDK_CURRENT_TIME);
purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/debug/enabled", TRUE);
}