Fixed XFCE systray panel size detection, general code polish
This commit is contained in:
parent
0410a83a62
commit
3b36203df7
@ -38,7 +38,6 @@ import dorkbox.jna.linux.structs.GtkStyle;
|
|||||||
import dorkbox.jna.linux.structs.PangoRectangle;
|
import dorkbox.jna.linux.structs.PangoRectangle;
|
||||||
import dorkbox.os.OS;
|
import dorkbox.os.OS;
|
||||||
import dorkbox.os.OSUtil;
|
import dorkbox.os.OSUtil;
|
||||||
import dorkbox.swt.Swt;
|
|
||||||
import dorkbox.util.FileUtil;
|
import dorkbox.util.FileUtil;
|
||||||
import dorkbox.util.MathUtil;
|
import dorkbox.util.MathUtil;
|
||||||
|
|
||||||
@ -242,12 +241,13 @@ class GtkTheme {
|
|||||||
|
|
||||||
|
|
||||||
OSUtil.DesktopEnv.Env env = OSUtil.DesktopEnv.get();
|
OSUtil.DesktopEnv.Env env = OSUtil.DesktopEnv.get();
|
||||||
|
|
||||||
// sometimes the scaling-factor is set. If we have gsettings, great! otherwise try KDE
|
// sometimes the scaling-factor is set. If we have gsettings, great! otherwise try KDE
|
||||||
try {
|
try {
|
||||||
// gsettings get org.gnome.desktop.interface scaling-factor
|
// gsettings get org.gnome.desktop.interface scaling-factor
|
||||||
String output = Executor.Companion.run("gsettings", "get", "org.gnome.desktop.interface", "scaling-factor");
|
String output = Executor.Companion.run("gsettings", "get", "org.gnome.desktop.interface", "scaling-factor");
|
||||||
|
|
||||||
if (!output.isEmpty()) {
|
if (!output.isEmpty() && !output.endsWith("not found")) {
|
||||||
// DEFAULT icon size is 16. HiDpi changes this scale, so we should use it as well.
|
// DEFAULT icon size is 16. HiDpi changes this scale, so we should use it as well.
|
||||||
// should be: uint32 0 or something
|
// should be: uint32 0 or something
|
||||||
if (output.contains("uint32")) {
|
if (output.contains("uint32")) {
|
||||||
@ -379,7 +379,7 @@ class GtkTheme {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (OSUtil.Linux.isUbuntu() && OSUtil.DesktopEnv.isUnity(env)) {
|
if (OSUtil.Linux.isUbuntu() && OSUtil.DesktopEnv.isUnity(env)) {
|
||||||
// if we measure on ubuntu unity using a screen shot (using swing, so....) , the max size was 24, HOWEVER this goes from
|
// if we measure on ubuntu unity using a screen shot (using swing, so....) , the max size was 24, HOWEVER this goes from
|
||||||
// the top->bottom of the indicator bar -- and since it was swing, it uses a different rendering method and it (honestly)
|
// the top->bottom of the indicator bar -- and since it was swing, it uses a different rendering method and it (honestly)
|
||||||
@ -388,16 +388,22 @@ class GtkTheme {
|
|||||||
|
|
||||||
return 22;
|
return 22;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// xfce is easy, because it's not a GTK setting for the size (xfce notification area maximum icon size)
|
|
||||||
if (env == OSUtil.DesktopEnv.Env.XFCE) {
|
if (env == OSUtil.DesktopEnv.Env.XFCE) {
|
||||||
|
// xfce is easy, because it's not a GTK setting for the size (xfce notification area maximum icon size)
|
||||||
String properties = OSUtil.DesktopEnv.queryXfce("xfce4-panel", null);
|
String properties = OSUtil.DesktopEnv.queryXfce("xfce4-panel", null);
|
||||||
String[] propertiesAsList = properties.split(OS.LINE_SEPARATOR);
|
String[] propertiesAsList = properties.split(OS.LINE_SEPARATOR);
|
||||||
for (String prop : propertiesAsList) {
|
for (String prop : propertiesAsList) {
|
||||||
if (prop.startsWith("/plugins/") && prop.endsWith("/size-max")) {
|
if (prop.startsWith("/plugins/") && prop.endsWith("/size-max")) {
|
||||||
// this is the property we are looking for (we just don't know which panel it's on)
|
// this is the property we are looking for (we just don't know which panel it's on)
|
||||||
|
// note: trim() is required because it will strip new-line
|
||||||
|
|
||||||
String size = OSUtil.DesktopEnv.queryXfce("xfce4-panel", prop);
|
// xfconf-query -c xfce4-panel -p /plugins/plugin-14 (this will say 'systray' or 'tasklist' or whatever)
|
||||||
|
// find the 'systray' plugin
|
||||||
|
String panelString = prop.substring(0, prop.indexOf("/size-max"));
|
||||||
|
String panelName = OSUtil.DesktopEnv.queryXfce("xfce4-panel", panelString).trim();
|
||||||
|
if (panelName.equals("systray")) {
|
||||||
|
String size = OSUtil.DesktopEnv.queryXfce("xfce4-panel", prop).trim();
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(size);
|
return Integer.parseInt(size);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -407,18 +413,11 @@ class GtkTheme {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// default...
|
|
||||||
return 22;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// try to use GTK to get the tray icon size
|
// try to use GTK to get the tray icon size
|
||||||
final AtomicInteger traySize = new AtomicInteger();
|
final AtomicInteger traySize = new AtomicInteger();
|
||||||
|
|
||||||
|
|
||||||
if (Swt.isLoaded) {
|
|
||||||
} else {
|
|
||||||
GtkEventDispatch.dispatchAndWait(new Runnable() {
|
GtkEventDispatch.dispatchAndWait(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public
|
public
|
||||||
@ -462,14 +461,11 @@ class GtkTheme {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
int i = traySize.get();
|
int i = traySize.get();
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// sane default
|
// sane default
|
||||||
LoggerFactory.getLogger(GtkTheme.class).warn("Unable to get tray image size. Using default.");
|
LoggerFactory.getLogger(GtkTheme.class).warn("Unable to get tray image size. Using default.");
|
||||||
|
Loading…
Reference in New Issue
Block a user