ViewManager: added Info button that shows -L info for db
This commit is contained in:
parent
d02640b6d1
commit
96241bd77b
@ -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
|
||||
|
@ -232,6 +232,21 @@
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="info">
|
||||
<property name="label" translatable="yes">_Info</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="remove">
|
||||
<property name="label" translatable="yes">_Delete</property>
|
||||
@ -245,7 +260,7 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@ -261,7 +276,7 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">2</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@ -277,7 +292,7 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">3</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@ -293,7 +308,7 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">4</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user