annotate src/ui_help.c @ 1624:b70603e03eb6

do not display menus ("FileMenu" etc.) in accelerator configuration improved tooltip texts
author nadvornik
date Sun, 31 May 2009 13:32:09 +0000
parents 89dedc61b1bd
children
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
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1174
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * 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
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 #ifdef HAVE_CONFIG_H
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 # include "config.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "intl.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include <stdio.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include <stdlib.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include <string.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include <gtk/gtk.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23
289
6a7298988a7a Simplify and unify gtk_window creation with the help of
zas_
parents: 9
diff changeset
24 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "ui_help.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #include "ui_misc.h"
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents: 627
diff changeset
29 #include "window.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31
626
20495dd4e6e6 Slightly increase help window's default width.
zas_
parents: 513
diff changeset
32 #define HELP_WINDOW_WIDTH 650
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 #define HELP_WINDOW_HEIGHT 350
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 /*
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 * 'help' window
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 */
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 #define SCROLL_MARKNAME "scroll_point"
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 static void help_window_scroll(GtkWidget *text, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 gchar *needle;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 GtkTextIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 GtkTextIter start, end;
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 if (!text || !key) return;
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 needle = g_strdup_printf("[section:%s]", key);
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 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
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 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
59 &start, &end, NULL))
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 gint line;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 GtkTextMark *mark;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 line = gtk_text_iter_get_line(&start);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 gtk_text_buffer_get_iter_at_line_offset(buffer, &iter, line, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 gtk_text_buffer_place_cursor(buffer, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 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
70 #endif
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 /* 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
73
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 /* if mark exists, move it instead of creating one for every scroll */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 mark = gtk_text_buffer_get_mark(buffer, SCROLL_MARKNAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 if (mark)
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 gtk_text_buffer_move_mark(buffer, mark, &iter);
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 else
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 mark = gtk_text_buffer_create_mark(buffer, SCROLL_MARKNAME, &iter, FALSE);
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 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
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 g_free(needle);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 static void help_window_load_text(GtkWidget *text, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 gchar s_buf[1024];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 GtkTextIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 GtkTextIter start, end;
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 if (!text || !path) return;
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 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
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_bounds(buffer, &start, &end);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 gtk_text_buffer_delete(buffer, &start, &end);
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 gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 f = fopen(pathl, "r");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 if (!f)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 buf = g_strdup_printf(_("Unable to load:\n%s"), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 gtk_text_buffer_insert(buffer, &iter, buf, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 g_free(buf);
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 else
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 while (fgets(s_buf, sizeof(s_buf), f))
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 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 gint l;
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 l = strlen(s_buf);
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 if (!g_utf8_validate(s_buf, l, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 {
627
2dc96f1fd83d Use computed string length.
zas_
parents: 626
diff changeset
129 buf = g_locale_to_utf8(s_buf, l, NULL, NULL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 if (!buf) buf = g_strdup("\n");
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 else
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 buf = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 (buf) ? buf : s_buf, -1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 "monospace", NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 g_free(buf);
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 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 gtk_text_buffer_place_cursor(buffer, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 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
147 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148
1448
89dedc61b1bd gint -> gboolean.
zas_
parents: 1284
diff changeset
149 static gboolean help_window_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
9
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 gtk_widget_destroy(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 static void help_window_close(GtkWidget *widget, gpointer data)
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 GtkWidget *window = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 gtk_widget_destroy(window);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 void help_window_set_key(GtkWidget *window, const gchar *key)
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 GtkWidget *text;
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 if (!window) 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 text = g_object_get_data(G_OBJECT(window), "text_widget");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 if (!text) return;
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 gdk_window_raise(window->window);
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 if (key) help_window_scroll(text, 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 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
176 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 GtkWidget *text;
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 if (!window || !path) 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 text = g_object_get_data(G_OBJECT(window), "text_widget");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 if (!text) return;
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 gdk_window_raise(window->window);
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 help_window_load_text(text, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 help_window_scroll(text, key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 GtkWidget *help_window_new(const gchar *title,
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1055
diff changeset
191 const gchar *subclass,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 const gchar *path, const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 GtkWidget *window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 GtkWidget *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 /* window */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203
289
6a7298988a7a Simplify and unify gtk_window creation with the help of
zas_
parents: 9
diff changeset
204 window = window_new(GTK_WINDOW_TOPLEVEL, subclass, NULL, NULL, title);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 gtk_container_set_border_width(GTK_CONTAINER(window), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 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
210
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 g_signal_connect(G_OBJECT(window), "delete_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 G_CALLBACK(help_window_delete_cb), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 gtk_container_add(GTK_CONTAINER(window), vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 gtk_widget_show(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 g_object_set_data(G_OBJECT(window), "text_vbox", vbox);
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 /* text window */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 hbox = gtk_hbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 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
228 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 text = gtk_text_view_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 gtk_container_add(GTK_CONTAINER(scrolled), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 gtk_widget_show(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 gtk_text_buffer_create_tag(buffer, "monospace",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 "family", "monospace", NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 hbox = gtk_hbutton_box_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 gtk_container_set_border_width(GTK_CONTAINER(hbox), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 475
diff changeset
249 g_signal_connect(G_OBJECT(button), "clicked",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 G_CALLBACK(help_window_close), window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 gtk_container_add(GTK_CONTAINER(hbox), button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 gtk_widget_grab_default(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 gtk_widget_show(button);
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 g_object_set_data(G_OBJECT(window), "text_widget", text);
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 help_window_load_text(text, path);
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 gtk_widget_show(window);
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 help_window_scroll(text, key);
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 return window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 }
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 GtkWidget *help_window_get_box(GtkWidget *window)
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 return g_object_get_data(G_OBJECT(window), "text_vbox");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 648
diff changeset
271 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */