Call g_getenv only one at startup.

This commit is contained in:
Simon Gomizelj 2012-05-31 17:16:01 -04:00
parent 94f6ed428f
commit 8d71f04b58
1 changed files with 7 additions and 2 deletions

View File

@ -29,6 +29,8 @@ typedef struct search_panel_info {
enum overlay_mode mode;
} search_panel_info;
static const gchar *browser_cmd[3] = { NULL };
static gboolean add_to_list_store(char *key,
__attribute__((unused)) void *value,
GtkListStore *store) {
@ -199,8 +201,8 @@ static char *check_match(VteTerminal *vte, int event_x, int event_y) {
static gboolean button_press_cb(VteTerminal *vte, GdkEventButton *event) {
char *match = check_match(vte, (int)event->x, (int)event->y);
if (event->button == 1 && event->type == GDK_BUTTON_PRESS && match != NULL) {
char *argv[] = URL_COMMAND(match);
g_spawn_async(NULL, argv, NULL, (GSpawnFlags)0, NULL, NULL, NULL, NULL);
browser_cmd[1] = match;
g_spawn_async(NULL, (gchar **)browser_cmd, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
g_free(match);
return TRUE;
}
@ -414,6 +416,9 @@ int main(int argc, char **argv) {
command_argv = default_argv;
}
browser_cmd[0] = g_getenv("BROWSER");
if (!browser_cmd[0]) browser_cmd[0] = default_browser;
VtePty *pty = vte_terminal_pty_new(VTE_TERMINAL(vte), VTE_PTY_DEFAULT, &error);
if (!pty) {