[gnome-photos/wip/rishi/edit-mode: 1/10] preview-view: Use a switch for enums instead of if-else
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/edit-mode: 1/10] preview-view: Use a switch for enums instead of if-else
- Date: Thu, 14 May 2015 09:12:46 +0000 (UTC)
commit 47340d243ed40bdd6c07a5845013aff24c1343b9
Author: Debarshi Ray <debarshir gnome org>
Date: Thu May 7 09:04:12 2015 +0200
preview-view: Use a switch for enums instead of if-else
Using a switch statement lets the compiler warn us through
-Wswitch-enum whenever we extend the enumeration range. An if-else
block does not do that.
src/photos-preview-view.c | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index b3955bf..852551c 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -227,8 +227,23 @@ photos_preview_view_create_view (PhotosPreviewView *self)
static void
photos_preview_view_window_mode_changed (PhotosPreviewView *self, PhotosWindowMode mode, PhotosWindowMode
old_mode)
{
- if (mode != PHOTOS_WINDOW_MODE_PREVIEW)
- photos_preview_nav_buttons_hide (self->priv->nav_buttons);
+ switch (mode)
+ {
+ case PHOTOS_WINDOW_MODE_COLLECTIONS:
+ case PHOTOS_WINDOW_MODE_FAVORITES:
+ case PHOTOS_WINDOW_MODE_OVERVIEW:
+ case PHOTOS_WINDOW_MODE_SEARCH:
+ photos_preview_nav_buttons_hide (self->priv->nav_buttons);
+ break;
+
+ case PHOTOS_WINDOW_MODE_PREVIEW:
+ break;
+
+ case PHOTOS_WINDOW_MODE_NONE:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]