commit e86cd8b11192ea99ee0c2fdcf877a2b009ec84eb
parent 6f41cc29e2468215409bbb31f6225aed98b5da2f
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date: Wed, 28 Apr 2010 20:38:21 +1000
Add toolbar to the main window.
Diffstat:
3 files changed, 49 insertions(+), 16 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
@@ -1,7 +1,8 @@
bin_PROGRAMS = spek
spek_SOURCES = \
- spek.vala
+ spek.vala \
+ spek-window.vala
INCLUDES = \
-include config.h \
diff --git a/src/spek-window.vala b/src/spek-window.vala
@@ -0,0 +1,35 @@
+using Gtk;
+
+namespace Spek {
+ public class Window : Gtk.Window {
+
+ public Window () {
+ this.title = "Spek";
+ this.set_default_size (300, 200);
+
+ var toolbar = new Toolbar ();
+ var open = new ToolButton.from_stock (STOCK_OPEN);
+ open.clicked.connect (on_open_clicked);
+ toolbar.insert (open, -1);
+ var quit = new ToolButton.from_stock (STOCK_QUIT);
+ quit.clicked.connect (s => this.destroy());
+ toolbar.insert (quit, -1);
+
+ var vbox = new VBox (false, 0);
+ vbox.pack_start (toolbar, false, true, 0);
+ this.add (vbox);
+ this.show_all ();
+ }
+
+ private void on_open_clicked () {
+ var chooser = new FileChooserDialog (
+ _ ("Open File"), this, FileChooserAction.OPEN,
+ STOCK_CANCEL, ResponseType.CANCEL,
+ STOCK_OPEN, ResponseType.ACCEPT, null);
+ if (chooser.run () == ResponseType.ACCEPT) {
+ // TODO
+ }
+ chooser.destroy ();
+ }
+ }
+}
+\ No newline at end of file
diff --git a/src/spek.vala b/src/spek.vala
@@ -1,19 +1,15 @@
-public class Main {
- public static int main (string[] args) {
- Intl.bindtextdomain( Config.GETTEXT_PACKAGE, Config.LOCALEDIR );
- Intl.bind_textdomain_codeset( Config.GETTEXT_PACKAGE, "UTF-8" );
- Intl.textdomain( Config.GETTEXT_PACKAGE );
+using Spek;
- Gtk.init (ref args);
+int main (string[] args) {
+ Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
+ Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
+ Intl.textdomain (Config.GETTEXT_PACKAGE);
- var window = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
- window.set_default_size (300, 200);
- window.destroy += Gtk.main_quit;
- window.add (new Gtk.Label ("Hello World!"));
- window.show_all ();
+ Gtk.init (ref args);
- Gtk.main ();
- return 0;
- }
-}
+ var window = new Spek.Window ();
+ window.destroy.connect (Gtk.main_quit);
+ Gtk.main ();
+ return 0;
+}