def setup(self): self._fonts_cache = pycam.Utils.FontCache.FontCache(get_font_dir(), core=self.core) self.core.set("fonts", self._fonts_cache) # "font dialog" window if self.gui: import gtk self._gtk = gtk self.font_dialog_window = self.gui.get_object("FontDialog") window = self.font_dialog_window hide_window = lambda *args: \ self.toggle_font_dialog_window(state=False) self._gtk_handlers = [ (window, "delete-event", hide_window), (window, "destroy", hide_window), (self.gui.get_object("FontDialogCancel"), "clicked", hide_window), (self.gui.get_object("FontDialogApply"), "clicked", self.import_from_font_dialog), (self.gui.get_object("FontDialogSave"), "clicked", self.export_from_font_dialog), (self.gui.get_object("FontDialogCopy"), "clicked", self.copy_font_dialog_to_clipboard), (self.gui.get_object("FontDialogInputBuffer"), "changed", self.update_font_dialog_preview), (self.gui.get_object("FontDialogPreview"), "configure_event", self.update_font_dialog_preview), (self.gui.get_object("FontDialogPreview"), "expose_event", self.update_font_dialog_preview) ] for objname in ("FontSideSkewValue", "FontCharacterSpacingValue", "FontLineSpacingValue"): obj = self.gui.get_object(objname) # set default value before connecting the change-handler if objname != "FontSideSkewValue": obj.set_value(1.0) self._gtk_handlers.append( (obj, "value-changed", self.update_font_dialog_preview)) for objname in ("FontTextAlignLeft", "FontTextAlignCenter", "FontTextAlignRight"): self._gtk_handlers.append( (self.gui.get_object(objname), "toggled", self.update_font_dialog_preview)) # use global key accel map font_action = self.gui.get_object("ShowFontDialog") self.register_gtk_accelerator("fonts", font_action, "<Control><Shift>t", "ShowFontDialog") self._gtk_handlers.append( (font_action, "activate", self.toggle_font_dialog_window)) self.core.register_ui("edit_menu", "ShowFontDialogSeparator", None, 55) self.core.register_ui("edit_menu", "ShowFontDialog", font_action, 60) # store window position self._font_dialog_window_visible = False self._font_dialog_window_position = None self.font_selector = None self.register_gtk_handlers(self._gtk_handlers) return True
def setup(self): self._fonts_cache = pycam.Utils.FontCache.FontCache(get_font_dir(), core=self.core) self.core.set("fonts", self._fonts_cache) # "font dialog" window if self.gui: import gtk self._gtk = gtk self.font_dialog_window = self.gui.get_object("FontDialog") window = self.font_dialog_window hide_window = lambda *args: \ self.toggle_font_dialog_window(state=False) self._gtk_handlers = [(window, "delete-event", hide_window), (window, "destroy", hide_window), (self.gui.get_object("FontDialogCancel"), "clicked", hide_window), (self.gui.get_object("FontDialogApply"), "clicked", self.import_from_font_dialog), (self.gui.get_object("FontDialogSave"), "clicked", self.export_from_font_dialog), (self.gui.get_object("FontDialogCopy"), "clicked", self.copy_font_dialog_to_clipboard), (self.gui.get_object("FontDialogInputBuffer"), "changed", self.update_font_dialog_preview), (self.gui.get_object("FontDialogPreview"), "configure_event", self.update_font_dialog_preview), (self.gui.get_object("FontDialogPreview"), "expose_event", self.update_font_dialog_preview)] for objname in ("FontSideSkewValue", "FontCharacterSpacingValue", "FontLineSpacingValue"): obj = self.gui.get_object(objname) # set default value before connecting the change-handler if objname != "FontSideSkewValue": obj.set_value(1.0) self._gtk_handlers.append((obj, "value-changed", self.update_font_dialog_preview)) for objname in ("FontTextAlignLeft", "FontTextAlignCenter", "FontTextAlignRight"): self._gtk_handlers.append((self.gui.get_object(objname), "toggled", self.update_font_dialog_preview)) # use global key accel map font_action = self.gui.get_object("ShowFontDialog") self.register_gtk_accelerator("fonts", font_action, "<Control><Shift>t", "ShowFontDialog") self._gtk_handlers.append((font_action, "activate", self.toggle_font_dialog_window)) self.core.register_ui("edit_menu", "ShowFontDialogSeparator", None, 55) self.core.register_ui("edit_menu", "ShowFontDialog", font_action, 60) # store window position self._font_dialog_window_visible = False self._font_dialog_window_position = None self.font_selector = None self.register_gtk_handlers(self._gtk_handlers) return True