def __create_widgets(self):
        self.label = HIGAnimatedLabel(self.label_text)

        self.label.label.set_alignment(0, 0.5)
        self.label.label.set_padding(0, 0)
        self.label.label.set_single_line_mode(True)

        self.anim_image = gtk.Image()
        self.image = gtk.image_new_from_stock(gtk.STOCK_CLOSE,
                                              gtk.ICON_SIZE_MENU)

        self.button = gtk.Button()
        self.button.set_focus_on_click(False)
        self.button.set_relief(gtk.RELIEF_NONE)
        self.button.set_name('tabNotebookButton')
        self.button.add(self.image)

        self.button.connect('clicked', self.__close_button_clicked)
        self.button.connect('style-set', self.__button_style_set)
        self.label.connect('button-press-event', self.on_button_press_event)
        self.label.entry.connect('focus-out-event', self.on_entry_focus_out)

        self.pack_start(self.anim_image, False, False, 0)
        self.pack_start(self.label)
        self.pack_end(self.button, False, False, 0)

        self.show_all()
        self.switch_button_mode(False)
Example #2
0
    def __create_widgets(self):
        self.label = HIGAnimatedLabel(self.label_text)

        self.label.label.set_alignment(0, 0.5)
        self.label.label.set_padding(0, 0)
        self.label.label.set_single_line_mode(True)

        self.anim_image = gtk.Image()
        self.image = gtk.image_new_from_stock(gtk.STOCK_CLOSE,
                                              gtk.ICON_SIZE_MENU)

        self.button = gtk.Button()
        self.button.set_focus_on_click(False)
        self.button.set_relief(gtk.RELIEF_NONE)
        self.button.set_name('tabNotebookButton')
        self.button.add(self.image)

        self.button.connect('clicked', self.__close_button_clicked)
        self.button.connect('style-set', self.__button_style_set)
        self.label.connect('button-press-event', self.on_button_press_event)
        self.label.entry.connect('focus-out-event', self.on_entry_focus_out)

        self.pack_start(self.anim_image, False, False, 0)
        self.pack_start(self.label)
        self.pack_end(self.button, False, False, 0)

        self.show_all()
        self.switch_button_mode(False)
class MyHIGClosableTabLabel(HIGHBox):
    __gsignals__ = {
        'close-clicked': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
    }

    def __init__(self, label_text=""):
        gobject.GObject.__init__(self)
        #HIGHBox.__init__(self, spacing=4)

        self.label_text = label_text

        self.set_spacing(4)
        self.set_border_width(0)

        self.__create_widgets()

        #self.propery_map = {"label_text" : self.label.get_label}

    def __create_widgets(self):
        self.label = HIGAnimatedLabel(self.label_text)

        self.label.label.set_alignment(0, 0.5)
        self.label.label.set_padding(0, 0)
        self.label.label.set_single_line_mode(True)

        self.anim_image = gtk.Image()
        self.image = gtk.image_new_from_stock(gtk.STOCK_CLOSE,
                                              gtk.ICON_SIZE_MENU)

        self.button = gtk.Button()
        self.button.set_focus_on_click(False)
        self.button.set_relief(gtk.RELIEF_NONE)
        self.button.set_name('tabNotebookButton')
        self.button.add(self.image)

        self.button.connect('clicked', self.__close_button_clicked)
        self.button.connect('style-set', self.__button_style_set)
        self.label.connect('button-press-event', self.on_button_press_event)
        self.label.entry.connect('focus-out-event', self.on_entry_focus_out)

        self.pack_start(self.anim_image, False, False, 0)
        self.pack_start(self.label)
        self.pack_end(self.button, False, False, 0)

        self.show_all()
        self.switch_button_mode(False)

    def on_entry_focus_out(self, widget, event):
        self.switch_button_mode(False)

    def on_button_press_event(self, widget, event):
        if event.type == gtk.gdk._2BUTTON_PRESS:
            self.switch_button_mode(True)

    def switch_button_mode(self, mode):
        """Switch button from editing mode (True) to label mode (False)
        """
        if mode:
            self.image.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_MENU)
        else:
            self.image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)

        parent = self.get_parent()

        if parent:
            parent.queue_draw()

    def do_realize(self):
        global global_animation

        HIGHBox.do_realize(self)

        self.anim_image.set_from_animation(global_animation)
        self.anim_image.hide()

    def __button_style_set(self, widget, prev_style):
        w, h = gtk.icon_size_lookup_for_settings(widget.get_settings(),
                                                 gtk.ICON_SIZE_MENU)
        widget.set_size_request(w + 2, h + 2)

    def __close_button_clicked(self, widget):
        self.emit('close-clicked')

    def set_throbber_pixbuf(self, animated):
        self.anim_image.set_from_animation(animated)

    def get_text(self):
        return self.label.get_text()

    def set_text(self, text):
        self.label.set_text(text)

    def get_label(self):
        return self.label.get_label()

    def set_label(self, label):
        self.label.set_text(label)

    def get_animated_label(self):
        return self.label

    def get_animated_image(self):
        return self.anim_image

    def start_animation(self):
        self.anim_image.show()

    def stop_animation(self):
        self.anim_image.hide()
Example #4
0
class MyHIGClosableTabLabel(HIGHBox):
    __gsignals__ = { 'close-clicked' : (gobject.SIGNAL_RUN_LAST,
                                        gobject.TYPE_NONE, ()) }

    def __init__(self, label_text=""):
        gobject.GObject.__init__(self)
        #HIGHBox.__init__(self, spacing=4)

        self.label_text = label_text

        self.set_spacing(4)
        self.set_border_width(0)

        self.__create_widgets()

        #self.propery_map = {"label_text" : self.label.get_label}

    def __create_widgets(self):
        self.label = HIGAnimatedLabel(self.label_text)

        self.label.label.set_alignment(0, 0.5)
        self.label.label.set_padding(0, 0)
        self.label.label.set_single_line_mode(True)

        self.anim_image = gtk.Image()
        self.image = gtk.image_new_from_stock(gtk.STOCK_CLOSE,
                                              gtk.ICON_SIZE_MENU)

        self.button = gtk.Button()
        self.button.set_focus_on_click(False)
        self.button.set_relief(gtk.RELIEF_NONE)
        self.button.set_name('tabNotebookButton')
        self.button.add(self.image)

        self.button.connect('clicked', self.__close_button_clicked)
        self.button.connect('style-set', self.__button_style_set)
        self.label.connect('button-press-event', self.on_button_press_event)
        self.label.entry.connect('focus-out-event', self.on_entry_focus_out)

        self.pack_start(self.anim_image, False, False, 0)
        self.pack_start(self.label)
        self.pack_end(self.button, False, False, 0)

        self.show_all()
        self.switch_button_mode(False)

    def on_entry_focus_out(self, widget, event):
        self.switch_button_mode(False)

    def on_button_press_event(self, widget, event):
        if event.type == gtk.gdk._2BUTTON_PRESS:
            self.switch_button_mode(True)

    def switch_button_mode(self, mode):
        """Switch button from editing mode (True) to label mode (False)
        """
        if mode:
            self.image.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_MENU)
        else:
            self.image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)

        parent = self.get_parent()

        if parent:
            parent.queue_draw()

    def do_realize(self):
        global global_animation
        
        HIGHBox.do_realize(self)
        
        self.anim_image.set_from_animation(global_animation)
        self.anim_image.hide()

    def __button_style_set(self, widget, prev_style):
        w, h = gtk.icon_size_lookup_for_settings(widget.get_settings(),
                                                 gtk.ICON_SIZE_MENU)
        widget.set_size_request(w + 2, h + 2)

    def __close_button_clicked(self, widget):
        self.emit('close-clicked')

    def set_throbber_pixbuf(self, animated):
        self.anim_image.set_from_animation(animated)

    def get_text(self):
        return self.label.get_text()

    def set_text(self, text):
        self.label.set_text(text)

    def get_label(self):
        return self.label.get_label()

    def set_label(self, label):
        self.label.set_text(label)

    def get_animated_label(self):
        return self.label

    def get_animated_image(self):
        return self.anim_image

    def start_animation(self):
        self.anim_image.show()

    def stop_animation(self):
        self.anim_image.hide()