qulogic/pidgin

Fix build information when config uses lists

8 months ago, Elliott Sales de Andrade
d9c2194dbc2b
Parents 73bb1fae628c
Children 097f57669043
Fix build information when config uses lists

For example, by default `c_winlib` is set to various Windows libraries there, but things like `c_args` could also be lists (they're just empty by default.)

The old code split by commas, which broke anything after a list that had any content. Instead, use a `PurpleKeyValuePair` array so that keys/values are in a structured format.

Also, change the value into an `AdwActionRow:subtitle`, as that wraps better.

Testing Done:
Compiled and checked that the About dialog had changed as expected.

Reviewed at https://reviews.imfreedom.org/r/2757/
--- a/mkmesonconf.py Tue Oct 31 01:12:44 2023 -0500
+++ b/mkmesonconf.py Tue Oct 31 01:41:45 2023 -0500
@@ -86,8 +86,11 @@
conf = [normalize_pidgin_option(option) for option in conf]
conf = [option for option in conf if ':' not in option['name']]
-settings = ' '.join('{}={}'.format(option['name'], tostr(option['value']))
- for option in sorted(conf, key=lambda x: x['name']))
-
with open(os.path.join(project_build_root, 'meson-config.h'), 'w') as f:
- f.write('#define MESON_ARGS "{}"'.format(settings))
+ f.write('#include <purple.h>\n')
+ f.write('const PurpleKeyValuePair MESON_ARGS[] = {\n')
+ for option in sorted(conf, key=lambda x: x['name']):
+ f.write('{ .key= "' + option['name'] + '",' +
+ ' .value="' + tostr(option['value']) + '" },\n')
+ f.write('{ .key=NULL, .value=NULL },\n')
+ f.write('};\n')
--- a/pidgin/pidginabout.c Tue Oct 31 01:12:44 2023 -0500
+++ b/pidgin/pidginabout.c Tue Oct 31 01:41:45 2023 -0500
@@ -22,10 +22,6 @@
#include <purpleconfig.h>
-#ifdef HAVE_MESON_CONFIG
-#include "meson-config.h"
-#endif
-
#include <glib/gi18n-lib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -36,6 +32,10 @@
#include "pidginabout.h"
+#ifdef HAVE_MESON_CONFIG
+#include "meson-config.h"
+#endif
+
#include "package_revision.h"
#include "gtkutils.h"
#include "pidgincore.h"
@@ -79,9 +79,7 @@
adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row), title);
if(value != NULL) {
- GtkWidget *label = gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(label), value);
- adw_action_row_add_suffix(ADW_ACTION_ROW(row), label);
+ adw_action_row_set_subtitle(ADW_ACTION_ROW(row), value);
}
adw_preferences_group_add(group, row);
@@ -463,31 +461,18 @@
static void
pidgin_about_dialog_add_build_args(PidginAboutDialog *about,
- const char *build_args)
+ const PurpleKeyValuePair build_args[])
{
- gchar **splits = NULL;
-
/* Walk through the arguments and add them */
- splits = g_strsplit(build_args, " ", -1);
- for(gint idx = 0; splits[idx]; idx++) {
- gchar **value_split = g_strsplit(splits[idx], "=", 2);
-
- if(value_split[0] == NULL || value_split[0][0] == '\0') {
- continue;
- }
-
+ for(gint idx = 0; build_args[idx].key != NULL; idx++) {
pidgin_about_dialog_group_add_row(about->build_args_group,
- value_split[0], value_split[1]);
-
- g_strfreev(value_split);
+ build_args[idx].key,
+ build_args[idx].value);
}
-
- g_strfreev(splits);
}
static char *
-pidgin_about_dialog_copy_build_args(const char *build_args) {
- char **splits = NULL;
+pidgin_about_dialog_copy_build_args(const PurpleKeyValuePair build_args[]) {
GString *info = NULL;
info = g_string_new(
@@ -495,29 +480,20 @@
"===============\n");
/* Walk through the arguments and add them */
- splits = g_strsplit(build_args, " ", -1);
- for(gint idx = 0; splits[idx]; idx++) {
- char **value_split = g_strsplit(splits[idx], "=", 2);
+ for(gint idx = 0; build_args[idx].key != NULL; idx++) {
char *value = NULL;
- if(value_split[0] == NULL || value_split[0][0] == '\0') {
- continue;
- }
-
- if(value_split[1] != NULL) {
- value = purple_unescape_text(value_split[1]);
+ if(build_args[idx].value != NULL) {
+ value = purple_unescape_text(build_args[idx].value);
} else {
value = NULL;
}
- g_string_append_printf(info, "%s: %s\n", value_split[0], value);
+ g_string_append_printf(info, "%s: %s\n", build_args[idx].key, value);
g_free(value);
- g_strfreev(value_split);
}
- g_strfreev(splits);
-
return g_string_free(info, FALSE);
}
@@ -529,10 +505,10 @@
pidgin_about_dialog_load_plugin_search_paths(about);
pidgin_about_dialog_load_conf_path_info(about);
-#ifdef MESON_ARGS
+#ifdef HAVE_MESON_CONFIG
pidgin_about_dialog_add_build_args(about, MESON_ARGS);
gtk_widget_set_visible(GTK_WIDGET(about->build_args_group), TRUE);
-#endif /* MESON_ARGS */
+#endif /* HAVE_MESON_CONFIG */
}
/******************************************************************************
@@ -570,7 +546,7 @@
info = pidgin_about_dialog_copy_plugin_search_paths();
} else if(data == about->conf_path_info_group) {
info = pidgin_about_dialog_copy_conf_path_info();
-#ifdef MESON_ARGS
+#ifdef HAVE_MESON_CONFIG
} else if(data == about->build_args_group) {
info = pidgin_about_dialog_copy_build_args(MESON_ARGS);
#endif
@@ -601,7 +577,7 @@
g_string_append(everything, info);
g_free(info);
-#ifdef MESON_ARGS
+#ifdef HAVE_MESON_CONFIG
g_string_append_c(everything, '\n');
info = pidgin_about_dialog_copy_build_args(MESON_ARGS);
g_string_append(everything, info);