My good deed of the day
- From: Tristan Van Berkom <vantr touchtunes com>
- To: gtk-app-devel-list gnome org
- Subject: My good deed of the day
- Date: Wed, 16 Oct 2002 15:54:48 -0400
It took me about a half hour to write
this thing and all the time wishing it
already existed.
So I figured if I can save someone else the troubble
... why not ?
this function/macros will print a GtkWidget's state
(flags values properties) of course ... for
debugging purposes.
Take it or leave it ;)
-Tristan
#define GTK_WIDGET_STATE_STR(wid) \
GTK_WIDGET_STATE(wid) == GTK_STATE_NORMAL ? "GTK_STATE_NORMAL" : \
GTK_WIDGET_STATE(wid) == GTK_STATE_ACTIVE ? "GTK_STATE_ACTIVE" : \
GTK_WIDGET_STATE(wid) == GTK_STATE_PRELIGHT ? "GTK_STATE_PRELIGHT" : \
GTK_WIDGET_STATE(wid) == GTK_STATE_SELECTED ? "GTK_STATE_SELECTED" : \
GTK_WIDGET_STATE(wid) == GTK_STATE_INSENSITIVE ? "GTK_STATE_INSENSITIVE" : "UNKNOWN"
#define GTK_WIDGET_TOPLEVEL_STR(wid) \
GTK_WIDGET_TOPLEVEL(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_NO_WINDOW_STR(wid) \
GTK_WIDGET_NO_WINDOW(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_REALIZED_STR(wid) \
GTK_WIDGET_REALIZED(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_MAPPED_STR(wid) \
GTK_WIDGET_MAPPED(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_VISIBLE_STR(wid) \
GTK_WIDGET_VISIBLE(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_DRAWABLE_STR(wid) \
GTK_WIDGET_DRAWABLE(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_SENSITIVE_STR(wid) \
GTK_WIDGET_SENSITIVE(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_PARENT_SENSITIVE_STR(wid) \
GTK_WIDGET_PARENT_SENSITIVE(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_CAN_FOCUS_STR(wid) \
GTK_WIDGET_CAN_FOCUS(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_HAS_FOCUS_STR(wid) \
GTK_WIDGET_HAS_FOCUS(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_CAN_DEFAULT_STR(wid) \
GTK_WIDGET_CAN_DEFAULT(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_RECEIVES_DEFAULT_STR(wid) \
GTK_WIDGET_RECEIVES_DEFAULT(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_HAS_DEFAULT_STR(wid) \
GTK_WIDGET_HAS_DEFAULT(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_HAS_GRAB_STR(wid) \
GTK_WIDGET_HAS_GRAB(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_RC_STYLE_STR(wid) \
GTK_WIDGET_RC_STYLE(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_COMPOSITE_CHILD_STR(wid) \
GTK_WIDGET_COMPOSITE_CHILD(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_APP_PAINTABLE_STR(wid) \
GTK_WIDGET_APP_PAINTABLE(wid) ? "TRUE" : "FALSE"
#define GTK_WIDGET_DOUBLE_BUFFERED_STR(wid) \
GTK_WIDGET_DOUBLE_BUFFERED(wid) ? "TRUE" : "FALSE"
void gtk_widget_debug(GtkWidget *wid) {
if (GTK_IS_WIDGET(wid)) {
g_message("Printing widget info for %s\n\t"
"Widget state: %s\n\t"
"Top Level: %s\n\t"
"No Window: %s\n\t"
"Realized: %s\n\t"
"Mapped: %s\n\t"
"Visible: %s\n\t"
"Drawable: %s\n\t"
"Sensitive: %s\n\t"
"Parent Sensative: %s\n\t"
"Can Focus: %s\n\t"
"Has Focus: %s\n\t"
"Can Default: %s\n\t"
"Recieves Default: %s\n\t"
"Has Defualt: %s\n\t"
"Has Grab: %s\n\t"
"Rc Style: %s\n\t"
"Composite Child: %s\n\t"
"App Paintable: %s\n\t"
"Double Buffered: %s\n",
gtk_widget_get_name(GTK_WIDGET(wid)),
GTK_WIDGET_STATE_STR(GTK_WIDGET(wid)),
GTK_WIDGET_TOPLEVEL_STR(GTK_WIDGET(wid)),
GTK_WIDGET_NO_WINDOW_STR(GTK_WIDGET(wid)),
GTK_WIDGET_REALIZED_STR(GTK_WIDGET(wid)),
GTK_WIDGET_MAPPED_STR(GTK_WIDGET(wid)),
GTK_WIDGET_VISIBLE_STR(GTK_WIDGET(wid)),
GTK_WIDGET_DRAWABLE_STR(GTK_WIDGET(wid)),
GTK_WIDGET_SENSITIVE_STR(GTK_WIDGET(wid)),
GTK_WIDGET_PARENT_SENSITIVE_STR(GTK_WIDGET(wid)),
GTK_WIDGET_CAN_FOCUS_STR(GTK_WIDGET(wid)),
GTK_WIDGET_HAS_FOCUS_STR(GTK_WIDGET(wid)),
GTK_WIDGET_CAN_DEFAULT_STR(GTK_WIDGET(wid)),
GTK_WIDGET_RECEIVES_DEFAULT_STR(GTK_WIDGET(wid)),
GTK_WIDGET_HAS_DEFAULT_STR(GTK_WIDGET(wid)),
GTK_WIDGET_HAS_GRAB_STR(GTK_WIDGET(wid)),
GTK_WIDGET_RC_STYLE_STR(GTK_WIDGET(wid)),
GTK_WIDGET_COMPOSITE_CHILD_STR(GTK_WIDGET(wid)),
GTK_WIDGET_APP_PAINTABLE_STR(GTK_WIDGET(wid)),
GTK_WIDGET_DOUBLE_BUFFERED_STR(GTK_WIDGET(wid)));
} else {
g_message(__FUNCTION__ ": Argument is not a widget");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]