| 91 G_DEFINE_TYPE(PidginApplication, pidgin_application, GTK_TYPE_APPLICATION) |
91 G_DEFINE_TYPE(PidginApplication, pidgin_application, GTK_TYPE_APPLICATION) |
| 92 |
92 |
| 93 /****************************************************************************** |
93 /****************************************************************************** |
| 94 * Helpers |
94 * Helpers |
| 95 *****************************************************************************/ |
95 *****************************************************************************/ |
| |
96 |
| |
97 /* |
| |
98 * pidgin_application_get_active_window: |
| |
99 * |
| |
100 * Calls gtk_application_get_active_window to get the active window. If that |
| |
101 * returns NULL, fallback to the first window of gtk_application_get_windows, |
| |
102 * and if that fails, returns NULL. |
| |
103 */ |
| |
104 static GtkWindow * |
| |
105 pidgin_application_get_active_window(void) { |
| |
106 GApplication *application = NULL; |
| |
107 GtkApplication *gtk_application = NULL; |
| |
108 GtkWindow *window = NULL; |
| |
109 |
| |
110 application = g_application_get_default(); |
| |
111 gtk_application = GTK_APPLICATION(application); |
| |
112 |
| |
113 window = gtk_application_get_active_window(gtk_application); |
| |
114 if(!GTK_IS_WINDOW(window)) { |
| |
115 GList *windows = NULL; |
| |
116 |
| |
117 windows = gtk_application_get_windows(gtk_application); |
| |
118 if(windows != NULL) { |
| |
119 window = windows->data; |
| |
120 } |
| |
121 } |
| |
122 |
| |
123 return window; |
| |
124 } |
| 96 static void |
125 static void |
| 97 pidgin_application_init_plugins(void) { |
126 pidgin_application_init_plugins(void) { |
| 98 GPluginManager *manager = gplugin_manager_get_default(); |
127 GPluginManager *manager = gplugin_manager_get_default(); |
| 99 |
128 |
| 100 gplugin_manager_append_paths_from_environment(manager, |
129 gplugin_manager_append_paths_from_environment(manager, |
| 217 gpointer data) |
246 gpointer data) |
| 218 { |
247 { |
| 219 static GtkWidget *about = NULL; |
248 static GtkWidget *about = NULL; |
| 220 |
249 |
| 221 if(!GTK_IS_WIDGET(about)) { |
250 if(!GTK_IS_WIDGET(about)) { |
| |
251 GtkWindow *window = NULL; |
| |
252 |
| 222 about = pidgin_about_dialog_new(); |
253 about = pidgin_about_dialog_new(); |
| 223 g_object_add_weak_pointer(G_OBJECT(about), (gpointer)&about); |
254 g_object_add_weak_pointer(G_OBJECT(about), (gpointer)&about); |
| |
255 |
| |
256 window = pidgin_application_get_active_window(); |
| |
257 if(GTK_IS_WINDOW(window)) { |
| |
258 gtk_window_set_transient_for(GTK_WINDOW(about), window); |
| |
259 } |
| 224 } |
260 } |
| 225 |
261 |
| 226 gtk_widget_show(about); |
262 gtk_widget_show(about); |
| 227 } |
263 } |
| 228 |
264 |
| 231 gpointer data) |
267 gpointer data) |
| 232 { |
268 { |
| 233 static GtkWidget *manager = NULL; |
269 static GtkWidget *manager = NULL; |
| 234 |
270 |
| 235 if(!GTK_IS_WIDGET(manager)) { |
271 if(!GTK_IS_WIDGET(manager)) { |
| |
272 GtkWindow *window = NULL; |
| |
273 |
| 236 manager = pidgin_account_manager_new(); |
274 manager = pidgin_account_manager_new(); |
| 237 g_object_add_weak_pointer(G_OBJECT(manager), (gpointer)&manager); |
275 g_object_add_weak_pointer(G_OBJECT(manager), (gpointer)&manager); |
| |
276 |
| |
277 window = pidgin_application_get_active_window(); |
| |
278 if(GTK_IS_WINDOW(window)) { |
| |
279 gtk_window_set_transient_for(GTK_WINDOW(manager), window); |
| |
280 } |
| 238 } |
281 } |
| 239 |
282 |
| 240 |
283 |
| 241 gtk_window_present_with_time(GTK_WINDOW(manager), GDK_CURRENT_TIME); |
284 gtk_window_present_with_time(GTK_WINDOW(manager), GDK_CURRENT_TIME); |
| 242 } |
285 } |
| 396 gpointer data) |
439 gpointer data) |
| 397 { |
440 { |
| 398 static GtkWidget *dialog = NULL; |
441 static GtkWidget *dialog = NULL; |
| 399 |
442 |
| 400 if(!GTK_IS_WIDGET(dialog)) { |
443 if(!GTK_IS_WIDGET(dialog)) { |
| |
444 GtkWindow *window = NULL; |
| |
445 |
| 401 dialog = pidgin_plugins_dialog_new(); |
446 dialog = pidgin_plugins_dialog_new(); |
| 402 g_object_add_weak_pointer(G_OBJECT(dialog), (gpointer)&dialog); |
447 g_object_add_weak_pointer(G_OBJECT(dialog), (gpointer)&dialog); |
| 403 |
448 |
| 404 /* fixme? */ |
449 window = pidgin_application_get_active_window(); |
| 405 #if 0 |
450 if(GTK_IS_WINDOW(window)) { |
| 406 gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(window)); |
451 gtk_window_set_transient_for(GTK_WINDOW(dialog), window); |
| 407 #endif |
452 } |
| 408 } |
453 } |
| 409 |
454 |
| 410 gtk_window_present_with_time(GTK_WINDOW(dialog), GDK_CURRENT_TIME); |
455 gtk_window_present_with_time(GTK_WINDOW(dialog), GDK_CURRENT_TIME); |
| 411 } |
456 } |
| 412 |
457 |
| 450 GVariant *parameter, gpointer data) |
495 GVariant *parameter, gpointer data) |
| 451 { |
496 { |
| 452 static GtkWidget *manager = NULL; |
497 static GtkWidget *manager = NULL; |
| 453 |
498 |
| 454 if(!GTK_IS_WIDGET(manager)) { |
499 if(!GTK_IS_WIDGET(manager)) { |
| |
500 GtkWindow *window = NULL; |
| |
501 |
| 455 manager = pidgin_status_manager_new(); |
502 manager = pidgin_status_manager_new(); |
| 456 g_object_add_weak_pointer(G_OBJECT(manager), (gpointer)&manager); |
503 g_object_add_weak_pointer(G_OBJECT(manager), (gpointer)&manager); |
| |
504 |
| |
505 window = pidgin_application_get_active_window(); |
| |
506 if(GTK_IS_WINDOW(window)) { |
| |
507 gtk_window_set_transient_for(GTK_WINDOW(manager), window); |
| |
508 } |
| 457 } |
509 } |
| 458 |
510 |
| 459 gtk_widget_show(manager); |
511 gtk_widget_show(manager); |
| 460 } |
512 } |
| 461 |
513 |