X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=sdl_gui.c;h=c63f9b804b5e994926b5bb8f548747cdb96c95ad;hp=b67b3d1e48554993f61f836e5bc3a60e23f828a1;hb=769888ee3175ed60df3c23caf51cdad5db33d141;hpb=8a8cd0f5bb40dcfad68608193e8c57decd90b25e diff --git a/sdl_gui.c b/sdl_gui.c index b67b3d1e..c63f9b80 100644 --- a/sdl_gui.c +++ b/sdl_gui.c @@ -1,25 +1,16 @@ /* - * Copyright (C) 2003-2006 Andre Noll + * Copyright (C) 2003-2007 Andre Noll * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Licensed under the GPL v2. For licencing details see COPYING. */ /** \file sdl_gui.c SDL-based interface for paraslash */ +#include +#include + #include "para.h" -#include "string.h" +#include "gui_common.h" #include "fd.h" @@ -356,7 +347,7 @@ static void init_SDL(void) SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE); /* Set the window manager title bar */ SDL_WM_SetCaption("The Gui of death that makes you blind (paraslash " - VERSION ")", "SFont"); + PACKAGE_VERSION ")", "SFont"); } /* @@ -672,17 +663,18 @@ static void do_update(int i) * Check if buf is a known status line. If so call do_update and return 1. * Return 0 otherwise. */ -void update_status(char *buf) +int update_status(char *buf, __a_unused void *data) { int i; i = stat_line_valid(buf); if (i < 0) - return; + return 1; //free(stat_items[i].content); stat_items[i].content = para_strdup(buf + strlen(status_item_list[i]) + 1); do_update(i); + return 1; } /* @@ -739,10 +731,11 @@ static int configfile_exists(void) */ int main(int argc, char *argv[]) { - int i, ret, fd; + int i, ret, fd = -1; SDLKey sym; sdl_gui_cmdline_parser(argc, argv, &args_info); + HANDLE_VERSION_FLAG("sdl_gui", args_info); ret = configfile_exists(); // printf("w=%i,h=%i,ret=%i, cf=%s\n", width, height, ret, args_info.config_file_arg); @@ -751,15 +744,21 @@ int main(int argc, char *argv[]) args_info.config_file_arg); exit(EXIT_FAILURE); } - if (ret) - sdl_gui_cmdline_parser_configfile(args_info.config_file_arg, - &args_info, 0, 0, 0); + if (ret) { + struct sdl_gui_cmdline_parser_params params = { + .override = 0, + .initialize = 0, + .check_required = 0, + .check_ambiguity = 0 + }; + sdl_gui_cmdline_parser_config_file(args_info.config_file_arg, + &args_info, ¶ms); + } signal(SIGCHLD, SIG_IGN); width = args_info.width_arg; height = args_info.height_arg; // printf("w=%i,h=%i,ret=%i, cf=%s\n", width, height, ret, args_info.config_file_arg); init_stat_items(); - fd = para_open_audiod_pipe(args_info.stat_cmd_arg); init_SDL(); for (i = 0; fonts[i].name[0]; i++) { char buf[MAXLINE]; @@ -775,6 +774,11 @@ int main(int argc, char *argv[]) update_input(); } for (;;) { + if (fd < 0) { + fd = para_open_audiod_pipe(args_info.stat_cmd_arg); + if (fd < 0) + clean_exit(EXIT_FAILURE); + } ret = draw_status(fd); if (ret < 0) { close(fd); @@ -802,10 +806,6 @@ int main(int argc, char *argv[]) || sym == SDLK_COMPOSE ) continue; - if (fd < 0) { - kill(0, SIGINT); - close(fd); - } fill_input_rect(); update_input(); if (!command_handler()) @@ -814,7 +814,6 @@ int main(int argc, char *argv[]) print_help(); update_pic(); SDL_UpdateRect(screen, 0, 0, 0, 0); - fd = para_open_audiod_pipe(args_info.stat_cmd_arg); break; } }