[nautilus/wip/delete_notification] delete notification



commit 65ef26e313af0f75241619ec74ee51d46281483a
Author: Carlos Soriano <csoriano gnome org>
Date:   Thu Jan 22 19:21:44 2015 +0100

    delete notification

 nautilus-delete-notification.h      |   39 ++++++++++++++
 src/nautilus-delete-notification.c  |   97 +++++++++++++++++++++++++++++++++++
 src/nautilus-notification-manager.c |   74 ++++++++++++++++++++++++++
 src/nautilus-notification-manager.h |   56 ++++++++++++++++++++
 4 files changed, 266 insertions(+), 0 deletions(-)
---
diff --git a/nautilus-delete-notification.h b/nautilus-delete-notification.h
new file mode 100644
index 0000000..3794e88
--- /dev/null
+++ b/nautilus-delete-notification.h
@@ -0,0 +1,39 @@
+#ifndef NAUTILUS_DELETE_NOTIFICATION_H
+#define NAUTILUS_DELETE_NOTIFICATION_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_DELETE_NOTIFICATION            (nautilus_delete_notification_get_type())
+#define NAUTILUS_DELETE_NOTIFICATION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
NAUTILUS_TYPE_DELETE_NOTIFICATION, NautilusDeleteNotification))
+#define NAUTILUS_DELETE_NOTIFICATION_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
NAUTILUS_TYPE_DELETE_NOTIFICATION, NautilusDeleteNotification const))
+#define NAUTILUS_DELETE_NOTIFICATION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  
NAUTILUS_TYPE_DELETE_NOTIFICATION, NautilusDeleteNotificationClass))
+#define NAUTILUS_IS_DELETE_NOTIFICATION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
NAUTILUS_TYPE_DELETE_NOTIFICATION))
+#define NAUTILUS_IS_DELETE_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  
NAUTILUS_TYPE_DELETE_NOTIFICATION))
+#define NAUTILUS_DELETE_NOTIFICATION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  
NAUTILUS_TYPE_DELETE_NOTIFICATION, NautilusDeleteNotificationClass))
+
+typedef struct _NautilusDeleteNotification        NautilusDeleteNotification;
+typedef struct _NautilusDeleteNotificationClass   NautilusDeleteNotificationClass;
+typedef struct _NautilusDeleteNotificationPrivate NautilusDeleteNotificationPrivate;
+
+struct _NautilusDeleteNotification
+{
+  GtkGrid parent;
+
+  /*< private >*/
+  NautilusDeleteNotificationPrivate *priv;
+};
+
+struct _NautilusDeleteNotificationClass
+{
+  GtkGridClass parent;
+};
+
+GType                           nautilus_delete_notification_get_type (void);
+NautilusDeleteNotification     *nautilus_delete_notification_new      (void);
+
+G_END_DECLS
+
+#endif /* NAUTILUS_DELETE_NOTIFICATION_H */
diff --git a/src/nautilus-delete-notification.c b/src/nautilus-delete-notification.c
new file mode 100644
index 0000000..46da6a5
--- /dev/null
+++ b/src/nautilus-delete-notification.c
@@ -0,0 +1,97 @@
+#include "nautilus-delete-notification.h"
+
+struct _NautilusDeleteNotificationPrivate
+{
+  GList *items;
+  guint timeout_id;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (NautilusDeleteNotification, nautilus_delete_notification, GTK_TYPE_GRID)
+
+enum {
+  PROP_0,
+  PROP_ITEMS,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+NautilusDeleteNotification *
+nautilus_delete_notification_new (void)
+{
+  return g_object_new (NAUTILUS_TYPE_DELETE_NOTIFICATION, NULL);
+}
+
+static void
+nautilus_delete_notification_finalize (GObject *object)
+{
+  NautilusDeleteNotificationPrivate *priv = NAUTILUS_DELETE_NOTIFICATION (object)->priv;
+
+  G_OBJECT_CLASS (nautilus_delete_notification_parent_class)->finalize (object);
+}
+
+static void
+nautilus_delete_notification_get_property (GObject    *object,
+                                           guint       prop_id,
+                                           GValue     *value,
+                                           GParamSpec *pspec)
+{
+  NautilusDeleteNotification *self = NAUTILUS_DELETE_NOTIFICATION (object);
+
+  switch (prop_id)
+    {
+    case PROP_ITEMS:
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+nautilus_delete_notification_set_property (GObject      *object,
+                                           guint         prop_id,
+                                           const GValue *value,
+                                           GParamSpec   *pspec)
+{
+  NautilusDeleteNotification *self = NAUTILUS_DELETE_NOTIFICATION (object);
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+nautilus_delete_notification_class_init (NautilusDeleteNotificationClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = nautilus_delete_notification_finalize;
+  object_class->get_property = nautilus_delete_notification_get_property;
+  object_class->set_property = nautilus_delete_notification_set_property;
+}
+
+static void
+nautilus_delete_notification_init (NautilusDeleteNotification *self)
+{
+  self->priv = nautilus_delete_notification_get_instance_private (self);
+}
+
+static void
+nautilus_delete_notification_remove_timeout (NAutilusDeleteNotification *self)
+{
+  if (self->priv->timeout_id != 0)
+    {
+      g_source_remove (self->priv->timeout_id);
+      self->priv->timeout_id = 0;
+    }
+}
+
+static void
+nautilus_delete_notification_destroy (PhotosDeleteNotification *self)
+{
+  nautilus_delete_notification_remove_timeout (self);
+  gtk_widget_destroy (GTK_WIDGET (self));
+}
+
diff --git a/src/nautilus-notification-manager.c b/src/nautilus-notification-manager.c
new file mode 100644
index 0000000..c844227
--- /dev/null
+++ b/src/nautilus-notification-manager.c
@@ -0,0 +1,74 @@
+#include "nautilus-notification-manager.h"
+
+struct _NautilusNotificationManagerPrivate
+{
+  GtkWidget *grid;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (NautilusNotificationManager, nautilus_notification_manager, GD_TYPE_NOTIFICATION)
+
+NautilusNotificationManager *
+nautilus_notification_manager_dup_singleton (void)
+{
+  return g_object_new (NAUTILUS_TYPE_NOTIFICATION_MANAGER,
+                       "show-close-button", FALSE,
+                       "timeout", -1,
+                       NULL);
+}
+
+static GObject *
+nautilus_notification_manager_constructor (GType type,
+                                           guint n_construct_params,
+                                           GObjectConstructParam *construct_params)
+{
+  static GObject *self = NULL;
+
+  if (self == NULL)
+    {
+      self = G_OBJECT_CLASS (nautilus_notification_manager_parent_class)->constructor (type,
+                                                                                       n_construct_params,
+                                                                                       construct_params);
+      g_object_add_weak_pointer (self, (gpointer) &self);
+      return self;
+    }
+
+  return g_object_ref (self);
+}
+
+static void
+nautilus_notification_manager_remove (NautilusNotificationManager *self)
+{
+  GList *children;
+
+  children = gtk_container_get_children (GTK_CONTAINER (self->priv->grid));
+  if (children == NULL)
+    gtk_widget_hide (GTK_WIDGET (self));
+  else
+    g_list_free (children);
+}
+
+static void
+nautilus_notification_manager_class_init (NautilusNotificationManagerClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->constructor = nautilus_notification_manager_constructor;
+}
+
+static void
+nautilus_notification_manager_init (NautilusNotificationManager *self)
+{
+  self->priv = nautilus_notification_manager_get_instance_private (self);
+
+  gtk_widget_set_halign (GTK_WIDGET (self), GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_START);
+
+  self->priv->grid = gtk_grid_new ();
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (self->priv->grid),
+                                  GTK_ORIENTATION_VERTICAL);
+  gtk_grid_set_row_spacing (GTK_GRID (self->priv->grid), 6);
+  gtk_container_add (GTK_CONTAINER (self), self->priv->grid);
+
+  g_signal_connect_swapped (self->priv->grid, "remove",
+                            G_CALLBACK (nautilus_notification_manager_remove), self);
+}
diff --git a/src/nautilus-notification-manager.h b/src/nautilus-notification-manager.h
new file mode 100644
index 0000000..5be7497
--- /dev/null
+++ b/src/nautilus-notification-manager.h
@@ -0,0 +1,56 @@
+/* nautilus-notification-manager.h
+ *
+ * Copyright (C) 2015 Carlos Soriano <csoriano gnome org>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NAUTILUS_NOTIFICATION_MANAGER_H
+#define NAUTILUS_NOTIFICATION_MANAGER_H
+
+#include <libgd/gd.h>
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_NOTIFICATION_MANAGER            (nautilus_notification_manager_get_type())
+#define NAUTILUS_NOTIFICATION_MANAGER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
NAUTILUS_TYPE_NOTIFICATION_MANAGER, NautilusNotificationManager))
+#define NAUTILUS_NOTIFICATION_MANAGER_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
NAUTILUS_TYPE_NOTIFICATION_MANAGER, NautilusNotificationManager const))
+#define NAUTILUS_NOTIFICATION_MANAGER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  
NAUTILUS_TYPE_NOTIFICATION_MANAGER, NautilusNotificationManagerClass))
+#define NAUTILUS_IS_NOTIFICATION_MANAGER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
NAUTILUS_TYPE_NOTIFICATION_MANAGER))
+#define NAUTILUS_IS_NOTIFICATION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  
NAUTILUS_TYPE_NOTIFICATION_MANAGER))
+#define NAUTILUS_NOTIFICATION_MANAGER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  
NAUTILUS_TYPE_NOTIFICATION_MANAGER, NautilusNotificationManagerClass))
+
+typedef struct _NautilusNotificationManager        NautilusNotificationManager;
+typedef struct _NautilusNotificationManagerClass   NautilusNotificationManagerClass;
+typedef struct _NautilusNotificationManagerPrivate NautilusNotificationManagerPrivate;
+
+struct _NautilusNotificationManager
+{
+  GdNotification parent;
+
+  /*< private >*/
+  NautilusNotificationManagerPrivate *priv;
+};
+
+struct _NautilusNotificationManagerClass
+{
+  GdNotificationClass parent;
+};
+
+GType                            nautilus_notification_manager_get_type      (void);
+NautilusNotificationManager     *nautilus_notification_manager_dup_singleton (void);
+
+G_END_DECLS
+
+#endif /* NAUTILUS_NOTIFICATION_MANAGER_H */


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