コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 def on_entry_name_changed(self, widget):
     """Check if the folder already exists"""
     name = self.ui.entry_name.get_text().strip()
     existing = (name in self.existing_folders and name != self.folder_name)
     # If a folder with the specified name already exists
     # then disable the creation and show an icon
     self.ui.action_create.set_sensitive(bool(name) and not existing)
     self.ui.entry_name.set_icon_from_icon_name(
         Gtk.EntryIconPosition.SECONDARY,
         'dialog-error' if existing else None)
     self.ui.entry_name.set_icon_tooltip_text(
         Gtk.EntryIconPosition.SECONDARY,
         text('A folder with that name already exists')
         if existing else None)
コード例 #5
0
 def on_entry_name_changed(self, widget):
     """Check if the folder already exists"""
     name = self.ui.entry_name.get_text().strip()
     existing = (name in self.existing_folders and name != self.folder_name)
     # If a folder with the specified name already exists
     # then disable the creation and show an icon
     self.ui.action_create.set_sensitive(bool(name) and not existing)
     self.ui.entry_name.set_icon_from_icon_name(
         Gtk.EntryIconPosition.SECONDARY,
         'dialog-error' if existing else None)
     self.ui.entry_name.set_icon_tooltip_text(
         Gtk.EntryIconPosition.SECONDARY,
         text('A folder with that name already exists')
         if existing else None)
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
0
#  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
##

import gettext
import locale

import gnome_appfolders_manager.requires

from gnome_appfolders_manager.functions import store_message, text, _
from gnome_appfolders_manager.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
for message in ('_Create', '_Remove', '_Save', '_Close', 'Show _Hidden Files',
                'A folder with that name already exists', 'General',
                'Preferences'):
    text(message=message, gtk30=True)
store_message('Folder Name:', '%s:' % text(message='Folder Name', gtk30=True))
store_message('_Files:', '_%s:' % text(message='Files', gtk30=True))
store_message('_Create Folder', text(message='Create Folder', gtk30=True))
store_message('_Properties', text(message='Properties', gtk30=True))

# With domain context
for message in ('_New', '_Delete', '_About', '_Close', '_Quit'):
    text(message=message, gtk30=True, context='Stock label')
store_message('Quit', text(message='_Quit', gtk30=True).replace('_', ''))
コード例 #9
0
#  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
##

import gettext
import locale

import gnome_appfolders_manager.requires

from gnome_appfolders_manager.functions import store_message, text, _
from gnome_appfolders_manager.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
for message in ('_Create', '_Remove', '_Save', '_Close', 'Show _Hidden Files',
                'A folder with that name already exists',
                'General', 'Preferences'):
    text(message=message, gtk30=True)
store_message('Folder Name:', '%s:' % text(message='Folder Name', gtk30=True))
store_message('_Files:', '_%s:' % text(message='Files', gtk30=True))
store_message('_Create Folder', text(message='Create Folder', gtk30=True))
store_message('_Properties', text(message='Properties', gtk30=True))

# With domain context
for message in ('_New', '_Delete', '_About', '_Close', '_Quit'):
    text(message=message, gtk30=True, context='Stock label')
store_message('Quit', text(message='_Quit', gtk30=True).replace('_', ''))
コード例 #10
0
 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)
コード例 #11
0
 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)