Skip to content

Commit 34b9472

Browse files
committed
Initial commit
0 parents  commit 34b9472

7 files changed

+880
-0
lines changed

LICENSE

+674
Large diffs are not rendered by default.

Makefile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
2+
FILES := $(basename $(wildcard $(DIR)/*.in))
3+
4+
PREFIX ?= /usr/local
5+
6+
%: %.in
7+
$(shell sed "s:%PREFIX%:$(PREFIX):" "$@.in" > "$@")
8+
9+
all: clean $(FILES)
10+
11+
clean:
12+
@rm -f $(FILES)
13+
14+
install:
15+
install -D -m 755 -t "$(PREFIX)/lib/mate-panel/" "$(DIR)/dockbarx_mate_applet"
16+
install -D -m 644 -t "$(PREFIX)/share/dbus-1/services/" "$(DIR)/org.mate.panel.applet.DockbarXAppletFactory.service"
17+
install -D -m 644 -t "$(PREFIX)/share/mate-panel/applets/" "$(DIR)/org.mate.panel.DockbarX.mate-panel-applet"
18+
install -D -m 644 -t "$(PREFIX)/share/mate-panel/ui/" "$(DIR)/dockbarx-applet-menu.xml"
19+
20+
uninstall:
21+
rm -f "$(PREFIX)/lib/mate-panel/dockbarx_mate_applet"
22+
rm -f "$(PREFIX)/share/dbus-1/services/org.mate.panel.applet.DockbarXAppletFactory.service"
23+
rm -f "$(PREFIX)/share/mate-panel/applets/org.mate.panel.DockbarX.mate-panel-applet"
24+
rm -f "$(PREFIX)/share/mate-panel/ui/dockbarx-applet-menu.xml"

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# DockbarX applet for the MATE panel
2+
### Version 1.0
3+
4+
## Runtime dependencies
5+
* [DockbarX](https://github.com/xuzhen/dockbarx)
6+
* MATE panel applet GObject introspection data (gir1.2-matepanelapplet-4.0 on Debian/Ubuntu)
7+
* Python3
8+
9+
## Installation
10+
11+
```
12+
git clone https://github.com/xuzhen/dockbarx-mate-applet.git
13+
cd dockbarx-mate-applet
14+
make
15+
sudo make install
16+
```
17+
The applet will be installed under /usr/local by default. You can change this behavior by setting the PREFIX variable to the `make` command.
18+
```
19+
make PREFIX=/usr
20+
sudo make PREFIX=/usr install
21+
```

dockbarx-applet-menu.xml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<menuitem name="About Item" action="About" />
2+
<menuitem name="Preferences" action="Pref" />
3+
<menuitem name="Reload" action="Reload" />
4+

dockbarx_mate_applet.in

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/python3
2+
3+
# dockbarx_mate_applet
4+
#
5+
# Copyright 2008, 2009, 2010 Aleksey Shaferov and Matias Sars
6+
# Copyright 2017 Alexey Hohlov
7+
#
8+
# DockbarX is free software: you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation, either version 3 of the License, or
11+
# (at your option) any later version.
12+
#
13+
# DockbarX is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License
19+
# along with dockbar. If not, see <http://www.gnu.org/licenses/>.
20+
21+
import gi
22+
gi.require_version("Gtk", "3.0")
23+
gi.require_version('MatePanelApplet', '4.0')
24+
from gi.repository import Gtk, GLib
25+
from gi.repository import MatePanelApplet
26+
27+
try:
28+
import sys
29+
import dockbarx.dockbar
30+
from dockbarx.log import *
31+
except Exception as e:
32+
print(e)
33+
sys.exit(1)
34+
35+
class DockbarMateApplet(object):
36+
def __init__(self, applet, iid):
37+
self.applet = applet
38+
self.size = None
39+
self.dockbar = dockbarx.dockbar.DockBar(self)
40+
applet.set_flags(MatePanelApplet.AppletFlags.HAS_HANDLE | \
41+
MatePanelApplet.AppletFlags.EXPAND_MINOR | \
42+
MatePanelApplet.AppletFlags.EXPAND_MAJOR)
43+
orients = {MatePanelApplet.AppletOrient.DOWN: "down",
44+
MatePanelApplet.AppletOrient.UP: "up",
45+
MatePanelApplet.AppletOrient.LEFT: "left",
46+
MatePanelApplet.AppletOrient.RIGHT: "right"}
47+
self.dockbar.set_orient(orients[applet.get_orient()])
48+
menu_actions = [("About", Gtk.STOCK_ABOUT, _("About"), None, None, self.dockbar.on_ppm_about),
49+
("Pref", Gtk.STOCK_PREFERENCES, _("Preferences"), None, None, self.dockbar.on_ppm_pref),
50+
("Reload", Gtk.STOCK_REFRESH, _("Refresh"), None, None, self.dockbar.reload)]
51+
actiongroup = Gtk.ActionGroup.new("DockBarXAppletActions")
52+
#actiongroup.set_translation_domain(dockbarx.defs.GETTEXT_PACKAGE)
53+
actiongroup.add_actions(menu_actions, None)
54+
applet.setup_menu_from_file("%PREFIX%/share/mate-panel/ui/dockbarx-applet-menu.xml", actiongroup)
55+
56+
# Set the applet coordinates to be way ofscreen until they've
57+
# been set correctly by a size allocate call.
58+
self.applet_origin_x = -1000
59+
self.applet_origin_y = -1000
60+
applet.connect("delete-event", self.__cleanup)
61+
applet.show_all()
62+
63+
# Most of initializion must happen after dockbarx is
64+
# realized since python mateapplets crash if it
65+
# takes too long to realize.
66+
GLib.idle_add(self.__load_on_realized)
67+
68+
def __load_on_realized(self):
69+
# Wait while gtk events are pending.
70+
while Gtk.events_pending():
71+
Gtk.main_iteration()
72+
# Load DockbarX.
73+
self.dockbar.load()
74+
# Add it to the applet.
75+
self.applet.add(self.dockbar.get_container())
76+
self.applet.show_all()
77+
# Connect events.
78+
self.applet.connect("size-allocate", self.__on_applet_size_alloc)
79+
#self.applet.connect("change_background", self.__on_change_background)
80+
self.applet.connect("change-orient", self.__on_change_orient)
81+
82+
def __on_applet_size_alloc(self, widget, allocation):
83+
if self.applet.get_orient() in (MatePanelApplet.AppletOrient.DOWN,
84+
MatePanelApplet.AppletOrient.UP):
85+
size = allocation.height
86+
else:
87+
size = allocation.width
88+
if self.size != size:
89+
self.dockbar.set_size(size)
90+
self.size = size
91+
if not widget.get_window():
92+
return
93+
#x,y = widget.get_window().get_origin()
94+
x,y = widget.get_window().get_root_coords(0, 0)
95+
if x == self.applet_origin_x or y == self.applet_origin_y:
96+
# Nothing moved.
97+
return
98+
# Applet and/or panel moved,
99+
# icon_geo needs to be updated.
100+
self.applet_origin_x = x
101+
self.applet_origin_y = y
102+
self.dockbar.dockbar_moved()
103+
104+
def __on_change_orient(self, arg1, data):
105+
orients = {MatePanelApplet.AppletOrient.DOWN: "down",
106+
MatePanelApplet.AppletOrient.UP: "up",
107+
MatePanelApplet.AppletOrient.LEFT: "left",
108+
MatePanelApplet.AppletOrient.RIGHT: "right"}
109+
self.applet.remove(self.dockbar.get_container())
110+
self.dockbar.set_orient(orients[self.applet.get_orient()])
111+
self.applet.add(self.dockbar.get_container())
112+
113+
def __on_change_background(self, applet, type, color, pixmap):
114+
applet.set_style(None)
115+
rc_style = Gtk.RcStyle()
116+
applet.modify_style(rc_style)
117+
if type == MatePanelApplet.AppletBackgroundType.COLOR_BACKGROUND:
118+
applet.modify_bg(Gtk.StateType.NORMAL, color)
119+
elif type == MatePanelApplet.AppletBackgroundType.PIXMAP_BACKGROUND:
120+
style = applet.style
121+
style.bg_pixmap[Gtk.StateType.NORMAL] = pixmap
122+
applet.set_style(style)
123+
return
124+
125+
def readd_container (self, container):
126+
self.applet.add(container)
127+
container.show_all()
128+
129+
def __cleanup(self,event):
130+
if hasattr(self.dockbar, "destroy"):
131+
self.dockbar.destroy()
132+
133+
134+
def applet_factory(applet, iid, data):
135+
DockbarMateApplet(applet, iid)
136+
return True
137+
138+
MatePanelApplet.Applet.factory_main("DockbarXAppletFactory", True,
139+
MatePanelApplet.Applet.__gtype__,
140+
applet_factory, None)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Applet Factory]
2+
Id=DockbarXAppletFactory
3+
InProcess=false
4+
Location=%PREFIX%/lib/mate-panel/dockbarx_mate_applet
5+
Name=DockBarX Applet
6+
Description=DockBarX Applet
7+
8+
[DockbarXApplet]
9+
Name=DockBarX Applet
10+
Description=DockBarX Applet
11+
Icon=dockbarx
12+
MateComponentId=OAFIID:MATE_DockbarXApplet;
13+
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[D-BUS Service]
2+
Name=org.mate.panel.applet.DockbarXAppletFactory
3+
Exec=%PREFIX%/lib/mate-panel/dockbarx_mate_applet

0 commit comments

Comments
 (0)