博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
gnome topIcons
阅读量:6586 次
发布时间:2019-06-24

本文共 5875 字,大约阅读时间需要 19 分钟。

hot3.png

gnome iconTop

{  "_generated": "Generated by SweetTooth, do not edit",   "description": "Shows legacy tray icons on top",   "name": "TopIcons",   "shell-version": [    "3.10",     "3.9.91",     "3.12",     "3.11.5",     "3.11.90"  ],   "url": "http://94.247.144.115/repo/topicons/",   "uuid": "topIcons@adel.gadllah@gmail.com",   "version": 24

// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-const Clutter = imports.gi.Clutter;const Shell = imports.gi.Shell;const St = imports.gi.St;const Main = imports.ui.main;const GLib = imports.gi.GLib;const Lang = imports.lang;const Panel = imports.ui.panel;const PanelMenu = imports.ui.panelMenu;const Meta = imports.gi.Meta;const Mainloop = imports.mainloop;const NotificationDaemon = imports.ui.notificationDaemon;let trayAddedId = 0;let trayRemovedId = 0;let getSource = null;let icons = [];let notificationDaemon;function init() {    if (Main.notificationDaemon._fdoNotificationDaemon) {        notificationDaemon = Main.notificationDaemon._fdoNotificationDaemon;        getSource = Lang.bind(notificationDaemon, NotificationDaemon.FdoNotificationDaemon.prototype._getSource);    }    else {        notificationDaemon = Main.notificationDaemon;        getSource = Lang.bind(notificationDaemon, NotificationDaemon.NotificationDaemon.prototype._getSource);    }}function enable() {    GLib.idle_add(GLib.PRIORITY_LOW, moveToTop);}function createSource (title, pid, ndata, sender, trayIcon) {   if (trayIcon) {    onTrayIconAdded(this, trayIcon, title);    return null;  }  return getSource(title, pid, ndata, sender, trayIcon);};function onTrayIconAdded(o, icon, role) {    let wmClass = icon.wm_class ? icon.wm_class.toLowerCase() : '';    if (NotificationDaemon.STANDARD_TRAY_ICON_IMPLEMENTATIONS[wmClass] !== undefined)        return;    let buttonBox = new PanelMenu.ButtonBox();    let box = buttonBox.actor;    let parent = box.get_parent();    let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;    let iconSize = Panel.PANEL_ICON_SIZE * scaleFactor;    icon.set_size(iconSize, iconSize);    box.add_actor(icon);    icon.reactive = true;    if (parent)        parent.remove_actor(box);    icons.push(icon);    Main.panel._rightBox.insert_child_at_index(box, 0);    let clickProxy = new St.Bin({ width: iconSize, height: iconSize });    clickProxy.reactive = true;    Main.uiGroup.add_actor(clickProxy);    icon._proxyAlloc = Main.panel._rightBox.connect('allocation-changed', function() {        Meta.later_add(Meta.LaterType.BEFORE_REDRAW, function() {            let [x, y] = icon.get_transformed_position();            clickProxy.set_position(x, y);        });    });    icon.connect("destroy", function() {        Main.panel._rightBox.disconnect(icon._proxyAlloc);        clickProxy.destroy();    });    clickProxy.connect('button-release-event', function(actor, event) {        icon.click(event);    });    icon._clickProxy = clickProxy;    /* Fixme: HACK */    Meta.later_add(Meta.LaterType.BEFORE_REDRAW, function() {        let [x, y] = icon.get_transformed_position();        clickProxy.set_position(x, y);        return false;    });    let timerId = 0;    let i = 0;    timerId = Mainloop.timeout_add(500, function() {        icon.set_size(icon.width == iconSize ? iconSize - 1 : iconSize,                      icon.width == iconSize ? iconSize - 1 : iconSize);        i++;        if (i == 2)            Mainloop.source_remove(timerId);    });}function onTrayIconRemoved(o, icon) {    let parent = icon.get_parent();    parent.destroy();    icon.destroy();    icons.splice(icons.indexOf(icon), 1);}function moveToTop() {    notificationDaemon._trayManager.disconnect(notificationDaemon._trayIconAddedId);    notificationDaemon._trayManager.disconnect(notificationDaemon._trayIconRemovedId);    trayAddedId = notificationDaemon._trayManager.connect('tray-icon-added', onTrayIconAdded);    trayRemovedId = notificationDaemon._trayManager.connect('tray-icon-removed', onTrayIconRemoved);        notificationDaemon._getSource = createSource;    let toDestroy = [];    for (let i = 0; i < notificationDaemon._sources.length; i++) {        let source = notificationDaemon._sources[i];        if (!source.trayIcon)            continue;        let parent = source.trayIcon.get_parent();        parent.remove_actor(source.trayIcon);        onTrayIconAdded(this, source.trayIcon, source.initialTitle);        toDestroy.push(source);    }     for (let i = 0; i < toDestroy.length; i++) {        toDestroy[i].destroy();     }}function moveToTray() {    if (trayAddedId != 0) {        notificationDaemon._trayManager.disconnect(trayAddedId);        trayAddedId = 0;    }    if (trayRemovedId != 0) {        notificationDaemon._trayManager.disconnect(trayRemovedId);        trayRemovedId = 0;    }        notificationDaemon._trayIconAddedId = notificationDaemon._trayManager.connect('tray-icon-added',                                                Lang.bind(notificationDaemon, notificationDaemon._onTrayIconAdded));    notificationDaemon._trayIconRemovedId = notificationDaemon._trayManager.connect('tray-icon-removed',                                                Lang.bind(notificationDaemon, notificationDaemon._onTrayIconRemoved));    notificationDaemon._getSource = getSource;    for (let i = 0; i < icons.length; i++) {        let icon = icons[i];        let parent = icon.get_parent();        if (icon._clicked) {            icon.disconnect(icon._clicked);        }        icon._clicked = undefined;        if (icon._proxyAlloc) {            Main.panel._rightBox.disconnect(icon._proxyAlloc);        }        icon._clickProxy.destroy();        parent.remove_actor(icon);        parent.destroy();        notificationDaemon._onTrayIconAdded(notificationDaemon, icon);    }        icons = [];}function disable() {    moveToTray();}

转载于:https://my.oschina.net/liangzi1210/blog/291397

你可能感兴趣的文章
echarts,两点连线,中间断裂
查看>>
文件状态是否变化
查看>>
面向对象
查看>>
HDU 1058 Humble Numbers
查看>>
wps10.1中将txt转为excel
查看>>
[BZOJ3312][USACO]不找零(状压DP)
查看>>
gtp转换mbr
查看>>
poj1985 求树的直径
查看>>
[Angularjs]系列——学习与实践
查看>>
js -- canvas img 封装
查看>>
适配器模式(数据库方面)支持不同的数据库连接
查看>>
CF456B Fedya and Maths 找规律
查看>>
转载:Beginning WF 4.0翻译——第三章(流程图工作流)
查看>>
mysql alter table
查看>>
芯片测试
查看>>
在源代码中插入防止盗版代码片段的方式
查看>>
ffserver联合ffmpeg建立媒体服务器
查看>>
微软URLRewriter.dll的url重写的简单使用(实现伪静态)
查看>>
leetcode -- Combination Sum II
查看>>
Navicat for MySQL 使用SSH方式链接远程数据库(二)
查看>>