annotate src/window.c @ 2916:ae6cdcd69d9f default tip

Merge with upstream/master.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 14 May 2019 11:46:50 +0300
parents f2f01d556f51
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
1 /*
2350
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
2 * Copyright (C) 2008 - 2016 The Geeqie Team
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
3 *
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
4 * Authors: Vladimir Nadvornik, Laurent Monin
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
5 *
2350
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
6 * This program is free software; you can redistribute it and/or modify
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
7 * it under the terms of the GNU General Public License as published by
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
9 * (at your option) any later version.
995
401cd18f8d38 Whitespaces cleanup.
Laurent Monin <geeqie@norz.org>
parents: 884
diff changeset
10 *
2350
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
11 * This program is distributed in the hope that it will be useful,
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
14 * GNU General Public License for more details.
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
15 *
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
16 * You should have received a copy of the GNU General Public License along
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
17 * with this program; if not, write to the Free Software Foundation, Inc.,
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2185
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
19 */
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
20
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
21 #include "main.h"
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
22 #include "window.h"
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
23
1144
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
24 #include "misc.h"
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
25 #include "pixbuf_util.h"
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
26 #include "ui_fileops.h"
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
27 #include "ui_help.h"
2756
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
28 #include "ui_misc.h"
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
29 #include "ui_utildlg.h"
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
30
1175
515b3acc9fe7 Rename wmsubclass and name to role, which corresponds better to the purpose of the parameter as it ends to be passed to gtk_window_set_role().
Laurent Monin <geeqie@norz.org>
parents: 1174
diff changeset
31 GtkWidget *window_new(GtkWindowType type, const gchar *role, const gchar *icon,
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
32 const gchar *icon_file, const gchar *subtitle)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
33 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
34 gchar *title;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
35 GtkWidget *window;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
36
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
37 window = gtk_window_new(type);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
38 if (!window) return NULL;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
39
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
40 if (subtitle)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
41 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
42 title = g_strdup_printf("%s - %s", subtitle, GQ_APPNAME);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
43 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
44 else
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
45 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
46 title = g_strdup_printf("%s", GQ_APPNAME);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
47 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
48
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
49 gtk_window_set_title(GTK_WINDOW(window), title);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
50 g_free(title);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
51
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
52 window_set_icon(window, icon, icon_file);
1175
515b3acc9fe7 Rename wmsubclass and name to role, which corresponds better to the purpose of the parameter as it ends to be passed to gtk_window_set_role().
Laurent Monin <geeqie@norz.org>
parents: 1174
diff changeset
53 gtk_window_set_role(GTK_WINDOW(window), role);
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
54
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
55 return window;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
56 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
57
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
58 void window_set_icon(GtkWidget *window, const gchar *icon, const gchar *file)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
59 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
60 if (!icon && !file) icon = PIXBUF_INLINE_ICON;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
61
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
62 if (icon)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
63 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
64 GdkPixbuf *pixbuf;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
65
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
66 pixbuf = pixbuf_inline(icon);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
67 if (pixbuf)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
68 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
69 gtk_window_set_icon(GTK_WINDOW(window), pixbuf);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
70 g_object_unref(pixbuf);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
71 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
72 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
73 else
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
74 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
75 gtk_window_set_icon_from_file(GTK_WINDOW(window), file, NULL);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
76 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
77 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
78
1453
ccc663a2e148 gint -> gboolean where applicable. The end (ouf!).
Laurent Monin <geeqie@norz.org>
parents: 1284
diff changeset
79 gboolean window_maximized(GtkWidget *window)
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
80 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
81 GdkWindowState state;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
82
2034
9297985567b5 use accessor functions
Vladimir Nadvornik <nadvornik@suse.cz>
parents: 2021
diff changeset
83 if (!window || !gtk_widget_get_window(window)) return FALSE;
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
84
2034
9297985567b5 use accessor functions
Vladimir Nadvornik <nadvornik@suse.cz>
parents: 2021
diff changeset
85 state = gdk_window_get_state(gtk_widget_get_window(window));
1453
ccc663a2e148 gint -> gboolean where applicable. The end (ouf!).
Laurent Monin <geeqie@norz.org>
parents: 1284
diff changeset
86 return !!(state & GDK_WINDOW_STATE_MAXIMIZED);
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
87 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
88
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
89 /*
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
90 *-----------------------------------------------------------------------------
884
bca2fba8791f Improve ways to specify html browser (used for help, see bug 2015099).
Laurent Monin <geeqie@norz.org>
parents: 883
diff changeset
91 * Open browser with the help Documentation
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
92 *-----------------------------------------------------------------------------
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
93 */
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
94
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
95 static gchar *command_result(const gchar *binary, const gchar *command)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
96 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
97 gchar *result = NULL;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
98 FILE *f;
884
bca2fba8791f Improve ways to specify html browser (used for help, see bug 2015099).
Laurent Monin <geeqie@norz.org>
parents: 883
diff changeset
99 gchar buf[2048];
bca2fba8791f Improve ways to specify html browser (used for help, see bug 2015099).
Laurent Monin <geeqie@norz.org>
parents: 883
diff changeset
100 gint l;
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
101
884
bca2fba8791f Improve ways to specify html browser (used for help, see bug 2015099).
Laurent Monin <geeqie@norz.org>
parents: 883
diff changeset
102 if (!binary || binary[0] == '\0') return NULL;
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
103 if (!file_in_path(binary)) return NULL;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
104
884
bca2fba8791f Improve ways to specify html browser (used for help, see bug 2015099).
Laurent Monin <geeqie@norz.org>
parents: 883
diff changeset
105 if (!command || command[0] == '\0') return g_strdup(binary);
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
106 if (command[0] == '!') return g_strdup(command + 1);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
107
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
108 f = popen(command, "r");
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
109 if (!f) return NULL;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
110
1000
07f6093c1c1a For the sake of consistency, use glib basic types everywhere.
Laurent Monin <geeqie@norz.org>
parents: 995
diff changeset
111 while ((l = fread(buf, sizeof(gchar), sizeof(buf), f)) > 0)
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
112 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
113 if (!result)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
114 {
884
bca2fba8791f Improve ways to specify html browser (used for help, see bug 2015099).
Laurent Monin <geeqie@norz.org>
parents: 883
diff changeset
115 gint n = 0;
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
116
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
117 while (n < l && buf[n] != '\n' && buf[n] != '\r') n++;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
118 if (n > 0) result = g_strndup(buf, n);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
119 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
120 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
121
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
122 pclose(f);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
123
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
124 return result;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
125 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
126
1144
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
127 static int help_browser_command(const gchar *command, const gchar *path)
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
128 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
129 gchar *result;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
130 gchar *buf;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
131 gchar *begin;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
132 gchar *end;
1144
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
133 int retval = -1;
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
134
1144
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
135 if (!command || !path) return retval;
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
136
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
137 DEBUG_1("Help command pre \"%s\", \"%s\"", command, path);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
138
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
139 buf = g_strdup(command);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
140 begin = strstr(buf, "%s");
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
141 if (begin)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
142 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
143 *begin = '\0';
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
144 end = begin + 2;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
145 begin = buf;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
146
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
147 result = g_strdup_printf("%s%s%s &", begin, path, end);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
148 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
149 else
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
150 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
151 result = g_strdup_printf("%s \"%s\" &", command, path);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
152 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
153 g_free(buf);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
154
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
155 DEBUG_1("Help command post [%s]", result);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
156
1144
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
157 retval = runcmd(result);
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
158 DEBUG_1("Help command exit code: %d", retval);
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
159
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
160 g_free(result);
1144
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
161 return retval;
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
162 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
163
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
164 /*
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
165 * each set of 2 strings is one browser:
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
166 * the 1st is the binary to look for in the path
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
167 * the 2nd has 3 capabilities:
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
168 * NULL exec binary with html file path as command line
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
169 * string exec string and use results for command line
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
170 * !string use text following ! as command line, replacing optional %s with html file path
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
171 */
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
172 static gchar *html_browsers[] =
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
173 {
884
bca2fba8791f Improve ways to specify html browser (used for help, see bug 2015099).
Laurent Monin <geeqie@norz.org>
parents: 883
diff changeset
174 /* Our specific script */
bca2fba8791f Improve ways to specify html browser (used for help, see bug 2015099).
Laurent Monin <geeqie@norz.org>
parents: 883
diff changeset
175 GQ_APPNAME_LC "_html_browser", NULL,
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
176 /* Redhat has a nifty htmlview script to start the user's preferred browser */
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
177 "htmlview", NULL,
883
8fbdaa7b7fb6 Apply debian-specific patch to launch help browser (bug 2015099).
Laurent Monin <geeqie@norz.org>
parents: 728
diff changeset
178 /* Debian has even better approach with alternatives */
8fbdaa7b7fb6 Apply debian-specific patch to launch help browser (bug 2015099).
Laurent Monin <geeqie@norz.org>
parents: 728
diff changeset
179 "sensible-browser", NULL,
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
180 /* GNOME 2 */
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
181 "gconftool-2", "gconftool-2 -g /desktop/gnome/url-handlers/http/command",
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
182 /* KDE */
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
183 "kfmclient", "!kfmclient exec \"%s\"",
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
184 /* use fallbacks */
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
185 "firefox", NULL,
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
186 "mozilla", NULL,
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
187 "konqueror", NULL,
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
188 "netscape", NULL,
1775
aabd3330a2e7 Add Opera to the list of browsers. Patch by Christian Heckendorf (feature request ID: 2908469).
Laurent Monin <geeqie@norz.org>
parents: 1453
diff changeset
189 "opera", "!opera --remote 'openURL(%s,new-page)'",
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
190 NULL, NULL
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
191 };
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
192
2571
6b6f18504950 Prelim: display README in html format
Colin Clark <colin.clark@cclark.uk>
parents: 2513
diff changeset
193 static void help_browser_run(const gchar *path)
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
194 {
1144
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
195 gchar *name = options->helpers.html_browser.command_name;
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
196 gchar *cmd = options->helpers.html_browser.command_line;
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
197 gchar *result = NULL;
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
198 gint i;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
199
2184
9cdebd070874 Trim trailing white spaces.
Laurent Monin <zas@norz.org>
parents: 2034
diff changeset
200 i = 0;
1144
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
201 while (!result)
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
202 {
1144
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
203 if ((name && *name) || (cmd && *cmd)) {
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
204 DEBUG_1("Trying browser: name=%s command=%s", name, cmd);
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
205 result = command_result(name, cmd);
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
206 DEBUG_1("Result: %s", result);
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
207 if (result)
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
208 {
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
209 int ret = help_browser_command(result, path);
2185
c14a1d8e6aa4 Trim trailing white spaces on empty lines.
Laurent Monin <zas@norz.org>
parents: 2184
diff changeset
210
1144
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
211 if (ret == 0) break;
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
212 g_free(result);
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
213 result = NULL;
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
214 }
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
215 }
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
216 if (!html_browsers[i]) break;
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
217 name = html_browsers[i++];
79248cd0d16e Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
218 cmd = html_browsers[i++];
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
219 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
220
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
221 if (!result)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
222 {
673
c9c2bc042e10 Do not use printf() directly but use new wrapper function log_printf() instead.
Laurent Monin <geeqie@norz.org>
parents: 671
diff changeset
223 log_printf("Unable to detect an installed browser.\n");
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
224 return;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
225 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
226
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
227 g_free(result);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
228 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
229
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
230 /*
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
231 *-----------------------------------------------------------------------------
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
232 * help window
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
233 *-----------------------------------------------------------------------------
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
234 */
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
235
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
236 static GtkWidget *help_window = NULL;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
237
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
238 static void help_window_destroy_cb(GtkWidget *window, gpointer data)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
239 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
240 help_window = NULL;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
241 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
242
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
243 void help_window_show(const gchar *key)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
244 {
1013
bce5d6ab9be4 Allow to override documentation paths through options:
Laurent Monin <geeqie@norz.org>
parents: 1000
diff changeset
245 gchar *path;
bce5d6ab9be4 Allow to override documentation paths through options:
Laurent Monin <geeqie@norz.org>
parents: 1000
diff changeset
246
2412
0168ad13f7d9 Fix #434: Part 2.0
Colin Clark <cclark@mcb.net>
parents: 2350
diff changeset
247 if (key && strstr(key, ".html") != 0)
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
248 {
2722
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
249 path = g_build_filename(GQ_HTMLDIR, key, NULL);
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
250 if (!isfile(path))
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
251 {
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
252 if (g_strcmp0(key, "index.html") == 0)
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
253 {
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
254 path = g_build_filename("http://geeqie.org/help/", "GuideIndex.html", NULL);
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
255 }
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
256 else
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
257 {
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
258 path = g_build_filename("http://geeqie.org/help/", key, NULL);
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
259 }
977b97448cbe Use web help files if local files do not exist
Colin Clark <colin.clark@cclark.uk>
parents: 2573
diff changeset
260 }
2571
6b6f18504950 Prelim: display README in html format
Colin Clark <colin.clark@cclark.uk>
parents: 2513
diff changeset
261 help_browser_run(path);
6b6f18504950 Prelim: display README in html format
Colin Clark <colin.clark@cclark.uk>
parents: 2513
diff changeset
262 g_free(path);
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
263 return;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
264 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
265
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
266 if (help_window)
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
267 {
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
268 gtk_window_present(GTK_WINDOW(help_window));
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
269 if (key) help_window_set_key(help_window, key);
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
270 return;
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
271 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
272
2573
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
273 if (!strcmp(key, "release_notes"))
2571
6b6f18504950 Prelim: display README in html format
Colin Clark <colin.clark@cclark.uk>
parents: 2513
diff changeset
274 {
2573
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
275 path = g_build_filename(GQ_HELPDIR, "README.html", NULL);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
276 if (isfile(path))
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
277 {
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
278 g_free(path);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
279 path = g_build_filename("file://", GQ_HELPDIR, "README.html", NULL);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
280 help_browser_run(path);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
281 g_free(path);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
282 }
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
283 else
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
284 {
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
285 g_free(path);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
286 path = g_build_filename(GQ_HELPDIR, "README.md", NULL);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
287 help_window = help_window_new(_("Help"), "help", path, key);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
288 g_free(path);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
289
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
290 g_signal_connect(G_OBJECT(help_window), "destroy",
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
291 G_CALLBACK(help_window_destroy_cb), NULL);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
292 }
2571
6b6f18504950 Prelim: display README in html format
Colin Clark <colin.clark@cclark.uk>
parents: 2513
diff changeset
293 }
6b6f18504950 Prelim: display README in html format
Colin Clark <colin.clark@cclark.uk>
parents: 2513
diff changeset
294 else
6b6f18504950 Prelim: display README in html format
Colin Clark <colin.clark@cclark.uk>
parents: 2513
diff changeset
295 {
2573
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
296 path = g_build_filename(GQ_HELPDIR, "ChangeLog.html", NULL);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
297 if (isfile(path))
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
298 {
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
299 g_free(path);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
300 path = g_build_filename("file://", GQ_HELPDIR, "ChangeLog.html", NULL);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
301 help_browser_run(path);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
302 g_free(path);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
303 }
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
304 else
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
305 {
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
306 g_free(path);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
307 path = g_build_filename(GQ_HELPDIR, "ChangeLog", NULL);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
308 help_window = help_window_new(_("Help"), "help", path, key);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
309 g_free(path);
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
310
2573
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
311 g_signal_connect(G_OBJECT(help_window), "destroy",
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
312 G_CALLBACK(help_window_destroy_cb), NULL);
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
313 }
3e5919841759 Update secondary user documentation
Colin Clark <colin.clark@cclark.uk>
parents: 2571
diff changeset
314
2571
6b6f18504950 Prelim: display README in html format
Colin Clark <colin.clark@cclark.uk>
parents: 2513
diff changeset
315 }
648
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
316 }
36e8da5a771d Move some functions from main.[ch] to new window.[ch].
Laurent Monin <geeqie@norz.org>
parents:
diff changeset
317
2756
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
318 /*
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
319 *-----------------------------------------------------------------------------
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
320 * on-line help search dialog
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
321 *-----------------------------------------------------------------------------
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
322 */
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
323
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
324 typedef struct _HelpSearchData HelpSearchData;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
325 struct _HelpSearchData {
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
326 GenericDialog *gd;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
327 GtkWidget *edit_widget;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
328 gchar *text_entry;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
329 };
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
330
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
331 static void help_search_window_show_icon_press(GtkEntry *entry, GtkEntryIconPosition pos,
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
332 GdkEvent *event, gpointer userdata)
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
333 {
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
334 HelpSearchData *hsd = userdata;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
335
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
336 g_free(hsd->text_entry);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
337 hsd->text_entry = g_strdup("");
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
338 gtk_entry_set_text(GTK_ENTRY(hsd->edit_widget), hsd->text_entry);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
339 }
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
340
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
341 static void help_search_window_ok_cb(GenericDialog *gd, gpointer data)
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
342 {
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
343 HelpSearchData *hsd = data;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
344 gchar *search_command;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
345
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
346 search_command = g_strconcat(options->help_search_engine,
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
347 gtk_entry_get_text(GTK_ENTRY(hsd->edit_widget)),
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
348 NULL);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
349 help_browser_run(search_command);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
350 g_free(search_command);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
351
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
352 g_free(hsd);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
353 }
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
354
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
355 static void help_search_window_cancel_cb(GenericDialog *gd, gpointer data)
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
356 {
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
357 HelpSearchData *hsd = data;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
358
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
359 g_free(hsd);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
360 }
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
361
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
362 void help_search_window_show()
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
363 {
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
364 HelpSearchData *hsd;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
365 GenericDialog *gd;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
366 GtkWidget *table;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
367 GtkWidget *label1;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
368 GtkWidget *label2;
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
369
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
370 hsd = g_new0(HelpSearchData, 1);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
371 hsd->gd = gd = generic_dialog_new(_("On-line help search"), "help_search",
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
372 NULL, TRUE,
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
373 help_search_window_cancel_cb, hsd);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
374 generic_dialog_add_message(gd, NULL, _("Search the on-line help files.\n"), NULL, FALSE);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
375
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
376 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
377 help_search_window_ok_cb, TRUE);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
378
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
379 label1 = pref_label_new(GENERIC_DIALOG(gd)->vbox, _("Search engine:"));
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
380 gtk_misc_set_alignment(GTK_MISC(label1), 0.0, 0.5);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
381
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
382 label2 = pref_label_new(GENERIC_DIALOG(gd)->vbox, options->help_search_engine);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
383 gtk_misc_set_alignment(GTK_MISC(label2), 0.0, 0.5);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
384 pref_spacer(GENERIC_DIALOG(gd)->vbox, 0);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
385
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
386 table = pref_table_new(gd->vbox, 3, 1, FALSE, TRUE);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
387 pref_table_label(table, 0, 0, _("Search terms:"), 1.0);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
388 hsd->edit_widget = gtk_entry_new();
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
389 gtk_widget_set_size_request(hsd->edit_widget, 300, -1);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
390 gtk_table_attach_defaults(GTK_TABLE(table), hsd->edit_widget, 1, 2, 0, 1);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
391 generic_dialog_attach_default(gd, hsd->edit_widget);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
392 gtk_widget_show(hsd->edit_widget);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
393
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
394 gtk_entry_set_icon_from_stock(GTK_ENTRY(hsd->edit_widget),
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
395 GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
396 gtk_entry_set_icon_tooltip_text (GTK_ENTRY(hsd->edit_widget),
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
397 GTK_ENTRY_ICON_SECONDARY, _("Clear"));
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
398 g_signal_connect(GTK_ENTRY(hsd->edit_widget), "icon-press",
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
399 G_CALLBACK(help_search_window_show_icon_press), hsd);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
400
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
401 gtk_widget_grab_focus(hsd->edit_widget);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
402
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
403 gtk_widget_show(gd->dialog);
f2f01d556f51 Fix #597: Help file search
Colin Clark <colin.clark@cclark.uk>
parents: 2722
diff changeset
404 }
1055
4bbdfab3c89a Adding a vim modeline to all files - patch by Klaus Ethgen
Vladimir Nadvornik <nadvornik@suse.cz>
parents: 1013
diff changeset
405 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */