1 static Xcls_ProjectSettings _ProjectSettings;
3 public class Xcls_ProjectSettings : Object
6 private Xcls_ProjectSettings _this;
8 public static Xcls_ProjectSettings singleton()
10 if (_ProjectSettings == null) {
11 _ProjectSettings= new Xcls_ProjectSettings();
13 return _ProjectSettings;
15 public Xcls_label_global label_global;
16 public Xcls_label_database label_database;
17 public Xcls_path path;
18 public Xcls_base_template base_template;
19 public Xcls_rootURL rootURL;
20 public Xcls_view view;
21 public Xcls_database_DBTYPE database_DBTYPE;
22 public Xcls_database_DBNAME database_DBNAME;
23 public Xcls_database_DBUSERNAME database_DBUSERNAME;
24 public Xcls_database_DBPASSWORD database_DBPASSWORD;
25 public Xcls_database_ERROR database_ERROR;
28 public signal void buttonPressed (string btn);
29 public Project.Project project;
32 public Xcls_ProjectSettings()
35 this.el = new Gtk.Popover( null );
40 this.el.border_width = 0;
42 this.el.position = Gtk.PositionType.RIGHT;
43 var child_0 = new Xcls_Box2( _this );
45 this.el.add ( child_0.el );
48 // user defined functions
49 public void show (Gtk.Widget btn, Project.Project project) {
50 _this.project = project;
51 _this.path.el.label = project.firstPath();
52 // get the active project.
53 var lm = Gtk.SourceLanguageManager.get_default();
55 ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(
57 lm.get_language("html"));
60 //project.runhtml = project.runhtml || '';
61 _this.view.el.get_buffer().set_text(project.runhtml);
64 _this.rootURL.el.set_text( _this.project.rootURL );
65 _this.base_template.el.set_text(_this.project.base_template);
66 var js = _this.project;
67 _this.database_DBTYPE.el.set_text( js.get_string_member("DBTYPE") );
68 _this.database_DBNAME.el.set_text( js.get_string_member("DBNAME") );
69 _this.database_DBUSERNAME.el.set_text( js.get_string_member("DBUSERNAME") );
70 _this.database_DBPASSWORD.el.set_text( js.get_string_member("DBPASSWORD") );
72 //console.log('show all');
73 this.el.set_modal(true);
74 this.el.set_relative_to(btn);
76 this.el.set_position(Gtk.PositionType.RIGHT);
79 print("SHOWALL - POPIP\n");
81 this.kname.el.grab_focus();
87 var buf = _this.view.el.get_buffer();
90 buf.get_start_iter(out s);
91 buf.get_end_iter(out e);
92 _this.project.runhtml = buf.get_text(s,e,true);
94 _this.project.rootURL = _this.rootURL.el.get_text();
95 _this.project.base_template = _this.base_template.el.get_text();
97 var js = _this.project.json_project_data;
98 js.set_string_member("DBTYPE", _this.database_DBTYPE.el.get_text());
99 js.set_string_member("DBNAME", _this.database_DBNAME.el.get_text());
100 js.set_string_member("DBUSERNAME", _this.database_DBUSERNAME.el.get_text());
101 js.set_string_member("DBPASSWORD", _this.database_DBPASSWORD.el.get_text());
102 // _this.project.set_string_member("DBHOST", _this.DBTYPE.el.get_text());
104 // need to re-init the database
106 _this.project.initRooDatabase();
110 public class Xcls_Box2 : Object
113 private Xcls_ProjectSettings _this;
119 public Xcls_Box2(Xcls_ProjectSettings _owner )
122 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
126 // set gobject values
127 this.el.homogeneous = false;
128 this.el.border_width = 5;
129 var child_0 = new Xcls_Notebook3( _this );
131 this.el.pack_start ( child_0.el , false,false,0 );
132 var child_1 = new Xcls_Box28( _this );
134 this.el.pack_end ( child_1.el , true,true,0 );
137 // user defined functions
139 public class Xcls_Notebook3 : Object
141 public Gtk.Notebook el;
142 private Xcls_ProjectSettings _this;
148 public Xcls_Notebook3(Xcls_ProjectSettings _owner )
151 this.el = new Gtk.Notebook();
155 // set gobject values
156 var child_0 = new Xcls_label_global( _this );
158 var child_1 = new Xcls_label_database( _this );
160 var child_2 = new Xcls_Box6( _this );
162 this.el.append_page ( child_2.el , _this.label_global.el );
163 var child_3 = new Xcls_Box17( _this );
165 this.el.append_page ( child_3.el , _this.label_database.el );
168 // user defined functions
170 public class Xcls_label_global : Object
173 private Xcls_ProjectSettings _this;
179 public Xcls_label_global(Xcls_ProjectSettings _owner )
182 _this.label_global = this;
183 this.el = new Gtk.Label( "Global" );
187 // set gobject values
190 // user defined functions
193 public class Xcls_label_database : Object
196 private Xcls_ProjectSettings _this;
202 public Xcls_label_database(Xcls_ProjectSettings _owner )
205 _this.label_database = this;
206 this.el = new Gtk.Label( "Database" );
210 // set gobject values
213 // user defined functions
216 public class Xcls_Box6 : Object
219 private Xcls_ProjectSettings _this;
225 public Xcls_Box6(Xcls_ProjectSettings _owner )
228 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
232 // set gobject values
233 this.el.homogeneous = false;
234 var child_0 = new Xcls_path( _this );
236 this.el.pack_start ( child_0.el , false,false,0 );
237 var child_1 = new Xcls_Box8( _this );
239 this.el.pack_start ( child_1.el , false,false,0 );
240 var child_2 = new Xcls_Box11( _this );
242 this.el.pack_start ( child_2.el , false,false,0 );
243 var child_3 = new Xcls_Label14( _this );
245 this.el.pack_start ( child_3.el , false,false,0 );
246 var child_4 = new Xcls_ScrolledWindow15( _this );
248 this.el.pack_start ( child_4.el , true,true,0 );
251 // user defined functions
253 public class Xcls_path : Object
256 private Xcls_ProjectSettings _this;
262 public Xcls_path(Xcls_ProjectSettings _owner )
266 this.el = new Gtk.Label( "filename" );
270 // set gobject values
275 // user defined functions
278 public class Xcls_Box8 : Object
281 private Xcls_ProjectSettings _this;
287 public Xcls_Box8(Xcls_ProjectSettings _owner )
290 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
294 // set gobject values
295 this.el.homogeneous = false;
296 this.el.expand = false;
297 var child_0 = new Xcls_Label9( _this );
299 this.el.pack_start ( child_0.el , false,false,0 );
300 var child_1 = new Xcls_base_template( _this );
302 this.el.add ( child_1.el );
305 // user defined functions
307 public class Xcls_Label9 : Object
310 private Xcls_ProjectSettings _this;
316 public Xcls_Label9(Xcls_ProjectSettings _owner )
319 this.el = new Gtk.Label( "HTML template file" );
323 // set gobject values
327 // user defined functions
330 public class Xcls_base_template : Object
333 private Xcls_ProjectSettings _this;
339 public Xcls_base_template(Xcls_ProjectSettings _owner )
342 _this.base_template = this;
343 this.el = new Gtk.Entry();
347 // set gobject values
350 // user defined functions
354 public class Xcls_Box11 : Object
357 private Xcls_ProjectSettings _this;
363 public Xcls_Box11(Xcls_ProjectSettings _owner )
366 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
370 // set gobject values
371 this.el.homogeneous = false;
372 this.el.expand = false;
373 var child_0 = new Xcls_Label12( _this );
375 this.el.pack_start ( child_0.el , false,false,0 );
376 var child_1 = new Xcls_rootURL( _this );
378 this.el.add ( child_1.el );
381 // user defined functions
383 public class Xcls_Label12 : Object
386 private Xcls_ProjectSettings _this;
392 public Xcls_Label12(Xcls_ProjectSettings _owner )
395 this.el = new Gtk.Label( "root URL" );
399 // set gobject values
403 // user defined functions
406 public class Xcls_rootURL : Object
409 private Xcls_ProjectSettings _this;
415 public Xcls_rootURL(Xcls_ProjectSettings _owner )
418 _this.rootURL = this;
419 this.el = new Gtk.Entry();
423 // set gobject values
426 // user defined functions
430 public class Xcls_Label14 : Object
433 private Xcls_ProjectSettings _this;
439 public Xcls_Label14(Xcls_ProjectSettings _owner )
442 this.el = new Gtk.Label( "HTML To insert at end of <HEAD>" );
446 // set gobject values
449 // user defined functions
452 public class Xcls_ScrolledWindow15 : Object
454 public Gtk.ScrolledWindow el;
455 private Xcls_ProjectSettings _this;
461 public Xcls_ScrolledWindow15(Xcls_ProjectSettings _owner )
464 this.el = new Gtk.ScrolledWindow( null, null );
468 // set gobject values
469 var child_0 = new Xcls_view( _this );
471 this.el.add ( child_0.el );
474 // user defined functions
476 public class Xcls_view : Object
478 public Gtk.SourceView el;
479 private Xcls_ProjectSettings _this;
485 public Xcls_view(Xcls_ProjectSettings _owner )
489 this.el = new Gtk.SourceView();
495 var description = Pango.FontDescription.from_string("monospace");
496 description.set_size(9000);
497 this.el.override_font(description);
500 this.el.key_release_event.connect( ( event) =>{
501 if (event.keyval != 115) {
505 if ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {
508 var buf = this.el.get_buffer();
511 buf.get_start_iter(out s);
512 buf.get_end_iter(out e);
513 _this.project.runhtml = buf.get_text(s,e,true);
516 _this.buttonPressed("save");
523 // user defined functions
528 public class Xcls_Box17 : Object
531 private Xcls_ProjectSettings _this;
537 public Xcls_Box17(Xcls_ProjectSettings _owner )
540 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
544 // set gobject values
545 this.el.homogeneous = false;
546 var child_0 = new Xcls_Label18( _this );
548 this.el.pack_start ( child_0.el , false,false,0 );
549 var child_1 = new Xcls_database_DBTYPE( _this );
551 this.el.pack_start ( child_1.el , false,false,0 );
552 var child_2 = new Xcls_Label20( _this );
554 this.el.pack_start ( child_2.el , false,false,0 );
555 var child_3 = new Xcls_database_DBNAME( _this );
557 this.el.pack_start ( child_3.el , false,false,0 );
558 var child_4 = new Xcls_Label22( _this );
560 this.el.pack_start ( child_4.el , false,false,0 );
561 var child_5 = new Xcls_database_DBUSERNAME( _this );
563 this.el.pack_start ( child_5.el , false,false,0 );
564 var child_6 = new Xcls_Label24( _this );
566 this.el.pack_start ( child_6.el , false,false,0 );
567 var child_7 = new Xcls_database_DBPASSWORD( _this );
569 this.el.pack_start ( child_7.el , false,false,0 );
570 var child_8 = new Xcls_Button26( _this );
572 this.el.pack_start ( child_8.el , false,false,0 );
573 var child_9 = new Xcls_database_ERROR( _this );
575 this.el.pack_start ( child_9.el , false,false,0 );
578 // user defined functions
580 public class Xcls_Label18 : Object
583 private Xcls_ProjectSettings _this;
589 public Xcls_Label18(Xcls_ProjectSettings _owner )
592 this.el = new Gtk.Label( "Type (eg. MySQL or PostgreSQL)" );
596 // set gobject values
600 // user defined functions
603 public class Xcls_database_DBTYPE : Object
606 private Xcls_ProjectSettings _this;
612 public Xcls_database_DBTYPE(Xcls_ProjectSettings _owner )
615 _this.database_DBTYPE = this;
616 this.el = new Gtk.Entry();
620 // set gobject values
623 this.el.key_press_event.connect( (ev) => {
625 if (ev.keyval == Gdk.Key.Tab) {
626 _this.database_DBNAME.el.grab_focus();
635 // user defined functions
638 public class Xcls_Label20 : Object
641 private Xcls_ProjectSettings _this;
647 public Xcls_Label20(Xcls_ProjectSettings _owner )
650 this.el = new Gtk.Label( "Name" );
654 // set gobject values
658 // user defined functions
661 public class Xcls_database_DBNAME : Object
664 private Xcls_ProjectSettings _this;
670 public Xcls_database_DBNAME(Xcls_ProjectSettings _owner )
673 _this.database_DBNAME = this;
674 this.el = new Gtk.Entry();
678 // set gobject values
681 this.el.key_press_event.connect( (ev) => {
683 if (ev.keyval == Gdk.Key.Tab) {
684 _this.database_DBUSERNAME.el.grab_focus();
693 // user defined functions
696 public class Xcls_Label22 : Object
699 private Xcls_ProjectSettings _this;
705 public Xcls_Label22(Xcls_ProjectSettings _owner )
708 this.el = new Gtk.Label( "Username" );
712 // set gobject values
716 // user defined functions
719 public class Xcls_database_DBUSERNAME : Object
722 private Xcls_ProjectSettings _this;
728 public Xcls_database_DBUSERNAME(Xcls_ProjectSettings _owner )
731 _this.database_DBUSERNAME = this;
732 this.el = new Gtk.Entry();
736 // set gobject values
739 this.el.key_press_event.connect( (ev) => {
741 if (ev.keyval == Gdk.Key.Tab) {
742 _this.database_DBPASSWORD.el.grab_focus();
751 // user defined functions
754 public class Xcls_Label24 : Object
757 private Xcls_ProjectSettings _this;
763 public Xcls_Label24(Xcls_ProjectSettings _owner )
766 this.el = new Gtk.Label( "Password" );
770 // set gobject values
774 // user defined functions
777 public class Xcls_database_DBPASSWORD : Object
780 private Xcls_ProjectSettings _this;
786 public Xcls_database_DBPASSWORD(Xcls_ProjectSettings _owner )
789 _this.database_DBPASSWORD = this;
790 this.el = new Gtk.Entry();
794 // set gobject values
797 // user defined functions
800 public class Xcls_Button26 : Object
802 public Gtk.Button el;
803 private Xcls_ProjectSettings _this;
809 public Xcls_Button26(Xcls_ProjectSettings _owner )
812 this.el = new Gtk.Button();
816 // set gobject values
817 this.el.label = "Check Connection";
820 this.el.clicked.connect( () => {
823 _this.database_ERROR.el.label = "";
826 // assumes localhost...
827 cnc = Gda.Connection.open_from_string (
828 _this.database_DBTYPE.el.get_text(),
829 "DB_NAME=" + _this.database_DBNAME.el.get_text(),
830 "USERNAME=" + _this.database_DBUSERNAME.el.get_text() +
831 ";PASSWORD=" + _this.database_DBPASSWORD.el.get_text(),
832 Gda.ConnectionOptions.NONE
834 //} catch (Gda.ConnectionError ce) {
835 // _this.database_ERROR.el.label = ce.message;
836 } catch(Gda.ConnectionError ue) {
837 _this.database_ERROR.el.label = ue.message;
839 } catch(Gda.ConfigError ue) {
840 _this.database_ERROR.el.label = ue.message;
843 _this.database_ERROR.el.label = "Connection Succeeded";
848 // user defined functions
851 public class Xcls_database_ERROR : Object
854 private Xcls_ProjectSettings _this;
860 public Xcls_database_ERROR(Xcls_ProjectSettings _owner )
863 _this.database_ERROR = this;
864 this.el = new Gtk.Label( " " );
868 // set gobject values
873 // user defined functions
878 public class Xcls_Box28 : Object
881 private Xcls_ProjectSettings _this;
887 public Xcls_Box28(Xcls_ProjectSettings _owner )
890 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
894 // set gobject values
895 this.el.homogeneous = true;
896 this.el.expand = false;
897 this.el.vexpand = false;
898 var child_0 = new Xcls_Button29( _this );
900 this.el.add ( child_0.el );
901 var child_1 = new Xcls_Button30( _this );
903 this.el.add ( child_1.el );
906 // user defined functions
908 public class Xcls_Button29 : Object
910 public Gtk.Button el;
911 private Xcls_ProjectSettings _this;
917 public Xcls_Button29(Xcls_ProjectSettings _owner )
920 this.el = new Gtk.Button();
924 // set gobject values
925 this.el.label = "Apply";
928 this.el.button_press_event.connect( () => {
931 _this.buttonPressed("apply");
936 // user defined functions
939 public class Xcls_Button30 : Object
941 public Gtk.Button el;
942 private Xcls_ProjectSettings _this;
948 public Xcls_Button30(Xcls_ProjectSettings _owner )
951 this.el = new Gtk.Button();
955 // set gobject values
956 this.el.label = "Save";
959 this.el.button_press_event.connect( () => {
962 _this.buttonPressed("save");
967 // user defined functions