/+junk/SAPG

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/SAPG
1 by Gustav Hartvigsson
* Initial code
1
[CCode(cname="GETTEXT_PACKAGE")] extern const string GETTEXT_PACKAGE;
2
3
namespace SAPG {
4
5
  const string[] authors = {
6
    "Gustav \"Gego/XAREN\" Hartvigsson (+GustavHartvigsson)",
7
  };
8
9
  int main (string[] args) {
10
    Intl.setlocale(LocaleCategory.MESSAGES, "");
11
    Intl.textdomain(GETTEXT_PACKAGE);
12
    Intl.bind_textdomain_codeset(GETTEXT_PACKAGE, "utf-8");
13
    Intl.bindtextdomain(GETTEXT_PACKAGE, "./locale");
14
15
    GLib.Environment.set_prgname (_("SAPG"));
16
17
    var app = new SAPG.App ();
18
19
    return app.run();
20
  }
21
22
  public
23
  class App : Gtk.Application {
24
    public App () {
25
      Object (application_id: "org.gego.sapg",
26
             flags: GLib.ApplicationFlags.FLAGS_NONE);
27
    }
28
29
    protected
30
    SAPG.AppWinodw window;
31
32
    protected
33
    int standard_height;
34
35
    protected
36
    int
37
    standard_width;
38
39
    protected override
40
    void activate () {
41
      this.build_ui ();
42
      this.add_actions ();
43
      this.show_all ();
44
    }
45
46
    void build_ui () {
47
      this.window = new SAPG.AppWinodw (this);
48
      this.window.resizable = false;
49
      this.window.set_size_request (0,0);
50
      this.window.destroy.connect (() => {
51
        this.quit ();
52
      });
53
54
      window.revealer.set_reveal_child (false);
55
56
      this.window.tgl_btn_show_volume.toggled.connect (() => {
57
        this.window.revealer.set_reveal_child (this.window.tgl_btn_show_volume.active);
58
      });
59
60
    }
61
62
    void add_actions () {
63
      var about_action = new GLib.SimpleAction ("about", null);
64
      about_action.activate.connect (() => {
65
        var about_dialogue = new SAPG.About (this.window);
66
        about_dialogue.run ();
67
        about_dialogue.destroy ();
68
      });
69
70
      var quit_action = new GLib.SimpleAction ("quit", null);
71
      quit_action.activate.connect (() => {
72
        this.window.destroy ();
73
        this.quit ();
74
      });
75
76
      this.add_action (about_action);
77
      this.add_action (quit_action);
78
79
      var app_menu = new GLib.Menu ();
80
      app_menu.append ("About", "app.about");
81
      app_menu.append ("Quit", "app.quit");
82
83
      this.set_app_menu (app_menu);
84
    }
85
86
    void show_all () {
87
      this.window.show_all ();
88
    }
89
90
    void quit_ui () {
91
92
    }
93
  }
94
95
  [GtkTemplate(ui = "/org/gego/sapg/window.glade")]
96
  public class AppWinodw : Gtk.ApplicationWindow {
97
98
    [GtkChild ]
99
    public Gtk.Revealer revealer;
100
101
    [GtkChild]
102
    public Gtk.ToggleButton tgl_btn_show_volume;
2 by Gustav Hartvigsson
* Added new icons.
103
    
1 by Gustav Hartvigsson
* Initial code
104
    public AppWinodw (Gtk.Application application) {
105
      Object (application: application);
4 by Gustav Hartvigsson
* Make use of new icons
106
      var icon_image = new Gtk.Image.from_resource ("/org/gego/sapg/icon_32.png");
1 by Gustav Hartvigsson
* Initial code
107
      Gtk.Window.set_default_icon (icon_image.get_pixbuf ());
108
    }
109
110
  }
111
112
  public class About : Gtk.AboutDialog {
113
    public About (Gtk.Window? window) {
114
      this.program_name = GLib.Environment.get_prgname ();
4 by Gustav Hartvigsson
* Make use of new icons
115
      this.logo = (new Gtk.Image.from_resource ("/org/gego/sapg/icon_256.png")).get_pixbuf ();
1 by Gustav Hartvigsson
* Initial code
116
      this.authors = SAPG.authors;
117
118
      this.set_modal (true);
119
      this.set_transient_for (window);
120
    }
121
  }
122
123
}