Added initial Spanish translation
[anjuta-git-plugin.git] / libanjuta / anjuta-shell.c
blobd317dce5b9df5d8be6139fc10ebe01fbafd733d5
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta-shell.c
4 * Copyright (C) Naba Kumar <naba@gnome.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /**
22 * SECTION:anjuta-shell
23 * @title: AnjutaShell
24 * @short_description: Application shell interface
25 * @see_also:
26 * @stability: Unstable
27 * @include: libanjuta/anjuta-shell.h
29 * Shell is the playground where plugins are loaded and their UI
30 * widgets shown. It is also a place where plugins export objects for letting
31 * other pluings to use. Plugins are loaded into shell on demand, but some
32 * plugins are loaded on startup (such as help and text editor plugin).
33 * Demand to load a plugin can be made by requesting for a primary inferface
34 * using anjuta_shell_get_interface() or anjuta_shell_get_object().
36 * Plugins can add widgets in shell with
37 * anjuta_shell_add_widget() and remove with anjuta_shell_remove_widget()
38 * functions.
40 * In Anjuta, shell is implemented using an advanced widget docking system,
41 * allowing plugin widgets to dock, undock and layout in any fashion. Dock
42 * layout is also maintained internally and is transparent to plugin
43 * implementations.
45 * #AnjutaShell allows plugins to export arbitrary objects as <emphasis>
46 * values</emphasis> in its <emphasis>Values System</emphasis>. "value_added"
47 * and "value_removed" signals are emitted when a value is added to or
48 * removed from the <emphasis>Values System</emphasis>, hence notifying
49 * plugins of its state. However, plugins should really not connect directly
50 * to these signals, because they are emitted for all values
51 * and not just for the values the plugin is interested in. Instead,
52 * to monitor specific <emphasis>Values</emphasis>, plugins should
53 * setup watches using anjuta_plugin_add_watch().
55 * <emphasis>Values</emphasis> are added, get or removed with
56 * anjuta_shell_add_value() and anjuta_shell_get_value() or
57 * anjuta_shell_remove_value(). There multi-valued equivalent functions
58 * can be used to manipulate multiple values at once.
60 * <emphasis>Values</emphasis> are identified with names. Since <emphasis>
61 * Values</emphasis> are effectively variables, their names should follow
62 * the standard GNOME variable naming convention and should be as descriptive
63 * as possible (e.g project_root_directory, project_name etc.). It is also
64 * essential that meaningful prefix be given to names so that <emphasis>
65 * Values</emphasis> are easily grouped (e.g all values exported by a
66 * project manager should start with project_ prefix).
68 * Plugins can find other plugins with anjuta_shell_get_object() or
69 * anjuta_shell_get_interface() based on their primary interfaces.
72 #include <config.h>
73 #include <string.h>
74 #include <gobject/gvaluecollector.h>
75 #include "anjuta-shell.h"
76 #include "anjuta-marshal.h"
77 #include "anjuta-debug.h"
79 typedef struct {
80 GtkWidget *widget;
81 gchar *name;
82 gchar *title;
83 gchar *stock_id;
84 AnjutaShellPlacement placement;
85 } WidgetQueueData;
87 static void
88 on_widget_data_free (WidgetQueueData *data)
90 g_object_unref (data->widget);
91 g_free (data->name);
92 g_free (data->title);
93 g_free (data->stock_id);
94 g_free (data);
97 static void
98 on_widget_data_add (WidgetQueueData *data, AnjutaShell *shell)
100 ANJUTA_SHELL_GET_IFACE (shell)->add_widget (shell, data->widget,
101 data->name,
102 data->title,
103 data->stock_id,
104 data->placement,
105 NULL);
108 static void
109 on_destroy_widget_queue (gpointer data)
111 GQueue *queue = (GQueue*)data;
112 g_queue_foreach (queue, (GFunc)on_widget_data_free, NULL);
113 g_queue_free (queue);
116 GQuark
117 anjuta_shell_error_quark (void)
119 static GQuark quark = 0;
121 if (quark == 0) {
122 quark = g_quark_from_static_string ("anjuta-shell-quark");
125 return quark;
129 * anjuta_shell_freeze:
130 * @shell: A #AnjutaShell interface.
131 * @error: Error propagation object.
133 * Freezes addition of any UI elements (widgets) in the shell. All widget
134 * additions are queued for later additions when freeze count reaches 0.
135 * Any number of this function can be called and each call will increase
136 * the freeze count. anjuta_shell_thaw() will reduce the freeze count by
137 * 1 and real thawing happens when the count reaches 0.
139 void
140 anjuta_shell_freeze (AnjutaShell *shell, GError **error)
142 gint freeze_count;
144 g_return_if_fail (shell != NULL);
145 freeze_count = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (shell),
146 "__freeze_count"));
147 freeze_count++;
148 g_object_set_data (G_OBJECT (shell), "__freeze_count",
149 GINT_TO_POINTER (freeze_count));
153 * anjuta_shell_thaw:
154 * @shell: A #AnjutaShell interface.
155 * @error: Error propagation object.
157 * Reduces the freeze count by one and performs pending widget additions
158 * when the count reaches 0.
160 void
161 anjuta_shell_thaw (AnjutaShell *shell, GError **error)
163 gint freeze_count;
165 g_return_if_fail (shell != NULL);
166 freeze_count = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (shell),
167 "__freeze_count"));
168 freeze_count--;
169 if (freeze_count < 0)
170 freeze_count = 0;
171 g_object_set_data (G_OBJECT (shell), "__freeze_count",
172 GINT_TO_POINTER (freeze_count));
174 if (freeze_count <= 0)
176 /* Add all pending widgets */
177 /* DEBUG_PRINT ("Thawing shell ..."); */
179 GQueue *queue;
180 queue = g_object_get_data (G_OBJECT (shell), "__widget_queue");
181 if (queue)
183 g_queue_reverse (queue);
184 g_queue_foreach (queue, (GFunc)on_widget_data_add, shell);
185 g_object_set_data (G_OBJECT (shell), "__widget_queue", NULL);
191 * anjuta_shell_add_widget:
192 * @shell: A #AnjutaShell interface.
193 * @widget: Then widget to add
194 * @name: Name of the widget. None translated string used to identify it in
195 * the shell.
196 * @stock_id: Icon stock ID. Could be null.
197 * @title: Translated string which is displayed along side the widget when
198 * required (eg. as window title or notebook tab label).
199 * @placement: Placement of the widget in shell.
200 * @error: Error propagation object.
202 * Adds @widget in the shell. The @placement tells where the widget should
203 * appear, but generally it will be overridden by the container
204 * (dock, notebook, GtkContainer etc.) saved layout.
206 void
207 anjuta_shell_add_widget (AnjutaShell *shell,
208 GtkWidget *widget,
209 const char *name,
210 const char *title,
211 const char *stock_id,
212 AnjutaShellPlacement placement,
213 GError **error)
215 GQueue *widget_queue;
216 gint freeze_count;
218 g_return_if_fail (shell != NULL);
219 g_return_if_fail (ANJUTA_IS_SHELL (shell));
220 g_return_if_fail (widget != NULL);
221 g_return_if_fail (GTK_IS_WIDGET (widget));
222 g_return_if_fail (name != NULL);
223 g_return_if_fail (title != NULL);
225 freeze_count = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (shell),
226 "__freeze_count"));
227 if (freeze_count <= 0)
229 ANJUTA_SHELL_GET_IFACE (shell)->add_widget (shell, widget, name,
230 title, stock_id,
231 placement, error);
233 else
235 /* Queue the operation */
236 WidgetQueueData *qd;
238 widget_queue = g_object_get_data (G_OBJECT (shell), "__widget_queue");
239 if (!widget_queue)
241 widget_queue = g_queue_new ();
242 g_object_set_data_full (G_OBJECT (shell), "__widget_queue",
243 widget_queue, on_destroy_widget_queue);
245 qd = g_new0(WidgetQueueData, 1);
246 g_object_ref (G_OBJECT (widget));
247 qd->widget = widget;
248 qd->name = g_strdup (name);
249 qd->title = g_strdup (title);
250 if (stock_id)
251 qd->stock_id = g_strdup (stock_id);
252 qd->placement = placement;
254 g_queue_push_head (widget_queue, qd);
259 * anjuta_shell_remove_widget:
260 * @shell: A #AnjutaShell interface
261 * @widget: The widget to remove
262 * @error: Error propagation object
264 * Removes the widget from shell. The widget should have been added before
265 * with #anjuta_shell_add_widget.
267 void
268 anjuta_shell_remove_widget (AnjutaShell *shell,
269 GtkWidget *widget,
270 GError **error)
272 GQueue *queue;
273 gboolean found_in_queue;
275 g_return_if_fail (shell != NULL);
276 g_return_if_fail (ANJUTA_IS_SHELL (shell));
277 g_return_if_fail (widget != NULL);
278 g_return_if_fail (GTK_IS_WIDGET (widget));
280 /* If there is a queue, remove widgets from it */
281 found_in_queue = FALSE;
282 queue = g_object_get_data (G_OBJECT (shell), "__widget_queue");
283 if (queue)
285 gint i;
286 for (i = g_queue_get_length(queue) - 1; i >= 0; i--)
288 WidgetQueueData *qd;
290 qd = g_queue_peek_nth (queue, i);
291 if (qd->widget == widget)
293 g_queue_remove (queue, qd);
294 on_widget_data_free (qd);
295 found_in_queue = TRUE;
296 break;
300 if (!found_in_queue)
301 ANJUTA_SHELL_GET_IFACE (shell)->remove_widget (shell, widget, error);
305 * anjuta_shell_present_widget:
306 * @shell: A #AnjutaShell interface
307 * @widget: The widget to present
308 * @error: Error propagation object
310 * Make sure the widget is visible to user. If the widget is hidden, it will
311 * be shown. If it is not visible to user, it will be made visible.
313 void
314 anjuta_shell_present_widget (AnjutaShell *shell,
315 GtkWidget *widget,
316 GError **error)
318 GQueue *queue;
319 gboolean found_in_queue;
321 g_return_if_fail (shell != NULL);
322 g_return_if_fail (ANJUTA_IS_SHELL (shell));
323 g_return_if_fail (widget != NULL);
324 g_return_if_fail (GTK_IS_WIDGET (widget));
326 /* If there is a queue and the widget is in the queue, there is no
327 * way we can 'present' the widget */
328 found_in_queue = FALSE;
329 queue = g_object_get_data (G_OBJECT (shell), "__widget_queue");
330 if (queue)
332 gint i;
333 for (i = g_queue_get_length(queue) - 1; i >= 0; i--)
335 WidgetQueueData *qd;
337 qd = g_queue_peek_nth (queue, i);
338 if (qd->widget == widget)
340 found_in_queue = TRUE;
341 break;
345 if (!found_in_queue)
346 ANJUTA_SHELL_GET_IFACE (shell)->present_widget (shell, widget, error);
350 * anjuta_shell_add_value:
351 * @shell: A #AnjutaShell interface
352 * @name: Name of the value
353 * @value: Value to add
354 * @error: Error propagation object
356 * Sets a value in the shell with the given name. Any previous value will
357 * be overridden. "value_added" signal will be emitted. Objects connecting
358 * to this signal can then update their data according to the new value.
360 void
361 anjuta_shell_add_value (AnjutaShell *shell,
362 const char *name,
363 const GValue *value,
364 GError **error)
366 g_return_if_fail (shell != NULL);
367 g_return_if_fail (ANJUTA_IS_SHELL (shell));
368 g_return_if_fail (name != NULL);
369 g_return_if_fail (value != NULL);
371 ANJUTA_SHELL_GET_IFACE (shell)->add_value (shell, name, value, error);
375 * anjuta_shell_add_valist:
376 * @shell: A #AnjutaShell interface
377 * @first_name: First value name
378 * @first_type: First value type
379 * @var_args: First value, Second value name, Second value type ....
381 * Adds a valist of values in the shell. The valist should be in the order -
382 * value1, name2, type2, value2,... "value_added" signal will be emitted
383 * for each of the value.
385 void
386 anjuta_shell_add_valist (AnjutaShell *shell,
387 const char *first_name,
388 GType first_type,
389 va_list var_args)
391 const char *name;
392 GType type;
394 g_return_if_fail (shell != NULL);
395 g_return_if_fail (ANJUTA_IS_SHELL (shell));
396 g_return_if_fail (first_name != NULL);
398 name = first_name;
399 type = first_type;
401 while (name) {
402 GValue value = {0, };
403 GError *err = NULL;
404 char *error;
406 g_value_init (&value, type);
408 G_VALUE_COLLECT (&value, var_args, 0, &error);
410 if (error){
411 g_warning ("%s: %s", G_STRLOC, error);
412 g_free (error);
413 break;
416 anjuta_shell_add_value (shell, name, &value, &err);
418 g_value_unset (&value);
420 if (err) {
421 g_warning ("Could not set value: %s\n", err->message);
422 g_error_free (err);
423 break;
426 name = va_arg (var_args, char *);
427 if (name) {
428 type = va_arg (var_args, GType);
434 * anjuta_shell_add:
435 * @shell: A #AnjutaShell interface
436 * @first_name: First value name
437 * @first_type: First value type
438 * @...: First value, Second value name, Second value type .... NULL
440 * Adds a list of values in the shell. The list should be NULL terminated
441 * and should be in the order - name1, type1, value1, name2, type2, value2,
442 * ..., NULL. "value_added" signal will be emitted for each of the value.
444 void
445 anjuta_shell_add (AnjutaShell *shell,
446 const char *first_name,
447 GType first_type,
448 ...)
450 va_list var_args;
452 g_return_if_fail (shell != NULL);
453 g_return_if_fail (ANJUTA_IS_SHELL (shell));
454 g_return_if_fail (first_name != NULL);
456 va_start (var_args, first_type);
457 anjuta_shell_add_valist (shell, first_name, first_type, var_args);
458 va_end (var_args);
462 * anjuta_shell_get_value:
463 * @shell: A #AnjutaShell interface
464 * @name: Name of the value to get
465 * @value: Value to get
466 * @error: Error propagation object
468 * Gets a value from the shell with the given name. The value will be set
469 * in the passed value pointer.
471 void
472 anjuta_shell_get_value (AnjutaShell *shell,
473 const char *name,
474 GValue *value,
475 GError **error)
477 g_return_if_fail (shell != NULL);
478 g_return_if_fail (ANJUTA_IS_SHELL (shell));
479 g_return_if_fail (name != NULL);
480 g_return_if_fail (value != NULL);
482 ANJUTA_SHELL_GET_IFACE (shell)->get_value (shell, name, value, error);
486 * anjuta_shell_get_valist:
487 * @shell: A #AnjutaShell interface
488 * @first_name: First value name
489 * @first_type: First value type
490 * @var_args: First value holder, Second value name, Second value type ....
492 * Gets a valist of values from the shell. The valist should be in the order -
493 * value1, name2, type2, value2,...
495 void
496 anjuta_shell_get_valist (AnjutaShell *shell,
497 const char *first_name,
498 GType first_type,
499 va_list var_args)
501 const char *name;
502 GType type;
504 g_return_if_fail (shell != NULL);
505 g_return_if_fail (ANJUTA_IS_SHELL (shell));
506 g_return_if_fail (first_name != NULL);
508 name = first_name;
509 type = first_type;
511 while (name) {
512 GValue value = {0, };
513 GError *err = NULL;
514 char *error;
516 g_value_init (&value, type);
518 anjuta_shell_get_value (shell, name, &value, &err);
520 if (err) {
521 g_warning ("Could not get value: %s", err->message);
522 g_error_free (err);
523 break;
526 G_VALUE_LCOPY (&value, var_args, 0, &error);
528 if (error){
529 g_warning ("%s: %s", G_STRLOC, error);
530 g_free (error);
531 break;
534 g_value_unset (&value);
536 name = va_arg (var_args, char *);
537 if (name) {
538 type = va_arg (var_args, GType);
544 * anjuta_shell_get:
545 * @shell: A #AnjutaShell interface
546 * @first_name: First value name
547 * @first_type: First value type
548 * @...: First value holder, Second value name, Second value type .... NULL
550 * Gets a list of values in the shell. The list should be NULL terminated
551 * and should be in the order - name1, type1, value1, name2, type2, value2,
552 * ..., NULL.
554 void
555 anjuta_shell_get (AnjutaShell *shell,
556 const char *first_name,
557 GType first_type,
558 ...)
560 va_list var_args;
562 g_return_if_fail (shell != NULL);
563 g_return_if_fail (ANJUTA_IS_SHELL (shell));
564 g_return_if_fail (first_name != NULL);
566 va_start (var_args, first_type);
567 anjuta_shell_get_valist (shell, first_name, first_type, var_args);
568 va_end (var_args);
572 * anjuta_shell_remove_value:
573 * @shell: A #AnjutaShell interface
574 * @name: Name of the value to remove
575 * @error: Error propagation object
577 * Removes a value from the shell with the given name. "value_removed" signal
578 * will be emitted. Objects connecting to this signal can then update their
579 * data/internal-state accordingly.
581 void
582 anjuta_shell_remove_value (AnjutaShell *shell,
583 const char *name,
584 GError **error)
586 g_return_if_fail (shell != NULL);
587 g_return_if_fail (ANJUTA_IS_SHELL (shell));
588 g_return_if_fail (name != NULL);
590 ANJUTA_SHELL_GET_IFACE (shell)->remove_value (shell, name, error);
594 * anjuta_shell_get_object:
595 * @shell: A #AnjutaShell interface
596 * @iface_name: The interface implemented by the object to be found
597 * @error: Error propagation.
599 * Searches the currently available plugins to find the one which
600 * implements the given interface as primary interface and returns it. If
601 * the plugin is not yet loaded, it will be loaded and activated.
602 * The returned object is garanteed to be an implementor of the
603 * interface (as exported by the plugin metafile). It only searches
604 * from the pool of plugin objects loaded in this shell and can only search
605 * by primary interface. If there are more objects implementing this primary
606 * interface, user might be prompted to select one from them (and might give
607 * the option to use it as default for future queries). A typical usage of this
608 * function is:
609 * <programlisting>
610 * GObject *docman =
611 * anjuta_plugins_get_object (shell, "IAnjutaDocumentManager", error);
612 * </programlisting>
613 * Notice that this function takes the interface name string as string, unlike
614 * anjuta_plugins_get_interface() which takes the type directly.
616 * Return value: A plugin object implementing the primary interface or NULL.
618 GObject*
619 anjuta_shell_get_object (AnjutaShell *shell, const gchar *iface_name,
620 GError **error)
622 g_return_val_if_fail (shell != NULL, NULL);
623 g_return_val_if_fail (iface_name != NULL, NULL);
624 g_return_val_if_fail (ANJUTA_IS_SHELL (shell), NULL);
626 return ANJUTA_SHELL_GET_IFACE (shell)->get_object (shell, iface_name, error);
630 * anjuta_shell_get_status:
631 * @shell: A #AnjutaShell interface
632 * @error: Error propagation object
634 * Retrieves the #AnjutaStatus object associated with the shell.
636 * Return value: The #AnjutaStatus object.
638 AnjutaStatus*
639 anjuta_shell_get_status (AnjutaShell *shell, GError **error)
641 g_return_val_if_fail (shell != NULL, NULL);
642 g_return_val_if_fail (ANJUTA_IS_SHELL (shell), NULL);
644 return ANJUTA_SHELL_GET_IFACE (shell)->get_status (shell, error);
648 * anjuta_shell_get_ui:
649 * @shell: A #AnjutaShell interface
650 * @error: Error propagation object
652 * Retrieves the #AnjutaUI object associated with the shell.
654 * Return value: The #AnjutaUI object.
656 AnjutaUI*
657 anjuta_shell_get_ui (AnjutaShell *shell, GError **error)
659 g_return_val_if_fail (shell != NULL, NULL);
660 g_return_val_if_fail (ANJUTA_IS_SHELL (shell), NULL);
662 return ANJUTA_SHELL_GET_IFACE (shell)->get_ui (shell, error);
666 * anjuta_shell_get_preferences:
667 * @shell: A #AnjutaShell interface
668 * @error: Error propagation object
670 * Retrieves the #AnjutaPreferences object associated with the shell.
672 * Return value: The #AnjutaPreferences object.
674 AnjutaPreferences*
675 anjuta_shell_get_preferences (AnjutaShell *shell, GError **error)
677 g_return_val_if_fail (shell != NULL, NULL);
678 g_return_val_if_fail (ANJUTA_IS_SHELL (shell), NULL);
680 return ANJUTA_SHELL_GET_IFACE (shell)->get_preferences (shell, error);
684 * anjuta_shell_get_plugin_manager:
685 * @shell: A #AnjutaShell interface
686 * @error: Error propagation object
688 * Retrieves the #AnjutaPluginManager object associated with the shell.
690 * Return value: The #AnjutaPluginManager object.
692 AnjutaPluginManager*
693 anjuta_shell_get_plugin_manager (AnjutaShell *shell, GError **error)
695 g_return_val_if_fail (shell != NULL, NULL);
696 g_return_val_if_fail (ANJUTA_IS_SHELL (shell), NULL);
698 return ANJUTA_SHELL_GET_IFACE (shell)->get_plugin_manager (shell, error);
702 * anjuta_shell_get_profile_manager:
703 * @shell: A #AnjutaShell interface
704 * @error: Error propagation object
706 * Retrieves the #AnjutaProfileManager object associated with the shell.
708 * Return value: The #AnjutaProfileManager object.
710 AnjutaProfileManager*
711 anjuta_shell_get_profile_manager (AnjutaShell *shell, GError **error)
713 g_return_val_if_fail (shell != NULL, NULL);
714 g_return_val_if_fail (ANJUTA_IS_SHELL (shell), NULL);
716 return ANJUTA_SHELL_GET_IFACE (shell)->get_profile_manager (shell, error);
719 void
720 anjuta_shell_session_save (AnjutaShell *shell, const gchar *session_directory,
721 GError **error)
723 AnjutaSession *session;
725 g_return_if_fail (ANJUTA_IS_SHELL (shell));
726 g_return_if_fail (session_directory != NULL);
728 session = anjuta_session_new (session_directory);
729 anjuta_session_clear (session);
730 g_signal_emit_by_name (G_OBJECT (shell), "save_session",
731 ANJUTA_SESSION_PHASE_FIRST, session);
732 g_signal_emit_by_name (G_OBJECT (shell), "save_session",
733 ANJUTA_SESSION_PHASE_NORMAL, session);
734 g_signal_emit_by_name (G_OBJECT (shell), "save_session",
735 ANJUTA_SESSION_PHASE_LAST, session);
736 anjuta_session_sync (session);
737 g_object_unref (session);
740 void
741 anjuta_shell_session_load (AnjutaShell *shell, const gchar *session_directory,
742 GError **error)
744 AnjutaSession *session;
746 g_return_if_fail (ANJUTA_IS_SHELL (shell));
747 g_return_if_fail (session_directory != NULL);
749 /* Do not allow multiple session loadings at once. Could be a trouble */
750 if (g_object_get_data (G_OBJECT (shell), "__session_loading"))
752 /* DEBUG_PRINT ("A session load is requested in the middle of another!!"); */
753 return;
755 g_object_set_data (G_OBJECT (shell), "__session_loading", "1");
757 session = anjuta_session_new (session_directory);
758 g_signal_emit_by_name (G_OBJECT (shell), "load_session",
759 ANJUTA_SESSION_PHASE_FIRST, session);
760 g_signal_emit_by_name (G_OBJECT (shell), "load_session",
761 ANJUTA_SESSION_PHASE_NORMAL, session);
762 g_signal_emit_by_name (G_OBJECT (shell), "load_session",
763 ANJUTA_SESSION_PHASE_LAST, session);
764 g_object_unref (session);
766 g_object_set_data (G_OBJECT (shell), "__session_loading", NULL);
769 void
770 anjuta_shell_save_prompt (AnjutaShell *shell,
771 AnjutaSavePrompt *save_prompt,
772 GError **error)
774 g_return_if_fail (ANJUTA_IS_SHELL (shell));
775 g_return_if_fail (ANJUTA_IS_SAVE_PROMPT (save_prompt));
776 g_signal_emit_by_name (shell, "save-prompt", save_prompt);
779 void
780 anjuta_shell_notify_exit (AnjutaShell *shell,
781 GError **error)
783 g_return_if_fail (ANJUTA_IS_SHELL (shell));
784 g_signal_emit_by_name (shell, "exiting");
787 static void
788 anjuta_shell_base_init (gpointer gclass)
790 static gboolean initialized = FALSE;
792 if (!initialized) {
793 g_signal_new ("value-added",
794 ANJUTA_TYPE_SHELL,
795 G_SIGNAL_RUN_LAST,
796 G_STRUCT_OFFSET (AnjutaShellIface, value_added),
797 NULL, NULL,
798 anjuta_cclosure_marshal_VOID__STRING_BOXED,
799 G_TYPE_NONE, 2,
800 G_TYPE_STRING, G_TYPE_VALUE);
802 g_signal_new ("value-removed",
803 ANJUTA_TYPE_SHELL,
804 G_SIGNAL_RUN_LAST,
805 G_STRUCT_OFFSET (AnjutaShellIface, value_removed),
806 NULL, NULL,
807 anjuta_cclosure_marshal_VOID__STRING,
808 G_TYPE_NONE, 1,
809 G_TYPE_STRING);
810 g_signal_new ("save-session",
811 ANJUTA_TYPE_SHELL,
812 G_SIGNAL_RUN_LAST,
813 G_STRUCT_OFFSET (AnjutaShellIface, save_session),
814 NULL, NULL,
815 anjuta_cclosure_marshal_VOID__INT_OBJECT,
816 G_TYPE_NONE, 2,
817 G_TYPE_INT,
818 G_TYPE_OBJECT);
819 g_signal_new ("load-session",
820 ANJUTA_TYPE_SHELL,
821 G_SIGNAL_RUN_LAST,
822 G_STRUCT_OFFSET (AnjutaShellIface, load_session),
823 NULL, NULL,
824 anjuta_cclosure_marshal_VOID__INT_OBJECT,
825 G_TYPE_NONE, 2,
826 G_TYPE_INT,
827 G_TYPE_OBJECT);
828 g_signal_new ("save-prompt",
829 ANJUTA_TYPE_SHELL,
830 G_SIGNAL_RUN_LAST,
831 G_STRUCT_OFFSET (AnjutaShellIface, save_prompt),
832 NULL, NULL,
833 anjuta_cclosure_marshal_VOID__OBJECT,
834 G_TYPE_NONE, 1,
835 G_TYPE_OBJECT);
836 g_signal_new ("exiting",
837 ANJUTA_TYPE_SHELL,
838 G_SIGNAL_RUN_LAST,
839 G_STRUCT_OFFSET (AnjutaShellIface, exiting),
840 NULL, NULL,
841 anjuta_cclosure_marshal_VOID__VOID,
842 G_TYPE_NONE, 0);
843 initialized = TRUE;
847 GType
848 anjuta_shell_get_type (void)
850 static GType type = 0;
852 if (!type) {
853 static const GTypeInfo info = {
854 sizeof (AnjutaShellIface),
855 anjuta_shell_base_init,
856 NULL,
857 NULL,
858 NULL,
859 NULL,
862 NULL
865 type = g_type_register_static (G_TYPE_INTERFACE,
866 "AnjutaShell",
867 &info,
870 g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
873 return type;