def delete_wallpaper(self): untitled_theme = theme_manager.get_untitled_theme() for item in self.items: if item.is_tick: self.theme.remove_option("system_wallpaper", item.image_path.split("/")[-1]) self.theme.remove_option("user_wallpaper", item.image_path) if untitled_theme: untitled_theme.remove_option( "system_wallpaper", item.image_path.split("/")[-1]) untitled_theme.remove_option("user_wallpaper", item.image_path) event_manager.emit("delete-wallpaper-link", item.image_path) self.theme.save() if untitled_theme: untitled_theme.save() event_manager.emit("update-theme", self.theme) self.set_theme(self.theme)
def set_option(self, option, value): """ Set an option (in ``section/key`` syntax) to the specified value :param option: the full path to an option :type option: string :param value: the value the option should be assigned :type value: any """ value = self._val_to_str(value) splitvals = option.split('/') section, key = "/".join(splitvals[:-1]), splitvals[-1] try: self.set(section, key, value) except NoSectionError: self.add_section(section) self.set(section, key, value) self._dirty = True section = section.replace('/', '_') event_manager.emit('option_set', option, self) event_manager.emit('%s_option_set' % section, option, self)
def click_cb(self): event_manager.emit('dsl-connection-start', self.connection) if net_manager.wired_device: device_path = net_manager.wired_device.object_path nm_module.nmclient.activate_connection_async(self.connection.object_path, device_path, "/")
def icon_item_button_press(self, x, y): ''' Handle button-press event. This is IconView interface, you should implement it. ''' event_manager.emit("add-local-wallpapers", self.theme)
def __sync_untitle_theme(self, theme): self.untitled_theme.clear_system_wallpapers() self.untitled_theme.add_system_wallpapers(theme.get_system_wallpapers()) self.untitled_theme.clear_user_wallpapers() self.untitled_theme.add_user_wallpapers(theme.get_user_wallpapers()) self.untitled_theme.save() event_manager.emit("update-theme", self.untitled_theme)
def download_finish(self, obj, data): event_manager.emit("download-finish", obj) self.progress_buffer.progress = 100 self.status_text = "下载完成" self.emit_request_redraw() if self.finish_callback: self.finish_callback(self)
def icon_item_button_press(self, x, y): ''' Handle button-press event. This is IconView interface, you should implement it. ''' self.toggle_tick() event_manager.emit("select-delete-wallpaper", self)
def on_library_location_removed(self, obj, gfile): file_path = gfile.get_path() items = filter(lambda item: item.image_path.startswith(file_path), self.items) if items: event_manager.emit("wallpapers-deleted", map(lambda item: item.image_path, items)) self.delete_items(items)
def icon_item_button_press(self, x, y): ''' Handle button-press event. This is IconView interface, you should implement it. ''' self.is_tick = not self.is_tick event_manager.emit("select-select-wallpaper", self) self.emit_redraw_request()
def icon_item_lost_focus(self): ''' Lost focus. This is IconView interface, you should implement it. ''' self.hover_flag = False self.emit_redraw_request() event_manager.emit("hide-text", None)
def icon_item_motion_notify(self, x, y): ''' Handle `motion-notify-event` signal. This is IconView interface, you should implement it. ''' self.hover_flag = True self.emit_redraw_request() event_manager.emit("text", self.name)
def create_new_theme(self, name, item): if name == "": return if theme_manager.is_theme_exist(name): return new_theme = theme_manager.create_new_theme(name, item.theme) new_theme.set_editable(True) event_manager.emit("create-new-theme", new_theme)
def __on_download_finish(self, name, obj, data): if self.image_object.big_url != data.url: return self.is_loop = False self.is_downloaded = True self.emit_redraw_request() self.image_path = self.image_object.get_save_path() event_manager.emit("add-download-wallpapers", [self.image_object.get_save_path()]) event_manager.emit("apply-download-wallpaper", self.image_object.get_save_path())
def icon_item_double_click(self, x, y): ''' Handle double click event. This is IconView interface, you should implement it. ''' self.__is_double_click = True self.is_tick = True self.emit_redraw_request() event_manager.emit("select-wallpaper", self) self.do_apply_wallpaper()
def delete(self): for item in self.items: if item.is_tick: if item.image_path.startswith(self.system_wallpapper_dir): self.delete_items([item]) add_system_deletes([item.image_path]) else: os.remove(item.image_path) event_manager.emit("delete-downloaded-wallpaper", item) self.queue_draw()
def icon_item_button_press(self, x, y): ''' Handle button-press event. This is IconView interface, you should implement it. ''' self.emit_redraw_request() # if self.is_downloaded: # is_download may be set to True even if download failed actually. if os.path.exists(self.image_object.get_save_path()): event_manager.emit("apply-wallpaper", self) event_manager.emit("download-images", [self.image_object])
def save_changes(self, connection): if isinstance(connection, NMRemoteConnection): connection.update() else: connection = nm_module.nm_remote_settings.new_connection_finish(connection.settings_dict, 'vpn') Dispatcher.emit("connection-replace", connection) Dispatcher.emit("vpn-redraw") net_manager.emit_vpn_setting_change(connection) Dispatcher.to_main_page() event_manager.emit("update-vpn-id", connection.get_setting("connection").id, self.spec_connection)
def __is_single_click(self, item): if self.__is_double_click: item.do_double_click() if self.__single_click_item: self.set_highlight(self.__single_click_item) else: self.__single_click_item = item event_manager.emit("clear-systemview-highlight", item.theme) theme_manager.apply_theme(item.theme) self.__sync_untitle_theme(item.theme) self.status_box.set_status(_("Changed User Theme to %s") % item.theme.get_name()) self.__is_double_click = False
def save_changes(self, connection): if isinstance(connection, NMRemoteConnection): connection.update() else: connection = nm_module.nm_remote_settings.new_connection_finish( connection.settings_dict, 'vpn') Dispatcher.emit("connection-replace", connection) Dispatcher.emit("vpn-redraw") net_manager.emit_vpn_setting_change(connection) Dispatcher.to_main_page() event_manager.emit("update-vpn-id", connection.get_setting("connection").id, self.spec_connection)
def save_changes(self, connection): if connection.check_setting_finish(): if isinstance(connection, NMRemoteConnection): #print "before update", TypeConvert.dbus2py(connection.settings_dict) connection.update() #print "after update", TypeConvert.dbus2py(connection.settings_dict) else: connection = nm_module.nm_remote_settings.new_connection_finish(connection.settings_dict, 'lan') Dispatcher.emit("connection-replace", connection) Dispatcher.emit("dsl-redraw") Dispatcher.to_main_page() event_manager.emit("update-dsl-id", connection.get_setting("connection").id, self.spec_connection)
def set_theme_tick(self, value): untitled_theme = theme_manager.get_untitled_theme() if self.readonly: self.theme.set_system_wallpaper_status(self.image_path, value) if untitled_theme: untitled_theme.set_system_wallpaper_status(self.image_path, value) else: if self.theme == None: return self.theme.set_user_wallpaper_status(self.image_path, value) if untitled_theme: untitled_theme.set_user_wallpaper_status(self.image_path, value) event_manager.emit("update-theme", self.theme)
def __init__(self, monitor_dir): gtk.VBox.__init__(self) self.set_spacing(10) self.select_view = SelectView(monitor_dir, filter_dir=["deepin-wallpapers"], add_system=False) self.select_view.connect("items-change", self.select_view_item_changed) self.select_view.connect("double-click-item", self.select_view_double_clicked) self.select_view_sw = self.select_view.get_scrolled_window() label_box = gtk.VBox() no_favorites_label = Label(_("Your Favorites folder is empty.")) align_up = get_align(align=(0.5, 0.5, 0, 0)) align_up.add(no_favorites_label) go_to_local_action = ActionButton( _("Add from Local Pictures"), lambda: event_manager.emit("switch-to-local-pictures", self)) align_down = get_align(align=(0.5, 0.5, 0, 0)) align_down.add(go_to_local_action) label_box.pack_start(align_up, False, False) label_box.pack_start(align_down, False, False) self.no_favorites_align = gtk.Alignment(0.5, 0.5, 0, 0) self.no_favorites_align.add(label_box) self.notice_label = Label("") set_wallpapper_button = Button(_("Set as wallpaper")) set_wallpapper_button.connect("clicked", self.__on_set_as_wallpapper) delete_button = Button(_("Delete")) delete_button.connect("clicked", self.__on_delete) self.button_box = gtk.HBox(spacing=10) self.button_box.pack_start(set_wallpapper_button, False, False) self.button_box.pack_start(delete_button, False, False) self.control_box = gtk.HBox() self.control_box.set_size_request(-1, 20) self.control_box.pack_start(self.notice_label, False, False) self.control_align = gtk.Alignment() self.control_align.set(0.5, 0.5, 1, 1) self.control_align.set_padding(0, 5, 20, 10) self.control_align.add(self.control_box) if len(self.select_view.items) == 0: self.pack_start(self.no_favorites_align, True, True) else: self.pack_start(self.select_view_sw, True, True) self.pack_end(self.control_align, False, True) event_manager.add_callback("select-select-wallpaper", self.__on_select_select_wallpaper) self.timeout_notice_hide_id = None
def set_theme_tick(self, value): untitled_theme = theme_manager.get_untitled_theme() if self.readonly: self.theme.set_system_wallpaper_status(self.image_path, value) if untitled_theme: untitled_theme.set_system_wallpaper_status( self.image_path, value) else: if self.theme == None: return self.theme.set_user_wallpaper_status(self.image_path, value) if untitled_theme: untitled_theme.set_user_wallpaper_status( self.image_path, value) event_manager.emit("update-theme", self.theme)
def _set_direct(self, option, value): """ Sets the option directly to the value, only for use in copying settings. :param option: the option path :type option: string :param value: the value to set :type value: any """ splitvals = option.split('/') section, key = "/".join(splitvals[:-1]), splitvals[-1] try: self.set(section, key, value) except NoSectionError: self.add_section(section) self.set(section, key, value) event_manager.emit('option_set', self, option)
def __init__(self, monitor_dir): gtk.VBox.__init__(self) self.set_spacing(10) self.select_view = SelectView(monitor_dir, filter_dir=["deepin-wallpapers"], add_system=False) self.select_view.connect("items-change", self.select_view_item_changed) self.select_view.connect("double-click-item", self.select_view_double_clicked) self.select_view_sw = self.select_view.get_scrolled_window() label_box = gtk.VBox() no_favorites_label = Label(_("Your Favorites folder is empty.")) align_up = get_align(align=(0.5, 0.5, 0, 0)) align_up.add(no_favorites_label) go_to_local_action = ActionButton(_("Add from Local Pictures"), lambda: event_manager.emit("switch-to-local-pictures", self)) align_down = get_align(align=(0.5, 0.5, 0, 0)) align_down.add(go_to_local_action) label_box.pack_start(align_up, False, False) label_box.pack_start(align_down, False, False) self.no_favorites_align = gtk.Alignment(0.5, 0.5, 0, 0) self.no_favorites_align.add(label_box) self.notice_label = Label("") set_wallpapper_button = Button(_("Set as wallpaper")) set_wallpapper_button.connect("clicked", self.__on_set_as_wallpapper) delete_button = Button(_("Delete")) delete_button.connect("clicked", self.__on_delete) self.button_box = gtk.HBox(spacing=10) self.button_box.pack_start(set_wallpapper_button, False, False) self.button_box.pack_start(delete_button, False, False) self.control_box = gtk.HBox() self.control_box.set_size_request(-1, 20) self.control_box.pack_start(self.notice_label, False, False) self.control_align = gtk.Alignment() self.control_align.set(0.5, 0.5, 1, 1) self.control_align.set_padding(0, 5, 20, 10) self.control_align.add(self.control_box) if len(self.select_view.items) == 0: self.pack_start(self.no_favorites_align, True, True) else: self.pack_start(self.select_view_sw, True, True) self.pack_end(self.control_align, False, True) event_manager.add_callback("select-select-wallpaper", self.__on_select_select_wallpaper) self.timeout_notice_hide_id = None
def message_handler(self, *message): (message_type, message_content) = message if message_type == "click_crumb": (crumb_index, crumb_label) = message_content elif message_type == "show_again": self.module_frame.send_module_info() elif message_type == "switch-theme": theme = None for item in theme_manager.get_user_themes() + theme_manager.get_system_themes(): if item.get_name() == message_content: theme = item break if theme: print "DEBUG", theme event_manager.emit("theme-detail", theme) elif message_type == "exit": self.module_frame.exit()
def delete_wallpaper(self): untitled_theme = theme_manager.get_untitled_theme() for item in self.items: if item.is_tick: self.theme.remove_option("system_wallpaper", item.image_path.split("/")[-1]) self.theme.remove_option("user_wallpaper", item.image_path) if untitled_theme: untitled_theme.remove_option("system_wallpaper", item.image_path.split("/")[-1]) untitled_theme.remove_option("user_wallpaper", item.image_path) event_manager.emit("delete-wallpaper-link", item.image_path) self.theme.save() if untitled_theme: untitled_theme.save() event_manager.emit("update-theme", self.theme) self.set_theme(self.theme)
def __on_delete(self, widget): event_manager.emit("switch-to-deletepage", self.theme)
def click_cb(self): event_manager.emit('dsl-connection-start', self.connection) if net_manager.wired_device: device_path = net_manager.wired_device.object_path nm_module.nmclient.activate_connection_async( self.connection.object_path, device_path, "/")
def on_download_finish(self, item): self.delete_items([item]) self.emit_task_number() event_manager.emit("download-image-finish", item.image_object.get_save_path())
def emit_task_number(self): event_manager.emit("downloading-tasks-number", len(self.get_items()))
def emit_download(self): download_items = self.items if download_items: image_items = map(lambda item: item.image_object, download_items) event_manager.emit("download-images", image_items)
def __is_single_click(self): if not self.__is_double_click: self.toggle_tick() event_manager.emit("select-wallpaper", self) self.__is_double_click = False
def __on_double_click_item(self, widget, item, x, y): self.__is_double_click = True event_manager.emit("theme-detail", item.theme)
def download_start(self, obj, data): event_manager.emit("download-start", obj) self.status_text = "开始下载" self.emit_request_redraw()
def __on_single_click_item(self, widget, item, x, y): self.set_highlight(item) event_manager.emit("clear-userview-highlight", item.theme) theme_manager.apply_theme(item.theme) self.__sync_untitle_theme(item.theme) self.status_box.set_status(_("Changed System Theme to %s") % item.theme.get_name())
def cancel(self): event_manager.emit("cancel", None)
def on_add_wallpapers(self, widget): event_manager.emit("add-local-wallpapers", None)
def on_add_wallpapers(self, name, obj, image_paths): filter_images = filter(lambda image: not self.is_exists(image), image_paths) if filter_images: self.add_user_wallpapers(filter_images, save=True) event_manager.emit("update-theme", self.theme)
def __on_back(self, widget): event_manager.emit("back-to-detailpage", self.theme)
def emit_add_wallpapers(self): tick_items = filter(lambda item: item.is_tick, self.items) if tick_items: image_paths = map(lambda item: item.image_path, tick_items) event_manager.emit("add-wallpapers", image_paths)
def fetch_failed(self): event_manager.emit("fetch-failed", None) pass