On Thu, 17 Nov 2011 21:07:41 +0100
Thomas Martitz thomas.mart...@student.htw-berlin.de wrote:
Am 17.11.2011 19:20, schrieb Dimitar Zhekov:
Is there any technical reason to check cl_options.readonly in
document.c, and clear it load_startup_files() [...]
In an earlier version it also worked when opening a .geany file (so all
session files would be opened readonly). As opening via socket also goes
through main_handle_filename() (and hopefully nothing else?), I guess
there's no real reason anymore.
Here's a small patch that cleanups readonly handling, and adds the
missing def_clo.readonly initializer, which was a bug. Tested with
normal and socket open.
BTW, -Wmissing-field-initializers displays a huge number of warnings in
highlightingmappings.h (fill_eol and merge), and no warnings in any
other source file (except def_clo above).
--
E-gards: Jimmy
--- ./src/document.c.orig 2011-11-17 19:36:09.0 +0200
+++ ./src/document.c 2011-11-18 19:03:10.0 +0200
@@ -1162,7 +1162,7 @@
doc-has_bom = filedata.bom;
store_saved_encoding(doc); /* store the opened encoding for undo/redo */
- doc-readonly = readonly || filedata.readonly || cl_options.readonly;
+ doc-readonly = readonly || filedata.readonly;
sci_set_readonly(doc-editor-sci, doc-readonly);
/* update line number margin width */
--- ./src/main.c.orig 2011-11-17 19:36:09.0 +0200
+++ ./src/main.c 2011-11-18 19:24:52.0 +0200
@@ -497,7 +497,7 @@
GError *error = NULL;
GOptionContext *context;
gint i;
- CommandLineOptions def_clo = {FALSE, NULL, TRUE, -1, -1, FALSE, FALSE};
+ CommandLineOptions def_clo = {FALSE, NULL, TRUE, -1, -1, FALSE, FALSE, FALSE};
/* first initialise cl_options fields with default values */
cl_options = def_clo;
@@ -774,7 +774,7 @@
if (g_file_test(filename, G_FILE_TEST_IS_REGULAR))
{
- doc = document_open_file(filename, FALSE, NULL, NULL);
+ doc = document_open_file(filename, cl_options.readonly, NULL, NULL);
/* add recent file manually if opening_session_files is set */
if (doc != NULL main_status.opening_session_files)
ui_add_recent_document(doc);
@@ -887,19 +887,13 @@
static void load_startup_files(gint argc, gchar **argv)
{
gboolean load_project_from_cl = FALSE;
- gboolean cl_files_opened = FALSE;
/* ATM when opening a project file any other filenames are ignored */
load_project_from_cl = (argc 1) g_str_has_suffix(argv[1], .geany);
if (load_project_from_cl argc 2)
g_print(Ignoring extra filenames after %s, argv[1]);
- if (!load_project_from_cl)
- cl_files_opened = open_cl_files(argc, argv);
- /* switch readonly mode off for session files, future files and projects */
- cl_options.readonly = FALSE;
-
- if (! cl_files_opened)
+ if (load_project_from_cl || ! open_cl_files(argc, argv))
{
if (prefs.load_session)
{
--- ./src/socket.c.orig 2011-11-17 19:36:09.0 +0200
+++ ./src/socket.c 2011-11-18 19:25:26.0 +0200
@@ -601,13 +601,11 @@
{
if (strncmp(buf, open, 4) == 0)
{
- if (strncmp(buf+4, ro, 2) == 0) /* open in readonly? */
-cl_options.readonly = TRUE;
+ cl_options.readonly = strncmp(buf+4, ro, 2) == 0; /* open in readonly? */
while (socket_fd_gets(sock, buf, sizeof(buf)) != -1 *buf != '.')
{
handle_input_filename(g_strstrip(buf));
}
- cl_options.readonly = FALSE; /* disable again for future files */
popup = TRUE;
}
else if (strncmp(buf, doclist, 7) == 0)
___
Geany-devel mailing list
Geany-devel@uvena.de
https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel