message-view: bgo #727634 - Cannot copy build output
[anjuta.git] / libanjuta / anjuta-dock-pane.c
blobaf3e508f29bfa3ffd88a576aaa7342d58f7cb418
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) James Liggett 2010 <jrliggett@cox.net>
5 *
6 * git-shell-test is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * git-shell-test is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "anjuta-dock-pane.h"
22 /**
23 * SECTION: anjuta-dock-pane
24 * @short_description: Wrapper class for #AnjutaDock panes
25 * @see_also: #AnjutaDock
26 * @include: libanjuta/anjuta-dock-pane.h
28 * AnjutaDockPane is an abstract wrapper class for panes in an
29 * #AnjutaDock.
31 * Using AnjutaDockPane is especially helpful for those panes that show data
32 * from extenal sources that must be refreshed frequently, or panes that are
33 * exceptionally complex.
36 enum
38 ANJUTA_DOCK_PANE_PLUGIN = 1
41 enum
43 SINGLE_SELECTION_CHANGED,
44 MULTIPLE_SELECTION_CHANGED,
46 LAST_SIGNAL
49 static guint anjuta_dock_pane_signals[LAST_SIGNAL] = { 0 };
51 struct _AnjutaDockPanePriv
53 AnjutaPlugin *plugin;
56 G_DEFINE_ABSTRACT_TYPE (AnjutaDockPane, anjuta_dock_pane, G_TYPE_OBJECT);
58 static void
59 anjuta_dock_pane_init (AnjutaDockPane *self)
61 self->priv = g_new0 (AnjutaDockPanePriv, 1);
64 static void
65 anjuta_dock_pane_finalize (GObject *object)
67 AnjutaDockPane *self;
69 self = ANJUTA_DOCK_PANE (object);
71 g_free (self->priv);
73 G_OBJECT_CLASS (anjuta_dock_pane_parent_class)->finalize (object);
76 static void
77 anjuta_dock_pane_set_property (GObject *object, guint property_id,
78 const GValue *value, GParamSpec *param_spec)
80 AnjutaDockPane *self;
82 self = ANJUTA_DOCK_PANE (object);
84 switch (property_id)
86 case ANJUTA_DOCK_PANE_PLUGIN:
87 self->priv->plugin = ANJUTA_PLUGIN (g_value_get_object (value));
88 break;
89 default:
90 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, param_spec);
91 break;
95 static void
96 anjuta_dock_pane_get_property (GObject *object, guint property_id,
97 GValue *value, GParamSpec *param_spec)
99 AnjutaDockPane *self;
101 self = ANJUTA_DOCK_PANE (object);
103 switch (property_id)
105 case ANJUTA_DOCK_PANE_PLUGIN:
106 g_value_set_object (value, self->priv->plugin);
107 break;
108 default:
109 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, param_spec);
110 break;
114 static void
115 anjuta_dock_pane_single_selection_changed (AnjutaDockPane *pane)
119 static void
120 anjuta_dock_pane_multiple_selection_changed (AnjutaDockPane *pane)
124 static void
125 anjuta_dock_pane_class_init (AnjutaDockPaneClass *klass)
127 GObjectClass* object_class = G_OBJECT_CLASS (klass);
128 GParamSpec *param_spec;
130 object_class->finalize = anjuta_dock_pane_finalize;
131 object_class->set_property = anjuta_dock_pane_set_property;
132 object_class->get_property = anjuta_dock_pane_get_property;
133 klass->refresh = NULL;
134 klass->get_widget = NULL;
135 klass->single_selection_changed = anjuta_dock_pane_single_selection_changed;
136 klass->multiple_selection_changed = anjuta_dock_pane_multiple_selection_changed;
138 param_spec = g_param_spec_object ("plugin", "Plugin",
139 "Plugin object associated with this pane.",
140 ANJUTA_TYPE_PLUGIN,
141 G_PARAM_READWRITE);
142 g_object_class_install_property (object_class, ANJUTA_DOCK_PANE_PLUGIN,
143 param_spec);
145 /**
146 * AnjutaDockPane::single-selection-changed:
147 * @pane: An AnjutaDockPane
149 * This signal is emitted by pane subclasses to notify clients that
150 * the user has selected an item. This signal should be used when users are
151 * expected to only select one item at a time.
153 anjuta_dock_pane_signals[SINGLE_SELECTION_CHANGED] =
154 g_signal_new ("single-selection-changed",
155 G_OBJECT_CLASS_TYPE (klass),
156 G_SIGNAL_RUN_FIRST,
157 G_STRUCT_OFFSET (AnjutaDockPaneClass, single_selection_changed),
158 NULL,
159 NULL,
160 g_cclosure_marshal_VOID__VOID,
161 G_TYPE_NONE,
165 * AnjutaDockPane::multiple-selection-changed:
166 * @pane: An AnjutaDockPane
168 * This signal is emitted by pane subclasses to notify clients that the set
169 * of selected items in the pane has changed.
171 anjuta_dock_pane_signals[MULTIPLE_SELECTION_CHANGED] =
172 g_signal_new ("multiple-selection-changed",
173 G_OBJECT_CLASS_TYPE (klass),
174 G_SIGNAL_RUN_FIRST,
175 G_STRUCT_OFFSET (AnjutaDockPaneClass, multiple_selection_changed),
176 NULL,
177 NULL,
178 g_cclosure_marshal_VOID__VOID,
179 G_TYPE_NONE,
185 * anjuta_dock_pane_refresh:
186 * @self: An AnjutaDockPane
188 * Refreshes the given pane. Subclasses only need to override this method if
189 * needed.
191 void
192 anjuta_dock_pane_refresh (AnjutaDockPane *self)
194 AnjutaDockPaneClass *klass;
196 klass = ANJUTA_DOCK_PANE_GET_CLASS (self);
198 if (klass->refresh)
199 klass->refresh (self);
203 * anjuta_dock_pane_get_widget:
204 * @self: An AnjutaDockPane
206 * Returns: The widget associated with the given pane. The returned widget is
207 * owned by the pane and should not be destroyed or modified.
209 GtkWidget *
210 anjuta_dock_pane_get_widget (AnjutaDockPane *self)
212 return ANJUTA_DOCK_PANE_GET_CLASS (self)->get_widget (self);
217 * anjuta_dock_pane_get_plugin:
218 * @self: An AnjutaDockPane
220 * Returns: The plugin object associated with this pane.
222 AnjutaPlugin *
223 anjuta_dock_pane_get_plugin (AnjutaDockPane *self)
225 return self->priv->plugin;
229 * anjuta_dock_pane_notify_single_selection_changed:
230 * @self: An AnjutaDockPane
232 * Emits the single-selection-changed signal.
234 void
235 anjuta_dock_pane_notify_single_selection_changed (AnjutaDockPane *self)
237 g_signal_emit_by_name (self, "single-selection-changed", NULL);
241 * anjuta_dock_pane_notify_multiple_selection_changed:
242 * @self: An AnjutaDockPane
244 * Emits the multiple-selection-changed signal.
246 void
247 anjuta_dock_pane_notify_multiple_selection_changed (AnjutaDockPane *self)
249 g_signal_emit_by_name (self, "multiple-selection-changed", NULL);