Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void load_thumbs(){
- pane.set_visible(false);
- pane.newmodel = new Gtk.ListStore (2, typeof (Gdk.Pixbuf), typeof (string));
- pane.set_selection_mode (Gtk.SelectionMode.SINGLE);
- pane.set_pixbuf_column (0);
- pane.set_model(pane.newmodel);
- string icon_style = """
- .thumbnail-view {
- background-color: #FFFFFF;
- }
- .thumbnail-view:selected {
- background-color: #9D9D9D;
- border-color: shade (mix (rgb (34, 255, 120), #fff, 0.5), 0.9);
- }
- """;
- var icon_view_style = new Gtk.CssProvider ();
- try {
- icon_view_style.load_from_data (icon_style, -1);
- } catch (Error e) {
- warning (e.message);
- }
- pane.get_style_context ().add_class ("thumbnail-view");
- pane.get_style_context ().add_provider (icon_view_style, Gtk.STYLE_PROVIDER_PRIORITY_THEME);
- //Add thumbnails to the iconview
- string buff1, buff2;
- for(int i=1; i<pane.image_list.size; i++){
- buff1 = pane.image_list.get_full_filename(i);
- buff2 = pane.image_list.get_filename(i);
- load_image_async.begin (buff2, buff1, (obj, async_res) => {
- GLib.debug ("Finished loading.");
- });
- }
- pane.selection_changed.connect (update_selected);
- pane.set_sensitive(true);
- this.queue_draw();
- }
- //I will use this as a base code to code the async load of stuff
- private async void load_image_async (string filename, string full_filename) {
- GLib.File file = GLib.File.new_for_commandline_arg (full_filename);
- try {
- GLib.InputStream stream = yield file.read_async ();
- Gdk.Pixbuf image = yield Gdk.Pixbuf.new_from_stream_at_scale_async (stream, 110, -1, true);
- // Add the image name and thumbnail to the IconView
- Gtk.TreeIter root;
- pane.newmodel.append(out root);
- pane.newmodel.set(root, 0, image, -1);
- pane.newmodel.set(root, 1, filename, -1);
- pane.iters.append (root);
- stdout.printf("Added %s to thumbnail\n", filename);
- } catch ( GLib.Error e ) {
- GLib.error (e.message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement