Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Copyright 2012 Andrew Higginson
- *
- * 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.
- */
- public class App : Object {
- private Gtk.Window window_main;
- private Gtk.MenuBar menubar;
- private Gtk.MenuItem menubar_item;
- private Gtk.Menu menu;
- private ContainerMenuItem menuitem_button;
- private Gtk.VBox vbox;
- public App(string datadir) {
- this.create_widgets();
- this.connect_signals();
- this.window_main.get_settings().gtk_theme_name = "Adwaita";
- this.window_main.show_all();
- }
- /* Private Functions */
- private void create_widgets() {
- this.window_main = new Gtk.Window();
- this.window_main.set_default_size(200, 200);
- this.vbox = new Gtk.VBox(false, 6);
- // In Menu
- var entry = new Gtk.Entry();
- entry.set_text("Hello!");
- entry.set_name("entry");
- entry.set_icon_from_icon_name(Gtk.EntryIconPosition.PRIMARY, "edit-copy");
- entry.set_position(3);
- var button = new Gtk.Button.with_label("Hi");
- button.set_name("button");
- var scale = new Gtk.Scale.with_range(Gtk.Orientation.HORIZONTAL, 0, 100, 1);
- scale.set_size_request(200, -1);
- scale.draw_value = false;
- // Not In Menu
- var entry2 = new Gtk.Entry();
- entry2.set_text("Hello!");
- entry2.set_name("entry");
- entry2.set_icon_from_icon_name(Gtk.EntryIconPosition.PRIMARY, "edit-copy");
- entry2.set_position(3);
- var button2 = new Gtk.Button.with_label("Hi");
- button2.set_name("button");
- var scale2 = new Gtk.Scale.with_range(Gtk.Orientation.HORIZONTAL, 0, 100, 1);
- scale2.set_size_request(200, -1);
- scale2.draw_value = false;
- this.menubar = new Gtk.MenuBar();
- this.menubar_item = new Gtk.MenuItem.with_label("Hiya");
- this.menu = new Gtk.Menu();
- this.menuitem_button = new ContainerMenuItem(Gtk.Orientation.HORIZONTAL, 6);
- this.menuitem_button.pack_start(entry, false, false);
- this.menuitem_button.pack_start(button, false, false);
- this.menuitem_button.pack_start(scale, false, false);
- var hbox = new Gtk.HBox(false, 6);
- hbox.pack_start(entry2, false, false);
- hbox.pack_start(button2, false, false);
- hbox.pack_start(scale2, false, false);
- hbox.margin_top = 50;
- this.menu.append(this.menuitem_button);
- this.menubar_item.set_submenu(this.menu);
- this.menubar.append(this.menubar_item);
- this.vbox.pack_start(this.menubar, false, false);
- this.vbox.pack_start(hbox, false, false);
- this.window_main.add(this.vbox);
- }
- private void connect_signals() {
- this.window_main.delete_event.connect(this.on_window_main_delete_event);
- }
- /* Callbacks */
- private bool on_window_main_delete_event(Gdk.EventAny event) {
- this.quit();
- return false;
- }
- /* Public Functions */
- public void quit() {
- Gtk.main_quit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment