| 20 * along with this program; if not, see <https://www.gnu.org/licenses/>. |
20 * along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 21 */ |
21 */ |
| 22 |
22 |
| 23 #include <purpleconfig.h> |
23 #include <purpleconfig.h> |
| 24 |
24 |
| |
25 #include <glib/gi18n-lib.h> |
| |
26 |
| |
27 #include <gdk-pixbuf/gdk-pixbuf.h> |
| |
28 |
| |
29 #include <json-glib/json-glib.h> |
| |
30 |
| |
31 #include <adwaita.h> |
| |
32 |
| |
33 #include "pidginabout.h" |
| |
34 |
| 25 #ifdef HAVE_MESON_CONFIG |
35 #ifdef HAVE_MESON_CONFIG |
| 26 #include "meson-config.h" |
36 #include "meson-config.h" |
| 27 #endif |
37 #endif |
| 28 |
|
| 29 #include <glib/gi18n-lib.h> |
|
| 30 |
|
| 31 #include <gdk-pixbuf/gdk-pixbuf.h> |
|
| 32 |
|
| 33 #include <json-glib/json-glib.h> |
|
| 34 |
|
| 35 #include <adwaita.h> |
|
| 36 |
|
| 37 #include "pidginabout.h" |
|
| 38 |
38 |
| 39 #include "package_revision.h" |
39 #include "package_revision.h" |
| 40 #include "gtkutils.h" |
40 #include "gtkutils.h" |
| 41 #include "pidgincore.h" |
41 #include "pidgincore.h" |
| 42 #include "pidginresources.h" |
42 #include "pidginresources.h" |
| 77 GtkWidget *row = adw_action_row_new(); |
77 GtkWidget *row = adw_action_row_new(); |
| 78 |
78 |
| 79 adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row), title); |
79 adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row), title); |
| 80 |
80 |
| 81 if(value != NULL) { |
81 if(value != NULL) { |
| 82 GtkWidget *label = gtk_label_new(NULL); |
82 adw_action_row_set_subtitle(ADW_ACTION_ROW(row), value); |
| 83 gtk_label_set_markup(GTK_LABEL(label), value); |
|
| 84 adw_action_row_add_suffix(ADW_ACTION_ROW(row), label); |
|
| 85 } |
83 } |
| 86 |
84 |
| 87 adw_preferences_group_add(group, row); |
85 adw_preferences_group_add(group, row); |
| 88 } |
86 } |
| 89 |
87 |
| 461 return info; |
459 return info; |
| 462 } |
460 } |
| 463 |
461 |
| 464 static void |
462 static void |
| 465 pidgin_about_dialog_add_build_args(PidginAboutDialog *about, |
463 pidgin_about_dialog_add_build_args(PidginAboutDialog *about, |
| 466 const char *build_args) |
464 const PurpleKeyValuePair build_args[]) |
| 467 { |
465 { |
| 468 gchar **splits = NULL; |
|
| 469 |
|
| 470 /* Walk through the arguments and add them */ |
466 /* Walk through the arguments and add them */ |
| 471 splits = g_strsplit(build_args, " ", -1); |
467 for(gint idx = 0; build_args[idx].key != NULL; idx++) { |
| 472 for(gint idx = 0; splits[idx]; idx++) { |
|
| 473 gchar **value_split = g_strsplit(splits[idx], "=", 2); |
|
| 474 |
|
| 475 if(value_split[0] == NULL || value_split[0][0] == '\0') { |
|
| 476 continue; |
|
| 477 } |
|
| 478 |
|
| 479 pidgin_about_dialog_group_add_row(about->build_args_group, |
468 pidgin_about_dialog_group_add_row(about->build_args_group, |
| 480 value_split[0], value_split[1]); |
469 build_args[idx].key, |
| 481 |
470 build_args[idx].value); |
| 482 g_strfreev(value_split); |
471 } |
| 483 } |
|
| 484 |
|
| 485 g_strfreev(splits); |
|
| 486 } |
472 } |
| 487 |
473 |
| 488 static char * |
474 static char * |
| 489 pidgin_about_dialog_copy_build_args(const char *build_args) { |
475 pidgin_about_dialog_copy_build_args(const PurpleKeyValuePair build_args[]) { |
| 490 char **splits = NULL; |
|
| 491 GString *info = NULL; |
476 GString *info = NULL; |
| 492 |
477 |
| 493 info = g_string_new( |
478 info = g_string_new( |
| 494 "Meson Arguments\n" |
479 "Meson Arguments\n" |
| 495 "===============\n"); |
480 "===============\n"); |
| 496 |
481 |
| 497 /* Walk through the arguments and add them */ |
482 /* Walk through the arguments and add them */ |
| 498 splits = g_strsplit(build_args, " ", -1); |
483 for(gint idx = 0; build_args[idx].key != NULL; idx++) { |
| 499 for(gint idx = 0; splits[idx]; idx++) { |
|
| 500 char **value_split = g_strsplit(splits[idx], "=", 2); |
|
| 501 char *value = NULL; |
484 char *value = NULL; |
| 502 |
485 |
| 503 if(value_split[0] == NULL || value_split[0][0] == '\0') { |
486 if(build_args[idx].value != NULL) { |
| 504 continue; |
487 value = purple_unescape_text(build_args[idx].value); |
| 505 } |
|
| 506 |
|
| 507 if(value_split[1] != NULL) { |
|
| 508 value = purple_unescape_text(value_split[1]); |
|
| 509 } else { |
488 } else { |
| 510 value = NULL; |
489 value = NULL; |
| 511 } |
490 } |
| 512 |
491 |
| 513 g_string_append_printf(info, "%s: %s\n", value_split[0], value); |
492 g_string_append_printf(info, "%s: %s\n", build_args[idx].key, value); |
| 514 |
493 |
| 515 g_free(value); |
494 g_free(value); |
| 516 g_strfreev(value_split); |
495 } |
| 517 } |
|
| 518 |
|
| 519 g_strfreev(splits); |
|
| 520 |
496 |
| 521 return g_string_free(info, FALSE); |
497 return g_string_free(info, FALSE); |
| 522 } |
498 } |
| 523 |
499 |
| 524 static void |
500 static void |
| 527 pidgin_about_dialog_load_runtime_info(about); |
503 pidgin_about_dialog_load_runtime_info(about); |
| 528 pidgin_about_dialog_load_gtk_settings(about); |
504 pidgin_about_dialog_load_gtk_settings(about); |
| 529 pidgin_about_dialog_load_plugin_search_paths(about); |
505 pidgin_about_dialog_load_plugin_search_paths(about); |
| 530 pidgin_about_dialog_load_conf_path_info(about); |
506 pidgin_about_dialog_load_conf_path_info(about); |
| 531 |
507 |
| 532 #ifdef MESON_ARGS |
508 #ifdef HAVE_MESON_CONFIG |
| 533 pidgin_about_dialog_add_build_args(about, MESON_ARGS); |
509 pidgin_about_dialog_add_build_args(about, MESON_ARGS); |
| 534 gtk_widget_set_visible(GTK_WIDGET(about->build_args_group), TRUE); |
510 gtk_widget_set_visible(GTK_WIDGET(about->build_args_group), TRUE); |
| 535 #endif /* MESON_ARGS */ |
511 #endif /* HAVE_MESON_CONFIG */ |
| 536 } |
512 } |
| 537 |
513 |
| 538 /****************************************************************************** |
514 /****************************************************************************** |
| 539 * Callbacks |
515 * Callbacks |
| 540 *****************************************************************************/ |
516 *****************************************************************************/ |
| 568 info = pidgin_about_dialog_copy_gtk_settings(); |
544 info = pidgin_about_dialog_copy_gtk_settings(); |
| 569 } else if(data == about->plugin_search_paths_group) { |
545 } else if(data == about->plugin_search_paths_group) { |
| 570 info = pidgin_about_dialog_copy_plugin_search_paths(); |
546 info = pidgin_about_dialog_copy_plugin_search_paths(); |
| 571 } else if(data == about->conf_path_info_group) { |
547 } else if(data == about->conf_path_info_group) { |
| 572 info = pidgin_about_dialog_copy_conf_path_info(); |
548 info = pidgin_about_dialog_copy_conf_path_info(); |
| 573 #ifdef MESON_ARGS |
549 #ifdef HAVE_MESON_CONFIG |
| 574 } else if(data == about->build_args_group) { |
550 } else if(data == about->build_args_group) { |
| 575 info = pidgin_about_dialog_copy_build_args(MESON_ARGS); |
551 info = pidgin_about_dialog_copy_build_args(MESON_ARGS); |
| 576 #endif |
552 #endif |
| 577 } else { |
553 } else { |
| 578 GString *everything = g_string_new(NULL); |
554 GString *everything = g_string_new(NULL); |
| 599 |
575 |
| 600 info = pidgin_about_dialog_copy_plugin_search_paths(); |
576 info = pidgin_about_dialog_copy_plugin_search_paths(); |
| 601 g_string_append(everything, info); |
577 g_string_append(everything, info); |
| 602 g_free(info); |
578 g_free(info); |
| 603 |
579 |
| 604 #ifdef MESON_ARGS |
580 #ifdef HAVE_MESON_CONFIG |
| 605 g_string_append_c(everything, '\n'); |
581 g_string_append_c(everything, '\n'); |
| 606 info = pidgin_about_dialog_copy_build_args(MESON_ARGS); |
582 info = pidgin_about_dialog_copy_build_args(MESON_ARGS); |
| 607 g_string_append(everything, info); |
583 g_string_append(everything, info); |
| 608 g_free(info); |
584 g_free(info); |
| 609 #endif |
585 #endif |