r21807 - gnucash/trunk/src - Read-only mode: Add "Read-only" checkbox when opening a file/database.
Christian Stimming
cstim at code.gnucash.org
Sat Dec 31 05:41:44 EST 2011
Author: cstim
Date: 2011-12-31 05:41:44 -0500 (Sat, 31 Dec 2011)
New Revision: 21807
Trac: http://svn.gnucash.org/trac/changeset/21807
Modified:
gnucash/trunk/src/bin/gnucash-bin.c
gnucash/trunk/src/gnome-utils/dialog-file-access.c
gnucash/trunk/src/gnome-utils/gnc-file.c
gnucash/trunk/src/gnome-utils/gnc-file.h
gnucash/trunk/src/gnome-utils/gnc-plugin-file-history.c
gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-file-access.glade
Log:
Read-only mode: Add "Read-only" checkbox when opening a file/database.
Modified: gnucash/trunk/src/bin/gnucash-bin.c
===================================================================
--- gnucash/trunk/src/bin/gnucash-bin.c 2011-12-31 09:21:57 UTC (rev 21806)
+++ gnucash/trunk/src/bin/gnucash-bin.c 2011-12-31 10:41:44 UTC (rev 21807)
@@ -719,7 +719,7 @@
if (!nofile && (fn = get_file_to_load()))
{
gnc_update_splash_screen(_("Loading data..."), GNC_SPLASH_PERCENTAGE_UNKNOWN);
- gnc_file_open_file(fn);
+ gnc_file_open_file(fn, /*open_readonly*/ FALSE);
g_free(fn);
}
else if (gnc_gconf_get_bool("dialogs/new_user", "first_startup", &error)
Modified: gnucash/trunk/src/gnome-utils/dialog-file-access.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-file-access.c 2011-12-31 09:21:57 UTC (rev 21806)
+++ gnucash/trunk/src/gnome-utils/dialog-file-access.c 2011-12-31 10:41:44 UTC (rev 21807)
@@ -52,6 +52,7 @@
GtkWidget* dialog;
GtkWidget* frame_file;
GtkWidget* frame_database;
+ GtkWidget* readonly_checkbutton;
GtkFileChooser* fileChooser;
gchar *starting_dir;
GtkComboBox* cb_uri_type;
@@ -140,7 +141,10 @@
}
if ( faw->type == FILE_ACCESS_OPEN )
{
- gnc_file_open_file( url );
+ gboolean open_readonly = faw->readonly_checkbutton
+ ? gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(faw->readonly_checkbutton))
+ : FALSE;
+ gnc_file_open_file( url, open_readonly );
}
else if ( faw->type == FILE_ACCESS_SAVE_AS )
{
@@ -278,6 +282,7 @@
faw->frame_file = GTK_WIDGET(gtk_builder_get_object (builder, "frame_file" ));
faw->frame_database = GTK_WIDGET(gtk_builder_get_object (builder, "frame_database" ));
+ faw->readonly_checkbutton = GTK_WIDGET(gtk_builder_get_object (builder, "readonly_checkbutton"));
faw->tf_host = GTK_ENTRY(gtk_builder_get_object (builder, "tf_host" ));
gtk_entry_set_text( faw->tf_host, DEFAULT_HOST );
faw->tf_database = GTK_ENTRY(gtk_builder_get_object (builder, "tf_database" ));
@@ -300,6 +305,8 @@
button_label = "gtk-save-as";
fileChooserAction = GTK_FILE_CHOOSER_ACTION_SAVE;
gconf_section = GCONF_DIR_OPEN_SAVE;
+ gtk_widget_destroy(faw->readonly_checkbutton);
+ faw->readonly_checkbutton = NULL;
break;
case FILE_ACCESS_EXPORT:
@@ -307,6 +314,8 @@
button_label = "gtk-save-as";
fileChooserAction = GTK_FILE_CHOOSER_ACTION_SAVE;
gconf_section = GCONF_DIR_EXPORT;
+ gtk_widget_destroy(faw->readonly_checkbutton);
+ faw->readonly_checkbutton = NULL;
break;
}
Modified: gnucash/trunk/src/gnome-utils/gnc-file.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.c 2011-12-31 09:21:57 UTC (rev 21806)
+++ gnucash/trunk/src/gnome-utils/gnc-file.c 2011-12-31 10:41:44 UTC (rev 21807)
@@ -686,7 +686,7 @@
#define RESPONSE_READONLY 4
static gboolean
-gnc_post_file_open (const char * filename)
+gnc_post_file_open (const char * filename, gboolean is_readonly)
{
QofSession *current_session, *new_session;
QofBook *new_book;
@@ -701,7 +701,6 @@
gchar *password = NULL;
gchar *path = NULL;
gint32 port = 0;
- gboolean is_readonly = FALSE;
ENTER(" ");
@@ -1069,7 +1068,7 @@
g_free ( last );
g_free ( default_dir );
- result = gnc_post_file_open ( newfile );
+ result = gnc_post_file_open ( newfile, /*is_readonly*/ FALSE );
/* This dialogue can show up early in the startup process. If the
* user fails to pick a file (by e.g. hitting the cancel button), we
@@ -1081,14 +1080,14 @@
}
gboolean
-gnc_file_open_file (const char * newfile)
+gnc_file_open_file (const char * newfile, gboolean open_readonly)
{
if (!newfile) return FALSE;
if (!gnc_file_query_save (TRUE))
return FALSE;
- return gnc_post_file_open (newfile);
+ return gnc_post_file_open (newfile, open_readonly);
}
/* Note: this dialog will only be used when dbi is not enabled
Modified: gnucash/trunk/src/gnome-utils/gnc-file.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.h 2011-12-31 09:21:57 UTC (rev 21806)
+++ gnucash/trunk/src/gnome-utils/gnc-file.h 2011-12-31 10:41:44 UTC (rev 21807)
@@ -143,7 +143,7 @@
const char * starting_dir,
GNCFileDialogType type);
-gboolean gnc_file_open_file (const char *filename);
+gboolean gnc_file_open_file (const char *filename, gboolean open_readonly);
gboolean gnc_file_query_save (gboolean can_cancel);
Modified: gnucash/trunk/src/gnome-utils/gnc-plugin-file-history.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-plugin-file-history.c 2011-12-31 09:21:57 UTC (rev 21806)
+++ gnucash/trunk/src/gnome-utils/gnc-plugin-file-history.c 2011-12-31 10:41:44 UTC (rev 21807)
@@ -725,7 +725,7 @@
filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING);
gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
/* also opens new account page */
- gnc_file_open_file (filename);
+ gnc_file_open_file (filename, /*open_readonly*/ FALSE);
gnc_window_set_progressbar_window (NULL);
}
Modified: gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-file-access.glade
===================================================================
--- gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-file-access.glade 2011-12-31 09:21:57 UTC (rev 21806)
+++ gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-file-access.glade 2011-12-31 10:41:44 UTC (rev 21807)
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
@@ -93,6 +93,23 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="readonly_checkbutton">
+ <property name="label" translatable="yes">Open _Read-Only</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
More information about the gnucash-changes
mailing list