Revision: 1659 http://svn.sourceforge.net/geany/?rev=1659&view=rev Author: ntrel Date: 2007-07-04 04:32:33 -0700 (Wed, 04 Jul 2007)
Log Message: ----------- Make Class Builder into a plugin. Add some function pointers to the plugin API (for the class builder). Don't use G_MODULE_BIND_LAZY when loading plugins otherwise we can potentially get unresolved symbols at runtime, causing a segfault. Capitalize 2 menu item labels.
Modified Paths: -------------- trunk/ChangeLog trunk/geany.glade trunk/plugins/Makefile.am trunk/po/POTFILES.in trunk/src/callbacks.c trunk/src/callbacks.h trunk/src/interface.c trunk/src/plugindata.h trunk/src/plugins.c trunk/src/templates.c trunk/src/templates.h trunk/src/tools.c trunk/src/tools.h
Added Paths: ----------- trunk/plugins/classbuilder.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-04 11:14:05 UTC (rev 1658) +++ trunk/ChangeLog 2007-07-04 11:32:33 UTC (rev 1659) @@ -1,3 +1,19 @@ +2007-07-04 Nick Treleaven nick.treleaven@btinternet.com + + * src/utils.c, src/utils.h: + Add comment for utils_free_pointers() warning not to use it if any + pointers may be NULL. + * plugins/Makefile.am, plugins/classbuilder.c, src/templates.c, + src/interface.c, src/templates.h, src/tools.c, src/tools.h, + src/plugindata.h, src/callbacks.c, src/callbacks.h, src/plugins.c, + po/POTFILES.in, geany.glade: + Make Class Builder into a plugin. + Add some function pointers to the plugin API (for the class builder). + Don't use G_MODULE_BIND_LAZY when loading plugins otherwise we can + potentially get unresolved symbols at runtime, causing a segfault. + Capitalize 2 menu item labels. + + 2007-07-02 Enrico Tröger enrico.troeger@uvena.de
* src/symbols.c, tagmanager/conf.c:
Modified: trunk/geany.glade =================================================================== --- trunk/geany.glade 2007-07-04 11:14:05 UTC (rev 1658) +++ trunk/geany.glade 2007-07-04 11:32:33 UTC (rev 1659) @@ -58,7 +58,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1776"> + <widget class="GtkImage" id="image1877"> <property name="visible">True</property> <property name="stock">gtk-new</property> <property name="icon_size">1</property> @@ -148,7 +148,7 @@ <signal name="activate" handler="on_save_all1_activate" last_modification_time="Thu, 02 Jun 2005 14:15:30 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1777"> + <widget class="GtkImage" id="image1878"> <property name="visible">True</property> <property name="stock">gtk-save</property> <property name="icon_size">1</property> @@ -169,7 +169,7 @@ <signal name="activate" handler="on_toolbutton23_clicked" last_modification_time="Mon, 24 Jul 2006 19:26:04 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1778"> + <widget class="GtkImage" id="image1879"> <property name="visible">True</property> <property name="stock">gtk-revert-to-saved</property> <property name="icon_size">1</property> @@ -189,7 +189,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1779"> + <widget class="GtkImage" id="image1880"> <property name="visible">True</property> <property name="stock">gtk-revert-to-saved</property> <property name="icon_size">1</property> @@ -285,7 +285,7 @@ <signal name="activate" handler="on_close_all1_activate" last_modification_time="Thu, 02 Jun 2005 14:15:30 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1780"> + <widget class="GtkImage" id="image1881"> <property name="visible">True</property> <property name="stock">gtk-close</property> <property name="icon_size">1</property> @@ -493,7 +493,7 @@ <signal name="activate" handler="on_menu_increase_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:28:54 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1781"> + <widget class="GtkImage" id="image1882"> <property name="visible">True</property> <property name="stock">gtk-indent</property> <property name="icon_size">1</property> @@ -514,7 +514,7 @@ <signal name="activate" handler="on_menu_decrease_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:28:54 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1782"> + <widget class="GtkImage" id="image1883"> <property name="visible">True</property> <property name="stock">gtk-unindent</property> <property name="icon_size">1</property> @@ -570,7 +570,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1783"> + <widget class="GtkImage" id="image1884"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -602,7 +602,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1784"> + <widget class="GtkImage" id="image1885"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -687,7 +687,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1785"> + <widget class="GtkImage" id="image1886"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -784,7 +784,7 @@ <signal name="activate" handler="on_replace1_activate" last_modification_time="Sun, 23 Oct 2005 13:22:36 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1786"> + <widget class="GtkImage" id="image1887"> <property name="visible">True</property> <property name="stock">gtk-find-and-replace</property> <property name="icon_size">1</property> @@ -850,7 +850,7 @@ <signal name="activate" handler="on_go_to_line1_activate" last_modification_time="Tue, 23 May 2006 17:10:49 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1787"> + <widget class="GtkImage" id="image1888"> <property name="visible">True</property> <property name="stock">gtk-jump-to</property> <property name="icon_size">1</property> @@ -874,7 +874,7 @@ <property name="use_underline">True</property>
<child> - <widget class="GtkMenu" id="menuitem3_menu"> + <widget class="GtkMenu" id="menu_view1_menu">
<child> <widget class="GtkImageMenuItem" id="menu_change_font1"> @@ -885,7 +885,7 @@ <signal name="activate" handler="on_change_font1_activate" last_modification_time="Fri, 22 Apr 2005 18:58:45 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1788"> + <widget class="GtkImage" id="image1889"> <property name="visible">True</property> <property name="stock">gtk-select-font</property> <property name="icon_size">1</property> @@ -907,7 +907,7 @@ <child> <widget class="GtkMenuItem" id="menu_toggle_all_additional_widgets1"> <property name="visible">True</property> - <property name="label" translatable="yes">Toggle all additional widgets</property> + <property name="label" translatable="yes">Toggle All Additional Widgets</property> <property name="use_underline">True</property> <signal name="activate" handler="on_menu_toggle_all_additional_widgets1_activate" last_modification_time="Sun, 06 May 2007 14:13:10 GMT"/> </widget> @@ -1021,7 +1021,7 @@ <property name="use_underline">True</property>
<child> - <widget class="GtkMenu" id="menu_item4_menu"> + <widget class="GtkMenu" id="menu_document1_menu">
<child> <widget class="GtkCheckMenuItem" id="menu_line_breaking1"> @@ -1245,7 +1245,7 @@ <signal name="activate" handler="on_project_new1_activate" last_modification_time="Thu, 18 Jan 2007 22:16:24 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1789"> + <widget class="GtkImage" id="image1890"> <property name="visible">True</property> <property name="stock">gtk-new</property> <property name="icon_size">1</property> @@ -1266,7 +1266,7 @@ <signal name="activate" handler="on_project_open1_activate" last_modification_time="Mon, 15 Jan 2007 17:34:17 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1790"> + <widget class="GtkImage" id="image1891"> <property name="visible">True</property> <property name="stock">gtk-open</property> <property name="icon_size">1</property> @@ -1287,7 +1287,7 @@ <signal name="activate" handler="on_project_close1_activate" last_modification_time="Mon, 15 Jan 2007 17:34:17 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1791"> + <widget class="GtkImage" id="image1892"> <property name="visible">True</property> <property name="stock">gtk-close</property> <property name="icon_size">1</property> @@ -1345,7 +1345,7 @@ <signal name="activate" handler="on_show_color_chooser1_activate" last_modification_time="Wed, 22 Jun 2005 18:10:21 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1792"> + <widget class="GtkImage" id="image1893"> <property name="visible">True</property> <property name="stock">gtk-select-color</property> <property name="icon_size">1</property> @@ -1376,49 +1376,6 @@ <signal name="activate" handler="on_menu_insert_special_chars1_activate" last_modification_time="Tue, 12 Dec 2006 22:03:01 GMT"/> </widget> </child> - - <child> - <widget class="GtkImageMenuItem" id="menu_create_class1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Create cla_ss</property> - <property name="use_underline">True</property> - - <child internal-child="image"> - <widget class="GtkImage" id="image1861"> - <property name="visible">True</property> - <property name="stock">gtk-add</property> - <property name="icon_size">1</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - - <child> - <widget class="GtkMenu" id="menu_create_class1_menu"> - - <child> - <widget class="GtkMenuItem" id="menu_create_cpp_class"> - <property name="visible">True</property> - <property name="label" translatable="yes">C++ class</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_menu_create_cpp_class_activate" last_modification_time="Mon, 11 Jun 2007 10:49:53 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menu_create_gtk_class"> - <property name="visible">True</property> - <property name="label" translatable="yes">GTK+ class</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_menu_create_gtk_class_activate" last_modification_time="Mon, 11 Jun 2007 10:50:17 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - </child> </widget> </child> </widget> @@ -1431,7 +1388,7 @@ <property name="use_underline">True</property>
<child> - <widget class="GtkMenu" id="menu_item5_menu"> + <widget class="GtkMenu" id="menu_help1_menu">
<child> <widget class="GtkImageMenuItem" id="help1"> @@ -2698,7 +2655,7 @@ <signal name="activate" handler="on_menu_increase_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:31:38 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1693"> + <widget class="GtkImage" id="image1894"> <property name="visible">True</property> <property name="stock">gtk-indent</property> <property name="icon_size">1</property> @@ -2719,7 +2676,7 @@ <signal name="activate" handler="on_menu_decrease_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:31:38 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1694"> + <widget class="GtkImage" id="image1895"> <property name="visible">True</property> <property name="stock">gtk-unindent</property> <property name="icon_size">1</property> @@ -2775,7 +2732,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1695"> + <widget class="GtkImage" id="image1896"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -2807,7 +2764,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1696"> + <widget class="GtkImage" id="image1897"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -2875,7 +2832,7 @@ <widget class="GtkMenuItem" id="insert_bsd_license_notice1"> <property name="visible">True</property> <property name="tooltip" translatable="yes">Inserts a BSD licence notice (should be done at the beginning of the file)</property> - <property name="label" translatable="yes">Insert BSD license Notice</property> + <property name="label" translatable="yes">Insert BSD License Notice</property> <property name="use_underline">True</property> <signal name="activate" handler="on_comments_bsd_activate" last_modification_time="Fri, 05 Jan 2007 13:32:16 GMT"/> </widget> @@ -2892,7 +2849,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1697"> + <widget class="GtkImage" id="image1898"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -2931,7 +2888,7 @@ <signal name="activate" handler="on_find_usage1_activate" last_modification_time="Fri, 27 May 2005 21:55:12 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1698"> + <widget class="GtkImage" id="image1899"> <property name="visible">True</property> <property name="stock">gtk-find</property> <property name="icon_size">1</property> @@ -2986,7 +2943,7 @@ <signal name="activate" handler="on_go_to_line_activate" last_modification_time="Sat, 16 Jul 2005 11:20:32 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1699"> + <widget class="GtkImage" id="image1900"> <property name="visible">True</property> <property name="stock">gtk-jump-to</property> <property name="icon_size">1</property>
Modified: trunk/plugins/Makefile.am =================================================================== --- trunk/plugins/Makefile.am 2007-07-04 11:14:05 UTC (rev 1658) +++ trunk/plugins/Makefile.am 2007-07-04 11:32:33 UTC (rev 1659) @@ -8,20 +8,24 @@ plugindir = $(libdir)/geany
demoplugin_la_LDFLAGS = -module -avoid-version +classbuilder_la_LDFLAGS = -module -avoid-version
if PLUGINS
# Plugins to be installed plugin_LTLIBRARIES = \ - demoplugin.la + demoplugin.la \ + classbuilder.la
# Plugins not to be installed #noinst_LTLIBRARIES = \ #demoplugin.la
demoplugin_la_SOURCES = demoplugin.c +classbuilder_la_SOURCES = classbuilder.c
demoplugin_la_LIBADD = $(GTK_LIBS) +classbuilder_la_LIBADD = $(GTK_LIBS)
endif # PLUGINS
Added: trunk/plugins/classbuilder.c =================================================================== --- trunk/plugins/classbuilder.c (rev 0) +++ trunk/plugins/classbuilder.c 2007-07-04 11:32:33 UTC (rev 1659) @@ -0,0 +1,859 @@ +/* + * classbuilder.c - this file is part of Geany, a fast and lightweight IDE + * + * Copyright 2007 Alexander Rodin <rodin(dot)alexander(at)gmail(dot)com> + * Copyright 2007 Enrico Tröger enrico.troeger@uvena.de + * Copyright 2007 Nick Treleaven nick.treleaven@btinternet.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id$ + */ + +/* Class Builder - creates source files containing a new class interface and definition. */ + +#include "geany.h" +#include "plugindata.h" +#include "support.h" +#include "filetypes.h" +#include "document.h" + + +enum +{ + GEANY_CLASS_TYPE_CPP, + GEANY_CLASS_TYPE_GTK +}; + +typedef struct _ClassInfo ClassInfo; + +struct _ClassInfo +{ + gint type; + gchar *class_name; + gchar *class_name_up; + gchar *class_name_low; + gchar *base_name; + gchar *base_gtype; + gchar *header; + gchar *header_guard; + gchar *base_include; + gchar *base_decl; + gchar *constructor_decl; + gchar *destructor_decl; + gchar *source; + gchar *constructor_impl; + gchar *destructor_impl; + gchar *gtk_destructor_registration; +}; + +typedef struct _CreateClassDialog +{ + gint class_type; + GtkWidget *dialog; + GtkWidget *class_name_entry; + GtkWidget *header_entry; + GtkWidget *source_entry; + GtkWidget *base_name_entry; + GtkWidget *base_header_entry; + GtkWidget *base_header_global_box; + GtkWidget *base_gtype_entry; + GtkWidget *create_constructor_box; + GtkWidget *create_destructor_box; + GtkWidget *gtk_constructor_type_entry; +} CreateClassDialog; + + +static PluginData *plugin_data; + +#define doc_array plugin_data->doc_array +// can't use document as a macro because it's currently a typename +#define documents plugin_data->document +#define scintilla plugin_data->sci +#define templates plugin_data->templates +#define utils plugin_data->utils + + +static struct +{ + GtkWidget *menu_item; +} +local_data; + + +static const gchar templates_cpp_class_header[] = "{fileheader}\n\n\ +#ifndef {header_guard}\n\ +#define {header_guard}\n\ +{base_include}\n\ +class {class_name}{base_decl}\n\ +{\n\ + public:\n\ + {constructor_decl}\ + {destructor_decl}\ + \n\ + private:\n\ + // add your private declarations\n\ +};\n\ +\n\ +#endif // {header_guard}\n\ +"; + +static const gchar templates_cpp_class_source[] = "{fileheader}\n\n\ +#include "{header}"\n\ +\n\ +{constructor_impl}\n\ +{destructor_impl}\n\ +"; + +static const gchar templates_gtk_class_header[] = "{fileheader}\n\n\ +#ifndef __{header_guard}__\n\ +#define __{header_guard}__\n\ +{base_include}\n\ +G_BEGIN_DECLS\n\ +\n\ +#define {class_name_up}_TYPE ({class_name_low}_get_type())\n\ +#define {class_name_up}(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\\n\ + {class_name_up}_TYPE, {class_name}))\n\ +#define {class_name_up}_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\\n\ + {class_name_up}_TYPE, {class_name}Class))\n\ +#define IS_{class_name_up}(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\\n\ + {class_name_up}_TYPE))\n\ +#define IS_{class_name_up}_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\\n\ + {class_name_up}_TYPE))\n\ +\n\ +typedef struct _{class_name} {class_name};\n\ +typedef struct _{class_name}Class {class_name}Class;\n\ +\n\ +struct _{class_name}\n\ +{\n\ + {base_name} parent;\n\ + /* add your public declarations here */\n\ +};\n\ +\n\ +struct _{class_name}Class\n\ +{\n\ + {base_name}Class parent_class;\n\ +};\n\ +\n\ +GType {class_name_low}_get_type (void);\n\ +{constructor_decl}\ +\n\ +G_END_DECLS\n\ +\n\ +#endif /* __{header_guard}__ */\n\ +"; + +static const gchar templates_gtk_class_source[] = "{fileheader}\n\ +#include "{header}"\n\ +\n\ +typedef struct _{class_name}Private {class_name}Private;\n\ +\n\ +#define {class_name_up}_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj),\\n\ + {class_name_up}_TYPE, {class_name}Private))\n\ +\n\ +struct _{class_name}Private\n\ +{\n\ + /* add your private declarations here */\n\ +};\n\ +\n\ +static void {class_name_low}_class_init ({class_name}Class *klass);\n\ +static void {class_name_low}_init ({class_name} *self);\n\ +{destructor_decl}\ +\n\ +/* Local data */\n\ +static {base_name}Class *parent_class = NULL;\n\ +\n\ +GType {class_name_low}_get_type(void)\n\ +{\n\ + static GType self_type = 0;\n\ + if (! self_type)\n\ + {\n\ + static const GTypeInfo self_info = \n\ + {\n\ + sizeof({class_name}Class),\n\ + NULL, /* base_init */\n\ + NULL, /* base_finalize */\n\ + (GClassInitFunc){class_name_low}_class_init,\n\ + NULL, /* class_finalize */\n\ + NULL, /* class_data */\n\ + sizeof({class_name}),\n\ + 0,\n\ + (GInstanceInitFunc){class_name_low}_init,\n\ + };\n\ + \n\ + self_type = g_type_register_static({base_gtype}, "{class_name}", &self_info, 0);\ + }\n\ + \n\ + return self_type;\n\ +}\n\ +\n\ +static void {class_name_low}_class_init({class_name}Class *klass)\n\ +{\n\ + {gtk_destructor_registration}\n\ + parent_class = ({base_name}Class*)g_type_class_peek({base_gtype});\n\ + g_type_class_add_private((gpointer)klass, sizeof({class_name}Private));\n\ +}\n\ +\n\ +static void {class_name_low}_init({class_name} *self)\n\ +{\n\ + \n\ +}\n\ +\n\ +{constructor_impl}\n\ +{destructor_impl}\n\ +"; + + +static void cc_dlg_on_set_sensitive_toggled(GtkWidget *toggle_button, GtkWidget *target_widget); +static void cc_dlg_on_class_name_entry_changed(GtkWidget *entry, CreateClassDialog *cc_dlg); +static void cc_dlg_on_base_name_entry_changed(GtkWidget *entry, CreateClassDialog *cc_dlg); +static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg); + + +VERSION_CHECK(3) + +PLUGIN_INFO(_("Class Builder"), _("Creates source files for new class types.")) + + +/* I don't want this to be in the plugin API because it can cause leaks if any pointers + * are NULL -ntrel. */ +/* Frees all passed pointers if they are *ALL* non-NULL. + * Do not use if any pointers may be NULL. + * The first argument is nothing special, it will also be freed. + * The list must be ended with NULL. */ +static void +utils_free_pointers(gpointer first, ...) +{ + va_list a; + gpointer sa; + + for (va_start(a, first); (sa = va_arg(a, gpointer), sa!=NULL);) + { + if (sa != NULL) + g_free(sa); + } + va_end(a); + + if (first != NULL) + g_free(first); +} + + +static gchar* +get_template_class_header(ClassInfo *class_info) +{ + switch (class_info->type) + { + case GEANY_CLASS_TYPE_CPP: + { + gchar *fileheader = NULL; + gchar *template; + + fileheader = templates->get_template_fileheader(GEANY_FILETYPES_C, class_info->header); + template = g_strdup(templates_cpp_class_header); + template = utils->str_replace(template, "{fileheader}", fileheader); + template = utils->str_replace(template, "{header_guard}", class_info->header_guard); + template = utils->str_replace(template, "{base_include}", class_info->base_include); + template = utils->str_replace(template, "{class_name}", class_info->class_name); + template = utils->str_replace(template, "{base_decl}", class_info->base_decl); + template = utils->str_replace(template, "{constructor_decl}", + class_info->constructor_decl); + template = utils->str_replace(template, "{destructor_decl}", + class_info->destructor_decl); + + return template; + } + case GEANY_CLASS_TYPE_GTK: + { + gchar *fileheader = NULL; + gchar *template; + + fileheader = templates->get_template_fileheader(GEANY_FILETYPES_C, class_info->header); + template = g_strdup(templates_gtk_class_header); + template = utils->str_replace(template, "{fileheader}", fileheader); + template = utils->str_replace(template, "{header_guard}", class_info->header_guard); + template = utils->str_replace(template, "{base_include}", class_info->base_include); + template = utils->str_replace(template, "{class_name}", class_info->class_name); + template = utils->str_replace(template, "{class_name_up}", class_info->class_name_up); + template = utils->str_replace(template, "{class_name_low}", class_info->class_name_low); + template = utils->str_replace(template, "{base_name}", class_info->base_name); + template = utils->str_replace(template, "{constructor_decl}", + class_info->constructor_decl); + + return template; + } + } + + return NULL; +} + +static gchar* +get_template_class_source(ClassInfo *class_info) +{ + switch (class_info->type) + { + case GEANY_CLASS_TYPE_CPP: + { + gchar *fileheader = NULL; + gchar *template; + + fileheader = templates->get_template_fileheader(GEANY_FILETYPES_C, class_info->source); + template = g_strdup(templates_cpp_class_source); + template = utils->str_replace(template, "{fileheader}", fileheader); + template = utils->str_replace(template, "{header}", class_info->header); + template = utils->str_replace(template, "{class_name}", class_info->class_name); + template = utils->str_replace(template, "{base_include}", class_info->base_include); + template = utils->str_replace(template, "{base_name}", class_info->base_name); + template = utils->str_replace(template, "{constructor_impl}", + class_info->constructor_impl); + template = utils->str_replace(template, "{destructor_impl}", + class_info->destructor_impl); + + return template; + } + case GEANY_CLASS_TYPE_GTK: + { + gchar *fileheader = NULL; + gchar *template; + + fileheader = templates->get_template_fileheader(GEANY_FILETYPES_C, class_info->source); + template = g_strdup(templates_gtk_class_source); + template = utils->str_replace(template, "{fileheader}", fileheader); + template = utils->str_replace(template, "{header}", class_info->header); + template = utils->str_replace(template, "{class_name}", class_info->class_name); + template = utils->str_replace(template, "{class_name_up}", class_info->class_name_up); + template = utils->str_replace(template, "{class_name_low}", class_info->class_name_low); + template = utils->str_replace(template, "{base_name}", class_info->base_name); + template = utils->str_replace(template, "{base_gtype}", class_info->base_gtype); + template = utils->str_replace(template, "{destructor_decl}", class_info->destructor_decl); + template = utils->str_replace(template, "{constructor_impl}", + class_info->constructor_impl); + template = utils->str_replace(template, "{destructor_impl}", + class_info->destructor_impl); + template = utils->str_replace(template, "{gtk_destructor_registration}", + class_info->gtk_destructor_registration); + + return template; + } + } + + return NULL; +} + + +void show_dialog_create_class(gint type) +{ + CreateClassDialog *cc_dlg; + GtkWidget *main_box; + GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *label; + + cc_dlg = g_new0(CreateClassDialog, 1); + cc_dlg->class_type = type; + + cc_dlg->dialog = gtk_dialog_new_with_buttons(_("Create class"), + GTK_WINDOW(plugin_data->app->window), + GTK_DIALOG_MODAL, + GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + gtk_container_set_border_width(GTK_CONTAINER(cc_dlg->dialog), 5); + g_signal_connect_swapped(G_OBJECT(cc_dlg->dialog), "destroy", + G_CALLBACK(g_free), (gpointer)cc_dlg); + + main_box = GTK_DIALOG(cc_dlg->dialog)->vbox; + gtk_box_set_spacing(GTK_BOX(main_box), 10); + + frame = gtk_frame_new(_("Class")); + gtk_container_add(GTK_CONTAINER(main_box), frame); + gtk_widget_show(frame); + + vbox = gtk_vbox_new(FALSE, 10); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_widget_show(vbox); + + hbox = gtk_hbox_new(FALSE, 10); + gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_widget_show(hbox); + + label = gtk_label_new(_("Class name:")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + cc_dlg->class_name_entry = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(hbox), cc_dlg->class_name_entry, TRUE, TRUE, 0); + gtk_widget_show(cc_dlg->class_name_entry); + g_signal_connect(G_OBJECT(cc_dlg->class_name_entry), "changed", + G_CALLBACK(cc_dlg_on_class_name_entry_changed), cc_dlg); + + hbox = gtk_hbox_new(FALSE, 10); + gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_widget_show(hbox); + + label = gtk_label_new(_("Header file:")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + cc_dlg->header_entry = gtk_entry_new(); + gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->header_entry); + gtk_widget_show(cc_dlg->header_entry); + + hbox = gtk_hbox_new(FALSE, 10); + gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_widget_show(hbox); + + label = gtk_label_new(_("Source file:")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + cc_dlg->source_entry = gtk_entry_new(); + gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->source_entry); + gtk_widget_show(cc_dlg->source_entry); + + frame = gtk_frame_new(_("Inheritance")); + gtk_container_add(GTK_CONTAINER(main_box), frame); + gtk_widget_show(frame); + + vbox = gtk_vbox_new(FALSE, 10); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_widget_show(vbox); + + hbox = gtk_hbox_new(FALSE, 10); + gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_widget_show(hbox); + + label = gtk_label_new(_("Base class:")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + cc_dlg->base_name_entry = gtk_entry_new(); + if (type == GEANY_CLASS_TYPE_GTK) + gtk_entry_set_text(GTK_ENTRY(cc_dlg->base_name_entry), "GObject"); + gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->base_name_entry); + gtk_widget_show(cc_dlg->base_name_entry); + g_signal_connect(G_OBJECT(cc_dlg->base_name_entry), "changed", + G_CALLBACK(cc_dlg_on_base_name_entry_changed), (gpointer)cc_dlg); + + hbox = gtk_hbox_new(FALSE, 10); + gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_widget_show(hbox); + + label = gtk_label_new(_("Base header:")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + cc_dlg->base_header_entry = gtk_entry_new(); + if (type == GEANY_CLASS_TYPE_GTK) + gtk_entry_set_text(GTK_ENTRY(cc_dlg->base_header_entry), "glib-object.h"); + gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->base_header_entry); + gtk_widget_show(cc_dlg->base_header_entry); + + cc_dlg->base_header_global_box = gtk_check_button_new_with_label(_("Global")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cc_dlg->base_header_global_box), TRUE); + gtk_box_pack_end(GTK_BOX(hbox), cc_dlg->base_header_global_box, FALSE, FALSE, 0); + gtk_widget_show(cc_dlg->base_header_global_box); + + if (type == GEANY_CLASS_TYPE_GTK) + { + hbox = gtk_hbox_new(FALSE, 10); + gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_widget_show(hbox); + + label = gtk_label_new(_("Base GType:")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + cc_dlg->base_gtype_entry = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(cc_dlg->base_gtype_entry), "GTK_TYPE_OBJECT"); + gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->base_gtype_entry); + gtk_widget_show(cc_dlg->base_gtype_entry); + } + + frame = gtk_frame_new(_("Options")); + gtk_container_add(GTK_CONTAINER(main_box), frame); + gtk_widget_show(frame); + + vbox = gtk_vbox_new(FALSE, 10); + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_widget_show(vbox); + + hbox = gtk_hbox_new(FALSE, 10); + gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_widget_show(hbox); + + cc_dlg->create_constructor_box = gtk_check_button_new_with_label(_("Create constructor")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cc_dlg->create_constructor_box), TRUE); + gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->create_constructor_box); + gtk_widget_show(cc_dlg->create_constructor_box); + + cc_dlg->create_destructor_box = gtk_check_button_new_with_label(_("Create destructor")); + gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->create_destructor_box); + gtk_widget_show(cc_dlg->create_destructor_box); + + if (type == GEANY_CLASS_TYPE_GTK) + { + hbox = gtk_hbox_new(FALSE, 10); + gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_widget_show(hbox); + g_signal_connect(G_OBJECT(cc_dlg->create_constructor_box), "toggled", + G_CALLBACK(cc_dlg_on_set_sensitive_toggled), (gpointer)hbox); + + label = gtk_label_new(_("GTK+ constructor type")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + cc_dlg->gtk_constructor_type_entry = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(cc_dlg->gtk_constructor_type_entry), "GObject"); + gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->gtk_constructor_type_entry); + gtk_widget_show(cc_dlg->gtk_constructor_type_entry); + } + + if (gtk_dialog_run(GTK_DIALOG(cc_dlg->dialog)) == GTK_RESPONSE_OK) + cc_dlg_on_create_class(cc_dlg); + + gtk_widget_destroy(cc_dlg->dialog); +// g_object_unref(G_OBJECT(cc_dlg->dialog)); +} + + +static void cc_dlg_on_set_sensitive_toggled(GtkWidget *toggle_button, GtkWidget *target_widget) +{ + g_return_if_fail(toggle_button != NULL); + g_return_if_fail(GTK_IS_TOGGLE_BUTTON(toggle_button)); + g_return_if_fail(target_widget != NULL); + g_return_if_fail(GTK_IS_WIDGET(target_widget)); + + gtk_widget_set_sensitive(target_widget, + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button))); +} + + +static void cc_dlg_on_class_name_entry_changed(GtkWidget *entry, CreateClassDialog *cc_dlg) +{ + gchar *class_name_down; + gchar *class_header; + gchar *class_source; + + g_return_if_fail(entry != NULL); + g_return_if_fail(GTK_IS_ENTRY(entry)); + g_return_if_fail(cc_dlg != NULL); + + class_name_down = g_ascii_strdown(gtk_entry_get_text(GTK_ENTRY(entry)), -1); + class_header = g_strconcat(class_name_down, ".h", NULL); + if (cc_dlg->class_type == GEANY_CLASS_TYPE_CPP) + class_source = g_strconcat(class_name_down, ".cpp", NULL); + else + class_source = g_strconcat(class_name_down, ".c", NULL); + + gtk_entry_set_text(GTK_ENTRY(cc_dlg->header_entry), class_header); + gtk_entry_set_text(GTK_ENTRY(cc_dlg->source_entry), class_source); + + g_free(class_name_down); + g_free(class_header); + g_free(class_source); +} + + +static gchar* str_case_split(const gchar *str, gchar splitter) +{ + GString *result; + + g_return_val_if_fail(str != NULL, NULL); + if (*str == '\0') + return g_strdup(""); + + result = g_string_new(NULL); + g_string_append_c(result, *str); + while (*(++str) != '\0') + { + if (g_ascii_isupper(*str) && g_ascii_islower(result->str[result->len - 1])) + g_string_append_c(result, splitter); + g_string_append_c(result, *str); + } + return g_string_free(result, FALSE); +} + + +static void cc_dlg_on_base_name_entry_changed(GtkWidget *entry, CreateClassDialog *cc_dlg) +{ + gchar *base_name_splitted; + gchar *base_header; + gchar *tmp; + + g_return_if_fail(entry != NULL); + g_return_if_fail(GTK_IS_ENTRY(entry)); + g_return_if_fail(cc_dlg != NULL); + + base_name_splitted = str_case_split(gtk_entry_get_text(GTK_ENTRY(entry)), '_'); + if (! g_ascii_strncasecmp(gtk_entry_get_text(GTK_ENTRY(entry)), "gtk", 3)) + tmp = g_strconcat("gtk/", gtk_entry_get_text(GTK_ENTRY(entry)), ".h", NULL); + else if (utils->str_equal(gtk_entry_get_text(GTK_ENTRY(entry)), "GObject")) + tmp = g_strdup("glib-object.h"); + else + tmp = g_strconcat(gtk_entry_get_text(GTK_ENTRY(entry)), ".h", NULL); + base_header = g_ascii_strdown(tmp, -1); + g_free(tmp); + + gtk_entry_set_text(GTK_ENTRY(cc_dlg->base_header_entry), base_header); + + if (cc_dlg->class_type == GEANY_CLASS_TYPE_GTK) + { + gchar *base_gtype; + if (! g_ascii_strncasecmp(gtk_entry_get_text(GTK_ENTRY(entry)), "gtk", 3)) + tmp = g_strdup_printf("%.3s_TYPE%s", + base_name_splitted, + base_name_splitted + 3); + else if (utils->str_equal(gtk_entry_get_text(GTK_ENTRY(entry)), "GObject")) + tmp = g_strdup("G_TYPE_OBJECT"); + else + tmp = g_strconcat(base_name_splitted, "_TYPE", NULL); + base_gtype = g_ascii_strup(tmp, -1); + gtk_entry_set_text(GTK_ENTRY(cc_dlg->base_gtype_entry), base_gtype); + + g_free(base_gtype); + g_free(tmp); + } + + g_free(base_name_splitted); + g_free(base_header); +} + + +static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg) +{ + ClassInfo *class_info; + gint idx; + gchar *text; + gchar *tmp; + + g_return_if_fail(cc_dlg != NULL); + + if (utils->str_equal(gtk_entry_get_text(GTK_ENTRY(cc_dlg->class_name_entry)), "")) + return; + + class_info = g_new0(ClassInfo, 1); + class_info->type = cc_dlg->class_type; + class_info->class_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(cc_dlg->class_name_entry))); + tmp = str_case_split(class_info->class_name, '_'); + class_info->class_name_up = g_ascii_strup(tmp, -1); + class_info->class_name_low = g_ascii_strdown(class_info->class_name_up, -1); + if (! utils->str_equal(gtk_entry_get_text(GTK_ENTRY(cc_dlg->base_name_entry)), "")) + { + class_info->base_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(cc_dlg->base_name_entry))); + class_info->base_include = g_strdup_printf("\n#include %c%s%c\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cc_dlg->base_header_global_box)) ? + '<' : '"', + gtk_entry_get_text(GTK_ENTRY(cc_dlg->base_header_entry)), + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cc_dlg->base_header_global_box)) ? + '>' : '"'); + } + else + { + class_info->base_name = g_strdup(""); + class_info->base_include = g_strdup(""); + } + class_info->header = g_strdup(gtk_entry_get_text(GTK_ENTRY(cc_dlg->header_entry))); + class_info->header_guard = g_ascii_strup(class_info->header, -1); + g_strdelimit(class_info->header_guard, ".", '_'); + switch (class_info->type) + { + case GEANY_CLASS_TYPE_CPP: + { + class_info->source = g_strdup(gtk_entry_get_text(GTK_ENTRY(cc_dlg->source_entry))); + if (! utils->str_equal(class_info->base_name, "")) + class_info->base_decl = g_strdup_printf(": public %s", class_info->base_name); + else + class_info->base_decl = g_strdup(""); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cc_dlg->create_constructor_box))) + { + gchar *base_constructor; + + if (utils->str_equal(class_info->base_name, "")) + base_constructor = g_strdup(""); + else + base_constructor = g_strdup_printf("\t: %s()\n", class_info->base_name); + class_info->constructor_decl = g_strdup_printf("%s();\n", class_info->class_name); + class_info->constructor_impl = g_strdup_printf("\n%s::%s()\n%s{\n\t\n}\n", + class_info->class_name, class_info->class_name, base_constructor); + g_free(base_constructor); + } + else + { + class_info->constructor_decl = g_strdup(""); + class_info->constructor_impl = g_strdup(""); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cc_dlg->create_destructor_box))) + { + class_info->destructor_decl = + g_strdup_printf("virtual ~%s();\n", class_info->class_name); + class_info->destructor_impl = g_strdup_printf("\n%s::~%s()\n{\n\t\n}\n", + class_info->class_name, class_info->class_name); + } + else + { + class_info->destructor_decl = g_strdup(""); + class_info->destructor_impl = g_strdup(""); + } + break; + } + case GEANY_CLASS_TYPE_GTK: + { + class_info->base_gtype = g_strdup(gtk_entry_get_text( + GTK_ENTRY(cc_dlg->base_gtype_entry))); + class_info->source = g_strdup(gtk_entry_get_text(GTK_ENTRY(cc_dlg->source_entry))); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cc_dlg->create_constructor_box))) + { + class_info->constructor_decl = g_strdup_printf("%s*\t%s_new\t\t\t(void);\n", + gtk_entry_get_text(GTK_ENTRY(cc_dlg->gtk_constructor_type_entry)), + class_info->class_name_low); + class_info->constructor_impl = g_strdup_printf("\n" + "%s* %s_new(void)\n" + "{\n" + "\treturn (%s*)g_object_new(%s_TYPE, NULL);\n" + "}\n", + gtk_entry_get_text(GTK_ENTRY(cc_dlg->gtk_constructor_type_entry)), + class_info->class_name_low, + gtk_entry_get_text(GTK_ENTRY(cc_dlg->gtk_constructor_type_entry)), + class_info->class_name_up); + } + else + { + class_info->constructor_decl = g_strdup(""); + class_info->constructor_impl = g_strdup(""); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cc_dlg->create_destructor_box))) + { + class_info->gtk_destructor_registration = + g_strdup_printf("GObjectClass *g_object_class;\n\n" + "\tg_object_class = G_OBJECT_CLASS(klass);\n\n" + "\tg_object_class->finalize = %s_finalize;\n", + class_info->class_name_low); + class_info->destructor_decl = + g_strdup_printf("static void %s_finalize\t\t\t(GObject *object);\n", + class_info->class_name_low); + class_info->destructor_impl = g_strdup_printf("\n" + "void %s_finalize(GObject *object)\n" + "{\n" + "\t%s *self;\n\n" + "\tg_return_if_fail(object != NULL);\n" + "\tg_return_if_fail(IS_%s(object));\n\n" + "\tself = %s(object);\n\n" + "\tif (G_OBJECT_CLASS(parent_class)->finalize)\n" + "\t\t(* G_OBJECT_CLASS(parent_class)->finalize)(object);\n" + "}\n", + class_info->class_name_low, + class_info->class_name, + class_info->class_name_up, + class_info->class_name_up); + } + else + { + class_info->gtk_destructor_registration = g_strdup(""); + class_info->destructor_decl = g_strdup(""); + class_info->destructor_impl = g_strdup(""); + } + break; + } + } + + // only create the files if the filename is not empty + if (! utils->str_equal(class_info->source, "")) + { + text = get_template_class_source(class_info); + idx = documents->new_file(class_info->source, NULL); + scintilla->set_text(doc_list[idx].sci, text); + g_free(text); + } + + if (! utils->str_equal(class_info->header, "")) + { + text = get_template_class_header(class_info); + idx = documents->new_file(class_info->header, NULL); + scintilla->set_text(doc_list[idx].sci, text); + g_free(text); + } + + utils_free_pointers(tmp, class_info->class_name, class_info->class_name_up, + class_info->base_name, class_info->class_name_low, class_info->base_include, + class_info->header, class_info->header_guard, class_info->source, class_info->base_decl, + class_info->constructor_decl, class_info->constructor_impl, + class_info->gtk_destructor_registration, class_info->destructor_decl, + class_info->destructor_impl, class_info->base_gtype, class_info, NULL); +} + + +static void +on_menu_create_cpp_class_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + show_dialog_create_class(GEANY_CLASS_TYPE_CPP); +} + + +static void +on_menu_create_gtk_class_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + show_dialog_create_class(GEANY_CLASS_TYPE_GTK); +} + + +void init(PluginData *data) +{ + GtkWidget *menu_create_class1; + GtkWidget *image1861; + GtkWidget *menu_create_class1_menu; + GtkWidget *menu_create_cpp_class; + GtkWidget *menu_create_gtk_class; + + plugin_data = data; + + menu_create_class1 = gtk_image_menu_item_new_with_mnemonic (_("Create Cla_ss")); + gtk_container_add (GTK_CONTAINER (data->tools_menu), menu_create_class1); + + image1861 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_create_class1), image1861); + + menu_create_class1_menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_create_class1), menu_create_class1_menu); + + menu_create_cpp_class = gtk_menu_item_new_with_mnemonic (_("C++ class")); + gtk_container_add (GTK_CONTAINER (menu_create_class1_menu), menu_create_cpp_class); + + menu_create_gtk_class = gtk_menu_item_new_with_mnemonic (_("GTK+ class")); + gtk_container_add (GTK_CONTAINER (menu_create_class1_menu), menu_create_gtk_class); + + g_signal_connect ((gpointer) menu_create_cpp_class, "activate", + G_CALLBACK (on_menu_create_cpp_class_activate), + NULL); + g_signal_connect ((gpointer) menu_create_gtk_class, "activate", + G_CALLBACK (on_menu_create_gtk_class_activate), + NULL); + + gtk_widget_show_all(menu_create_class1); + + local_data.menu_item = menu_create_class1; +} + + +void cleanup() +{ + gtk_widget_destroy(local_data.menu_item); +}
Property changes on: trunk/plugins/classbuilder.c ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native
Modified: trunk/po/POTFILES.in =================================================================== --- trunk/po/POTFILES.in 2007-07-04 11:14:05 UTC (rev 1658) +++ trunk/po/POTFILES.in 2007-07-04 11:32:33 UTC (rev 1659) @@ -33,3 +33,4 @@ src/utils.c src/vte.c src/win32.c +plugins/classbuilder.c
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2007-07-04 11:14:05 UTC (rev 1658) +++ trunk/src/callbacks.c 2007-07-04 11:32:33 UTC (rev 1659) @@ -1587,9 +1587,15 @@ { gint idx = document_get_cur_idx(); gchar *text; + gchar *fname; + filetype *ft;
- text = templates_get_template_fileheader(idx); + g_return_if_fail(DOC_IDX_VALID(idx));
+ ft = doc_list[idx].file_type; + fname = doc_list[idx].file_name; + text = templates_get_template_fileheader(FILETYPE_ID(ft), fname); + sci_insert_text(doc_list[idx].sci, 0, text); sci_goto_pos(doc_list[idx].sci, 0, FALSE); g_free(text); @@ -2300,18 +2306,3 @@ }
-void -on_menu_create_cpp_class_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - tools_show_dialog_create_class(GEANY_CLASS_TYPE_CPP); -} - - -void -on_menu_create_gtk_class_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - tools_show_dialog_create_class(GEANY_CLASS_TYPE_GTK); -} -
Modified: trunk/src/callbacks.h =================================================================== --- trunk/src/callbacks.h 2007-07-04 11:14:05 UTC (rev 1658) +++ trunk/src/callbacks.h 2007-07-04 11:32:33 UTC (rev 1659) @@ -617,10 +617,3 @@ GdkEventMotion *event, gpointer user_data);
-void -on_menu_create_cpp_class_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_create_gtk_class_activate (GtkMenuItem *menuitem, - gpointer user_data);
Modified: trunk/src/interface.c =================================================================== --- trunk/src/interface.c 2007-07-04 11:14:05 UTC (rev 1658) +++ trunk/src/interface.c 2007-07-04 11:32:33 UTC (rev 1659) @@ -37,7 +37,7 @@ GtkWidget *file1_menu; GtkWidget *menu_new1; GtkWidget *menu_new_with_template1; - GtkWidget *image1776; + GtkWidget *image1877; GtkWidget *menu_new_with_template1_menu; GtkWidget *invisible2; GtkWidget *separator12; @@ -48,11 +48,11 @@ GtkWidget *menu_save1; GtkWidget *menu_save_as1; GtkWidget *menu_save_all1; - GtkWidget *image1777; + GtkWidget *image1878; GtkWidget *menu_reload1; - GtkWidget *image1778; + GtkWidget *image1879; GtkWidget *menu_reload_as1; - GtkWidget *image1779; + GtkWidget *image1880; GtkWidget *menu_reload_as1_menu; GtkWidget *invisible7; GtkWidget *separator21; @@ -64,7 +64,7 @@ GtkWidget *separator14; GtkWidget *menu_close1; GtkWidget *menu_close_all1; - GtkWidget *image1780; + GtkWidget *image1881; GtkWidget *menu_separatormenuitem1; GtkWidget *menu_quit1; GtkWidget *edit1; @@ -90,20 +90,20 @@ GtkWidget *menu_duplicate_line1; GtkWidget *separator29; GtkWidget *menu_increase_indent1; - GtkWidget *image1781; + GtkWidget *image1882; GtkWidget *menu_decrease_indent1; - GtkWidget *image1782; + GtkWidget *image1883; GtkWidget *separator37; GtkWidget *send_selection_to2; GtkWidget *send_selection_to2_menu; GtkWidget *invisible13; GtkWidget *separator18; GtkWidget *insert_include2; - GtkWidget *image1783; + GtkWidget *image1884; GtkWidget *insert_include2_menu; GtkWidget *invisible4; GtkWidget *add_comments1; - GtkWidget *image1784; + GtkWidget *image1885; GtkWidget *add_comments1_menu; GtkWidget *menu_add_changelog_entry1; GtkWidget *insert_file_header1; @@ -112,7 +112,7 @@ GtkWidget *insert_gpl_notice2; GtkWidget *insert_bsd_license_notice2; GtkWidget *insert_date1; - GtkWidget *image1785; + GtkWidget *image1886; GtkWidget *insert_date1_menu; GtkWidget *invisible8; GtkWidget *separator9; @@ -124,7 +124,7 @@ GtkWidget *find_previous1; GtkWidget *find_in_files1; GtkWidget *replace1; - GtkWidget *image1786; + GtkWidget *image1887; GtkWidget *separator33; GtkWidget *find_nextsel1; GtkWidget *find_prevsel1; @@ -132,11 +132,11 @@ GtkWidget *next_message1; GtkWidget *separator32; GtkWidget *go_to_line1; - GtkWidget *image1787; + GtkWidget *image1888; GtkWidget *menu_view1; - GtkWidget *menuitem3_menu; + GtkWidget *menu_view1_menu; GtkWidget *menu_change_font1; - GtkWidget *image1788; + GtkWidget *image1889; GtkWidget *menu_separator4; GtkWidget *menu_toggle_all_additional_widgets1; GtkWidget *menu_fullscreen1; @@ -150,7 +150,7 @@ GtkWidget *menu_zoom_out1; GtkWidget *normal_size1; GtkWidget *menu_document1; - GtkWidget *menu_item4_menu; + GtkWidget *menu_document1_menu; GtkWidget *menu_line_breaking1; GtkWidget *menu_use_auto_indentation1; GtkWidget *set_file_readonly1; @@ -179,27 +179,22 @@ GtkWidget *menu_project1; GtkWidget *menu_project1_menu; GtkWidget *project_new1; - GtkWidget *image1789; + GtkWidget *image1890; GtkWidget *project_open1; - GtkWidget *image1790; + GtkWidget *image1891; GtkWidget *project_close1; - GtkWidget *image1791; + GtkWidget *image1892; GtkWidget *separator34; GtkWidget *project_properties1; GtkWidget *menu_build1; GtkWidget *tools1; GtkWidget *tools1_menu; GtkWidget *menu_choose_color1; - GtkWidget *image1792; + GtkWidget *image1893; GtkWidget *menu_count_words1; GtkWidget *menu_insert_special_chars1; - GtkWidget *menu_create_class1; - GtkWidget *image1861; - GtkWidget *menu_create_class1_menu; - GtkWidget *menu_create_cpp_class; - GtkWidget *menu_create_gtk_class; GtkWidget *menu_help1; - GtkWidget *menu_item5_menu; + GtkWidget *menu_help1_menu; GtkWidget *help1; GtkWidget *keyboard_shortcuts1; GtkWidget *website1; @@ -300,9 +295,9 @@ gtk_widget_show (menu_new_with_template1); gtk_container_add (GTK_CONTAINER (file1_menu), menu_new_with_template1);
- image1776 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1776); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_new_with_template1), image1776); + image1877 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1877); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_new_with_template1), image1877);
menu_new_with_template1_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_new_with_template1), menu_new_with_template1_menu); @@ -345,25 +340,25 @@ gtk_container_add (GTK_CONTAINER (file1_menu), menu_save_all1); gtk_tooltips_set_tip (tooltips, menu_save_all1, _("Saves all open files"), NULL);
- image1777 = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1777); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_save_all1), image1777); + image1878 = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1878); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_save_all1), image1878);
menu_reload1 = gtk_image_menu_item_new_with_mnemonic (_("_Reload")); gtk_widget_show (menu_reload1); gtk_container_add (GTK_CONTAINER (file1_menu), menu_reload1);
- image1778 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1778); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_reload1), image1778); + image1879 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1879); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_reload1), image1879);
menu_reload_as1 = gtk_image_menu_item_new_with_mnemonic (_("R_eload As")); gtk_widget_show (menu_reload_as1); gtk_container_add (GTK_CONTAINER (file1_menu), menu_reload_as1);
- image1779 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1779); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_reload_as1), image1779); + image1880 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1880); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_reload_as1), image1880);
menu_reload_as1_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_reload_as1), menu_reload_as1_menu); @@ -414,9 +409,9 @@ gtk_container_add (GTK_CONTAINER (file1_menu), menu_close_all1); gtk_tooltips_set_tip (tooltips, menu_close_all1, _("Closes all open files"), NULL);
- image1780 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1780); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_close_all1), image1780); + image1881 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1881); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_close_all1), image1881);
menu_separatormenuitem1 = gtk_separator_menu_item_new (); gtk_widget_show (menu_separatormenuitem1); @@ -524,17 +519,17 @@ gtk_widget_show (menu_increase_indent1); gtk_container_add (GTK_CONTAINER (menu_format1_menu), menu_increase_indent1);
- image1781 = gtk_image_new_from_stock ("gtk-indent", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1781); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_increase_indent1), image1781); + image1882 = gtk_image_new_from_stock ("gtk-indent", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1882); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_increase_indent1), image1882);
menu_decrease_indent1 = gtk_image_menu_item_new_with_mnemonic (_("_Decrease Indent")); gtk_widget_show (menu_decrease_indent1); gtk_container_add (GTK_CONTAINER (menu_format1_menu), menu_decrease_indent1);
- image1782 = gtk_image_new_from_stock ("gtk-unindent", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1782); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_decrease_indent1), image1782); + image1883 = gtk_image_new_from_stock ("gtk-unindent", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1883); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_decrease_indent1), image1883);
separator37 = gtk_separator_menu_item_new (); gtk_widget_show (separator37); @@ -560,9 +555,9 @@ gtk_widget_show (insert_include2); gtk_container_add (GTK_CONTAINER (edit1_menu), insert_include2);
- image1783 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1783); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_include2), image1783); + image1884 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1884); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_include2), image1884);
insert_include2_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_include2), insert_include2_menu); @@ -574,9 +569,9 @@ gtk_widget_show (add_comments1); gtk_container_add (GTK_CONTAINER (edit1_menu), add_comments1);
- image1784 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1784); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (add_comments1), image1784); + image1885 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1885); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (add_comments1), image1885);
add_comments1_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (add_comments1), add_comments1_menu); @@ -615,9 +610,9 @@ gtk_widget_show (insert_date1); gtk_container_add (GTK_CONTAINER (edit1_menu), insert_date1);
- image1785 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1785); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_date1), image1785); + image1886 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1886); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_date1), image1886);
insert_date1_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_date1), insert_date1_menu); @@ -661,9 +656,9 @@ gtk_widget_show (replace1); gtk_container_add (GTK_CONTAINER (search1_menu), replace1);
- image1786 = gtk_image_new_from_stock ("gtk-find-and-replace", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1786); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (replace1), image1786); + image1887 = gtk_image_new_from_stock ("gtk-find-and-replace", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1887); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (replace1), image1887);
separator33 = gtk_separator_menu_item_new (); gtk_widget_show (separator33); @@ -696,120 +691,120 @@ gtk_widget_show (go_to_line1); gtk_container_add (GTK_CONTAINER (search1_menu), go_to_line1);
- image1787 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1787); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (go_to_line1), image1787); + image1888 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1888); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (go_to_line1), image1888);
menu_view1 = gtk_menu_item_new_with_mnemonic (_("_View")); gtk_widget_show (menu_view1); gtk_container_add (GTK_CONTAINER (menubar1), menu_view1);
- menuitem3_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_view1), menuitem3_menu); + menu_view1_menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_view1), menu_view1_menu);
menu_change_font1 = gtk_image_menu_item_new_with_mnemonic (_("Change _Font")); gtk_widget_show (menu_change_font1); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_change_font1); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_change_font1); gtk_tooltips_set_tip (tooltips, menu_change_font1, _("Change the default font"), NULL);
- image1788 = gtk_image_new_from_stock ("gtk-select-font", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1788); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_change_font1), image1788); + image1889 = gtk_image_new_from_stock ("gtk-select-font", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1889); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_change_font1), image1889);
menu_separator4 = gtk_separator_menu_item_new (); gtk_widget_show (menu_separator4); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_separator4); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_separator4); gtk_widget_set_sensitive (menu_separator4, FALSE);
- menu_toggle_all_additional_widgets1 = gtk_menu_item_new_with_mnemonic (_("Toggle all additional widgets")); + menu_toggle_all_additional_widgets1 = gtk_menu_item_new_with_mnemonic (_("Toggle All Additional Widgets")); gtk_widget_show (menu_toggle_all_additional_widgets1); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_toggle_all_additional_widgets1); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_toggle_all_additional_widgets1);
menu_fullscreen1 = gtk_check_menu_item_new_with_mnemonic (_("Full_screen")); gtk_widget_show (menu_fullscreen1); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_fullscreen1); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_fullscreen1);
menu_show_messages_window1 = gtk_check_menu_item_new_with_mnemonic (_("Show Message _Window")); gtk_widget_show (menu_show_messages_window1); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_show_messages_window1); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_show_messages_window1); gtk_tooltips_set_tip (tooltips, menu_show_messages_window1, _("Toggle the window with status and compiler messages on and off"), NULL); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_show_messages_window1), TRUE);
menu_show_toolbar1 = gtk_check_menu_item_new_with_mnemonic (_("Show _Toolbar")); gtk_widget_show (menu_show_toolbar1); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_show_toolbar1); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_show_toolbar1); gtk_tooltips_set_tip (tooltips, menu_show_toolbar1, _("Toggle the toolbar on and off"), NULL); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_show_toolbar1), TRUE);
menu_show_sidebar1 = gtk_check_menu_item_new_with_mnemonic (_("Show Side_bar")); gtk_widget_show (menu_show_sidebar1); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_show_sidebar1); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_show_sidebar1); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_show_sidebar1), TRUE);
menu_markers_margin1 = gtk_check_menu_item_new_with_mnemonic (_("Show _Markers Margin")); gtk_widget_show (menu_markers_margin1); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_markers_margin1); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_markers_margin1); gtk_tooltips_set_tip (tooltips, menu_markers_margin1, _("Shows or hides the small margin right of the line numbers, which is used to mark lines."), NULL); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_markers_margin1), TRUE);
menu_linenumber_margin1 = gtk_check_menu_item_new_with_mnemonic (_("Show _Line Numbers")); gtk_widget_show (menu_linenumber_margin1); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_linenumber_margin1); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_linenumber_margin1); gtk_tooltips_set_tip (tooltips, menu_linenumber_margin1, _("Shows or hides the Line Number margin."), NULL); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_linenumber_margin1), TRUE);
menu_separator5 = gtk_separator_menu_item_new (); gtk_widget_show (menu_separator5); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_separator5); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_separator5); gtk_widget_set_sensitive (menu_separator5, FALSE);
menu_zoom_in1 = gtk_image_menu_item_new_from_stock ("gtk-zoom-in", accel_group); gtk_widget_show (menu_zoom_in1); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_zoom_in1); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_zoom_in1);
menu_zoom_out1 = gtk_image_menu_item_new_from_stock ("gtk-zoom-out", accel_group); gtk_widget_show (menu_zoom_out1); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_zoom_out1); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_zoom_out1);
normal_size1 = gtk_image_menu_item_new_from_stock ("gtk-zoom-100", accel_group); gtk_widget_show (normal_size1); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), normal_size1); + gtk_container_add (GTK_CONTAINER (menu_view1_menu), normal_size1);
menu_document1 = gtk_menu_item_new_with_mnemonic (_("_Document")); gtk_widget_show (menu_document1); gtk_container_add (GTK_CONTAINER (menubar1), menu_document1);
- menu_item4_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_document1), menu_item4_menu); + menu_document1_menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_document1), menu_document1_menu);
menu_line_breaking1 = gtk_check_menu_item_new_with_mnemonic (_("_Line Wrapping")); gtk_widget_show (menu_line_breaking1); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), menu_line_breaking1); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), menu_line_breaking1); gtk_tooltips_set_tip (tooltips, menu_line_breaking1, _("Wrap the line at the window border and continue it on the next line. Note: line wrapping has a high performance cost for large documents so should be disabled on slow machines."), NULL); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_line_breaking1), TRUE);
menu_use_auto_indentation1 = gtk_check_menu_item_new_with_mnemonic (_("_Use Auto-indentation")); gtk_widget_show (menu_use_auto_indentation1); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), menu_use_auto_indentation1); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), menu_use_auto_indentation1); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_use_auto_indentation1), TRUE);
set_file_readonly1 = gtk_check_menu_item_new_with_mnemonic (_("Read _Only")); gtk_widget_show (set_file_readonly1); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), set_file_readonly1); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), set_file_readonly1); gtk_tooltips_set_tip (tooltips, set_file_readonly1, _("Treat this file as read-only. No changes can be made."), NULL);
menu_write_unicode_bom1 = gtk_check_menu_item_new_with_mnemonic (_("_Write Unicode BOM")); gtk_widget_show (menu_write_unicode_bom1); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), menu_write_unicode_bom1); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), menu_write_unicode_bom1);
separator10 = gtk_separator_menu_item_new (); gtk_widget_show (separator10); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), separator10); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), separator10); gtk_widget_set_sensitive (separator10, FALSE);
set_filetype1 = gtk_menu_item_new_with_mnemonic (_("Set File_type")); gtk_widget_show (set_filetype1); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), set_filetype1); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), set_filetype1);
set_filetype1_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (set_filetype1), set_filetype1_menu); @@ -819,7 +814,7 @@
set_encoding1 = gtk_menu_item_new_with_mnemonic (_("Set _Encoding")); gtk_widget_show (set_encoding1); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), set_encoding1); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), set_encoding1);
set_encoding1_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (set_encoding1), set_encoding1_menu); @@ -829,7 +824,7 @@
menu_line_endings1 = gtk_menu_item_new_with_mnemonic (_("Set Line E_ndings")); gtk_widget_show (menu_line_endings1); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), menu_line_endings1); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), menu_line_endings1);
menu_line_endings1_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_line_endings1), menu_line_endings1_menu); @@ -854,41 +849,41 @@
separator8 = gtk_separator_menu_item_new (); gtk_widget_show (separator8); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), separator8); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), separator8); gtk_widget_set_sensitive (separator8, FALSE);
menu_replace_tabs = gtk_menu_item_new_with_mnemonic (_("_Replace Tabs by Spaces")); gtk_widget_show (menu_replace_tabs); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), menu_replace_tabs); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), menu_replace_tabs); gtk_tooltips_set_tip (tooltips, menu_replace_tabs, _("Replaces all tabs in document by spaces."), NULL);
separator22 = gtk_separator_menu_item_new (); gtk_widget_show (separator22); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), separator22); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), separator22); gtk_widget_set_sensitive (separator22, FALSE);
menu_fold_all1 = gtk_menu_item_new_with_mnemonic (_("_Fold All")); gtk_widget_show (menu_fold_all1); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), menu_fold_all1); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), menu_fold_all1); gtk_tooltips_set_tip (tooltips, menu_fold_all1, _("Folds all contractible code blocks"), NULL);
menu_unfold_all1 = gtk_menu_item_new_with_mnemonic (_("_Unfold All")); gtk_widget_show (menu_unfold_all1); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), menu_unfold_all1); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), menu_unfold_all1); gtk_tooltips_set_tip (tooltips, menu_unfold_all1, _("Unfolds all contracted code blocks"), NULL);
separator23 = gtk_separator_menu_item_new (); gtk_widget_show (separator23); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), separator23); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), separator23); gtk_widget_set_sensitive (separator23, FALSE);
remove_markers1 = gtk_menu_item_new_with_mnemonic (_("Remove _Markers")); gtk_widget_show (remove_markers1); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), remove_markers1); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), remove_markers1);
menu_remove_indicators1 = gtk_menu_item_new_with_mnemonic (_("Remove Error _Indicators")); gtk_widget_show (menu_remove_indicators1); - gtk_container_add (GTK_CONTAINER (menu_item4_menu), menu_remove_indicators1); + gtk_container_add (GTK_CONTAINER (menu_document1_menu), menu_remove_indicators1); gtk_tooltips_set_tip (tooltips, menu_remove_indicators1, _("Removes all error indicators in the current document."), NULL);
menu_project1 = gtk_menu_item_new_with_mnemonic (_("_Project")); @@ -902,25 +897,25 @@ gtk_widget_show (project_new1); gtk_container_add (GTK_CONTAINER (menu_project1_menu), project_new1);
- image1789 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1789); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_new1), image1789); + image1890 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1890); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_new1), image1890);
project_open1 = gtk_image_menu_item_new_with_mnemonic (_("_Open")); gtk_widget_show (project_open1); gtk_container_add (GTK_CONTAINER (menu_project1_menu), project_open1);
- image1790 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1790); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_open1), image1790); + image1891 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1891); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_open1), image1891);
project_close1 = gtk_image_menu_item_new_with_mnemonic (_("_Close")); gtk_widget_show (project_close1); gtk_container_add (GTK_CONTAINER (menu_project1_menu), project_close1);
- image1791 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1791); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_close1), image1791); + image1892 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1892); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_close1), image1892);
separator34 = gtk_separator_menu_item_new (); gtk_widget_show (separator34); @@ -947,9 +942,9 @@ gtk_container_add (GTK_CONTAINER (tools1_menu), menu_choose_color1); gtk_tooltips_set_tip (tooltips, menu_choose_color1, _("Open a color chooser dialog, to interactively pick colors from a palette."), NULL);
- image1792 = gtk_image_new_from_stock ("gtk-select-color", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1792); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_choose_color1), image1792); + image1893 = gtk_image_new_from_stock ("gtk-select-color", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1893); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_choose_color1), image1893);
menu_count_words1 = gtk_menu_item_new_with_mnemonic (_("_Word Count")); gtk_widget_show (menu_count_words1); @@ -960,53 +955,34 @@ gtk_widget_show (menu_insert_special_chars1); gtk_container_add (GTK_CONTAINER (tools1_menu), menu_insert_special_chars1);
- menu_create_class1 = gtk_image_menu_item_new_with_mnemonic (_("Create cla_ss")); - gtk_widget_show (menu_create_class1); - gtk_container_add (GTK_CONTAINER (tools1_menu), menu_create_class1); - - image1861 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1861); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_create_class1), image1861); - - menu_create_class1_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_create_class1), menu_create_class1_menu); - - menu_create_cpp_class = gtk_menu_item_new_with_mnemonic (_("C++ class")); - gtk_widget_show (menu_create_cpp_class); - gtk_container_add (GTK_CONTAINER (menu_create_class1_menu), menu_create_cpp_class); - - menu_create_gtk_class = gtk_menu_item_new_with_mnemonic (_("GTK+ class")); - gtk_widget_show (menu_create_gtk_class); - gtk_container_add (GTK_CONTAINER (menu_create_class1_menu), menu_create_gtk_class); - menu_help1 = gtk_menu_item_new_with_mnemonic (_("_Help")); gtk_widget_show (menu_help1); gtk_container_add (GTK_CONTAINER (menubar1), menu_help1);
- menu_item5_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_help1), menu_item5_menu); + menu_help1_menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_help1), menu_help1_menu);
help1 = gtk_image_menu_item_new_from_stock ("gtk-help", accel_group); gtk_widget_show (help1); - gtk_container_add (GTK_CONTAINER (menu_item5_menu), help1); + gtk_container_add (GTK_CONTAINER (menu_help1_menu), help1);
keyboard_shortcuts1 = gtk_menu_item_new_with_mnemonic (_("_Keyboard Shortcuts")); gtk_widget_show (keyboard_shortcuts1); - gtk_container_add (GTK_CONTAINER (menu_item5_menu), keyboard_shortcuts1); + gtk_container_add (GTK_CONTAINER (menu_help1_menu), keyboard_shortcuts1); gtk_tooltips_set_tip (tooltips, keyboard_shortcuts1, _("Shows a list of all keyboard shortcuts for Geany."), NULL);
website1 = gtk_menu_item_new_with_mnemonic (_("_Website")); gtk_widget_show (website1); - gtk_container_add (GTK_CONTAINER (menu_item5_menu), website1); + gtk_container_add (GTK_CONTAINER (menu_help1_menu), website1);
separator16 = gtk_separator_menu_item_new (); gtk_widget_show (separator16); - gtk_container_add (GTK_CONTAINER (menu_item5_menu), separator16); + gtk_container_add (GTK_CONTAINER (menu_help1_menu), separator16); gtk_widget_set_sensitive (separator16, FALSE);
menu_info1 = gtk_image_menu_item_new_from_stock ("gtk-about", accel_group); gtk_widget_show (menu_info1); - gtk_container_add (GTK_CONTAINER (menu_item5_menu), menu_info1); + gtk_container_add (GTK_CONTAINER (menu_help1_menu), menu_info1);
toolbar1 = gtk_toolbar_new (); gtk_widget_show (toolbar1); @@ -1532,12 +1508,6 @@ g_signal_connect ((gpointer) menu_insert_special_chars1, "activate", G_CALLBACK (on_menu_insert_special_chars1_activate), NULL); - g_signal_connect ((gpointer) menu_create_cpp_class, "activate", - G_CALLBACK (on_menu_create_cpp_class_activate), - NULL); - g_signal_connect ((gpointer) menu_create_gtk_class, "activate", - G_CALLBACK (on_menu_create_gtk_class_activate), - NULL); g_signal_connect ((gpointer) help1, "activate", G_CALLBACK (on_help1_activate), NULL); @@ -1635,7 +1605,7 @@ GLADE_HOOKUP_OBJECT (window1, file1_menu, "file1_menu"); GLADE_HOOKUP_OBJECT (window1, menu_new1, "menu_new1"); GLADE_HOOKUP_OBJECT (window1, menu_new_with_template1, "menu_new_with_template1"); - GLADE_HOOKUP_OBJECT (window1, image1776, "image1776"); + GLADE_HOOKUP_OBJECT (window1, image1877, "image1877"); GLADE_HOOKUP_OBJECT (window1, menu_new_with_template1_menu, "menu_new_with_template1_menu"); GLADE_HOOKUP_OBJECT (window1, invisible2, "invisible2"); GLADE_HOOKUP_OBJECT (window1, separator12, "separator12"); @@ -1646,11 +1616,11 @@ GLADE_HOOKUP_OBJECT (window1, menu_save1, "menu_save1"); GLADE_HOOKUP_OBJECT (window1, menu_save_as1, "menu_save_as1"); GLADE_HOOKUP_OBJECT (window1, menu_save_all1, "menu_save_all1"); - GLADE_HOOKUP_OBJECT (window1, image1777, "image1777"); + GLADE_HOOKUP_OBJECT (window1, image1878, "image1878"); GLADE_HOOKUP_OBJECT (window1, menu_reload1, "menu_reload1"); - GLADE_HOOKUP_OBJECT (window1, image1778, "image1778"); + GLADE_HOOKUP_OBJECT (window1, image1879, "image1879"); GLADE_HOOKUP_OBJECT (window1, menu_reload_as1, "menu_reload_as1"); - GLADE_HOOKUP_OBJECT (window1, image1779, "image1779"); + GLADE_HOOKUP_OBJECT (window1, image1880, "image1880"); GLADE_HOOKUP_OBJECT (window1, menu_reload_as1_menu, "menu_reload_as1_menu"); GLADE_HOOKUP_OBJECT (window1, invisible7, "invisible7"); GLADE_HOOKUP_OBJECT (window1, separator21, "separator21"); @@ -1662,7 +1632,7 @@ GLADE_HOOKUP_OBJECT (window1, separator14, "separator14"); GLADE_HOOKUP_OBJECT (window1, menu_close1, "menu_close1"); GLADE_HOOKUP_OBJECT (window1, menu_close_all1, "menu_close_all1"); - GLADE_HOOKUP_OBJECT (window1, image1780, "image1780"); + GLADE_HOOKUP_OBJECT (window1, image1881, "image1881"); GLADE_HOOKUP_OBJECT (window1, menu_separatormenuitem1, "menu_separatormenuitem1"); GLADE_HOOKUP_OBJECT (window1, menu_quit1, "menu_quit1"); GLADE_HOOKUP_OBJECT (window1, edit1, "edit1"); @@ -1688,20 +1658,20 @@ GLADE_HOOKUP_OBJECT (window1, menu_duplicate_line1, "menu_duplicate_line1"); GLADE_HOOKUP_OBJECT (window1, separator29, "separator29"); GLADE_HOOKUP_OBJECT (window1, menu_increase_indent1, "menu_increase_indent1"); - GLADE_HOOKUP_OBJECT (window1, image1781, "image1781"); + GLADE_HOOKUP_OBJECT (window1, image1882, "image1882"); GLADE_HOOKUP_OBJECT (window1, menu_decrease_indent1, "menu_decrease_indent1"); - GLADE_HOOKUP_OBJECT (window1, image1782, "image1782"); + GLADE_HOOKUP_OBJECT (window1, image1883, "image1883"); GLADE_HOOKUP_OBJECT (window1, separator37, "separator37"); GLADE_HOOKUP_OBJECT (window1, send_selection_to2, "send_selection_to2"); GLADE_HOOKUP_OBJECT (window1, send_selection_to2_menu, "send_selection_to2_menu"); GLADE_HOOKUP_OBJECT (window1, invisible13, "invisible13"); GLADE_HOOKUP_OBJECT (window1, separator18, "separator18"); GLADE_HOOKUP_OBJECT (window1, insert_include2, "insert_include2"); - GLADE_HOOKUP_OBJECT (window1, image1783, "image1783"); + GLADE_HOOKUP_OBJECT (window1, image1884, "image1884"); GLADE_HOOKUP_OBJECT (window1, insert_include2_menu, "insert_include2_menu"); GLADE_HOOKUP_OBJECT (window1, invisible4, "invisible4"); GLADE_HOOKUP_OBJECT (window1, add_comments1, "add_comments1"); - GLADE_HOOKUP_OBJECT (window1, image1784, "image1784"); + GLADE_HOOKUP_OBJECT (window1, image1885, "image1885"); GLADE_HOOKUP_OBJECT (window1, add_comments1_menu, "add_comments1_menu"); GLADE_HOOKUP_OBJECT (window1, menu_add_changelog_entry1, "menu_add_changelog_entry1"); GLADE_HOOKUP_OBJECT (window1, insert_file_header1, "insert_file_header1"); @@ -1710,7 +1680,7 @@ GLADE_HOOKUP_OBJECT (window1, insert_gpl_notice2, "insert_gpl_notice2"); GLADE_HOOKUP_OBJECT (window1, insert_bsd_license_notice2, "insert_bsd_license_notice2"); GLADE_HOOKUP_OBJECT (window1, insert_date1, "insert_date1"); - GLADE_HOOKUP_OBJECT (window1, image1785, "image1785"); + GLADE_HOOKUP_OBJECT (window1, image1886, "image1886"); GLADE_HOOKUP_OBJECT (window1, insert_date1_menu, "insert_date1_menu"); GLADE_HOOKUP_OBJECT (window1, invisible8, "invisible8"); GLADE_HOOKUP_OBJECT (window1, separator9, "separator9"); @@ -1722,7 +1692,7 @@ GLADE_HOOKUP_OBJECT (window1, find_previous1, "find_previous1"); GLADE_HOOKUP_OBJECT (window1, find_in_files1, "find_in_files1"); GLADE_HOOKUP_OBJECT (window1, replace1, "replace1"); - GLADE_HOOKUP_OBJECT (window1, image1786, "image1786"); + GLADE_HOOKUP_OBJECT (window1, image1887, "image1887"); GLADE_HOOKUP_OBJECT (window1, separator33, "separator33"); GLADE_HOOKUP_OBJECT (window1, find_nextsel1, "find_nextsel1"); GLADE_HOOKUP_OBJECT (window1, find_prevsel1, "find_prevsel1"); @@ -1730,11 +1700,11 @@ GLADE_HOOKUP_OBJECT (window1, next_message1, "next_message1"); GLADE_HOOKUP_OBJECT (window1, separator32, "separator32"); GLADE_HOOKUP_OBJECT (window1, go_to_line1, "go_to_line1"); - GLADE_HOOKUP_OBJECT (window1, image1787, "image1787"); + GLADE_HOOKUP_OBJECT (window1, image1888, "image1888"); GLADE_HOOKUP_OBJECT (window1, menu_view1, "menu_view1"); - GLADE_HOOKUP_OBJECT (window1, menuitem3_menu, "menuitem3_menu"); + GLADE_HOOKUP_OBJECT (window1, menu_view1_menu, "menu_view1_menu"); GLADE_HOOKUP_OBJECT (window1, menu_change_font1, "menu_change_font1"); - GLADE_HOOKUP_OBJECT (window1, image1788, "image1788"); + GLADE_HOOKUP_OBJECT (window1, image1889, "image1889"); GLADE_HOOKUP_OBJECT (window1, menu_separator4, "menu_separator4"); GLADE_HOOKUP_OBJECT (window1, menu_toggle_all_additional_widgets1, "menu_toggle_all_additional_widgets1"); GLADE_HOOKUP_OBJECT (window1, menu_fullscreen1, "menu_fullscreen1"); @@ -1748,7 +1718,7 @@ GLADE_HOOKUP_OBJECT (window1, menu_zoom_out1, "menu_zoom_out1"); GLADE_HOOKUP_OBJECT (window1, normal_size1, "normal_size1"); GLADE_HOOKUP_OBJECT (window1, menu_document1, "menu_document1"); - GLADE_HOOKUP_OBJECT (window1, menu_item4_menu, "menu_item4_menu"); + GLADE_HOOKUP_OBJECT (window1, menu_document1_menu, "menu_document1_menu"); GLADE_HOOKUP_OBJECT (window1, menu_line_breaking1, "menu_line_breaking1"); GLADE_HOOKUP_OBJECT (window1, menu_use_auto_indentation1, "menu_use_auto_indentation1"); GLADE_HOOKUP_OBJECT (window1, set_file_readonly1, "set_file_readonly1"); @@ -1776,27 +1746,22 @@ GLADE_HOOKUP_OBJECT (window1, menu_project1, "menu_project1"); GLADE_HOOKUP_OBJECT (window1, menu_project1_menu, "menu_project1_menu"); GLADE_HOOKUP_OBJECT (window1, project_new1, "project_new1"); - GLADE_HOOKUP_OBJECT (window1, image1789, "image1789"); + GLADE_HOOKUP_OBJECT (window1, image1890, "image1890"); GLADE_HOOKUP_OBJECT (window1, project_open1, "project_open1"); - GLADE_HOOKUP_OBJECT (window1, image1790, "image1790"); + GLADE_HOOKUP_OBJECT (window1, image1891, "image1891"); GLADE_HOOKUP_OBJECT (window1, project_close1, "project_close1"); - GLADE_HOOKUP_OBJECT (window1, image1791, "image1791"); + GLADE_HOOKUP_OBJECT (window1, image1892, "image1892"); GLADE_HOOKUP_OBJECT (window1, separator34, "separator34"); GLADE_HOOKUP_OBJECT (window1, project_properties1, "project_properties1"); GLADE_HOOKUP_OBJECT (window1, menu_build1, "menu_build1"); GLADE_HOOKUP_OBJECT (window1, tools1, "tools1"); GLADE_HOOKUP_OBJECT (window1, tools1_menu, "tools1_menu"); GLADE_HOOKUP_OBJECT (window1, menu_choose_color1, "menu_choose_color1"); - GLADE_HOOKUP_OBJECT (window1, image1792, "image1792"); + GLADE_HOOKUP_OBJECT (window1, image1893, "image1893"); GLADE_HOOKUP_OBJECT (window1, menu_count_words1, "menu_count_words1"); GLADE_HOOKUP_OBJECT (window1, menu_insert_special_chars1, "menu_insert_special_chars1"); - GLADE_HOOKUP_OBJECT (window1, menu_create_class1, "menu_create_class1"); - GLADE_HOOKUP_OBJECT (window1, image1861, "image1861"); - GLADE_HOOKUP_OBJECT (window1, menu_create_class1_menu, "menu_create_class1_menu"); - GLADE_HOOKUP_OBJECT (window1, menu_create_cpp_class, "menu_create_cpp_class"); - GLADE_HOOKUP_OBJECT (window1, menu_create_gtk_class, "menu_create_gtk_class"); GLADE_HOOKUP_OBJECT (window1, menu_help1, "menu_help1"); - GLADE_HOOKUP_OBJECT (window1, menu_item5_menu, "menu_item5_menu"); + GLADE_HOOKUP_OBJECT (window1, menu_help1_menu, "menu_help1_menu"); GLADE_HOOKUP_OBJECT (window1, help1, "help1"); GLADE_HOOKUP_OBJECT (window1, keyboard_shortcuts1, "keyboard_shortcuts1"); GLADE_HOOKUP_OBJECT (window1, website1, "website1"); @@ -1994,20 +1959,20 @@ GtkWidget *menu_duplicate_line2; GtkWidget *separator31; GtkWidget *menu_increase_indent2; - GtkWidget *image1693; + GtkWidget *image1894; GtkWidget *menu_decrease_indent2; - GtkWidget *image1694; + GtkWidget *image1895; GtkWidget *separator38; GtkWidget *send_selection_to1; GtkWidget *send_selection_to1_menu; GtkWidget *invisible12; GtkWidget *separator17; GtkWidget *insert_include1; - GtkWidget *image1695; + GtkWidget *image1896; GtkWidget *insert_include1_menu; GtkWidget *invisible3; GtkWidget *comments; - GtkWidget *image1696; + GtkWidget *image1897; GtkWidget *comments_menu; GtkWidget *add_changelog_entry2; GtkWidget *insert_file_header2; @@ -2016,18 +1981,18 @@ GtkWidget *insert_gpl_notice1; GtkWidget *insert_bsd_license_notice1; GtkWidget *insert_date2; - GtkWidget *image1697; + GtkWidget *image1898; GtkWidget *insert_date2_menu; GtkWidget *invisible10; GtkWidget *separator7; GtkWidget *find_usage1; - GtkWidget *image1698; + GtkWidget *image1899; GtkWidget *goto_tag_definition1; GtkWidget *goto_tag_declaration1; GtkWidget *context_action1; GtkWidget *separator15; GtkWidget *go_to_line; - GtkWidget *image1699; + GtkWidget *image1900; GtkAccelGroup *accel_group; GtkTooltips *tooltips;
@@ -2134,17 +2099,17 @@ gtk_widget_show (menu_increase_indent2); gtk_container_add (GTK_CONTAINER (menu_format2_menu), menu_increase_indent2);
- image1693 = gtk_image_new_from_stock ("gtk-indent", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1693); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_increase_indent2), image1693); + image1894 = gtk_image_new_from_stock ("gtk-indent", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1894); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_increase_indent2), image1894);
menu_decrease_indent2 = gtk_image_menu_item_new_with_mnemonic (_("_Decrease Indent")); gtk_widget_show (menu_decrease_indent2); gtk_container_add (GTK_CONTAINER (menu_format2_menu), menu_decrease_indent2);
- image1694 = gtk_image_new_from_stock ("gtk-unindent", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1694); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_decrease_indent2), image1694); + image1895 = gtk_image_new_from_stock ("gtk-unindent", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1895); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_decrease_indent2), image1895);
separator38 = gtk_separator_menu_item_new (); gtk_widget_show (separator38); @@ -2170,9 +2135,9 @@ gtk_widget_show (insert_include1); gtk_container_add (GTK_CONTAINER (edit_menu1), insert_include1);
- image1695 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1695); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_include1), image1695); + image1896 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1896); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_include1), image1896);
insert_include1_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_include1), insert_include1_menu); @@ -2184,9 +2149,9 @@ gtk_widget_show (comments); gtk_container_add (GTK_CONTAINER (edit_menu1), comments);
- image1696 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1696); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (comments), image1696); + image1897 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1897); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (comments), image1897);
comments_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (comments), comments_menu); @@ -2216,7 +2181,7 @@ gtk_container_add (GTK_CONTAINER (comments_menu), insert_gpl_notice1); gtk_tooltips_set_tip (tooltips, insert_gpl_notice1, _("Inserts a GPL notice (should be done at the beginning of the file)"), NULL);
- insert_bsd_license_notice1 = gtk_menu_item_new_with_mnemonic (_("Insert BSD license Notice")); + insert_bsd_license_notice1 = gtk_menu_item_new_with_mnemonic (_("Insert BSD License Notice")); gtk_widget_show (insert_bsd_license_notice1); gtk_container_add (GTK_CONTAINER (comments_menu), insert_bsd_license_notice1); gtk_tooltips_set_tip (tooltips, insert_bsd_license_notice1, _("Inserts a BSD licence notice (should be done at the beginning of the file)"), NULL); @@ -2225,9 +2190,9 @@ gtk_widget_show (insert_date2); gtk_container_add (GTK_CONTAINER (edit_menu1), insert_date2);
- image1697 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1697); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_date2), image1697); + image1898 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1898); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_date2), image1898);
insert_date2_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_date2), insert_date2_menu); @@ -2244,9 +2209,9 @@ gtk_widget_show (find_usage1); gtk_container_add (GTK_CONTAINER (edit_menu1), find_usage1);
- image1698 = gtk_image_new_from_stock ("gtk-find", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1698); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (find_usage1), image1698); + image1899 = gtk_image_new_from_stock ("gtk-find", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1899); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (find_usage1), image1899);
goto_tag_definition1 = gtk_menu_item_new_with_mnemonic (_("Go to Tag Definition")); gtk_widget_show (goto_tag_definition1); @@ -2270,9 +2235,9 @@ gtk_container_add (GTK_CONTAINER (edit_menu1), go_to_line); gtk_tooltips_set_tip (tooltips, go_to_line, _("Goto to the entered line"), NULL);
- image1699 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_MENU); - gtk_widget_show (image1699); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (go_to_line), image1699); + image1900 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_MENU); + gtk_widget_show (image1900); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (go_to_line), image1900);
g_signal_connect ((gpointer) undo1, "activate", G_CALLBACK (on_undo1_activate), @@ -2381,20 +2346,20 @@ GLADE_HOOKUP_OBJECT (edit_menu1, menu_duplicate_line2, "menu_duplicate_line2"); GLADE_HOOKUP_OBJECT (edit_menu1, separator31, "separator31"); GLADE_HOOKUP_OBJECT (edit_menu1, menu_increase_indent2, "menu_increase_indent2"); - GLADE_HOOKUP_OBJECT (edit_menu1, image1693, "image1693"); + GLADE_HOOKUP_OBJECT (edit_menu1, image1894, "image1894"); GLADE_HOOKUP_OBJECT (edit_menu1, menu_decrease_indent2, "menu_decrease_indent2"); - GLADE_HOOKUP_OBJECT (edit_menu1, image1694, "image1694"); + GLADE_HOOKUP_OBJECT (edit_menu1, image1895, "image1895"); GLADE_HOOKUP_OBJECT (edit_menu1, separator38, "separator38"); GLADE_HOOKUP_OBJECT (edit_menu1, send_selection_to1, "send_selection_to1"); GLADE_HOOKUP_OBJECT (edit_menu1, send_selection_to1_menu, "send_selection_to1_menu"); GLADE_HOOKUP_OBJECT (edit_menu1, invisible12, "invisible12"); GLADE_HOOKUP_OBJECT (edit_menu1, separator17, "separator17"); GLADE_HOOKUP_OBJECT (edit_menu1, insert_include1, "insert_include1"); - GLADE_HOOKUP_OBJECT (edit_menu1, image1695, "image1695"); + GLADE_HOOKUP_OBJECT (edit_menu1, image1896, "image1896"); GLADE_HOOKUP_OBJECT (edit_menu1, insert_include1_menu, "insert_include1_menu"); GLADE_HOOKUP_OBJECT (edit_menu1, invisible3, "invisible3"); GLADE_HOOKUP_OBJECT (edit_menu1, comments, "comments"); - GLADE_HOOKUP_OBJECT (edit_menu1, image1696, "image1696"); + GLADE_HOOKUP_OBJECT (edit_menu1, image1897, "image1897"); GLADE_HOOKUP_OBJECT (edit_menu1, comments_menu, "comments_menu"); GLADE_HOOKUP_OBJECT (edit_menu1, add_changelog_entry2, "add_changelog_entry2"); GLADE_HOOKUP_OBJECT (edit_menu1, insert_file_header2, "insert_file_header2"); @@ -2403,18 +2368,18 @@ GLADE_HOOKUP_OBJECT (edit_menu1, insert_gpl_notice1, "insert_gpl_notice1"); GLADE_HOOKUP_OBJECT (edit_menu1, insert_bsd_license_notice1, "insert_bsd_license_notice1"); GLADE_HOOKUP_OBJECT (edit_menu1, insert_date2, "insert_date2"); - GLADE_HOOKUP_OBJECT (edit_menu1, image1697, "image1697"); + GLADE_HOOKUP_OBJECT (edit_menu1, image1898, "image1898"); GLADE_HOOKUP_OBJECT (edit_menu1, insert_date2_menu, "insert_date2_menu"); GLADE_HOOKUP_OBJECT (edit_menu1, invisible10, "invisible10"); GLADE_HOOKUP_OBJECT (edit_menu1, separator7, "separator7"); GLADE_HOOKUP_OBJECT (edit_menu1, find_usage1, "find_usage1"); - GLADE_HOOKUP_OBJECT (edit_menu1, image1698, "image1698"); + GLADE_HOOKUP_OBJECT (edit_menu1, image1899, "image1899"); GLADE_HOOKUP_OBJECT (edit_menu1, goto_tag_definition1, "goto_tag_definition1"); GLADE_HOOKUP_OBJECT (edit_menu1, goto_tag_declaration1, "goto_tag_declaration1"); GLADE_HOOKUP_OBJECT (edit_menu1, context_action1, "context_action1"); GLADE_HOOKUP_OBJECT (edit_menu1, separator15, "separator15"); GLADE_HOOKUP_OBJECT (edit_menu1, go_to_line, "go_to_line"); - GLADE_HOOKUP_OBJECT (edit_menu1, image1699, "image1699"); + GLADE_HOOKUP_OBJECT (edit_menu1, image1900, "image1900"); GLADE_HOOKUP_OBJECT_NO_REF (edit_menu1, tooltips, "tooltips");
gtk_menu_set_accel_group (GTK_MENU (edit_menu1), accel_group);
Modified: trunk/src/plugindata.h =================================================================== --- trunk/src/plugindata.h 2007-07-04 11:14:05 UTC (rev 1658) +++ trunk/src/plugindata.h 2007-07-04 11:32:33 UTC (rev 1659) @@ -27,7 +27,7 @@
/* The API version should be incremented whenever any plugin data types below are * modified. */ -static const gint api_version = 2; +static const gint api_version = 3;
/* The ABI version should be incremented whenever existing fields in the plugin * data types below have to be changed or reordered. It should stay the same if fields @@ -68,6 +68,11 @@ }
+typedef struct DocumentFuncs DocumentFuncs; +typedef struct ScintillaFuncs ScintillaFuncs; +typedef struct TemplateFuncs TemplateFuncs; +typedef struct UtilsFuncs UtilsFuncs; + /* These are fields and functions owned by Geany. * Fields will be appended when needed by plugin authors. * Note: Remember to increment api_version (and abi_version if necessary) when @@ -76,10 +81,41 @@ { MyApp *app; // Geany application data fields
- /* Almost all plugins should add menu items to the Tools menu only */ - GtkWidget *tools_menu; + GtkWidget *tools_menu; // Almost all plugins should add menu items to the Tools menu only + + GArray *doc_array; // array of document pointers + + DocumentFuncs *document; + ScintillaFuncs *sci; + TemplateFuncs *templates; + UtilsFuncs *utils; } PluginData;
+struct filetype; + +struct DocumentFuncs +{ + gint (*new_file) (const gchar *filename, struct filetype *ft); +}; + +struct _ScintillaObject; + +struct ScintillaFuncs +{ + void (*set_text) (struct _ScintillaObject *sci, const gchar *text); +}; + +struct TemplateFuncs +{ + gchar* (*get_template_fileheader) (gint filetype_idx, const gchar *fname); +}; + +struct UtilsFuncs +{ + gboolean (*str_equal) (const gchar *a, const gchar *b); + gchar* (*str_replace) (gchar *haystack, const gchar *needle, const gchar *replacement); +}; + #endif
Modified: trunk/src/plugins.c =================================================================== --- trunk/src/plugins.c 2007-07-04 11:14:05 UTC (rev 1658) +++ trunk/src/plugins.c 2007-07-04 11:32:33 UTC (rev 1659) @@ -32,11 +32,12 @@ #include "plugindata.h" #include "support.h" #include "utils.h" +#include "document.h" +#include "templates.h" +#include "sciwrappers.h"
-typedef struct Plugin Plugin; - -struct Plugin +typedef struct Plugin { GModule *module; gchar *filename; // plugin filename (/path/libname.so) @@ -45,11 +46,46 @@ PluginInfo* (*info) (); /* Returns plugin name, description */ void (*init) (PluginData *data); /* Called when the plugin is enabled */ void (*cleanup) (); /* Called when the plugin is disabled or when Geany exits */ -}; +} +Plugin;
+static DocumentFuncs doc_funcs; +static ScintillaFuncs sci_funcs; +static TemplateFuncs template_funcs; +static UtilsFuncs utils_funcs; + static GList *plugin_list = NULL;
+ +static void +init_function_pointers() +{ + doc_funcs.new_file = &document_new_file; + + template_funcs.get_template_fileheader = &templates_get_template_fileheader; + + sci_funcs.set_text = &sci_set_text; + + utils_funcs.str_equal = &utils_str_equal; + utils_funcs.str_replace = &utils_str_replace; +} + + +static void +init_plugin_data(PluginData *data) +{ + data->app = app; + data->tools_menu = lookup_widget(app->window, "tools1_menu"); + data->doc_array = doc_array; + + data->document = &doc_funcs; + data->sci = &sci_funcs; + data->templates = &template_funcs; + data->utils = &utils_funcs; +} + + /* Prevent the same plugin filename being loaded more than once. * Note: g_module_name always returns the .so name, even when Plugin::filename * is an .la file. */ @@ -108,7 +144,10 @@ g_return_val_if_fail(fname, NULL); g_return_val_if_fail(g_module_supported(), NULL);
- module = g_module_open(fname, G_MODULE_BIND_LAZY); + /* Don't use G_MODULE_BIND_LAZY otherwise we can get unresolved symbols at runtime, + * causing a segfault. + * Without that flag the module will safely fail to load. */ + module = g_module_open(fname, 0); if (! module) { g_warning("%s", g_module_error()); @@ -148,8 +187,7 @@ plugin->filename = g_strdup(fname); plugin->module = module;
- plugin->data.app = app; - plugin->data.tools_menu = lookup_widget(app->window, "tools1_menu"); + init_plugin_data(&plugin->data);
g_module_symbol(module, "init", (void *) &plugin->init); g_module_symbol(module, "cleanup", (void *) &plugin->cleanup); @@ -192,6 +230,8 @@ const gchar *path = LIBDIR; GSList *list, *item;
+ init_function_pointers(); + list = utils_get_file_list(path, NULL, NULL);
for (item = list; item != NULL; item = g_slist_next(item))
Modified: trunk/src/templates.c =================================================================== --- trunk/src/templates.c 2007-07-04 11:14:05 UTC (rev 1658) +++ trunk/src/templates.c 2007-07-04 11:32:33 UTC (rev 1659) @@ -206,128 +206,6 @@ x = StdClass.new\n\ ";
-static const gchar templates_cpp_class_header[] = "{fileheader}\n\n\ -#ifndef {header_guard}\n\ -#define {header_guard}\n\ -{base_include}\n\ -class {class_name}{base_decl}\n\ -{\n\ - public:\n\ - {constructor_decl}\ - {destructor_decl}\ - \n\ - private:\n\ - // add your private declarations\n\ -};\n\ -\n\ -#endif // {header_guard}\n\ -"; - -static const gchar templates_cpp_class_source[] = "{fileheader}\n\n\ -#include "{header}"\n\ -\n\ -{constructor_impl}\n\ -{destructor_impl}\n\ -"; - -static const gchar templates_gtk_class_header[] = "{fileheader}\n\n\ -#ifndef __{header_guard}__\n\ -#define __{header_guard}__\n\ -{base_include}\n\ -G_BEGIN_DECLS\n\ -\n\ -#define {class_name_up}_TYPE ({class_name_low}_get_type())\n\ -#define {class_name_up}(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\\n\ - {class_name_up}_TYPE, {class_name}))\n\ -#define {class_name_up}_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\\n\ - {class_name_up}_TYPE, {class_name}Class))\n\ -#define IS_{class_name_up}(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\\n\ - {class_name_up}_TYPE))\n\ -#define IS_{class_name_up}_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\\n\ - {class_name_up}_TYPE))\n\ -\n\ -typedef struct _{class_name} {class_name};\n\ -typedef struct _{class_name}Class {class_name}Class;\n\ -\n\ -struct _{class_name}\n\ -{\n\ - {base_name} parent;\n\ - /* add your public declarations here */\n\ -};\n\ -\n\ -struct _{class_name}Class\n\ -{\n\ - {base_name}Class parent_class;\n\ -};\n\ -\n\ -GType {class_name_low}_get_type (void);\n\ -{constructor_decl}\ -\n\ -G_END_DECLS\n\ -\n\ -#endif /* __{header_guard}__ */\n\ -"; - -static const gchar templates_gtk_class_source[] = "{fileheader}\n\ -#include "{header}"\n\ -\n\ -typedef struct _{class_name}Private {class_name}Private;\n\ -\n\ -#define {class_name_up}_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj),\\n\ - {class_name_up}_TYPE, {class_name}Private))\n\ -\n\ -struct _{class_name}Private\n\ -{\n\ - /* add your private declarations here */\n\ -};\n\ -\n\ -static void {class_name_low}_class_init ({class_name}Class *klass);\n\ -static void {class_name_low}_init ({class_name} *self);\n\ -{destructor_decl}\ -\n\ -/* Local data */\n\ -static {base_name}Class *parent_class = NULL;\n\ -\n\ -GType {class_name_low}_get_type(void)\n\ -{\n\ - static GType self_type = 0;\n\ - if (! self_type)\n\ - {\n\ - static const GTypeInfo self_info = \n\ - {\n\ - sizeof({class_name}Class),\n\ - NULL, /* base_init */\n\ - NULL, /* base_finalize */\n\ - (GClassInitFunc){class_name_low}_class_init,\n\ - NULL, /* class_finalize */\n\ - NULL, /* class_data */\n\ - sizeof({class_name}),\n\ - 0,\n\ - (GInstanceInitFunc){class_name_low}_init,\n\ - };\n\ - \n\ - self_type = g_type_register_static({base_gtype}, "{class_name}", &self_info, 0);\ - }\n\ - \n\
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.