def __init__(self, application): """Constructs the AboutView.""" self.application = application about_controller = self.application.get_about_controller() about_dialog_glade = os.path.join( constants.GUI_DIRECTORY, 'about_dialog.glade') # This must be set before the window is created or # the url will not be clickable. gtk.about_dialog_set_url_hook( about_controller.on_about_dialog_url_clicked) View.__init__( self, about_controller, about_dialog_glade, 'about_dialog', None, False) self.log = logging.getLogger(self.__class__.__name__) # Can't do this in constructor as main_view has multiple # top-level widgets self['about_dialog'].set_transient_for( self.application.get_main_view()['scan_window']) self['about_dialog'].set_version('%i.%i.%i' % constants.VERSION) self.application.get_about_controller().register_view(self) self.log.debug('Created.')
def __init__(self, application): """ Constructs the DocumentView, including setting up controls that could not be configured in Glade and constructing sub-views. """ self.application = application document_view_glade = os.path.join( constants.GUI_DIRECTORY, 'document_view.glade') View.__init__( self, application.get_document_controller(), document_view_glade, 'dummy_document_view_window', None, False) self.log = logging.getLogger(self.__class__.__name__) # Setup controls that could not be configured in Glade self['thumbnails_tree_view'] = gtk.TreeView() self['thumbnails_column'] = gtk.TreeViewColumn(None) self['thumbnails_cell'] = gtk.CellRendererPixbuf() self['thumbnails_column'].set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) self['thumbnails_column'].set_fixed_width( constants.DEFAULT_THUMBNAIL_SIZE) self['thumbnails_tree_view'].append_column(self['thumbnails_column']) self['thumbnails_column'].pack_start(self['thumbnails_cell'], True) self['thumbnails_column'].set_cell_data_func( self['thumbnails_cell'], self.thumbnails_column_cell_data_func) self['thumbnails_tree_view'].get_selection().set_mode( gtk.SELECTION_SINGLE) self['thumbnails_tree_view'].set_headers_visible(False) self['thumbnails_tree_view'].set_property('can-focus', False) self['thumbnails_tree_view'].set_reorderable(True) self['thumbnails_scrolled_window'].add(self['thumbnails_tree_view']) self['thumbnails_context_menu'] = gtk.Menu() self['delete_menu_item'] = gtk.MenuItem('Delete') self['thumbnails_context_menu'].append(self['delete_menu_item']) self['thumbnails_context_menu'].show_all() # Dock sub-views page_view = self.application.get_page_view() page_view['page_view_table'].reparent( self['page_view_docking_viewport']) application.get_document_controller().register_view(self) self.log.debug('Created.')
def __init__(self, application): """ Constructs the StatusView. """ self.application = application status_view_glade = os.path.join( constants.GUI_DIRECTORY, 'status_view.glade') View.__init__( self, application.get_status_controller(), status_view_glade, 'dummy_status_view_window', None, False) self.log = logging.getLogger(self.__class__.__name__) application.get_status_controller().register_view(self) self.log.debug('Created.')
def __init__(self, application): """ Constructs the MainView, including setting up controls that could not be configured in Glade and constructing sub-views. """ self.application = application scan_window_glade = os.path.join( constants.GUI_DIRECTORY, 'scan_window.glade') View.__init__( self, application.get_main_controller(), scan_window_glade, ['scan_window', 'progress_window'], None, False) self.log = logging.getLogger(self.__class__.__name__) # Setup controls which can not be configured in Glade self['scan_window'].set_geometry_hints(min_width=600, min_height=400) # Setup sub views document_view = self.application.get_document_view() document_view['document_view_horizontal_box'].reparent( self['document_view_docking_viewport']) self['document_view_docking_viewport'].show_all() status_view = self.application.get_status_view() status_view['statusbar'].reparent( self['status_view_docking_viewport']) self['status_view_docking_viewport'].show_all() # All controls are disabled by default, they become # avaiable when an event indicates that they should be. self.set_scan_controls_sensitive(False) self.set_file_controls_sensitive(False) self.set_delete_controls_sensitive(False) self.set_zoom_controls_sensitive(False) self.set_adjustment_controls_sensitive(False) self.set_navigation_controls_sensitive(False) document_view.set_adjustments_sensitive(False) application.get_main_controller().register_view(self) self.log.debug('Created.')
def __init__(self, application): """ Constructs the PageView, including setting up controls that could not be configured in Glade. """ self.application = application page_view_glade = os.path.join(constants.GUI_DIRECTORY, "page_view.glade") View.__init__(self, application.get_page_controller(), page_view_glade, "dummy_page_view_window", None, False) self.log = logging.getLogger(self.__class__.__name__) self["page_view_horizontal_scrollbar"].set_adjustment(self["page_view_image_layout"].get_hadjustment()) self["page_view_vertical_scrollbar"].set_adjustment(self["page_view_image_layout"].get_vadjustment()) self["page_view_image_layout"].modify_bg( gtk.STATE_NORMAL, gtk.gdk.colormap_get_system().alloc_color(gtk.gdk.Color(0, 0, 0), False, True) ) application.get_page_controller().register_view(self) self.log.debug("Created.")
def __init__(self, application): """ Constructs the MainView, including setting up controls that could not be configured in Glade and constructing sub-views. """ self.application = application save_dialog_glade = os.path.join( constants.GUI_DIRECTORY, 'save_dialog.glade') View.__init__( self, self.application.get_save_controller(), save_dialog_glade, 'save_dialog', None, False) self.log = logging.getLogger(self.__class__.__name__) # Can't do this in constructor as main_view has multiple # top-level widgets self['save_dialog'].set_transient_for( self.application.get_main_view()['scan_window']) # Setup filename filter filename_filter = gtk.FileFilter() filename_filter.set_name('PDF Files') filename_filter.add_mime_type('application/pdf') filename_filter.add_pattern('*.pdf') self['save_dialog'].add_filter(filename_filter) # Setup custom control self['keywords_entry'] = nostaples.utils.gui.KeywordsCompletionEntry() self['keywords_hbox'].pack_start(self['keywords_entry']) self['keywords_entry'].show() model = self['keywords_entry'].get_liststore() for word in ["abc", "def", "ghi", "jkl", "mno", "pqr", "stu", "vwx", "yz"]: model.append([word]) self.application.get_save_controller().register_view(self) self.log.debug('Created.')
def __init__(self, application): """ Constructs the PreferencesView, including setting up controls that could not be configured in Glade. """ self.application = application preferences_controller = application.get_preferences_controller() preferences_dialog_glade = os.path.join(constants.GUI_DIRECTORY, "preferences_dialog.glade") View.__init__(self, preferences_controller, preferences_dialog_glade, "preferences_dialog", None, False) self.log = logging.getLogger(self.__class__.__name__) # Can not configure this via constructor do to the multiple # root windows in the Main View. self["preferences_dialog"].set_transient_for(application.get_main_view()["scan_window"]) # These two combobox's are setup dynamically. Because of this they # must have their signal handlers connected manually. Otherwise # their signals will fire before the view creation is finished. setup_combobox( self["preview_mode_combobox"], constants.PREVIEW_MODES_LIST, application.get_preferences_model().preview_mode, ) self["preview_mode_combobox"].connect("changed", preferences_controller.on_preview_mode_combobox_changed) setup_combobox( self["thumbnail_size_combobox"], constants.THUMBNAIL_SIZE_LIST, application.get_preferences_model().thumbnail_size, ) self["thumbnail_size_combobox"].connect("changed", preferences_controller.on_thumbnail_size_combobox_changed) setup_combobox( self["toolbar_style_combobox"], constants.TOOLBAR_STYLES_LIST, application.get_preferences_model().toolbar_style, ) self["toolbar_style_combobox"].connect("changed", preferences_controller.on_toolbar_style_combobox_changed) # Setup the unavailable scanners tree view unavailable_liststore = gtk.ListStore(str, str) self["unavailable_tree_view"] = gtk.TreeView() self["unavailable_tree_view"].set_model(unavailable_liststore) self["unavailable_column"] = gtk.TreeViewColumn(None) self["unavailable_cell"] = gtk.CellRendererText() self["unavailable_tree_view"].append_column(self["unavailable_column"]) self["unavailable_column"].pack_start(self["unavailable_cell"], True) self["unavailable_column"].add_attribute(self["unavailable_cell"], "text", 0) self["unavailable_tree_view"].get_selection().set_mode(gtk.SELECTION_NONE) self["unavailable_tree_view"].set_headers_visible(False) self["unavailable_tree_view"].set_property("can-focus", False) self["unavailable_tree_view"].set_tooltip_column(1) self["unavailable_scrolled_window"].add(self["unavailable_tree_view"]) self["unavailable_scrolled_window"].show_all() # Setup the blacklist tree view blacklist_liststore = gtk.ListStore(str) self["blacklist_tree_view"] = gtk.TreeView() self["blacklist_tree_view"].set_model(blacklist_liststore) self["blacklist_column"] = gtk.TreeViewColumn(None) self["blacklist_cell"] = gtk.CellRendererText() self["blacklist_tree_view"].append_column(self["blacklist_column"]) self["blacklist_column"].pack_start(self["blacklist_cell"], True) self["blacklist_column"].add_attribute(self["blacklist_cell"], "text", 0) self["blacklist_tree_view"].get_selection().set_mode(gtk.SELECTION_SINGLE) self["blacklist_tree_view"].set_headers_visible(False) self["blacklist_tree_view"].set_property("can-focus", False) self["blacklist_scrolled_window"].add(self["blacklist_tree_view"]) self["blacklist_scrolled_window"].show_all() self["blacklist_tree_view"].get_selection().connect( "changed", preferences_controller.on_blacklist_tree_view_selection_changed ) # Setup the available devices tree view available_liststore = gtk.ListStore(str) self["available_tree_view"] = gtk.TreeView() self["available_tree_view"].set_model(available_liststore) self["available_column"] = gtk.TreeViewColumn(None) self["available_cell"] = gtk.CellRendererText() self["available_tree_view"].append_column(self["available_column"]) self["available_column"].pack_start(self["available_cell"], True) self["available_column"].add_attribute(self["available_cell"], "text", 0) self["available_tree_view"].get_selection().set_mode(gtk.SELECTION_SINGLE) self["available_tree_view"].set_headers_visible(False) self["available_tree_view"].set_property("can-focus", False) self["available_scrolled_window"].add(self["available_tree_view"]) self["available_scrolled_window"].show_all() self["available_tree_view"].get_selection().connect( "changed", preferences_controller.on_available_tree_view_selection_changed ) # Setup the keywords tree view keywords_liststore = gtk.ListStore(str) self["keywords_tree_view"] = gtk.TreeView() self["keywords_tree_view"].set_model(keywords_liststore) self["keywords_column"] = gtk.TreeViewColumn(None) self["keywords_cell"] = gtk.CellRendererText() self["keywords_tree_view"].append_column(self["keywords_column"]) self["keywords_column"].pack_start(self["keywords_cell"], True) self["keywords_column"].add_attribute(self["keywords_cell"], "text", 0) self["keywords_tree_view"].get_selection().set_mode(gtk.SELECTION_SINGLE) self["keywords_tree_view"].set_headers_visible(False) self["keywords_tree_view"].set_property("can-focus", False) self["keywords_scrolled_window"].add(self["keywords_tree_view"]) self["keywords_scrolled_window"].show_all() application.get_preferences_controller().register_view(self) self.log.debug("Created.")
def __init__(self, ctrl): View.__init__(self, ctrl, 'basic.glade')