Mercurial > geeqie.yaz
comparison src/window.c @ 884:ff16ed0d2c8a
Improve ways to specify html browser (used for help, see bug 2015099).
Two new rc file options were added:
- helpers.html_browser.command_name
- helpers.html_browser.command_line
These are checked first before trying common browser locations.
If these do not lead to a valid browser, then geeqie will
search for geeqie_html_browser script in the path, then
it will try various common browsers.
author | zas_ |
---|---|
date | Sun, 13 Jul 2008 14:50:07 +0000 |
parents | 391a9e3336db |
children | 6ca2c5fd7b13 |
comparison
equal
deleted
inserted
replaced
883:391a9e3336db | 884:ff16ed0d2c8a |
---|---|
75 return (state & GDK_WINDOW_STATE_MAXIMIZED); | 75 return (state & GDK_WINDOW_STATE_MAXIMIZED); |
76 } | 76 } |
77 | 77 |
78 /* | 78 /* |
79 *----------------------------------------------------------------------------- | 79 *----------------------------------------------------------------------------- |
80 * Open browser with the help Documentation | 80 * Open browser with the help Documentation |
81 *----------------------------------------------------------------------------- | 81 *----------------------------------------------------------------------------- |
82 */ | 82 */ |
83 | 83 |
84 static gchar *command_result(const gchar *binary, const gchar *command) | 84 static gchar *command_result(const gchar *binary, const gchar *command) |
85 { | 85 { |
86 gchar *result = NULL; | 86 gchar *result = NULL; |
87 FILE *f; | 87 FILE *f; |
88 char buf[2048]; | 88 gchar buf[2048]; |
89 int l; | 89 gint l; |
90 | 90 |
91 if (!binary) return NULL; | 91 if (!binary || binary[0] == '\0') return NULL; |
92 if (!file_in_path(binary)) return NULL; | 92 if (!file_in_path(binary)) return NULL; |
93 | 93 |
94 if (!command) return g_strdup(binary); | 94 if (!command || command[0] == '\0') return g_strdup(binary); |
95 if (command[0] == '!') return g_strdup(command + 1); | 95 if (command[0] == '!') return g_strdup(command + 1); |
96 | 96 |
97 f = popen(command, "r"); | 97 f = popen(command, "r"); |
98 if (!f) return NULL; | 98 if (!f) return NULL; |
99 | 99 |
100 while ((l = fread(buf, sizeof(char), sizeof(buf), f)) > 0) | 100 while ((l = fread(buf, sizeof(char), sizeof(buf), f)) > 0) |
101 { | 101 { |
102 if (!result) | 102 if (!result) |
103 { | 103 { |
104 int n = 0; | 104 gint n = 0; |
105 | 105 |
106 while (n < l && buf[n] != '\n' && buf[n] != '\r') n++; | 106 while (n < l && buf[n] != '\n' && buf[n] != '\r') n++; |
107 if (n > 0) result = g_strndup(buf, n); | 107 if (n > 0) result = g_strndup(buf, n); |
108 } | 108 } |
109 } | 109 } |
155 * string exec string and use results for command line | 155 * string exec string and use results for command line |
156 * !string use text following ! as command line, replacing optional %s with html file path | 156 * !string use text following ! as command line, replacing optional %s with html file path |
157 */ | 157 */ |
158 static gchar *html_browsers[] = | 158 static gchar *html_browsers[] = |
159 { | 159 { |
160 /* Our specific script */ | |
161 GQ_APPNAME_LC "_html_browser", NULL, | |
160 /* Redhat has a nifty htmlview script to start the user's preferred browser */ | 162 /* Redhat has a nifty htmlview script to start the user's preferred browser */ |
161 "htmlview", NULL, | 163 "htmlview", NULL, |
162 /* Debian has even better approach with alternatives */ | 164 /* Debian has even better approach with alternatives */ |
163 "sensible-browser", NULL, | 165 "sensible-browser", NULL, |
164 /* GNOME 2 */ | 166 /* GNOME 2 */ |
173 NULL, NULL | 175 NULL, NULL |
174 }; | 176 }; |
175 | 177 |
176 static void help_browser_run(void) | 178 static void help_browser_run(void) |
177 { | 179 { |
178 gchar *result = NULL; | 180 gchar *result; |
179 gint i; | 181 gint i; |
182 | |
183 result = command_result(options->helpers.html_browser.command_name, options->helpers.html_browser.command_line); | |
180 | 184 |
181 i = 0; | 185 i = 0; |
182 while (!result && html_browsers[i]) | 186 while (!result && html_browsers[i]) |
183 { | 187 { |
184 result = command_result(html_browsers[i], html_browsers[i+1]); | 188 result = command_result(html_browsers[i], html_browsers[i+1]); |