Commit 02a7b4e7 authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

Integration of GlobalVariables.java, Skin.java, TreeRenderer.java into the translation system

parent 1415cfe8
......@@ -51,6 +51,8 @@ WIN_RES_EDIT|Edit the selected resource
WIN_RES_DELETE|Delete the selected resource
WIN_RES_PU_ADD_BMP|Add Bitmap/s
WIN_RES_PU_ADD_SBMP|Add SubBitmap
WIN_RES_BITMAPS|Bitmaps
WIN_RES_FONTS|Fonts
#Windows window
WIN_WIN_TITLE|Windows
......@@ -202,6 +204,26 @@ ACTION_UNMAXIMIZE|Unmaximize the window with the ID
ACTION_LAYOUT_OF|Set the Layout of the window with the ID
ACTION_TO| to
#Global variables
WIN_VARS_TITLE|Global variables
WIN_VARS_NOTE|<html>These variables only affect the preview.<br>They simulate the state of VLC.</html>
WIN_VARS_SLIDER|Slider position
#Theme options
WIN_THEME_TITLE|Theme settings
WIN_THEME_NAME|Name:
WIN_THEME_AUTHOR|Author:
WIN_THEME_EMAIL|Author's E-Mail:
WIN_THEME_WEB|Author's webpage:
WIN_THEME_MAGNET|Magnet:
WIN_THEME_MAGNET_TIP|When the distance between the border of the screen and an anchor of a window is less than this value, the window will stick to the border
WIN_THEME_ALPHA|Opacity:
WIN_THEME_ALPHA_TIP|Sets the alpha transparency of the windows. The value must be between 1 (nearly total transparency) and 255 (total opacity). Low values should be avoided.
WIN_THEME_MOVEALPHA|Opacity when moving:
WIN_THEME_MOVEALPHA_TIP|Sets the alpha transparency of the windows when they are moved.
WIN_THEME_INFO_TITLE|Theme information
WIN_THEME_ATTR_TITLE|Theme attributes
#Messages
ABOUT_TITLE|About VLC Skin Editor
ABOUT_MSG|<html><h3>Copyright 2007-%y The VideoLAN Team</h3>Released under terms of the GPL 2+<br><br><b>Lead programmer:</b> Daniel Dreibrodt (daniel.dreibrodt@googlemail.com)<br><b>Website:</b> %w<br><br><b>Credits:</b><br>Timothy Gerard Endres for registry access and TAR support (Public Domain)<br>The Tango! Desktop Project (http://tango.freedesktop.org) for some icons (Creative Commons BY-SA 2.5)<br>Cyril Deguet (asmax@via.ecp.fr) and Olivier Teuli&egrave;re (ipkiss@via.ecp.fr) for the Boolean Expression Evaluator and Bezier code (GPL 2+)</html>
......@@ -233,6 +255,11 @@ BUTTON_OK|OK
BUTTON_CANCEL|Cancel
BUTTON_HELP|Help
#Other strings
THEMEINFO_NAME_DEFAULT|Unnamed Theme
THEMEINFO_AUTHOR_DEFAULT|Unknown Author
THEMEINFO_EMAIL_DEFAULT|Unknown
#Error messages
ERROR_FILENEXIST_TITLE|Error while opening file
ERROR_FILENEXIST_MSG|The file "%f" does not exist and thus could not be opened!
......@@ -253,4 +280,15 @@ ERROR_ADD_LAYOUT_TITLE|Could not add layout
ERROR_ADD_LAYOUT_MSG|No parent window selected!
ERROR_UPDATE_TITLE|Error while updating!
ERROR_SAVEPNG_TITLE|Error while saving preview image
ERROR_SAVEPNG_MSG|Could not save preview image.
\ No newline at end of file
ERROR_SAVEPNG_MSG|Could not save preview image.
ERROR_NEWSKIN_TITLE|Error while creating new skin file!
ERROR_NEWSKIN_MSG|The new skin file could not be created.
ERROR_INVALID_HEADER|File appears not to be a valid VLC Theme!\n Invalid header:
ERROR_INVALID_FILE|Selected file is not a valid VLC skin file!
ERROR_VERSION_UNSUPPORTED|The version of the theme used in the selected skin is not yet supported!
ERROR_SAVE_TITLE|Error while saving the skin file!
ERROR_SAVE_MSG|Skin file could not be saved.
ERROR_ALPHA_TITLE|Opacity value not valid
ERROR_ALPHA_MSG|Please enter a valid opacity! (0-255)
ERROR_MALPHA_TITLE|Opacity when moving not valid
ERROR_MALPHA_MSG|Please enter a valid opacity when moving! (0-255)
\ No newline at end of file
......@@ -218,11 +218,11 @@ public class GlobalVariables implements ActionListener{
/** Creates and shows the dialog to modify the global variables */
public void showOptions() {
if(frame==null) {
frame = new JFrame("Global variables");
frame = new JFrame(Language.get("WIN_VARS_TITLE"));
frame.setResizable(false);
frame.setLayout(null);
JLabel desc_l = new JLabel("<html>These variables only affect the preview.<br>They simulate the state of VLC.</html>");
JLabel desc_l = new JLabel(Language.get("WIN_VARS_NOTE"));
Object[] bool_values = { true, false };
JLabel eq_l = new JLabel("equalizer.isEnabled");
eq_cb = new JComboBox(bool_values);
......@@ -252,7 +252,7 @@ public class GlobalVariables implements ActionListener{
repeat_cb = new JComboBox(bool_values);
JLabel dvd_l = new JLabel("dvd.isActive");
dvd_cb = new JComboBox(bool_values);
JLabel slider_l = new JLabel("Slider position");
JLabel slider_l = new JLabel(Language.get("WIN_VARS_SLIDER"));
slider_s = new JSlider(JSlider.HORIZONTAL,0,100,0);
slider_s.setMajorTickSpacing(10);
slider_s.setMinorTickSpacing(5);
......@@ -260,9 +260,9 @@ public class GlobalVariables implements ActionListener{
slider_s.setSize(100,20);
ok_btn = new JButton("OK");
ok_btn = new JButton(Language.get("BUTTON_OK"));
ok_btn.addActionListener(this);
help_btn = new JButton("Help");
help_btn = new JButton(Language.get("BUTTON_HELP"));
help_btn.addActionListener(this);
frame.add(desc_l);
......
......@@ -77,9 +77,9 @@ public class Skin implements ActionListener{
public int theme_magnet = THEME_MAGNET_DEFAULT;
public int theme_alpha = THEME_ALPHA_DEFAULT;
public int theme_movealpha = THEME_MOVEALPHA_DEFAULT;
final String THEMEINFO_NAME_DEFAULT = "Unnamed Theme";
final String THEMEINFO_AUTHOR_DEFAULT = "Unknown Author";
final String THEMEINFO_EMAIL_DEFAULT = "Unknown";
final String THEMEINFO_NAME_DEFAULT = Language.get("THEMEINFO_NAME_DEFAULT");
final String THEMEINFO_AUTHOR_DEFAULT = Language.get("THEMEINFO_AUTHOR_DEFAULT");
final String THEMEINFO_EMAIL_DEFAULT = Language.get("THEMEINFO_EMAIL_DEFAULT");
final String THEMEINFO_WEBPAGE_DEFAULT = "http://www.videolan.org/vlc/";
public String themeinfo_name = THEMEINFO_NAME_DEFAULT;
public String themeinfo_author = THEMEINFO_AUTHOR_DEFAULT;
......@@ -116,7 +116,7 @@ public class Skin implements ActionListener{
skinfile.createNewFile();
}
catch(Exception ex) {
JOptionPane.showMessageDialog(null,ex.toString(),"Error while creating new skin file!",JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null,Language.get("ERROR_NEWSKIN_TITLE")+"\n\n"+ex.toString(),Language.get("ERROR_NEWSKIN_TITLE"),JOptionPane.ERROR_MESSAGE);
}
}
/** Parses an XML file **/
......@@ -162,8 +162,9 @@ public class Skin implements ActionListener{
//System.out.println("Header read");
if (header.indexOf("//VideoLAN//DTD VLC Skins")==-1) {
br.close();
//System.out.println("Invalid header");
throw new Exception("File appears not to be a valid VLC Theme!\nInvalid Header:\n"+header);
System.err.println("Invalid header:\n"+header);
throw new Exception(Language.get("ERROR_INVALID_FILE"));
}
//System.out.println("Valid header");
boolean eof = false;
......@@ -273,7 +274,7 @@ public class Skin implements ActionListener{
Document doc = docBuilder.parse(f);
if(!doc.getDoctype().getName().equals("Theme"))
throw new Exception("Selected file is not a valid VLC skin file!");
throw new Exception(Language.get("ERROR_INVALID_FILE"));
NodeList nodes = doc.getElementsByTagName("*");
for(int i=0;i<nodes.getLength();i++) {
......@@ -286,7 +287,7 @@ public class Skin implements ActionListener{
if(tag.equals("Theme")) {
if(e.hasAttribute("version")) theme_version = e.getAttribute("version");
if(Double.parseDouble(theme_version)!=2.0)
throw new Exception("The version of the theme used in the selected skin is not yet supported!");
throw new Exception(Language.get("ERROR_VERSION_UNSUPPORTED"));
}
else if(tag.equals("ThemeInfo")) {
if(e.hasAttribute("author")) themeinfo_author = e.getAttribute("author");
......@@ -316,45 +317,45 @@ public class Skin implements ActionListener{
writer.close();
}
catch(Exception ex) {
JOptionPane.showMessageDialog(null,ex.toString(),"Error while saving skin file!",JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null,Language.get("ERROR_SAVE_MSG")+"\n\n"+ex.toString(),Language.get("ERROR_SAVE_TITLE"),JOptionPane.ERROR_MESSAGE);
}
}
/** Show the theme setting editing dialog **/
public void showThemeOptions() {
if(theme_frame==null) {
theme_frame = new JFrame("Theme settings");
theme_frame = new JFrame(Language.get("WIN_THEME_TITLE"));
theme_frame.setResizable(false);
theme_frame.setLayout(new FlowLayout());
theme_frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
JLabel themeinfo_name_l = new JLabel("Name:");
JLabel themeinfo_name_l = new JLabel(Language.get("WIN_THEME_NAME"));
themeinfo_name_tf = new JTextField();
JLabel themeinfo_author_l = new JLabel("Author:");
JLabel themeinfo_author_l = new JLabel(Language.get("WIN_THEME_AUTHOR"));
themeinfo_author_tf = new JTextField();
JLabel themeinfo_email_l = new JLabel("Author's E-Mail:");
JLabel themeinfo_email_l = new JLabel(Language.get("WIN_THEME_EMAIL"));
themeinfo_email_tf = new JTextField();
JLabel themeinfo_webpage_l = new JLabel("Author's webpage:");
JLabel themeinfo_webpage_l = new JLabel(Language.get("WIN_THEME_WEB"));
themeinfo_webpage_tf = new JTextField();
JLabel theme_magnet_l = new JLabel("Magnet:");
JLabel theme_magnet_l = new JLabel(Language.get("WIN_THEME_MAGNET"));
theme_magnet_tf = new JTextField();
theme_magnet_tf.setDocument(new NumbersOnlyDocument(false));
theme_magnet_tf.setToolTipText("When the distance between the border of the screen and an anchor of a window is less than this value, the window will stick to the border");
JLabel theme_alpha_l = new JLabel("Opacity:");
theme_magnet_tf.setToolTipText(Language.get("WIN_THEME_MAGNET_TIP"));
JLabel theme_alpha_l = new JLabel(Language.get("WIN_THEME_ALPHA"));
theme_alpha_tf = new JTextField();
theme_alpha_tf.setDocument(new NumbersOnlyDocument(false));
theme_alpha_tf.setToolTipText("Sets the alpha transparency of the windows. The value must be between 1 (nearly total transparency) and 255 (total opacity). Low values should be avoided.");
JLabel theme_movealpha_l = new JLabel("Opacity when moving:");
theme_alpha_tf.setToolTipText(Language.get("WIN_THEME_ALPHA_TIP"));
JLabel theme_movealpha_l = new JLabel(Language.get("WIN_THEME_MOVEALPHA"));
theme_movealpha_tf = new JTextField();
theme_alpha_tf.setDocument(new NumbersOnlyDocument(false));
theme_alpha_tf.setToolTipText("Sets the alpha transparency of the windows when they are moved.");
theme_ok_btn = new JButton("OK");
theme_alpha_tf.setToolTipText(Language.get("WIN_THEME_MOVEALPHA_TIP"));
theme_ok_btn = new JButton(Language.get("BUTTON_OK"));
theme_ok_btn.addActionListener(this);
theme_ok_btn.setPreferredSize(new Dimension(70,25));
theme_cancel_btn = new JButton("Cancel");
theme_cancel_btn = new JButton(Language.get("BUTTON_CANCEL"));
theme_cancel_btn.addActionListener(this);
theme_cancel_btn.setPreferredSize(new Dimension(70,25));
theme_help_btn = new JButton("Help");
theme_help_btn = new JButton(Language.get("BUTTON_HELP"));
theme_help_btn.addActionListener(this);
theme_help_btn.setPreferredSize(new Dimension(70,25));
......@@ -375,7 +376,7 @@ public class Skin implements ActionListener{
themeinfo_p.add(themeinfo_webpage_tf);
themeinfo_webpage_l.setBounds(5,105,150,24);
themeinfo_webpage_tf.setBounds(160,105,150,24);
themeinfo_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Theme Information"));
themeinfo_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), Language.get("WIN_THEME_INFO_TITLE")));
themeinfo_p.setMinimumSize(new Dimension(315,135));
themeinfo_p.setMaximumSize(new Dimension(315,135));
themeinfo_p.setPreferredSize(new Dimension(315,135));
......@@ -394,7 +395,7 @@ public class Skin implements ActionListener{
theme_p.add(theme_movealpha_tf);
theme_movealpha_l.setBounds(5,75,150,24);
theme_movealpha_tf.setBounds(160,75,150,24);
theme_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Theme Attributes"));
theme_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), Language.get("WIN_THEME_ATTR_TITLE")));
theme_p.setMinimumSize(new Dimension(315,105));
theme_p.setMaximumSize(new Dimension(315,105));
theme_p.setPreferredSize(new Dimension(315,105));
......@@ -422,11 +423,11 @@ public class Skin implements ActionListener{
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(theme_ok_btn)) {
if(Integer.parseInt(theme_alpha_tf.getText())>255 || Integer.parseInt(theme_alpha_tf.getText())<1) {
JOptionPane.showMessageDialog(theme_frame,"Please enter a valid alpha value!","Alpha value not valid",JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(theme_frame,Language.get("ERROR_ALPHA_MSG"),Language.get("ERROR_ALPHA_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
if(Integer.parseInt(theme_movealpha_tf.getText())>255 || Integer.parseInt(theme_movealpha_tf.getText())<1) {
JOptionPane.showMessageDialog(theme_frame,"Please enter a valid movealpha value!","Movealpha value not valid",JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(theme_frame,Language.get("ERROR_MALPHA_MSG"),Language.get("ERROR_MALPHA_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
ThemeEditEvent tee = new ThemeEditEvent(this);
......@@ -596,8 +597,8 @@ public class Skin implements ActionListener{
/** Creates the resources hierarchy **/
public DefaultMutableTreeNode getResourcesTree() {
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Root: Resources");
DefaultMutableTreeNode bitmaps_node = new DefaultMutableTreeNode("Root: Bitmaps");
DefaultMutableTreeNode fonts_node = new DefaultMutableTreeNode("Root: Fonts");
DefaultMutableTreeNode bitmaps_node = new DefaultMutableTreeNode("Root: "+Language.get("WIN_RES_BITMAPS"));
DefaultMutableTreeNode fonts_node = new DefaultMutableTreeNode("Root: "+Language.get("WIN_RES_FONTS"));
for(Resource r:resources) {
if(r.getClass()==Bitmap.class) {
bitmaps_node.add(r.getTreeNode());
......@@ -653,7 +654,7 @@ public class Skin implements ActionListener{
code+=" email=\""+themeinfo_email+"\"";
code+=" webpage=\""+themeinfo_webpage+"\"";
code+="/>\n\n";
code+=Skin.indentation+"<!-- Created using the VLC Skin Editor "+m.VERSION+" (http://www.videolan.org/vlc/skineditor.php)-->\n\n";
code+=Skin.indentation+"<!-- Created using the VLC Skin Editor "+m.VERSION+" (http://www.videolan.org/vlc/skineditor.html)-->\n\n";
for (int i=0;i<resources.size();i++) {
code+=resources.get(i).returnCode(Skin.indentation);
}
......@@ -674,15 +675,16 @@ public class Skin implements ActionListener{
Resource r = getResource(id);
if(r==null) return;
if(r.type.equals("Bitmap")) {
TreePath tp = findInTree(m.res_tree,"Root: Bitmaps");
TreePath tp = findInTree(m.res_tree,"Root: "+Language.get("WIN_RES_BITMAPS"));
m.res_tree.expandPath(tp);
}
else if(r.type.equals("Font")) {
TreePath tp = findInTree(m.res_tree,"Root: Fonts");
TreePath tp = findInTree(m.res_tree,"Root: "+Language.get("WIN_RES_FONTS"));
m.res_tree.expandPath(tp);
}
else {
System.err.println("Resource of the given id is neither a Font nor a Bitmap its a "+r.type);
System.err.println("Error encountered while trying to expand a resource:");
System.err.println(" Resource of the given id is neither a Font nor a Bitmap its a "+r.type);
return;
}
......
......@@ -69,9 +69,9 @@ public class TreeRenderer extends DefaultTreeCellRenderer {
*/
public ImageIcon getIcon(String name) {
if(name.startsWith("Bitmap:")) return bitmap_icon;
if(name.startsWith("Root: Bitmaps")) return bitmap_icon;
if(name.startsWith("Root: "+Language.get("WIN_RES_BITMAPS"))) return bitmap_icon;
else if(name.startsWith("Font:")) return font_icon;
else if(name.startsWith("Root: Fonts")) return font_icon;
else if(name.startsWith("Root: "+Language.get("WIN_RES_FONTS"))) return font_icon;
else if(name.startsWith("Bitmapfont:")) return bitmapfont_icon;
else if(name.startsWith("Window:")) return window_icon;
else if(name.startsWith("Layout:")) return layout_icon;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment