1. /*
  2. * @(#)GTKLookAndFeel.java 1.71 04/07/16
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.java.swing.plaf.gtk;
  8. import com.sun.java.swing.SwingUtilities2;
  9. import java.lang.ref.*;
  10. import javax.swing.plaf.synth.*;
  11. import java.awt.*;
  12. import java.awt.event.*;
  13. import java.beans.*;
  14. import java.io.File;
  15. import java.lang.reflect.*;
  16. import java.security.AccessController;
  17. import java.security.PrivilegedAction;
  18. import java.util.HashMap;
  19. import java.util.Locale;
  20. import javax.swing.*;
  21. import javax.swing.colorchooser.*;
  22. import javax.swing.plaf.*;
  23. import javax.swing.text.DefaultEditorKit;
  24. import java.io.IOException;
  25. import sun.security.action.GetPropertyAction;
  26. /**
  27. * @version 1.71, 07/16/04
  28. * @author Scott Violet
  29. */
  30. public class GTKLookAndFeel extends SynthLookAndFeel {
  31. private static final boolean IS_22;
  32. /**
  33. * Whether or not text is drawn antialiased. This keys off the
  34. * desktop property 'gnome.Xft/Antialias'.
  35. */
  36. static Boolean aaText = Boolean.FALSE;
  37. /**
  38. * Whether or not the default locale is CJK. If it is,
  39. * the GNOME desktop property for antialiasing is ignored
  40. * and the text is always rendered w/o aa.
  41. * This is done to be consistent with what GTK does - they
  42. * disable text aa for CJK locales as well.
  43. *
  44. * Note: this doesn't work well with changing locales
  45. * at runtime. But most of Swing/2D code (including fonts
  46. * initialization) doesn't either.
  47. */
  48. static boolean cjkLocale;
  49. /**
  50. * Font to use in places where there is no widget.
  51. */
  52. private Font fallbackFont;
  53. /**
  54. * If true, GTKLookAndFeel is inside the <code>initialize</code>
  55. * method.
  56. */
  57. private boolean inInitialize;
  58. static {
  59. // Backup for specifying the version, this isn't currently documented.
  60. // If you pass in anything but 2.2 you got the 2.0 colors/look.
  61. String version = (String)java.security.AccessController.doPrivileged(
  62. new GetPropertyAction("swing.gtk.version"));
  63. if (version != null) {
  64. IS_22 = version.equals("2.2");
  65. }
  66. else {
  67. IS_22 = true;
  68. }
  69. }
  70. /**
  71. * Returns true if running on system containing at least 2.2.
  72. */
  73. static boolean is2_2() {
  74. // NOTE: We're currently hard coding to use 2.2.
  75. // If we want to support both GTK 2.0 and 2.2, we'll
  76. // need to get the major/minor/micro version from the .so.
  77. // Refer to bug 4912613 for details.
  78. return IS_22;
  79. }
  80. /**
  81. * Maps a swing constant to a GTK constant.
  82. */
  83. static int SwingOrientationConstantToGTK(int side) {
  84. switch (side) {
  85. case SwingConstants.LEFT:
  86. return GTKConstants.LEFT;
  87. case SwingConstants.RIGHT:
  88. return GTKConstants.RIGHT;
  89. case SwingConstants.TOP:
  90. return GTKConstants.TOP;
  91. case SwingConstants.BOTTOM:
  92. return GTKConstants.BOTTOM;
  93. }
  94. assert false : "Unknowning orientation: " + side;
  95. return side;
  96. }
  97. /**
  98. * Maps from a Synth state to the corresponding GTK state.
  99. * The GTK states are named differently than Synth's states, the
  100. * following gives the mapping:
  101. * <table><tr><td>Synth<td>GTK
  102. * <tr><td>SynthConstants.PRESSED<td>ACTIVE
  103. * <tr><td>SynthConstants.SELECTED<td>SELECTED
  104. * <tr><td>SynthConstants.MOUSE_OVER<td>PRELIGHT
  105. * <tr><td>SynthConstants.DISABLED<td>INACTIVE
  106. * <tr><td>SynthConstants.ENABLED<td>NORMAL
  107. * </table>
  108. * Additionally some widgets are special cased.
  109. */
  110. static int synthStateToGTKState(Region region, int state) {
  111. int orgState = state;
  112. if ((state & SynthConstants.PRESSED) != 0) {
  113. if (region == Region.RADIO_BUTTON
  114. || region == Region.CHECK_BOX
  115. || region == Region.TOGGLE_BUTTON
  116. || region == Region.MENU
  117. || region == Region.MENU_ITEM
  118. || region == Region.RADIO_BUTTON_MENU_ITEM
  119. || region == Region.CHECK_BOX_MENU_ITEM
  120. || region == Region.SPLIT_PANE) {
  121. state = SynthConstants.MOUSE_OVER;
  122. } else {
  123. state = SynthConstants.PRESSED;
  124. }
  125. }
  126. else if ((state & SynthConstants.SELECTED) != 0) {
  127. if (region == Region.MENU) {
  128. state = SynthConstants.MOUSE_OVER;
  129. } else if (region == Region.RADIO_BUTTON ||
  130. region == Region.TOGGLE_BUTTON ||
  131. region == Region.RADIO_BUTTON_MENU_ITEM ||
  132. region == Region.CHECK_BOX_MENU_ITEM ||
  133. region == Region.CHECK_BOX ||
  134. region == Region.BUTTON) {
  135. // If the button is SELECTED and is PRELIGHT we need to
  136. // make the state MOUSE_OVER otherwise we don't paint the
  137. // PRELIGHT.
  138. if ((state & SynthConstants.MOUSE_OVER) != 0) {
  139. state = SynthConstants.MOUSE_OVER;
  140. } else {
  141. state = SynthConstants.PRESSED;
  142. }
  143. } else if (region == Region.TABBED_PANE_TAB) {
  144. state = SynthConstants.ENABLED;
  145. } else {
  146. state = SynthConstants.SELECTED;
  147. }
  148. }
  149. else if ((state & SynthConstants.MOUSE_OVER) != 0) {
  150. state = SynthConstants.MOUSE_OVER;
  151. }
  152. else if ((state & SynthConstants.DISABLED) != 0) {
  153. state = SynthConstants.DISABLED;
  154. }
  155. else {
  156. if (region == Region.SLIDER_TRACK) {
  157. state = SynthConstants.PRESSED;
  158. } else if (region == Region.TABBED_PANE_TAB) {
  159. state = SynthConstants.PRESSED;
  160. } else {
  161. state = SynthConstants.ENABLED;
  162. }
  163. }
  164. return state;
  165. }
  166. static boolean isText(Region region) {
  167. // These Regions treat FOREGROUND as TEXT.
  168. return (region == Region.TEXT_FIELD ||
  169. region == Region.FORMATTED_TEXT_FIELD ||
  170. region == Region.LIST ||
  171. region == Region.PASSWORD_FIELD ||
  172. region == Region.SPINNER ||
  173. region == Region.TABLE ||
  174. region == Region.TEXT_AREA ||
  175. region == Region.TEXT_FIELD ||
  176. region == Region.TEXT_PANE ||
  177. region == Region.TREE);
  178. }
  179. public UIDefaults getDefaults() {
  180. // We need to call super for basic's properties file.
  181. UIDefaults table = super.getDefaults();
  182. initResourceBundle(table);
  183. // For compatability with apps expecting certain defaults we'll
  184. // populate the table with the values from basic.
  185. initSystemColorDefaults(table);
  186. initComponentDefaults(table);
  187. return table;
  188. }
  189. private void initResourceBundle(UIDefaults table) {
  190. table.addResourceBundle("com.sun.java.swing.plaf.gtk.resources.gtk");
  191. }
  192. protected void initComponentDefaults(UIDefaults table) {
  193. // For compatability with apps expecting certain defaults we'll
  194. // populate the table with the values from basic.
  195. super.initComponentDefaults(table);
  196. Object tempBorder = new GTKStyle.GTKLazyValue(
  197. "com.sun.java.swing.plaf.gtk.GTKPainter$ListTableFocusBorder");
  198. Integer caretBlinkRate = new Integer(500);
  199. Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0);
  200. Double defaultCaretAspectRatio = new Double(0.025);
  201. Color caretColor = table.getColor("caretColor");
  202. Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
  203. "ctrl C", DefaultEditorKit.copyAction,
  204. "ctrl V", DefaultEditorKit.pasteAction,
  205. "ctrl X", DefaultEditorKit.cutAction,
  206. "COPY", DefaultEditorKit.copyAction,
  207. "PASTE", DefaultEditorKit.pasteAction,
  208. "CUT", DefaultEditorKit.cutAction,
  209. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  210. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  211. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  212. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  213. "ctrl LEFT", DefaultEditorKit.previousWordAction,
  214. "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  215. "ctrl RIGHT", DefaultEditorKit.nextWordAction,
  216. "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
  217. "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  218. "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
  219. "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  220. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
  221. "ctrl A", DefaultEditorKit.selectAllAction,
  222. "HOME", DefaultEditorKit.beginLineAction,
  223. "END", DefaultEditorKit.endLineAction,
  224. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  225. "shift END", DefaultEditorKit.selectionEndLineAction,
  226. "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
  227. "ctrl H", DefaultEditorKit.deletePrevCharAction,
  228. "DELETE", DefaultEditorKit.deleteNextCharAction,
  229. "RIGHT", DefaultEditorKit.forwardAction,
  230. "LEFT", DefaultEditorKit.backwardAction,
  231. "KP_RIGHT", DefaultEditorKit.forwardAction,
  232. "KP_LEFT", DefaultEditorKit.backwardAction,
  233. "ENTER", JTextField.notifyAction,
  234. "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
  235. "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
  236. });
  237. Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[] {
  238. "ctrl C", DefaultEditorKit.copyAction,
  239. "ctrl V", DefaultEditorKit.pasteAction,
  240. "ctrl X", DefaultEditorKit.cutAction,
  241. "COPY", DefaultEditorKit.copyAction,
  242. "PASTE", DefaultEditorKit.pasteAction,
  243. "CUT", DefaultEditorKit.cutAction,
  244. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  245. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  246. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  247. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  248. "ctrl LEFT", DefaultEditorKit.beginLineAction,
  249. "ctrl KP_LEFT", DefaultEditorKit.beginLineAction,
  250. "ctrl RIGHT", DefaultEditorKit.endLineAction,
  251. "ctrl KP_RIGHT", DefaultEditorKit.endLineAction,
  252. "ctrl shift LEFT", DefaultEditorKit.selectionBeginLineAction,
  253. "ctrl shift KP_LEFT", DefaultEditorKit.selectionBeginLineAction,
  254. "ctrl shift RIGHT", DefaultEditorKit.selectionEndLineAction,
  255. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionEndLineAction,
  256. "ctrl A", DefaultEditorKit.selectAllAction,
  257. "HOME", DefaultEditorKit.beginLineAction,
  258. "END", DefaultEditorKit.endLineAction,
  259. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  260. "shift END", DefaultEditorKit.selectionEndLineAction,
  261. "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
  262. "ctrl H", DefaultEditorKit.deletePrevCharAction,
  263. "DELETE", DefaultEditorKit.deleteNextCharAction,
  264. "RIGHT", DefaultEditorKit.forwardAction,
  265. "LEFT", DefaultEditorKit.backwardAction,
  266. "KP_RIGHT", DefaultEditorKit.forwardAction,
  267. "KP_LEFT", DefaultEditorKit.backwardAction,
  268. "ENTER", JTextField.notifyAction,
  269. "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
  270. "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
  271. });
  272. Object editorMargin = new InsetsUIResource(3,3,3,3);
  273. Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] {
  274. "ctrl C", DefaultEditorKit.copyAction,
  275. "ctrl V", DefaultEditorKit.pasteAction,
  276. "ctrl X", DefaultEditorKit.cutAction,
  277. "COPY", DefaultEditorKit.copyAction,
  278. "PASTE", DefaultEditorKit.pasteAction,
  279. "CUT", DefaultEditorKit.cutAction,
  280. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  281. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  282. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  283. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  284. "ctrl LEFT", DefaultEditorKit.previousWordAction,
  285. "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  286. "ctrl RIGHT", DefaultEditorKit.nextWordAction,
  287. "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
  288. "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  289. "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
  290. "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  291. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
  292. "ctrl A", DefaultEditorKit.selectAllAction,
  293. "HOME", DefaultEditorKit.beginLineAction,
  294. "END", DefaultEditorKit.endLineAction,
  295. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  296. "shift END", DefaultEditorKit.selectionEndLineAction,
  297. "UP", DefaultEditorKit.upAction,
  298. "KP_UP", DefaultEditorKit.upAction,
  299. "DOWN", DefaultEditorKit.downAction,
  300. "KP_DOWN", DefaultEditorKit.downAction,
  301. "PAGE_UP", DefaultEditorKit.pageUpAction,
  302. "PAGE_DOWN", DefaultEditorKit.pageDownAction,
  303. "shift PAGE_UP", "selection-page-up",
  304. "shift PAGE_DOWN", "selection-page-down",
  305. "ctrl shift PAGE_UP", "selection-page-left",
  306. "ctrl shift PAGE_DOWN", "selection-page-right",
  307. "shift UP", DefaultEditorKit.selectionUpAction,
  308. "shift KP_UP", DefaultEditorKit.selectionUpAction,
  309. "shift DOWN", DefaultEditorKit.selectionDownAction,
  310. "shift KP_DOWN", DefaultEditorKit.selectionDownAction,
  311. "ENTER", DefaultEditorKit.insertBreakAction,
  312. "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
  313. "ctrl H", DefaultEditorKit.deletePrevCharAction,
  314. "DELETE", DefaultEditorKit.deleteNextCharAction,
  315. "RIGHT", DefaultEditorKit.forwardAction,
  316. "LEFT", DefaultEditorKit.backwardAction,
  317. "KP_RIGHT", DefaultEditorKit.forwardAction,
  318. "KP_LEFT", DefaultEditorKit.backwardAction,
  319. "TAB", DefaultEditorKit.insertTabAction,
  320. "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
  321. "ctrl HOME", DefaultEditorKit.beginAction,
  322. "ctrl END", DefaultEditorKit.endAction,
  323. "ctrl shift HOME", DefaultEditorKit.selectionBeginAction,
  324. "ctrl shift END", DefaultEditorKit.selectionEndAction,
  325. "ctrl T", "next-link-action",
  326. "ctrl shift T", "previous-link-action",
  327. "ctrl SPACE", "activate-link-action",
  328. "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
  329. });
  330. class FontLazyValue implements UIDefaults.LazyValue {
  331. private Region region;
  332. FontLazyValue(Region region) {
  333. this.region = region;
  334. }
  335. public Object createValue(UIDefaults table) {
  336. GTKStyleFactory factory = (GTKStyleFactory)getStyleFactory();
  337. GTKStyle style = (GTKStyle)factory.getStyle(
  338. GTKStyleFactory.gtkClassFor(region));
  339. return style.getFontForState(
  340. null, region, SynthConstants.ENABLED);
  341. }
  342. }
  343. Object[] defaults = new Object[] {
  344. "ArrowButton.size", new Integer(13),
  345. "Button.defaultButtonFollowsFocus", Boolean.FALSE,
  346. "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
  347. "SPACE", "pressed",
  348. "released SPACE", "released",
  349. "ENTER", "pressed",
  350. "released ENTER", "released"
  351. }),
  352. "Button.font", new FontLazyValue(Region.BUTTON),
  353. "CheckBox.focusInputMap", new UIDefaults.LazyInputMap(new Object[]{
  354. "SPACE", "pressed",
  355. "released SPACE", "released",
  356. }),
  357. "CheckBox.icon", new GTKStyle.GTKLazyValue(
  358. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  359. "getCheckBoxIcon"),
  360. "CheckBox.font", new FontLazyValue(Region.CHECK_BOX),
  361. "CheckBoxMenuItem.arrowIcon", new GTKStyle.GTKLazyValue(
  362. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  363. "getCheckBoxMenuItemArrowIcon"),
  364. "CheckBoxMenuItem.checkIcon", new GTKStyle.GTKLazyValue(
  365. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  366. "getCheckBoxMenuItemCheckIcon"),
  367. "CheckBoxMenuItem.font",
  368. new FontLazyValue(Region.CHECK_BOX_MENU_ITEM),
  369. "CheckBoxMenuItem.margin", zeroInsets,
  370. "ColorChooser.showPreviewPanelText", Boolean.FALSE,
  371. "ColorChooser.panels", new UIDefaults.ActiveValue() {
  372. public Object createValue(UIDefaults table) {
  373. return new AbstractColorChooserPanel[] {
  374. new GTKColorChooserPanel() };
  375. }
  376. },
  377. "ColorChooser.font", new FontLazyValue(Region.COLOR_CHOOSER),
  378. "ComboBox.ancestorInputMap",
  379. new UIDefaults.LazyInputMap(new Object[] {
  380. "ESCAPE", "hidePopup",
  381. "PAGE_UP", "pageUpPassThrough",
  382. "PAGE_DOWN", "pageDownPassThrough",
  383. "HOME", "homePassThrough",
  384. "END", "endPassThrough",
  385. "DOWN", "selectNext",
  386. "KP_DOWN", "selectNext",
  387. "alt DOWN", "togglePopup",
  388. "alt KP_DOWN", "togglePopup",
  389. "alt UP", "togglePopup",
  390. "alt KP_UP", "togglePopup",
  391. "SPACE", "spacePopup",
  392. "ENTER", "enterPressed",
  393. "UP", "selectPrevious",
  394. "KP_UP", "selectPrevious"
  395. }),
  396. "ComboBox.font", new FontLazyValue(Region.COMBO_BOX),
  397. "EditorPane.caretForeground", caretColor,
  398. "EditorPane.caretAspectRatio", defaultCaretAspectRatio,
  399. "EditorPane.caretBlinkRate", caretBlinkRate,
  400. "EditorPane.margin", editorMargin,
  401. "EditorPane.focusInputMap", multilineInputMap,
  402. "EditorPane.font", new FontLazyValue(Region.EDITOR_PANE),
  403. "FileChooser.ancestorInputMap",
  404. new UIDefaults.LazyInputMap(new Object[] {
  405. "ESCAPE", "cancelSelection"
  406. }),
  407. "FileChooserUI", "com.sun.java.swing.plaf.gtk.GTKLookAndFeel",
  408. "FormattedTextField.caretForeground", caretColor,
  409. "FormattedTextField.caretAspectRatio", defaultCaretAspectRatio,
  410. "FormattedTextField.caretBlinkRate", caretBlinkRate,
  411. "FormattedTextField.focusInputMap",
  412. new UIDefaults.LazyInputMap(new Object[] {
  413. "ctrl C", DefaultEditorKit.copyAction,
  414. "ctrl V", DefaultEditorKit.pasteAction,
  415. "ctrl X", DefaultEditorKit.cutAction,
  416. "COPY", DefaultEditorKit.copyAction,
  417. "PASTE", DefaultEditorKit.pasteAction,
  418. "CUT", DefaultEditorKit.cutAction,
  419. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  420. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  421. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  422. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  423. "ctrl LEFT", DefaultEditorKit.previousWordAction,
  424. "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  425. "ctrl RIGHT", DefaultEditorKit.nextWordAction,
  426. "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
  427. "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  428. "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
  429. "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  430. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
  431. "ctrl A", DefaultEditorKit.selectAllAction,
  432. "HOME", DefaultEditorKit.beginLineAction,
  433. "END", DefaultEditorKit.endLineAction,
  434. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  435. "shift END", DefaultEditorKit.selectionEndLineAction,
  436. "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
  437. "ctrl H", DefaultEditorKit.deletePrevCharAction,
  438. "DELETE", DefaultEditorKit.deleteNextCharAction,
  439. "RIGHT", DefaultEditorKit.forwardAction,
  440. "LEFT", DefaultEditorKit.backwardAction,
  441. "KP_RIGHT", DefaultEditorKit.forwardAction,
  442. "KP_LEFT", DefaultEditorKit.backwardAction,
  443. "ENTER", JTextField.notifyAction,
  444. "ctrl BACK_SLASH", "unselect",
  445. "control shift O", "toggle-componentOrientation",
  446. "ESCAPE", "reset-field-edit",
  447. "UP", "increment",
  448. "KP_UP", "increment",
  449. "DOWN", "decrement",
  450. "KP_DOWN", "decrement",
  451. }),
  452. "FormattedTextField.font",
  453. new FontLazyValue(Region.FORMATTED_TEXT_FIELD),
  454. "InternalFrameTitlePane.titlePaneLayout",
  455. new GTKStyle.GTKLazyValue("com.sun.java.swing.plaf.gtk.Metacity",
  456. "getTitlePaneLayout"),
  457. "InternalFrame.windowBindings", new Object[] {
  458. "shift ESCAPE", "showSystemMenu",
  459. "ctrl SPACE", "showSystemMenu",
  460. "ESCAPE", "hideSystemMenu" },
  461. "InternalFrame.layoutTitlePaneAtOrigin", Boolean.TRUE,
  462. "InternalFrame.useTaskBar", Boolean.TRUE,
  463. "Label.font", new FontLazyValue(Region.LABEL),
  464. "List.focusCellHighlightBorder", tempBorder,
  465. "List.focusInputMap",
  466. new UIDefaults.LazyInputMap(new Object[] {
  467. "ctrl C", "copy",
  468. "ctrl V", "paste",
  469. "ctrl X", "cut",
  470. "COPY", "copy",
  471. "PASTE", "paste",
  472. "CUT", "cut",
  473. "UP", "selectPreviousRow",
  474. "KP_UP", "selectPreviousRow",
  475. "shift UP", "selectPreviousRowExtendSelection",
  476. "shift KP_UP", "selectPreviousRowExtendSelection",
  477. "ctrl shift UP", "selectPreviousRowExtendSelection",
  478. "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
  479. "ctrl UP", "selectPreviousRowChangeLead",
  480. "ctrl KP_UP", "selectPreviousRowChangeLead",
  481. "DOWN", "selectNextRow",
  482. "KP_DOWN", "selectNextRow",
  483. "shift DOWN", "selectNextRowExtendSelection",
  484. "shift KP_DOWN", "selectNextRowExtendSelection",
  485. "ctrl shift DOWN", "selectNextRowExtendSelection",
  486. "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
  487. "ctrl DOWN", "selectNextRowChangeLead",
  488. "ctrl KP_DOWN", "selectNextRowChangeLead",
  489. "LEFT", "selectPreviousColumn",
  490. "KP_LEFT", "selectPreviousColumn",
  491. "shift LEFT", "selectPreviousColumnExtendSelection",
  492. "shift KP_LEFT", "selectPreviousColumnExtendSelection",
  493. "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
  494. "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
  495. "ctrl LEFT", "selectPreviousColumnChangeLead",
  496. "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
  497. "RIGHT", "selectNextColumn",
  498. "KP_RIGHT", "selectNextColumn",
  499. "shift RIGHT", "selectNextColumnExtendSelection",
  500. "shift KP_RIGHT", "selectNextColumnExtendSelection",
  501. "ctrl shift RIGHT", "selectNextColumnExtendSelection",
  502. "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
  503. "ctrl RIGHT", "selectNextColumnChangeLead",
  504. "ctrl KP_RIGHT", "selectNextColumnChangeLead",
  505. "HOME", "selectFirstRow",
  506. "shift HOME", "selectFirstRowExtendSelection",
  507. "ctrl shift HOME", "selectFirstRowExtendSelection",
  508. "ctrl HOME", "selectFirstRowChangeLead",
  509. "END", "selectLastRow",
  510. "shift END", "selectLastRowExtendSelection",
  511. "ctrl shift END", "selectLastRowExtendSelection",
  512. "ctrl END", "selectLastRowChangeLead",
  513. "PAGE_UP", "scrollUp",
  514. "shift PAGE_UP", "scrollUpExtendSelection",
  515. "ctrl shift PAGE_UP", "scrollUpExtendSelection",
  516. "ctrl PAGE_UP", "scrollUpChangeLead",
  517. "PAGE_DOWN", "scrollDown",
  518. "shift PAGE_DOWN", "scrollDownExtendSelection",
  519. "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
  520. "ctrl PAGE_DOWN", "scrollDownChangeLead",
  521. "ctrl A", "selectAll",
  522. "ctrl SLASH", "selectAll",
  523. "ctrl BACK_SLASH", "clearSelection",
  524. "SPACE", "addToSelection",
  525. "ctrl SPACE", "toggleAndAnchor",
  526. "shift SPACE", "extendTo",
  527. "ctrl shift SPACE", "moveSelectionTo"
  528. }),
  529. "List.focusInputMap.RightToLeft",
  530. new UIDefaults.LazyInputMap(new Object[] {
  531. "LEFT", "selectNextColumn",
  532. "KP_LEFT", "selectNextColumn",
  533. "shift LEFT", "selectNextColumnExtendSelection",
  534. "shift KP_LEFT", "selectNextColumnExtendSelection",
  535. "ctrl shift LEFT", "selectNextColumnExtendSelection",
  536. "ctrl shift KP_LEFT", "selectNextColumnExtendSelection",
  537. "ctrl LEFT", "selectNextColumnChangeLead",
  538. "ctrl KP_LEFT", "selectNextColumnChangeLead",
  539. "RIGHT", "selectPreviousColumn",
  540. "KP_RIGHT", "selectPreviousColumn",
  541. "shift RIGHT", "selectPreviousColumnExtendSelection",
  542. "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
  543. "ctrl shift RIGHT", "selectPreviousColumnExtendSelection",
  544. "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection",
  545. "ctrl RIGHT", "selectPreviousColumnChangeLead",
  546. "ctrl KP_RIGHT", "selectPreviousColumnChangeLead",
  547. }),
  548. "List.font", new FontLazyValue(Region.LIST),
  549. "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK},
  550. "Menu.arrowIcon", new GTKStyle.GTKLazyValue(
  551. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  552. "getMenuArrowIcon"),
  553. "Menu.font", new FontLazyValue(Region.MENU),
  554. "Menu.margin", zeroInsets,
  555. "MenuBar.windowBindings", new Object[] {
  556. "F10", "takeFocus" },
  557. "MenuBar.font", new FontLazyValue(Region.MENU_BAR),
  558. "MenuItem.arrowIcon", new GTKStyle.GTKLazyValue(
  559. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  560. "getMenuItemArrowIcon"),
  561. "MenuItem.font", new FontLazyValue(Region.MENU_ITEM),
  562. "MenuItem.margin", zeroInsets,
  563. "OptionPane.setButtonMargin", Boolean.FALSE,
  564. "OptionPane.sameSizeButtons", Boolean.TRUE,
  565. "OptionPane.buttonOrientation", new Integer(SwingConstants.RIGHT),
  566. "OptionPane.minimumSize", new DimensionUIResource(262, 90),
  567. "OptionPane.buttonPadding", new Integer(10),
  568. "OptionPane.windowBindings", new Object[] {
  569. "ESCAPE", "close" },
  570. "OptionPane.buttonClickThreshhold", new Integer(500),
  571. "OptionPane.isYesLast", Boolean.TRUE,
  572. "OptionPane.font", new FontLazyValue(Region.OPTION_PANE),
  573. "Panel.font", new FontLazyValue(Region.PANEL),
  574. "PasswordField.caretForeground", caretColor,
  575. "PasswordField.caretAspectRatio", defaultCaretAspectRatio,
  576. "PasswordField.caretBlinkRate", caretBlinkRate,
  577. "PasswordField.margin", zeroInsets,
  578. "PasswordField.focusInputMap", passwordInputMap,
  579. "PasswordField.font", new FontLazyValue(Region.PASSWORD_FIELD),
  580. "PopupMenu.consumeEventOnClose", Boolean.TRUE,
  581. "PopupMenu.selectedWindowInputMapBindings", new Object[] {
  582. "ESCAPE", "cancel",
  583. "DOWN", "selectNext",
  584. "KP_DOWN", "selectNext",
  585. "UP", "selectPrevious",
  586. "KP_UP", "selectPrevious",
  587. "LEFT", "selectParent",
  588. "KP_LEFT", "selectParent",
  589. "RIGHT", "selectChild",
  590. "KP_RIGHT", "selectChild",
  591. "ENTER", "return",
  592. "SPACE", "return"
  593. },
  594. "PopupMenu.selectedWindowInputMapBindings.RightToLeft",
  595. new Object[] {
  596. "LEFT", "selectChild",
  597. "KP_LEFT", "selectChild",
  598. "RIGHT", "selectParent",
  599. "KP_RIGHT", "selectParent",
  600. },
  601. "PopupMenu.font", new FontLazyValue(Region.POPUP_MENU),
  602. "ProgressBar.horizontalSize", new DimensionUIResource(146, 16),
  603. "ProgressBar.verticalSize", new DimensionUIResource(16, 146),
  604. "ProgressBar.font", new FontLazyValue(Region.PROGRESS_BAR),
  605. "RadioButton.focusInputMap",
  606. new UIDefaults.LazyInputMap(new Object[] {
  607. "SPACE", "pressed",
  608. "released SPACE", "released",
  609. "RETURN", "pressed"
  610. }),
  611. "RadioButton.icon", new GTKStyle.GTKLazyValue(
  612. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  613. "getRadioButtonIcon"),
  614. "RadioButton.font", new FontLazyValue(Region.RADIO_BUTTON),
  615. "RadioButtonMenuItem.arrowIcon", new GTKStyle.GTKLazyValue(
  616. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  617. "getRadioButtonMenuItemArrowIcon"),
  618. "RadioButtonMenuItem.checkIcon", new GTKStyle.GTKLazyValue(
  619. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  620. "getRadioButtonMenuItemCheckIcon"),
  621. "RadioButtonMenuItem.font", new FontLazyValue(Region.RADIO_BUTTON_MENU_ITEM),
  622. "RadioButtonMenuItem.margin", zeroInsets,
  623. // These bindings are only enabled when there is a default
  624. // button set on the rootpane.
  625. "RootPane.defaultButtonWindowKeyBindings", new Object[] {
  626. "ENTER", "press",
  627. "released ENTER", "release",
  628. "ctrl ENTER", "press",
  629. "ctrl released ENTER", "release"
  630. },
  631. "ScrollBar.squareButtons", Boolean.TRUE,
  632. "ScrollBar.thumbHeight", new Integer(14),
  633. "ScrollBar.width", new Integer(16),
  634. "ScrollBar.minimumThumbSize", new Dimension(8, 8),
  635. "ScrollBar.maximumThumbSize", new Dimension(4096, 4096),
  636. "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
  637. "ScrollBar.ancestorInputMap",
  638. new UIDefaults.LazyInputMap(new Object[] {
  639. "RIGHT", "positiveUnitIncrement",
  640. "KP_RIGHT", "positiveUnitIncrement",
  641. "DOWN", "positiveUnitIncrement",
  642. "KP_DOWN", "positiveUnitIncrement",
  643. "PAGE_DOWN", "positiveBlockIncrement",
  644. "LEFT", "negativeUnitIncrement",
  645. "KP_LEFT", "negativeUnitIncrement",
  646. "UP", "negativeUnitIncrement",
  647. "KP_UP", "negativeUnitIncrement",
  648. "PAGE_UP", "negativeBlockIncrement",
  649. "HOME", "minScroll",
  650. "END", "maxScroll"
  651. }),
  652. "ScrollBar.ancestorInputMap.RightToLeft",
  653. new UIDefaults.LazyInputMap(new Object[] {
  654. "RIGHT", "negativeUnitIncrement",
  655. "KP_RIGHT", "negativeUnitIncrement",
  656. "LEFT", "positiveUnitIncrement",
  657. "KP_LEFT", "positiveUnitIncrement",
  658. }),
  659. "ScrollPane.ancestorInputMap",
  660. new UIDefaults.LazyInputMap(new Object[] {
  661. "RIGHT", "unitScrollRight",
  662. "KP_RIGHT", "unitScrollRight",
  663. "DOWN", "unitScrollDown",
  664. "KP_DOWN", "unitScrollDown",
  665. "LEFT", "unitScrollLeft",
  666. "KP_LEFT", "unitScrollLeft",
  667. "UP", "unitScrollUp",
  668. "KP_UP", "unitScrollUp",
  669. "PAGE_UP", "scrollUp",
  670. "PAGE_DOWN", "scrollDown",
  671. "ctrl PAGE_UP", "scrollLeft",
  672. "ctrl PAGE_DOWN", "scrollRight",
  673. "ctrl HOME", "scrollHome",
  674. "ctrl END", "scrollEnd"
  675. }),
  676. "ScrollPane.ancestorInputMap.RightToLeft",
  677. new UIDefaults.LazyInputMap(new Object[] {
  678. "ctrl PAGE_UP", "scrollRight",
  679. "ctrl PAGE_DOWN", "scrollLeft",
  680. }),
  681. "ScrollPane.font", new FontLazyValue(Region.SCROLL_PANE),
  682. "Separator.insets", zeroInsets,
  683. "Separator.thickness", new Integer(2),
  684. "Slider.paintValue", Boolean.TRUE,
  685. "Slider.thumbWidth", new Integer(30),
  686. "Slider.thumbHeight", new Integer(14),
  687. "Slider.focusInputMap",
  688. new UIDefaults.LazyInputMap(new Object[] {
  689. "RIGHT", "positiveUnitIncrement",
  690. "KP_RIGHT", "positiveUnitIncrement",
  691. "DOWN", "negativeUnitIncrement",
  692. "KP_DOWN", "negativeUnitIncrement",
  693. "PAGE_DOWN", "negativeBlockIncrement",
  694. "LEFT", "negativeUnitIncrement",
  695. "KP_LEFT", "negativeUnitIncrement",
  696. "UP", "positiveUnitIncrement",
  697. "KP_UP", "positiveUnitIncrement",
  698. "PAGE_UP", "positiveBlockIncrement",
  699. "HOME", "minScroll",
  700. "END", "maxScroll"
  701. }),
  702. "Slider.focusInputMap.RightToLeft",
  703. new UIDefaults.LazyInputMap(new Object[] {
  704. "RIGHT", "negativeUnitIncrement",
  705. "KP_RIGHT", "negativeUnitIncrement",
  706. "LEFT", "positiveUnitIncrement",
  707. "KP_LEFT", "positiveUnitIncrement",
  708. }),
  709. "Spinner.ancestorInputMap",
  710. new UIDefaults.LazyInputMap(new Object[] {
  711. "UP", "increment",
  712. "KP_UP", "increment",
  713. "DOWN", "decrement",
  714. "KP_DOWN", "decrement",
  715. }),
  716. "Spinner.font", new FontLazyValue(Region.SPINNER),
  717. "SplitPane.ancestorInputMap",
  718. new UIDefaults.LazyInputMap(new Object[] {
  719. "UP", "negativeIncrement",
  720. "DOWN", "positiveIncrement",
  721. "LEFT", "negativeIncrement",
  722. "RIGHT", "positiveIncrement",
  723. "KP_UP", "negativeIncrement",
  724. "KP_DOWN", "positiveIncrement",
  725. "KP_LEFT", "negativeIncrement",
  726. "KP_RIGHT", "positiveIncrement",
  727. "HOME", "selectMin",
  728. "END", "selectMax",
  729. "F8", "startResize",
  730. "F6", "toggleFocus",
  731. "ctrl TAB", "focusOutForward",
  732. "ctrl shift TAB", "focusOutBackward"
  733. }),
  734. "SplitPane.size", new Integer(7),
  735. "SplitPane.oneTouchOffset", new Integer(2),
  736. "SplitPane.oneTouchButtonSize", new Integer(5),
  737. "SplitPane.supportsOneTouchButtons", Boolean.FALSE,
  738. "TabbedPane.focusInputMap",
  739. new UIDefaults.LazyInputMap(new Object[] {
  740. "RIGHT", "navigateRight",
  741. "KP_RIGHT", "navigateRight",
  742. "LEFT", "navigateLeft",
  743. "KP_LEFT", "navigateLeft",
  744. "UP", "navigateUp",
  745. "KP_UP", "navigateUp",
  746. "DOWN", "navigateDown",
  747. "KP_DOWN", "navigateDown",
  748. "ctrl DOWN", "requestFocusForVisibleComponent",
  749. "ctrl KP_DOWN", "requestFocusForVisibleComponent",
  750. "SPACE", "selectTabWithFocus"
  751. }),
  752. "TabbedPane.ancestorInputMap",
  753. new UIDefaults.LazyInputMap(new Object[] {
  754. "ctrl TAB", "navigateNext",
  755. "ctrl shift TAB", "navigatePrevious",
  756. "ctrl PAGE_DOWN", "navigatePageDown",
  757. "ctrl PAGE_UP", "navigatePageUp",
  758. "ctrl UP", "requestFocus",
  759. "ctrl KP_UP", "requestFocus",
  760. }),
  761. "TabbedPane.selectionFollowsFocus", Boolean.FALSE,
  762. "TabbedPane.font", new FontLazyValue(Region.TABBED_PANE),
  763. "Table.focusCellHighlightBorder", tempBorder,
  764. "Table.ancestorInputMap",
  765. new UIDefaults.LazyInputMap(new Object[] {
  766. "ctrl C", "copy",
  767. "ctrl V", "paste",
  768. "ctrl X", "cut",
  769. "COPY", "copy",
  770. "PASTE", "paste",
  771. "CUT", "cut",
  772. "RIGHT", "selectNextColumn",
  773. "KP_RIGHT", "selectNextColumn",
  774. "shift RIGHT", "selectNextColumnExtendSelection",
  775. "shift KP_RIGHT", "selectNextColumnExtendSelection",
  776. "ctrl shift RIGHT", "selectNextColumnExtendSelection",
  777. "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
  778. "ctrl RIGHT", "selectNextColumnChangeLead",
  779. "ctrl KP_RIGHT", "selectNextColumnChangeLead",
  780. "LEFT", "selectPreviousColumn",
  781. "KP_LEFT", "selectPreviousColumn",
  782. "shift LEFT", "selectPreviousColumnExtendSelection",
  783. "shift KP_LEFT", "selectPreviousColumnExtendSelection",
  784. "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
  785. "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
  786. "ctrl LEFT", "selectPreviousColumnChangeLead",
  787. "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
  788. "DOWN", "selectNextRow",
  789. "KP_DOWN", "selectNextRow",
  790. "shift DOWN", "selectNextRowExtendSelection",
  791. "shift KP_DOWN", "selectNextRowExtendSelection",
  792. "ctrl shift DOWN", "selectNextRowExtendSelection",
  793. "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
  794. "ctrl DOWN", "selectNextRowChangeLead",
  795. "ctrl KP_DOWN", "selectNextRowChangeLead",
  796. "UP", "selectPreviousRow",
  797. "KP_UP", "selectPreviousRow",
  798. "shift UP", "selectPreviousRowExtendSelection",
  799. "shift KP_UP", "selectPreviousRowExtendSelection",
  800. "ctrl shift UP", "selectPreviousRowExtendSelection",
  801. "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
  802. "ctrl UP", "selectPreviousRowChangeLead",
  803. "ctrl KP_UP", "selectPreviousRowChangeLead",
  804. "HOME", "selectFirstColumn",
  805. "shift HOME", "selectFirstColumnExtendSelection",
  806. "ctrl shift HOME", "selectFirstRowExtendSelection",
  807. "ctrl HOME", "selectFirstRow",
  808. "END", "selectLastColumn",
  809. "shift END", "selectLastColumnExtendSelection",
  810. "ctrl shift END", "selectLastRowExtendSelection",
  811. "ctrl END", "selectLastRow",
  812. "PAGE_UP", "scrollUpChangeSelection",
  813. "shift PAGE_UP", "scrollUpExtendSelection",
  814. "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
  815. "ctrl PAGE_UP", "scrollLeftChangeSelection",
  816. "PAGE_DOWN", "scrollDownChangeSelection",
  817. "shift PAGE_DOWN", "scrollDownExtendSelection",
  818. "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
  819. "ctrl PAGE_DOWN", "scrollRightChangeSelection",
  820. "TAB", "selectNextColumnCell",
  821. "shift TAB", "selectPreviousColumnCell",
  822. "ENTER", "selectNextRowCell",
  823. "shift ENTER", "selectPreviousRowCell",
  824. "ctrl A", "selectAll",
  825. "ctrl SLASH", "selectAll",
  826. "ctrl BACK_SLASH", "clearSelection",
  827. "ESCAPE", "cancel",
  828. "F2", "startEditing",
  829. "SPACE", "addToSelection",
  830. "ctrl SPACE", "toggleAndAnchor",
  831. "shift SPACE", "extendTo",
  832. "ctrl shift SPACE", "moveSelectionTo"
  833. }),
  834. "Table.ancestorInputMap.RightToLeft",
  835. new UIDefaults.LazyInputMap(new Object[] {
  836. "RIGHT", "selectPreviousColumn",
  837. "KP_RIGHT", "selectPreviousColumn",
  838. "shift RIGHT", "selectPreviousColumnExtendSelection",
  839. "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
  840. "ctrl shift RIGHT", "selectPreviousColumnExtendSelection",
  841. "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection",
  842. "shift RIGHT", "selectPreviousColumnChangeLead",
  843. "shift KP_RIGHT", "selectPreviousColumnChangeLead",
  844. "LEFT", "selectNextColumn",
  845. "KP_LEFT", "selectNextColumn",
  846. "shift LEFT", "selectNextColumnExtendSelection",
  847. "shift KP_LEFT", "selectNextColumnExtendSelection",
  848. "ctrl shift LEFT", "selectNextColumnExtendSelection",
  849. "ctrl shift KP_LEFT", "selectNextColumnExtendSelection",
  850. "ctrl LEFT", "selectNextColumnChangeLead",
  851. "ctrl KP_LEFT", "selectNextColumnChangeLead",
  852. "ctrl PAGE_UP", "scrollRightChangeSelection",
  853. "ctrl PAGE_DOWN", "scrollLeftChangeSelection",
  854. "ctrl shift PAGE_UP", "scrollRightExtendSelection",
  855. "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
  856. }),
  857. "Table.font", new FontLazyValue(Region.TABLE),
  858. "TableHeader.font", new FontLazyValue(Region.TABLE_HEADER),
  859. "TextArea.caretForeground", caretColor,
  860. "TextArea.caretAspectRatio", defaultCaretAspectRatio,
  861. "TextArea.caretBlinkRate", caretBlinkRate,
  862. "TextArea.margin", zeroInsets,
  863. "TextArea.focusInputMap", multilineInputMap,
  864. "TextArea.font", new FontLazyValue(Region.TEXT_AREA),
  865. "TextField.caretForeground", caretColor,
  866. "TextField.caretAspectRatio", defaultCaretAspectRatio,
  867. "TextField.caretBlinkRate", caretBlinkRate,
  868. "TextField.margin", zeroInsets,
  869. "TextField.focusInputMap", fieldInputMap,
  870. "TextField.font", new FontLazyValue(Region.TEXT_FIELD),
  871. "TextPane.caretForeground", caretColor,
  872. "TextPane.caretAspectRatio", defaultCaretAspectRatio,
  873. "TextPane.caretBlinkRate", caretBlinkRate,
  874. "TextPane.margin", editorMargin,
  875. "TextPane.focusInputMap", multilineInputMap,
  876. "TextPane.font", new FontLazyValue(Region.TEXT_PANE),
  877. "TitledBorder.titleColor", new ColorUIResource(Color.BLACK),
  878. "TitledBorder.border", new UIDefaults.ProxyLazyValue(
  879. "javax.swing.plaf.BorderUIResource",
  880. "getEtchedBorderUIResource"),
  881. "ToggleButton.focusInputMap",
  882. new UIDefaults.LazyInputMap(new Object[] {
  883. "SPACE", "pressed",
  884. "released SPACE", "released"
  885. }),
  886. "ToggleButton.font", new FontLazyValue(Region.TOGGLE_BUTTON),
  887. "ToolBar.separatorSize", new DimensionUIResource(10, 10),
  888. "ToolBar.handleIcon", new UIDefaults.ActiveValue() {
  889. public Object createValue(UIDefaults table) {
  890. return GTKIconFactory.getToolBarHandleIcon();
  891. }
  892. },
  893. "ToolBar.ancestorInputMap",
  894. new UIDefaults.LazyInputMap(new Object[] {
  895. "UP", "navigateUp",
  896. "KP_UP", "navigateUp",
  897. "DOWN", "navigateDown",
  898. "KP_DOWN", "navigateDown",
  899. "LEFT", "navigateLeft",
  900. "KP_LEFT", "navigateLeft",
  901. "RIGHT", "navigateRight",
  902. "KP_RIGHT", "navigateRight"
  903. }),
  904. "ToolBar.font", new FontLazyValue(Region.TOOL_BAR),
  905. "ToolTip.font", new FontLazyValue(Region.TOOL_TIP),
  906. "Tree.padding", new Integer(4),
  907. "Tree.drawHorizontalLines", Boolean.FALSE,
  908. "Tree.drawVerticalLines", Boolean.FALSE,
  909. "Tree.rowHeight", new Integer(-1),
  910. "Tree.scrollsOnExpand", Boolean.FALSE,
  911. "Tree.expanderSize", new Integer(10),
  912. "Tree.closedIcon", null,
  913. "Tree.leafIcon", null,
  914. "Tree.openIcon", null,
  915. "Tree.expandedIcon", new GTKStyle.GTKLazyValue(
  916. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  917. "getTreeExpandedIcon"),
  918. "Tree.collapsedIcon", new GTKStyle.GTKLazyValue(
  919. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  920. "getTreeCollapsedIcon"),
  921. "Tree.leftChildIndent", new Integer(2),
  922. "Tree.rightChildIndent", new Integer(12),
  923. "Tree.scrollsHorizontallyAndVertically", Boolean.FALSE,
  924. "Tree.drawsFocusBorder", Boolean.TRUE,
  925. "Tree.focusInputMap",
  926. new UIDefaults.LazyInputMap(new Object[] {
  927. "ctrl C", "copy",
  928. "ctrl V", "paste",
  929. "ctrl X", "cut",
  930. "COPY", "copy",
  931. "PASTE", "paste",
  932. "CUT", "cut",
  933. "UP", "selectPrevious",
  934. "KP_UP", "selectPrevious",
  935. "shift UP", "selectPreviousExtendSelection",
  936. "shift KP_UP", "selectPreviousExtendSelection",
  937. "ctrl shift UP", "selectPreviousExtendSelection",
  938. "ctrl shift KP_UP", "selectPreviousExtendSelection",
  939. "ctrl UP", "selectPreviousChangeLead",
  940. "ctrl KP_UP", "selectPreviousChangeLead",
  941. "DOWN", "selectNext",
  942. "KP_DOWN", "selectNext",
  943. "shift DOWN", "selectNextExtendSelection",
  944. "shift KP_DOWN", "selectNextExtendSelection",
  945. "ctrl shift DOWN", "selectNextExtendSelection",
  946. "ctrl shift KP_DOWN", "selectNextExtendSelection",
  947. "ctrl DOWN", "selectNextChangeLead",
  948. "ctrl KP_DOWN", "selectNextChangeLead",
  949. "RIGHT", "selectChild",
  950. "KP_RIGHT", "selectChild",
  951. "LEFT", "selectParent",
  952. "KP_LEFT", "selectParent",
  953. "typed +", "expand",
  954. "typed -", "collapse",
  955. "BACK_SPACE", "moveSelectionToParent",
  956. "PAGE_UP", "scrollUpChangeSelection",
  957. "shift PAGE_UP", "scrollUpExtendSelection",
  958. "ctrl shift PAGE_UP", "scrollUpExtendSelection",
  959. "ctrl PAGE_UP", "scrollUpChangeLead",
  960. "PAGE_DOWN", "scrollDownChangeSelection",
  961. "shift PAGE_DOWN", "scrollDownExtendSelection",
  962. "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
  963. "ctrl PAGE_DOWN", "scrollDownChangeLead",
  964. "HOME", "selectFirst",
  965. "shift HOME", "selectFirstExtendSelection",
  966. "ctrl shift HOME", "selectFirstExtendSelection",
  967. "ctrl HOME", "selectFirstChangeLead",
  968. "END", "selectLast",
  969. "shift END", "selectLastExtendSelection",
  970. "ctrl shift END", "selectLastExtendSelection",
  971. "ctrl END", "selectLastChangeLead",
  972. "F2", "startEditing",
  973. "ctrl A", "selectAll",
  974. "ctrl SLASH", "selectAll",
  975. "ctrl BACK_SLASH", "clearSelection",
  976. "ctrl LEFT", "scrollLeft",
  977. "ctrl KP_LEFT", "scrollLeft",
  978. "ctrl RIGHT", "scrollRight",
  979. "ctrl KP_RIGHT", "scrollRight",
  980. "SPACE", "addToSelection",
  981. "ctrl SPACE", "toggleAndAnchor",
  982. "shift SPACE", "extendTo",
  983. "ctrl shift SPACE", "moveSelectionTo"
  984. }),
  985. "Tree.focusInputMap.RightToLeft",
  986. new UIDefaults.LazyInputMap(new Object[] {
  987. "RIGHT", "selectParent",
  988. "KP_RIGHT", "selectParent",
  989. "LEFT", "selectChild",
  990. "KP_LEFT", "selectChild",
  991. }),
  992. "Tree.ancestorInputMap",
  993. new UIDefaults.LazyInputMap(new Object[] {
  994. "ESCAPE", "cancel"
  995. }),
  996. "Tree.font", new FontLazyValue(Region.TREE),
  997. "Viewport.font", new FontLazyValue(Region.VIEWPORT)
  998. };
  999. table.putDefaults(defaults);
  1000. if (fallbackFont != null) {
  1001. table.put("TitledBorder.font", fallbackFont);
  1002. }
  1003. }
  1004. protected void initSystemColorDefaults(UIDefaults table) {
  1005. GTKStyleFactory factory = (GTKStyleFactory)getStyleFactory();
  1006. GTKStyle windowStyle = (GTKStyle)factory.getStyle("GtkWindow");
  1007. table.put("window", windowStyle.getGTKColor(SynthConstants.ENABLED,
  1008. GTKColorType.BACKGROUND));
  1009. table.put("windowText", windowStyle.getGTKColor(
  1010. SynthConstants.ENABLED, GTKColorType.TEXT_FOREGROUND));
  1011. GTKStyle entryStyle = (GTKStyle)factory.getStyle("GtkEntry");
  1012. table.put("text", entryStyle.getGTKColor(SynthConstants.ENABLED,
  1013. GTKColorType.TEXT_BACKGROUND));
  1014. table.put("textText", entryStyle.getGTKColor(SynthConstants.ENABLED,
  1015. GTKColorType.TEXT_FOREGROUND));
  1016. table.put("textHighlight",
  1017. entryStyle.getGTKColor(SynthConstants.SELECTED,
  1018. GTKColorType.TEXT_BACKGROUND));
  1019. table.put("textHighlightText",
  1020. entryStyle.getGTKColor(SynthConstants.SELECTED,
  1021. GTKColorType.TEXT_FOREGROUND));
  1022. table.put("textInactiveText",
  1023. entryStyle.getGTKColor(SynthConstants.DISABLED,
  1024. GTKColorType.TEXT_FOREGROUND));
  1025. Object caretColor =
  1026. entryStyle.getClassSpecificValue(Region.TEXT_FIELD, "cursor-color");
  1027. if (caretColor == null) {
  1028. caretColor = GTKStyle.BLACK_COLOR;
  1029. }
  1030. table.put("caretColor", caretColor);
  1031. GTKStyle widgetStyle = (GTKStyle)factory.getStyle("GtkWidget");
  1032. table.put("control", widgetStyle.getGTKColor(SynthConstants.ENABLED,
  1033. GTKColorType.BACKGROUND));
  1034. table.put("controlText", widgetStyle.getGTKColor(
  1035. SynthConstants.ENABLED,
  1036. GTKColorType.TEXT_FOREGROUND));
  1037. table.put("controlHighlight", widgetStyle.getGTKColor(
  1038. SynthConstants.ENABLED, GTKColorType.BACKGROUND));
  1039. table.put("controlLtHighlight", widgetStyle.getGTKColor(
  1040. SynthConstants.ENABLED, GTKColorType.LIGHT));
  1041. table.put("controlShadow", widgetStyle.getGTKColor(
  1042. SynthConstants.ENABLED, GTKColorType.DARK));
  1043. table.put("controlDkShadow", widgetStyle.getGTKColor(
  1044. SynthConstants.ENABLED, GTKColorType.BLACK));
  1045. GTKStyle menuStyle = (GTKStyle)factory.getStyle("GtkMenuItem");
  1046. table.put("menu", menuStyle.getGTKColor(SynthConstants.ENABLED,
  1047. GTKColorType.BACKGROUND));
  1048. table.put("menuText", menuStyle.getGTKColor(SynthConstants.ENABLED,
  1049. GTKColorType.TEXT_FOREGROUND));
  1050. GTKStyle scrollbarStyle = (GTKStyle)factory.getStyle("GtkScrollbar");
  1051. table.put("scrollbar", scrollbarStyle.getGTKColor(SynthConstants.ENABLED,
  1052. GTKColorType.BACKGROUND));
  1053. GTKStyle infoStyle = (GTKStyle)factory.getStyle("GtkMessageDialog");
  1054. table.put("info", scrollbarStyle.getGTKColor(SynthConstants.ENABLED,
  1055. GTKColorType.BACKGROUND));
  1056. table.put("infoText", scrollbarStyle.getGTKColor(SynthConstants.ENABLED,
  1057. GTKColorType.TEXT_FOREGROUND));
  1058. GTKStyle desktopStyle = (GTKStyle)factory.getStyle("GtkContainer");
  1059. table.put("desktop", scrollbarStyle.getGTKColor(SynthConstants.ENABLED,
  1060. GTKColorType.BACKGROUND));
  1061. // colors specific only for GTK
  1062. table.put("light", widgetStyle.getGTKColor(
  1063. SynthConstants.ENABLED, GTKColorType.LIGHT));
  1064. table.put("mid", widgetStyle.getGTKColor(
  1065. SynthConstants.ENABLED, GTKColorType.MID));
  1066. table.put("dark", widgetStyle.getGTKColor(
  1067. SynthConstants.ENABLED, GTKColorType.DARK));
  1068. table.put("black", widgetStyle.getGTKColor(
  1069. SynthConstants.ENABLED, GTKColorType.BLACK));
  1070. table.put("white", widgetStyle.getGTKColor(
  1071. SynthConstants.ENABLED, GTKColorType.WHITE));
  1072. }
  1073. /**
  1074. * Creates the GTK look and feel class for the passed in Component.
  1075. */
  1076. public static ComponentUI createUI(JComponent c) {
  1077. String key = c.getUIClassID().intern();
  1078. if (key == "FileChooserUI") {
  1079. return GTKFileChooserUI.createUI(c);
  1080. }
  1081. return SynthLookAndFeel.createUI(c);
  1082. }
  1083. /**
  1084. * Updates the <code>aaText</code> field.
  1085. */
  1086. static void updateAAText() {
  1087. if (!cjkLocale) {
  1088. Object aaValue = Toolkit.getDefaultToolkit().
  1089. getDesktopProperty("gnome.Xft/Antialias");
  1090. aaText = Boolean.valueOf(((aaValue instanceof Number) &&
  1091. ((Number)aaValue).intValue() == 1));
  1092. }
  1093. }
  1094. static boolean isLeftToRight(Component c) {
  1095. return c.getComponentOrientation().isLeftToRight();
  1096. }
  1097. private static boolean isLocalDisplay() {
  1098. try {
  1099. Class x11Class = Class.forName("sun.awt.X11GraphicsEnvironment");
  1100. Method isDisplayLocalMethod = x11Class.getMethod(
  1101. "isDisplayLocal", new Class[0]);
  1102. return (Boolean)isDisplayLocalMethod.invoke(null, null);
  1103. } catch (NoSuchMethodException nsme) {
  1104. } catch (ClassNotFoundException cnfe) {
  1105. } catch (IllegalAccessException iae) {
  1106. } catch (InvocationTargetException ite) {
  1107. }
  1108. // If we get here we're most likely being run on Windows, return
  1109. // false.
  1110. return false;
  1111. }
  1112. public void initialize() {
  1113. super.initialize();
  1114. inInitialize = true;
  1115. loadStylesFromThemeFiles();
  1116. inInitialize = false;
  1117. Toolkit kit = Toolkit.getDefaultToolkit();
  1118. WeakPCL pcl = new WeakPCL(this, kit, "gnome.Net/ThemeName");
  1119. kit.addPropertyChangeListener(pcl.getKey(), pcl);
  1120. pcl = new WeakPCL(this, kit, "gnome.Gtk/FontName");
  1121. kit.addPropertyChangeListener(pcl.getKey(), pcl);
  1122. pcl = new WeakPCL(this, kit, "gnome.Xft/DPI");
  1123. kit.addPropertyChangeListener(pcl.getKey(), pcl);
  1124. String language = Locale.getDefault().getLanguage();
  1125. cjkLocale =
  1126. (Locale.CHINESE.getLanguage().equals(language) ||
  1127. Locale.JAPANESE.getLanguage().equals(language) ||
  1128. Locale.KOREAN.getLanguage().equals(language));
  1129. if (isLocalDisplay()) {
  1130. pcl = new WeakPCL(this, kit, "gnome.Xft/Antialias");
  1131. kit.addPropertyChangeListener(pcl.getKey(), pcl);
  1132. updateAAText();
  1133. }
  1134. flushUnreferenced();
  1135. }
  1136. static ReferenceQueue queue = new ReferenceQueue();
  1137. static void flushUnreferenced() {
  1138. WeakPCL pcl;
  1139. while ((pcl = (WeakPCL)queue.poll()) != null) {
  1140. pcl.dispose();
  1141. }
  1142. }
  1143. static class WeakPCL extends WeakReference implements
  1144. PropertyChangeListener {
  1145. private Toolkit kit;
  1146. private String key;
  1147. WeakPCL(Object target, Toolkit kit, String key) {
  1148. super(target, queue);
  1149. this.kit = kit;
  1150. this.key = key;
  1151. }
  1152. public String getKey() { return key; }
  1153. public void propertyChange(final PropertyChangeEvent pce) {
  1154. final GTKLookAndFeel lnf = (GTKLookAndFeel)get();
  1155. if (lnf == null) {
  1156. // The property was GC'ed, we're no longer interested in
  1157. // PropertyChanges, remove the listener.
  1158. dispose();
  1159. }
  1160. else {
  1161. // We are using invokeLater here because we are getting called
  1162. // on the AWT-Motif thread which can cause a deadlock.
  1163. SwingUtilities.invokeLater(new Runnable() {
  1164. public void run() {
  1165. if ("gnome.Xft/Antialias".equals(
  1166. pce.getPropertyName())) {
  1167. updateAAText();
  1168. }
  1169. lnf.loadStylesFromThemeFiles();
  1170. Frame appFrames[] = Frame.getFrames();
  1171. for (int i = 0; i < appFrames.length; i++) {
  1172. SynthLookAndFeel.updateStyles(appFrames[i]);
  1173. }
  1174. }
  1175. });
  1176. }
  1177. }
  1178. void dispose() {
  1179. kit.removePropertyChangeListener(key, this);
  1180. }
  1181. }
  1182. public void propertyChange(PropertyChangeEvent evt) {
  1183. String propertyName = evt.getPropertyName();
  1184. loadStylesFromThemeFiles();
  1185. Frame appFrames[] = Frame.getFrames();
  1186. for (int i = 0; i < appFrames.length; i++) {
  1187. SynthLookAndFeel.updateStyles(appFrames[i]);
  1188. }
  1189. }
  1190. public boolean isSupportedLookAndFeel() {
  1191. return true;
  1192. }
  1193. public boolean isNativeLookAndFeel() {
  1194. return false;
  1195. }
  1196. public String getDescription() {
  1197. return "GTK look and feel";
  1198. }
  1199. public String getName() {
  1200. return "GTK look and feel";
  1201. }
  1202. public String getID() {
  1203. return "GTK";
  1204. }
  1205. // Subclassed to pass in false to the superclass, we don't want to try
  1206. // and load the system colors.
  1207. protected void loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative) {
  1208. super.loadSystemColors(table, systemColors, false);
  1209. }
  1210. private void loadStylesFromThemeFiles() {
  1211. AccessController.doPrivileged(new PrivilegedAction() {
  1212. public Object run() {
  1213. GTKParser parser = new GTKParser();
  1214. // GTK rc file parsing:
  1215. // First, attempts to load the file specified in the
  1216. // swing.gtkthemefile system property.
  1217. // RC files come from one of the following locations:
  1218. // 1 - environment variable GTK2_RC_FILES, which is colon
  1219. // separated list of rc files or
  1220. // 2 - SYSCONFDIR/gtk-2.0/gtkrc and ~/.gtkrc-2.0
  1221. //
  1222. // Additionally the default Theme file is parsed last. The default
  1223. // theme name comes from the desktop property gnome.Net/ThemeName
  1224. // Default theme is looked for in ~/.themes/THEME/gtk-2.0/gtkrc
  1225. // and env variable GTK_DATA_PREFIX/THEME/gtkrc or
  1226. // GTK_DATA_PREFIX/THEME/gtk-2.0/gtkrc
  1227. // (or compiled GTK_DATA_PREFIX) GTK_DATA_PREFIX is
  1228. // /usr/share/themes on debian,
  1229. // /usr/sfw/share/themes on Solaris.
  1230. // Lastly key bindings are supposed to come from a different theme
  1231. // with the path built as above, using the desktop property
  1232. // named gnome.Gtk/KeyThemeName.
  1233. // Try system property override first:
  1234. String filename = System.getProperty("swing.gtkthemefile");
  1235. String sep = File.separator;
  1236. if (filename == null || !parseThemeFile(filename, parser)) {
  1237. // Try to load user's theme first
  1238. String userHome = System.getProperty("user.home");
  1239. if (userHome != null) {
  1240. parseThemeFile(userHome + sep + ".gtkrc-2.0", parser);
  1241. }
  1242. // Now try to load "Default" theme
  1243. String themeName = (String)Toolkit.getDefaultToolkit().
  1244. getDesktopProperty("gnome.Net/ThemeName");
  1245. if (themeName == null) {
  1246. themeName = "Default";
  1247. }
  1248. String[] dirs = new String[] {
  1249. userHome + "/.themes",
  1250. System.getProperty("swing.gtkthemedir"),
  1251. "/usr/share/themes" // Debian/Redhat/Solaris/SuSE
  1252. };
  1253. String themeDirName = null;
  1254. // Find the first existing rc file in the list.
  1255. for (int i = 0; i < dirs.length; i++) {
  1256. if (dirs[i] == null) {
  1257. continue;
  1258. }
  1259. if (new File(dirs[i] + sep + themeName + sep +
  1260. "gtk-2.0" + sep + "gtkrc").canRead()) {
  1261. themeDirName = dirs[i];
  1262. break;
  1263. }
  1264. }
  1265. if (themeDirName != null) {
  1266. parseThemeFile(themeDirName + sep + themeName + sep +
  1267. "gtk-2.0" + sep + "gtkrc", parser);
  1268. }
  1269. }
  1270. setStyleFactory(handleParsedData(parser));
  1271. parser.clearParser();
  1272. return null;
  1273. }
  1274. });
  1275. // If we are in initialize initializations will be
  1276. // called later, don't do it now.
  1277. if (!inInitialize) {
  1278. UIDefaults table = UIManager.getLookAndFeelDefaults();
  1279. initSystemColorDefaults(table);
  1280. initComponentDefaults(table);
  1281. }
  1282. }
  1283. private boolean parseThemeFile(String fileName, GTKParser parser) {
  1284. File file = new File(fileName);
  1285. if (file.exists()) {
  1286. try {
  1287. parser.parseFile(file, fileName);
  1288. } catch (IOException ioe) {
  1289. System.err.println("error: (" + ioe.toString()
  1290. + ") while parsing file: \""
  1291. + fileName
  1292. + "\"");
  1293. }
  1294. return true;
  1295. }
  1296. return false; // file doesn't exist
  1297. }
  1298. /**
  1299. * This method is responsible for handling the data that was parsed.
  1300. * One of it's jobs is to fetch and deal with the GTK settings stored
  1301. * in the parser. It's other job is to create a style factory with an
  1302. * appropriate default style, load into it the styles from the parser,
  1303. * and return that factory.
  1304. */
  1305. private GTKStyleFactory handleParsedData(GTKParser parser) {
  1306. HashMap settings = parser.getGTKSettings();
  1307. /*
  1308. * The following is a list of the settings that GTK supports and their meanings.
  1309. * Currently, we only support a subset ("gtk-font-name" and "gtk-icon-sizes"):
  1310. *
  1311. * "gtk-can-change-accels" : Whether menu accelerators can be changed
  1312. * by pressing a key over the menu item.
  1313. * "gtk-color-palette" : Palette to use in the color selector.
  1314. * "gtk-cursor-blink" : Whether the cursor should blink.
  1315. * "gtk-cursor-blink-time" : Length of the cursor blink cycle, in milleseconds.
  1316. * "gtk-dnd-drag-threshold" : Number of pixels the cursor can move before dragging.
  1317. * "gtk-double-click-time" : Maximum time allowed between two clicks for them
  1318. * to be considered a double click (in milliseconds).
  1319. * "gtk-entry-select-on-focus" : Whether to select the contents of an entry when it
  1320. * is focused.
  1321. * "gtk-font-name" : Name of default font to use.
  1322. * "gtk-icon-sizes" : List of icon sizes (gtk-menu=16,16:gtk-button=20,20...
  1323. * "gtk-key-theme-name" : Name of key theme RC file to load.
  1324. * "gtk-menu-bar-accel" : Keybinding to activate the menu bar.
  1325. * "gtk-menu-bar-popup-delay" : Delay before the submenus of a menu bar appear.
  1326. * "gtk-menu-popdown-delay" : The time before hiding a submenu when the pointer is
  1327. * moving towards the submenu.
  1328. * "gtk-menu-popup-delay" : Minimum time the pointer must stay over a menu item
  1329. * before the submenu appear.
  1330. * "gtk-split-cursor" : Whether two cursors should be displayed for mixed
  1331. * left-to-right and right-to-left text.
  1332. * "gtk-theme-name" : Name of theme RC file to load.
  1333. * "gtk-toolbar-icon-size" : Size of icons in default toolbars.
  1334. * "gtk-toolbar-style" : Whether default toolbars have text only, text and icons,
  1335. * icons only, etc.
  1336. */
  1337. Object iconSizes = settings.get("gtk-icon-sizes");
  1338. if (iconSizes instanceof String) {
  1339. if (!configIconSizes((String)iconSizes)) {
  1340. System.err.println("Error parsing gtk-icon-sizes string: '" + iconSizes + "'");
  1341. }
  1342. }
  1343. // Desktop property appears to have preference over rc font.
  1344. Object fontName = Toolkit.getDefaultToolkit().getDesktopProperty(
  1345. "gnome.Gtk/FontName");
  1346. if (!(fontName instanceof String)) {
  1347. fontName = settings.get("gtk-font-name");
  1348. if (!(fontName instanceof String)) {
  1349. fontName = "sans 10";
  1350. }
  1351. }
  1352. Font defaultFont = PangoFonts.lookupFont((String)fontName);
  1353. GTKStyle defaultStyle = new GTKStyle(defaultFont);
  1354. GTKStyleFactory factory = new GTKStyleFactory(defaultStyle);
  1355. parser.loadStylesInto(factory);
  1356. fallbackFont = defaultFont;
  1357. return factory;
  1358. }
  1359. private boolean configIconSizes(String sizeString) {
  1360. String[] sizes = sizeString.split(":");
  1361. for (int i = 0; i < sizes.length; i++) {
  1362. String[] splits = sizes[i].split("=");
  1363. if (splits.length != 2) {
  1364. return false;
  1365. }
  1366. String size = splits[0].trim().intern();
  1367. if (size.length() < 1) {
  1368. return false;
  1369. }
  1370. splits = splits[1].split(",");
  1371. if (splits.length != 2) {
  1372. return false;
  1373. }
  1374. String width = splits[0].trim();
  1375. String height = splits[1].trim();
  1376. if (width.length() < 1 || height.length() < 1) {
  1377. return false;
  1378. }
  1379. int w = 0;
  1380. int h = 0;
  1381. try {
  1382. w = Integer.parseInt(width);
  1383. h = Integer.parseInt(height);
  1384. } catch (NumberFormatException nfe) {
  1385. return false;
  1386. }
  1387. if (w > 0 && h > 0) {
  1388. int type = GTKStyle.GTKStockIconInfo.getIconType(size);
  1389. GTKStyle.GTKStockIconInfo.setIconSize(type, w, h);
  1390. } else {
  1391. System.err.println("Invalid size in gtk-icon-sizes: " + w + "," + h);
  1392. }
  1393. }
  1394. return true;
  1395. }
  1396. /**
  1397. * Returns whether or not the UIs should update their
  1398. * <code>SynthStyles</code> from the <code>SynthStyleFactory</code>
  1399. * when the ancestor of the Component changes.
  1400. *
  1401. * @return whether or not the UIs should update their
  1402. * <code>SynthStyles</code> from the <code>SynthStyleFactory</code>
  1403. * when the ancestor changed.
  1404. */
  1405. public boolean shouldUpdateStyleOnAncestorChanged() {
  1406. return true;
  1407. }
  1408. }