[gnome-documents] main-view: remove "none" from the supported view types



commit 3e98c4d77aba1bd3c541f72918cd8fbe12bdca48
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jan 23 16:17:53 2012 -0500

    main-view: remove "none" from the supported view types
    
    Views shouldn't really set, and we'd better track the initial state
    internally.

 src/lib/gd-main-view.c |   14 ++++++++------
 src/lib/gd-main-view.h |    1 -
 2 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/src/lib/gd-main-view.c b/src/lib/gd-main-view.c
index 8d6e39b..9062a46 100644
--- a/src/lib/gd-main-view.c
+++ b/src/lib/gd-main-view.c
@@ -25,6 +25,8 @@
 #include "gd-main-icon-view.h"
 #include "gd-main-list-view.h"
 
+#define MAIN_VIEW_TYPE_INITIAL -1
+
 struct _GdMainViewPrivate {
   GdMainViewType current_type;
   gboolean selection_mode;
@@ -57,7 +59,9 @@ gd_main_view_init (GdMainView *self)
   GtkStyleContext *context;
 
   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GD_TYPE_MAIN_VIEW, GdMainViewPrivate);
-  self->priv->current_type = GD_MAIN_VIEW_NONE;
+
+  /* so that we get constructed with the right view even at startup */
+  self->priv->current_type = MAIN_VIEW_TYPE_INITIAL;
 
   gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE);
   gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE);
@@ -129,10 +133,11 @@ gd_main_view_class_init (GdMainViewClass *klass)
     g_param_spec_int ("view-type",
                       "View type",
                       "View type",
-                      GD_MAIN_VIEW_NONE,
+                      GD_MAIN_VIEW_ICON,
                       GD_MAIN_VIEW_LIST,
-                      GD_MAIN_VIEW_NONE,
+                      GD_MAIN_VIEW_ICON,
                       G_PARAM_READWRITE |
+                      G_PARAM_CONSTRUCT |
                       G_PARAM_STATIC_STRINGS);
 
   properties[PROP_SELECTION_MODE] =
@@ -301,9 +306,6 @@ gd_main_view_rebuild (GdMainView *self)
 {
   GtkStyleContext *context;
 
-  if (self->priv->current_type == GD_MAIN_VIEW_NONE)
-    return;
-
   if (self->priv->current_view != NULL)
     gtk_widget_destroy (self->priv->current_view);
 
diff --git a/src/lib/gd-main-view.h b/src/lib/gd-main-view.h
index e1014d2..4e814a8 100644
--- a/src/lib/gd-main-view.h
+++ b/src/lib/gd-main-view.h
@@ -63,7 +63,6 @@ typedef enum {
 } GdMainColumns;
 
 typedef enum {
-  GD_MAIN_VIEW_NONE,
   GD_MAIN_VIEW_ICON,
   GD_MAIN_VIEW_LIST
 } GdMainViewType;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]