summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-06-22 04:38:16 +0000
committerMatthias Clasen <mclasen@redhat.com>2020-10-01 14:51:04 -0400
commitc755ff3ba0889d3da7f8097f9175f482d78c56fe (patch)
tree4751c24ce5677e51d5952e5f958ccf8a17aebda6
parentb6fa56d3760c2dff2f8f1950c21ae49d5a2eee67 (diff)
downloadgtk-doc-c755ff3ba0889d3da7f8097f9175f482d78c56fe.tar.gz
scangobj: Introspect GTK4 actions
GTK4 can define actions for widget classes. Write these out to a .actions file.
-rw-r--r--gtkdoc/scangobj.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/gtkdoc/scangobj.py b/gtkdoc/scangobj.py
index 003c517..296fd85 100644
--- a/gtkdoc/scangobj.py
+++ b/gtkdoc/scangobj.py
@@ -100,6 +100,7 @@ const gchar *hierarchy_filename = "${new_hierarchy_filename}";
const gchar *interfaces_filename = "${new_interfaces_filename}";
const gchar *prerequisites_filename = "${new_prerequisites_filename}";
const gchar *args_filename = "${new_args_filename}";
+const gchar *actions_filename = "${new_actions_filename}";
static void output_signals (void);
static void output_object_signals (FILE *fp,
@@ -125,6 +126,9 @@ static void output_prerequisites (FILE *fp,
static void output_args (void);
static void output_object_args (FILE *fp, GType object_type);
+static void output_actions (void);
+static void output_object_actions (FILE *fp, GType object_type);
+
int
main (${main_func_params})
{
@@ -137,6 +141,7 @@ main (${main_func_params})
output_object_interfaces ();
output_interface_prerequisites ();
output_args ();
+ output_actions ();
return 0;
}
@@ -566,6 +571,71 @@ output_prerequisites (FILE *fp,
}
static void
+output_actions (void)
+{
+ FILE *fp;
+ gint i;
+
+ fp = fopen (actions_filename, "w");
+ if (fp == NULL) {
+ g_warning ("Couldn't open output file: %s : %s", actions_filename, g_strerror(errno));
+ return;
+ }
+
+ for (i = 0; object_types[i]; i++) {
+ output_object_actions (fp, object_types[i]);
+ }
+
+ fclose (fp);
+}
+
+static void
+output_object_actions (FILE *fp, GType object_type)
+{
+ gpointer class;
+
+ if (!G_TYPE_IS_OBJECT (object_type))
+ return;
+
+ class = g_type_class_peek (object_type);
+ if (!class)
+ return;
+
+#ifdef GTK_IS_WIDGET_CLASS
+#if GTK_CHECK_VERSION(3,96,0)
+ if (GTK_IS_WIDGET_CLASS (class)) {
+ guint i = 0;
+ const char *action_name;
+ GType owner;
+ const GVariantType *parameter_type;
+ const char *property_name;
+ const gchar *object_class_name;
+
+ object_class_name = g_type_name (object_type);
+ while (gtk_widget_class_query_action (GTK_WIDGET_CLASS (class),
+ i,
+ &owner,
+ &action_name,
+ &parameter_type,
+ &property_name)) {
+ i++;
+ if (owner == G_TYPE_FROM_CLASS (class))
+ fprintf (fp, "<ACTION>\\n"
+ "<NAME>%s:::%s</NAME>\\n"
+ "<PARAMETER>%s</PARAMETER>\\n"
+ "<PROPERTY>%s</PROPERTY>\\n"
+ "</ACTION>\\n\\n",
+ object_class_name,
+ action_name,
+ parameter_type ? g_variant_type_peek_string (parameter_type) : "",
+ property_name ? property_name : "");
+ }
+ }
+#endif
+#endif
+}
+
+static void
output_args (void)
{
FILE *fp;
@@ -1225,6 +1295,8 @@ def run(options):
new_prerequisites_filename = base_filename + '.prerequisites.new'
old_args_filename = base_filename + '.args'
new_args_filename = base_filename + '.args.new'
+ old_actions_filename = base_filename + '.actions'
+ new_actions_filename = base_filename + '.actions.new'
# generate a C program to scan the types
@@ -1335,5 +1407,6 @@ def run(options):
common.UpdateFileIfChanged(old_interfaces_filename, new_interfaces_filename, False)
common.UpdateFileIfChanged(old_prerequisites_filename, new_prerequisites_filename, False)
common.UpdateFileIfChanged(old_args_filename, new_args_filename, False)
+ common.UpdateFileIfChanged(old_actions_filename, new_actions_filename, False)
return 0