Compare commits

..

2 Commits

Author SHA1 Message Date
a69e45b5eb goa: implement marking a message as Starred or Junk
This works with the latest GOA tree

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-05-19 14:52:52 -04:00
a355398b0f Initial goa client work
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-05-16 17:10:43 -04:00
120 changed files with 5928 additions and 16080 deletions

8
.gitignore vendored
View File

@ -3,7 +3,6 @@
*.o
.deps
.libs
ABOUT-NLS
ChangeLog
INSTALL
Makefile
@ -30,13 +29,8 @@ m4/
omf.make
po/*.gmo
po/gnome-shell.pot
po/*.header
po/*.sed
po/*.sin
po/Makefile.in.in
po/Makevars.template
po/POTFILES
po/Rules-quot
po/stamp-it
scripts/launcher.pyc
src/*.gir
@ -49,11 +43,9 @@ src/calendar-server/org.gnome.Shell.CalendarServer.service
src/gnome-shell
src/gnome-shell-calendar-server
src/gnome-shell-extension-tool
src/gnome-shell-hotplug-sniffer
src/gnome-shell-jhbuild
src/gnome-shell-perf-helper
src/gnome-shell-real
src/hotplug-sniffer/org.gnome.Shell.HotplugSniffer.service
src/run-js-test
src/test-recorder
src/test-recorder.ogg

View File

@ -3,5 +3,5 @@ E-mail: otaylor@redhat.com
Userid: otaylor
Colin Walters
E-mail: walters@verbum.org
E-mail: walters@redhat.com
Userid: walters

116
NEWS
View File

@ -1,119 +1,3 @@
3.1.3
=====
* Fix problem with "user theme extension" breaking the CSS for other
extensions [Giovanni; #650971]
* Telepathy IM framework integration
- Switch to using telepathy-glib rather than talking to
Telepathy via D-Bus [Guillaume, Jasper; #645585, #649633, #651138, #651227]
- Acknowledge messages when the user clicks on them [Guillaume, #647893]
- Fix problem with telepathy icon blinking for incoming messages
even though the user has been notified of them [Guillaume; #643594]
* Networking
- keep wirelesss networks in predictable order [Giovanni; #646580, #652313]
- Show unmanaged devices in the menu [Giovanni; #646946]
- Fix overflow when too many VPN connections [Giovanni; #651602]
* Bluetooth
- Show "hardware disabled" when disabled by rfkill [Giovanni; #648048]
- Fix bug updating status of devices [Giovanni; #647565]
* LookingGlass console:
- Add a "Memory" tab [Colin; #650692]
- Make escape work from any page [Dan Winship; #647303]
- Provide a way to refer to panel items as, e.g.,
Main.panel._activities [Dan Winship; #646915]
* User menu
- Fix problem with suspend menu option locking the screen even when the user
disabled that. [Florian; #652327]
- Hide "power off..." option if shutdown is disabled via PolicyKit
[Florian; #652038]
* Track changes to WM_CLASS (fixes problems with LibreOffice tracking)
[Colin; #649315]
* Remove app tracking workarounds for Firefox and LibreOffice [Colin; #651015]
* Use upstream gettext autoconfigury rather than glib version [Javier; #631576]
* Show messages in the message tray when an application is fullscreen
[Dan Winship; #608667]
* Don't autohide the workspace pager if there is more than one workspace
[Florian; #652714, #653078, #653142]
* Don't always slide out the workspace pager at drag begin [Florian; #652730]
* Only offer to remove a favorite app when dragging it's icon [Owen; #642895]
* Allow dropping an icon anywhere on a workspace [Adel; #652079]
* st-scroll-view: Make the fade effect and offset themable [Jasper; #651813]
* Obey the user's preference when running an application in a terminal
from the run dialog [Florian; #648422]
* Consistently exit overview when launching external applications
[Colin; #653095]
* Adapt to changes in GJS for how GObject APIs are bound
[Alex, Colin, Florian, Jasper, Marc-Antoine; #649981, #652597]
* Fix problems with scrolling in overflow for alt-Tab switcher
[Dan Winship, Adel; #647807]
* Mark relationships between labels and actors for accessibility [Alejandro]
* Add org.gnome.shell.enabled-extensions complementing disabled-extensions
GSetting [Tassilo; #651088]
* Visual tweaks [Jakub, Jasper; #646261, #652715]
* Switch to building against clutter-1.7 with independent Cogl [Adel; #653397]
* Code cleanups [Colin, Dan Winship, Florian; #633620, #645031, #648755, #648758,
#648760, #649203, #649517, #650317, #652730]
* Memory leak fixes [Colin, Maxim; #649508, #650934]
* Build Fixes [Colin, Dan Winship, Florian, Ionut, Morten, Owen, Sean; #647395,
#648006, #650869, #653199, #653275
* Miscellaneous bug fixes [Adam, Adel, Dan Williams, Dan Winship, Florian,
Ionut, Jasper, Maxim, Ray; #620105, #639459, #641570, #642793, #643513,
#645848, #646919, #647186, #648305, #648410, #648562, #648894, #649001,
#645990, #647893, #647907, #651012, #651086, #651606, #651569, #651866,
#652388, #653511]
Contributors:
Ionut Biru, Giovanni Campagna, Guillaume Desmottes, Adam Dingle,
Maxim Ermilov, Adel Gadllah, Tassilo Horn, Javier Jardón, Jonny Lamb,
Alexander Larsson, Rui Matos, Morten Mjelva, Florian Müllner,
Marc-Antoine Perennou, Alejandro Piñeiro, Jasper St. Pierre, Jakub Steiner,
Ray Strode, Owen Taylor, Colin Walters, Dan Williams, Sean Wilson, Dan Winship
Translations:
Daniel Martinez Cucalon [ar], Ihar Hrachyshka [be], Carles Ferrando,
Gil Forcada, Sílvia Miranda [ca], Kristjan Schmidt [eo], Jorge González,
Daniel Mustieles [es], Seán de Búrca [ga], Fran Diéguez [gl],
Yaron Shahrabani [he], Kjartan Maraas [nb], Misha Shnurapet,
Yuri Myasoedov [ru], Daniel Nylander [se], Peter Mráz [sk],
Matej Urbančič [sl], Krishnababu Krothapalli [te], Daniel Korostil [uk],
Aron Xu [zh_CN]
3.0.2
=====
* Network Menu [Dan Williams]
- Fix connecting to WPA2 Enterprise access points
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=648171
- Show the mobile broadband wizard when selecting 3G network
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=649318
- Miscellaneous bug fixes
648648, 650124
* Fix duplicate icons in the application browser [Owen]
https://bugzilla.gnome.org/show_bug.cgi?id=648739
* Make clicking anywhere on the volume icon slider work [Giovanni]
https://bugzilla.gnome.org/show_bug.cgi?id=646660
* Fix a case where activating and clicking the hot corner
at the same time could result in immediately leaving the
overview [Rui]
https://bugzilla.gnome.org/show_bug.cgi?id=649427
* Fix a case where applications became misordered in Alt-Tab [Jasper]
https://bugzilla.gnome.org/show_bug.cgi?id=643302
* Fix a bug where messages you send could show up in
notifications as if someone else sent them [Jonny]
https://bugzilla.gnome.org/show_bug.cgi?id=650219
* Memory leak fixes [Colin, Maxim]
642652, 649508, 649497
* Miscellaneous minor bug fixes [Adel, Christopher, Jasper]
649596, 648765, 648983, 649632
Contributors:
Christopher Aillon, Giovanni Campagna, Maxim Ermilov,
Adel Gadllah, Jonny Lamb, Rui Matos, Jasper St. Pierre,
Owen Taylor, Colin Walters, Dan Williams
Translations:
Arash Mousavi [fa], Seán de Búrca [ga], Timo Jyrinki [fi],
Sigurd Gartmann [nb], Daniel Nylander [se], Peter Mráz [sl],
Abduxukur Abdurixit [ug], Nguyễn Thái Ngọc Duy [vi]
3.0.1
=====

View File

@ -1,5 +1,5 @@
AC_PREREQ(2.63)
AC_INIT([gnome-shell],[3.1.3],[https://bugzilla.gnome.org/enter_bug.cgi?product=gnome-shell],[gnome-shell])
AC_INIT([gnome-shell],[3.0.1],[https://bugzilla.gnome.org/enter_bug.cgi?product=gnome-shell],[gnome-shell])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([src/shell-global.c])
@ -23,16 +23,12 @@ AM_PROG_CC_C_O
LT_PREREQ([2.2.6])
LT_INIT([disable-static])
# i18n
IT_PROG_INTLTOOL([0.40])
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.17])
GETTEXT_PACKAGE=gnome-shell
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
[The prefix for our gettext translation domains.])
IT_PROG_INTLTOOL(0.26)
AM_GLIB_GNU_GETTEXT
PKG_PROG_PKG_CONFIG([0.22])
@ -64,7 +60,7 @@ fi
AM_CONDITIONAL(BUILD_RECORDER, $build_recorder)
CLUTTER_MIN_VERSION=1.7.5
CLUTTER_MIN_VERSION=1.5.15
GOBJECT_INTROSPECTION_MIN_VERSION=0.10.1
GJS_MIN_VERSION=0.7.11
MUTTER_MIN_VERSION=3.0.0
@ -72,11 +68,11 @@ GTK_MIN_VERSION=3.0.0
GIO_MIN_VERSION=2.25.9
LIBECAL_MIN_VERSION=2.32.0
LIBEDATASERVER_MIN_VERSION=1.2.0
LIBEDATASERVERUI_MIN_VERSION=2.91.6
TELEPATHY_GLIB_MIN_VERSION=0.15.3
LIBEDATASERVERUI2_MIN_VERSION=1.2.0
LIBEDATASERVERUI3_MIN_VERSION=2.91.6
TELEPATHY_GLIB_MIN_VERSION=0.13.12
TELEPATHY_LOGGER_MIN_VERSION=0.2.4
POLKIT_MIN_VERSION=0.100
STARTUP_NOTIFICATION_MIN_VERSION=0.11
# Collect more than 20 libraries for a prize!
PKG_CHECK_MODULES(GNOME_SHELL, gio-2.0 >= $GIO_MIN_VERSION
@ -85,10 +81,10 @@ PKG_CHECK_MODULES(GNOME_SHELL, gio-2.0 >= $GIO_MIN_VERSION
libmutter >= $MUTTER_MIN_VERSION
gjs-internals-1.0 >= $GJS_MIN_VERSION
libgnome-menu $recorder_modules gconf-2.0
gdk-x11-3.0 libsoup-2.4
gdk-x11-3.0
clutter-x11-1.0 >= $CLUTTER_MIN_VERSION
clutter-glx-1.0 >= $CLUTTER_MIN_VERSION
libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_MIN_VERSION
libstartup-notification-1.0
gobject-introspection-1.0 >= $GOBJECT_INTROSPECTION_MIN_VERSION
libcanberra
telepathy-glib >= $TELEPATHY_GLIB_MIN_VERSION
@ -97,8 +93,6 @@ PKG_CHECK_MODULES(GNOME_SHELL, gio-2.0 >= $GIO_MIN_VERSION
PKG_CHECK_MODULES(SHELL_PERF_HELPER, gtk+-3.0 gio-2.0)
PKG_CHECK_MODULES(SHELL_HOTPLUG_SNIFFER, gio-2.0 gdk-pixbuf-2.0)
GJS_VERSION=`$PKG_CONFIG --modversion gjs-internals-1.0`
AC_DEFINE_UNQUOTED([GJS_VERSION], ["$GJS_VERSION"], [The version of GJS we're linking to])
AC_SUBST([GJS_VERSION], ["$GJS_VERSION"])
@ -117,7 +111,8 @@ saved_CFLAGS=$CFLAGS
saved_LIBS=$LIBS
CFLAGS=$GNOME_SHELL_CFLAGS
LIBS=$GNOME_SHELL_LIBS
AC_CHECK_FUNCS(JS_NewGlobalObject XFixesCreatePointerBarrier)
# sn_startup_sequence_get_application_id, we can replace with a version check later
AC_CHECK_FUNCS(JS_NewGlobalObject sn_startup_sequence_get_application_id XFixesCreatePointerBarrier)
CFLAGS=$saved_CFLAGS
LIBS=$saved_LIBS
@ -128,9 +123,9 @@ PKG_CHECK_MODULES(GVC, libpulse libpulse-mainloop-glib gobject-2.0)
PKG_CHECK_MODULES(DESKTOP_SCHEMAS, gsettings-desktop-schemas >= 0.1.7)
AC_MSG_CHECKING([for bluetooth support])
PKG_CHECK_EXISTS([gnome-bluetooth-1.0 >= 3.1.0],
[BLUETOOTH_DIR=`$PKG_CONFIG --variable=applet_libdir gnome-bluetooth-1.0`
BLUETOOTH_LIBS=`$PKG_CONFIG --variable=applet_libs gnome-bluetooth-1.0`
PKG_CHECK_EXISTS([gnome-bluetooth-1.0 >= 2.90.0],
[BLUETOOTH_DIR=`$PKG_CONFIG --variable=libdir gnome-bluetooth-1.0`/gnome-bluetooth
BLUETOOTH_LIBS="-L'$BLUETOOTH_DIR' -lgnome-bluetooth-applet"
AC_SUBST([BLUETOOTH_LIBS],["$BLUETOOTH_LIBS"])
AC_DEFINE_UNQUOTED([BLUETOOTH_DIR],["$BLUETOOTH_DIR"],[Path to installed GnomeBluetooth typelib and library])
AC_DEFINE([HAVE_BLUETOOTH],[1],[Define if you have libgnome-bluetooth-applet])
@ -140,7 +135,13 @@ PKG_CHECK_EXISTS([gnome-bluetooth-1.0 >= 3.1.0],
AC_SUBST([HAVE_BLUETOOTH],[0])
AC_MSG_RESULT([no])])
PKG_CHECK_MODULES(CALENDAR_SERVER, libecal-1.2 >= $LIBECAL_MIN_VERSION libedataserver-1.2 >= $LIBEDATASERVER_MIN_VERSION libedataserverui-3.0 >= $LIBEDATASERVERUI_MIN_VERSION gio-2.0)
# Default to libedataserverui-3.0, but allow falling back to 1.2
PKG_CHECK_EXISTS(libedataserverui-3.0,
[EDS_API=3.0
LIBEDATASERVERUI_MIN_VERSION=$LIBEDATASERVERUI3_MIN_VERSION],
[EDS_API=1.2
LIBEDATASERVERUI_MIN_VERSION=$LIBEDATASERVERUI2_MIN_VERSION])
PKG_CHECK_MODULES(CALENDAR_SERVER, libecal-1.2 >= $LIBECAL_MIN_VERSION libedataserver-1.2 >= $LIBEDATASERVER_MIN_VERSION libedataserverui-$EDS_API >= $LIBEDATASERVERUI_MIN_VERSION gio-2.0)
AC_SUBST(CALENDAR_SERVER_CFLAGS)
AC_SUBST(CALENDAR_SERVER_LIBS)

View File

@ -15,18 +15,8 @@
<default>[]</default>
<_summary>Uuids of extensions to disable</_summary>
<_description>
GNOME Shell extensions have a uuid property; this key lists extensions
which should not be loaded. This setting overrides enabled-extensions
for extensions that appear in both lists.
</_description>
</key>
<key name="enabled-extensions" type="as">
<default>[]</default>
<_summary>Uuids of extensions to enable</_summary>
<_description>
GNOME Shell extensions have a uuid property; this key lists extensions
which should be loaded. disabled-extensions overrides this setting for
extensions that appear in both lists.
GNOME Shell extensions have a uuid property;
this key lists extensions which should not be loaded.
</_description>
</key>
<key name="enable-app-monitoring" type="b">
@ -62,7 +52,6 @@
<child name="clock" schema="org.gnome.shell.clock"/>
<child name="calendar" schema="org.gnome.shell.calendar"/>
<child name="recorder" schema="org.gnome.shell.recorder"/>
<child name="keyboard" schema="org.gnome.shell.keyboard"/>
</schema>
<schema id="org.gnome.shell.calendar" path="/org/gnome/shell/calendar/"
@ -76,38 +65,6 @@
</key>
</schema>
<schema id="org.gnome.shell.keyboard" path="/org/gnome/shell/keyboard/"
gettext-domain="@GETTEXT_PACKAGE@">
<key name="show-keyboard" type="b">
<default>false</default>
<_summary>Show the onscreen keyboard</_summary>
<_description>
If true, display onscreen keyboard.
</_description>
</key>
<key name="keyboard-type" type="s">
<default>'touch'</default>
<_summary>Which keyboard to use</_summary>
<_description>
The type of keyboard to use.
</_description>
</key>
<key name="enable-drag" type="b">
<default>false</default>
<_summary>Enable keyboard dragging</_summary>
<_description>
If true, enable keyboard dragging.
</_description>
</key>
<key name="enable-float" type="b">
<default>false</default>
<_summary>Enable floating keyboard</_summary>
<_description>
If true, enable floating keyboard.
</_description>
</key>
</schema>
<schema id="org.gnome.shell.clock" path="/org/gnome/shell/clock/"
gettext-domain="@GETTEXT_PACKAGE@">
<key name="show-seconds" type="b">

View File

@ -39,11 +39,6 @@ StScrollBar
padding: 0px;
}
StScrollView.vfade
{
-st-vfade-offset: 68px;
}
StScrollView StScrollBar
{
min-width: 16px;
@ -187,7 +182,6 @@ StTooltip StLabel {
}
.popup-inactive-menu-item {
font-weight: normal;
color: #999;
}
@ -264,7 +258,7 @@ StTooltip StLabel {
}
.panel-corner:active,
.panel-corner:overview,
.panel-corner:checked,
.panel-corner:focus {
-panel-corner-inner-border-color: rgba(255,255,255,0.8);
}
@ -301,7 +295,7 @@ StTooltip StLabel {
}
.panel-button:active,
.panel-button:overview,
.panel-button:checked,
.panel-button:focus {
border-image: url("panel-button-border.svg") 10 10 0 2;
background-image: url("panel-button-highlight-wide.svg");
@ -464,7 +458,6 @@ StTooltip StLabel {
background-gradient-start: rgba(5,5,6,0.1);
background-gradient-end: rgba(254,254,254,0.1);
background-gradient-direction: vertical;
selected-color: black;
caret-color: rgb(128, 128, 128);
caret-size: 1px;
width: 250px;
@ -725,8 +718,6 @@ StTooltip StLabel {
.lg-dialog StEntry
{
color: #88ff66;
selection-background-color: #88ff66;
selected-color: black;
}
.lg-obj-inspector-title
@ -1139,83 +1130,6 @@ StTooltip StLabel {
icon-size: 36px;
}
.hotplug-transient-box {
spacing: 6px;
padding: 2px 72px 2px 12px;
}
.hotplug-notification-item {
background-color: #3c3c3c;
padding: 0px 10px;
border-radius: 8px;
border: 1px solid #181818;
}
.hotplug-notification-item:hover {
border: 1px solid #a1a1a1;
}
.hotplug-notification-item:focus {
background-color: #666666;
}
.hotplug-notification-item:active {
border: 1px solid #a1a1a1;
background-color: #2b2b2b;
}
.hotplug-notification-item-icon {
icon-size: 24px;
padding: 2px 5px;
}
.hotplug-resident-box {
spacing: 8px;
}
.hotplug-resident-mount {
spacing: 8px;
border-radius: 4px;
color: #ccc;
}
.hotplug-resident-mount:hover {
background-gradient-direction: horizontal;
background-gradient-start: rgba(255, 255, 255, 0.1);
background-gradient-end: rgba(255, 255, 255, 0);
color: #fff;
}
.hotplug-resident-mount-label {
color: inherit;
padding-left: 6px;
}
.hotplug-resident-mount-icon {
icon-size: 24px;
padding-left: 6px;
}
.hotplug-resident-eject-icon {
icon-size: 16px;
}
.hotplug-resident-eject-button {
padding: 2px;
border: 1px solid #2b2b2b;
border-radius: 5px;
color: #ccc;
}
.hotplug-resident-eject-button:hover {
color: #fff;
background-color: #2b2b2b;
border: 1px solid #a1a1a1;
}
.chat-log-message {
color: #888888;
}
@ -1275,8 +1189,6 @@ StTooltip StLabel {
color: #545454;
background-color: #e8e8e8;
caret-color: #545454;
selection-background-color: #bcbcbc;
selected-color: #323232;
box-shadow: 0px 0px 6px 2px rgba(255,255,255,0.9);
}
@ -1343,16 +1255,6 @@ StTooltip StLabel {
padding-left: 4px;
}
.summary-source-counter {
color: white;
background-color: #3465A4;
text-shadow: black 1px 1px 0;
font-size: 9pt;
border-radius: 1em;
min-height: 1em;
min-width: 1em;
}
.source-title {
font-size: 9pt;
font-weight: bold;
@ -1568,8 +1470,6 @@ StTooltip StLabel {
font-weight: bold;
width: 23em;
color: white;
selection-background-color: white;
selected-color: black;
}
.run-dialog {
@ -1673,90 +1573,6 @@ StTooltip StLabel {
color: #444444;
}
/* ShellMountOperation Dialogs */
.shell-mount-operation-icon {
icon-size: 48px;
}
.mount-password-reask {
color: red;
}
.show-processes-dialog,
.mount-question-dialog {
spacing: 24px;
}
.show-processes-dialog-subject,
.mount-question-dialog-subject {
font-size: 12pt;
font-weight: bold;
color: #666666;
padding-top: 10px;
padding-left: 17px;
padding-bottom: 6px;
}
.show-processes-dialog-subject:rtl,
.mount-question-dialog-subject:rtl {
padding-left: 0px;
padding-right: 17px;
}
.show-processes-dialog-description,
.mount-question-dialog-description {
font-size: 10pt;
color: white;
padding-left: 17px;
width: 28em;
}
.show-processes-dialog-description:rtl,
.mount-question-dialog-description:rtl {
padding-right: 17px;
}
.show-processes-dialog-app-list {
font-size: 10pt;
max-height: 200px;
padding-top: 24px;
padding-left: 49px;
padding-right: 32px;
}
.show-processes-dialog-app-list:rtl {
padding-right: 49px;
padding-left: 32px;
}
.show-processes-dialog-app-list-item {
color: #ccc;
}
.show-processes-dialog-app-list-item:hover {
color: white;
}
.show-processes-dialog-app-list-item:ltr {
padding-right: 1em;
}
.show-processes-dialog-app-list-item:rtl {
padding-left: 1em;
}
.show-processes-dialog-app-list-item-icon:ltr {
padding-right: 17px;
}
.show-processes-dialog-app-list-item-icon:rtl {
padding-left: 17px;
}
.show-processes-dialog-app-list-item-name {
font-size: 10pt;
}
/* PolicyKit Authentication Dialog */
.polkit-dialog {
/* this is the width of the entire modal popup */
@ -1840,56 +1656,48 @@ StTooltip StLabel {
border-width: 0px;
}
/* On-screen Keyboard */
#keyboard {
background: rgba(0,0,0,0.8);
/* goa message popup */
.goa-message-table {
}
.keyboard-layout {
spacing: 10px;
padding: 10px;
.goa-message-base {
font-size: 9pt;
}
.keyboard-row {
spacing: 15px;
}
.keyboard-key {
min-height: 30px;
min-width: 30px;
background-gradient-start: rgba(255,245,245,0.4);
background-gradient-end: rgba(105,105,105,0.1);
background-gradient-direction: vertical;
font-size: 14pt;
.goa-message-from-header {
color: #666666;
font-weight: bold;
border-radius: 10px;
border: 2px solid #a0a0a0;
color: white;
}
.keyboard-key:grayed {
color: #808080;
border-color: #808080;
.goa-message-subject-header {
color: #666666;
font-weight: bold;
}
.keyboard-key:checked,
.keyboard-key:hover {
background: #303030;
border: 3px solid white;
.goa-message-date-header {
color: #666666;
font-weight: bold;
}
.keyboard-key:active {
background: #808080;
.goa-message-from {
font-weight: bold;
min-width: 125px;
}
.keyboard-subkeys {
color: white;
padding: 5px;
-arrow-border-radius: 10px;
-arrow-background-color: #090909;
-arrow-border-width: 2px;
-arrow-border-color: white;
-arrow-base: 20px;
-arrow-rise: 10px;
.goa-message-hbox {
spacing: 0.25em;
min-width: 300px;
}
.goa-message-subject {
}
.goa-message-excerpt {
color: rgba(153, 153, 153, 1.0);
}
.goa-message-date {
min-width: 80px;
}

View File

@ -2,62 +2,24 @@
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="119.97824"
height="119.97824"
id="svg7355"
version="1.1"
inkscape:version="0.48.1 r9760"
sodipodi:docname="running-indicator.svg">
<metadata
id="metadata4175">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#2c1cff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1141"
id="namedview4173"
showgrid="false"
inkscape:zoom="8.1348081"
inkscape:cx="81.120662"
inkscape:cy="58.117986"
inkscape:window-x="0"
inkscape:window-y="26"
inkscape:window-maximized="1"
inkscape:current-layer="g30864" />
version="1.1">
<defs
id="defs7357">
<radialGradient
xlink:href="#linearGradient36429"
id="radialGradient7461"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.011539,0,0,0.57582113,-0.39262194,71.83807)"
cx="47.428951"
cy="167.16817"
fx="47.428951"
fy="167.16817"
gradientTransform="matrix(1.0525552,0,0,1.0525552,-2.5162753,-9.0000838)"
cx="47.878681"
cy="171.25"
fx="47.878681"
fy="171.25"
r="37" />
<linearGradient
id="linearGradient36429">
@ -97,7 +59,7 @@
fx="49.067139"
cy="242.50381"
cx="49.067139"
gradientTransform="matrix(1.1891549,0,0,0.15252127,-9.281289,132.52772)"
gradientTransform="matrix(1.1891549,0,0,0.55513246,-9.281289,36.12653)"
gradientUnits="userSpaceOnUse"
id="radialGradient7488"
xlink:href="#linearGradient36471" />
@ -110,21 +72,19 @@
id="g30864"
transform="translate(255.223,70.118091)">
<rect
ry="3.4593496"
rx="3.4593496"
y="99.596962"
x="12.596948"
height="71.116341"
width="71.116341"
ry="3.5996203"
rx="3.5996203"
y="98"
x="11"
height="74"
width="74"
id="rect14000"
style="opacity:0.37187500000000001;fill:url(#radialGradient7461);fill-opacity:1;stroke:none" />
style="opacity:0.371875;fill:url(#radialGradient7461);fill-opacity:1;stroke:none" />
<path
id="rect34520"
d="m 83.273151,166.72152 c 0,1.96759 -1.584022,3.55163 -3.551629,3.55163 l -63.443032,0 c -1.967608,0 -3.551648,-1.58402 -3.551643,-3.55164 0,-5.85318 0,-5.85318 0,0"
style="opacity:0.35;fill:none;stroke:url(#radialGradient7488);stroke-width:1;stroke-opacity:1"
connector-curvature="0"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccscc" />
d="m 84.506708,167.95508 c 6e-6,1.96759 -1.584022,3.55162 -3.551629,3.55163 l -65.910146,0 c -1.967608,-1e-5 -3.551648,-1.58402 -3.551643,-3.55164"
style="opacity:0.2;fill:none;stroke:url(#radialGradient7488);stroke-width:1;stroke-opacity:1"
inkscape:connector-curvature="0" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -13,8 +13,8 @@
height="22"
id="svg3199"
version="1.1"
inkscape:version="0.48.1 r9760"
sodipodi:docname="toggle-on-intl.svg">
inkscape:version="0.47 r22583"
sodipodi:docname="New document 11">
<defs
id="defs3201">
<inkscape:perspective
@ -39,14 +39,14 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1"
inkscape:cx="49.147112"
inkscape:cy="17.532036"
inkscape:zoom="0.35"
inkscape:cx="32.500004"
inkscape:cy="10.999997"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1412"
inkscape:window-height="1067"
inkscape:window-width="609"
inkscape:window-height="501"
inkscape:window-x="0"
inkscape:window-y="26"
inkscape:window-maximized="0" />
@ -58,7 +58,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
@ -72,7 +72,7 @@
transform="translate(-453.5,448.36218)"
id="g16453">
<rect
style="color:#000000;fill:#4a90d9;fill-opacity:1;fill-rule:nonzero;stroke:#3465a4;stroke-width:0.99999994000000003;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
style="color:#000000;fill:#204a87;fill-opacity:1;fill-rule:nonzero;stroke:#3465a4;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rect16256-9-4"
width="63.000004"
height="19"

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -13,8 +13,8 @@
height="22"
id="svg2857"
version="1.1"
inkscape:version="0.48.1 r9760"
sodipodi:docname="toggle-on-us.svg">
inkscape:version="0.47 r22583"
sodipodi:docname="New document 2">
<defs
id="defs2859">
<inkscape:perspective
@ -40,18 +40,16 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1"
inkscape:cx="19.689855"
inkscape:cy="2.0517979"
inkscape:cx="-69.642856"
inkscape:cy="42.428569"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="941"
inkscape:window-height="751"
inkscape:window-x="2577"
inkscape:window-y="206"
inkscape:window-maximized="0"
borderlayer="true"
inkscape:showpageshadow="false" />
inkscape:window-width="609"
inkscape:window-height="501"
inkscape:window-x="0"
inkscape:window-y="26"
inkscape:window-maximized="0" />
<metadata
id="metadata2862">
<rdf:RDF>
@ -60,7 +58,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
@ -74,7 +72,7 @@
transform="translate(-351.35714,708.36218)"
id="g16453">
<rect
style="color:#000000;fill:#4a90d9;fill-opacity:1;fill-rule:nonzero;stroke:#3465a4;stroke-width:0.99999994000000003;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
style="color:#000000;fill:#204a87;fill-opacity:1;fill-rule:nonzero;stroke:#3465a4;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rect16256-9-4"
width="63.000004"
height="19"

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -10,14 +10,11 @@ nobase_dist_js_DATA = \
misc/history.js \
misc/modemManager.js \
misc/params.js \
misc/screenSaver.js \
misc/util.js \
perf/core.js \
ui/altTab.js \
ui/appDisplay.js \
ui/appFavorites.js \
ui/automountManager.js \
ui/autorunManager.js \
ui/boxpointer.js \
ui/calendar.js \
ui/chrome.js \
@ -29,9 +26,8 @@ nobase_dist_js_DATA = \
ui/endSessionDialog.js \
ui/environment.js \
ui/extensionSystem.js \
ui/goaClient.js \
ui/iconGrid.js \
ui/keyboard.js \
ui/layout.js \
ui/lightbox.js \
ui/link.js \
ui/lookingGlass.js \
@ -40,7 +36,6 @@ nobase_dist_js_DATA = \
ui/main.js \
ui/messageTray.js \
ui/modalDialog.js \
ui/shellMountOperation.js \
ui/notificationDaemon.js \
ui/overview.js \
ui/panel.js \

View File

@ -109,8 +109,7 @@ const SessionManagerIface = {
name: 'org.gnome.SessionManager',
methods: [
{ name: 'Logout', inSignature: 'u', outSignature: '' },
{ name: 'Shutdown', inSignature: '', outSignature: '' },
{ name: 'CanShutdown', inSignature: '', outSignature: 'b' }
{ name: 'Shutdown', inSignature: '', outSignature: '' }
]
};

View File

@ -1,53 +0,0 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const DBus = imports.dbus;
const Lang = imports.lang;
const ScreenSaverIface = {
name: 'org.gnome.ScreenSaver',
methods: [{ name: 'GetActive',
inSignature: '',
outSignature: 'b' },
{ name: 'Lock',
inSignature: '' },
{ name: 'SetActive',
inSignature: 'b' }],
signals: [{ name: 'ActiveChanged',
inSignature: 'b' }]
};
function ScreenSaverProxy() {
this._init();
}
ScreenSaverProxy.prototype = {
_init: function() {
DBus.session.proxifyObject(this,
'org.gnome.ScreenSaver',
'/org/gnome/ScreenSaver');
DBus.session.watch_name('org.gnome.ScreenSaver',
false, // do not launch a name-owner if none exists
Lang.bind(this, this._onSSAppeared),
Lang.bind(this, this._onSSVanished));
this.screenSaverActive = false;
this.connect('ActiveChanged',
Lang.bind(this, this._onActiveChanged));
},
_onSSAppeared: function(owner) {
this.GetActiveRemote(Lang.bind(this, function(isActive) {
this.screenSaverActive = isActive;
}))
},
_onSSVanished: function(oldOwner) {
this.screenSaverActive = false;
},
_onActiveChanged: function(object, isActive) {
this.screenSaverActive = isActive;
}
};
DBus.proxifyPrototype(ScreenSaverProxy.prototype, ScreenSaverIface);

View File

@ -45,7 +45,7 @@ function spawn(argv) {
// occur when trying to parse or start the program.
function spawnCommandLine(command_line) {
try {
let [success, argv] = GLib.shell_parse_argv(command_line);
let [success, argc, argv] = GLib.shell_parse_argv(command_line);
trySpawn(argv);
} catch (err) {
_handleSpawnError(command_line, err);
@ -85,10 +85,10 @@ function trySpawn(argv)
// Runs @command_line in the background. If launching @command_line
// fails, this will throw an error.
function trySpawnCommandLine(command_line) {
let success, argv;
let success, argc, argv;
try {
[success, argv] = GLib.shell_parse_argv(command_line);
[success, argc, argv] = GLib.shell_parse_argv(command_line);
} catch (err) {
// Replace "Error invoking GLib.shell_parse_argv: " with
// something nicer

View File

@ -14,8 +14,7 @@ const Tweener = imports.ui.tweener;
const POPUP_APPICON_SIZE = 96;
const POPUP_SCROLL_TIME = 0.10; // seconds
const POPUP_FADE_IN_TIME = 0.4; // seconds
const POPUP_FADE_OUT_TIME = 0.1; // seconds
const POPUP_FADE_TIME = 0.1; // seconds
const APP_ICON_HOVER_TIMEOUT = 200; // milliseconds
@ -75,7 +74,7 @@ AltTabPopup.prototype = {
_allocate: function (actor, box, flags) {
let childBox = new Clutter.ActorBox();
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
let leftPadding = this.actor.get_theme_node().get_padding(St.Side.LEFT);
let rightPadding = this.actor.get_theme_node().get_padding(St.Side.RIGHT);
@ -98,6 +97,8 @@ AltTabPopup.prototype = {
// those calculations
if (this._thumbnails) {
let icon = this._appIcons[this._currentApp].actor;
// Force a stage relayout to make sure we get the correct position
global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, 0, 0);
let [posX, posY] = icon.get_transformed_position();
let thumbnailCenter = posX + icon.width / 2;
let [childMinWidth, childNaturalWidth] = this._thumbnails.actor.get_preferred_width(-1);
@ -120,7 +121,7 @@ AltTabPopup.prototype = {
}
},
show : function(backward, binding) {
show : function(backward, switch_group) {
let tracker = Shell.WindowTracker.get_default();
let apps = tracker.get_running_apps ('');
@ -151,7 +152,7 @@ AltTabPopup.prototype = {
this.actor.get_allocation_box();
// Make the initial selection
if (binding == 'switch_group') {
if (switch_group) {
if (backward) {
this._select(0, this._appIcons[0].cachedWindows.length - 1);
} else {
@ -160,10 +161,6 @@ AltTabPopup.prototype = {
else
this._select(0, 0);
}
} else if (binding == 'switch_group_backward') {
this._select(0, this._appIcons[0].cachedWindows.length - 1);
} else if (binding == 'switch_windows_backward') {
this._select(this._appIcons.length - 1);
} else if (this._appIcons.length == 1) {
this._select(0);
} else if (backward) {
@ -183,15 +180,10 @@ AltTabPopup.prototype = {
return false;
}
// Using easeInOutExpo over 400ms gives us 150ms of "nearly
// invisible" (less than 10% opacity), followed by a 100ms
// tween in (to 90% opacity, with the last 10% coming over the
// next 150ms). So if the user releases Alt quickly after we
// start tweening, they'll never see the switcher.
Tweener.addTween(this.actor,
{ opacity: 255,
time: POPUP_FADE_IN_TIME,
transition: 'easeInOutExpo'
time: POPUP_FADE_TIME,
transition: 'easeOutQuad'
});
return true;
@ -227,25 +219,33 @@ AltTabPopup.prototype = {
this._disableHover();
if (keysym == Clutter.Escape) {
this.destroy();
} else if (action == Meta.KeyBindingAction.SWITCH_GROUP) {
if (action == Meta.KeyBindingAction.SWITCH_GROUP)
this._select(this._currentApp, backwards ? this._previousWindow() : this._nextWindow());
} else if (action == Meta.KeyBindingAction.SWITCH_GROUP_BACKWARD) {
this._select(this._currentApp, this._previousWindow());
} else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS) {
this._select(backwards ? this._previousApp() : this._nextApp());
} else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD) {
this._select(this._previousApp());
} else if (this._thumbnailsFocused) {
if (keysym == Clutter.Left)
else if (keysym == Clutter.Escape)
this.destroy();
else if (this._thumbnailsFocused) {
if (action == Meta.KeyBindingAction.SWITCH_WINDOWS)
if (backwards) {
if (this._currentWindow == 0 || this._currentWindow == -1)
this._select(this._previousApp());
else
this._select(this._currentApp, this._previousWindow());
} else {
if (this._currentWindow == this._appIcons[this._currentApp].cachedWindows.length - 1)
this._select(this._nextApp());
else
this._select(this._currentApp, this._nextWindow());
}
else if (keysym == Clutter.Left)
this._select(this._currentApp, this._previousWindow());
else if (keysym == Clutter.Right)
this._select(this._currentApp, this._nextWindow());
else if (keysym == Clutter.Up)
this._select(this._currentApp, null, true);
} else {
if (keysym == Clutter.Left)
if (action == Meta.KeyBindingAction.SWITCH_WINDOWS)
this._select(backwards ? this._previousApp() : this._nextApp());
else if (keysym == Clutter.Left)
this._select(this._previousApp());
else if (keysym == Clutter.Right)
this._select(this._nextApp());
@ -374,7 +374,7 @@ AltTabPopup.prototype = {
if (this.actor.visible) {
Tweener.addTween(this.actor,
{ opacity: 0,
time: POPUP_FADE_OUT_TIME,
time: POPUP_FADE_TIME,
transition: 'easeOutQuad',
onComplete: Lang.bind(this,
function() {
@ -632,7 +632,7 @@ SwitcherList.prototype = {
this._items[this._highlighted].add_style_pseudo_class('selected');
}
let monitor = Main.layoutManager.primaryMonitor;
let monitor = global.get_primary_monitor();
let itemSize = this._items[index].allocation.x2 - this._items[index].allocation.x1;
let [posX, posY] = this._items[index].get_transformed_position();
posX += this.actor.x;
@ -660,7 +660,7 @@ SwitcherList.prototype = {
_scrollToRight : function() {
this._scrollableLeft = true;
let monitor = Main.layoutManager.primaryMonitor;
let monitor = global.get_primary_monitor();
let padding = this.actor.get_theme_node().get_horizontal_padding();
let parentPadding = this.actor.get_parent().get_theme_node().get_horizontal_padding();
let x = this._items[this._highlighted].allocation.x2 - monitor.width + padding + parentPadding;
@ -757,7 +757,7 @@ SwitcherList.prototype = {
let children = this._list.get_children();
let childBox = new Clutter.ActorBox();
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
let parentRightPadding = this.actor.get_parent().get_theme_node().get_padding(St.Side.RIGHT);
if (this.actor.allocation.x2 == primary.x + primary.width - parentRightPadding) {
if (this._squareItems)
@ -887,7 +887,7 @@ AppSwitcher.prototype = {
totalSpacing += this._separator.width + this._list.spacing;
// We just assume the whole screen here due to weirdness happing with the passed width
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
let parentPadding = this.actor.get_parent().get_theme_node().get_horizontal_padding();
let availWidth = primary.width - parentPadding - this.actor.get_theme_node().get_horizontal_padding();
let height = 0;

View File

@ -44,7 +44,7 @@ AlphabeticalView.prototype = {
this.actor = new St.ScrollView({ x_fill: true,
y_fill: false,
y_align: St.Align.START,
style_class: 'vfade' });
vfade: true });
this.actor.add_actor(box);
this.actor.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
this.actor.connect('notify::mapped', Lang.bind(this,
@ -172,12 +172,10 @@ ViewByCategories.prototype = {
// (used only before the actor is mapped the first time)
this._currentCategory = -2;
this._filters = new St.BoxLayout({ vertical: true, reactive: true });
this._filtersBox = new St.ScrollView({ x_fill: false,
y_fill: false,
style_class: 'vfade' });
this._filtersBox.add_actor(this._filters);
this._filters.connect('scroll-event', Lang.bind(this, this._scrollFilter));
this.actor.add(this._view.actor, { expand: true, x_fill: true, y_fill: true });
this.actor.add(this._filtersBox, { expand: false, y_fill: false, y_align: St.Align.START });
this.actor.add(this._filters, { expand: false, y_fill: false, y_align: St.Align.START });
// Always select the "All" filter when switching to the app view
this.actor.connect('notify::mapped', Lang.bind(this,
@ -195,6 +193,14 @@ ViewByCategories.prototype = {
this.actor.add(this._focusDummy);
},
_scrollFilter: function(actor, event) {
let direction = event.get_scroll_direction();
if (direction == Clutter.ScrollDirection.UP)
this._selectCategory(Math.max(this._currentCategory - 1, -1))
else if (direction == Clutter.ScrollDirection.DOWN)
this._selectCategory(Math.min(this._currentCategory + 1, this._sections.length - 1));
},
_selectCategory: function(num) {
if (this._currentCategory == num) // nothing to do
return;
@ -327,16 +333,8 @@ BaseAppSearchProvider.prototype = {
params = Params.parse(params, { workspace: null,
timestamp: null });
let workspace = params.workspace ? params.workspace.index() : -1;
let event = Clutter.get_current_event();
let modifiers = event ? Shell.get_event_state(event) : 0;
let openNewWindow = modifiers & Clutter.ModifierType.CONTROL_MASK;
let app = this._appSys.get_app(id);
if (openNewWindow)
app.open_new_window(workspace);
else
app.activate(workspace);
app.activate(params.workspace ? params.workspace.index() : -1);
},
dragActivateResult: function(id, params) {

View File

@ -1,278 +0,0 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Lang = imports.lang;
const DBus = imports.dbus;
const Mainloop = imports.mainloop;
const Gio = imports.gi.Gio;
const Params = imports.misc.params;
const Main = imports.ui.main;
const ShellMountOperation = imports.ui.shellMountOperation;
const ScreenSaver = imports.misc.screenSaver;
// GSettings keys
const SETTINGS_SCHEMA = 'org.gnome.desktop.media-handling';
const SETTING_ENABLE_AUTOMOUNT = 'automount';
const AUTORUN_EXPIRE_TIMEOUT_SECS = 10;
const ConsoleKitSessionIface = {
name: 'org.freedesktop.ConsoleKit.Session',
methods: [{ name: 'IsActive',
inSignature: '',
outSignature: 'b' }],
signals: [{ name: 'ActiveChanged',
inSignature: 'b' }]
};
const ConsoleKitSessionProxy = DBus.makeProxyClass(ConsoleKitSessionIface);
const ConsoleKitManagerIface = {
name: 'org.freedesktop.ConsoleKit.Manager',
methods: [{ name: 'GetCurrentSession',
inSignature: '',
outSignature: 'o' }]
};
function ConsoleKitManager() {
this._init();
};
ConsoleKitManager.prototype = {
_init: function() {
this.sessionActive = true;
DBus.system.proxifyObject(this,
'org.freedesktop.ConsoleKit',
'/org/freedesktop/ConsoleKit/Manager');
DBus.system.watch_name('org.freedesktop.ConsoleKit',
false, // do not launch a name-owner if none exists
Lang.bind(this, this._onManagerAppeared),
Lang.bind(this, this._onManagerVanished));
},
_onManagerAppeared: function(owner) {
this.GetCurrentSessionRemote(Lang.bind(this, this._onCurrentSession));
},
_onManagerVanished: function(oldOwner) {
this.sessionActive = true;
},
_onCurrentSession: function(session) {
this._ckSession = new ConsoleKitSessionProxy(DBus.system, 'org.freedesktop.ConsoleKit', session);
this._ckSession.connect
('ActiveChanged', Lang.bind(this, function(object, isActive) {
this.sessionActive = isActive;
}));
this._ckSession.IsActiveRemote(Lang.bind(this, function(isActive) {
this.sessionActive = isActive;
}));
}
};
DBus.proxifyPrototype(ConsoleKitManager.prototype, ConsoleKitManagerIface);
function AutomountManager() {
this._init();
}
AutomountManager.prototype = {
_init: function() {
this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
this._volumeQueue = [];
this.ckListener = new ConsoleKitManager();
this._ssProxy = new ScreenSaver.ScreenSaverProxy();
this._ssProxy.connect('ActiveChanged',
Lang.bind(this,
this._screenSaverActiveChanged));
this._volumeMonitor = Gio.VolumeMonitor.get();
this._volumeMonitor.connect('volume-added',
Lang.bind(this,
this._onVolumeAdded));
this._volumeMonitor.connect('volume-removed',
Lang.bind(this,
this._onVolumeRemoved));
this._volumeMonitor.connect('drive-connected',
Lang.bind(this,
this._onDriveConnected));
this._volumeMonitor.connect('drive-disconnected',
Lang.bind(this,
this._onDriveDisconnected));
this._volumeMonitor.connect('drive-eject-button',
Lang.bind(this,
this._onDriveEjectButton));
Mainloop.idle_add(Lang.bind(this, this._startupMountAll));
},
_screenSaverActiveChanged: function(object, isActive) {
if (!isActive) {
this._volumeQueue.forEach(Lang.bind(this, function(volume) {
this._checkAndMountVolume(volume);
}));
}
// clear the queue anyway
this._volumeQueue = [];
},
_startupMountAll: function() {
let volumes = this._volumeMonitor.get_volumes();
volumes.forEach(Lang.bind(this, function(volume) {
this._checkAndMountVolume(volume, { checkSession: false,
useMountOp: false });
}));
return false;
},
_onDriveConnected: function() {
// if we're not in the current ConsoleKit session,
// or screensaver is active, don't play sounds
if (!this.ckListener.sessionActive)
return;
if (this._ssProxy.screenSaverActive)
return;
global.play_theme_sound(0, 'device-added-media');
},
_onDriveDisconnected: function() {
// if we're not in the current ConsoleKit session,
// or screensaver is active, don't play sounds
if (!this.ckListener.sessionActive)
return;
if (this._ssProxy.screenSaverActive)
return;
global.play_theme_sound(0, 'device-removed-media');
},
_onDriveEjectButton: function(monitor, drive) {
// TODO: this code path is not tested, as the GVfs volume monitor
// doesn't emit this signal just yet.
if (!this.ckListener.sessionActive)
return;
// we force stop/eject in this case, so we don't have to pass a
// mount operation object
if (drive.can_stop()) {
drive.stop
(Gio.MountUnmountFlags.FORCE, null, null,
Lang.bind(this, function(drive, res) {
try {
drive.stop_finish(res);
} catch (e) {
log("Unable to stop the drive after drive-eject-button " + e.toString());
}
}));
} else if (drive.can_eject()) {
drive.eject_with_operation
(Gio.MountUnmountFlags.FORCE, null, null,
Lang.bind(this, function(drive, res) {
try {
drive.eject_with_operation_finish(res);
} catch (e) {
log("Unable to eject the drive after drive-eject-button " + e.toString());
}
}));
}
},
_onVolumeAdded: function(monitor, volume) {
this._checkAndMountVolume(volume);
},
_checkAndMountVolume: function(volume, params) {
params = Params.parse(params, { checkSession: true,
useMountOp: true });
if (params.checkSession) {
// if we're not in the current ConsoleKit session,
// don't attempt automount
if (!this.ckListener.sessionActive)
return;
if (this._ssProxy.screenSaverActive) {
if (this._volumeQueue.indexOf(volume) == -1)
this._volumeQueue.push(volume);
return;
}
}
if (!this._settings.get_boolean(SETTING_ENABLE_AUTOMOUNT) ||
!volume.should_automount() ||
!volume.can_mount()) {
// allow the autorun to run anyway; this can happen if the
// mount gets added programmatically later, even if
// should_automount() or can_mount() are false, like for
// blank optical media.
this._allowAutorun(volume);
this._allowAutorunExpire(volume);
return;
}
if (params.useMountOp) {
let operation = new ShellMountOperation.ShellMountOperation(volume);
this._mountVolume(volume, operation.mountOp);
} else {
this._mountVolume(volume, null);
}
},
_mountVolume: function(volume, operation) {
this._allowAutorun(volume);
volume.mount(0, operation, null,
Lang.bind(this, this._onVolumeMounted));
},
_onVolumeMounted: function(volume, res) {
this._allowAutorunExpire(volume);
try {
volume.mount_finish(res);
} catch (e) {
let string = e.toString();
// FIXME: needs proper error code handling instead of this
// See https://bugzilla.gnome.org/show_bug.cgi?id=591480
if (string.indexOf('No key available with this passphrase') != -1)
this._reaskPassword(volume);
else
log('Unable to mount volume ' + volume.get_name() + ': ' + string);
}
},
_onVolumeRemoved: function(monitor, volume) {
this._volumeQueue =
this._volumeQueue.filter(function(element) {
return (element != volume);
});
},
_reaskPassword: function(volume) {
let operation = new ShellMountOperation.ShellMountOperation(volume, { reaskPassword: true });
this._mountVolume(volume, operation.mountOp);
},
_allowAutorun: function(volume) {
volume.allowAutorun = true;
},
_allowAutorunExpire: function(volume) {
Mainloop.timeout_add_seconds(AUTORUN_EXPIRE_TIMEOUT_SECS, function() {
volume.allowAutorun = false;
return false;
});
}
}

View File

@ -1,634 +0,0 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Lang = imports.lang;
const DBus = imports.dbus;
const Gio = imports.gi.Gio;
const St = imports.gi.St;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
const ShellMountOperation = imports.ui.shellMountOperation;
// GSettings keys
const SETTINGS_SCHEMA = 'org.gnome.desktop.media-handling';
const SETTING_DISABLE_AUTORUN = 'autorun-never';
const SETTING_START_APP = 'autorun-x-content-start-app';
const SETTING_IGNORE = 'autorun-x-content-ignore';
const SETTING_OPEN_FOLDER = 'autorun-x-content-open-folder';
const AutorunSetting = {
RUN: 0,
IGNORE: 1,
FILES: 2,
ASK: 3
};
const HOTPLUG_ICON_SIZE = 16;
// misc utils
function ignoreAutorunForMount(mount) {
let root = mount.get_root();
let volume = mount.get_volume();
if ((root.is_native() && !isMountRootHidden(root)) ||
(volume && volume.allowAutorun && volume.should_automount()))
return false;
return true;
}
function isMountRootHidden(root) {
let path = root.get_path();
// skip any mounts in hidden directory hierarchies
return (path.indexOf('/.') != -1);
}
function startAppForMount(app, mount) {
let files = [];
let root = mount.get_root();
let retval = false;
files.push(root);
try {
retval = app.launch(files,
global.create_app_launch_context())
} catch (e) {
log('Unable to launch the application ' + app.get_name()
+ ': ' + e.toString());
}
return retval;
}
/******************************************/
const HotplugSnifferIface = {
name: 'org.gnome.Shell.HotplugSniffer',
methods: [{ name: 'SniffURI',
inSignature: 's',
outSignature: 'as' }]
};
const HotplugSniffer = function() {
this._init();
};
HotplugSniffer.prototype = {
_init: function() {
DBus.session.proxifyObject(this,
'org.gnome.Shell.HotplugSniffer',
'/org/gnome/Shell/HotplugSniffer');
},
};
DBus.proxifyPrototype(HotplugSniffer.prototype, HotplugSnifferIface);
function ContentTypeDiscoverer(callback) {
this._init(callback);
}
ContentTypeDiscoverer.prototype = {
_init: function(callback) {
this._callback = callback;
},
guessContentTypes: function(mount) {
// guess mount's content types using GIO
mount.guess_content_type(false, null,
Lang.bind(this,
this._onContentTypeGuessed));
},
_onContentTypeGuessed: function(mount, res) {
let contentTypes = [];
try {
contentTypes = mount.guess_content_type_finish(res);
} catch (e) {
log('Unable to guess content types on added mount ' + mount.get_name()
+ ': ' + e.toString());
}
if (contentTypes.length) {
this._emitCallback(mount, contentTypes);
} else {
let root = mount.get_root();
let hotplugSniffer = new HotplugSniffer();
hotplugSniffer.SniffURIRemote
(root.get_uri(), DBus.CALL_FLAG_START,
Lang.bind(this, function(contentTypes) {
this._emitCallback(mount, contentTypes);
}));
}
},
_emitCallback: function(mount, contentTypes) {
if (!contentTypes)
contentTypes = [];
// we're not interested in win32 software content types here
contentTypes = contentTypes.filter(function(type) {
return (type != 'x-content/win32-software');
});
let apps = [];
contentTypes.forEach(function(type) {
let app = Gio.app_info_get_default_for_type(type, false);
if (app)
apps.push(app);
});
if (apps.length == 0)
apps.push(Gio.app_info_get_default_for_type('inode/directory', false));
this._callback(mount, apps, contentTypes);
}
}
function AutorunManager() {
this._init();
}
AutorunManager.prototype = {
_init: function() {
this._volumeMonitor = Gio.VolumeMonitor.get();
this._volumeMonitor.connect('mount-added',
Lang.bind(this,
this._onMountAdded));
this._volumeMonitor.connect('mount-removed',
Lang.bind(this,
this._onMountRemoved));
this._transDispatcher = new AutorunTransientDispatcher();
this._createResidentSource();
let mounts = this._volumeMonitor.get_mounts();
mounts.forEach(Lang.bind(this, function (mount) {
let discoverer = new ContentTypeDiscoverer(Lang.bind (this,
function (mount, apps) {
this._residentSource.addMount(mount, apps);
}));
discoverer.guessContentTypes(mount);
}));
},
_createResidentSource: function() {
this._residentSource = new AutorunResidentSource();
this._residentSource.connect('destroy',
Lang.bind(this,
this._createResidentSource));
},
_onMountAdded: function(monitor, mount) {
// don't do anything if our session is not the currently
// active one
if (!Main.automountManager.ckListener.sessionActive)
return;
let discoverer = new ContentTypeDiscoverer(Lang.bind (this,
function (mount, apps, contentTypes) {
this._transDispatcher.addMount(mount, apps, contentTypes);
this._residentSource.addMount(mount, apps);
}));
discoverer.guessContentTypes(mount);
},
_onMountRemoved: function(monitor, mount) {
this._transDispatcher.removeMount(mount);
this._residentSource.removeMount(mount);
},
ejectMount: function(mount) {
let mountOp = new ShellMountOperation.ShellMountOperation(mount);
// first, see if we have a drive
let drive = mount.get_drive();
let volume = mount.get_volume();
if (drive &&
drive.get_start_stop_type() == Gio.DriveStartStopType.SHUTDOWN &&
drive.can_stop()) {
drive.stop(0, mountOp.mountOp, null,
Lang.bind(this, this._onStop));
} else {
if (mount.can_eject()) {
mount.eject_with_operation(0, mountOp.mountOp, null,
Lang.bind(this, this._onEject));
} else if (volume && volume.can_eject()) {
volume.eject_with_operation(0, mountOp.mountOp, null,
Lang.bind(this, this._onEject));
} else if (drive && drive.can_eject()) {
drive.eject_with_operation(0, mountOp.mountOp, null,
Lang.bind(this, this._onEject));
} else if (mount.can_unmount()) {
mount.unmount_with_operation(0, mountOp.mountOp, null,
Lang.bind(this, this._onUnmount));
}
}
},
_onUnmount: function(mount, res) {
try {
mount.unmount_with_operation_finish(res);
} catch (e) {
// FIXME: we need to ignore G_IO_ERROR_FAILED_HANDLED errors here
// but we can't access the error code from JS.
// See https://bugzilla.gnome.org/show_bug.cgi?id=591480
log('Unable to eject the mount ' + mount.get_name()
+ ': ' + e.toString());
}
},
_onEject: function(source, res) {
try {
source.eject_with_operation_finish(res);
} catch (e) {
// FIXME: we need to ignore G_IO_ERROR_FAILED_HANDLED errors here
// but we can't access the error code from JS.
// See https://bugzilla.gnome.org/show_bug.cgi?id=591480
log('Unable to eject the drive ' + source.get_name()
+ ': ' + e.toString());
}
},
_onStop: function(drive, res) {
try {
drive.stop_finish(res);
} catch (e) {
// FIXME: we need to ignore G_IO_ERROR_FAILED_HANDLED errors here
// but we can't access the error code from JS.
// See https://bugzilla.gnome.org/show_bug.cgi?id=591480
log('Unable to stop the drive ' + drive.get_name()
+ ': ' + e.toString());
}
},
}
function AutorunResidentSource() {
this._init();
}
AutorunResidentSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function() {
MessageTray.Source.prototype._init.call(this, _('Removable Devices'));
this._mounts = [];
this._notification = new AutorunResidentNotification(this);
this._setSummaryIcon(this.createNotificationIcon(HOTPLUG_ICON_SIZE));
},
addMount: function(mount, apps) {
if (ignoreAutorunForMount(mount))
return;
let filtered = this._mounts.filter(function (element) {
return (element.mount == mount);
});
if (filtered.length != 0)
return;
let element = { mount: mount, apps: apps };
this._mounts.push(element);
this._redisplay();
},
removeMount: function(mount) {
this._mounts =
this._mounts.filter(function (element) {
return (element.mount != mount);
});
this._redisplay();
},
_redisplay: function() {
if (this._mounts.length == 0) {
this._notification.destroy();
this.destroy();
return;
}
this._notification.updateForMounts(this._mounts);
// add ourselves as a source, and push the notification
if (!Main.messageTray.contains(this)) {
Main.messageTray.add(this);
this.pushNotification(this._notification);
}
},
createNotificationIcon: function(iconSize) {
return new St.Icon ({ icon_name: 'drive-harddisk',
icon_size: iconSize ? iconSize : this.ICON_SIZE });
}
}
function AutorunResidentNotification(source) {
this._init(source);
}
AutorunResidentNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source) {
MessageTray.Notification.prototype._init.call(this, source,
source.title, null,
{ customContent: true });
// set the notification as resident
this.setResident(true);
this._layout = new St.BoxLayout ({ style_class: 'hotplug-resident-box',
vertical: true });
this.addActor(this._layout,
{ x_expand: true,
x_fill: true });
},
updateForMounts: function(mounts) {
// remove all the layout content
this._layout.destroy_children();
for (let idx = 0; idx < mounts.length; idx++) {
let element = mounts[idx];
let actor = this._itemForMount(element.mount, element.apps);
this._layout.add(actor, { x_fill: true,
expand: true });
}
},
_itemForMount: function(mount, apps) {
let item = new St.BoxLayout();
// prepare the mount button content
let mountLayout = new St.BoxLayout();
let mountIcon = new St.Icon({ gicon: mount.get_icon(),
style_class: 'hotplug-resident-mount-icon' });
mountLayout.add_actor(mountIcon);
let labelBin = new St.Bin({ y_align: St.Align.MIDDLE });
let mountLabel =
new St.Label({ text: mount.get_name(),
style_class: 'hotplug-resident-mount-label',
track_hover: true,
reactive: true });
labelBin.add_actor(mountLabel);
mountLayout.add_actor(labelBin);
let mountButton = new St.Button({ child: mountLayout,
x_align: St.Align.START,
x_fill: true,
style_class: 'hotplug-resident-mount',
button_mask: St.ButtonMask.ONE });
item.add(mountButton, { x_align: St.Align.START,
expand: true });
let ejectIcon =
new St.Icon({ icon_name: 'media-eject',
style_class: 'hotplug-resident-eject-icon' });
let ejectButton =
new St.Button({ style_class: 'hotplug-resident-eject-button',
button_mask: St.ButtonMask.ONE,
child: ejectIcon });
item.add(ejectButton, { x_align: St.Align.END });
// now connect signals
mountButton.connect('clicked', Lang.bind(this, function(actor, event) {
startAppForMount(apps[0], mount);
}));
ejectButton.connect('clicked', Lang.bind(this, function() {
Main.autorunManager.ejectMount(mount);
}));
return item;
},
}
function AutorunTransientDispatcher() {
this._init();
}
AutorunTransientDispatcher.prototype = {
_init: function() {
this._sources = [];
this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
},
_getAutorunSettingForType: function(contentType) {
let runApp = this._settings.get_strv(SETTING_START_APP);
if (runApp.indexOf(contentType) != -1)
return AutorunSetting.RUN;
let ignore = this._settings.get_strv(SETTING_IGNORE);
if (ignore.indexOf(contentType) != -1)
return AutorunSetting.IGNORE;
let openFiles = this._settings.get_strv(SETTING_OPEN_FOLDER);
if (openFiles.indexOf(contentType) != -1)
return AutorunSetting.FILES;
return AutorunSetting.ASK;
},
_getSourceForMount: function(mount) {
let filtered =
this._sources.filter(function (source) {
return (source.mount == mount);
});
// we always make sure not to add two sources for the same
// mount in addMount(), so it's safe to assume filtered.length
// is always either 1 or 0.
if (filtered.length == 1)
return filtered[0];
return null;
},
_addSource: function(mount, apps) {
// if we already have a source showing for this
// mount, return
if (this._getSourceForMount(mount))
return;
// add a new source
this._sources.push(new AutorunTransientSource(mount, apps));
},
addMount: function(mount, apps, contentTypes) {
// if autorun is disabled globally, return
if (this._settings.get_boolean(SETTING_DISABLE_AUTORUN))
return;
// if the mount doesn't want to be autorun, return
if (ignoreAutorunForMount(mount))
return;
let setting = this._getAutorunSettingForType(contentTypes[0]);
// check at the settings for the first content type
// to see whether we should ask
if (setting == AutorunSetting.IGNORE)
return; // return right away
let success = false;
let app = null;
if (setting == AutorunSetting.RUN) {
app = Gio.app_info_get_default_for_type(type, false);
} else if (setting == AutorunSetting.FILES) {
app = Gio.app_info_get_default_for_type('inode/directory', false);
}
if (app)
success = startAppForMount(app, mount);
// we fallback here also in case the settings did not specify 'ask',
// but we failed launching the default app or the default file manager
if (!success)
this._addSource(mount, apps);
},
removeMount: function(mount) {
let source = this._getSourceForMount(mount);
// if we aren't tracking this mount, don't do anything
if (!source)
return;
// destroy the notification source
source.destroy();
}
}
function AutorunTransientSource(mount, apps) {
this._init(mount, apps);
}
AutorunTransientSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(mount, apps) {
MessageTray.Source.prototype._init.call(this, mount.get_name());
this.mount = mount;
this.apps = apps;
this._notification = new AutorunTransientNotification(this);
this._setSummaryIcon(this.createNotificationIcon(this.ICON_SIZE));
// add ourselves as a source, and popup the notification
Main.messageTray.add(this);
this.notify(this._notification);
},
createNotificationIcon: function(iconSize) {
return new St.Icon({ gicon: this.mount.get_icon(),
icon_size: iconSize ? iconSize : this.ICON_SIZE });
}
}
function AutorunTransientNotification(source) {
this._init(source);
}
AutorunTransientNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source) {
MessageTray.Notification.prototype._init.call(this, source,
source.title, null,
{ customContent: true });
this._box = new St.BoxLayout({ style_class: 'hotplug-transient-box',
vertical: true });
this.addActor(this._box);
this._mount = source.mount;
source.apps.forEach(Lang.bind(this, function (app) {
let actor = this._buttonForApp(app);
if (actor)
this._box.add(actor, { x_fill: true,
x_align: St.Align.START });
}));
this._box.add(this._buttonForEject(), { x_fill: true,
x_align: St.Align.START });
// set the notification to transient and urgent, so that it
// expands out
this.setTransient(true);
this.setUrgency(MessageTray.Urgency.CRITICAL);
},
_buttonForApp: function(app) {
let box = new St.BoxLayout();
let icon = new St.Icon({ gicon: app.get_icon(),
style_class: 'hotplug-notification-item-icon' });
box.add(icon);
let label = new St.Bin({ y_align: St.Align.MIDDLE,
child: new St.Label
({ text: _("Open with %s").format(app.get_display_name()) })
});
box.add(label);
let button = new St.Button({ child: box,
x_fill: true,
x_align: St.Align.START,
button_mask: St.ButtonMask.ONE,
style_class: 'hotplug-notification-item' });
button.connect('clicked', Lang.bind(this, function() {
startAppForMount(app, this._mount);
this.destroy();
}));
return button;
},
_buttonForEject: function() {
let box = new St.BoxLayout();
let icon = new St.Icon({ icon_name: 'media-eject',
style_class: 'hotplug-notification-item-icon' });
box.add(icon);
let label = new St.Bin({ y_align: St.Align.MIDDLE,
child: new St.Label
({ text: _("Eject") })
});
box.add(label);
let button = new St.Button({ child: box,
x_fill: true,
x_align: St.Align.START,
button_mask: St.ButtonMask.ONE,
style_class: 'hotplug-notification-item' });
button.connect('clicked', Lang.bind(this, function() {
Main.autorunManager.ejectMount(this._mount);
}));
return button;
}
}

View File

@ -6,7 +6,6 @@ const Meta = imports.gi.Meta;
const St = imports.gi.St;
const Shell = imports.gi.Shell;
const Main = imports.ui.main;
const Tweener = imports.ui.tweener;
const POPUP_ANIMATION_TIME = 0.15;
@ -330,7 +329,7 @@ BoxPointer.prototype = {
// We also want to keep it onscreen, and separated from the
// edge by the same distance as the main part of the box is
// separated from its sourceActor
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
let themeNode = this.actor.get_theme_node();
let borderWidth = themeNode.get_length('-arrow-border-width');
let arrowBase = themeNode.get_length('-arrow-base');

View File

@ -8,13 +8,13 @@ const Signals = imports.signals;
const Main = imports.ui.main;
const Params = imports.misc.params;
const ScreenSaver = imports.misc.screenSaver;
// This manages the shell "chrome"; the UI that's visible in the
// normal mode (ie, outside the Overview), that surrounds the main
// workspace content.
const defaultParams = {
visibleInOverview: false,
visibleInFullscreen: false,
affectsStruts: true,
affectsInputRegion: true
@ -36,12 +36,8 @@ Chrome.prototype = {
this._trackedActors = [];
Main.connect('initialized', Lang.bind(this, this._finishInit));
},
_finishInit: function() {
Main.layoutManager.connect('monitors-changed',
Lang.bind(this, this._relayout));
global.screen.connect('monitors-changed',
Lang.bind(this, this._monitorsChanged));
global.screen.connect('restacked',
Lang.bind(this, this._windowsRestacked));
@ -54,15 +50,9 @@ Chrome.prototype = {
Main.overview.connect('hidden',
Lang.bind(this, this._overviewHidden));
this._screenSaverProxy = new ScreenSaver.ScreenSaverProxy();
this._screenSaverProxy.connect('ActiveChanged', Lang.bind(this, this._onScreenSaverActiveChanged));
this._screenSaverProxy.GetActiveRemote(Lang.bind(this,
function(result, err) {
if (!err)
this._onScreenSaverActiveChanged(this._screenSaverProxy, result);
}));
this._relayout();
this._updateMonitors();
this._updateFullscreen();
this._queueUpdateRegions();
},
_allocated: function(actor, box, flags) {
@ -83,8 +73,11 @@ Chrome.prototype = {
// in its visibility will affect the input region, but NOT the
// struts.
//
// If %visibleInFullscreen is %true, the actor will be visible
// even when a fullscreen window should be covering it.
// If %visibleInOverview is %true in @params, @actor will remain
// visible when the overview is brought up. Otherwise it will
// automatically be hidden. Likewise, if %visibleInFullscreen is
// %true, the actor will be visible even when a fullscreen window
// should be covering it.
//
// If %affectsStruts or %affectsInputRegion is %false, the actor
// will not have the indicated effect.
@ -103,7 +96,7 @@ Chrome.prototype = {
//
// @params can have any of the same values as in addActor(), though
// some possibilities don't make sense (eg, trying to have a
// %visibleInFullscreen child of a non-%visibleInFullscreen parent).
// %visibleInOverview child of a non-%visibleInOverview parent).
// By default, @actor has the same params as its chrome ancestor.
trackActor: function(actor, params) {
let ancestor = actor.get_parent();
@ -196,8 +189,10 @@ Chrome.prototype = {
_updateVisibility: function() {
for (let i = 0; i < this._trackedActors.length; i++) {
let actorData = this._trackedActors[i];
if (!this._inOverview && !actorData.visibleInFullscreen &&
this._findMonitorForActor(actorData.actor).inFullscreen)
if (this._inOverview && !actorData.visibleInOverview)
this.actor.set_skip_paint(actorData.actor, true);
else if (!this._inOverview && !actorData.visibleInFullscreen &&
this._findMonitorForActor(actorData.actor).inFullscreen)
this.actor.set_skip_paint(actorData.actor, true);
else
this.actor.set_skip_paint(actorData.actor, false);
@ -216,18 +211,18 @@ Chrome.prototype = {
this._queueUpdateRegions();
},
_relayout: function() {
this._monitors = Main.layoutManager.monitors;
this._primaryMonitor = Main.layoutManager.primaryMonitor;
this._updateFullscreen();
this._updateVisibility();
this._queueUpdateRegions();
},
_onScreenSaverActiveChanged: function(proxy, screenSaverActive) {
this.actor.visible = !screenSaverActive;
this._queueUpdateRegions();
_updateMonitors: function() {
let monitors = global.get_monitors();
let primary = global.get_primary_monitor();
this._monitors = monitors;
for (let i = 0; i < monitors.length; i++) {
let monitor = monitors[i];
if (monitor.x == primary.x &&
monitor.y == primary.y &&
monitor.width == primary.width &&
monitor.height == primary.height)
this._primaryMonitor = monitor;
}
},
_findMonitorForRect: function(x, y, w, h) {
@ -266,6 +261,15 @@ Chrome.prototype = {
return this._primaryMonitor; // Not on any monitor, pretend its on the primary
},
_monitorsChanged: function() {
this._updateMonitors();
// Update everything that depends on monitor positions
this._updateFullscreen();
this._updateVisibility();
this._queueUpdateRegions();
},
_queueUpdateRegions: function() {
if (!this._updateRegionIdle)
this._updateRegionIdle = Mainloop.idle_add(Lang.bind(this, this._updateRegions),
@ -331,6 +335,11 @@ Chrome.prototype = {
this._updateVisibility();
this._queueUpdateRegions();
}
// Figure out where the pointer is in case we lost track of
// it during a grab. (In particular, if a trayicon popup menu
// is dismissed, see if we need to close the message tray.)
global.sync_pointer();
},
_updateRegions: function() {

View File

@ -153,14 +153,14 @@ CtrlAltTabPopup.prototype = {
},
_getPreferredWidth: function (actor, forHeight, alloc) {
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
alloc.min_size = primary.width;
alloc.natural_size = primary.width;
},
_getPreferredHeight: function (actor, forWidth, alloc) {
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
alloc.min_size = primary.height;
alloc.natural_size = primary.height;
@ -168,7 +168,7 @@ CtrlAltTabPopup.prototype = {
_allocate: function (actor, box, flags) {
let childBox = new Clutter.ActorBox();
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
let leftPadding = this.actor.get_theme_node().get_padding(St.Side.LEFT);
let vPadding = this.actor.get_theme_node().get_vertical_padding();

View File

@ -324,7 +324,7 @@ Dash.prototype = {
this._favRemoveTarget = null;
}));
}
DND.removeDragMonitor(this._dragMonitor);
DND.removeMonitor(this._dragMonitor);
},
_onDragMotion: function(dragEvent) {
@ -342,10 +342,7 @@ Dash.prototype = {
let srcIsFavorite = (id in favorites);
if (srcIsFavorite &&
dragEvent.source.actor &&
this.actor.contains (dragEvent.source.actor) &&
this._favRemoveTarget == null) {
if (srcIsFavorite && this._favRemoveTarget == null) {
this._favRemoveTarget = new RemoveFavoriteIcon();
this._favRemoveTarget.icon.setIconSize(this.iconSize);
this._box.add(this._favRemoveTarget.actor);

View File

@ -198,7 +198,6 @@ DateMenuButton.prototype = {
_onPreferencesActivate: function() {
this.menu.close();
Main.overview.hide();
let app = Shell.AppSystem.get_default().get_app('gnome-datetime-panel.desktop');
app.activate(-1);
},

View File

@ -61,7 +61,7 @@ function addDragMonitor(monitor) {
dragMonitors.push(monitor);
}
function removeDragMonitor(monitor) {
function removeMonitor(monitor) {
for (let i = 0; i < dragMonitors.length; i++)
if (dragMonitors[i] == monitor) {
dragMonitors.splice(i, 1);
@ -284,13 +284,13 @@ _Draggable.prototype = {
this._dragOffsetY = actorStageY - this._dragStartY;
// Set the actor's scale such that it will keep the same
// transformed size when it's reparented to the uiGroup
// transformed size when it's reparented to the stage
let [scaledWidth, scaledHeight] = this.actor.get_transformed_size();
this.actor.set_scale(scaledWidth / this.actor.width,
scaledHeight / this.actor.height);
}
this._dragActor.reparent(Main.uiGroup);
this._dragActor.reparent(this.actor.get_stage());
this._dragActor.raise_top();
Shell.util_set_hidden_from_pick(this._dragActor, true);
@ -442,7 +442,7 @@ _Draggable.prototype = {
return true;
// If it accepted the drop without taking the actor,
// handle it ourselves.
if (this._dragActor.get_parent() == Main.uiGroup) {
if (this._dragActor.get_parent() == this._dragActor.get_stage()) {
if (this._restoreOnSuccess) {
this._restoreDragActor(event.get_time());
return true;

View File

@ -39,6 +39,35 @@ function _patchContainerClass(containerClass) {
};
}
// Replace @method with something that throws an error instead
function _blockMethod(method, replacement, reason) {
let match = method.match(/^(.+)\.([^.]+)$/);
if (!match)
throw new Error('Bad method name "' + method + '"');
let proto = 'imports.gi.' + match[1] + '.prototype';
let property = match[2];
if (!global.set_property_mutable(proto, property, true))
throw new Error('Bad method name "' + method + '"');
// eval() is evil in general, but we know it's safe here since
// set_property_mutable() would have failed if proto was
// malformed.
let node = eval(proto);
let msg = 'Do not use "' + method + '".';
if (replacement)
msg += ' Use "' + replacement + '" instead.';
if (reason)
msg += ' (' + reason + ')';
node[property] = function() {
throw new Error(msg);
};
global.set_property_mutable(proto, property, false);
}
function init() {
// Add some bindings to the global JS namespace; (gjs keeps the web
// browser convention of having that namespace be called 'window'.)
@ -70,6 +99,17 @@ function init() {
return base;
};
_blockMethod('Clutter.Event.get_state', 'Shell.get_event_state',
'gjs\'s handling of Clutter.ModifierType is broken. See bug 597292.');
_blockMethod('Gdk.Window.get_device_position', 'global.get_pointer',
'gjs\'s handling of Gdk.ModifierType is broken. See bug 597292.');
// Now close the back door to prevent extensions from trying to
// abuse it. We can't actually delete it since
// Shell.Global.prototype itself is read-only.
global.set_property_mutable('imports.gi.Shell.Global.prototype', 'set_property_mutable', true);
Shell.Global.prototype.set_property_mutable = undefined;
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=508783
Date.prototype.toLocaleFormat = function(format) {
return Shell.util_format_date(format, this.getTime());

View File

@ -23,9 +23,8 @@ const ExtensionType = {
const extensionMeta = {};
// Maps uuid -> importer object (extension directory tree)
const extensions = {};
// Arrays of uuids
// Array of uuids
var disabledExtensions;
var enabledExtensions;
// GFile for user extensions
var userExtensionsDir = null;
@ -179,7 +178,6 @@ function init() {
}
disabledExtensions = global.settings.get_strv('disabled-extensions', -1);
enabledExtensions = global.settings.get_strv('enabled-extensions', -1);
}
function _loadExtensionsIn(dir, type) {
@ -197,10 +195,7 @@ function _loadExtensionsIn(dir, type) {
if (fileType != Gio.FileType.DIRECTORY)
continue;
let name = info.get_name();
// Enable all but disabled extensions if enabledExtensions is not set.
// If it is set, enable one those, except they are disabled as well.
let enabled = (enabledExtensions.length == 0 || enabledExtensions.indexOf(name) >= 0)
&& disabledExtensions.indexOf(name) < 0;
let enabled = disabledExtensions.indexOf(name) < 0;
let child = dir.get_child(name);
loadExtension(child, enabled, type);
}

500
js/ui/goaClient.js Normal file
View File

@ -0,0 +1,500 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Goa = imports.gi.Goa;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Shell = imports.gi.Shell;
const Signals = imports.signals;
const St = imports.gi.St;
const Gettext = imports.gettext.domain('gnome-shell');
const _ = Gettext.gettext;
const C_ = Gettext.pgettext;
const Gtk = imports.gi.Gtk;
const Pango = imports.gi.Pango;
const History = imports.misc.history;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
// ----------------------------------------------------------------------------------------------------
function Client() {
this._init();
}
Client.prototype = {
_init : function() {
this._client = null;
this._accountIdToMailMonitor = {}
this._mailSource = null;
// TODO: need to call refreshAllMonitors() when network-connectivity changes
Goa.Client.new(null, /* cancellable */
Lang.bind(this, this._onClientConstructed));
},
_onClientConstructed : function(object, asyncRes) {
this._client = object.new_finish(asyncRes);
this._updateAccounts();
this._client.connect('account-added', Lang.bind(this, this._updateAccounts));
this._client.connect('account-removed', Lang.bind(this, this._updateAccounts));
this._client.connect('account-changed', Lang.bind(this, this._updateAccounts));
},
_updateAccounts : function () {
let objects = this._client.get_accounts();
let mailIds = {};
// Add monitors for accounts that now exist
for (let n = 0; n < objects.length; n++) {
let object = objects[n];
let id = object.account.id;
if (object.mail) {
mailIds[id] = true;
if (!(id in this._accountIdToMailMonitor)) {
let monitor = new MailMonitor(this, object);
this._accountIdToMailMonitor[id] = monitor;
}
}
}
// Nuke monitors for accounts that are now non-existant
let monitorsToRemove = []
for (let existingMonitorId in this._accountIdToMailMonitor) {
if (!(existingMonitorId in mailIds)) {
monitorsToRemove.push(existingMonitorId);
}
}
for (let n = 0; n < monitorsToRemove.length; n++) {
let id = monitorsToRemove[n];
let monitor = this._accountIdToMailMonitor[id];
delete this._accountIdToMailMonitor[id]
monitor.destroy();
}
},
_ensureMailSource: function() {
if (!this._mailSource) {
this._mailSource = new MailSource(this);
this._mailSource.connect('destroy', Lang.bind(this,
function () {
this._mailSource = null;
}));
Main.messageTray.add(this._mailSource);
}
},
addPendingMessage: function(message) {
this._ensureMailSource();
this._mailSource.addMessage(message);
},
refreshAllMonitors: function() {
log('Refreshing all mail monitors');
for (let id in this._accountIdToMailMonitor) {
let monitor = this._accountIdToMailMonitor[id];
monitor.refresh();
}
}
}
// ----------------------------------------------------------------------------------------------------
function Message(uid, from, subject, excerpt, uri, can_be_marked_as_spam, can_be_starred) {
this._init(uid, from, subject, excerpt, uri, can_be_marked_as_spam, can_be_starred);
}
Message.prototype = {
_init: function(uid, from, subject, excerpt, uri, can_be_marked_as_spam, can_be_starred) {
this.uid = uid;
this.from = from;
this.subject = subject;
this.excerpt = excerpt;
this.uri = uri;
this.can_be_marked_as_spam = can_be_marked_as_spam;
this.can_be_starred = can_be_starred;
this.receivedAt = new Date();
}
}
// ----------------------------------------------------------------------------------------------------
function MailMonitor(client, accountObject) {
this._init(client, accountObject);
}
MailMonitor.prototype = {
_init : function(client, accountObject) {
this._client = client;
this._accountObject = accountObject;
this._account = this._accountObject.get_account();
this._mail = this._accountObject.get_mail();
// Create the remote monitor object
this._proxy = null;
this._cancellable = new Gio.Cancellable();
this._mail.call_create_monitor(this._cancellable, Lang.bind(this, this._onMonitorCreated));
},
destroy : function() {
this._cancellable.cancel();
if (this._proxy) {
// We don't really care if this fails or not
this._proxy.call_close(null, Lang.bind(this, function() { }));
this._proxy.disconnect(this._messageReceivedId);
this._proxy = null;
}
},
refresh : function() {
if (this._proxy) {
// We don't really care if this fails or not
log('Refreshing mail monitor for account ' + this._account.name);
this._proxy.call_refresh(null, Lang.bind(this, function() { }));
}
},
_onMonitorCreated : function(mail, asyncRes) {
// TODO: a (gboolean, object_path) tuple is returned here
// See https://bugzilla.gnome.org/show_bug.cgi?id=649657
let ret = mail.call_create_monitor_finish(asyncRes);
let object_path = ret[1];
Goa.MailMonitorProxy.new_for_bus(Gio.BusType.SESSION,
Gio.DBusProxyFlags.NONE,
'org.gnome.OnlineAccounts',
object_path,
null, /* cancellable */
Lang.bind(this, this._onMonitorProxyConstructed));
},
_onMonitorProxyConstructed : function(monitor, asyncRes) {
this._proxy = monitor.new_for_bus_finish(asyncRes);
// Now listen for changes on the mail monitor proxy
this._messageReceivedId = this._proxy.connect('message-received',
Lang.bind(this, this._onMessageReceived));
},
_onMessageReceived : function(monitor, uid, from, subject, excerpt, uri, can_be_marked_as_spam, can_be_starred) {
let message = new Message(uid, from, subject, excerpt, uri, can_be_marked_as_spam, can_be_starred);
if (!Main.messageTray.getBusy()) {
let source = new Source(this._client, message);
let notification = new Notification(source, this._client, this, message);
// If the user is not marked as busy, present the notification to the user
Main.messageTray.add(source);
source.notify(notification);
} else {
// ... otherwise, if the user is busy, just add it to the MailSource's list
// of pending messages
this._client.addPendingMessage(message);
}
},
MessageAddStar: function (message) {
this._proxy.call_add_star(message.uid,
null, /* cancellable */
Lang.bind(this,
function(object, asyncRes) {
this._proxy.call_add_star_finish(asyncRes);
}));
},
MessageMarkAsSpam: function (message) {
this._proxy.call_mark_as_spam(message.uid,
null, /* cancellable */
Lang.bind(this,
function(object, asyncRes) {
this._proxy.call_add_star_finish(asyncRes);
}));
}
}
// ----------------------------------------------------------------------------------------------------
function Source(client, message) {
this._init(client, message);
}
Source.prototype = {
__proto__: MessageTray.Source.prototype,
_init : function(client, message) {
this._client = client;
this._message = message;
// Init super class and add ourselves to the message tray
MessageTray.Source.prototype._init.call(this, 'Message from ' + _stripEmailAddress(this._message.from));
this.setTransient(true);
this.isChat = true;
this._setSummaryIcon(this.createNotificationIcon());
},
createNotificationIcon : function() {
// TODO: use account icon
let icon = new St.Icon({ icon_type: St.IconType.FULLCOLOR,
icon_size: this.ICON_SIZE,
icon_name: 'mail-send'});
return icon;
}
}
// ----------------------------------------------------------------------------------------------------
function _stripEmailAddress(name_and_addr) {
let bracketStartPos = name_and_addr.indexOf(' <');
if (bracketStartPos == -1) {
return name_and_addr;
} else {
return name_and_addr.slice(0, bracketStartPos);
}
}
function Notification(source, client, monitor, message) {
this._init(source, client, monitor, message);
}
Notification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init : function(source, client, monitor, message) {
this._client = client;
this._monitor = monitor
this._message = message;
this._ignore = false;
this._alreadyExpanded = false;
this._strippedFrom = _stripEmailAddress(this._message.from);
let title = this._strippedFrom;
let banner = this._message.subject + ' \u2014 ' + this._message.excerpt; // — U+2014 EM DASH
// Init super class
MessageTray.Notification.prototype._init.call(this, source, title, banner);
// Change the contents once expanded
this.connect('expanded', Lang.bind (this, this._onExpanded));
this.update(title, banner);
this.setUrgency(MessageTray.Urgency.NORMAL);
this.setTransient(true);
this.addButton('ignore', 'Ignore');
if (message.can_be_starred)
this.addButton('star', 'Star');
if (message.can_be_marked_as_spam)
this.addButton('spam', 'Junk');
if (this._message.uri.length > 0) {
this.addButton('open', 'Open');
}
this.connect('action-invoked', Lang.bind(this,
function(notification, id) {
if (id == 'ignore') {
this._actionIgnore();
} else if (id == 'star') {
this._actionStar();
} else if (id == 'spam') {
this._actionSpam();
} else if (id == 'open') {
this._actionOpen();
}
}));
this.connect('clicked', Lang.bind(this,
function() {
if (this._message.uri.length > 0) {
this._actionOpen();
}
}));
// Hmm, should be ::done-displaying instead?
this.connect('destroy', Lang.bind(this, this._onDestroyed));
},
_onExpanded : function() {
if (this._alreadyExpanded)
return;
this._alreadyExpanded = true;
let escapedExcerpt = GLib.markup_escape_text(this._message.excerpt, -1);
let bannerMarkup = '<b>Subject:</b> ' + this._message.subject + '\n';
// TODO: if available, insert other headers such as Cc
bannerMarkup += '\n' + escapedExcerpt;
this.update(this._strippedFrom, bannerMarkup, {bannerMarkup: true});
},
_onDestroyed : function(reason) {
// If not ignoring the message, push it onto the Mail source
if (!this._ignore) {
this._client.addPendingMessage(this._message);
}
},
_actionIgnore : function() {
this._ignore = true;
},
_actionStar : function() {
this._ignore = true;
this._monitor.MessageAddStar(this._message);
},
_actionSpam : function() {
this._ignore = true;
this._monitor.MessageMarkAsSpam(this._message);
},
_actionOpen : function() {
this._ignore = true;
Gio.app_info_launch_default_for_uri(this._message.uri,
global.create_app_launch_context());
}
}
// ----------------------------------------------------------------------------------------------------
function _sameDay(dateA, dateB) {
return (dateA.getDate() == dateB.getDate() &&
dateA.getMonth() == dateB.getMonth() &&
dateA.getYear() == dateB.getYear());
}
function _sameYear(dateA, dateB) {
return (dateA.getYear() == dateB.getYear());
}
function _formatRelativeDate(date) {
let ret = ''
let now = new Date();
if (_sameDay(date, now)) {
ret = date.toLocaleFormat("%l:%M %p");
} else {
if (_sameYear(date, now)) {
ret = date.toLocaleFormat("%B %e");
} else {
ret = date.toLocaleFormat("%B %e, %Y");
}
}
return ret;
}
function _addMessageToTable(table, message) {
let formattedExcerpt = message.excerpt.replace(/\r/g, '').replace(/\n/g, ' ');
let formattedDate = _formatRelativeDate(message.receivedAt);
let fromLabel = new St.Label({ style_class: 'goa-message-base goa-message-from',
text: _stripEmailAddress(message.from)});
let hbox = new St.BoxLayout({ style_class: 'goa-message-hbox', vertical: false });
let subjectLabel = new St.Label({ style_class: 'goa-message-base goa-message-subject',
text: message.subject });
let excerptLabel = new St.Label({ style_class: 'goa-message-base goa-message-excerpt',
text: formattedExcerpt });
let dateLabel = new St.Label({ style_class: 'goa-message-base goa-message-date',
text: formattedDate });
excerptLabel.clutter_text.line_wrap = false;
excerptLabel.clutter_text.ellipsize = Pango.EllipsizeMode.END;
hbox.add(subjectLabel, { x_fill: true,
y_fill: false,
x_align: St.Align.END,
y_align: St.Align.START });
hbox.add(excerptLabel, { x_fill: true,
y_fill: false,
x_align: St.Align.END,
y_align: St.Align.START });
let n = table.get_row_count();
table.add(fromLabel, { x_fill: true, x_expand: true, row: n, col: 0 });
table.add(hbox, { row: n, col: 1 });
table.add(dateLabel, { row: n, col: 2 });
}
function MailSource(client) {
this._init(client);
}
MailSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init : function(client) {
this._client = client;
this._pendingMessages = [];
// Init super class and add ourselves to the message tray
MessageTray.Source.prototype._init.call(this, 'Mail');
// Create the notification
this._notification = new MessageTray.Notification(this)
this._notification.setUrgency(MessageTray.Urgency.NORMAL);
this._notification.setResident(true);
this._updateNotification();
this.pushNotification(this._notification);
// Refresh all monitors everytime the "Mail" notification is displayed
this._notification.connect('expanded', Lang.bind(this,
function() {
this._client.refreshAllMonitors();
}));
},
createNotificationIcon : function() {
let numPending = this._pendingMessages.length;
let baseIcon = new Gio.ThemedIcon({ name: 'mail-mark-unread'});
let numerableIcon = new Gtk.NumerableIcon({ gicon: baseIcon });
numerableIcon.set_count(numPending);
let icon = new St.Icon({ icon_type: St.IconType.FULLCOLOR,
icon_size: this.ICON_SIZE });
icon.set_gicon(numerableIcon);
return icon;
},
_updateNotification: function() {
if (!this._notification)
return
let title = 'Mail';
let banner = ''
let table = new St.Table({ homogeneous: false,
style_class: 'goa-message-table',
reactive: true });
for (let n = 0; n < this._pendingMessages.length; n++)
_addMessageToTable (table, this._pendingMessages[n]);
this._notification.update(title, banner, { clear: true,
icon: this.createNotificationIcon() });
this._notification.addActor(table);
this._notification.addButton('close', 'Close');
this._notification.addButton('ignore-all', 'Ignore All');
this._notification.connect('action-invoked', Lang.bind(this,
function(notification, id) {
if (id == 'close') {
// TODO: Can't find another way hide it
notification._onClicked();
} else if (id == 'ignore-all') {
this.clearMessages();
}
}));
},
addMessage: function(message) {
this._pendingMessages.push(message);
// Update notification
this._updateNotification();
// Update icon with latest pending count
this._setSummaryIcon(this.createNotificationIcon());
},
clearMessages: function() {
let notification = this._notification;
this._notification = null;
if (notification)
notification.destroy();
this.destroy();
},
}

View File

@ -1,609 +0,0 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Caribou = imports.gi.Caribou;
const Clutter = imports.gi.Clutter;
const DBus = imports.dbus;
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
const BoxPointer = imports.ui.boxpointer;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
const PopupMenu = imports.ui.popupMenu;
const Tweener = imports.ui.tweener;
const KEYBOARD_SCHEMA = 'org.gnome.shell.keyboard';
const SHOW_KEYBOARD = 'show-keyboard';
const KEYBOARD_TYPE = 'keyboard-type';
const ENABLE_DRAGGABLE = 'enable-drag';
const ENABLE_FLOAT = 'enable-float';
// Key constants taken from Antler
const PRETTY_KEYS = {
'BackSpace': '\u232b',
'space': ' ',
'Return': '\u23ce',
'Caribou_Prefs': '\u2328',
'Caribou_ShiftUp': '\u2b06',
'Caribou_ShiftDown': '\u2b07',
'Caribou_Emoticons': '\u263a',
'Caribou_Symbols': '123',
'Caribou_Symbols_More': '{#*',
'Caribou_Alpha': 'Abc',
'Tab': 'Tab',
'Escape': 'Esc',
'Control_L': 'Ctrl',
'Alt_L': 'Alt'
};
const CaribouKeyboardIface = {
name: 'org.gnome.Caribou.Keyboard',
methods: [ { name: 'Show',
inSignature: '',
outSignature: ''
},
{ name: 'Hide',
inSignature: '',
outSignature: ''
},
{ name: 'SetCursorLocation',
inSignature: 'iiii',
outSignature: ''
},
{ name: 'SetEntryLocation',
inSignature: 'iiii',
outSignature: ''
} ],
properties: [ { name: 'Name',
signature: 's',
access: 'read' } ]
};
function Key() {
this._init.apply(this, arguments);
}
Key.prototype = {
_init : function(key, key_width, key_height) {
this._key = key;
this._width = key_width;
this._height = key_height;
this.actor = this._getKey();
this._extended_keys = this._key.get_extended_keys();
this._extended_keyboard = {};
if (this._key.name == "Control_L" || this._key.name == "Alt_L")
this._key.latch = true;
this._key.connect('key-pressed', Lang.bind(this, function ()
{ this.actor.checked = true }));
this._key.connect('key-released', Lang.bind(this, function ()
{ this.actor.checked = false; }));
if (this._extended_keys.length > 0) {
this._grabbed = false;
this._eventCaptureId = 0;
this._key.connect('notify::show-subkeys', Lang.bind(this, this._onShowSubkeysChanged));
this._boxPointer = new BoxPointer.BoxPointer(St.Side.BOTTOM,
{ x_fill: true,
y_fill: true,
x_align: St.Align.START });
// Adds style to existing keyboard style to avoid repetition
this._boxPointer.actor.add_style_class_name('keyboard-subkeys');
this._getExtendedKeys();
this.actor._extended_keys = this._extended_keyboard;
this._boxPointer.actor.hide();
Main.chrome.addActor(this._boxPointer.actor, { visibleInFullscreen: true,
affectsStruts: false });
}
},
_getKey: function () {
let label = this._key.name;
if (label.length > 1) {
let pretty = PRETTY_KEYS[label];
if (pretty)
label = pretty;
else
label = this._getUnichar(this._key);
}
label = GLib.markup_escape_text(label, -1);
let button = new St.Button ({ label: label, style_class: 'keyboard-key' });
button.width = this._width;
button.key_width = this._key.width;
button.height = this._height;
button.draggable = false;
button.connect('button-press-event', Lang.bind(this, function () { this._key.press(); }));
button.connect('button-release-event', Lang.bind(this, function () { this._key.release(); }));
return button;
},
_getUnichar: function(key) {
let keyval = key.keyval;
let unichar = Gdk.keyval_to_unicode(keyval);
if (unichar) {
return String.fromCharCode(unichar);
} else {
return key.name;
}
},
_getExtendedKeys: function () {
this._extended_keyboard = new St.BoxLayout({ style_class: 'keyboard-layout',
vertical: false });
for (let i = 0; i < this._extended_keys.length; ++i) {
let extended_key = this._extended_keys[i];
let label = this._getUnichar(extended_key);
let key = new St.Button({ label: label, style_class: 'keyboard-key' });
key.extended_key = extended_key;
key.width = this._width;
key.height = this._height;
key.draggable = false;
key.connect('button-press-event', Lang.bind(this, function () { extended_key.press(); }));
key.connect('button-release-event', Lang.bind(this, function () { extended_key.release(); }));
this._extended_keyboard.add(key);
}
this._boxPointer.bin.add_actor(this._extended_keyboard);
},
_onEventCapture: function (actor, event) {
let source = event.get_source();
if (event.type() == Clutter.EventType.BUTTON_PRESS ||
(event.type() == Clutter.EventType.BUTTON_RELEASE && source.draggable)) {
if (this._extended_keyboard.contains(source)) {
if (source.draggable) {
source.extended_key.press();
source.extended_key.release();
}
this._ungrab();
return false;
}
this._boxPointer.actor.hide();
this._ungrab();
return true;
}
return false;
},
_ungrab: function () {
global.stage.disconnect(this._eventCaptureId);
this._eventCaptureId = 0;
this._grabbed = false;
Main.popModal(this.actor);
},
_onShowSubkeysChanged: function () {
if (this._key.show_subkeys) {
this.actor.fake_release();
this._boxPointer.actor.raise_top();
this._boxPointer.setPosition(this.actor, 5, 0.5);
this._boxPointer.show(true);
this.actor.set_hover(false);
if (!this._grabbed) {
Main.pushModal(this.actor);
this._eventCaptureId = global.stage.connect('captured-event', Lang.bind(this, this._onEventCapture));
this._grabbed = true;
}
this._key.release();
} else {
if (this._grabbed)
this._ungrab();
this._boxPointer.hide(true);
}
}
};
function Keyboard() {
this._init.apply(this, arguments);
}
Keyboard.prototype = {
_init: function () {
DBus.session.exportObject('/org/gnome/Caribou/Keyboard', this);
DBus.session.acquire_name('org.gnome.Caribou.Keyboard', 0, null, null);
this.actor = new St.BoxLayout({ name: 'keyboard', vertical: true, reactive: true });
this._keyboardSettings = new Gio.Settings({ schema: KEYBOARD_SCHEMA });
this._keyboardSettings.connect('changed', Lang.bind(this, this._display));
this._setupKeyboard();
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._redraw));
Main.layoutManager.bottomBox.add_actor(this.actor);
},
init: function () {
this._display();
},
_setupKeyboard: function() {
if (this._keyboardNotifyId)
this._keyboard.disconnect(this._keyboardNotifyId);
let children = this.actor.get_children();
for (let i = 0; i < children.length; i++)
children[i].destroy();
this._keyboard = new Caribou.KeyboardModel({ keyboard_type: this._keyboardSettings.get_string(KEYBOARD_TYPE) });
this._groups = {};
this._current_page = null;
// Initialize keyboard key measurements
this._numOfHorizKeys = 0;
this._numOfVertKeys = 0;
this._floatId = 0;
this._addKeys();
this._keyboardNotifyId = this._keyboard.connect('notify::active-group', Lang.bind(this, this._onGroupChanged));
},
_display: function () {
if (this._keyboard.keyboard_type != this._keyboardSettings.get_string(KEYBOARD_TYPE))
this._setupKeyboard();
this._showKeyboard = this._keyboardSettings.get_boolean(SHOW_KEYBOARD);
this._draggable = this._keyboardSettings.get_boolean(ENABLE_DRAGGABLE);
this._floating = this._keyboardSettings.get_boolean(ENABLE_FLOAT);
if (this._floating) {
this._floatId = this.actor.connect('button-press-event', Lang.bind(this, this._startDragging));
this._dragging = false;
}
else
this.actor.disconnect(this._floatId);
if (this._showKeyboard)
this.show();
else {
this.hide();
this.destroySource();
}
},
_startDragging: function (actor, event) {
if (this._dragging) // don't allow two drags at the same time
return;
this._dragging = true;
this._preDragStageMode = global.stage_input_mode;
Clutter.grab_pointer(this.actor);
global.set_stage_input_mode(Shell.StageInputMode.FULLSCREEN);
this._releaseId = this.actor.connect('button-release-event', Lang.bind(this, this._endDragging));
this._motionId = this.actor.connect('motion-event', Lang.bind(this, this._motionEvent));
[this._dragStartX, this._dragStartY] = event.get_coords();
[this._currentX, this._currentY] = this.actor.get_position();
},
_endDragging: function () {
if (this._dragging) {
this.actor.disconnect(this._releaseId);
this.actor.disconnect(this._motionId);
Clutter.ungrab_pointer();
global.set_stage_input_mode(this._preDragStageMode);
global.unset_cursor();
this._dragging = false;
}
return true;
},
_motionEvent: function(actor, event) {
let absX, absY;
[absX, absY] = event.get_coords();
global.set_cursor(Shell.Cursor.DND_IN_DRAG);
this._moveHandle(absX, absY);
return true;
},
_moveHandle: function (stageX, stageY) {
let x, y;
x = stageX - this._dragStartX + this._currentX;
y = stageY - this._dragStartY + this._currentY;
this.actor.set_position(x,y);
},
_addKeys: function () {
let groups = this._keyboard.get_groups();
for (let i = 0; i < groups.length; ++i) {
let gname = groups[i];
let group = this._keyboard.get_group(gname);
group.connect('notify::active-level', Lang.bind(this, this._onLevelChanged));
let layers = {};
let levels = group.get_levels();
for (let j = 0; j < levels.length; ++j) {
let lname = levels[j];
let level = group.get_level(lname);
let layout = new St.BoxLayout({ style_class: 'keyboard-layout',
vertical: true });
this._loadRows(level, layout);
layers[lname] = layout;
this.actor.add(layout, { x_fill: false });
layout.hide();
}
this._groups[gname] = layers;
}
this._setActiveLayer();
},
_getTrayIcon: function () {
let trayButton = new St.Button ({ label: "tray", style_class: 'keyboard-key' });
trayButton.key_width = 1;
trayButton.connect('button-press-event', Lang.bind(this, function () {
Main.layoutManager.updateForTray();
}));
Main.overview.connect('showing', Lang.bind(this, function () {
trayButton.reactive = false;
trayButton.add_style_pseudo_class('grayed');
}));
Main.overview.connect('hiding', Lang.bind(this, function () {
trayButton.reactive = true;
trayButton.remove_style_pseudo_class('grayed');
}));
return trayButton;
},
_addRows : function (keys, layout) {
let keyboard_row = new St.BoxLayout();
for (let i = 0; i < keys.length; ++i) {
let children = keys[i].get_children();
let right_box = new St.BoxLayout({ style_class: 'keyboard-row' });
let left_box = new St.BoxLayout({ style_class: 'keyboard-row' });
for (let j = 0; j < children.length; ++j) {
if (this._numOfHorizKeys == 0)
this._numOfHorizKeys = children.length;
let key = children[j];
let button = new Key(key, 0, 0);
if (key.align == 'right')
right_box.add(button.actor);
else
left_box.add(button.actor);
if (key.name == "Caribou_Prefs") {
key.connect('key-released', Lang.bind(this, this._onPrefsClick));
// Add new key for hiding message tray
right_box.add(this._getTrayIcon());
}
}
keyboard_row.add(left_box, { expand: true, x_fill: false, x_align: St.Align.START });
keyboard_row.add(right_box, { expand: true, x_fill: false, x_align: St.Align.END });
}
layout.add(keyboard_row);
},
_manageTray: function () {
this.createSource();
},
_onPrefsClick: function () {
this.hide();
this._manageTray();
},
_loadRows : function (level, layout) {
let rows = level.get_rows();
for (let i = 0; i < rows.length; ++i) {
let row = rows[i];
if (this._numOfVertKeys == 0)
this._numOfVertKeys = rows.length;
this._addRows(row.get_columns(), layout);
}
},
_redraw: function () {
let monitor = Main.layoutManager.bottomMonitor;
let maxHeight = monitor.height / 3;
this.actor.width = monitor.width;
let layout = this._current_page;
let verticalSpacing = layout.get_theme_node().get_length('spacing');
let padding = layout.get_theme_node().get_length('padding');
let box = layout.get_children()[0].get_children()[0];
let horizontalSpacing = box.get_theme_node().get_length('spacing');
let allHorizontalSpacing = (this._numOfHorizKeys - 1) * horizontalSpacing;
let keyWidth = Math.floor((this.actor.width - allHorizontalSpacing - 2 * padding) / this._numOfHorizKeys);
let allVerticalSpacing = (this._numOfVertKeys - 1) * verticalSpacing;
let keyHeight = Math.floor((maxHeight - allVerticalSpacing - 2 * padding) / this._numOfVertKeys);
let keySize = Math.min(keyWidth, keyHeight);
this.actor.height = keySize * this._numOfVertKeys + allVerticalSpacing + 2 * padding;
let rows = this._current_page.get_children();
for (let i = 0; i < rows.length; ++i) {
let keyboard_row = rows[i];
let boxes = keyboard_row.get_children();
for (let j = 0; j < boxes.length; ++j) {
let keys = boxes[j].get_children();
for (let k = 0; k < keys.length; ++k) {
let child = keys[k];
child.width = keySize * child.key_width;
child.height = keySize;
child.draggable = this._draggable;
if (child._extended_keys) {
let extended_keys = child._extended_keys.get_children();
for (let n = 0; n < extended_keys.length; ++n) {
let extended_key = extended_keys[n];
extended_key.width = keySize;
extended_key.height = keySize;
extended_key.draggable = this._draggable;
}
}
}
}
}
},
_onLevelChanged: function () {
this._setActiveLayer();
this._redraw();
},
_onGroupChanged: function () {
this._setActiveLayer();
this._redraw();
},
_setActiveLayer: function () {
let active_group_name = this._keyboard.active_group;
let active_group = this._keyboard.get_group(active_group_name);
let active_level = active_group.active_level;
let layers = this._groups[active_group_name];
if (this._current_page != null) {
this._current_page.hide();
}
this._current_page = layers[active_level];
this._current_page.show();
},
createSource: function () {
if (this._source == null) {
this._source = new KeyboardSource(this);
Main.messageTray.add(this._source);
}
},
destroySource: function () {
if (this._source) {
this._source.destroy();
this._source = null;
}
},
show: function () {
this._redraw();
Main.layoutManager.showKeyboard();
},
hide: function () {
Main.layoutManager.hideKeyboard();
},
// Window placement method
_updatePosition: function (x, y) {
let primary = Main.layoutManager.primaryMonitor;
x -= this.actor.width / 2;
// Determines bottom/top centered
if (y <= primary.height / 2)
y += this.actor.height / 2;
else
y -= 3 * this.actor.height / 2;
// Accounting for monitor boundaries
if (x < primary.x)
x = primary.x;
if (x + this.actor.width > primary.width)
x = primary.width - this.actor.width;
this.actor.set_position(x, y);
},
_moveTemporarily: function () {
this._currentWindow = global.screen.get_display().focus_window;
let rect = this._currentWindow.get_outer_rect();
this._currentWindow.x = rect.x;
this._currentWindow.y = rect.y;
let newX = this._currentWindow.x;
let newY = 3 * this.actor.height / 2;
this._currentWindow.move_frame(true, newX, newY);
},
_setLocation: function (x, y) {
if (this._floating)
this._updatePosition(x, y);
else {
if (y >= 2 * this.actor.height)
this._moveTemporarily();
}
},
// D-Bus methods
Show: function() {
this.destroySource();
this.show();
},
Hide: function() {
if (this._currentWindow) {
this._currentWindow.move_frame(true, this._currentWindow.x, this._currentWindow.y);
this._currentWindow = null;
}
this.hide();
this._manageTray();
},
SetCursorLocation: function(x, y, w, h) {
this._setLocation(x, y);
},
SetEntryLocation: function(x, y, w, h) {
this._setLocation(x, y);
},
get Name() {
return 'gnome-shell';
}
};
DBus.conformExport(Keyboard.prototype, CaribouKeyboardIface);
function KeyboardSource() {
this._init.apply(this, arguments);
}
KeyboardSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(keyboard) {
this._keyboard = keyboard;
MessageTray.Source.prototype._init.call(this, _("Keyboard"));
this._setSummaryIcon(this.createNotificationIcon());
},
createNotificationIcon: function() {
return new St.Icon({ icon_name: 'input-keyboard',
icon_type: St.IconType.SYMBOLIC,
icon_size: this.ICON_SIZE });
},
handleSummaryClick: function() {
let event = Clutter.get_current_event();
if (event.type() != Clutter.EventType.BUTTON_RELEASE)
return false;
if (event.get_button() != 1)
return false;
this.open();
return true;
},
open: function() {
this._keyboard.show();
this._keyboard.destroySource();
}
};

View File

@ -1,422 +0,0 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Clutter = imports.gi.Clutter;
const Lang = imports.lang;
const Signals = imports.signals;
const St = imports.gi.St;
const Main = imports.ui.main;
const Meta = imports.gi.Meta;
const Panel = imports.ui.panel;
const Tweener = imports.ui.tweener;
const State = {
HIDDEN: 0,
SHOWING: 1,
SHOWN: 2,
HIDING: 3
};
const HOT_CORNER_ACTIVATION_TIMEOUT = 0.5;
function LayoutManager() {
this._init.apply(this, arguments);
}
LayoutManager.prototype = {
_init: function () {
this._rtl = (St.Widget.get_default_direction() == St.TextDirection.RTL);
this.monitors = [];
this.primaryMonitor = null;
this.primaryIndex = -1;
this._hotCorners = [];
this.bottomBox = new Clutter.Group();
this.topBox = new Clutter.Group({ clip_to_allocation: true });
this.bottomBox.add_actor(this.topBox);
global.screen.connect('monitors-changed', Lang.bind(this, this._monitorsChanged));
this._updateMonitors();
Main.connect('layout-initialized', Lang.bind(this, this._initChrome));
Main.connect('main-ui-initialized', Lang.bind(this, this._finishInit));
},
_initChrome: function() {
Main.chrome.addActor(this.bottomBox, { affectsStruts: false,
visibleInFullscreen: true });
},
// _updateHotCorners needs access to Main.panel
_finishInit: function() {
this._updateHotCorners();
this.topBox.height = Main.messageTray.actor.height;
this.topBox.y = - Main.messageTray.actor.height;
this._keyboardState = Main.keyboard.actor.visible ? State.SHOWN : State.HIDDEN;
this._traySummoned = true;
Main.keyboard.actor.connect('allocation-changed', Lang.bind(this, this._reposition));
},
_reposition: function () {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function () { this._updateForKeyboard(); }));
},
_updateForKeyboard: function () {
if (Tweener.isTweening(this.bottomBox))
return;
this.topBox.y = - Main.messageTray.actor.height;
let bottom = this.bottomMonitor.y + this.bottomMonitor.height;
if (this._keyboardState == State.SHOWN)
this.bottomBox.y = bottom - Main.keyboard.actor.height;
else {
this.bottomBox.y = bottom;
this._keyboardState = State.HIDDEN;
}
},
updateForTray: function () {
if (this._keyboardState == State.SHOWN) {
if (this._traySummoned) {
Main.messageTray.lock();
this._traySummoned = false;
}
else {
Main.messageTray.unlock();
this._traySummoned = true;
}
}
else {
Main.messageTray.unlock();
this._traySummoned = false;
}
},
showKeyboard: function () {
let bottom = this.bottomMonitor.y + this.bottomMonitor.height;
// Keyboard height cannot be found directly since the first
// call to this method may be when Keyboard.Keyboard() has
// not returned; therefore the keyboard would be null
Tweener.addTween(this.bottomBox,
{ y: bottom - Main.keyboard.actor.height,
time: 0.5,
transition: 'easeOutQuad',
});
this._keyboardState = State.SHOWN;
this.updateForTray();
},
hideKeyboard: function () {
let bottom = this.bottomMonitor.y + this.bottomMonitor.height;
Tweener.addTween(this.bottomBox,
{ y: bottom,
time: 0.5,
transition: 'easeOutQuad'
});
this._keyboardState = State.HIDDEN;
this.updateForTray();
},
// This is called by Main after everything else is constructed;
// _updateHotCorners needs access to Main.panel, which didn't exist
// yet when the LayoutManager was constructed.
init: function() {
global.screen.connect('monitors-changed', Lang.bind(this, this._monitorsChanged));
this._updateHotCorners();
},
_updateMonitors: function() {
let screen = global.screen;
this.monitors = [];
let nMonitors = screen.get_n_monitors();
for (let i = 0; i < nMonitors; i++)
this.monitors.push(screen.get_monitor_geometry(i));
if (nMonitors == 1) {
this.primaryIndex = this.bottomIndex = 0;
} else {
// If there are monitors below the primary, then we need
// to split primary from bottom.
this.primaryIndex = this.bottomIndex = screen.get_primary_monitor();
for (let i = 0; i < this.monitors.length; i++) {
let monitor = this.monitors[i];
if (this._isAboveOrBelowPrimary(monitor)) {
if (monitor.y > this.monitors[this.bottomIndex].y)
this.bottomIndex = i;
}
}
}
this.primaryMonitor = this.monitors[this.primaryIndex];
this.bottomMonitor = this.monitors[this.bottomIndex];
this.bottomBox.set_position(0, this.bottomMonitor.y + this.bottomMonitor.height);
this.bottomBox.width = this.bottomMonitor.width;
},
_updateHotCorners: function() {
// destroy old hot corners
for (let i = 0; i < this._hotCorners.length; i++)
this._hotCorners[i].destroy();
this._hotCorners = [];
// build new hot corners
for (let i = 0; i < this.monitors.length; i++) {
if (i == this.primaryIndex)
continue;
let monitor = this.monitors[i];
let cornerX = this._rtl ? monitor.x + monitor.width : monitor.x;
let cornerY = monitor.y;
let haveTopLeftCorner = true;
// Check if we have a top left (right for RTL) corner.
// I.e. if there is no monitor directly above or to the left(right)
let besideX = this._rtl ? monitor.x + 1 : cornerX - 1;
let besideY = cornerY;
let aboveX = cornerX;
let aboveY = cornerY - 1;
for (let j = 0; j < this.monitors.length; j++) {
if (i == j)
continue;
let otherMonitor = this.monitors[j];
if (besideX >= otherMonitor.x &&
besideX < otherMonitor.x + otherMonitor.width &&
besideY >= otherMonitor.y &&
besideY < otherMonitor.y + otherMonitor.height) {
haveTopLeftCorner = false;
break;
}
if (aboveX >= otherMonitor.x &&
aboveX < otherMonitor.x + otherMonitor.width &&
aboveY >= otherMonitor.y &&
aboveY < otherMonitor.y + otherMonitor.height) {
haveTopLeftCorner = false;
break;
}
}
if (!haveTopLeftCorner)
continue;
let corner = new HotCorner();
this._hotCorners.push(corner);
corner.actor.set_position(cornerX, cornerY);
Main.chrome.addActor(corner.actor, { affectsStruts: false });
}
},
_monitorsChanged: function() {
this._updateMonitors();
this._updateHotCorners();
this.emit('monitors-changed');
},
_isAboveOrBelowPrimary: function(monitor) {
let primary = this.monitors[this.primaryIndex];
let monitorLeft = monitor.x, monitorRight = monitor.x + monitor.width;
let primaryLeft = primary.x, primaryRight = primary.x + primary.width;
if ((monitorLeft >= primaryLeft && monitorLeft <= primaryRight) ||
(monitorRight >= primaryLeft && monitorRight <= primaryRight) ||
(primaryLeft >= monitorLeft && primaryLeft <= monitorRight) ||
(primaryRight >= monitorLeft && primaryRight <= monitorRight))
return true;
return false;
},
get focusIndex() {
let screen = global.screen;
let display = screen.get_display();
let focusWindow = display.focus_window;
if (focusWindow) {
let wrect = focusWindow.get_outer_rect();
for (let i = 0; i < this.monitors.length; i++) {
let monitor = this.monitors[i];
if (monitor.x <= wrect.x && monitor.y <= wrect.y &&
monitor.x + monitor.width > wrect.x &&
monitor.y + monitor.height > wrect.y)
return i;
}
}
return this.primaryIndex;
},
get focusMonitor() {
return this.monitors[this.focusIndex];
}
};
Signals.addSignalMethods(LayoutManager.prototype);
// HotCorner:
//
// This class manages a "hot corner" that can toggle switching to
// overview.
function HotCorner() {
this._init();
}
HotCorner.prototype = {
_init : function() {
// We use this flag to mark the case where the user has entered the
// hot corner and has not left both the hot corner and a surrounding
// guard area (the "environs"). This avoids triggering the hot corner
// multiple times due to an accidental jitter.
this._entered = false;
this.actor = new Clutter.Group({ name: 'hot-corner-environs',
width: 3,
height: 3,
reactive: true });
this._corner = new Clutter.Rectangle({ name: 'hot-corner',
width: 1,
height: 1,
opacity: 0,
reactive: true });
this._corner._delegate = this;
this.actor.add_actor(this._corner);
if (St.Widget.get_default_direction() == St.TextDirection.RTL) {
this._corner.set_position(this.actor.width - this._corner.width, 0);
this.actor.set_anchor_point_from_gravity(Clutter.Gravity.NORTH_EAST);
} else {
this._corner.set_position(0, 0);
}
this._activationTime = 0;
this.actor.connect('leave-event',
Lang.bind(this, this._onEnvironsLeft));
// Clicking on the hot corner environs should result in the
// same behavior as clicking on the hot corner.
this.actor.connect('button-release-event',
Lang.bind(this, this._onCornerClicked));
// In addition to being triggered by the mouse enter event,
// the hot corner can be triggered by clicking on it. This is
// useful if the user wants to undo the effect of triggering
// the hot corner once in the hot corner.
this._corner.connect('enter-event',
Lang.bind(this, this._onCornerEntered));
this._corner.connect('button-release-event',
Lang.bind(this, this._onCornerClicked));
this._corner.connect('leave-event',
Lang.bind(this, this._onCornerLeft));
},
destroy: function() {
this.actor.destroy();
},
_addRipple : function(delay, time, startScale, startOpacity, finalScale, finalOpacity) {
// We draw a ripple by using a source image and animating it scaling
// outwards and fading away. We want the ripples to move linearly
// or it looks unrealistic, but if the opacity of the ripple goes
// linearly to zero it fades away too quickly, so we use Tweener's
// 'onUpdate' to give a non-linear curve to the fade-away and make
// it more visible in the middle section.
let [x, y] = this._corner.get_transformed_position();
let ripple = new St.BoxLayout({ style_class: 'ripple-box',
opacity: 255 * Math.sqrt(startOpacity),
scale_x: startScale,
scale_y: startScale,
x: x,
y: y });
ripple._opacity = startOpacity;
if (ripple.get_direction() == St.TextDirection.RTL)
ripple.set_anchor_point_from_gravity(Clutter.Gravity.NORTH_EAST);
Tweener.addTween(ripple, { _opacity: finalOpacity,
scale_x: finalScale,
scale_y: finalScale,
delay: delay,
time: time,
transition: 'linear',
onUpdate: function() { ripple.opacity = 255 * Math.sqrt(ripple._opacity); },
onComplete: function() { ripple.destroy(); } });
Main.uiGroup.add_actor(ripple);
},
rippleAnimation: function() {
// Show three concentric ripples expanding outwards; the exact
// parameters were found by trial and error, so don't look
// for them to make perfect sense mathematically
// delay time scale opacity => scale opacity
this._addRipple(0.0, 0.83, 0.25, 1.0, 1.5, 0.0);
this._addRipple(0.05, 1.0, 0.0, 0.7, 1.25, 0.0);
this._addRipple(0.35, 1.0, 0.0, 0.3, 1, 0.0);
},
handleDragOver: function(source, actor, x, y, time) {
if (source != Main.xdndHandler)
return;
if (!Main.overview.visible && !Main.overview.animationInProgress) {
this.rippleAnimation();
Main.overview.showTemporarily();
Main.overview.beginItemDrag(actor);
}
},
_onCornerEntered : function() {
if (!this._entered) {
this._entered = true;
if (!Main.overview.animationInProgress) {
this._activationTime = Date.now() / 1000;
this.rippleAnimation();
Main.overview.toggle();
}
}
return false;
},
_onCornerClicked : function() {
if (this.shouldToggleOverviewOnClick())
Main.overview.toggle();
return true;
},
_onCornerLeft : function(actor, event) {
if (event.get_related() != this.actor)
this._entered = false;
// Consume event, otherwise this will confuse onEnvironsLeft
return true;
},
_onEnvironsLeft : function(actor, event) {
if (event.get_related() != this._corner)
this._entered = false;
return false;
},
// Checks if the Activities button is currently sensitive to
// clicks. The first call to this function within the
// HOT_CORNER_ACTIVATION_TIMEOUT time of the hot corner being
// triggered will return false. This avoids opening and closing
// the overview if the user both triggered the hot corner and
// clicked the Activities button.
shouldToggleOverviewOnClick: function() {
if (Main.overview.animationInProgress)
return false;
if (this._activationTime == 0 || Date.now() / 1000 - this._activationTime > HOT_CORNER_ACTIVATION_TIMEOUT)
return true;
return false;
}
};

View File

@ -436,7 +436,7 @@ Inspector.prototype = {
if (!this._eventHandler)
return;
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
let [minWidth, minHeight, natWidth, natHeight] =
this._eventHandler.get_preferred_size();
@ -582,53 +582,6 @@ ErrorLog.prototype = {
}
};
function Memory() {
this._init();
}
Memory.prototype = {
_init: function() {
this.actor = new St.BoxLayout({ vertical: true });
this._glibc_uordblks = new St.Label();
this.actor.add(this._glibc_uordblks);
this._js_bytes = new St.Label();
this.actor.add(this._js_bytes);
this._gjs_boxed = new St.Label();
this.actor.add(this._gjs_boxed);
this._gjs_gobject = new St.Label();
this.actor.add(this._gjs_gobject);
this._gjs_function = new St.Label();
this.actor.add(this._gjs_function);
this._gjs_closure = new St.Label();
this.actor.add(this._gjs_closure);
this._gcbutton = new St.Button({ label: 'Full GC',
style_class: 'lg-obj-inspector-button' });
this._gcbutton.connect('clicked', Lang.bind(this, function () { global.gc(); this._renderText(); }));
this.actor.add(this._gcbutton, { x_align: St.Align.START,
x_fill: false });
this.actor.connect('notify::mapped', Lang.bind(this, this._renderText));
},
_renderText: function() {
if (!this.actor.mapped)
return;
let memInfo = global.get_memory_info();
this._glibc_uordblks.text = 'glibc_uordblks: ' + memInfo.glibc_uordblks;
this._js_bytes.text = 'js bytes: ' + memInfo.js_bytes;
this._gjs_boxed.text = 'gjs_boxed: ' + memInfo.gjs_boxed;
this._gjs_gobject.text = 'gjs_gobject: ' + memInfo.gjs_gobject;
this._gjs_function.text = 'gjs_function: ' + memInfo.gjs_function;
this._gjs_closure.text = 'gjs_closure: ' + memInfo.gjs_closure;
}
};
function Extensions() {
this._init();
}
@ -811,9 +764,6 @@ LookingGlass.prototype = {
this._errorLog = new ErrorLog();
notebook.appendPage('Errors', this._errorLog.actor);
this._memory = new Memory();
notebook.appendPage('Memory', this._memory.actor);
this._extensions = new Extensions();
notebook.appendPage('Extensions', this._extensions.actor);
@ -907,7 +857,7 @@ LookingGlass.prototype = {
},
_resizeTo: function(actor) {
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
let myWidth = primary.width * 0.7;
let myHeight = primary.height * 0.7;
let [srcX, srcY] = actor.get_transformed_position();

View File

@ -10,30 +10,26 @@ const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const Signals = imports.signals;
const St = imports.gi.St;
const AutomountManager = imports.ui.automountManager;
const AutorunManager = imports.ui.autorunManager;
const Chrome = imports.ui.chrome;
const CtrlAltTab = imports.ui.ctrlAltTab;
const EndSessionDialog = imports.ui.endSessionDialog;
const PolkitAuthenticationAgent = imports.ui.polkitAuthenticationAgent;
const Environment = imports.ui.environment;
const ExtensionSystem = imports.ui.extensionSystem;
const Keyboard = imports.ui.keyboard;
const MessageTray = imports.ui.messageTray;
const Overview = imports.ui.overview;
const Panel = imports.ui.panel;
const PlaceDisplay = imports.ui.placeDisplay;
const RunDialog = imports.ui.runDialog;
const Layout = imports.ui.layout;
const LookingGlass = imports.ui.lookingGlass;
const NotificationDaemon = imports.ui.notificationDaemon;
const WindowAttentionHandler = imports.ui.windowAttentionHandler;
const Scripting = imports.ui.scripting;
const ShellDBus = imports.ui.shellDBus;
const TelepathyClient = imports.ui.telepathyClient;
const GoaClient = imports.ui.goaClient;
const WindowManager = imports.ui.windowManager;
const Magnifier = imports.ui.magnifier;
const XdndHandler = imports.ui.xdndHandler;
@ -43,38 +39,34 @@ const Util = imports.misc.util;
const DEFAULT_BACKGROUND_COLOR = new Clutter.Color();
DEFAULT_BACKGROUND_COLOR.from_pixel(0x2266bbff);
let automountManager = null;
let autorunManager = null;
let chrome = null;
let panel = null;
let hotCorners = [];
let placesManager = null;
let overview = null;
let runDialog = null;
let lookingGlass = null;
let wm = null;
let messageTray = null;
let notificationDaemon = null;
let windowAttentionHandler = null;
let telepathyClient = null;
let goaClient = null;
let ctrlAltTabManager = null;
let recorder = null;
let shellDBusService = null;
let modalCount = 0;
let modalActorFocusStack = [];
let uiGroup = null;
let magnifier = null;
let xdndHandler = null;
let statusIconDispatcher = null;
let keyboard = null;
let layoutManager = null;
let _runDialog = null;
let lookingGlass = null;
let _recorder = null;
let _modalCount = 0;
let _modalActorFocusStack = [];
let _errorLogStack = [];
let _startDate;
let _defaultCssStylesheet = null;
let _cssStylesheet = null;
const Main = this;
Signals.addSignalMethods(Main)
let background = null;
function start() {
// Monkey patch utility functions into the global proxy;
@ -136,62 +128,47 @@ function start() {
global.overlay_group.reparent(uiGroup);
global.stage.add_actor(uiGroup);
// Initialize JS modules. We do this in several steps, so that
// less-fundamental modules can depend on more-fundamental ones.
// Overall layout management
layoutManager = new Layout.LayoutManager();
chrome = new Chrome.Chrome();
ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager();
Main.emit('layout-initialized');
// Major UI elements; initialize overview first since both panel
// and messageTray connect to its signals
overview = new Overview.Overview();
panel = new Panel.Panel();
messageTray = new MessageTray.MessageTray();
keyboard = new Keyboard.Keyboard();
Main.emit('main-ui-initialized');
// Now the rest of the JS modules (arbitrarily in alphabetical
// order).
keyboard.init();
magnifier = new Magnifier.Magnifier();
notificationDaemon = new NotificationDaemon.NotificationDaemon();
placesManager = new PlaceDisplay.PlacesManager();
statusIconDispatcher = new StatusIconDispatcher.StatusIconDispatcher();
telepathyClient = new TelepathyClient.Client();
windowAttentionHandler = new WindowAttentionHandler.WindowAttentionHandler();
wm = new WindowManager.WindowManager();
xdndHandler = new XdndHandler.XdndHandler();
automountManager = new AutomountManager.AutomountManager();
autorunManager = new AutorunManager.AutorunManager();
ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager();
overview = new Overview.Overview();
chrome = new Chrome.Chrome();
magnifier = new Magnifier.Magnifier();
statusIconDispatcher = new StatusIconDispatcher.StatusIconDispatcher();
panel = new Panel.Panel();
wm = new WindowManager.WindowManager();
messageTray = new MessageTray.MessageTray();
notificationDaemon = new NotificationDaemon.NotificationDaemon();
windowAttentionHandler = new WindowAttentionHandler.WindowAttentionHandler();
telepathyClient = new TelepathyClient.Client();
goaClient = new GoaClient.Client();
Main.emit('initialized');
overview.init();
statusIconDispatcher.start(messageTray.actor);
_startDate = new Date();
let recorderSettings = new Gio.Settings({ schema: 'org.gnome.shell.recorder' });
global.screen.connect('toggle-recording', function() {
if (_recorder == null) {
_recorder = new Shell.Recorder({ stage: global.stage });
if (recorder == null) {
recorder = new Shell.Recorder({ stage: global.stage });
}
if (_recorder.is_recording()) {
_recorder.pause();
if (recorder.is_recording()) {
recorder.pause();
} else {
// read the parameters from GSettings always in case they have changed
_recorder.set_framerate(recorderSettings.get_int('framerate'));
_recorder.set_filename('shell-%d%u-%c.' + recorderSettings.get_string('file-extension'));
recorder.set_framerate(recorderSettings.get_int('framerate'));
recorder.set_filename('shell-%d%u-%c.' + recorderSettings.get_string('file-extension'));
let pipeline = recorderSettings.get_string('pipeline');
if (!pipeline.match(/^\s*$/))
_recorder.set_pipeline(pipeline);
recorder.set_pipeline(pipeline);
else
_recorder.set_pipeline(null);
recorder.set_pipeline(null);
_recorder.record();
recorder.record();
}
});
@ -204,10 +181,14 @@ function start() {
// Attempt to become a PolicyKit authentication agent
PolkitAuthenticationAgent.init()
global.screen.connect('monitors-changed', _relayout);
ExtensionSystem.init();
ExtensionSystem.loadExtensions();
// Initialize the panel status area now that extensions are loaded
// Perform initial relayout here
_relayout();
panel.startStatusArea();
panel.startupAnimation();
@ -230,7 +211,6 @@ function start() {
global.screen.connect('window-entered-monitor', _windowEnteredMonitor);
global.screen.connect('window-left-monitor', _windowLeftMonitor);
global.screen.connect('restacked', _windowsRestacked);
_nWorkspacesChanged();
}
@ -322,24 +302,17 @@ function _windowRemoved(workspace, window) {
function _windowLeftMonitor(metaScreen, monitorIndex, metaWin) {
// If the window left the primary monitor, that
// might make that workspace empty
if (monitorIndex == layoutManager.primaryIndex)
if (monitorIndex == global.get_primary_monitor_index())
_queueCheckWorkspaces();
}
function _windowEnteredMonitor(metaScreen, monitorIndex, metaWin) {
// If the window entered the primary monitor, that
// might make that workspace non-empty
if (monitorIndex == layoutManager.primaryIndex)
if (monitorIndex == global.get_primary_monitor_index())
_queueCheckWorkspaces();
}
function _windowsRestacked() {
// Figure out where the pointer is in case we lost track of
// it during a grab. (In particular, if a trayicon popup menu
// is dismissed, see if we need to close the message tray.)
global.sync_pointer();
}
function _queueCheckWorkspaces() {
if (_checkWorkspacesId == 0)
_checkWorkspacesId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, _checkWorkspaces);
@ -423,21 +396,12 @@ function setThemeStylesheet(cssStylesheet)
*/
function loadTheme() {
let themeContext = St.ThemeContext.get_for_stage (global.stage);
let previousTheme = themeContext.get_theme();
let cssStylesheet = _defaultCssStylesheet;
if (_cssStylesheet != null)
cssStylesheet = _cssStylesheet;
let theme = new St.Theme ({ application_stylesheet: cssStylesheet });
if (previousTheme) {
let customStylesheets = previousTheme.get_custom_stylesheets();
for (let i = 0; i < customStylesheets.length; i++)
theme.load_stylesheet(customStylesheets[i]);
}
themeContext.set_theme (theme);
}
@ -503,16 +467,80 @@ function _getAndClearErrorStack() {
return errors;
}
function logStackTrace(msg) {
try {
throw new Error();
} catch (e) {
// e.stack must have at least two lines, with the first being
// logStackTrace() (which we strip off), and the second being
// our caller.
let trace = e.stack.substr(e.stack.indexOf('\n') + 1);
log(msg ? (msg + '\n' + trace) : trace);
function _relayout() {
let monitors = global.get_monitors();
// destroy old corners
for (let i = 0; i < hotCorners.length; i++)
hotCorners[i].destroy();
hotCorners = [];
let primary = global.get_primary_monitor();
for (let i = 0; i < monitors.length; i++) {
let monitor = monitors[i];
let isPrimary = (monitor.x == primary.x &&
monitor.y == primary.y &&
monitor.width == primary.width &&
monitor.height == primary.height);
let cornerX = monitor.x;
let cornerY = monitor.y;
if (St.Widget.get_default_direction() == St.TextDirection.RTL)
cornerX += monitor.width;
let haveTopLeftCorner = true;
/* Check if we have a top left (right for RTL) corner.
* I.e. if there is no monitor directly above or to the left(right) */
let besideX;
if (St.Widget.get_default_direction() == St.TextDirection.RTL)
besideX = monitor.x + 1;
else
besideX = cornerX - 1;
let besideY = cornerY;
let aboveX = cornerX;
let aboveY = cornerY - 1;
for (let j = 0; j < monitors.length; j++) {
if (i == j)
continue;
let otherMonitor = monitors[j];
if (besideX >= otherMonitor.x &&
besideX < otherMonitor.x + otherMonitor.width &&
besideY >= otherMonitor.y &&
besideY < otherMonitor.y + otherMonitor.height) {
haveTopLeftCorner = false;
break;
}
if (aboveX >= otherMonitor.x &&
aboveX < otherMonitor.x + otherMonitor.width &&
aboveY >= otherMonitor.y &&
aboveY < otherMonitor.y + otherMonitor.height) {
haveTopLeftCorner = false;
break;
}
}
/* We only want hot corners where there is a natural top-left
* corner, and on the primary monitor */
if (!isPrimary && !haveTopLeftCorner)
continue;
let corner = new Panel.HotCorner(isPrimary ? panel.button : null);
hotCorners.push(corner);
corner.actor.set_position(cornerX, cornerY);
if (isPrimary)
panel.setHotCorner(corner);
}
panel.relayout();
overview.relayout();
// To avoid updating the position and size of the workspaces
// in the overview, we just hide the overview. The positions
// will be updated when it is next shown.
overview.hide();
}
function isWindowActorDisplayedOnWorkspace(win, workspaceIndex) {
@ -532,7 +560,7 @@ function getWindowActorsForWorkspace(workspaceIndex) {
// all key events will be delivered to the stage, so ::captured-event
// on the stage can be used for global keybindings.)
function _globalKeyPressHandler(actor, event) {
if (_modalCount == 0)
if (modalCount == 0)
return false;
if (event.type() != Clutter.EventType.KEY_PRESS)
return false;
@ -557,7 +585,7 @@ function _globalKeyPressHandler(actor, event) {
// Other bindings are only available when the overview is up and
// no modal dialog is present.
if (!overview.visible || _modalCount > 1)
if (!overview.visible || modalCount > 1)
return false;
// This isn't a Meta.KeyBindingAction yet
@ -598,8 +626,8 @@ function _globalKeyPressHandler(actor, event) {
}
function _findModal(actor) {
for (let i = 0; i < _modalActorFocusStack.length; i++) {
if (_modalActorFocusStack[i].actor == actor)
for (let i = 0; i < modalActorFocusStack.length; i++) {
if (modalActorFocusStack[i].actor == actor)
return i;
}
return -1;
@ -629,7 +657,7 @@ function pushModal(actor, timestamp) {
if (timestamp == undefined)
timestamp = global.get_current_time();
if (_modalCount == 0) {
if (modalCount == 0) {
if (!global.begin_modal(timestamp)) {
log('pushModal: invocation of begin_modal failed');
return false;
@ -638,11 +666,11 @@ function pushModal(actor, timestamp) {
global.set_stage_input_mode(Shell.StageInputMode.FULLSCREEN);
_modalCount += 1;
modalCount += 1;
let actorDestroyId = actor.connect('destroy', function() {
let index = _findModal(actor);
if (index >= 0)
_modalActorFocusStack.splice(index, 1);
modalActorFocusStack.splice(index, 1);
});
let curFocus = global.stage.get_key_focus();
let curFocusDestroyId;
@ -650,10 +678,10 @@ function pushModal(actor, timestamp) {
curFocusDestroyId = curFocus.connect('destroy', function() {
let index = _findModal(actor);
if (index >= 0)
_modalActorFocusStack[index].actor = null;
modalActorFocusStack[index].actor = null;
});
}
_modalActorFocusStack.push({ actor: actor,
modalActorFocusStack.push({ actor: actor,
focus: curFocus,
destroyId: actorDestroyId,
focusDestroyId: curFocusDestroyId });
@ -688,28 +716,28 @@ function popModal(actor, timestamp) {
throw new Error('incorrect pop');
}
_modalCount -= 1;
modalCount -= 1;
let record = _modalActorFocusStack[focusIndex];
let record = modalActorFocusStack[focusIndex];
record.actor.disconnect(record.destroyId);
if (focusIndex == _modalActorFocusStack.length - 1) {
if (focusIndex == modalActorFocusStack.length - 1) {
if (record.focus)
record.focus.disconnect(record.focusDestroyId);
global.stage.set_key_focus(record.focus);
} else {
let t = _modalActorFocusStack[_modalActorFocusStack.length - 1];
let t = modalActorFocusStack[modalActorFocusStack.length - 1];
if (t.focus)
t.focus.disconnect(t.focusDestroyId);
// Remove from the middle, shift the focus chain up
for (let i = _modalActorFocusStack.length - 1; i > focusIndex; i--) {
_modalActorFocusStack[i].focus = _modalActorFocusStack[i - 1].focus;
_modalActorFocusStack[i].focusDestroyId = _modalActorFocusStack[i - 1].focusDestroyId;
for (let i = modalActorFocusStack.length - 1; i > focusIndex; i--) {
modalActorFocusStack[i].focus = modalActorFocusStack[i - 1].focus;
modalActorFocusStack[i].focusDestroyId = modalActorFocusStack[i - 1].focusDestroyId;
}
}
_modalActorFocusStack.splice(focusIndex, 1);
modalActorFocusStack.splice(focusIndex, 1);
if (_modalCount > 0)
if (modalCount > 0)
return;
global.end_modal(timestamp);
@ -725,10 +753,10 @@ function createLookingGlass() {
}
function getRunDialog() {
if (_runDialog == null) {
_runDialog = new RunDialog.RunDialog();
if (runDialog == null) {
runDialog = new RunDialog.RunDialog();
}
return _runDialog;
return runDialog;
}
/**

View File

@ -557,7 +557,7 @@ Notification.prototype = {
this._scrollArea = new St.ScrollView({ name: 'notification-scrollview',
vscrollbar_policy: this._scrollPolicy,
hscrollbar_policy: Gtk.PolicyType.NEVER,
style_class: 'vfade' });
vfade: true });
this._table.add(this._scrollArea, { row: 1, col: 1 });
this._contentArea = new St.BoxLayout({ name: 'notification-body',
vertical: true });
@ -829,7 +829,6 @@ Notification.prototype = {
// Restore banner opacity in case the notification is shown in the
// banner mode again on update.
this._bannerLabel.opacity = 255;
this.emit('collapsed');
},
_onActionInvoked: function(actor, mouseButtonClicked, id) {
@ -880,96 +879,20 @@ Source.prototype = {
_init: function(title) {
this.title = title;
this.actor = new Shell.GenericContainer();
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this.actor.connect('allocate', Lang.bind(this, this._allocate));
this.actor.connect('destroy', Lang.bind(this,
function() {
this._actorDestroyed = true;
}));
this._actorDestroyed = false;
this._counterLabel = new St.Label();
this._counterBin = new St.Bin({ style_class: 'summary-source-counter',
child: this._counterLabel });
this._counterBin.hide();
this._iconBin = new St.Bin({ width: this.ICON_SIZE,
height: this.ICON_SIZE,
x_fill: true,
y_fill: true });
this.actor.add_actor(this._iconBin);
this.actor.add_actor(this._counterBin);
this.isTransient = false;
this.isChat = false;
this.notifications = [];
},
_getPreferredWidth: function (actor, forHeight, alloc) {
let [min, nat] = this._iconBin.get_preferred_width(forHeight);
alloc.min_size = min; alloc.nat_size = nat;
},
_getPreferredHeight: function (actor, forWidth, alloc) {
let [min, nat] = this._iconBin.get_preferred_height(forWidth);
alloc.min_size = min; alloc.nat_size = nat;
},
_allocate: function(actor, box, flags) {
// the iconBin should fill our entire box
this._iconBin.allocate(box, flags);
let childBox = new Clutter.ActorBox();
let [minWidth, minHeight, naturalWidth, naturalHeight] = this._counterBin.get_preferred_size();
let direction = this.actor.get_direction();
if (direction == St.TextDirection.LTR) {
// allocate on the right in LTR
childBox.x1 = box.x2 - naturalWidth;
childBox.x2 = box.x2;
} else {
// allocate on the left in RTL
childBox.x1 = 0;
childBox.x2 = naturalWidth;
}
childBox.y1 = box.y2 - naturalHeight;
childBox.y2 = box.y2;
this._counterBin.allocate(childBox, flags);
},
_setCount: function(count, visible) {
if (isNaN(parseInt(count)))
throw new Error("Invalid notification count: " + count);
if (this._actorDestroyed)
return;
this._counterBin.visible = visible;
this._counterLabel.set_text(count.toString());
},
_updateCount: function() {
let count = this.notifications.length;
this._setCount(count, count > 1);
},
setTransient: function(isTransient) {
this.isTransient = isTransient;
},
setTitle: function(newTitle) {
this.title = newTitle;
this.emit('title-changed');
},
// Called to create a new icon actor (of size this.ICON_SIZE).
// Must be overridden by the subclass if you do not pass icons
// explicitly to the Notification() constructor.
@ -980,7 +903,7 @@ Source.prototype = {
// Unlike createNotificationIcon, this always returns the same actor;
// there is only one summary icon actor for a Source.
getSummaryIcon: function() {
return this.actor;
return this._iconBin;
},
pushNotification: function(notification) {
@ -999,11 +922,7 @@ Source.prototype = {
this.notifications.splice(index, 1);
if (this.notifications.length == 0)
this._lastNotificationRemoved();
this._updateCount();
}));
this._updateCount();
},
notify: function(notification) {
@ -1040,8 +959,6 @@ Source.prototype = {
for (let i = this.notifications.length - 1; i >= 0; i--)
if (!this.notifications[i].resident)
this.notifications[i].destroy();
this._updateCount();
},
// Default implementation is to destroy this source, but subclasses can override
@ -1078,11 +995,6 @@ SummaryItem.prototype = {
this._sourceTitleBin.child = this._sourceTitle;
this._sourceTitleBin.width = 0;
this.source.connect('title-changed',
Lang.bind(this, function() {
this._sourceTitle.text = source.title;
}));
this._sourceBox.add(this._sourceIcon, { y_fill: false });
this._sourceBox.add(this._sourceTitleBin, { expand: true, y_fill: false });
this.actor.child = this._sourceBox;
@ -1090,7 +1002,7 @@ SummaryItem.prototype = {
this.notificationStackView = new St.ScrollView({ name: source.isChat ? '' : 'summary-notification-stack-scrollview',
vscrollbar_policy: source.isChat ? Gtk.PolicyType.NEVER : Gtk.PolicyType.AUTOMATIC,
hscrollbar_policy: Gtk.PolicyType.NEVER,
style_class: 'vfade' });
vfade: true });
this.notificationStack = new St.BoxLayout({ name: 'summary-notification-stack',
vertical: true });
this.notificationStackView.add_actor(this.notificationStack);
@ -1301,9 +1213,9 @@ MessageTray.prototype = {
this._focusGrabber.connect('focus-grabbed', Lang.bind(this,
function() {
if (this._summaryBoxPointer.bin.child)
this.lock();
this._lock();
}));
this._focusGrabber.connect('focus-ungrabbed', Lang.bind(this, this.unlock));
this._focusGrabber.connect('focus-ungrabbed', Lang.bind(this, this._unlock));
this._focusGrabber.connect('button-pressed', Lang.bind(this,
function(focusGrabber, source) {
if (this._clickedSummaryItem && !this._clickedSummaryItem.actor.contains(source))
@ -1313,7 +1225,7 @@ MessageTray.prototype = {
this._focusGrabber.connect('escape-pressed', Lang.bind(this, this._escapeTray));
this._trayState = State.HIDDEN;
this._locked = 0;
this._locked = false;
this._useLongerTrayLeftTimeout = false;
this._trayLeftTimeoutId = 0;
this._pointerInTray = false;
@ -1329,21 +1241,21 @@ MessageTray.prototype = {
this._notificationRemoved = false;
this._reNotifyAfterHideNotification = null;
Main.layoutManager.topBox.add_actor(this.actor);
Main.chrome.addActor(this.actor, { affectsStruts: false,
visibleInOverview: true });
Main.chrome.trackActor(this._notificationBin);
Main.chrome.trackActor(this._summaryBin);
Main.chrome.trackActor(this._summaryBoxPointer.actor);
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._setSizePosition));
global.screen.connect('monitors-changed', Lang.bind(this, this._setSizePosition));
this._setSizePosition();
Main.overview.connect('showing', Lang.bind(this,
function() {
this._overviewVisible = true;
if (this._locked > 0) {
if (this._locked) {
this._unsetClickedSummaryItem();
this.unlock();
this._unlock();
} else {
this._updateState();
}
@ -1351,9 +1263,9 @@ MessageTray.prototype = {
Main.overview.connect('hiding', Lang.bind(this,
function() {
this._overviewVisible = false;
if (this._locked > 0) {
if (this._locked) {
this._unsetClickedSummaryItem();
this.unlock();
this._unlock();
} else {
this._updateState();
}
@ -1370,25 +1282,29 @@ MessageTray.prototype = {
},
_setSizePosition: function() {
let monitor = Main.layoutManager.bottomMonitor;
this.actor.x = monitor.x;
this.actor.y = -1;
this.actor.width = monitor.width;
let primary = global.get_primary_monitor();
this.actor.x = primary.x;
this.actor.y = primary.y + primary.height - 1;
this.actor.width = primary.width;
this._notificationBin.x = 0;
this._notificationBin.width = monitor.width;
this._notificationBin.width = primary.width;
this._summaryBin.x = 0;
this._summaryBin.width = monitor.width;
this._summaryBin.width = primary.width;
if (this._pointerBarrier)
global.destroy_pointer_barrier(this._pointerBarrier);
this._pointerBarrier =
global.create_pointer_barrier(monitor.x + monitor.width, monitor.y + monitor.height - this.actor.height,
monitor.x + monitor.width, monitor.y + monitor.height,
global.create_pointer_barrier(primary.x + primary.width, primary.y + primary.height - this.actor.height,
primary.x + primary.width, primary.y + primary.height,
4 /* BarrierNegativeX */);
},
getBusy: function(source) {
return this._busy;
},
contains: function(source) {
return this._getIndexOfSummaryItemForSource(source) >= 0;
},
@ -1524,16 +1440,15 @@ MessageTray.prototype = {
this._notificationQueue.splice(index, 1);
},
lock: function() {
this._locked += 1;
this._updateState();
_lock: function() {
this._locked = true;
},
unlock: function() {
if (this._locked > 0)
this._locked -= 1;
this._pointerInSummary = false;
this._pointerInTray = false;
_unlock: function() {
if (!this._locked)
return;
this._locked = false;
this._pointerInTray = this.actor.hover && !this._summaryBoxPointer.bin.hover;
this._updateState();
},
@ -1694,8 +1609,6 @@ MessageTray.prototype = {
this._clickedSummaryItemMouseButton != button) {
this._clickedSummaryItem = summaryItem;
this._clickedSummaryItemMouseButton = button;
summaryItem.source.emit('summary-item-clicked', button);
} else {
this._unsetClickedSummaryItem();
}
@ -1817,7 +1730,7 @@ MessageTray.prototype = {
},
_escapeTray: function() {
this.unlock();
this._unlock();
this._pointerInTray = false;
this._pointerInSummary = false;
this._updateNotificationTimeout(0);
@ -1835,7 +1748,7 @@ MessageTray.prototype = {
let notificationsPending = this._notificationQueue.length > 0 && (!this._busy || notificationUrgent);
let notificationPinned = this._pointerInTray && !this._pointerInSummary && !this._notificationRemoved;
let notificationExpanded = this._notificationBin.y < 0;
let notificationExpired = (this._notificationTimeoutId == 0 && !(this._notification && this._notification.urgency == Urgency.CRITICAL) && !this._pointerInTray && (this._locked == 0)) || this._notificationRemoved;
let notificationExpired = (this._notificationTimeoutId == 0 && !(this._notification && this._notification.urgency == Urgency.CRITICAL) && !this._pointerInTray && !this._locked) || this._notificationRemoved;
let canShowNotification = notificationsPending && this._summaryState == State.HIDDEN;
if (this._notificationState == State.HIDDEN) {
@ -1851,17 +1764,17 @@ MessageTray.prototype = {
}
// Summary
let summarySummoned = this._pointerInSummary || this._overviewVisible || (this._locked > 0);
let summaryPinned = this._summaryTimeoutId != 0 || this._pointerInTray || summarySummoned;
let summarySummoned = this._pointerInSummary || this._overviewVisible;
let summaryPinned = this._summaryTimeoutId != 0 || this._pointerInTray || summarySummoned || this._locked;
let summaryHovered = this._pointerInTray || this._pointerInSummary;
let summaryVisibleWithNoHover = (this._overviewVisible || this._locked > 0) && !summaryHovered;
let summaryVisibleWithNoHover = (this._overviewVisible || this._locked) && !summaryHovered;
let summaryNotificationIsForExpandedSummaryItem = (this._clickedSummaryItem == this._expandedSummaryItem);
let notificationsVisible = (this._notificationState == State.SHOWING ||
this._notificationState == State.SHOWN);
let notificationsDone = !notificationsVisible && !notificationsPending;
let summaryOptionalInOverview = this._overviewVisible && (this._locked == 0) && !summaryHovered;
let summaryOptionalInOverview = this._overviewVisible && !this._locked && !summaryHovered;
let mustHideSummary = (notificationsPending && (notificationUrgent || summaryOptionalInOverview))
|| notificationsVisible;
@ -1945,16 +1858,18 @@ MessageTray.prototype = {
},
_showTray: function() {
let primary = global.get_primary_monitor();
this._tween(this.actor, '_trayState', State.SHOWN,
{ y: 0,
{ y: primary.y + primary.height - this.actor.height,
time: ANIMATION_TIME,
transition: 'easeOutQuad'
});
},
_hideTray: function() {
let primary = global.get_primary_monitor();
this._tween(this.actor, '_trayState', State.HIDDEN,
{ y: Main.layoutManager.topBox.height - 1,
{ y: primary.y + primary.height - 1,
time: ANIMATION_TIME,
transition: 'easeOutQuad'
});
@ -2100,15 +2015,9 @@ MessageTray.prototype = {
this._notification.expand(!autoExpanding);
},
_onNotificationExpanded: function() {
_onNotificationExpanded: function() {
let expandedY = this.actor.height - this._notificationBin.height;
// Don't animate the notification to its new position if it has shrunk:
// there will be a very visible "gap" that breaks the illusion.
if (this._notificationBin.y < expandedY)
this._notificationBin.y = expandedY;
else if (this._notification.y != expandedY)
if (this._notificationBin.y != expandedY)
this._tween(this._notificationBin, '_notificationState', State.SHOWN,
{ y: expandedY,
time: ANIMATION_TIME,
@ -2123,6 +2032,7 @@ MessageTray.prototype = {
},
_showSummary: function(timeout) {
let primary = global.get_primary_monitor();
this._summaryBin.opacity = 0;
this._summaryBin.y = this.actor.height;
this._tween(this._summaryBin, '_summaryState', State.SHOWN,

View File

@ -149,7 +149,7 @@ ModalDialog.prototype = {
},
_fadeOpen: function() {
let monitor = Main.layoutManager.focusMonitor;
let monitor = global.get_focus_monitor();
this._backgroundBin.set_position(monitor.x, monitor.y);
this._backgroundBin.set_size(monitor.width, monitor.height);

View File

@ -97,10 +97,8 @@ NotificationDaemon.prototype = {
this._notifications = {};
this._busProxy = new Bus();
Main.connect('initialized', Lang.bind(this, function() {
Main.statusIconDispatcher.connect('message-icon-added', Lang.bind(this, this._onTrayIconAdded));
Main.statusIconDispatcher.connect('message-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
}));
Main.statusIconDispatcher.connect('message-icon-added', Lang.bind(this, this._onTrayIconAdded));
Main.statusIconDispatcher.connect('message-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
Shell.WindowTracker.get_default().connect('notify::focus-app',
Lang.bind(this, this._onFocusAppChanged));
@ -124,7 +122,7 @@ NotificationDaemon.prototype = {
} else if (hints['image-data']) {
let [width, height, rowStride, hasAlpha,
bitsPerSample, nChannels, data] = hints['image-data'];
return textureCache.load_from_raw(data, hasAlpha,
return textureCache.load_from_raw(data, data.length, hasAlpha,
width, height, rowStride, size);
} else {
let stockIcon;
@ -150,7 +148,7 @@ NotificationDaemon.prototype = {
//
// Either a pid or ndata.notification is needed to retrieve or
// create a source.
_getSource: function(title, pid, ndata, sender) {
_getSource: function(title, pid, ndata) {
if (!pid && !(ndata && ndata.notification))
return null;
@ -167,13 +165,10 @@ NotificationDaemon.prototype = {
// with a transient one from the same sender, so we
// always create a new source object for new transient notifications
// and never add it to this._sources .
if (!isForTransientNotification && this._sources[pid]) {
let source = this._sources[pid];
source.setTitle(title);
return source;
}
if (!isForTransientNotification && this._sources[pid])
return this._sources[pid];
let source = new Source(title, pid, sender);
let source = new Source(title, pid);
source.setTransient(isForTransientNotification);
if (!isForTransientNotification) {
@ -192,11 +187,9 @@ NotificationDaemon.prototype = {
actions, hints, timeout) {
let id;
// Filter out chat, presence, calls and invitation notifications from
// Empathy, since we handle that information from telepathyClient.js
// Filter out chat and presence notifications from Empathy, since we
// handle that information from telepathyClient.js
if (appName == 'Empathy' && (hints['category'] == 'im.received' ||
hints['category'] == 'x-empathy.im.room-invitation' ||
hints['category'] == 'x-empathy.call.incoming' ||
hints['category'] == 'presence.online' ||
hints['category'] == 'presence.offline')) {
// Ignore replacesId since we already sent back a
@ -248,7 +241,7 @@ NotificationDaemon.prototype = {
let sender = DBus.getCurrentMessageContext().sender;
let pid = this._senderToPid[sender];
let source = this._getSource(appName, pid, ndata, sender);
let source = this._getSource(appName, pid, ndata);
if (source) {
this._notifyForSource(source, ndata);
@ -269,7 +262,7 @@ NotificationDaemon.prototype = {
if (!ndata)
return;
source = this._getSource(appName, pid, ndata, sender);
source = this._getSource(appName, pid, ndata);
// We only store sender-pid entries for persistent sources.
// Removing the entries once the source is destroyed
@ -418,7 +411,7 @@ NotificationDaemon.prototype = {
},
_onTrayIconAdded: function(o, icon) {
let source = this._getSource(icon.title || icon.wm_class || _("Unknown"), icon.pid, null, null);
let source = this._getSource(icon.title || icon.wm_class || _("Unknown"), icon.pid, null);
source.setTrayIcon(icon);
},
@ -431,28 +424,18 @@ NotificationDaemon.prototype = {
DBus.conformExport(NotificationDaemon.prototype, NotificationDaemonIface);
function Source(title, pid, sender) {
this._init(title, pid, sender);
function Source(title, pid) {
this._init(title, pid);
}
Source.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(title, pid, sender) {
_init: function(title, pid) {
MessageTray.Source.prototype._init.call(this, title);
this._pid = pid;
if (sender)
// TODO: dbus-glib implementation of watch_name() doesnt return an id to be used for
// unwatch_name() or implement unwatch_name(), however when we move to using GDBus implementation,
// we should save the id here and call unwatch_name() with it in destroy().
// Moving to GDBus is the work in progress: https://bugzilla.gnome.org/show_bug.cgi?id=648651
// and https://bugzilla.gnome.org/show_bug.cgi?id=622921 .
DBus.session.watch_name(sender,
false,
null,
Lang.bind(this, this._onNameVanished));
this._appStateChangedId = 0;
this._setApp();
if (this.app)
this.title = this.app.get_name();
@ -461,14 +444,6 @@ Source.prototype = {
this._trayIcon = null;
},
_onNameVanished: function() {
// Destroy the notification source when its sender is removed from DBus.
// Sender being removed from DBus would normally result in a tray icon being removed,
// so allow the code path that handles the tray icon being removed to handle that case.
if (!this.trayIcon)
this.destroy();
},
processNotification: function(notification, icon) {
if (!this.app)
this._setApp();
@ -521,6 +496,10 @@ Source.prototype = {
if (!this.app)
return;
// We only update the app if this.app is null, so we can't disconnect the old this._appStateChangedId
// even if it were non-zero for some reason.
this._appStateChangedId = this.app.connect('notify::state', Lang.bind(this, this._appStateChanged));
// Only override the icon if we were previously using
// notification-based icons (ie, not a trayicon) or if it was unset before
if (!this._trayIcon) {
@ -545,6 +524,19 @@ Source.prototype = {
this.destroy();
},
_appStateChanged: function() {
// Destroy notification sources when their apps exit.
// The app exiting would normally result in a tray icon being removed,
// so the associated source would be destroyed through the code path
// that handles the tray icon being removed. We should not destroy
// the source associated with a tray icon when the application state
// is Shell.AppState.STOPPED because running applications that have
// no open windows would also have that state. This is often the case
// for applications that use tray icons.
if (!this._trayIcon && this.app.get_state() == Shell.AppState.STOPPED)
this.destroy();
},
openApp: function() {
if (this.app == null)
return;
@ -557,6 +549,10 @@ Source.prototype = {
},
destroy: function() {
if (this.app && this._appStateChangedId) {
this.app.disconnect(this._appStateChangedId);
this._appStateChangedId = 0;
}
MessageTray.Source.prototype.destroy.call(this);
}
};

View File

@ -121,7 +121,7 @@ Overview.prototype = {
let spacing = node.get_length('spacing');
if (spacing != this._spacing) {
this._spacing = spacing;
this._relayout();
this.relayout();
}
}));
@ -153,18 +153,6 @@ Overview.prototype = {
this._coverPane.hide();
this._windowSwitchTimeoutId = 0;
this._windowSwitchTimestamp = 0;
this._lastActiveWorkspaceIndex = -1;
this._lastHoveredWindow = null;
this._needsFakePointerEvent = false;
this.workspaces = null;
Main.connect('initialized', Lang.bind(this, this._finishInit));
},
_finishInit: function() {
// XDND
this._dragMonitor = {
dragMotion: Lang.bind(this, this._onDragMotion)
@ -173,11 +161,22 @@ Overview.prototype = {
Main.xdndHandler.connect('drag-begin', Lang.bind(this, this._onDragBegin));
Main.xdndHandler.connect('drag-end', Lang.bind(this, this._onDragEnd));
this._windowSwitchTimeoutId = 0;
this._windowSwitchTimestamp = 0;
this._lastActiveWorkspaceIndex = -1;
this._lastHoveredWindow = null;
this._needsFakePointerEvent = false;
this.workspaces = null;
},
// The members we construct that are implemented in JS might
// want to access the overview as Main.overview to connect
// signal handlers and so forth. So we create them after
// construction in this init() method.
init: function() {
this.shellInfo = new ShellInfo();
// The members we construct that are implemented in JS might
// want to access the overview as Main.overview to connect
// signal handlers and so forth. So we create them here.
this.viewSelector = new ViewSelector.ViewSelector();
this._group.add_actor(this.viewSelector.actor);
@ -203,8 +202,6 @@ Overview.prototype = {
// the left of the overview
Main.ctrlAltTabManager.addGroup(this.dash.actor, _("Dash"), 'user-bookmarks');
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._relayout));
this._relayout();
},
_onDragBegin: function() {
@ -223,7 +220,7 @@ Overview.prototype = {
}
this._resetWindowSwitchTimeout();
this._lastHoveredWindow = null;
DND.removeDragMonitor(this._dragMonitor);
DND.removeMonitor(this._dragMonitor);
this.endItemDrag();
},
@ -284,8 +281,7 @@ Overview.prototype = {
},
_onButtonPress: function(actor, event) {
if (this._scrollDirection == SwipeScrollDirection.NONE
|| event.get_button() != 1)
if (this._scrollDirection == SwipeScrollDirection.NONE)
return;
let [stageX, stageY] = event.get_coords();
@ -394,7 +390,7 @@ Overview.prototype = {
[stageX, stageY] = event.get_coords();
let dx = this._dragX - stageX;
let dy = this._dragY - stageY;
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
this._dragX = stageX;
this._dragY = stageY;
@ -441,25 +437,23 @@ Overview.prototype = {
return clone;
},
_relayout: function () {
// To avoid updating the position and size of the workspaces
// we just hide the overview. The positions will be updated
// when it is next shown.
this.hide();
let primary = Main.layoutManager.primaryMonitor;
relayout: function () {
let primary = global.get_primary_monitor();
let rtl = (St.Widget.get_default_direction () == St.TextDirection.RTL);
let contentY = Main.panel.actor.height;
let contentHeight = primary.height - contentY - Main.messageTray.actor.height;
this._group.set_position(primary.x, primary.y);
this._group.set_size(primary.width, primary.height);
this._coverPane.set_position(primary.x, primary.y);
this._coverPane.set_size(primary.width, primary.height);
this._coverPane.set_position(0, contentY);
this._coverPane.set_size(primary.width, contentHeight);
let dashWidth = Math.round(DASH_SPLIT_FRACTION * primary.width);
let viewWidth = primary.width - dashWidth - this._spacing;
let viewHeight = primary.height - 2 * this._spacing;
let viewY = primary.y + this._spacing;
let viewHeight = contentHeight - 2 * this._spacing;
let viewY = contentY + this._spacing;
let viewX = rtl ? 0 : dashWidth + this._spacing;
// Set the dash's x position - y is handled by a constraint

View File

@ -12,7 +12,6 @@ const Signals = imports.signals;
const Config = imports.misc.config;
const CtrlAltTab = imports.ui.ctrlAltTab;
const Layout = imports.ui.layout;
const Overview = imports.ui.overview;
const PopupMenu = imports.ui.popupMenu;
const PanelMenu = imports.ui.panelMenu;
@ -25,6 +24,8 @@ const PANEL_ICON_SIZE = 24;
const STARTUP_ANIMATION_TIME = 0.2;
const HOT_CORNER_ACTIVATION_TIMEOUT = 0.5;
const BUTTON_DND_ACTIVATION_TIMEOUT = 250;
const ANIMATED_ICON_UPDATE_TIMEOUT = 100;
@ -301,7 +302,6 @@ AppMenuButton.prototype = {
this._visible = true;
this.actor.show();
this.actor.reactive = true;
if (!this._targetIsCurrent)
return;
@ -318,7 +318,6 @@ AppMenuButton.prototype = {
return;
this._visible = false;
this.actor.reactive = false;
if (!this._targetIsCurrent) {
this.actor.hide();
return;
@ -543,163 +542,13 @@ AppMenuButton.prototype = {
Signals.addSignalMethods(AppMenuButton.prototype);
// Activities button. Because everything else in the top bar is a
// PanelMenu.Button, it simplifies some things to make this be one too.
// We just hack it up to not actually have a menu attached to it.
function ActivitiesButton() {
this._init.apply(this, arguments);
}
ActivitiesButton.prototype = {
__proto__: PanelMenu.Button.prototype,
_init: function() {
PanelMenu.Button.prototype._init.call(this, 0.0);
let container = new Shell.GenericContainer();
container.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
container.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
container.connect('allocate', Lang.bind(this, this._allocate));
this.actor.child = container;
this.actor.name = 'panelActivities';
/* Translators: If there is no suitable word for "Activities"
in your language, you can use the word for "Overview". */
this._label = new St.Label({ text: _("Activities") });
container.add_actor(this._label);
this._hotCorner = new Layout.HotCorner();
container.add_actor(this._hotCorner.actor);
// Hack up our menu...
this.menu.open = Lang.bind(this, this._onMenuOpenRequest);
this.menu.close = Lang.bind(this, this._onMenuCloseRequest);
this.menu.toggle = Lang.bind(this, this._onMenuToggleRequest);
this.actor.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
this.actor.connect_after('button-release-event', Lang.bind(this, this._onButtonRelease));
this.actor.connect_after('key-release-event', Lang.bind(this, this._onKeyRelease));
Main.overview.connect('showing', Lang.bind(this, function() {
this.actor.add_style_pseudo_class('overview');
this._escapeMenuGrab();
}));
Main.overview.connect('hiding', Lang.bind(this, function() {
this.actor.remove_style_pseudo_class('overview');
this._escapeMenuGrab();
}));
this._xdndTimeOut = 0;
},
_getPreferredWidth: function(actor, forHeight, alloc) {
[alloc.min_size, alloc.natural_size] = this._label.get_preferred_width(forHeight);
},
_getPreferredHeight: function(actor, forWidth, alloc) {
[alloc.min_size, alloc.natural_size] = this._label.get_preferred_height(forWidth);
},
_allocate: function(actor, box, flags) {
this._label.allocate(box, flags);
// The hot corner needs to be outside any padding/alignment
// that has been imposed on us
let primary = Main.layoutManager.primaryMonitor;
let hotBox = new Clutter.ActorBox();
let ok, x, y;
if (actor.get_direction() == St.TextDirection.LTR) {
[ok, x, y] = actor.transform_stage_point(primary.x, primary.y)
} else {
[ok, x, y] = actor.transform_stage_point(primary.x + primary.width, primary.y);
// hotCorner.actor has northeast gravity, so we don't need
// to adjust x for its width
}
hotBox.x1 = Math.round(x);
hotBox.x2 = hotBox.x1 + this._hotCorner.actor.width;
hotBox.y1 = Math.round(y);
hotBox.y2 = hotBox.y1 + this._hotCorner.actor.height;
this._hotCorner.actor.allocate(hotBox, flags);
},
handleDragOver: function(source, actor, x, y, time) {
if (source != Main.xdndHandler)
return;
if (this._xdndTimeOut != 0)
Mainloop.source_remove(this._xdndTimeOut);
this._xdndTimeOut = Mainloop.timeout_add(BUTTON_DND_ACTIVATION_TIMEOUT,
Lang.bind(this, this._xdndShowOverview, actor));
},
_escapeMenuGrab: function() {
if (this.menu.isOpen)
this.menu.close();
},
_onCapturedEvent: function(actor, event) {
if (event.type() == Clutter.EventType.BUTTON_PRESS) {
if (!this._hotCorner.shouldToggleOverviewOnClick())
return true;
}
return false;
},
_onMenuOpenRequest: function() {
this.menu.isOpen = true;
this.menu.emit('open-state-changed', true);
},
_onMenuCloseRequest: function() {
this.menu.isOpen = false;
this.menu.emit('open-state-changed', false);
},
_onMenuToggleRequest: function() {
this.menu.isOpen = !this.menu.isOpen;
this.menu.emit('open-state-changed', this.menu.isOpen);
},
_onButtonRelease: function() {
if (this.menu.isOpen) {
this.menu.close();
Main.overview.toggle();
}
},
_onKeyRelease: function(actor, event) {
let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Return || symbol == Clutter.KEY_space) {
if (this.menu.isOpen)
this.menu.close();
Main.overview.toggle();
}
},
_xdndShowOverview: function(actor) {
let [x, y, mask] = global.get_pointer();
let pickedActor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, x, y);
if (pickedActor == this.actor) {
if (!Main.overview.visible && !Main.overview.animationInProgress) {
Main.overview.showTemporarily();
Main.overview.beginItemDrag(actor);
}
}
Mainloop.source_remove(this._xdndTimeOut);
this._xdndTimeOut = 0;
}
};
function PanelCorner(panel, side) {
this._init(panel, side);
function PanelCorner(side) {
this._init(side);
}
PanelCorner.prototype = {
_init: function(panel, side) {
this._panel = panel;
_init: function(side) {
this._side = side;
this.actor = new St.DrawingArea({ style_class: 'panel-corner' });
this.actor.connect('repaint', Lang.bind(this, this._repaint));
@ -775,14 +624,185 @@ PanelCorner.prototype = {
this.actor.set_size(cornerRadius,
innerBorderWidth + cornerRadius);
if (this._side == St.Side.LEFT)
this.actor.set_position(this._panel.actor.x,
this._panel.actor.y + this._panel.actor.height - innerBorderWidth);
this.actor.set_position(Main.panel.actor.x,
Main.panel.actor.y + Main.panel.actor.height - innerBorderWidth);
else
this.actor.set_position(this._panel.actor.x + this._panel.actor.width - cornerRadius,
this._panel.actor.y + this._panel.actor.height - innerBorderWidth);
this.actor.set_position(Main.panel.actor.x + Main.panel.actor.width - cornerRadius,
Main.panel.actor.y + Main.panel.actor.height - innerBorderWidth);
}
};
/**
* HotCorner:
*
* This class manages the "hot corner" that can toggle switching to
* overview.
*/
function HotCorner(button) {
this._init(button);
}
HotCorner.prototype = {
_init : function(button) {
// This is the activities button associated with this hot corner,
// if this is on the primary monitor (or null with the corner is
// on a different monitor)
this._button = button;
// We use this flag to mark the case where the user has entered the
// hot corner and has not left both the hot corner and a surrounding
// guard area (the "environs"). This avoids triggering the hot corner
// multiple times due to an accidental jitter.
this._entered = false;
this.actor = new Clutter.Group({ width: 3,
height: 3,
reactive: true });
this._corner = new Clutter.Rectangle({ width: 1,
height: 1,
opacity: 0,
reactive: true });
this.actor.add_actor(this._corner);
if (St.Widget.get_default_direction() == St.TextDirection.RTL) {
this._corner.set_position(this.actor.width - this._corner.width, 0);
this.actor.set_anchor_point_from_gravity(Clutter.Gravity.NORTH_EAST);
} else {
this._corner.set_position(0, 0);
}
this._activationTime = 0;
this.actor.connect('enter-event',
Lang.bind(this, this._onEnvironsEntered));
this.actor.connect('leave-event',
Lang.bind(this, this._onEnvironsLeft));
// Clicking on the hot corner environs should result in the same bahavior
// as clicking on the hot corner.
this.actor.connect('button-release-event',
Lang.bind(this, this._onCornerClicked));
// In addition to being triggered by the mouse enter event, the hot corner
// can be triggered by clicking on it. This is useful if the user wants to
// undo the effect of triggering the hot corner once in the hot corner.
this._corner.connect('enter-event',
Lang.bind(this, this._onCornerEntered));
this._corner.connect('button-release-event',
Lang.bind(this, this._onCornerClicked));
this._corner.connect('leave-event',
Lang.bind(this, this._onCornerLeft));
this._corner._delegate = this._corner;
this._corner.handleDragOver = Lang.bind(this,
function(source, actor, x, y, time) {
if (source == Main.xdndHandler) {
if(!Main.overview.visible && !Main.overview.animationInProgress) {
this.rippleAnimation();
Main.overview.showTemporarily();
Main.overview.beginItemDrag(actor);
}
}
});
Main.chrome.addActor(this.actor, { visibleInOverview: true, affectsStruts: false });
},
destroy: function() {
this.actor.destroy();
},
_addRipple : function(delay, time, startScale, startOpacity, finalScale, finalOpacity) {
// We draw a ripple by using a source image and animating it scaling
// outwards and fading away. We want the ripples to move linearly
// or it looks unrealistic, but if the opacity of the ripple goes
// linearly to zero it fades away too quickly, so we use Tweener's
// 'onUpdate' to give a non-linear curve to the fade-away and make
// it more visible in the middle section.
let [x, y] = this._corner.get_transformed_position();
let ripple = new St.BoxLayout({ style_class: 'ripple-box',
opacity: 255 * Math.sqrt(startOpacity),
scale_x: startScale,
scale_y: startScale,
x: x,
y: y });
ripple._opacity = startOpacity;
if (ripple.get_direction() == St.TextDirection.RTL)
ripple.set_anchor_point_from_gravity(Clutter.Gravity.NORTH_EAST);
Tweener.addTween(ripple, { _opacity: finalOpacity,
scale_x: finalScale,
scale_y: finalScale,
delay: delay,
time: time,
transition: 'linear',
onUpdate: function() { ripple.opacity = 255 * Math.sqrt(ripple._opacity); },
onComplete: function() { ripple.destroy(); } });
Main.uiGroup.add_actor(ripple);
},
rippleAnimation: function() {
// Show three concentric ripples expanding outwards; the exact
// parameters were found by trial and error, so don't look
// for them to make perfect sense mathematically
// delay time scale opacity => scale opacity
this._addRipple(0.0, 0.83, 0.25, 1.0, 1.5, 0.0);
this._addRipple(0.05, 1.0, 0.0, 0.7, 1.25, 0.0);
this._addRipple(0.35, 1.0, 0.0, 0.3, 1, 0.0);
},
_onEnvironsEntered : function() {
if (this._button)
this._button.hover = true;
},
_onCornerEntered : function() {
if (!this._entered) {
this._entered = true;
if (!Main.overview.animationInProgress) {
this._activationTime = Date.now() / 1000;
this.rippleAnimation();
Main.overview.toggle();
}
}
return false;
},
_onCornerClicked : function() {
if (!Main.overview.animationInProgress)
this.maybeToggleOverviewOnClick();
return false;
},
_onCornerLeft : function(actor, event) {
if (event.get_related() != this.actor)
this._entered = false;
// Consume event, otherwise this will confuse onEnvironsLeft
return true;
},
_onEnvironsLeft : function(actor, event) {
if (this._button)
this._button.hover = false;
if (event.get_related() != this._corner)
this._entered = false;
return false;
},
// Toggles the overview unless this is the first click on the Activities button within the HOT_CORNER_ACTIVATION_TIMEOUT time
// of the hot corner being triggered. This check avoids opening and closing the overview if the user both triggered the hot corner
// and clicked the Activities button.
maybeToggleOverviewOnClick: function() {
if (this._activationTime == 0 || Date.now() / 1000 - this._activationTime > HOT_CORNER_ACTIVATION_TIMEOUT)
Main.overview.toggle();
this._activationTime = 0;
}
}
function Panel() {
this._init();
@ -812,8 +832,8 @@ Panel.prototype = {
this._centerBox = new St.BoxLayout({ name: 'panelCenter' });
this._rightBox = new St.BoxLayout({ name: 'panelRight' });
this._leftCorner = new PanelCorner(this, St.Side.LEFT);
this._rightCorner = new PanelCorner(this, St.Side.RIGHT);
this._leftCorner = new PanelCorner(St.Side.LEFT);
this._rightCorner = new PanelCorner(St.Side.RIGHT);
/* This box container ensures that the centerBox is positioned in the *absolute*
* center, but can be pushed aside if necessary. */
@ -887,16 +907,32 @@ Panel.prototype = {
}));
/* Button on the left side of the panel. */
this._activitiesButton = new ActivitiesButton();
this._activities = this._activitiesButton.actor;
this._leftBox.add(this._activities);
/* Translators: If there is no suitable word for "Activities" in your language, you can use the word for "Overview". */
let label = new St.Label({ text: _("Activities") });
this.button = new St.Button({ name: 'panelActivities',
style_class: 'panel-button',
reactive: true,
can_focus: true });
this._activities = this.button;
this.button.set_child(label);
this.button._delegate = this.button;
this.button._xdndTimeOut = 0;
this.button.handleDragOver = Lang.bind(this,
function(source, actor, x, y, time) {
if (source == Main.xdndHandler) {
if (this.button._xdndTimeOut != 0)
Mainloop.source_remove(this.button._xdndTimeOut);
this.button._xdndTimeOut = Mainloop.timeout_add(BUTTON_DND_ACTIVATION_TIMEOUT,
Lang.bind(this,
function() {
this._xdndShowOverview(actor);
}));
}
});
this._leftBox.add(this.button);
// The activities button has a pretend menu, so as to integrate
// more cleanly with the rest of the panel
this._menus.addMenu(this._activitiesButton.menu);
// Synchronize the button's pseudo classes with its corner
this._activities.connect('style-changed', Lang.bind(this,
// Synchronize the buttons pseudo classes with its corner
this.button.connect('style-changed', Lang.bind(this,
function(actor) {
let rtl = actor.get_direction() == St.TextDirection.RTL;
let corner = rtl ? this._rightCorner : this._leftCorner;
@ -904,6 +940,8 @@ Panel.prototype = {
corner.actor.set_style_pseudo_class(pseudoClass);
}));
this._hotCorner = null;
this._appMenu = new AppMenuButton();
this._leftBox.add(this._appMenu.actor);
@ -939,17 +977,68 @@ Panel.prototype = {
corner.actor.set_style_pseudo_class(pseudoClass);
}));
Main.chrome.addActor(this.actor);
Main.chrome.addActor(this._leftCorner.actor, { affectsStruts: false,
affectsInputRegion: false });
Main.chrome.addActor(this._rightCorner.actor, { affectsStruts: false,
affectsInputRegion: false });
Main.statusIconDispatcher.connect('status-icon-added', Lang.bind(this, this._onTrayIconAdded));
Main.statusIconDispatcher.connect('status-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
// TODO: decide what to do with the rest of the panel in the Overview mode (make it fade-out, become non-reactive, etc.)
// We get into the Overview mode on button-press-event as opposed to button-release-event because eventually we'll probably
// have the Overview act like a menu that allows the user to release the mouse on the activity the user wants
// to switch to.
this.button.connect('clicked', Lang.bind(this, function(b) {
if (!Main.overview.animationInProgress) {
this._hotCorner.maybeToggleOverviewOnClick();
return true;
} else {
return false;
}
}));
// In addition to pressing the button, the Overview can be entered and exited by other means, such as
// pressing the System key, Alt+F1 or Esc. We want the button to be pressed in when the Overview is entered
// and to be released when it is exited regardless of how it was triggered.
Main.overview.connect('showing', Lang.bind(this, function() {
this.button.checked = true;
}));
Main.overview.connect('hiding', Lang.bind(this, function() {
this.button.checked = false;
}));
Main.chrome.addActor(this.actor, { visibleInOverview: true });
Main.chrome.addActor(this._leftCorner.actor, { visibleInOverview: true,
affectsStruts: false,
affectsInputRegion: false });
Main.chrome.addActor(this._rightCorner.actor, { visibleInOverview: true,
affectsStruts: false,
affectsInputRegion: false });
Main.ctrlAltTabManager.addGroup(this.actor, _("Top Bar"), 'start-here',
{ sortGroup: CtrlAltTab.SortGroup.TOP });
},
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._relayout));
this._relayout();
_xdndShowOverview: function (actor) {
let [x, y, mask] = global.get_pointer();
let pickedActor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, x, y);
if (pickedActor != this.button) {
Mainloop.source_remove(this.button._xdndTimeOut);
this.button._xdndTimeOut = 0;
return;
}
if(!Main.overview.visible && !Main.overview.animationInProgress) {
Main.overview.showTemporarily();
Main.overview.beginItemDrag(actor);
}
Mainloop.source_remove(this.button._xdndTimeOut);
this.button._xdndTimeOut = 0;
},
// While there can be multiple hotcorners (one per monitor), the hot corner
// that is on top of the Activities button is special since it needs special
// coordination with clicking on that button
setHotCorner: function(corner) {
this._hotCorner = corner;
},
startStatusArea: function() {
@ -967,11 +1056,8 @@ Panel.prototype = {
this._statusArea[role] = indicator;
}
Main.statusIconDispatcher.connect('status-icon-added', Lang.bind(this, this._onTrayIconAdded));
Main.statusIconDispatcher.connect('status-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
// PopupMenuManager depends on menus being added in order for
// keyboard navigation, so we couldn't add this before
// keyboard navigation
this._menus.addMenu(this._userMenu.menu);
},
@ -999,8 +1085,8 @@ Panel.prototype = {
});
},
_relayout: function() {
let primary = Main.layoutManager.primaryMonitor;
relayout: function() {
let primary = global.get_primary_monitor();
this.actor.set_position(primary.x, primary.y);
this.actor.set_size(primary.width, -1);

View File

@ -26,7 +26,8 @@ Button.prototype = {
this.menu = new PopupMenu.PopupMenu(this.actor, menuAlignment, St.Side.TOP, 0);
this.menu.connect('open-state-changed', Lang.bind(this, this._onOpenStateChanged));
this.menu.actor.connect('key-press-event', Lang.bind(this, this._onMenuKeyPress));
Main.chrome.addActor(this.menu.actor, { affectsStruts: false });
Main.chrome.addActor(this.menu.actor, { visibleInOverview: true,
affectsStruts: false });
this.menu.actor.hide();
},
@ -35,7 +36,7 @@ Button.prototype = {
// Setting the max-height won't do any good if the minimum height of the
// menu is higher then the screen; it's useful if part of the menu is
// scrollable so the minimum height is smaller than the natural height
let monitor = Main.layoutManager.primaryMonitor;
let monitor = global.get_primary_monitor();
this.menu.actor.style = ('max-height: ' +
Math.round(monitor.height - Main.panel.actor.height) +
'px;');

View File

@ -268,7 +268,10 @@ PlacesManager.prototype = {
if (!GLib.file_test(this._bookmarksPath, GLib.FileTest.EXISTS))
return;
let bookmarksContent = Shell.get_file_contents_utf8_sync(this._bookmarksPath);
let [success, bookmarksContent, len] = GLib.file_get_contents(this._bookmarksPath);
if (!success)
return;
let bookmarks = bookmarksContent.split('\n');

View File

@ -704,35 +704,11 @@ PopupSwitchMenuItem.prototype = {
this._switch = new Switch(active);
this.addActor(this.label);
this.addActor(this._switch.actor, { align: St.Align.END });
this._statusBin = new St.Bin({ x_align: St.Align.END });
this.addActor(this._statusBin, { align: St.Align.END });
this._statusLabel = new St.Label({ text: '',
style_class: 'popup-inactive-menu-item'
});
this._statusBin.child = this._switch.actor;
},
setStatus: function(text) {
if (text != null) {
this._statusLabel.text = text;
this._statusBin.child = this._statusLabel;
this.actor.reactive = false;
this.actor.can_focus = false;
} else {
this._statusBin.child = this._switch.actor;
this.actor.reactive = true;
this.actor.can_focus = true;
}
},
activate: function(event) {
if (this._switch.actor.mapped) {
this.connect('activate', Lang.bind(this,function(from) {
this.toggle();
}
PopupBaseMenuItem.prototype.activate.call(this, event);
}));
},
toggle: function() {
@ -946,14 +922,6 @@ PopupMenuBase.prototype = {
});
},
get firstMenuItem() {
let items = this._getMenuItems();
if (items.length)
return items[0];
else
return null;
},
removeAll: function() {
let children = this._getMenuItems();
for (let i = 0; i < children.length; i++) {

View File

@ -23,10 +23,6 @@ const HISTORY_KEY = 'command-history';
const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
const DISABLE_COMMAND_LINE_KEY = 'disable-command-line';
const TERMINAL_SCHEMA = 'org.gnome.desktop.default-applications.terminal';
const EXEC_KEY = 'exec';
const EXEC_ARG_KEY = 'exec-arg';
const DIALOG_GROW_TIME = 0.1;
function CommandCompleter() {
@ -173,7 +169,6 @@ __proto__: ModalDialog.ModalDialog.prototype,
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'run-dialog' });
this._lockdownSettings = new Gio.Settings({ schema: LOCKDOWN_SCHEMA });
this._terminalSettings = new Gio.Settings({ schema: TERMINAL_SCHEMA });
global.settings.connect('changed::development-tools', Lang.bind(this, function () {
this._enableInternalCommands = global.settings.get_boolean('development-tools');
}));
@ -194,7 +189,7 @@ __proto__: ModalDialog.ModalDialog.prototype,
}),
'debugexit': Lang.bind(this, function() {
Meta.quit(Meta.ExitCode.ERROR);
Meta.exit(Meta.ExitCode.ERROR);
}),
// rt is short for "reload theme"
@ -314,11 +309,8 @@ __proto__: ModalDialog.ModalDialog.prototype,
f();
} else if (input) {
try {
if (inTerminal) {
let exec = this._terminalSettings.get_string(EXEC_KEY);
let exec_arg = this._terminalSettings.get_string(EXEC_ARG_KEY);
command = exec + ' ' + exec_arg + ' ' + input;
}
if (inTerminal)
command = 'gnome-terminal -x ' + input;
Util.trySpawnCommandLine(command);
} catch (e) {
// Mmmh, that failed - see if @input matches an existing file
@ -333,46 +325,33 @@ __proto__: ModalDialog.ModalDialog.prototype,
if (GLib.file_test(path, GLib.FileTest.EXISTS)) {
let file = Gio.file_new_for_path(path);
try {
Gio.app_info_launch_default_for_uri(file.get_uri(),
global.create_app_launch_context());
} catch (e) {
// The exception from gjs contains an error string like:
// Error invoking Gio.app_info_launch_default_for_uri: No application
// is registered as handling this file
// We are only interested in the part after the first colon.
let message = e.message.replace(/[^:]*: *(.+)/, '$1');
this._showError(message);
}
Gio.app_info_launch_default_for_uri(file.get_uri(),
global.create_app_launch_context());
} else {
this._showError(e.message);
this._commandError = true;
this._errorMessage.set_text(e.message);
if (!this._errorBox.visible) {
let [errorBoxMinHeight, errorBoxNaturalHeight] = this._errorBox.get_preferred_height(-1);
let parentActor = this._errorBox.get_parent();
Tweener.addTween(parentActor,
{ height: parentActor.height + errorBoxNaturalHeight,
time: DIALOG_GROW_TIME,
transition: 'easeOutQuad',
onComplete: Lang.bind(this,
function() {
parentActor.set_height(-1);
this._errorBox.show();
})
});
}
}
}
}
},
_showError : function(message) {
this._commandError = true;
this._errorMessage.set_text(message);
if (!this._errorBox.visible) {
let [errorBoxMinHeight, errorBoxNaturalHeight] = this._errorBox.get_preferred_height(-1);
let parentActor = this._errorBox.get_parent();
Tweener.addTween(parentActor,
{ height: parentActor.height + errorBoxNaturalHeight,
time: DIALOG_GROW_TIME,
transition: 'easeOutQuad',
onComplete: Lang.bind(this,
function() {
parentActor.set_height(-1);
this._errorBox.show();
})
});
}
},
open: function() {
this._history.lastItem();
this._errorBox.hide();

View File

@ -3,11 +3,10 @@
const DBus = imports.dbus;
const Gio = imports.gi.Gio;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const Main = imports.ui.main;
// This module provides functionality for driving the shell user interface
// in an automated fashion. The primary current use case for this is
// automated performance testing (see runPerfScript()), but it could
@ -247,14 +246,18 @@ function _collect(scriptModule, outputFile) {
Shell.write_string_to_stream(out, '"events":\n');
Shell.PerfLog.get_default().dump_events(out);
let monitors = Main.layoutManager.monitors;
let primary = Main.layoutManager.primaryIndex;
let monitors = global.get_monitors();
let primary = global.get_primary_monitor();
Shell.write_string_to_stream(out, ',\n"monitors":\n[');
for (let i = 0; i < monitors.length; i++) {
let monitor = monitors[i];
let is_primary = (monitor.x == primary.x &&
monitor.y == primary.y &&
monitor.width == primary.width &&
monitor.height == primary.height);
if (i != 0)
Shell.write_string_to_stream(out, ', ');
Shell.write_string_to_stream(out, '"%s%dx%d+%d+%d"'.format(i == primary ? "*" : "",
Shell.write_string_to_stream(out, '"%s%dx%d+%d+%d"'.format(is_primary ? "*" : "",
monitor.width, monitor.height,
monitor.x, monitor.y));
}

View File

@ -157,7 +157,7 @@ SearchProvider.prototype = {
},
/**
* getResultMeta:
* getResultInfo:
* @id: Result identifier string
*
* Return an object with 'id', 'name', (both strings) and 'createIcon'

View File

@ -28,7 +28,6 @@ SearchResult.prototype = {
x_align: St.Align.START,
y_fill: true });
this.actor._delegate = this;
this._dragActorSource = null;
let content = provider.createResultActor(metaInfo, terms);
if (content == null) {
@ -38,11 +37,7 @@ SearchResult.prototype = {
let icon = new IconGrid.BaseIcon(this.metaInfo['name'],
{ createIcon: this.metaInfo['createIcon'] });
content.set_child(icon.actor);
this._dragActorSource = icon.icon;
this.actor.label_actor = icon.label;
} else {
if (content._delegate && content._delegate.getDragActorSource)
this._dragActorSource = content._delegate.getDragActorSource();
}
this._content = content;
this.actor.set_child(content);
@ -81,8 +76,6 @@ SearchResult.prototype = {
},
getDragActorSource: function() {
if (this._dragActorSource)
return this._dragActorSource;
// not exactly right, but alignment problems are hard to notice
return this._content;
},
@ -199,7 +192,7 @@ SearchResults.prototype = {
let scrollView = new St.ScrollView({ x_fill: true,
y_fill: false,
style_class: 'vfade' });
vfade: true });
scrollView.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
scrollView.add_actor(this._content);

View File

@ -1,405 +0,0 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Lang = imports.lang;
const Signals = imports.signals;
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Pango = imports.gi.Pango;
const St = imports.gi.St;
const Shell = imports.gi.Shell;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
const ModalDialog = imports.ui.modalDialog;
const Params = imports.misc.params;
const LIST_ITEM_ICON_SIZE = 48;
/* ------ Common Utils ------- */
function _setLabelText(label, text) {
if (text) {
label.set_text(text);
label.show();
} else {
label.set_text('');
label.hide();
}
}
function _setButtonsForChoices(dialog, choices) {
let buttons = [];
for (let idx = 0; idx < choices.length; idx++) {
let button = idx;
buttons.unshift({ label: choices[idx],
action: Lang.bind(dialog, function() {
dialog.emit('response', button);
})});
}
dialog.setButtons(buttons);
}
function _setLabelsForMessage(dialog, message) {
let labels = message.split('\n');
_setLabelText(dialog.subjectLabel, labels[0]);
if (labels.length > 1)
_setLabelText(dialog.descriptionLabel, labels[1]);
}
/* -------------------------------------------------------- */
function ListItem(app) {
this._init(app);
}
ListItem.prototype = {
_init: function(app) {
this._app = app;
let layout = new St.BoxLayout({ vertical: false});
this.actor = new St.Button({ style_class: 'show-processes-dialog-app-list-item',
can_focus: true,
child: layout,
reactive: true,
x_align: St.Align.START,
x_fill: true });
this._icon = this._app.create_icon_texture(LIST_ITEM_ICON_SIZE);
let iconBin = new St.Bin({ style_class: 'show-processes-dialog-app-list-item-icon',
child: this._icon });
layout.add(iconBin);
this._nameLabel = new St.Label({ text: this._app.get_name(),
style_class: 'show-processes-dialog-app-list-item-name' });
let labelBin = new St.Bin({ y_align: St.Align.MIDDLE,
child: this._nameLabel });
layout.add(labelBin);
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
},
_onClicked: function() {
this.emit('activate');
this._app.activate(-1);
}
};
Signals.addSignalMethods(ListItem.prototype);
function ShellMountOperation(source, params) {
this._init(source, params);
}
ShellMountOperation.prototype = {
_init: function(source, params) {
params = Params.parse(params, { reaskPassword: false });
this._reaskPassword = params.reaskPassword;
this._dialog = null;
this._processesDialog = null;
this.mountOp = new Shell.MountOperation();
this.mountOp.connect('ask-question',
Lang.bind(this, this._onAskQuestion));
this.mountOp.connect('ask-password',
Lang.bind(this, this._onAskPassword));
this.mountOp.connect('show-processes-2',
Lang.bind(this, this._onShowProcesses2));
this.mountOp.connect('aborted',
Lang.bind(this, this._onAborted));
this._icon = new St.Icon({ gicon: source.get_icon(),
style_class: 'shell-mount-operation-icon' });
},
_onAskQuestion: function(op, message, choices) {
this._dialog = new ShellMountQuestionDialog(this._icon);
this._dialog.connect('response',
Lang.bind(this, function(object, choice) {
this.mountOp.set_choice(choice);
this.mountOp.reply(Gio.MountOperationResult.HANDLED);
this._dialog.close(global.get_current_time());
this._dialog = null;
}));
this._dialog.update(message, choices);
this._dialog.open(global.get_current_time());
},
_onAskPassword: function(op, message) {
this._notificationShowing = true;
this._source = new ShellMountPasswordSource(message, this._icon, this._reaskPassword);
this._source.connect('password-ready',
Lang.bind(this, function(source, password) {
this.mountOp.set_password(password);
this.mountOp.reply(Gio.MountOperationResult.HANDLED);
this._notificationShowing = false;
this._source.destroy();
}));
this._source.connect('destroy',
Lang.bind(this, function() {
if (!this._notificationShowing)
return;
this._notificationShowing = false;
this.mountOp.reply(Gio.MountOperationResult.ABORTED);
}));
},
_onAborted: function(op) {
if (!this._dialog)
return;
this._dialog.close(global.get_current_time());
this._dialog = null;
},
_onShowProcesses2: function(op) {
let processes = op.get_show_processes_pids();
let choices = op.get_show_processes_choices();
let message = op.get_show_processes_message();
if (!this._processesDialog) {
this._processesDialog = new ShellProcessesDialog(this._icon);
this._dialog = this._processesDialog;
this._processesDialog.connect('response',
Lang.bind(this, function(object, choice) {
if (choice == -1) {
this.mountOp.reply(Gio.MountOperationResult.ABORTED);
} else {
this.mountOp.set_choice(choice);
this.mountOp.reply(Gio.MountOperationResult.HANDLED);
}
this._processesDialog.close(global.get_current_time());
this._dialog = null;
}));
this._processesDialog.open(global.get_current_time());
}
this._processesDialog.update(message, processes, choices);
},
}
function ShellMountQuestionDialog(icon) {
this._init(icon);
}
ShellMountQuestionDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(icon) {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'mount-question-dialog' });
let mainContentLayout = new St.BoxLayout();
this.contentLayout.add(mainContentLayout, { x_fill: true,
y_fill: false });
this._iconBin = new St.Bin({ child: icon });
mainContentLayout.add(this._iconBin,
{ x_fill: true,
y_fill: false,
x_align: St.Align.END,
y_align: St.Align.MIDDLE });
let messageLayout = new St.BoxLayout({ vertical: true });
mainContentLayout.add(messageLayout,
{ y_align: St.Align.START });
this.subjectLabel = new St.Label({ style_class: 'mount-question-dialog-subject' });
messageLayout.add(this.subjectLabel,
{ y_fill: false,
y_align: St.Align.START });
this.descriptionLabel = new St.Label({ style_class: 'mount-question-dialog-description' });
this.descriptionLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
this.descriptionLabel.clutter_text.line_wrap = true;
messageLayout.add(this.descriptionLabel,
{ y_fill: true,
y_align: St.Align.START });
},
update: function(message, choices) {
_setLabelsForMessage(this, message);
_setButtonsForChoices(this, choices);
}
}
Signals.addSignalMethods(ShellMountQuestionDialog.prototype);
function ShellMountPasswordSource(message, icon, reaskPassword) {
this._init(message, icon, reaskPassword);
}
ShellMountPasswordSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(message, icon, reaskPassword) {
let strings = message.split('\n');
MessageTray.Source.prototype._init.call(this, strings[0]);
this._notification = new ShellMountPasswordNotification(this, strings, icon, reaskPassword);
// add ourselves as a source, and popup the notification
Main.messageTray.add(this);
this.notify(this._notification);
},
}
Signals.addSignalMethods(ShellMountPasswordSource.prototype);
function ShellMountPasswordNotification(source, strings, icon, reaskPassword) {
this._init(source, strings, icon, reaskPassword);
}
ShellMountPasswordNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source, strings, icon, reaskPassword) {
MessageTray.Notification.prototype._init.call(this, source,
strings[0], null,
{ customContent: true,
icon: icon });
// set the notification to transient and urgent, so that it
// expands out
this.setTransient(true);
this.setUrgency(MessageTray.Urgency.CRITICAL);
if (strings[1])
this.addBody(strings[1]);
if (reaskPassword) {
let label = new St.Label({ style_class: 'mount-password-reask',
text: _("Wrong password, please try again") });
this.addActor(label);
}
this._responseEntry = new St.Entry({ style_class: 'mount-password-entry',
can_focus: true });
this.setActionArea(this._responseEntry);
this._responseEntry.clutter_text.connect('activate',
Lang.bind(this, this._onEntryActivated));
this._responseEntry.clutter_text.set_password_char('\u25cf'); // ● U+25CF BLACK CIRCLE
this._responseEntry.grab_key_focus();
},
_onEntryActivated: function() {
let text = this._responseEntry.get_text();
if (text == '')
return;
this.source.emit('password-ready', text);
}
}
function ShellProcessesDialog(icon) {
this._init(icon);
}
ShellProcessesDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(icon) {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'show-processes-dialog' });
let mainContentLayout = new St.BoxLayout();
this.contentLayout.add(mainContentLayout, { x_fill: true,
y_fill: false });
this._iconBin = new St.Bin({ child: icon });
mainContentLayout.add(this._iconBin,
{ x_fill: true,
y_fill: false,
x_align: St.Align.END,
y_align: St.Align.MIDDLE });
let messageLayout = new St.BoxLayout({ vertical: true });
mainContentLayout.add(messageLayout,
{ y_align: St.Align.START });
this.subjectLabel = new St.Label({ style_class: 'show-processes-dialog-subject' });
messageLayout.add(this.subjectLabel,
{ y_fill: false,
y_align: St.Align.START });
this.descriptionLabel = new St.Label({ style_class: 'show-processes-dialog-description' });
this.descriptionLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
this.descriptionLabel.clutter_text.line_wrap = true;
messageLayout.add(this.descriptionLabel,
{ y_fill: true,
y_align: St.Align.START });
let scrollView = new St.ScrollView({ style_class: 'show-processes-dialog-app-list'});
scrollView.set_policy(Gtk.PolicyType.NEVER,
Gtk.PolicyType.AUTOMATIC);
this.contentLayout.add(scrollView,
{ x_fill: true,
y_fill: true });
scrollView.hide();
this._applicationList = new St.BoxLayout({ vertical: true });
scrollView.add_actor(this._applicationList,
{ x_fill: true,
y_fill: true,
x_align: St.Align.START,
y_align: St.Align.MIDDLE });
this._applicationList.connect('actor-added',
Lang.bind(this, function() {
if (this._applicationList.get_children().length == 1)
scrollView.show();
}));
this._applicationList.connect('actor-removed',
Lang.bind(this, function() {
if (this._applicationList.get_children().length == 0)
scrollView.hide();
}));
},
_setAppsForPids: function(pids) {
// remove all the items
this._applicationList.destroy_children();
pids.forEach(Lang.bind(this, function(pid) {
let tracker = Shell.WindowTracker.get_default();
let app = tracker.get_app_from_pid(pid);
if (!app)
return;
let item = new ListItem(app);
this._applicationList.add(item.actor, { x_fill: true });
item.connect('activate',
Lang.bind(this, function() {
// use -1 to indicate Cancel
this.emit('response', -1);
}));
}));
},
update: function(message, processes, choices) {
this._setAppsForPids(processes);
_setLabelsForMessage(this, message);
_setButtonsForChoices(this, choices);
}
}
Signals.addSignalMethods(ShellProcessesDialog.prototype);

View File

@ -10,7 +10,6 @@ const Shell = imports.gi.Shell;
const Signals = imports.signals;
const St = imports.gi.St;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Util = imports.misc.util;
@ -40,8 +39,6 @@ const KEY_TEXT_SCALING_FACTOR = 'text-scaling-factor';
const HIGH_CONTRAST_THEME = 'HighContrast';
const KEYBOARD_SCHEMA = 'org.gnome.shell.keyboard'
function ATIndicator() {
this._init.apply(this, arguments);
}
@ -70,9 +67,9 @@ ATIndicator.prototype = {
// 'screen-reader-enabled');
// this.menu.addMenuItem(screenReader);
let screenKeyboard = this._buildItem(_("Screen Keyboard"), KEYBOARD_SCHEMA,
'show-keyboard');
this.menu.addMenuItem(screenKeyboard);
// let screenKeyboard = this._buildItem(_("Screen Keyboard"), APPLICATIONS_SCHEMA,
// 'screen-keyboard-enabled');
// this.menu.addMenuItem(screenKeyboard);
let visualBell = this._buildItemGConf(_("Visual Alerts"), client, KEY_VISUAL_BELL);
this.menu.addMenuItem(visualBell);
@ -91,7 +88,6 @@ ATIndicator.prototype = {
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.menu.addAction(_("Universal Access Settings"), function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().get_app('gnome-universal-access-panel.desktop');
app.activate(-1);
});

View File

@ -90,7 +90,6 @@ Indicator.prototype = {
this._updateFullMenu();
this.menu.addAction(_("Bluetooth Settings"), function() {
Main.overview.hide()
let app = Shell.AppSystem.get_default().get_app('bluetooth-properties.desktop');
app.activate(-1);
});
@ -109,11 +108,7 @@ Indicator.prototype = {
current_state != GnomeBluetoothApplet.KillswitchState.HARD_BLOCKED;
this._killswitch.setToggleState(on);
if (can_toggle)
this._killswitch.setStatus(null);
else
/* TRANSLATORS: this means that bluetooth was disabled by hardware rfkill */
this._killswitch.setStatus(_("hardware disabled"));
this._killswitch.actor.reactive = can_toggle;
if (has_adapter)
this.actor.show();
@ -215,15 +210,14 @@ Indicator.prototype = {
if (device.can_connect) {
item._connected = device.connected;
item._connectedMenuitem = new PopupMenu.PopupSwitchMenuItem(_("Connection"), device.connected);
item._connectedMenuitem.connect('toggled', Lang.bind(this, function() {
if (item._connected > ConnectionState.CONNECTED) {
// operation already in progress, revert
// (should not happen anyway)
menuitem.setToggleState(menuitem.state);
}
if (item._connected) {
item._connected = ConnectionState.DISCONNECTING;
menuitem.setStatus(_("disconnecting..."));
this._applet.disconnect_device(item._device.device_path, function(applet, success) {
if (success) { // apply
item._connected = ConnectionState.DISCONNECTED;
@ -232,11 +226,9 @@ Indicator.prototype = {
item._connected = ConnectionState.CONNECTED;
menuitem.setToggleState(true);
}
menuitem.setStatus(null);
});
} else {
item._connected = ConnectionState.CONNECTING;
menuitem.setStatus(_("connecting..."));
this._applet.connect_device(item._device.device_path, function(applet, success) {
if (success) { // apply
item._connected = ConnectionState.CONNECTED;
@ -245,7 +237,6 @@ Indicator.prototype = {
item._connected = ConnectionState.DISCONNECTED;
menuitem.setToggleState(false);
}
menuitem.setStatus(null);
});
}
}));

View File

@ -9,7 +9,6 @@ const Lang = imports.lang;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
const Main = imports.ui.main;
const PopupMenu = imports.ui.popupMenu;
const PanelMenu = imports.ui.panelMenu;
const Util = imports.misc.util;
@ -69,11 +68,9 @@ XKBIndicator.prototype = {
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.menu.addAction(_("Show Keyboard Layout..."), Lang.bind(this, function() {
Main.overview.hide();
Util.spawn(['gkbd-keyboard-display', '-g', String(this._config.get_current_group() + 1)]);
}));
this.menu.addAction(_("Localization Settings"), function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().get_app('gnome-region-panel.desktop');
app.activate(-1);
});

View File

@ -192,7 +192,63 @@ NMNetworkMenuItem.prototype = {
apObj.updateId = 0;
}
PopupMenu.PopupBaseMenuItem.prototype.destroy.call(this);
PopupMenu.PopupImageMenuItem.prototype.destroy.call(this);
}
};
function NMDeviceTitleMenuItem() {
this._init.apply(this, arguments);
}
NMDeviceTitleMenuItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,
_init: function(description, params) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this, params);
this._descriptionLabel = new St.Label({ text: description,
style_class: 'popup-subtitle-menu-item'
});
this.addActor(this._descriptionLabel);
this._statusBin = new St.Bin({ x_align: St.Align.END });
this.addActor(this._statusBin, { align: St.Align.END });
this._statusLabel = new St.Label({ text: '',
style_class: 'popup-inactive-menu-item'
});
this._switch = new PopupMenu.Switch(false);
this._statusBin.child = this._switch.actor;
},
setStatus: function(text) {
if (text != null) {
this._statusLabel.text = text;
this._statusBin.child = this._statusLabel;
this.actor.reactive = false;
this.actor.can_focus = false;
} else {
this._statusBin.child = this._switch.actor;
this.actor.reactive = true;
this.actor.can_focus = true;
}
},
activate: function(event) {
if (this._switch.actor.mapped) {
this._switch.toggle();
this.emit('toggled', this._switch.state);
}
PopupMenu.PopupBaseMenuItem.prototype.activate.call(this, event);
},
get state() {
return this._switch.state;
},
setToggleState: function(newval) {
this._switch.setToggleState(newval);
}
};
@ -201,13 +257,7 @@ function NMWiredSectionTitleMenuItem() {
}
NMWiredSectionTitleMenuItem.prototype = {
__proto__: PopupMenu.PopupSwitchMenuItem.prototype,
_init: function(label, params) {
params = params || { };
params.style_class = 'popup-subtitle-menu-item';
PopupMenu.PopupSwitchMenuItem.prototype._init.call(this, label, false, params);
},
__proto__: NMDeviceTitleMenuItem.prototype,
updateForDevice: function(device) {
if (device) {
@ -219,7 +269,7 @@ NMWiredSectionTitleMenuItem.prototype = {
},
activate: function(event) {
PopupMenu.PopupSwitchMenuItem.prototype.activate.call(this, event);
NMDeviceTitleMenuItem.prototype.activate.call(this, event);
if (!this._device) {
log('Section title activated when there is more than one device, should be non reactive');
@ -245,12 +295,10 @@ function NMWirelessSectionTitleMenuItem() {
}
NMWirelessSectionTitleMenuItem.prototype = {
__proto__: PopupMenu.PopupSwitchMenuItem.prototype,
__proto__: NMDeviceTitleMenuItem.prototype,
_init: function(client, property, title, params) {
params = params || { };
params.style_class = 'popup-subtitle-menu-item';
PopupMenu.PopupSwitchMenuItem.prototype._init.call(this, title, false, params);
NMDeviceTitleMenuItem.prototype._init.call(this, title, params);
this._client = client;
this._property = property + '_enabled';
@ -276,7 +324,7 @@ NMWirelessSectionTitleMenuItem.prototype = {
},
activate: function(event) {
PopupMenu.PopupSwitchMenuItem.prototype.activate.call(this, event);
NMDeviceTitleMenuItem.prototype.activate.call(this, event);
this._client[this._setEnabledFunc](this._switch.state);
},
@ -325,14 +373,15 @@ NMDevice.prototype = {
};
this._connections.push(obj);
}
this._connections.sort(this._connectionSortFunction);
this._connections.sort(function(one, two) {
return two.timestamp - one.timestamp;
});
this._activeConnection = null;
this._activeConnectionItem = null;
this._autoConnectionItem = null;
this._overflowItem = null;
if (this.device) {
this.statusItem = new PopupMenu.PopupSwitchMenuItem(this._getDescription(), this.connected, { style_class: 'popup-subtitle-menu-item' });
this.statusItem = new NMDeviceTitleMenuItem(this._getDescription());
this._statusChanged = this.statusItem.connect('toggled', Lang.bind(this, function(item, state) {
if (state)
this.activate();
@ -433,7 +482,9 @@ NMDevice.prototype = {
timestamp: connection._timestamp,
};
this._connections.push(obj);
this._connections.sort(this._connectionSortFunction);
this._connections.sort(function(one, two) {
return two.timestamp - one.timestamp;
});
this._clearSection();
this._createSection();
@ -468,13 +519,6 @@ NMDevice.prototype = {
return this.device.connection_valid(connection);
},
_connectionSortFunction: function(one, two) {
if (one.timestamp == two.timestamp)
return GLib.utf8_collate(one.name, two.name);
return two.timestamp - one.timestamp;
},
setEnabled: function(enabled) {
// do nothing by default, we want to keep the conneciton list visible
// in the majority of cases (wired, wwan, vpn)
@ -482,15 +526,11 @@ NMDevice.prototype = {
getStatusLabel: function() {
switch(this.device.state) {
case NetworkManager.DeviceState.UNMANAGED:
case NetworkManager.DeviceState.DISCONNECTED:
case NetworkManager.DeviceState.DEACTIVATING:
case NetworkManager.DeviceState.ACTIVATED:
return null;
case NetworkManager.DeviceState.UNMANAGED:
/* Translators: this is for network devices that are physically present but are not
under NetworkManager's control (and thus cannot be used in the menu) */
return _("unmanaged");
case NetworkManager.DeviceState.DEACTIVATING:
return _("disconnecting...");
case NetworkManager.DeviceState.PREPARE:
case NetworkManager.DeviceState.CONFIG:
case NetworkManager.DeviceState.IP_CONFIG:
@ -549,7 +589,6 @@ NMDevice.prototype = {
this.section.removeAll();
this._autoConnectionItem = null;
this._activeConnectionItem = null;
this._overflowItem = null;
for (let i = 0; i < this._connections.length; i++) {
this._connections[i].item = null;
}
@ -568,23 +607,13 @@ NMDevice.prototype = {
this.section.addMenuItem(this._activeConnectionItem);
}
if (this._connections.length > 0) {
let activeOffset = this._activeConnectionItem ? 1 : 0;
for(let j = 0; j < this._connections.length; ++j) {
let obj = this._connections[j];
if (this._activeConnection &&
obj.connection == this._activeConnection._connection)
continue;
obj.item = this._createConnectionItem(obj);
if (j + activeOffset >= NUM_VISIBLE_NETWORKS) {
if (!this._overflowItem) {
this._overflowItem = new PopupMenu.PopupSubMenuMenuItem(_("More..."));
this.section.addMenuItem(this._overflowItem);
}
this._overflowItem.menu.addMenuItem(obj.item);
} else
this.section.addMenuItem(obj.item);
this.section.addMenuItem(obj.item);
}
} else if (this._autoConnectionName) {
this._autoConnectionItem = new PopupMenu.PopupMenuItem(this._autoConnectionName);
@ -792,7 +821,7 @@ NMDeviceModem.prototype = {
}));
}
NMDevice.prototype._init.call(this, client, device, connections);
NMDevice.prototype._init.call(this, client, device, connections, 1);
},
setEnabled: function(enabled) {
@ -809,7 +838,7 @@ NMDeviceModem.prototype = {
},
get connected() {
return this._enabled && this.device.state == NetworkManager.DeviceState.ACTIVATED;
return this._enabled && this.device.state == NetworkManager.DeviceState.CONNECTED;
},
destroy: function() {
@ -1281,29 +1310,12 @@ NMDeviceWireless.prototype = {
if (apObj.accessPoints.length == 0) {
if (apObj.item)
apObj.item.destroy();
if (this._overflowItem) {
if (!apObj.isMore) {
// we removed an item in the main menu, and we have a more submenu
// we need to extract the first item in more and move it to the submenu
let apObj = this._overflowItem.menu.firstMenuItem;
if (apObj.item) {
apObj.item.destroy();
this._createNetworkItem(apObj, NUM_VISIBLE_NETWORKS-1);
}
}
// This can happen if the removed connection is from the overflow
// menu, or if we just moved the last connection out from the menu
if (this._overflowItem.menu.length == 0) {
this._overflowItem.destroy();
this._overflowItem = null;
}
}
this._networks.splice(pos, 1);
if (this._overflowItem &&
this._overflowItem.menu.length == 0) {
this._overflowItem.destroy();
this._overflowItem = null;
}
} else if (apObj.item)
apObj.item.updateAccessPoints(apObj.accessPoints);
},
@ -1499,16 +1511,14 @@ NMDeviceWireless.prototype = {
}
}));
}
if (position < NUM_VISIBLE_NETWORKS) {
apObj.isMore = false;
this.section.addMenuItem(apObj.item, position);
} else {
if (position < NUM_VISIBLE_NETWORKS)
this.section.addMenuItem(apObj.item);
else {
if (!this._overflowItem) {
this._overflowItem = new PopupMenu.PopupSubMenuMenuItem(_("More..."));
this.section.addMenuItem(this._overflowItem);
}
this._overflowItem.menu.addMenuItem(apObj.item, position - NUM_VISIBLE_NETWORKS);
apObj.isMore = true;
}
},
@ -1603,7 +1613,6 @@ NMApplet.prototype = {
this.menu.addMenuItem(this._devices.vpn.section);
this.menu.addAction(_("Network Settings"), function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().get_app('gnome-network-panel.desktop');
app.activate(-1);
});
@ -1682,18 +1691,21 @@ NMApplet.prototype = {
_syncSectionTitle: function(category) {
let devices = this._devices[category].devices;
let managedDevices = devices.filter(function(dev) {
return dev.device.state != NetworkManager.DeviceState.UNMANAGED;
});
let item = this._devices[category].item;
let section = this._devices[category].section;
if (devices.length == 0)
if (managedDevices.length == 0)
section.actor.hide();
else {
section.actor.show();
if (devices.length == 1) {
let dev = devices[0];
if (managedDevices.length == 1) {
let dev = managedDevices[0];
dev.statusItem.actor.hide();
item.updateForDevice(dev);
} else {
devices.forEach(function(dev) {
managedDevices.forEach(function(dev) {
dev.statusItem.actor.show();
});
// remove status text from the section title item

View File

@ -7,13 +7,12 @@ const Mainloop = imports.mainloop;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Util = imports.misc.util;
const BUS_NAME = 'org.gnome.SettingsDaemon';
const OBJECT_PATH = '/org/gnome/SettingsDaemon/Power';
const BUS_NAME = 'org.gnome.PowerManager';
const OBJECT_PATH = '/org/gnome/PowerManager';
const UPDeviceType = {
UNKNOWN: 0,
@ -41,7 +40,7 @@ const UPDeviceState = {
};
const PowerManagerInterface = {
name: 'org.gnome.SettingsDaemon.Power',
name: 'org.gnome.PowerManager',
methods: [
{ name: 'GetDevices', inSignature: '', outSignature: 'a(susbut)' },
{ name: 'GetPrimaryDevice', inSignature: '', outSignature: '(susbut)' },
@ -81,7 +80,6 @@ Indicator.prototype = {
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.menu.addAction(_("Power Settings"),function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().get_app('gnome-power-panel.desktop');
app.activate(-1);
});
@ -93,6 +91,7 @@ Indicator.prototype = {
_readPrimaryDevice: function() {
this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(device, error) {
if (error) {
this._checkError(error);
this._hasPrimary = false;
this._primaryDeviceId = null;
this._batteryItem.actor.hide();
@ -144,6 +143,7 @@ Indicator.prototype = {
this._deviceItems = [];
if (error) {
this._checkError(error);
this._deviceSep.actor.hide();
return;
}
@ -174,12 +174,21 @@ Indicator.prototype = {
this.setGIcon(gicon);
this.actor.show();
} else {
this._checkError(error);
this.menu.close();
this.actor.hide();
}
}));
this._readPrimaryDevice();
this._readOtherDevices();
},
_checkError: function(error) {
if (!this._restarted && error && error.message.match(/org\.freedesktop\.DBus\.Error\.(UnknownMethod|InvalidArgs)/)) {
Util.killall('gnome-power-manager');
Util.spawn(['gnome-power-manager']);
this._restarted = true;
}
}
};

View File

@ -9,7 +9,6 @@ const Gvc = imports.gi.Gvc;
const Signals = imports.signals;
const St = imports.gi.St;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Util = imports.misc.util;
@ -62,7 +61,6 @@ Indicator.prototype = {
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.menu.addAction(_("Sound Settings"), function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().get_app('gnome-sound-panel.desktop');
app.activate(-1);
});

View File

@ -4,7 +4,6 @@ const Lang = imports.lang;
const Shell = imports.gi.Shell;
const Signals = imports.signals;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
const NotificationDaemon = imports.ui.notificationDaemon;
const Util = imports.misc.util;
@ -39,10 +38,10 @@ StatusIconDispatcher.prototype = {
// status icons
// http://bugzilla.gnome.org/show_bug.cgi=id=621382
Util.killall('indicator-application-service');
},
Main.connect('initialized', Lang.bind(this, function() {
this._traymanager.manage_stage(global.stage, Main.messageTray.actor);
}));
start: function(themeWidget) {
this._traymanager.manage_stage(global.stage, themeWidget);
},
_onTrayIconAdded: function(o, icon) {

View File

@ -14,14 +14,23 @@ const GnomeSession = imports.misc.gnomeSession;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const ScreenSaver = imports.misc.screenSaver;
const Util = imports.misc.util;
const BUS_NAME = 'org.gnome.ScreenSaver';
const OBJECT_PATH = '/org/gnome/ScreenSaver';
const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
const DISABLE_USER_SWITCH_KEY = 'disable-user-switching';
const DISABLE_LOCK_SCREEN_KEY = 'disable-lock-screen';
const DISABLE_LOG_OUT_KEY = 'disable-log-out';
const ScreenSaverInterface = {
name: BUS_NAME,
methods: [ { name: 'Lock', inSignature: '' } ]
};
let ScreenSaverProxy = DBus.makeProxyClass(ScreenSaverInterface);
// Adapted from gdm/gui/user-switch-applet/applet.c
//
// Copyright (C) 2004-2005 James M. Cape <jcape@ignore-your.tv>.
@ -48,12 +57,11 @@ StatusMenuButton.prototype = {
this._presence = new GnomeSession.Presence();
this._presenceItems = {};
this._session = new GnomeSession.SessionManager();
this._haveShutdown = true;
this._account_mgr = Tp.AccountManager.dup()
this._upClient = new UPowerGlib.Client();
this._screenSaverProxy = new ScreenSaver.ScreenSaverProxy();
this._screenSaverProxy = new ScreenSaverProxy(DBus.session, BUS_NAME, OBJECT_PATH);
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
this._iconBox = new St.Bin();
@ -81,25 +89,12 @@ StatusMenuButton.prototype = {
Lang.bind(this, this._updateSwitchUser));
this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
Lang.bind(this, this._updateLogout));
this._lockdownSettings.connect('changed::' + DISABLE_LOCK_SCREEN_KEY,
Lang.bind(this, this._updateLockScreen));
this._updateSwitchUser();
this._updateLogout();
this._updateLockScreen();
// Whether shutdown is available or not depends on both lockdown
// settings (disable-log-out) and Polkit policy - the latter doesn't
// notify, so we update the menu item each time the menu opens or
// the lockdown setting changes, which should be close enough.
this.menu.connect('open-state-changed', Lang.bind(this,
function(menu, open) {
if (open)
this._updateHaveShutdown();
}));
this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
Lang.bind(this, this._updateHaveShutdown));
this._upClient.connect('notify::can-suspend', Lang.bind(this, this._updateSuspendOrPowerOff));
},
@ -116,25 +111,13 @@ StatusMenuButton.prototype = {
},
_updateSessionSeparator: function() {
let sessionItemsVisible = this._loginScreenItem.actor.visible ||
this._logoutItem.actor.visible ||
this._lockScreenItem.actor.visible;
let showSessionSeparator = sessionItemsVisible &&
this._suspendOrPowerOffItem.actor.visible;
let showSettingsSeparator = sessionItemsVisible ||
this._suspendOrPowerOffItem.actor.visible;
if (showSessionSeparator)
let showSeparator = this._loginScreenItem.actor.visible ||
this._logoutItem.actor.visible ||
this._lockScreenItem.actor.visible;
if (showSeparator)
this._sessionSeparator.actor.show();
else
this._sessionSeparator.actor.hide();
if (showSettingsSeparator)
this._settingsSeparator.actor.show();
else
this._settingsSeparator.actor.hide();
},
_updateSwitchUser: function() {
@ -164,34 +147,16 @@ StatusMenuButton.prototype = {
this._updateSessionSeparator();
},
_updateHaveShutdown: function() {
this._session.CanShutdownRemote(Lang.bind(this,
function(result, error) {
if (!error) {
this._haveShutdown = result;
this._updateSuspendOrPowerOff();
}
}));
},
_updateSuspendOrPowerOff: function() {
this._haveSuspend = this._upClient.get_can_suspend();
if (!this._suspendOrPowerOffItem)
return;
if (!this._haveShutdown && !this._haveSuspend)
this._suspendOrPowerOffItem.actor.hide();
else
this._suspendOrPowerOffItem.actor.show();
this._updateSessionSeparator();
// If we can't suspend show Power Off... instead
// and disable the alt key
if (!this._haveSuspend) {
this._suspendOrPowerOffItem.updateText(_("Power Off..."), null);
} else if (!this._haveShutdown) {
this._suspendOrPowerOffItem.updateText(_("Suspend"), null);
} else {
this._suspendOrPowerOffItem.updateText(_("Suspend"), _("Power Off..."));
}
@ -237,7 +202,6 @@ StatusMenuButton.prototype = {
item = new PopupMenu.PopupSeparatorMenuItem();
this.menu.addMenuItem(item);
this._settingsSeparator = item;
item = new PopupMenu.PopupMenuItem(_("Lock Screen"));
item.connect('activate', Lang.bind(this, this._onLockScreenActivate));
@ -291,11 +255,8 @@ StatusMenuButton.prototype = {
_onLoginScreenActivate: function() {
Main.overview.hide();
// Ensure we only move to GDM after the screensaver has activated; in some
// OS configurations, the X server may block event processing on VT switch
this._screenSaverProxy.SetActiveRemote(true, Lang.bind(this, function() {
this._gdm.goto_login_session();
}));
this._gdm.goto_login_session();
this._onLockScreenActivate();
},
_onQuitSessionActivate: function() {
@ -308,8 +269,7 @@ StatusMenuButton.prototype = {
if (this._haveSuspend &&
this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
// Ensure we only suspend after the screensaver has activated
this._screenSaverProxy.SetActiveRemote(true, Lang.bind(this, function() {
this._screenSaverProxy.LockRemote(Lang.bind(this, function() {
this._upClient.suspend_sync(null);
}));
} else {

View File

@ -24,9 +24,6 @@ const SCROLLBACK_IDLE_LENGTH = 5;
// See Source._displayPendingMessages
const SCROLLBACK_HISTORY_LINES = 10;
// See Notification._onEntryChanged
const COMPOSING_STOP_TIMEOUT = 5;
const NotificationDirection = {
SENT: 'chat-sent',
RECEIVED: 'chat-received'
@ -72,34 +69,22 @@ function Client() {
Client.prototype = {
_init : function() {
// channel path -> ChatSource
this._chatSources = {};
this._chatState = Tp.ChannelChatState.ACTIVE;
// channel path -> Source
this._sources = {};
// Set up a SimpleObserver, which will call _observeChannels whenever a
// channel matching its filters is detected.
// The second argument, recover, means _observeChannels will be run
// for any existing channel as well.
let dbus = Tp.DBusDaemon.dup();
this._tpClient = new Shell.TpClient({ 'dbus_daemon': dbus,
'name': 'GnomeShell',
'uniquify-name': true })
this._tpClient.set_observe_channels_func(
this._observer = Shell.TpClient.new(dbus);
this._observer.set_observe_channels_func(
Lang.bind(this, this._observeChannels));
this._tpClient.set_approve_channels_func(
Lang.bind(this, this._approveChannels));
this._tpClient.set_handle_channels_func(
Lang.bind(this, this._handleChannels));
// Allow other clients (such as Empathy) to pre-empt our channels if
// needed
this._tpClient.set_delegated_channels_callback(
Lang.bind(this, this._delegatedChannelsCb));
try {
this._tpClient.register();
this._observer.register();
} catch (e) {
throw new Error('Couldn\'t register Telepathy client. Error: \n' + e);
throw new Error('Couldn\'t register SimpleObserver. Error: \n' + e);
}
},
@ -112,7 +97,7 @@ Client.prototype = {
this._finishObserveChannels(account, conn, channels, context);
} else {
Shell.get_self_contact_features(conn,
contactFeatures,
contactFeatures.length, contactFeatures,
Lang.bind(this, function() {
this._finishObserveChannels(account, conn, channels, context);
}));
@ -132,216 +117,60 @@ Client.prototype = {
continue;
/* Request a TpContact */
Shell.get_tp_contacts(conn, [targetHandle],
contactFeatures,
Shell.get_tp_contacts(conn, 1, [targetHandle],
contactFeatures.length, contactFeatures,
Lang.bind(this, function (connection, contacts, failed) {
if (contacts.length < 1)
return;
/* We got the TpContact */
this._createChatSource(account, conn, channel, contacts[0]);
this._createSource(account, conn, channel, contacts[0]);
}), null);
}
context.accept();
},
_createChatSource: function(account, conn, channel, contact) {
if (this._chatSources[channel.get_object_path()])
_createSource: function(account, conn, channel, contact) {
if (this._sources[channel.get_object_path()])
return;
let source = new ChatSource(account, conn, channel, contact, this._tpClient);
let source = new Source(account, conn, channel, contact);
this._chatSources[channel.get_object_path()] = source;
this._sources[channel.get_object_path()] = source;
source.connect('destroy', Lang.bind(this,
function() {
if (this._tpClient.is_handling_channel(channel)) {
// The chat box has been destroyed so it can't
// handle the channel any more.
channel.close_async(function(src, result) {
channel.close_finish(result);
});
}
delete this._chatSources[channel.get_object_path()];
delete this._sources[channel.get_object_path()];
}));
},
_handleChannels: function(handler, account, conn, channels,
requests, user_action_time, context) {
this._handlingChannels(account, conn, channels);
context.accept();
},
_handlingChannels: function(account, conn, channels) {
let len = channels.length;
for (let i = 0; i < len; i++) {
let channel = channels[i];
// We can only handle text channel, so close any other channel
if (!(channel instanceof Tp.TextChannel)) {
channel.close_async(null);
continue;
}
if (this._tpClient.is_handling_channel(channel)) {
// We are already handling the channel, display the source
let source = this._chatSources[channel.get_object_path()];
if (source)
source.notify();
}
}
},
_displayRoomInvitation: function(conn, channel, dispatchOp, context) {
// We can only approve the rooms if we have been invited to it
let selfHandle = channel.group_get_self_handle();
if (selfHandle == 0) {
Shell.decline_dispatch_op(context, 'Not invited to the room');
return;
}
let [invited, inviter, reason, msg] = channel.group_get_local_pending_info(selfHandle);
if (!invited) {
Shell.decline_dispatch_op(context, 'Not invited to the room');
return;
}
// Request a TpContact for the inviter
Shell.get_tp_contacts(conn, [inviter],
contactFeatures,
Lang.bind(this, this._createRoomInviteSource, channel, context, dispatchOp));
context.delay();
},
_createRoomInviteSource: function(connection, contacts, failed, channel, context, dispatchOp) {
if (contacts.length < 1) {
Shell.decline_dispatch_op(context, 'Failed to get inviter');
return;
}
// We got the TpContact
// FIXME: We don't have a 'chat room' icon (bgo #653737) use
// system-users for now as Empathy does.
let source = new ApproverSource(dispatchOp, _("Invitation"), 'system-users');
Main.messageTray.add(source);
let notif = new RoomInviteNotification(source, dispatchOp, channel, contacts[0]);
source.notify(notif);
context.accept();
},
_approveChannels: function(approver, account, conn, channels,
dispatchOp, context) {
let channel = channels[0];
let chanType = channel.get_channel_type();
if (chanType == Tp.IFACE_CHANNEL_TYPE_TEXT)
this._approveTextChannel(account, conn, channel, dispatchOp, context);
else if (chanType == Tp.IFACE_CHANNEL_TYPE_STREAMED_MEDIA ||
chanType == 'org.freedesktop.Telepathy.Channel.Type.Call.DRAFT')
this._approveCall(account, conn, channel, dispatchOp, context);
},
_approveTextChannel: function(account, conn, channel, dispatchOp, context) {
let [targetHandle, targetHandleType] = channel.get_handle();
if (targetHandleType == Tp.HandleType.CONTACT) {
// Approve private text channels right away as we are going to handle it
dispatchOp.claim_with_async(this._tpClient,
Lang.bind(this, function(dispatchOp, result) {
try {
dispatchOp.claim_with_finish(result);
this._handlingChannels(account, conn, [channel]);
} catch (err) {
throw new Error('Failed to Claim channel: ' + err);
}}));
context.accept();
} else {
this._displayRoomInvitation(conn, channel, dispatchOp, context);
}
},
_approveCall: function(account, conn, channel, dispatchOp, context) {
let [targetHandle, targetHandleType] = channel.get_handle();
Shell.get_tp_contacts(conn, [targetHandle],
contactFeatures,
Lang.bind(this, this._createAudioVideoSource, channel, context, dispatchOp));
},
_createAudioVideoSource: function(connection, contacts, failed, channel, context, dispatchOp) {
if (contacts.length < 1) {
Shell.decline_dispatch_op(context, 'Failed to get inviter');
return;
}
let isVideo = false;
let props = channel.borrow_immutable_properties();
if (props['org.freedesktop.Telepathy.Channel.Type.Call.DRAFT.InitialVideo'] ||
props[Tp.PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO])
isVideo = true;
// We got the TpContact
let source = new ApproverSource(dispatchOp, _("Call"), isVideo ? 'camera-web' : 'audio-input-microphone');
Main.messageTray.add(source);
let notif = new AudioVideoNotification(source, dispatchOp, channel, contacts[0], isVideo);
source.notify(notif);
context.accept();
},
_delegatedChannelsCb: function(client, channels) {
// Nothing to do as we don't make a distinction between observed and
// handled channels.
}
};
function ChatSource(account, conn, channel, contact, client) {
this._init(account, conn, channel, contact, client);
function Source(account, conn, channel, contact) {
this._init(account, conn, channel, contact);
}
ChatSource.prototype = {
Source.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(account, conn, channel, contact, client) {
_init: function(account, conn, channel, contact) {
MessageTray.Source.prototype._init.call(this, contact.get_alias());
this.isChat = true;
this._account = account;
this._contact = contact;
this._client = client;
this._pendingMessages = [];
this._conn = conn;
this._channel = channel;
this._closedId = this._channel.connect('invalidated', Lang.bind(this, this._channelClosed));
this._notification = new ChatNotification(this);
this._notification = new Notification(this);
this._notification.setUrgency(MessageTray.Urgency.HIGH);
// We ack messages when the message box is collapsed if user has
// interacted with it before and so read the messages:
// - user clicked on it the tray
// - user expanded the notification by hovering over the toaster notification
this._shouldAck = false;
this.connect('summary-item-clicked', Lang.bind(this, this._summaryItemClicked));
this._notification.connect('expanded', Lang.bind(this, this._notificationExpanded));
this._notification.connect('collapsed', Lang.bind(this, this._notificationCollapsed));
this._presence = contact.get_presence_type();
this._sentId = this._channel.connect('message-sent', Lang.bind(this, this._messageSent));
this._receivedId = this._channel.connect('message-received', Lang.bind(this, this._messageReceived));
this._pendingId = this._channel.connect('pending-message-removed', Lang.bind(this, this._pendingRemoved));
this._setSummaryIcon(this.createNotificationIcon());
@ -358,7 +187,7 @@ ChatSource.prototype = {
_updateAlias: function() {
let oldAlias = this.title;
this.setTitle(this._contact.get_alias());
this.title = this._contact.get_alias();
this._notification.appendAliasChange(oldAlias, this.title);
this.pushNotification(this._notification);
},
@ -387,17 +216,13 @@ ChatSource.prototype = {
},
open: function(notification) {
if (this._client.is_handling_channel(this._channel)) {
// We are handling the channel, try to pass it to Empathy
this._client.delegate_channels_async([this._channel], global.get_current_time(), "", null);
}
else {
// We are not the handler, just ask to present the channel
let dbus = Tp.DBusDaemon.dup();
let cd = Tp.ChannelDispatcher.new(dbus);
let props = {};
props[Tp.PROP_CHANNEL_CHANNEL_TYPE] = Tp.IFACE_CHANNEL_TYPE_TEXT;
[props[Tp.PROP_CHANNEL_TARGET_HANDLE], props[Tp.PROP_CHANNEL_TARGET_HANDLE_TYPE]] = this._channel.get_handle();
cd.present_channel_async(this._channel, global.get_current_time(), null);
}
let req = Tp.AccountChannelRequest.new(this._account, props, global.get_current_time());
req.ensure_channel_async('', null, null);
},
_getLogMessages: function() {
@ -415,20 +240,7 @@ ChatSource.prototype = {
let logMessages = events.map(makeMessageFromTplEvent);
let pendingTpMessages = this._channel.get_pending_messages();
let pendingMessages = [];
for (let i = 0; i < pendingTpMessages.length; i++) {
let message = pendingTpMessages[i];
if (message.get_message_type() == Tp.ChannelTextMessageType.DELIVERY_REPORT)
continue;
pendingMessages.push(makeMessageFromTpMessage(message, NotificationDirection.RECEIVED));
this._pendingMessages.push(message);
}
this._updateCount();
let pendingMessages = pendingTpMessages.map(function (tpMessage) { return makeMessageFromTpMessage(tpMessage, NotificationDirection.RECEIVED); });
let showTimestamp = false;
@ -464,7 +276,6 @@ ChatSource.prototype = {
_channelClosed: function() {
this._channel.disconnect(this._closedId);
this._channel.disconnect(this._receivedId);
this._channel.disconnect(this._pendingId);
this._channel.disconnect(this._sentId);
this._contact.disconnect(this._notifyAliasId);
@ -474,17 +285,10 @@ ChatSource.prototype = {
this.destroy();
},
_updateCount: function() {
this._setCount(this._pendingMessages.length, this._pendingMessages.length > 0);
},
_messageReceived: function(channel, message) {
if (message.get_message_type() == Tp.ChannelTextMessageType.DELIVERY_REPORT)
return;
this._pendingMessages.push(message);
this._updateCount();
message = makeMessageFromTpMessage(message, NotificationDirection.RECEIVED);
this._notification.appendMessage(message);
this.notify();
@ -511,25 +315,10 @@ ChatSource.prototype = {
}
let msg = Tp.ClientMessage.new_text(type, text);
this._channel.send_message_async(msg, 0, Lang.bind(this, function (src, result) {
this._channel.send_message_finish(result);
}));
this._channel.send_message_async(msg, 0, null);
},
setChatState: function(state) {
// We don't want to send COMPOSING every time a letter is typed into
// the entry. We send the state only when it changes. Telepathy/Empathy
// might change it behind our back if the user is using both
// gnome-shell's entry and the Empathy conversation window. We could
// keep track of it with the ChatStateChanged signal but it is good
// enough right now.
if (state != this._chatState) {
this._chatState = state;
this._channel.set_chat_state_async(state, null);
}
},
_presenceChanged: function (contact, presence, status, message) {
_presenceChanged: function (contact, presence, type, status, message) {
let msg, shouldNotify, title;
if (this._presence == presence)
@ -562,53 +351,14 @@ ChatSource.prototype = {
this._notification.appendPresence(msg, shouldNotify);
if (shouldNotify)
this.notify();
},
_pendingRemoved: function(channel, message) {
let idx = this._pendingMessages.indexOf(message);
if (idx >= 0) {
this._pendingMessages.splice(idx, 1);
this._updateCount();
}
else
throw new Error('Message not in our pending list: ' + message);
},
_ackMessages: function() {
if (this._pendingMessages.length == 0)
return;
// Don't clear our messages here, tp-glib will send a
// 'pending-message-removed' for each one.
this._channel.ack_messages_async(this._pendingMessages, Lang.bind(this, function(src, result) {
this._channel.ack_messages_finish(result);}));
},
_summaryItemClicked: function(source, button) {
if (button != 1)
return;
this._shouldAck = true;
},
_notificationExpanded: function() {
this._shouldAck = true;
},
_notificationCollapsed: function() {
if (this._shouldAck)
this._ackMessages();
this._shouldAck = false;
}
};
function ChatNotification(source) {
function Notification(source) {
this._init(source);
}
ChatNotification.prototype = {
Notification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source) {
@ -618,7 +368,6 @@ ChatNotification.prototype = {
this._responseEntry = new St.Entry({ style_class: 'chat-response',
can_focus: true });
this._responseEntry.clutter_text.connect('activate', Lang.bind(this, this._onEntryActivated));
this._responseEntry.clutter_text.connect('text-changed', Lang.bind(this, this._onEntryChanged));
this.setActionArea(this._responseEntry);
this._oldMaxScrollAdjustment = 0;
@ -635,7 +384,6 @@ ChatNotification.prototype = {
this._history = [];
this._timestampTimeoutId = 0;
this._composingTimeoutId = 0;
},
/**
@ -663,43 +411,17 @@ ChatNotification.prototype = {
styles.push('chat-action');
}
if (message.direction == NotificationDirection.RECEIVED) {
this.update(this.source.title, messageBody, { customContent: true,
bannerMarkup: true });
}
this.update(this.source.title, messageBody, { customContent: true, bannerMarkup: true });
this._append(messageBody, styles, message.timestamp, noTimestamp);
},
_filterMessages: function() {
if (this._history.length < 1)
return;
let lastMessageTime = this._history[0].time;
let currentTime = (Date.now() / 1000);
// Keep the scrollback from growing too long. If the most
// recent message (before the one we just added) is within
// SCROLLBACK_RECENT_TIME, we will keep
// SCROLLBACK_RECENT_LENGTH previous messages. Otherwise
// we'll keep SCROLLBACK_IDLE_LENGTH messages.
let maxLength = (lastMessageTime < currentTime - SCROLLBACK_RECENT_TIME) ?
SCROLLBACK_IDLE_LENGTH : SCROLLBACK_RECENT_LENGTH;
let filteredHistory = this._history.filter(function(item) { return item.realMessage });
if (filteredHistory.length > maxLength) {
let lastMessageToKeep = filteredHistory[maxLength];
let expired = this._history.splice(this._history.indexOf(lastMessageToKeep));
for (let i = 0; i < expired.length; i++)
expired[i].actor.destroy();
}
},
_append: function(text, styles, timestamp, noTimestamp) {
let currentTime = (Date.now() / 1000);
if (!timestamp)
timestamp = currentTime;
let lastMessageTime = -1;
if (this._history.length > 0)
lastMessageTime = this._history[0].time;
// Reset the old message timeout
if (this._timestampTimeoutId)
@ -722,7 +444,23 @@ ChatNotification.prototype = {
Lang.bind(this, this.appendTimestamp));
}
this._filterMessages();
if (this._history.length > 1) {
// Keep the scrollback from growing too long. If the most
// recent message (before the one we just added) is within
// SCROLLBACK_RECENT_TIME, we will keep
// SCROLLBACK_RECENT_LENGTH previous messages. Otherwise
// we'll keep SCROLLBACK_IDLE_LENGTH messages.
let maxLength = (lastMessageTime < currentTime - SCROLLBACK_RECENT_TIME) ?
SCROLLBACK_IDLE_LENGTH : SCROLLBACK_RECENT_LENGTH;
let filteredHistory = this._history.filter(function(item) { return item.realMessage });
if (filteredHistory.length > maxLength) {
let lastMessageToKeep = filteredHistory[maxLength];
let expired = this._history.splice(this._history.indexOf(lastMessageToKeep));
for (let i = 0; i < expired.length; i++)
expired[i].actor.destroy();
}
}
},
_formatTimestamp: function(date) {
@ -764,9 +502,6 @@ ChatNotification.prototype = {
this._history.unshift({ actor: timeLabel, time: lastMessageTime, realMessage: false });
this._timestampTimeoutId = 0;
this._filterMessages();
return false;
},
@ -778,8 +513,6 @@ ChatNotification.prototype = {
let label = this.addBody(text, true);
label.add_style_class_name('chat-meta-message');
this._history.unshift({ actor: label, time: (Date.now() / 1000), realMessage: false});
this._filterMessages();
},
appendAliasChange: function(oldAlias, newAlias) {
@ -793,8 +526,6 @@ ChatNotification.prototype = {
label.add_style_class_name('chat-meta-message');
this._history.unshift({ actor: label, time: (Date.now() / 1000), realMessage: false });
this.update(newAlias, null, { customContent: true });
this._filterMessages();
},
_onEntryActivated: function() {
@ -808,166 +539,5 @@ ChatNotification.prototype = {
// see Source._messageSent
this._responseEntry.set_text('');
this.source.respond(text);
},
_composingStopTimeout: function() {
this._composingTimeoutId = 0;
this.source.setChatState(Tp.ChannelChatState.PAUSED);
return false;
},
_onEntryChanged: function() {
let text = this._responseEntry.get_text();
// If we're typing, we want to send COMPOSING.
// If we empty the entry, we want to send ACTIVE.
// If we've stopped typing for COMPOSING_STOP_TIMEOUT
// seconds, we want to send PAUSED.
// Remove composing timeout.
if (this._composingTimeoutId > 0) {
Mainloop.source_remove(this._composingTimeoutId);
this._composingTimeoutId = 0;
}
if (text != '') {
this.source.setChatState(Tp.ChannelChatState.COMPOSING);
this._composingTimeoutId = Mainloop.timeout_add_seconds(
COMPOSING_STOP_TIMEOUT,
Lang.bind(this, this._composingStopTimeout));
} else {
this.source.setChatState(Tp.ChannelChatState.ACTIVE);
}
}
};
function ApproverSource(dispatchOp, text, icon) {
this._init(dispatchOp, text, icon);
}
ApproverSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(dispatchOp, text, icon) {
MessageTray.Source.prototype._init.call(this, text);
this._icon = icon;
this._setSummaryIcon(this.createNotificationIcon());
this._dispatchOp = dispatchOp;
// Destroy the source if the channel dispatch operation is invalidated
// as we can't approve any more.
this._invalidId = dispatchOp.connect('invalidated',
Lang.bind(this, function(domain, code, msg) {
this.destroy();
}));
},
destroy: function() {
if (this._invalidId != 0) {
this._dispatchOp.disconnect(this._invalidId);
this._invalidId = 0;
}
MessageTray.Source.prototype.destroy.call(this);
},
createNotificationIcon: function() {
return new St.Icon({ icon_name: this._icon,
icon_type: St.IconType.FULLCOLOR,
icon_size: this.ICON_SIZE });
}
}
function RoomInviteNotification(source, dispatchOp, channel, inviter) {
this._init(source, dispatchOp, channel, inviter);
}
RoomInviteNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source, dispatchOp, channel, inviter) {
MessageTray.Notification.prototype._init.call(this,
source,
/* translators: argument is a room name like
* room@jabber.org for example. */
_("Invitation to %s").format(channel.get_identifier()),
null,
{ customContent: true });
this.setResident(true);
/* translators: first argument is the name of a contact and the second
* one the name of a room. "Alice is inviting you to join room@jabber.org
* for example. */
this.addBody(_("%s is inviting you to join %s").format(inviter.get_alias(), channel.get_identifier()));
this.addButton('decline', _("Decline"));
this.addButton('accept', _("Accept"));
this.connect('action-invoked', Lang.bind(this, function(self, action) {
switch (action) {
case 'decline':
dispatchOp.leave_channels_async(Tp.ChannelGroupChangeReason.NONE,
'', function(src, result) {
src.leave_channels_finish(result)});
break;
case 'accept':
dispatchOp.handle_with_time_async('', global.get_current_time(),
function(src, result) {
src.handle_with_time_finish(result)});
break;
}
this.destroy();
}));
}
};
// Audio Video
function AudioVideoNotification(source, dispatchOp, channel, contact, isVideo) {
this._init(source, dispatchOp, channel, contact, isVideo);
}
AudioVideoNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source, dispatchOp, channel, contact, isVideo) {
let title = '';
if (isVideo)
/* translators: argument is a contact name like Alice for example. */
title = _("Video call from %s").format(contact.get_alias());
else
/* translators: argument is a contact name like Alice for example. */
title = _("Call from %s").format(contact.get_alias());
MessageTray.Notification.prototype._init.call(this,
source,
title,
null,
{ customContent: true });
this.setResident(true);
this.addButton('reject', _("Reject"));
this.addButton('answer', _("Answer"));
this.connect('action-invoked', Lang.bind(this, function(self, action) {
switch (action) {
case 'reject':
dispatchOp.leave_channels_async(Tp.ChannelGroupChangeReason.NONE,
'', function(src, result) {
src.leave_channels_finish(result)});
break;
case 'answer':
dispatchOp.handle_with_time_async('', global.get_current_time(),
function(src, result) {
src.handle_with_time_finish(result)});
break;
}
this.destroy();
}));
}
};

View File

@ -141,19 +141,13 @@ SearchTab.prototype = {
'edit-find');
this._text.connect('text-changed', Lang.bind(this, this._onTextChanged));
this._text.connect('key-press-event', Lang.bind(this, function (o, e) {
// We can't connect to 'activate' here because search providers
// might want to do something with the modifiers in activateSelected.
let symbol = e.get_key_symbol();
if (symbol == Clutter.Return || symbol == Clutter.KP_Enter) {
if (this._searchTimeoutId > 0) {
Mainloop.source_remove(this._searchTimeoutId);
this._doSearch();
}
this._searchResults.activateSelected();
return true;
this._text.connect('activate', Lang.bind(this, function (se) {
if (this._searchTimeoutId > 0) {
Mainloop.source_remove(this._searchTimeoutId);
this._doSearch();
}
return false;
this._searchResults.activateSelected();
return true;
}));
this._entry.connect('notify::mapped', Lang.bind(this, this._onMapped));

View File

@ -6,7 +6,6 @@ const Gio = imports.gi.Gio;
const Lang = imports.lang;
const Meta = imports.gi.Meta;
const St = imports.gi.St;
const Shell = imports.gi.Shell;
const AltTab = imports.ui.altTab;
const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
@ -23,7 +22,8 @@ function getDimShader() {
if (dimShader === null)
return null;
if (!dimShader) {
let source = Shell.get_file_contents_utf8_sync(global.datadir + '/shaders/dim-window.glsl');
let [success, source, length] = GLib.file_get_contents(global.datadir +
'/shaders/dim-window.glsl');
try {
let shader = new Clutter.Shader();
shader.set_fragment_source(source, -1);
@ -119,8 +119,6 @@ WindowManager.prototype = {
this.setKeybindingHandler('switch_to_workspace_down', Lang.bind(this, this._showWorkspaceSwitcher));
this.setKeybindingHandler('switch_windows', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch_group', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch_windows_backward', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch_group_backward', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch_panels', Lang.bind(this, this._startA11ySwitcher));
Main.overview.connect('showing', Lang.bind(this, function() {
@ -182,7 +180,7 @@ WindowManager.prototype = {
*/
this._minimizing.push(actor);
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
let xDest = primary.x;
if (St.Widget.get_default_direction() == St.TextDirection.RTL)
xDest += primary.width;
@ -536,7 +534,7 @@ WindowManager.prototype = {
let tabPopup = new AltTab.AltTabPopup();
if (!tabPopup.show(backwards, binding))
if (!tabPopup.show(backwards, binding == 'switch_group'))
tabPopup.destroy();
},

View File

@ -1,7 +1,6 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Clutter = imports.gi.Clutter;
const GConf = imports.gi.GConf;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
@ -28,8 +27,6 @@ const CLOSE_BUTTON_FADE_TIME = 0.1;
const DRAGGING_WINDOW_OPACITY = 100;
const BUTTON_LAYOUT_KEY = '/desktop/gnome/shell/windows/button_layout';
// Define a layout scheme for small window counts. For larger
// counts we fall back to an algorithm. We need more schemes here
// unless we have a really good algorithm.
@ -225,12 +222,8 @@ WindowClone.prototype = {
let [width, height] = this.actor.get_transformed_size();
let monitorIndex = this.metaWindow.get_monitor();
let monitor = Main.layoutManager.monitors[monitorIndex];
let availArea = new Meta.Rectangle({ x: monitor.x,
y: monitor.y,
width: monitor.width,
height: monitor.height });
if (monitorIndex == Main.layoutManager.primaryIndex) {
let availArea = global.get_monitors()[monitorIndex];
if (monitorIndex == global.get_primary_monitor_index()) {
availArea.y += Main.panel.actor.height;
availArea.height -= Main.panel.actor.height;
}
@ -312,21 +305,6 @@ WindowClone.prototype = {
this.emit('drag-begin');
},
_getWorkspaceActor : function() {
let index = this.metaWindow.get_workspace().index();
return Main.overview.workspaces.getWorkspaceByIndex(index);
},
handleDragOver : function(source, actor, x, y, time) {
let workspace = this._getWorkspaceActor();
return workspace.handleDragOver(source, actor, x, y, time);
},
acceptDrop : function(source, actor, x, y, time) {
let workspace = this._getWorkspaceActor();
workspace.acceptDrop(source, actor, x, y, time);
},
_onDragCancelled : function (draggable, time) {
this.emit('drag-cancelled');
},
@ -457,20 +435,9 @@ WindowOverlay.prototype = {
let button = this.closeButton;
let title = this.title;
let gconf = GConf.Client.get_default();
let layout = gconf.get_string(BUTTON_LAYOUT_KEY);
let rtl = St.Widget.get_default_direction() == St.TextDirection.RTL;
let split = layout.split(":");
let side;
if (split[0].indexOf("close") > -1)
side = rtl ? St.Side.RIGHT : St.Side.LEFT;
else
side = rtl ? St.Side.LEFT : St.Side.RIGHT;
let buttonX;
let buttonY = cloneY - (button.height - button._overlap);
if (side == St.Side.LEFT)
if (St.Widget.get_default_direction() == St.TextDirection.RTL)
buttonX = cloneX - (button.width - button._overlap);
else
buttonX = cloneX + (cloneWidth - button._overlap);
@ -597,7 +564,7 @@ Workspace.prototype = {
this._height = 0;
this.monitorIndex = monitorIndex;
this._monitor = Main.layoutManager.monitors[this.monitorIndex];
this._monitor = global.get_monitors()[this.monitorIndex];
this._windowOverlaysGroup = new Clutter.Group();
// Without this the drop area will be overlapped.
this._windowOverlaysGroup.set_size(0, 0);
@ -652,7 +619,6 @@ Workspace.prototype = {
function () {
this._dropRect.set_position(x, y);
this._dropRect.set_size(width, height);
this.positionWindows(WindowPositionFlags.ANIMATE);
return false;
}));
@ -675,6 +641,16 @@ Workspace.prototype = {
return this._windows.length == 0;
},
/**
* setReactive:
* @reactive: %true iff the workspace should be reactive
*
* Set the workspace (desktop) reactive
**/
setReactive: function(reactive) {
this.actor.reactive = reactive;
},
// Only use this for n <= 20 say
_factorial: function(n) {
let result = 1;

View File

@ -56,7 +56,7 @@ WorkspaceSwitcherPopup.prototype = {
_getPreferredHeight : function (actor, forWidth, alloc) {
let children = this._list.get_children();
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
let availHeight = primary.height;
availHeight -= Main.panel.actor.height;
@ -82,7 +82,7 @@ WorkspaceSwitcherPopup.prototype = {
},
_getPreferredWidth : function (actor, forHeight, alloc) {
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
this._childWidth = Math.round(this._childHeight * primary.width / primary.height);
alloc.min_size = this._childWidth;
@ -125,7 +125,7 @@ WorkspaceSwitcherPopup.prototype = {
},
_position: function() {
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
this._container.x = primary.x + Math.floor((primary.width - this._container.width) / 2);
this._container.y = primary.y + Main.panel.actor.height +
Math.floor(((primary.height - Main.panel.actor.height) - this._container.height) / 2);

View File

@ -146,7 +146,7 @@ function WorkspaceThumbnail(metaWorkspace) {
WorkspaceThumbnail.prototype = {
_init : function(metaWorkspace) {
this.metaWorkspace = metaWorkspace;
this.monitorIndex = Main.layoutManager.primaryIndex;
this.monitorIndex = global.get_primary_monitor_index();
this.actor = new St.Group({ reactive: true,
clip_to_allocation: true,
@ -170,7 +170,7 @@ WorkspaceThumbnail.prototype = {
this._background = new Clutter.Clone({ source: global.background_actor });
this._contents.add_actor(this._background);
let monitor = Main.layoutManager.primaryMonitor;
let monitor = global.get_primary_monitor();
this.setPorthole(monitor.x, monitor.y, monitor.width, monitor.height);
let windows = global.get_window_actors().filter(this._isMyWindow, this);
@ -178,11 +178,6 @@ WorkspaceThumbnail.prototype = {
// Create clones for windows that should be visible in the Overview
this._windows = [];
for (let i = 0; i < windows.length; i++) {
windows[i].meta_window._minimizedChangedId =
windows[i].meta_window.connect('notify::minimized',
Lang.bind(this,
this._updateMinimized));
if (this._isOverviewWindow(windows[i])) {
this._addWindowClone(windows[i]);
}
@ -262,18 +257,11 @@ WorkspaceThumbnail.prototype = {
return;
// Check if window still should be here
if (win && this._isMyWindow(win) && this._isOverviewWindow(win))
if (win && this._isMyWindow(win))
return;
let clone = this._windows[index];
this._windows.splice(index, 1);
if (win && this._isOverviewWindow(win)) {
if (metaWin._minimizedChangedId) {
metaWin.disconnect(metaWin._minimizedChangedId);
delete metaWin._minimizedChangedId;
}
}
clone.destroy();
},
@ -302,11 +290,6 @@ WorkspaceThumbnail.prototype = {
if (this._lookupIndex (metaWin) != -1)
return;
if (!metaWin._minimizedChangedId)
metaWin._minimizedChangedId = metaWin.connect('notify::minimized',
Lang.bind(this,
this._updateMinimized));
if (!this._isMyWindow(win) || !this._isOverviewWindow(win))
return;
@ -333,13 +316,6 @@ WorkspaceThumbnail.prototype = {
}
},
_updateMinimized: function(metaWin) {
if (metaWin.minimized)
this._doRemoveWindow(metaWin);
else
this._doAddWindow(metaWin);
},
destroy : function() {
this.actor.destroy();
},
@ -350,14 +326,6 @@ WorkspaceThumbnail.prototype = {
global.screen.disconnect(this._windowEnteredMonitorId);
global.screen.disconnect(this._windowLeftMonitorId);
for (let i = 0; i < this._windows.length; i++) {
let metaWin = this._windows[i].metaWindow;
if (metaWin._minimizedChangedId) {
metaWin.disconnect(metaWin._minimizedChangedId);
delete metaWin._minimizedChangedId;
}
}
this._windows = [];
this.actor = null;
},
@ -371,8 +339,7 @@ WorkspaceThumbnail.prototype = {
// Tests if @win should be shown in the Overview
_isOverviewWindow : function (win) {
let tracker = Shell.WindowTracker.get_default();
return tracker.is_window_interesting(win.get_meta_window()) &&
win.get_meta_window().showing_on_its_workspace();
return tracker.is_window_interesting(win.get_meta_window());
},
// Create a clone of a (non-desktop) window and add it to the window list
@ -528,7 +495,7 @@ ThumbnailsBox.prototype = {
// The "porthole" is the portion of the screen that we show in the workspaces
let panelHeight = Main.panel.actor.height;
let monitor = Main.layoutManager.primaryMonitor;
let monitor = global.get_primary_monitor();
this._porthole = {
x: monitor.x,
y: monitor.y + panelHeight,

View File

@ -49,12 +49,9 @@ WorkspacesView.prototype = {
this._height = 0;
this._x = 0;
this._y = 0;
this._clipX = 0;
this._clipY = 0;
this._clipWidth = 0;
this._clipHeight = 0;
this._workspaceRatioSpacing = 0;
this._spacing = 0;
this._lostWorkspaces = [];
this._animating = false; // tweening
this._scrolling = false; // swipe-scrolling
this._animatingScroll = false; // programatically updating the adjustment
@ -70,10 +67,10 @@ WorkspacesView.prototype = {
this._workspaces[activeWorkspaceIndex].actor.raise_top();
this._extraWorkspaces = [];
let monitors = Main.layoutManager.monitors;
let monitors = global.get_monitors();
let m = 0;
for (let i = 0; i < monitors.length; i++) {
if (i == Main.layoutManager.primaryIndex)
if (i == global.get_primary_monitor_index())
continue;
let ws = new Workspace.Workspace(null, i);
this._extraWorkspaces[m++] = ws;
@ -96,8 +93,7 @@ WorkspacesView.prototype = {
this._overviewShownId =
Main.overview.connect('shown',
Lang.bind(this, function() {
this.actor.set_clip(this._clipX, this._clipY,
this._clipWidth, this._clipHeight);
this.actor.set_clip(this._x, this._y, this._width, this._height);
}));
this._scrollAdjustment = new St.Adjustment({ value: activeWorkspaceIndex,
@ -141,13 +137,6 @@ WorkspacesView.prototype = {
this._workspaces[i].setGeometry(x, y, width, height);
},
setClipRect: function(x, y, width, height) {
this._clipX = x;
this._clipY = y;
this._clipWidth = width;
this._clipHeight = height;
},
_lookupWorkspaceForMetaWindow: function (metaWindow) {
for (let i = 0; i < this._workspaces.length; i++) {
if (this._workspaces[i].containsMetaWindow(metaWindow))
@ -161,10 +150,6 @@ WorkspacesView.prototype = {
return this._workspaces[active];
},
getWorkspaceByIndex: function(index) {
return this._workspaces[index];
},
hide: function() {
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
let activeWorkspace = this._workspaces[activeWorkspaceIndex];
@ -239,6 +224,27 @@ WorkspacesView.prototype = {
this._updateVisibility();
}
}
for (let l = 0; l < this._lostWorkspaces.length; l++) {
let workspace = this._lostWorkspaces[l];
Tweener.removeTweens(workspace.actor);
workspace.actor.show();
workspace.hideWindowsOverlays();
if (showAnimation) {
Tweener.addTween(workspace.actor,
{ y: workspace.x,
time: WORKSPACE_SWITCH_TIME,
transition: 'easeOutQuad',
onComplete: Lang.bind(this,
this._cleanWorkspaces)
});
} else {
this._cleanWorkspaces();
}
}
},
_updateVisibility: function() {
@ -259,6 +265,17 @@ WorkspacesView.prototype = {
}
},
_cleanWorkspaces: function() {
if (this._lostWorkspaces.length == 0)
return;
for (let l = 0; l < this._lostWorkspaces.length; l++)
this._lostWorkspaces[l].destroy();
this._lostWorkspaces = [];
this._updateWorkspaceActors(false);
},
_updateScrollAdjustment: function(index, showAnimation) {
if (this._scrolling)
return;
@ -281,9 +298,12 @@ WorkspacesView.prototype = {
}
},
updateWorkspaces: function(oldNumWorkspaces, newNumWorkspaces) {
updateWorkspaces: function(oldNumWorkspaces, newNumWorkspaces, lostWorkspaces) {
let active = global.screen.get_active_workspace_index();
for (let l = 0; l < lostWorkspaces.length; l++)
lostWorkspaces[l].disconnectAll();
Tweener.addTween(this._scrollAdjustment,
{ upper: newNumWorkspaces,
time: WORKSPACE_SWITCH_TIME,
@ -291,13 +311,12 @@ WorkspacesView.prototype = {
});
if (newNumWorkspaces > oldNumWorkspaces) {
for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
this._workspaces[w].setGeometry(this._x, this._y,
this._width, this._height);
for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++)
this.actor.add_actor(this._workspaces[w].actor);
}
this._updateWorkspaceActors(false);
} else {
this._lostWorkspaces = lostWorkspaces;
}
this._scrollToActive(true);
@ -383,7 +402,7 @@ WorkspacesView.prototype = {
this._extraWorkspaces[i].setReservedSlot(dragEvent.dragActor._delegate);
}
let primary = Main.layoutManager.primaryMonitor;
let primary = global.get_primary_monitor();
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
let topWorkspace, bottomWorkspace;
@ -449,7 +468,7 @@ WorkspacesView.prototype = {
Mainloop.source_remove(this._timeoutId);
this._timeoutId = 0;
}
DND.removeDragMonitor(this._dragMonitor);
DND.removeMonitor(this._dragMonitor);
this._inDrag = false;
for (let i = 0; i < this._workspaces.length; i++)
@ -550,7 +569,8 @@ WorkspacesDisplay.prototype = {
controls.connect('scroll-event',
Lang.bind(this, this._onScrollEvent));
this._monitorIndex = Main.layoutManager.primaryIndex;
this._monitorIndex = global.get_primary_monitor_index();
this._monitor = global.get_monitors()[this._monitorIndex];
this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox();
controls.add_actor(this._thumbnailsBox.actor);
@ -566,10 +586,7 @@ WorkspacesDisplay.prototype = {
this._updateAlwaysZoom();
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._updateAlwaysZoom));
global.screen.connect('notify::n-workspaces',
Lang.bind(this, this._workspacesChanged));
global.screen.connect('monitors-changed', Lang.bind(this, this._updateAlwaysZoom));
Main.xdndHandler.connect('drag-begin', Lang.bind(this, function(){
this._alwaysZoomOut = true;
}));
@ -579,6 +596,7 @@ WorkspacesDisplay.prototype = {
this._updateAlwaysZoom();
}));
this._nWorkspacesNotifyId = 0;
this._switchWorkspaceNotifyId = 0;
this._itemDragBeginId = 0;
@ -608,6 +626,10 @@ WorkspacesDisplay.prototype = {
this.workspacesView = new WorkspacesView(this._workspaces);
this._updateWorkspacesGeometry();
this._nWorkspacesNotifyId =
global.screen.connect('notify::n-workspaces',
Lang.bind(this, this._workspacesChanged));
this._restackedNotifyId =
global.screen.connect('restacked',
Lang.bind(this, this._onRestacked));
@ -638,6 +660,10 @@ WorkspacesDisplay.prototype = {
this._controls.hide();
this._thumbnailsBox.hide();
if (this._nWorkspacesNotifyId > 0) {
global.screen.disconnect(this._nWorkspacesNotifyId);
this._nWorkspacesNotifyId = 0;
}
if (this._restackedNotifyId > 0){
global.screen.disconnect(this._restackedNotifyId);
this._restackedNotifyId = 0;
@ -686,15 +712,10 @@ WorkspacesDisplay.prototype = {
},
_updateAlwaysZoom: function() {
// Always show the pager if workspaces are actually used,
// e.g. there are windows on more than one
this._alwaysZoomOut = global.screen.n_workspaces > 2;
this._alwaysZoomOut = false;
if (this._alwaysZoomOut)
return;
let monitors = Main.layoutManager.monitors;
let primary = Main.layoutManager.primaryMonitor;
let monitors = global.get_monitors();
let primary = global.get_primary_monitor();
/* Look for any monitor to the right of the primary, if there is
* one, we always keep zoom out, otherwise its hard to reach
@ -762,13 +783,6 @@ WorkspacesDisplay.prototype = {
let rtl = (St.Widget.get_default_direction () == St.TextDirection.RTL);
let clipWidth = width - controlsVisible;
let clipHeight = (fullHeight / fullWidth) * clipWidth;
let clipX = rtl ? x + controlsVisible : x;
let clipY = y + (fullHeight - clipHeight) / 2;
this.workspacesView.setClipRect(clipX, clipY, clipWidth, clipHeight);
if (this._zoomOut) {
width -= controlsNatural;
if (rtl)
@ -807,12 +821,6 @@ WorkspacesDisplay.prototype = {
if (oldNumWorkspaces == newNumWorkspaces)
return;
this._updateAlwaysZoom();
this._updateZoom();
if (this.workspacesView == null)
return;
let lostWorkspaces = [];
if (newNumWorkspaces > oldNumWorkspaces) {
// Assume workspaces are only added at the end
@ -838,23 +846,24 @@ WorkspacesDisplay.prototype = {
lostWorkspaces = this._workspaces.splice(removedIndex,
removedNum);
for (let l = 0; l < lostWorkspaces.length; l++) {
lostWorkspaces[l].disconnectAll();
lostWorkspaces[l].destroy();
}
// Don't let the user try to select this workspace as it's
// making its exit.
for (let l = 0; l < lostWorkspaces.length; l++)
lostWorkspaces[l].setReactive(false);
this._thumbnailsBox.removeThumbmails(removedIndex, removedNum);
}
this.workspacesView.updateWorkspaces(oldNumWorkspaces,
newNumWorkspaces);
newNumWorkspaces,
lostWorkspaces);
},
_updateZoom : function() {
if (Main.overview.animationInProgress)
return;
let shouldZoom = this._alwaysZoomOut || this._controls.hover;
let shouldZoom = this._alwaysZoomOut || this._controls.hover || (this._inDrag && !this._cancelledDrag);
if (shouldZoom != this._zoomOut) {
this._zoomOut = shouldZoom;
this._updateWorkspacesGeometry();
@ -878,22 +887,12 @@ WorkspacesDisplay.prototype = {
_dragBegin: function() {
this._inDrag = true;
this._cancelledDrag = false;
this._dragMonitor = {
dragMotion: Lang.bind(this, this._onDragMotion)
};
DND.addDragMonitor(this._dragMonitor);
this._updateZoom();
},
_dragCancelled: function() {
this._cancelledDrag = true;
DND.removeDragMonitor(this._dragMonitor);
},
_onDragMotion: function(dragEvent) {
let controlsHovered = this._controls.contains(dragEvent.targetActor);
this._controls.set_hover(controlsHovered);
return DND.DragMotionResult.CONTINUE;
this._updateZoom();
},
_dragEnd: function() {

View File

@ -36,48 +36,53 @@ visually attractive and easy to use experience.
.SH OPTIONS
.TP
.B \-\-replace
Replace the running window manager
.B \-r, \-\-replace
Replace the running metacity/gnome-panel
.br
.TP
.B \-\-sm-disable
Disable connection to the session manager
.B \-v, \-\-verbose
Shows details about the results of running `gnome-shell'.
.br
.TP
.B \-\-sm-client-id=ID
Specify session management ID
.B \-g, \-\-debug
Run under a debugger
.br
.TP
.B \-\-sm-save-file=FILE
Initialize session from savefile
.br
.TP
.B \-\-screen=SCREEN
X screen to use
.br
.TP
.B \-d, \-\-display=DISPLAY
X display to use
.B \-\-debug\-command
Command to use for debugging (defaults to 'gdb \-\-args')
.br
.TP
.B \-\-sync
Make X calls synchronous
.br
Make X calls synchronously, useful when debugging down X errors
.br
.TP
.B \-\-version
Print version and exit
.B \-\-xephyr
Run a debugging instance inside Xephyr
.br
.TP
.B \-\-help
Display help and exit
.B \-\-geometry
Specify Xephyr screen geometry
.br
.TP
.B \-w, \-\-wide
Use widescreen (1280x800) with Xephyr
.br
.TP
.B \-\-create\-extension
Create a new GNOME Shell extension
.TP
.B \-\-eval\-file
Evaluate the contents of the given JavaScript file
.br
.SH BUGS

View File

@ -1,12 +1,10 @@
af
an
ar
be
bg
bn
bn_IN
ca
ca@valencia
cs
da
de
@ -48,7 +46,6 @@ sr
sr@latin
sv
ta
te
th
tr
ug

1217
po/be.po

File diff suppressed because it is too large Load Diff

553
po/ca.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

622
po/de.po

File diff suppressed because it is too large Load Diff

616
po/es.po

File diff suppressed because it is too large Load Diff

1248
po/ga.po

File diff suppressed because it is too large Load Diff

569
po/gl.po

File diff suppressed because it is too large Load Diff

577
po/he.po

File diff suppressed because it is too large Load Diff

619
po/it.po

File diff suppressed because it is too large Load Diff

609
po/lv.po

File diff suppressed because it is too large Load Diff

550
po/nb.po

File diff suppressed because it is too large Load Diff

662
po/pa.po

File diff suppressed because it is too large Load Diff

735
po/ru.po

File diff suppressed because it is too large Load Diff

586
po/sl.po

File diff suppressed because it is too large Load Diff

511
po/sv.po

File diff suppressed because it is too large Load Diff

1254
po/te.po

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@ msgstr ""
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-"
"shell&keywords=I18N+L10N&component=general\n"
"POT-Creation-Date: 2011-03-25 20:20+0000\n"
"PO-Revision-Date: 2011-05-22 21:50+0700\n"
"PO-Revision-Date: 2011-04-12 18:34+0700\n"
"Last-Translator: Duy <pclouds@gmail.com>\n"
"Language-Team: Vietnamese <vi-VN@googlegroups.com>\n"
"MIME-Version: 1.0\n"
@ -551,7 +551,7 @@ msgstr "Ứng dụng"
#. the left of the overview
#: ../js/ui/overview.js:205
msgid "Dash"
msgstr "Neo ứng dụng"
msgstr "Khung ứng dụng"
#. TODO - _quit() doesn't really work on apps in state STARTING yet
#: ../js/ui/panel.js:515

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,13 @@
service_in_files += calendar-server/org.gnome.Shell.CalendarServer.service.in
servicedir = $(datadir)/dbus-1/services
service_in_files = calendar-server/org.gnome.Shell.CalendarServer.service.in
service_DATA = $(service_in_files:.service.in=.service)
$(service_DATA): $(service_in_files) Makefile
$(AM_V_GEN) \
[ -d $(@D) ] || $(mkdir_p) $(@D) ; \
sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@.tmp && mv $@.tmp $@
CLEANFILES += $(service_DATA)
libexec_PROGRAMS += gnome-shell-calendar-server

View File

@ -1,24 +0,0 @@
service_in_files += hotplug-sniffer/org.gnome.Shell.HotplugSniffer.service.in
libexec_PROGRAMS += gnome-shell-hotplug-sniffer
gnome_shell_hotplug_sniffer_SOURCES = \
hotplug-sniffer/hotplug-mimetypes.h \
hotplug-sniffer/shell-mime-sniffer.h \
hotplug-sniffer/shell-mime-sniffer.c \
hotplug-sniffer/hotplug-sniffer.c \
$(NULL)
gnome_shell_hotplug_sniffer_CFLAGS = \
-I$(top_srcdir)/src \
-DG_DISABLE_DEPRECATED \
$(SHELL_HOTPLUG_SNIFFER_CFLAGS) \
$(NULL)
gnome_shell_hotplug_sniffer_LDFLAGS = \
$(SHELL_HOTPLUG_SNIFFER_LIBS) \
$(NULL)
EXTRA_DIST += \
hotplug-sniffer/org.gnome.Shell.HotplugSniffer.service.in \
$(NULL)

View File

@ -47,20 +47,20 @@ st-marshal.c: Makefile st/st-marshal.list
st-enum-types.h: stamp-st-enum-types.h Makefile
@true
stamp-st-enum-types.h: $(source_h) $(srcdir)/st/st-enum-types.h.in $(st_source_h)
$(AM_V_GEN) ( \
stamp-st-enum-types.h: $(source_h) st/st-enum-types.h.in $(st_source_h)
$(AM_V_GEN) ( cd $(srcdir) && \
$(GLIB_MKENUMS) \
--template $(srcdir)/st/st-enum-types.h.in \
$(addprefix $(srcdir)/, $(st_source_h)) ) >> $@.tmp && \
--template st/st-enum-types.h.in \
$(st_source_h) ) >> $@.tmp && \
(cmp -s $@.tmp st-enum-types.h || cp $@.tmp st-enum-types.h) && \
rm -f $@.tmp && \
echo timestamp > $(@F)
st-enum-types.c: stamp-st-enum-types.h $(srcdir)/st/st-enum-types.c.in
$(AM_V_GEN) ( \
st-enum-types.c: stamp-st-enum-types.h st/st-enum-types.c.in
$(AM_V_GEN) ( cd $(srcdir) && \
$(GLIB_MKENUMS) \
--template $(srcdir)/st/st-enum-types.c.in \
$(addprefix $(srcdir)/,$(st_source_h)) ) >> $@.tmp && \
--template st/st-enum-types.c.in \
$(st_source_h) ) >> $@.tmp && \
cp $@.tmp $@ && \
rm -f $@.tmp

View File

@ -6,7 +6,6 @@ bin_SCRIPTS =
libexec_PROGRAMS =
noinst_LTLIBRARIES =
noinst_PROGRAMS =
service_in_files =
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS =
@ -16,15 +15,6 @@ INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) --includedir=$(MUTTER_TYPEL
typelibdir = $(pkglibdir)
typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
servicedir = $(datadir)/dbus-1/services
service_DATA = $(service_in_files:.service.in=.service)
$(service_DATA): $(service_in_files) Makefile
$(AM_V_GEN) \
[ -d $(@D) ] || $(mkdir_p) $(@D) ; \
sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@.tmp && mv $@.tmp $@
CLEANFILES += $(service_DATA)
CLEANFILES += $(gir_DATA) $(typelib_DATA)
bin_SCRIPTS += gnome-shell-extension-tool
@ -72,7 +62,6 @@ include Makefile-st.am
include Makefile-tray.am
include Makefile-gvc.am
include Makefile-calendar-server.am
include Makefile-hotplug-sniffer.am
gnome_shell_cflags = \
$(GNOME_SHELL_CFLAGS) \
@ -108,7 +97,6 @@ shell_public_headers_h = \
shell-gtk-embed.h \
shell-global.h \
shell-mobile-providers.h \
shell-mount-operation.h \
shell-perf-log.h \
shell-slicer.h \
shell-stack.h \
@ -142,7 +130,6 @@ libgnome_shell_la_SOURCES = \
shell-gtk-embed.c \
shell-global.c \
shell-mobile-providers.c \
shell-mount-operation.c \
shell-perf-log.c \
shell-polkit-authentication-agent.h \
shell-polkit-authentication-agent.c \
@ -235,21 +222,21 @@ shell-marshal.c: Makefile shell-marshal.list
shell-enum-types.h: stamp-shell-enum-types.h Makefile
@true
stamp-shell-enum-types.h: $(srcdir)/shell-enum-types.h.in $(shell_public_headers_h)
$(AM_V_GEN) ( \
$(AM_V_GEN) ( cd $(srcdir) && \
$(GLIB_MKENUMS) \
--template $< \
$(addprefix $(srcdir)/,$(shell_public_headers_h)) ) > $(@F).tmp && \
$(shell_public_headers_h) ) > $(@F).tmp && \
(cmp -s $(@F).tmp shell-enum-types.h || mv $(@F).tmp shell-enum-types.h) && \
rm -f $(@F).tmp && \
echo timestamp > $(@F)
EXTRA_DIST += shell-enum-types.h.in
CLEANFILES += stamp-shell-enum-types.h
shell-enum-types.c: $(srcdir)/shell-enum-types.c.in stamp-shell-enum-types.h
$(AM_V_GEN) ( \
shell-enum-types.c: shell-enum-types.c.in stamp-shell-enum-types.h
$(AM_V_GEN) ( cd $(srcdir) && \
$(GLIB_MKENUMS) \
--template $< \
$(addprefix $(srcdir)/,$(shell_public_headers_h)) ) > $(@F).tmp && \
$(shell_public_headers_h) ) > $(@F).tmp && \
mv $(@F).tmp $(@F) && \
rm -f $(@F).tmp
EXTRA_DIST += shell-enum-types.c.in
@ -268,10 +255,10 @@ libgnome_shell_la_LIBADD = \
libgnome_shell_la_CPPFLAGS = $(gnome_shell_cflags)
Shell-0.1.gir: libgnome-shell.la St-1.0.gir
Shell_0_1_gir_INCLUDES = Clutter-1.0 ClutterX11-1.0 Meta-3.0 TelepathyGLib-0.12 TelepathyLogger-0.2 Soup-2.4
Shell_0_1_gir_INCLUDES = Clutter-1.0 ClutterX11-1.0 Meta-3.0 TelepathyGLib-0.12 TelepathyLogger-0.2
Shell_0_1_gir_CFLAGS = $(libgnome_shell_la_CPPFLAGS) -I $(srcdir)
Shell_0_1_gir_LIBS = libgnome-shell.la
Shell_0_1_gir_FILES = $(libgnome_shell_la_gir_sources)
Shell_0_1_gir_FILES = $(addprefix $(srcdir)/,$(libgnome_shell_la_gir_sources))
Shell_0_1_gir_SCANNERFLAGS = --include-uninstalled=$(builddir)/St-1.0.gir \
--add-include-path=$(MUTTER_GIR_DIR)
INTROSPECTION_GIRS += Shell-0.1.gir

View File

@ -777,10 +777,7 @@ remove_user (GdmUserManager *manager,
if (gdm_user_get_object_path (user) != NULL) {
g_hash_table_remove (manager->priv->users_by_object_path, gdm_user_get_object_path (user));
}
if (gdm_user_get_user_name (user) != NULL) {
g_hash_table_remove (manager->priv->users_by_name, gdm_user_get_user_name (user));
}
g_hash_table_remove (manager->priv->users_by_name, gdm_user_get_user_name (user));
if (manager->priv->is_loaded) {
g_signal_emit (manager, signals[USER_REMOVED], 0, user);
@ -887,13 +884,6 @@ on_user_removed_in_accounts_service (DBusGProxy *proxy,
user = g_hash_table_lookup (manager->priv->users_by_object_path, object_path);
if (user == NULL) {
g_debug ("GdmUserManager: ignoring untracked user %s", object_path);
return;
} else {
g_debug ("GdmUserManager: tracked user %s removed from accounts service", object_path);
}
manager->priv->new_users = g_slist_remove (manager->priv->new_users, user);
remove_user (manager, user);

View File

@ -3,7 +3,6 @@
import os
import re
import socket
import subprocess
import sys
import optparse
@ -27,69 +26,6 @@ if args:
parser.print_usage()
sys.exit(1)
SAMPLE_EXTENSION_FILES = {
"extension.js": """
const St = imports.gi.St;
const Main = imports.ui.main;
const Tweener = imports.ui.tweener;
let text;
function _hideHello() {
Main.uiGroup.remove_actor(text);
text = null;
}
function _showHello() {
if (!text) {
text = new St.Label({ style_class: 'helloworld-label', text: "Hello, world!" });
Main.uiGroup.add_actor(text);
}
text.opacity = 255;
let monitor = Main.layoutManager.primaryMonitor;
text.set_position(Math.floor(monitor.width / 2 - text.width / 2),
Math.floor(monitor.height / 2 - text.height / 2));
Tweener.addTween(text,
{ opacity: 0,
time: 2,
transition: 'easeOutQuad',
onComplete: _hideHello });
}
function main() {
let button = new St.Bin({ style_class: 'panel-button',
reactive: true,
can_focus: true,
x_fill: true,
y_fill: false,
track_hover: true });
let icon = new St.Icon({ icon_name: 'system-run',
icon_type: St.IconType.SYMBOLIC,
style_class: 'system-status-icon' });
button.set_child(icon);
button.connect('button-press-event', _showHello);
Main.panel._rightBox.insert_actor(button, 0);
}
""",
"stylesheet.css": """
.helloworld-label {
font-size: 36px;
font-weight: bold;
color: #ffffff;
background-color: rgba(10,10,10,0.7);
border-radius: 5px;
padding: .5em;
}
""",
}
if options.create_extension:
print
print '''Name should be a very short (ideally descriptive) string.
@ -105,7 +41,7 @@ Examples are: "Make windows visible on click", "Block advertisement popups"
underifier = re.compile('[^A-Za-z]')
sample_uuid = underifier.sub('_', name)
# TODO use evolution data server
hostname = socket.gethostname()
hostname = subprocess.Popen(['hostname'], stdout=subprocess.PIPE).communicate()[0].strip()
sample_uuid = sample_uuid + '@' + hostname
print
@ -135,11 +71,41 @@ use an extension title clicktofocus@janedoe.example.com.'''
f.write(json.write(meta) + '\n')
f.close()
for filename, contents in SAMPLE_EXTENSION_FILES.iteritems():
path = os.path.join(extension_path, filename)
f = open(path, 'w')
f.write(contents)
f.close()
extensionjs_path = os.path.join(extension_path, 'extension.js')
f = open(extensionjs_path, 'w')
f.write('''// Sample extension code, makes clicking on the panel show a message
const St = imports.gi.St;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
function _showHello() {
let text = new St.Label({ style_class: 'helloworld-label', text: "Hello, world!" });
let monitor = global.get_primary_monitor();
global.stage.add_actor(text);
text.set_position(Math.floor (monitor.width / 2 - text.width / 2), Math.floor(monitor.height / 2 - text.height / 2));
Mainloop.timeout_add(3000, function () { text.destroy(); });
}
// Put your extension initialization code here
function main() {
Main.panel.actor.reactive = true;
Main.panel.actor.connect('button-release-event', _showHello);
}
''')
f.close()
f = open(os.path.join(extension_path, 'stylesheet.css'), 'w')
f.write('''/* Example stylesheet */
.helloworld-label {
font-size: 36px;
font-weight: bold;
color: #ffffff;
background-color: rgba(10,10,10,0.7);
border-radius: 5px;
}
''')
f.close()
print "Created extension in %r" % (extension_path, )
subprocess.Popen(['gnome-open', extensionjs_path])

View File

@ -532,7 +532,7 @@ def restore_gnome():
component = client.get_string(gconf_path)
if component == None or component == "":
return False
return
# See gnome-session/gsm-util.c:gsm_util_find_desktop_file_for_app_name()
# The one difference is that we don't search the autostart directories,
@ -549,15 +549,9 @@ def restore_gnome():
if appinfo:
appinfo.launch()
return True
return False
# GNOME2 fallback
wm = launch_component("/desktop/gnome/session/required_components/windowmanager")
panel = launch_component("/desktop/gnome/session/required_components/panel")
if not wm and not panel: # Probably GNOME3
subprocess.Popen(['gnome-shell'])
launch_component("/desktop/gnome/session/required_components/windowmanager")
launch_component("/desktop/gnome/session/required_components/panel")
# Main program

View File

@ -1,139 +0,0 @@
#ifndef __HOTPLUG_MIMETYPES_H__
#define __HOTPLUG_MIMETYPES_H__
#include <glib.h>
G_GNUC_UNUSED static const gchar *docs_mimetypes[] = {
"application/vnd.oasis.opendocument.text",
"application/vnd.oasis.opendocument.presentation",
"application/vnd.oasis.opendocument.spreadsheet",
"application/msword",
"application/vnd.ms-excel",
"application/vnd.ms-powerpoint",
"application/rtf",
"application/pdf",
"application/x-bzpdf",
"application/x-gzpdf",
"application/x-xzpdf",
"application/postscript",
"application/x-bzpostscript",
"application/x-gzpostscript",
"image/x-eps",
"image/x-bzeps",
"image/x-gzeps",
"application/x-dvi",
"application/x-bzdvi",
"application/x-gzdvi",
"image/vnd.djvu",
"application/x-cbr",
"application/x-cbz",
"application/x-cb7",
"application/x-cbt",
NULL
};
G_GNUC_UNUSED static const gchar *video_mimetypes[] = {
"application/mxf",
"application/ogg",
"application/ram",
"application/sdp",
"application/vnd.ms-wpl",
"application/vnd.rn-realmedia",
"application/x-extension-m4a",
"application/x-extension-mp4",
"application/x-flash-video",
"application/x-matroska",
"application/x-netshow-channel",
"application/x-ogg",
"application/x-quicktimeplayer",
"application/x-shorten",
"image/vnd.rn-realpix",
"image/x-pict",
"misc/ultravox",
"text/x-google-video-pointer",
"video/3gpp",
"video/dv",
"video/fli",
"video/flv",
"video/mp2t",
"video/mp4",
"video/mp4v-es",
"video/mpeg",
"video/msvideo",
"video/ogg",
"video/quicktime",
"video/vivo",
"video/vnd.divx",
"video/vnd.rn-realvideo",
"video/vnd.vivo",
"video/webm",
"video/x-anim",
"video/x-avi",
"video/x-flc",
"video/x-fli",
"video/x-flic",
"video/x-flv",
"video/x-m4v",
"video/x-matroska",
"video/x-mpeg",
"video/x-ms-asf",
"video/x-ms-asx",
"video/x-msvideo",
"video/x-ms-wm",
"video/x-ms-wmv",
"video/x-ms-wmx",
"video/x-ms-wvx",
"video/x-nsv",
"video/x-ogm+ogg",
"video/x-theora+ogg",
"video/x-totem-stream",
NULL
};
G_GNUC_UNUSED static const gchar *audio_mimetypes[] = {
"audio/3gpp",
"audio/ac3",
"audio/AMR",
"audio/AMR-WB",
"audio/basic",
"audio/flac",
"audio/midi",
"audio/mp2",
"audio/mp4",
"audio/mpeg",
"audio/ogg",
"audio/prs.sid",
"audio/vnd.rn-realaudio",
"audio/x-aiff",
"audio/x-ape",
"audio/x-flac",
"audio/x-gsm",
"audio/x-it",
"audio/x-m4a",
"audio/x-matroska",
"audio/x-mod",
"audio/x-mp3",
"audio/x-mpeg",
"audio/x-ms-asf",
"audio/x-ms-asx",
"audio/x-ms-wax",
"audio/x-ms-wma",
"audio/x-musepack",
"audio/x-pn-aiff",
"audio/x-pn-au",
"audio/x-pn-wav",
"audio/x-pn-windows-acm",
"audio/x-realaudio",
"audio/x-real-audio",
"audio/x-sbc",
"audio/x-speex",
"audio/x-tta",
"audio/x-wav",
"audio/x-wavpack",
"audio/x-vorbis",
"audio/x-vorbis+ogg",
"audio/x-xm",
NULL
};
#endif /* __HOTPLUG_MIMETYPES_H__ */

View File

@ -1,319 +0,0 @@
/*
* Copyright (C) 2011 Red Hat, Inc.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Authors: David Zeuthen <davidz@redhat.com>
* Cosimo Cecchi <cosimoc@redhat.com>
*
*/
#include "shell-mime-sniffer.h"
#include "hotplug-mimetypes.h"
/* Set the environment variable HOTPLUG_SNIFFER_DEBUG to show debug */
static void print_debug (const gchar *str, ...);
#define BUS_NAME "org.gnome.Shell.HotplugSniffer"
#define AUTOQUIT_TIMEOUT 5
static const gchar introspection_xml[] =
"<node>"
" <interface name='org.gnome.Shell.HotplugSniffer'>"
" <method name='SniffURI'>"
" <arg type='s' name='uri' direction='in'/>"
" <arg type='as' name='content_types' direction='out'/>"
" </method>"
" </interface>"
"</node>";
static GDBusNodeInfo *introspection_data = NULL;
static GMainLoop *loop = NULL;
static guint autoquit_id = 0;
static gboolean
autoquit_timeout_cb (gpointer _unused)
{
print_debug ("Timeout reached, quitting...");
autoquit_id = 0;
g_main_loop_quit (loop);
return FALSE;
}
static void
ensure_autoquit_off (void)
{
if (g_getenv ("HOTPLUG_SNIFFER_PERSIST") != NULL)
return;
if (autoquit_id != 0)
{
g_source_remove (autoquit_id);
autoquit_id = 0;
}
}
static void
ensure_autoquit_on (void)
{
if (g_getenv ("HOTPLUG_SNIFFER_PERSIST") != NULL)
return;
autoquit_id =
g_timeout_add_seconds (AUTOQUIT_TIMEOUT,
autoquit_timeout_cb, NULL);
}
typedef struct {
GVariant *parameters;
GDBusMethodInvocation *invocation;
} InvocationData;
static InvocationData *
invocation_data_new (GVariant *params,
GDBusMethodInvocation *invocation)
{
InvocationData *ret;
ret = g_slice_new0 (InvocationData);
ret->parameters = g_variant_ref (params);
ret->invocation = g_object_ref (invocation);
return ret;
}
static void
invocation_data_free (InvocationData *data)
{
g_variant_unref (data->parameters);
g_clear_object (&data->invocation);
g_slice_free (InvocationData, data);
}
static void
sniff_async_ready_cb (GObject *source,
GAsyncResult *res,
gpointer user_data)
{
InvocationData *data = user_data;
gchar **types;
gint idx;
GError *error = NULL;
GVariantBuilder *builder;
GVariant *result;
types = shell_mime_sniffer_sniff_finish (SHELL_MIME_SNIFFER (source),
res, &error);
if (error != NULL)
{
g_dbus_method_invocation_return_gerror (data->invocation, error);
g_error_free (error);
goto out;
}
builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
for (idx = 0; types[idx] != NULL; idx++)
g_variant_builder_add (builder, "s", types[idx]);
result = g_variant_new ("(as)", builder);
g_dbus_method_invocation_return_value (data->invocation, result);
g_variant_unref (result);
g_variant_builder_unref (builder);
g_strfreev (types);
out:
invocation_data_free (data);
ensure_autoquit_on ();
}
static void
handle_sniff_uri (InvocationData *data)
{
ShellMimeSniffer *sniffer;
const gchar *uri;
GFile *file;
ensure_autoquit_off ();
g_variant_get (data->parameters,
"(&s)", &uri,
NULL);
file = g_file_new_for_uri (uri);
print_debug ("Initiating sniff for uri %s", uri);
sniffer = shell_mime_sniffer_new (file);
shell_mime_sniffer_sniff_async (sniffer,
sniff_async_ready_cb,
data);
g_object_unref (sniffer);
g_object_unref (file);
}
static void
handle_method_call (GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
const gchar *interface_name,
const gchar *method_name,
GVariant *parameters,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
InvocationData *data;
data = invocation_data_new (parameters, invocation);
if (g_strcmp0 (method_name, "SniffURI") == 0)
handle_sniff_uri (data);
else
g_assert_not_reached ();
}
static const GDBusInterfaceVTable interface_vtable =
{
handle_method_call,
NULL, /* get_property */
NULL, /* set_property */
};
static void
on_bus_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
GError *error = NULL;
print_debug ("Connected to the session bus: %s", name);
g_dbus_connection_register_object (connection,
"/org/gnome/Shell/HotplugSniffer",
introspection_data->interfaces[0],
&interface_vtable,
NULL,
NULL,
&error);
if (error != NULL)
{
g_printerr ("Error exporting object on the session bus: %s",
error->message);
g_error_free (error);
_exit(1);
}
print_debug ("Object exported on the session bus");
}
static void
on_name_lost (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
print_debug ("Lost bus name: %s, exiting", name);
g_main_loop_quit (loop);
}
static void
on_name_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
print_debug ("Acquired bus name: %s", name);
}
int
main (int argc,
char **argv)
{
guint name_owner_id;
g_type_init ();
introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
g_assert (introspection_data != NULL);
ensure_autoquit_on ();
loop = g_main_loop_new (NULL, FALSE);
name_owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
BUS_NAME, 0,
on_bus_acquired,
on_name_acquired,
on_name_lost,
NULL,
NULL);
g_main_loop_run (loop);
if (name_owner_id != 0)
g_bus_unown_name (name_owner_id);
if (loop != NULL)
g_main_loop_unref (loop);
return 0;
}
/* ---------------------------------------------------------------------------------------------------- */
static void
print_debug (const gchar *format, ...)
{
gchar *s;
va_list ap;
gchar timebuf[64];
GTimeVal now;
time_t now_t;
struct tm broken_down;
static volatile gsize once_init_value = 0;
static gboolean show_debug = FALSE;
static guint pid = 0;
if (g_once_init_enter (&once_init_value))
{
show_debug = (g_getenv ("HOTPLUG_SNIFFER_DEBUG") != NULL);
pid = getpid ();
g_once_init_leave (&once_init_value, 1);
}
if (!show_debug)
goto out;
g_get_current_time (&now);
now_t = now.tv_sec;
localtime_r (&now_t, &broken_down);
strftime (timebuf, sizeof timebuf, "%H:%M:%S", &broken_down);
va_start (ap, format);
s = g_strdup_vprintf (format, ap);
va_end (ap);
g_print ("gnome-shell-hotplug-sniffer[%d]: %s.%03d: %s\n", pid, timebuf, (gint) (now.tv_usec / 1000), s);
g_free (s);
out:
;
}

View File

@ -1,3 +0,0 @@
[D-BUS Service]
Name=org.gnome.Shell.HotplugSniffer
Exec=@libexecdir@/gnome-shell-hotplug-sniffer

View File

@ -1,607 +0,0 @@
/*
* Copyright (C) 1999, 2000, 2001 Eazel, Inc.
* Copyright (C) 2011 Red Hat, Inc.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Author: Cosimo Cecchi <cosimoc@redhat.com>
*
* The code for crawling the directory hierarchy is based on
* nautilus/libnautilus-private/nautilus-directory-async.c, with
* the following copyright and author:
*
* Copyright (C) 1999, 2000, 2001 Eazel, Inc.
* Author: Darin Adler <darin@bentspoon.com>
*
*/
#include "shell-mime-sniffer.h"
#include "hotplug-mimetypes.h"
#include <glib/gi18n.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#define LOADER_ATTRS \
G_FILE_ATTRIBUTE_STANDARD_TYPE "," \
G_FILE_ATTRIBUTE_STANDARD_NAME "," \
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
#define WATCHDOG_TIMEOUT 1500
#define DIRECTORY_LOAD_ITEMS_PER_CALLBACK 100
#define HIGH_SCORE_RATIO 0.10
G_DEFINE_TYPE (ShellMimeSniffer, shell_mime_sniffer, G_TYPE_OBJECT);
enum {
PROP_FILE = 1,
NUM_PROPERTIES
};
static GHashTable *image_type_table = NULL;
static GHashTable *audio_type_table = NULL;
static GHashTable *video_type_table = NULL;
static GHashTable *docs_type_table = NULL;
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
typedef struct {
ShellMimeSniffer *self;
GFile *file;
GFileEnumerator *enumerator;
GList *deep_count_subdirectories;
gint audio_count;
gint image_count;
gint document_count;
gint video_count;
gint total_items;
} DeepCountState;
struct _ShellMimeSnifferPrivate {
GFile *file;
GCancellable *cancellable;
guint watchdog_id;
GSimpleAsyncResult *async_result;
gchar **sniffed_mime;
};
static void deep_count_load (DeepCountState *state,
GFile *file);
static void
init_mimetypes (void)
{
static gsize once_init = 0;
if (g_once_init_enter (&once_init))
{
GSList *formats, *l;
GdkPixbufFormat *format;
gchar **types;
gint idx;
image_type_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
video_type_table = g_hash_table_new (g_str_hash, g_str_equal);
audio_type_table = g_hash_table_new (g_str_hash, g_str_equal);
docs_type_table = g_hash_table_new (g_str_hash, g_str_equal);
formats = gdk_pixbuf_get_formats ();
for (l = formats; l != NULL; l = l->next)
{
format = l->data;
types = gdk_pixbuf_format_get_mime_types (format);
for (idx = 0; types[idx] != NULL; idx++)
g_hash_table_insert (image_type_table, g_strdup (types[idx]), GINT_TO_POINTER (1));
g_strfreev (types);
}
g_slist_free (formats);
for (idx = 0; audio_mimetypes[idx] != NULL; idx++)
g_hash_table_insert (audio_type_table, (gpointer) audio_mimetypes[idx], GINT_TO_POINTER (1));
for (idx = 0; video_mimetypes[idx] != NULL; idx++)
g_hash_table_insert (video_type_table, (gpointer) video_mimetypes[idx], GINT_TO_POINTER (1));
for (idx = 0; docs_mimetypes[idx] != NULL; idx++)
g_hash_table_insert (docs_type_table, (gpointer) docs_mimetypes[idx], GINT_TO_POINTER (1));
g_once_init_leave (&once_init, 1);
}
}
static void
add_content_type_to_cache (DeepCountState *state,
const gchar *content_type)
{
gboolean matched = TRUE;
if (g_hash_table_lookup (image_type_table, content_type))
state->image_count++;
else if (g_hash_table_lookup (video_type_table, content_type))
state->video_count++;
else if (g_hash_table_lookup (docs_type_table, content_type))
state->document_count++;
else if (g_hash_table_lookup (audio_type_table, content_type))
state->audio_count++;
else
matched = FALSE;
if (matched)
state->total_items++;
}
typedef struct {
const gchar *type;
gdouble ratio;
} SniffedResult;
static gint
results_cmp_func (gconstpointer a,
gconstpointer b)
{
const SniffedResult *sniffed_a = a;
const SniffedResult *sniffed_b = b;
if (sniffed_a->ratio < sniffed_b->ratio)
return 1;
if (sniffed_a->ratio > sniffed_b->ratio)
return -1;
return 0;
}
static void
prepare_async_result (DeepCountState *state)
{
ShellMimeSniffer *self = state->self;
GArray *results;
GPtrArray *sniffed_mime;
SniffedResult result;
sniffed_mime = g_ptr_array_new ();
results = g_array_new (TRUE, TRUE, sizeof (SniffedResult));
if (state->total_items == 0)
goto out;
result.type = "x-content/video";
result.ratio = (gdouble) state->video_count / (gdouble) state->total_items;
g_array_append_val (results, result);
result.type = "x-content/audio";
result.ratio = (gdouble) state->audio_count / (gdouble) state->total_items;
g_array_append_val (results, result);
result.type = "x-content/pictures";
result.ratio = (gdouble) state->image_count / (gdouble) state->total_items;
g_array_append_val (results, result);
result.type = "x-content/documents";
result.ratio = (gdouble) state->document_count / (gdouble) state->total_items;
g_array_append_val (results, result);
g_array_sort (results, results_cmp_func);
result = g_array_index (results, SniffedResult, 0);
g_ptr_array_add (sniffed_mime, g_strdup (result.type));
/* if other types score high in ratio, add them, up to three */
result = g_array_index (results, SniffedResult, 1);
if (result.ratio < HIGH_SCORE_RATIO)
goto out;
g_ptr_array_add (sniffed_mime, g_strdup (result.type));
result = g_array_index (results, SniffedResult, 2);
if (result.ratio < HIGH_SCORE_RATIO)
goto out;
g_ptr_array_add (sniffed_mime, g_strdup (result.type));
out:
g_ptr_array_add (sniffed_mime, NULL);
self->priv->sniffed_mime = (gchar **) g_ptr_array_free (sniffed_mime, FALSE);
g_array_free (results, TRUE);
g_simple_async_result_complete_in_idle (self->priv->async_result);
}
/* adapted from nautilus/libnautilus-private/nautilus-directory-async.c */
static void
deep_count_one (DeepCountState *state,
GFileInfo *info)
{
GFile *subdir;
const char *content_type;
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
{
/* record the fact that we have to descend into this directory */
subdir = g_file_get_child (state->file, g_file_info_get_name (info));
state->deep_count_subdirectories =
g_list_append (state->deep_count_subdirectories, subdir);
}
else
{
content_type = g_file_info_get_content_type (info);
add_content_type_to_cache (state, content_type);
}
}
static void
deep_count_finish (DeepCountState *state)
{
prepare_async_result (state);
if (state->enumerator)
{
if (!g_file_enumerator_is_closed (state->enumerator))
g_file_enumerator_close_async (state->enumerator,
0, NULL, NULL, NULL);
g_object_unref (state->enumerator);
}
g_cancellable_reset (state->self->priv->cancellable);
g_clear_object (&state->file);
g_list_free_full (state->deep_count_subdirectories, g_object_unref);
g_free (state);
}
static void
deep_count_next_dir (DeepCountState *state)
{
GFile *new_file;
g_clear_object (&state->file);
if (state->deep_count_subdirectories != NULL)
{
/* Work on a new directory. */
new_file = state->deep_count_subdirectories->data;
state->deep_count_subdirectories =
g_list_remove (state->deep_count_subdirectories, new_file);
deep_count_load (state, new_file);
g_object_unref (new_file);
}
else
{
deep_count_finish (state);
}
}
static void
deep_count_more_files_callback (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
DeepCountState *state;
GList *files, *l;
GFileInfo *info;
state = user_data;
if (g_cancellable_is_cancelled (state->self->priv->cancellable))
{
deep_count_finish (state);
return;
}
files = g_file_enumerator_next_files_finish (state->enumerator,
res, NULL);
for (l = files; l != NULL; l = l->next)
{
info = l->data;
deep_count_one (state, info);
g_object_unref (info);
}
if (files == NULL)
{
g_file_enumerator_close_async (state->enumerator, 0, NULL, NULL, NULL);
g_object_unref (state->enumerator);
state->enumerator = NULL;
deep_count_next_dir (state);
}
else
{
g_file_enumerator_next_files_async (state->enumerator,
DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
G_PRIORITY_LOW,
state->self->priv->cancellable,
deep_count_more_files_callback,
state);
}
g_list_free (files);
}
static void
deep_count_callback (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
DeepCountState *state;
GFileEnumerator *enumerator;
state = user_data;
if (g_cancellable_is_cancelled (state->self->priv->cancellable))
{
deep_count_finish (state);
return;
}
enumerator = g_file_enumerate_children_finish (G_FILE (source_object),
res, NULL);
if (enumerator == NULL)
{
deep_count_next_dir (state);
}
else
{
state->enumerator = enumerator;
g_file_enumerator_next_files_async (state->enumerator,
DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
G_PRIORITY_LOW,
state->self->priv->cancellable,
deep_count_more_files_callback,
state);
}
}
static void
deep_count_load (DeepCountState *state,
GFile *file)
{
state->file = g_object_ref (file);
g_file_enumerate_children_async (state->file,
LOADER_ATTRS,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, /* flags */
G_PRIORITY_LOW, /* prio */
state->self->priv->cancellable,
deep_count_callback,
state);
}
static void
deep_count_start (ShellMimeSniffer *self)
{
DeepCountState *state;
state = g_new0 (DeepCountState, 1);
state->self = self;
deep_count_load (state, self->priv->file);
}
static void
query_info_async_ready_cb (GObject *source,
GAsyncResult *res,
gpointer user_data)
{
GFileInfo *info;
GError *error = NULL;
ShellMimeSniffer *self = user_data;
info = g_file_query_info_finish (G_FILE (source),
res, &error);
if (error != NULL)
{
g_simple_async_result_take_error (self->priv->async_result,
error);
g_simple_async_result_complete_in_idle (self->priv->async_result);
return;
}
if (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY)
{
g_simple_async_result_set_error (self->priv->async_result,
G_IO_ERROR,
G_IO_ERROR_NOT_DIRECTORY,
"Not a directory");
g_simple_async_result_complete_in_idle (self->priv->async_result);
return;
}
deep_count_start (self);
}
static gboolean
watchdog_timeout_reached_cb (gpointer user_data)
{
ShellMimeSniffer *self = user_data;
self->priv->watchdog_id = 0;
g_cancellable_cancel (self->priv->cancellable);
return FALSE;
}
static void
start_loading_file (ShellMimeSniffer *self)
{
g_file_query_info_async (self->priv->file,
LOADER_ATTRS,
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
self->priv->cancellable,
query_info_async_ready_cb,
self);
}
static void
shell_mime_sniffer_set_file (ShellMimeSniffer *self,
GFile *file)
{
g_clear_object (&self->priv->file);
self->priv->file = g_object_ref (file);
}
static void
shell_mime_sniffer_dispose (GObject *object)
{
ShellMimeSniffer *self = SHELL_MIME_SNIFFER (object);
g_clear_object (&self->priv->file);
g_clear_object (&self->priv->cancellable);
g_clear_object (&self->priv->async_result);
if (self->priv->watchdog_id != 0)
{
g_source_remove (self->priv->watchdog_id);
self->priv->watchdog_id = 0;
}
G_OBJECT_CLASS (shell_mime_sniffer_parent_class)->dispose (object);
}
static void
shell_mime_sniffer_finalize (GObject *object)
{
ShellMimeSniffer *self = SHELL_MIME_SNIFFER (object);
g_strfreev (self->priv->sniffed_mime);
G_OBJECT_CLASS (shell_mime_sniffer_parent_class)->finalize (object);
}
static void
shell_mime_sniffer_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ShellMimeSniffer *self = SHELL_MIME_SNIFFER (object);
switch (prop_id) {
case PROP_FILE:
g_value_set_object (value, self->priv->file);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
shell_mime_sniffer_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ShellMimeSniffer *self = SHELL_MIME_SNIFFER (object);
switch (prop_id) {
case PROP_FILE:
shell_mime_sniffer_set_file (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
shell_mime_sniffer_class_init (ShellMimeSnifferClass *klass)
{
GObjectClass *oclass;
oclass = G_OBJECT_CLASS (klass);
oclass->dispose = shell_mime_sniffer_dispose;
oclass->finalize = shell_mime_sniffer_finalize;
oclass->get_property = shell_mime_sniffer_get_property;
oclass->set_property = shell_mime_sniffer_set_property;
properties[PROP_FILE] =
g_param_spec_object ("file",
"File",
"The loaded file",
G_TYPE_FILE,
G_PARAM_READWRITE);
g_type_class_add_private (klass, sizeof (ShellMimeSnifferPrivate));
g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
}
static void
shell_mime_sniffer_init (ShellMimeSniffer *self)
{
self->priv =
G_TYPE_INSTANCE_GET_PRIVATE (self,
SHELL_TYPE_MIME_SNIFFER,
ShellMimeSnifferPrivate);
init_mimetypes ();
}
ShellMimeSniffer *
shell_mime_sniffer_new (GFile *file)
{
return g_object_new (SHELL_TYPE_MIME_SNIFFER,
"file", file,
NULL);
}
void
shell_mime_sniffer_sniff_async (ShellMimeSniffer *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_assert (self->priv->watchdog_id == 0);
g_assert (self->priv->async_result == NULL);
self->priv->async_result =
g_simple_async_result_new (G_OBJECT (self),
callback, user_data,
shell_mime_sniffer_sniff_finish);
self->priv->cancellable = g_cancellable_new ();
self->priv->watchdog_id =
g_timeout_add (WATCHDOG_TIMEOUT,
watchdog_timeout_reached_cb, self);
start_loading_file (self);
}
gchar **
shell_mime_sniffer_sniff_finish (ShellMimeSniffer *self,
GAsyncResult *res,
GError **error)
{
if (g_simple_async_result_propagate_error (self->priv->async_result, error))
return NULL;
return g_strdupv (self->priv->sniffed_mime);
}

View File

@ -1,68 +0,0 @@
/*
* Copyright (C) 2011 Red Hat, Inc.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Author: Cosimo Cecchi <cosimoc@redhat.com>
*
*/
#ifndef __SHELL_MIME_SNIFFER_H__
#define __SHELL_MIME_SNIFFER_H__
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
#define SHELL_TYPE_MIME_SNIFFER (shell_mime_sniffer_get_type ())
#define SHELL_MIME_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHELL_TYPE_MIME_SNIFFER, ShellMimeSniffer))
#define SHELL_IS_MIME_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SHELL_TYPE_MIME_SNIFFER))
#define SHELL_MIME_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SHELL_TYPE_MIME_SNIFFER, ShellMimeSnifferClass))
#define SHELL_IS_MIME_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SHELL_TYPE_MIME_SNIFFER))
#define SHELL_MIME_SNIFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SHELL_TYPE_MIME_SNIFFER, ShellMimeSnifferClass))
typedef struct _ShellMimeSniffer ShellMimeSniffer;
typedef struct _ShellMimeSnifferPrivate ShellMimeSnifferPrivate;
typedef struct _ShellMimeSnifferClass ShellMimeSnifferClass;
struct _ShellMimeSniffer
{
GObject parent_instance;
ShellMimeSnifferPrivate *priv;
};
struct _ShellMimeSnifferClass
{
GObjectClass parent_class;
};
GType shell_mime_sniffer_get_type (void) G_GNUC_CONST;
ShellMimeSniffer *shell_mime_sniffer_new (GFile *file);
void shell_mime_sniffer_sniff_async (ShellMimeSniffer *self,
GAsyncReadyCallback callback,
gpointer user_data);
gchar ** shell_mime_sniffer_sniff_finish (ShellMimeSniffer *self,
GAsyncResult *res,
GError **error);
G_END_DECLS
#endif /* __SHELL_MIME_SNIFFER_H__ */

View File

@ -19,8 +19,6 @@
#include <meta/main.h>
#include <meta/meta-plugin.h>
#include <meta/prefs.h>
#include <telepathy-glib/debug.h>
#include <telepathy-glib/debug-sender.h>
#include "shell-a11y.h"
#include "shell-global.h"
@ -430,25 +428,6 @@ muted_log_handler (const char *log_domain,
/* Intentionally empty to discard message */
}
static void
default_log_handler (const char *log_domain,
GLogLevelFlags log_level,
const char *message,
gpointer data)
{
TpDebugSender *sender = data;
GTimeVal now;
g_get_current_time (&now);
tp_debug_sender_add_message (sender, &now, log_domain, log_level, message);
/* Filter out telepathy-glib logs, we don't want to flood Shell's output
* with those. */
if (!g_str_has_prefix (log_domain, "tp-glib"))
g_log_default_handler (log_domain, log_level, message, data);
}
static gboolean
print_version (const gchar *option_name,
const gchar *value,
@ -474,8 +453,6 @@ main (int argc, char **argv)
{
GOptionContext *ctx;
GError *error = NULL;
int ecode;
TpDebugSender *sender;
g_type_init ();
@ -491,8 +468,6 @@ main (int argc, char **argv)
exit (1);
}
g_option_context_free (ctx);
meta_plugin_type_register (gnome_shell_plugin_get_type ());
/* Prevent meta_init() from causing gtk to load gail and at-bridge */
@ -528,29 +503,9 @@ main (int argc, char **argv)
muted_log_handler, NULL);
g_log_set_handler ("Bluetooth", G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE,
muted_log_handler, NULL);
g_log_set_handler ("tp-glib/proxy", G_LOG_LEVEL_DEBUG,
muted_log_handler, NULL);
/* Turn on telepathy-glib debugging but filter it out in
* default_log_handler. This handler also exposes all the logs over D-Bus
* using TpDebugSender. */
tp_debug_set_flags ("all");
sender = tp_debug_sender_dup ();
g_log_set_default_handler (default_log_handler, sender);
/* Initialize the global object */
shell_global_get ();
ecode = meta_run ();
if (g_getenv ("GNOME_SHELL_ENABLE_CLEANUP"))
{
g_printerr ("Doing final cleanup...\n");
g_object_unref (shell_global_get ());
}
g_object_unref (sender);
return ecode;
return meta_run ();
}

View File

@ -25,11 +25,6 @@
#include <meta/display.h>
#include <meta/util.h>
/* Memory report bits */
#ifdef HAVE_MALLINFO
#include <malloc.h>
#endif
#include "shell-enum-types.h"
#include "shell-global-private.h"
#include "shell-jsapi-compat-private.h"
@ -39,8 +34,6 @@
#include "shell-wm.h"
#include "st.h"
static ShellGlobal *the_object = NULL;
static void grab_notify (GtkWidget *widget, gboolean is_grab, gpointer user_data);
struct _ShellGlobal {
@ -69,6 +62,8 @@ struct _ShellGlobal {
GdkWindow *stage_window;
gint last_change_screen_width, last_change_screen_height;
guint work_count;
GSList *leisure_closures;
guint leisure_function_id;
@ -242,6 +237,9 @@ shell_global_init (ShellGlobal *global)
global->input_mode = SHELL_STAGE_INPUT_MODE_NORMAL;
global->last_change_screen_width = 0;
global->last_change_screen_height = 0;
ca_context_create (&global->sound_context);
ca_context_change_props (global->sound_context, CA_PROP_APPLICATION_NAME, PACKAGE_NAME, CA_PROP_APPLICATION_ID, "org.gnome.Shell", NULL);
ca_context_open (global->sound_context);
@ -256,20 +254,6 @@ shell_global_init (ShellGlobal *global)
g_strfreev (search_path);
}
static void
shell_global_finalize (GObject *object)
{
ShellGlobal *global = SHELL_GLOBAL (object);
g_object_unref (global->js_context);
gtk_widget_destroy (GTK_WIDGET (global->grab_notifier));
g_object_unref (global->settings);
the_object = NULL;
G_OBJECT_CLASS(shell_global_parent_class)->finalize (object);
}
static void
shell_global_class_init (ShellGlobalClass *klass)
{
@ -277,7 +261,6 @@ shell_global_class_init (ShellGlobalClass *klass)
gobject_class->get_property = shell_global_get_property;
gobject_class->set_property = shell_global_set_property;
gobject_class->finalize = shell_global_finalize;
/* Emitted from gnome-shell-plugin.c during event handling */
shell_global_signals[XDND_POSITION_CHANGED] =
@ -441,6 +424,8 @@ shell_global_class_init (ShellGlobalClass *klass)
ShellGlobal *
shell_global_get (void)
{
static ShellGlobal *the_object = NULL;
if (!the_object)
the_object = g_object_new (SHELL_TYPE_GLOBAL, 0);
@ -695,6 +680,23 @@ shell_global_get_window_actors (ShellGlobal *global)
return meta_plugin_get_window_actors (global->plugin);
}
static gboolean
update_screen_size (gpointer data)
{
int width, height;
ShellGlobal *global = SHELL_GLOBAL (data);
meta_plugin_query_screen_size (global->plugin, &width, &height);
if (global->last_change_screen_width == width && global->last_change_screen_height == height)
return FALSE;
global->last_change_screen_width = width;
global->last_change_screen_height = height;
return FALSE;
}
static void
global_stage_notify_width (GObject *gobject,
GParamSpec *pspec,
@ -703,6 +705,11 @@ global_stage_notify_width (GObject *gobject,
ShellGlobal *global = SHELL_GLOBAL (data);
g_object_notify (G_OBJECT (global), "screen-width");
meta_later_add (META_LATER_BEFORE_REDRAW,
update_screen_size,
global,
NULL);
}
static void
@ -713,6 +720,11 @@ global_stage_notify_height (GObject *gobject,
ShellGlobal *global = SHELL_GLOBAL (data);
g_object_notify (G_OBJECT (global), "screen-height");
meta_later_add (META_LATER_BEFORE_REDRAW,
update_screen_size,
global,
NULL);
}
static void
@ -751,6 +763,7 @@ _shell_global_set_plugin (ShellGlobal *global,
G_CALLBACK (global_stage_notify_width), global);
g_signal_connect (stage, "notify::height",
G_CALLBACK (global_stage_notify_height), global);
update_screen_size (global);
g_signal_connect (stage, "paint",
G_CALLBACK (global_stage_before_paint), global);
@ -1098,38 +1111,6 @@ shell_global_maybe_gc (ShellGlobal *global)
gjs_context_maybe_gc (global->js_context);
}
/**
* shell_global_get_memory_info:
* @global:
* @meminfo: (out caller-allocates): Output location for memory information
*
* Load process-global data about memory usage.
*/
void
shell_global_get_memory_info (ShellGlobal *global,
ShellMemoryInfo *meminfo)
{
JSContext *context;
memset (meminfo, 0, sizeof (meminfo));
#ifdef HAVE_MALLINFO
{
struct mallinfo info = mallinfo ();
meminfo->glibc_uordblks = info.uordblks;
}
#endif
context = gjs_context_get_native_context (global->js_context);
meminfo->js_bytes = JS_GetGCParameter (JS_GetRuntime (context), JSGC_BYTES);
meminfo->gjs_boxed = (unsigned int) gjs_counter_boxed.value;
meminfo->gjs_gobject = (unsigned int) gjs_counter_object.value;
meminfo->gjs_function = (unsigned int) gjs_counter_function.value;
meminfo->gjs_closure = (unsigned int) gjs_counter_closure.value;
}
/**
* shell_global_notify_error:
* @global: a #ShellGlobal
@ -1193,6 +1174,109 @@ void shell_global_init_xdnd (ShellGlobal *global)
32, PropModeReplace, (const unsigned char *)&stage_win, 1);
}
/**
* shell_global_get_monitors:
* @global: the #ShellGlobal
*
* Gets a list of the bounding boxes of the active screen's monitors.
*
* Return value: (transfer full) (element-type Meta.Rectangle): a list
* of monitor bounding boxes.
*/
GSList *
shell_global_get_monitors (ShellGlobal *global)
{
MetaScreen *screen = shell_global_get_screen (global);
GSList *monitors = NULL;
MetaRectangle rect;
int i;
for (i = meta_screen_get_n_monitors (screen) - 1; i >= 0; i--)
{
meta_screen_get_monitor_geometry (screen, i, &rect);
monitors = g_slist_prepend (monitors,
meta_rectangle_copy (&rect));
}
return monitors;
}
/**
* shell_global_get_primary_monitor:
* @global: the #ShellGlobal
*
* Gets the bounding box of the primary monitor (the one that the
* panel is on).
*
* Return value: the bounding box of the primary monitor
*/
MetaRectangle *
shell_global_get_primary_monitor (ShellGlobal *global)
{
MetaScreen *screen = shell_global_get_screen (global);
MetaRectangle rect;
gint primary = 0;
primary = meta_screen_get_primary_monitor (screen);
meta_screen_get_monitor_geometry (screen, primary, &rect);
return meta_rectangle_copy (&rect);
}
/**
* shell_global_get_primary_monitor_index:
* @global: the #ShellGlobal
*
* Gets the index of the primary monitor (the one that the
* panel is on).
*
* Return value: the index of the primary monitor
*/
int
shell_global_get_primary_monitor_index (ShellGlobal *global)
{
MetaScreen *screen = shell_global_get_screen (global);
return meta_screen_get_primary_monitor (screen);
}
/**
* shell_global_get_focus_monitor:
* @global: the #ShellGlobal
*
* Gets the bounding box of the monitor containing the window that
* currently contains the keyboard focus.
*
* Return value: the bounding box of the focus monitor
*/
MetaRectangle *
shell_global_get_focus_monitor (ShellGlobal *global)
{
MetaScreen *screen = shell_global_get_screen (global);
MetaDisplay *display = meta_screen_get_display (screen);
MetaWindow *focus = meta_display_get_focus_window (display);
MetaRectangle rect, wrect;
int nmonitors, i;
if (focus)
{
meta_window_get_outer_rect (focus, &wrect);
nmonitors = meta_screen_get_n_monitors (screen);
/* Find the monitor that the top-left corner of @focus is on. */
for (i = 0; i < nmonitors; i++)
{
meta_screen_get_monitor_geometry (screen, i, &rect);
if (rect.x <= wrect.x && rect.y <= wrect.y &&
rect.x + rect.width > wrect.x &&
rect.y + rect.height > wrect.y)
return meta_rectangle_copy (&rect);
}
}
return shell_global_get_primary_monitor (global);
}
/**
* shell_global_get_pointer:
* @global: the #ShellGlobal
@ -1346,6 +1430,73 @@ shell_global_create_app_launch_context (ShellGlobal *global)
return (GAppLaunchContext *)context;
}
/**
* shell_global_set_property_mutable:
* @global: the #ShellGlobal
* @object: the "path" to a JS object, starting from the root object.
* (Eg, "global.stage" or "imports.gi.Gtk.Window.prototype")
* @property: a property on @object
* @mutable: %TRUE or %FALSE
*
* If @mutable is %TRUE, this clears the "permanent" and "readonly" flags
* on @property of @object. If @mutable is %FALSE, it sets them.
*
* You can use this to make it possible to modify properties that
* would otherwise be read-only from JavaScript.
*
* Return value: success or failure.
*/
gboolean
shell_global_set_property_mutable (ShellGlobal *global,
const char *object,
const char *property,
gboolean mutable)
{
JSContext *context = gjs_context_get_native_context (global->js_context);
char **parts;
JSObject *obj;
jsval val = JSVAL_VOID;
int i;
jsuint attrs;
JSBool found;
JS_BeginRequest (context);
JS_AddValueRoot (context, &val);
parts = g_strsplit (object, ".", -1);
obj = JS_GetGlobalObject (context);
for (i = 0; parts[i]; i++)
{
if (!JS_GetProperty (context, obj, parts[i], &val))
{
g_strfreev (parts);
goto out_error;
}
obj = JSVAL_TO_OBJECT (val);
}
g_strfreev (parts);
if (!JS_GetPropertyAttributes (context, obj, property, &attrs, &found) || !found)
goto out_error;
if (mutable)
attrs &= ~(JSPROP_PERMANENT | JSPROP_READONLY);
else
attrs |= (JSPROP_PERMANENT | JSPROP_READONLY);
if (!JS_SetPropertyAttributes (context, obj, property, attrs, &found))
goto out_error;
JS_RemoveValueRoot (context, &val);
JS_EndRequest (context);
return TRUE;
out_error:
gjs_log_exception (context, NULL);
JS_RemoveValueRoot (context, &val);
JS_EndRequest (context);
return FALSE;
}
typedef struct
{
ShellLeisureFunction func;

View File

@ -32,6 +32,10 @@ ShellGlobal *shell_global_get (void);
MetaScreen *shell_global_get_screen (ShellGlobal *global);
GdkScreen *shell_global_get_gdk_screen (ShellGlobal *global);
GList *shell_global_get_window_actors (ShellGlobal *global);
GSList *shell_global_get_monitors (ShellGlobal *global);
MetaRectangle *shell_global_get_primary_monitor (ShellGlobal *global);
int shell_global_get_primary_monitor_index (ShellGlobal *global);
MetaRectangle *shell_global_get_focus_monitor (ShellGlobal *global);
GSettings *shell_global_get_settings (ShellGlobal *global);
guint32 shell_global_get_current_time (ShellGlobal *global);
@ -86,19 +90,10 @@ void shell_global_get_pointer (ShellGlobal *global,
void shell_global_gc (ShellGlobal *global);
void shell_global_maybe_gc (ShellGlobal *global);
typedef struct {
guint glibc_uordblks;
guint js_bytes;
guint gjs_boxed;
guint gjs_gobject;
guint gjs_function;
guint gjs_closure;
} ShellMemoryInfo;
void shell_global_get_memory_info (ShellGlobal *global,
ShellMemoryInfo *meminfo);
gboolean shell_global_set_property_mutable (ShellGlobal *global,
const char *object,
const char *property,
gboolean mutable);
/* Run-at-leisure API */

View File

@ -1,184 +0,0 @@
/*
* Copyright (C) 2011 Red Hat, Inc.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Author: Cosimo Cecchi <cosimoc@redhat.com>
*
*/
#include "shell-mount-operation.h"
/* This is a dummy class; we would like to be able to subclass the
* object from JS but we can't yet; the default GMountOperation impl
* automatically calls g_mount_operation_reply(UNHANDLED) after an idle,
* in interactive methods. We want to handle the reply outselves
* instead, so we just override the default methods with empty ones,
* except for ask-password, as we don't want to handle that.
*
* Also, we need to workaround the fact that gjs doesn't support type
* annotations for signals yet (so we can't effectively forward e.g.
* the GPid array to JS).
* See https://bugzilla.gnome.org/show_bug.cgi?id=645978
*/
G_DEFINE_TYPE (ShellMountOperation, shell_mount_operation, G_TYPE_MOUNT_OPERATION);
enum {
SHOW_PROCESSES_2,
NUM_SIGNALS
};
static guint signals[NUM_SIGNALS] = { 0, };
struct _ShellMountOperationPrivate {
GArray *pids;
gchar **choices;
gchar *message;
};
static void
shell_mount_operation_init (ShellMountOperation *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, SHELL_TYPE_MOUNT_OPERATION,
ShellMountOperationPrivate);
}
static void
shell_mount_operation_ask_password (GMountOperation *op,
const char *message,
const char *default_user,
const char *default_domain,
GAskPasswordFlags flags)
{
/* do nothing */
}
static void
shell_mount_operation_ask_question (GMountOperation *op,
const char *message,
const char *choices[])
{
/* do nothing */
}
static void
shell_mount_operation_show_processes (GMountOperation *operation,
const gchar *message,
GArray *processes,
const gchar *choices[])
{
ShellMountOperation *self = SHELL_MOUNT_OPERATION (operation);
if (self->priv->pids != NULL)
{
g_array_unref (self->priv->pids);
self->priv->pids = NULL;
}
g_free (self->priv->message);
g_strfreev (self->priv->choices);
/* save the parameters */
self->priv->pids = g_array_ref (processes);
self->priv->choices = g_strdupv ((gchar **) choices);
self->priv->message = g_strdup (message);
g_signal_emit (self, signals[SHOW_PROCESSES_2], 0);
}
static void
shell_mount_operation_finalize (GObject *obj)
{
ShellMountOperation *self = SHELL_MOUNT_OPERATION (obj);
g_strfreev (self->priv->choices);
g_free (self->priv->message);
if (self->priv->pids != NULL)
{
g_array_unref (self->priv->pids);
self->priv->pids = NULL;
}
G_OBJECT_CLASS (shell_mount_operation_parent_class)->finalize (obj);
}
static void
shell_mount_operation_class_init (ShellMountOperationClass *klass)
{
GMountOperationClass *mclass;
GObjectClass *oclass;
mclass = G_MOUNT_OPERATION_CLASS (klass);
mclass->show_processes = shell_mount_operation_show_processes;
mclass->ask_question = shell_mount_operation_ask_question;
mclass->ask_password = shell_mount_operation_ask_password;
oclass = G_OBJECT_CLASS (klass);
oclass->finalize = shell_mount_operation_finalize;
signals[SHOW_PROCESSES_2] =
g_signal_new ("show-processes-2",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_type_class_add_private (klass, sizeof (ShellMountOperationPrivate));
}
GMountOperation *
shell_mount_operation_new (void)
{
return g_object_new (SHELL_TYPE_MOUNT_OPERATION, NULL);
}
/**
* shell_mount_operation_get_show_processes_pids:
* @self: a #ShellMountOperation
*
* Returns: (transfer full) (element-type GPid): a #GArray
*/
GArray *
shell_mount_operation_get_show_processes_pids (ShellMountOperation *self)
{
return g_array_ref (self->priv->pids);
}
/**
* shell_mount_operation_get_show_processes_choices:
* @self: a #ShellMountOperation
*
* Returns: (transfer full):
*/
gchar **
shell_mount_operation_get_show_processes_choices (ShellMountOperation *self)
{
return g_strdupv (self->priv->choices);
}
/**
* shell_mount_operation_get_show_processes_message:
* @self: a #ShellMountOperation
*
* Returns: (transfer full):
*/
gchar *
shell_mount_operation_get_show_processes_message (ShellMountOperation *self)
{
return g_strdup (self->priv->message);
}

View File

@ -1,63 +0,0 @@
/*
* Copyright (C) 2011 Red Hat, Inc.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Author: Cosimo Cecchi <cosimoc@redhat.com>
*
*/
#ifndef __SHELL_MOUNT_OPERATION_H__
#define __SHELL_MOUNT_OPERATION_H__
#include <gio/gio.h>
G_BEGIN_DECLS
#define SHELL_TYPE_MOUNT_OPERATION (shell_mount_operation_get_type ())
#define SHELL_MOUNT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SHELL_TYPE_MOUNT_OPERATION, ShellMountOperation))
#define SHELL_MOUNT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SHELL_TYPE_MOUNT_OPERATION, ShellMountOperationClass))
#define SHELL_IS_MOUNT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SHELL_TYPE_MOUNT_OPERATION))
#define SHELL_IS_MOUNT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SHELL_TYPE_MOUNT_OPERATION))
#define SHELL_MOUNT_OPERATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), SHELL_TYPE_MOUNT_OPERATION, ShellMountOperationClass))
typedef struct _ShellMountOperation ShellMountOperation;
typedef struct _ShellMountOperationClass ShellMountOperationClass;
typedef struct _ShellMountOperationPrivate ShellMountOperationPrivate;
struct _ShellMountOperation
{
GMountOperation parent_instance;
ShellMountOperationPrivate *priv;
};
struct _ShellMountOperationClass
{
GMountOperationClass parent_class;
};
GType shell_mount_operation_get_type (void);
GMountOperation *shell_mount_operation_new (void);
GArray * shell_mount_operation_get_show_processes_pids (ShellMountOperation *self);
gchar ** shell_mount_operation_get_show_processes_choices (ShellMountOperation *self);
gchar * shell_mount_operation_get_show_processes_message (ShellMountOperation *self);
G_END_DECLS
#endif /* __SHELL_MOUNT_OPERATION_H__ */

View File

@ -62,6 +62,8 @@ struct _ShellRecorder {
gboolean only_paint; /* Used to temporarily suppress recording */
gboolean have_pack_invert; /* True when GL_MESA_pack_invert is available */
int framerate;
char *pipeline_description;
char *filename;
@ -198,7 +200,7 @@ create_recording_icon (void)
texture = cogl_texture_new_from_data (32, 32,
COGL_TEXTURE_NONE,
CLUTTER_CAIRO_FORMAT_ARGB32,
COGL_PIXEL_FORMAT_BGRA_8888,
COGL_PIXEL_FORMAT_ANY,
cairo_image_surface_get_stride (surface),
cairo_image_surface_get_data (surface));
@ -412,8 +414,6 @@ recorder_fetch_cursor_image (ShellRecorder *recorder)
*(guint32 *)(data + i * stride + 4 * j) = cursor_image->pixels[i * cursor_image->width + j];
cairo_surface_mark_dirty (recorder->cursor_image);
XFree (cursor_image);
}
/* Overlay the cursor image on the frame. We draw the cursor image
@ -450,7 +450,15 @@ recorder_draw_cursor (ShellRecorder *recorder,
recorder->stage_height,
recorder->stage_width * 4);
/* When not using GL_MESA_pack_invert the data we get from glReadPixels is "upside down",
* so transform our cairo drawing to match */
cr = cairo_create (surface);
if (!recorder->have_pack_invert)
{
cairo_translate(cr, 0, recorder->stage_height);
cairo_scale(cr, 1, -1);
}
cairo_set_source_surface (cr,
recorder->cursor_image,
recorder->pointer_x - recorder->cursor_hot_x,
@ -526,11 +534,36 @@ recorder_record_frame (ShellRecorder *recorder)
GST_BUFFER_TIMESTAMP(buffer) = get_wall_time() - recorder->start_time;
cogl_read_pixels (0, 0,
recorder->stage_width, recorder->stage_height,
COGL_READ_PIXELS_COLOR_BUFFER,
CLUTTER_CAIRO_FORMAT_ARGB32,
data);
/* We could use cogl_read_pixels, but it only currently supports
* COGL_PIXEL_FORMAT_RGBA_8888, while we prefer the native framebuffer
* format. (COGL_PIXEL_FORMAT_ARGB_8888_PRE,
* COGL_PIXEL_FORMAT_BGRA_PRE, depending on endianess)
*
* http://bugzilla.openedhand.com/show_bug.cgi?id=1959
*/
/* Flush any primitives that Cogl has batched up */
cogl_flush ();
/* Set the parameters for how data is stored; these are the initial
* values but Cogl will have modified them for its own purposes */
glPixelStorei (GL_PACK_ALIGNMENT, 4);
glPixelStorei (GL_PACK_ROW_LENGTH, 0);
glPixelStorei (GL_PACK_SKIP_PIXELS, 0);
glPixelStorei (GL_PACK_SKIP_ROWS, 0);
if (recorder->have_pack_invert)
glPixelStorei (GL_PACK_INVERT_MESA, TRUE);
glReadBuffer (GL_BACK_LEFT);
glReadPixels (0, 0,
recorder->stage_width, recorder->stage_height,
GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV,
data);
if (recorder->have_pack_invert)
glPixelStorei (GL_PACK_INVERT_MESA, FALSE);
recorder_draw_cursor (recorder, buffer);
@ -833,6 +866,7 @@ recorder_set_stage (ShellRecorder *recorder,
if (recorder->stage)
{
int error_base;
const char *gl_extensions;
recorder->stage = stage;
g_signal_connect (recorder->stage, "destroy",
@ -857,6 +891,8 @@ recorder_set_stage (ShellRecorder *recorder,
XFixesDisplayCursorNotifyMask);
clutter_stage_ensure_current (stage);
gl_extensions = (const char *)glGetString (GL_EXTENSIONS);
recorder->have_pack_invert = strstr (gl_extensions, "GL_MESA_pack_invert") != NULL;
recorder_get_initial_cursor_position (recorder);
}
@ -1057,6 +1093,8 @@ recorder_pipeline_add_source (RecorderPipeline *pipeline)
GstPad *sink_pad = NULL, *src_pad = NULL;
gboolean result = FALSE;
GstElement *ffmpegcolorspace;
GstElement *videoflip;
GError *error = NULL;
sink_pad = gst_bin_find_unlinked_pad (GST_BIN (pipeline->pipeline), GST_PAD_SINK);
if (sink_pad == NULL)
@ -1086,8 +1124,38 @@ recorder_pipeline_add_source (RecorderPipeline *pipeline)
}
gst_bin_add (GST_BIN (pipeline->pipeline), ffmpegcolorspace);
gst_element_link_many (pipeline->src, ffmpegcolorspace, NULL);
src_pad = gst_element_get_static_pad (ffmpegcolorspace, "src");
/* glReadPixels gives us an upside-down buffer, so we have to flip it back
* right-side up.
*
* When available MESA_pack_invert extension is used to avoid the
* flip entirely, since the data is actually stored in the frame buffer
* in the order that we expect.
*
* We use gst_parse_launch to avoid having to know the enum value for flip-vertical
*/
if (!pipeline->recorder->have_pack_invert)
{
videoflip = gst_parse_launch_full ("videoflip method=vertical-flip", NULL,
GST_PARSE_FLAG_FATAL_ERRORS,
&error);
if (videoflip == NULL)
{
g_warning("Can't create videoflip element: %s", error->message);
g_error_free (error);
goto out;
}
gst_bin_add (GST_BIN (pipeline->pipeline), videoflip);
gst_element_link_many (pipeline->src, ffmpegcolorspace, videoflip, NULL);
src_pad = gst_element_get_static_pad (videoflip, "src");
}
else
{
gst_element_link_many (pipeline->src, ffmpegcolorspace, NULL);
src_pad = gst_element_get_static_pad (ffmpegcolorspace, "src");
}
if (!src_pad)
{

View File

@ -11,14 +11,6 @@ struct _ShellTpClientPrivate
ShellTpClientObserveChannelsImpl observe_impl;
gpointer user_data_obs;
GDestroyNotify destroy_obs;
ShellTpClientApproveChannelsImpl approve_channels_impl;
gpointer user_data_approve_channels;
GDestroyNotify destroy_approve_channels;
ShellTpClientHandleChannelsImpl handle_channels_impl;
gpointer user_data_handle_channels;
GDestroyNotify destroy_handle_channels;
};
/**
@ -40,97 +32,23 @@ struct _ShellTpClientPrivate
* Signature of the implementation of the ObserveChannels method.
*/
/**
* ShellTpClientApproveChannelsImpl:
* @client: a #ShellTpClient instance
* @account: a #TpAccount having %TP_ACCOUNT_FEATURE_CORE prepared if possible
* @connection: a #TpConnection having %TP_CONNECTION_FEATURE_CORE prepared
* if possible
* @channels: (element-type TelepathyGLib.Channel): a #GList of #TpChannel,
* all having %TP_CHANNEL_FEATURE_CORE prepared if possible
* @dispatch_operation: (allow-none): a #TpChannelDispatchOperation or %NULL;
* the dispatch_operation is not guaranteed to be prepared
* @context: a #TpAddDispatchOperationContext representing the context of this
* D-Bus call
*
* Signature of the implementation of the AddDispatchOperation method.
*/
/**
* ShellTpClientHandleChannelsImpl:
* @client: a #ShellTpClient instance
* @account: a #TpAccount having %TP_ACCOUNT_FEATURE_CORE prepared if possible
* @connection: a #TpConnection having %TP_CONNECTION_FEATURE_CORE prepared
* if possible
* @channels: (element-type TelepathyGLib.Channel): a #GList of #TpChannel,
* all having %TP_CHANNEL_FEATURE_CORE prepared if possible
* @requests_satisfied: (element-type TelepathyGLib.ChannelRequest): a #GList of
* #TpChannelRequest having their object-path defined but are not guaranteed
* to be prepared.
* @user_action_time: the time at which user action occurred, or one of the
* special values %TP_USER_ACTION_TIME_NOT_USER_ACTION or
* %TP_USER_ACTION_TIME_CURRENT_TIME
* (see #TpAccountChannelRequest:user-action-time for details)
* @context: a #TpHandleChannelsContext representing the context of this
* D-Bus call
*
* Signature of the implementation of the HandleChannels method.
*/
static void
shell_tp_client_init (ShellTpClient *self)
{
GHashTable *filter;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, SHELL_TYPE_TP_CLIENT,
ShellTpClientPrivate);
/* We only care about single-user text-based chats */
filter = tp_asv_new (
TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
TP_IFACE_CHANNEL_TYPE_TEXT,
TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
TP_HANDLE_TYPE_CONTACT,
NULL);
/* Observer */
tp_base_client_set_observer_recover (TP_BASE_CLIENT (self), TRUE);
tp_base_client_add_observer_filter (TP_BASE_CLIENT (self), filter);
/* Approver */
tp_base_client_add_approver_filter (TP_BASE_CLIENT (self), filter);
/* Approve room invitations. We don't handle or observe room channels so
* just register this filter for the approver. */
tp_base_client_take_approver_filter (TP_BASE_CLIENT (self), tp_asv_new (
TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
TP_IFACE_CHANNEL_TYPE_TEXT,
TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
TP_HANDLE_TYPE_ROOM,
NULL));
/* Approve calls (StreameMedia and Call.DRAFT). We let Empathy handle the
* call itself. */
tp_base_client_take_approver_filter (TP_BASE_CLIENT (self),
/* We only care about single-user text-based chats */
tp_base_client_take_observer_filter (TP_BASE_CLIENT (self),
tp_asv_new (
TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
TP_IFACE_CHANNEL_TYPE_TEXT,
TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
TP_HANDLE_TYPE_CONTACT,
NULL));
/* FIXME: use TP_IFACE_CHANNEL_TYPE_CALL once API is undrafted (fdo #24936) */
tp_base_client_take_approver_filter (TP_BASE_CLIENT (self),
tp_asv_new (
TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
"org.freedesktop.Telepathy.Channel.Type.Call.DRAFT",
TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
NULL));
/* Handler */
tp_base_client_add_handler_filter (TP_BASE_CLIENT (self), filter);
g_hash_table_unref (filter);
}
static void
@ -150,40 +68,6 @@ observe_channels (TpBaseClient *client,
dispatch_operation, requests, context, self->priv->user_data_obs);
}
static void
add_dispatch_operation (TpBaseClient *client,
TpAccount *account,
TpConnection *connection,
GList *channels,
TpChannelDispatchOperation *dispatch_operation,
TpAddDispatchOperationContext *context)
{
ShellTpClient *self = (ShellTpClient *) client;
g_assert (self->priv->approve_channels_impl != NULL);
self->priv->approve_channels_impl (self, account, connection, channels,
dispatch_operation, context, self->priv->user_data_approve_channels);
}
static void
handle_channels (TpBaseClient *client,
TpAccount *account,
TpConnection *connection,
GList *channels,
GList *requests_satisfied,
gint64 user_action_time,
TpHandleChannelsContext *context)
{
ShellTpClient *self = (ShellTpClient *) client;
g_assert (self->priv->handle_channels_impl != NULL);
self->priv->handle_channels_impl (self, account, connection, channels,
requests_satisfied, user_action_time, context,
self->priv->user_data_handle_channels);
}
static void
shell_tp_client_dispose (GObject *object)
{
@ -195,21 +79,6 @@ shell_tp_client_dispose (GObject *object)
{
self->priv->destroy_obs (self->priv->user_data_obs);
self->priv->destroy_obs = NULL;
self->priv->user_data_obs = NULL;
}
if (self->priv->destroy_approve_channels != NULL)
{
self->priv->destroy_approve_channels (self->priv->user_data_approve_channels);
self->priv->destroy_approve_channels = NULL;
self->priv->user_data_approve_channels = NULL;
}
if (self->priv->destroy_handle_channels != NULL)
{
self->priv->destroy_handle_channels (self->priv->user_data_handle_channels);
self->priv->destroy_handle_channels = NULL;
self->priv->user_data_handle_channels = NULL;
}
if (dispose != NULL)
@ -227,8 +96,22 @@ shell_tp_client_class_init (ShellTpClientClass *cls)
object_class->dispose = shell_tp_client_dispose;
base_clt_cls->observe_channels = observe_channels;
base_clt_cls->add_dispatch_operation = add_dispatch_operation;
base_clt_cls->handle_channels = handle_channels;
}
/**
* shell_tp_client_new:
* @dbus: a #TpDBusDaemon object, may not be %NULL
*
* Returns: a new #ShellTpClient
*/
ShellTpClient *
shell_tp_client_new (TpDBusDaemon *dbus)
{
return g_object_new (SHELL_TYPE_TP_CLIENT,
"dbus-daemon", dbus,
"name", "GnomeShell",
"uniquify-name", TRUE,
NULL);
}
void
@ -244,32 +127,6 @@ shell_tp_client_set_observe_channels_func (ShellTpClient *self,
self->priv->destroy_obs = destroy;
}
void
shell_tp_client_set_approve_channels_func (ShellTpClient *self,
ShellTpClientApproveChannelsImpl approve_channels_impl,
gpointer user_data,
GDestroyNotify destroy)
{
g_assert (self->priv->approve_channels_impl == NULL);
self->priv->approve_channels_impl = approve_channels_impl;
self->priv->user_data_approve_channels = user_data;
self->priv->destroy_approve_channels = destroy;
}
void
shell_tp_client_set_handle_channels_func (ShellTpClient *self,
ShellTpClientHandleChannelsImpl handle_channels_impl,
gpointer user_data,
GDestroyNotify destroy)
{
g_assert (self->priv->handle_channels_impl == NULL);
self->priv->handle_channels_impl = handle_channels_impl;
self->priv->user_data_handle_channels = user_data;
self->priv->destroy_handle_channels = destroy;
}
/* Telepathy utility functions */
/**
@ -397,15 +254,3 @@ shell_get_contact_events (TplLogManager *log_manager,
NULL, NULL,
callback, NULL);
}
/* gjs doesn't allow us to craft a GError so we need a C wrapper */
void
shell_decline_dispatch_op (TpAddDispatchOperationContext *context,
const gchar *message)
{
GError *error = g_error_new_literal (TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
message);
tp_add_dispatch_operation_context_fail (context, error);
g_error_free (error);
}

View File

@ -51,40 +51,13 @@ typedef void (*ShellTpClientObserveChannelsImpl) (ShellTpClient *client,
TpObserveChannelsContext *context,
gpointer user_data);
ShellTpClient * shell_tp_client_new (TpDBusDaemon *dbus);
void shell_tp_client_set_observe_channels_func (ShellTpClient *self,
ShellTpClientObserveChannelsImpl observe_impl,
gpointer user_data,
GDestroyNotify destroy);
typedef void (*ShellTpClientApproveChannelsImpl) (
ShellTpClient *client,
TpAccount *account,
TpConnection *connection,
GList *channels,
TpChannelDispatchOperation *dispatch_operation,
TpAddDispatchOperationContext *context,
gpointer user_data);
void shell_tp_client_set_approve_channels_func (ShellTpClient *self,
ShellTpClientApproveChannelsImpl approve_impl,
gpointer user_data,
GDestroyNotify destroy);
typedef void (*ShellTpClientHandleChannelsImpl) (
ShellTpClient *client,
TpAccount *account,
TpConnection *connection,
GList *channels,
GList *requests_satisfied,
gint64 user_action_time,
TpHandleChannelsContext *context,
gpointer user_data);
void shell_tp_client_set_handle_channels_func (ShellTpClient *self,
ShellTpClientHandleChannelsImpl handle_channels_impl,
gpointer user_data,
GDestroyNotify destroy);
/* Telepathy utility functions */
typedef void (*ShellGetTpContactCb) (TpConnection *connection,
GList *contacts,
@ -111,8 +84,5 @@ void shell_get_contact_events (TplLogManager *log_manager,
guint num_events,
GAsyncReadyCallback callback);
void shell_decline_dispatch_op (TpAddDispatchOperationContext *context,
const gchar *message);
G_END_DECLS
#endif /* __SHELL_TP_CLIENT_H__ */

View File

@ -4,6 +4,7 @@
#include "shell-util.h"
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
#include <gtk/gtk.h>
#include <libxml/parser.h>
@ -71,8 +72,7 @@ shell_util_get_file_display_name_if_mount (GFile *file)
return ret;
}
#define HOME_NAME_SCHEMA "org.gnome.nautilus.desktop"
#define HOME_NAME_KEY "home-icon-name"
#define HOME_NAME_KEY "/apps/nautilus/desktop/home_icon_name"
static char *
shell_util_get_file_display_for_common_files (GFile *file)
{
@ -81,23 +81,20 @@ shell_util_get_file_display_for_common_files (GFile *file)
compare = g_file_new_for_path (g_get_home_dir ());
if (g_file_equal (file, compare))
{
GSettings *settings;
char *name;
char *gconf_name;
g_object_unref (compare);
settings = g_settings_new (HOME_NAME_SCHEMA);
name = g_settings_get_string (settings, HOME_NAME_KEY);
g_object_unref (settings);
if (!(name && name[0]))
gconf_name = gconf_client_get_string (gconf_client_get_default (),
HOME_NAME_KEY, NULL);
if (!(gconf_name && gconf_name[0]))
{
g_free (name);
g_free (gconf_name);
return g_strdup (_("Home Folder"));
}
else
{
return name;
return gconf_name;
}
}
g_object_unref (compare);
@ -560,29 +557,6 @@ shell_get_event_state (ClutterEvent *event)
return state & CLUTTER_MODIFIER_MASK;
}
/**
* shell_write_soup_message_to_stream:
* @stream: a #GOutputStream
* @message: a #SoupMessage
* @error: location to store GError
*
* Write a string to a GOutputStream as binary data. This is a
* workaround for the lack of proper binary strings in GJS.
*/
void
shell_write_soup_message_to_stream (GOutputStream *stream,
SoupMessage *message,
GError **error)
{
SoupMessageBody *body;
body = message->response_body;
g_output_stream_write_all (stream,
body->data, body->length,
NULL, NULL, error);
}
/**
* shell_write_string_to_stream:
* @stream: a #GOutputStream

View File

@ -5,7 +5,6 @@
#include <gio/gio.h>
#include <clutter/clutter.h>
#include <libsoup/soup.h>
G_BEGIN_DECLS
@ -26,10 +25,6 @@ char *shell_util_format_date (const char *format,
ClutterModifierType
shell_get_event_state (ClutterEvent *event);
void shell_write_soup_message_to_stream (GOutputStream *stream,
SoupMessage *message,
GError **error);
gboolean shell_write_string_to_stream (GOutputStream *stream,
const char *str,
GError **error);

Some files were not shown because too many files have changed in this diff Show More