Kaydet (Commit) 6738d43d authored tarafından Dimitar Zhekov's avatar Dimitar Zhekov Kaydeden (comit) Colomban Wendling

--read-only cleanup

Use the global variable only when needed and add an initializer for it
in the default options.
üst 102ce1d2
...@@ -1162,7 +1162,7 @@ GeanyDocument *document_open_file_full(GeanyDocument *doc, const gchar *filename ...@@ -1162,7 +1162,7 @@ GeanyDocument *document_open_file_full(GeanyDocument *doc, const gchar *filename
doc->has_bom = filedata.bom; doc->has_bom = filedata.bom;
store_saved_encoding(doc); /* store the opened encoding for undo/redo */ 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); sci_set_readonly(doc->editor->sci, doc->readonly);
/* update line number margin width */ /* update line number margin width */
......
...@@ -497,7 +497,7 @@ static void parse_command_line_options(gint *argc, gchar ***argv) ...@@ -497,7 +497,7 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
GError *error = NULL; GError *error = NULL;
GOptionContext *context; GOptionContext *context;
gint i; 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 */ /* first initialise cl_options fields with default values */
cl_options = def_clo; cl_options = def_clo;
...@@ -774,7 +774,7 @@ gboolean main_handle_filename(const gchar *locale_filename) ...@@ -774,7 +774,7 @@ gboolean main_handle_filename(const gchar *locale_filename)
if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) 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 */ /* add recent file manually if opening_session_files is set */
if (doc != NULL && main_status.opening_session_files) if (doc != NULL && main_status.opening_session_files)
ui_add_recent_document(doc); ui_add_recent_document(doc);
...@@ -887,19 +887,13 @@ void main_load_project_from_command_line(const gchar *locale_filename, gboolean ...@@ -887,19 +887,13 @@ void main_load_project_from_command_line(const gchar *locale_filename, gboolean
static void load_startup_files(gint argc, gchar **argv) static void load_startup_files(gint argc, gchar **argv)
{ {
gboolean load_project_from_cl = FALSE; gboolean load_project_from_cl = FALSE;
gboolean cl_files_opened = FALSE;
/* ATM when opening a project file any other filenames are ignored */ /* ATM when opening a project file any other filenames are ignored */
load_project_from_cl = (argc > 1) && g_str_has_suffix(argv[1], ".geany"); load_project_from_cl = (argc > 1) && g_str_has_suffix(argv[1], ".geany");
if (load_project_from_cl && argc > 2) if (load_project_from_cl && argc > 2)
g_print("Ignoring extra filenames after %s", argv[1]); g_print("Ignoring extra filenames after %s", argv[1]);
if (!load_project_from_cl) if (load_project_from_cl || ! open_cl_files(argc, argv))
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 (prefs.load_session) if (prefs.load_session)
{ {
......
...@@ -601,13 +601,11 @@ gboolean socket_lock_input_cb(GIOChannel *source, GIOCondition condition, gpoint ...@@ -601,13 +601,11 @@ gboolean socket_lock_input_cb(GIOChannel *source, GIOCondition condition, gpoint
{ {
if (strncmp(buf, "open", 4) == 0) if (strncmp(buf, "open", 4) == 0)
{ {
if (strncmp(buf+4, "ro", 2) == 0) /* open in readonly? */ cl_options.readonly = strncmp(buf+4, "ro", 2) == 0; /* open in readonly? */
cl_options.readonly = TRUE;
while (socket_fd_gets(sock, buf, sizeof(buf)) != -1 && *buf != '.') while (socket_fd_gets(sock, buf, sizeof(buf)) != -1 && *buf != '.')
{ {
handle_input_filename(g_strstrip(buf)); handle_input_filename(g_strstrip(buf));
} }
cl_options.readonly = FALSE; /* disable again for future files */
popup = TRUE; popup = TRUE;
} }
else if (strncmp(buf, "doclist", 7) == 0) else if (strncmp(buf, "doclist", 7) == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment