Find the answer to your Linux question:
Results 1 to 2 of 2
Howdy all. I have a question about using Gtk+. I'm writing a program that needs to display an image. My approach was to either set the window size to the ...
  1. #1
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230

    Gtk+ Max Window Size

    Howdy all. I have a question about using Gtk+.

    I'm writing a program that needs to display an image. My approach was to either set the window size to the resolution of the image (which I have successfully obtained), or if this is too big, then set it to the max size that it can be (that is, maximize it), and then let the scroll pane take over.

    To do this, I need to figure out the max size of a window. I've tried this code, but it returns 200x200, not the max size:
    Code:
    static void determine_max_vals(void)
    {
        GtkWidget *window;
    
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_maximize(GTK_WINDOW(window));
        gtk_window_get_size(GTK_WINDOW(window), &max_window_width, &max_window_height);
    
        printf("Max Width: %d\nMax Height: %d\n", max_window_width, max_window_height);
    }
    Does anyone know how to actually find the maximum size? If not, how can I find the resolution of the screen? I could hack together a solution using that, if necessary.
    DISTRO=Arch
    Registered Linux User #388732

  2. #2
    Just Joined!
    Join Date
    Feb 2007
    Location
    Elkesley, Nottinghamshire, UK
    Posts
    3
    Code:
    GdkScreen* screen = NULL;
    
    screen = gtk_window_get_screen(GTK_WINDOW(window));
    width = gdk_screen_get_width(screen);
    height = gdk_screen_get_height(screen);
        
    printf("Screen resolution is (%d x %d)\n", width, height);
    That should get the resolution of the screen you window is currently on, if that helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...