Quick viewing(Text Mode)

Mastering™ Linux

Mastering™ Linux

SYBEX Sample Chapter

Mastering™

Arman Danesh and Michael Jang

Chapter 9: Using Applications with GNOME and X Windows

Copyright © 2001 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501. World rights reserved. No part of this publication may be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic or other record, without the prior agreement and written permission of the publisher. ISBN: 0-7821-2915-3 SYBEX and the SYBEX logo are either registered trademarks or trademarks of SYBEX Inc. in the USA and other countries. TRADEMARKS: Sybex has attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the capitalization style used by the manufacturer. Copyrights and trademarks of all products and services listed or described herein are property of their respective owners and companies. All rules and laws pertaining to said copyrights and trademarks are inferred. This document may contain images, text, trademarks, logos, and/or other material owned by third parties. All rights reserved. Such material may not be copied, distributed, transmitted, or stored without the express, prior, written consent of the owner. The author and publisher have made their best efforts to prepare this book, and the content is based upon final release whenever possible. Portions of the manuscript may be based upon pre-release versions supplied by software manufacturers. The author and the publisher make no representation or warranties of any kind with regard to the completeness or accuracy of the contents herein and accept no liability of any kind including but not limited to performance, merchantability, fitness for any particular purpose, or any losses or damages of any kind caused or alleged to be caused directly or indirectly from this book. SYBEX Inc. 1151 Marina Village Pkwy. Alameda, CA 94501 USA Phone: 510-523-8233 www.sybex.com 2915ch09.qxd 04/19/01 3:37 PM Page 161

CHAPTER NINE 9

Using Applications with GNOME and X Windows

■ Using

■ Customizing Xterm

■ X Windows Applications

■ X Windows Utilities 2915ch09.qxd 04/19/01 3:37 PM Page 162

162 Chapter 9 • Using Applications with GNOME and X Windows

This chapter looks at some X Windows and GNOME applications and how they can be run and used within the GNOME desktop. These applications include xterm, the GNOME (called ), a pro- gram called The GIMP, and several X Windows utilities. These applications have been selected based on one of two criteria: They are useful in everyday Linux operations, or they are representative of the power or range of many Linux applications. This chapter should give you the confidence to begin experimenting with other X Windows applications.

Using Xterm

While X Windows puts a nice-looking and user-friendly face on Linux and allows the creation of fully graphical applications, the fact remains that as a clone, Linux is a command-line-oriented . Although it is possible to use Linux for everyday work without ever using the command prompt, to take advantage of the real power and flexibility of a Unix- like operating system, you need to make at least occasional forays into the world of the command line. Fortunately, this doesn’t mean abandoning the ease of X Windows. The xterm program provides a command prompt window that is fully integrated into the X Windows environment, with a scroll bar, a resizable window, and the ability to copy and paste with other X Windows applications—all features that a standard Linux console lacks.

NOTE You can launch an xterm window in Red Hat Linux 7 by selecting Regular XTerm from the System submenu of the Programs menu. GNOME includes a clone of xterm, known as GNOME . Nevertheless, this chapter describes xterm in detail, because it is available in other Linux graphical environments, including KDE. Many of the same commands work for GNOME terminal; some require slight changes such as an extra dash. Only significant functional differences between these two types of terminals are noted in this chapter. 2915ch09.qxd 04/19/01 3:37 PM Page 163

Using Xterm 163

If you want to launch additional xterm windows, you can also do so from the command line of another xterm window using the command $ xterm & or, if you find that for some reason xterm isn’t on your path, use the command $ /usr/X11R6/bin/xterm &

TIP You can locate most files easily with the locate command. If you want to find the directory where xterm is located, run the locate xterm command. Unfortu- nately, locate doesn’t work with recently created or moved files; in that case, use the find command as described in Chapter 13, “Introducing Linux Commands.”

Alternatively, you can launch additional GNOME terminal windows from the command line of another xterm window using the command $ -terminal &

or you can just click the terminal on the default GNOME panel. By default, this opens a window that is 80 characters wide and 24 lines deep with a scroll bar. The window can be resized to provide more space for viewing information and working. As shown in Figure 9.1, the default color scheme for new xterm windows in Red Hat Linux 7 is black characters on a white back- ground. The default title of the window specifies the current user and directory.

FIGURE 9.1: An xterm window 2915ch09.qxd 04/19/01 3:37 PM Page 164

164 Chapter 9 • Using Applications with GNOME and X Windows

Customizing Xterm

The xterm program is highly customizable. Among other things, you can change the following characteristics: • The window’s font • The color scheme • The default window size • The placement of new windows on the screen • The title of the window This section will look at these options and describe how to use them when launching new xterm windows. At first it might seem that this flexibility has no real value, but in reality it does. On different monitors, different color combinations produce the most readable text, so being able to change the color scheme is a valuable feature. Also, if you regularly use several xterm windows for different tasks (such as running top for managing system performance, reading your e-mail, and managing your files), being able to quickly identify which window is currently being used for which task makes switching between open windows much easier.

Flags and Arguments: A Quick Unix Primer

Before going forward, you need a quick tutorial about how Unix commands work. A com- plete introduction to Unix and Unix commands as used in Linux comes in Chapter 13. To execute a program (or command), you simply need to type the name of the program (and possibly the complete location of the program) and press the Enter key. For instance, to launch xterm, you can use the command $ xterm

or, if the directory where xterm is located is not on your path, use the command $ /usr/X11R6/bin/xterm

The path is where Linux searches for commands. You can find the path with this command: $ echo $PATH

Continued on next page 2915ch09.qxd 04/19/01 3:37 PM Page 165

Customizing Xterm 165

Most programs either require or can accept information that alters the way they behave or provides information to be processed. Two types of information can be provided to a com- mand: flags and arguments. Arguments are information provided to the program to be processed; they can be any- thing from filenames to text to search for. Flags are options that alter the behavior of a program. They appear after the command, separated by one or more spaces and preceded by a dash. For instance, the flag -help causes xterm to print out a help message: $ xterm -help usage: xterm -options ... -e command args

where options include: -help print out this message -display display name X server to contact -geometry geom size (in characters) and position -/+rv turn on/off reverse video -bg color background color -fg color foreground color -bd color border color -bw number border width in pixels -fn fontname normal text font -iconic start iconic -name string client instance, icon, and title strings -title string title string -xrm resourcestring additional resource specifications -/+132 turn on/off column switch inhibiting -/+ah turn on/off always highlight -/+ai turn on/off active icon

Complex flags can also be created to provide information that the flag needs to function correctly. For instance, to set the xterm title, you use the -T flag, but you also need to pro- vide the text that you want to appear in the title bar. The command $ xterm -T Email

creates an xterm window with the word Email as the title. On the other hand, one simple flag is the ampersand (&). For example, the command

Continued on next page 2915ch09.qxd 04/19/01 3:37 PM Page 166

166 Chapter 9 • Using Applications with GNOME and X Windows

$ xterm &

opens another xterm window and returns the current xterm window to the command- line interface. Arguments, on the other hand, are not configuration options but information provided to a program to be processed. Arguments are not preceded by a dash as are flags. Argu- ments are often the names of files to be opened, processed, or edited—as in the follow- ing example, which indicates that the file testfile should be opened for editing with the editor : $ emacs testfile

Setting the Color Scheme Using a variety of flags, it is possible to set almost all aspects of an xterm win- dow’s color scheme from border color to the color of the cursor. This section examines the main elements of the color scheme: foreground color, background color, and cursor color.

Understanding X Windows Colors Before looking at the specific flags used to set colors of an xterm window, you need to look at how colors are referred to in X Windows. Colors in X Windows are specified in RGB (red-green-blue) format. RGB format consists of ordered triplets of numbers, with each number having a value from 0 to 255. The numbers represent the value of the red, green, and blue channels respec- tively, with 0 representing no color and 255 representing the highest possible value of the color. Luckily, you don’t need to figure out the color channel combinations to get your desired color. The work has already been done and is stored in a file that X Windows uses to map color names to their numerical triplets. This file, nor- mally called rgb.txt, is usually found in the directory /usr/X11R6/lib/X11/. A selected list of values in the Red Hat Linux 7 rgb.txt file appears here to make it easy to experiment with colors as you work through this section: snow GhostWhite PapayaWhip LemonChiffon AliceBlue LavenderBlush MistyRose white 2915ch09.qxd 04/19/01 3:37 PM Page 167

Customizing Xterm 167

DarkSlateGray DimGray gray MidnightBlue NavyBlue SlateBlue blue SteelBlue turquoise cyan DarkGreen SeaGreen LawnGreen green GreenYellow DarkKhaki LightYellow yellow RosyBrown IndianRed sienna beige wheat tan chocolate DarkSalmon orange tomato red DeepPink pink maroon magenta violet orchid purple DarkCyan DarkRed LightGreen

NOTE Depending on the of your video display and the applications you are running, you may find that the colors you use don’t appear quite the way you expect. This is due to video card limitations and differences between systems.

Background and Foreground Colors Setting background and foreground colors allows you to control the appearance of the text on your screen. Text appears in the foreground color while the back- ground color, logically, is assigned to the background of the window. The usual default xterm window is black text on a white background. Use the -fg and -bg flags to set the foreground and background colors: $ xterm -fg white -bg black &

This command provides exactly the reverse color scheme of the default xterm window, causing the background to be set to black and the foreground to white. The result looks like Figure 9.2.

NOTE The -bg and -fg flags are not specific to xterm. In fact, they are standard X Win- dows flags that can be used to change the color schemes of most X Windows applications. However, these flags do not work for the gnome-terminal com- mand. To find the right switches for GNOME terminal, run the gnome-terminal --help command. 2915ch09.qxd 04/19/01 3:37 PM Page 168

168 Chapter 9 • Using Applications with GNOME and X Windows

FIGURE 9.2: Controlling the color scheme

Cursor Color If you tried the last example for setting colors, you probably noticed that the cur- sor stayed the same color as the default xterm color scheme. You can change this color as well, using the -cr flag. For instance, if you want a dark blue cursor, you might use the command $ xterm -bg white -fg black -cr MidnightBlue &

Setting the Window Size and Location When you open an xterm window (or any other application’s window, for that matter), the size of the window is set to a default size and the location of the win- dow is determined by the configuration of your window manager (you will see xterm commands in key files when you read Chapter 12, “Advanced X Windows Configuration”). However, you can specify the exact size and placement of windows in X Win- dows using the -geometry flag. This flag is a standard X Windows flag (like -bg and -fg) and works with most X Windows programs. The basic syntax of the flag is -geometry widthxheight+x+y. The variables in this command are shown below: • width specifies the width of the window in pixels. • height specifies the height of the window in pixels. 2915ch09.qxd 04/19/01 3:37 PM Page 169

Customizing Xterm 169

• x specifies the horizontal placement of the window as an offset in pixels from the left side of the display. • y specifies the vertical placement of the window as an offset in pixels from the top of the display. Xterm accepts the use of the -geometry flag but handles the information in a somewhat nonstandard way. When you think about it, specifying the height and width of a terminal window in pixels doesn’t make a lot of sense. Instead, xterm interprets width and height as the number of columns and rows of characters to display and sizes the window according to the font being used. The default window size is 80 columns by 24 lines of characters. But what if you want a small 10-character by 10-character window to be placed 200 pixels from the left side of the screen and 300 pixels down from the top of the screen? You could use the command $ xterm -geometry 10x10+200+300 &

to get a window like the one in Figure 9.3. Note the position of the window rela- tive to the left edge and the top of the screen.

FIGURE 9.3: Using the -geometry flag 2915ch09.qxd 04/19/01 3:37 PM Page 170

170 Chapter 9 • Using Applications with GNOME and X Windows

NOTE The corresponding command for the GNOME terminal is gnome-terminal --geometry=10x10+200+300 &. However, the effect of this command is limited since GNOME terminals have a minimum width of 25 columns.

By adding the -fg and -bg flags, you can also change the default color scheme at the same time you define the size of the window when it opens: $ xterm -geometry 10x10+200+300 -fg DarkRed -bg cyan &

The result looks like Figure 9.4.

FIGURE 9.4: Combining the -geometry flag with the color flags

Setting the Window Title As mentioned earlier, it is useful to be able to set the title of an xterm window to help identify what different windows are being used for. The easiest way to set the title is with the -T or -title flag (they are the same). The command $ xterm -title Email &

creates an xterm window with the title Email, as would the command $ xterm -T Email &

In order to create titles consisting of more than one word (in other words, con- taining spaces and other separators), you need to quote the title so that xterm knows which part of the command to treat as the title. If you prefer to use the title My Email, use the command $ xterm -T “My Email” &

By default, the name of an xterm or GNOME terminal window in Red Hat Linux 7 is the name of the current working directory unless, as you will see below, an application is specified to run inside the xterm window when it opens. 2915ch09.qxd 04/19/01 3:37 PM Page 171

Customizing Xterm 171

NOTE Corresponding commands for the GNOME terminal are gnome-terminal -t Email or gnome-terminal --title Email.

Running an Application in an Xterm Window While the purpose of an xterm window is to use the command line to execute commands, you may want certain character-mode programs to run by default when you launch the xterm window. For instance, if you always keep top running inside an xterm window while you work, you might want to have top launch when you open its xterm. This is done with the -e flag: $ xterm -e top &

This command opens a window like the one in Figure 9.5.

FIGURE 9.5: Launching top when an xterm window opens

When the program running inside the window quits, the xterm window closes. It is important to note that the default window title when you use the -e flag in xterm is the name of the program launched with the -e flag.

NOTE While the -e flag works for the gnome-terminal command, it does not set the default window title. 2915ch09.qxd 04/19/01 3:37 PM Page 172

172 Chapter 9 • Using Applications with GNOME and X Windows

Setting the Font The default font used by xterm is usually quite readable and suited to the average monitor. But if you have a particularly large or small monitor or use an unusually low or high resolution, you may find it wise to change the font you use in your xterm windows. In order to do this, use the -fn flag. But how do you refer to fonts? Fonts are referred to by names that can be as simple as 7x13, which indicates 7 pixels wide and 13 pixels deep, or as complex as -sony-fixed-medium--normal--24-230-75- 75--120-iso8859-1, which indicates the 24-point Latin character set, medium weight, Roman-style font named fixed from the Sony font foundry. X Windows offers a program, xlsfonts, that provides a list of available fonts on your X Windows system. To see a list of available fonts on your system, use the following command in an xterm window: $ xlsfonts | more

The | more part of the command allows you to page through the long list of fonts by hitting the spacebar to move forward a page. So, to choose the 10x20 font, use the command $ xterm -fn 10x20 &

to get a window with a large font like the one in Figure 9.6. When you compare this to Figure 9.1, note that not only is the font bigger, but the xterm window is also bigger to accommodate the bigger font with the same number of rows and columns. In theory, any of these fonts can be used with the -fn flag and the xterm com- mand. In practice, though, this doesn’t work. The nature of xterm is that it needs fixed-width fonts—that is, fonts in which all characters occupy the same amount of space regardless of their comparative sizes. In the world of Win- dows, an example of a fixed-width font is Courier. By contrast, many fonts are proportionally spaced. This means that a letter “i” takes up space than a “w” because the latter is a wider letter. Xterm doesn’t do a good job of handling these proportionally spaced fonts, as can be seen in Figure 9.7 where the selected font is from the Times family. 2915ch09.qxd 04/19/01 3:37 PM Page 173

Customizing Xterm 173

FIGURE 9.6: The 10x20 font

FIGURE 9.7: Using a proportionally spaced font

Listed below are some of the common (and easy-to-type) fixed-width fonts that are available in the X Windows distribution included with Red Hat Linux 7: 5×76×13bold 7×14bold 9×15bold 5×86×98×13 10×20 6×10 7×13 8×13bold 12×24 2915ch09.qxd 04/19/01 3:37 PM Page 174

174 Chapter 9 • Using Applications with GNOME and X Windows

6×12 7×13bold 8×16 6×13 7×14 9×15 If you want to experiment with other fonts, use xlsfonts to see a list of fonts, select a font, and then use the xfd command to display the font in a window. For instance, to display the Sony font -sony-fixed-medium-r-normal--24-230-75-75- c-120-iso8859-1 that you saw earlier, use the command $ xfd -fn -sony-fixed-medium-r-normal--24-230-75-75-c-120-iso8859-1

Notice the use of the -fn flag to specify the font name. The font will be displayed in a window like the one in Figure 9.8.

FIGURE 9.8: Displaying fonts with the xfd command

Click the Quit button to close the window. 2915ch09.qxd 04/19/01 3:37 PM Page 175

X Windows Applications 175

Other Features Xterm offers many more features than the ones listed here. You can find out about them in the xterm man page. A man (short for manual) page provides infor- mation about how to use a specific program. To access the xterm man page, use the command $ man xterm

in an xterm window. This command displays a man page like the one shown in Figure 9.9. Use the arrow keys to scroll through the man page. To exit the man page, type q.

FIGURE 9.9: The xterm man page

NOTE As of this writing, there is no man page available for GNOME terminal. For more information about this program, open up a GNOME terminal window, then click Help ➢ GNOME Terminal Users Guide.

X Windows Applications

So far, you have seen two of the most basic of X Windows applications in action: xterm and the GNOME file manager. If there were nothing more than this, it would 2915ch09.qxd 04/19/01 3:37 PM Page 176

176 Chapter 9 • Using Applications with GNOME and X Windows

reinforce the views of the naysayers who complain that X Windows doesn’t have any applications and that Windows and the Mac OS are where the action is. The reality, though, is that powerful, effective applications do exist for the X Win- dows environment. Even among the free tools out there are those that rival the fea- tures of commercial applications. This section looks at two of the components of the GNOME Office Suite: The GIMP graphical utility and the spreadsheet. Because these are both large programs with extensive feature sets, this section just provides an overview of the applications and what they do and then points to where complete informa- tion on the applications is available. Mastering an application like The GIMP or Gnumeric, after all, would require a book in itself.

NOTE Other components of the GNOME Office Suite include the AbiWord word proces- sor, the program for Visio-style diagrams and flowcharts, and the GNOME-PIM personal information manager.

The GIMP The GIMP (GNU Image Manipulation Program) is an attempt to offer the Linux community a freely available, full-featured image-editing package to rival the likes of or Corel PhotoPaint. Figure 9.10 shows The GIMP run- ning with several of its boxes and tools open. The GIMP is designed to integrate tightly into GNOME and is considered the standard image-editing application for GNOME and a showcase of a high-powered GNOME application. GNOME is included as part of Red Hat Linux 7. Offered under the General Public License, The GIMP is under constant develop- ment by Spencer Kimball and Peter Mattis at the University of California–Berkeley. The GIMP includes all the tools expected of a full-featured image-editing pack- age, including numerous brush types, special-effects filters, intelligent scissors, Bezier selection, layers, transparencies, and 24-bit image support. The GIMP also provides a plug-in mechanism. Numerous plug-ins are freely available on the Internet to perform a variety of tasks, including despeckling, mapping to a sphere, creating mosaics, generating lens flares, and more. 2915ch09.qxd 04/19/01 3:37 PM Page 177

X Windows Applications 177

FIGURE 9.10: The GIMP

In addition, the most recent version (1.2.1) includes a downloadable manual that provides the in-depth instruction and documentation often lacking in . This is all available from The GIMP Web site at manual..org. The version included with Red Hat Linux 7 is 1.1.25. You can run The GIMP from an xterm window with the command $ gimp &

or $ /usr/bin/gimp &

Alternatively, from the main GNOME system menu choose Programs ➢ Graphics ➢ The GIMP to start The GIMP. The GIMP starts up by displaying its toolbar. This window, shown in Fig- ure 9.11, offers access to a wide range of tools plus the main File menu. 2915ch09.qxd 04/19/01 3:37 PM Page 178

178 Chapter 9 • Using Applications with GNOME and X Windows

FIGURE 9.11: The GIMP toolbar

Let’s take a quick look at some of the main tasks in The GIMP: opening and saving images, cropping an image, and capturing a window to an image file. To learn the full set of The GIMP features, refer to the manual for the software that is on The GIMP’s Web site, mentioned earlier.

Opening Images To open an image, click File ➢ Open. A dialog box like the one in Figure 9.12 appears.

FIGURE 9.12: The GIMP Load Image window 2915ch09.qxd 04/19/01 3:37 PM Page 179

X Windows Applications 179

This dialog box works in a vaguely Mac-like fashion. Above the list of files, you see the name of the current directory. You can click the directory name to get a list of its parent directories and, by selecting one of these, quickly change to that directory. Select the filename of your choice. If you are not sure which file you need, you can preview a thumbnail by clicking the Generate Preview button in the Preview section of the Load Image window. When you see the file that you need, click the OK button. The file appears in the viewer window and the dialog box closes.

Saving Images If you want to save an image, you need The GIMP main menu. While working on an actual image, right-clicking anywhere in the image brings up the complete menu for The GIMP, like the one shown in Figure 9.13.

FIGURE 9.13: The GIMP main menu

To open the Save Image dialog box, click File ➢ Save As from The GIMP main menu. The result shown in Figure 9.14 is similar to the Load Image dialog box. Directory navigation works in the same fashion; you select existing filenames by clicking them in the file list, and clicking OK saves the current file to the name displayed in the Save File field. If you want to save the image to a new filename, simply type the name you want in the Selection field. When saving an image, you also want to specify the type of image. In the middle of the dialog box is the Determine File Type button. By clicking this button, you can view a list of available file types. Select the file type you desire from the list. Once you are ready to save your file, click OK. 2915ch09.qxd 04/19/01 3:37 PM Page 180

180 Chapter 9 • Using Applications with GNOME and X Windows

FIGURE 9.14: The GIMP Save Image window

Cropping an Image Cropping an image is a simple process: Turn on cropping, select the area you want to crop, and press the Crop button in the Crop & Resize Information window. To turn on cropping, right-click an image. In the menu that opens, select Tools ➢ Transform Tools ➢ Crop & Resize. To select an area for cropping, drag out a rec- tangle with the left mouse button in the viewer window. Figure 9.15 shows an image displayed in the viewer window with a rectangle indicating where the user has dragged the mouse.

FIGURE 9.15: Selecting a crop area 2915ch09.qxd 04/19/01 3:37 PM Page 181

X Windows Applications 181

Once you have selected an area to crop, simply click the Crop button in the Crop & Resize Information window. The result would be something like Fig- ure 9.16 for the previous example.

FIGURE 9.16: The result of cropping

If you don’t like the results of your cropping, right-click the image. In the menu that opens, select File ➢ Revert to return to the original image.

Capturing a Window One of the popular uses of The GIMP is to create screen shots. If you want to cap- ture an open window to an image file, you can do this using the Acquire Screen Shot feature. When you have a window that you want to capture, click File ➢ Acquire ➢ Screen Shot, which opens the Screen Shot dialog box like the one in Figure 9.17.

FIGURE 9.17: The Screen Shot window

You can grab an individual window or the entire contents of your desktop. To grab an individual window, select Single Window. Click OK, then click the win- dow of your choice. If you don’t want to show the window frame or title, deselect With Decora- tions. For example, if you were to grab an xterm window of the top utility, with background and foreground colors reversed, the result would look almost as if you were not using the X window, as shown in Figure 9.18. 2915ch09.qxd 04/19/01 3:37 PM Page 182

182 Chapter 9 • Using Applications with GNOME and X Windows

FIGURE 9.18: A screen shot of top

Alternatively, you can grab the entire contents of your desktop in the Screen Shot window by selecting Whole Screen. Set the Seconds Delay box to give you time to close or open other windows before The GIMP makes a screen shot of your desktop. Once you have grabbed a window, the image of that window appears in the viewer window, and you can save it like any other image in The GIMP.

Gnumeric Gnumeric is another component of the GNOME , designed to manage numeric data through spreadsheets. This program offers Linux users a freely available full-featured spreadsheet program that can exchange data with other spreadsheet programs such as Microsoft Excel. It is installed by default on Red Hat Linux 7. Offered under the General Public License, Gnumeric is under constant develop- ment by a number of independent developers, most prominently and Jody Goldberg. Since the current version is 0.63, it is not “officially” ready for release; however, support as of this writing can be purchased from at http://www.ximian.com. Gnumeric includes most of the tools of normal spreadsheets. You can find more information about Gnumeric at http://www.gnome.org/gnumeric, including a pub- lic list of “pending tasks.” If you are interested, you can contribute to the devel- opment of this spreadsheet. 2915ch09.qxd 04/19/01 3:37 PM Page 183

X Windows Applications 183

Using Gnumeric Let’s take just a quick look at using Gnumeric. This spreadsheet is part of a num- ber of standard Linux distributions, including Red Hat Linux 7. You can run it from an xterm window with the command $ gnumeric &

or with the command $ /usr/bin/gnumeric &

Alternatively, you can run Gnumeric by clicking the Main Menu button and choosing Programs ➢ Applications ➢ Gnumeric. Gnumeric starts with a blank spreadsheet, as shown in Figure 9.19. Like other spreadsheet programs, Gnumeric includes a number of icons that serve as short- cuts to various tools for editing and creating formulas.

FIGURE 9.19: The Gnumeric spreadsheet

Now you can open up a Gnumeric file when you click the File ➢ Open com- mand. This takes you to a Load File dialog box where you can navigate to the file that you need, in Gnumeric XML . 2915ch09.qxd 04/19/01 3:37 PM Page 184

184 Chapter 9 • Using Applications with GNOME and X Windows

Importing Files From the File menu, you can import Gnumeric data from a number of other file formats. When you click File ➢ Import and then select a file, Gnumeric prompts you to place the file in one of the following five categories: HTML File Made By Gnumeric If you saved a spreadsheet as an HTML file from Gnumeric, you can re-import data from the HTML file. Text File Import One common way to distribute data is in a text file, where commas separate each data point. This is sometimes known as comma-delimited format. The Text File Import option allows Gnumeric to use each comma to assign data to different cells. SC/xspread File Import Gnumeric can import data from other spread- sheet formats, including those based on Microsoft Excel, IBM (Lotus) 1-2-3, and Applixware spreadsheets. Data Interchange Format (DIF) Import The Data Interchange Format is a common way to exchange data between databases and spreadsheets. It is also used as a common translation medium between spreadsheets when there are no other compatible file formats. Simple Text Gnumeric can import text files as simple text. Each line in the text file is assigned to consecutive cells.

Exporting Files You can share Gnumeric files with people who use other spreadsheets. Gnumeric supports exporting to 14 different file formats. To set up this process, choose File ➢ Save As. Enter the desired filename in the Selection box. Click the File Format box to see your options, as shown in Figure 9.20. Select a file format, then click OK.

NOTE The ability to exchange files between different applications is typically less than perfect. This premise holds true for Excel and Gnumeric. Some users have success- fully imported Excel 2000 files into Gnumeric; however, not all functions of these two programs are compatible. 2915ch09.qxd 04/19/01 3:37 PM Page 185

X Windows Utilities 185

FIGURE 9.20: The Save Workbook As window

Formulas The heart of any spreadsheet application is its formulas. By definition, formulas are defined and embedded in specific cells in a spreadsheet. Formulas include functions such as SUM, which totals the cells in a specified range. When Gnumeric converts files from other spreadsheets, it converts these functions as well. If you do not recognize a Gnumeric function, get help by choosing Help ➢ Gnumeric Function Reference.

X Windows Utilities

Before closing this chapter, let’s look at a few handy X Windows utilities and how to use them. These utilities are as follows: •

• xclock

• xcalc 2915ch09.qxd 04/19/01 3:37 PM Page 186

186 Chapter 9 • Using Applications with GNOME and X Windows

Using Gedit Gedit is a GNOME application that provides functionality similar to Windows Notepad. You can use it to open and change the contents of plain text files, search and replace text, and create new files. Admittedly, as Figure 9.21 shows, the gedit interface is a bit spartan, but for quick editing of simple text files, it does the trick.

FIGURE 9.21: The gedit window

You can launch gedit with the command $ gedit &

or, if gedit is not on your path, with the command $ /usr/bin/gedit &

or you can click the main GNOME System menu and choose Programs ➢ Appli- cations ➢ Gedit. The interface is simple. Across the top is the toolbar with self-explanatory buttons for loading and saving files, cutting, copying, pasting, and searching for text. 2915ch09.qxd 04/19/01 3:37 PM Page 187

X Windows Utilities 187

To load an existing file, click the Open button or choose File ➢ Open. A dialog box appears, where you can browse for and select a file to open. When a file is opened, it appears as shown in Figure 9.22.

FIGURE 9.22: The results of loading a file

You can save a file you have opened by clicking the Save button on the toolbar or by choosing File ➢ Save. The Find button on the toolbar brings up the Find dialog box shown in Fig- ure 9.23. You can also open this dialog box by choosing Edit ➢ Find.

FIGURE 9.23: The Find dialog box 2915ch09.qxd 04/19/01 3:37 PM Page 188

188 Chapter 9 • Using Applications with GNOME and X Windows

Using this dialog box is relatively simple: Fill in the text to search for and click the Find button. You can also indicate if you prefer to start your search at the beginning of the document or the current cursor position and whether or not the search should be considered case-sensitive. Replace takes things one step further. You can open the Replace dialog box by selecting Edit ➢ Replace. This dialog box looks like the Find dialog box except that it has an additional field for indicating the text with which to replace each found item. In addition, you can use the Replace button to indicate that you want to be prompted before replacing any text.

X Windows Clocks You have probably noticed the clock that appears in the GNOME panel. Some users, though, like to see a larger digital or analog clock on their desktop. This can be achieved using the xclock program. Xclock is a basic clock program that allows you to create an analog or digital clock. By default, xclock displays an analog clock, so the command $ xclock &

or $ /usr/X11R6/bin/xclock &

creates a window like the one in Figure 9.24.

FIGURE 9.24: The default xclock style

The -digital flag causes xclock to display a digital clock like the one shown in Figure 9.25.

FIGURE 9.25: A digital xclock window 2915ch09.qxd 04/19/01 3:37 PM Page 189

X Windows Utilities 189

The -digital flag is not the only flag accepted by xclock. The -hd and -hl flags help create a more interesting visual display for an analog clock. The -hd flag is used to specify a color for the hands of the clock, and the -hl flag specifies the color for the outline of the hands of the clock. (Remember the discussion of RGB colors earlier? This is one instance where you would use RGB colors.) For example, the command $ xclock -hd yellow -hl green &

creates a clock that has yellow hands with green outlines as in Figure 9.26 (of course, this is hard to see in the black-and-white reproduction you are looking at).

FIGURE 9.26: Setting the color of the clock’s hands

Notice the lack of contrast between the hands and the white face of the clock. This can be rectified with a standard X Windows flag: the -bg flag that you saw earlier in the discussion of xterm. By specifying a background color of black with $ xclock -hd yellow -hl green -bg black &

you end up with something like Figure 9.27.

FIGURE 9.27: Setting the background color

While the hands are now clearly visible, a new problem has arisen: The marks that indicate the points of the clock are now invisible, since they are black and they are drawn against a black background. These marks are considered part of 2915ch09.qxd 04/19/01 3:37 PM Page 190

190 Chapter 9 • Using Applications with GNOME and X Windows

the foreground, and their color can be changed with the standard X Windows -fg flag. The command $ xclock -hd yellow -hl green -bg black -fg cyan &

gives a result like Figure 9.28.

FIGURE 9.28: Setting the foreground color

Using the GNOME Calculator Finally, let’s take a quick look at the GNOME Calculator, the default GNOME cal- culator tool that should be available in every distribution of Linux that includes GNOME. As you might expect by this point, you can run the GNOME Calculator with the command $ gcalc &

or with the command $ /usr/bin/gcalc &

The GNOME Calculator can also be opened by selecting Simple Calculator from the Utilities submenu of the main GNOME System menu. The GNOME Calculator window looks like Figure 9.29. The Calculator operates much as any standard scientific calculator does. It pro- vides all the expected scientific functions, including trigonometric and logarithmic functions, plus a memory. The actual use of such a calculator and its functions is not really the subject of this chapter, and a full description of the meaning of these functions is best left to a mathematics text. 2915ch09.qxd 04/19/01 3:37 PM Page 191

Looking Ahead 191

FIGURE 9.29: The GNOME Calculator window

Looking Ahead

By now, you should be feeling fairly comfortable navigating your GNOME envi- ronment. You can control basic options of GNOME, you can launch applications, and you can manipulate windows. As mentioned earlier, though, the power of both X Windows and GNOME comes from their flexibility and configurability. Chapter 10, “Advanced GNOME Configuration,” looks at how to go about con- figuring GNOME to meet your personal needs. This includes customizing the main GNOME panel, changing your desktop appearance and themes, and per- forming other common GNOME configuration tasks.