Vala and Genie programming
Nico,
that looks great!
I will use parts of the code to update Puppybrowser, for the optional webkit support.
At moment, I now DO have time, but programming goes slow:
- very hot (33° in mai, very warm nights like in summer)
I grew up not far from the coast in the north, and the temperatures in the deep south are great to go swimming in the lakes, but also have disadvantages...
- the building I live in (15 floors) is renovated - I have guys working with heavy machines to destroy beton on my balcony.
So cannot sleep at night - too warm, and not at day - too loud.
I currently sleep 3 hours in the early evening, and 2-3 at early morning.
This is not good for concentration
So I'm very happy to see, how new examples are posted by several people now, and I will incorporate them in my exampleviewer, once I have time and concentration, to start it.
Many thanks, Mark
that looks great!
I will use parts of the code to update Puppybrowser, for the optional webkit support.
At moment, I now DO have time, but programming goes slow:
- very hot (33° in mai, very warm nights like in summer)
I grew up not far from the coast in the north, and the temperatures in the deep south are great to go swimming in the lakes, but also have disadvantages...
- the building I live in (15 floors) is renovated - I have guys working with heavy machines to destroy beton on my balcony.
So cannot sleep at night - too warm, and not at day - too loud.
I currently sleep 3 hours in the early evening, and 2-3 at early morning.
This is not good for concentration
So I'm very happy to see, how new examples are posted by several people now, and I will incorporate them in my exampleviewer, once I have time and concentration, to start it.
Many thanks, Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]
- Lobster
- Official Crustacean
- Posts: 15522
- Joined: Wed 04 May 2005, 06:06
- Location: Paradox Realm
- Contact:
as well as the above logo I have created the following stub about Genie on Puppy. Copying material wherever I can find it
http://www.puppylinux.org/?q=wiki/devel ... ries/genie
Message Dialog Testing
Re-Hi All !
New testing program:
Build with:
Nicolas.
New testing program:
Code: Select all
[indent=4]
uses
Gtk
class MessageDialog : Window
init
title = "Simple Message Dialog Test"
window_position = WindowPosition.CENTER
default_height = 200
default_width = 350
destroy += Gtk.main_quit
var vbox = new VBox (true, 5)
var button1 = new Button.with_label("Question")
button1.clicked += question_clicked
var button2 = new Button.with_label("Information")
button2.clicked += information_clicked
var button3 = new Button.with_label("Warning")
button3.clicked += warning_clicked
var button4 = new Button.with_label("Error")
button4.clicked += error_clicked
var button5 = new Button.with_label("Exit this stupid program now !")
button5.clicked += Gtk.main_quit
vbox.add (button1)
vbox.add (button2)
vbox.add (button3)
vbox.add (button4)
vbox.add (button5)
add (vbox)
def private question_clicked ()
var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, ("This is question message dialog with Yes and No buttons !!"))
messagedialog.run()
messagedialog.destroy()
def private information_clicked ()
var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, ("This is information message dialog with Ok button !!"))
messagedialog.run()
messagedialog.destroy()
def private warning_clicked ()
var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, ("This is warning message dialog with Ok and Cancel buttons !!"))
messagedialog.run()
messagedialog.destroy()
def private error_clicked ()
var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, ("This is error message dialog with Close button !!"))
messagedialog.run()
messagedialog.destroy()
init
Gtk.init (ref args)
var test = new MessageDialog ()
test.show_all ()
Gtk.main ()
Code: Select all
valac --pkg gtk+-2.0 yourprogname.gs
cool, thanks Nico!
Right such small examples are great for a collection, so people quickly can look up code, without having to search in long listings
I compiled the latest Gtk version of webkit, but it is larger than I thought.
It is 12 MB, plus 15 MB or so for the "icu" library.
There are patches to remove icu, but they seem not to be finished yet.
Icu seems to be a unicode library for QT, but Glib already has its own unicode.
Compressed in a pet, the files are around 12 MB, so more than the whole seamonkey.
Anyway: as Seamonkey 2 no longer supports gtkembedmoz.so, we need a replacement in some months.
And maybe the patches to use only the glib-unicode will be available then somewhen this summer. At moment, both libs are used, even if you force to compile with glib unicode.
So it is worth, to follow both approaches.
I can try to create a pet tomorrow, I must recompile files in Puppy 4.12 (I used Newyearspup with the newer glib for first tests, your webkit example works here)
Oh yes, I also must compile kerberos and others, or https will not work.
Maybe it will be easier, to use Debian packages.
here the issue is dicussed:
https://bugs.webkit.org/show_bug.cgi?id=15914
Mark
note for me:
to build:
WebKitTools/Scripts/build-webkit --gtk --no-video
(--no-video removes dependency of gstreamer)
I modified some files to force the use of glib-unicode
Right such small examples are great for a collection, so people quickly can look up code, without having to search in long listings
I compiled the latest Gtk version of webkit, but it is larger than I thought.
It is 12 MB, plus 15 MB or so for the "icu" library.
There are patches to remove icu, but they seem not to be finished yet.
Icu seems to be a unicode library for QT, but Glib already has its own unicode.
Compressed in a pet, the files are around 12 MB, so more than the whole seamonkey.
Anyway: as Seamonkey 2 no longer supports gtkembedmoz.so, we need a replacement in some months.
And maybe the patches to use only the glib-unicode will be available then somewhen this summer. At moment, both libs are used, even if you force to compile with glib unicode.
So it is worth, to follow both approaches.
I can try to create a pet tomorrow, I must recompile files in Puppy 4.12 (I used Newyearspup with the newer glib for first tests, your webkit example works here)
Oh yes, I also must compile kerberos and others, or https will not work.
Maybe it will be easier, to use Debian packages.
here the issue is dicussed:
https://bugs.webkit.org/show_bug.cgi?id=15914
Mark
note for me:
to build:
WebKitTools/Scripts/build-webkit --gtk --no-video
(--no-video removes dependency of gstreamer)
I modified some files to force the use of glib-unicode
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]
Hi.
I want to start to learn a programming language. Should it be vala? I generally code programs that take in data and transform it, and also programs that act as 'macros'.
Could you, if you are so kind as to, please also tell me what i would need to start compiling and programming?
Thank you very much.
I want to start to learn a programming language. Should it be vala? I generally code programs that take in data and transform it, and also programs that act as 'macros'.
Could you, if you are so kind as to, please also tell me what i would need to start compiling and programming?
Thank you very much.
na, bullshit... *deleted*
Last edited by MU on Mon 25 May 2009, 23:51, edited 2 times in total.
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]
shorter and better for your purpose:
Works also with utf8 characters
see also:
http://www.puppylinux.com/genie/inputoutput.htm
http://valadoc.org/?pkg=glib-2.0
Mark
Code: Select all
[indent=4]
init
Intl.setlocale(LocaleCategory.ALL , Environment.get_variable("LANG"))
print ("argument passed to program was: %s\n" , args[1])
print ("your language setting is: %s\n" ,Environment.get_variable("LANG") )
print "Please enter something and hit [enter]:"
var mychar = new array of char[64]
stdin.gets(mychar)
mychar[mychar.length - 1] = 0
mystring:string = (string)mychar
print("you entered: %s" , mystring)
//end
see also:
http://www.puppylinux.com/genie/inputoutput.htm
http://valadoc.org/?pkg=glib-2.0
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]
We should make a method of it, so you have shorter code...
Mark
Code: Select all
[indent=4]
def read_from_console() : string
var mychar = new array of char[64]
stdin.gets(mychar)
mychar[mychar.length - 1] = 0
var s = (string)mychar
return s.strip() //this removes linefeeds
init
Intl.setlocale(LocaleCategory.ALL , Environment.get_variable("LANG"))
print ("argument passed to program was: %s\n" , args[1])
print ("your language setting is: %s\n" ,Environment.get_variable("LANG") )
print "Please enter your first name and hit [enter]:"
var firstname = read_from_console()
print "Please enter your last name and hit [enter]:"
var lastname = read_from_console()
var fullname = firstname + " " + lastname
print("your full name is: %s" , fullname)
//end
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]
Simple Menu Test
Hi All,
New testing program:
Build with:
Of course, there is a problem with the radiomenuitem, someone know how to make it working ?
Nicolas.
New testing program:
Code: Select all
[indent=4]
uses
Gtk
class MenuTest : Window
mylist : SList
check_menu_item : CheckMenuItem
radio_menu_item : RadioMenuItem
separator_menu_item : SeparatorMenuItem
image_menu_item : ImageMenuItem
menu_item2 : MenuItem
messagedialog : MessageDialog
init
title = "Simple Menu Test"
window_position = WindowPosition.CENTER
default_height = 50
default_width = 350
destroy += Gtk.main_quit
var vbox = new VBox (true, 5)
var bar = new MenuBar()
/* Menu 1 */
var menu1 = new Menu()
/* Checkbox */
var check_menu_item = new CheckMenuItem.with_label("I'm a CheckBox in a menu !")
menu1.append(check_menu_item)
/* Separator */
separator_menu_item = new SeparatorMenuItem()
menu1.append(separator_menu_item)
/* Radio */
radio_menu_item = new RadioMenuItem.with_label(mylist, "I'm a Radio Menu Item 1")
menu1.append(radio_menu_item)
radio_menu_item = new RadioMenuItem.with_label(mylist, "I'm a Radio Menu Item 2")
menu1.append(radio_menu_item)
radio_menu_item = new RadioMenuItem.with_label(mylist, "I'm a Radio Menu Item 3")
menu1.append(radio_menu_item)
/* Separator */
separator_menu_item = new SeparatorMenuItem()
menu1.append(separator_menu_item)
/* Image Menu */
var image_menu_item = new ImageMenuItem.from_stock(STOCK_QUIT, null)
image_menu_item.label = "_Exit"
image_menu_item.activate += exit_clicked
menu1.append(image_menu_item)
var launcher = new MenuItem.with_label("File")
launcher.set_submenu(menu1)
bar.append(launcher)
/* End menu 1 */
/* Simple Menu 2 without Image */
var menu2 = new Menu()
menu2.append(menu_item2 = new MenuItem.with_label("About this program..."))
menu_item2.activate += about_clicked
var launcher2 = new MenuItem.with_label("?")
launcher2.set_submenu(menu2)
bar.append(launcher2)
/* End Simple Menu 2 */
vbox.add (bar)
add (vbox)
def private exit_clicked ()
Gtk.main_quit()
def private about_clicked ()
var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, ("This is a Simple Menu test in pure Gtk, don't hesitate to reuse this code, it is not patented !! :o))"))
messagedialog.run()
messagedialog.destroy()
init
Gtk.init (ref args)
var test = new MenuTest ()
test.show_all ()
Gtk.main ()
Code: Select all
valac --pkg gtk+-2.0 yourfilename.gs
Nicolas.
Nico,
your menu example works for me.
I just had to comment this line:
I think it is, because stock-items get a automatically geerated, translated text.
What problem do you have with the radiobuttons?
I just checked it in Newyearspup with newr Gtk than Pupp4, maybe the older Gtk did not support them?
Mark
your menu example works for me.
I just had to comment this line:
Code: Select all
//image_menu_item.label = "_Exit"
What problem do you have with the radiobuttons?
I just checked it in Newyearspup with newr Gtk than Pupp4, maybe the older Gtk did not support them?
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]
yep
update: deleted outdated code.
references:
http://valadoc.org/?pkg=gtk+-2.0&elemen ... adioButton
http://library.gnome.org/devel/gtk/stab ... utton.html
Mark
update: deleted outdated code.
references:
http://valadoc.org/?pkg=gtk+-2.0&elemen ... adioButton
http://library.gnome.org/devel/gtk/stab ... utton.html
Mark
Last edited by MU on Thu 28 May 2009, 19:13, edited 1 time in total.
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]
Menu Test (ImageMenuItem, RadioMenuItem, CheckMenuItem, Tear
Thanks Mark,
I make some changes on the code:
Test it !!
Nicolas.
I make some changes on the code:
Code: Select all
[indent=4]
uses
Gtk
class MenuTest : Window
mylist : SList
check_menu_item : CheckMenuItem
radio_menu_item1 : RadioMenuItem
radio_menu_item2 : RadioMenuItem
radio_menu_item3 : RadioMenuItem
separator_menu_item : SeparatorMenuItem
image_menu_item : ImageMenuItem
menu_item : MenuItem
menu_item2 : MenuItem
messagedialog : MessageDialog
init
title = "Simple Menu Test"
window_position = WindowPosition.CENTER
default_height = 50
default_width = 350
destroy += Gtk.main_quit
var vbox = new VBox (true, 5)
var bar = new MenuBar()
/* Menu 1 */
var menu1 = new Menu()
/* With this TearoffMenuItem, you can detach the 'File' menu, click on the dotted */
menu_item = new TearoffMenuItem()
menu1.append(menu_item)
/* Checkbox */
check_menu_item = new CheckMenuItem.with_label("I'm a CheckBox in a menu !")
menu1.append(check_menu_item)
check_menu_item.toggled += on_check
/* Separator */
separator_menu_item = new SeparatorMenuItem()
menu1.append(separator_menu_item)
/* Radio */
radio_menu_item1 = new RadioMenuItem.with_label(mylist, "I'm a Radio Menu Item 1")
menu1.append(radio_menu_item1)
radio_menu_item1.toggled += on_radio1
radio_menu_item2 = new RadioMenuItem.with_label(radio_menu_item1.get_group(), "I'm a Radio Menu Item 2")
menu1.append(radio_menu_item2)
radio_menu_item2.toggled += on_radio2
radio_menu_item3 = new RadioMenuItem.with_label(radio_menu_item1.get_group(), "I'm a Radio Menu Item 3")
menu1.append(radio_menu_item3)
radio_menu_item3.toggled += on_radio3
/* Separator */
separator_menu_item = new SeparatorMenuItem()
menu1.append(separator_menu_item)
/* Image Menu */
image_menu_item = new ImageMenuItem.from_stock(STOCK_QUIT, null)
image_menu_item.activate += exit_clicked
menu1.append(image_menu_item)
var launcher = new MenuItem.with_label("File")
launcher.set_submenu(menu1)
bar.append(launcher)
/* End menu 1 */
/* Simple Menu 2 without Image */
var menu2 = new Menu()
menu2.append(menu_item2 = new MenuItem.with_label("About this program..."))
menu_item2.activate += about_clicked
var launcher2 = new MenuItem.with_label("?")
launcher2.set_submenu(menu2)
bar.append(launcher2)
/* End Simple Menu 2 */
vbox.add (bar)
add (vbox)
def private on_radio1()
toogled : bool = radio_menu_item1.get_active()
if toogled is true
print("Radio 1 Toogled")
def private on_radio2()
toogled : bool = radio_menu_item2.get_active()
if toogled is true
print("Radio 2 Toogled")
def private on_radio3()
toogled : bool = radio_menu_item3.get_active()
if toogled is true
print("Radio 3 Toogled")
def private on_check()
checked : bool = check_menu_item.get_active()
if checked is true
print("Checked")
else
print("Unchecked")
def private exit_clicked ()
Gtk.main_quit()
def private about_clicked ()
var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, ("This is a Simple Menu test in pure Gtk, don't hesitate to reuse this code, it is not patented !! :o))"))
messagedialog.run()
messagedialog.destroy()
init
Gtk.init (ref args)
var test = new MenuTest ()
test.show_all ()
Gtk.main ()
Nicolas.
Simple Text Editor (not finished)
Hi all,
I've modified the "Simple Text Viewer" to "Simple Text Editor"
WARNING: This is not finished !
Build with:
If you want to help, don't hesitate !!!
Nicolas.
I've modified the "Simple Text Viewer" to "Simple Text Editor"
WARNING: This is not finished !
Code: Select all
[indent=4]
uses
Gtk
init
Gtk.init (ref args)
var test = new TextFileViewer ()
test.open_file(args[1])
test.show_all ()
Gtk.main ()
class TextFileViewer : Window
toolbar : Toolbar
text_view : SourceView
status_bar : Statusbar
status_bar2 : Statusbar
status_hbox : HBox
scrool : ScrolledWindow
document_modified : bool = false
separator_menu_item : SeparatorMenuItem
image_menu_item : ImageMenuItem
image_menu_item2 : ImageMenuItem
image_menu_item3 : ImageMenuItem
check_menu_item : CheckMenuItem
check_menu_item2 : CheckMenuItem
image_menu_item4 : ImageMenuItem
image_menu_item5 : ImageMenuItem
menu_item : MenuItem
messagedialog : MessageDialog
init
title = "Simple Text Editor"
default_height = 560
default_width = 950
window_position = WindowPosition.CENTER
destroy += Gtk.main_quit
/* Menus */
var bar = new MenuBar()
var menu1 = new Menu()
image_menu_item = new ImageMenuItem.from_stock(STOCK_NEW, null)
image_menu_item.activate += new_text
menu1.append(image_menu_item)
image_menu_item = new ImageMenuItem.from_stock(STOCK_OPEN, null)
image_menu_item.activate += on_open_clicked
menu1.append(image_menu_item)
separator_menu_item = new SeparatorMenuItem()
menu1.append(separator_menu_item)
image_menu_item = new ImageMenuItem.from_stock(STOCK_SAVE, null)
image_menu_item.activate += notimplemented_clicked
menu1.append(image_menu_item)
image_menu_item = new ImageMenuItem.from_stock(STOCK_SAVE_AS, null)
image_menu_item.activate += notimplemented_clicked
menu1.append(image_menu_item)
separator_menu_item = new SeparatorMenuItem()
menu1.append(separator_menu_item)
image_menu_item = new ImageMenuItem.from_stock(STOCK_PRINT, null)
image_menu_item.activate += notimplemented_clicked
menu1.append(image_menu_item)
separator_menu_item = new SeparatorMenuItem()
menu1.append(separator_menu_item)
image_menu_item = new ImageMenuItem.from_stock(STOCK_QUIT, null)
image_menu_item.activate += exit_clicked
menu1.append(image_menu_item)
var launcher = new MenuItem.with_mnemonic("_File")
launcher.set_submenu(menu1)
bar.append(launcher)
/* *************** */
var menu2 = new Menu()
image_menu_item2 = new ImageMenuItem.from_stock(STOCK_UNDO, null)
image_menu_item2.activate += undo_clicked
menu2.append(image_menu_item2)
image_menu_item2 = new ImageMenuItem.from_stock(STOCK_REDO, null)
image_menu_item2.activate += redo_clicked
menu2.append(image_menu_item2)
separator_menu_item = new SeparatorMenuItem()
menu2.append(separator_menu_item)
image_menu_item2 = new ImageMenuItem.from_stock(STOCK_CUT, null)
image_menu_item2.activate += cut_clipboard
menu2.append(image_menu_item2)
image_menu_item2 = new ImageMenuItem.from_stock(STOCK_COPY, null)
image_menu_item2.activate += copy_clipboard
menu2.append(image_menu_item2)
image_menu_item2 = new ImageMenuItem.from_stock(STOCK_PASTE, null)
image_menu_item2.activate += paste_clipboard
menu2.append(image_menu_item2)
separator_menu_item = new SeparatorMenuItem()
menu2.append(separator_menu_item)
image_menu_item2 = new ImageMenuItem.from_stock(STOCK_SELECT_ALL, null)
image_menu_item2.activate += select_all
menu2.append(image_menu_item2)
var launcher2 = new MenuItem.with_mnemonic("E_dit")
launcher2.set_submenu(menu2)
bar.append(launcher2)
/* *************** */
var menu3 = new Menu()
check_menu_item = new CheckMenuItem.with_label("Show Toolbar")
menu3.append(check_menu_item)
check_menu_item.set_active(true)
check_menu_item.toggled += on_check
separator_menu_item = new SeparatorMenuItem()
menu3.append(separator_menu_item)
check_menu_item2 = new CheckMenuItem.with_label("Insert spaces instead of tabs")
menu3.append(check_menu_item2)
check_menu_item2.toggled += on_check2
var launcher3 = new MenuItem.with_mnemonic("_View")
launcher3.set_submenu(menu3)
bar.append(launcher3)
/* *************** */
var menu4 = new Menu()
image_menu_item4 = new ImageMenuItem.from_stock(STOCK_FIND, null)
image_menu_item4.activate += notimplemented_clicked
menu4.append(image_menu_item4)
separator_menu_item = new SeparatorMenuItem()
menu4.append(separator_menu_item)
image_menu_item4 = new ImageMenuItem.from_stock(STOCK_JUMP_TO, null)
image_menu_item4.activate += notimplemented_clicked
menu4.append(image_menu_item4)
var launcher4 = new MenuItem.with_mnemonic("_Search")
launcher4.set_submenu(menu4)
bar.append(launcher4)
/* *************** */
var menu5 = new Menu()
image_menu_item5 = new ImageMenuItem.from_stock(STOCK_ABOUT, null)
image_menu_item5.activate += about_clicked
menu5.append(image_menu_item5)
var launcher5 = new MenuItem.with_label("?")
launcher5.set_submenu(menu5)
bar.append(launcher5)
/* Toolbar */
toolbar = new Toolbar ()
var separator = new SeparatorToolItem ()
var separator2 = new SeparatorToolItem ()
var separator3 = new SeparatorToolItem ()
var separator4 = new SeparatorToolItem ()
var new_button = new ToolButton.from_stock (STOCK_NEW)
var open_button = new ToolButton.from_stock (STOCK_OPEN)
var save_button = new ToolButton.from_stock (STOCK_SAVE)
var print_button = new ToolButton.from_stock (STOCK_PRINT)
var undo_button = new ToolButton.from_stock (STOCK_UNDO)
var redo_button = new ToolButton.from_stock (STOCK_REDO)
var cut_button = new ToolButton.from_stock (STOCK_CUT)
var copy_button = new ToolButton.from_stock (STOCK_COPY)
var paste_button = new ToolButton.from_stock (STOCK_PASTE)
var find_button = new ToolButton.from_stock (STOCK_FIND)
toolbar.add (new_button)
toolbar.add (open_button)
toolbar.add (save_button)
toolbar.add (separator)
toolbar.add (print_button)
toolbar.add (separator2)
toolbar.add (undo_button)
toolbar.add (redo_button)
toolbar.add (separator3)
toolbar.add (cut_button)
toolbar.add (copy_button)
toolbar.add (paste_button)
toolbar.add (separator4)
toolbar.add (find_button)
new_button.clicked += new_text
open_button.clicked += on_open_clicked
save_button.clicked += notimplemented_clicked
print_button.clicked += notimplemented_clicked
undo_button.clicked += undo_clicked
redo_button.clicked += redo_clicked
cut_button.clicked += cut_clipboard
copy_button.clicked += copy_clipboard
paste_button.clicked += paste_clipboard
find_button.clicked += notimplemented_clicked
/* Textview */
text_view = new SourceView
text_view.set_insert_spaces_instead_of_tabs(false)
/* Scrolled Window */
var scroll = new ScrolledWindow (null, null)
scroll.set_policy (PolicyType.AUTOMATIC, PolicyType.AUTOMATIC)
scroll.add (text_view)
/* Status Bar */
status_bar = new Statusbar ()
status_bar.set_has_resize_grip (false)
status_bar.pop(0)
status_bar.push(0, "New unregistered file")
status_bar2 = new Statusbar ()
status_bar2.set_has_resize_grip (false)
status_bar2.pop(0)
/* HBox */
status_hbox = new HBox (false, 0)
status_hbox.pack_start (status_bar, true, true, 0)
status_hbox.pack_start (status_bar2, false, true, 0)
/* VBox */
var vbox = new VBox (false, 0)
vbox.pack_start (bar, false, true, 0)
vbox.pack_start (toolbar, false, true, 0)
vbox.pack_start (scroll, true, true, 0)
vbox.pack_start (status_hbox, false, true, 0)
add (vbox)
def private on_check ()
checked : bool = check_menu_item.get_active()
if checked is true
toolbar.show()
else
toolbar.hide()
def private on_check2 ()
checked : bool = check_menu_item2.get_active()
if checked is true
text_view.set_insert_spaces_instead_of_tabs(true)
else
text_view.set_insert_spaces_instead_of_tabs(false)
def private new_text ()
text_view.buffer.set_text ("", 0)
status_bar.push(0, "New unregistered file")
def private select_all ()
text_view.select_all (true)
def private undo_clicked ()
text_view.undo()
def private redo_clicked ()
text_view.redo()
def private cut_clipboard ()
text_view.cut_clipboard()
def private copy_clipboard ()
text_view.copy_clipboard()
def private paste_clipboard ()
text_view.paste_clipboard()
def private notimplemented_clicked ()
var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, ("This function is not implemented yet !! :o(("))
messagedialog.run()
messagedialog.destroy()
def private on_open_clicked ()
var file_chooser = new FileChooserDialog ("Open File", this, FileChooserAction.OPEN, STOCK_CANCEL, ResponseType.CANCEL, STOCK_OPEN, ResponseType.ACCEPT, null)
if (file_chooser.run () == ResponseType.ACCEPT)
open_file (file_chooser.get_filename ())
file_chooser.destroy ()
def open_file (filename : string)
try
text : string
len : int
FileUtils.get_contents (filename, out text, out len)
text_view.buffer.set_text (text, len)
status_bar.push(0, "You are editing: " + filename)
except e:OptionError
var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, ("Unable to open file !"))
messagedialog.run()
messagedialog.destroy()
def private exit_clicked ()
Gtk.main_quit()
def private about_clicked ()
var about = new AboutDialog ()
about.set_version("0.2")
about.set_program_name("Simple Text Editor")
about.set_comments("This is a Simple Text Editor in pure Gtk, don't hesitate to reuse this code, it is not patented !! :o))")
about.set_copyright("Nicolas alias nikobordx")
about.run()
about.hide()
Code: Select all
valac --pkg gtk+-2.0 --pkg gtksourceview-2.0 yourfile.gs
Nicolas.
Nico...
wow, must test it tomorrow after some sleep...
-----------------
Here is a first release of a Genie examplebrowser.
Not complete yet, but pretty usable.
I included some, but far not all examples.
Work in progress...
Windows is not yet supported, as I use some linux specific shell commands.
They must be replaced later.
Note:
defaultbrowser is seamonkey,
defaulteditor leafpad.
To change that:
run the examples, and close them.
This creates a rc file.
That you can edit then:
/root/.Genie-examples/settings.rc
Mark
wow, must test it tomorrow after some sleep...
-----------------
Here is a first release of a Genie examplebrowser.
Not complete yet, but pretty usable.
I included some, but far not all examples.
Work in progress...
Windows is not yet supported, as I use some linux specific shell commands.
They must be replaced later.
Note:
defaultbrowser is seamonkey,
defaulteditor leafpad.
To change that:
run the examples, and close them.
This creates a rc file.
That you can edit then:
/root/.Genie-examples/settings.rc
Mark
- Attachments
-
- GenieExamples-0.1.pet
- (133.79 KiB) Downloaded 314 times
-
- GenieExamples01.jpg
- (79.71 KiB) Downloaded 433 times
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]
Nico,
your editor looks great!
Please tell us if you need help to add the search and other stuff
Mark
your editor looks great!
Please tell us if you need help to add the search and other stuff
Mark
- Attachments
-
- Texteditor.jpg
- (43.3 KiB) Downloaded 423 times
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]