def make_audiobox(self, obj, property, width): image_file = os.path.join(Globals.pwd, theme.AUDIO_CHOOSE) if not os.path.exists(image_file): logging.debug("cannot find %s" % image_file) return hippo.CanvasBox() surface = cairo.ImageSurface.create_from_png(image_file) preview_sound = hippo.CanvasImage(image=surface, xalign=hippo.ALIGNMENT_START, yalign=hippo.ALIGNMENT_CENTER) preview_sound.connect("button-press-event", self.__do_clicked_preview_sound, obj, property) if hasattr(obj, property) and getattr(obj, property) != None: sound_name = getattr(obj, property) else: sound_name = _("Click to choose a sound") choose_sound = hippo.CanvasText(text=sound_name, xalign=hippo.ALIGNMENT_START) choose_sound.connect("button-press-event", self.__do_clicked_choose_sound, obj, property) sound_box = RoundBox() sound_box.props.padding = 2 sound_box.props.spacing = 10 sound_box.props.box_width = width sound_box.props.border = theme.BORDER_WIDTH_CONTROL / 2 sound_box.props.border_color = theme.COLOR_DARK_GREEN.get_int() sound_box.props.background_color = theme.COLOR_WHITE.get_int() sound_box.props.orientation = hippo.ORIENTATION_HORIZONTAL sound_box.props.xalign = hippo.ALIGNMENT_START sound_box.set_clickable(True) sound_box.append(preview_sound) sound_box.append(choose_sound) deglitch_box = hippo.CanvasBox(xalign=hippo.ALIGNMENT_START, box_width=width) deglitch_box.append(sound_box) return deglitch_box
def make_listrow(self, contents=None, *args): list_row = RoundBox() list_row.props.border = 0 # properties not being set properly by constructor list_row.props.padding = theme.DEFAULT_PADDING #list_row.props.padding_right=0 list_row.props.background_color = self.color_listrow if contents is not None: list_row.append(contents, *args) return list_row
def make_listrow(self, contents=None, *args): list_row = RoundBox() list_row.props.border = 0 # properties not being set properly by constructor list_row.props.padding = theme.DEFAULT_PADDING # list_row.props.padding_right=0 list_row.props.background_color = self.color_listrow if contents is not None: list_row.append(contents, *args) return list_row
def __textview(self, text, width=300, height=-1, editable=True, multiline=False): textview = gtk.TextView() textview.get_buffer().set_text(text) # control props textview.set_wrap_mode(gtk.WRAP_WORD) textview.modify_base(gtk.STATE_NORMAL, theme.COLOR_TEXTBOX.get_gdk_color()) textview.set_editable(editable) textview.set_cursor_visible(editable) if height == -1: context = textview.create_pango_context() layout = pango.Layout(context) layout.set_text(text[:text.find('\n')]) (w, h) = layout.get_pixel_size() height = h #+ theme.BORDER_WIDTH_CONTROL / 2 # fudge factor - on the XO-1 hardware all known solutions evaporate textview.set_size_request(width, height) textview.set_border_window_size(gtk.TEXT_WINDOW_LEFT, 0) textview.set_border_window_size(gtk.TEXT_WINDOW_RIGHT, 0) textview.set_border_window_size(gtk.TEXT_WINDOW_TOP, 0) textview.set_border_window_size(gtk.TEXT_WINDOW_BOTTOM, 0) textview.show() if editable: # because rounded corners are well... pretty border_box = RoundBox() border_box.control = textview border_box.props.padding = 2 border_box.props.spacing = 0 border_box.props.border = theme.BORDER_WIDTH_CONTROL / 2 border_box.props.border_color = theme.COLOR_DARK_GREEN.get_int() border_box.props.background_color = theme.COLOR_TEXTBOX.get_int() border_box.props.xalign = hippo.ALIGNMENT_START #border_box.props.box_width = width #border_box.props.box_height = height # TODO - File bug: RoundBox seriously messes with TextView's # (and other things) width !! deglitch_box = hippo.CanvasBox() deglitch_box.append(hippo.CanvasWidget(widget=textview)) border_box.append(deglitch_box) return border_box no_edit_box = hippo.CanvasWidget(widget=textview) no_edit_box.control = textview return no_edit_box
def __textview(self, text, width=300, height=-1, editable=True, multiline=False): textview = gtk.TextView() textview.get_buffer().set_text(text) # control props textview.set_wrap_mode(gtk.WRAP_WORD) textview.modify_base(gtk.STATE_NORMAL, theme.COLOR_TEXTBOX.get_gdk_color()) textview.set_editable(editable) textview.set_cursor_visible(editable) if height == -1: context = textview.create_pango_context() layout = pango.Layout(context) layout.set_text(text[: text.find("\n")]) (w, h) = layout.get_pixel_size() height = ( h ) # + theme.BORDER_WIDTH_CONTROL / 2 # fudge factor - on the XO-1 hardware all known solutions evaporate textview.set_size_request(width, height) textview.set_border_window_size(gtk.TEXT_WINDOW_LEFT, 0) textview.set_border_window_size(gtk.TEXT_WINDOW_RIGHT, 0) textview.set_border_window_size(gtk.TEXT_WINDOW_TOP, 0) textview.set_border_window_size(gtk.TEXT_WINDOW_BOTTOM, 0) textview.show() if editable: # because rounded corners are well... pretty border_box = RoundBox() border_box.control = textview border_box.props.padding = 2 border_box.props.spacing = 0 border_box.props.border = theme.BORDER_WIDTH_CONTROL / 2 border_box.props.border_color = theme.COLOR_DARK_GREEN.get_int() border_box.props.background_color = theme.COLOR_TEXTBOX.get_int() border_box.props.xalign = hippo.ALIGNMENT_START # border_box.props.box_width = width # border_box.props.box_height = height # TODO - File bug: RoundBox seriously messes with TextView's # (and other things) width !! deglitch_box = hippo.CanvasBox() deglitch_box.append(hippo.CanvasWidget(widget=textview)) border_box.append(deglitch_box) return border_box no_edit_box = hippo.CanvasWidget(widget=textview) no_edit_box.control = textview return no_edit_box
def make_audiobox(self, obj, property, width): image_file = os.path.join(Globals.pwd, theme.AUDIO_CHOOSE) if not os.path.exists(image_file): logging.debug('cannot find %s' % image_file) return hippo.CanvasBox() surface = cairo.ImageSurface.create_from_png(image_file) preview_sound = hippo.CanvasImage(image=surface, xalign=hippo.ALIGNMENT_START, yalign=hippo.ALIGNMENT_CENTER) preview_sound.connect('button-press-event', self.__do_clicked_preview_sound, obj, property) if hasattr(obj, property) and getattr(obj, property) != None: sound_name = getattr(obj, property) else: sound_name = _('Click to choose a sound') choose_sound = hippo.CanvasText(text=sound_name, xalign=hippo.ALIGNMENT_START) choose_sound.connect('button-press-event', self.__do_clicked_choose_sound, obj, property) sound_box = RoundBox() sound_box.props.padding = 2 sound_box.props.spacing = 10 sound_box.props.box_width = width sound_box.props.border = theme.BORDER_WIDTH_CONTROL / 2 sound_box.props.border_color = theme.COLOR_DARK_GREEN.get_int() sound_box.props.background_color = theme.COLOR_WHITE.get_int() sound_box.props.orientation = hippo.ORIENTATION_HORIZONTAL sound_box.props.xalign = hippo.ALIGNMENT_START sound_box.set_clickable(True) sound_box.append(preview_sound) sound_box.append(choose_sound) deglitch_box = hippo.CanvasBox(xalign=hippo.ALIGNMENT_START, box_width=width) deglitch_box.append(sound_box) return deglitch_box