From 96241bd77bbd0f92be60932ad415d26d9e8a3f19 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Mon, 10 Aug 2015 22:42:27 -0400 Subject: [PATCH] ViewManager: added Info button that shows -L info for db --- gramps/gui/dbman.py | 47 ++++++++++++++++++++++++++++++++++-- gramps/gui/glade/dbman.glade | 23 +++++++++++++++--- gramps/gui/viewmanager.py | 2 +- 3 files changed, 65 insertions(+), 7 deletions(-) diff --git a/gramps/gui/dbman.py b/gramps/gui/dbman.py index 19307334c..85d442b29 100644 --- a/gramps/gui/dbman.py +++ b/gramps/gui/dbman.py @@ -75,6 +75,7 @@ from .user import User from .dialog import ErrorDialog, QuestionDialog, QuestionDialog2, ICON from .pluginmanager import GuiPluginManager from gramps.cli.clidbman import CLIDbManager, NAME_FILE, time_val +from .managedwindow import ManagedWindow from .ddtargets import DdTargets from gramps.gen.recentfiles import rename_filename, remove_filename from .glade import Glade @@ -104,6 +105,29 @@ ICON_COL = 6 RCS_BUTTON = { True : _('_Extract'), False : _('_Archive') } +class Information(ManagedWindow): + def __init__(self, uistate, text, parent): + super().__init__(uistate, [], self) + self.window = Gtk.Dialog('Gramp') + self.set_window(self.window, None, _("Database Information")) + self.window.set_modal(True) + self.ok = self.window.add_button(_('_OK'), Gtk.ResponseType.OK) + self.ok.connect('clicked', self.on_ok_clicked) + self.window.set_position(Gtk.WindowPosition.CENTER) + self.window.set_default_size(600, 400) + s = Gtk.ScrolledWindow() + self.window.vbox.pack_start(s, True, True, 0) + self.textview = Gtk.TextView() + self.textview.get_buffer().set_text(text) + s.add(self.textview) + self.show() + + def on_ok_clicked(self, obj): + self.window.close() + + def build_menu_names(self, obj): + return (_('Database Information'), None) + class DbManager(CLIDbManager): """ Database Manager. Opens a database manager window that allows users to @@ -118,11 +142,12 @@ class DbManager(CLIDbManager): ERROR = ErrorDialog - def __init__(self, dbstate, parent=None): + def __init__(self, uistate, dbstate, parent=None): """ Create the top level window from the glade description, and extracts the GTK widgets that are needed. """ + self.uistate = uistate CLIDbManager.__init__(self, dbstate) self.glade = Glade(toplevel='dbmanager') self.top = self.glade.toplevel @@ -130,7 +155,7 @@ class DbManager(CLIDbManager): if parent: self.top.set_transient_for(parent) - for attr in ['connect', 'cancel', 'new', 'remove', + for attr in ['connect', 'cancel', 'new', 'remove', 'info', 'dblist', 'rename', 'repair', 'rcs', 'msg']: setattr(self, attr, self.glade.get_object(attr)) @@ -159,6 +184,7 @@ class DbManager(CLIDbManager): self.remove.connect('clicked', self.__remove_db) self.new.connect('clicked', self.__new_db) self.rename.connect('clicked', self.__rename_db) + self.info.connect('clicked', self.__info_db) self.repair.connect('clicked', self.__repair_db) self.selection.connect('changed', self.__selection_changed) self.dblist.connect('button-press-event', self.__button_press) @@ -215,6 +241,7 @@ class DbManager(CLIDbManager): if not node: self.connect.set_sensitive(False) self.rename.set_sensitive(False) + self.info.set_sensitive(False) self.rcs.set_sensitive(False) self.repair.set_sensitive(False) self.remove.set_sensitive(False) @@ -246,6 +273,7 @@ class DbManager(CLIDbManager): self.repair.set_sensitive(False) self.rename.set_sensitive(True) + self.info.set_sensitive(True) self.remove.set_sensitive(True) self.new.set_sensitive(True) @@ -411,6 +439,7 @@ class DbManager(CLIDbManager): """ self.connect.set_sensitive(False) self.rename.set_sensitive(False) + self.info.set_sensitive(False) self.rcs.set_sensitive(False) self.repair.set_sensitive(False) self.remove.set_sensitive(False) @@ -632,6 +661,20 @@ class DbManager(CLIDbManager): self.name_renderer.set_property('editable', True) self.dblist.set_cursor(path, self.column, True) + def __info_db(self, obj): + """ + Show info on this database. + """ + store, node = self.selection.get_selected() + name = store[node][0] + dirname = store[node][1] + # if this is open, get info from there, otherwise, temp open? + result = self.get_dbdir_summary(dirname, name) + result_str = "" + for key in sorted(result.keys()): + result_str += "%s: %s\n" % (key, result[key]) + Information(self.uistate, result_str, parent=self.top) + def __repair_db(self, obj): """ Start the repair process by calling the start_editing option on diff --git a/gramps/gui/glade/dbman.glade b/gramps/gui/glade/dbman.glade index 2b5442d26..9ae8cd72f 100644 --- a/gramps/gui/glade/dbman.glade +++ b/gramps/gui/glade/dbman.glade @@ -232,6 +232,21 @@ 0 + + + _Info + True + True + True + True + True + + + False + False + 1 + + _Delete @@ -245,7 +260,7 @@ False False - 1 + 2 @@ -261,7 +276,7 @@ False False - 2 + 3 @@ -277,7 +292,7 @@ False False - 3 + 4 @@ -293,7 +308,7 @@ False False - 4 + 5 diff --git a/gramps/gui/viewmanager.py b/gramps/gui/viewmanager.py index acfdf94d7..16146abef 100644 --- a/gramps/gui/viewmanager.py +++ b/gramps/gui/viewmanager.py @@ -1091,7 +1091,7 @@ class ViewManager(CLIManager): Called when the Open button is clicked, opens the DbManager """ from .dbman import DbManager - dialog = DbManager(self.dbstate, self.window) + dialog = DbManager(self.uistate, self.dbstate, self.window) value = dialog.run() if value: (filename, title) = value