Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
P
Pardus APT Update Indicator - GNOME Shell Extension
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Erdem Ersoy
Pardus APT Update Indicator - GNOME Shell Extension
Commits
ba583337
Kaydet (Commit)
ba583337
authored
Ara 10, 2016
tarafından
franglais125
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add a proper signal connection/disconnection system
üst
392dad50
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
147 additions
and
33 deletions
+147
-33
extension.js
extension.js
+66
-33
utils.js
utils.js
+81
-0
No files found.
extension.js
Dosyayı görüntüle @
ba583337
...
...
@@ -94,8 +94,6 @@ const AptUpdateIndicator = new Lang.Class({
_residualPackagesList
:
[],
_autoremovablePackagesList
:
[],
_bindings
:
[],
_init
:
function
()
{
this
.
parent
(
0.0
,
"AptUpdateIndicator"
);
...
...
@@ -110,6 +108,9 @@ const AptUpdateIndicator = new Lang.Class({
box
.
add_child
(
this
.
label
);
this
.
actor
.
add_child
(
box
);
// Prepare to track connections
this
.
_signalsHandler
=
new
Utils
.
GlobalSignalsHandler
();
// Assemble the menu
this
.
_assembleMenu
();
...
...
@@ -123,7 +124,9 @@ const AptUpdateIndicator = new Lang.Class({
// We check for the network status before trying to update apt-cache
this
.
_network_monitor
=
Gio
.
network_monitor_get_default
();
this
.
_network_monitor_connection
=
this
.
_network_monitor
.
connect
(
'network-changed'
,
Lang
.
bind
(
this
,
this
.
_checkConnectionState
));
this
.
_signalsHandler
.
add
([
this
.
_network_monitor
,
'network-changed'
,
Lang
.
bind
(
this
,
this
.
_checkConnectionState
)]);
this
.
_checkConnectionState
();
},
...
...
@@ -183,10 +186,23 @@ const AptUpdateIndicator = new Lang.Class({
this
.
menu
.
addMenuItem
(
settingsMenuItem
);
// Bind some events
this
.
menu
.
connect
(
'open-state-changed'
,
Lang
.
bind
(
this
,
this
.
_onMenuOpened
));
this
.
checkNowMenuItem
.
connect
(
'activate'
,
Lang
.
bind
(
this
,
this
.
_checkUpdates
));
settingsMenuItem
.
connect
(
'activate'
,
Lang
.
bind
(
this
,
this
.
_openSettings
));
this
.
updateNowMenuItem
.
connect
(
'activate'
,
Lang
.
bind
(
this
,
this
.
_updateNow
));
this
.
_signalsHandler
.
add
([
this
.
menu
,
'open-state-changed'
,
Lang
.
bind
(
this
,
this
.
_onMenuOpened
)
],[
this
.
checkNowMenuItem
,
'activate'
,
Lang
.
bind
(
this
,
this
.
_checkUpdates
)
],[
this
.
updateNowMenuItem
,
'activate'
,
Lang
.
bind
(
this
,
this
.
_updateNow
)
],[
settingsMenuItem
,
'activate'
,
Lang
.
bind
(
this
,
this
.
_openSettings
)
]);
},
_applySettings
:
function
()
{
...
...
@@ -272,26 +288,47 @@ const AptUpdateIndicator = new Lang.Class({
},
_bindSettings
:
function
()
{
this
.
_bindings
.
push
(
this
.
_settings
.
connect
(
'changed::update-cmd'
,
Lang
.
bind
(
this
,
this
.
_updateCMD
)));
this
.
_bindings
.
push
(
this
.
_settings
.
connect
(
'changed::check-cmd'
,
Lang
.
bind
(
this
,
this
.
_checkCMD
)));
this
.
_bindings
.
push
(
this
.
_settings
.
connect
(
'changed::check-interval'
,
Lang
.
bind
(
this
,
this
.
_checkInterval
)));
this
.
_bindings
.
push
(
this
.
_settings
.
connect
(
'changed::allow-no-passwd'
,
Lang
.
bind
(
this
,
this
.
_checkCMD
)));
this
.
_bindings
.
push
(
this
.
_settings
.
connect
(
'changed::show-count'
,
Lang
.
bind
(
this
,
this
.
_checkShowHideIndicator
)));
this
.
_bindings
.
push
(
this
.
_settings
.
connect
(
'changed::always-visible'
,
Lang
.
bind
(
this
,
this
.
_checkShowHideIndicator
)));
this
.
_bindings
.
push
(
this
.
_settings
.
connect
(
'changed::new-packages'
,
Lang
.
bind
(
this
,
this
.
_newPackagesBinding
)));
this
.
_bindings
.
push
(
this
.
_settings
.
connect
(
'changed::obsolete-packages'
,
Lang
.
bind
(
this
,
this
.
_obsoletePackagesBinding
)));
this
.
_bindings
.
push
(
this
.
_settings
.
connect
(
'changed::residual-packages'
,
Lang
.
bind
(
this
,
this
.
_residualPackagesBinding
)));
this
.
_bindings
.
push
(
this
.
_settings
.
connect
(
'changed::autoremovable-packages'
,
Lang
.
bind
(
this
,
this
.
_autoremovablePackagesBinding
)));
this
.
_signalsHandler
.
add
([
this
.
_settings
,
'changed::update-cmd'
,
Lang
.
bind
(
this
,
this
.
_updateCMD
)
],[
this
.
_settings
,
'changed::check-cmd'
,
Lang
.
bind
(
this
,
this
.
_checkCMD
)
],[
this
.
_settings
,
'changed::check-interval'
,
Lang
.
bind
(
this
,
this
.
_checkInterval
)
],[
this
.
_settings
,
'changed::allow-no-passwd'
,
Lang
.
bind
(
this
,
this
.
_checkCMD
)
],[
this
.
_settings
,
'changed::show-count'
,
Lang
.
bind
(
this
,
this
.
_checkShowHideIndicator
)
],[
this
.
_settings
,
'changed::always-visible'
,
Lang
.
bind
(
this
,
this
.
_checkShowHideIndicator
)
],[
this
.
_settings
,
'changed::new-packages'
,
Lang
.
bind
(
this
,
this
.
_newPackagesBinding
)
],[
this
.
_settings
,
'changed::obsolete-packages'
,
Lang
.
bind
(
this
,
this
.
_obsoletePackagesBinding
)
],[
this
.
_settings
,
'changed::residual-packages'
,
Lang
.
bind
(
this
,
this
.
_residualPackagesBinding
)
],[
this
.
_settings
,
'changed::autoremovable-packages'
,
Lang
.
bind
(
this
,
this
.
_autoremovablePackagesBinding
)
]);
},
_checkConnectionState
:
function
()
{
...
...
@@ -329,12 +366,8 @@ const AptUpdateIndicator = new Lang.Class({
this
.
_TimeoutId
=
null
;
}
for
(
let
i
=
0
;
i
<
this
.
_bindings
.
length
;
i
++
)
{
this
.
_settings
.
disconnect
(
this
.
_bindings
[
0
]);
this
.
_bindings
[
0
]
=
0
;
this
.
_bindings
.
shift
();
}
this
.
_bindings
=
null
;
// Disconnect global signals
this
.
_signalsHandler
.
destroy
();
this
.
parent
();
},
...
...
utils.js
Dosyayı görüntüle @
ba583337
const
Gettext
=
imports
.
gettext
;
const
Lang
=
imports
.
lang
;
const
Gio
=
imports
.
gi
.
Gio
;
...
...
@@ -57,3 +58,83 @@ function initTranslations(domain) {
else
Gettext
.
bindtextdomain
(
domain
,
Config
.
LOCALEDIR
);
}
/**
* Simplify global signals and function injections handling
* abstract class
*/
const
BasicHandler
=
new
Lang
.
Class
({
Name
:
'AptUpdateIndicator.BasicHandler'
,
_init
:
function
()
{
this
.
_storage
=
new
Object
();
},
add
:
function
(
/* unlimited 3-long array arguments */
)
{
// Convert arguments object to array, concatenate with generic
let
args
=
Array
.
concat
(
'generic'
,
Array
.
slice
(
arguments
));
// Call addWithLabel with ags as if they were passed arguments
this
.
addWithLabel
.
apply
(
this
,
args
);
},
destroy
:
function
()
{
for
(
let
label
in
this
.
_storage
)
this
.
removeWithLabel
(
label
);
},
addWithLabel
:
function
(
label
/* plus unlimited 3-long array arguments*/
)
{
if
(
this
.
_storage
[
label
]
==
undefined
)
this
.
_storage
[
label
]
=
new
Array
();
// Skip first element of the arguments
for
(
let
i
=
1
;
i
<
arguments
.
length
;
i
++
)
{
this
.
_storage
[
label
].
push
(
this
.
_create
(
arguments
[
i
]));
}
},
removeWithLabel
:
function
(
label
)
{
if
(
this
.
_storage
[
label
])
{
for
(
let
i
=
0
;
i
<
this
.
_storage
[
label
].
length
;
i
++
)
this
.
_remove
(
this
.
_storage
[
label
][
i
]);
delete
this
.
_storage
[
label
];
}
},
// Virtual methods to be implemented by subclass
/**
* Create single element to be stored in the storage structure
*/
_create
:
function
(
item
)
{
throw
new
Error
(
'no implementation of _create in '
+
this
);
},
/**
* Correctly delete single element
*/
_remove
:
function
(
item
)
{
throw
new
Error
(
'no implementation of _remove in '
+
this
);
}
});
/**
* Manage global signals
*/
const
GlobalSignalsHandler
=
new
Lang
.
Class
({
Name
:
'AptUpdateIndicator.GlobalSignalHandler'
,
Extends
:
BasicHandler
,
_create
:
function
(
item
)
{
let
object
=
item
[
0
];
let
event
=
item
[
1
];
let
callback
=
item
[
2
]
let
id
=
object
.
connect
(
event
,
callback
);
return
[
object
,
id
];
},
_remove
:
function
(
item
)
{
item
[
0
].
disconnect
(
item
[
1
]);
}
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment