Get the meson arguments working

Thu, 10 Aug 2017 23:00:22 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 10 Aug 2017 23:00:22 -0500
changeset 38660
d6a4308481c7
parent 38659
7772f66662f0
child 38661
cf4073d0d648

Get the meson arguments working

pidgin/about.ui file | annotate | diff | comparison | revisions
pidgin/pidginabout.c file | annotate | diff | comparison | revisions
--- a/pidgin/about.ui	Thu Aug 10 21:36:08 2017 -0500
+++ b/pidgin/about.ui	Thu Aug 10 23:00:22 2017 -0500
@@ -2,6 +2,14 @@
 <!-- Generated with glade 3.20.0 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
+  <object class="GtkTreeStore" id="build_info_store">
+    <columns>
+      <!-- column-name title -->
+      <column type="gchararray"/>
+      <!-- column-name value -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkTreeStore" id="credits_store">
     <columns>
       <!-- column-name markup -->
@@ -39,7 +47,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkToggleButton">
+              <object class="GtkToggleButton" id="build_info_button">
                 <property name="label" translatable="yes">Build Information</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -219,11 +227,14 @@
                   <object class="GtkScrolledWindow" id="build_info_page">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
+                    <property name="hscrollbar_policy">never</property>
                     <property name="shadow_type">in</property>
                     <child>
-                      <object class="GtkTreeView">
+                      <object class="GtkTreeView" id="build_info_treeview">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="model">build_info_store</property>
+                        <property name="headers_visible">False</property>
                         <child internal-child="selection">
                           <object class="GtkTreeSelection"/>
                         </child>
@@ -233,7 +244,7 @@
                             <child>
                               <object class="GtkCellRendererText"/>
                               <attributes>
-                                <attribute name="markup">1</attribute>
+                                <attribute name="markup">0</attribute>
                               </attributes>
                             </child>
                           </object>
@@ -254,8 +265,8 @@
                     </child>
                   </object>
                   <packing>
-                    <property name="name">buildinfo</property>
-                    <property name="title" translatable="yes">buildinfo</property>
+                    <property name="name">build-info</property>
+                    <property name="title" translatable="yes">build-info</property>
                     <property name="position">2</property>
                   </packing>
                 </child>
--- a/pidgin/pidginabout.c	Thu Aug 10 21:36:08 2017 -0500
+++ b/pidgin/pidginabout.c	Thu Aug 10 23:00:22 2017 -0500
@@ -4,6 +4,15 @@
 #include "pidginabout.h"
 #include "pidginresources.h"
 
+#include <stdio.h>
+
+#include "config.h"
+#ifdef HAVE_MESON_CONFIG
+#include "meson-config.h"
+#else
+#error HAVE_MESON_CONFIG is not defined
+#endif
+
 struct _PidginAboutDialogPrivate {
 	GtkWidget *stack;
 
@@ -12,6 +21,11 @@
 	GtkWidget *credits_treeview;
 	GtkTreeStore *credits_store;
 
+	GtkWidget *build_info_button;
+	GtkWidget *build_info_page;
+	GtkWidget *build_info_treeview;
+	GtkWidget *build_info_store;
+
 	gboolean switching_pages;
 };
 
@@ -30,6 +44,12 @@
 		g_str_equal("credits", name)
 	);
 
+	/* is the build info button active? */
+	gtk_toggle_button_set_active(
+		GTK_TOGGLE_BUTTON(about->priv->build_info_button),
+		g_str_equal("build-info", name)
+	);
+
 	about->priv->switching_pages = FALSE;
 }
 
@@ -55,7 +75,7 @@
 	parser = json_parser_new();
 
 	if(!json_parser_load_from_stream(parser, istream, NULL, &error)) {
-		g_critical(error->message);
+		g_critical("%s", error->message);
 	}
 
 	root_node = json_parser_get_root(parser);
@@ -117,6 +137,55 @@
 	g_input_stream_close(istream, NULL, NULL);
 }
 
+static void
+_pidgin_about_dialog_add_config_args(PidginAboutDialog *about) {
+#ifdef CONFIG_ARGS
+#endif /* CONFIG_ARGS */
+}
+
+static void
+_pidgin_about_dialog_add_meson_args(PidginAboutDialog *about) {
+#ifdef MESON_ARGS
+	GtkTreeIter meson, value;
+	gchar **splits = NULL;
+	gchar *split = NULL;
+	gint idx = 0;
+
+	gtk_tree_store_append(about->priv->build_info_store, &meson, NULL);
+	gtk_tree_store_set(
+		about->priv->build_info_store,
+		&meson,
+		0, "<span font-weight=\"bold\">Meson Arguments</span>",
+		-1
+	);
+
+	/* now walk through the arguments and add them */
+	splits = g_strsplit(MESON_ARGS, " ", -1);
+	for(idx = 0; splits[idx]; idx++) {
+		gchar **value_split = g_strsplit(splits[idx], "=", 2);
+
+		gtk_tree_store_append(about->priv->build_info_store, &value, &meson);
+		gtk_tree_store_set(
+			about->priv->build_info_store,
+			&value,
+			0, value_split[0],
+			1, value_split[1],
+			-1
+		);
+
+		g_strfreev(value_split);
+	}
+
+	g_strfreev(splits);
+#endif /* MESON_ARGS */
+}
+
+static void
+_pidgin_about_dialog_load_build_info(PidginAboutDialog *about) {
+	_pidgin_about_dialog_add_config_args(about);
+	_pidgin_about_dialog_add_meson_args(about);
+}
+
 /******************************************************************************
  * Callbacks
  *****************************************************************************/
@@ -133,6 +202,19 @@
 	_pidgin_about_dialog_switch_page(d, show ? "credits" : "main");
 }
 
+static void
+_pidgin_about_dialog_toggle_build_info(GtkToggleButton *b, gpointer d) {
+	PidginAboutDialog *about = d;
+	gboolean show = FALSE;
+
+	if(about->priv->switching_pages)
+		return;
+
+	show = gtk_toggle_button_get_active(b);
+
+	_pidgin_about_dialog_switch_page(d, show ? "build-info" : "main");
+}
+
 /******************************************************************************
  * GObject Stuff
  *****************************************************************************/
@@ -153,6 +235,11 @@
 	gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, credits_page);
 	gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, credits_store);
 	gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, credits_treeview);
+
+	gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, build_info_button);
+	gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, build_info_page);
+	gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, build_info_store);
+	gtk_widget_class_bind_template_child_private(widget_class, PidginAboutDialog, build_info_treeview);
 }
 
 static void
@@ -163,6 +250,7 @@
 
 	gtk_widget_init_template(GTK_WIDGET(about));
 
+	/* setup the credits stuff */
 	g_signal_connect(
 		about->priv->credits_button,
 		"toggled",
@@ -171,11 +259,18 @@
 	);
 
 	_pidgin_about_dialog_load_contributors(about);
+	gtk_tree_view_expand_all(GTK_TREE_VIEW(about->priv->credits_treeview));
 
-	/* expand all the nodes in the credits treeview and tweak some other
-	 * properties.
-	 */
-	gtk_tree_view_expand_all(GTK_TREE_VIEW(about->priv->credits_treeview));
+	/* setup the build info page */
+	g_signal_connect(
+		about->priv->build_info_button,
+		"toggled",
+		G_CALLBACK(_pidgin_about_dialog_toggle_build_info),
+		about
+	);
+
+	_pidgin_about_dialog_load_build_info(about);
+	gtk_tree_view_expand_all(GTK_TREE_VIEW(about->priv->build_info_treeview));
 }
 
 GtkWidget *

mercurial