def __init__(self, parent, existing_folders): """Prepare the AppFolder creation dialog""" # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('create_appfolder.ui')) self.ui.dialog_create_appfolder.set_titlebar(self.ui.header_bar) # Initialize actions for widget in self.ui.get_objects_by_type(Gtk.Action): # Connect the actions accelerators widget.connect_accelerator() # Set labels label = widget.get_label() if not label: label = widget.get_short_label() widget.set_short_label(text(label)) widget.set_label(text(label)) # Initialize labels for widget in self.ui.get_objects_by_type(Gtk.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('_', '')) # Set various properties self.ui.dialog_create_appfolder.set_transient_for(parent) set_style_suggested_action(self.ui.button_ok) self.existing_folders = existing_folders self.ui.button_ok.grab_default() self.folder_name = '' self.folder_title = '' # Connect signals from the glade file to the module functions self.ui.connect_signals(self)
def __init__(self, parent): """Prepare the shortcuts dialog""" # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('shortcuts.ui')) self.ui.shortcuts.set_transient_for(parent) # Initialize groups for widget in self.ui.get_objects_by_type(Gtk.ShortcutsGroup): widget.props.title = text(widget.props.title) # Initialize shortcuts for widget in self.ui.get_objects_by_type(Gtk.ShortcutsShortcut): widget.props.title = text(widget.props.title)
def startup(self, application): """Configure the application during the startup""" __pychecker__ = 'unusednames=application' self.ui = UIMain(self) # Add the about action to the app menu action = Gio.SimpleAction(name="about") action.connect("activate", self.on_app_about_activate) self.add_action(action) # Add the shortcut action to the app menu # only for GTK+ 3.20.0 and higher if not Gtk.check_version(3, 20, 0): action = Gio.SimpleAction(name="shortcuts") action.connect("activate", self.on_app_shortcuts_activate) self.add_action(action) # Add the quit action to the app menu action = Gio.SimpleAction(name="quit") action.connect("activate", self.on_app_quit_activate) self.add_action(action) # Add the app menu builder_appmenu = GtkBuilderLoader(get_ui_file('appmenu.ui')) self.set_app_menu(builder_appmenu.app_menu)
def __init__(self, parent): """Prepare the about dialog""" # Retrieve the translators list translators = [] for line in readlines(FILE_TRANSLATORS, False): if ':' in line: line = line.split(':', 1)[1] line = line.replace('(at)', '@').strip() if line not in translators: translators.append(line) # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('about.ui')) # Set various properties self.ui.dialog_about.set_program_name(APP_NAME) self.ui.dialog_about.set_version(_('Version %s') % APP_VERSION) self.ui.dialog_about.set_comments(APP_DESCRIPTION) self.ui.dialog_about.set_website(APP_URL) self.ui.dialog_about.set_copyright(APP_COPYRIGHT) # Prepare lists for authors and contributors authors = ['%s <%s>' % (APP_AUTHOR, APP_AUTHOR_EMAIL)] contributors = [] for line in readlines(FILE_CONTRIBUTORS, False): contributors.append(line) if len(contributors) > 0: contributors.insert(0, _('Contributors:')) authors.extend(contributors) self.ui.dialog_about.set_authors(authors) self.ui.dialog_about.set_license( '\n'.join(readlines(FILE_LICENSE, True))) self.ui.dialog_about.set_translator_credits('\n'.join(translators)) # Retrieve the external resources links # only for GTK+ 3.6.0 and higher if not Gtk.check_version(3, 6, 0): for line in readlines(FILE_RESOURCES, False): resource_type, resource_url = line.split(':', 1) self.ui.dialog_about.add_credit_section( resource_type, (resource_url,)) icon_logo = Pixbuf.new_from_file(FILE_ICON) self.ui.dialog_about.set_logo(icon_logo) self.ui.dialog_about.set_transient_for(parent)
def __init__(self, parent): """Prepare the about dialog""" # Retrieve the translators list translators = [] for line in readlines(FILE_TRANSLATORS, False): if ':' in line: line = line.split(':', 1)[1] line = line.replace('(at)', '@').strip() if line not in translators: translators.append(line) # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('about.ui')) # Set various properties self.ui.dialog_about.set_program_name(APP_NAME) self.ui.dialog_about.set_version(_('Version %s') % APP_VERSION) self.ui.dialog_about.set_comments(APP_DESCRIPTION) self.ui.dialog_about.set_website(APP_URL) self.ui.dialog_about.set_copyright(APP_COPYRIGHT) # Prepare lists for authors and contributors authors = ['%s <%s>' % (APP_AUTHOR, APP_AUTHOR_EMAIL)] contributors = [] for line in readlines(FILE_CONTRIBUTORS, False): contributors.append(line) if len(contributors) > 0: contributors.insert(0, _('Contributors:')) authors.extend(contributors) self.ui.dialog_about.set_authors(authors) self.ui.dialog_about.set_license('\n'.join( readlines(FILE_LICENSE, True))) self.ui.dialog_about.set_translator_credits('\n'.join(translators)) # Retrieve the external resources links # only for GTK+ 3.6.0 and higher if not Gtk.check_version(3, 6, 0): for line in readlines(FILE_RESOURCES, False): resource_type, resource_url = line.split(':', 1) self.ui.dialog_about.add_credit_section( resource_type, (resource_url, )) icon_logo = Pixbuf.new_from_file(FILE_ICON) self.ui.dialog_about.set_logo(icon_logo) self.ui.dialog_about.set_transient_for(parent)
def loadUI(self): """Load the interface UI""" self.ui = GtkBuilderLoader(get_ui_file('main.ui')) 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 label = widget.get_label() if not label: label = widget.get_short_label() widget.set_label(text(label)) widget.set_short_label(label) # Initialize labels for widget in self.ui.get_objects_by_type(Gtk.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 Gtk.HeaderBar self.ui.header_bar.props.title = self.ui.win_main.get_title() self.ui.win_main.set_titlebar(self.ui.header_bar) for button in (self.ui.button_folder_new, self.ui.button_folder_remove, self.ui.button_folder_properties, self.ui.button_files_add, self.ui.button_files_remove, self.ui.button_files_save, self.ui.button_about, ): action = button.get_related_action() icon_name = action.get_icon_name() if preferences.get(preferences.HEADERBARS_SYMBOLIC_ICONS): icon_name += '-symbolic' # Get desired icon size icon_size = (Gtk.IconSize.BUTTON if preferences.get(preferences.HEADERBARS_SMALL_ICONS) else Gtk.IconSize.LARGE_TOOLBAR) button.set_image(Gtk.Image.new_from_icon_name(icon_name, icon_size)) # Remove the button label button.props.label = None # Set the tooltip from the action label button.set_tooltip_text(action.get_label().replace('_', '')) # Set preferences button icon icon_name = self.ui.image_preferences.get_icon_name()[0] if preferences.get(preferences.HEADERBARS_SYMBOLIC_ICONS): icon_name += '-symbolic' self.ui.image_preferences.set_from_icon_name(icon_name, icon_size) # Load settings self.dict_settings_map = { preferences.HEADERBARS_SMALL_ICONS: self.ui.action_preferences_small_icons, preferences.HEADERBARS_SYMBOLIC_ICONS: self.ui.action_preferences_symbolic_icons, preferences.PREFERENCES_SHOW_MISSING: self.ui.action_preferences_show_missing_files } for setting_name, action in self.dict_settings_map.items(): action.set_active(preferences.get(setting_name)) # Connect signals from the glade file to the module functions self.ui.connect_signals(self)
def __init__(self, parent, existing_files): """Prepare the application picker dialog""" # Load the user interface self.ui = GtkBuilderLoader(get_ui_file('application_picker.ui')) self.ui.dialog_application_picker.set_titlebar(self.ui.header_bar) # Prepares the models for the applications self.model_applications = ModelApplications(self.ui.store_applications) self.model_applications.model.set_sort_column_id( self.ui.treeview_column_applications.get_sort_column_id(), Gtk.SortType.ASCENDING) self.ui.filter_applications.set_visible_column( ModelApplications.COL_VISIBLE) # Initialize actions for widget in self.ui.get_objects_by_type(Gtk.Action): # Connect the actions accelerators widget.connect_accelerator() # Set labels label = widget.get_label() if not label: label = widget.get_short_label() widget.set_short_label(text(label)) widget.set_label(text(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('_', '')) # Set various properties self.ui.dialog_application_picker.set_transient_for(parent) set_style_suggested_action(self.ui.button_add) self.selected_applications = None # Set preferences button icon icon_name = self.ui.image_preferences.get_icon_name()[0] if preferences.get(preferences.HEADERBARS_SYMBOLIC_ICONS): icon_name += '-symbolic' # Get desired icon size icon_size = (Gtk.IconSize.BUTTON if preferences.get(preferences.HEADERBARS_SMALL_ICONS) else Gtk.IconSize.LARGE_TOOLBAR) self.ui.image_preferences.set_from_icon_name(icon_name, icon_size) # Load settings self.dict_settings_map = { preferences.APP_PICKER_SHOW_HIDDEN: self.ui.action_show_hidden } for setting_name, action in self.dict_settings_map.items(): action.set_active(preferences.get(setting_name)) # Prepares the applications list for desktop_entry in Gio.app_info_get_all(): try: icon_name = None icon = desktop_entry.get_icon() if isinstance(icon, Gio.ThemedIcon): # From Gio.ThemedIcon get the icon name only icons = desktop_entry.get_icon().get_names() icon_name = icons[0] if icons else None elif isinstance(icon, Gio.FileIcon): # From Gio.FileIcon get the full file name icon_name = icon.get_file().get_parse_name() description = (desktop_entry.get_description() if desktop_entry.get_description() else '') application = ApplicationInfo(desktop_entry.get_id(), desktop_entry.get_name(), description, icon_name, desktop_entry.should_show()) # Skip existing files if application.filename not in existing_files: self.model_applications.add_data(application) except Exception as e: print 'error for', desktop_entry.get_id(), e self.model_applications.set_all_rows_visibility( preferences.get(preferences.APP_PICKER_SHOW_HIDDEN)) # Connect signals from the glade file to the module functions self.ui.connect_signals(self)
def loadUI(self): """Load the interface UI""" self.ui = GtkBuilderLoader(get_ui_file('main.ui')) 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 label = widget.get_label() if not label: label = widget.get_short_label() widget.set_label(text(label)) widget.set_short_label(label) # Initialize labels for widget in self.ui.get_objects_by_type(Gtk.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 Gtk.HeaderBar self.ui.header_bar.props.title = self.ui.win_main.get_title() self.ui.win_main.set_titlebar(self.ui.header_bar) for button in ( self.ui.button_folder_new, self.ui.button_folder_remove, self.ui.button_folder_properties, self.ui.button_files_add, self.ui.button_files_remove, self.ui.button_files_save, self.ui.button_about, ): action = button.get_related_action() icon_name = action.get_icon_name() if preferences.get(preferences.HEADERBARS_SYMBOLIC_ICONS): icon_name += '-symbolic' # Get desired icon size icon_size = (Gtk.IconSize.BUTTON if preferences.get(preferences.HEADERBARS_SMALL_ICONS) else Gtk.IconSize.LARGE_TOOLBAR) button.set_image(Gtk.Image.new_from_icon_name( icon_name, icon_size)) # Remove the button label button.props.label = None # Set the tooltip from the action label button.set_tooltip_text(action.get_label().replace('_', '')) # Set preferences button icon icon_name = self.ui.image_preferences.get_icon_name()[0] if preferences.get(preferences.HEADERBARS_SYMBOLIC_ICONS): icon_name += '-symbolic' self.ui.image_preferences.set_from_icon_name(icon_name, icon_size) # Load settings self.dict_settings_map = { preferences.HEADERBARS_SMALL_ICONS: self.ui.action_preferences_small_icons, preferences.HEADERBARS_SYMBOLIC_ICONS: self.ui.action_preferences_symbolic_icons, preferences.PREFERENCES_SHOW_MISSING: self.ui.action_preferences_show_missing_files } for setting_name, action in self.dict_settings_map.items(): action.set_active(preferences.get(setting_name)) # Connect signals from the glade file to the module functions self.ui.connect_signals(self)