1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18 #if 0 19 20 #include "config.h" 21 22 #include <gegl.h> 23 #include <gtk/gtk.h> 24 25 #include "tools-types.h" 26 27 #include "gimpforegroundselecttool.h" 28 #include "gimpforegroundselecttoolundo.h" 29 30 31 enum 32 { 33 PROP_0, 34 PROP_FOREGROUND_SELECT_TOOL 35 }; 36 37 38 static void gimp_foreground_select_tool_undo_constructed (GObject *object); 39 static void gimp_foreground_select_tool_undo_set_property (GObject *object, 40 guint property_id, 41 const GValue *value, 42 GParamSpec *pspec); 43 static void gimp_foreground_select_tool_undo_get_property (GObject *object, 44 guint property_id, 45 GValue *value, 46 GParamSpec *pspec); 47 48 static void gimp_foreground_select_tool_undo_pop (GimpUndo *undo, 49 GimpUndoMode undo_mode, 50 GimpUndoAccumulator *accum); 51 static void gimp_foreground_select_tool_undo_free (GimpUndo *undo, 52 GimpUndoMode undo_mode); 53 54 55 G_DEFINE_TYPE (GimpForegroundSelectToolUndo, gimp_foreground_select_tool_undo, 56 GIMP_TYPE_UNDO) 57 58 #define parent_class gimp_foreground_select_tool_undo_parent_class 59 60 61 static void 62 gimp_foreground_select_tool_undo_class_init (GimpForegroundSelectToolUndoClass *klass) 63 { 64 GObjectClass *object_class = G_OBJECT_CLASS (klass); 65 GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass); 66 67 object_class->constructed = gimp_foreground_select_tool_undo_constructed; 68 object_class->set_property = gimp_foreground_select_tool_undo_set_property; 69 object_class->get_property = gimp_foreground_select_tool_undo_get_property; 70 71 undo_class->pop = gimp_foreground_select_tool_undo_pop; 72 undo_class->free = gimp_foreground_select_tool_undo_free; 73 74 g_object_class_install_property (object_class, PROP_FOREGROUND_SELECT_TOOL, 75 g_param_spec_object ("foreground-select-tool", 76 NULL, NULL, 77 GIMP_TYPE_FOREGROUND_SELECT_TOOL, 78 GIMP_PARAM_READWRITE | 79 G_PARAM_CONSTRUCT_ONLY)); 80 } 81 82 static void 83 gimp_foreground_select_tool_undo_init (GimpForegroundSelectToolUndo *undo) 84 { 85 } 86 87 static void 88 gimp_foreground_select_tool_undo_constructed (GObject *object) 89 { 90 GimpForegroundSelectToolUndo *fg_select_tool_undo; 91 92 G_OBJECT_CLASS (parent_class)->constructed (object); 93 94 fg_select_tool_undo = GIMP_FOREGROUND_SELECT_TOOL_UNDO (object); 95 96 gimp_assert (GIMP_IS_FOREGROUND_SELECT_TOOL (fg_select_tool_undo->foreground_select_tool)); 97 98 g_object_add_weak_pointer (G_OBJECT (fg_select_tool_undo->foreground_select_tool), 99 (gpointer) &fg_select_tool_undo->foreground_select_tool); 100 } 101 102 static void 103 gimp_foreground_select_tool_undo_set_property (GObject *object, 104 guint property_id, 105 const GValue *value, 106 GParamSpec *pspec) 107 { 108 GimpForegroundSelectToolUndo *fg_select_tool_undo = 109 GIMP_FOREGROUND_SELECT_TOOL_UNDO (object); 110 111 switch (property_id) 112 { 113 case PROP_FOREGROUND_SELECT_TOOL: 114 fg_select_tool_undo->foreground_select_tool = g_value_get_object (value); 115 break; 116 117 default: 118 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); 119 break; 120 } 121 } 122 123 static void 124 gimp_foreground_select_tool_undo_get_property (GObject *object, 125 guint property_id, 126 GValue *value, 127 GParamSpec *pspec) 128 { 129 GimpForegroundSelectToolUndo *fg_select_tool_undo = 130 GIMP_FOREGROUND_SELECT_TOOL_UNDO (object); 131 132 switch (property_id) 133 { 134 case PROP_FOREGROUND_SELECT_TOOL: 135 g_value_set_object (value, fg_select_tool_undo->foreground_select_tool); 136 break; 137 138 default: 139 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); 140 break; 141 } 142 } 143 144 static void 145 gimp_foreground_select_tool_undo_pop (GimpUndo *undo, 146 GimpUndoMode undo_mode, 147 GimpUndoAccumulator *accum) 148 { 149 GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); 150 } 151 152 static void 153 gimp_foreground_select_tool_undo_free (GimpUndo *undo, 154 GimpUndoMode undo_mode) 155 { 156 GimpForegroundSelectToolUndo *fg_select_tool_undo = GIMP_FOREGROUND_SELECT_TOOL_UNDO (undo); 157 158 if (fg_select_tool_undo->foreground_select_tool) 159 { 160 g_object_remove_weak_pointer (G_OBJECT (fg_select_tool_undo->foreground_select_tool), 161 (gpointer) &fg_select_tool_undo->foreground_select_tool); 162 fg_select_tool_undo->foreground_select_tool = NULL; 163 } 164 165 GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode); 166 } 167 168 #endif 169