/* NOTE: Glade will generate code for a dialogue box which you should * then patch into this file whenever you make a change to the Glade * template. */ #include #include #include #include #include #include #include #include #include #include #ifndef LINKED_GTK # include "dynamicgtk.h" #endif #include "duke3d.h" #include "build.h" #include "compat.h" #include "baselayer.h" #define TAB_CONFIG 0 #define TAB_MESSAGES 1 static struct { int fullscreen; int xdim3d, ydim3d, bpp3d; int forcesetup; int usemouse, usejoy; } settings; extern int gtkenabled; static GtkWidget *startwin = NULL; static int retval = -1, mode = TAB_MESSAGES; // -- SUPPORT FUNCTIONS ------------------------------------------------------- #define GLADE_HOOKUP_OBJECT(component,widget,name) \ g_object_set_data_full (G_OBJECT (component), name, \ gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ g_object_set_data (G_OBJECT (component), name, widget) #define lookup_widget(x,w) \ (GtkWidget*) g_object_get_data(G_OBJECT(x), w) static GdkPixbuf *load_banner(void) { extern const GdkPixdata startbanner_pixdata; return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); } static void SetPage(int n) { if (!gtkenabled || !startwin) return; mode = n; gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); // each control in the config page vertical layout plus the start button should be made (in)sensitive if (n == TAB_CONFIG) n = TRUE; else n = FALSE; gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n); gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), (GtkCallback)gtk_widget_set_sensitive, (gpointer)n); } static void on_vmode3dcombo_changed(GtkComboBox *, gpointer); static void PopulateForm(void) { int mode3d, i; GtkListStore *modes3d; GtkTreeIter iter; GtkComboBox *box3d; char buf[64]; mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); if (mode3d < 0) { int i, cd[] = { 32, 24, 16, 15, 8, 0 }; for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp3d) i++; else break; } for ( ; cd[i]; i++) { mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); if (mode3d < 0) continue; settings.bpp3d = cd[i]; break; } } gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"fullscreencheck")), settings.fullscreen); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"alwaysshowcheck")), settings.forcesetup); box3d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode3dcombo")); modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d)); gtk_list_store_clear(modes3d); for (i=0; i aptr) gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); #if GTK_CHECK_VERSION(2,6,0) gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); #else { GtkTextIter iter2 = enditer; gtk_text_iter_backward_cursor_position(&iter2); //FIXME: this seems be deleting one too many chars somewhere! if (!gtk_text_iter_equal(&iter2, &enditer)) gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); } #endif aptr = ++bptr; break; case 0: if (bptr > aptr) gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); aptr = bptr; break; case '\r': // FIXME default: bptr++; break; } } mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1); gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0); gtk_text_buffer_delete_mark(textbuffer, mark); return 0; } int startwin_settitle(const char *title) { if (!gtkenabled) return 0; if (!startwin) return 1; gtk_window_set_title (GTK_WINDOW (startwin), title); return 0; } int startwin_idle(void *s) { if (!gtkenabled) return 0; //if (!startwin) return 1; gtk_main_iteration_do (FALSE); return 0; } int startwin_run(void) { if (!gtkenabled) return 0; if (!startwin) return 1; SetPage(TAB_CONFIG); settings.fullscreen = ScreenMode; settings.xdim3d = ScreenWidth; settings.ydim3d = ScreenHeight; settings.bpp3d = ScreenBPP; settings.forcesetup = ForceSetup; settings.usemouse = UseMouse; settings.usejoy = UseJoystick; PopulateForm(); gtk_main(); SetPage(TAB_MESSAGES); if (retval) { ScreenMode = settings.fullscreen; ScreenWidth = settings.xdim3d; ScreenHeight = settings.ydim3d; ScreenBPP = settings.bpp3d; ForceSetup = settings.forcesetup; UseMouse = settings.usemouse; UseJoystick = settings.usejoy; } return retval; }