예제 #1
0
 def __init__(self, parent, services):
     """Prepare the services detail dialog"""
     # Load the user interface
     self.ui = GtkBuilderLoader(get_ui_file('service_detail.glade'))
     if not preferences.get(preferences.DETACHED_WINDOWS):
         self.ui.dialog_edit_service.set_transient_for(parent)
     # Restore the saved size and position
     settings.positions.restore_window_position(
         self.ui.dialog_edit_service, SECTION_WINDOW_NAME)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         widget.set_label(text(widget.get_label()))
     # Initialize labels
     for widget in self.ui.get_objects_by_type(Gtk.Label):
         widget.set_label(text(widget.get_label()))
         widget.set_tooltip_text(widget.get_label().replace('_', ''))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.Button):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     self.model = services
     self.selected_iter = None
     self.name = ''
     self.description = ''
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #2
0
 def __init__(self, parent):
     """Prepare the devices dialog"""
     # Load the user interface
     self.ui = GtkBuilderLoader(get_ui_file('devices.glade'))
     if not preferences.get(preferences.DETACHED_WINDOWS):
         self.ui.dialog_devices.set_transient_for(parent)
     # Restore the saved size and position
     settings.positions.restore_window_position(self.ui.dialog_devices,
                                                SECTION_WINDOW_NAME)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         widget.set_label(text(widget.get_label()))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.Button):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     # Initialize column headers
     for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn):
         widget.set_title(text(widget.get_title()))
     # Load the devices
     self.model = ModelDevices(self.ui.store_devices)
     self.selected_iter = None
     # Sort the data in the models
     self.model.model.set_sort_column_id(
         self.ui.column_name.get_sort_column_id(), Gtk.SortType.ASCENDING)
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #3
0
 def __init__(self, parent, services):
     """Prepare the services detail dialog"""
     # Load the user interface
     self.ui = GtkBuilderLoader(get_ui_file('service_detail.glade'))
     if not preferences.get(preferences.DETACHED_WINDOWS):
         self.ui.dialog_edit_service.set_transient_for(parent)
     # Restore the saved size and position
     settings.positions.restore_window_position(
         self.ui.dialog_edit_service, SECTION_WINDOW_NAME)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         widget.set_label(text(widget.get_label()))
     # Initialize labels
     for widget in self.ui.get_objects_by_type(Gtk.Label):
         widget.set_label(text(widget.get_label()))
         widget.set_tooltip_text(widget.get_label().replace('_', ''))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.Button):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     self.model = services
     self.selected_iter = None
     self.name = ''
     self.description = ''
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #4
0
 def __init__(self, parent, groups):
     """Prepare the group detail dialog"""
     # Load the user interface
     self.ui = GtkBuilderLoader(get_ui_file('group_detail.glade'))
     if not preferences.get(preferences.DETACHED_WINDOWS):
         self.ui.dialog_edit_group.set_transient_for(parent)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         widget.set_label(text(widget.get_label()))
     # Initialize labels
     for widget in self.ui.get_objects_by_type(Gtk.Label):
         widget.set_label(text(widget.get_label()))
         widget.set_tooltip_text(widget.get_label().replace('_', ''))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.Button):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     self.model = groups
     self.name = ''
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #5
0
파일: host.py 프로젝트: muflone/glivesnmp
 def __init__(self, parent, hosts):
     """Prepare the host dialog"""
     self.hosts = hosts
     # Load the user interface
     self.ui = GtkBuilderLoader(get_ui_file('host.glade'))
     if not preferences.get(preferences.DETACHED_WINDOWS):
         self.ui.dialog_host.set_transient_for(parent)
     # Restore the saved size and position
     settings.positions.restore_window_position(
         self.ui.dialog_host, SECTION_WINDOW_NAME)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         if widget.get_label():
             widget.set_label(text(widget.get_label()))
         else:
             widget.set_label(text(widget.get_short_label()))
     # Initialize labels
     for widget in self.ui.get_objects_by_type(Gtk.Label):
         widget.set_label(text(widget.get_label()))
         widget.set_tooltip_text(widget.get_label().replace('_', ''))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.Button):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     # Initialize column headers
     for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn):
         widget.set_title(text(widget.get_title()))
     self.selected_iter = None
     self.model_devices = ModelDevices(self.ui.store_devices)
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #6
0
 def __init__(self, parent, groups):
     """Prepare the group detail dialog"""
     # Load the user interface
     self.ui = GtkBuilderLoader(get_ui_file('group_detail.glade'))
     if not preferences.get(preferences.DETACHED_WINDOWS):
         self.ui.dialog_edit_group.set_transient_for(parent)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         widget.set_label(text(widget.get_label()))
     # Initialize labels
     for widget in self.ui.get_objects_by_type(Gtk.Label):
         widget.set_label(text(widget.get_label()))
         widget.set_tooltip_text(widget.get_label().replace('_', ''))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.Button):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     self.model = groups
     self.name = ''
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #7
0
파일: host.py 프로젝트: muflone/glivesnmp
 def __init__(self, parent, hosts):
     """Prepare the host dialog"""
     self.hosts = hosts
     # Load the user interface
     self.ui = GtkBuilderLoader(get_ui_file('host.glade'))
     if not preferences.get(preferences.DETACHED_WINDOWS):
         self.ui.dialog_host.set_transient_for(parent)
     # Restore the saved size and position
     settings.positions.restore_window_position(self.ui.dialog_host,
                                                SECTION_WINDOW_NAME)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         if widget.get_label():
             widget.set_label(text(widget.get_label()))
         else:
             widget.set_label(text(widget.get_short_label()))
     # Initialize labels
     for widget in self.ui.get_objects_by_type(Gtk.Label):
         widget.set_label(text(widget.get_label()))
         widget.set_tooltip_text(widget.get_label().replace('_', ''))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.Button):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     # Initialize column headers
     for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn):
         widget.set_title(text(widget.get_title()))
     self.selected_iter = None
     self.model_devices = ModelDevices(self.ui.store_devices)
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #8
0
 def __init__(self, parent):
     """Prepare the devices dialog"""
     # Load the user interface
     self.ui = GtkBuilderLoader(get_ui_file('devices.glade'))
     if not preferences.get(preferences.DETACHED_WINDOWS):
         self.ui.dialog_devices.set_transient_for(parent)
     # Restore the saved size and position
     settings.positions.restore_window_position(
         self.ui.dialog_devices, SECTION_WINDOW_NAME)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         widget.set_label(text(widget.get_label()))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.Button):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     # Initialize column headers
     for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn):
         widget.set_title(text(widget.get_title()))
     # Load the devices
     self.model = ModelDevices(self.ui.store_devices)
     self.selected_iter = None
     # Sort the data in the models
     self.model.model.set_sort_column_id(
         self.ui.column_name.get_sort_column_id(),
         Gtk.SortType.ASCENDING)
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #9
0
 def on_action_remove_activate(self, action):
     """Remove the selected group"""
     selected_row = get_treeview_selected_row(self.ui.tvw_groups)
     group_name = self.model.get_key(selected_row) if selected_row else ''
     if selected_row and group_name and show_message_dialog(
             class_=UIMessageDialogNoYes,
             parent=self.ui.dialog_groups,
             message_type=Gtk.MessageType.WARNING,
             title=None,
             msg1=_('Remove the group'),
             msg2=_('Remove the group «%s»?') % group_name,
             is_response_id=Gtk.ResponseType.YES):
         group_path = os.path.join(DIR_HOSTS, group_name)
         # Check for directory not empty
         if len(os.listdir(group_path)) and not show_message_dialog(
                 class_=UIMessageDialogNoYes,
                 parent=self.ui.dialog_groups,
                 message_type=Gtk.MessageType.WARNING,
                 title=None,
                 msg1=_('The group is not empty'),
                 msg2='%s\n%s\n\n%s' % (
                     text('If you delete an item, it will '
                          'be permanently lost.'),
                     _('All the hosts defined for the group will be lost.'),
                     _('Are you sure you want to delete the '
                       'group «%s»?') % group_name,
                                    ),
                 is_response_id=Gtk.ResponseType.YES):
             # Exit immediately without deleting the group
             return
         # Delete all the contained files and the directory for the group
         for filename in os.listdir(group_path):
             os.remove(os.path.join(group_path, filename))
         os.rmdir(group_path)
         self.model.remove(selected_row)
예제 #10
0
 def __init__(self, parent, host):
     """Prepare the snmp values dialog"""
     # Load the user interface
     self.ui = GtkBuilderLoader(get_ui_file('snmp_values.glade'))
     if not preferences.get(preferences.DETACHED_WINDOWS):
         self.ui.window_snmp.set_transient_for(parent)
     # Restore the saved size and position
     settings.positions.restore_window_position(
         self.ui.window_snmp, SECTION_WINDOW_NAME)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         if widget.get_label():
             widget.set_label(text(widget.get_label()))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.Button):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     # Initialize column headers
     for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn):
         widget.set_title(text(widget.get_title()))
     # Initialize services
     self.model = SNMPValues(self.ui.store_values)
     self.services = {}
     for service in model_devices.devices[host.device].services:
         oid = model_services.services[service].numeric_oid
         self.services[service] = oid
         value = SNMPValueInfo(name=service, value='', timestamp=0)
         self.model.add_data(value)
     # Sort the data in the models
     self.model.model.set_sort_column_id(
         self.ui.column_name.get_sort_column_id(),
         Gtk.SortType.ASCENDING)
     self.host = host
     self.ui.window_snmp.set_title(_('SNMP values for %s') % host.name)
     self.semaphore = None
     self.completed_threads = 0
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #11
0
 def __init__(self, parent, host):
     """Prepare the snmp values dialog"""
     # Load the user interface
     self.ui = GtkBuilderLoader(get_ui_file('snmp_values.glade'))
     if not preferences.get(preferences.DETACHED_WINDOWS):
         self.ui.window_snmp.set_transient_for(parent)
     # Restore the saved size and position
     settings.positions.restore_window_position(self.ui.window_snmp,
                                                SECTION_WINDOW_NAME)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         if widget.get_label():
             widget.set_label(text(widget.get_label()))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.Button):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     # Initialize column headers
     for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn):
         widget.set_title(text(widget.get_title()))
     # Initialize services
     self.model = SNMPValues(self.ui.store_values)
     self.services = {}
     for service in model_devices.devices[host.device].services:
         oid = model_services.services[service].numeric_oid
         self.services[service] = oid
         value = SNMPValueInfo(name=service, value='', timestamp=0)
         self.model.add_data(value)
     # Sort the data in the models
     self.model.model.set_sort_column_id(
         self.ui.column_name.get_sort_column_id(), Gtk.SortType.ASCENDING)
     self.host = host
     self.ui.window_snmp.set_title(_('SNMP values for %s') % host.name)
     self.semaphore = None
     self.completed_threads = 0
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #12
0
파일: main.py 프로젝트: muflone/glivesnmp
 def loadUI(self):
     """Load the interface UI"""
     self.ui = GtkBuilderLoader(get_ui_file('main.glade'))
     self.ui.win_main.set_application(self.application)
     self.ui.win_main.set_title(APP_NAME)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         widget.set_label(text(widget.get_label()))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.ToolButton):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     # Initialize column headers
     for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn):
         widget.set_title(text(widget.get_title()))
     # Set list items row height
     icon_size = preferences.ICON_SIZE
     self.ui.cell_name.props.height = preferences.get(icon_size)
     self.ui.cell_group_name.props.height = preferences.get(icon_size)
     # Set groups visibility
     self.ui.scroll_groups.set_visible(
         preferences.get(preferences.GROUPS_SHOW))
     # Add a Gtk.Headerbar, only for GTK+ 3.10.0 and higher
     if (not Gtk.check_version(3, 10, 0)
             and not preferences.get(preferences.HEADERBARS_DISABLE)):
         self.load_ui_headerbar()
         if preferences.get(preferences.HEADERBARS_REMOVE_TOOLBAR):
             # This is only for development, it should always be True
             # Remove the redundant toolbar
             self.ui.toolbar_main.destroy()
         # Flatten the Gtk.ScrolledWindows
         self.ui.scroll_groups.set_shadow_type(Gtk.ShadowType.NONE)
         self.ui.scroll_connections.set_shadow_type(Gtk.ShadowType.NONE)
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #13
0
파일: main.py 프로젝트: muflone/glivesnmp
 def loadUI(self):
     """Load the interface UI"""
     self.ui = GtkBuilderLoader(get_ui_file('main.glade'))
     self.ui.win_main.set_application(self.application)
     self.ui.win_main.set_title(APP_NAME)
     # Initialize actions
     for widget in self.ui.get_objects_by_type(Gtk.Action):
         # Connect the actions accelerators
         widget.connect_accelerator()
         # Set labels
         widget.set_label(text(widget.get_label()))
     # Initialize tooltips
     for widget in self.ui.get_objects_by_type(Gtk.ToolButton):
         action = widget.get_related_action()
         if action:
             widget.set_tooltip_text(action.get_label().replace('_', ''))
     # Initialize column headers
     for widget in self.ui.get_objects_by_type(Gtk.TreeViewColumn):
         widget.set_title(text(widget.get_title()))
     # Set list items row height
     icon_size = preferences.ICON_SIZE
     self.ui.cell_name.props.height = preferences.get(icon_size)
     self.ui.cell_group_name.props.height = preferences.get(icon_size)
     # Set groups visibility
     self.ui.scroll_groups.set_visible(
         preferences.get(preferences.GROUPS_SHOW))
     # Add a Gtk.Headerbar, only for GTK+ 3.10.0 and higher
     if (not Gtk.check_version(3, 10, 0) and
             not preferences.get(preferences.HEADERBARS_DISABLE)):
         self.load_ui_headerbar()
         if preferences.get(preferences.HEADERBARS_REMOVE_TOOLBAR):
             # This is only for development, it should always be True
             # Remove the redundant toolbar
             self.ui.toolbar_main.destroy()
         # Flatten the Gtk.ScrolledWindows
         self.ui.scroll_groups.set_shadow_type(Gtk.ShadowType.NONE)
         self.ui.scroll_connections.set_shadow_type(Gtk.ShadowType.NONE)
     # Connect signals from the glade file to the module functions
     self.ui.connect_signals(self)
예제 #14
0
 def __init__(self, parent, title):
     """Prepare the file chooser dialog"""
     UIFileChooser.__init__(self, parent, title,
                            Gtk.FileChooserAction.OPEN, (
                                text('_Cancel'), Gtk.ResponseType.CANCEL,
                                text('_Open'), Gtk.ResponseType.OK))
예제 #15
0
 def __init__(self, parent, title):
     """Prepare the file chooser dialog"""
     UIFileChooser.__init__(self, parent, title, Gtk.FileChooserAction.OPEN,
                            (text('_Cancel'), Gtk.ResponseType.CANCEL,
                             text('_Open'), Gtk.ResponseType.OK))
예제 #16
0
#  with this program; if not, write to the Free Software Foundation, Inc.,
#  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
##

import gettext
import locale

import glivesnmp.requires

from glivesnmp.functions import store_message, text, _
from glivesnmp.constants import DOMAIN_NAME, DIR_LOCALE

# Load domain for translation
for module in (gettext, locale):
    module.bindtextdomain(DOMAIN_NAME, DIR_LOCALE)
    module.textdomain(DOMAIN_NAME)

# Import some translated messages from GTK+ domain
store_message('_Icon:', '_%s:' % text(message='Icon', gtk30=True))
for message in ('_OK', '_Cancel', '_Close', '_Open', '_Save', '_Connect',
                '_Copy', '_Delete', 'Select a File', 'Services',
                'Name', 'Value', '_Name:', '_Value:',
                'If you delete an item, it will be permanently lost.'):
    text(message=message, gtk30=True)
# With domain context
for message in ('_Add', '_Remove', '_Edit', '_New', '_Quit', '_About'):
    text(message=message, gtk30=True, context='Stock label')
# Remove the underscore
for message in ('_Add', '_Remove', '_Edit', '_New', '_Connect', '_Delete'):
    store_message(message.replace('_', ''), _(message).replace('_', ''))