[gnome-photos/wip/rishi/edit-mode: 4/7] 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: 4/7] preview-view: Use a switch for enums instead of if-else
- Date: Thu, 7 May 2015 07:13:58 +0000 (UTC)
commit 5080536e7c5743bc1621b17f99c24167c33527a8
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 | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index b3955bf..bce895f 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -227,8 +227,24 @@ 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_EDIT:
+ 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]