1 /********************************************************************************
2 * Copyright (c) 2001, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sf.glxdesktop.gui.glxinfo;
12
13 import net.sf.glxdesktop.gui.glade.LoadGladeException;
14
15 import org.gnu.gdk.KeyValue;
16 import org.gnu.gtk.Gtk;
17 import org.gnu.gtk.event.KeyEvent;
18 import org.gnu.gtk.event.KeyListener;
19 import org.gnu.gtk.event.LifeCycleEvent;
20 import org.gnu.gtk.event.LifeCycleListener;
21
22 public class GlxInfoWindowImpl extends GlxInfoWindow {
23
24 public static final String APP_ICON = "pixmap/3ddesktop.png";
25
26 public GlxInfoWindowActions actions;
27
28 public GlxInfoWindowMenu menu;
29
30 protected String display;
31
32 protected String glxinfo;
33
34 public GlxInfoWindowImpl() throws LoadGladeException {
35 setListeners();
36
37
38 window.setIconFromFile(ClassLoader.getSystemClassLoader().getResource(APP_ICON).getFile());
39 menu = new GlxInfoWindowMenu(this);
40 actions = new GlxInfoWindowActions(this);
41 menu.setActions(actions);
42 actions.refreshGlxinfo();
43 }
44
45 public void initGui() {
46
47
48 entryGlxDisplay.setText(actions.getDisplayName());
49 labelGlxScreen.setText(actions.getGlxinfoText(
50 "screen:", "direct rendering:"));
51 labelGlxDirectRedering.setText(actions.getI18nDirectRendering());
52
53 labelServerGlxVendor.setText(actions.getGlxinfoText(
54 "server glx vendor string:", "server glx version"));
55 labelServerGlxVersion.setText(actions.getGlxinfoText(
56 "server glx version string:", "server glx extensions"));
57 labelServerGlxExtensions.setText(actions.getGlxServerExtensions());
58
59 labelClientGlxVendor.setText(actions.getGlxinfoText(
60 "client glx vendor string:", "client glx version"));
61 labelClientGlxVersion.setText(actions.getGlxinfoText(
62 "client glx version string:", "client glx extensions"));
63 labelClientGlxExtensions.setText(actions.getGlxClientExtensions());
64
65 labelGlxVersion.setText(actions.getGlxinfoText(
66 "GLX version:", "GLX extensions"));
67 labelGlxExtensions.setText(actions.getGLXExtensions());
68
69 labelOpenGLVendor.setText(actions.getGlxinfoText(
70 "OpenGL vendor string:", "OpenGL renderer"));
71 labelOpenGLRender.setText(actions.getGlxinfoText(
72 "OpenGL renderer string:", "OpenGL version"));
73 labelOpenGLVersion.setText(actions.getGlxinfoText(
74 "OpenGL version string:", "OpenGL extensions"));
75 labelOpenGLExtensions.setText(actions.getOpenGLExtensions());
76
77 String gluExtensions = actions.getGLUExtensions();
78 labelGluVersion.setText(actions.getGlxinfoText(
79 "glu version:", "glu extensions"));
80 if (!gluExtensions.equals("")) {
81 labelGluExtensions.setText(gluExtensions);
82 } else {
83 labelGluExtensions.setText(Messages.getString("GlxInfoWindowActions.no_dr_info"));
84
85 }
86
87 actions.setGlxTableTreeViewer();
88 }
89
90 private void setListeners() {
91 window.addListener(new LifeCycleListener() {
92
93
94
95
96 public void lifeCycleEvent(LifeCycleEvent event) {
97 }
98
99
100
101
102 public boolean lifeCycleQuery(LifeCycleEvent event) {
103 if (event.isOfType(LifeCycleEvent.Type.DESTROY)
104 || event.isOfType(LifeCycleEvent.Type.DELETE))
105 Gtk.mainQuit();
106 return true;
107 }
108 });
109
110 entryGlxDisplay.addListener(new KeyListener() {
111
112
113
114
115 public boolean keyEvent(KeyEvent event) {
116 if (event.isOfType(KeyEvent.Type.KEY_PRESSED))
117 if (event.getKeyval() == KeyValue.Return)
118 actions.refreshGlxinfo();
119 return false;
120 }
121 });
122 }
123
124 public static void main(String[] args) {
125
126 Gtk.init(args);
127 try {
128 new GlxInfoWindowImpl();
129 } catch (LoadGladeException e) {
130 e.printStackTrace();
131 }
132 Gtk.main();
133 }
134
135 }