annotate src/ui_help.c @ 370:1eaea84877ce

save file_class to config file
author nadvornik
date Tue, 15 Apr 2008 16:57:30 +0000
parents 6a7298988a7a
children ddabc4873a3f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2 * (SLIK) SimpLIstic sKin functions
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
4 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12 #ifdef HAVE_CONFIG_H
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 # include "config.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "intl.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include <stdio.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include <stdlib.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include <string.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include <gtk/gtk.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22
289
6a7298988a7a Simplify and unify gtk_window creation with the help of
zas_
parents: 9
diff changeset
23 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "ui_help.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #define HELP_WINDOW_WIDTH 620
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #define HELP_WINDOW_HEIGHT 350
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 * 'help' window
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 #define SCROLL_MARKNAME "scroll_point"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 static void help_window_scroll(GtkWidget *text, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 gchar *needle;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 GtkTextIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 GtkTextIter start, end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 if (!text || !key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 needle = g_strdup_printf("[section:%s]", key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 if (gtk_text_iter_forward_search(&iter, needle, GTK_TEXT_SEARCH_TEXT_ONLY,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 &start, &end, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 gint line;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 GtkTextMark *mark;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 line = gtk_text_iter_get_line(&start);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 gtk_text_buffer_get_iter_at_line_offset(buffer, &iter, line, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 gtk_text_buffer_place_cursor(buffer, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(text), &iter, 0.0, TRUE, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 /* apparently only scroll_to_mark works when the textview is not visible yet */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 /* if mark exists, move it instead of creating one for every scroll */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 mark = gtk_text_buffer_get_mark(buffer, SCROLL_MARKNAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 if (mark)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 gtk_text_buffer_move_mark(buffer, mark, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 mark = gtk_text_buffer_create_mark(buffer, SCROLL_MARKNAME, &iter, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(text), mark, 0.0, TRUE, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 g_free(needle);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 static void help_window_load_text(GtkWidget *text, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 gchar s_buf[1024];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 GtkTextIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 GtkTextIter start, end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 if (!text || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 gtk_text_buffer_get_bounds(buffer, &start, &end);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 gtk_text_buffer_delete(buffer, &start, &end);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 f = fopen(pathl, "r");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 if (!f)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 buf = g_strdup_printf(_("Unable to load:\n%s"), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 gtk_text_buffer_insert(buffer, &iter, buf, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 while (fgets(s_buf, sizeof(s_buf), f))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 l = strlen(s_buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 if (!g_utf8_validate(s_buf, l, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 buf = g_locale_to_utf8(s_buf, strlen(s_buf), NULL, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 if (!buf) buf = g_strdup("\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 buf = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 (buf) ? buf : s_buf, -1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 "monospace", NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 gtk_text_buffer_place_cursor(buffer, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(text), &iter, 0.0, TRUE, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 static gint help_window_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 gtk_widget_destroy(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 static void help_window_close(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 GtkWidget *window = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 gtk_widget_destroy(window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 void help_window_set_key(GtkWidget *window, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 GtkWidget *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 if (!window) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 text = g_object_get_data(G_OBJECT(window), "text_widget");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 if (!text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 gdk_window_raise(window->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 if (key) help_window_scroll(text, key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 void help_window_set_file(GtkWidget *window, const gchar *path, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 GtkWidget *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 if (!window || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 text = g_object_get_data(G_OBJECT(window), "text_widget");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 if (!text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 gdk_window_raise(window->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 help_window_load_text(text, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 help_window_scroll(text, key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 GtkWidget *help_window_new(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 const gchar *wmclass, const gchar *subclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 const gchar *path, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 GtkWidget *window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 GtkWidget *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 /* window */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201
289
6a7298988a7a Simplify and unify gtk_window creation with the help of
zas_
parents: 9
diff changeset
202 window = window_new(GTK_WINDOW_TOPLEVEL, subclass, NULL, NULL, title);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 gtk_container_set_border_width(GTK_CONTAINER(window), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 gtk_window_set_default_size(GTK_WINDOW(window), HELP_WINDOW_WIDTH, HELP_WINDOW_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 g_signal_connect(G_OBJECT(window), "delete_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 G_CALLBACK(help_window_delete_cb), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 gtk_container_add(GTK_CONTAINER(window), vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 g_object_set_data(G_OBJECT(window), "text_vbox", vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 /* text window */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 hbox = gtk_hbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 text = gtk_text_view_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 gtk_container_add(GTK_CONTAINER(scrolled), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 gtk_widget_show(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 gtk_text_buffer_create_tag(buffer, "monospace",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 "family", "monospace", NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 hbox = gtk_hbutton_box_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 gtk_container_set_border_width(GTK_CONTAINER(hbox), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 g_signal_connect(G_OBJECT (button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 G_CALLBACK(help_window_close), window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 gtk_container_add(GTK_CONTAINER(hbox), button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 gtk_widget_grab_default(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 g_object_set_data(G_OBJECT(window), "text_widget", text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 help_window_load_text(text, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 gtk_widget_show(window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 help_window_scroll(text, key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 return window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 GtkWidget *help_window_get_box(GtkWidget *window)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 return g_object_get_data(G_OBJECT(window), "text_vbox");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269