diff --git a/CMakeLists.txt b/CMakeLists.txt index 662ba839a..318275266 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,8 +52,6 @@ CMAKE_DEPENDENT_OPTION(USE_SDL_MAINLOOP "Use SDL to create windows etc." OFF "NO CMAKE_DEPENDENT_OPTION(USE_X11 "Use X11 to create windows etc." ON "UNIX AND NOT APPLE AND NOT USE_SDL_MAINLOOP AND NOT USE_CONSOLE" OFF) CMAKE_DEPENDENT_OPTION(USE_GTK "Use GTK for the developer mode" ON "USE_X11" OFF) -CMAKE_DEPENDENT_OPTION(USE_GTK3 "Use GTK3 instead of GTK2" OFF "USE_GTK" OFF) - CMAKE_DEPENDENT_OPTION(USE_COCOA "Use Apple Cocoa for the developer mode and the windows." ON "APPLE" OFF) option(WITH_AUTOMATIC_UPDATE "Automatic updates are downloaded from the project website." OFF) @@ -860,25 +858,15 @@ endif() # otherwise the path is not used for linking clonk if(USE_GTK) find_package(PkgConfig) - if (USE_GTK3) - pkg_check_modules(GTK3 REQUIRED "glib-2.0 >= 2.32" "gtk+-3.0 >= 3.4") - include_directories(${GTK3_INCLUDE_DIRS}) - link_directories(${GTK3_LIBRARY_DIRS}) - else() - pkg_check_modules(GTK REQUIRED "glib-2.0 >= 2.28" "gtk+-2.0 >= 2.20") - include_directories(${GTK_INCLUDE_DIRS}) - link_directories(${GTK_LIBRARY_DIRS}) - endif() + pkg_check_modules(GTK REQUIRED "glib-2.0 >= 2.32" "gtk+-3.0 >= 3.4") + include_directories(${GTK_INCLUDE_DIRS}) + link_directories(${GTK_LIBRARY_DIRS}) endif() # Try to find GTK for mape find_package(PkgConfig) if (PKG_CONFIG_FOUND) - if (USE_GTK3) - pkg_check_modules(MAPE_GTK glib-2.0>=2.32 gthread-2.0 gtk+-3.0>=3.4 gtksourceview-3.0) - else() - pkg_check_modules(MAPE_GTK glib-2.0>=2.28 gthread-2.0 gtk+-2.0>=2.20 gtksourceview-2.0) - endif() + pkg_check_modules(MAPE_GTK glib-2.0>=2.32 gthread-2.0 gtk+-3.0>=3.4 gtksourceview-3.0) endif() if(MAPE_GTK_FOUND) # hrm, cmake doesn't have target_include_directories... @@ -1342,19 +1330,11 @@ if(NOT USE_CONSOLE) CHECK_CXX_SOURCE_COMPILES("#include \nvoid GLAPIENTRY OpenGLDebugProc(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* message, const void* userParam) {}\nint main() { GLDEBUGPROCARB proc = &OpenGLDebugProc; }" GLDEBUGPROCARB_USERPARAM_IS_CONST) endif() if(USE_GTK) - if(USE_GTK3) - SET(WITH_DEVELOPER_MODE ${GTK3_FOUND}) - SET(WITH_GLIB ${GTK3_FOUND}) - target_link_libraries(openclonk - ${GTK3_LIBRARIES} - ) - else() - SET(WITH_DEVELOPER_MODE ${GTK_FOUND}) - SET(WITH_GLIB ${GTK_FOUND}) - target_link_libraries(openclonk - ${GTK_LIBRARIES} - ) - endif() + SET(WITH_DEVELOPER_MODE ${GTK_FOUND}) + SET(WITH_GLIB ${GTK_FOUND}) + target_link_libraries(openclonk + ${GTK_LIBRARIES} + ) endif() if(MAPE_GTK_FOUND) target_link_libraries(mape ${MAPE_GTK_LIBRARIES}) diff --git a/README b/README index a39762ff2..92c1dc752 100644 --- a/README +++ b/README @@ -29,7 +29,7 @@ Linux Specific ============== For building OpenClonk on Linux, you need the following libraries in addition to the ones listed above: - - GTK+ 2.0 or 3.0 (http://www.gtk.org) + - GTK+ 3.4 or greater (http://www.gtk.org) - libGL (http://www.mesa3d.org/) - SDL 1.2 (http://www.libsdl.org/download-1.2.php) - SDL_mixer 1.2 (http://www.libsdl.org/projects/SDL_mixer/release-1.2.html) @@ -38,7 +38,7 @@ to the ones listed above: Most distributions should provide these dependencies via their packaging system. For Debian based distributions, you will need these packages: build-essential cmake imagemagick libfreetype6-dev libgl1-mesa-dev - libglew-dev libgtk2.0-dev libjpeg-dev libpng-dev libsdl1.2-dev + libglew-dev libgtk-3-dev libjpeg-dev libpng-dev libsdl1.2-dev libsdl-mixer1.2-dev libupnp-dev libxrandr-dev x11proto-core-dev zlib1g-dev At least gcc-4.9 is required. diff --git a/src/editor/C4ConsoleGTK.cpp b/src/editor/C4ConsoleGTK.cpp index 048c5aaea..a6d15327a 100644 --- a/src/editor/C4ConsoleGTK.cpp +++ b/src/editor/C4ConsoleGTK.cpp @@ -1109,17 +1109,10 @@ bool C4ToolsDlg::State::Open() gtk_box_pack_start(GTK_BOX(local_hbox), scale, false, false, 0); vbox = gtk_vbox_new(false, 6); -#if GTK_CHECK_VERSION(2,23,0) fg_materials = gtk_combo_box_text_new(); fg_textures = gtk_combo_box_text_new(); bg_materials = gtk_combo_box_text_new(); bg_textures = gtk_combo_box_text_new(); -#else - fg_materials = gtk_combo_box_new_text(); - fg_textures = gtk_combo_box_new_text(); - bg_materials = gtk_combo_box_new_text(); - bg_textures = gtk_combo_box_new_text(); -#endif // Link the material combo boxes together, but not the texture combo boxes, // so that we can sort the texture combo box differently. @@ -1178,11 +1171,6 @@ void C4ConsoleGUI::ToolsDlgInitMaterialCtrls(C4ToolsDlg *dlg) dlg->state->InitMaterialCtrls(); } -#if GTK_CHECK_VERSION(2,23,0) -#define gtk_combo_box_append_text(c,t) gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(c),t) -#define gtk_combo_box_prepend_text(c,t) gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(c),t) -#define gtk_combo_box_get_active_text(c) gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(c)) -#endif void C4ToolsDlg::State::InitMaterialCtrls() { GtkListStore* list = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(fg_materials))); @@ -1191,11 +1179,11 @@ void C4ToolsDlg::State::InitMaterialCtrls() g_signal_handler_block(bg_materials, handlerBgMaterials); gtk_list_store_clear(list); - gtk_combo_box_append_text(GTK_COMBO_BOX(fg_materials), C4TLS_MatSky); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(fg_materials), C4TLS_MatSky); for (int32_t cnt = 0; cnt < ::MaterialMap.Num; cnt++) { - gtk_combo_box_append_text(GTK_COMBO_BOX(fg_materials), ::MaterialMap.Map[cnt].Name); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(fg_materials), ::MaterialMap.Map[cnt].Name); } g_signal_handler_unblock(fg_materials, handlerFgMaterials); @@ -1260,13 +1248,13 @@ void C4ToolsDlg::UpdateTextures() if (!::TextureMap.GetIndex(material, szTexture, false)) { fAnyEntry = true; - gtk_combo_box_prepend_text(box, szTexture); + gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(box), szTexture); } } // separator if (fAnyEntry) { - gtk_combo_box_prepend_text(box, "-------"); + gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(box), "-------"); } // atop: valid textures @@ -1275,7 +1263,7 @@ void C4ToolsDlg::UpdateTextures() // Current material-texture valid? Always valid for exact mode if (::TextureMap.GetIndex(material,szTexture,false) || ::Landscape.Mode==C4LSC_Exact) { - gtk_combo_box_prepend_text(box, szTexture); + gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(box), szTexture); } } } @@ -1630,28 +1618,28 @@ void C4ToolsDlg::State::OnButtonNoIft(GtkWidget* widget, gpointer data) void C4ToolsDlg::State::OnComboMaterial(GtkWidget* widget, gpointer data) { - gchar* text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget)); + gchar* text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widget)); static_cast(data)->GetOwner()->SetMaterial(text); g_free(text); } void C4ToolsDlg::State::OnComboTexture(GtkWidget* widget, gpointer data) { - gchar* text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget)); + gchar* text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widget)); static_cast(data)->GetOwner()->SetTexture(text); g_free(text); } void C4ToolsDlg::State::OnComboBgMaterial(GtkWidget* widget, gpointer data) { - gchar* text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget)); + gchar* text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widget)); static_cast(data)->GetOwner()->SetBackMaterial(text); g_free(text); } void C4ToolsDlg::State::OnComboBgTexture(GtkWidget* widget, gpointer data) { - gchar* text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget)); + gchar* text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widget)); static_cast(data)->GetOwner()->SetBackTexture(text); g_free(text); } diff --git a/src/gui/C4KeyboardInput.cpp b/src/gui/C4KeyboardInput.cpp index 6c6777d48..c0eec59e0 100644 --- a/src/gui/C4KeyboardInput.cpp +++ b/src/gui/C4KeyboardInput.cpp @@ -453,11 +453,7 @@ StdStrBuf C4KeyCodeEx::KeyCode2String(C4KeyCode wCode, bool fHumanReadable, bool KeySym keysym = (KeySym)XkbKeycodeToKeysym(dpy,wCode+8,0,0); char* name = NULL; if (keysym != NoSymbol) { // is the keycode without shift modifiers mapped to a symbol? - #if defined(USE_GTK3) - name = gtk_accelerator_get_label_with_keycode(dpy, keysym, wCode+8, (GdkModifierType)0); - #else - name = gtk_accelerator_get_label(keysym, (GdkModifierType)0); - #endif + name = gtk_accelerator_get_label_with_keycode(gdk_display_get_default(), keysym, wCode+8, (GdkModifierType)0); } if (name) { // is there a string representation of the keysym? // prevent memleak diff --git a/src/mape/diskview.c b/src/mape/diskview.c index a4b45e1aa..da8d59492 100644 --- a/src/mape/diskview.c +++ b/src/mape/diskview.c @@ -525,11 +525,7 @@ static gboolean mape_disk_view_cb_key_press_event(GtkWidget* widget, disk_view = (MapeDiskView*)user_data; -#if GTK_CHECK_VERSION(2,21,8) if(event->keyval != GDK_KEY_Left && event->keyval != GDK_KEY_Right) -#else - if(event->keyval != GDK_Left && event->keyval != GDK_Right) -#endif return FALSE; gtk_tree_view_get_cursor( @@ -542,11 +538,7 @@ static gboolean mape_disk_view_cb_key_press_event(GtkWidget* widget, switch(event->keyval) { -#if GTK_CHECK_VERSION(2,21,8) case GDK_KEY_Left: -#else - case GDK_Left: -#endif result = gtk_tree_view_row_expanded( GTK_TREE_VIEW(disk_view->view), path @@ -576,11 +568,7 @@ static gboolean mape_disk_view_cb_key_press_event(GtkWidget* widget, } break; -#if GTK_CHECK_VERSION(2,21,8) case GDK_KEY_Right: -#else - case GDK_Right: -#endif result = gtk_tree_view_row_expanded( GTK_TREE_VIEW(disk_view->view), path diff --git a/src/mape/iconview.c b/src/mape/iconview.c index 1be62def8..2cea22a96 100644 --- a/src/mape/iconview.c +++ b/src/mape/iconview.c @@ -32,11 +32,7 @@ MapeIconView* mape_icon_view_new(GError** error) view->view = gtk_icon_view_new_with_model(view->list_store); g_object_unref(view->list_store); -#if GTK_CHECK_VERSION(2,22,0) gtk_icon_view_set_item_orientation( -#else - gtk_icon_view_set_orientation( -#endif GTK_ICON_VIEW(view->view), GTK_ORIENTATION_HORIZONTAL ); diff --git a/src/platform/C4WindowGTK.cpp b/src/platform/C4WindowGTK.cpp index 8b1aa23f3..2dfc48d73 100644 --- a/src/platform/C4WindowGTK.cpp +++ b/src/platform/C4WindowGTK.cpp @@ -189,11 +189,7 @@ static void OnRealizeStatic(GtkWidget* widget, gpointer user_data) static gboolean OnKeyPressStatic(GtkWidget* widget, GdkEventKey* event, gpointer user_data) { -#if GTK_CHECK_VERSION(2,21,8) if (event->keyval == GDK_KEY_Scroll_Lock) -#else - if (event->keyval == GDK_Scroll_Lock) -#endif { static_cast(user_data)->cvp->TogglePlayerLock(); return true; @@ -446,14 +442,12 @@ static gboolean OnScroll(GtkWidget* widget, GdkEventScroll* event, gpointer user C4GUI::DialogWindow * window = static_cast(user_data); C4GUI::Dialog *pDlg = ::pGUI->GetDialog(window); int idy; -#if GTK_CHECK_VERSION(3,4,0) gdouble dx, dy; if (gdk_event_get_scroll_deltas((GdkEvent*)event, &dx, &dy)) { idy = short(round(dy)); } else -#endif { if (event->direction == GDK_SCROLL_UP) idy = 32; @@ -662,11 +656,7 @@ C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char gtk_drag_dest_set(GTK_WIDGET(render_widget), GTK_DEST_DEFAULT_ALL, drag_drop_entries, 1, GDK_ACTION_COPY); g_signal_connect(G_OBJECT(render_widget), "drag-data-received", G_CALLBACK(OnDragDataReceivedStatic), this); - #if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(render_widget), "draw", G_CALLBACK(OnExposeStatic), this); - #else - g_signal_connect(G_OBJECT(render_widget), "expose-event", G_CALLBACK(OnExposeStatic), this); - #endif g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(OnKeyPressStatic), this); g_signal_connect(G_OBJECT(window), "key-release-event", G_CALLBACK(OnKeyReleaseStatic), this); g_signal_connect(G_OBJECT(window), "scroll-event", G_CALLBACK(OnScrollVW), this); @@ -684,9 +674,7 @@ C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char gtk_widget_set_double_buffered (GTK_WIDGET(render_widget), false); gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(Console.window)); -#if GTK_CHECK_VERSION(3,0,0) gtk_window_set_has_resize_grip(GTK_WINDOW(window), false); -#endif } else if (windowKind == W_Fullscreen) { @@ -712,9 +700,7 @@ C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char g_object_set_property (G_OBJECT (render_widget), "can-focus", &val); g_object_set_property (G_OBJECT (window), "can-focus", &val); g_value_unset (&val); -#if GTK_CHECK_VERSION(3,0,0) gtk_window_set_has_resize_grip(GTK_WINDOW(window), false); -#endif } else if (windowKind == W_GuiWindow) { @@ -726,9 +712,7 @@ C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char g_signal_connect(G_OBJECT(window), "scroll-event", G_CALLBACK(OnScroll), this); gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(Console.window)); -#if GTK_CHECK_VERSION(3,0,0) gtk_window_set_has_resize_grip(GTK_WINDOW(window), false); -#endif } else if (windowKind == W_Console) { @@ -743,9 +727,7 @@ C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(OnDelete), this); handlerDestroy = g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(OnDestroyStatic), this); gtk_widget_add_events(GTK_WIDGET(window), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_SCROLL_MASK); -#if GTK_CHECK_VERSION(3,4,0) gtk_widget_add_events(GTK_WIDGET(window), GDK_SMOOTH_SCROLL_MASK); -#endif GdkScreen * scr = gtk_widget_get_screen(GTK_WIDGET(render_widget)); Display * const dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default()); @@ -753,13 +735,7 @@ C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char assert(vis_info); GdkVisual * vis = gdk_x11_screen_lookup_visual(scr, vis_info->visualid); XFree(vis_info); -#if GTK_CHECK_VERSION(2,91,0) gtk_widget_set_visual(GTK_WIDGET(render_widget),vis); -#else - GdkColormap * cmap = gdk_colormap_new(vis, true); - gtk_widget_set_colormap(GTK_WIDGET(render_widget), cmap); - g_object_unref(cmap); -#endif gtk_widget_show_all(GTK_WIDGET(window)); // XVisualInfo vitmpl; int blub; @@ -832,13 +808,7 @@ bool C4Window::ReInit(C4AbstractApp* pApp) gtk_widget_set_double_buffered (GTK_WIDGET(render_widget), false); g_object_set(G_OBJECT(render_widget), "can-focus", TRUE, NULL); -#if GTK_CHECK_VERSION(2,91,0) gtk_widget_set_visual(GTK_WIDGET(render_widget),vis); -#else - GdkColormap * cmap = gdk_colormap_new(vis, true); - gtk_widget_set_colormap(GTK_WIDGET(render_widget), cmap); - g_object_unref(cmap); -#endif Info = new_info;