Commit 801875b8 authored by Tor Lillqvist's avatar Tor Lillqvist

Replace gtk_debug_flags with getter and setter functions

Preferrably should be made just into a local variable for libgtk like
_gdk_debug_flags for libgdk. But for now used by
gtk/tests/textbuffer.c and modules/printbackends/cups/gtkprintbackendcups.c.
parent 2ab562a6
......@@ -1849,6 +1849,8 @@ gtk_list_store_swap
#if IN_HEADER(__GTK_MAIN_H__)
#if IN_FILE(__GTK_MAIN_C__)
gtk_get_debug_flags
gtk_set_debug_flags
gtk_get_option_group
gtk_get_current_event
gtk_get_current_event_device
......@@ -4540,7 +4542,6 @@ gtk_info_bar_get_message_type
#endif
#ifdef INCLUDE_VARIABLES
gtk_debug_flags
gtk_text_attr_appearance_type
gtk_text_char_type
gtk_text_child_type
......
......@@ -701,7 +701,7 @@ _gtk_builder_construct (GtkBuilder *builder,
g_object_set_property (obj, param->name, &param->value);
#if G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_BUILDER)
if (gtk_get_debug_flags () & GTK_DEBUG_BUILDER)
{
gchar *str = g_strdup_value_contents ((const GValue*)&param->value);
g_print ("set %s: %s = %s\n", info->id, param->name, str);
......
......@@ -835,7 +835,7 @@ start_element (GMarkupParseContext *context,
ParserData *data = (ParserData*)user_data;
#ifdef GTK_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_BUILDER)
if (gtk_get_debug_flags () & GTK_DEBUG_BUILDER)
{
GString *tags = g_string_new ("");
int i;
......
......@@ -54,7 +54,7 @@ typedef enum {
#ifdef G_ENABLE_DEBUG
#define GTK_NOTE(type,action) G_STMT_START { \
if (gtk_debug_flags & GTK_DEBUG_##type) \
if (gtk_get_debug_flags () & GTK_DEBUG_##type) \
{ action; }; } G_STMT_END
#else /* !G_ENABLE_DEBUG */
......@@ -63,17 +63,8 @@ typedef enum {
#endif /* G_ENABLE_DEBUG */
#ifdef G_OS_WIN32
# ifdef GTK_COMPILATION
# define GTKVAR __declspec(dllexport)
# else
# define GTKVAR extern __declspec(dllimport)
# endif
#else
# define GTKVAR extern
#endif
GTKVAR guint gtk_debug_flags;
guint gtk_get_debug_flags (void);
void gtk_set_debug_flags (guint flags);
G_END_DECLS
......
......@@ -130,7 +130,7 @@ _gtk_icon_cache_new_for_path (const gchar *path)
info.flags = CHECK_OFFSETS|CHECK_STRINGS;
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_ICONTHEME)
if (gtk_get_debug_flags () & GTK_DEBUG_ICONTHEME)
{
if (!_gtk_icon_cache_validate (&info))
{
......
......@@ -192,7 +192,7 @@ static GList *quit_functions = NULL; /* A list of quit functions.
*/
static GSList *key_snoopers = NULL;
guint gtk_debug_flags = 0; /* Global GTK debug flag */
static guint debug_flags = 0; /* Global GTK debug flag */
#ifdef G_ENABLE_DEBUG
static const GDebugKey gtk_debug_keys[] = {
......@@ -477,9 +477,9 @@ static gboolean g_fatal_warnings = FALSE;
static gboolean
gtk_arg_debug_cb (const char *key, const char *value, gpointer user_data)
{
gtk_debug_flags |= g_parse_debug_string (value,
gtk_debug_keys,
G_N_ELEMENTS (gtk_debug_keys));
debug_flags |= g_parse_debug_string (value,
gtk_debug_keys,
G_N_ELEMENTS (gtk_debug_keys));
return TRUE;
}
......@@ -487,9 +487,9 @@ gtk_arg_debug_cb (const char *key, const char *value, gpointer user_data)
static gboolean
gtk_arg_no_debug_cb (const char *key, const char *value, gpointer user_data)
{
gtk_debug_flags &= ~g_parse_debug_string (value,
gtk_debug_keys,
G_N_ELEMENTS (gtk_debug_keys));
debug_flags &= ~g_parse_debug_string (value,
gtk_debug_keys,
G_N_ELEMENTS (gtk_debug_keys));
return TRUE;
}
......@@ -727,9 +727,9 @@ do_pre_parse_initialization (int *argc,
env_string = g_getenv ("GTK_DEBUG");
if (env_string != NULL)
{
gtk_debug_flags = g_parse_debug_string (env_string,
gtk_debug_keys,
G_N_ELEMENTS (gtk_debug_keys));
debug_flags = g_parse_debug_string (env_string,
gtk_debug_keys,
G_N_ELEMENTS (gtk_debug_keys));
env_string = NULL;
}
#endif /* G_ENABLE_DEBUG */
......@@ -776,7 +776,7 @@ do_post_parse_initialization (int *argc,
g_log_set_always_fatal (fatal_mask);
}
if (gtk_debug_flags & GTK_DEBUG_UPDATES)
if (debug_flags & GTK_DEBUG_UPDATES)
gdk_window_set_debug_updates (TRUE);
{
......@@ -861,6 +861,28 @@ post_parse_hook (GOptionContext *context,
}
/**
* gtk_get_debug_flags:
*
* Returns the GTK+ debug flags setting.
*/
guint
gtk_get_debug_flags (void)
{
return debug_flags;
}
/**
* gtk_set_debug_flags:
*
* Sets the GTK+ debug flags.
*/
void
gtk_set_debug_flags (guint flags)
{
debug_flags = flags;
}
/**
* gtk_get_option_group:
* @open_default_display: whether to open the default display
......
......@@ -485,7 +485,7 @@ gtk_print_job_get_surface (GtkPrintJob *job,
#ifdef G_ENABLE_DEBUG
/* If we are debugging printing don't delete the tmp files */
if (!(gtk_debug_flags & GTK_DEBUG_PRINTING))
if (!(gtk_get_debug_flags () & GTK_DEBUG_PRINTING))
#endif /* G_ENABLE_DEBUG */
g_unlink (filename);
g_free (filename);
......
......@@ -59,7 +59,7 @@ _gtk_rbnode_new (GtkRBTree *tree,
static void
_gtk_rbnode_free (GtkRBNode *node)
{
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
{
node->left = (gpointer) 0xdeadbeef;
node->right = (gpointer) 0xdeadbeef;
......@@ -384,7 +384,7 @@ _gtk_rbtree_remove (GtkRBTree *tree)
gint height = tree->root->offset;
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
_gtk_rbtree_test (G_STRLOC, tree);
#endif
......@@ -417,7 +417,7 @@ _gtk_rbtree_remove (GtkRBTree *tree)
_gtk_rbtree_free (tree);
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
_gtk_rbtree_test (G_STRLOC, tmp_tree);
#endif
}
......@@ -435,7 +435,7 @@ _gtk_rbtree_insert_after (GtkRBTree *tree,
GtkRBTree *tmp_tree;
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
{
g_print ("\n\n_gtk_rbtree_insert_after: %p\n", current);
_gtk_rbtree_debug_spew (tree);
......@@ -496,7 +496,7 @@ _gtk_rbtree_insert_after (GtkRBTree *tree,
_gtk_rbtree_insert_fixup (tree, node);
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
{
g_print ("_gtk_rbtree_insert_after finished...\n");
_gtk_rbtree_debug_spew (tree);
......@@ -520,7 +520,7 @@ _gtk_rbtree_insert_before (GtkRBTree *tree,
GtkRBTree *tmp_tree;
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
{
g_print ("\n\n_gtk_rbtree_insert_before: %p\n", current);
_gtk_rbtree_debug_spew (tree);
......@@ -582,7 +582,7 @@ _gtk_rbtree_insert_before (GtkRBTree *tree,
_gtk_rbtree_insert_fixup (tree, node);
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
{
g_print ("_gtk_rbtree_insert_before finished...\n");
_gtk_rbtree_debug_spew (tree);
......@@ -639,7 +639,7 @@ _gtk_rbtree_node_set_height (GtkRBTree *tree,
}
}
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
_gtk_rbtree_test (G_STRLOC, tree);
#endif
}
......@@ -1119,7 +1119,7 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
{
g_print ("\n\n_gtk_rbtree_remove_node: %p\n", node);
_gtk_rbtree_debug_spew (tree);
......@@ -1133,7 +1133,7 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
g_return_if_fail (x == tree->root);
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
_gtk_rbtree_test (G_STRLOC, tree);
#endif
......@@ -1262,7 +1262,7 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
_gtk_rbnode_free (y);
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
{
g_print ("_gtk_rbtree_remove_node finished...\n");
_gtk_rbtree_debug_spew (tree);
......
......@@ -753,7 +753,7 @@ _gtk_text_btree_delete (GtkTextIter *start,
tree = _gtk_text_iter_get_btree (start);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
/* Broadcast the need for redisplay before we break the iterators */
......@@ -1075,7 +1075,7 @@ _gtk_text_btree_delete (GtkTextIter *start,
chars_changed (tree);
segments_changed (tree);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
/* Re-initialize our iterators */
......@@ -1357,7 +1357,7 @@ find_line_by_y (GtkTextBTree *tree, BTreeView *view,
{
gint current_y = 0;
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
if (node->level == 0)
......@@ -2009,7 +2009,7 @@ _gtk_text_btree_tag (const GtkTextIter *start_orig,
queue_tag_redisplay (tree, tag, &start, &end);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
}
......@@ -2734,7 +2734,7 @@ real_set_mark (GtkTextBTree *tree,
iter = *where;
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_iter_check (&iter);
if (mark != NULL)
......@@ -2791,7 +2791,7 @@ real_set_mark (GtkTextBTree *tree,
mark);
}
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_iter_check (&iter);
/* Link mark into new location */
......@@ -2806,10 +2806,10 @@ real_set_mark (GtkTextBTree *tree,
redisplay_mark_if_visible (mark);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_iter_check (&iter);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
return mark;
......@@ -4327,7 +4327,7 @@ _gtk_text_line_next_could_contain_tag (GtkTextLine *line,
g_return_val_if_fail (line != NULL, NULL);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
if (tag == NULL)
......@@ -4490,7 +4490,7 @@ _gtk_text_line_previous_could_contain_tag (GtkTextLine *line,
g_return_val_if_fail (line != NULL, NULL);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
if (tag == NULL)
......@@ -5262,7 +5262,7 @@ _gtk_text_btree_validate (GtkTextBTree *tree,
if (new_height)
*new_height = state.new_height;
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
return TRUE;
......@@ -5971,7 +5971,7 @@ post_insert_fixup (GtkTextBTree *tree,
gtk_text_btree_rebalance (tree, node);
}
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
}
......@@ -6537,7 +6537,7 @@ gtk_text_btree_link_segment (GtkTextLineSegment *seg,
cleanup_line (line);
segments_changed (tree);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
}
......
......@@ -370,7 +370,7 @@ is_segment_start (GtkTextRealIter *real)
static void
check_invariants (const GtkTextIter *iter)
{
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_iter_check (iter);
}
#else
......
......@@ -103,7 +103,7 @@ gtk_text_line_segment_split (const GtkTextIter *iter)
count = gtk_text_iter_get_line_index (iter);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_iter_check (iter);
prev = NULL;
......@@ -203,7 +203,7 @@ _gtk_char_segment_new (const gchar *text, guint len)
seg->char_count = g_utf8_strlen (seg->body.chars, seg->byte_count);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
char_segment_self_check (seg);
return seg;
......@@ -232,7 +232,7 @@ _gtk_char_segment_new_from_two_strings (const gchar *text1,
seg->char_count = chars1 + chars2;
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
char_segment_self_check (seg);
return seg;
......@@ -263,7 +263,7 @@ char_segment_split_func (GtkTextLineSegment *seg, int index)
g_assert (index < seg->byte_count);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
{
char_segment_self_check (seg);
}
......@@ -279,7 +279,7 @@ char_segment_split_func (GtkTextLineSegment *seg, int index)
new1->next = new2;
new2->next = seg->next;
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
{
char_segment_self_check (new1);
char_segment_self_check (new2);
......@@ -318,7 +318,7 @@ char_segment_cleanup_func (GtkTextLineSegment *segPtr, GtkTextLine *line)
{
GtkTextLineSegment *segPtr2, *newPtr;
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
char_segment_self_check (segPtr);
segPtr2 = segPtr->next;
......@@ -337,7 +337,7 @@ char_segment_cleanup_func (GtkTextLineSegment *segPtr, GtkTextLine *line)
newPtr->next = segPtr2->next;
if (gtk_debug_flags & GTK_DEBUG_TEXT)
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
char_segment_self_check (newPtr);
g_free (segPtr);
......
......@@ -5011,7 +5011,7 @@ cursor_blinks (GtkTextView *text_view)
#ifdef DEBUG_VALIDATION_AND_SCROLLING
return FALSE;
#endif
if (gtk_debug_flags & GTK_DEBUG_UPDATES)
if (gtk_get_debug_flags () & GTK_DEBUG_UPDATES)
return FALSE;
g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
......
......@@ -143,7 +143,7 @@ static void gtk_tree_store_move (GtkTreeStore *
static inline void
validate_tree (GtkTreeStore *tree_store)
{
if (gtk_debug_flags & GTK_DEBUG_TREE)
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
{
g_assert (G_NODE (tree_store->root)->parent == NULL);
......
......@@ -3896,7 +3896,7 @@ gtk_widget_size_allocate (GtkWidget *widget,
g_return_if_fail (GTK_IS_WIDGET (widget));
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_GEOMETRY)
if (gtk_get_debug_flags () & GTK_DEBUG_GEOMETRY)
{
gint depth;
GtkWidget *parent;
......
......@@ -1326,7 +1326,7 @@ int
main (int argc, char** argv)
{
/* First, we turn on btree debugging. */
gtk_debug_flags |= GTK_DEBUG_TEXT;
gtk_set_debug_flags (gtk_get_debug_flags () | GTK_DEBUG_TEXT);
gtk_test_init (&argc, &argv);
pixbuf_init ();
......
......@@ -2342,7 +2342,7 @@ cups_request_ppd (GtkPrinter *printer)
#ifdef G_ENABLE_DEBUG
/* If we are debugging printing don't delete the tmp files */
if (!(gtk_debug_flags & GTK_DEBUG_PRINTING))
if (!(gtk_get_debug_flags () & GTK_DEBUG_PRINTING))
unlink (ppd_filename);
#else
unlink (ppd_filename);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment