[gthumb] add the negative filter to the special effects
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] add the negative filter to the special effects
- Date: Sun, 25 Jan 2015 12:06:02 +0000 (UTC)
commit ef847c20d9991458c41f942ab797d512ef6a826f
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Jan 7 13:01:06 2015 +0100
add the negative filter to the special effects
extensions/file_tools/gth-file-tool-negative.c | 58 +++++-------------------
extensions/file_tools/gth-file-tool-negative.h | 21 +--------
extensions/file_tools/main.c | 2 +-
3 files changed, 14 insertions(+), 67 deletions(-)
---
diff --git a/extensions/file_tools/gth-file-tool-negative.c b/extensions/file_tools/gth-file-tool-negative.c
index 170aa3d..7d7f65d 100644
--- a/extensions/file_tools/gth-file-tool-negative.c
+++ b/extensions/file_tools/gth-file-tool-negative.c
@@ -3,7 +3,7 @@
/*
* GThumb
*
- * Copyright (C) 2009 Free Software Foundation, Inc.
+ * Copyright (C) 2009-2014 Free Software Foundation, 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
@@ -21,13 +21,9 @@
#include <config.h>
#include <gthumb.h>
-#include <extensions/image_viewer/image-viewer.h>
#include "gth-file-tool-negative.h"
-G_DEFINE_TYPE (GthFileToolNegative, gth_file_tool_negative, GTH_TYPE_IMAGE_VIEWER_PAGE_TOOL)
-
-
static gpointer
negative_exec (GthAsyncTask *task,
gpointer user_data)
@@ -60,8 +56,11 @@ negative_exec (GthAsyncTask *task,
p_destination_line = _cairo_image_surface_flush_and_get_data (destination);
for (y = 0; y < height; y++) {
gth_async_task_get_data (task, NULL, &cancelled, NULL);
- if (cancelled)
+ if (cancelled) {
+ cairo_surface_destroy (destination);
+ cairo_surface_destroy (source);
return NULL;
+ }
progress = (double) y / height;
gth_async_task_set_data (task, NULL, NULL, &progress);
@@ -93,45 +92,12 @@ negative_exec (GthAsyncTask *task,
}
-static void
-gth_file_tool_negative_activate (GthFileTool *base)
-{
- GtkWidget *window;
- GtkWidget *viewer_page;
- GthTask *task;
-
- window = gth_file_tool_get_window (base);
- viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
- if (! GTH_IS_IMAGE_VIEWER_PAGE (viewer_page))
- return;
-
- task = gth_image_viewer_task_new (GTH_IMAGE_VIEWER_PAGE (viewer_page),
- _("Applying changes"),
- NULL,
- negative_exec,
- NULL,
- NULL,
- NULL);
- g_signal_connect (task,
- "completed",
- G_CALLBACK (gth_image_viewer_task_set_destination),
- NULL);
- gth_browser_exec_task (GTH_BROWSER (window), task, FALSE);
-}
-
-
-static void
-gth_file_tool_negative_class_init (GthFileToolNegativeClass *klass)
-{
- GthFileToolClass *file_tool_class;
-
- file_tool_class = GTH_FILE_TOOL_CLASS (klass);
- file_tool_class->activate = gth_file_tool_negative_activate;
-}
-
-
-static void
-gth_file_tool_negative_init (GthFileToolNegative *self)
+void
+negative_add_to_special_effects (GthFilterGrid *grid)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), "image-invert-symbolic", _("Negative"),
GTH_TOOLBOX_SECTION_COLORS);
+ gth_filter_grid_add_filter (grid,
+ GTH_FILTER_GRID_NEW_FILTER_ID,
+ gth_image_task_new (_("Applying changes"), NULL, negative_exec, NULL,
NULL, NULL),
+ _("Negative"),
+ NULL);
}
diff --git a/extensions/file_tools/gth-file-tool-negative.h b/extensions/file_tools/gth-file-tool-negative.h
index 358f2ac..e284006 100644
--- a/extensions/file_tools/gth-file-tool-negative.h
+++ b/extensions/file_tools/gth-file-tool-negative.h
@@ -23,29 +23,10 @@
#define GTH_FILE_TOOL_NEGATIVE_H
#include <gthumb.h>
-#include <extensions/image_viewer/image-viewer.h>
G_BEGIN_DECLS
-#define GTH_TYPE_FILE_TOOL_NEGATIVE (gth_file_tool_negative_get_type ())
-#define GTH_FILE_TOOL_NEGATIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_FILE_TOOL_NEGATIVE,
GthFileToolNegative))
-#define GTH_FILE_TOOL_NEGATIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_FILE_TOOL_NEGATIVE,
GthFileToolNegativeClass))
-#define GTH_IS_FILE_TOOL_NEGATIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_FILE_TOOL_NEGATIVE))
-#define GTH_IS_FILE_TOOL_NEGATIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GTH_TYPE_FILE_TOOL_NEGATIVE))
-#define GTH_FILE_TOOL_NEGATIVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GTH_TYPE_FILE_TOOL_NEGATIVE, GthFileToolNegativeClass))
-
-typedef struct _GthFileToolNegative GthFileToolNegative;
-typedef struct _GthFileToolNegativeClass GthFileToolNegativeClass;
-
-struct _GthFileToolNegative {
- GthImageViewerPageTool parent_instance;
-};
-
-struct _GthFileToolNegativeClass {
- GthImageViewerPageToolClass parent_class;
-};
-
-GType gth_file_tool_negative_get_type (void);
+void negative_add_to_special_effects (GthFilterGrid *);
G_END_DECLS
diff --git a/extensions/file_tools/main.c b/extensions/file_tools/main.c
index cbfc0fd..7ae9483 100644
--- a/extensions/file_tools/main.c
+++ b/extensions/file_tools/main.c
@@ -57,7 +57,6 @@ gthumb_extension_activate (void)
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_SHARPEN);
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_GRAYSCALE);
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_CURVES);
- gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_NEGATIVE);
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_EFFECTS);
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_ROTATE_LEFT);
@@ -84,6 +83,7 @@ gthumb_extension_activate (void)
gth_hook_add_callback ("add-special-effect", 40, G_CALLBACK (grapes_add_to_special_effects), NULL);
gth_hook_add_callback ("add-special-effect", 50, G_CALLBACK (instagram_add_to_special_effects), NULL);
gth_hook_add_callback ("add-special-effect", 70, G_CALLBACK (vintage_add_to_special_effects), NULL);
+ gth_hook_add_callback ("add-special-effect", 80, G_CALLBACK (negative_add_to_special_effects), NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]