Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8037829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:02:28+00:00 2026-06-05T03:02:28+00:00

I created this class, And I want to load thumbnails into the iconview as

  • 0

I created this class, And I want to load thumbnails into the iconview as a different thread for efficiency reasons, because the gui load very slow if I do it in the same thread. But when I create the thread, it doesn’t works, it draw some thumbnails and then they dissapear. When I use join, it works. This is my code:

    public class FotoThumbnailPane : Gtk.ScrolledWindow{

private FotoThumbnailPane_i pane;   
private string namet;

public FotoThumbnailPane(string name){
    this.namet = name;
}

public void set_imagelist(fileutils.ImageList image_list){
    pane = new FotoThumbnailPane_i(image_list);
    this.add (pane);
    this.set_min_content_width(140);
    this.show_all();
}

    //This is my threaded function
    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 buff;
    for(int i=1; i<pane.image_list.size; i++){
    buff = pane.image_list.get_full_filename(i);
    stdout.printf("Added %s to thumbnail\n", buff);
            var image = new Gdk.Pixbuf.from_file_at_scale(buff, 110, 80, false);
            // Add the wallpaper 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, pane.image_list.get_filename(i), -1);

            // Select the thumbnail if it is the first in list
            if (i==0) {
                pane.select_path (pane.newmodel.get_path (root));
            }    
            pane.iters.append (root);
    }
    pane.set_sensitive(true);
    this.queue_draw();
return null;
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:02:30+00:00Added an answer on June 5, 2026 at 3:02 am

    You don’t actually need to deal with threads in your program–you can just use an asynchronous method to load the content. Specifically, Gdk.Pixbuf.new_from_stream_at_scale_async.

    Here is an example:

    public async void load (Gtk.Image img, string filename) {
      GLib.File file = GLib.File.new_for_commandline_arg (filename);
      try {
        GLib.InputStream stream = yield file.read_async ();
        Gdk.Pixbuf pixbuf = yield Gdk.Pixbuf.new_from_stream_at_scale_async (stream, 320, -1, true);
        img.set_from_pixbuf (pixbuf);
      } catch ( GLib.Error e ) {
        GLib.error (e.message);
      }
    }
    
    private static int main (string[] args) {
      GLib.return_val_if_fail (args.length > 1, -1);
    
      Gtk.init (ref args);
    
      Gtk.Window win = new Gtk.Window ();
      win.destroy.connect (() => {
          Gtk.main_quit ();
        });
    
      Gtk.Image image = new Gtk.Image ();
      win.add (image);
    
      load.begin (image, args[1], (obj, async_res) => {
          GLib.debug ("Finished loading.");
        });
    
      win.show_all ();
    
      Gtk.main ();
    
      return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a class, and I want it to load a frame (created with
For example I now created a this tiny class: public static class FileSystemInfoComparers<T> where
I've created a class that extends Application. This class starts a service when the
I created a class that's something like this: public class MovieTheaterList { public DateTime
Say I've got a domain model created from C# classes like this: public class
I have a db that is created like this... public class DataBaseManager extends SQLiteOpenHelper{
I have created my own Attached Property like this: public static class LabelExtension {
I created a class under 'src' dir. I'm using this code to access the
I've created a singleton class that loads a plist. I keep getting this error
I've created a simple buffer manager class to be used with asyncroneous sockets. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.