[anjuta] Add Vala class wizard to class-gen plugin
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] Add Vala class wizard to class-gen plugin
- Date: Mon, 27 Dec 2010 13:55:50 +0000 (UTC)
commit 8b7bcf26202124d901bb964f8dd8c667e27cc210
Author: Kenny Meyer <knny myer gmail com>
Date: Thu Dec 23 11:45:29 2010 -0300
Add Vala class wizard to class-gen plugin
plugins/class-gen/anjuta-class-gen-plugin.ui | 449 ++++++++++++++++++++++++++
plugins/class-gen/templates/Makefile.am | 3 +-
plugins/class-gen/templates/vala-source.tpl | 70 ++++
plugins/class-gen/window.c | 179 ++++++++++-
4 files changed, 698 insertions(+), 3 deletions(-)
---
diff --git a/plugins/class-gen/anjuta-class-gen-plugin.ui b/plugins/class-gen/anjuta-class-gen-plugin.ui
index df87d03..c832420 100644
--- a/plugins/class-gen/anjuta-class-gen-plugin.ui
+++ b/plugins/class-gen/anjuta-class-gen-plugin.ui
@@ -1543,6 +1543,455 @@
<property name="tab_fill">False</property>
</packing>
</child>
+ <child>
+ <object class="GtkVBox" id="vbox_vala">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkFrame" id="frame_vala">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment4">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table2">
+ <property name="visible">True</property>
+ <property name="n_rows">5</property>
+ <property name="n_columns">3</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Class Name:</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkEntry" id="vala_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="label17">
+ <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">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="vala_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">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label41">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Class Scope:</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="vala_class_scope">
+ <property name="visible">True</property>
+ <property name="model">model1</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer2"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="lbl_vala_base">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="label" translatable="yes">Base Class:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="vala_base">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</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>
+ <object class="GtkCheckButton" id="vala_derive_from_glib">
+ <property name="label" translatable="yes">Derive from GLib.Object</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="active">True</property>
+ <property name="draw_indicator">True</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>
+ <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="label19">
+ <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="frame3">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment9">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkNotebook" id="notebook4">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkVBox" id="vbox7">
+ <property name="visible">True</property>
+ <property name="border_width">8</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow10">
+ <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="vala_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="hbuttonbox10">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="vala_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="vala_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="label20">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Class Methods</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox11">
+ <property name="visible">True</property>
+ <property name="border_width">8</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow11">
+ <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="vala_properties">
+ <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="hbuttonbox11">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="vala_properties_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="vala_properties_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="label21">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Properties</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox14">
+ <property name="visible">True</property>
+ <property name="border_width">8</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow12">
+ <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="vala_signals">
+ <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="hbuttonbox12">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="vala_signals_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="vala_signals_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="label22">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Signals</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="label24">
+ <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">4</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label25">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Vala Class</property>
+ </object>
+ <packing>
+ <property name="position">4</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">0</property>
diff --git a/plugins/class-gen/templates/Makefile.am b/plugins/class-gen/templates/Makefile.am
index 41e0beb..05c34e6 100644
--- a/plugins/class-gen/templates/Makefile.am
+++ b/plugins/class-gen/templates/Makefile.am
@@ -6,7 +6,8 @@ clsgen_appdata_DATA = \
go-header.tpl \
go-source.tpl \
js-source.tpl \
- py-source.tpl
+ py-source.tpl \
+ vala-source.tpl
EXTRA_DIST = \
$(clsgen_appdata_DATA)
diff --git a/plugins/class-gen/templates/vala-source.tpl b/plugins/class-gen/templates/vala-source.tpl
new file mode 100644
index 0000000..7acdfc7
--- /dev/null
+++ b/plugins/class-gen/templates/vala-source.tpl
@@ -0,0 +1,70 @@
+[+ AutoGen5 template
+##
+## vala-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: vala; tab-width: 4; intend-tabs-mode: t -*- */
+/* [+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+] */
+
+[+ClassScope+] class [+ClassName+][+
+IF (=(get "DeriveFromGlib") "1") +] : GLib.Object[+
+ELIF (not (=(get "BaseClass") "")) +] : [+BaseClass+][+
+ENDIF+] {[+
+FOR Properties+]
+ [+Scope+] [+Type+] _[+Name+] = [+Value+];[+
+ IF (last-for?) +]
+[+
+ ENDIF+][+
+ENDFOR+][+
+FOR Signals+][+
+ IF (first-for?) +]
+ /* Signal definitions */[+ENDIF+]
+ [+Scope+] signal [+Type+] [+Name+] [+Arguments+];[+
+ IF (last-for?) +]
+
+[+
+ ENDIF+][+
+ENDFOR+]
+ // Constructor
+ public [+ClassName+] () {
+ }
+[+
+FOR Properties+]
+ public int [+Name+] {
+ get { return _[+Name+] }[+
+ IF (not (=(get "Setter") "")) +]
+ set { _[+Name+] = value }[+
+ ENDIF+]
+ }[+
+ENDFOR+]
+[+
+FOR Methods+][+
+ IF (first-for?) +]
+ /* Method definitions */[+ENDIF+]
+ [+Scope+] [+Type+] [+Name+] [+Arguments+] {
+ // TODO: Add implementation here.
+ }[+
+ENDFOR+]
+}
diff --git a/plugins/class-gen/window.c b/plugins/class-gen/window.c
index a037b93..3c1c3a3 100644
--- a/plugins/class-gen/window.c
+++ b/plugins/class-gen/window.c
@@ -47,8 +47,8 @@ struct _CgWindowPrivate
GtkWidget *window;
CgElementEditor *editor_cc;
- CgElementEditor *editor_go_members;
+ CgElementEditor *editor_go_members;
CgElementEditor *editor_go_properties;
CgElementEditor *editor_go_signals;
@@ -58,7 +58,11 @@ struct _CgWindowPrivate
CgElementEditor *editor_js_methods;
CgElementEditor *editor_js_variables;
CgElementEditor *editor_js_imports;
-
+
+ CgElementEditor *editor_vala_methods;
+ CgElementEditor *editor_vala_properties;
+ CgElementEditor *editor_vala_signals;
+
CgValidator *validator;
};
@@ -137,6 +141,21 @@ static const CgElementEditorFlags GO_SIGNAL_FLAGS[] =
{ NULL, NULL }
};
+static const gchar *VALA_BOOLEAN_LIST[] =
+{
+ "Yes",
+ "No",
+ NULL
+};
+
+static const gchar *VALA_SCOPE_LIST[] =
+{
+ "public",
+ "private",
+ "protected",
+ NULL
+};
+
#if 0
static void
cg_window_browse_button_clicked_cb (GtkButton *button,
@@ -333,6 +352,21 @@ cg_window_validate_js (CgWindow *window)
}
static void
+cg_window_validate_vala (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, "vala_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;
@@ -375,6 +409,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_js (window);
break;
+ case 4: /* Vala */
+ cg_window_header_file_entry_set_sensitive (user_data, FALSE);
+ cg_window_validate_vala (window);
+ break;
default:
g_assert_not_reached ();
break;
@@ -592,6 +630,43 @@ cg_window_js_is_subclass_changed_cb (GtkEntry *entry,
}
}
+static void
+cg_window_vala_name_changed_cb (GtkEntry *entry,
+ gpointer user_data)
+{
+ cg_window_dynamic_name_changed_cb (entry, user_data, ".vala");
+}
+
+static void
+cg_window_vala_derive_from_glib (GtkEntry *entry,
+ gpointer user_data)
+{
+ CgWindow *window;
+ CgWindowPrivate *priv;
+
+ GtkWidget *derive_from_glib;
+ GtkWidget *entry_base_class;
+ GtkWidget *label_base_class;
+
+ window = CG_WINDOW (user_data);
+ priv = CG_WINDOW_PRIVATE (window);
+
+ derive_from_glib = GTK_WIDGET (gtk_builder_get_object (priv->bxml, "vala_derive_from_glib"));
+ entry_base_class = GTK_WIDGET (gtk_builder_get_object (priv->bxml, "vala_base"));
+ label_base_class = GTK_WIDGET (gtk_builder_get_object (priv->bxml, "lbl_vala_base"));
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (derive_from_glib)) == FALSE)
+ {
+ 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,
@@ -716,6 +791,37 @@ cg_window_set_builder (CgWindow *window,
_("Name"), CG_ELEMENT_EDITOR_COLUMN_STRING,
_("Module"), CG_ELEMENT_EDITOR_COLUMN_STRING);
+ priv->editor_vala_methods = cg_element_editor_new (
+ GTK_TREE_VIEW (gtk_builder_get_object (priv->bxml, "vala_methods")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "vala_methods_add")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "vala_methods_remove")),
+ 4,
+ _("Scope"), CG_ELEMENT_EDITOR_COLUMN_LIST, VALA_SCOPE_LIST,
+ _("Type"), CG_ELEMENT_EDITOR_COLUMN_STRING,
+ _("Name"), CG_ELEMENT_EDITOR_COLUMN_STRING,
+ _("Arguments"), CG_ELEMENT_EDITOR_COLUMN_ARGUMENTS);
+
+ priv->editor_vala_properties = cg_element_editor_new (
+ GTK_TREE_VIEW (gtk_builder_get_object (priv->bxml, "vala_properties")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "vala_properties_add")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "vala_properties_remove")),
+ 5,
+ _("Scope"), CG_ELEMENT_EDITOR_COLUMN_LIST, VALA_SCOPE_LIST,
+ _("Type"), CG_ELEMENT_EDITOR_COLUMN_STRING,
+ _("Name"), CG_ELEMENT_EDITOR_COLUMN_STRING,
+ _("Value"), CG_ELEMENT_EDITOR_COLUMN_STRING,
+ _("Setter"), CG_ELEMENT_EDITOR_COLUMN_LIST, VALA_BOOLEAN_LIST);
+
+ priv->editor_vala_signals = cg_element_editor_new (
+ GTK_TREE_VIEW (gtk_builder_get_object (priv->bxml, "vala_signals")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "vala_signals_add")),
+ GTK_BUTTON (gtk_builder_get_object (priv->bxml, "vala_signals_remove")),
+ 4,
+ _("Scope"), CG_ELEMENT_EDITOR_COLUMN_LIST, VALA_SCOPE_LIST,
+ _("Type"), CG_ELEMENT_EDITOR_COLUMN_STRING,
+ _("Name"), CG_ELEMENT_EDITOR_COLUMN_STRING,
+ _("Arguments"), CG_ELEMENT_EDITOR_COLUMN_ARGUMENTS);
+
/* Active item property in glade cannot be set because no GtkTreeModel
* is assigned. */
gtk_combo_box_set_active (
@@ -728,6 +834,17 @@ cg_window_set_builder (CgWindow *window,
G_OBJECT (gtk_builder_get_object (priv->bxml, "py_name")), "changed",
G_CALLBACK (cg_window_py_name_changed_cb), window);
+ g_signal_connect (
+ G_OBJECT (gtk_builder_get_object (priv->bxml, "vala_name")), "changed",
+ G_CALLBACK (cg_window_vala_name_changed_cb), window);
+
+ g_signal_connect (
+ G_OBJECT (gtk_builder_get_object (priv->bxml, "vala_derive_from_glib")), "toggled",
+ G_CALLBACK (cg_window_vala_derive_from_glib), window);
+ gtk_combo_box_set_active (
+ GTK_COMBO_BOX (gtk_builder_get_object (priv->bxml, "vala_class_scope")),
+ 0);
+
/* This revalidates the appropriate validator */
g_signal_connect (
G_OBJECT (gtk_builder_get_object (priv->bxml, "top_notebook")),
@@ -895,6 +1012,29 @@ cg_window_js_imports_transform_func (GHashTable *table,
cg_transform_string (table, "Name");
}
+static void
+cg_window_vala_methods_transform_func (GHashTable *table,
+ G_GNUC_UNUSED gpointer user_data)
+{
+ cg_transform_string (table, "Name");
+ cg_transform_arguments (table, "Arguments", FALSE);
+}
+
+static void
+cg_window_vala_signals_transform_func (GHashTable *table,
+ G_GNUC_UNUSED gpointer user_data)
+{
+ cg_transform_string (table, "Name");
+ cg_transform_arguments (table, "Arguments", FALSE);
+}
+
+static void
+cg_window_vala_properties_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,
@@ -947,6 +1087,9 @@ cg_window_init (CgWindow *window)
priv->editor_js_methods = NULL;
priv->editor_js_variables = NULL;
priv->editor_js_imports = NULL;
+ priv->editor_vala_methods = NULL;
+ priv->editor_vala_properties = NULL;
+ priv->editor_vala_signals = NULL;
priv->validator = NULL;
}
@@ -978,6 +1121,12 @@ cg_window_finalize (GObject *object)
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->editor_vala_methods != NULL)
+ g_object_unref (G_OBJECT (priv->editor_vala_methods));
+ if (priv->editor_vala_properties != NULL)
+ g_object_unref (G_OBJECT (priv->editor_vala_properties));
+ if (priv->editor_vala_signals != NULL)
+ g_object_unref (G_OBJECT (priv->editor_vala_signals));
if (priv->validator != NULL)
g_object_unref (G_OBJECT (priv->validator));
@@ -1273,6 +1422,28 @@ cg_window_create_value_heap (CgWindow *window)
cg_window_js_imports_transform_func,
window, "Name", "Module");
break;
+ case 4: /* Vala */
+ cg_window_set_heap_value (window, values, G_TYPE_STRING,
+ "ClassName", "vala_name");
+ cg_window_set_heap_value (window, values, G_TYPE_STRING,
+ "BaseClass", "vala_base");
+ cg_window_set_heap_value (window, values, G_TYPE_STRING,
+ "ClassScope", "vala_class_scope");
+ cg_window_set_heap_value (window, values, G_TYPE_BOOLEAN,
+ "Headings", "vala_headings");
+ cg_window_set_heap_value (window, values, G_TYPE_BOOLEAN,
+ "DeriveFromGlib", "vala_derive_from_glib");
+ cg_element_editor_set_values (priv->editor_vala_methods, "Methods", values,
+ cg_window_vala_methods_transform_func,
+ window, "Scope", "Type", "Name", "Arguments");
+ cg_element_editor_set_values (priv->editor_vala_properties, "Properties", values,
+ cg_window_vala_properties_transform_func,
+ window, "Scope", "Type", "Name", "Value",
+ "Setter");
+ cg_element_editor_set_values (priv->editor_vala_signals, "Signals", values,
+ cg_window_vala_signals_transform_func,
+ window, "Scope", "Type", "Name", "Arguments");
+ break;
default:
g_assert_not_reached ();
break;
@@ -1327,6 +1498,8 @@ cg_window_get_header_template (CgWindow *window)
return PY_SOURCE_TEMPLATE;
case 3: /* JavaScript */
return JS_SOURCE_TEMPLATE;
+ case 4: /* Vala */
+ return VALA_SOURCE_TEMPLATE;
default:
g_assert_not_reached ();
return NULL;
@@ -1368,6 +1541,8 @@ cg_window_get_source_template(CgWindow *window)
return PY_SOURCE_TEMPLATE;
case 3: /* JavaScript */
return JS_SOURCE_TEMPLATE;
+ case 4: /* Vala */
+ return VALA_SOURCE_TEMPLATE;
default:
g_assert_not_reached ();
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]