Changeset 114


Ignore:
Timestamp:
Aug 14, 2010, 11:15:46 PM (10 years ago)
Author:
sam
Message:

Switch editor building scheme to GtkBuilder.

Location:
trunk/src
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r111 r114  
    2121editor_LDADD = libcommon.a
    2222editor_LDFLAGS = `pkg-config --libs sdl gl gtk+-2.0 gtkgl-2.0 SDL_image`
     23EXTRA_DIST = gtk/editor.xml
    2324
  • trunk/src/gtk/editor.cpp

    r112 r114  
    102102    }
    103103
     104    GtkBuilder *builder = gtk_builder_new();
     105    if (!gtk_builder_add_from_file(builder, "src/gtk/editor.xml", NULL))
     106    {
     107        g_print("Cannot build from XML\n");
     108        return EXIT_FAILURE;
     109    }
     110
    104111    /* Create new top level window. */
    105     GtkWidget *window = gtk_window_new( GTK_WINDOW_TOPLEVEL);
    106     gtk_window_set_title(GTK_WINDOW(window), "Simple");
    107     gtk_container_set_border_width(GTK_CONTAINER(window), 5);
    108 
    109     /* Quit form main if got delete event */
    110     gtk_signal_connect(GTK_OBJECT(window), "delete_event",
    111                        GTK_SIGNAL_FUNC(main_quit), NULL);
     112    GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window1"));
    112113
    113114    /* You should always delete gtk_gl_area widgets before exit or else
     
    137138                          GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
    138139
     140    gtk_signal_connect(GTK_OBJECT(window), "delete_event",
     141                       GTK_SIGNAL_FUNC(main_quit), NULL);
    139142    gtk_signal_connect(GTK_OBJECT(glarea), "expose_event",
    140143                       GTK_SIGNAL_FUNC(draw), NULL);
     
    144147                       GTK_SIGNAL_FUNC(init), NULL);
    145148
    146     // FIXME: is this needed?
    147     gtk_widget_set_usize(GTK_WIDGET(glarea), 400, 300);
     149    // Create a scrolled window around our GL widget
     150    GtkWidget *sw = GTK_WIDGET(gtk_builder_get_object(builder, "scrolledwindow1"));
     151    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), glarea);
    148152
    149     /* Put glarea into window and show it all */
    150     gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(glarea));
    151     gtk_widget_show(GTK_WIDGET(glarea));
    152     gtk_widget_show(GTK_WIDGET(window));
     153    /* Put scrolled window into main window */
     154    gtk_widget_show_all(GTK_WIDGET(window));
    153155
    154156    // FIXME: detect when the game is killed
     
    164166    return EXIT_SUCCESS;
    165167}
     168
Note: See TracChangeset for help on using the changeset viewer.