Splash Screen in GTK

前端 未结 2 666
说谎
说谎 2021-01-21 11:06

I\'m new to GTK and i\'m using it to create UI in C. I\'ve created a splash screen and i\'m able to close it after specified seconds using the function g_timeout_add(100,

相关标签:
2条回答
  • 2021-01-21 11:32

    I've created a splashscreen header file which is shown below..

    #include <gtk/gtk.h>
    
    /* Close the splash screen */
    gboolean close_screen(gpointer data)
    {
      gtk_widget_destroy((GtkWidget*)data);
      gtk_main_quit ();
      return(FALSE);
    }
    
    
    int Show_Splash_Screen(char* image_name,int time,int width,int height)
    {
      GtkWidget  *image, *window;
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_widget_set_size_request (window, width, height);
      gtk_window_set_decorated(GTK_WINDOW (window), FALSE);
      gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER_ALWAYS);
      gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
      image=gtk_image_new_from_file(image_name);
      gtk_container_add(GTK_CONTAINER(window), image);
      gtk_widget_show_all (window);
      g_timeout_add (time, close_screen, window);
      gtk_main ();
      return 0;
    }
    

    just include this file and to show a splash screen call the function Show_Splash_Screen("image_path",time_in_seconds,width_of_image_in_pixels,height_of_image_in_pixels);

    0 讨论(0)
  • 2021-01-21 11:35

    Your function_to_call doesn't close your splash window here, it ends the gtk_main event loop. You don't need to end the event loop.

    What you want to do instead, in your function_to_call, is hide (or destroy) your splash window and show your next window (gtk_widget_hide(),gtk_widget_show()).

    0 讨论(0)
提交回复
热议问题