[gnome-photos] Add PhotosIndexingNotification
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] Add PhotosIndexingNotification
- Date: Sat, 17 Nov 2012 21:03:42 +0000 (UTC)
commit f68d49b1aa417fc821cffdfa35ff562db03b9aa7
Author: Debarshi Ray <debarshir gnome org>
Date: Sat Nov 17 19:05:34 2012 +0100
Add PhotosIndexingNotification
configure.ac | 2 +-
po/POTFILES.in | 1 +
src/Makefile.am | 2 +
src/photos-indexing-notification.c | 216 ++++++++++++++++++++++++++++++++++++
src/photos-indexing-notification.h | 75 +++++++++++++
5 files changed, 295 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 98cf5d1..997b2a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,7 +94,7 @@ PKG_CHECK_MODULES(GTK_UNIX_PRINT, [gtk+-unix-print-3.0])
PKG_CHECK_MODULES(LCMS, [lcms2])
PKG_CHECK_MODULES(LIBEXIF, [libexif >= $LIBEXIF_MIN_VERSION])
PKG_CHECK_MODULES(LIBRSVG, [librsvg-2.0 >= $LIBRSVG_MIN_VERSION])
-PKG_CHECK_MODULES(TRACKER, [tracker-sparql-0.14])
+PKG_CHECK_MODULES(TRACKER, [tracker-miner-0.14 tracker-sparql-0.14])
LIBGD_INIT([
main-toolbar
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 17e4ae5..c364899 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,6 +11,7 @@ src/eog-util.c
src/photos-application.c
[type: gettext/glade]src/photos-app-menu.ui
src/photos-empty-results-box.c
+src/photos-indexing-notification.c
src/photos-load-more-button.c
src/photos-main-toolbar.c
src/photos-main-window.c
diff --git a/src/Makefile.am b/src/Makefile.am
index d38ed4d..0c82a80 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -63,6 +63,8 @@ gnome_photos_SOURCES = \
photos-error-box.h \
photos-filterable.c \
photos-filterable.h \
+ photos-indexing-notification.c \
+ photos-indexing-notification.h \
photos-item-manager.c \
photos-item-manager.h \
photos-load-more-button.c \
diff --git a/src/photos-indexing-notification.c b/src/photos-indexing-notification.c
new file mode 100644
index 0000000..1dd9221
--- /dev/null
+++ b/src/photos-indexing-notification.c
@@ -0,0 +1,216 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright  2012 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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+/* Based on code from:
+ * + Documents
+ */
+
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <libtracker-miner/tracker-miner.h>
+
+#include "photos-indexing-notification.h"
+#include "photos-notification-manager.h"
+
+
+struct _PhotosIndexingNotificationPrivate
+{
+ ClutterActor *ntfctn_mngr;
+ TrackerMinerManager *manager;
+ gboolean manually_closed;
+ gboolean on_display;
+};
+
+
+G_DEFINE_TYPE (PhotosIndexingNotification, photos_indexing_notification, GTK_TYPE_GRID);
+
+
+static const gchar *MINER_FILES = "org.freedesktop.Tracker1.Miner.Files";
+
+
+static void
+photos_indexing_notification_destroy_notification (PhotosIndexingNotification *self)
+{
+ GtkWidget *parent;
+
+ self->priv->on_display = FALSE;
+ parent = gtk_widget_get_parent (GTK_WIDGET (self));
+ if (parent != NULL)
+ gtk_container_remove (GTK_CONTAINER (parent), GTK_WIDGET (self));
+}
+
+
+static void
+photos_indexing_notification_clicked (PhotosIndexingNotification *self)
+{
+ self->priv->manually_closed = TRUE;
+ photos_indexing_notification_destroy_notification (self);
+}
+
+
+static void
+photos_indexing_notification_display_notification (PhotosIndexingNotification *self)
+{
+ PhotosIndexingNotificationPrivate *priv = self->priv;
+
+ if (priv->on_display)
+ return;
+
+ if (priv->manually_closed)
+ return;
+
+ photos_notification_manager_add_notification (PHOTOS_NOTIFICATION_MANAGER (priv->ntfctn_mngr),
+ GTK_WIDGET (self));
+ priv->on_display = TRUE;
+}
+
+
+static void
+photos_indexing_notification_check_notification (PhotosIndexingNotification *self)
+{
+ PhotosIndexingNotificationPrivate *priv = self->priv;
+ GSList *running;
+
+ running = tracker_miner_manager_get_running (priv->manager);
+ if (g_slist_find_custom (running, (gconstpointer) MINER_FILES, (GCompareFunc) g_strcmp0) != NULL)
+ {
+ gdouble progress;
+
+ tracker_miner_manager_get_status (priv->manager, MINER_FILES, NULL, &progress, NULL);
+ if (progress < 1)
+ photos_indexing_notification_display_notification (self);
+ else
+ {
+ priv->manually_closed = FALSE;
+ photos_indexing_notification_destroy_notification (self);
+ }
+ }
+
+ if (running != NULL)
+ g_slist_free_full (running, g_free);
+}
+
+
+static void
+photos_indexing_notification_dispose (GObject *object)
+{
+ PhotosIndexingNotification *self = PHOTOS_INDEXING_NOTIFICATION (object);
+ PhotosIndexingNotificationPrivate *priv = self->priv;
+
+ g_clear_object (&priv->ntfctn_mngr);
+ g_clear_object (&priv->manager);
+
+ G_OBJECT_CLASS (photos_indexing_notification_parent_class)->dispose (object);
+}
+
+
+static void
+photos_indexing_notification_init (PhotosIndexingNotification *self)
+{
+ PhotosIndexingNotificationPrivate *priv;
+ GError *error;
+ GtkStyleContext *context;
+ GtkWidget *close;
+ GtkWidget *image;
+ GtkWidget *labels;
+ GtkWidget *primary;
+ GtkWidget *secondary;
+ GtkWidget *spinner;
+
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ PHOTOS_TYPE_INDEXING_NOTIFICATION,
+ PhotosIndexingNotificationPrivate);
+ priv = self->priv;
+
+ error = NULL;
+ priv->manager = tracker_miner_manager_new_full (FALSE, &error);
+ if (error != NULL)
+ {
+ g_warning ("Unable to create a TrackerMinerManager, indexing progress notification won't work: %s",
+ error->message);
+ g_error_free (error);
+ return;
+ }
+
+ priv->ntfctn_mngr = g_object_ref_sink (photos_notification_manager_new ());
+
+ spinner = gtk_spinner_new ();
+ gtk_widget_set_size_request (spinner, 16, 16);
+ gtk_container_add (GTK_CONTAINER (self), spinner);
+
+ labels = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (labels), GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (labels), 3);
+ gtk_container_add (GTK_CONTAINER (self), labels);
+
+ primary = gtk_label_new (_("Your photos are being indexed"));
+ gtk_widget_set_halign (primary, GTK_ALIGN_START);
+ gtk_container_add (GTK_CONTAINER (labels), primary);
+
+ secondary = gtk_label_new (_("Some photos might not be available during this process"));
+ gtk_widget_set_halign (secondary, GTK_ALIGN_START);
+ context = gtk_widget_get_style_context (secondary);
+ gtk_style_context_add_class (context, "dim-label");
+ gtk_container_add (GTK_CONTAINER (labels), secondary);
+
+ image = gtk_image_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_INVALID);
+ gtk_widget_set_margin_bottom (image, 2);
+ gtk_widget_set_margin_top (image, 2);
+ gtk_image_set_pixel_size (GTK_IMAGE (image), 16);
+
+ close = gtk_button_new ();
+ gtk_widget_set_valign (close, GTK_ALIGN_CENTER);
+ gtk_container_add (GTK_CONTAINER (close), image);
+ gtk_container_add (GTK_CONTAINER (self), close);
+
+ g_signal_connect_swapped (close, "clicked", G_CALLBACK (photos_indexing_notification_clicked), self);
+
+ g_signal_connect_swapped (priv->manager,
+ "miner-progress",
+ G_CALLBACK (photos_indexing_notification_check_notification),
+ self);
+ photos_indexing_notification_check_notification (self);
+}
+
+
+static void
+photos_indexing_notification_class_init (PhotosIndexingNotificationClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->dispose = photos_indexing_notification_dispose;
+
+ g_type_class_add_private (class, sizeof (PhotosIndexingNotificationPrivate));
+}
+
+
+GtkWidget *
+photos_indexing_notification_new (void)
+{
+ return g_object_new (PHOTOS_TYPE_INDEXING_NOTIFICATION,
+ "column-spacing", 12,
+ "margin-left", 12,
+ "margin-right", 12,
+ "orientation", GTK_ORIENTATION_HORIZONTAL,
+ NULL);
+}
diff --git a/src/photos-indexing-notification.h b/src/photos-indexing-notification.h
new file mode 100644
index 0000000..1f0872f
--- /dev/null
+++ b/src/photos-indexing-notification.h
@@ -0,0 +1,75 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright  2012 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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+/* Based on code from:
+ * + Documents
+ */
+
+#ifndef PHOTOS_INDEXING_NOTIFICATION_H
+#define PHOTOS_INDEXING_NOTIFICATION_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_INDEXING_NOTIFICATION (photos_indexing_notification_get_type ())
+
+#define PHOTOS_INDEXING_NOTIFICATION(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ PHOTOS_TYPE_INDEXING_NOTIFICATION, PhotosIndexingNotification))
+
+#define PHOTOS_INDEXING_NOTIFICATION_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ PHOTOS_TYPE_INDEXING_NOTIFICATION, PhotosIndexingNotificationClass))
+
+#define PHOTOS_IS_INDEXING_NOTIFICATION(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ PHOTOS_TYPE_INDEXING_NOTIFICATION))
+
+#define PHOTOS_IS_INDEXING_NOTIFICATION_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ PHOTOS_TYPE_INDEXING_NOTIFICATION))
+
+#define PHOTOS_INDEXING_NOTIFICATION_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ PHOTOS_TYPE_INDEXING_NOTIFICATION, PhotosIndexingNotificationClass))
+
+typedef struct _PhotosIndexingNotification PhotosIndexingNotification;
+typedef struct _PhotosIndexingNotificationClass PhotosIndexingNotificationClass;
+typedef struct _PhotosIndexingNotificationPrivate PhotosIndexingNotificationPrivate;
+
+struct _PhotosIndexingNotification
+{
+ GtkGrid parent_instance;
+ PhotosIndexingNotificationPrivate *priv;
+};
+
+struct _PhotosIndexingNotificationClass
+{
+ GtkGridClass parent_class;
+};
+
+GType photos_indexing_notification_get_type (void) G_GNUC_CONST;
+
+GtkWidget *photos_indexing_notification_new (void);
+
+G_END_DECLS
+
+#endif /* PHOTOS_INDEXING_NOTIFICATION_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]