1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2010 <jrliggett@cox.net>
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"
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
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.
38 ANJUTA_DOCK_PANE_PLUGIN
= 1
43 SINGLE_SELECTION_CHANGED
,
44 MULTIPLE_SELECTION_CHANGED
,
49 static guint anjuta_dock_pane_signals
[LAST_SIGNAL
] = { 0 };
51 struct _AnjutaDockPanePriv
56 G_DEFINE_ABSTRACT_TYPE (AnjutaDockPane
, anjuta_dock_pane
, G_TYPE_OBJECT
);
59 anjuta_dock_pane_init (AnjutaDockPane
*self
)
61 self
->priv
= g_new0 (AnjutaDockPanePriv
, 1);
65 anjuta_dock_pane_finalize (GObject
*object
)
69 self
= ANJUTA_DOCK_PANE (object
);
73 G_OBJECT_CLASS (anjuta_dock_pane_parent_class
)->finalize (object
);
77 anjuta_dock_pane_set_property (GObject
*object
, guint property_id
,
78 const GValue
*value
, GParamSpec
*param_spec
)
82 self
= ANJUTA_DOCK_PANE (object
);
86 case ANJUTA_DOCK_PANE_PLUGIN
:
87 self
->priv
->plugin
= ANJUTA_PLUGIN (g_value_get_object (value
));
90 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, param_spec
);
96 anjuta_dock_pane_get_property (GObject
*object
, guint property_id
,
97 GValue
*value
, GParamSpec
*param_spec
)
101 self
= ANJUTA_DOCK_PANE (object
);
105 case ANJUTA_DOCK_PANE_PLUGIN
:
106 g_value_set_object (value
, self
->priv
->plugin
);
109 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, param_spec
);
115 anjuta_dock_pane_single_selection_changed (AnjutaDockPane
*pane
)
120 anjuta_dock_pane_multiple_selection_changed (AnjutaDockPane
*pane
)
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.",
142 g_object_class_install_property (object_class
, ANJUTA_DOCK_PANE_PLUGIN
,
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
),
157 G_STRUCT_OFFSET (AnjutaDockPaneClass
, single_selection_changed
),
160 g_cclosure_marshal_VOID__VOID
,
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
),
175 G_STRUCT_OFFSET (AnjutaDockPaneClass
, multiple_selection_changed
),
178 g_cclosure_marshal_VOID__VOID
,
185 * anjuta_dock_pane_refresh:
186 * @self: An AnjutaDockPane
188 * Refreshes the given pane. Subclasses only need to override this method if
192 anjuta_dock_pane_refresh (AnjutaDockPane
*self
)
194 AnjutaDockPaneClass
*klass
;
196 klass
= ANJUTA_DOCK_PANE_GET_CLASS (self
);
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.
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.
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.
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.
247 anjuta_dock_pane_notify_multiple_selection_changed (AnjutaDockPane
*self
)
249 g_signal_emit_by_name (self
, "multiple-selection-changed", NULL
);