1 /*
2 * gedit-bookmarks-message-goto-previous.c
3 * This file is part of gedit
4 *
5 * Copyright (C) 2011 - Paolo Borelli
6 *
7 * gedit is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * gedit is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with gedit; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301 USA
21 */
22
23 #include <gtk/gtk.h>
24 #include <gedit/gedit-view.h>
25 #include "gedit-bookmarks-message-goto-previous.h"
26
27 enum
28 {
29 PROP_0,
30
31 PROP_VIEW,
32 PROP_ITER,
33 };
34
35 struct _GeditBookmarksMessageGotoPreviousPrivate
36 {
37 GeditView *view;
38 GtkTextIter *iter;
39 };
40
G_DEFINE_TYPE_WITH_PRIVATE(GeditBookmarksMessageGotoPrevious,gedit_bookmarks_message_goto_previous,GEDIT_TYPE_MESSAGE)41 G_DEFINE_TYPE_WITH_PRIVATE (GeditBookmarksMessageGotoPrevious, gedit_bookmarks_message_goto_previous, GEDIT_TYPE_MESSAGE)
42
43 static void
44 gedit_bookmarks_message_goto_previous_finalize (GObject *obj)
45 {
46 GeditBookmarksMessageGotoPrevious *msg = GEDIT_BOOKMARKS_MESSAGE_GOTO_PREVIOUS (obj);
47
48 if (msg->priv->view)
49 {
50 g_object_unref (msg->priv->view);
51 }
52 if (msg->priv->iter)
53 {
54 g_object_unref (msg->priv->iter);
55 }
56
57 G_OBJECT_CLASS (gedit_bookmarks_message_goto_previous_parent_class)->finalize (obj);
58 }
59
60 static void
gedit_bookmarks_message_goto_previous_get_property(GObject * obj,guint prop_id,GValue * value,GParamSpec * pspec)61 gedit_bookmarks_message_goto_previous_get_property (GObject *obj,
62 guint prop_id,
63 GValue *value,
64 GParamSpec *pspec)
65 {
66 GeditBookmarksMessageGotoPrevious *msg;
67
68 msg = GEDIT_BOOKMARKS_MESSAGE_GOTO_PREVIOUS (obj);
69
70 switch (prop_id)
71 {
72 case PROP_VIEW:
73 g_value_set_object (value, msg->priv->view);
74 break;
75 case PROP_ITER:
76 g_value_set_boxed (value, msg->priv->iter);
77 break;
78 }
79 }
80
81 static void
gedit_bookmarks_message_goto_previous_set_property(GObject * obj,guint prop_id,GValue const * value,GParamSpec * pspec)82 gedit_bookmarks_message_goto_previous_set_property (GObject *obj,
83 guint prop_id,
84 GValue const *value,
85 GParamSpec *pspec)
86 {
87 GeditBookmarksMessageGotoPrevious *msg;
88
89 msg = GEDIT_BOOKMARKS_MESSAGE_GOTO_PREVIOUS (obj);
90
91 switch (prop_id)
92 {
93 case PROP_VIEW:
94 {
95 if (msg->priv->view)
96 {
97 g_object_unref (msg->priv->view);
98 }
99 msg->priv->view = g_value_dup_object (value);
100 break;
101 }
102 case PROP_ITER:
103 {
104 if (msg->priv->iter)
105 {
106 g_boxed_free (GTK_TYPE_TEXT_ITER, msg->priv->iter);
107 }
108 msg->priv->iter = g_boxed_copy (GTK_TYPE_TEXT_ITER, value);
109 break;
110 }
111 }
112 }
113
114 static void
gedit_bookmarks_message_goto_previous_class_init(GeditBookmarksMessageGotoPreviousClass * klass)115 gedit_bookmarks_message_goto_previous_class_init (GeditBookmarksMessageGotoPreviousClass *klass)
116 {
117 GObjectClass *object_class = G_OBJECT_CLASS(klass);
118
119 object_class->finalize = gedit_bookmarks_message_goto_previous_finalize;
120
121 object_class->get_property = gedit_bookmarks_message_goto_previous_get_property;
122 object_class->set_property = gedit_bookmarks_message_goto_previous_set_property;
123
124 g_object_class_install_property (object_class,
125 PROP_VIEW,
126 g_param_spec_object ("view",
127 "View",
128 "View",
129 GEDIT_TYPE_VIEW,
130 G_PARAM_READWRITE |
131 G_PARAM_CONSTRUCT |
132 G_PARAM_STATIC_STRINGS));
133
134 g_object_class_install_property (object_class,
135 PROP_ITER,
136 g_param_spec_boxed ("iter",
137 "Iter",
138 "Iter",
139 GTK_TYPE_TEXT_ITER,
140 G_PARAM_READWRITE |
141 G_PARAM_CONSTRUCT |
142 G_PARAM_STATIC_STRINGS));
143
144 }
145
146 static void
gedit_bookmarks_message_goto_previous_init(GeditBookmarksMessageGotoPrevious * message)147 gedit_bookmarks_message_goto_previous_init (GeditBookmarksMessageGotoPrevious *message)
148 {
149 message->priv = gedit_bookmarks_message_goto_previous_get_instance_private (message);
150 }
151