bzr branch
http://gegoxaren.bato24.eu/bzr/gpump/trunk
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
1 |
/* This file is part of GPump, a Pump.io client.
|
2 |
*
|
|
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.
|
|
6 |
*/
|
|
7 |
||
8 |
const Gio = imports.gi.Gio; |
|
9 |
const GLib = imports.gi.GLib; |
|
10 |
const Gtk = imports.gi.Gtk; |
|
11 |
const Lang = imports.lang; |
|
|
34
by Gustav Hartvigsson
* added GetText stuffs... |
12 |
const _ = imports.gettext.gettext; |
13 |
||
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
14 |
|
15 |
const SettingsData = imports.settings_data; |
|
16 |
||
17 |
const Application = new Lang.Class ({ |
|
18 |
Name: "Application", |
|
|
35
by Gustav Hartvigsson
* Changed to extending Gtk.Application instead.... |
19 |
Extends: Gtk.Application, |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
20 |
|
21 |
_init: function () { |
|
|
35
by Gustav Hartvigsson
* Changed to extending Gtk.Application instead.... |
22 |
this.parent ({ |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
23 |
application_id: "org.gego.gpump", |
24 |
flags: Gio.ApplicationFlags.FLAGS_NONE, |
|
25 |
register_session: true |
|
26 |
}); |
|
|
37
by Gustav Hartvigsson
* finnihed the construction of the settings file. |
27 |
|
28 |
this.settings = SettingsData.get_settings (); |
|
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
29 |
}, |
30 |
|
|
|
36
by Gustav Hartvigsson
* changed from this.connect(...) to vfunc_ . |
31 |
vfunc_activate: function () { |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
32 |
/* Guarantee that only one window is present at any time. */ |
|
35
by Gustav Hartvigsson
* Changed to extending Gtk.Application instead.... |
33 |
let w_list = this.get_windows (); |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
34 |
if (w_list.length) { |
35 |
w_list[0].present (); |
|
36 |
return; |
|
37 |
} |
|
38 |
|
|
39 |
this._prepareWindow (); |
|
40 |
this._prepareAppMenu (); |
|
41 |
this._prepareHeaderBar (); |
|
42 |
|
|
43 |
this.window.show_all (); |
|
44 |
}, |
|
45 |
|
|
46 |
/** |
|
47 |
* This function is used to prepare the window, it also initializes and adds
|
|
48 |
* the headerbar to it.
|
|
49 |
*/
|
|
50 |
_prepareWindow: function () { |
|
51 |
this.window = new Gtk.Window ({ |
|
52 |
type: Gtk.WindowType.TOPLEVEL, |
|
53 |
title: 'GPump', |
|
54 |
default_height: 500, |
|
55 |
default_width: 500, |
|
56 |
height_request: 500, |
|
57 |
width_request: 500 |
|
58 |
}); |
|
59 |
|
|
60 |
this.window.set_titlebar ((this.headerbar = new Gtk.HeaderBar({ |
|
61 |
title: 'GPump', |
|
|
34
by Gustav Hartvigsson
* added GetText stuffs... |
62 |
subtitle: _('A Pump.io client'), |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
63 |
show_close_button: true |
64 |
}))); |
|
65 |
|
|
66 |
this.window.add (( this.scroll_view = new Gtk.ScrolledWindow () )); |
|
67 |
this.scroll_view.add ((this.list_box = new Gtk.ListBox ())); |
|
68 |
|
|
69 |
this.window.connect ('delete_event', |
|
70 |
Lang.bind (this.window, |
|
71 |
this.window.hide_on_delete)); |
|
72 |
|
|
|
35
by Gustav Hartvigsson
* Changed to extending Gtk.Application instead.... |
73 |
this.add_window (this.window); |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
74 |
}, |
75 |
|
|
76 |
/** |
|
77 |
* This function is used to create the application menu.
|
|
78 |
*/
|
|
79 |
_prepareAppMenu: function () { |
|
80 |
let menu = new Gio.Menu (); |
|
81 |
let section = new Gio.Menu (); |
|
82 |
|
|
83 |
section.append ("Preferences", "app.preferences"); |
|
84 |
menu.append_section (null, section); |
|
85 |
|
|
86 |
section = new Gio.Menu (); |
|
|
34
by Gustav Hartvigsson
* added GetText stuffs... |
87 |
section.append (_("About"), "app.about"); |
88 |
section.append (_("Quit"), "app.quit"); |
|
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
89 |
menu.append_section (null, section); |
90 |
|
|
|
35
by Gustav Hartvigsson
* Changed to extending Gtk.Application instead.... |
91 |
this.set_app_menu (menu); |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
92 |
|
93 |
let quit_action = new Gio.SimpleAction ({name: "quit"}); |
|
94 |
quit_action.connect ('activate', Lang.bind (this, function () { |
|
|
35
by Gustav Hartvigsson
* Changed to extending Gtk.Application instead.... |
95 |
this.quit (); |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
96 |
})); |
|
35
by Gustav Hartvigsson
* Changed to extending Gtk.Application instead.... |
97 |
this.add_action (quit_action); |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
98 |
|
99 |
}, |
|
100 |
|
|
101 |
/** |
|
102 |
* This function is used to prepare the hearderbar by adding buttons and
|
|
103 |
* assigning callback functions to them.
|
|
104 |
*/
|
|
105 |
_prepareHeaderBar: function () { |
|
106 |
this.headerbar.pack_start ((this.new_post_btn = new Gtk.Button ({ |
|
107 |
image: (new Gtk.Image ({icon_name: 'text-editor-symbolic'})), |
|
|
34
by Gustav Hartvigsson
* added GetText stuffs... |
108 |
tooltip_text: _('Create new post') |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
109 |
}))); |
110 |
|
|
111 |
this.headerbar.pack_start ((this.refresh_btn = new Gtk.Button({ |
|
112 |
image: (new Gtk.Image ({icon_name: 'emblem-synchronizing-symbolic'})), |
|
|
34
by Gustav Hartvigsson
* added GetText stuffs... |
113 |
tooltip_text: _('Refresh the stream') |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
114 |
}))); |
115 |
|
|
116 |
this.headerbar.pack_end ((this.user_menu_btn = new Gtk.Button ({ |
|
117 |
image: (new Gtk.Image ({icon_name: 'emblem-system-symbolic'})), |
|
|
34
by Gustav Hartvigsson
* added GetText stuffs... |
118 |
tooltip_text: _('Switch and manage users') |
|
33
by Gustav Hartvigsson
* Main window no on par with the C version |
119 |
}))); |
120 |
} |
|
121 |
|
|
122 |
});
|