-
Notifications
You must be signed in to change notification settings - Fork 22
/
prefsWidgets.js
189 lines (169 loc) · 4.64 KB
/
prefsWidgets.js
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
* Arc Menu: The new applications menu for Gnome 3.
*
* Copyright (C) 2017 Alexander Rüedlinger
*
* Copyright (C) 2017-2018 LinxGem33
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Import Libraries
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const GdkPixbuf = imports.gi.GdkPixbuf;
const Lang = imports.lang;
const Params = imports.misc.params;
/**
* The module prefsWidgets.js contains all the customized GUI elements
* for the preferences widget (prefs.js).
* In order to have a consistent UI/UX, every GUI element in the preferences
* should be based on a widget from this module.
*/
/**
* Arc Menu Notebook
*/
const Notebook = new GObject.Class({
Name: 'ArcMenu.ArcMenuNotebook',
GTypeName: 'ArcMenuNotebook',
Extends: Gtk.Notebook,
_init: function() {
this.parent({
margin_left: 6,
margin_right: 6
});
},
append_page: function(notebookPage) {
Gtk.Notebook.prototype.append_page.call(
this,
notebookPage,
notebookPage.getTitleLabel()
);
}
});
/**
* Arc Menu Notebook Page
*/
const NotebookPage = new GObject.Class({
Name: 'ArcMenu.ArcMenuNotebookPage',
GTypeName: 'ArcMenuNotebookPage',
Extends: Gtk.Box,
_init: function(title) {
this.parent({
orientation: Gtk.Orientation.VERTICAL,
margin: 24,
spacing: 20,
homogeneous: false
});
this._title = new Gtk.Label({
label: "<b>" + title + "</b>",
use_markup: true,
xalign: 0
});
},
getTitleLabel: function() {
return this._title;
}
});
/**
* Arc Menu icon Button
*/
const IconButton = new GObject.Class({
Name: 'ArcMenu.ArcMenuIconButton',
GTypeName: 'ArcMenuIconButton',
Extends: Gtk.Button,
_init: function(params) {
this.parent();
this._params = Params.parse(params, {
circular: true,
icon_name: ''
});
if (this._params.circular) {
let context = this.get_style_context();
context.add_class('circular');
}
if (this._params.icon_name) {
let image = new Gtk.Image({
icon_name: this._params.icon_name,
xalign: 0.46
});
this.add(image);
}
}
});
/**
* Arc Menu Dialog Window
*/
const DialogWindow = new Lang.Class({
Name: 'ArcMenu.DialogWindow',
GTypeName: 'ArcMenuDialogWindow',
Extends: Gtk.Dialog,
_init: function(title, parent) {
this.parent({
title: title,
transient_for: parent.get_toplevel(),
use_header_bar: true,
modal: true
});
let vbox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 20,
homogeneous: false,
margin: 5
});
this._createLayout(vbox);
this.get_content_area().add(vbox);
},
_createLayout: function(vbox) {
throw "Not implemented!";
}
});
/**
* Arc Menu Frame Box
*/
const FrameBox = new Lang.Class({
Name: 'ArcMenu.FrameBox',
GTypeName: 'ArcMenuFrameBox',
Extends: Gtk.Frame,
_init: function() {
this.parent({ label_yalign: 0.50 });
this._listBox = new Gtk.ListBox();
this._listBox.set_selection_mode(Gtk.SelectionMode.NONE);
Gtk.Frame.prototype.add.call(this, this._listBox);
},
add: function(boxRow) {
this._listBox.add(boxRow);
}
});
/**
* Arc Menu Frame Box Row
*/
const FrameBoxRow = new Lang.Class({
Name: 'ArcMenu.FrameBoxRow',
GTypeName: 'ArcMenuFrameBoxRow',
Extends: Gtk.ListBoxRow,
_init: function() {
this.parent({});
this._grid = new Gtk.Grid({
margin: 5,
column_spacing: 20,
row_spacing: 20
});
Gtk.ListBoxRow.prototype.add.call(this, this._grid);
},
add: function(widget) {
this._grid.add(widget);
}
});