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/anjuta-encodings.h>
25 #include <libanjuta/interfaces/ianjuta-document-manager.h>
26 #include <libanjuta/interfaces/ianjuta-file.h>
27 #include <libanjuta/interfaces/ianjuta-file-savable.h>
28 #include <libanjuta/interfaces/ianjuta-editor-factory.h>
29 #include <libanjuta/interfaces/ianjuta-preferences.h>
35 #include "style-editor.h"
36 #include "text_editor.h"
38 #define PREFS_GLADE PACKAGE_DATA_DIR"/glade/anjuta-editor-scintilla.glade"
39 #define ICON_FILE "anjuta-editor-scintilla-plugin-48.png"
41 gpointer parent_class
;
44 on_style_button_clicked(GtkWidget
* button
, AnjutaPreferences
* prefs
)
46 StyleEditor
* se
= style_editor_new(prefs
);
47 style_editor_show(se
);
51 activate_plugin (AnjutaPlugin
*plugin
)
57 deactivate_plugin (AnjutaPlugin
*plugin
)
64 dispose (GObject
*obj
)
66 /* EditorPlugin *eplugin = ANJUTA_PLUGIN_EDITOR (obj); */
68 G_OBJECT_CLASS (parent_class
)->dispose (obj
);
72 finalize (GObject
*obj
)
74 /* Finalization codes here */
75 G_OBJECT_CLASS (parent_class
)->finalize (obj
);
79 editor_plugin_instance_init (GObject
*obj
)
81 /* EditorPlugin *plugin = ANJUTA_PLUGIN_EDITOR (obj); */
85 editor_plugin_class_init (GObjectClass
*klass
)
87 AnjutaPluginClass
*plugin_class
= ANJUTA_PLUGIN_CLASS (klass
);
89 parent_class
= g_type_class_peek_parent (klass
);
91 plugin_class
->activate
= activate_plugin
;
92 plugin_class
->deactivate
= deactivate_plugin
;
93 klass
->dispose
= dispose
;
94 klass
->finalize
= finalize
;
98 itext_editor_factory_new_editor(IAnjutaEditorFactory
* factory
,
100 const gchar
* filename
,
103 AnjutaShell
*shell
= ANJUTA_PLUGIN (factory
)->shell
;
104 AnjutaPreferences
*prefs
= anjuta_shell_get_preferences (shell
, NULL
);
105 AnjutaStatus
*status
= anjuta_shell_get_status (shell
, NULL
);
106 gchar
* uri
= g_file_get_uri (file
);
107 IAnjutaEditor
* editor
= IANJUTA_EDITOR(text_editor_new(status
, prefs
,
114 itext_editor_factory_iface_init (IAnjutaEditorFactoryIface
*iface
)
116 iface
->new_editor
= itext_editor_factory_new_editor
;
120 ipreferences_merge(IAnjutaPreferences
* ipref
, AnjutaPreferences
* prefs
, GError
** e
)
123 EditorPlugin
* plugin
= ANJUTA_PLUGIN_EDITOR (ipref
);
124 gxml
= glade_xml_new (PREFS_GLADE
, "preferences_dialog", NULL
);
125 plugin
->style_button
= glade_xml_get_widget(gxml
, "style_button");
126 g_signal_connect(G_OBJECT(plugin
->style_button
), "clicked",
127 G_CALLBACK(on_style_button_clicked
), prefs
);
128 anjuta_preferences_add_page (prefs
,
129 gxml
, "Editor", _("Scintilla Editor"), ICON_FILE
);
130 g_object_unref(gxml
);
134 ipreferences_unmerge(IAnjutaPreferences
* ipref
, AnjutaPreferences
* prefs
, GError
** e
)
136 EditorPlugin
* plugin
= ANJUTA_PLUGIN_EDITOR (ipref
);
137 g_signal_handlers_disconnect_by_func(G_OBJECT(plugin
->style_button
),
138 G_CALLBACK(on_style_button_clicked
),
139 anjuta_shell_get_preferences(ANJUTA_PLUGIN(plugin
)->shell
, NULL
));
141 anjuta_preferences_remove_page(prefs
, _("Scintilla Editor"));
145 ipreferences_iface_init(IAnjutaPreferencesIface
* iface
)
147 iface
->merge
= ipreferences_merge
;
148 iface
->unmerge
= ipreferences_unmerge
;
151 ANJUTA_PLUGIN_BEGIN (EditorPlugin
, editor_plugin
);
152 ANJUTA_TYPE_ADD_INTERFACE(itext_editor_factory
, IANJUTA_TYPE_EDITOR_FACTORY
);
153 ANJUTA_TYPE_ADD_INTERFACE(ipreferences
, IANJUTA_TYPE_PREFERENCES
);
156 ANJUTA_SIMPLE_PLUGIN (EditorPlugin
, editor_plugin
);