2 Copyright (C) 1995 Jakub Jelinek.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19 #include <xview/xview.h>
20 #include <xview/frame.h>
21 #include <xview/panel.h>
22 #include <xview/canvas.h>
23 #include <xview/svrimage.h>
24 #include <xview/cms.h>
25 #include <xview/font.h>
26 #include <xview/scrollbar.h>
42 extern Dlg_head
*midnight_dlg
;
43 extern int defaultDepth
; /* xvmain.c */
44 extern Display
*dpy
; /* xvmain.c */
45 extern Frame mcframe
; /* ??? xvmain.c, but is this what we want?? */
50 #include "mc_icon.xpm"
52 void x_setup_info (void)
54 Pixmap pixmap
, shapemask
= 0;
56 infocms
= xv_create (XV_NULL
, CMS
,
57 CMS_SIZE
, sizeof (mc_colors
) / sizeof (Xv_singlecolor
) + CMS_CONTROL_COLORS
,
58 CMS_CONTROL_CMS
, TRUE
,
60 CMS_COLORS
, &mc_colors
,
63 XpmCreatePixmapFromData (dpy
, (Drawable
)xv_get(mcframe
, XV_XID
),
64 mc_icon_xpm
, &pixmap
, &shapemask
, NULL
);
66 mcimage
= xv_create (XV_NULL
, SERVER_IMAGE
,
69 SERVER_IMAGE_COLORMAP
, "infocms",
70 SERVER_IMAGE_DEPTH
, defaultDepth
,
71 /* SERVER_IMAGE_X_BITS, mc_bits, */
72 SERVER_IMAGE_PIXMAP
, pixmap
,
77 static void x_info_recalculate (Columnizer tile
)
79 int i
, j
, top
= xv_get (tile
, COLUMNIZER_N_COLUMNS
);
80 int count
= xv_get (tile
, COLUMNIZER_N_ROWS
), max
, w
;
82 for (i
= 0; i
< top
; i
++) {
84 for (j
= 0; j
< count
; j
++) {
85 w
= xv_get ((Rectobj
) xv_get (tile
, COLUMNIZER_POSITION
, i
, j
),
90 for (j
= 0; j
< count
; j
++) {
91 xv_set ((Rectobj
) xv_get (tile
, COLUMNIZER_POSITION
, i
, j
),
99 void x_show_info (WInfo
*info
, struct my_statfs
*s
, struct stat
*b
)
102 Canvas_shell canvas
= (Canvas_shell
) xv_get ((Bag
) (info
->widget
.wdata
),
104 Columnizer tile
= (Columnizer
) xv_get ((Bag
) (info
->widget
.wdata
),
105 RECTOBJ_NTH_CHILD
, 3);
115 CANVAS_SHELL_DELAY_REPAINT
, TRUE
,
118 for (i
= 0; i
< 14; i
++) {
122 if (s
->nfree
>0 || s
->nodes
> 0)
123 sprintf (buffer
, "%d (%d%%) of %d",
126 ? 100 * s
->nfree
/ s
->nodes
: 0,
129 text
= "No node information";
133 if (s
->avail
> 0 || s
->total
> 0){
134 sprint_bytesize (buffer
, s
->avail
, 1);
135 p
= strchr (buffer
, 0);
136 sprintf (p
, " (%d%%) of ", s
->total
137 ? 100 * s
->avail
/ s
->total
: 0);
138 p
= strchr (buffer
, 0);
139 sprint_bytesize (p
, s
->total
, 1);
141 text
= "No space information";
145 sprintf (buffer
, "%s ", s
->typename
);
146 p
= strchr (buffer
, 0);
147 if ((unsigned) s
->type
!= 0xffff &&
148 (unsigned) s
->type
!= 0xffffffff)
149 sprintf (p
, " (%Xh)", s
->type
);
161 text
= file_date (b
->st_atime
);
165 text
= file_date (b
->st_mtime
);
169 text
= file_date (b
->st_ctime
);
175 sprintf (buffer
, "major: %d, minor: %d",
176 b
->st_rdev
>> 8, b
->st_rdev
& 0xff);
177 xv_set (xv_get (tile
, COLUMNIZER_POSITION
, 0, i
),
178 DRAWTEXT_STRING
, "Inode dev:",
181 xv_set (xv_get (tile
, COLUMNIZER_POSITION
, 0, i
),
182 DRAWTEXT_STRING
, "Size:",
185 sprint_bytesize (buffer
, b
->st_size
, 0);
186 p
= strchr (buffer
, 0);
187 #ifdef HAVE_ST_BLOCKS
188 sprintf (p
, " (%d blocks)", (int) b
->st_blocks
);
196 sprintf (buffer
, "%s/%s", get_owner (b
->st_uid
),
197 get_group (b
->st_gid
));
201 sprintf (buffer
, "%d", b
->st_nlink
);
205 sprintf (buffer
, "%s (%o)",
206 string_perm (b
->st_mode
), b
->st_mode
& 07777);
210 sprintf (buffer
, "%Xh:%Xh", (int) b
->st_dev
, (int) b
->st_ino
);
214 text
= cpanel
->dir
.list
[cpanel
->selected
].fname
;
217 xv_set (xv_get (tile
, COLUMNIZER_POSITION
, 1, i
),
218 DRAWTEXT_STRING
, text
,
222 x_info_recalculate (tile
);
224 w
= xv_get ((Bag
) (info
->widget
.wdata
), XV_WIDTH
);
225 h
= xv_get ((Bag
) (info
->widget
.wdata
), XV_HEIGHT
);
228 CANVAS_MIN_PAINT_WIDTH
, w
,
229 CANVAS_MIN_PAINT_HEIGHT
, h
,
232 OPENWIN_EACH_VIEW (canvas
, win
)
233 scrollbar
= (Scrollbar
) xv_get (canvas
, OPENWIN_HORIZONTAL_SCROLLBAR
, win
);
234 if (scrollbar
!= XV_NULL
)
236 SCROLLBAR_OBJECT_LENGTH
, w
,
237 SCROLLBAR_PIXELS_PER_UNIT
, 1,
239 scrollbar
= (Scrollbar
) xv_get (canvas
, OPENWIN_VERTICAL_SCROLLBAR
, win
);
240 if (scrollbar
!= XV_NULL
)
242 SCROLLBAR_OBJECT_LENGTH
, h
,
243 SCROLLBAR_PIXELS_PER_UNIT
, 1,
248 CANVAS_SHELL_DELAY_REPAINT
, FALSE
,
254 # define VERSION "undefined"
258 void backevent_proc_seal (Xv_window
, Event
*, Canvas_shell
, Rectobj
);
260 int x_create_info (Dlg_head
*h
, widget_data parent
, WInfo
*info
)
264 (Canvas
) x_get_parent_object ((Widget
*) info
, parent
);
271 static char *names
[] = { "File:", "Location:", "Mode:", "Links:", "Owner:",
272 "Size:", "Created:", "Modified:", "Accessed:", "Filesystem:", "Device:",
273 "Type:", "Free space:", "Free nodes:" };
275 previous
= xv_get (canvas
, RECTOBJ_NTH_CHILD
, 0);
277 if (previous
!= XV_NULL
)
278 xv_destroy_safe (previous
);
280 tile
= xv_create (canvas
, BAG
,
281 XV_KEY_DATA
, KEY_DATA_PANEL
, info
,
282 XV_KEY_DATA
, KEY_DATA_PANEL_CONTAINER
, xv_get (canvas
, XV_OWNER
),
283 RECTOBJ_EVENT_PROC
, backevent_proc_seal
,
286 XV_KEY_DATA
, KEY_DATA_BOLD_FONT
,
287 xv_find (canvas
, FONT
,
288 FONT_FAMILY
, xv_get (xv_get (canvas
, CANVAS_SHELL_FONT
),
290 FONT_SIZE
, xv_get (xv_get (canvas
, CANVAS_SHELL_FONT
),
292 FONT_STYLE
, FONT_STYLE_BOLD
,
296 XV_KEY_DATA
, KEY_DATA_TILE
, tile
,
297 RECTOBJ_ACCEPTS_DROP
, FALSE
,
298 RECTOBJ_EVENT_PROC
, backevent_proc_seal
,
299 CANVAS_PAINTWINDOW_ATTRS
,
301 KBD_DONE
, KBD_USE
, WIN_ASCII_EVENTS
, WIN_LEFT_KEYS
, WIN_TOP_KEYS
,
302 WIN_RIGHT_KEYS
, WIN_META_EVENTS
, WIN_EDIT_KEYS
, WIN_MOTION_KEYS
,
306 CANVAS_SHELL_EVENT_PROC
, NULL
,
309 xv_create (tile
, DRAWIMAGE
,
313 XV_HEIGHT
, mc_height
,
314 DRAWIMAGE_IMAGE1
, mcimage
,
315 RECTOBJ_SELECTABLE
, FALSE
,
316 RECTOBJ_EVENT_PROC
, backevent_proc_seal
,
318 sprintf (buffer
, "Midnight X Commander, version %s", VERSION
);
319 text
= (Drawtext
) xv_create (tile
, DRAWTEXT
,
321 XV_Y
, mc_height
+ 15,
322 DRAWTEXT_STRING
, buffer
,
323 DRAWTEXT_FONT
, xv_get (tile
, XV_KEY_DATA
, KEY_DATA_BOLD_FONT
),
324 RECTOBJ_SELECTABLE
, FALSE
,
325 RECTOBJ_EVENT_PROC
, backevent_proc_seal
,
327 height
= xv_get (text
, XV_HEIGHT
) + mc_height
+ 15;
328 xv_create (tile
, DRAWRECT
,
331 XV_WIDTH
, xv_get (text
, XV_WIDTH
),
334 RECTOBJ_SELECTABLE
, FALSE
,
335 RECTOBJ_EVENT_PROC
, backevent_proc_seal
,
337 tile1
= xv_create (tile
, COLUMNIZER
,
340 COLUMNIZER_N_COLUMNS
, 2,
341 COLUMNIZER_N_ROWS
, 14,
342 COLUMNIZER_COLUMN_GAP
, 10,
343 COLUMNIZER_ROW_GAP
, 0,
344 RECTOBJ_EVENT_PROC
, backevent_proc_seal
,
346 for (i
= 0; i
< 14; i
++) {
347 xv_create (tile1
, DRAWTEXT
,
348 DRAWTEXT_STRING
, names
[i
],
349 DRAWTEXT_FONT
, xv_get (tile
, XV_KEY_DATA
, KEY_DATA_BOLD_FONT
),
350 RECTOBJ_SELECTABLE
, FALSE
,
351 RECTOBJ_EVENT_PROC
, backevent_proc_seal
,
353 xv_create (tile1
, DRAWTEXT
,
354 RECTOBJ_SELECTABLE
, FALSE
,
355 RECTOBJ_EVENT_PROC
, backevent_proc_seal
,
358 info
->widget
.wdata
= (widget_data
) tile
;
359 info_show_info (info
);
360 x_info_recalculate (tile1
);