Revision: 749 Author: ntrel Date: 2006-08-20 05:33:09 -0700 (Sun, 20 Aug 2006) ViewCVS: http://svn.sourceforge.net/geany/?rev=749&view=rev
Log Message: ----------- Moved HAVE_FIFO MyApp fields to fifo_info struct in src/main.c; Prevent unnecessary 'does not look like a filename' debug messages
Modified Paths: -------------- trunk/ChangeLog trunk/src/Makefile.am trunk/src/callbacks.c trunk/src/geany.h trunk/src/main.c
Added Paths: ----------- trunk/src/main.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-08-20 11:54:33 UTC (rev 748) +++ trunk/ChangeLog 2006-08-20 12:33:09 UTC (rev 749) @@ -2,6 +2,11 @@
* src/callbacks.c, src/main.c: Fix opening more than one file from the command-line (with fifo). + * src/geany.h, src/callbacks.c, src/Makefile.am, src/main.c, + src/main.h: + Moved HAVE_FIFO MyApp fields to fifo_info struct in src/main.c. + Prevent unnecessary 'does not look like a filename' debug messages. + Added fifo_finalize().
2006-08-19 Enrico Tröger enrico.troeger@uvena.de
Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2006-08-20 11:54:33 UTC (rev 748) +++ trunk/src/Makefile.am 2006-08-20 12:33:09 UTC (rev 749) @@ -7,7 +7,7 @@ bin_PROGRAMS = geany
SRCS = \ - main.c geany.h \ + main.c main.h geany.h \ search.c search.h \ notebook.c notebook.h \ keybindings.c keybindings.h \
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2006-08-20 11:54:33 UTC (rev 748) +++ trunk/src/callbacks.c 2006-08-20 12:33:09 UTC (rev 749) @@ -49,8 +49,8 @@ #include "keybindings.h" #include "encodings.h" #include "search.h" +#include "main.h"
- #ifdef G_OS_WIN32 # include "win32.h" #endif @@ -85,18 +85,8 @@ geany_debug("Quitting...");
#ifdef HAVE_FIFO - if (! app->ignore_fifo) - { - gchar *fifo = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, GEANY_FIFO_NAME, NULL); - // delete the fifo early, because we don't accept new files anymore - if (app->fifo_ioc != NULL) - { - g_io_channel_shutdown(app->fifo_ioc, FALSE, NULL); - g_io_channel_unref(app->fifo_ioc); - } - unlink(fifo); - g_free(fifo); - } + // delete the fifo early, because we don't accept new files anymore + fifo_finalize(); #endif
keybindings_free();
Modified: trunk/src/geany.h =================================================================== --- trunk/src/geany.h 2006-08-20 11:54:33 UTC (rev 748) +++ trunk/src/geany.h 2006-08-20 12:33:09 UTC (rev 749) @@ -168,10 +168,6 @@ gint autocompletion_max_height; gint long_line_type; gint long_line_column; -#ifdef HAVE_FIFO - gboolean ignore_fifo; - GIOChannel *fifo_ioc; -#endif gchar *long_line_color; gchar *pref_template_developer; gchar *pref_template_company;
Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2006-08-20 11:54:33 UTC (rev 748) +++ trunk/src/main.c 2006-08-20 12:33:09 UTC (rev 749) @@ -57,8 +57,17 @@
#define N_(String) (String)
+ #ifdef HAVE_FIFO -static gchar fifo_name[512]; +static struct +{ + gboolean ignore_fifo; + gchar file_name[512]; + GIOChannel *read_ioc; +} fifo_info; +#endif + +#ifdef HAVE_FIFO static gboolean ignore_fifo = FALSE; #endif static gboolean debug_mode = FALSE; @@ -334,16 +343,18 @@ g_strstrip(buffer); // remove \n char
// try to interpret the received data as a filename, otherwise do nothing - if (status == G_IO_STATUS_NORMAL && - g_file_test(buffer, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK)) + if (status == G_IO_STATUS_NORMAL) { - document_open_file(-1, buffer, 0, FALSE, NULL, NULL); - gtk_window_deiconify(GTK_WINDOW(app->window)); + if (g_file_test(buffer, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK)) + { + document_open_file(-1, buffer, 0, FALSE, NULL, NULL); + gtk_window_deiconify(GTK_WINDOW(app->window)); + } + else + { + geany_debug("got data from named pipe, but it does not look like a filename"); + } } - else - { - geany_debug("got data from named pipe, but it does not look like a filename"); - } g_free(buffer);
return TRUE; // allow receiving more data @@ -355,7 +366,7 @@ gint i; GIOChannel *ioc;
- ioc = g_io_channel_unix_new(open(fifo_name, O_WRONLY)); + ioc = g_io_channel_unix_new(open(fifo_info.file_name, O_WRONLY));
for(i = 1; i < argc && argv[i] != NULL; i++) { @@ -385,14 +396,14 @@ GIOChannel *ioc;
tmp = g_strconcat(config_dir, G_DIR_SEPARATOR_S, GEANY_FIFO_NAME, NULL); - g_strlcpy(fifo_name, tmp, sizeof(fifo_name)); + g_strlcpy(fifo_info.file_name, tmp, sizeof(fifo_info.file_name)); g_free(tmp);
- if (stat(fifo_name, &st) == 0 && (! S_ISFIFO(st.st_mode))) + if (stat(fifo_info.file_name, &st) == 0 && (! S_ISFIFO(st.st_mode))) { // the FIFO file exists, but is not a FIFO - unlink(fifo_name); + unlink(fifo_info.file_name); } - else if (stat(fifo_name, &st) == 0 && S_ISFIFO(st.st_mode)) + else if (stat(fifo_info.file_name, &st) == 0 && S_ISFIFO(st.st_mode)) { // FIFO exists, there should be a running instance of Geany if (argc > 1) { @@ -404,7 +415,7 @@ { if (dialogs_show_question(_("Geany is exiting because a named pipe was found. Mostly this means, Geany is already running. If you know Geany is not running, you can delete the file and start Geany anyway.\nDelete the named pipe and start Geany?"))) { - unlink(fifo_name); + unlink(fifo_info.file_name); } else exit(0); } @@ -413,17 +424,33 @@ // there is no Geany running, create fifo and start as usual, so we are a kind of server geany_debug("trying to create a new named pipe");
- if ((mkfifo(fifo_name, S_IRUSR | S_IWUSR)) == -1) + if ((mkfifo(fifo_info.file_name, S_IRUSR | S_IWUSR)) == -1) { if (errno != EEXIST) geany_debug("creating of a named pipe for IPC failed! (%s)", g_strerror(errno)); return NULL; }
- ioc = g_io_channel_unix_new(open(fifo_name, O_RDONLY | O_NONBLOCK)); + ioc = g_io_channel_unix_new(open(fifo_info.file_name, O_RDONLY | O_NONBLOCK)); g_io_add_watch(ioc, G_IO_IN | G_IO_PRI, read_fifo, NULL);
return ioc; } + + +void fifo_finalize() +{ + if (! fifo_info.ignore_fifo) + { + gchar *fifo = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, GEANY_FIFO_NAME, NULL); + if (fifo_info.read_ioc != NULL) + { + g_io_channel_shutdown(fifo_info.read_ioc, FALSE, NULL); + g_io_channel_unref(fifo_info.read_ioc); + } + unlink(fifo); + g_free(fifo); + } +} #endif
@@ -510,7 +537,7 @@ app->configdir = g_strconcat(GEANY_HOME_DIR, G_DIR_SEPARATOR_S, ".", PACKAGE, NULL);
#ifdef HAVE_FIFO - app->ignore_fifo = ignore_fifo; + fifo_info.ignore_fifo = ignore_fifo; #endif #ifdef HAVE_VTE vte_info.lib_vte = lib_vte; @@ -570,7 +597,7 @@ config_dir_result = setup_config_dir(); // handle fifo #ifdef HAVE_FIFO - app->fifo_ioc = (ignore_fifo) ? NULL : create_fifo(argc, argv, app->configdir); + fifo_info.read_ioc = (ignore_fifo) ? NULL : create_fifo(argc, argv, app->configdir); #endif
gtk_init(&argc, &argv);
Added: trunk/src/main.h =================================================================== --- trunk/src/main.h (rev 0) +++ trunk/src/main.h 2006-08-20 12:33:09 UTC (rev 749) @@ -0,0 +1,30 @@ +/* + * main.h - this file is part of Geany, a fast and lightweight IDE + * + * Copyright 2006 Enrico Troeger enrico.troeger@uvena.de + * Copyright 2006 Nick Treleaven nick.treleaven@btinternet.com + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ + + +#ifndef GEANY_MAIN_H +#define GEANY_MAIN_H + +void fifo_finalize(); + +#endif
Property changes on: trunk/src/main.h ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.