annotate src/ui_help.c @ 159:436376b60867

moved some actions to menu and accels
author nadvornik
date Mon, 17 Dec 2007 21:42:24 +0000
parents d907d608745f
children 6a7298988a7a
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "ui_help.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27
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 #define HELP_WINDOW_WIDTH 620
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #define HELP_WINDOW_HEIGHT 350
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31
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 * 'help' window
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 *-----------------------------------------------------------------------------
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 #define SCROLL_MARKNAME "scroll_point"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 static void help_window_scroll(GtkWidget *text, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 gchar *needle;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 GtkTextIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 GtkTextIter start, end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 if (!text || !key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 needle = g_strdup_printf("[section:%s]", key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 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
56 &start, &end, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 gint line;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 GtkTextMark *mark;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 line = gtk_text_iter_get_line(&start);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 gtk_text_buffer_get_iter_at_line_offset(buffer, &iter, line, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 gtk_text_buffer_place_cursor(buffer, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 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
67 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 /* 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
70
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 /* if mark exists, move it instead of creating one for every scroll */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 mark = gtk_text_buffer_get_mark(buffer, SCROLL_MARKNAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 if (mark)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 gtk_text_buffer_move_mark(buffer, mark, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 mark = gtk_text_buffer_create_mark(buffer, SCROLL_MARKNAME, &iter, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 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
82 }
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 g_free(needle);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 }
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 static void help_window_load_text(GtkWidget *text, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 gchar s_buf[1024];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 GtkTextIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 GtkTextIter start, end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 if (!text || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 gtk_text_buffer_get_bounds(buffer, &start, &end);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 gtk_text_buffer_delete(buffer, &start, &end);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 f = fopen(pathl, "r");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 if (!f)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 buf = g_strdup_printf(_("Unable to load:\n%s"), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 gtk_text_buffer_insert(buffer, &iter, buf, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 while (fgets(s_buf, sizeof(s_buf), f))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 l = strlen(s_buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 if (!g_utf8_validate(s_buf, l, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 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
127 if (!buf) buf = g_strdup("\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 buf = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 (buf) ? buf : s_buf, -1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 "monospace", NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 }
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 gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 gtk_text_buffer_place_cursor(buffer, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 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
144 }
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 static gint help_window_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 gtk_widget_destroy(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 }
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 static void help_window_close(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 GtkWidget *window = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 gtk_widget_destroy(window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 }
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 void help_window_set_key(GtkWidget *window, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 GtkWidget *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 if (!window) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 text = g_object_get_data(G_OBJECT(window), "text_widget");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 if (!text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 gdk_window_raise(window->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 if (key) help_window_scroll(text, key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 }
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 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
173 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 GtkWidget *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 if (!window || !path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 text = g_object_get_data(G_OBJECT(window), "text_widget");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 if (!text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 gdk_window_raise(window->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 help_window_load_text(text, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 help_window_scroll(text, key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 }
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 GtkWidget *help_window_new(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 const gchar *wmclass, const gchar *subclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 const gchar *path, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 GtkWidget *window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 GtkWidget *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 /* window */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 gtk_container_set_border_width(GTK_CONTAINER(window), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 gtk_window_set_wmclass(GTK_WINDOW(window), subclass, wmclass);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 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
209
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 gtk_window_set_title(GTK_WINDOW(window), title);
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 g_signal_connect(G_OBJECT(window), "delete_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 G_CALLBACK(help_window_delete_cb), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 gtk_container_add(GTK_CONTAINER(window), vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 g_object_set_data(G_OBJECT(window), "text_vbox", vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 /* text window */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 hbox = gtk_hbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 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
229 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 text = gtk_text_view_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 gtk_container_add(GTK_CONTAINER(scrolled), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 gtk_widget_show(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 gtk_text_buffer_create_tag(buffer, "monospace",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 "family", "monospace", NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 hbox = gtk_hbutton_box_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 gtk_container_set_border_width(GTK_CONTAINER(hbox), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 g_signal_connect(G_OBJECT (button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 G_CALLBACK(help_window_close), window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 gtk_container_add(GTK_CONTAINER(hbox), button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 gtk_widget_grab_default(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 g_object_set_data(G_OBJECT(window), "text_widget", text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 help_window_load_text(text, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 gtk_widget_show(window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 help_window_scroll(text, key);
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 return 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 GtkWidget *help_window_get_box(GtkWidget *window)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 return g_object_get_data(G_OBJECT(window), "text_vbox");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272