[gnome-photos] empty-results-box: Tailor it to the specific modes
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] empty-results-box: Tailor it to the specific modes
- Date: Thu, 6 Feb 2014 15:56:48 +0000 (UTC)
commit 4b5d6023e1e25c6ee76c6ee9b6e5eb27758d8388
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Feb 6 11:39:14 2014 +0100
empty-results-box: Tailor it to the specific modes
src/photos-empty-results-box.c | 103 +++++++++++++++++++++++++++++++++++++---
src/photos-empty-results-box.h | 6 ++-
src/photos-view-container.c | 2 +-
3 files changed, 101 insertions(+), 10 deletions(-)
---
diff --git a/src/photos-empty-results-box.c b/src/photos-empty-results-box.c
index 7eda8a8..768391c 100644
--- a/src/photos-empty-results-box.c
+++ b/src/photos-empty-results-box.c
@@ -28,6 +28,7 @@
#include <glib/gi18n.h>
#include "photos-empty-results-box.h"
+#include "photos-enums.h"
#include "photos-icons.h"
#include "photos-source-manager.h"
@@ -36,6 +37,13 @@ struct _PhotosEmptyResultsBoxPrivate
{
GtkWidget *labels_grid;
PhotosBaseManager *src_mngr;
+ PhotosWindowMode mode;
+};
+
+enum
+{
+ PROP_0,
+ PROP_MODE
};
@@ -96,6 +104,21 @@ photos_empty_results_box_activate_link (PhotosEmptyResultsBox *self, const gchar
static void
+photos_empty_results_box_add_collections_label (PhotosEmptyResultsBox *self)
+{
+ GtkWidget *details;
+
+ details = gtk_label_new (_("Name your first album"));
+ gtk_widget_set_halign (details, GTK_ALIGN_START);
+ gtk_misc_set_alignment (GTK_MISC (details), 0.0, 0.5);
+ gtk_label_set_line_wrap (GTK_LABEL (details), TRUE);
+ gtk_label_set_max_width_chars (GTK_LABEL (details), 24);
+ gtk_label_set_use_markup (GTK_LABEL (details), TRUE);
+ gtk_container_add (GTK_CONTAINER (self->priv->labels_grid), details);
+}
+
+
+static void
photos_empty_results_box_add_system_settings_label (PhotosEmptyResultsBox *self)
{
GtkWidget *details;
@@ -158,7 +181,26 @@ photos_empty_results_box_constructed (GObject *object)
gtk_grid_set_row_spacing (GTK_GRID (priv->labels_grid), 12);
gtk_container_add (GTK_CONTAINER (self), priv->labels_grid);
- label = g_strconcat ("<b><span size=\"large\">", _("No Photos Found"), "</span></b>", NULL);
+ switch (priv->mode)
+ {
+ case PHOTOS_WINDOW_MODE_COLLECTIONS:
+ label = g_strconcat ("<b><span size=\"large\">", _("No Albums Found"), "</span></b>", NULL);
+ break;
+
+ case PHOTOS_WINDOW_MODE_FAVORITES:
+ label = g_strconcat ("<b><span size=\"large\">", _("No Favorites Found"), "</span></b>", NULL);
+ break;
+
+ case PHOTOS_WINDOW_MODE_OVERVIEW:
+ case PHOTOS_WINDOW_MODE_SEARCH:
+ label = g_strconcat ("<b><span size=\"large\">", _("No Photos Found"), "</span></b>", NULL);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
title_label = gtk_label_new (label);
gtk_widget_set_halign (title_label, GTK_ALIGN_START);
gtk_widget_set_vexpand (title_label, TRUE);
@@ -166,12 +208,31 @@ photos_empty_results_box_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (priv->labels_grid), title_label);
g_free (label);
- if (photos_source_manager_has_online_sources (PHOTOS_SOURCE_MANAGER (self->priv->src_mngr)))
- gtk_widget_set_valign (title_label, GTK_ALIGN_CENTER);
- else
+ switch (priv->mode)
{
+ case PHOTOS_WINDOW_MODE_COLLECTIONS:
gtk_widget_set_valign (title_label, GTK_ALIGN_START);
- photos_empty_results_box_add_system_settings_label (self);
+ photos_empty_results_box_add_collections_label (self);
+ break;
+
+ case PHOTOS_WINDOW_MODE_FAVORITES:
+ case PHOTOS_WINDOW_MODE_SEARCH:
+ gtk_widget_set_valign (title_label, GTK_ALIGN_CENTER);
+ break;
+
+ case PHOTOS_WINDOW_MODE_OVERVIEW:
+ if (photos_source_manager_has_online_sources (PHOTOS_SOURCE_MANAGER (self->priv->src_mngr)))
+ gtk_widget_set_valign (title_label, GTK_ALIGN_CENTER);
+ else
+ {
+ gtk_widget_set_valign (title_label, GTK_ALIGN_START);
+ photos_empty_results_box_add_system_settings_label (self);
+ }
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
}
gtk_widget_show_all (GTK_WIDGET (self));
@@ -190,6 +251,24 @@ photos_empty_results_box_dispose (GObject *object)
static void
+photos_empty_results_box_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec
*pspec)
+{
+ PhotosEmptyResultsBox *self = PHOTOS_EMPTY_RESULTS_BOX (object);
+
+ switch (prop_id)
+ {
+ case PROP_MODE:
+ self->priv->mode = (PhotosWindowMode) g_value_get_enum (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+static void
photos_empty_results_box_init (PhotosEmptyResultsBox *self)
{
PhotosEmptyResultsBoxPrivate *priv;
@@ -208,11 +287,21 @@ photos_empty_results_box_class_init (PhotosEmptyResultsBoxClass *class)
object_class->constructed = photos_empty_results_box_constructed;
object_class->dispose = photos_empty_results_box_dispose;
+ object_class->set_property = photos_empty_results_box_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_MODE,
+ g_param_spec_enum ("mode",
+ "PhotosWindowMode enum",
+ "The mode for which no results were found",
+ PHOTOS_TYPE_WINDOW_MODE,
+ PHOTOS_WINDOW_MODE_NONE,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
}
GtkWidget *
-photos_empty_results_box_new (void)
+photos_empty_results_box_new (PhotosWindowMode mode)
{
- return g_object_new (PHOTOS_TYPE_EMPTY_RESULTS_BOX, NULL);
+ return g_object_new (PHOTOS_TYPE_EMPTY_RESULTS_BOX, "mode", mode, NULL);
}
diff --git a/src/photos-empty-results-box.h b/src/photos-empty-results-box.h
index a96a76c..2913a55 100644
--- a/src/photos-empty-results-box.h
+++ b/src/photos-empty-results-box.h
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013 Red Hat, Inc.
+ * Copyright © 2012, 2013, 2014 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -27,6 +27,8 @@
#include <gtk/gtk.h>
+#include "photos-mode-controller.h"
+
G_BEGIN_DECLS
#define PHOTOS_TYPE_EMPTY_RESULTS_BOX (photos_empty_results_box_get_type ())
@@ -68,7 +70,7 @@ struct _PhotosEmptyResultsBoxClass
GType photos_empty_results_box_get_type (void) G_GNUC_CONST;
-GtkWidget *photos_empty_results_box_new (void);
+GtkWidget *photos_empty_results_box_new (PhotosWindowMode mode);
G_END_DECLS
diff --git a/src/photos-view-container.c b/src/photos-view-container.c
index 5c9d1e1..c06e7e0 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -295,7 +295,7 @@ photos_view_container_constructed (GObject *object)
gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
gtk_stack_add_named (GTK_STACK (self), grid, "view");
- priv->no_results = photos_empty_results_box_new ();
+ priv->no_results = photos_empty_results_box_new (priv->mode);
gtk_stack_add_named (GTK_STACK (self), priv->no_results, "no-results");
priv->error_box = photos_error_box_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]