| 100 * Calls gtk_application_get_active_window to get the active window. If that |
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, |
101 * returns NULL, fallback to the first window of gtk_application_get_windows, |
| 102 * and if that fails, returns NULL. |
102 * and if that fails, returns NULL. |
| 103 */ |
103 */ |
| 104 static GtkWindow * |
104 static GtkWindow * |
| 105 pidgin_application_get_active_window(void) { |
105 pidgin_application_get_active_window(PidginApplication *application) { |
| 106 GApplication *application = NULL; |
|
| 107 GtkApplication *gtk_application = NULL; |
106 GtkApplication *gtk_application = NULL; |
| 108 GtkWindow *window = NULL; |
107 GtkWindow *window = NULL; |
| 109 |
108 |
| 110 application = g_application_get_default(); |
|
| 111 gtk_application = GTK_APPLICATION(application); |
109 gtk_application = GTK_APPLICATION(application); |
| 112 |
110 |
| 113 window = gtk_application_get_active_window(gtk_application); |
111 window = gtk_application_get_active_window(gtk_application); |
| 114 if(!GTK_IS_WINDOW(window)) { |
112 if(!GTK_IS_WINDOW(window)) { |
| 115 GList *windows = NULL; |
113 GList *windows = NULL; |
| 119 window = windows->data; |
117 window = windows->data; |
| 120 } |
118 } |
| 121 } |
119 } |
| 122 |
120 |
| 123 return window; |
121 return window; |
| |
122 } |
| |
123 |
| |
124 /* |
| |
125 * pidgin_application_present_transient_window: |
| |
126 * @application: The application instance. |
| |
127 * @window: The [class@Gtk.Window] to present. |
| |
128 * |
| |
129 * Presents a window and makes sure its transient parent is set to the currently |
| |
130 * active window of @application. |
| |
131 * |
| |
132 * Since: 3.0.0 |
| |
133 */ |
| |
134 static void |
| |
135 pidgin_application_present_transient_window(PidginApplication *application, |
| |
136 GtkWindow *window) |
| |
137 { |
| |
138 GtkWindow *active_window = NULL; |
| |
139 |
| |
140 g_return_if_fail(PIDGIN_IS_APPLICATION(application)); |
| |
141 g_return_if_fail(GTK_IS_WINDOW(window)); |
| |
142 |
| |
143 active_window = pidgin_application_get_active_window(application); |
| |
144 |
| |
145 gtk_window_set_transient_for(window, active_window); |
| |
146 |
| |
147 gtk_window_present_with_time(window, GDK_CURRENT_TIME); |
| 124 } |
148 } |
| 125 |
149 |
| 126 static void |
150 static void |
| 127 pidgin_application_plugin_state_changed(G_GNUC_UNUSED GPluginManager *manager, |
151 pidgin_application_plugin_state_changed(G_GNUC_UNUSED GPluginManager *manager, |
| 128 G_GNUC_UNUSED GPluginPlugin *plugin, |
152 G_GNUC_UNUSED GPluginPlugin *plugin, |
| 261 |
285 |
| 262 static void |
286 static void |
| 263 pidgin_application_about(GSimpleAction *simple, GVariant *parameter, |
287 pidgin_application_about(GSimpleAction *simple, GVariant *parameter, |
| 264 gpointer data) |
288 gpointer data) |
| 265 { |
289 { |
| |
290 PidginApplication *application = data; |
| 266 static GtkWidget *about = NULL; |
291 static GtkWidget *about = NULL; |
| 267 |
292 |
| 268 if(!GTK_IS_WIDGET(about)) { |
293 if(!GTK_IS_WIDGET(about)) { |
| 269 GtkWindow *window = NULL; |
|
| 270 |
|
| 271 about = pidgin_about_dialog_new(); |
294 about = pidgin_about_dialog_new(); |
| 272 g_object_add_weak_pointer(G_OBJECT(about), (gpointer)&about); |
295 g_object_add_weak_pointer(G_OBJECT(about), (gpointer)&about); |
| 273 |
296 } |
| 274 window = pidgin_application_get_active_window(); |
297 |
| 275 if(GTK_IS_WINDOW(window)) { |
298 pidgin_application_present_transient_window(application, GTK_WINDOW(about)); |
| 276 gtk_window_set_transient_for(GTK_WINDOW(about), window); |
|
| 277 } |
|
| 278 } |
|
| 279 |
|
| 280 gtk_widget_show(about); |
|
| 281 } |
299 } |
| 282 |
300 |
| 283 static void |
301 static void |
| 284 pidgin_application_accounts(GSimpleAction *simple, GVariant *parameter, |
302 pidgin_application_accounts(GSimpleAction *simple, GVariant *parameter, |
| 285 gpointer data) |
303 gpointer data) |
| 286 { |
304 { |
| |
305 PidginApplication *application = data; |
| 287 static GtkWidget *manager = NULL; |
306 static GtkWidget *manager = NULL; |
| 288 |
307 |
| 289 if(!GTK_IS_WIDGET(manager)) { |
308 if(!GTK_IS_WIDGET(manager)) { |
| 290 GtkWindow *window = NULL; |
|
| 291 |
|
| 292 manager = pidgin_account_manager_new(); |
309 manager = pidgin_account_manager_new(); |
| 293 g_object_add_weak_pointer(G_OBJECT(manager), (gpointer)&manager); |
310 g_object_add_weak_pointer(G_OBJECT(manager), (gpointer)&manager); |
| 294 |
311 } |
| 295 window = pidgin_application_get_active_window(); |
312 |
| 296 if(GTK_IS_WINDOW(window)) { |
313 pidgin_application_present_transient_window(application, |
| 297 gtk_window_set_transient_for(GTK_WINDOW(manager), window); |
314 GTK_WINDOW(manager)); |
| 298 } |
|
| 299 } |
|
| 300 |
|
| 301 |
|
| 302 gtk_window_present_with_time(GTK_WINDOW(manager), GDK_CURRENT_TIME); |
|
| 303 } |
315 } |
| 304 |
316 |
| 305 static void |
317 static void |
| 306 pidgin_application_add_buddy(GSimpleAction *simple, GVariant *parameter, |
318 pidgin_application_add_buddy(GSimpleAction *simple, GVariant *parameter, |
| 307 gpointer data) |
319 gpointer data) |
| 372 |
384 |
| 373 static void |
385 static void |
| 374 pidgin_application_edit_account(GSimpleAction *simple, GVariant *parameter, |
386 pidgin_application_edit_account(GSimpleAction *simple, GVariant *parameter, |
| 375 gpointer data) |
387 gpointer data) |
| 376 { |
388 { |
| |
389 PidginApplication *application = data; |
| 377 PurpleAccount *account = NULL; |
390 PurpleAccount *account = NULL; |
| 378 PurpleAccountManager *manager = NULL; |
391 PurpleAccountManager *manager = NULL; |
| 379 const gchar *id = NULL; |
392 const gchar *id = NULL; |
| 380 |
393 |
| 381 id = g_variant_get_string(parameter, NULL); |
394 id = g_variant_get_string(parameter, NULL); |
| 383 manager = purple_account_manager_get_default(); |
396 manager = purple_account_manager_get_default(); |
| 384 |
397 |
| 385 account = purple_account_manager_find_by_id(manager, id); |
398 account = purple_account_manager_find_by_id(manager, id); |
| 386 if(PURPLE_IS_ACCOUNT(account)) { |
399 if(PURPLE_IS_ACCOUNT(account)) { |
| 387 GtkWidget *editor = pidgin_account_editor_new(account); |
400 GtkWidget *editor = pidgin_account_editor_new(account); |
| 388 gtk_widget_show(editor); |
401 |
| |
402 pidgin_application_present_transient_window(application, |
| |
403 GTK_WINDOW(editor)); |
| 389 } |
404 } |
| 390 } |
405 } |
| 391 |
406 |
| 392 static void |
407 static void |
| 393 pidgin_application_enable_account(GSimpleAction *simple, GVariant *parameter, |
408 pidgin_application_enable_account(GSimpleAction *simple, GVariant *parameter, |
| 441 pidgin_application_new_status(G_GNUC_UNUSED GSimpleAction *simple, |
456 pidgin_application_new_status(G_GNUC_UNUSED GSimpleAction *simple, |
| 442 G_GNUC_UNUSED GVariant *parameter, |
457 G_GNUC_UNUSED GVariant *parameter, |
| 443 G_GNUC_UNUSED gpointer data) |
458 G_GNUC_UNUSED gpointer data) |
| 444 { |
459 { |
| 445 GtkWidget *editor = pidgin_status_editor_new(NULL); |
460 GtkWidget *editor = pidgin_status_editor_new(NULL); |
| 446 gtk_widget_show(editor); |
461 gtk_window_present_with_time(GTK_WINDOW(editor), GDK_CURRENT_TIME); |
| 447 } |
462 } |
| 448 |
463 |
| 449 static void |
464 static void |
| 450 pidgin_application_online_help(GSimpleAction *simple, GVariant *parameter, |
465 pidgin_application_online_help(GSimpleAction *simple, GVariant *parameter, |
| 451 gpointer data) |
466 gpointer data) |
| 455 |
470 |
| 456 static void |
471 static void |
| 457 pidgin_application_plugins(GSimpleAction *simple, GVariant *parameter, |
472 pidgin_application_plugins(GSimpleAction *simple, GVariant *parameter, |
| 458 gpointer data) |
473 gpointer data) |
| 459 { |
474 { |
| |
475 PidginApplication *application = data; |
| 460 static GtkWidget *dialog = NULL; |
476 static GtkWidget *dialog = NULL; |
| 461 |
477 |
| 462 if(!GTK_IS_WIDGET(dialog)) { |
478 if(!GTK_IS_WIDGET(dialog)) { |
| 463 GtkWindow *window = NULL; |
|
| 464 |
|
| 465 dialog = pidgin_plugins_dialog_new(); |
479 dialog = pidgin_plugins_dialog_new(); |
| 466 g_object_add_weak_pointer(G_OBJECT(dialog), (gpointer)&dialog); |
480 g_object_add_weak_pointer(G_OBJECT(dialog), (gpointer)&dialog); |
| 467 |
481 } |
| 468 window = pidgin_application_get_active_window(); |
482 |
| 469 if(GTK_IS_WINDOW(window)) { |
483 pidgin_application_present_transient_window(application, |
| 470 gtk_window_set_transient_for(GTK_WINDOW(dialog), window); |
484 GTK_WINDOW(dialog)); |
| 471 } |
|
| 472 } |
|
| 473 |
|
| 474 gtk_window_present_with_time(GTK_WINDOW(dialog), GDK_CURRENT_TIME); |
|
| 475 } |
485 } |
| 476 |
486 |
| 477 static void |
487 static void |
| 478 pidgin_application_preferences(GSimpleAction *simple, GVariant *parameter, |
488 pidgin_application_preferences(GSimpleAction *simple, GVariant *parameter, |
| 479 gpointer data) |
489 gpointer data) |
| 511 |
521 |
| 512 static void |
522 static void |
| 513 pidgin_application_show_status_manager(GSimpleAction *simple, |
523 pidgin_application_show_status_manager(GSimpleAction *simple, |
| 514 GVariant *parameter, gpointer data) |
524 GVariant *parameter, gpointer data) |
| 515 { |
525 { |
| |
526 PidginApplication *application = data; |
| 516 static GtkWidget *manager = NULL; |
527 static GtkWidget *manager = NULL; |
| 517 |
528 |
| 518 if(!GTK_IS_WIDGET(manager)) { |
529 if(!GTK_IS_WIDGET(manager)) { |
| 519 GtkWindow *window = NULL; |
|
| 520 |
|
| 521 manager = pidgin_status_manager_new(); |
530 manager = pidgin_status_manager_new(); |
| 522 g_object_add_weak_pointer(G_OBJECT(manager), (gpointer)&manager); |
531 g_object_add_weak_pointer(G_OBJECT(manager), (gpointer)&manager); |
| 523 |
532 } |
| 524 window = pidgin_application_get_active_window(); |
533 |
| 525 if(GTK_IS_WINDOW(window)) { |
534 pidgin_application_present_transient_window(application, |
| 526 gtk_window_set_transient_for(GTK_WINDOW(manager), window); |
535 GTK_WINDOW(manager)); |
| 527 } |
|
| 528 } |
|
| 529 |
|
| 530 gtk_widget_show(manager); |
|
| 531 } |
536 } |
| 532 |
537 |
| 533 static GActionEntry app_entries[] = { |
538 static GActionEntry app_entries[] = { |
| 534 { |
539 { |
| 535 .name = "about", |
540 .name = "about", |