Example #1
0
def confirm_rewrite_brush(window, brushname, existing_preview_pixbuf, imported_preview_data):
    dialog = Gtk.Dialog(_("Overwrite brush?"),
                        window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT)

    cancel = Gtk.Button(stock=Gtk.STOCK_CANCEL)
    cancel.show_all()
    img_yes = Gtk.Image()
    img_yes.set_from_stock(Gtk.STOCK_YES, Gtk.IconSize.BUTTON)
    img_no = Gtk.Image()
    img_no.set_from_stock(Gtk.STOCK_NO, Gtk.IconSize.BUTTON)
    overwrite_this = Gtk.Button(_("Replace"))
    overwrite_this.set_image(img_yes)
    overwrite_this.show_all()
    skip_this = Gtk.Button(_("Rename"))
    skip_this.set_image(img_no)
    skip_this.show_all()
    overwrite_all = Gtk.Button(_("Replace all"))
    overwrite_all.show_all()
    skip_all = Gtk.Button(_("Rename all"))
    skip_all.show_all()

    buttons = [(cancel,         CANCEL),
               (skip_all,       DONT_OVERWRITE_ANYTHING),
               (overwrite_all,  OVERWRITE_ALL),
               (skip_this,      DONT_OVERWRITE_THIS),
               (overwrite_this, OVERWRITE_THIS)]
    for button, code in buttons:
        dialog.add_action_widget(button, code)

    hbox = Gtk.HBox()
    vbox_l = Gtk.VBox()
    vbox_r = Gtk.VBox()
    try:
        preview_r = Gtk.image_new_from_pixbuf(existing_preview_pixbuf)
    except AttributeError:
        preview_r = Gtk.Image.new_from_pixbuf(existing_preview_pixbuf)
    label_l = Gtk.Label(label=_("Imported brush"))
    label_r = Gtk.Label(label=_("Existing brush"))

    question = Gtk.Label(_("<b>A brush named `%s' already exists.</b>\nDo you want to replace it, or should the new brush be renamed?") % brushname)
    question.set_use_markup(True)

    preview_l = image_new_from_png_data(imported_preview_data)

    vbox_l.pack_start(preview_l, True, True, 0)
    vbox_l.pack_start(label_l, False, True, 0)

    vbox_r.pack_start(preview_r, True, True, 0)
    vbox_r.pack_start(label_r, False, True, 0)

    hbox.pack_start(vbox_l, False, True, 0)
    hbox.pack_start(question, True, True, 0)
    hbox.pack_start(vbox_r, False, True, 0)
    hbox.show_all()

    dialog.vbox.pack_start(hbox, True, True, 0)

    answer = dialog.run()
    dialog.destroy()
    return answer
Example #2
0
    def terminalshot(self, _widget, terminal):
        """Handle the taking, prompting and saving of a terminalshot"""
        # Grab a pixbuf of the terminal
        orig_pixbuf = widget_pixbuf(terminal)

        savedialog = Gtk.FileChooserDialog(title=_("Save image"),
                                           action=self.dialog_action,
                                           buttons=self.dialog_buttons)
        savedialog.set_transient_for(_widget.get_toplevel())
        savedialog.set_do_overwrite_confirmation(True)
        savedialog.set_local_only(True)

        pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2, 
                                     orig_pixbuf.get_height() / 2,
                                     GdkPixbuf.InterpType.BILINEAR)
        image = Gtk.image_new_from_pixbuf(pixbuf)
        savedialog.set_preview_widget(image)

        savedialog.show_all()
        response = savedialog.run()
        path = None
        if response == Gtk.ResponseType.OK:
            path = os.path.join(savedialog.get_current_folder(),
                                savedialog.get_filename())
            orig_pixbuf.save(path, 'png')

        savedialog.destroy()
Example #3
0
def confirm_rewrite_brush(window, brushname, existing_preview_pixbuf,
                          imported_preview_data):
    dialog = Gtk.Dialog(
        _("Overwrite brush?"), window,
        Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT)

    cancel = Gtk.Button(stock=Gtk.STOCK_CANCEL)
    cancel.show_all()
    img_yes = Gtk.Image()
    img_yes.set_from_stock(Gtk.STOCK_YES, Gtk.IconSize.BUTTON)
    img_no = Gtk.Image()
    img_no.set_from_stock(Gtk.STOCK_NO, Gtk.IconSize.BUTTON)
    overwrite_this = Gtk.Button(_("Replace"))
    overwrite_this.set_image(img_yes)
    overwrite_this.show_all()
    skip_this = Gtk.Button(_("Rename"))
    skip_this.set_image(img_no)
    skip_this.show_all()
    overwrite_all = Gtk.Button(_("Replace all"))
    overwrite_all.show_all()
    skip_all = Gtk.Button(_("Rename all"))
    skip_all.show_all()

    buttons = [(cancel, CANCEL), (skip_all, DONT_OVERWRITE_ANYTHING),
               (overwrite_all, OVERWRITE_ALL),
               (skip_this, DONT_OVERWRITE_THIS),
               (overwrite_this, OVERWRITE_THIS)]
    for button, code in buttons:
        dialog.add_action_widget(button, code)

    hbox = Gtk.HBox()
    vbox_l = Gtk.VBox()
    vbox_r = Gtk.VBox()
    preview_r = Gtk.image_new_from_pixbuf(existing_preview_pixbuf)
    label_l = Gtk.Label(label=_("Imported brush"))
    label_r = Gtk.Label(label=_("Existing brush"))

    question = Gtk.Label(
        _("<b>A brush named `%s' already exists.</b>\nDo you want to replace it, or should the new brush be renamed?"
          ) % brushname)
    question.set_use_markup(True)

    preview_l = image_new_from_png_data(imported_preview_data)

    vbox_l.pack_start(preview_l, True, True, 0)
    vbox_l.pack_start(label_l, False, True, 0)

    vbox_r.pack_start(preview_r, True, True, 0)
    vbox_r.pack_start(label_r, False, True, 0)

    hbox.pack_start(vbox_l, False, True, 0)
    hbox.pack_start(question, True, True, 0)
    hbox.pack_start(vbox_r, False, True, 0)
    hbox.show_all()

    dialog.vbox.pack_start(hbox, True, True, 0)

    answer = dialog.run()
    dialog.destroy()
    return answer
Example #4
0
    def terminalshot(self, _widget, terminal):
        """Handle the taking, prompting and saving of a terminalshot"""
        # Grab a pixbuf of the terminal
        orig_pixbuf = widget_pixbuf(terminal)

        savedialog = Gtk.FileChooserDialog(title="Save image",
                                           action=self.dialog_action,
                                           buttons=self.dialog_buttons)
        savedialog.set_do_overwrite_confirmation(True)
        savedialog.set_local_only(True)

        pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2, 
                                     orig_pixbuf.get_height() / 2,
                                     GdkPixbuf.InterpType.BILINEAR)
        image = Gtk.image_new_from_pixbuf(pixbuf)
        savedialog.set_preview_widget(image)

        savedialog.show_all()
        response = savedialog.run()
        path = None
        if response == Gtk.ResponseType.OK:
            path = os.path.join(savedialog.get_current_folder(),
                                savedialog.get_filename())
            orig_pixbuf.save(path, 'png')

        savedialog.destroy()
Example #5
0
 def wrap(widgetstore=None,
          id=None,
          w=None,
          label=None,
          color=None,
          image=None,
          align=1,
          label_size=305,
          label_markup=0):
     if id:
         widgetstore[id] = w
     if label:
         if type(w) is gtk.Entry:
             w.set_width_chars(11)
         w = uikit.hbox(w,
                        uikit.label(label,
                                    size=label_size,
                                    markup=label_markup),
                        exr=True)
     if image:
         pix = gtk.image_new_from_pixbuf(uikit.pixbuf(image))
         if pix:
             w = uikit.hbox(w, pix, exr=False)
     if color:
         w = uikit.bg(w, color)
     if align:
         a = gtk.Alignment()
         a.set_padding(0, 0, align, 0)
         a.add(w)
         w = a
     w.show_all()
     return w
Example #6
0
 def factory(menu_, parent, context):
     menu_item = Gtk.ImageMenuItem.new_with_mnemonic(label)
     if pix:
         menu_item.set_image(Gtk.image_new_from_pixbuf(pix))
     
     if menu_ is self.menu:
         menu_item.connect('activate', self.do_bookmark, (key,pos))
     else:
         menu_item.connect('activate', self.delete_bookmark, (counter,key,pos))
         
     return menu_item
Example #7
0
        def factory(menu_, parent, context):
            menu_item = Gtk.ImageMenuItem.new_with_mnemonic(label)
            if pix:
                menu_item.set_image(Gtk.image_new_from_pixbuf(pix))

            if menu_ is self.menu:
                menu_item.connect('activate', self.do_bookmark, (key, pos))
            else:
                menu_item.connect('activate', self.delete_bookmark,
                                  (counter, key, pos))

            return menu_item
Example #8
0
    def __init__(self, qty, base, filename, parent, all_effects, vol_adj, mute_adj):
        GObject.GObject.__init__(self)
        self.base = base
        self.session_filename = filename
        
        hbox = Gtk.HBox()
        hbox.set_spacing(1)
        self.add(hbox)
        vbox = Gtk.VBox()
        hbox.pack_start(vbox, True, True, 0)
        
        self.effects = []
        self.all_effects = all_effects
        
        count = 0
        
        for row in range(qty):
            effect = Effect(base + row, self.all_effects, parent)
            self.effects.append(effect)
            self.all_effects.append(effect)
            vbox.pack_start(effect, True, True, 0)
            count += 1

        level_vbox = Gtk.VBox()
        hbox.pack_start(level_vbox, False, padding=3)
        
        vol_image = Gtk.image_new_from_file(FGlobs.pkgdatadir / "volume2.png")
        vol = Gtk.VScale(vol_adj)
        vol.set_inverted(True)
        vol.set_draw_value(False)
        set_tip(vol, _('Effects volume.'))

        pb = GdkPixbuf.Pixbuf.new_from_file(FGlobs.pkgdatadir / "headroom.png")
        mute_image = Gtk.image_new_from_pixbuf(pb)
        mute = Gtk.VScale(mute_adj)
        mute.set_inverted(True)
        mute.set_draw_value(False)
        set_tip(mute, _('Player headroom that is applied when an effect is playing.'))
        
        spc = Gtk.VBox()
        
        for widget, expand in zip((vol_image, vol, spc, mute_image, mute), 
                                    (False, True, False, False, True)):
            level_vbox.pack_start(widget, expand, padding=2)
Example #9
0
    def __init__(self, parent):
        self.approot = parent

        self.nb_label = Gtk.HBox(False, 0)
        vb = Gtk.VBox()
        lbl = Gtk.Label(label=_('Effects'))
        lbl.set_padding(0, 2)
        vb.pack_start(lbl, True, True, 0)
        vb.show()
        self.nb_label.pack_start(vb, True, True, 0)
        self.nb_effects_box = Gtk.HBox(False, 5)
        self.nb_label.pack_start(self.nb_effects_box, True, True, 0)
        self.nb_label.show_all()
        self.nb_effects_box.hide()
        GObject.GObject.__init__(self)
        self.set_border_width(4)
        self.set_spacing(10)
        self.viewlevels = (5,)

        esbox = Gtk.VBox()
        self.pack_start(esbox, True, True, 0)
        estable = Gtk.Table(columns=2, homogeneous=True)
        estable.set_col_spacing(1, 8)
        esbox.pack_start(estable, True, True, 0)

        self.jvol_adj = (Gtk.Adjustment(127.0, 0.0, 127.0, 1.0, 10.0),
                         Gtk.Adjustment(127.0, 0.0, 127.0, 1.0, 10.0))
        self.jmute_adj = (Gtk.Adjustment(100.0, 0.0, 127.0, 1.0, 10.0),
                          Gtk.Adjustment(100.0, 0.0, 127.0, 1.0, 10.0))
        self.ivol_adj = Gtk.Adjustment(64.0, 0.0, 127.0, 1.0, 10.0)
        for each in (self.jvol_adj[0], self.jvol_adj[1], self.ivol_adj,
                                        self.jmute_adj[0], self.jmute_adj[1]):
            each.connect("value-changed",
                                lambda w: parent.send_new_mixer_stats())

        effects_hbox = Gtk.HBox(homogeneous=True)
        effects_hbox.set_spacing(6)
        effects = PGlobs.num_effects
        base = 0
        max_rows = 12
        effect_cols = (effects + max_rows - 1) // max_rows
        self.all_effects = []
        self.effect_banks = []
        for col in range(effect_cols):
            bank = EffectBank(min(effects - base, max_rows), base,
            "effects%d_session" % (col + 1), parent, self.all_effects,
            self.jvol_adj[col], self.jmute_adj[col])
            parent.label_subst.add_widget(bank, 
                            "effectbank%d" % col, _('Effects %d') % (col + 1))
            self.effect_banks.append(bank)
            effects_hbox.pack_start(bank, True, True, 0)
            base += max_rows
        estable.attach(effects_hbox, 0, 2, 0, 1)

        self.interlude_frame = interlude_frame = Gtk.Frame()
        parent.label_subst.add_widget(interlude_frame, "bgplayername",
                                                        _('Background Tracks'))
        self.pack_start(interlude_frame, True, True, 0)
        hbox = Gtk.HBox()
        hbox.set_spacing(1)
        interlude_frame.add(hbox)
        interlude_box = Gtk.VBox()
        hbox.pack_start(interlude_box, True, True, 0)
        self.interlude = IDJC_Media_Player(interlude_box, "interlude", parent)
        interlude_box.set_no_show_all(True)

        ilevel_vbox = Gtk.VBox()
        hbox.pack_start(ilevel_vbox, False, padding=3)
        volpb = GdkPixbuf.Pixbuf.new_from_file(FGlobs.pkgdatadir / "volume2.png")
        ivol_image = Gtk.image_new_from_pixbuf(volpb)
        ilevel_vbox.pack_start(ivol_image, False, padding=2)
        ivol = Gtk.VScale(self.ivol_adj)
        ivol.set_inverted(True)
        ivol.set_draw_value(False)
        ilevel_vbox.pack_start(ivol, True, True, 2)
        set_tip(ivol, _('Background Tracks volume.'))

        self.show_all()
        interlude_box.show()
        self.approot.player_nb.connect('switch-page',
                                       self._on_nb_switch_page,
                                       self.nb_effects_box)