annotate src/window.c @ 902:c414002a1f27

Move history_list_*() functions to separate files: history_list.c and history_list.h.
author zas_
date Sun, 20 Jul 2008 14:56:32 +0000
parents ff16ed0d2c8a
children 6ca2c5fd7b13
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
1 /*
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
2 * Geeqie
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
3 * Copyright (C) 2008 The Geeqie Team
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
4 *
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
5 * Authors: Vladimir Nadvornik / Laurent Monin
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
6 *
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
7 * This software is released under the GNU General Public License (GNU GPL).
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
8 * Please read the included file COPYING for more information.
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
9 * This software comes with no warranty of any kind, use at your own risk!
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
10 */
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
11
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
12 #include "main.h"
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
13 #include "window.h"
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
14
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
15 #include "pixbuf_util.h"
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
16 #include "ui_fileops.h"
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
17 #include "ui_help.h"
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
18
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
19 GtkWidget *window_new(GtkWindowType type, const gchar *name, const gchar *icon,
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
20 const gchar *icon_file, const gchar *subtitle)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
21 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
22 gchar *title;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
23 GtkWidget *window;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
24
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
25 window = gtk_window_new(type);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
26 if (!window) return NULL;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
27
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
28 if (subtitle)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
29 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
30 title = g_strdup_printf("%s - %s", subtitle, GQ_APPNAME);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
31 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
32 else
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
33 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
34 title = g_strdup_printf("%s", GQ_APPNAME);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
35 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
36
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
37 gtk_window_set_title(GTK_WINDOW(window), title);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
38 g_free(title);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
39
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
40 window_set_icon(window, icon, icon_file);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
41 gtk_window_set_role(GTK_WINDOW(window), name);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
42 gtk_window_set_wmclass(GTK_WINDOW(window), name, GQ_WMCLASS);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
43
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
44 return window;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
45 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
46
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
47 void window_set_icon(GtkWidget *window, const gchar *icon, const gchar *file)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
48 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
49 if (!icon && !file) icon = PIXBUF_INLINE_ICON;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
50
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
51 if (icon)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
52 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
53 GdkPixbuf *pixbuf;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
54
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
55 pixbuf = pixbuf_inline(icon);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
56 if (pixbuf)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
57 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
58 gtk_window_set_icon(GTK_WINDOW(window), pixbuf);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
59 g_object_unref(pixbuf);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
60 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
61 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
62 else
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
63 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
64 gtk_window_set_icon_from_file(GTK_WINDOW(window), file, NULL);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
65 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
66 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
67
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
68 gint window_maximized(GtkWidget *window)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
69 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
70 GdkWindowState state;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
71
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
72 if (!window || !window->window) return FALSE;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
73
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
74 state = gdk_window_get_state(window->window);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
75 return (state & GDK_WINDOW_STATE_MAXIMIZED);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
76 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
77
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
78 /*
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
79 *-----------------------------------------------------------------------------
884
ff16ed0d2c8a Improve ways to specify html browser (used for help, see bug 2015099).
zas_
parents: 883
diff changeset
80 * Open browser with the help Documentation
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
81 *-----------------------------------------------------------------------------
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
82 */
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
83
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
84 static gchar *command_result(const gchar *binary, const gchar *command)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
85 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
86 gchar *result = NULL;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
87 FILE *f;
884
ff16ed0d2c8a Improve ways to specify html browser (used for help, see bug 2015099).
zas_
parents: 883
diff changeset
88 gchar buf[2048];
ff16ed0d2c8a Improve ways to specify html browser (used for help, see bug 2015099).
zas_
parents: 883
diff changeset
89 gint l;
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
90
884
ff16ed0d2c8a Improve ways to specify html browser (used for help, see bug 2015099).
zas_
parents: 883
diff changeset
91 if (!binary || binary[0] == '\0') return NULL;
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
92 if (!file_in_path(binary)) return NULL;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
93
884
ff16ed0d2c8a Improve ways to specify html browser (used for help, see bug 2015099).
zas_
parents: 883
diff changeset
94 if (!command || command[0] == '\0') return g_strdup(binary);
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
95 if (command[0] == '!') return g_strdup(command + 1);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
96
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
97 f = popen(command, "r");
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
98 if (!f) return NULL;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
99
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
100 while ((l = fread(buf, sizeof(char), sizeof(buf), f)) > 0)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
101 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
102 if (!result)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
103 {
884
ff16ed0d2c8a Improve ways to specify html browser (used for help, see bug 2015099).
zas_
parents: 883
diff changeset
104 gint n = 0;
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
105
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
106 while (n < l && buf[n] != '\n' && buf[n] != '\r') n++;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
107 if (n > 0) result = g_strndup(buf, n);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
108 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
109 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
110
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
111 pclose(f);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
112
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
113 return result;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
114 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
115
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
116 static void help_browser_command(const gchar *command, const gchar *path)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
117 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
118 gchar *result;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
119 gchar *buf;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
120 gchar *begin;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
121 gchar *end;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
122
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
123 if (!command || !path) return;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
124
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
125 DEBUG_1("Help command pre \"%s\", \"%s\"", command, path);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
126
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
127 buf = g_strdup(command);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
128 begin = strstr(buf, "%s");
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
129 if (begin)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
130 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
131 *begin = '\0';
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
132 end = begin + 2;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
133 begin = buf;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
134
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
135 result = g_strdup_printf("%s%s%s &", begin, path, end);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
136 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
137 else
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
138 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
139 result = g_strdup_printf("%s \"%s\" &", command, path);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
140 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
141 g_free(buf);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
142
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
143 DEBUG_1("Help command post [%s]", result);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
144
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
145 system(result);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
146
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
147 g_free(result);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
148 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
149
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
150 /*
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
151 * each set of 2 strings is one browser:
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
152 * the 1st is the binary to look for in the path
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
153 * the 2nd has 3 capabilities:
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
154 * NULL exec binary with html file path as command line
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
155 * string exec string and use results for command line
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
156 * !string use text following ! as command line, replacing optional %s with html file path
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
157 */
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
158 static gchar *html_browsers[] =
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
159 {
884
ff16ed0d2c8a Improve ways to specify html browser (used for help, see bug 2015099).
zas_
parents: 883
diff changeset
160 /* Our specific script */
ff16ed0d2c8a Improve ways to specify html browser (used for help, see bug 2015099).
zas_
parents: 883
diff changeset
161 GQ_APPNAME_LC "_html_browser", NULL,
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
162 /* Redhat has a nifty htmlview script to start the user's preferred browser */
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
163 "htmlview", NULL,
883
391a9e3336db Apply debian-specific patch to launch help browser (bug 2015099).
zas_
parents: 728
diff changeset
164 /* Debian has even better approach with alternatives */
391a9e3336db Apply debian-specific patch to launch help browser (bug 2015099).
zas_
parents: 728
diff changeset
165 "sensible-browser", NULL,
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
166 /* GNOME 2 */
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
167 "gconftool-2", "gconftool-2 -g /desktop/gnome/url-handlers/http/command",
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
168 /* KDE */
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
169 "kfmclient", "!kfmclient exec \"%s\"",
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
170 /* use fallbacks */
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
171 "firefox", NULL,
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
172 "mozilla", NULL,
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
173 "konqueror", NULL,
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
174 "netscape", NULL,
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
175 NULL, NULL
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
176 };
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
177
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
178 static void help_browser_run(void)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
179 {
884
ff16ed0d2c8a Improve ways to specify html browser (used for help, see bug 2015099).
zas_
parents: 883
diff changeset
180 gchar *result;
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
181 gint i;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
182
884
ff16ed0d2c8a Improve ways to specify html browser (used for help, see bug 2015099).
zas_
parents: 883
diff changeset
183 result = command_result(options->helpers.html_browser.command_name, options->helpers.html_browser.command_line);
ff16ed0d2c8a Improve ways to specify html browser (used for help, see bug 2015099).
zas_
parents: 883
diff changeset
184
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
185 i = 0;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
186 while (!result && html_browsers[i])
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
187 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
188 result = command_result(html_browsers[i], html_browsers[i+1]);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
189 i += 2;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
190 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
191
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
192 if (!result)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
193 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
194 log_printf("Unable to detect an installed browser.\n");
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
195 return;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
196 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
197
728
5042236af960 Replace hardcoded "/" by G_DIR_SEPARATOR_S where applicable.
zas_
parents: 673
diff changeset
198 help_browser_command(result, GQ_HTMLDIR G_DIR_SEPARATOR_S "index.html");
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
199
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
200 g_free(result);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
201 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
202
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
203 /*
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
204 *-----------------------------------------------------------------------------
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
205 * help window
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
206 *-----------------------------------------------------------------------------
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
207 */
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
208
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
209 static GtkWidget *help_window = NULL;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
210
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
211 static void help_window_destroy_cb(GtkWidget *window, gpointer data)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
212 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
213 help_window = NULL;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
214 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
215
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
216 void help_window_show(const gchar *key)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
217 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
218 if (key && strcmp(key, "html_contents") == 0)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
219 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
220 help_browser_run();
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
221 return;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
222 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
223
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
224 if (help_window)
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
225 {
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
226 gtk_window_present(GTK_WINDOW(help_window));
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
227 if (key) help_window_set_key(help_window, key);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
228 return;
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
229 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
230
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
231 help_window = help_window_new(_("Help"), GQ_WMCLASS, "help",
728
5042236af960 Replace hardcoded "/" by G_DIR_SEPARATOR_S where applicable.
zas_
parents: 673
diff changeset
232 GQ_HELPDIR G_DIR_SEPARATOR_S "README", key);
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
233
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
234 g_signal_connect(G_OBJECT(help_window), "destroy",
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
235 G_CALLBACK(help_window_destroy_cb), NULL);
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
236 }
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents:
diff changeset
237