summaryrefslogtreecommitdiff
path: root/gtk/gtknotebook.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2017-10-06 21:19:42 +0200
committerBenjamin Otte <otte@redhat.com>2017-10-06 21:23:39 +0200
commit43c212ac28f5f80e10c49590e569b6450098743f (patch)
treeae5210d90f79d313d3b4c88c88f5e00b87405e0e /gtk/gtknotebook.c
parent2ac66328a3edc0838c19b49fcb9468c473936c9c (diff)
downloadgtk+-43c212ac28f5f80e10c49590e569b6450098743f.tar.gz
build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options: 1. Add all missing enums to the switch statement or 2. Cast the switch argument to a uint to avoid having to do that (mostly for GdkEventType). I even found a bug while doing that: clearing a GtkImage with a surface did not notify thae surface property. The reason for enabling this flag even though it is tedious at times is that it is very useful when adding values to an enum, because it makes GTK immediately warn about all the switch statements where this enum is relevant. And I expect changes to enums to be frequent during the GTK4 development cycle.
Diffstat (limited to 'gtk/gtknotebook.c')
-rw-r--r--gtk/gtknotebook.c82
1 files changed, 68 insertions, 14 deletions
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index d1f90ab3f3..144a5fc3ce 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -1214,6 +1214,9 @@ gtk_notebook_focus_tab (GtkNotebook *notebook,
if (list)
gtk_notebook_switch_focus_tab (notebook, list);
break;
+
+ default:
+ break;
}
return TRUE;
@@ -1869,6 +1872,9 @@ gtk_notebook_get_preferred_tabs_size (GtkNotebook *notebook,
tab_width = MAX (tab_width, page->requisition.width);
tab_max = MAX (tab_max, page->requisition.height);
break;
+ default:
+ g_assert_not_reached ();
+ break;
}
}
else if (gtk_widget_get_visible (page->tab_label))
@@ -2428,13 +2434,16 @@ get_drop_position (GtkNotebook *notebook)
if (allocation.x + allocation.width / 2 < x)
return children;
}
-
break;
+
case GTK_POS_LEFT:
case GTK_POS_RIGHT:
if (allocation.y + allocation.height / 2 > y)
return children;
+ break;
+ default:
+ g_assert_not_reached ();
break;
}
@@ -3608,7 +3617,7 @@ gtk_notebook_focus (GtkWidget *widget,
if (old_focus_child == priv->action_widget[ACTION_WIDGET_START])
{
- switch (effective_direction)
+ switch ((guint) effective_direction)
{
case GTK_DIR_DOWN:
return focus_child_in (notebook, GTK_DIR_TAB_FORWARD);
@@ -3619,7 +3628,7 @@ gtk_notebook_focus (GtkWidget *widget,
case GTK_DIR_UP:
return FALSE;
default:
- switch (direction)
+ switch ((guint) direction)
{
case GTK_DIR_TAB_FORWARD:
if ((priv->tab_pos == GTK_POS_RIGHT || priv->tab_pos == GTK_POS_BOTTOM) &&
@@ -3630,12 +3639,13 @@ gtk_notebook_focus (GtkWidget *widget,
return FALSE;
default:
g_assert_not_reached ();
+ break;
}
}
}
else if (old_focus_child == priv->action_widget[ACTION_WIDGET_END])
{
- switch (effective_direction)
+ switch ((guint) effective_direction)
{
case GTK_DIR_DOWN:
return focus_child_in (notebook, GTK_DIR_TAB_FORWARD);
@@ -3646,7 +3656,7 @@ gtk_notebook_focus (GtkWidget *widget,
case GTK_DIR_UP:
return FALSE;
default:
- switch (direction)
+ switch ((guint) direction)
{
case GTK_DIR_TAB_FORWARD:
return FALSE;
@@ -3657,12 +3667,13 @@ gtk_notebook_focus (GtkWidget *widget,
return focus_tabs_in (notebook);
default:
g_assert_not_reached ();
+ break;
}
}
}
else
{
- switch (effective_direction)
+ switch ((guint) effective_direction)
{
case GTK_DIR_TAB_BACKWARD:
case GTK_DIR_UP:
@@ -3674,12 +3685,14 @@ gtk_notebook_focus (GtkWidget *widget,
return FALSE;
case GTK_DIR_TAB_FORWARD:
return focus_action_in (notebook, last_action, direction);
+ default:
+ break;
}
}
}
else if (widget_is_focus) /* Focus was on tabs */
{
- switch (effective_direction)
+ switch ((guint) effective_direction)
{
case GTK_DIR_TAB_BACKWARD:
return focus_action_in (notebook, first_action, direction);
@@ -3699,11 +3712,13 @@ gtk_notebook_focus (GtkWidget *widget,
return focus_tabs_move (notebook, direction, STEP_PREV);
case GTK_DIR_RIGHT:
return focus_tabs_move (notebook, direction, STEP_NEXT);
+ default:
+ break;
}
}
else /* Focus was not on widget */
{
- switch (effective_direction)
+ switch ((guint) effective_direction)
{
case GTK_DIR_TAB_FORWARD:
case GTK_DIR_DOWN:
@@ -3729,6 +3744,8 @@ gtk_notebook_focus (GtkWidget *widget,
case GTK_DIR_LEFT:
case GTK_DIR_RIGHT:
return focus_child_in (notebook, direction);
+ default:
+ break;
}
}
@@ -4420,6 +4437,9 @@ gtk_notebook_snapshot_tabs (GtkGizmo *gizmo,
case GTK_POS_RIGHT:
step = STEP_PREV;
break;
+ default:
+ g_assert_not_reached ();
+ break;
}
}
@@ -4601,6 +4621,9 @@ gtk_notebook_allocate_arrows (GtkNotebook *notebook,
}
break;
+ default:
+ g_assert_not_reached ();
+ break;
}
}
@@ -4650,6 +4673,10 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
*tab_space += page->requisition.height;
}
break;
+
+ default:
+ g_assert_not_reached ();
+ break;
}
if (!priv->scrollable)
@@ -4680,6 +4707,10 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
*tab_space = tabs_allocation->height;
}
break;
+
+ default:
+ g_assert_not_reached ();
+ break;
}
}
}
@@ -4903,14 +4934,14 @@ get_allocate_at_bottom (GtkWidget *widget,
else
return (search_direction == STEP_NEXT);
- break;
case GTK_POS_RIGHT:
case GTK_POS_LEFT:
return (search_direction == STEP_PREV);
- break;
- }
- return FALSE;
+ default:
+ g_assert_not_reached ();
+ return FALSE;
+ }
}
static void
@@ -4939,7 +4970,6 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
widget = GTK_WIDGET (notebook);
tab_pos = get_effective_tab_pos (notebook);
allocate_at_bottom = get_allocate_at_bottom (widget, direction);
- anchor = 0;
child_allocation = *allocation;
@@ -4958,6 +4988,11 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
child_allocation.y += allocation->height;
anchor = child_allocation.y;
break;
+
+ default:
+ g_assert_not_reached ();
+ anchor = 0;
+ break;
}
gtk_widget_get_own_allocation (priv->cur_page->tab_widget, &drag_allocation);
@@ -5094,7 +5129,10 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
child_allocation.y = anchor;
}
+ break;
+ default:
+ g_assert_not_reached ();
break;
}
@@ -5165,6 +5203,9 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
}
break;
+ default:
+ g_assert_not_reached ();
+ break;
}
}
@@ -5192,6 +5233,9 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
(allocate_at_bottom && priv->drag_window_y < anchor))
priv->drag_window_y = anchor;
break;
+ default:
+ g_assert_not_reached ();
+ break;
}
}
}
@@ -5319,6 +5363,9 @@ gtk_notebook_calc_tabs (GtkNotebook *notebook,
children = children->prev;
}
break;
+ default:
+ g_assert_not_reached ();
+ break;
}
}
@@ -5409,7 +5456,7 @@ gtk_notebook_page_select (GtkNotebook *notebook,
{
GtkNotebookPrivate *priv = notebook->priv;
GtkNotebookPage *page;
- GtkDirectionType dir = GTK_DIR_DOWN; /* Quiet GCC */
+ GtkDirectionType dir;
GtkPositionType tab_pos = get_effective_tab_pos (notebook);
if (!priv->focus_tab)
@@ -5434,6 +5481,10 @@ gtk_notebook_page_select (GtkNotebook *notebook,
case GTK_POS_RIGHT:
dir = GTK_DIR_LEFT;
break;
+ default:
+ g_assert_not_reached ();
+ dir = GTK_DIR_DOWN;
+ break;
}
if (gtk_widget_child_focus (page->child, dir))
@@ -6242,6 +6293,9 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_HORIZONTAL);
gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_VERTICAL);
break;
+ default:
+ g_assert_not_reached ();
+ break;
}
update_node_ordering (notebook);