[anjuta] Add JavaScript wizard to class-gen plugin
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] Add JavaScript wizard to class-gen plugin
- Date: Wed, 22 Dec 2010 15:40:06 +0000 (UTC)
commit 5b69927abbfeed06e00362ad85db45c0f5188f1c
Author: Kenny Meyer <knny myer gmail com>
Date: Mon Dec 20 13:00:11 2010 -0300
Add JavaScript wizard to class-gen plugin
plugins/class-gen/anjuta-class-gen-plugin.ui | 457 +++++++++++++++++++++++++-
plugins/class-gen/templates/Makefile.am | 1 +
plugins/class-gen/templates/js-source.tpl | 80 +++++
plugins/class-gen/window.c | 164 +++++++++-
4 files changed, 693 insertions(+), 9 deletions(-)
---
diff --git a/plugins/class-gen/anjuta-class-gen-plugin.ui b/plugins/class-gen/anjuta-class-gen-plugin.ui
index 5d8a470..df87d03 100644
--- a/plugins/class-gen/anjuta-class-gen-plugin.ui
+++ b/plugins/class-gen/anjuta-class-gen-plugin.ui
@@ -1094,6 +1094,451 @@
<property name="label" translatable="yes">Python Class</property>
</object>
<packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox_javascript">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkFrame" id="frame_javascript">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="n_rows">4</property>
+ <property name="n_columns">4</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Class Name:</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkEntry" id="js_name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Source/Header Headings:</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="js_headings">
+ <property name="label" translatable="yes">Author/Date/Time</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="lbl_js_base">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="label" translatable="yes">Base Class:</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="js_base">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="js_is_subclass">
+ <property name="label" translatable="yes">is Sub-Class</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label23">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Initializer Arguments:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="js_initargs">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">General Class Properties</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame2">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkNotebook" id="notebook3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkVBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="border_width">8</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow3">
+ <property name="height_request">100</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="js_methods">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox3">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="js_methods_remove">
+ <property name="label">gtk-remove</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="js_methods_add">
+ <property name="label">gtk-add</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Methods</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox5">
+ <property name="visible">True</property>
+ <property name="border_width">8</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow6">
+ <property name="height_request">100</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="js_variables">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox6">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="js_variables_remove">
+ <property name="label">gtk-remove</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="js_variables_add">
+ <property name="label">gtk-add</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label14">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Variables</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox642">
+ <property name="visible">True</property>
+ <property name="border_width">8</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow9">
+ <property name="height_request">100</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="js_imports">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox9">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="js_imports_remove">
+ <property name="label">gtk-remove</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="js_imports_add">
+ <property name="label">gtk-add</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label1213">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Imports</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label15">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Class Elements</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label16">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">JavaScript Class</property>
+ </object>
+ <packing>
<property name="position">3</property>
<property name="tab_fill">False</property>
</packing>
@@ -1125,7 +1570,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label14">
+ <object class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Author Email Address:</property>
@@ -1154,7 +1599,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label12">
+ <object class="GtkLabel" id="label18">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Author Name:</property>
@@ -1186,7 +1631,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label8">
+ <object class="GtkLabel" id="label19">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">License:</property>
@@ -1199,7 +1644,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label5">
+ <object class="GtkLabel" id="label20">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Header File:</property>
@@ -1231,7 +1676,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label6">
+ <object class="GtkLabel" id="label21">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Source File:</property>
@@ -1352,7 +1797,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label7">
+ <object class="GtkLabel" id="label22">
<property name="visible">True</property>
<property name="label" translatable="yes">Create</property>
</object>
diff --git a/plugins/class-gen/templates/Makefile.am b/plugins/class-gen/templates/Makefile.am
index d4838ae..41e0beb 100644
--- a/plugins/class-gen/templates/Makefile.am
+++ b/plugins/class-gen/templates/Makefile.am
@@ -5,6 +5,7 @@ clsgen_appdata_DATA = \
cc-source.tpl \
go-header.tpl \
go-source.tpl \
+ js-source.tpl \
py-source.tpl
EXTRA_DIST = \
diff --git a/plugins/class-gen/templates/js-source.tpl b/plugins/class-gen/templates/js-source.tpl
new file mode 100644
index 0000000..58827f4
--- /dev/null
+++ b/plugins/class-gen/templates/js-source.tpl
@@ -0,0 +1,80 @@
+[+ AutoGen5 template
+##
+## js-source.tpl
+## Copyright (C) 2010 Kenny Meyer <knny myer gmail 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 Library 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.
++]
+/* -*- Mode: javascript; js-basic-offset: 4; indent-tabs-mode: nil -*-
+ *
+ * [+ProjectName+][+IF (=(get "Headings") "1")+]
+ * Copyright (C) [+AuthorName+] [+(shell "date +%Y")+] <[+AuthorEmail+]>[+ENDIF+]
+ *
+[+CASE (get "License") +]
+[+ == "BSD" +][+(bsd (get "ProjectName") (get "AuthorName") " * ")+]
+[+ == "LGPL" +][+(lgpl (get "ProjectName") (get "AuthorName") " * ")+]
+[+ == "GPL" +][+(gpl (get "ProjectName") " * ")+]
+[+ESAC+] */
+
+[+
+FOR Imports +][+
+ IF (not (=(get "Name") "")) +]
+const [+Name+] = imports.[+Module+];[+
+ ENDIF+][+
+ENDFOR+]
+
+[+
+IF (not (=(get "BaseClass") "")) +]
+function [+BaseClass+]([+Initargs+]){
+ this._init([+Initargs+]);
+}
+
+[+BaseClass+].prototype = {
+ _init: function([+Initargs+]) {
+ // The Base class.
+ }
+};[+
+ENDIF+]
+
+function [+ClassName+]() {
+ this._init([+Initargs+]);
+}
+
+[+ClassName+].prototype = {[+
+IF (not (=(get "BaseClass") "")) +]
+ __proto__ : [+BaseClass+].prototype,
+[+
+ENDIF+]
+ _init: function([+Initargs+]) {[+
+FOR Variables +][+
+ IF (not (=(get "Name") "")) +]
+ this.[+Name+] = [+Value+];[+
+ ENDIF+][+
+ENDFOR+]
+ },
+[+
+FOR Methods +][+
+ IF (not (=(get "Name") "")) +]
+ [+Name+] : function[+Arguments+] {
+ // TODO: Delete this line and add something useful[+
+ IF (last-for?) +]
+ }[+
+ ELSE+]
+ },
+[+
+ ENDIF+][+
+ ENDIF+][+
+ENDFOR+]
+};
diff --git a/plugins/class-gen/window.c b/plugins/class-gen/window.c
index 94eaca3..a037b93 100644
--- a/plugins/class-gen/window.c
+++ b/plugins/class-gen/window.c
@@ -38,6 +38,8 @@
#define PY_SOURCE_TEMPLATE PACKAGE_DATA_DIR"/class-templates/py-source.tpl"
+#define JS_SOURCE_TEMPLATE PACKAGE_DATA_DIR"/class-templates/js-source.tpl"
+
typedef struct _CgWindowPrivate CgWindowPrivate;
struct _CgWindowPrivate
{
@@ -46,10 +48,16 @@ struct _CgWindowPrivate
CgElementEditor *editor_cc;
CgElementEditor *editor_go_members;
+
CgElementEditor *editor_go_properties;
CgElementEditor *editor_go_signals;
+
CgElementEditor *editor_py_methods;
CgElementEditor *editor_py_constvars;
+
+ CgElementEditor *editor_js_methods;
+ CgElementEditor *editor_js_variables;
+ CgElementEditor *editor_js_imports;
CgValidator *validator;
};
@@ -311,6 +319,20 @@ cg_window_validate_py (CgWindow *window)
}
static void
+cg_window_validate_js (CgWindow *window)
+{
+ CgWindowPrivate *priv;
+ priv = CG_WINDOW_PRIVATE (window);
+
+ if (priv->validator != NULL) g_object_unref (G_OBJECT (priv->validator));
+
+ priv->validator = cg_validator_new (
+ GTK_WIDGET (gtk_builder_get_object (priv->bxml, "create_button")),
+ GTK_ENTRY (gtk_builder_get_object (priv->bxml, "js_name")),
+ GTK_ENTRY (gtk_builder_get_object (priv->bxml, "source_file")), NULL);
+}
+
+static void
cg_window_header_file_entry_set_sensitive (gpointer user_data, gboolean sensitive)
{
CgWindow *window;
@@ -349,6 +371,10 @@ cg_window_top_notebook_switch_page_cb (G_GNUC_UNUSED GtkNotebook *notebook,
cg_window_header_file_entry_set_sensitive (user_data, FALSE);
cg_window_validate_py (window);
break;
+ case 3: /* JavaScript */
+ cg_window_header_file_entry_set_sensitive (user_data, FALSE);
+ cg_window_validate_js (window);
+ break;
default:
g_assert_not_reached ();
break;
@@ -492,8 +518,9 @@ cg_window_go_name_changed_cb (GtkEntry *entry,
}
static void
-cg_window_py_name_changed_cb (GtkEntry *entry,
- gpointer user_data)
+cg_window_dynamic_name_changed_cb (GtkEntry *entry,
+ gpointer user_data,
+ const gchar *file_ending)
{
CgWindow *window;
CgWindowPrivate *priv;
@@ -512,7 +539,7 @@ cg_window_py_name_changed_cb (GtkEntry *entry,
str_filebase = cg_window_class_name_to_file_name (
gtk_entry_get_text (GTK_ENTRY (entry)));
- str_filesource = g_strconcat (str_filebase, ".py", NULL);
+ str_filesource = g_strconcat (str_filebase, file_ending, NULL);
g_free (str_filebase);
gtk_entry_set_text (GTK_ENTRY (file_header), str_filesource);
@@ -521,6 +548,50 @@ cg_window_py_name_changed_cb (GtkEntry *entry,
g_free (str_filesource);
}
+static void
+cg_window_py_name_changed_cb (GtkEntry *entry,
+ gpointer user_data)
+{
+ cg_window_dynamic_name_changed_cb (entry, user_data, ".py");
+}
+
+static void
+cg_window_js_name_changed_cb (GtkEntry *entry,
+ gpointer user_data)
+{
+ cg_window_dynamic_name_changed_cb (entry, user_data, ".js");
+}
+
+static void
+cg_window_js_is_subclass_changed_cb (GtkEntry *entry,
+ gpointer user_data)
+{
+ CgWindow *window;
+ CgWindowPrivate *priv;
+
+ GtkWidget *is_subclass;
+ GtkWidget *entry_base_class;
+ GtkWidget *label_base_class;
+
+ window = CG_WINDOW (user_data);
+ priv = CG_WINDOW_PRIVATE (window);
+
+ is_subclass = GTK_WIDGET (gtk_builder_get_object (priv->bxml, "js_is_subclass"));
+ entry_base_class = GTK_WIDGET (gtk_builder_get_object (priv->bxml, "js_base"));
+ label_base_class = GTK_WIDGET (gtk_builder_get_object (priv->bxml, "lbl_js_base"));
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (is_subclass)) == TRUE)
+ {
+ gtk_editable_set_editable (GTK_EDITABLE (entry_base_class), TRUE);
+ gtk_widget_set_sensitive (label_base_class, TRUE);
+ }
+ else
+ {
+ gtk_editable_set_editable (GTK_EDITABLE (entry_base_class), FALSE);
+ gtk_widget_set_sensitive (label_base_class, FALSE);
+ }
+}
+
#if 0
static void
cg_window_associate_browse_button (GladeXML *xml,
@@ -621,6 +692,29 @@ cg_window_set_builder (CgWindow *window,
_("Name"), CG_ELEMENT_EDITOR_COLUMN_STRING,
_("Value"), CG_ELEMENT_EDITOR_COLUMN_STRING);
+ priv->editor_js_methods = cg_element_editor_new (
+ GTK_TREE_VIEW (gtk_builder_get_object (priv->bxml, "js_methods")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "js_methods_add")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "js_methods_remove")),
+ 2,
+ _("Name"), CG_ELEMENT_EDITOR_COLUMN_STRING,
+ _("Arguments"), CG_ELEMENT_EDITOR_COLUMN_ARGUMENTS);
+
+ priv->editor_js_variables = cg_element_editor_new (
+ GTK_TREE_VIEW (gtk_builder_get_object (priv->bxml, "js_variables")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "js_variables_add")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "js_variables_remove")),
+ 2,
+ _("Name"), CG_ELEMENT_EDITOR_COLUMN_STRING,
+ _("Value"), CG_ELEMENT_EDITOR_COLUMN_STRING);
+
+ priv->editor_js_imports = cg_element_editor_new (
+ GTK_TREE_VIEW (gtk_builder_get_object (priv->bxml, "js_imports")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "js_imports_add")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "js_imports_remove")),
+ 2,
+ _("Name"), CG_ELEMENT_EDITOR_COLUMN_STRING,
+ _("Module"), CG_ELEMENT_EDITOR_COLUMN_STRING);
/* Active item property in glade cannot be set because no GtkTreeModel
* is assigned. */
@@ -649,6 +743,14 @@ cg_window_set_builder (CgWindow *window,
G_CALLBACK (cg_window_cc_name_changed_cb), window);
g_signal_connect (
+ G_OBJECT (gtk_builder_get_object (priv->bxml, "js_name")), "changed",
+ G_CALLBACK (cg_window_js_name_changed_cb), window);
+
+ g_signal_connect (
+ G_OBJECT (gtk_builder_get_object (priv->bxml, "js_is_subclass")), "toggled",
+ G_CALLBACK (cg_window_js_is_subclass_changed_cb), window);
+
+ g_signal_connect (
G_OBJECT (gtk_builder_get_object (priv->bxml, "add_project")), "toggled",
G_CALLBACK (cg_window_add_project_toggled_cb), window);
@@ -771,6 +873,28 @@ cg_window_py_constvars_transform_func (GHashTable *table,
cg_transform_string (table, "Value");
}
+static void
+cg_window_js_methods_transform_func (GHashTable *table,
+ G_GNUC_UNUSED gpointer user_data)
+{
+ cg_transform_arguments (table, "Arguments", FALSE);
+}
+
+static void
+cg_window_js_variables_transform_func (GHashTable *table,
+ G_GNUC_UNUSED gpointer user_data)
+{
+
+ cg_transform_string (table, "Name");
+}
+
+static void
+cg_window_js_imports_transform_func (GHashTable *table,
+ G_GNUC_UNUSED gpointer user_data)
+{
+ cg_transform_string (table, "Name");
+}
+
#if 0
static gboolean
cg_window_scope_condition_func (const gchar **elements,
@@ -820,6 +944,9 @@ cg_window_init (CgWindow *window)
priv->editor_go_signals = NULL;
priv->editor_py_methods = NULL;
priv->editor_py_constvars = NULL;
+ priv->editor_js_methods = NULL;
+ priv->editor_js_variables = NULL;
+ priv->editor_js_imports = NULL;
priv->validator = NULL;
}
@@ -845,6 +972,12 @@ cg_window_finalize (GObject *object)
g_object_unref (G_OBJECT (priv->editor_py_methods));
if (priv->editor_py_constvars != NULL)
g_object_unref (G_OBJECT (priv->editor_py_constvars));
+ if (priv->editor_js_methods != NULL)
+ g_object_unref (G_OBJECT (priv->editor_js_methods));
+ if (priv->editor_js_variables != NULL)
+ g_object_unref (G_OBJECT (priv->editor_js_variables));
+ if (priv->editor_js_imports != NULL)
+ g_object_unref (G_OBJECT (priv->editor_js_imports));
if (priv->validator != NULL)
g_object_unref (G_OBJECT (priv->validator));
@@ -1119,6 +1252,27 @@ cg_window_create_value_heap (CgWindow *window)
cg_window_py_constvars_transform_func,
window, "Name", "Value");
break;
+ case 3: /* JavaScript */
+ cg_window_set_heap_value (window, values, G_TYPE_STRING,
+ "ClassName", "js_name");
+ cg_window_set_heap_value (window, values, G_TYPE_STRING,
+ "BaseClass", "js_base");
+ cg_window_set_heap_value (window, values, G_TYPE_STRING,
+ "Initargs", "js_initargs");
+ cg_window_set_heap_value (window, values, G_TYPE_BOOLEAN,
+ "Headings", "js_headings");
+ cg_element_editor_set_values (priv->editor_js_methods, "Methods", values,
+ cg_window_js_methods_transform_func,
+ window, "Name", "Arguments");
+ cg_element_editor_set_values (priv->editor_js_variables, "Variables",
+ values,
+ cg_window_js_variables_transform_func,
+ window, "Name", "Value");
+ cg_element_editor_set_values (priv->editor_js_imports, "Imports",
+ values,
+ cg_window_js_imports_transform_func,
+ window, "Name", "Module");
+ break;
default:
g_assert_not_reached ();
break;
@@ -1171,6 +1325,8 @@ cg_window_get_header_template (CgWindow *window)
return GO_HEADER_TEMPLATE;
case 2: /* Python */
return PY_SOURCE_TEMPLATE;
+ case 3: /* JavaScript */
+ return JS_SOURCE_TEMPLATE;
default:
g_assert_not_reached ();
return NULL;
@@ -1210,6 +1366,8 @@ cg_window_get_source_template(CgWindow *window)
return GO_SOURCE_TEMPLATE;
case 2:
return PY_SOURCE_TEMPLATE;
+ case 3: /* JavaScript */
+ return JS_SOURCE_TEMPLATE;
default:
g_assert_not_reached ();
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]