"Fossies" - the Fresh Open Source Software Archive 
Member "xzgv-0.9.2/src/help.c" (3 Sep 2017, 3519 Bytes) of package /linux/misc/old/xzgv-0.9.2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "help.c" see the
Fossies "Dox" file reference documentation.
1 /* xzgv - picture viewer for X, with file selector.
2 * Copyright (C) 1999-2003 Russell Marks. See main.c for license details.
3 *
4 * help.c - help viewing, and about box.
5 */
6
7 #include <stdio.h>
8 #include <string.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 #include <utime.h>
14 #include <errno.h>
15 #include <gtk/gtk.h>
16 #include <gdk/gdkkeysyms.h>
17 #include "backend.h"
18 #include "main.h"
19 #include "rcfile.h" /* for XZGV_VER */
20
21 #include "help.h"
22
23
24 void help_about(void)
25 {
26 GtkWidget *about_win;
27 GtkWidget *vbox,*label,*action_tbl,*button;
28
29 about_win=gtk_dialog_new();
30
31 /* make a new vbox for the top part so we can get spacing more sane */
32 vbox=gtk_vbox_new(FALSE,10);
33 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(about_win)->vbox),
34 vbox,TRUE,TRUE,0);
35 gtk_widget_show(vbox);
36
37 gtk_container_set_border_width(GTK_CONTAINER(vbox),5);
38 gtk_container_set_border_width(
39 GTK_CONTAINER(GTK_DIALOG(about_win)->action_area),2);
40
41 gtk_window_set_title(GTK_WINDOW(about_win),"About xzgv");
42 gtk_window_set_policy(GTK_WINDOW(about_win),FALSE,TRUE,TRUE);
43 gtk_window_set_position(GTK_WINDOW(about_win),GTK_WIN_POS_CENTER);
44 /* doesn't really need to be modal, but it'd be confusing if it weren't */
45 gtk_window_set_modal(GTK_WINDOW(about_win),TRUE);
46
47 label=gtk_label_new("xzgv " XZGV_VER " - picture viewer for X with file selector\n"
48 "Copyright (C) 1999-2005 Russell Marks\n"
49 "Copyright (C) 2007 Reuben Thomas\n"
50 "Homepage - http://sourceforge.net/projects/xzgv");
51 gtk_box_pack_start(GTK_BOX(vbox),label,TRUE,TRUE,2);
52 gtk_widget_show(label);
53
54 /* add ok button */
55 action_tbl=gtk_table_new(1,3,TRUE);
56 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(about_win)->action_area),
57 action_tbl,TRUE,TRUE,0);
58 gtk_widget_show(action_tbl);
59
60 button=gtk_button_new_with_label("Ok");
61 gtk_table_attach_defaults(GTK_TABLE(action_tbl),button, 1,2, 0,1);
62 gtk_signal_connect_object(GTK_OBJECT(button),"clicked",
63 GTK_SIGNAL_FUNC(gtk_widget_destroy),
64 GTK_OBJECT(about_win));
65 gtk_widget_grab_focus(button);
66 gtk_widget_show(button);
67
68 /* also allow escs (even from main window!) */
69 gtk_widget_add_accelerator(button,"clicked",mainwin_accel_group,
70 GDK_Escape,0,0);
71
72
73 gtk_widget_show(about_win);
74 }
75
76
77 /* currently, this runs info in an xterm on the specified node.
78 * It's better than nothing, but it wouldn't hurt to have something
79 * nicer... :-)
80 *
81 * And don't worry, this *will* be configurable in future (XXX).
82 */
83 void help_run(char *node)
84 {
85 char *cmd_start="xterm -e info '(xzgv)";
86 char *cmd_end="' &";
87 char *buf;
88
89 if((buf=malloc(strlen(cmd_start)+strlen(node)+strlen(cmd_end)+1))==NULL)
90 {
91 /* if we're *that* low on memory, then error_dialog() will fail too,
92 * so just return.
93 */
94 return;
95 }
96
97 strcpy(buf,cmd_start);
98 strcat(buf,node);
99 strcat(buf,cmd_end);
100
101 /* XXX it turns out the error check is useless, as the `&' leads to
102 * starting another shell which is the one to give any errors. The
103 * one we directly run here is always happy, error or not. :-/
104 * Looks like I'll need the full fork/exec junk, oh well...
105 */
106 if(system(buf)!=0)
107 {
108 char *msg="Couldn't run help command:\n";
109 char *buf2;
110
111 if((buf2=malloc(strlen(msg)+strlen(buf)+1))==NULL)
112 error_dialog("xzgv error",msg);
113 else
114 {
115 strcpy(buf2,msg);
116 strcat(buf2,buf);
117 error_dialog("xzgv error",buf2);
118 free(buf2);
119 }
120
121 free(buf);
122 return;
123 }
124
125 free(buf);
126 }