Initial commit...

This commit is contained in:
2021-02-18 17:45:52 -06:00
parent dc3906fa9b
commit 1180e3171f
2159 changed files with 45470 additions and 2 deletions

View File

@@ -0,0 +1 @@
ude-desktop

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="ude-desktop" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM">
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
</component>
</project>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@@ -0,0 +1,181 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="da49a23f-ac53-4385-bed0-813ee5f947a4" name="Default Changelist" comment="" />
<ignored path="$PROJECT_DIR$/target/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/CleanPath.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="17" column="29" selection-start-line="17" selection-start-column="29" selection-end-line="17" selection-end-column="29" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/Thumbnail.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240">
<caret line="17" column="24" selection-start-line="17" selection-start-column="24" selection-end-line="17" selection-end-column="24" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/Settings.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="398">
<caret line="37" column="76" selection-start-line="37" selection-start-column="76" selection-end-line="37" selection-end-column="76" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="y" value="32" />
<option name="width" value="1920" />
<option name="height" value="1016" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="ude-desktop" type="b2602c69:ProjectViewProjectNode" />
<item name="UDE-Desktop" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="ude-desktop" type="b2602c69:ProjectViewProjectNode" />
<item name="UDE-Desktop" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="ude-desktop" type="b2602c69:ProjectViewProjectNode" />
<item name="UDE-Desktop" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="ude-desktop" type="b2602c69:ProjectViewProjectNode" />
<item name="UDE-Desktop" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1546130209215" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="UDEDesktop" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="UDEDesktop" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.UDEDesktop" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="da49a23f-ac53-4385-bed0-813ee5f947a4" name="Default Changelist" comment="" />
<created>1546129975632</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1546129975632</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="-2" y="31" width="1924" height="1019" extended-state="6" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.25239617" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" />
<window_info id="UI Designer" order="4" />
<window_info id="Capture Tool" order="5" />
<window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Terminal" order="7" />
<window_info anchor="bottom" id="Event Log" order="8" side_tool="true" />
<window_info anchor="bottom" id="Version Control" order="9" />
<window_info anchor="bottom" id="Messages" order="10" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" id="Maven" order="4" />
<window_info anchor="right" id="Theme Preview" order="5" />
<window_info anchor="right" id="Capture Analysis" order="6" />
<window_info anchor="right" id="Palette&#9;" order="7" />
</layout>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/main/java/CleanPath.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="17" column="29" selection-start-line="17" selection-start-column="29" selection-end-line="17" selection-end-column="29" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/Thumbnail.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240">
<caret line="17" column="24" selection-start-line="17" selection-start-column="24" selection-end-line="17" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/Settings.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="398">
<caret line="37" column="76" selection-start-line="37" selection-start-column="76" selection-end-line="37" selection-end-column="76" />
</state>
</provider>
</entry>
</component>
</project>

View File

@@ -0,0 +1,17 @@
# UDE Desktop Environment
This is a mavenized version of UDE.
Compile:
```sh
$ cd <project-dir>
$ mvn clean install
```
Run:
```sh
$ cd <project-dir>
$ java -jar target/ude-desktop.jar
```

View File

@@ -0,0 +1,82 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github</groupId>
<artifactId>ude-desktop</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>UDE Desktop Environment</name>
<description>UDE is a Java desktop environment that has both a file manager and desktop.</description>
<url>https://github.com/maximstewart/UDE</url>
<licenses>
<license>
<name>GNU General Public License v2.0</name>
<url>https://github.com/maximstewart/UDE/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<name>Maxim Stewart</name>
<email>MaximStewart1@gmail.com</email>
<id>maximstewart</id>
</developer>
</developers>
<issueManagement>
<url>https://github.com/maximstewart/UDE/issues</url>
<system>GitHub Issues</system>
</issueManagement>
<scm>
<connection>https://github.com/maximstewart/UDE.git</connection>
<developerConnection>git@github.com:maximstewart/UDE.git</developerConnection>
<url>https://github.com/maximstewart/UDE</url>
</scm>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.maven-compiler-plugin>3.7.0</version.maven-compiler-plugin>
<version.spring-boot-maven-plugin>2.0.4.RELEASE</version.spring-boot-maven-plugin>
</properties>
<build>
<finalName>ude-desktop</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.maven-compiler-plugin}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${version.spring-boot-maven-plugin}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<!--<classifier>spring-boot</classifier>-->
<mainClass>UDEDesktop</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,40 @@
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Scene;
public class BackgroundManager {
protected final Stage backgroundStage = new Stage();
protected Scene scene;
// Private class to generate singleton
private static BackgroundManager backgroundManager = new BackgroundManager();
// init
private BackgroundManager() {
// Setup window
try {
scene = new Scene(FXMLLoader.load(BackgroundManager.class.getResource("resources/BackgroundManagerWindow.fxml")), 800, 600);
} catch (Exception e) {
// If it fails, write the error message to screen
e.printStackTrace();
}
backgroundStage.setScene(scene);
backgroundStage.setTitle("Background");
backgroundStage.setMinWidth(300);
backgroundStage.setMinHeight(300);
}
// Functions
// Geters
public static BackgroundManager getInstance() {
return backgroundManager;
}
// Setters
// Others
protected void showWindow() {
backgroundStage.show();
}
}

View File

@@ -0,0 +1,147 @@
import javafx.stage.Stage;
import javafx.stage.DirectoryChooser;
import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.TilePane;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.event.ActionEvent;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.KeyCode;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.MouseButton;
import java.io.File;
import javafx.concurrent.Task;
public class BackgroundMngrController {
// Class objects
private Settings settings = Settings.getInstance(); // Singleton Class settings
// Fxml objects
@FXML
private Label dir;
@FXML
private TextField txtDirPath;
@FXML
private Button clear;
@FXML
private TilePane tilePane;
// Generics
private DirectoryChooser folderChooser = new DirectoryChooser();
private Image pth = new Image(".");
private Image previewPth = new Image(".");
private ImageView imgView = new ImageView(pth);
private String textAreaPth = "";
private File directory;
private File[] fileList;
@FXML
void initialize() {
// Initialize any logic here: all @FXML variables will have been injected
}
@FXML
void onEnter(KeyEvent event) {
if (event.getCode().equals(KeyCode.ENTER)) {
textAreaPth = txtDirPath.getText();
System.out.println(textAreaPth);
newDir();
}
}
@FXML
void setNewDir(MouseEvent event) {
newDir();
}
// Scan selected dir
public void newDir() {
tilePane.getChildren().clear();
Stage stage = new Stage();
if (textAreaPth != "") {
directory = new File(textAreaPth);
} else {
directory = folderChooser.showDialog(stage);
if (directory != null) {
System.out.println("Directory: " + directory);
}
}
fileList = directory.listFiles();
txtDirPath.setText("" + directory);
for (int i = 0; i < fileList.length; i++) {
imgView = new ImageView();
imgView.setFitWidth(300); // Need these here to get grid properly.
imgView.setFitHeight(200);
tilePane.getChildren().add(imgView);
}
Task getDir = new Task<Void>() {
@Override
public Void call() {
newDir2();
return null;
}
};
new Thread(getDir).start();
}
public void newDir2() {
int j = 0; // Used to properly insert to grid when there are files other than an image
for (int i = 0; i < fileList.length; i++) {
String path = "" + fileList[i];
if (fileList[i].getName().contains(".png") || fileList[i].getName().contains(".jpg")
|| fileList[i].getName().contains(".gif") || fileList[i].getName().contains(".jpeg")) {
String title = "" + fileList[i];
pth = new Image("file://" + fileList[i]);
ImageView view = (ImageView) (tilePane.getChildren().get(j));
view.setImage(pth);
view.setCache(true);
final ImageView imgViewPoped = new ImageView("file://" + fileList[i]);
// image click actions
view.setOnMouseClicked(mouse -> {
MouseButton button = mouse.getButton();
if (mouse.getClickCount() == 2 && button == MouseButton.PRIMARY && !mouse.isConsumed()) {
mouse.consume();
txtDirPath.setText(path);
settings.setBackgroundInfo(path);
} else if (button == MouseButton.SECONDARY) {
displayImg(imgViewPoped, title);
}
});
j++;
} else {
System.out.println("Not an image file.");
}
}
}
public void displayImg(ImageView imgViewPoped, String title) {
Stage popOut = new Stage();
Pane pane = new Pane();
imgViewPoped.setLayoutX(0);
imgViewPoped.setLayoutY(0);
imgViewPoped.fitWidthProperty().bind(pane.widthProperty());
imgViewPoped.fitHeightProperty().bind(pane.heightProperty());
pane.getChildren().add(imgViewPoped);
Scene scene = new Scene(pane, 1280, 900);
popOut.setTitle(title);
popOut.setScene(scene);
popOut.show();
}
@FXML
void clearBttnClick(ActionEvent event) {
tilePane.getChildren().clear();
tilePane.getChildren().addAll(dir);
txtDirPath.setText("");
}
}

View File

@@ -0,0 +1,29 @@
// Clear file of special characters and spaces
import java.io.File;
public class CleanPath {
private String preLine = "";
public String cleanThumbPth(String tmp) {
File f = new File(tmp);
// if it's a directory, don't remove the extention
if (f.isDirectory()) {
System.out.println("This is a a directory.");
}
String name = f.getName();
final int lastPeriodPos = name.lastIndexOf('.');
if (lastPeriodPos <= 0) {
preLine = "" + name;
} else {
// Remove the last period and everything after it
File renamed = new File(f.getParent(), name.substring(0, lastPeriodPos));
preLine = "" + renamed;
preLine = preLine.replaceAll("[^A-Za-z]+", "");
preLine = preLine.replaceAll("\\s+", "");
}
return preLine;
}
}

View File

@@ -0,0 +1,85 @@
import javafx.fxml.FXML;
import javafx.scene.layout.AnchorPane;
import javafx.scene.image.ImageView;
import javafx.scene.control.ContextMenu;
import javafx.scene.input.ContextMenuEvent;
import javafx.scene.control.MenuItem;
import javafx.event.EventHandler;
public class Controller {
// Class objects
private Settings settings = Settings.getInstance(); // Singleton Class settings
// Fxml objects
@FXML private AnchorPane desktopArea;
@FXML private ImageView backgroundImgView;
// Generics
private int x = 0, y = 0, found = 0; // x & y for grid generation
private boolean isMain = false;
private ContextMenu contextMenu = new ContextMenu();
final private MenuItem settingsMenuItm = new MenuItem("Settings"),
chngBckgrndMenuItem = new MenuItem("Desktop Background");
public Controller(boolean isMain) {
this.isMain = isMain;
}
@FXML void initialize() {
// Create ContextMenu
settingsMenuItm.setOnAction(e -> {
settings.showWindow();
});
chngBckgrndMenuItem.setOnAction(e -> {
settings.callBackgroundMngr();
});
// Add MenuItem to ContextMenu
contextMenu.getItems().addAll(settingsMenuItm, chngBckgrndMenuItem);
// When user right-click on desktop
desktopArea.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
@Override
public void handle(ContextMenuEvent event) {
contextMenu.show(desktopArea, event.getScreenX(), event.getScreenY());
}
});
settings.setsettingsImgView(backgroundImgView);
// backgroundImgView.setImage(settings.getBackgroundInfo());
backgroundImgView.setFitWidth(1920); // Scale to view Note: need to do based on system parameters
backgroundImgView.setFitHeight(1080);
if (isMain) {
addIconTiles();
}
}
// set icons to desktop view
// Possibly too many calls....
void addIconTiles() {
if (settings.getDesktopItems() != null) {
for (int i = 0; i < settings.getDesktopItems().length; i++) {
Icon icon = new Icon();
final String fileName = "" + settings.getDesktopItems()[i].getName(),
file = "" + settings.getDesktopItems()[i];
// Create Icon and position icon on grid according to parameters
// passes desktop, path, name, index, and x and y coridinits
icon.createIcon(desktopArea, file, fileName, i, x, y);
desktopArea.getChildren().add(icon.getIcon());
desktopArea.setLeftAnchor(icon.getIcon(), (double) x);
desktopArea.setTopAnchor(icon.getIcon(), (double) y);
// Grid management
x += 160;
if (x >= 1600) {
x = 0;
y += 150;
}
}
}
}
}

View File

@@ -0,0 +1,138 @@
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import javafx.scene.input.MouseEvent;
import javafx.event.EventHandler;
import java.util.Scanner;
import java.io.File;
public class Icon {
// Class objects
private Thumbnail thumbnail = new Thumbnail();
// Generics
private VBox icon = new VBox();
private Image img;
private ImageView imgView = new ImageView();
private Label title = new Label("");
private Tooltip tooltip;
private Process pb; // Process runner
private Scanner scanner;
private File file;
private String containsStr = System.getProperty("user.home") + "/Desktop/",
toLaunch = "", runCommand = "", thumbImg = "",
toShellOut = "", toShellExec = "", line = "",
path = "", name = "";
private double orgSceneX, orgSceneY, orgTranslateX, orgTranslateY;
private double iconWidth = 150.0, iconHeight = 100.0;
public VBox getIcon() {
return icon;
}
public void createIcon(AnchorPane desktopArea, String pth, String nme,
int i, int x, int y) {
icon.getStyleClass().add("vbox");
path = pth;
name = nme;
// Creates Icon parts for desktop and sets click actions
getIconImg();
mergeIconParts();
setExecuteModel();
setIconEvents(desktopArea);
}
private void getIconImg() {
thumbnail.setIconImg(path, name);
thumbImg = thumbnail.getIconImg();
System.out.println("b4 insert " + thumbImg);
img = new Image("file:" + thumbImg);
imgView.setImage(img);
imgView.setFitWidth(iconWidth); // Need these here to get grid properly.
imgView.setFitHeight(iconHeight);
imgView.setCache(true); // Improves responsiveness when there are many images
}
private void mergeIconParts() {
title.setMaxWidth(iconWidth); // Based On Character Count??
title.setText(name);
tooltip = new Tooltip(name);
tooltip.minHeight(800);
tooltip.minWidth(800);
Tooltip.install(icon, tooltip);
icon.getChildren().addAll(imgView, title); // Insert image and name to icon VBox container
}
private void setExecuteModel() {
// Set file execution for .desktop files else use xdg-open
toLaunch = path;
if (path.contains(".desktop")) {
file = new File(path);
try {
scanner = new Scanner(file);
while (scanner.hasNext()) {
line = scanner.nextLine();
if (line.contains("Exec=")) {
toShellOut = line;
break;
}
}
} catch (Throwable lineErr) {
System.out.println("Failed To Get Exec Info: " + lineErr);
}
if (toShellOut.contains("TryExec=")) {
toShellOut = toShellOut.replaceAll("TryExec=", "");
} else if (toShellOut.contains("Exec=")) {
toShellOut = toShellOut.replaceAll("Exec=", "");
}
runCommand = toShellOut;
} else {
runCommand = "xdg-open " + toLaunch;
}
}
private void setIconEvents(AnchorPane desktopArea) {
icon.addEventFilter(MouseEvent.MOUSE_PRESSED,
new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent click) {
if (click.getClickCount() == 2) {
click.consume();
try {
System.out.println(runCommand);
pb = Runtime.getRuntime().exec(runCommand);
} catch (Throwable imgIOErr) {
System.out.println(imgIOErr);
}
} else {
orgSceneX = click.getSceneX();
orgSceneY = click.getSceneY();
orgTranslateX = desktopArea.getLeftAnchor(icon);
orgTranslateY = desktopArea.getTopAnchor(icon);
}
}
});
icon.addEventFilter(MouseEvent.MOUSE_DRAGGED,
new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent clck) {
double offsetX = clck.getSceneX() - orgSceneX;
double offsetY = clck.getSceneY() - orgSceneY;
double newTranslateX = orgTranslateX + offsetX;
double newTranslateY = orgTranslateY + offsetY;
desktopArea.setLeftAnchor(icon, newTranslateX);
desktopArea.setTopAnchor(icon, newTranslateY);
}
});
}
}

View File

@@ -0,0 +1,136 @@
// :: NOTES ::
// Read file for Icon= to get the desktop's icon. Then look for it in:
// Steam --> ~/.local/share/icons/hicolor/256x256/apps/.
// --> ~/.local/share/applications/
// Other Icons --> /usr/share/icons/<themeName>/<size>
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import java.io.File;
import java.util.Scanner;
public class Settings {
// Class objects
protected final Stage settingsStage = new Stage();
private BackgroundManager backgroundManager = BackgroundManager.getInstance(); // Singleton Class backgroundManager
// Generics
protected Scene scene;
private File thumbDirPth = new File("thumbs/"),
desktopDir = new File(System.getProperty("user.home") + "/Desktop/"),
highColorDir = new File(System.getProperty("user.home")
+ "/.local/share/icons/hicolor/256x256/apps/"),
localApplicationsDir = new File(System.getProperty("user.home")
+ "/.local/share/applications/");
private File[] desktopItems = desktopDir.listFiles(), // Gets files in desktop folder
thumbsList = thumbDirPth.listFiles(), // Gets video thumbnail list
highColorDirList = highColorDir.listFiles(),
localApplicationsDirList = localApplicationsDir.listFiles();
private String imgPath, line, defaultBG = "resources/generic-theme/background.png";
private Image backgroundImg;
private ImageView bgView;
private Scanner scanner;
private File file = new File(System.getProperty("user.home") + "/ude-config.txt");
// Private class to generate singleton
private static Settings settings = new Settings();
// init
private Settings() {
// Setup window
try {
scene = new Scene(FXMLLoader.load(Settings.class.getResource("resources/SettingsManagerWindow.fxml")), 800, 600);
} catch (Exception e) {
// If it fails, write the error message to screen
e.printStackTrace();
}
settingsStage.setScene(scene);
settingsStage.setTitle("Settings");
settingsStage.setMinWidth(300);
settingsStage.setMinHeight(300);
// load settings info from file by reading line by line
if (file.exists()) {
try {
scanner = new Scanner(file);
while (scanner.hasNext()) {
line = scanner.nextLine();
if (line.contains("Background=")) {
line = line.replaceAll("Background=", "");
if (line.isEmpty()) {
backgroundImg = new Image(defaultBG);
} else {
backgroundImg = new Image("file://" + line);
break;
}
}
}
} catch (Throwable lineErr) {
backgroundImg = new Image(defaultBG);
System.out.println("Failed To Get Config Info: " + lineErr);
}
} else {
backgroundImg = new Image(defaultBG);
System.out.println("Config file does not exist.");
}
}
// Functions
// Geters
public static Settings getInstance() {
return settings;
}
protected Image getBackgroundInfo() {
return backgroundImg;
}
protected String getImgPath() {
return imgPath;
}
protected File getThumbDirPth() {
return thumbDirPth;
}
protected File[] getDesktopItems() {
return desktopItems;
}
protected File[] getThumbsList() {
return thumbsList;
}
protected File[] getHighColorDirList() {
return highColorDirList;
}
protected File[] getLocalApplicationsDirList() {
return localApplicationsDirList;
}
// Setters
protected void setsettingsImgView(ImageView imgVw) {
bgView = imgVw;
}
protected void setBackgroundInfo(String file) {
imgPath = file;
bgView.setImage(new Image("file://" + file));
}
// Others
protected void callBackgroundMngr() {
showWindow();
backgroundManager.showWindow();
}
protected void showWindow() {
settingsStage.show();
}
}

View File

@@ -0,0 +1,75 @@
// Generates the actual image of the icon.
import java.util.Scanner;
import java.io.File;
public class Thumbnail {
// Class objects
private Settings settings = Settings.getInstance(); // Singleton Class
private CleanPath cleaner = new CleanPath(); // Cleans thumbnail names
private ThumbnailGenerator vidThumbnailGen = new ThumbnailGenerator();
// Generics
private Scanner scanner;
private File file;
private String thumbImg = "", line = "", temp = "";
public String getIconImg() {
return thumbImg;
}
public void setIconImg(String path, String name) {
File[] highColorDirList = settings.getHighColorDirList();
File[] localApplicationsDirList = settings.getLocalApplicationsDirList();
temp = path.toLowerCase();
if (temp.matches("^.*?(avi|webm|mpeg|mpg|mkv|flv|wmv|mp4).*$")) {
thumbImg = vidThumbnailGen.generateThumb(path, cleaner.cleanThumbPth(name));
} else if (temp.matches("^.*?(png|svg|jpg|jpeg|tiff).*$")) {
thumbImg = path;
} else if (temp.contains(".desktop")) {
file = new File(path);
try {
scanner = new Scanner(file);
while (scanner.hasNext()) {
line = scanner.nextLine();
if (line.contains("Icon=")) {
thumbImg = line;
break;
}
}
} catch (Throwable lineErr) {
System.out.println("Failed To Get Icon: " + lineErr);
}
thumbImg = thumbImg.replaceAll("Icon=", ""); // Strip Icon= from the icon info
// Steam Icons
if (thumbImg.contains("steam_icon")) {
for (int i = 0; i < highColorDirList.length; i++) {
if (highColorDirList[i].toString().contains(thumbImg)) {
thumbImg = "" + highColorDirList[i];
}
}
for (int i = 0; i < localApplicationsDirList.length; i++) {
if (localApplicationsDirList[i].toString().contains(thumbImg)) {
thumbImg = "" + localApplicationsDirList[i];
}
}
}
} else {
// use getGenericIcon.py to get generic icon
// String command = "python getGenericIcon.py " + path, shellOut = "";
// try {
// scanner = new Scanner(Runtime.getRuntime().exec(command).getInputStream()).useDelimiter("\\A");
// shellOut = (scanner.hasNext()) ? scanner.next() : "";
// scanner = new Scanner(Runtime.getRuntime().exec("readlink -f " + shellOut).getInputStream()).useDelimiter("\\A");
// shellOut = (scanner.hasNext()) ? scanner.next() : "t";
// } catch (Throwable e) {
// System.out.println("Exception Caught In Thumbnail.\n" + e);
// }
// thumbImg = shellOut;
thumbImg = "generic-theme/genericfile.png";
}
}
}

View File

@@ -0,0 +1,21 @@
// Generate Thumbnails for videos with ffmpegthumbnailer
public class ThumbnailGenerator {
private Process pb; // Process runner
private String thumbName, genCommand;
public String generateThumb(String file, String thumb) {
thumbName = thumb;
genCommand = "ffmpegthumbnailer -w -t='00:30:00' -c png -i "
+ file + " -s 300 -o " + "thumbs/" + thumbName + ".png";
try {
pb = Runtime.getRuntime().exec(genCommand);
pb.waitFor();
} catch (Throwable imgIOErr) {
System.out.println(imgIOErr);
}
thumbName = "./thumbs/" + thumbName + ".png";
return thumbName;
}
}

View File

@@ -0,0 +1,63 @@
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.scene.Scene;
import javafx.scene.Parent;
public class UDEDesktop extends Application {
// Classes
// Generics
private static final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
private static final GraphicsDevice[] screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
private static boolean isMain = true;
@Override public void start(final Stage stg) throws Exception {
for (int i=0; i<screens.length; i++) {
FXMLLoader loader = new FXMLLoader(getClass().getResource("resources/UDEDesktopWindow.fxml"));
Controller ctrllr = new Controller(isMain);
loader.setController(ctrllr);
Parent root = loader.load();
Stage stage = new Stage();
double width = (double) screens[i].getDisplayMode().getWidth();
double height = (double) screens[i].getDisplayMode().getHeight();
Scene scene = new Scene(root, width, height);
scene.getStylesheets().add("resources/stylesheet.css");
scene.setFill(null);
// AnchorPane ap = new AnchorPane();
// ap.setMinSize(width, height);
// stage.initStyle(StageStyle.TRANSPARENT);
stage.initStyle(StageStyle.UNDECORATED);
stage.setScene(scene);
stage.show();
// stage.setX(screens[i].getDisplayMode().getX());
// stage.setY(screens[i].getDisplayMode().getY());
stage.toBack();
isMain = false;
}
// int width = screens[0].getDisplayMode().getWidth();
// int height = screens[0].getDisplayMode().getHeight();
// Controller ctrl = new Controller();
// FXMLLoader loader = new FXMLLoader(UDEDesktop.class.getResource("UDEDesktopWindow.fxml"))
// loader.setController(mc);
//
// Scene scene = new Scene(, width, height);
// scene.setFill(null);
// scene.getStylesheets().add("stylesheet.css");
// stage.setScene(scene);
// stage.initStyle(StageStyle.UNDECORATED);
// stage.setTitle("UDEDesktop");
// stage.show();
// stage.toBack();
}
// needed because you know... it's java.
public static void main(String[] args) { launch(args); }
}

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.TilePane?>
<?import javafx.scene.text.Font?>
<?scenebuilder-background-color 0x444444ff?>
<AnchorPane minHeight="300.0" minWidth="300.0" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="BackgroundMngrController">
<children>
<HBox alignment="TOP_RIGHT" layoutY="0.0" prefHeight="21.0" prefWidth="948.0" AnchorPane.leftAnchor="1.0" AnchorPane.rightAnchor="1.0">
<children>
<TextField fx:id="txtDirPath" blendMode="DIFFERENCE" onKeyReleased="#onEnter" prefWidth="200.0" promptText="Dir Path" HBox.hgrow="ALWAYS" />
<Button fx:id="clear" mnemonicParsing="false" onAction="#clearBttnClick" text="Clear" />
</children>
</HBox>
<ScrollPane id="ScrollPane" minHeight="300.0" minWidth="300.0" prefHeight="547.0" prefViewportHeight="534.0" prefViewportWidth="742.0" prefWidth="770.0" style=" -fx-fit-to-height: true;&#10; -fx-fit-to-width: true;" AnchorPane.bottomAnchor="-2.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="25.0">
<content>
<TilePane fx:id="tilePane" hgap="15.0" prefHeight="532.0" prefWidth="755.0" vgap="15.0">
<children>
<Label fx:id="dir" contentDisplay="CENTER" labelFor="$clear" onMouseClicked="#setNewDir" prefHeight="575.0" prefWidth="948.0" text="Choose Dir" textAlignment="LEFT" textFill="#dfdfdf" textOverrun="CLIP" underline="false" wrapText="false" TilePane.alignment="CENTER_LEFT">
<font>
<Font name="System Bold" size="32.0" />
</font>
<TilePane.margin>
<Insets />
</TilePane.margin>
</Label>
</children>
</TilePane>
</content>
</ScrollPane>
</children>
</AnchorPane>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.layout.AnchorPane?>
<?scenebuilder-background-color 0x444444ff?>
<AnchorPane fx:id="desktopArea" minHeight="300.0" minWidth="300.0" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
<children>
<CheckBox fx:id="toGridOrNaw" layoutX="85.0" layoutY="558.0" mnemonicParsing="false" text="Gridded View or Free Form View" />
</children>
</AnchorPane>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Rectangle2D?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?scenebuilder-background-color 0x444444ff?>
<AnchorPane fx:id="desktopArea" minHeight="300.0" minWidth="300.0" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ImageView fx:id="backgroundImgView" fitHeight="600.0" fitWidth="950.0" mouseTransparent="true" pickOnBounds="true" preserveRatio="true" x="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<viewport>
<Rectangle2D />
</viewport>
</ImageView>
</children>
</AnchorPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -0,0 +1,14 @@
.root {
/*-fx-background: rgba(68, 68, 68, 0.8); // == #444444;*/
-fx-background: rgba(0, 0, 0, 0.0);
}
.button {
}
.vbox {
-fx-background-color: rgba(68, 68, 68, .5);
}
.vbox:hover {
-fx-background-color: rgba(68, 68, 68, 1)s
}

View File

@@ -0,0 +1,2 @@
Background=
/home/abaddon/LazyShare/Pictures/Background/Budah.jpg