本文整理汇总了Python中gi.repository.SugarExt类的典型用法代码示例。如果您正苦于以下问题:Python SugarExt类的具体用法?Python SugarExt怎么用?Python SugarExt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SugarExt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __copy_to_clipboard_cb
def __copy_to_clipboard_cb(self, menu_item):
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
uid_list = self._get_uid_list_cb()
if len(uid_list) == 1:
uid = uid_list[0]
file_path = model.get_file(uid)
if not file_path or not os.path.exists(file_path):
logging.warn('Entries without a file cannot be copied.')
self.emit('volume-error',
_('Entries without a file cannot be copied.'),
_('Warning'))
return
# XXX SL#4307 - until set_with_data bindings are fixed upstream
if hasattr(clipboard, 'set_with_data'):
clipboard.set_with_data(
[Gtk.TargetEntry.new('text/uri-list', 0, 0)],
self.__clipboard_get_func_cb,
self.__clipboard_clear_func_cb,
None)
else:
SugarExt.clipboard_set_with_data(
clipboard,
[Gtk.TargetEntry.new('text/uri-list', 0, 0)],
self.__clipboard_get_func_cb,
self.__clipboard_clear_func_cb,
None)
示例2: __realize_cb
def __realize_cb(self, window):
xid = window.get_window().get_xid()
SugarExt.wm_set_bundle_id(xid, _BUNDLE_ID)
activity_id = activityfactory.create_activity_id()
SugarExt.wm_set_activity_id(xid, str(activity_id))
self.disconnect(self._realized_sid)
self._realized_sid = None
示例3: _window_opened_cb
def _window_opened_cb(self, screen, window):
"""Handle the callback for the 'window opened' event.
Most activities will register 2 windows during
their lifetime: the launcher window, and the 'main'
app window.
When the main window appears, we send a signal to
the launcher window to close.
Some activities (notably non-native apps) open several
windows during their lifetime, switching from one to
the next as the 'main' window. We use a stack to track
them.
"""
if window.get_window_type() == Wnck.WindowType.NORMAL or \
window.get_window_type() == Wnck.WindowType.SPLASHSCREEN:
home_activity = None
xid = window.get_xid()
activity_id = SugarExt.wm_get_activity_id(xid)
service_name = SugarExt.wm_get_bundle_id(xid)
if service_name:
registry = get_registry()
activity_info = registry.get_bundle(service_name)
else:
activity_info = None
if activity_id:
home_activity = self.get_activity_by_id(activity_id)
display = Gdk.Display.get_default()
gdk_window = GdkX11.X11Window.foreign_new_for_display(display,
xid)
gdk_window.set_decorations(0)
window.maximize()
if not home_activity:
logging.debug('first window registered for %s', activity_id)
color = self._shared_activities.get(activity_id, None)
home_activity = Activity(activity_info, activity_id,
color, window)
self._add_activity(home_activity)
else:
logging.debug('window registered for %s', activity_id)
home_activity.add_window(window)
if window.get_window_type() != Wnck.WindowType.SPLASHSCREEN \
and \
home_activity.get_launch_status() == Activity.LAUNCHING:
self.emit('launch-completed', home_activity)
startup_time = time.time() - home_activity.get_launch_time()
logging.debug('%s launched in %f seconds.',
activity_id, startup_time)
if self._active_activity is None:
self._set_active_activity(home_activity)
示例4: __realize_cb
def __realize_cb(self, window):
display_name = Gdk.Display.get_default().get_name()
if ':' in display_name:
# X11 for sure; this only works in X11
xid = window.get_window().get_xid()
SugarExt.wm_set_bundle_id(xid, self.get_bundle_id())
SugarExt.wm_set_activity_id(xid, str(self._activity_id))
elif display_name is 'Broadway':
# GTK3's HTML5 backend
# This is needed so that the window takes the whole browser window
self.maximize()
示例5: __init__
def __init__(self):
GObject.GObject.__init__(self)
address = SugarExt.xsmp_init()
os.environ['SESSION_MANAGER'] = address
SugarExt.xsmp_run()
self.session = SugarExt.Session.create_global()
self._shell_model = shell.get_model()
self._shutdown_tries = 0
self._logout_mode = None
示例6: tearDown
def tearDown(self):
client = GConf.Client.get_default()
if self._save_view_icons is None:
client.unset(_VIEW_KEY)
else:
SugarExt.gconf_client_set_string_list(client,
_VIEW_KEY,
self._save_view_icons)
if self._save_favorite_icons is None:
client.unset(_FAVORITE_KEY)
else:
SugarExt.gconf_client_set_string_list(client,
_FAVORITE_KEY,
self._save_favorite_icons)
示例7: _check_gconf_settings
def _check_gconf_settings():
client = GConf.Client.get_default()
# Zendesk
client.set_string('/desktop/sugar/services/zendesk/url',
'https://oneedu.zendesk.com')
client.set_string('/desktop/sugar/services/zendesk/token',
'eG8tc3VwcG9ydEBsYXB0b3Aub3JnLmF1L3Rva2VuOlZTaWM4'
'TThZbjZBRTJkMWxYNkFGbFhkZzUxSjlJSHFUQ01DYzNjOHY=')
try:
SugarExt.gconf_client_set_string_list(
client, '/desktop/sugar/services/zendesk/fields',
['21891880', '21729904', '21729914'])
except Exception as e:
_logger.error('Could not set zendesk fields: %s' % e)
示例8: set_option_group
def set_option_group(self, option_group):
"""Sets the supplied option for switching keyboard group"""
#XXX: Merge, not overwrite previous options
if not option_group:
options = ['']
elif isinstance(option_group, list):
options = option_group
else:
options = [option_group]
# FIXME, gconf_client_set_list not introspectable #681433
# self._gconf_client.set_list(_OPTIONS_KEY, GConf.ValueType.STRING,
# options)
SugarExt.gconf_client_set_string_list(self._gconf_client,
_OPTIONS_KEY, options)
self._configrec.set_options(options)
self._configrec.activate(self._engine)
示例9: _put_in_clipboard
def _put_in_clipboard(self):
logging.debug('ClipboardIcon._put_in_clipboard')
if self._cb_object.get_percent() < 100:
raise ValueError('Object is not complete, cannot be put into the'
' clipboard.')
targets = self._get_targets()
if targets:
x_clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
# XXX SL#4307 - until set_with_data bindings are fixed upstream
if hasattr(x_clipboard, 'set_with_data'):
stored = x_clipboard.set_with_data(
targets,
self._clipboard_data_get_cb,
self._clipboard_clear_cb,
targets)
else:
stored = SugarExt.clipboard_set_with_data(
x_clipboard,
targets,
self._clipboard_data_get_cb,
self._clipboard_clear_cb,
targets)
if not stored:
logging.error('GtkClipboard.set_with_data failed!')
else:
self.owns_clipboard = True
示例10: set_layouts
def set_layouts(self, layouts):
"""Sets the supplied keyboard layouts (with variants)"""
if layouts is None or not layouts:
return
# FIXME, gconf_client_set_list not introspectable #681433
# self._gconf_client.set_list(_LAYOUTS_KEY, GConf.ValueType.STRING,
# layouts)
SugarExt.gconf_client_set_string_list(self._gconf_client,
_LAYOUTS_KEY, layouts)
layouts_list = []
variants_list = []
for layout in layouts:
layouts_list.append(layout.split('(')[0])
variants_list.append(layout.split('(')[1][:-1])
self._configrec.set_layouts(layouts_list)
self._configrec.set_variants(variants_list)
self._configrec.activate(self._engine)
示例11: get_for_file
def get_for_file(file_name):
if file_name.startswith('file://'):
file_name = file_name[7:]
file_name = os.path.realpath(file_name)
mime_type = SugarExt.mime_get_mime_type_for_file(file_name, None)
if mime_type == 'application/octet-stream':
if _file_looks_like_text(file_name):
return 'text/plain'
else:
return 'application/octet-stream'
return mime_type
示例12: shutdown_completed
def shutdown_completed(self):
if self._logout_mode != self.MODE_LOGOUT:
bus = dbus.SystemBus()
if have_systemd():
try:
proxy = bus.get_object('org.freedesktop.login1',
'/org/freedesktop/login1')
pm = dbus.Interface(proxy,
'org.freedesktop.login1.Manager')
if self._logout_mode == self.MODE_SHUTDOWN:
pm.PowerOff(False)
elif self._logout_mode == self.MODE_REBOOT:
pm.Reboot(True)
except:
logging.exception('Can not stop sugar')
self.session.cancel_shutdown()
return
else:
CONSOLEKIT_DBUS_PATH = '/org/freedesktop/ConsoleKit/Manager'
try:
proxy = bus.get_object('org.freedesktop.ConsoleKit',
CONSOLEKIT_DBUS_PATH)
pm = dbus.Interface(proxy,
'org.freedesktop.ConsoleKit.Manager')
if self._logout_mode == self.MODE_SHUTDOWN:
pm.Stop()
elif self._logout_mode == self.MODE_REBOOT:
pm.Restart()
except:
logging.exception('Can not stop sugar')
self.session.cancel_shutdown()
return
SugarExt.xsmp_shutdown()
Gtk.main_quit()
示例13: _check_gconf_settings
def _check_gconf_settings():
from gi.repository import GConf
client = GConf.Client.get_default()
# Training server
client.set_string(
'/desktop/sugar/services/training/url',
'https://training.one-education.org/training/report ')
client.set_string('/desktop/sugar/services/training/api_key',
'SbCeK4nH8dpQJsHNn9djza9g')
# Zendesk
client.set_string('/desktop/sugar/services/zendesk/url',
'https://oneedu1392860248.zendesk.com')
client.set_string('/desktop/sugar/services/zendesk/token',
'eG8tc3VwcG9ydEBsYXB0b3Aub3JnLmF1L3Rva2VuOjdHRkV5'
'STF2MFNRVzJyYmdFVXFFUWRpOE1Cc1I0NGdHVURhTWg2QWU=')
try:
SugarExt.gconf_client_set_string_list(
client, '/desktop/sugar/services/zendesk/fields',
['21765610', '21605694', '21765620'])
except Exception as e:
_logger.error('Could not set zendesk fields: %s' % e)
示例14: save_to_gconf
def save_to_gconf(self, icon=False, name=False):
view_icons = []
favorite_icons = []
favorite_names = []
for button in self._view_buttons:
view_icons.append(self._view_icons[button])
favorite_icons.append(self._favorite_icons[button])
if self.favorite_names_enabled:
favorite_names.append(self._favorite_names[button])
client = GConf.Client.get_default()
SugarExt.gconf_client_set_string_list(client,
_FAVORITE_KEY,
favorite_icons)
SugarExt.gconf_client_set_string_list(client,
_VIEW_KEY,
view_icons)
if self.favorite_names_enabled:
SugarExt.gconf_client_set_string_list(client,
_FAVORITE_NAME_KEY,
favorite_names)
if icon:
for x in self.activity._alerts:
self.activity.remove_alert(x)
alert = NotifyAlert(5)
alert.props.title = _('Icon')
alert.props.msg = _('For see icons, restart sugar is needed.')
self.activity.add_alert(alert)
alert.connect('response',
lambda x, y: self.activity.remove_alert(x))
if name:
for x in self.activity._alerts:
self.activity.remove_alert(x)
alert = NotifyAlert(5)
alert.props.title = _('View Name')
alert.props.msg = _('For seeing View name changes, '
'restarting Sugar is required.')
self.activity.add_alert(alert)
alert.connect('response',
lambda x, y: self.activity.remove_alert(x))
示例15: _realize_cb
def _realize_cb(self, window):
xid = window.get_window().get_xid()
SugarExt.wm_set_bundle_id(xid, self._bundle_id)
SugarExt.wm_set_activity_id(xid, str(self._activity_id))