1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 Copyright (C) 2000 Naba Kumar
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <libanjuta/anjuta-shell.h>
23 #include <libanjuta/anjuta-debug.h>
24 #include <libanjuta/interfaces/ianjuta-document-manager.h>
28 #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-sample.ui"
30 static gpointer parent_class
;
33 on_sample_action_activate (GtkAction
*action
, SamplePlugin
*plugin
)
36 IAnjutaDocument
*editor
;
37 IAnjutaDocumentManager
*docman
;
39 /* Query for object implementing IAnjutaDocumentManager interface */
40 obj
= anjuta_shell_get_object (ANJUTA_PLUGIN (plugin
)->shell
,
41 "IAnjutaDocumentManager", NULL
);
42 docman
= IANJUTA_DOCUMENT_MANAGER (obj
);
43 editor
= ianjuta_document_manager_get_current_document (docman
, NULL
);
45 /* Do whatever with plugin */
46 anjuta_util_dialog_info (GTK_WINDOW (ANJUTA_PLUGIN (plugin
)->shell
),
47 "Document manager pointer is: '0x%X'\n"
48 "Current Editor pointer is: 0x%X", docman
,
52 static GtkActionEntry actions_file
[] = {
54 "ActionFileSample", /* Action name */
55 GTK_STOCK_NEW
, /* Stock icon, if any */
56 N_("_Sample action"), /* Display label */
58 N_("Sample action"), /* Tooltip */
59 G_CALLBACK (on_sample_action_activate
) /* action callback */
64 sample_plugin_activate_plugin (AnjutaPlugin
*plugin
)
68 SamplePlugin
*sample_plugin
;
70 DEBUG_PRINT ("SamplePlugin: Activating Sample plugin ...");
71 sample_plugin
= ANJUTA_PLUGIN_SAMPLE (plugin
);
73 ui
= anjuta_shell_get_ui (plugin
->shell
, NULL
);
74 wid
= gtk_label_new ("This is a sample plugin");
75 sample_plugin
->widget
= wid
;
77 /* Add all our editor actions */
78 anjuta_ui_add_action_group_entries (ui
, "ActionGroupSampleFile",
79 _("Sample file operations"),
81 G_N_ELEMENTS (actions_file
),
82 GETTEXT_PACKAGE
, TRUE
, plugin
);
83 sample_plugin
->uiid
= anjuta_ui_merge (ui
, UI_FILE
);
84 anjuta_shell_add_widget (plugin
->shell
, wid
,
85 "AnjutaSamplePlugin", _("SamplePlugin"), NULL
,
86 ANJUTA_SHELL_PLACEMENT_BOTTOM
, NULL
);
91 sample_plugin_deactivate_plugin (AnjutaPlugin
*plugin
)
93 AnjutaUI
*ui
= anjuta_shell_get_ui (plugin
->shell
, NULL
);
94 DEBUG_PRINT ("SamplePlugin: Dectivating Sample plugin ...");
95 anjuta_shell_remove_widget (plugin
->shell
, ANJUTA_PLUGIN_SAMPLE (plugin
)->widget
,
97 anjuta_ui_unmerge (ui
, ANJUTA_PLUGIN_SAMPLE (plugin
)->uiid
);
102 sample_plugin_finalize (GObject
*obj
)
104 /* Finalization codes here */
105 G_OBJECT_CLASS (parent_class
)->finalize (obj
);
109 sample_plugin_dispose (GObject
*obj
)
111 /* Disposition codes */
112 G_OBJECT_CLASS (parent_class
)->dispose (obj
);
116 anjuta_sample_plugin_instance_init (GObject
*obj
)
118 SamplePlugin
*plugin
= ANJUTA_PLUGIN_SAMPLE (obj
);
123 anjuta_sample_plugin_class_init (GObjectClass
*klass
)
125 AnjutaPluginClass
*plugin_class
= ANJUTA_PLUGIN_CLASS (klass
);
127 parent_class
= g_type_class_peek_parent (klass
);
129 plugin_class
->activate
= sample_plugin_activate_plugin
;
130 plugin_class
->deactivate
= sample_plugin_deactivate_plugin
;
131 klass
->finalize
= sample_plugin_finalize
;
132 klass
->dispose
= sample_plugin_dispose
;
135 ANJUTA_PLUGIN_BOILERPLATE (SamplePlugin
, anjuta_sample_plugin
);
136 ANJUTA_SIMPLE_PLUGIN (SamplePlugin
, anjuta_sample_plugin
);