/+junk/SAPG

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/SAPG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
[CCode(cname="GETTEXT_PACKAGE")] extern const string GETTEXT_PACKAGE;

namespace SAPG {

  const string[] authors = {
    "Gustav \"Gego/XAREN\" Hartvigsson (+GustavHartvigsson)",
  };

  int main (string[] args) {
    Intl.setlocale(LocaleCategory.MESSAGES, "");
    Intl.textdomain(GETTEXT_PACKAGE);
    Intl.bind_textdomain_codeset(GETTEXT_PACKAGE, "utf-8");
    Intl.bindtextdomain(GETTEXT_PACKAGE, "./locale");

    GLib.Environment.set_prgname (_("SAPG"));

    var app = new SAPG.App ();

    return app.run();
  }

  public
  class App : Gtk.Application {
    public App () {
      Object (application_id: "org.gego.sapg",
             flags: GLib.ApplicationFlags.FLAGS_NONE);
    }

    protected
    SAPG.AppWinodw window;

    protected
    int standard_height;

    protected
    int
    standard_width;

    protected override
    void activate () {
      this.build_ui ();
      this.add_actions ();
      this.show_all ();
    }

    void build_ui () {
      this.window = new SAPG.AppWinodw (this);
      this.window.resizable = false;
      this.window.set_size_request (0,0);
      this.window.destroy.connect (() => {
        this.quit ();
      });

      window.revealer.set_reveal_child (false);

      this.window.tgl_btn_show_volume.toggled.connect (() => {
        this.window.revealer.set_reveal_child (this.window.tgl_btn_show_volume.active);
      });

    }

    void add_actions () {
      var about_action = new GLib.SimpleAction ("about", null);
      about_action.activate.connect (() => {
        var about_dialogue = new SAPG.About (this.window);
        about_dialogue.run ();
        about_dialogue.destroy ();
      });

      var quit_action = new GLib.SimpleAction ("quit", null);
      quit_action.activate.connect (() => {
        this.window.destroy ();
        this.quit ();
      });

      this.add_action (about_action);
      this.add_action (quit_action);

      var app_menu = new GLib.Menu ();
      app_menu.append ("About", "app.about");
      app_menu.append ("Quit", "app.quit");

      this.set_app_menu (app_menu);
    }

    void show_all () {
      this.window.show_all ();
    }

    void quit_ui () {

    }
  }

  [GtkTemplate(ui = "/org/gego/sapg/window.glade")]
  public class AppWinodw : Gtk.ApplicationWindow {

    [GtkChild ]
    public Gtk.Revealer revealer;

    [GtkChild]
    public Gtk.ToggleButton tgl_btn_show_volume;
    
    public AppWinodw (Gtk.Application application) {
      Object (application: application);
      var icon_image = new Gtk.Image.from_resource ("/org/gego/sapg/icon_32.png");
      Gtk.Window.set_default_icon (icon_image.get_pixbuf ());
    }

  }

  public class About : Gtk.AboutDialog {
    public About (Gtk.Window? window) {
      this.program_name = GLib.Environment.get_prgname ();
      this.logo = (new Gtk.Image.from_resource ("/org/gego/sapg/icon_256.png")).get_pixbuf ();
      this.authors = SAPG.authors;

      this.set_modal (true);
      this.set_transient_for (window);
    }
  }

}