1
/* This file is part of GPump, a Pump.io client.
3
* GPump (THE SOFTWARE) is made available under the terms and conditions of the
4
* GNU Lesser General Public Licence 3.0. A copy of the licence can be read
5
* in the file lgpl-3.0.txt in the root of this project.
8
const Gio = imports.gi.Gio;
9
const Gst = imports.gi.Gst;
10
const GLib = imports.gi.GLib;
11
const Gtk = imports.gi.Gtk;
12
const Lang = imports.lang;
14
const SettingsData = imports.settings_data;
16
const Application = new Lang.Class ({
20
this.application = new Gtk.Application ({
21
application_id: "org.gego.gpump",
22
flags: Gio.ApplicationFlags.FLAGS_NONE,
23
register_session: true
25
this.application.connect('activate', Lang.bind(this, this._on_activate));
28
_on_activate: function () {
29
/* Guarantee that only one window is present at any time. */
30
let w_list = this.application.get_windows ();
36
this._prepareWindow ();
37
this._prepareAppMenu ();
38
this._prepareHeaderBar ();
40
this.window.show_all ();
44
* This function is used to prepare the window, it also initializes and adds
45
* the headerbar to it.
47
_prepareWindow: function () {
48
this.window = new Gtk.Window ({
49
type: Gtk.WindowType.TOPLEVEL,
57
this.window.set_titlebar ((this.headerbar = new Gtk.HeaderBar({
59
subtitle: 'A Pump.io client',
60
show_close_button: true
63
this.window.add (( this.scroll_view = new Gtk.ScrolledWindow () ));
64
this.scroll_view.add ((this.list_box = new Gtk.ListBox ()));
66
this.window.connect ('delete_event',
67
Lang.bind (this.window,
68
this.window.hide_on_delete));
70
this.application.add_window (this.window);
74
* This function is used to create the application menu.
76
_prepareAppMenu: function () {
77
let menu = new Gio.Menu ();
78
let section = new Gio.Menu ();
80
section.append ("Preferences", "app.preferences");
81
menu.append_section (null, section);
83
section = new Gio.Menu ();
84
section.append ("About", "app.about");
85
section.append ("Quit", "app.quit");
86
menu.append_section (null, section);
88
this.application.set_app_menu (menu);
90
let quit_action = new Gio.SimpleAction ({name: "quit"});
91
quit_action.connect ('activate', Lang.bind (this, function () {
92
this.application.quit ();
94
this.application.add_action (quit_action);
99
* This function is used to prepare the hearderbar by adding buttons and
100
* assigning callback functions to them.
102
_prepareHeaderBar: function () {
103
this.headerbar.pack_start ((this.new_post_btn = new Gtk.Button ({
104
image: (new Gtk.Image ({icon_name: 'text-editor-symbolic'})),
105
tooltip_text: 'Create new post'
108
this.headerbar.pack_start ((this.refresh_btn = new Gtk.Button({
109
image: (new Gtk.Image ({icon_name: 'emblem-synchronizing-symbolic'})),
110
tooltip_text: 'Refresh the stream'
113
this.headerbar.pack_end ((this.user_menu_btn = new Gtk.Button ({
114
image: (new Gtk.Image ({icon_name: 'emblem-system-symbolic'})),
115
tooltip_text: 'Switch and manage users'