[gnome-photos/wip/rishi/edit-mode: 15/33] Add PhotosTool



commit 431523dbbc4be7428f0c3a4851140adafb08a8e0
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Jun 2 20:35:39 2015 +0200

    Add PhotosTool

 src/Makefile.am   |    2 +
 src/photos-tool.c |  163 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/photos-tool.h |  107 +++++++++++++++++++++++++++++++++++
 3 files changed, 272 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index a3a5b80..f420258 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -188,6 +188,8 @@ gnome_photos_SOURCES = \
        photos-source-manager.h \
        photos-spinner-box.c \
        photos-spinner-box.h \
+       photos-tool.c \
+       photos-tool.h \
        photos-tracker-change-event.c \
        photos-tracker-change-event.h \
        photos-tracker-change-monitor.c \
diff --git a/src/photos-tool.c b/src/photos-tool.c
new file mode 100644
index 0000000..c911e49
--- /dev/null
+++ b/src/photos-tool.c
@@ -0,0 +1,163 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2015 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.
+ */
+
+
+#include "config.h"
+
+#include <gio/gio.h>
+#include <glib.h>
+
+#include "photos-tool.h"
+#include "photos-utils.h"
+
+
+enum
+{
+  HIDE_REQUESTED,
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+
+G_DEFINE_ABSTRACT_TYPE (PhotosTool, photos_tool, G_TYPE_OBJECT);
+
+
+static void
+photos_tool_default_deactivate (PhotosTool *self)
+{
+}
+
+
+static void
+photos_tool_default_draw (PhotosTool *self, cairo_t *cr, GdkRectangle *rect)
+{
+}
+
+
+static gboolean
+photos_tool_default_left_click_event (PhotosTool *self, GdkEventButton *event)
+{
+  return GDK_EVENT_PROPAGATE;
+}
+
+
+static gboolean
+photos_tool_default_left_unclick_event (PhotosTool *self, GdkEventButton *event)
+{
+  return GDK_EVENT_PROPAGATE;
+}
+
+
+static gboolean
+photos_tool_default_motion_event (PhotosTool *self, GdkEventMotion *event)
+{
+  return GDK_EVENT_PROPAGATE;
+}
+
+
+static void
+photos_tool_init (PhotosTool *self)
+{
+}
+
+
+static void
+photos_tool_class_init (PhotosToolClass *class)
+{
+  class->deactivate = photos_tool_default_deactivate;
+  class->draw = photos_tool_default_draw;
+  class->left_click_event = photos_tool_default_left_click_event;
+  class->left_unclick_event = photos_tool_default_left_unclick_event;
+  class->motion_event = photos_tool_default_motion_event;
+
+  signals[HIDE_REQUESTED] = g_signal_new ("hide-requested",
+                                          G_TYPE_FROM_CLASS (class),
+                                          G_SIGNAL_RUN_LAST,
+                                          G_STRUCT_OFFSET (PhotosToolClass, hide_requested),
+                                          NULL, /* accumulator */
+                                          NULL, /* accu_data */
+                                          g_cclosure_marshal_VOID__VOID,
+                                          G_TYPE_NONE,
+                                          0);
+}
+
+
+void
+photos_tool_activate (PhotosTool *self, PhotosBaseItem *item, GeglGtkView *view)
+{
+  PHOTOS_TOOL_GET_CLASS (self)->activate (self, item, view);
+}
+
+
+void
+photos_tool_deactivate (PhotosTool *self)
+{
+  PHOTOS_TOOL_GET_CLASS (self)->deactivate (self);
+}
+
+
+void
+photos_tool_draw (PhotosTool *self, cairo_t *cr, GdkRectangle *rect)
+{
+  return PHOTOS_TOOL_GET_CLASS (self)->draw (self, cr, rect);
+}
+
+
+const gchar *
+photos_tool_get_icon_name (PhotosTool *self)
+{
+  return PHOTOS_TOOL_GET_CLASS (self)->icon_name;
+}
+
+
+const gchar *
+photos_tool_get_name (PhotosTool *self)
+{
+  return PHOTOS_TOOL_GET_CLASS (self)->name;
+}
+
+
+GtkWidget *
+photos_tool_get_widget (PhotosTool *self)
+{
+  return PHOTOS_TOOL_GET_CLASS (self)->get_widget (self);
+}
+
+
+gboolean
+photos_tool_left_click_event (PhotosTool *self, GdkEventButton *event)
+{
+  return PHOTOS_TOOL_GET_CLASS (self)->left_click_event (self, event);
+}
+
+
+gboolean
+photos_tool_left_unclick_event (PhotosTool *self, GdkEventButton *event)
+{
+  return PHOTOS_TOOL_GET_CLASS (self)->left_unclick_event (self, event);
+}
+
+
+gboolean
+photos_tool_motion_event (PhotosTool *self, GdkEventMotion *event)
+{
+  return PHOTOS_TOOL_GET_CLASS (self)->motion_event (self, event);
+}
diff --git a/src/photos-tool.h b/src/photos-tool.h
new file mode 100644
index 0000000..a766555
--- /dev/null
+++ b/src/photos-tool.h
@@ -0,0 +1,107 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2015 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.
+ */
+
+#ifndef PHOTOS_TOOL_H
+#define PHOTOS_TOOL_H
+
+#include <cairo.h>
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+
+#include "gegl-gtk-view.h"
+#include "photos-base-item.h"
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_TOOL (photos_tool_get_type ())
+
+#define PHOTOS_TOOL(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   PHOTOS_TYPE_TOOL, PhotosTool))
+
+#define PHOTOS_TOOL_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+   PHOTOS_TYPE_TOOL, PhotosToolClass))
+
+#define PHOTOS_IS_TOOL(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   PHOTOS_TYPE_TOOL))
+
+#define PHOTOS_IS_TOOL_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+   PHOTOS_TYPE_TOOL))
+
+#define PHOTOS_TOOL_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+   PHOTOS_TYPE_TOOL, PhotosToolClass))
+
+typedef struct _PhotosTool        PhotosTool;
+typedef struct _PhotosToolClass   PhotosToolClass;
+typedef struct _PhotosToolPrivate PhotosToolPrivate;
+
+struct _PhotosTool
+{
+  GObject parent_instance;
+  PhotosToolPrivate *priv;
+};
+
+struct _PhotosToolClass
+{
+  GObjectClass parent_class;
+
+  const gchar *icon_name;
+  const gchar *name;
+
+  /* virtual methods */
+  void          (*activate)                   (PhotosTool *self, PhotosBaseItem *item, GeglGtkView *view);
+  void          (*deactivate)                 (PhotosTool *self);
+  void          (*draw)                       (PhotosTool *self, cairo_t *cr, GdkRectangle *rect);
+  GtkWidget    *(*get_widget)                 (PhotosTool *self);
+  gboolean      (*left_click_event)           (PhotosTool *self, GdkEventButton *event);
+  gboolean      (*left_unclick_event)         (PhotosTool *self, GdkEventButton *event);
+  gboolean      (*motion_event)               (PhotosTool *self, GdkEventMotion *event);
+
+  /* signals */
+  void          (*hide_requested)             (PhotosTool *self);
+};
+
+GType               photos_tool_get_type                (void) G_GNUC_CONST;
+
+void                photos_tool_activate                (PhotosTool *self, PhotosBaseItem *item, GeglGtkView 
*view);
+
+void                photos_tool_deactivate              (PhotosTool *self);
+
+void                photos_tool_draw                    (PhotosTool *self, cairo_t *cr, GdkRectangle *rect);
+
+const gchar        *photos_tool_get_icon_name           (PhotosTool *self);
+
+const gchar        *photos_tool_get_name                (PhotosTool *self);
+
+GtkWidget          *photos_tool_get_widget              (PhotosTool *self);
+
+gboolean            photos_tool_left_click_event        (PhotosTool *self, GdkEventButton *event);
+
+gboolean            photos_tool_left_unclick_event      (PhotosTool *self, GdkEventButton *event);
+
+gboolean            photos_tool_motion_event            (PhotosTool *self, GdkEventMotion *event);
+
+G_END_DECLS
+
+#endif /* PHOTOS_TOOL_H */


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