Advertisement
tmcopeland

open-imagination

Nov 10th, 2011
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 2.58 KB | None | 0 0
  1. /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
  2. /*
  3.  * main.c
  4.  * Copyright (C) Taylor Copeland 2011 <taylor@taylorcopeland.com>
  5.  *
  6. open-imagination-vala is free software: you can redistribute it and/or modify it
  7.  * under the terms of the GNU General Public License as published by the
  8.  * Free Software Foundation, either version 3 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * open-imagination-vala is distributed in the hope that it will be useful, but
  12.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14.  * See the GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License along
  17.  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  */
  19.  
  20. using GLib;
  21. using Gtk;
  22.  
  23. public class Main : Object
  24. {
  25.  
  26.     /*
  27.      * Uncomment this line when you are done testing and building a tarball
  28.      * or installing
  29.      */
  30.     //const string UI_FILE = Config.PACKAGE_DATA_DIR + "/" + "open_imagination_vala.ui";
  31.     //const string UI_FILE = "src/open_imagination_vala.ui";
  32.  
  33.  
  34.     public Main ()
  35.     {
  36.  
  37.         /*try
  38.         {
  39.             var builder = new Builder ();
  40.             builder.add_from_file (UI_FILE);
  41.             builder.connect_signals (this);
  42.  
  43.             var window = builder.get_object ("window") as Window;
  44.             window.show_all ();
  45.         }
  46.         catch (Error e) {
  47.             stderr.printf ("Could not load UI: %s\n", e.message);
  48.         }*/
  49.  
  50.         var window = new Gtk.Window ();
  51.         window.set_size_request (320, 256);
  52.         window.title = "Open Imagination";
  53.         window.destroy.connect (Gtk.main_quit);
  54.  
  55.         var mainMenuBar = new Gtk.MenuBar ();
  56.  
  57.         var fileMenu = new Gtk.Menu ();
  58.  
  59.         var open_item = new Gtk.MenuItem.with_mnemonic ("_Open");
  60.         var quit_item = new Gtk.MenuItem.with_mnemonic ("_Quit");
  61.  
  62.         fileMenu.append (open_item);
  63.         fileMenu.append (quit_item);
  64.  
  65.         quit_item.select.connect (Gtk.main_quit);
  66.  
  67.         var file_launcher = new MenuItem.with_mnemonic ("_File");
  68.         file_launcher.set_submenu (fileMenu);
  69.  
  70.         mainMenuBar.append (file_launcher);
  71.        
  72.  
  73.         var mainToolbar = new Gtk.Toolbar ();
  74.  
  75.         var quitToolButton = new Gtk.ToolButton (new Gtk.Label ("Quit"), "Quit");
  76.         quitToolButton.clicked.connect (Gtk.main_quit);
  77.  
  78.         mainToolbar.add (quitToolButton);
  79.  
  80.         window.add (mainMenuBar);
  81.         window.add (mainToolbar);
  82.  
  83.         window.show_all ();
  84.  
  85.     }
  86.  
  87.     [CCode (instance_pos = -1)]
  88.     public void on_destroy (Widget window)
  89.     {
  90.         Gtk.main_quit();
  91.     }
  92.  
  93.     static int main (string[] args)
  94.     {
  95.         Gtk.init (ref args);
  96.         var app = new Main ();
  97.  
  98.         Gtk.main ();
  99.        
  100.         return 0;
  101.     }
  102. }
  103.  
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement