--read-only cleanup
Use the global variable only when needed and add an initializer for it in the default options.
This commit is contained in:
parent
102ce1d205
commit
6738d43dee
@ -1162,7 +1162,7 @@ GeanyDocument *document_open_file_full(GeanyDocument *doc, const gchar *filename
|
||||
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 */
|
||||
|
12
src/main.c
12
src/main.c
@ -497,7 +497,7 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
|
||||
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 @@ gboolean main_handle_filename(const gchar *locale_filename)
|
||||
|
||||
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 @@ void main_load_project_from_command_line(const gchar *locale_filename, gboolean
|
||||
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)
|
||||
{
|
||||
|
@ -601,13 +601,11 @@ gboolean socket_lock_input_cb(GIOChannel *source, GIOCondition condition, gpoint
|
||||
{
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user