[chronojump] chronojump-importer: improves the UI.
- From: Carles Pina i Estany <carlespina src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] chronojump-importer: improves the UI.
- Date: Mon, 21 Nov 2016 21:09:07 +0000 (UTC)
commit 43894a5d7ec90fe719652c92d6fe369fd26a0121
Author: Carles Pina i Estany <carles pina cat>
Date: Mon Nov 21 22:04:37 2016 +0100
chronojump-importer: improves the UI.
Changes:
a) A combobox to import the session into a the current session or as a
new session.
b) Shows the confirmation message only if needed
c) Improves the confirmation message
glade/session_load.glade | 7 ++++---
src/chronojumpImporter.cs | 33 ++++++++++++++++-----------------
src/gui/chronojump.cs | 13 ++++++++++++-
src/gui/session.cs | 19 ++++++++++++++++++-
4 files changed, 50 insertions(+), 22 deletions(-)
---
diff --git a/glade/session_load.glade b/glade/session_load.glade
index db54050..49310b0 100644
--- a/glade/session_load.glade
+++ b/glade/session_load.glade
@@ -29,7 +29,7 @@
<widget class="GtkLabel" id="file_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">File name:</property>
+ <property name="label" translatable="yes">Import from file:</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -72,10 +72,11 @@
</child>
<child>
<widget class="GtkHBox" id="import_options_box">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkRadioButton" id="radio_import_new_session">
- <property name="label" translatable="yes">Import in a new session</property>
+ <property name="label" translatable="yes">Import into a new session</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -90,7 +91,7 @@
</child>
<child>
<widget class="GtkRadioButton" id="radio_import_current_session">
- <property name="label" translatable="yes">Import in the current session</property>
+ <property name="label" translatable="yes">Import into the current session</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
diff --git a/src/chronojumpImporter.cs b/src/chronojumpImporter.cs
index 217a565..2d486ae 100644
--- a/src/chronojumpImporter.cs
+++ b/src/chronojumpImporter.cs
@@ -80,27 +80,26 @@ class ChronojumpImporter
string message;
string sessionName = getSessionName (sourceFile, sourceSession);
- string sessionInformation = String.Format (Catalog.GetString ("Session name: {0}\n" +
- "from file: {1}"), sessionName, sourceFile);
-
- if (importsToNew()) {
- message = Catalog.GetString ("A new session will be created with the data from:" +
"\n" +
- sessionInformation + "\n\n" +
- Catalog.GetString ("(if you would like to import into an existing session
then press Cancel, Load the session that you would like to import into and import it)"));
+ if (importsToNew ()) {
+ // We don't need any confirmation to import into a new session (the user could delete
it easily if it was a mistake)
+ return Gtk.ResponseType.Accept;
} else {
- message = String.Format (Catalog.GetString ("The current session will be modified.
The data from:") + "\n" +
- sessionInformation + "\n" +
- Catalog.GetString ("Will be imported in the current session") + "\n\n" +
- Catalog.GetString ("(if you would like to import it as a new session then
press Cancel, exit Chronojump and import before Loading a session)"));
- }
+ // If the user is importing it into an existing session we require a confirmation.
+ // This is very hard to Undo.
+ string sessionInformation = String.Format (Catalog.GetString ("Session name: {0}\n" +
+ "from file: {1}"),
sessionName, sourceFile);
+ message = String.Format (Catalog.GetString ("The current session will be modified
(and it's not possible to Undo it easily). The data from:") + "\n\n" +
+ sessionInformation + "\n\n" +
+ Catalog.GetString ("Will be imported into the current session. It cannot be
undone."));
- Gtk.MessageDialog confirmationDialog = new Gtk.MessageDialog (parentWindow,
Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.OkCancel, message);
- confirmationDialog.Title = Catalog.GetString ("Import session?");
- Gtk.ResponseType response = (Gtk.ResponseType) confirmationDialog.Run ();
+ Gtk.MessageDialog confirmationDialog = new Gtk.MessageDialog (parentWindow,
Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.OkCancel, message);
+ confirmationDialog.Title = Catalog.GetString ("Import session?");
+ Gtk.ResponseType response = (Gtk.ResponseType)confirmationDialog.Run ();
- confirmationDialog.Destroy ();
+ confirmationDialog.Destroy ();
- return response;
+ return response;
+ }
}
public void showImportCorrectlyFinished()
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index fcfbcc5..f052e15 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2327,6 +2327,11 @@ public partial class ChronoJumpWindow
private void on_button_encoder_import_chronojump_session(object o, EventArgs args)
{
sessionLoadWin = SessionLoadWindow.Show (app1, SessionLoadWindow.WindowType.IMPORT_SESSION);
+
+ if (currentSession == null) {
+ sessionLoadWin.DisableImportToCurrentSession ();
+ }
+
sessionLoadWin.Button_accept.Clicked += new EventHandler(on_load_session_accepted_to_import);
}
@@ -2337,7 +2342,13 @@ public partial class ChronoJumpWindow
string databasePath = sessionLoadWin.ImportDatabasePath();
LogB.Information (databasePath);
- ImportSessionFromDatabase (databasePath, sourceSession, currentSession);
+ Session destinationSession = currentSession;
+
+ if (sessionLoadWin.ImportToNewSession ()) {
+ destinationSession = null;
+ }
+
+ ImportSessionFromDatabase (databasePath, sourceSession, destinationSession);
}
private void ImportSessionFromDatabase(string databasePath, int sourceSession, Session
destinationSession)
diff --git a/src/gui/session.cs b/src/gui/session.cs
index b251e98..d612363 100644
--- a/src/gui/session.cs
+++ b/src/gui/session.cs
@@ -660,6 +660,9 @@ public class SessionLoadWindow {
[Widget] Gtk.CheckButton checkbutton_show_data_encoder;
[Widget] Gtk.Label file_path_import;
[Widget] Gtk.VBox session_import_box;
+
+ [Widget] Gtk.RadioButton radio_import_new_session;
+ [Widget] Gtk.RadioButton radio_import_current_session;
static SessionLoadWindow SessionLoadWindowBox;
@@ -696,6 +699,11 @@ public class SessionLoadWindow {
entry_search_filter.CanFocus = true;
entry_search_filter.IsFocus = true;
+ // Leave the state of the Importing Comboboxes as they are by default
+ /*radio_import_new_session.Active = true;
+ radio_import_current_session.Sensitive = false;
+ */
+
treeview_session_load.Selection.Changed += onSelectionEntry;
/**
@@ -983,7 +991,16 @@ public class SessionLoadWindow {
public string ImportDatabasePath() {
return import_file_path;
}
-
+
+ public bool ImportToNewSession() {
+ return radio_import_new_session.Active;
+ }
+
+ public void DisableImportToCurrentSession() {
+ radio_import_new_session.Active = true;
+ radio_import_current_session.Sensitive = false;
+ }
+
void on_row_double_clicked (object o, Gtk.RowActivatedArgs args)
{
TreeView tv = (TreeView) o;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]