From 48c3d8e1cfa7dfde5eea1339c754e81075fe17e8 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 28 Jun 2011 23:42:50 -0400 Subject: [PATCH] Drop gail-private-macros.h Nothing like obfuscating an early return behind a macro. --- gtk/a11y/Makefile.am | 1 - gtk/a11y/gail-private-macros.h | 33 ------------ gtk/a11y/gailnotebook.c | 14 +++-- gtk/a11y/gailnotebookpage.c | 10 ++-- gtk/a11y/gailtextcell.c | 1 - gtk/a11y/gailtreeview.c | 99 ++++++++++++++++++---------------- gtk/a11y/gailutil.c | 10 ++-- gtk/a11y/gailwidget.c | 46 +++------------- 8 files changed, 79 insertions(+), 135 deletions(-) delete mode 100644 gtk/a11y/gail-private-macros.h diff --git a/gtk/a11y/Makefile.am b/gtk/a11y/Makefile.am index 202d96a9db..449d3132e9 100644 --- a/gtk/a11y/Makefile.am +++ b/gtk/a11y/Makefile.am @@ -3,7 +3,6 @@ include $(top_srcdir)/Makefile.decl noinst_LTLIBRARIES = libgail.la gail_c_sources = \ - gail-private-macros.h \ gail.c \ gtkarrowaccessible.c \ gailbooleancell.c \ diff --git a/gtk/a11y/gail-private-macros.h b/gtk/a11y/gail-private-macros.h deleted file mode 100644 index 6e33ff7198..0000000000 --- a/gtk/a11y/gail-private-macros.h +++ /dev/null @@ -1,33 +0,0 @@ -/* GAIL - The GNOME Accessibility Implementation Library - * Copyright 2001 Sun Microsystems Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef __GAIL_PRIVATE_MACROS_H__ -#define __GAIL_PRIVATE_MACROS_H__ - -G_BEGIN_DECLS - -/* Note: these macros are logic macros, not intended to warn on failure. */ - -#define gail_return_val_if_fail(a, b) if (!(a)) return (b) -#define gail_return_if_fail(a) if (!(a)) return - -G_END_DECLS - -#endif /* __GAIL_PRIVATE_MACROS_H__ */ diff --git a/gtk/a11y/gailnotebook.c b/gtk/a11y/gailnotebook.c index 228641a8ce..17fb6c7095 100644 --- a/gtk/a11y/gailnotebook.c +++ b/gtk/a11y/gailnotebook.c @@ -23,7 +23,6 @@ #include #include "gailnotebook.h" #include "gailnotebookpage.h" -#include "gail-private-macros.h" static void gail_notebook_class_init (GailNotebookClass *klass); static void gail_notebook_init (GailNotebook *notebook); @@ -337,11 +336,8 @@ gail_notebook_ref_selection (AtkSelection *selection, GtkNotebook *notebook; gint pagenum; - /* - * A note book can have only one selection. - */ - gail_return_val_if_fail (i == 0, NULL); - g_return_val_if_fail (GAIL_IS_NOTEBOOK (selection), NULL); + if (i != 0) + return NULL; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); if (widget == NULL) @@ -350,7 +346,8 @@ gail_notebook_ref_selection (AtkSelection *selection, notebook = GTK_NOTEBOOK (widget); pagenum = gtk_notebook_get_current_page (notebook); - gail_return_val_if_fail (pagenum != -1, NULL); + if (pagenum == -1) + return NULL; accessible = gail_notebook_ref_child (ATK_OBJECT (selection), pagenum); return accessible; @@ -498,7 +495,8 @@ gail_notebook_child_parent_set (GtkWidget *widget, { GailNotebook *gail_notebook; - gail_return_if_fail (old_parent != NULL); + if (!old_parent) + return; gail_notebook = GAIL_NOTEBOOK (gtk_widget_get_accessible (old_parent)); gail_notebook->remove_index = GAIL_NOTEBOOK_PAGE (data)->index; } diff --git a/gtk/a11y/gailnotebookpage.c b/gtk/a11y/gailnotebookpage.c index 7c201a8435..1bf12da716 100644 --- a/gtk/a11y/gailnotebookpage.c +++ b/gtk/a11y/gailnotebookpage.c @@ -23,7 +23,6 @@ #include #include "gailnotebookpage.h" #include -#include "gail-private-macros.h" static void gail_notebook_page_class_init (GailNotebookPageClass *klass); static void gail_notebook_page_init (GailNotebookPage *page); @@ -355,7 +354,8 @@ gail_notebook_page_ref_child (AtkObject *accessible, return NULL; child = gtk_notebook_get_nth_page (page->notebook, page->index); - gail_return_val_if_fail (GTK_IS_WIDGET (child), NULL); + if (!GTK_IS_WIDGET (child)) + return NULL; child_obj = gtk_widget_get_accessible (child); g_object_ref (child_obj); @@ -396,7 +396,8 @@ gail_notebook_page_ref_state_set (AtkObject *accessible) AtkObject *child; child = atk_object_ref_accessible_child (accessible, 0); - gail_return_val_if_fail (child, state_set); + if (!child) + return state_set; merged_state_set = state_set; state_set = atk_object_ref_state_set (child); @@ -465,7 +466,8 @@ gail_notebook_page_get_extents (AtkComponent *component, *height = 0; child = atk_object_ref_accessible_child (ATK_OBJECT (component), 0); - gail_return_if_fail (child); + if (!child) + return; atk_component_get_position (ATK_COMPONENT (child), x, y, coord_type); g_object_unref (child); diff --git a/gtk/a11y/gailtextcell.c b/gtk/a11y/gailtextcell.c index a4e5528118..ae88d3cd6c 100644 --- a/gtk/a11y/gailtextcell.c +++ b/gtk/a11y/gailtextcell.c @@ -24,7 +24,6 @@ #include "gailcontainercell.h" #include "gailcellparent.h" #include -#include "gail-private-macros.h" static void gail_text_cell_class_init (GailTextCellClass *klass); static void gail_text_cell_init (GailTextCell *text_cell); diff --git a/gtk/a11y/gailtreeview.c b/gtk/a11y/gailtreeview.c index 3db34a6a70..ccf93da511 100644 --- a/gtk/a11y/gailtreeview.c +++ b/gtk/a11y/gailtreeview.c @@ -30,7 +30,6 @@ #include "gailcontainercell.h" #include "gailtextcell.h" #include "gailcellparent.h" -#include "gail-private-macros.h" typedef struct _GailTreeViewCellInfo GailTreeViewCellInfo; @@ -632,7 +631,8 @@ gail_tree_view_destroyed (GtkWidget *widget, GtkAdjustment *adj; GailTreeView *gailview; - gail_return_if_fail (GTK_IS_TREE_VIEW (widget)); + if (!GTK_IS_TREE_VIEW (widget)) + return; gailview = GAIL_TREE_VIEW (accessible); adj = gailview->old_hadj; @@ -713,7 +713,8 @@ gail_tree_view_get_n_children (AtkObject *obj) { GtkWidget *widget; - gail_return_val_if_fail (GAIL_IS_TREE_VIEW (obj), 0); + if (!GAIL_IS_TREE_VIEW (obj)) + return 0; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); if (widget == NULL) @@ -795,7 +796,8 @@ gail_tree_view_ref_child (AtkObject *obj, tree_model = gtk_tree_view_get_model (tree_view); retval = gtk_tree_model_get_iter (tree_model, &iter, path); - gail_return_val_if_fail (retval, NULL); + if (!retval) + return NULL; expander_tv = gtk_tree_view_get_expander_column (tree_view); is_expander = FALSE; @@ -820,11 +822,10 @@ gail_tree_view_ref_child (AtkObject *obj, GailCell *container_cell; container = gail_container_cell_new (); - gail_return_val_if_fail (container, NULL); container_cell = GAIL_CELL (container); gail_cell_initialise (container_cell, - widget, ATK_OBJECT (gailview), + widget, ATK_OBJECT (gailview), i); /* * The GailTreeViewCellInfo structure for the container will be before @@ -853,7 +854,6 @@ gail_tree_view_ref_child (AtkObject *obj, G_OBJECT_TYPE (fake_renderer)); child = atk_object_factory_create_accessible (factory, G_OBJECT (fake_renderer)); - gail_return_val_if_fail (GAIL_IS_RENDERER_CELL (child), NULL); cell = GAIL_CELL (child); renderer_cell = GAIL_RENDERER_CELL (child); renderer_cell->renderer = fake_renderer; @@ -889,7 +889,6 @@ gail_tree_view_ref_child (AtkObject *obj, G_OBJECT_TYPE (renderer)); child = atk_object_factory_create_accessible (factory, G_OBJECT (renderer)); - gail_return_val_if_fail (GAIL_IS_RENDERER_CELL (child), NULL); cell = GAIL_CELL (child); renderer_cell = GAIL_RENDERER_CELL (child); @@ -1645,9 +1644,8 @@ gail_tree_view_get_cell_area (GailCellParent *parent, top_cell = cell; } cell_info = find_cell_info (GAIL_TREE_VIEW (parent), top_cell, TRUE); - gail_return_if_fail (cell_info); - gail_return_if_fail (cell_info->cell_col_ref); - gail_return_if_fail (cell_info->cell_row_ref); + if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref) + return; path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref); tv_col = cell_info->cell_col_ref; if (path && cell_info->in_use) @@ -1729,9 +1727,8 @@ gail_tree_view_grab_cell_focus (GailCellParent *parent, tree_view = GTK_TREE_VIEW (widget); cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, TRUE); - gail_return_val_if_fail (cell_info, FALSE); - gail_return_val_if_fail (cell_info->cell_col_ref, FALSE); - gail_return_val_if_fail (cell_info->cell_row_ref, FALSE); + if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref) + return FALSE; cell_object = ATK_OBJECT (cell); parent_cell = atk_object_get_parent (cell_object); tv_col = cell_info->cell_col_ref; @@ -1903,10 +1900,11 @@ gail_tree_view_collapse_row_gtk (GtkTreeView *tree_view, traverse_cells (gailview, path, FALSE, FALSE); /* Set collapse state */ set_expand_state (tree_view, tree_model, gailview, path, FALSE); - - gail_return_val_if_fail (gailview->n_children_deleted, FALSE); + if (gailview->n_children_deleted == 0) + return FALSE; row = get_row_from_tree_path (tree_view, path); - gail_return_val_if_fail (row != -1, FALSE); + if (row == -1) + return FALSE; g_signal_emit_by_name (atk_obj, "row_deleted", row, gailview->n_children_deleted); gailview->n_children_deleted = 0; @@ -2502,7 +2500,8 @@ destroy_count_func (GtkTreeView *tree_view, AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view)); GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj); - gail_return_if_fail (gailview->n_children_deleted == 0); + if (gailview->n_children_deleted != 0) + return; gailview->n_children_deleted = count; } @@ -2654,9 +2653,8 @@ update_cell_value (GailRendererCell *renderer_cell, cell = GAIL_CELL (renderer_cell); cell_info = find_cell_info (gailview, cell, TRUE); - gail_return_val_if_fail (cell_info, FALSE); - gail_return_val_if_fail (cell_info->cell_col_ref, FALSE); - gail_return_val_if_fail (cell_info->cell_row_ref, FALSE); + if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref) + return FALSE; if (emit_change_signal && cell_info->in_use) { @@ -2685,7 +2683,8 @@ update_cell_value (GailRendererCell *renderer_cell, tree_model, &iter, is_expander, is_expanded); } renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (cell_info->cell_col_ref)); - gail_return_val_if_fail (renderers, FALSE); + if (!renderers) + return FALSE; /* * If the cell is in a container, its index is used to find the renderer @@ -2709,7 +2708,8 @@ update_cell_value (GailRendererCell *renderer_cell, return FALSE; } - gail_return_val_if_fail (cur_renderer != NULL, FALSE); + if (cur_renderer == NULL) + return FALSE; if (gtk_cell_renderer_class) { @@ -3372,13 +3372,13 @@ toggle_cell_expanded (GailCell *cell) parent = atk_object_get_parent (parent); cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, TRUE); - gail_return_if_fail (cell_info); - gail_return_if_fail (cell_info->cell_col_ref); - gail_return_if_fail (cell_info->cell_row_ref); + if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref) + return; tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent))); path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref); - gail_return_if_fail (path); + if (!path) + return; stateset = atk_object_ref_state_set (ATK_OBJECT (cell)); if (atk_state_set_contains_state (stateset, ATK_STATE_EXPANDED)) @@ -3408,16 +3408,17 @@ toggle_cell_toggled (GailCell *cell) } cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, TRUE); - gail_return_if_fail (cell_info); - gail_return_if_fail (cell_info->cell_col_ref); - gail_return_if_fail (cell_info->cell_row_ref); + if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref) + return; path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref); - gail_return_if_fail (path); + if (!path) + return; pathstring = gtk_tree_path_to_string (path); renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (cell_info->cell_col_ref)); - gail_return_if_fail (renderers); + if (!renderers) + return; /* * if the cell is in a container, its index is used to find the @@ -3433,7 +3434,8 @@ toggle_cell_toggled (GailCell *cell) */ cur_renderer = renderers; - gail_return_if_fail (cur_renderer); + if (!cur_renderer) + return; g_signal_emit_by_name (cur_renderer->data, "toggled", pathstring); g_list_free (renderers); @@ -3456,13 +3458,13 @@ edit_cell (GailCell *cell) parent = atk_object_get_parent (parent); cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, TRUE); - gail_return_if_fail (cell_info); - gail_return_if_fail (cell_info->cell_col_ref); - gail_return_if_fail (cell_info->cell_row_ref); + if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref) + return; tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent))); path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref); - gail_return_if_fail (path); + if (!path) + return; gtk_tree_view_set_cursor (tree_view, path, cell_info->cell_col_ref, TRUE); gtk_tree_path_free (path); return; @@ -3482,13 +3484,13 @@ activate_cell (GailCell *cell) parent = atk_object_get_parent (parent); cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, TRUE); - gail_return_if_fail (cell_info); - gail_return_if_fail (cell_info->cell_col_ref); - gail_return_if_fail (cell_info->cell_row_ref); + if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref) + return; tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent))); path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref); - gail_return_if_fail (path); + if (!path) + return; gtk_tree_view_row_activated (tree_view, path, cell_info->cell_col_ref); gtk_tree_path_free (path); return; @@ -3499,7 +3501,8 @@ cell_destroyed (gpointer data) { GailTreeViewCellInfo *cell_info = data; - gail_return_if_fail (cell_info); + if (!cell_info) + return; if (cell_info->in_use) { cell_info->in_use = FALSE; @@ -3521,7 +3524,8 @@ cell_info_get_index (GtkTreeView *tree_view, gint column_number; path = gtk_tree_row_reference_get_path (info->cell_row_ref); - gail_return_if_fail (path); + if (!path) + return; column_number = get_column_number (tree_view, info->cell_col_ref, FALSE); *index = get_index (tree_view, path, column_number); @@ -3579,7 +3583,8 @@ refresh_cell_index (GailCell *cell) gint index; parent = atk_object_get_parent (ATK_OBJECT (cell)); - gail_return_if_fail (GAIL_IS_TREE_VIEW (parent)); + if (!GAIL_IS_TREE_VIEW (parent)) + return; gailview = GAIL_TREE_VIEW (parent); tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent))); @@ -3587,7 +3592,8 @@ refresh_cell_index (GailCell *cell) /* Find this cell in the GailTreeView's cache */ info = find_cell_info (gailview, cell, TRUE); - gail_return_if_fail (info); + if (!info) + return; cell_info_get_index (tree_view, info, &index); cell->index = index; @@ -3969,7 +3975,8 @@ get_path_column_from_index (GtkTreeView *tree_view, row_index = index / gailview->n_cols; retval = get_tree_path_from_row_index (tree_model, row_index, path); - gail_return_val_if_fail (retval, FALSE); + if (!retval) + return FALSE; if (*path == NULL) return FALSE; } diff --git a/gtk/a11y/gailutil.c b/gtk/a11y/gailutil.c index 4d1d6da02c..316efff919 100644 --- a/gtk/a11y/gailutil.c +++ b/gtk/a11y/gailutil.c @@ -25,7 +25,6 @@ #include "gailutil.h" #include "gailtoplevel.h" #include "gailwindow.h" -#include "gail-private-macros.h" static void gail_util_class_init (GailUtilClass *klass); static void gail_util_init (GailUtil *utils); @@ -441,7 +440,8 @@ state_event_watcher (GSignalInvocationHint *hint, return FALSE; event = g_value_get_boxed (param_values + 1); - gail_return_val_if_fail (event->type == GDK_WINDOW_STATE, FALSE); + if (event->type == GDK_WINDOW_STATE) + return FALSE; widget = GTK_WIDGET (object); if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) @@ -488,7 +488,8 @@ window_added (AtkObject *atk_obj, if (!GAIL_IS_WINDOW (child)) return; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (child)); - gail_return_if_fail (widget); + if (!widget) + return; g_signal_connect (widget, "focus-in-event", (GCallback) window_focus, NULL); @@ -509,7 +510,8 @@ window_removed (AtkObject *atk_obj, if (!GAIL_IS_WINDOW (child)) return; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (child)); - gail_return_if_fail (widget); + if (!widget) + return; window = GTK_WINDOW (widget); /* diff --git a/gtk/a11y/gailwidget.c b/gtk/a11y/gailwidget.c index e2b1c3d5f0..bf0e5b3a2e 100644 --- a/gtk/a11y/gailwidget.c +++ b/gtk/a11y/gailwidget.c @@ -27,7 +27,6 @@ #endif #include "gailwidget.h" #include "gailnotebookpage.h" -#include "gail-private-macros.h" extern GtkWidget *focus_widget; @@ -257,11 +256,7 @@ gail_widget_get_parent (AtkObject *accessible) widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); if (widget == NULL) - /* - * State is defunct - */ return NULL; - gail_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); parent_widget = gtk_widget_get_parent (widget); if (parent_widget == NULL) @@ -355,13 +350,8 @@ gail_widget_ref_relation_set (AtkObject *obj) AtkObject *array[1]; AtkRelation* relation; - gail_return_val_if_fail (GAIL_IS_WIDGET (obj), NULL); - widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); if (widget == NULL) - /* - * State is defunct - */ return NULL; relation_set = ATK_OBJECT_CLASS (gail_widget_parent_class)->ref_relation_set (obj); @@ -558,11 +548,11 @@ gail_widget_get_index_in_parent (AtkObject *accessible) } } - gail_return_val_if_fail (GTK_IS_WIDGET (widget), -1); - parent_widget = gtk_widget_get_parent (widget); - if (parent_widget == NULL) + if (!GTK_IS_WIDGET (widget)) + return -1; + parent_widget = gtk_widget_get_parent (widget); + if (!GTK_IS_CONTAINER (parent_widget)) return -1; - gail_return_val_if_fail (GTK_IS_CONTAINER (parent_widget), -1); children = gtk_container_get_children (GTK_CONTAINER (parent_widget)); @@ -631,13 +621,8 @@ gail_widget_get_extents (AtkComponent *component, GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component)); if (widget == NULL) - /* - * Object is defunct - */ return; - gail_return_if_fail (GTK_IS_WIDGET (widget)); - gtk_widget_get_allocation (widget, &allocation); *width = allocation.width; *height = allocation.height; @@ -684,13 +669,8 @@ gail_widget_get_size (AtkComponent *component, GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component)); if (widget == NULL) - /* - * Object is defunct - */ return; - gail_return_if_fail (GTK_IS_WIDGET (widget)); - gtk_widget_get_allocation (widget, &allocation); *width = allocation.width; *height = allocation.height; @@ -705,13 +685,15 @@ gail_widget_get_layer (AtkComponent *component) return (AtkLayer) layer; } -static gboolean +static gboolean gail_widget_grab_focus (AtkComponent *component) { GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component)); GtkWidget *toplevel; - gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + if (!widget) + return FALSE; + if (gtk_widget_get_can_focus (widget)) { gtk_widget_grab_focus (widget); @@ -749,11 +731,7 @@ gail_widget_set_extents (AtkComponent *component, GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component)); if (widget == NULL) - /* - * Object is defunct - */ return FALSE; - gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); if (gtk_widget_is_toplevel (widget)) { @@ -793,11 +771,7 @@ gail_widget_set_position (AtkComponent *component, GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component)); if (widget == NULL) - /* - * Object is defunct - */ return FALSE; - gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); if (gtk_widget_is_toplevel (widget)) { @@ -834,11 +808,7 @@ gail_widget_set_size (AtkComponent *component, GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component)); if (widget == NULL) - /* - * Object is defunct - */ return FALSE; - gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); if (gtk_widget_is_toplevel (widget)) {