[20744] | 1 | #!@PERL@ -w |
---|
| 2 | # -*- cperl -*- |
---|
| 3 | # |
---|
| 4 | # gtk-doc - GTK DocBook documentation generator. |
---|
| 5 | # Copyright (C) 1998 Damon Chaplin |
---|
| 6 | # |
---|
| 7 | # This program is free software; you can redistribute it and/or modify |
---|
| 8 | # it under the terms of the GNU General Public License as published by |
---|
| 9 | # the Free Software Foundation; either version 2 of the License, or |
---|
| 10 | # (at your option) any later version. |
---|
| 11 | # |
---|
| 12 | # This program is distributed in the hope that it will be useful, |
---|
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | # GNU General Public License for more details. |
---|
| 16 | # |
---|
| 17 | # You should have received a copy of the GNU General Public License |
---|
| 18 | # along with this program; if not, write to the Free Software |
---|
| 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 20 | # |
---|
| 21 | |
---|
| 22 | # |
---|
| 23 | # This gets information about object heirarchies and signals |
---|
| 24 | # by compiling a small C program. CFLAGS and LDFLAGS must be |
---|
| 25 | # set appropriately before running this script. |
---|
| 26 | # |
---|
| 27 | # NOTE: the lookup_signal_arg_names() function contains the argument names of |
---|
| 28 | # standard GTK signal handlers. This may need to be updated for new |
---|
| 29 | # GTK signals or Gnome widget signals. |
---|
| 30 | |
---|
| 31 | use Getopt::Long; |
---|
| 32 | |
---|
| 33 | unshift @INC, "@PACKAGE_DATA_DIR@"; |
---|
| 34 | require "gtkdoc-common.pl"; |
---|
| 35 | |
---|
| 36 | # Options |
---|
| 37 | |
---|
| 38 | # name of documentation module |
---|
| 39 | my $MODULE; |
---|
| 40 | my $OUTPUT_DIR; |
---|
| 41 | my $PRINT_VERSION; |
---|
| 42 | |
---|
| 43 | %optctl = (module => \$MODULE, |
---|
| 44 | types => \$TYPES_FILE, |
---|
| 45 | nogtkinit => \$NO_GTK_INIT, |
---|
| 46 | 'output-dir' => \$OUTPUT_DIR, |
---|
| 47 | 'version' => \$PRINT_VERSION); |
---|
| 48 | |
---|
| 49 | GetOptions(\%optctl, "module=s", "types:s", "output-dir:s", "nogtkinit", "version"); |
---|
| 50 | |
---|
| 51 | if ($PRINT_VERSION) { |
---|
| 52 | print "@VERSION@\n"; |
---|
| 53 | exit 0; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | $OUTPUT_DIR = $OUTPUT_DIR ? $OUTPUT_DIR : "."; |
---|
| 57 | |
---|
| 58 | $TYPES_FILE = $TYPES_FILE ? $TYPES_FILE : "$OUTPUT_DIR/$MODULE.types"; |
---|
| 59 | |
---|
| 60 | open TYPES, $TYPES_FILE || die "Cannot open $TYPES_FILE: $!\n"; |
---|
| 61 | open OUTPUT, ">$MODULE-scan.c" || die "Cannot open $MODULE-scan.c: $!\n"; |
---|
| 62 | |
---|
| 63 | my $old_signals_filename = "$OUTPUT_DIR/$MODULE.signals"; |
---|
| 64 | my $new_signals_filename = "$OUTPUT_DIR/$MODULE.signals.new"; |
---|
| 65 | my $old_hierarchy_filename = "$OUTPUT_DIR/$MODULE.hierarchy"; |
---|
| 66 | my $new_hierarchy_filename = "$OUTPUT_DIR/$MODULE.hierarchy.new"; |
---|
| 67 | my $old_args_filename = "$OUTPUT_DIR/$MODULE.args"; |
---|
| 68 | my $new_args_filename = "$OUTPUT_DIR/$MODULE.args.new"; |
---|
| 69 | |
---|
| 70 | # write a C program to scan the types |
---|
| 71 | |
---|
| 72 | $includes = ""; |
---|
| 73 | @types = (); |
---|
| 74 | |
---|
| 75 | for (<TYPES>) { |
---|
| 76 | if (/^#include/) { |
---|
| 77 | $includes .= $_; |
---|
| 78 | } elsif (/^%/) { |
---|
| 79 | next; |
---|
| 80 | } elsif (/^\s*$/) { |
---|
| 81 | next; |
---|
| 82 | } else { |
---|
| 83 | chomp; |
---|
| 84 | push @types, $_; |
---|
| 85 | } |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | $ntypes = @types + 1; |
---|
| 89 | |
---|
| 90 | print OUTPUT <<EOT; |
---|
| 91 | #include <string.h> |
---|
| 92 | #include <stdio.h> |
---|
| 93 | |
---|
| 94 | $includes |
---|
| 95 | GtkType object_types[$ntypes]; |
---|
| 96 | |
---|
| 97 | GtkType * |
---|
| 98 | get_object_types (void) |
---|
| 99 | { |
---|
| 100 | gint i = 0; |
---|
| 101 | EOT |
---|
| 102 | |
---|
| 103 | for (@types) { |
---|
| 104 | print OUTPUT " object_types[i++] = $_ ();\n"; |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | print OUTPUT <<EOT; |
---|
| 108 | object_types[i] = 0; |
---|
| 109 | |
---|
| 110 | return object_types; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | /* |
---|
| 114 | * This uses GTK type functions to output signal prototypes and the widget |
---|
| 115 | * hierarchy. |
---|
| 116 | */ |
---|
| 117 | |
---|
| 118 | /* The output files */ |
---|
| 119 | gchar *signals_filename = "$new_signals_filename"; |
---|
| 120 | gchar *hierarchy_filename = "$new_hierarchy_filename"; |
---|
| 121 | gchar *args_filename = "$new_args_filename"; |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | static void output_signals (void); |
---|
| 125 | static void output_widget_signals (FILE *fp, |
---|
| 126 | GtkType object_type); |
---|
| 127 | static void output_widget_signal (FILE *fp, |
---|
| 128 | GtkType object_type, |
---|
| 129 | gchar *object_class_name, |
---|
| 130 | guint signal_id); |
---|
| 131 | static gchar * get_type_name (GtkType type, |
---|
| 132 | gboolean * is_pointer); |
---|
| 133 | static gchar * get_gdk_event (const gchar * signal_name); |
---|
| 134 | static gchar ** lookup_signal_arg_names (gchar * type, |
---|
| 135 | const gchar * signal_name); |
---|
| 136 | |
---|
| 137 | static void output_widget_hierarchy (void); |
---|
| 138 | static void output_hierarchy (FILE *fp, |
---|
| 139 | GtkType type, |
---|
| 140 | gint level); |
---|
| 141 | |
---|
| 142 | static void output_args (void); |
---|
| 143 | static void output_widget_args (FILE *fp, GtkType object_type); |
---|
| 144 | |
---|
| 145 | int |
---|
| 146 | main (int argc, char *argv[]) |
---|
| 147 | { |
---|
| 148 | EOT |
---|
| 149 | |
---|
| 150 | if ($NO_GTK_INIT) { |
---|
| 151 | print OUTPUT <<EOT; |
---|
| 152 | gtk_type_init (); |
---|
| 153 | EOT |
---|
| 154 | } else { |
---|
| 155 | print OUTPUT <<EOT; |
---|
| 156 | gtk_init (&argc, &argv); |
---|
| 157 | EOT |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | print OUTPUT <<EOT; |
---|
| 161 | get_object_types (); |
---|
| 162 | |
---|
| 163 | output_signals (); |
---|
| 164 | output_widget_hierarchy (); |
---|
| 165 | output_args (); |
---|
| 166 | |
---|
| 167 | return 0; |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | static void |
---|
| 172 | output_signals (void) |
---|
| 173 | { |
---|
| 174 | FILE *fp; |
---|
| 175 | gint i; |
---|
| 176 | |
---|
| 177 | fp = fopen (signals_filename, "w"); |
---|
| 178 | if (fp == NULL) |
---|
| 179 | { |
---|
| 180 | g_warning ("Couldn't open output file: %s", signals_filename); |
---|
| 181 | return; |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | for (i = 0; object_types[i]; i++) |
---|
| 185 | output_widget_signals (fp, object_types[i]); |
---|
| 186 | |
---|
| 187 | fclose (fp); |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | |
---|
| 191 | /* This outputs all the signals of one widget. */ |
---|
| 192 | static void |
---|
| 193 | output_widget_signals (FILE *fp, GtkType object_type) |
---|
| 194 | { |
---|
| 195 | GtkObjectClass *class; |
---|
| 196 | gchar *object_class_name; |
---|
| 197 | guint sig; |
---|
| 198 | |
---|
| 199 | class = gtk_type_class (object_type); |
---|
| 200 | if (!class || class->nsignals == 0) |
---|
| 201 | return; |
---|
| 202 | |
---|
| 203 | object_class_name = gtk_type_name (object_type); |
---|
| 204 | |
---|
| 205 | for (sig = 0; sig < class->nsignals; sig++) |
---|
| 206 | { |
---|
| 207 | if (!class->signals[sig]) |
---|
| 208 | { |
---|
| 209 | /*g_print ("Signal slot [%u] is empty\\n", sig);*/ |
---|
| 210 | continue; |
---|
| 211 | } |
---|
| 212 | |
---|
| 213 | output_widget_signal (fp, object_type, object_class_name, |
---|
| 214 | class->signals[sig]); |
---|
| 215 | } |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | |
---|
| 219 | /* This outputs one signal. */ |
---|
| 220 | static void |
---|
| 221 | output_widget_signal (FILE *fp, |
---|
| 222 | GtkType object_type, |
---|
| 223 | gchar *object_name, |
---|
| 224 | guint signal_id) |
---|
| 225 | { |
---|
| 226 | GtkSignalQuery *query_info; |
---|
| 227 | gchar *ret_type, *pos, *type_name, *arg_name, *object_arg, *object_arg_start; |
---|
| 228 | gboolean is_pointer; |
---|
| 229 | gchar ret_type_buffer[1024], buffer[1024]; |
---|
| 230 | gint i, param; |
---|
| 231 | gchar **arg_names; |
---|
| 232 | gint param_num, widget_num, event_num, callback_num; |
---|
| 233 | gint *arg_num; |
---|
| 234 | gchar signal_name[128]; |
---|
| 235 | |
---|
| 236 | |
---|
| 237 | /* g_print ("Object: %s Type: %i Signal: %u\\n", object_name, object_type, |
---|
| 238 | signal_id);*/ |
---|
| 239 | |
---|
| 240 | param_num = 1; |
---|
| 241 | widget_num = event_num = callback_num = 0; |
---|
| 242 | |
---|
| 243 | query_info = gtk_signal_query (signal_id); |
---|
| 244 | if (query_info == NULL) |
---|
| 245 | { |
---|
| 246 | g_warning ("Couldn't query signal"); |
---|
| 247 | return; |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | /* Output the return type and function name. */ |
---|
| 251 | ret_type = get_type_name (query_info->return_val, &is_pointer); |
---|
| 252 | sprintf (ret_type_buffer, "%s%s", ret_type, is_pointer ? "*" : ""); |
---|
| 253 | |
---|
| 254 | /* Output the signal object type and the argument name. We assume the |
---|
| 255 | type is a pointer - I think that is OK. We remove "Gtk" or "Gnome" and |
---|
| 256 | convert to lower case for the argument name. */ |
---|
| 257 | pos = buffer; |
---|
| 258 | sprintf (pos, "%s ", object_name); |
---|
| 259 | pos += strlen (pos); |
---|
| 260 | |
---|
| 261 | if (!strncmp (object_name, "Gtk", 3)) |
---|
| 262 | object_arg = object_name + 3; |
---|
| 263 | else if (!strncmp (object_name, "Gnome", 5)) |
---|
| 264 | object_arg = object_name + 5; |
---|
| 265 | else |
---|
| 266 | object_arg = object_name; |
---|
| 267 | |
---|
| 268 | object_arg_start = pos; |
---|
| 269 | sprintf (pos, "*%s\\n", object_arg); |
---|
| 270 | pos += strlen (pos); |
---|
| 271 | g_strdown (object_arg_start); |
---|
| 272 | if (!strcmp (object_arg_start, "widget")) |
---|
| 273 | widget_num++; |
---|
| 274 | |
---|
| 275 | /* Convert signal name to use underscores rather than dashes '-'. */ |
---|
| 276 | strcpy (signal_name, query_info->signal_name); |
---|
| 277 | for (i = 0; signal_name[i]; i++) |
---|
| 278 | { |
---|
| 279 | if (signal_name[i] == '-') |
---|
| 280 | signal_name[i] = '_'; |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | /* Output the signal parameters. */ |
---|
| 284 | arg_names = lookup_signal_arg_names (object_name, signal_name); |
---|
| 285 | |
---|
| 286 | for (param = 0; param < query_info->nparams; param++) |
---|
| 287 | { |
---|
| 288 | if (arg_names) |
---|
| 289 | { |
---|
| 290 | sprintf (pos, "%s\\n", arg_names[param]); |
---|
| 291 | pos += strlen (pos); |
---|
| 292 | } |
---|
| 293 | else |
---|
| 294 | { |
---|
| 295 | type_name = get_type_name (query_info->params[param], &is_pointer); |
---|
| 296 | |
---|
| 297 | /* Most arguments to the callback are called "arg1", "arg2", etc. |
---|
| 298 | GdkWidgets are called "widget", "widget2", ... |
---|
| 299 | GdkEvents are called "event", "event2", ... |
---|
| 300 | GtkCallbacks are called "callback", "callback2", ... */ |
---|
| 301 | if (!strcmp (type_name, "GtkWidget")) |
---|
| 302 | { |
---|
| 303 | arg_name = "widget"; |
---|
| 304 | arg_num = &widget_num; |
---|
| 305 | } |
---|
| 306 | else if (!strcmp (type_name, "GdkEvent")) |
---|
| 307 | { |
---|
| 308 | type_name = get_gdk_event (signal_name); |
---|
| 309 | arg_name = "event"; |
---|
| 310 | arg_num = &event_num; |
---|
| 311 | is_pointer = TRUE; |
---|
| 312 | } |
---|
| 313 | else if (!strcmp (type_name, "GtkCallback") |
---|
| 314 | || !strcmp (type_name, "GtkCCallback")) |
---|
| 315 | { |
---|
| 316 | arg_name = "callback"; |
---|
| 317 | arg_num = &callback_num; |
---|
| 318 | } |
---|
| 319 | else |
---|
| 320 | { |
---|
| 321 | arg_name = "arg"; |
---|
| 322 | arg_num = ¶m_num; |
---|
| 323 | } |
---|
| 324 | sprintf (pos, "%s ", type_name); |
---|
| 325 | pos += strlen (pos); |
---|
| 326 | |
---|
| 327 | if (!arg_num || *arg_num == 0) |
---|
| 328 | sprintf (pos, "%s%s\\n", is_pointer ? "*" : " ", arg_name); |
---|
| 329 | else |
---|
| 330 | sprintf (pos, "%s%s%i\\n", is_pointer ? "*" : " ", arg_name, |
---|
| 331 | *arg_num); |
---|
| 332 | pos += strlen (pos); |
---|
| 333 | |
---|
| 334 | if (arg_num) |
---|
| 335 | *arg_num += 1; |
---|
| 336 | } |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | fprintf (fp, |
---|
| 340 | "<SIGNAL>\\n<NAME>%s::%s</NAME>\\n<RETURNS>%s</RETURNS>\\n%s</SIGNAL>\\n\\n", |
---|
| 341 | object_name, query_info->signal_name, ret_type_buffer, buffer); |
---|
| 342 | g_free (query_info); |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | |
---|
| 346 | /* Returns the type name to use for a signal argument or return value, given |
---|
| 347 | the GtkType from the signal info. It also sets is_pointer to TRUE if the |
---|
| 348 | argument needs a '*' since it is a pointer. */ |
---|
| 349 | static gchar * |
---|
| 350 | get_type_name (GtkType type, gboolean * is_pointer) |
---|
| 351 | { |
---|
| 352 | gchar *type_name; |
---|
| 353 | |
---|
| 354 | *is_pointer = FALSE; |
---|
| 355 | type_name = gtk_type_name (type); |
---|
| 356 | |
---|
| 357 | switch (type) { |
---|
| 358 | case GTK_TYPE_NONE: |
---|
| 359 | case GTK_TYPE_CHAR: |
---|
| 360 | case GTK_TYPE_UCHAR: |
---|
| 361 | case GTK_TYPE_BOOL: |
---|
| 362 | case GTK_TYPE_INT: |
---|
| 363 | case GTK_TYPE_UINT: |
---|
| 364 | case GTK_TYPE_LONG: |
---|
| 365 | case GTK_TYPE_ULONG: |
---|
| 366 | case GTK_TYPE_FLOAT: |
---|
| 367 | case GTK_TYPE_DOUBLE: |
---|
| 368 | case GTK_TYPE_POINTER: |
---|
| 369 | /* These all have normal C type names so they are OK. */ |
---|
| 370 | return type_name; |
---|
| 371 | |
---|
| 372 | case GTK_TYPE_STRING: |
---|
| 373 | /* A GtkString is really a gchar*. */ |
---|
| 374 | *is_pointer = TRUE; |
---|
| 375 | return "gchar"; |
---|
| 376 | |
---|
| 377 | case GTK_TYPE_ENUM: |
---|
| 378 | case GTK_TYPE_FLAGS: |
---|
| 379 | /* We use a gint for both of these. Hopefully a subtype with a decent |
---|
| 380 | name will be registered and used instead, as GTK+ does itself. */ |
---|
| 381 | return "gint"; |
---|
| 382 | |
---|
| 383 | case GTK_TYPE_BOXED: |
---|
| 384 | /* A boxed value is just an opaque pointer, I think. */ |
---|
| 385 | return "gpointer"; |
---|
| 386 | |
---|
| 387 | case GTK_TYPE_SIGNAL: |
---|
| 388 | case GTK_TYPE_ARGS: |
---|
| 389 | case GTK_TYPE_FOREIGN: |
---|
| 390 | case GTK_TYPE_CALLBACK: |
---|
| 391 | case GTK_TYPE_C_CALLBACK: |
---|
| 392 | /* FIXME: These are wrong. I think they expand into more than 1 argument. |
---|
| 393 | See the GtkArg struct in gtktypeutils.h and gtkargcollector.c. |
---|
| 394 | Fortunately I doubt anything uses these as signal args. */ |
---|
| 395 | return "gpointer"; |
---|
| 396 | |
---|
| 397 | default: |
---|
| 398 | break; |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | /* For all GtkObject subclasses we can use the class name with a "*", |
---|
| 402 | e.g. 'GtkWidget *'. */ |
---|
| 403 | if (gtk_type_is_a (type, GTK_TYPE_OBJECT)) |
---|
| 404 | *is_pointer = TRUE; |
---|
| 405 | |
---|
| 406 | return type_name; |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | |
---|
| 410 | static gchar * |
---|
| 411 | get_gdk_event (const gchar * signal_name) |
---|
| 412 | { |
---|
| 413 | static gchar *GbGDKEvents[] = |
---|
| 414 | { |
---|
| 415 | "button_press_event", "GdkEventButton", |
---|
| 416 | "button_release_event", "GdkEventButton", |
---|
| 417 | "motion_notify_event", "GdkEventMotion", |
---|
| 418 | "delete_event", "GdkEvent", |
---|
| 419 | "destroy_event", "GdkEvent", |
---|
| 420 | "expose_event", "GdkEventExpose", |
---|
| 421 | "key_press_event", "GdkEventKey", |
---|
| 422 | "key_release_event", "GdkEventKey", |
---|
| 423 | "enter_notify_event", "GdkEventCrossing", |
---|
| 424 | "leave_notify_event", "GdkEventCrossing", |
---|
| 425 | "configure_event", "GdkEventConfigure", |
---|
| 426 | "focus_in_event", "GdkEventFocus", |
---|
| 427 | "focus_out_event", "GdkEventFocus", |
---|
| 428 | "map_event", "GdkEvent", |
---|
| 429 | "unmap_event", "GdkEvent", |
---|
| 430 | "property_notify_event", "GdkEventProperty", |
---|
| 431 | "selection_clear_event", "GdkEventSelection", |
---|
| 432 | "selection_request_event", "GdkEventSelection", |
---|
| 433 | "selection_notify_event", "GdkEventSelection", |
---|
| 434 | "proximity_in_event", "GdkEventProximity", |
---|
| 435 | "proximity_out_event", "GdkEventProximity", |
---|
| 436 | "drag_begin_event", "GdkEventDragBegin", |
---|
| 437 | "drag_request_event", "GdkEventDragRequest", |
---|
| 438 | "drag_end_event", "GdkEventDragRequest", |
---|
| 439 | "drop_enter_event", "GdkEventDropEnter", |
---|
| 440 | "drop_leave_event", "GdkEventDropLeave", |
---|
| 441 | "drop_data_available_event", "GdkEventDropDataAvailable", |
---|
| 442 | "other_event", "GdkEventOther", |
---|
| 443 | "client_event", "GdkEventClient", |
---|
| 444 | "no_expose_event", "GdkEventNoExpose", |
---|
| 445 | NULL |
---|
| 446 | }; |
---|
| 447 | |
---|
| 448 | gint i; |
---|
| 449 | |
---|
| 450 | for (i = 0; GbGDKEvents[i]; i += 2) |
---|
| 451 | { |
---|
| 452 | if (!strcmp (signal_name, GbGDKEvents[i])) |
---|
| 453 | return GbGDKEvents[i + 1]; |
---|
| 454 | } |
---|
| 455 | return "GdkEvent"; |
---|
| 456 | } |
---|
| 457 | |
---|
| 458 | |
---|
| 459 | /* This returns argument names to use for some known GTK signals. |
---|
| 460 | It is passed a widget name, e.g. 'GtkCList' and a signal name, e.g. |
---|
| 461 | 'select_row' and it returns a pointer to an array of argument types and |
---|
| 462 | names. */ |
---|
| 463 | static gchar ** |
---|
| 464 | lookup_signal_arg_names (gchar * type, const gchar * signal_name) |
---|
| 465 | { |
---|
| 466 | /* Each arg array starts with the object type name and the signal name, |
---|
| 467 | and then signal arguments follow. */ |
---|
| 468 | static gchar *GbArgTable[][16] = |
---|
| 469 | { |
---|
| 470 | {"GtkCList", "select_row", |
---|
| 471 | "gint row", |
---|
| 472 | "gint column", |
---|
| 473 | "GdkEventButton *event"}, |
---|
| 474 | {"GtkCList", "unselect_row", |
---|
| 475 | "gint row", |
---|
| 476 | "gint column", |
---|
| 477 | "GdkEventButton *event"}, |
---|
| 478 | {"GtkCList", "click_column", |
---|
| 479 | "gint column"}, |
---|
| 480 | |
---|
| 481 | {"GtkCList", "resize_column", |
---|
| 482 | "gint column", |
---|
| 483 | "gint width"}, |
---|
| 484 | |
---|
| 485 | {"GtkCList", "extend_selection", |
---|
| 486 | "GtkScrollType scroll_type", |
---|
| 487 | "gfloat position", |
---|
| 488 | "gboolean auto_start_selection"}, |
---|
| 489 | {"GtkCList", "scroll_vertical", |
---|
| 490 | "GtkScrollType scroll_type", |
---|
| 491 | "gfloat position"}, |
---|
| 492 | {"GtkCList", "scroll_horizontal", |
---|
| 493 | "GtkScrollType scroll_type", |
---|
| 494 | "gfloat position"}, |
---|
| 495 | {"GtkContainer", "focus", |
---|
| 496 | "GtkDirectionType direction"}, |
---|
| 497 | {"GtkCTree", "tree_select_row", |
---|
| 498 | "GList *node", |
---|
| 499 | "gint column"}, |
---|
| 500 | {"GtkCTree", "tree_unselect_row", |
---|
| 501 | "GList *node", |
---|
| 502 | "gint column"}, |
---|
| 503 | |
---|
| 504 | {"GtkCTree", "tree_expand", |
---|
| 505 | "GList *node"}, |
---|
| 506 | {"GtkCTree", "tree_collapse", |
---|
| 507 | "GList *node"}, |
---|
| 508 | {"GtkCTree", "tree_move", |
---|
| 509 | "GList *node", |
---|
| 510 | "GList *new_parent", |
---|
| 511 | "GList *new_sibling"}, |
---|
| 512 | {"GtkCTree", "change_focus_row_expansion", |
---|
| 513 | "GtkCTreeExpansionType expansion"}, |
---|
| 514 | |
---|
| 515 | {"GtkEditable", "insert_text", |
---|
| 516 | "gchar *new_text", |
---|
| 517 | "gint new_text_length", |
---|
| 518 | "gint *position"}, |
---|
| 519 | {"GtkEditable", "delete_text", |
---|
| 520 | "gint start_pos", |
---|
| 521 | "gint end_pos"}, |
---|
| 522 | {"GtkEditable", "set_editable", |
---|
| 523 | "gboolean is_editable"}, |
---|
| 524 | {"GtkEditable", "move_cursor", |
---|
| 525 | "gint x", |
---|
| 526 | "gint y"}, |
---|
| 527 | {"GtkEditable", "move_word", |
---|
| 528 | "gint num_words"}, |
---|
| 529 | {"GtkEditable", "move_page", |
---|
| 530 | "gint x", |
---|
| 531 | "gint y"}, |
---|
| 532 | {"GtkEditable", "move_to_row", |
---|
| 533 | "gint row"}, |
---|
| 534 | {"GtkEditable", "move_to_column", |
---|
| 535 | "gint column"}, |
---|
| 536 | |
---|
| 537 | {"GtkEditable", "kill_char", |
---|
| 538 | "gint direction"}, |
---|
| 539 | {"GtkEditable", "kill_word", |
---|
| 540 | "gint direction"}, |
---|
| 541 | {"GtkEditable", "kill_line", |
---|
| 542 | "gint direction"}, |
---|
| 543 | |
---|
| 544 | |
---|
| 545 | {"GtkInputDialog", "enable_device", |
---|
| 546 | "gint deviceid"}, |
---|
| 547 | {"GtkInputDialog", "disable_device", |
---|
| 548 | "gint deviceid"}, |
---|
| 549 | |
---|
| 550 | {"GtkListItem", "extend_selection", |
---|
| 551 | "GtkScrollType scroll_type", |
---|
| 552 | "gfloat position", |
---|
| 553 | "gboolean auto_start_selection"}, |
---|
| 554 | {"GtkListItem", "scroll_vertical", |
---|
| 555 | "GtkScrollType scroll_type", |
---|
| 556 | "gfloat position"}, |
---|
| 557 | {"GtkListItem", "scroll_horizontal", |
---|
| 558 | "GtkScrollType scroll_type", |
---|
| 559 | "gfloat position"}, |
---|
| 560 | |
---|
| 561 | {"GtkMenuShell", "move_current", |
---|
| 562 | "GtkMenuDirectionType direction"}, |
---|
| 563 | {"GtkMenuShell", "activate_current", |
---|
| 564 | "gboolean force_hide"}, |
---|
| 565 | |
---|
| 566 | |
---|
| 567 | {"GtkNotebook", "switch_page", |
---|
| 568 | "GtkNotebookPage *page", |
---|
| 569 | "gint page_num"}, |
---|
| 570 | {"GtkStatusbar", "text_pushed", |
---|
| 571 | "guint context_id", |
---|
| 572 | "gchar *text"}, |
---|
| 573 | {"GtkStatusbar", "text_popped", |
---|
| 574 | "guint context_id", |
---|
| 575 | "gchar *text"}, |
---|
| 576 | {"GtkTipsQuery", "widget_entered", |
---|
| 577 | "GtkWidget *widget", |
---|
| 578 | "gchar *tip_text", |
---|
| 579 | "gchar *tip_private"}, |
---|
| 580 | {"GtkTipsQuery", "widget_selected", |
---|
| 581 | "GtkWidget *widget", |
---|
| 582 | "gchar *tip_text", |
---|
| 583 | "gchar *tip_private", |
---|
| 584 | "GdkEventButton *event"}, |
---|
| 585 | {"GtkToolbar", "orientation_changed", |
---|
| 586 | "GtkOrientation orientation"}, |
---|
| 587 | {"GtkToolbar", "style_changed", |
---|
| 588 | "GtkToolbarStyle style"}, |
---|
| 589 | {"GtkWidget", "draw", |
---|
| 590 | "GdkRectangle *area"}, |
---|
| 591 | {"GtkWidget", "size_request", |
---|
| 592 | "GtkRequisition *requisition"}, |
---|
| 593 | {"GtkWidget", "size_allocate", |
---|
| 594 | "GtkAllocation *allocation"}, |
---|
| 595 | {"GtkWidget", "state_changed", |
---|
| 596 | "GtkStateType state"}, |
---|
| 597 | {"GtkWidget", "style_set", |
---|
| 598 | "GtkStyle *previous_style"}, |
---|
| 599 | |
---|
| 600 | {"GtkWidget", "install_accelerator", |
---|
| 601 | "gchar *signal_name", |
---|
| 602 | "gchar key", |
---|
| 603 | "gint modifiers"}, |
---|
| 604 | |
---|
| 605 | {"GtkWidget", "add_accelerator", |
---|
| 606 | "guint accel_signal_id", |
---|
| 607 | "GtkAccelGroup *accel_group", |
---|
| 608 | "guint accel_key", |
---|
| 609 | "GdkModifierType accel_mods", |
---|
| 610 | "GtkAccelFlags accel_flags"}, |
---|
| 611 | |
---|
| 612 | {"GtkWidget", "parent_set", |
---|
| 613 | "GtkObject *old_parent"}, |
---|
| 614 | |
---|
| 615 | {"GtkWidget", "remove_accelerator", |
---|
| 616 | "GtkAccelGroup *accel_group", |
---|
| 617 | "guint accel_key", |
---|
| 618 | "GdkModifierType accel_mods"}, |
---|
| 619 | {"GtkWidget", "debug_msg", |
---|
| 620 | "gchar *message"}, |
---|
| 621 | {"GtkWindow", "move_resize", |
---|
| 622 | "gint *x", |
---|
| 623 | "gint *y", |
---|
| 624 | "gint width", |
---|
| 625 | "gint height"}, |
---|
| 626 | {"GtkWindow", "set_focus", |
---|
| 627 | "GtkWidget *widget"}, |
---|
| 628 | |
---|
| 629 | {"GtkWidget", "selection_get", |
---|
| 630 | "GtkSelectionData *data", |
---|
| 631 | "guint info", |
---|
| 632 | "guint time"}, |
---|
| 633 | {"GtkWidget", "selection_received", |
---|
| 634 | "GtkSelectionData *data", |
---|
| 635 | "guint time"}, |
---|
| 636 | |
---|
| 637 | {"GtkWidget", "drag_begin", |
---|
| 638 | "GdkDragContext *drag_context"}, |
---|
| 639 | {"GtkWidget", "drag_end", |
---|
| 640 | "GdkDragContext *drag_context"}, |
---|
| 641 | {"GtkWidget", "drag_data_delete", |
---|
| 642 | "GdkDragContext *drag_context"}, |
---|
| 643 | {"GtkWidget", "drag_leave", |
---|
| 644 | "GdkDragContext *drag_context", |
---|
| 645 | "guint time"}, |
---|
| 646 | {"GtkWidget", "drag_motion", |
---|
| 647 | "GdkDragContext *drag_context", |
---|
| 648 | "gint x", |
---|
| 649 | "gint y", |
---|
| 650 | "guint time"}, |
---|
| 651 | {"GtkWidget", "drag_drop", |
---|
| 652 | "GdkDragContext *drag_context", |
---|
| 653 | "gint x", |
---|
| 654 | "gint y", |
---|
| 655 | "guint time"}, |
---|
| 656 | {"GtkWidget", "drag_data_get", |
---|
| 657 | "GdkDragContext *drag_context", |
---|
| 658 | "GtkSelectionData *data", |
---|
| 659 | "guint info", |
---|
| 660 | "guint time"}, |
---|
| 661 | {"GtkWidget", "drag_data_received", |
---|
| 662 | "GdkDragContext *drag_context", |
---|
| 663 | "gint x", |
---|
| 664 | "gint y", |
---|
| 665 | "GtkSelectionData *data", |
---|
| 666 | "guint info", |
---|
| 667 | "guint time"}, |
---|
| 668 | |
---|
| 669 | {NULL} |
---|
| 670 | }; |
---|
| 671 | |
---|
| 672 | gint i; |
---|
| 673 | |
---|
| 674 | for (i = 0; GbArgTable[i][0]; i++) |
---|
| 675 | { |
---|
| 676 | if (!strcmp (type, GbArgTable[i][0]) |
---|
| 677 | && !strcmp (signal_name, GbArgTable[i][1])) |
---|
| 678 | return &GbArgTable[i][2]; |
---|
| 679 | } |
---|
| 680 | return NULL; |
---|
| 681 | } |
---|
| 682 | |
---|
| 683 | |
---|
| 684 | /* This outputs the hierarchy of all widgets which have been initialized, |
---|
| 685 | i.e. by calling their XXX_get_type() initialization function. */ |
---|
| 686 | static void |
---|
| 687 | output_widget_hierarchy (void) |
---|
| 688 | { |
---|
| 689 | FILE *fp; |
---|
| 690 | |
---|
| 691 | fp = fopen (hierarchy_filename, "w"); |
---|
| 692 | if (fp == NULL) |
---|
| 693 | { |
---|
| 694 | g_warning ("Couldn't open output file: %s", hierarchy_filename); |
---|
| 695 | return; |
---|
| 696 | } |
---|
| 697 | output_hierarchy (fp, GTK_TYPE_OBJECT, 0); |
---|
| 698 | fclose (fp); |
---|
| 699 | } |
---|
| 700 | |
---|
| 701 | |
---|
| 702 | /* This is called recursively to output the hierarchy of a widget. */ |
---|
| 703 | static void |
---|
| 704 | output_hierarchy (FILE *fp, |
---|
| 705 | GtkType type, |
---|
| 706 | gint level) |
---|
| 707 | { |
---|
| 708 | GList *list; |
---|
| 709 | guint i; |
---|
| 710 | |
---|
| 711 | if (!type) |
---|
| 712 | return; |
---|
| 713 | |
---|
| 714 | for (i = 0; i < level; i++) |
---|
| 715 | fprintf (fp, " "); |
---|
| 716 | fprintf (fp, gtk_type_name (type)); |
---|
| 717 | fprintf (fp, "\\n"); |
---|
| 718 | |
---|
| 719 | list = gtk_type_children_types (type); |
---|
| 720 | |
---|
| 721 | while (list) |
---|
| 722 | { |
---|
| 723 | GtkType child = (GtkType) list->data; |
---|
| 724 | output_hierarchy (fp, child, level + 1); |
---|
| 725 | list = list->next; |
---|
| 726 | } |
---|
| 727 | } |
---|
| 728 | |
---|
| 729 | |
---|
| 730 | static void |
---|
| 731 | output_args (void) |
---|
| 732 | { |
---|
| 733 | FILE *fp; |
---|
| 734 | gint i; |
---|
| 735 | |
---|
| 736 | fp = fopen (args_filename, "w"); |
---|
| 737 | if (fp == NULL) |
---|
| 738 | { |
---|
| 739 | g_warning ("Couldn't open output file: %s", args_filename); |
---|
| 740 | return; |
---|
| 741 | } |
---|
| 742 | |
---|
| 743 | for (i = 0; object_types[i]; i++) |
---|
| 744 | output_widget_args (fp, object_types[i]); |
---|
| 745 | |
---|
| 746 | fclose (fp); |
---|
| 747 | } |
---|
| 748 | |
---|
| 749 | |
---|
| 750 | static void |
---|
| 751 | output_widget_args (FILE *fp, GtkType object_type) |
---|
| 752 | { |
---|
| 753 | GtkObjectClass *class; |
---|
| 754 | gchar *object_class_name; |
---|
| 755 | GtkArg *args; |
---|
| 756 | guint32 *arg_flags; |
---|
| 757 | guint n_args; |
---|
| 758 | gint arg; |
---|
| 759 | gchar flags[16], *pos; |
---|
| 760 | |
---|
| 761 | class = gtk_type_class (object_type); |
---|
| 762 | if (!class) |
---|
| 763 | return; |
---|
| 764 | |
---|
| 765 | object_class_name = gtk_type_name (object_type); |
---|
| 766 | |
---|
| 767 | args = gtk_object_query_args (class->type, &arg_flags, &n_args); |
---|
| 768 | |
---|
| 769 | for (arg = 0; arg < n_args; arg++) |
---|
| 770 | { |
---|
| 771 | pos = flags; |
---|
| 772 | /* We use one-character flags for simplicity. */ |
---|
| 773 | if (arg_flags[arg] & GTK_ARG_READABLE) |
---|
| 774 | *pos++ = 'r'; |
---|
| 775 | if (arg_flags[arg] & GTK_ARG_WRITABLE) |
---|
| 776 | *pos++ = 'w'; |
---|
| 777 | if (arg_flags[arg] & GTK_ARG_CONSTRUCT) |
---|
| 778 | *pos++ = 'x'; |
---|
| 779 | if (arg_flags[arg] & GTK_ARG_CONSTRUCT_ONLY) |
---|
| 780 | *pos++ = 'X'; |
---|
| 781 | if (arg_flags[arg] & GTK_ARG_CHILD_ARG) |
---|
| 782 | *pos++ = 'c'; |
---|
| 783 | *pos = 0; |
---|
| 784 | |
---|
| 785 | fprintf (fp, "<ARG>\\n<NAME>%s</NAME>\\n<TYPE>%s</TYPE>\\n<FLAGS>%s</FLAGS>\\n</ARG>\\n\\n", |
---|
| 786 | args[arg].name, gtk_type_name (args[arg].type), flags); |
---|
| 787 | } |
---|
| 788 | |
---|
| 789 | g_free (args); |
---|
| 790 | g_free (arg_flags); |
---|
| 791 | } |
---|
| 792 | EOT |
---|
| 793 | |
---|
| 794 | close OUTPUT; |
---|
| 795 | |
---|
| 796 | # Compile and run our file |
---|
| 797 | |
---|
| 798 | $CC = $ENV{CC} ? $ENV{CC} : "gcc"; |
---|
| 799 | $LD = $ENV{LD} ? $ENV{LD} : $CC; |
---|
| 800 | $CFLAGS = $ENV{CFLAGS} ? $ENV{CFLAGS} : ""; |
---|
| 801 | $LDFLAGS = $ENV{LDFLAGS} ? $ENV{LDFLAGS} : ""; |
---|
| 802 | |
---|
| 803 | my $o_file; |
---|
| 804 | if ($CC =~ /libtool/) { |
---|
| 805 | $o_file = "$MODULE-scan.lo" |
---|
| 806 | } else { |
---|
| 807 | $o_file = "$MODULE-scan.o" |
---|
| 808 | } |
---|
| 809 | |
---|
| 810 | $command = "$CC $CFLAGS -c -o $o_file $MODULE-scan.c && $LD -o $MODULE-scan $o_file $LDFLAGS"; |
---|
| 811 | |
---|
| 812 | system($command) == 0 or die "Compilation of scanner failed\n"; |
---|
| 813 | |
---|
| 814 | system("./$MODULE-scan") == 0 or die "Scan failed\n"; |
---|
| 815 | |
---|
| 816 | unlink "./$MODULE-scan.c", "./$MODULE-scan.o", "./$MODULE-scan.lo", "./$MODULE-scan"; |
---|
| 817 | |
---|
| 818 | &UpdateFileIfChanged ($old_signals_filename, $new_signals_filename, 0); |
---|
| 819 | &UpdateFileIfChanged ($old_hierarchy_filename, $new_hierarchy_filename, 0); |
---|
| 820 | &UpdateFileIfChanged ($old_args_filename, $new_args_filename, 0); |
---|
| 821 | |
---|