From: TimePath Date: Tue, 1 Aug 2017 10:51:11 +0000 (+0000) Subject: Merge branch 'TimePath/gtk++' into 'master' X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=c001d05fb1dc902a725dbf50df82e88a1a526a21;hp=78da6626a0eb04653cf7655dee97cf3ad487fbb4 Merge branch 'TimePath/gtk++' into 'master' GTK Upgrade See merge request !59 --- diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 00000000..d40dd2e3 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,8 @@ +build: + image: teaci/msys32 + shell: mingw32 + pull: true + commands: + - pacman -S --needed --noconfirm --noprogressbar mingw-w64-i686-{toolchain,cmake,gtk2,gtkglext} + - cmake -G "MSYS Makefiles" . + - make diff --git a/CMakeLists.txt b/CMakeLists.txt index 9af79ce9..b2b766ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,8 @@ if (NOT WIN32) endif () set(CMAKE_POSITION_INDEPENDENT_CODE 1) -set(GTK_NS "GTK2" CACHE STRING "GTK variable prefix") +set(GTK_TARGET 2 CACHE STRING "GTK target") +add_definitions(-DGTK_TARGET=${GTK_TARGET}) #----------------------------------------------------------------------- # Defs @@ -89,6 +90,20 @@ if (NOT CMAKE_BUILD_TYPE MATCHES Release) add_definitions(-D_DEBUG=1) endif () +macro(disable_deprecated name gtk2only) + add_definitions(-D${name}_DISABLE_SINGLE_INCLUDES) + if ((${gtk2only} EQUAL 0) OR (GTK_TARGET EQUAL 2)) + add_definitions(-D${name}_DISABLE_DEPRECATED) + endif () +endmacro() + +disable_deprecated(ATK 0) +disable_deprecated(G 0) +disable_deprecated(GDK 0) +disable_deprecated(GDK_PIXBUF 0) +disable_deprecated(GTK 1) +disable_deprecated(PANGO 0) + if (APPLE) option(XWINDOWS "Build against X11" ON) add_definitions( diff --git a/Makefile b/Makefile index fddd0049..0a2d4b97 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,7 @@ CFLAGS_COMMON = -MMD -W -Wall -Wcast-align -Wcast-qual -Wno-unused-parameter -fn CPPFLAGS_COMMON = LDFLAGS_COMMON = LIBS_COMMON = -CXXFLAGS_COMMON = -Wno-non-virtual-dtor -Wreorder -fno-exceptions -fno-rtti +CXXFLAGS_COMMON = -std=c++11 -Wno-non-virtual-dtor -Wreorder -fno-exceptions -fno-rtti ifeq ($(BUILD),debug) ifeq ($(findstring $(CFLAGS),-g),) @@ -258,6 +258,7 @@ ifneq ($(GIT_VERSION),) endif CPPFLAGS += -DRADIANT_VERSION="\"$(RADIANT_VERSION)\"" -DRADIANT_MAJOR_VERSION="\"$(RADIANT_MAJOR_VERSION)\"" -DRADIANT_MINOR_VERSION="\"$(RADIANT_MINOR_VERSION)\"" -DRADIANT_PATCH_VERSION="\"$(RADIANT_PATCH_VERSION)\"" -DRADIANT_ABOUTMSG="\"$(RADIANT_ABOUTMSG)\"" -DQ3MAP_VERSION="\"$(Q3MAP_VERSION)\"" -DRADIANT_EXECUTABLE="\"$(RADIANT_EXECUTABLE)\"" +CPPFLAGS += -DGTK_TARGET=2 .PHONY: all all: \ @@ -697,6 +698,7 @@ $(INSTALLDIR)/radiant.$(EXE): \ radiant/stacktrace.o \ radiant/surfacedialog.o \ radiant/texmanip.o \ + radiant/textureentry.o \ radiant/textures.o \ radiant/texwindow.o \ radiant/timer.o \ @@ -711,6 +713,7 @@ $(INSTALLDIR)/radiant.$(EXE): \ radiant/xywindow.o \ libcmdlib.$(A) \ libgtkutil.$(A) \ + libuilib.$(A) \ libl_net.$(A) \ libmathlib.$(A) \ libprofile.$(A) \ @@ -735,8 +738,6 @@ libgtkutil.$(A): \ libs/gtkutil/accelerator.o \ libs/gtkutil/button.o \ libs/gtkutil/clipboard.o \ - libs/gtkutil/closure.o \ - libs/gtkutil/container.o \ libs/gtkutil/cursor.o \ libs/gtkutil/dialog.o \ libs/gtkutil/entry.o \ @@ -744,51 +745,42 @@ libgtkutil.$(A): \ libs/gtkutil/frame.o \ libs/gtkutil/glfont.o \ libs/gtkutil/glwidget.o \ - libs/gtkutil/idledraw.o \ libs/gtkutil/image.o \ libs/gtkutil/menu.o \ libs/gtkutil/messagebox.o \ libs/gtkutil/nonmodal.o \ libs/gtkutil/paned.o \ - libs/gtkutil/pointer.o \ libs/gtkutil/toolbar.o \ libs/gtkutil/widget.o \ libs/gtkutil/window.o \ libs/gtkutil/xorrectangle.o \ +libuilib.$(A): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_GTKGLEXT) -Ilibs -Iinclude +libuilib.$(A): \ + libs/uilib/uilib.o \ + libxmllib.$(A): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) -Ilibs -Iinclude libxmllib.$(A): \ - libs/xml/ixml.o \ - libs/xml/xmlelement.o \ - libs/xml/xmlparser.o \ libs/xml/xmltextags.o \ - libs/xml/xmlwriter.o \ $(INSTALLDIR)/modules/archivezip.$(DLL): LIBS_EXTRA := $(LIBS_ZLIB) $(INSTALLDIR)/modules/archivezip.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_ZLIB) -Ilibs -Iinclude $(INSTALLDIR)/modules/archivezip.$(DLL): \ plugins/archivezip/archive.o \ - plugins/archivezip/pkzip.o \ plugins/archivezip/plugin.o \ - plugins/archivezip/zlibstream.o \ $(INSTALLDIR)/modules/archivewad.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude $(INSTALLDIR)/modules/archivewad.$(DLL): \ plugins/archivewad/archive.o \ plugins/archivewad/plugin.o \ - plugins/archivewad/wad.o \ $(INSTALLDIR)/modules/archivepak.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude $(INSTALLDIR)/modules/archivepak.$(DLL): \ plugins/archivepak/archive.o \ - plugins/archivepak/pak.o \ plugins/archivepak/plugin.o \ -$(INSTALLDIR)/modules/entity.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude +$(INSTALLDIR)/modules/entity.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) -Ilibs -Iinclude $(INSTALLDIR)/modules/entity.$(DLL): \ - plugins/entity/angle.o \ - plugins/entity/angles.o \ - plugins/entity/colour.o \ plugins/entity/doom3group.o \ plugins/entity/eclassmodel.o \ plugins/entity/entity.o \ @@ -797,13 +789,7 @@ $(INSTALLDIR)/modules/entity.$(DLL): \ plugins/entity/group.o \ plugins/entity/light.o \ plugins/entity/miscmodel.o \ - plugins/entity/model.o \ - plugins/entity/modelskinkey.o \ - plugins/entity/namedentity.o \ - plugins/entity/origin.o \ plugins/entity/plugin.o \ - plugins/entity/rotation.o \ - plugins/entity/scale.o \ plugins/entity/skincache.o \ plugins/entity/targetable.o \ @@ -838,7 +824,7 @@ $(INSTALLDIR)/modules/imagepng.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_PNG) -Ilibs $(INSTALLDIR)/modules/imagepng.$(DLL): \ plugins/imagepng/plugin.o \ -$(INSTALLDIR)/modules/mapq3.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude +$(INSTALLDIR)/modules/mapq3.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) -Ilibs -Iinclude $(INSTALLDIR)/modules/mapq3.$(DLL): \ plugins/mapq3/parse.o \ plugins/mapq3/plugin.o \ diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake index 092bdc86..4b1b2650 100644 --- a/cmake/FindGLIB.cmake +++ b/cmake/FindGLIB.cmake @@ -1,9 +1,21 @@ -include(FindPkgConfig) +find_package(PkgConfig) if (PKG_CONFIG_FOUND) if (GLIB_FIND_REQUIRED) - set(_PACKAGE_ARGS REQUIRED) - else () - set(_PACKAGE_ARGS "") + set(_pkgconfig_REQUIRED REQUIRED) + endif () + pkg_check_modules(GLIB ${_pkgconfig_REQUIRED} glib-2.0) +else () + find_path(GLIB_INCLUDE_DIRS glib.h) + find_library(GLIB_LIBRARIES glib-2.0) + if (GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES) + set(GLIB_FOUND 1) + if (NOT GLIB_FIND_QUIETLY) + message(STATUS "Found GLIB: ${GLIB_LIBRARIES}") + endif () + elseif (GLIB_FIND_REQUIRED) + message(SEND_ERROR "Could not find GLIB") + elseif (NOT GLIB_FIND_QUIETLY) + message(STATUS "Could not find GLIB") endif () - pkg_check_modules(GLIB glib-2.0 ${_PACKAGE_ARGS}) endif () +mark_as_advanced(GLIB_INCLUDE_DIRS GLIB_LIBRARIES) diff --git a/cmake/FindGTK2.cmake b/cmake/FindGTK2.cmake new file mode 100644 index 00000000..ff205261 --- /dev/null +++ b/cmake/FindGTK2.cmake @@ -0,0 +1,21 @@ +find_package(PkgConfig) +if (PKG_CONFIG_FOUND) + if (GTK2_FIND_REQUIRED) + set(_pkgconfig_REQUIRED REQUIRED) + endif () + pkg_check_modules(GTK2 ${_pkgconfig_REQUIRED} gtk+-2.0) +else () + find_path(GTK2_INCLUDE_DIRS gtk.h) + # find_library(GTK2_LIBRARIES) + if (GTK2_INCLUDE_DIRS AND GTK2_LIBRARIES) + set(GTK2_FOUND 1) + if (NOT GTK2_FIND_QUIETLY) + message(STATUS "Found GTK2: ${GTK2_LIBRARIES}") + endif () + elseif (GTK2_FIND_REQUIRED) + message(SEND_ERROR "Could not find GTK2") + elseif (NOT GTK2_FIND_QUIETLY) + message(STATUS "Could not find GTK2") + endif () +endif () +mark_as_advanced(GTK2_INCLUDE_DIRS GTK2_LIBRARIES) diff --git a/cmake/FindGTK3.cmake b/cmake/FindGTK3.cmake new file mode 100644 index 00000000..7bef3b01 --- /dev/null +++ b/cmake/FindGTK3.cmake @@ -0,0 +1,21 @@ +find_package(PkgConfig) +if (PKG_CONFIG_FOUND) + if (GTK3_FIND_REQUIRED) + set(_pkgconfig_REQUIRED REQUIRED) + endif () + pkg_check_modules(GTK3 ${_pkgconfig_REQUIRED} gtk+-3.0) +else () + find_path(GTK3_INCLUDE_DIRS gtk.h) + # find_library(GTK3_LIBRARIES) + if (GTK3_INCLUDE_DIRS AND GTK3_LIBRARIES) + set(GTK3_FOUND 1) + if (NOT GTK3_FIND_QUIETLY) + message(STATUS "Found GTK3: ${GTK3_LIBRARIES}") + endif () + elseif (GTK3_FIND_REQUIRED) + message(SEND_ERROR "Could not find GTK3") + elseif (NOT GTK3_FIND_QUIETLY) + message(STATUS "Could not find GTK3") + endif () +endif () +mark_as_advanced(GTK3_INCLUDE_DIRS GTK3_LIBRARIES) diff --git a/cmake/FindGtkGLExt.cmake b/cmake/FindGtkGLExt.cmake index 7fb3e9d1..b30a1e11 100644 --- a/cmake/FindGtkGLExt.cmake +++ b/cmake/FindGtkGLExt.cmake @@ -1,16 +1,27 @@ -include(FindPkgConfig) +find_package(PkgConfig) if (PKG_CONFIG_FOUND) if (GtkGLExt_FIND_REQUIRED) - set(_PACKAGE_ARGS REQUIRED) - else () - set(_PACKAGE_ARGS "") + set(_pkgconfig_REQUIRED REQUIRED) endif () - pkg_check_modules(GTK gtk+-2.0 ${_PACKAGE_ARGS}) if (XWINDOWS) - pkg_check_modules(GTKGL gtkglext-x11-1.0 ${_PACKAGE_ARGS}) + pkg_check_modules(GtkGLExt ${_pkgconfig_REQUIRED} gtkglext-x11-1.0) elseif (WIN32) - pkg_check_modules(GTKGL gtkglext-win32-1.0 ${_PACKAGE_ARGS}) + pkg_check_modules(GtkGLExt ${_pkgconfig_REQUIRED} gtkglext-win32-1.0) else () - pkg_check_modules(GTKGL gtkglext-quartz-1.0 ${_PACKAGE_ARGS}) + pkg_check_modules(GtkGLExt ${_pkgconfig_REQUIRED} gtkglext-quartz-1.0) + endif () +else () + find_path(GtkGLExt_INCLUDE_DIRS gtkglwidget.h) + # find_library(GtkGLExt_LIBRARIES) + if (GtkGLExt_INCLUDE_DIRS AND GtkGLExt_LIBRARIES) + set(GtkGLExt_FOUND 1) + if (NOT GtkGLExt_FIND_QUIETLY) + message(STATUS "Found GtkGLExt: ${GtkGLExt_LIBRARIES}") + endif () + elseif (GtkGLExt_FIND_REQUIRED) + message(SEND_ERROR "Could not find GtkGLExt") + elseif (NOT GtkGLExt_FIND_QUIETLY) + message(STATUS "Could not find GtkGLExt") endif () endif () +mark_as_advanced(GtkGLExt_INCLUDE_DIRS GtkGLExt_LIBRARIES) diff --git a/cmake/FindMinizip.cmake b/cmake/FindMinizip.cmake index 10a5fc6f..0de098f4 100644 --- a/cmake/FindMinizip.cmake +++ b/cmake/FindMinizip.cmake @@ -1,9 +1,21 @@ -include(FindPkgConfig) +find_package(PkgConfig) if (PKG_CONFIG_FOUND) if (Minizip_FIND_REQUIRED) - set(_PACKAGE_ARGS REQUIRED) - else () - set(_PACKAGE_ARGS "") + set(_pkgconfig_REQUIRED REQUIRED) + endif () + pkg_check_modules(Minizip ${_pkgconfig_REQUIRED} minizip) +else () + find_path(Minizip_INCLUDE_DIRS unzip.h) + # find_library(Minizip_LIBRARIES) + if (Minizip_INCLUDE_DIRS AND Minizip_LIBRARIES) + set(Minizip_FOUND 1) + if (NOT Minizip_FIND_QUIETLY) + message(STATUS "Found Minizip: ${Minizip_LIBRARIES}") + endif () + elseif (Minizip_FIND_REQUIRED) + message(SEND_ERROR "Could not find Minizip") + elseif (NOT Minizip_FIND_QUIETLY) + message(STATUS "Could not find Minizip") endif () - pkg_check_modules(Minizip minizip ${_PACKAGE_ARGS}) endif () +mark_as_advanced(Minizip_INCLUDE_DIRS Minizip_LIBRARIES) diff --git a/cmake/FindPango.cmake b/cmake/FindPango.cmake new file mode 100644 index 00000000..67359ef0 --- /dev/null +++ b/cmake/FindPango.cmake @@ -0,0 +1,23 @@ +find_package(PkgConfig) +if (PKG_CONFIG_FOUND) + if (Pango_FIND_REQUIRED) + set(_pkgconfig_REQUIRED REQUIRED) + endif () + pkg_search_module(Pango ${_pkgconfig_REQUIRED} pango pangocairo) + pkg_search_module(PangoFT2 ${_pkgconfig_REQUIRED} pangoft2) +else () + # find_path(Pango_INCLUDE_DIRS) + # find_library(Pango_LIBRARIES) + if (Pango_INCLUDE_DIRS AND Pango_LIBRARIES) + set(Pango_FOUND 1) + if (NOT Pango_FIND_QUIETLY) + message(STATUS "Found Pango: ${Pango_LIBRARIES}") + endif () + elseif (Pango_FIND_REQUIRED) + message(SEND_ERROR "Could not find Pango") + elseif (NOT Pango_FIND_QUIETLY) + message(STATUS "Could not find Pango") + endif () +endif () +mark_as_advanced(Pango_INCLUDE_DIRS Pango_LIBRARIES) +mark_as_advanced(PangoFT2_INCLUDE_DIRS PangoFT2_LIBRARIES) diff --git a/contrib/bkgrnd2d/dialog.cpp b/contrib/bkgrnd2d/dialog.cpp index 6d63bc3f..f66fb6fb 100644 --- a/contrib/bkgrnd2d/dialog.cpp +++ b/contrib/bkgrnd2d/dialog.cpp @@ -172,8 +172,6 @@ void CBackgroundDialogPage::SetPosLabel(){ } CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ - GtkWidget *frame; - GtkWidget *hbox; GtkWidget *w; m_vt = vt; @@ -183,47 +181,45 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ switch ( m_vt ) { case XY: - m_pTabLabel = gtk_label_new( "X/Y" ); + m_pTabLabel = ui::Label( "X/Y" ); m_pImage = &backgroundXY; break; case XZ: - m_pTabLabel = gtk_label_new( "X/Z" ); + m_pTabLabel = ui::Label( "X/Z" ); m_pImage = &backgroundXZ; break; case YZ: - m_pTabLabel = gtk_label_new( "Y/Z" ); + m_pTabLabel = ui::Label( "Y/Z" ); m_pImage = &backgroundYZ; break; } // A vbox to hold everything - m_pWidget = gtk_vbox_new( FALSE,0 ); + m_pWidget = ui::VBox( FALSE,0 ); // Frame for file row - frame = gtk_frame_new( "File" ); + auto frame = ui::Frame( "File" ); gtk_box_pack_start( GTK_BOX( m_pWidget ),frame, FALSE, FALSE, 2 ); // hbox for first row - hbox = gtk_hbox_new( FALSE,5 ); + auto hbox = ui::HBox( FALSE,5 ); gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 ); - gtk_container_add( GTK_CONTAINER( frame ), hbox ); + frame.add(hbox); // label to display filename - m_pFileLabel = gtk_label_new( NO_FILE_MSG ); + m_pFileLabel = ui::Label( NO_FILE_MSG ); gtk_label_set_selectable( GTK_LABEL( m_pFileLabel ),TRUE ); //TODO set min size ? done with spaces right now gtk_box_pack_start( GTK_BOX( hbox ),m_pFileLabel, TRUE, TRUE, 5 ); gtk_widget_show( m_pFileLabel ); - w = gtk_button_new_with_label( "Browse..." ); - g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( browse_callback ), - ( gpointer ) this ); + w = ui::Button( "Browse..." ); + w.connect( "clicked", G_CALLBACK( browse_callback ), ( gpointer ) this ); gtk_box_pack_start( GTK_BOX( hbox ),w, FALSE, FALSE, 5 ); gtk_tooltips_set_tip( pTooltips, w, "Select a file", NULL ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Reload" ); - g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( reload_callback ), - ( gpointer ) this ); + w = ui::Button( "Reload" ); + w.connect( "clicked", G_CALLBACK( reload_callback ), ( gpointer ) this ); // TODO disable until we have file // gtk_widget_set_sensitive(w,FALSE); gtk_tooltips_set_tip( pTooltips, w, "Reload current file", NULL ); @@ -234,22 +230,21 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ gtk_widget_show( frame ); // second row (rendering options) - frame = gtk_frame_new( "Rendering" ); + frame = ui::Frame( "Rendering" ); gtk_box_pack_start( GTK_BOX( m_pWidget ),frame, FALSE, FALSE, 2 ); - hbox = gtk_hbox_new( FALSE,5 ); + hbox = ui::HBox( FALSE,5 ); gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 ); - gtk_container_add( GTK_CONTAINER( frame ), hbox ); + frame.add(hbox); - w = gtk_label_new( "Vertex alpha:" ); + w = ui::Label( "Vertex alpha:" ); gtk_box_pack_start( GTK_BOX( hbox ),w, FALSE, FALSE, 5 ); gtk_widget_show( w ); - w = gtk_hscale_new_with_range( 0.0,1.0,0.01 ); + w = ui::HScale( 0.0, 1.0, 0.01 ); gtk_range_set_value( GTK_RANGE( w ),0.5 ); gtk_scale_set_value_pos( GTK_SCALE( w ),GTK_POS_LEFT ); - g_signal_connect( G_OBJECT( w ), "value-changed", - G_CALLBACK( alpha_adjust_callback ), ( gpointer ) this ); + w.connect( "value-changed", G_CALLBACK( alpha_adjust_callback ), ( gpointer ) this ); gtk_box_pack_start( GTK_BOX( hbox ),w, TRUE, TRUE, 5 ); gtk_tooltips_set_tip( pTooltips, w, "Set image transparancy", NULL ); gtk_widget_show( w ); @@ -257,26 +252,24 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ gtk_widget_show( hbox ); gtk_widget_show( frame ); // Third row (size and position) - frame = gtk_frame_new( "Size/Position (undefined)" ); + frame = ui::Frame( "Size/Position (undefined)" ); m_pPosLabel = gtk_frame_get_label_widget( GTK_FRAME( frame ) ); gtk_box_pack_start( GTK_BOX( m_pWidget ), frame, FALSE, FALSE, 2 ); - hbox = gtk_hbox_new( FALSE,5 ); - gtk_container_add( GTK_CONTAINER( frame ), hbox ); + hbox = ui::HBox( FALSE,5 ); + frame.add(hbox); gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 ); - w = gtk_button_new_with_label( "from selection" ); + w = ui::Button( "from selection" ); gtk_box_pack_start( GTK_BOX( hbox ),w, TRUE, FALSE, 5 ); - g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( size_sel_callback ), - ( gpointer ) this ); + w.connect( "clicked", G_CALLBACK( size_sel_callback ), ( gpointer ) this ); gtk_tooltips_set_tip( pTooltips, w, "Set the size of the image to the bounding rectangle of all selected brushes and entities", NULL ); gtk_widget_show( w ); if ( m_vt == XY ) { - w = gtk_button_new_with_label( "from map mins/maxs" ); + w = ui::Button( "from map mins/maxs" ); gtk_box_pack_start( GTK_BOX( hbox ),w, TRUE, FALSE, 2 ); - g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( size_mm_callback ), - ( gpointer ) this ); + w.connect( "clicked", G_CALLBACK( size_mm_callback ), ( gpointer ) this ); gtk_tooltips_set_tip( pTooltips, w, "Set the size of the image using the mapcoordsmins and mapcoordsmaxs keys of the worldspawn entity", NULL ); gtk_widget_show( w ); } @@ -320,11 +313,9 @@ void InitBackgroundDialog(){ // GTK_STOCK_CLOSE, // GTK_RESPONSE_CLOSE, NULL ); - gtk_signal_connect( GTK_OBJECT( pDialogWnd ), "delete_event", - GTK_SIGNAL_FUNC( close_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( pDialogWnd ), "response", - GTK_SIGNAL_FUNC( response_callback ), NULL ); -// gtk_signal_connect( GTK_OBJECT (pDialogWnd), "expose_event", GTK_SIGNAL_FUNC( ci_expose ), NULL ); + pDialogWnd.connect( "delete_event", G_CALLBACK( close_callback ), NULL ); + pDialogWnd.connect( "response", G_CALLBACK( response_callback ), NULL ); +// pDialogWnd.connect( "expose_event", G_CALLBACK( ci_expose ), NULL ); pTooltips = gtk_tooltips_new(); diff --git a/contrib/bobtoolz/CMakeLists.txt b/contrib/bobtoolz/CMakeLists.txt index fb6f7fb0..c9b83cb7 100644 --- a/contrib/bobtoolz/CMakeLists.txt +++ b/contrib/bobtoolz/CMakeLists.txt @@ -26,7 +26,6 @@ radiant_plugin(bobtoolz resource-gtk.h ScriptParser.cpp ScriptParser.h shapes.cpp shapes.h - StdAfx.cpp StdAfx.h visfind.cpp visfind.h ) diff --git a/contrib/bobtoolz/StdAfx.cpp b/contrib/bobtoolz/StdAfx.cpp deleted file mode 100644 index 5c7495fa..00000000 --- a/contrib/bobtoolz/StdAfx.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - BobToolz plugin for GtkRadiant - Copyright (C) 2001 Gordon Biggans - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -// stdafx.cpp : source file that includes just the standard includes -// plugin.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "StdAfx.h" diff --git a/contrib/bobtoolz/StdAfx.h b/contrib/bobtoolz/StdAfx.h deleted file mode 100644 index cfce5a4e..00000000 --- a/contrib/bobtoolz/StdAfx.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - BobToolz plugin for GtkRadiant - Copyright (C) 2001 Gordon Biggans - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __STDAFX_BOBTOOLZ__ -#define __STDAFX_BOBTOOLZ__ - - - -#endif diff --git a/contrib/bobtoolz/bobToolz-GTK.cpp b/contrib/bobtoolz/bobToolz-GTK.cpp index 4eecfd92..6cf91a0b 100644 --- a/contrib/bobtoolz/bobToolz-GTK.cpp +++ b/contrib/bobtoolz/bobToolz-GTK.cpp @@ -63,7 +63,7 @@ char* PLUGIN_NAME = "bobToolz"; static char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge"; // globals -GtkWidget *g_pRadiantWnd = NULL; +ui::Widget g_pRadiantWnd; static const char *PLUGIN_ABOUT = "bobToolz for SDRadiant\n" "by digibob (digibob@splashdamage.com)\n" @@ -72,7 +72,7 @@ static const char *PLUGIN_ABOUT = "bobToolz for SDRadiant\n" "MarsMattel, RR2DO2\n"; extern "C" const char* QERPlug_Init( void* hApp, void* pMainWidget ) { - g_pRadiantWnd = (GtkWidget*)pMainWidget; + g_pRadiantWnd = ui::Widget::from(pMainWidget); return "bobToolz for GTKradiant"; } diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index b596f059..41e4d410 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -34,17 +34,17 @@ ---------------------------------*/ typedef struct { - GtkWidget *cbTexChange; - GtkWidget *editTexOld, *editTexNew; + ui::Widget cbTexChange; + ui::Widget editTexOld, editTexNew; - GtkWidget *cbScaleHor, *cbScaleVert; - GtkWidget *editScaleHor, *editScaleVert; + ui::Widget cbScaleHor, cbScaleVert; + ui::Widget editScaleHor, editScaleVert; - GtkWidget *cbShiftHor, *cbShiftVert; - GtkWidget *editShiftHor, *editShiftVert; + ui::Widget cbShiftHor, cbShiftVert; + ui::Widget editShiftHor, editShiftVert; - GtkWidget *cbRotation; - GtkWidget *editRotation; + ui::Widget cbRotation; + ui::Widget editRotation; }dlg_texReset_t; dlg_texReset_t dlgTexReset; @@ -59,23 +59,23 @@ void Update_TextureReseter(){ gboolean check; check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editTexNew ), check ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editTexOld ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editTexNew ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editTexOld ), check ); check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editScaleHor ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleHor ), check ); check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editScaleVert ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleVert ), check ); check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editShiftHor ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftHor ), check ); check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editShiftVert ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftVert ), check ); check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) ); - gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editRotation ), check ); + gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editRotation ), check ); } static void dialog_button_callback( GtkWidget *widget, gpointer data ){ @@ -105,9 +105,9 @@ static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){ TwinWidget* tw = (TwinWidget*)data; GtkEntry* entry = GTK_ENTRY( tw->one ); - GtkCombo* combo = GTK_COMBO( tw->two ); + auto* combo = GTK_BIN(tw->two); - const gchar* tex = gtk_entry_get_text( GTK_ENTRY( combo->entry ) ); + const gchar *tex = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(combo))); gtk_entry_set_text( entry, tex ); } @@ -209,100 +209,90 @@ bool ValidateTextInt( const char* pData, char* error_title, int* value ){ */ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ){ - GtkWidget *window, *w, *vbox, *hbox; + ui::Widget w, vbox, hbox; EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + auto window = ui::Window( ui::window_type::TOP ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), lpCaption ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); - w = gtk_label_new( lpText ); + w = ui::Label( lpText ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); - w = gtk_hseparator_new(); + w = ui::Widget(gtk_hseparator_new()); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_widget_show( w ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); if ( type == eMB_OK ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + gtk_widget_set_can_default(w, true); gtk_widget_grab_default( w ); gtk_widget_show( w ); ret = eIDOK; } else if ( type == eMB_OKCANCEL ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; } else if ( type == eMB_YESNOCANCEL ) { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; } else /* if (mode == MB_YESNO) */ { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); gtk_widget_show( w ); ret = eIDNO; } @@ -321,19 +311,18 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess } EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ - GtkWidget *window, *w, *vbox, *hbox; - GtkWidget *radio1, *radio2; + GtkWidget *hbox; GtkWidget *check1, *check2; EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Intersect" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -342,50 +331,50 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); // ---- vbox ---- - radio1 = gtk_radio_button_new_with_label( NULL, "Use Whole Map" ); + auto radio1 = gtk_radio_button_new_with_label( NULL, "Use Whole Map" ); gtk_box_pack_start( GTK_BOX( vbox ), radio1, FALSE, FALSE, 2 ); gtk_widget_show( radio1 ); - radio2 = gtk_radio_button_new_with_label( ( (GtkRadioButton*)radio1 )->group, "Use Selected Brushes" ); + auto radio2 = gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" ); gtk_box_pack_start( GTK_BOX( vbox ), radio2, FALSE, FALSE, 2 ); gtk_widget_show( radio2 ); - w = gtk_hseparator_new(); - gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); - gtk_widget_show( w ); + auto hsep = ui::Widget(gtk_hseparator_new()); + gtk_box_pack_start( GTK_BOX( vbox ), hsep, FALSE, FALSE, 2 ); + hsep.show(); - check1 = gtk_check_button_new_with_label( "Include Detail Brushes" ); + check1 = ui::CheckButton( "Include Detail Brushes" ); gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 ); gtk_widget_show( check1 ); - check2 = gtk_check_button_new_with_label( "Select Duplicate Brushes Only" ); + check2 = ui::CheckButton( "Select Duplicate Brushes Only" ); gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 ); gtk_widget_show( check2 ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- ok/cancel buttons - w = gtk_button_new_with_label( "Ok" ); + auto w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -417,7 +406,7 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ } EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ - GtkWidget *window, *w, *vbox, *hbox, *vbox2, *hbox2; + GtkWidget *hbox, *vbox2, *hbox2; GtkWidget *check1, *check2, *check3; GtkWidget *text1, *text2; @@ -425,13 +414,13 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Polygon Builder" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -440,58 +429,58 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); + vbox.show(); // ---- vbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - vbox2 = gtk_vbox_new( FALSE, 10 ); + vbox2 = ui::VBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 ); gtk_widget_show( vbox2 ); // ---- vbox2 ---- - hbox2 = gtk_hbox_new( FALSE, 10 ); + hbox2 = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 ); gtk_widget_show( hbox2 ); // ---- hbox2 ---- - text1 = gtk_entry_new_with_max_length( 256 ); + text1 = ui::Entry( 256 ); gtk_entry_set_text( (GtkEntry*)text1, "3" ); gtk_box_pack_start( GTK_BOX( hbox2 ), text1, FALSE, FALSE, 2 ); gtk_widget_show( text1 ); - w = gtk_label_new( "Number Of Sides" ); - gtk_box_pack_start( GTK_BOX( hbox2 ), w, FALSE, FALSE, 2 ); - gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); - gtk_widget_show( w ); + auto l = ui::Label( "Number Of Sides" ); + gtk_box_pack_start( GTK_BOX( hbox2 ), l, FALSE, FALSE, 2 ); + gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT ); + gtk_widget_show( l ); // ---- /hbox2 ---- - hbox2 = gtk_hbox_new( FALSE, 10 ); + hbox2 = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 ); gtk_widget_show( hbox2 ); // ---- hbox2 ---- - text2 = gtk_entry_new_with_max_length( 256 ); + text2 = ui::Entry( 256 ); gtk_entry_set_text( (GtkEntry*)text2, "8" ); gtk_box_pack_start( GTK_BOX( hbox2 ), text2, FALSE, FALSE, 2 ); gtk_widget_show( text2 ); - w = gtk_label_new( "Border Width" ); - gtk_box_pack_start( GTK_BOX( hbox2 ), w, FALSE, FALSE, 2 ); - gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); - gtk_widget_show( w ); + l = ui::Label( "Border Width" ); + gtk_box_pack_start( GTK_BOX( hbox2 ), l, FALSE, FALSE, 2 ); + gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT ); + gtk_widget_show( l ); // ---- /hbox2 ---- @@ -499,23 +488,23 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ - vbox2 = gtk_vbox_new( FALSE, 10 ); + vbox2 = ui::VBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 ); gtk_widget_show( vbox2 ); // ---- vbox2 ---- - check1 = gtk_check_button_new_with_label( "Use Border" ); + check1 = ui::CheckButton( "Use Border" ); gtk_box_pack_start( GTK_BOX( vbox2 ), check1, FALSE, FALSE, 0 ); gtk_widget_show( check1 ); - check2 = gtk_check_button_new_with_label( "Inverse Polygon" ); + check2 = ui::CheckButton( "Inverse Polygon" ); gtk_box_pack_start( GTK_BOX( vbox2 ), check2, FALSE, FALSE, 0 ); gtk_widget_show( check2 ); - check3 = gtk_check_button_new_with_label( "Align Top Edge" ); + check3 = ui::CheckButton( "Align Top Edge" ); gtk_box_pack_start( GTK_BOX( vbox2 ), check3, FALSE, FALSE, 0 ); gtk_widget_show( check3 ); @@ -523,23 +512,23 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ // ---- /hbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - w = gtk_button_new_with_label( "Ok" ); + auto w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -587,8 +576,6 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ // for stair builder stuck as close as i could to the MFC version // obviously feel free to change it at will :) EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ - // i made widgets for just about everything ... i think that's what i need to do dunno tho - GtkWidget *window, *w, *vbox, *hbox; GtkWidget *textStairHeight, *textRiserTex, *textMainTex; GtkWidget *radioNorth, *radioSouth, *radioEast, *radioWest; // i'm guessing we can't just abuse 'w' for these if we're getting a value GtkWidget *radioOldStyle, *radioBobStyle, *radioCornerStyle; @@ -597,16 +584,16 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ EMessageBoxReturn ret; int loop = 1; - char *text = "Please set a value in the boxes below and press 'OK' to build the stairs"; + char *text = "Please set a value in the boxes below and press 'OK' to build the stairs"; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Stair Builder" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -614,51 +601,51 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_widget_realize( window ); // new vbox - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); - hbox = gtk_hbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( vbox ), hbox ); + auto hbox = ui::HBox( FALSE, 10 ); + vbox.add(hbox); gtk_widget_show( hbox ); // dunno if you want this text or not ... - w = gtk_label_new( text ); + ui::Widget w = ui::Label( text ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ... gtk_widget_show( w ); - w = gtk_hseparator_new(); + w = ui::Widget(gtk_hseparator_new()); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); // ------------------------- // indenting == good way of keeping track of lines :) // new hbox - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textStairHeight = gtk_entry_new_with_max_length( 256 ); + textStairHeight = ui::Entry( 256 ); gtk_box_pack_start( GTK_BOX( hbox ), textStairHeight, FALSE, FALSE, 1 ); gtk_widget_show( textStairHeight ); - w = gtk_label_new( "Stair Height" ); + w = ui::Label( "Stair Height" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); // ------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Direction:" ); + w = ui::Label( "Direction:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 ); gtk_widget_show( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); @@ -672,19 +659,19 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), radioNorth, FALSE, FALSE, 3 ); gtk_widget_show( radioNorth ); - radioDirection = gtk_radio_button_group( GTK_RADIO_BUTTON( radioNorth ) ); + radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNorth ) ); radioSouth = gtk_radio_button_new_with_label( radioDirection, "South" ); gtk_box_pack_start( GTK_BOX( hbox ), radioSouth, FALSE, FALSE, 2 ); gtk_widget_show( radioSouth ); - radioDirection = gtk_radio_button_group( GTK_RADIO_BUTTON( radioSouth ) ); + radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioSouth ) ); radioEast = gtk_radio_button_new_with_label( radioDirection, "East" ); gtk_box_pack_start( GTK_BOX( hbox ), radioEast, FALSE, FALSE, 1 ); gtk_widget_show( radioEast ); - radioDirection = gtk_radio_button_group( GTK_RADIO_BUTTON( radioEast ) ); + radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioEast ) ); radioWest = gtk_radio_button_new_with_label( radioDirection, "West" ); gtk_box_pack_start( GTK_BOX( hbox ), radioWest, FALSE, FALSE, 0 ); @@ -692,17 +679,17 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ // --------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Style:" ); + w = ui::Label( "Style:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 ); gtk_widget_show( w ); // --------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); @@ -710,13 +697,13 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), radioOldStyle, FALSE, FALSE, 0 ); gtk_widget_show( radioOldStyle ); - radioStyle = gtk_radio_button_group( GTK_RADIO_BUTTON( radioOldStyle ) ); + radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioOldStyle ) ); radioBobStyle = gtk_radio_button_new_with_label( radioStyle, "Bob's Style" ); gtk_box_pack_start( GTK_BOX( hbox ), radioBobStyle, FALSE, FALSE, 0 ); gtk_widget_show( radioBobStyle ); - radioStyle = gtk_radio_button_group( GTK_RADIO_BUTTON( radioBobStyle ) ); + radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioBobStyle ) ); radioCornerStyle = gtk_radio_button_new_with_label( radioStyle, "Corner Style" ); gtk_box_pack_start( GTK_BOX( hbox ), radioCornerStyle, FALSE, FALSE, 0 ); @@ -729,58 +716,58 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ // djbob: think we need some button callback functions or smuffin // FIXME: actually get around to doing what i suggested!!!! - checkUseDetail = gtk_check_button_new_with_label( "Use Detail Brushes" ); + checkUseDetail = ui::CheckButton( "Use Detail Brushes" ); gtk_box_pack_start( GTK_BOX( hbox ), checkUseDetail, FALSE, FALSE, 0 ); gtk_widget_show( checkUseDetail ); // --------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textMainTex = gtk_entry_new_with_max_length( 512 ); + textMainTex = ui::Entry( 512 ); gtk_entry_set_text( GTK_ENTRY( textMainTex ), rs->mainTexture ); gtk_box_pack_start( GTK_BOX( hbox ), textMainTex, FALSE, FALSE, 0 ); gtk_widget_show( textMainTex ); - w = gtk_label_new( "Main Texture" ); + w = ui::Label( "Main Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textRiserTex = gtk_entry_new_with_max_length( 512 ); + textRiserTex = ui::Entry( 512 ); gtk_box_pack_start( GTK_BOX( hbox ), textRiserTex, FALSE, FALSE, 0 ); gtk_widget_show( textRiserTex ); - w = gtk_label_new( "Riser Texture" ); + w = ui::Label( "Riser Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); // -------------------------- // - w = gtk_hseparator_new(); + w = ui::Widget(gtk_hseparator_new()); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "OK" ); + w = ui::Button( "OK" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -844,25 +831,22 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ } EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ - GtkWidget *window, *hbox, *vbox, *w; - GtkWidget *textFrontBackTex, *textTrimTex; + GtkWidget *hbox; GtkWidget *checkScaleMainH, *checkScaleMainV, *checkScaleTrimH, *checkScaleTrimV; - GtkWidget *comboMain, *comboTrim; - GtkWidget *buttonSetMain, *buttonSetTrim; GtkWidget *radioNS, *radioEW; GSList *radioOrientation; TwinWidget tw1, tw2; EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Door Builder" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -870,126 +854,124 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ gtk_widget_realize( window ); char buffer[256]; - GList *listMainTextures = NULL; - GList *listTrimTextures = NULL; - LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), &listMainTextures ); - LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), &listTrimTextures ); + ui::ListStore listMainTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); + ui::ListStore listTrimTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); + LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures ); + LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures ); - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textFrontBackTex = gtk_entry_new_with_max_length( 512 ); + auto textFrontBackTex = ui::Entry( 512 ); gtk_entry_set_text( GTK_ENTRY( textFrontBackTex ), rs->mainTexture ); gtk_box_pack_start( GTK_BOX( hbox ), textFrontBackTex, FALSE, FALSE, 0 ); gtk_widget_show( textFrontBackTex ); - w = gtk_label_new( "Door Front/Back Texture" ); + ui::Widget w = ui::Label( "Door Front/Back Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); // ------------------------ // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textTrimTex = gtk_entry_new_with_max_length( 512 ); + auto textTrimTex = ui::Entry( 512 ); gtk_box_pack_start( GTK_BOX( hbox ), textTrimTex, FALSE, FALSE, 0 ); gtk_widget_show( textTrimTex ); - w = gtk_label_new( "Door Trim Texture" ); + w = ui::Label( "Door Trim Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); // ----------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); // sp: horizontally ???? // djbob: yes mars, u can spell :] - checkScaleMainH = gtk_check_button_new_with_label( "Scale Main Texture Horizontally" ); + checkScaleMainH = ui::CheckButton( "Scale Main Texture Horizontally" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainH ), TRUE ); gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainH, FALSE, FALSE, 0 ); gtk_widget_show( checkScaleMainH ); - checkScaleTrimH = gtk_check_button_new_with_label( "Scale Trim Texture Horizontally" ); + checkScaleTrimH = ui::CheckButton( "Scale Trim Texture Horizontally" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ), TRUE ); gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimH, FALSE, FALSE, 0 ); gtk_widget_show( checkScaleTrimH ); // ---------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - checkScaleMainV = gtk_check_button_new_with_label( "Scale Main Texture Vertically" ); + checkScaleMainV = ui::CheckButton( "Scale Main Texture Vertically" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainV ), TRUE ); gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainV, FALSE, FALSE, 0 ); gtk_widget_show( checkScaleMainV ); - checkScaleTrimV = gtk_check_button_new_with_label( "Scale Trim Texture Vertically" ); + checkScaleTrimV = ui::CheckButton( "Scale Trim Texture Vertically" ); gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimV, FALSE, FALSE, 0 ); gtk_widget_show( checkScaleTrimV ); // --------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); // djbob: lists added - comboMain = gtk_combo_new(); + auto comboMain = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listMainTextures)))); + gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0); gtk_box_pack_start( GTK_BOX( hbox ), comboMain, FALSE, FALSE, 0 ); - gtk_combo_set_popdown_strings( GTK_COMBO( comboMain ), listMainTextures ); - gtk_combo_set_use_arrows( GTK_COMBO( comboMain ), 1 ); gtk_widget_show( comboMain ); tw1.one = textFrontBackTex; tw1.two = comboMain; - buttonSetMain = gtk_button_new_with_label( "Set As Main Texture" ); - gtk_signal_connect( GTK_OBJECT( buttonSetMain ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback_settex ), &tw1 ); + auto buttonSetMain = ui::Button( "Set As Main Texture" ); + buttonSetMain.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw1 ); gtk_box_pack_start( GTK_BOX( hbox ), buttonSetMain, FALSE, FALSE, 0 ); gtk_widget_show( buttonSetMain ); // ------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - comboTrim = gtk_combo_new(); + auto comboTrim = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listTrimTextures)))); + gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0); gtk_box_pack_start( GTK_BOX( hbox ), comboTrim, FALSE, FALSE, 0 ); - gtk_combo_set_popdown_strings( GTK_COMBO( comboTrim ), listTrimTextures ); - gtk_combo_set_use_arrows( GTK_COMBO( comboMain ), 1 ); gtk_widget_show( comboTrim ); tw2.one = textTrimTex; tw2.two = comboTrim; - buttonSetTrim = gtk_button_new_with_label( "Set As Trim Texture" ); - gtk_signal_connect( GTK_OBJECT( buttonSetTrim ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback_settex ), &tw2 ); + auto buttonSetTrim = ui::Button( "Set As Trim Texture" ); + buttonSetTrim.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw2 ); gtk_box_pack_start( GTK_BOX( hbox ), buttonSetTrim, FALSE, FALSE, 0 ); gtk_widget_show( buttonSetTrim ); // ------------------ // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Orientation" ); + w = ui::Label( "Orientation" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -998,7 +980,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), radioNS, FALSE, FALSE, 0 ); gtk_widget_show( radioNS ); - radioOrientation = gtk_radio_button_group( GTK_RADIO_BUTTON( radioNS ) ); + radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) ); radioEW = gtk_radio_button_new_with_label( radioOrientation, "East - West" ); gtk_box_pack_start( GTK_BOX( hbox ), radioEW, FALSE, FALSE, 0 ); @@ -1006,26 +988,26 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ // ----------------- // - w = gtk_hseparator_new(); + w = ui::Widget(gtk_hseparator_new()); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); // ----------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "OK" ); + w = ui::Button( "OK" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -1062,21 +1044,21 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ } EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ - GtkWidget *window, *w, *vbox, *hbox; + ui::Widget w, hbox; - GtkWidget *text1, *text2, *text3; - GtkWidget *check1, *check2; + ui::Entry text1, text2, text3; + ui::Widget check1, check2; EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -1085,80 +1067,80 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); // ---- vbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - text1 = gtk_entry_new_with_max_length( 256 ); - gtk_entry_set_text( (GtkEntry*)text1, "25" ); + text1 = ui::Entry( 256 ); + gtk_entry_set_text( text1, "25" ); gtk_box_pack_start( GTK_BOX( hbox ), text1, FALSE, FALSE, 2 ); gtk_widget_show( text1 ); - w = gtk_label_new( "Number Of Points" ); + w = ui::Label( "Number Of Points" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); // ---- /hbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - text2 = gtk_entry_new_with_max_length( 256 ); - gtk_entry_set_text( (GtkEntry*)text2, "3" ); + text2 = ui::Entry( 256 ); + gtk_entry_set_text( text2, "3" ); gtk_box_pack_start( GTK_BOX( hbox ), text2, FALSE, FALSE, 2 ); gtk_widget_show( text2 ); - w = gtk_label_new( "Multipler" ); + w = ui::Label( "Multipler" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); // ---- /hbox ---- - w = gtk_label_new( "Path Distance = dist(start -> apex) * multiplier" ); + w = ui::Label( "Path Distance = dist(start -> apex) * multiplier" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - text3 = gtk_entry_new_with_max_length( 256 ); - gtk_entry_set_text( (GtkEntry*)text3, "-800" ); + text3 = ui::Entry( 256 ); + gtk_entry_set_text( text3, "-800" ); gtk_box_pack_start( GTK_BOX( hbox ), text3, FALSE, FALSE, 2 ); gtk_widget_show( text3 ); - w = gtk_label_new( "Gravity" ); + w = ui::Label( "Gravity" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); // ---- /hbox ---- - w = gtk_hseparator_new(); + w = ui::Widget(gtk_hseparator_new()); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - check1 = gtk_check_button_new_with_label( "No Dynamic Update" ); + check1 = ui::CheckButton( "No Dynamic Update" ); gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 ); gtk_widget_show( check1 ); - check2 = gtk_check_button_new_with_label( "Show Bounding Lines" ); + check2 = ui::CheckButton( "Show Bounding Lines" ); gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 ); gtk_widget_show( check2 ); @@ -1167,32 +1149,32 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ // ----------------- // - w = gtk_hseparator_new(); + w = ui::Widget(gtk_hseparator_new()); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); // ----------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Enable" ); + w = ui::Button( "Enable" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); gtk_widget_show( w ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); - w = gtk_button_new_with_label( "Disable" ); + w = ui::Button( "Disable" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -1237,17 +1219,17 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ } EMessageBoxReturn DoCTFColourChangeBox(){ - GtkWidget *window, *w, *vbox, *hbox; + ui::Widget w, hbox; EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "CTF Colour Changer" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -1256,34 +1238,34 @@ EMessageBoxReturn DoCTFColourChangeBox(){ - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); // ---- vbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 ); gtk_widget_show( hbox ); // ---- hbox ---- ok/cancel buttons - w = gtk_button_new_with_label( "Red->Blue" ); + w = ui::Button( "Red->Blue" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Blue->Red" ); + w = ui::Button( "Blue->Red" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -1307,31 +1289,31 @@ EMessageBoxReturn DoCTFColourChangeBox(){ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ Str texSelected; - GtkWidget *window, *w, *vbox, *hbox, *frame, *table; + ui::Widget w, hbox; EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); + vbox.show(); // ---- vbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); @@ -1340,53 +1322,53 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ texSelected = "Currently Selected Texture: "; texSelected += GetCurrentTexture(); - w = gtk_label_new( texSelected ); + w = ui::Label( texSelected ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); // ---- /hbox ---- - frame = gtk_frame_new( "Reset Texture Names" ); + auto frame = ui::Frame( "Reset Texture Names" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + auto table = ui::Table( 2, 3, TRUE ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); // ---- frame ---- - dlgTexReset.cbTexChange = gtk_check_button_new_with_label( "Enabled" ); - gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbTexChange ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL ); + dlgTexReset.cbTexChange = ui::CheckButton( "Enabled" ); + dlgTexReset.cbTexChange.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL ); gtk_widget_show( dlgTexReset.cbTexChange ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbTexChange, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "Old Name: " ); + w = ui::Label( "Old Name: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editTexOld = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editTexOld = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexOld ), rs->textureName ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexOld, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( dlgTexReset.editTexOld ); - w = gtk_label_new( "New Name: " ); + w = ui::Label( "New Name: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editTexNew = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editTexNew = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexNew ), rs->textureName ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexNew, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1395,33 +1377,33 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- /frame ---- - frame = gtk_frame_new( "Reset Scales" ); + frame = ui::Frame( "Reset Scales" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table = ui::Table( 2, 3, TRUE ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); // ---- frame ---- - dlgTexReset.cbScaleHor = gtk_check_button_new_with_label( "Enabled" ); - gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbScaleHor ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL ); + dlgTexReset.cbScaleHor = ui::CheckButton( "Enabled" ); + dlgTexReset.cbScaleHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL ); gtk_widget_show( dlgTexReset.cbScaleHor ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleHor, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Horizontal Scale: " ); + w = ui::Label( "New Horizontal Scale: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editScaleHor = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editScaleHor = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleHor ), "0.5" ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleHor, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1429,20 +1411,20 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ gtk_widget_show( dlgTexReset.editScaleHor ); - dlgTexReset.cbScaleVert = gtk_check_button_new_with_label( "Enabled" ); - gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbScaleVert ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL ); + dlgTexReset.cbScaleVert = ui::CheckButton( "Enabled" ); + dlgTexReset.cbScaleVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL ); gtk_widget_show( dlgTexReset.cbScaleVert ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleVert, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Vertical Scale: " ); + w = ui::Label( "New Vertical Scale: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editScaleVert = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editScaleVert = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleVert ), "0.5" ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleVert, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1451,33 +1433,33 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- /frame ---- - frame = gtk_frame_new( "Reset Shift" ); + frame = ui::Frame( "Reset Shift" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table = ui::Table( 2, 3, TRUE ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); // ---- frame ---- - dlgTexReset.cbShiftHor = gtk_check_button_new_with_label( "Enabled" ); - gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbShiftHor ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL ); + dlgTexReset.cbShiftHor = ui::CheckButton( "Enabled" ); + dlgTexReset.cbShiftHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL ); gtk_widget_show( dlgTexReset.cbShiftHor ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftHor, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Horizontal Shift: " ); + w = ui::Label( "New Horizontal Shift: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editShiftHor = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editShiftHor = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftHor ), "0" ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftHor, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1485,20 +1467,20 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ gtk_widget_show( dlgTexReset.editShiftHor ); - dlgTexReset.cbShiftVert = gtk_check_button_new_with_label( "Enabled" ); - gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbShiftVert ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL ); + dlgTexReset.cbShiftVert = ui::CheckButton( "Enabled" ); + dlgTexReset.cbShiftVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL ); gtk_widget_show( dlgTexReset.cbShiftVert ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftVert, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Vertical Shift: " ); + w = ui::Label( "New Vertical Shift: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editShiftVert = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editShiftVert = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftVert ), "0" ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftVert, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1507,32 +1489,32 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- /frame ---- - frame = gtk_frame_new( "Reset Rotation" ); + frame = ui::Frame( "Reset Rotation" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 1, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table = ui::Table( 1, 3, TRUE ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); // ---- frame ---- - dlgTexReset.cbRotation = gtk_check_button_new_with_label( "Enabled" ); + dlgTexReset.cbRotation = ui::CheckButton( "Enabled" ); gtk_widget_show( dlgTexReset.cbRotation ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbRotation, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Rotation Value: " ); + w = ui::Label( "New Rotation Value: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - dlgTexReset.editRotation = gtk_entry_new_with_max_length( 256 ); + dlgTexReset.editRotation = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editRotation ), "0" ); gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editRotation, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1541,28 +1523,28 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- /frame ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - w = gtk_button_new_with_label( "Use Selected Brushes" ); + w = ui::Button( "Use Selected Brushes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Use All Brushes" ); + w = ui::Button( "Use All Brushes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -1638,61 +1620,61 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ Str texSelected; - GtkWidget *window, *w, *vbox, *hbox, *frame, *table; + ui::Widget w, hbox; - GtkWidget *radiusX, *radiusY; - GtkWidget *angleStart, *angleEnd; - GtkWidget *heightStart, *heightEnd; - GtkWidget *numPoints; + ui::Widget radiusX, radiusY; + ui::Widget angleStart, angleEnd; + ui::Widget heightStart, heightEnd; + ui::Widget numPoints; EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Train Thing" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); - gtk_object_set_data( GTK_OBJECT( window ), "loop", &loop ); - gtk_object_set_data( GTK_OBJECT( window ), "ret", &ret ); + g_object_set_data( G_OBJECT( window ), "loop", &loop ); + g_object_set_data( G_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); + vbox.show(); // ---- vbox ---- - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- /hbox ---- - frame = gtk_frame_new( "Radii" ); + auto frame = ui::Frame( "Radii" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + auto table = ui::Table( 2, 3, TRUE ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); // ---- frame ---- - w = gtk_label_new( "X: " ); + w = ui::Label( "X: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - radiusX = gtk_entry_new_with_max_length( 256 ); + radiusX = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( radiusX ), "100" ); gtk_table_attach( GTK_TABLE( table ), radiusX, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1701,13 +1683,13 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - w = gtk_label_new( "Y: " ); + w = ui::Label( "Y: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - radiusY = gtk_entry_new_with_max_length( 256 ); + radiusY = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( radiusY ), "100" ); gtk_table_attach( GTK_TABLE( table ), radiusY, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1716,26 +1698,26 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - frame = gtk_frame_new( "Angles" ); + frame = ui::Frame( "Angles" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table = ui::Table( 2, 3, TRUE ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); // ---- frame ---- - w = gtk_label_new( "Start: " ); + w = ui::Label( "Start: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - angleStart = gtk_entry_new_with_max_length( 256 ); + angleStart = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( angleStart ), "0" ); gtk_table_attach( GTK_TABLE( table ), angleStart, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1744,13 +1726,13 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - w = gtk_label_new( "End: " ); + w = ui::Label( "End: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - angleEnd = gtk_entry_new_with_max_length( 256 ); + angleEnd = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( angleEnd ), "90" ); gtk_table_attach( GTK_TABLE( table ), angleEnd, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1758,26 +1740,26 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ gtk_widget_show( angleEnd ); - frame = gtk_frame_new( "Height" ); + frame = ui::Frame( "Height" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table = ui::Table( 2, 3, TRUE ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); // ---- frame ---- - w = gtk_label_new( "Start: " ); + w = ui::Label( "Start: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - heightStart = gtk_entry_new_with_max_length( 256 ); + heightStart = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( heightStart ), "0" ); gtk_table_attach( GTK_TABLE( table ), heightStart, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1786,13 +1768,13 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - w = gtk_label_new( "End: " ); + w = ui::Label( "End: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - heightEnd = gtk_entry_new_with_max_length( 256 ); + heightEnd = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( heightEnd ), "0" ); gtk_table_attach( GTK_TABLE( table ), heightEnd, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1801,26 +1783,26 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - frame = gtk_frame_new( "Points" ); + frame = ui::Frame( "Points" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table = ui::Table( 2, 3, TRUE ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); // ---- frame ---- - w = gtk_label_new( "Number: " ); + w = ui::Label( "Number: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( w ); - numPoints = gtk_entry_new_with_max_length( 256 ); + numPoints = ui::Entry( 256 ); gtk_entry_set_text( GTK_ENTRY( numPoints ), "0" ); gtk_table_attach( GTK_TABLE( table ), numPoints, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1828,23 +1810,23 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ gtk_widget_show( numPoints ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); // ---- hbox ---- - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -1904,21 +1886,21 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ // ailmanki // add a simple input for the MakeChain thing.. EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ - GtkWidget *window, *w, *vbox, *hbox; - GtkWidget *textlinkNum, *textlinkName; + ui::Widget w; + ui::Entry textlinkNum, textlinkName; EMessageBoxReturn ret; int loop = 1; - char *text = "Please set a value in the boxes below and press 'OK' to make a chain"; + char const *text = "Please set a value in the boxes below and press 'OK' to make a chain"; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), "Make Chain" ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -1926,63 +1908,63 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ gtk_widget_realize( window ); // new vbox - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); + vbox.show(); - hbox = gtk_hbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( vbox ), hbox ); - gtk_widget_show( hbox ); + auto hbox = ui::HBox( FALSE, 10 ); + vbox.add(hbox); + hbox.show(); // dunno if you want this text or not ... - w = gtk_label_new( text ); + w = ui::Label( text ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_hseparator_new(); + w = ui::Widget(gtk_hseparator_new()); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); // ------------------------- // // new hbox - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textlinkNum = gtk_entry_new_with_max_length( 256 ); + textlinkNum = ui::Entry( 256 ); gtk_box_pack_start( GTK_BOX( hbox ), textlinkNum, FALSE, FALSE, 1 ); gtk_widget_show( textlinkNum ); - w = gtk_label_new( "Number of elements in chain" ); + w = ui::Label( "Number of elements in chain" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - textlinkName = gtk_entry_new_with_max_length( 256 ); + textlinkName = ui::Entry( 256 ); gtk_box_pack_start( GTK_BOX( hbox ), textlinkName, FALSE, FALSE, 0 ); gtk_widget_show( textlinkName ); - w = gtk_label_new( "Basename for chain's targetnames." ); + w = ui::Label( "Basename for chain's targetnames." ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "OK" ); + w = ui::Button( "OK" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -2001,8 +1983,8 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ dialogError = FALSE; if ( ret == eIDOK ) { - strcpy( rs->linkName, gtk_entry_get_text( (GtkEntry*)textlinkName ) ); - if ( !ValidateTextInt( gtk_entry_get_text( (GtkEntry*)textlinkNum ), "Elements", &rs->linkNum ) ) { + strcpy( rs->linkName, gtk_entry_get_text( textlinkName ) ); + if ( !ValidateTextInt( gtk_entry_get_text( textlinkNum ), "Elements", &rs->linkNum ) ) { dialogError = TRUE; } } @@ -2012,4 +1994,4 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ gtk_widget_destroy( window ); return ret; -} \ No newline at end of file +} diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.h b/contrib/bobtoolz/dialogs/dialogs-gtk.h index ae354904..a8490459 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.h +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.h @@ -90,11 +90,9 @@ struct MakeChainRS { int linkNum; }; -typedef struct _GtkWidget GtkWidget; - struct TwinWidget { - GtkWidget* one; - GtkWidget* two; + ui::Widget one{ui::null}; + ui::ComboBox two{ui::null}; }; EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ); diff --git a/contrib/bobtoolz/lists.cpp b/contrib/bobtoolz/lists.cpp index 81079839..96aff197 100644 --- a/contrib/bobtoolz/lists.cpp +++ b/contrib/bobtoolz/lists.cpp @@ -24,6 +24,7 @@ #endif #include +#include #include "misc.h" @@ -54,7 +55,7 @@ bool LoadExclusionList( char* filename, std::list* exclusionList ){ return FALSE; } -bool LoadGList( char* filename, GList** loadlist ){ +bool LoadGList( char* filename, ui::ListStore loadlist ){ FILE* eFile = fopen( filename, "r" ); if ( eFile ) { char buffer[256]; @@ -67,7 +68,9 @@ bool LoadGList( char* filename, GList** loadlist ){ if ( strlen( buffer ) > 0 ) { char* buffer2 = new char[strlen( buffer ) + 1]; strcpy( buffer2, buffer ); - *loadlist = g_list_append( *loadlist, buffer2 ); + GtkTreeIter iter; + gtk_list_store_append(loadlist, &iter); + gtk_list_store_set(loadlist, &iter, 0, buffer2, -1); } else{ cnt++; diff --git a/contrib/bobtoolz/lists.h b/contrib/bobtoolz/lists.h index 827c9cbc..7a8ecc18 100644 --- a/contrib/bobtoolz/lists.h +++ b/contrib/bobtoolz/lists.h @@ -18,8 +18,9 @@ */ #include +#include #include "str.h" typedef struct _GList GList; bool LoadExclusionList( char* filename, std::list* exclusionList ); -bool LoadGList( char* filename, GList** loadlist ); +bool LoadGList( char* filename, ui::ListStore loadlist ); diff --git a/contrib/bobtoolz/shapes.cpp b/contrib/bobtoolz/shapes.cpp index f466c515..2e47035d 100644 --- a/contrib/bobtoolz/shapes.cpp +++ b/contrib/bobtoolz/shapes.cpp @@ -58,9 +58,9 @@ / | / | / | / | 4 ----- 6 | - | 2|_|___|8 - | / | / - | / | / ----> WEST, definitely + | 2|_|___|8 + | / | / + | / | / ----> WEST, definitely ||/ | / 1|_____|/3 diff --git a/contrib/brushexport/callbacks.cpp b/contrib/brushexport/callbacks.cpp index 6a346f3a..29fb3263 100644 --- a/contrib/brushexport/callbacks.cpp +++ b/contrib/brushexport/callbacks.cpp @@ -18,8 +18,8 @@ void OnDestroy( GtkWidget* w, gpointer data ){ } void OnExportClicked( GtkButton* button, gpointer user_data ){ - GtkWidget* window = lookup_widget( GTK_WIDGET( button ), "w_plugplug2" ); - ASSERT_NOTNULL( window ); + ui::Widget window = lookup_widget( GTK_WIDGET( button ), "w_plugplug2" ); + ASSERT_TRUE( window ); const char* cpath = GlobalRadiant().m_pfnFileDialog( window, false, "Save as Obj", 0, 0, false, false, true ); if ( !cpath ) { return; @@ -31,7 +31,7 @@ void OnExportClicked( GtkButton* button, gpointer user_data ){ std::set ignore; GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) ); - GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( view ) ); + ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( view ) )); GtkTreeIter iter; gboolean valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( list ), &iter ); @@ -68,7 +68,7 @@ void OnExportClicked( GtkButton* button, gpointer user_data ){ { radio = lookup_widget( GTK_WIDGET( button ), "r_nocollapse" ); ASSERT_NOTNULL( radio ); - ASSERT_NOTNULL( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ); + ASSERT_TRUE( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ); mode = COLLAPSE_NONE; } } @@ -113,7 +113,7 @@ void OnAddMaterial( GtkButton* button, gpointer user_data ){ const gchar* name = gtk_entry_get_text( edit ); if ( g_utf8_strlen( name, -1 ) > 0 ) { - GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) ) ) ); + ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) ) ) )); GtkTreeIter iter; gtk_list_store_append( list, &iter ); gtk_list_store_set( list, &iter, 0, name, -1 ); @@ -123,7 +123,7 @@ void OnAddMaterial( GtkButton* button, gpointer user_data ){ void OnRemoveMaterial( GtkButton* button, gpointer user_data ){ GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) ); - GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( view ) ); + ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( view ) )); GtkTreeSelection* sel = gtk_tree_view_get_selection( view ); GtkTreeIter iter; diff --git a/contrib/brushexport/callbacks.h b/contrib/brushexport/callbacks.h index eea5aa8b..eece65a1 100644 --- a/contrib/brushexport/callbacks.h +++ b/contrib/brushexport/callbacks.h @@ -1,5 +1,3 @@ -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkButton GtkButton; namespace callbacks { diff --git a/contrib/brushexport/interface.cpp b/contrib/brushexport/interface.cpp index 76279ab0..c08ce71a 100644 --- a/contrib/brushexport/interface.cpp +++ b/contrib/brushexport/interface.cpp @@ -7,16 +7,14 @@ #define GLADE_HOOKUP_OBJECT( component,widget,name ) \ g_object_set_data_full( G_OBJECT( component ), name, \ - gtk_widget_ref( widget ), (GDestroyNotify) gtk_widget_unref ) + g_object_ref( (void *) widget ), (GDestroyNotify) g_object_unref ) #define GLADE_HOOKUP_OBJECT_NO_REF( component,widget,name ) \ - g_object_set_data( G_OBJECT( component ), name, widget ) + g_object_set_data( G_OBJECT( component ), name, (void *) widget ) // created by glade GtkWidget* create_w_plugplug2( void ){ - GtkWidget *w_plugplug2; - GtkWidget *vbox1; GtkWidget *hbox2; GtkWidget *vbox4; GtkWidget *r_collapse; @@ -24,49 +22,39 @@ create_w_plugplug2( void ){ GtkWidget *r_collapsebymaterial; GtkWidget *r_nocollapse; GtkWidget *vbox3; - GtkWidget *b_export; - GtkWidget *b_close; GtkWidget *vbox2; GtkWidget *label1; - GtkWidget *scrolledwindow1; - GtkWidget *t_materialist; GtkWidget *ed_materialname; GtkWidget *hbox1; - GtkWidget *b_addmaterial; - GtkWidget *b_removematerial; - GtkWidget *t_exportmaterials; GtkWidget *t_limitmatnames; GtkWidget *t_objects; - GtkTooltips *tooltips; - tooltips = gtk_tooltips_new(); - - w_plugplug2 = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto w_plugplug2 = ui::Window( ui::window_type::TOP ); gtk_widget_set_name( w_plugplug2, "w_plugplug2" ); gtk_window_set_title( GTK_WINDOW( w_plugplug2 ), "BrushExport-Plugin 3.0 by namespace" ); gtk_window_set_position( GTK_WINDOW( w_plugplug2 ), GTK_WIN_POS_CENTER ); gtk_window_set_destroy_with_parent( GTK_WINDOW( w_plugplug2 ), TRUE ); - vbox1 = gtk_vbox_new( FALSE, 0 ); + auto vbox1 = ui::VBox( FALSE, 0 ); gtk_widget_set_name( vbox1, "vbox1" ); gtk_widget_show( vbox1 ); - gtk_container_add( GTK_CONTAINER( w_plugplug2 ), vbox1 ); + w_plugplug2.add(vbox1); gtk_container_set_border_width( GTK_CONTAINER( vbox1 ), 5 ); - hbox2 = gtk_hbox_new( TRUE, 5 ); + hbox2 = ui::HBox( TRUE, 5 ); gtk_widget_set_name( hbox2, "hbox2" ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox1 ), hbox2, FALSE, FALSE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( hbox2 ), 5 ); - vbox4 = gtk_vbox_new( TRUE, 0 ); + vbox4 = ui::VBox( TRUE, 0 ); gtk_widget_set_name( vbox4, "vbox4" ); gtk_widget_show( vbox4 ); gtk_box_pack_start( GTK_BOX( hbox2 ), vbox4, TRUE, FALSE, 0 ); r_collapse = gtk_radio_button_new_with_mnemonic( NULL, "Collapse mesh" ); gtk_widget_set_name( r_collapse, "r_collapse" ); - gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), r_collapse, "Collapse all brushes into a single group", "Collapse all brushes into a single group" ); + gtk_widget_set_tooltip_text(r_collapse, "Collapse all brushes into a single group"); gtk_widget_show( r_collapse ); gtk_box_pack_start( GTK_BOX( vbox4 ), r_collapse, FALSE, FALSE, 0 ); gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_collapse ), r_collapse_group ); @@ -74,7 +62,7 @@ create_w_plugplug2( void ){ r_collapsebymaterial = gtk_radio_button_new_with_mnemonic( NULL, "Collapse by material" ); gtk_widget_set_name( r_collapsebymaterial, "r_collapsebymaterial" ); - gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), r_collapsebymaterial, "Collapse into groups by material", "Collapse into groups by material" ); + gtk_widget_set_tooltip_text(r_collapsebymaterial, "Collapse into groups by material"); gtk_widget_show( r_collapsebymaterial ); gtk_box_pack_start( GTK_BOX( vbox4 ), r_collapsebymaterial, FALSE, FALSE, 0 ); gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_collapsebymaterial ), r_collapse_group ); @@ -82,70 +70,70 @@ create_w_plugplug2( void ){ r_nocollapse = gtk_radio_button_new_with_mnemonic( NULL, "Don't collapse" ); gtk_widget_set_name( r_nocollapse, "r_nocollapse" ); - gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), r_nocollapse, "Every brush is stored in its own group", "Every brush is stored in its own group" ); + gtk_widget_set_tooltip_text(r_nocollapse, "Every brush is stored in its own group"); gtk_widget_show( r_nocollapse ); gtk_box_pack_start( GTK_BOX( vbox4 ), r_nocollapse, FALSE, FALSE, 0 ); gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_nocollapse ), r_collapse_group ); r_collapse_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( r_nocollapse ) ); - vbox3 = gtk_vbox_new( FALSE, 0 ); + vbox3 = ui::VBox( FALSE, 0 ); gtk_widget_set_name( vbox3, "vbox3" ); gtk_widget_show( vbox3 ); gtk_box_pack_start( GTK_BOX( hbox2 ), vbox3, FALSE, FALSE, 0 ); - b_export = gtk_button_new_from_stock( "gtk-save" ); + auto b_export = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-save" ))); gtk_widget_set_name( b_export, "b_export" ); gtk_widget_show( b_export ); gtk_box_pack_start( GTK_BOX( vbox3 ), b_export, TRUE, FALSE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( b_export ), 5 ); - b_close = gtk_button_new_from_stock( "gtk-cancel" ); + auto b_close = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-cancel" ))); gtk_widget_set_name( b_close, "b_close" ); gtk_widget_show( b_close ); gtk_box_pack_start( GTK_BOX( vbox3 ), b_close, TRUE, FALSE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( b_close ), 5 ); - vbox2 = gtk_vbox_new( FALSE, 5 ); + vbox2 = ui::VBox( FALSE, 5 ); gtk_widget_set_name( vbox2, "vbox2" ); gtk_widget_show( vbox2 ); gtk_box_pack_start( GTK_BOX( vbox1 ), vbox2, TRUE, TRUE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 2 ); - label1 = gtk_label_new( "Ignored materials:" ); + label1 = ui::Label( "Ignored materials:" ); gtk_widget_set_name( label1, "label1" ); gtk_widget_show( label1 ); gtk_box_pack_start( GTK_BOX( vbox2 ), label1, FALSE, FALSE, 0 ); - scrolledwindow1 = gtk_scrolled_window_new( NULL, NULL ); + auto scrolledwindow1 = ui::ScrolledWindow(); gtk_widget_set_name( scrolledwindow1, "scrolledwindow1" ); - gtk_widget_show( scrolledwindow1 ); + scrolledwindow1.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), scrolledwindow1, TRUE, TRUE, 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scrolledwindow1 ), GTK_SHADOW_IN ); - t_materialist = gtk_tree_view_new(); + auto t_materialist = ui::TreeView(); gtk_widget_set_name( t_materialist, "t_materialist" ); - gtk_widget_show( t_materialist ); - gtk_container_add( GTK_CONTAINER( scrolledwindow1 ), t_materialist ); + t_materialist.show(); + scrolledwindow1.add(t_materialist); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( t_materialist ), FALSE ); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( t_materialist ), FALSE ); - ed_materialname = gtk_entry_new(); + ed_materialname = ui::Entry(); gtk_widget_set_name( ed_materialname, "ed_materialname" ); gtk_widget_show( ed_materialname ); gtk_box_pack_start( GTK_BOX( vbox2 ), ed_materialname, FALSE, FALSE, 0 ); - hbox1 = gtk_hbox_new( TRUE, 0 ); + hbox1 = ui::HBox( TRUE, 0 ); gtk_widget_set_name( hbox1, "hbox1" ); gtk_widget_show( hbox1 ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox1, FALSE, FALSE, 0 ); - b_addmaterial = gtk_button_new_from_stock( "gtk-add" ); + auto b_addmaterial = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-add" ))); gtk_widget_set_name( b_addmaterial, "b_addmaterial" ); gtk_widget_show( b_addmaterial ); gtk_box_pack_start( GTK_BOX( hbox1 ), b_addmaterial, FALSE, FALSE, 0 ); - b_removematerial = gtk_button_new_from_stock( "gtk-remove" ); + auto b_removematerial = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-remove" ))); gtk_widget_set_name( b_removematerial, "b_removematerial" ); gtk_widget_show( b_removematerial ); gtk_box_pack_start( GTK_BOX( hbox1 ), b_removematerial, FALSE, FALSE, 0 ); @@ -160,20 +148,20 @@ create_w_plugplug2( void ){ gtk_widget_show( t_objects ); gtk_box_pack_end( GTK_BOX( vbox2 ), t_objects, FALSE, FALSE, 0 ); - t_exportmaterials = gtk_check_button_new_with_mnemonic( "Create material information (.mtl file)" ); + auto t_exportmaterials = ui::CheckButton(GTK_CHECK_BUTTON(gtk_check_button_new_with_mnemonic( "Create material information (.mtl file)" ))); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( t_exportmaterials ), true ); gtk_widget_set_name( t_exportmaterials, "t_exportmaterials" ); gtk_widget_show( t_exportmaterials ); gtk_box_pack_end( GTK_BOX( vbox2 ), t_exportmaterials, FALSE, FALSE, 10 ); using namespace callbacks; - g_signal_connect( G_OBJECT( w_plugplug2 ), "destroy", G_CALLBACK( OnDestroy ), NULL ); + w_plugplug2.connect( "destroy", G_CALLBACK( OnDestroy ), NULL ); g_signal_connect_swapped( G_OBJECT( b_close ), "clicked", G_CALLBACK( OnDestroy ), NULL ); - g_signal_connect( ( gpointer )b_export, "clicked", G_CALLBACK( OnExportClicked ), NULL ); - g_signal_connect( ( gpointer )b_addmaterial, "clicked", G_CALLBACK( OnAddMaterial ), NULL ); - g_signal_connect( ( gpointer )b_removematerial, "clicked", G_CALLBACK( OnRemoveMaterial ), NULL ); - g_signal_connect( ( gpointer )t_exportmaterials, "clicked", G_CALLBACK( OnExportMatClicked ), NULL ); + b_export.connect( "clicked", G_CALLBACK( OnExportClicked ), NULL ); + b_addmaterial.connect( "clicked", G_CALLBACK( OnAddMaterial ), NULL ); + b_removematerial.connect( "clicked", G_CALLBACK( OnRemoveMaterial ), NULL ); + t_exportmaterials.connect( "clicked", G_CALLBACK( OnExportMatClicked ), NULL ); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF( w_plugplug2, w_plugplug2, "w_plugplug2" ); @@ -206,7 +194,7 @@ GtkWidget* g_brushexp_window = 0; // spawn plugin window (and make sure it got destroyed first or never created) void CreateWindow( void ){ - ASSERT_NOTNULL( !g_brushexp_window ); + ASSERT_TRUE( !g_brushexp_window ); GtkWidget* wnd = create_w_plugplug2(); @@ -214,13 +202,13 @@ void CreateWindow( void ){ GtkTreeViewColumn* col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title( col, "materials" ); gtk_tree_view_append_column( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), col ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), -1, "", renderer, "text", 0, NULL ); // list store - GtkListStore* ignorelist = gtk_list_store_new( 1, G_TYPE_STRING ); + ui::ListStore ignorelist = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); gtk_tree_view_set_model( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), GTK_TREE_MODEL( ignorelist ) ); - g_object_unref( ignorelist ); + ignorelist.unref(); gtk_widget_show_all( wnd ); g_brushexp_window = wnd; diff --git a/contrib/brushexport/plugin.cpp b/contrib/brushexport/plugin.cpp index 274c840e..a2d0d621 100644 --- a/contrib/brushexport/plugin.cpp +++ b/contrib/brushexport/plugin.cpp @@ -24,7 +24,6 @@ #include "qerplugin.h" #include -#include #include "debugging/debugging.h" #include "string/string.h" @@ -50,11 +49,11 @@ bool IsWindowOpen( void ); namespace BrushExport { -GtkWindow* g_mainwnd; +ui::Window g_mainwnd{ui::null}; const char* init( void* hApp, void* pMainWidget ){ - g_mainwnd = (GtkWindow*)pMainWidget; - ASSERT_NOTNULL( g_mainwnd ); + g_mainwnd = ui::Window(GTK_WINDOW(pMainWidget)); + ASSERT_TRUE( g_mainwnd ); return ""; } const char* getName(){ @@ -69,7 +68,7 @@ const char* getCommandTitleList(){ void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ if ( string_equal( command, "About" ) ) { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ), "Brushexport plugin v 2.0 by namespace (www.codecreator.net)\n" + GlobalRadiant().m_pfnMessageBox( g_mainwnd, "Brushexport plugin v 2.0 by namespace (www.codecreator.net)\n" "Enjoy!\n\nSend feedback to spam@codecreator.net", "About me...", eMB_OK, eMB_ICONDEFAULT ); diff --git a/contrib/brushexport/support.cpp b/contrib/brushexport/support.cpp index 79c5e145..768f213a 100644 --- a/contrib/brushexport/support.cpp +++ b/contrib/brushexport/support.cpp @@ -1,8 +1,9 @@ #include +#include #include "support.h" -GtkWidget* +ui::Widget lookup_widget( GtkWidget *widget, const gchar *widget_name ){ GtkWidget *parent, *found_widget; @@ -13,7 +14,7 @@ lookup_widget( GtkWidget *widget, parent = gtk_menu_get_attach_widget( GTK_MENU( widget ) ); } else{ - parent = widget->parent; + parent = gtk_widget_get_parent(widget); } if ( !parent ) { parent = (GtkWidget*) g_object_get_data( G_OBJECT( widget ), "GladeParentKey" ); @@ -29,5 +30,5 @@ lookup_widget( GtkWidget *widget, if ( !found_widget ) { g_warning( "Widget not found: %s", widget_name ); } - return found_widget; + return ui::Widget(found_widget); } diff --git a/contrib/brushexport/support.h b/contrib/brushexport/support.h index e8f4cb04..a5bd9655 100644 --- a/contrib/brushexport/support.h +++ b/contrib/brushexport/support.h @@ -6,7 +6,7 @@ # include #endif -#include +#include /* * Public Functions. @@ -18,5 +18,5 @@ * or alternatively any widget in the component, and the name of the widget * you want returned. */ -GtkWidget* lookup_widget( GtkWidget *widget, +ui::Widget lookup_widget( GtkWidget *widget, const gchar *widget_name ); diff --git a/contrib/camera/camera.h b/contrib/camera/camera.h index 896ca1be..8f2091c5 100644 --- a/contrib/camera/camera.h +++ b/contrib/camera/camera.h @@ -48,7 +48,6 @@ extern _QERQglTable __QGLTABLENAME; #include "bytebool.h" class CCamera; -#include #include "str.h" diff --git a/contrib/camera/dialogs.cpp b/contrib/camera/dialogs.cpp index acd2fbd4..9425521d 100644 --- a/contrib/camera/dialogs.cpp +++ b/contrib/camera/dialogs.cpp @@ -61,7 +61,7 @@ static gint ci_editmode_add( GtkWidget *widget, gpointer data ){ }*/ static gint ci_new( GtkWidget *widget, gpointer data ){ - GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame; //, *name; + GtkWidget *w, *hbox; //, *name; GtkWidget *fixed, *interpolated, *spline; EMessageBoxReturn ret; int loop = 1; @@ -69,10 +69,10 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ // char buf[128]; // create the window - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "New Camera" ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -81,22 +81,22 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + window.add(vbox); + vbox.show(); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - frame = gtk_frame_new( "Type" ); + auto frame = ui::Frame( "Type" ); gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 ); gtk_widget_show( frame ); - vbox2 = gtk_vbox_new( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); + auto vbox2 = ui::VBox( FALSE, 5 ); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); gtk_widget_show( vbox2 ); @@ -105,17 +105,17 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ fixed = gtk_radio_button_new_with_label( targetTypeRadio, "Fixed" ); gtk_box_pack_start( GTK_BOX( vbox2 ), fixed, FALSE, FALSE, 3 ); gtk_widget_show( fixed ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( fixed ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( fixed ) ); interpolated = gtk_radio_button_new_with_label( targetTypeRadio, "Interpolated" ); gtk_box_pack_start( GTK_BOX( vbox2 ), interpolated, FALSE, FALSE, 3 ); gtk_widget_show( interpolated ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( interpolated ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( interpolated ) ); spline = gtk_radio_button_new_with_label( targetTypeRadio, "Spline" ); gtk_box_pack_start( GTK_BOX( vbox2 ), spline, FALSE, FALSE, 3 ); gtk_widget_show( spline ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( spline ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( spline ) ); // -------------------------- // @@ -125,21 +125,21 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); gtk_widget_show( w ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -314,7 +314,7 @@ static gint ci_pathlist_changed( GtkWidget *widget, gpointer data ){ } // start edit mode - if ( g_pCameraInspectorWnd && GTK_WIDGET_VISIBLE( g_pCameraInspectorWnd ) ) { + if ( g_pCameraInspectorWnd && gtk_widget_get_visible( g_pCameraInspectorWnd ) ) { DoStartEdit( GetCurrentCam() ); } @@ -353,7 +353,7 @@ static void RefreshEventList( void ){ } static gint ci_rename( GtkWidget *widget, gpointer data ){ - GtkWidget *window, *w, *vbox, *hbox, *name; + GtkWidget *w, *hbox, *name; EMessageBoxReturn ret; int loop = 1; @@ -362,10 +362,10 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ } // create the window - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Rename Path" ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -374,21 +374,21 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + window.add(vbox); + vbox.show(); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Name:" ); + w = ui::Label( "Name:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - name = gtk_entry_new(); + name = ui::Entry(); gtk_box_pack_start( GTK_BOX( hbox ), name, FALSE, FALSE, 0 ); gtk_widget_show( name ); @@ -407,21 +407,21 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); gtk_widget_show( w ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -469,7 +469,7 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ } static gint ci_add_target( GtkWidget *widget, gpointer data ){ - GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame, *name; + GtkWidget *w, *hbox, *name; GtkWidget *fixed, *interpolated, *spline; EMessageBoxReturn ret; int loop = 1; @@ -481,10 +481,10 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ } // create the window - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Add Target" ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -493,21 +493,21 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + window.add(vbox); + vbox.show(); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Name:" ); + w = ui::Label( "Name:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - name = gtk_entry_new(); + name = ui::Entry(); gtk_box_pack_start( GTK_BOX( hbox ), name, TRUE, TRUE, 0 ); gtk_widget_show( name ); @@ -516,16 +516,16 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - frame = gtk_frame_new( "Type" ); + auto frame = ui::Frame( "Type" ); gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 ); gtk_widget_show( frame ); - vbox2 = gtk_vbox_new( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); + auto vbox2 = ui::VBox( FALSE, 5 ); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); gtk_widget_show( vbox2 ); @@ -534,17 +534,17 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ fixed = gtk_radio_button_new_with_label( targetTypeRadio, "Fixed" ); gtk_box_pack_start( GTK_BOX( vbox2 ), fixed, FALSE, FALSE, 3 ); gtk_widget_show( fixed ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( fixed ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( fixed ) ); interpolated = gtk_radio_button_new_with_label( targetTypeRadio, "Interpolated" ); gtk_box_pack_start( GTK_BOX( vbox2 ), interpolated, FALSE, FALSE, 3 ); gtk_widget_show( interpolated ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( interpolated ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( interpolated ) ); spline = gtk_radio_button_new_with_label( targetTypeRadio, "Spline" ); gtk_box_pack_start( GTK_BOX( vbox2 ), spline, FALSE, FALSE, 3 ); gtk_widget_show( spline ); - targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( spline ) ); + targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( spline ) ); // -------------------------- // @@ -554,21 +554,21 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); gtk_widget_show( w ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -756,7 +756,7 @@ static gint ci_camlist_changed( GtkWidget *widget, gpointer data ){ // start edit mode g_iActiveTarget = -1; - if ( g_pCameraInspectorWnd && GTK_WIDGET_VISIBLE( g_pCameraInspectorWnd ) ) { + if ( g_pCameraInspectorWnd && gtk_widget_get_visible( g_pCameraInspectorWnd ) ) { DoStartEdit( GetCurrentCam() ); } @@ -817,7 +817,7 @@ const char *camEventStr[] = { }; static gint ci_add( GtkWidget *widget, gpointer data ){ - GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame, *parameters; + GtkWidget *w, *hbox, *parameters; GtkWidget *eventWidget[EVENT_COUNT]; EMessageBoxReturn ret; int i, loop = 1; @@ -829,10 +829,10 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ } // create the window - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Add Event" ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -841,22 +841,22 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + window.add(vbox); + vbox.show(); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - frame = gtk_frame_new( "Type" ); + auto frame = ui::Frame( "Type" ); gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 ); gtk_widget_show( frame ); - vbox2 = gtk_vbox_new( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); + auto vbox2 = ui::VBox( FALSE, 5 ); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); gtk_widget_show( vbox2 ); @@ -866,7 +866,7 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ eventWidget[i] = gtk_radio_button_new_with_label( eventTypeRadio, camEventStr[i] ); gtk_box_pack_start( GTK_BOX( vbox2 ), eventWidget[i], FALSE, FALSE, 3 ); gtk_widget_show( eventWidget[i] ); - eventTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( eventWidget[i] ) ); + eventTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( eventWidget[i] ) ); if ( camEventFlags[i][1] == false ) { gtk_widget_set_sensitive( eventWidget[i], FALSE ); } @@ -874,15 +874,15 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Parameters:" ); + w = ui::Label( "Parameters:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - parameters = gtk_entry_new(); + parameters = ui::Entry(); gtk_box_pack_start( GTK_BOX( hbox ), parameters, TRUE, TRUE, 0 ); gtk_widget_show( parameters ); @@ -894,21 +894,21 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); gtk_widget_show( w ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); + w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); gtk_widget_show( w ); ret = eIDCANCEL; @@ -992,14 +992,14 @@ static gint ci_timeline_changed( GtkAdjustment *adjustment ){ } GtkWidget *CreateCameraInspectorDialog( void ){ - GtkWidget *window, *w, *vbox, *hbox, *table, *frame; + GtkWidget *w, *hbox; // create the window - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Camera Inspector" ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( ci_close ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "expose_event", GTK_SIGNAL_FUNC( ci_expose ), NULL ); - // gtk_signal_connect( GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + window.connect( "delete_event", G_CALLBACK( ci_close ), NULL ); + window.connect( "expose_event", G_CALLBACK( ci_expose ), NULL ); + // window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) ); // don't use show, as you don't want to have it displayed on startup ;-) @@ -1010,9 +1010,9 @@ GtkWidget *CreateCameraInspectorDialog( void ){ // the table // -------------------------- // - table = gtk_table_new( 3, 2, FALSE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( window ), table ); + auto table = ui::Table( 3, 2, FALSE ); + table.show(); + window.add(table); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); @@ -1020,7 +1020,7 @@ GtkWidget *CreateCameraInspectorDialog( void ){ // the properties column // -------------------------- // - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1028,11 +1028,11 @@ GtkWidget *CreateCameraInspectorDialog( void ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "File:" ); + w = ui::Label( "File:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1042,52 +1042,52 @@ GtkWidget *CreateCameraInspectorDialog( void ){ // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Name:" ); + w = ui::Label( "Name:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - g_pCamName = gtk_entry_new(); + g_pCamName = ui::Entry(); gtk_box_pack_start( GTK_BOX( hbox ), g_pCamName, FALSE, FALSE, 0 ); gtk_widget_show( g_pCamName ); - w = gtk_label_new( "Type: " ); + w = ui::Label( "Type: " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "" ); + w = ui::Label( "" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pCamType = GTK_LABEL( w ); RefreshCamListCombo(); - gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO( g_pCamListCombo )->entry ), FALSE ); - gtk_signal_connect( GTK_OBJECT( GTK_COMBO( g_pCamListCombo )->entry ), "changed", GTK_SIGNAL_FUNC( ci_camlist_changed ), NULL ); + gtk_editable_set_editable( GTK_EDITABLE( GTK_COMBO( g_pCamListCombo )->entry ), FALSE ); + ( GTK_COMBO( g_pCamListCombo )->entry ).connect( "changed", G_CALLBACK( ci_camlist_changed ), NULL ); // -------------------------- // - frame = gtk_frame_new( "Path and Target editing" ); - gtk_widget_show( frame ); + auto frame = ui::Frame( "Path and Target editing" ); + frame.show(); gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + frame.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - gtk_widget_show( vbox ); + vbox.show(); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Edit:" ); + w = ui::Label( "Edit:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1097,28 +1097,28 @@ GtkWidget *CreateCameraInspectorDialog( void ){ RefreshPathListCombo(); - gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO( g_pPathListCombo )->entry ), FALSE ); - gtk_signal_connect( GTK_OBJECT( GTK_COMBO( g_pPathListCombo )->entry ), "changed", GTK_SIGNAL_FUNC( ci_pathlist_changed ), NULL ); + gtk_editable_set_editable( GTK_EDITABLE( GTK_COMBO( g_pPathListCombo )->entry ), FALSE ); + ( GTK_COMBO( g_pPathListCombo )->entry ).connect( "changed", G_CALLBACK( ci_pathlist_changed ), NULL ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); g_pEditModeEditRadioButton = gtk_radio_button_new_with_label( g_pEditTypeRadio, "Edit Points" ); gtk_box_pack_start( GTK_BOX( hbox ), g_pEditModeEditRadioButton, FALSE, FALSE, 3 ); gtk_widget_show( g_pEditModeEditRadioButton ); - g_pEditTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( g_pEditModeEditRadioButton ) ); + g_pEditTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( g_pEditModeEditRadioButton ) ); - gtk_signal_connect( GTK_OBJECT( g_pEditModeEditRadioButton ), "clicked", GTK_SIGNAL_FUNC( ci_editmode_edit ), NULL ); + g_pEditModeEditRadioButton.connect( "clicked", G_CALLBACK( ci_editmode_edit ), NULL ); g_pEditModeAddRadioButton = gtk_radio_button_new_with_label( g_pEditTypeRadio, "Add Points" ); gtk_box_pack_start( GTK_BOX( hbox ), g_pEditModeAddRadioButton, FALSE, FALSE, 3 ); gtk_widget_show( g_pEditModeAddRadioButton ); - g_pEditTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( g_pEditModeAddRadioButton ) ); + g_pEditTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( g_pEditModeAddRadioButton ) ); - gtk_signal_connect( GTK_OBJECT( g_pEditModeAddRadioButton ), "clicked", GTK_SIGNAL_FUNC( ci_editmode_add ), NULL ); + g_pEditModeAddRadioButton.connect( "clicked", G_CALLBACK( ci_editmode_add ), NULL ); // see if we should use a different default if ( g_iEditMode == 1 ) { @@ -1126,141 +1126,141 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( g_pEditModeAddRadioButton ), TRUE ); } - w = gtk_label_new( "Type: " ); + w = ui::Label( "Type: " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "" ); + w = ui::Label( "" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pPathType = GTK_LABEL( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_button_new_with_label( "Rename..." ); + w = ui::Button( "Rename..." ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_rename ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_rename ), NULL ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Add Target..." ); + w = ui::Button( "Add Target..." ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_add_target ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_add_target ), NULL ); gtk_widget_show( w ); // not available in splines library /*w = gtk_button_new_with_label( "Delete Selected" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_delete_selected ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_delete_selected ), NULL ); gtk_widget_show( w ); w = gtk_button_new_with_label( "Select All" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_select_all ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_select_all ), NULL ); gtk_widget_show( w );*/ // -------------------------- // - frame = gtk_frame_new( "Time" ); + frame = ui::Frame( "Time" ); gtk_widget_show( frame ); gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox ); + vbox = ui::VBox( FALSE, 5 ); + frame.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - gtk_widget_show( vbox ); + vbox.show(); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Length (seconds):" ); + w = ui::Label( "Length (seconds):" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - g_pSecondsEntry = gtk_entry_new(); + g_pSecondsEntry = ui::Entry(); gtk_box_pack_start( GTK_BOX( hbox ), g_pSecondsEntry, FALSE, FALSE, 0 ); gtk_widget_show( g_pSecondsEntry ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Current Time: " ); + w = ui::Label( "Current Time: " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "0.00" ); + w = ui::Label( "0.00" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pCurrentTime = GTK_LABEL( w ); - w = gtk_label_new( " of " ); + w = ui::Label( " of " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "0.00" ); + w = ui::Label( "0.00" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pTotalTime = GTK_LABEL( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - g_pTimeLine = GTK_ADJUSTMENT( gtk_adjustment_new( 0, 0, 30000, 100, 250, 0 ) ); - gtk_signal_connect( GTK_OBJECT( g_pTimeLine ), "value_changed", GTK_SIGNAL_FUNC( ci_timeline_changed ), NULL ); - w = gtk_hscale_new( g_pTimeLine ); + g_pTimeLine = ui::Adjustment( 0, 0, 30000, 100, 250, 0 ); + g_pTimeLine.connect( "value_changed", G_CALLBACK( ci_timeline_changed ), NULL ); + w = ui::HScale( g_pTimeLine ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_widget_show( w ); gtk_scale_set_draw_value( GTK_SCALE( w ), FALSE ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - g_pTrackCamera = gtk_check_button_new_with_label( "Track Camera" ); + g_pTrackCamera = ui::CheckButton( "Track Camera" ); gtk_box_pack_start( GTK_BOX( hbox ), g_pTrackCamera, FALSE, FALSE, 0 ); gtk_widget_show( g_pTrackCamera ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Events:" ); + w = ui::Label( "Events:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); // -------------------------- // - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_scrolled_window_new( NULL, NULL ); - gtk_widget_set_usize( w, 0, 150 ); + auto scr = w = ui::ScrolledWindow(); + gtk_widget_set_size_request( w, 0, 150 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( w ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_widget_show( w ); g_pEventsList = gtk_clist_new( 3 ); - gtk_container_add( GTK_CONTAINER( w ), g_pEventsList ); - //gtk_signal_connect( GTK_OBJECT(g_pEventsList), "select_row", GTK_SIGNAL_FUNC (proplist_select_row), NULL); + scr.add(g_pEventsList); + //g_pEventsList.connect( "select_row", G_CALLBACK (proplist_select_row), NULL); gtk_clist_set_selection_mode( GTK_CLIST( g_pEventsList ), GTK_SELECTION_BROWSE ); gtk_clist_column_titles_hide( GTK_CLIST( g_pEventsList ) ); gtk_clist_set_column_auto_resize( GTK_CLIST( g_pEventsList ), 0, TRUE ); @@ -1268,18 +1268,18 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_clist_set_column_auto_resize( GTK_CLIST( g_pEventsList ), 2, TRUE ); gtk_widget_show( g_pEventsList ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, FALSE, 0 ); gtk_widget_show( vbox ); - w = gtk_button_new_with_label( "Add..." ); + w = ui::Button( "Add..." ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_add ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_add ), NULL ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Del" ); + w = ui::Button( "Del" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_del ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_del ), NULL ); gtk_widget_show( w ); // -------------------------- // @@ -1301,12 +1301,12 @@ GtkWidget *CreateCameraInspectorDialog( void ){ w = gtk_button_new_with_label( "New..." ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_new ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_new ), NULL ); gtk_widget_show( w ); w = gtk_button_new_with_label( "Load..." ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_load ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_load ), NULL ); gtk_widget_show( w ); // -------------------------- // @@ -1319,12 +1319,12 @@ GtkWidget *CreateCameraInspectorDialog( void ){ w = gtk_button_new_with_label( "Save..." ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_save ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_save ), NULL ); gtk_widget_show( w ); w = gtk_button_new_with_label( "Unload" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_unload ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_unload ), NULL ); gtk_widget_show( w ); hbox = gtk_hbox_new( FALSE, 5 ); @@ -1333,12 +1333,12 @@ GtkWidget *CreateCameraInspectorDialog( void ){ w = gtk_button_new_with_label( "Apply" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_apply ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_apply ), NULL ); gtk_widget_show( w ); w = gtk_button_new_with_label( "Preview" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_preview ), NULL ); + w.connect( "clicked", G_CALLBACK( ci_preview ), NULL ); gtk_widget_show( w ); // -------------------------- // @@ -1355,8 +1355,8 @@ GtkWidget *CreateCameraInspectorDialog( void ){ w = gtk_button_new_with_label( "Close" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_close ), NULL ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", G_CALLBACK( ci_close ), NULL ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); diff --git a/contrib/gtkgensurf/gendlgs.cpp b/contrib/gtkgensurf/gendlgs.cpp index bfaf9849..881de8af 100644 --- a/contrib/gtkgensurf/gendlgs.cpp +++ b/contrib/gtkgensurf/gendlgs.cpp @@ -1344,9 +1344,9 @@ void create_tooltips(){ // create main dialog GtkWidget* create_main_dialog(){ - GtkWidget *dlg, *vbox, *hbox, *hbox2, *button, *notebook, *frame, *table, *table2; + GtkWidget *hbox2, *button, *notebook, *table2; GtkWidget *check, *spin, *radio, *label, *entry, *scale; - GtkObject *adj; + ui::Adjustment adj; GSList *group; int i; const char *games[] = { "Quake 2", "Half-Life", "SiN", "Heretic 2", "Kingpin", "Genesis3D", "Quake 3 Arena" }; @@ -1355,44 +1355,44 @@ GtkWidget* create_main_dialog(){ const char *orientations[] = { "Ground surface", "Ceiling", "Wall facing 0", "Wall facing 90", "Wall facing 180","Wall facing 270" }; - g_pWnd = dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto dlg = g_pWnd = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), gszCaption ); - g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( main_close ), NULL ); - // g_signal_connect (G_OBJECT (dlg), "destroy", G_CALLBACK (gtk_widget_destroy), NULL); + dlg.connect( "delete_event", G_CALLBACK( main_close ), NULL ); + // dlg.connect( "destroy", G_CALLBACK (gtk_widget_destroy), NULL); gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) ); - hbox = gtk_hbox_new( FALSE, 5 ); - gtk_widget_show( hbox ); - gtk_container_add( GTK_CONTAINER( dlg ), hbox ); + auto hbox = ui::HBox( FALSE, 5 ); + hbox.show(); + dlg.add(hbox); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 5 ); notebook = gtk_notebook_new(); gtk_widget_show( notebook ); gtk_box_pack_start( GTK_BOX( hbox ), notebook, TRUE, TRUE, 0 ); - g_signal_connect( G_OBJECT( notebook ), "switch_page", + notebook.connect( "switch_page", G_CALLBACK( switch_page ), NULL ); gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_TOP ); g_object_set_data( G_OBJECT( dlg ), "notebook", notebook ); - table = gtk_table_new( 2, 2, FALSE ); + table = ui::Table( 2, 2, FALSE ); gtk_widget_show( table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "General" ); + label = ui::Label( "General" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), table, label ); - frame = gtk_frame_new( "Game" ); + auto frame = ui::Frame( "Game" ); gtk_widget_show( frame ); gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - vbox = gtk_vbox_new( TRUE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( frame ), vbox ); + auto vbox = ui::VBox( TRUE, 5 ); + vbox.show(); + frame.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); for ( i = 0, group = NULL; i < NUMGAMES; i++ ) @@ -1400,20 +1400,20 @@ GtkWidget* create_main_dialog(){ radio = gtk_radio_button_new_with_label( group, games[i] ); gtk_widget_show( radio ); gtk_box_pack_start( GTK_BOX( vbox ), radio, TRUE, TRUE, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( radio ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) ); game_radios[i] = radio; - g_signal_connect( G_OBJECT( radio ), "toggled", G_CALLBACK( general_game ), GINT_TO_POINTER( i ) ); + radio.connect( "toggled", G_CALLBACK( general_game ), GINT_TO_POINTER( i ) ); } - frame = gtk_frame_new( "Waveform" ); + frame = ui::Frame( "Waveform" ); gtk_widget_show( frame ); gtk_table_attach( GTK_TABLE( table ), frame, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - vbox = gtk_vbox_new( TRUE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( frame ), vbox ); + vbox = ui::VBox( TRUE, 5 ); + vbox.show(); + frame.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); for ( i = 0, group = NULL; i < 5; i++ ) @@ -1421,20 +1421,20 @@ GtkWidget* create_main_dialog(){ radio = gtk_radio_button_new_with_label( group, waveforms[i] ); gtk_widget_show( radio ); gtk_box_pack_start( GTK_BOX( vbox ), radio, TRUE, TRUE, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( radio ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) ); wave_radios[i] = radio; - g_signal_connect( G_OBJECT( radio ), "toggled", G_CALLBACK( general_wave ), GINT_TO_POINTER( i ) ); + radio.connect( "toggled", G_CALLBACK( general_wave ), GINT_TO_POINTER( i ) ); } - frame = gtk_frame_new( "Orientation" ); + frame = ui::Frame( "Orientation" ); gtk_widget_show( frame ); gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - vbox = gtk_vbox_new( TRUE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( frame ), vbox ); + vbox = ui::VBox( TRUE, 5 ); + vbox.show(); + frame.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); for ( i = 0, group = NULL; i < 6; i++ ) @@ -1442,12 +1442,12 @@ GtkWidget* create_main_dialog(){ radio = gtk_radio_button_new_with_label( group, orientations[i] ); gtk_widget_show( radio ); gtk_box_pack_start( GTK_BOX( vbox ), radio, TRUE, TRUE, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( radio ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) ); plane_radios[i] = radio; - g_signal_connect( G_OBJECT( radio ), "toggled", G_CALLBACK( general_plane ), GINT_TO_POINTER( i ) ); + radio.connect( "toggled", G_CALLBACK( general_plane ), GINT_TO_POINTER( i ) ); } - table2 = gtk_table_new( 4, 2, FALSE ); + table2 = ui::Table( 4, 2, FALSE ); gtk_widget_show( table2 ); gtk_table_set_row_spacings( GTK_TABLE( table2 ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table2 ), 5 ); @@ -1455,7 +1455,7 @@ GtkWidget* create_main_dialog(){ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Wavelength:" ); + label = ui::Label( "Wavelength:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1463,7 +1463,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Max. amplitude:" ); + label = ui::Label( "Max. amplitude:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1471,7 +1471,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Roughness:" ); + label = ui::Label( "Roughness:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1479,7 +1479,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Random seed:" ); + label = ui::Label( "Random seed:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1487,368 +1487,368 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table2 ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "wavelength", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &WaveLength ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &WaveLength ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table2 ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "amplitude", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Amplitude ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Amplitude ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table2 ), entry, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "roughness", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Roughness ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Roughness ); - adj = gtk_adjustment_new( 1, 1, 32767, 1, 10, 0 ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( general_random ), NULL ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + adj = ui::Adjustment( 1, 1, 32767, 1, 10, 0 ); + adj.connect( "value_changed", G_CALLBACK( general_random ), NULL ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table2 ), spin, 1, 2, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "random", spin ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Extents" ); + label = ui::Label( "Extents" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); - hbox2 = gtk_hbox_new( FALSE, 5 ); + hbox2 = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 ); - frame = gtk_frame_new( "Extents" ); + frame = ui::Frame( "Extents" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( hbox2 ), frame, TRUE, TRUE, 0 ); - table = gtk_table_new( 3, 4, FALSE ); - gtk_widget_show( table ); + auto table = ui::Table( 3, 4, FALSE ); + table.show(); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "X:" ); + label = ui::Label( "X:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "hmin_text", label ); - label = gtk_label_new( "X:" ); + label = ui::Label( "X:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "hmax_text", label ); - label = gtk_label_new( "Y:" ); + label = ui::Label( "Y:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "vmin_text", label ); - label = gtk_label_new( "Y:" ); + label = ui::Label( "Y:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "vmax_text", label ); - label = gtk_label_new( "Lower-left" ); + label = ui::Label( "Lower-left" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Upper-right" ); + label = ui::Label( "Upper-right" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "hmin", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Hll ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Hll ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "hmax", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Hur ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Hur ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "vmin", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Vll ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Vll ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "vmax", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Vur ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Vur ); - frame = gtk_frame_new( "Divisions" ); + frame = ui::Frame( "Divisions" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( hbox2 ), frame, TRUE, TRUE, 0 ); - table = gtk_table_new( 2, 2, FALSE ); - gtk_widget_show( table ); + table = ui::Table( 2, 2, FALSE ); + table.show(); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "X:" ); + label = ui::Label( "X:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "nh_text", label ); - label = gtk_label_new( "Y:" ); + label = ui::Label( "Y:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "nv_text", label ); - adj = gtk_adjustment_new( 8, 1, MAX_ROWS, 1, 10, 0 ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_nhnv_spin ), &NH ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + adj = ui::Adjustment( 8, 1, MAX_ROWS, 1, 10, 0 ); + adj.connect( "value_changed", G_CALLBACK( extents_nhnv_spin ), &NH ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "nh", spin ); - adj = gtk_adjustment_new( 8, 1, MAX_ROWS, 1, 10, 0 ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_nhnv_spin ), &NV ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + adj = ui::Adjustment( 8, 1, MAX_ROWS, 1, 10, 0 ); + adj.connect( "value_changed", G_CALLBACK( extents_nhnv_spin ), &NV ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "nv", spin ); - check = gtk_check_button_new_with_label( "Use Bezier patches" ); + check = ui::CheckButton( "Use Bezier patches" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "use_patches", check ); - g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( extents_use_patches ), NULL ); + check.connect( "toggled", G_CALLBACK( extents_use_patches ), NULL ); // ^Fishman - Snap to grid, replaced scroll bar with a texbox. - label = gtk_label_new( "Snap to grid:" ); + label = ui::Label( "Snap to grid:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 ); gtk_object_set_data( GTK_OBJECT( dlg ), "snap_text", label ); - adj = gtk_adjustment_new( 8, 0, 256, 1, 10, 0 ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_snaptogrid_spin ), &SP ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + adj = ui::Adjustment( 8, 0, 256, 1, 10, 0 ); + adj.connect( "value_changed", G_CALLBACK( extents_snaptogrid_spin ), &SP ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_box_pack_start( GTK_BOX( vbox ), spin, FALSE, TRUE, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "sp", spin ); // ^Fishman - End of Snap to grid code. - hbox2 = gtk_hbox_new( FALSE, 5 ); + hbox2 = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 10 ); - label = gtk_label_new( "Decimate:" ); + label = ui::Label( "Decimate:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); - adj = gtk_adjustment_new( 0, 0, 110, 1, 10, 0 ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_decimate ), NULL ); + adj = ui::Adjustment( 0, 0, 110, 1, 10, 0 ); + adj.connect( "value_changed", G_CALLBACK( extents_decimate ), NULL ); g_object_set_data( G_OBJECT( dlg ), "decimate_adj", adj ); - scale = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + scale = ui::HScale( adj ); gtk_widget_show( scale ); gtk_box_pack_start( GTK_BOX( hbox2 ), scale, TRUE, TRUE, 0 ); gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_RIGHT ); gtk_scale_set_digits( GTK_SCALE( scale ), 0 ); g_object_set_data( G_OBJECT( dlg ), "decimate", scale ); - frame = gtk_frame_new( "Corner values" ); + frame = ui::Frame( "Corner values" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = gtk_table_new( 3, 4, FALSE ); - gtk_widget_show( table ); + table = ui::Table( 3, 4, FALSE ); + table.show(); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Upper-left:" ); + label = ui::Label( "Upper-left:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Lower-left:" ); + label = ui::Label( "Lower-left:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Upper-right:" ); + label = ui::Label( "Upper-right:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Lower-right:" ); + label = ui::Label( "Lower-right:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "z01", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z01 ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z01 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "z00", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z00 ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z00 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "z11", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z11 ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z11 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "z10", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z10 ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z10 ); - check = gtk_check_button_new_with_label( "Linear borders" ); + check = ui::CheckButton( "Linear borders" ); gtk_widget_show( check ); gtk_table_attach( GTK_TABLE( table ), check, 0, 4, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "linearborder", check ); - g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( extents_linearborder ), NULL ); + check.connect( "toggled", G_CALLBACK( extents_linearborder ), NULL ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Bitmap" ); + label = ui::Label( "Bitmap" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); - label = gtk_label_new( "" ); + label = ui::Label( "" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "bmp_note", label ); - table = gtk_table_new( 2, 2, FALSE ); + table = ui::Table( 2, 2, FALSE ); gtk_widget_show( table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Filename:" ); + label = ui::Label( "Filename:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "bmp_text1", label ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "bmp_file", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( bitmap_file_entryfocusout ), NULL ); + entry.connect( "focus_out_event", G_CALLBACK( bitmap_file_entryfocusout ), NULL ); - hbox2 = gtk_hbox_new( TRUE, 5 ); + hbox2 = ui::HBox( TRUE, 5 ); gtk_widget_show( hbox2 ); gtk_table_attach( GTK_TABLE( table ), hbox2, 1, 2, 1, 2, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - button = gtk_button_new_with_label( "Browse..." ); + button = ui::Button( "Browse..." ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "bmp_file_browse", button ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( bitmap_browse ), NULL ); + button.connect( "clicked", G_CALLBACK( bitmap_browse ), NULL ); - button = gtk_button_new_with_label( "Reload" ); + button = ui::Button( "Reload" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "bmp_reload", button ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( bitmap_reload ), NULL ); + button.connect( "clicked", G_CALLBACK( bitmap_reload ), NULL ); - table = gtk_table_new( 2, 2, TRUE ); + table = ui::Table( 2, 2, TRUE ); gtk_widget_show( table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Map color 0 to:" ); + label = ui::Label( "Map color 0 to:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), @@ -1857,7 +1857,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Map color 255 to:" ); + label = ui::Label( "Map color 255 to:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), @@ -1866,41 +1866,41 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - hbox2 = gtk_hbox_new( FALSE, 5 ); + hbox2 = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_table_attach( GTK_TABLE( table ), hbox2, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_box_pack_start( GTK_BOX( hbox2 ), entry, FALSE, FALSE, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "bmp_black", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &gbmp.black_value ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &gbmp.black_value ); - hbox2 = gtk_hbox_new( FALSE, 5 ); + hbox2 = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_table_attach( GTK_TABLE( table ), hbox2, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_box_pack_start( GTK_BOX( hbox2 ), entry, FALSE, FALSE, 0 ); - gtk_widget_set_usize( entry, 50, -2 ); + gtk_widget_set_size_request( entry, 50, -1 ); g_object_set_data( G_OBJECT( dlg ), "bmp_white", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &gbmp.white_value ); + entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &gbmp.white_value ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Fix Points" ); + label = ui::Label( "Fix Points" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); - label = gtk_label_new( "Click on a vertex in the lower half of the preview window,\n" + label = ui::Label( "Click on a vertex in the lower half of the preview window,\n" "then use the arrow keys or text box to assign a value.\n" "Use Ctrl+Click to select multiple vertices/toggle a\n" "selection. Use Shift+Click to select a range of vertices.\n\n" @@ -1909,14 +1909,14 @@ GtkWidget* create_main_dialog(){ gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 ); - table = gtk_table_new( 3, 3, FALSE ); + table = ui::Table( 3, 3, FALSE ); gtk_widget_show( table ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Value:" ); + label = ui::Label( "Value:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1924,7 +1924,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); g_object_set_data( G_OBJECT( dlg ), "fix_value_text", label ); - label = gtk_label_new( "Range affected:" ); + label = ui::Label( "Range affected:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1932,7 +1932,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); g_object_set_data( G_OBJECT( dlg ), "fix_range_text", label ); - label = gtk_label_new( "Rate of change:" ); + label = ui::Label( "Rate of change:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), @@ -1940,250 +1940,250 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); g_object_set_data( G_OBJECT( dlg ), "fix_rate_text", label ); - adj = gtk_adjustment_new( 0, -65536, 65536, 1, 16, 0 ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( fix_value_changed ), NULL ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + adj = ui::Adjustment( 0, -65536, 65536, 1, 16, 0 ); + adj.connect( "value_changed", G_CALLBACK( fix_value_changed ), NULL ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND ), (GtkAttachOptions) ( GTK_EXPAND ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "fix_value", spin ); - g_signal_connect( G_OBJECT( spin ), "focus_out_event", G_CALLBACK( fix_value_entryfocusout ), NULL ); + spin.connect( "focus_out_event", G_CALLBACK( fix_value_entryfocusout ), NULL ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "fix_range", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( fix_range_entryfocusout ), NULL ); + entry.connect( "focus_out_event", G_CALLBACK( fix_range_entryfocusout ), NULL ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_EXPAND ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "fix_rate", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( fix_rate_entryfocusout ), NULL ); + entry.connect( "focus_out_event", G_CALLBACK( fix_rate_entryfocusout ), NULL ); - button = gtk_button_new_with_label( "Free" ); + button = ui::Button( "Free" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_EXPAND ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "fix_free", button ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( fix_free ), NULL ); + button.connect( "clicked", G_CALLBACK( fix_free ), NULL ); - button = gtk_button_new_with_label( "Free All" ); + button = ui::Button( "Free All" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_EXPAND ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "fix_freeall", button ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( fix_freeall ), NULL ); + button.connect( "clicked", G_CALLBACK( fix_freeall ), NULL ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::VBox( FALSE, 10 ); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Texture" ); + label = ui::Label( "Texture" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); // ^Fishman - Modified to add more labels and textboxes. - table = gtk_table_new( 5, 2, FALSE ); + table = ui::Table( 5, 2, FALSE ); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Surface:" ); + label = ui::Label( "Surface:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); - label = gtk_label_new( "Other:" ); + label = ui::Label( "Other:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); - label = gtk_label_new( "Steep:" ); + label = ui::Label( "Steep:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texture1", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( texture_entryfocusout ), GINT_TO_POINTER( 0 ) ); + entry.connect( "focus_out_event", G_CALLBACK( texture_entryfocusout ), GINT_TO_POINTER( 0 ) ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texture2", entry ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( texture_entryfocusout ), GINT_TO_POINTER( 1 ) ); + entry.connect( "focus_out_event", G_CALLBACK( texture_entryfocusout ), GINT_TO_POINTER( 1 ) ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texture3", entry ); - hbox2 = gtk_hbox_new( FALSE, 5 ); + hbox2 = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 ); - label = gtk_label_new( "\"Steep\" angle:" ); + label = ui::Label( "\"Steep\" angle:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); - adj = gtk_adjustment_new( 60, 0, 90, 1, 10, 0 ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + adj = ui::Adjustment( 60, 0, 90, 1, 10, 0 ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_box_pack_start( GTK_BOX( hbox2 ), spin, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "tex_slant", spin ); - table = gtk_table_new( 2, 4, TRUE ); + table = ui::Table( 2, 4, TRUE ); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Offset " ); + label = ui::Label( "Offset " ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Scale " ); + label = ui::Label( "Scale " ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 4, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texoffsetx", entry ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texoffsety", entry ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texscalex", entry ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - gtk_widget_set_usize( entry, 60, -2 ); + gtk_widget_set_size_request( entry, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "texscaley", entry ); - check = gtk_check_button_new_with_label( "Use detail brushes" ); + check = ui::CheckButton( "Use detail brushes" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "detail", check ); - g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( texture_detail ), NULL ); + check.connect( "toggled", G_CALLBACK( texture_detail ), NULL ); - check = gtk_check_button_new_with_label( "Detail hint brushes" ); + check = ui::CheckButton( "Detail hint brushes" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "hint", check ); - g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( texture_hint ), NULL ); + check.connect( "toggled", G_CALLBACK( texture_hint ), NULL ); // ^Fishman - Add terrain key to func_group. - check = gtk_check_button_new_with_label( "Add terrain key" ); + check = ui::CheckButton( "Add terrain key" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "terrain_ent", check ); - g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( texture_terrainent ), NULL ); + check.connect( "toggled", G_CALLBACK( texture_terrainent ), NULL ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::VBox( FALSE, 5 ); gtk_widget_show( vbox ); gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, TRUE, 0 ); - button = gtk_button_new_with_label( "OK" ); + button = ui::Button( "OK" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); g_object_set_data( G_OBJECT( dlg ), "go", button ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_go ), NULL ); + button.connect( "clicked", G_CALLBACK( main_go ), NULL ); - label = gtk_label_new( "Settings:" ); + label = ui::Label( "Settings:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 ); - button = gtk_button_new_with_label( "Open..." ); + button = ui::Button( "Open..." ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "open", button ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_open ), NULL ); + button.connect( "clicked", G_CALLBACK( main_open ), NULL ); - button = gtk_button_new_with_label( "Save as..." ); + button = ui::Button( "Save as..." ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "save", button ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_save ), NULL ); + button.connect( "clicked", G_CALLBACK( main_save ), NULL ); - button = gtk_button_new_with_label( "Defaults" ); + button = ui::Button( "Defaults" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "defaults", button ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_defaults ), NULL ); + button.connect( "clicked", G_CALLBACK( main_defaults ), NULL ); - button = gtk_button_new_with_label( "About..." ); + button = ui::Button( "About..." ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_about ), NULL ); + button.connect( "clicked", G_CALLBACK( main_about ), NULL ); - check = gtk_check_button_new_with_label( "Preview" ); + check = ui::CheckButton( "Preview" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); - g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( main_preview ), NULL ); + check.connect( "toggled", G_CALLBACK( main_preview ), NULL ); g_object_set_data( G_OBJECT( dlg ), "main_preview", check ); // ^Fishman - Antializing for the preview window. - check = gtk_check_button_new_with_label( "Antialised lines" ); + check = ui::CheckButton( "Antialised lines" ); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "main_antialiasing", check ); - g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( main_antialiasing ), NULL ); + check.connect( "toggled", G_CALLBACK( main_antialiasing ), NULL ); for ( i = 0; i < 5; i++ ) SetDlgValues( i ); diff --git a/contrib/gtkgensurf/gensurf.cpp b/contrib/gtkgensurf/gensurf.cpp index b28416e2..1be8b135 100644 --- a/contrib/gtkgensurf/gensurf.cpp +++ b/contrib/gtkgensurf/gensurf.cpp @@ -71,7 +71,7 @@ int Antialiasing; // ^Fishman - Antializing for the preview window. int AddTerrainKey; // ^Fishman - Add terrain key to func_group. int SP; // ^Fishman - Snap to grid. -GtkWidget *g_pWnd; // ghwnd; +ui::Window g_pWnd{ui::null}; // ghwnd; GtkWidget *g_pRadiantWnd; // ghwnd_main; /*HWND ghwndAngles; */GtkWidget *g_pWndPreview; @@ -409,7 +409,7 @@ void WriteIniFile( const char *file ){ } void UpdatePreview( bool DataChange ){ - if ( g_pWndPreview && GTK_WIDGET_VISIBLE( g_pWndPreview ) ) { + if ( g_pWndPreview && gtk_widget_get_visible( g_pWndPreview ) ) { if ( DataChange ) { GenerateXYZ(); } diff --git a/contrib/gtkgensurf/gensurf.h b/contrib/gtkgensurf/gensurf.h index 99e4a46b..cb4a2d55 100644 --- a/contrib/gtkgensurf/gensurf.h +++ b/contrib/gtkgensurf/gensurf.h @@ -48,8 +48,6 @@ extern _QERBrushTable __BRUSHTABLENAME; #include "igl.h" #include "ientity.h" -#include - #include "iui_gtk.h" #include "gendlgs.h" @@ -414,7 +412,7 @@ extern int SP; // ^Fishman - Snap to grid. extern HCURSOR ghCursorVertex; extern HINSTANCE ghInst;*/ extern GtkWidget *g_pRadiantWnd; -extern GtkWidget *g_pWnd; +extern ui::Window g_pWnd; /*extern HWND ghwndAngles; extern HWND ghwndFix; */extern GtkWidget *g_pWndPreview; diff --git a/contrib/gtkgensurf/view.cpp b/contrib/gtkgensurf/view.cpp index ba0c43d5..307ccdc4 100644 --- a/contrib/gtkgensurf/view.cpp +++ b/contrib/gtkgensurf/view.cpp @@ -363,72 +363,71 @@ static void preview_spin( GtkAdjustment *adj, double *data ){ } void CreateViewWindow(){ - GtkWidget *dlg, *vbox, *hbox, *label, *spin, *frame; - GtkObject *adj; + GtkWidget *hbox, *label, *spin; #ifndef ISOMETRIC elevation = PI / 6.; azimuth = PI / 6.; #endif - g_pWndPreview = dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto dlg = g_pWndPreview = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "GtkGenSurf Preview" ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", GTK_SIGNAL_FUNC( preview_close ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + dlg.connect( "delete_event", G_CALLBACK( preview_close ), NULL ); + dlg.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pWnd ) ); gtk_window_set_default_size( GTK_WINDOW( dlg ), 300, 400 ); - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( dlg ), vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + vbox.show(); + dlg.add(vbox); #ifndef ISOMETRIC - hbox = gtk_hbox_new( TRUE, 5 ); + hbox = ui::HBox( TRUE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, TRUE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 3 ); - label = gtk_label_new( "Elevation" ); + label = ui::Label( "Elevation" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_box_pack_start( GTK_BOX( hbox ), label, FALSE, TRUE, 0 ); - adj = gtk_adjustment_new( 30, -90, 90, 1, 10, 0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( preview_spin ), &elevation ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + auto adj = ui::Adjustment( 30, -90, 90, 1, 10, 0 ); + adj.connect( "value_changed", G_CALLBACK( preview_spin ), &elevation ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_box_pack_start( GTK_BOX( hbox ), spin, FALSE, TRUE, 0 ); - g_signal_connect( G_OBJECT( spin ), "focus_out_event", G_CALLBACK( doublevariable_spinfocusout ), &elevation ); + spin.connect( "focus_out_event", G_CALLBACK( doublevariable_spinfocusout ), &elevation ); - adj = gtk_adjustment_new( 30, 0, 359, 1, 10, 0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( preview_spin ), &azimuth ); - spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 ); + adj = ui::Adjustment( 30, 0, 359, 1, 10, 0 ); + adj.connect( "value_changed", G_CALLBACK( preview_spin ), &azimuth ); + spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( spin ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( spin ), TRUE ); gtk_box_pack_end( GTK_BOX( hbox ), spin, FALSE, TRUE, 0 ); - label = gtk_label_new( "Azimuth" ); + label = ui::Label( "Azimuth" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_box_pack_end( GTK_BOX( hbox ), label, FALSE, TRUE, 0 ); - g_signal_connect( G_OBJECT( spin ), "focus_out_event", G_CALLBACK( doublevariable_spinfocusout ), &azimuth ); + spin.connect( "focus_out_event", G_CALLBACK( doublevariable_spinfocusout ), &azimuth ); #endif - frame = gtk_frame_new( NULL ); - gtk_widget_show( frame ); + auto frame = ui::Frame(ui::null); + frame.show(); gtk_frame_set_shadow_type( GTK_FRAME( frame ), GTK_SHADOW_IN ); gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 ); g_pPreviewWidget = g_UIGtkTable.m_pfn_glwidget_new( FALSE, NULL ); gtk_widget_set_events( g_pPreviewWidget, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK ); - gtk_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "expose_event", GTK_SIGNAL_FUNC( expose ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "motion_notify_event", GTK_SIGNAL_FUNC( motion ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "button_press_event", - GTK_SIGNAL_FUNC( button_press ), NULL ); + g_pPreviewWidget.connect( "expose_event", G_CALLBACK( expose ), NULL ); + g_pPreviewWidget.connect( "motion_notify_event", G_CALLBACK( motion ), NULL ); + g_pPreviewWidget.connect( "button_press_event", + G_CALLBACK( button_press ), NULL ); gtk_widget_show( g_pPreviewWidget ); - gtk_container_add( GTK_CONTAINER( frame ), g_pPreviewWidget ); + frame.add(ui::Widget(g_pPreviewWidget)); if ( Preview ) { gtk_widget_show( g_pWndPreview ); diff --git a/contrib/hydratoolz/plugin.cpp b/contrib/hydratoolz/plugin.cpp index 44393ea1..5ca4fad1 100644 --- a/contrib/hydratoolz/plugin.cpp +++ b/contrib/hydratoolz/plugin.cpp @@ -81,25 +81,25 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer } int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ - GtkWidget *window, *w, *vbox, *hbox; + GtkWidget *w, *hbox; int mode = ( uType & MB_TYPEMASK ), ret, loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + auto window = ui::Window( ui::window_type::TOP ); + window.connect( "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), lpCaption ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); gtk_object_set_data( GTK_OBJECT( window ), "loop", &loop ); gtk_object_set_data( GTK_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); + vbox.show(); - w = gtk_label_new( lpText ); + w = ui::Label( lpText ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -108,72 +108,72 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_widget_show( w ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); if ( mode == MB_OK ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); ret = IDOK; } else if ( mode == MB_OKCANCEL ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); gtk_widget_show( w ); ret = IDCANCEL; } else if ( mode == MB_YESNOCANCEL ) { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); gtk_widget_show( w ); ret = IDCANCEL; } else /* if (mode == MB_YESNO) */ { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); gtk_widget_show( w ); ret = IDNO; } diff --git a/contrib/hydratoolz/plugin.h b/contrib/hydratoolz/plugin.h index 7e9e9771..055cf991 100644 --- a/contrib/hydratoolz/plugin.h +++ b/contrib/hydratoolz/plugin.h @@ -35,13 +35,11 @@ #define USE_ENTITYTABLE_DEFINE #include "ientity.h" -#include #include #include #include "iplugin.h" -#include #include "synapse.h" class CSynapseClientHydraToolz : public CSynapseClient diff --git a/contrib/prtview/AboutDialog.cpp b/contrib/prtview/AboutDialog.cpp index 1baec68d..70067e0c 100644 --- a/contrib/prtview/AboutDialog.cpp +++ b/contrib/prtview/AboutDialog.cpp @@ -20,6 +20,7 @@ #include "AboutDialog.h" #include #include +#include #include "version.h" #include "gtkutil/pointer.h" @@ -49,43 +50,42 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer } void DoAboutDlg(){ - GtkWidget *dlg, *hbox, *vbox, *button, *label; + GtkWidget *vbox, *label; int loop = 1, ret = IDCANCEL; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto dlg = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "About Portal Viewer" ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + dlg.connect( "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + dlg.connect( "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); - hbox = gtk_hbox_new( FALSE, 10 ); - gtk_widget_show( hbox ); - gtk_container_add( GTK_CONTAINER( dlg ), hbox ); + auto hbox = ui::HBox( FALSE, 10 ); + hbox.show(); + dlg.add(hbox); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 10 ); - label = gtk_label_new( "Version 1.000\n\n" + char const *label_text = "Version 1.000\n\n" "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n" "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n" "Built against NetRadiant " RADIANT_VERSION "\n" - __DATE__ - ); + __DATE__; gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox ), label, TRUE, TRUE, 0 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); - vbox = gtk_vbox_new( FALSE, 0 ); + vbox = ui::VBox( FALSE, 0 ); gtk_widget_show( vbox ); gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, FALSE, 0 ); - button = gtk_button_new_with_label( "OK" ); + auto button = ui::Button( "OK" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_widget_set_usize( button, 60, -2 ); + button.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_size_request( button, 60, -1 ); gtk_grab_add( dlg ); gtk_widget_show( dlg ); diff --git a/contrib/prtview/ConfigDialog.cpp b/contrib/prtview/ConfigDialog.cpp index a91a6a2b..391c1e6f 100644 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@ -20,6 +20,7 @@ #include "ConfigDialog.h" #include #include +#include #include "gtkutil/pointer.h" #include "iscenegraph.h" @@ -53,24 +54,23 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer // Color selection dialog static int DoColor( PackedColour *c ){ - GtkWidget* dlg; - double clr[4]; + GdkColor clr; int loop = 1, ret = IDCANCEL; - clr[0] = ( (double)GetRValue( *c ) ) / 255.0; - clr[1] = ( (double)GetGValue( *c ) ) / 255.0; - clr[2] = ( (double)GetBValue( *c ) ) / 255.0; - - dlg = gtk_color_selection_dialog_new( "Choose Color" ); - gtk_color_selection_set_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); - gtk_signal_connect( GTK_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->ok_button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_signal_connect( GTK_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->cancel_button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + clr.red = (guint16) (GetRValue(*c) * (65535 / 255)); + clr.blue = (guint16) (GetGValue(*c) * (65535 / 255)); + clr.green = (guint16) (GetBValue(*c) * (65535 / 255)); + + auto dlg = ui::Widget(gtk_color_selection_dialog_new( "Choose Color" )); + gtk_color_selection_set_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(dlg)) ), &clr ); + dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); + dlg.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); + + GtkWidget *ok_button, *cancel_button; + g_object_get(dlg, "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr); + + ui::Widget(ok_button).connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + ui::Widget(cancel_button).connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); @@ -80,13 +80,13 @@ static int DoColor( PackedColour *c ){ while ( loop ) gtk_main_iteration(); - gtk_color_selection_get_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr ); + gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(dlg)) ), &clr ); gtk_grab_remove( dlg ); gtk_widget_destroy( dlg ); if ( ret == IDOK ) { - *c = RGB( clr[0] * 255, clr[1] * 255, clr[2] * 255 ); + *c = RGB( clr.red / (65535 / 255), clr.green / (65535 / 255), clr.blue / (65535 / 255)); } return ret; @@ -125,7 +125,7 @@ static void SetClipText( GtkWidget* label ){ } static void OnScroll2d( GtkAdjustment *adj, gpointer data ){ - portals.width_2d = static_cast( adj->value ); + portals.width_2d = static_cast( gtk_adjustment_get_value(adj) ); Set2DText( GTK_WIDGET( data ) ); Portals_shadersChanged(); @@ -133,21 +133,21 @@ static void OnScroll2d( GtkAdjustment *adj, gpointer data ){ } static void OnScroll3d( GtkAdjustment *adj, gpointer data ){ - portals.width_3d = static_cast( adj->value ); + portals.width_3d = static_cast( gtk_adjustment_get_value(adj) ); Set3DText( GTK_WIDGET( data ) ); SceneChangeNotify(); } static void OnScrollTrans( GtkAdjustment *adj, gpointer data ){ - portals.trans_3d = static_cast( adj->value ); + portals.trans_3d = static_cast( gtk_adjustment_get_value(adj) ); Set3DTransText( GTK_WIDGET( data ) ); SceneChangeNotify(); } static void OnScrollClip( GtkAdjustment *adj, gpointer data ){ - portals.clip_range = static_cast( adj->value ); + portals.clip_range = static_cast( gtk_adjustment_get_value(adj) ); SetClipText( GTK_WIDGET( data ) ); SceneChangeNotify(); @@ -238,236 +238,219 @@ static void OnClip( GtkWidget *widget, gpointer data ){ } void DoConfigDialog(){ - GtkWidget *dlg, *hbox, *vbox, *vbox2, *button, *table, *frame; - GtkWidget *lw3slider, *lw3label, *lw2slider, *lw2label, *zlist, *menu, *item; - GtkWidget *aa2check, *aa3check, *depthcheck, *linescheck, *polyscheck; + GtkWidget *hbox, *table; + GtkWidget *lw3slider, *lw3label, *lw2slider, *lw2label, *item; GtkWidget *transslider, *translabel, *clipslider, *cliplabel; - GtkWidget *show2check, *show3check, *portalcheck; int loop = 1, ret = IDCANCEL; - GtkObject *adj; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto dlg = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "Portal Viewer Configuration" ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + dlg.connect( "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + dlg.connect( "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( dlg ), vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + vbox.show(); + dlg.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - frame = gtk_frame_new( "3D View" ); - gtk_widget_show( frame ); + auto frame = ui::Frame( "3D View" ); + frame.show(); gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 ); - vbox2 = gtk_vbox_new( FALSE, 5 ); - gtk_widget_show( vbox2 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); + auto vbox2 = ui::VBox( FALSE, 5 ); + vbox2.show(); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, TRUE, 0 ); - adj = gtk_adjustment_new( portals.width_3d, 2, 40, 1, 1, 0 ); - lw3slider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + auto adj = ui::Adjustment( portals.width_3d, 2, 40, 1, 1, 0 ); + lw3slider = ui::HScale( adj ); gtk_widget_show( lw3slider ); gtk_box_pack_start( GTK_BOX( hbox ), lw3slider, TRUE, TRUE, 0 ); gtk_scale_set_draw_value( GTK_SCALE( lw3slider ), FALSE ); - lw3label = gtk_label_new( "" ); + lw3label = ui::Label( "" ); gtk_widget_show( lw3label ); gtk_box_pack_start( GTK_BOX( hbox ), lw3label, FALSE, TRUE, 0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScroll3d ), lw3label ); + adj.connect( "value_changed", G_CALLBACK( OnScroll3d ), lw3label ); - table = gtk_table_new( 2, 4, FALSE ); + table = ui::Table( 2, 4, FALSE ); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox2 ), table, TRUE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - button = gtk_button_new_with_label( "Color" ); + auto button = ui::Button( "Color" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnColor3d ), NULL ); + button.connect( "clicked", G_CALLBACK( OnColor3d ), NULL ); - button = gtk_button_new_with_label( "Depth Color" ); + button = ui::Button( "Depth Color" ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnColorFog ), NULL ); + button.connect( "clicked", G_CALLBACK( OnColorFog ), NULL ); - aa3check = gtk_check_button_new_with_label( "Anti-Alias (May not work on some video cards)" ); + auto aa3check = ui::CheckButton( "Anti-Alias (May not work on some video cards)" ); gtk_widget_show( aa3check ); gtk_table_attach( GTK_TABLE( table ), aa3check, 1, 4, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( aa3check ), "toggled", GTK_SIGNAL_FUNC( OnAntiAlias3d ), NULL ); + aa3check.connect( "toggled", G_CALLBACK( OnAntiAlias3d ), NULL ); - depthcheck = gtk_check_button_new_with_label( "Depth Cue" ); + auto depthcheck = ui::CheckButton( "Depth Cue" ); gtk_widget_show( depthcheck ); gtk_table_attach( GTK_TABLE( table ), depthcheck, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( depthcheck ), "toggled", GTK_SIGNAL_FUNC( OnFog ), NULL ); + depthcheck.connect( "toggled", G_CALLBACK( OnFog ), NULL ); - linescheck = gtk_check_button_new_with_label( "Lines" ); + auto linescheck = ui::CheckButton( "Lines" ); gtk_widget_show( linescheck ); gtk_table_attach( GTK_TABLE( table ), linescheck, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( linescheck ), "toggled", GTK_SIGNAL_FUNC( OnLines ), NULL ); + linescheck.connect( "toggled", G_CALLBACK( OnLines ), NULL ); - polyscheck = gtk_check_button_new_with_label( "Polygons" ); + auto polyscheck = ui::CheckButton( "Polygons" ); gtk_widget_show( polyscheck ); gtk_table_attach( GTK_TABLE( table ), polyscheck, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_signal_connect( GTK_OBJECT( polyscheck ), "toggled", GTK_SIGNAL_FUNC( OnPoly ), NULL ); + polyscheck.connect( "toggled", G_CALLBACK( OnPoly ), NULL ); - zlist = gtk_option_menu_new(); + auto zlist = ui::ComboBoxText(); gtk_widget_show( zlist ); gtk_box_pack_start( GTK_BOX( vbox2 ), zlist, TRUE, FALSE, 0 ); - menu = gtk_menu_new(); - gtk_widget_show( menu ); - gtk_option_menu_set_menu( GTK_OPTION_MENU( zlist ), menu ); - - item = gtk_menu_item_new_with_label( "Z-Buffer Test and Write (recommended for solid or no polygons)" ); - gtk_widget_show( item ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", - GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 0 ) ); - gtk_menu_append( GTK_MENU( menu ), item ); - - item = gtk_menu_item_new_with_label( "Z-Buffer Test Only (recommended for transparent polygons)" ); - gtk_widget_show( item ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", - GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 1 ) ); - gtk_menu_append( GTK_MENU( menu ), item ); - - item = gtk_menu_item_new_with_label( "Z-Buffer Off" ); - gtk_widget_show( item ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", - GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 2 ) ); - gtk_menu_append( GTK_MENU( menu ), item ); - - table = gtk_table_new( 2, 2, FALSE ); + gtk_combo_box_text_append_text(zlist, "Z-Buffer Test and Write (recommended for solid or no polygons)"); + gtk_combo_box_text_append_text(zlist, "Z-Buffer Test Only (recommended for transparent polygons)"); + gtk_combo_box_text_append_text(zlist, "Z-Buffer Off"); + + zlist.connect("changed", G_CALLBACK(+[](GtkComboBox *self, void *) { + OnSelchangeZbuffer(GTK_WIDGET(self), GINT_TO_POINTER(gtk_combo_box_get_active(self))); + }), nullptr); + + table = ui::Table( 2, 2, FALSE ); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox2 ), table, TRUE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - adj = gtk_adjustment_new( portals.trans_3d, 0, 100, 1, 1, 0 ); - transslider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + adj = ui::Adjustment( portals.trans_3d, 0, 100, 1, 1, 0 ); + transslider = ui::HScale( adj ); gtk_widget_show( transslider ); gtk_table_attach( GTK_TABLE( table ), transslider, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_scale_set_draw_value( GTK_SCALE( transslider ), FALSE ); - translabel = gtk_label_new( "" ); + translabel = ui::Label( "" ); gtk_widget_show( translabel ); gtk_table_attach( GTK_TABLE( table ), translabel, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( translabel ), 0.0, 0.0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScrollTrans ), translabel ); + adj.connect( "value_changed", G_CALLBACK( OnScrollTrans ), translabel ); - adj = gtk_adjustment_new( portals.clip_range, 1, 128, 1, 1, 0 ); - clipslider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + adj = ui::Adjustment( portals.clip_range, 1, 128, 1, 1, 0 ); + clipslider = ui::HScale( adj ); gtk_widget_show( clipslider ); gtk_table_attach( GTK_TABLE( table ), clipslider, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_scale_set_draw_value( GTK_SCALE( clipslider ), FALSE ); - cliplabel = gtk_label_new( "" ); + cliplabel = ui::Label( "" ); gtk_widget_show( cliplabel ); gtk_table_attach( GTK_TABLE( table ), cliplabel, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( cliplabel ), 0.0, 0.0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScrollClip ), cliplabel ); + adj.connect( "value_changed", G_CALLBACK( OnScrollClip ), cliplabel ); - hbox = gtk_hbox_new( TRUE, 5 ); + hbox = ui::HBox( TRUE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 ); - show3check = gtk_check_button_new_with_label( "Show" ); + auto show3check = ui::CheckButton( "Show" ); gtk_widget_show( show3check ); gtk_box_pack_start( GTK_BOX( hbox ), show3check, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( show3check ), "toggled", GTK_SIGNAL_FUNC( OnConfig3d ), NULL ); + show3check.connect( "toggled", G_CALLBACK( OnConfig3d ), NULL ); - portalcheck = gtk_check_button_new_with_label( "Portal cubic clipper" ); + auto portalcheck = ui::CheckButton( "Portal cubic clipper" ); gtk_widget_show( portalcheck ); gtk_box_pack_start( GTK_BOX( hbox ), portalcheck, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( portalcheck ), "toggled", GTK_SIGNAL_FUNC( OnClip ), NULL ); + portalcheck.connect( "toggled", G_CALLBACK( OnClip ), NULL ); - frame = gtk_frame_new( "2D View" ); + frame = ui::Frame( "2D View" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 ); - vbox2 = gtk_vbox_new( FALSE, 5 ); - gtk_widget_show( vbox2 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); + vbox2 = ui::VBox( FALSE, 5 ); + vbox2.show(); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 ); - adj = gtk_adjustment_new( portals.width_2d, 2, 40, 1, 1, 0 ); - lw2slider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + adj = ui::Adjustment( portals.width_2d, 2, 40, 1, 1, 0 ); + lw2slider = ui::HScale( adj ); gtk_widget_show( lw2slider ); gtk_box_pack_start( GTK_BOX( hbox ), lw2slider, TRUE, TRUE, 0 ); gtk_scale_set_draw_value( GTK_SCALE( lw2slider ), FALSE ); - lw2label = gtk_label_new( "" ); + lw2label = ui::Label( "" ); gtk_widget_show( lw2label ); gtk_box_pack_start( GTK_BOX( hbox ), lw2label, FALSE, TRUE, 0 ); - gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScroll2d ), lw2label ); + adj.connect( "value_changed", G_CALLBACK( OnScroll2d ), lw2label ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 ); - button = gtk_button_new_with_label( "Color" ); + button = ui::Button( "Color" ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnColor2d ), NULL ); - gtk_widget_set_usize( button, 60, -2 ); + button.connect( "clicked", G_CALLBACK( OnColor2d ), NULL ); + gtk_widget_set_size_request( button, 60, -1 ); - aa2check = gtk_check_button_new_with_label( "Anti-Alias (May not work on some video cards)" ); + auto aa2check = ui::CheckButton( "Anti-Alias (May not work on some video cards)" ); gtk_widget_show( aa2check ); gtk_box_pack_start( GTK_BOX( hbox ), aa2check, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( aa2check ), "toggled", GTK_SIGNAL_FUNC( OnAntiAlias2d ), NULL ); + aa2check.connect( "toggled", G_CALLBACK( OnAntiAlias2d ), NULL ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 ); - show2check = gtk_check_button_new_with_label( "Show" ); + auto show2check = ui::CheckButton( "Show" ); gtk_widget_show( show2check ); gtk_box_pack_start( GTK_BOX( hbox ), show2check, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( show2check ), "toggled", GTK_SIGNAL_FUNC( OnConfig2d ), NULL ); + show2check.connect( "toggled", G_CALLBACK( OnConfig2d ), NULL ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); - button = gtk_button_new_with_label( "OK" ); + button = ui::Button( "OK" ); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_widget_set_usize( button, 60, -2 ); + button.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_size_request( button, 60, -1 ); // initialize dialog gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( show2check ), portals.show_2d ); @@ -479,7 +462,7 @@ void DoConfigDialog(){ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( polyscheck ), portals.polygons ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( linescheck ), portals.lines ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( aa3check ), portals.aa_3d ); - gtk_option_menu_set_history( GTK_OPTION_MENU( zlist ), portals.zbuffer ); + gtk_combo_box_set_active(zlist, portals.zbuffer); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( portalcheck ), portals.clip ); Set3DText( lw3label ); diff --git a/contrib/prtview/LoadPortalFileDialog.cpp b/contrib/prtview/LoadPortalFileDialog.cpp index f3d4df8d..f6f024c8 100644 --- a/contrib/prtview/LoadPortalFileDialog.cpp +++ b/contrib/prtview/LoadPortalFileDialog.cpp @@ -55,47 +55,22 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer return TRUE; } -static void file_sel_callback( GtkWidget *widget, gpointer data ){ - GtkWidget *parent; - int *loop; - char **filename; - - parent = gtk_widget_get_toplevel( widget ); - loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" ); - filename = (char**)g_object_get_data( G_OBJECT( parent ), "filename" ); - - *loop = 0; - if ( gpointer_to_int( data ) == IDOK ) { - *filename = g_strdup( gtk_file_selection_get_filename( GTK_FILE_SELECTION( parent ) ) ); - } -} - static void change_clicked( GtkWidget *widget, gpointer data ){ GtkWidget* file_sel; char* filename = NULL; - int loop = 1; - file_sel = gtk_file_selection_new( "Locate portal (.prt) file" ); - gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->ok_button ), "clicked", - GTK_SIGNAL_FUNC( file_sel_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->cancel_button ), "clicked", - GTK_SIGNAL_FUNC( file_sel_callback ), GINT_TO_POINTER( IDCANCEL ) ); - gtk_signal_connect( GTK_OBJECT( file_sel ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_file_selection_hide_fileop_buttons( GTK_FILE_SELECTION( file_sel ) ); + file_sel = gtk_file_chooser_dialog_new ( "Locate portal (.prt) file", nullptr, GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + nullptr); - g_object_set_data( G_OBJECT( file_sel ), "loop", &loop ); - g_object_set_data( G_OBJECT( file_sel ), "filename", &filename ); - gtk_file_selection_set_filename( GTK_FILE_SELECTION( file_sel ), portals.fn ); + gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(file_sel), portals.fn ); - gtk_grab_add( file_sel ); - gtk_widget_show( file_sel ); - - while ( loop ) - gtk_main_iteration(); - - gtk_grab_remove( file_sel ); - gtk_widget_destroy( file_sel ); + if (gtk_dialog_run (GTK_DIALOG (file_sel)) == GTK_RESPONSE_ACCEPT) + { + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_sel)); + } + gtk_widget_destroy (file_sel); if ( filename != NULL ) { strcpy( portals.fn, filename ); @@ -105,63 +80,63 @@ static void change_clicked( GtkWidget *widget, gpointer data ){ } int DoLoadPortalFileDialog(){ - GtkWidget *dlg, *vbox, *hbox, *button, *entry, *check2d, *check3d; + GtkWidget *hbox, *entry, *check2d, *check3d; int loop = 1, ret = IDCANCEL; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto dlg = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "Load .prt" ); - gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + dlg.connect( "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + dlg.connect( "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( dlg ), vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + vbox.show(); + dlg.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - entry = gtk_entry_new(); + entry = ui::Entry(); gtk_widget_show( entry ); - gtk_entry_set_editable( GTK_ENTRY( entry ), FALSE ); + gtk_editable_set_editable( GTK_EDITABLE( entry ), FALSE ); gtk_box_pack_start( GTK_BOX( vbox ), entry, FALSE, FALSE, 0 ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); - check3d = gtk_check_button_new_with_label( "Show 3D" ); + check3d = ui::CheckButton( "Show 3D" ); gtk_widget_show( check3d ); gtk_box_pack_start( GTK_BOX( hbox ), check3d, FALSE, FALSE, 0 ); - check2d = gtk_check_button_new_with_label( "Show 2D" ); + check2d = ui::CheckButton( "Show 2D" ); gtk_widget_show( check2d ); gtk_box_pack_start( GTK_BOX( hbox ), check2d, FALSE, FALSE, 0 ); - button = gtk_button_new_with_label( "Change" ); + auto button = ui::Button( "Change" ); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( change_clicked ), entry ); - gtk_widget_set_usize( button, 60, -2 ); + button.connect( "clicked", G_CALLBACK( change_clicked ), entry ); + gtk_widget_set_size_request( button, 60, -1 ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::HBox( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); - button = gtk_button_new_with_label( "Cancel" ); + button = ui::Button( "Cancel" ); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); - gtk_widget_set_usize( button, 60, -2 ); + button.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + gtk_widget_set_size_request( button, 60, -1 ); - button = gtk_button_new_with_label( "OK" ); + button = ui::Button( "OK" ); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - gtk_signal_connect( GTK_OBJECT( button ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - gtk_widget_set_usize( button, 60, -2 ); + button.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_size_request( button, 60, -1 ); strcpy( portals.fn, GlobalRadiant().getMapName() ); char* fn = strrchr( portals.fn, '.' ); diff --git a/contrib/shaderplug/shaderplug.cpp b/contrib/shaderplug/shaderplug.cpp index 62e9abe6..e8f4f5fc 100644 --- a/contrib/shaderplug/shaderplug.cpp +++ b/contrib/shaderplug/shaderplug.cpp @@ -57,7 +57,7 @@ ShaderPlugPluginDependencies() : namespace Shaderplug { -GtkWindow* g_window; +ui::Window g_window{ui::null}; std::vector archives; std::set shaders; @@ -67,7 +67,7 @@ XmlTagBuilder TagBuilder; void CreateTagFile(); const char* init( void* hApp, void* pMainWidget ){ - g_window = GTK_WINDOW( pMainWidget ); + g_window = ui::Window(GTK_WINDOW( pMainWidget )); return ""; } const char* getName(){ @@ -81,7 +81,7 @@ const char* getCommandTitleList(){ } void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ if ( string_equal( command, "About" ) ) { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), "Shaderplug (1.0)\n\n" + GlobalRadiant().m_pfnMessageBox( g_window, "Shaderplug (1.0)\n\n" "by Shaderman (shaderman@gmx.net)", "About", eMB_OK, @@ -181,23 +181,23 @@ void CreateTagFile(){ strcat( message, "\nPlease restart Radiant now.\n" ); if ( file_exists( tagFile ) ) { - EMessageBoxReturn result = GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), + EMessageBoxReturn result = GlobalRadiant().m_pfnMessageBox( g_window , "WARNING! A tag file already exists! Overwrite it?", "Overwrite tag file?", eMB_NOYES, eMB_ICONWARNING ); if ( result == eIDYES ) { TagBuilder.SaveXmlDoc( tagFile ); - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), message, "INFO", eMB_OK, eMB_ICONASTERISK ); + GlobalRadiant().m_pfnMessageBox( g_window, message, "INFO", eMB_OK, eMB_ICONASTERISK ); } } else { TagBuilder.SaveXmlDoc( tagFile ); - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), message, "INFO", eMB_OK, eMB_ICONASTERISK ); + GlobalRadiant().m_pfnMessageBox( g_window, message, "INFO", eMB_OK, eMB_ICONASTERISK ); } } else { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), + GlobalRadiant().m_pfnMessageBox( g_window, "No shaders or textures found. No XML tag file created!\n" "", "ERROR", diff --git a/contrib/sunplug/sunplug.cpp b/contrib/sunplug/sunplug.cpp index 50fb2cd8..a6928537 100644 --- a/contrib/sunplug/sunplug.cpp +++ b/contrib/sunplug/sunplug.cpp @@ -184,11 +184,11 @@ SunPlugPluginDependencies() : // ************************* namespace SunPlug { -GtkWindow* main_window; +ui::Window main_window{ui::null}; char MenuList[100] = ""; const char* init( void* hApp, void* pMainWidget ){ - main_window = GTK_WINDOW( pMainWidget ); + main_window = ui::Window(GTK_WINDOW( pMainWidget )); return "Initializing SunPlug for GTKRadiant"; } const char* getName(){ @@ -253,26 +253,26 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server // About dialog void about_plugin_window(){ - GtkWidget *window, *vbox, *label, *button; + GtkWidget *label, *button; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); // create a window + auto window = ui::Window( ui::window_type::TOP ); // create a window gtk_window_set_transient_for( GTK_WINDOW( window ), SunPlug::main_window ); // make the window to stay in front of the main window - g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event - g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window + window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event + window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window gtk_window_set_title( GTK_WINDOW( window ), "About SunPlug" ); // set the title of the window for the window gtk_window_set_resizable( GTK_WINDOW( window ), FALSE ); // don't let the user resize the window gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); // force the user not to do something with the other windows gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window - vbox = gtk_vbox_new( FALSE, 10 ); // create a box to arrange new objects vertically - gtk_container_add( GTK_CONTAINER( window ), vbox ); // add the box to the window + auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically + window.add(vbox); - label = gtk_label_new( "SunPlug v1.0 for NetRadiant 1.5\nby Topsun" ); // create a label + label = ui::Label( "SunPlug v1.0 for NetRadiant 1.5\nby Topsun" ); // create a label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // text align left gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, FALSE, 2 ); // insert the label in the box - button = gtk_button_new_with_label( "OK" ); // create a button with text - g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( gtk_widget_destroy ), window ); // connect the click event to close the window + button = ui::Button( "OK" ); // create a button with text + g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( gtk_widget_destroy ), (void *) window ); // connect the click event to close the window gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 ); // insert the button in the box gtk_window_set_position( GTK_WINDOW( window ), GTK_WIN_POS_CENTER ); // center the window on screen @@ -314,24 +314,23 @@ void GetOptimalCoordinates( AABB *levelBoundingBox ){ // MapCoordinator dialog window void MapCoordinator(){ - GtkWidget *window, *vbox, *table, *label, *spinnerMinX, *spinnerMinY, *spinnerMaxX, *spinnerMaxY, *button; - GtkAdjustment *spinner_adj_MinX, *spinner_adj_MinY, *spinner_adj_MaxX, *spinner_adj_MaxY; + GtkWidget *table, *label, *spinnerMinX, *spinnerMinY, *spinnerMaxX, *spinnerMaxY; Entity *theWorldspawn = NULL; const char *buffer; char line[20]; // in any case we need a window to show the user what to do - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); // create the window + auto window = ui::Window( ui::window_type::TOP ); // create the window gtk_window_set_transient_for( GTK_WINDOW( window ), SunPlug::main_window ); // make the window to stay in front of the main window - g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event for the window - g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window + window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event for the window + window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window gtk_window_set_title( GTK_WINDOW( window ), "ET-MapCoordinator" ); // set the title of the window for the window gtk_window_set_resizable( GTK_WINDOW( window ), FALSE ); // don't let the user resize the window gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); // force the user not to do something with the other windows gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window - vbox = gtk_vbox_new( FALSE, 10 ); // create a box to arrange new objects vertically - gtk_container_add( GTK_CONTAINER( window ), vbox ); // add the box to the window + auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically + window.add(vbox); scene::Path path = makeReference( GlobalSceneGraph().root() ); // get the path to the root element of the graph scene::Instance* instance = GlobalSceneGraph().find( path ); // find the instance to the given path @@ -366,48 +365,48 @@ void MapCoordinator(){ globalOutputStream() << "SunPlug: adviced mapcoordsmins=" << minX << " " << maxY << "\n"; // console info about mapcoordsmins globalOutputStream() << "SunPlug: adviced mapcoordsmaxs=" << maxX << " " << minY << "\n"; // console info about mapcoordsmaxs - spinner_adj_MinX = (GtkAdjustment *)gtk_adjustment_new( map_minX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum x value - spinner_adj_MinY = (GtkAdjustment *)gtk_adjustment_new( map_minY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum y value - spinner_adj_MaxX = (GtkAdjustment *)gtk_adjustment_new( map_maxX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum x value - spinner_adj_MaxY = (GtkAdjustment *)gtk_adjustment_new( map_maxY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum y value + auto spinner_adj_MinX = ui::Adjustment( map_minX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum x value + auto spinner_adj_MinY = ui::Adjustment( map_minY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum y value + auto spinner_adj_MaxX = ui::Adjustment( map_maxX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum x value + auto spinner_adj_MaxY = ui::Adjustment( map_maxY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum y value - button = gtk_button_new_with_label( "Get optimal mapcoords" ); // create button with text - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( input_optimal ), NULL ); // connect button with callback function + auto button = ui::Button( "Get optimal mapcoords" ); // create button with text + button.connect( "clicked", G_CALLBACK( input_optimal ), NULL ); // connect button with callback function gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 ); // insert button into vbox gtk_box_pack_start( GTK_BOX( vbox ), gtk_hseparator_new(), FALSE, FALSE, 2 ); // insert separator into vbox - table = gtk_table_new( 4, 3, TRUE ); // create table + table = ui::Table( 4, 3, TRUE ); // create table gtk_table_set_row_spacings( GTK_TABLE( table ), 8 ); // set row spacings gtk_table_set_col_spacings( GTK_TABLE( table ), 8 ); // set column spacings gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, FALSE, 2 ); // insert table into vbox - label = gtk_label_new( "x" ); // create label + label = ui::Label( "x" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 1, 2, 0, 1 ); // insert label into table - label = gtk_label_new( "y" ); // create label + label = ui::Label( "y" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 2, 3, 0, 1 ); // insert label into table - label = gtk_label_new( "mapcoordsmins" ); // create label + label = ui::Label( "mapcoordsmins" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 0, 1, 1, 2 ); // insert label into table - spinnerMinX = gtk_spin_button_new( spinner_adj_MinX, 1.0, 0 ); // create textbox wiht value spin, value and value range + spinnerMinX = ui::SpinButton( spinner_adj_MinX, 1.0, 0 ); // create textbox wiht value spin, value and value range gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMinX, 1, 2, 1, 2 ); // insert spinbox into table - spinnerMinY = gtk_spin_button_new( spinner_adj_MinY, 1.0, 0 ); // create textbox wiht value spin, value and value range + spinnerMinY = ui::SpinButton( spinner_adj_MinY, 1.0, 0 ); // create textbox wiht value spin, value and value range gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMinY, 2, 3, 1, 2 ); // insert spinbox into table - label = gtk_label_new( "mapcoordsmaxs" ); // create label + label = ui::Label( "mapcoordsmaxs" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 0, 1, 2, 3 ); // insert label into table - spinnerMaxX = gtk_spin_button_new( spinner_adj_MaxX, 1.0, 0 ); // create textbox wiht value spin, value and value range + spinnerMaxX = ui::SpinButton( spinner_adj_MaxX, 1.0, 0 ); // create textbox wiht value spin, value and value range gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMaxX, 1, 2, 2, 3 ); // insert spinbox into table - spinnerMaxY = gtk_spin_button_new( spinner_adj_MaxY, 1.0, 0 ); // create textbox wiht value spin, value and value range + spinnerMaxY = ui::SpinButton( spinner_adj_MaxY, 1.0, 0 ); // create textbox wiht value spin, value and value range gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMaxY, 2, 3, 2, 3 ); // insert spinbox into table // put the references to the spinboxes and the worldspawn into the global exchange @@ -417,23 +416,23 @@ void MapCoordinator(){ msp.spinner4 = GTK_SPIN_BUTTON( spinnerMaxY ); msp.worldspawn = theWorldspawn; - button = gtk_button_new_with_label( "Set" ); // create button with text - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( set_coordinates ), NULL ); // connect button with callback function + button = ui::Button( "Set" ); // create button with text + button.connect( "clicked", G_CALLBACK( set_coordinates ), NULL ); // connect button with callback function gtk_table_attach_defaults( GTK_TABLE( table ), button, 1, 2, 3, 4 ); // insert button into table - button = gtk_button_new_with_label( "Cancel" ); // create button with text - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( close_window ), NULL ); // connect button with callback function + button = ui::Button( "Cancel" ); // create button with text + button.connect( "clicked", G_CALLBACK( close_window ), NULL ); // connect button with callback function gtk_table_attach_defaults( GTK_TABLE( table ), button, 2, 3, 3, 4 ); // insert button into table } else { globalOutputStream() << "SunPlug: no worldspawn found!\n"; // output error to console - label = gtk_label_new( "ERROR: No worldspawn was found in the map!\nIn order to use this tool the map must have at least one brush in the worldspawn. " ); // create a label + label = ui::Label( "ERROR: No worldspawn was found in the map!\nIn order to use this tool the map must have at least one brush in the worldspawn. " ); // create a label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // text align left gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, FALSE, 2 ); // insert the label in the box - button = gtk_button_new_with_label( "OK" ); // create a button with text - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( close_window ), NULL ); // connect the click event to close the window + auto button = ui::Button( "OK" ); // create a button with text + button.connect( "clicked", G_CALLBACK( close_window ), NULL ); // connect the click event to close the window gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 ); // insert the button in the box } diff --git a/contrib/ufoaiplug/ufoai.cpp b/contrib/ufoaiplug/ufoai.cpp index bb118664..d654edc7 100644 --- a/contrib/ufoaiplug/ufoai.cpp +++ b/contrib/ufoaiplug/ufoai.cpp @@ -59,10 +59,10 @@ UFOAIPluginDependencies( void ) : namespace UFOAI { -GtkWindow* g_mainwnd; + ui::Window g_mainwnd{ui::null}; const char* init( void* hApp, void* pMainWidget ){ - g_mainwnd = GTK_WINDOW( pMainWidget ); + g_mainwnd = ui::Window(GTK_WINDOW( pMainWidget )); return "Initializing GTKRadiant UFOAI plugin"; } const char* getName(){ @@ -78,8 +78,12 @@ const char* getCommandTitleList(){ void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ char *message = NULL; if ( string_equal( command, "About" ) ) { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ), - "UFO:AI Plugin (http://ufoai.sf.net)\nBuild: " __DATE__ "\nRadiant version: " RADIANT_VERSION "\nPlugin version: " PLUGIN_VERSION "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n", "About", + char const *version_string = "UFO:AI Plugin (http://ufoai.sf.net)\nBuild: " __DATE__ + "\nRadiant version: " RADIANT_VERSION + "\nPlugin version: " PLUGIN_VERSION + "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n"; + GlobalRadiant().m_pfnMessageBox( g_mainwnd, + version_string, "About", eMB_OK, eMB_ICONDEFAULT ); } else if ( string_equal( command, "Level 1" ) ) { @@ -129,7 +133,7 @@ void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush } if ( message != NULL ) { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ), + GlobalRadiant().m_pfnMessageBox( g_mainwnd, message, "Note", eMB_OK, eMB_ICONDEFAULT ); } diff --git a/contrib/ufoaiplug/ufoai_gtk.cpp b/contrib/ufoaiplug/ufoai_gtk.cpp index c5470474..072b8c7e 100644 --- a/contrib/ufoaiplug/ufoai_gtk.cpp +++ b/contrib/ufoaiplug/ufoai_gtk.cpp @@ -23,18 +23,7 @@ #include "iscenegraph.h" #include - -/** - * GTK callback functions - */ - -class UFOAIGtk -{ -GtkWindow* m_gtk_window; -public: -UFOAIGtk( void* gtk_window ) : m_gtk_window( ( GtkWindow* )gtk_window ){ -} -}; +#include /** * @brief If you return FALSE in the "delete_event" signal handler, diff --git a/contrib/ufoaiplug/ufoai_gtk.h b/contrib/ufoaiplug/ufoai_gtk.h index 0254f7d6..939c1f6f 100644 --- a/contrib/ufoaiplug/ufoai_gtk.h +++ b/contrib/ufoaiplug/ufoai_gtk.h @@ -20,7 +20,6 @@ #define INCLUDED_UFOAI_GTK_H #include "itoolbar.h" -#include const IToolbarButton* GetToolbarButton( std::size_t index ); const IToolbarButton* GetToolbarNoButton( std::size_t index ); diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 5c2a286d..40ab7936 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,48 +1,48 @@ add_library(includes aboutmsg.h - cullable.cpp cullable.h + cullable.h dpkdeps.h - editable.cpp editable.h - iarchive.cpp iarchive.h - ibrush.cpp ibrush.h - icamera.cpp icamera.h - idatastream.cpp idatastream.h - ieclass.cpp ieclass.h - ientity.cpp ientity.h - ifilesystem.cpp ifilesystem.h - ifiletypes.cpp ifiletypes.h - ifilter.cpp ifilter.h - igl.cpp igl.h - iglrender.cpp iglrender.h - igtkgl.cpp igtkgl.h - iimage.cpp iimage.h - imap.cpp imap.h - imodel.cpp imodel.h - ipatch.cpp ipatch.h - iplugin.cpp iplugin.h - ireference.cpp ireference.h - irender.cpp irender.h - iscenegraph.cpp iscenegraph.h - iscriplib.cpp iscriplib.h - iselection.cpp iselection.h - ishaders.cpp ishaders.h - itexdef.cpp itexdef.h - itextstream.cpp itextstream.h - itextures.cpp itextures.h - itoolbar.cpp itoolbar.h - iundo.cpp iundo.h - mapfile.cpp mapfile.h - modelskin.cpp modelskin.h - moduleobserver.cpp moduleobserver.h - modulesystem.cpp modulesystem.h - nameable.cpp nameable.h - namespace.cpp namespace.h + editable.h + iarchive.h + ibrush.h + icamera.h + idatastream.h + ieclass.h + ientity.h + ifilesystem.h + ifiletypes.h + ifilter.h + igl.h + iglrender.h + igtkgl.h + iimage.h + imap.h + imodel.h + ipatch.h + iplugin.h + ireference.h + irender.h + iscenegraph.h + iscriplib.h + iselection.h + ishaders.h + itexdef.h + itextstream.h + itextures.h + itoolbar.h + iundo.h + mapfile.h + modelskin.h + moduleobserver.h + modulesystem.h + nameable.h + namespace.h preferencesystem.cpp preferencesystem.h - qerplugin.cpp qerplugin.h - renderable.cpp renderable.h - selectable.cpp selectable.h + qerplugin.h + renderable.h + selectable.h stream_version.h version.h warnings.h - windowobserver.cpp windowobserver.h + windowobserver.h ) diff --git a/include/cullable.cpp b/include/cullable.cpp deleted file mode 100644 index 395d3e1c..00000000 --- a/include/cullable.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "cullable.h" diff --git a/include/editable.cpp b/include/editable.cpp deleted file mode 100644 index 63314dc1..00000000 --- a/include/editable.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "editable.h" diff --git a/include/iarchive.cpp b/include/iarchive.cpp deleted file mode 100644 index 1cf00055..00000000 --- a/include/iarchive.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "iarchive.h" diff --git a/include/ibrush.cpp b/include/ibrush.cpp deleted file mode 100644 index f075783b..00000000 --- a/include/ibrush.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "ibrush.h" diff --git a/include/icamera.cpp b/include/icamera.cpp deleted file mode 100644 index bad7cacf..00000000 --- a/include/icamera.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "icamera.h" diff --git a/include/idatastream.cpp b/include/idatastream.cpp deleted file mode 100644 index e6ef881e..00000000 --- a/include/idatastream.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "idatastream.h" diff --git a/include/ieclass.cpp b/include/ieclass.cpp deleted file mode 100644 index 5fd59c3a..00000000 --- a/include/ieclass.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "ieclass.h" diff --git a/include/ientity.cpp b/include/ientity.cpp deleted file mode 100644 index 88dd59eb..00000000 --- a/include/ientity.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "ientity.h" diff --git a/include/ifilesystem.cpp b/include/ifilesystem.cpp deleted file mode 100644 index 154f9065..00000000 --- a/include/ifilesystem.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "ifilesystem.h" diff --git a/include/ifiletypes.cpp b/include/ifiletypes.cpp deleted file mode 100644 index b4e55668..00000000 --- a/include/ifiletypes.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "ifiletypes.h" diff --git a/include/ifilter.cpp b/include/ifilter.cpp deleted file mode 100644 index a5e732f4..00000000 --- a/include/ifilter.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "ifilter.h" diff --git a/include/igl.cpp b/include/igl.cpp deleted file mode 100644 index 41781a49..00000000 --- a/include/igl.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "igl.h" diff --git a/include/iglrender.cpp b/include/iglrender.cpp deleted file mode 100644 index 6a9d9a74..00000000 --- a/include/iglrender.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "iglrender.h" diff --git a/include/igtkgl.cpp b/include/igtkgl.cpp deleted file mode 100644 index d0084a85..00000000 --- a/include/igtkgl.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "igtkgl.h" diff --git a/include/igtkgl.h b/include/igtkgl.h index e6e85254..b4454564 100644 --- a/include/igtkgl.h +++ b/include/igtkgl.h @@ -22,22 +22,21 @@ #if !defined( INCLUDED_IGTKGL_H ) #define INCLUDED_IGTKGL_H +#include #include "generic/constant.h" -typedef struct _GtkWidget GtkWidget; -typedef int gint; -typedef gint gboolean; +template +using func = T *; -struct _QERGtkGLTable -{ - INTEGER_CONSTANT( Version, 1 ); - STRING_CONSTANT( Name, "gtkgl" ); +struct _QERGtkGLTable { + STRING_CONSTANT(Name, "gtkgl"); + INTEGER_CONSTANT(Version, 1); - GtkWidget* ( *glwidget_new )(gboolean zbufffer); - void ( *glwidget_swap_buffers )( GtkWidget* widget ); - gboolean ( *glwidget_make_current )( GtkWidget* widget ); - void ( *glwidget_destroy_context )( GtkWidget* widget ); - void ( *glwidget_create_context )( GtkWidget* widget ); + func glwidget_new; + func glwidget_swap_buffers; + func glwidget_make_current; + func glwidget_destroy_context; + func glwidget_create_context; }; #endif diff --git a/include/iimage.cpp b/include/iimage.cpp deleted file mode 100644 index f438be78..00000000 --- a/include/iimage.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "iimage.h" diff --git a/include/imap.cpp b/include/imap.cpp deleted file mode 100644 index a91f14da..00000000 --- a/include/imap.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "imap.h" diff --git a/include/imodel.cpp b/include/imodel.cpp deleted file mode 100644 index 0b932e25..00000000 --- a/include/imodel.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "imodel.h" diff --git a/include/ipatch.cpp b/include/ipatch.cpp deleted file mode 100644 index e29029c3..00000000 --- a/include/ipatch.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "ipatch.h" diff --git a/include/iplugin.cpp b/include/iplugin.cpp deleted file mode 100644 index 2a7dab9b..00000000 --- a/include/iplugin.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "iplugin.h" diff --git a/include/ireference.cpp b/include/ireference.cpp deleted file mode 100644 index d2f56c49..00000000 --- a/include/ireference.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "ireference.h" diff --git a/include/irender.cpp b/include/irender.cpp deleted file mode 100644 index 9726b6d8..00000000 --- a/include/irender.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "irender.h" diff --git a/include/iscenegraph.cpp b/include/iscenegraph.cpp deleted file mode 100644 index 48cbcf23..00000000 --- a/include/iscenegraph.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "iscenegraph.h" diff --git a/include/iscriplib.cpp b/include/iscriplib.cpp deleted file mode 100644 index 3c4ba180..00000000 --- a/include/iscriplib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "iscriplib.h" diff --git a/include/iselection.cpp b/include/iselection.cpp deleted file mode 100644 index c0686cf2..00000000 --- a/include/iselection.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "iselection.h" diff --git a/include/ishaders.cpp b/include/ishaders.cpp deleted file mode 100644 index 4a7affdd..00000000 --- a/include/ishaders.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "ishaders.h" diff --git a/include/itexdef.cpp b/include/itexdef.cpp deleted file mode 100644 index 462a7a2f..00000000 --- a/include/itexdef.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "itexdef.h" diff --git a/include/itextstream.cpp b/include/itextstream.cpp deleted file mode 100644 index 3ce3df75..00000000 --- a/include/itextstream.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "itextstream.h" diff --git a/include/itextures.cpp b/include/itextures.cpp deleted file mode 100644 index ae75c635..00000000 --- a/include/itextures.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "itextures.h" diff --git a/include/itoolbar.cpp b/include/itoolbar.cpp deleted file mode 100644 index 146f7551..00000000 --- a/include/itoolbar.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "itoolbar.h" diff --git a/include/itoolbar.h b/include/itoolbar.h index 62d82b6e..7e5daad3 100644 --- a/include/itoolbar.h +++ b/include/itoolbar.h @@ -33,7 +33,6 @@ enum EType eSpace, eButton, eToggleButton, - eRadioButton, }; virtual const char* getImage() const = 0; diff --git a/include/iundo.cpp b/include/iundo.cpp deleted file mode 100644 index 8dfd9e2d..00000000 --- a/include/iundo.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "iundo.h" diff --git a/include/mapfile.cpp b/include/mapfile.cpp deleted file mode 100644 index 5a6332ee..00000000 --- a/include/mapfile.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapfile.h" diff --git a/include/modelskin.cpp b/include/modelskin.cpp deleted file mode 100644 index fcdda390..00000000 --- a/include/modelskin.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "modelskin.h" diff --git a/include/moduleobserver.cpp b/include/moduleobserver.cpp deleted file mode 100644 index f9d40b12..00000000 --- a/include/moduleobserver.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "moduleobserver.h" diff --git a/include/modulesystem.cpp b/include/modulesystem.cpp deleted file mode 100644 index 907e8f7c..00000000 --- a/include/modulesystem.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "modulesystem.h" diff --git a/include/nameable.cpp b/include/nameable.cpp deleted file mode 100644 index 8722c471..00000000 --- a/include/nameable.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "nameable.h" diff --git a/include/namespace.cpp b/include/namespace.cpp deleted file mode 100644 index f9b22f5b..00000000 --- a/include/namespace.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "namespace.h" diff --git a/include/qerplugin.cpp b/include/qerplugin.cpp deleted file mode 100644 index 54760013..00000000 --- a/include/qerplugin.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "qerplugin.h" diff --git a/include/qerplugin.h b/include/qerplugin.h index cb6c2ba5..8e56da9c 100644 --- a/include/qerplugin.h +++ b/include/qerplugin.h @@ -26,6 +26,7 @@ #ifndef __QERPLUGIN_H__ #define __QERPLUGIN_H__ +#include "uilib/uilib.h" #include "generic/constant.h" @@ -35,7 +36,6 @@ // NOTE: parent can be 0 in all functions but it's best to set them // this API does not depend on gtk+ or glib -typedef struct _GtkWidget GtkWidget; enum EMessageBoxType { @@ -65,28 +65,27 @@ enum EMessageBoxReturn // simple Message Box, see above for the 'type' flags -typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( GtkWidget *parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ ); +typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( ui::Widget parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ ); // file and directory selection functions return null if the user hits cancel // - 'title' is the dialog title (can be null) // - 'path' is used to set the initial directory (can be null) // - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples -typedef const char* ( *PFN_QERAPP_FILEDIALOG )( GtkWidget *parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ ); +typedef const char* ( *PFN_QERAPP_FILEDIALOG )( ui::Widget parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ ); // returns a gchar* string that must be g_free'd by the user -typedef char* ( *PFN_QERAPP_DIRDIALOG )( GtkWidget *parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ ); +typedef char* ( *PFN_QERAPP_DIRDIALOG )( ui::Widget parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ ); // return true if the user closed the dialog with 'Ok' // 'color' is used to set the initial value and store the selected value template class BasicVector3; typedef BasicVector3 Vector3; -typedef bool ( *PFN_QERAPP_COLORDIALOG )( GtkWidget *parent, Vector3& color, +typedef bool ( *PFN_QERAPP_COLORDIALOG )( ui::Widget parent, Vector3& color, const char* title /* = "Choose Color"*/ ); // load a .bmp file and create a GtkImage widget from it // NOTE: 'filename' is relative to /plugins/bitmaps/ -typedef struct _GtkImage GtkImage; -typedef GtkImage* ( *PFN_QERAPP_NEWIMAGE )( const char* filename ); +typedef ui::Image ( *PFN_QERAPP_NEWIMAGE )( const char* filename ); // ======================================== diff --git a/include/renderable.cpp b/include/renderable.cpp deleted file mode 100644 index dfc186fd..00000000 --- a/include/renderable.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "renderable.h" diff --git a/include/selectable.cpp b/include/selectable.cpp deleted file mode 100644 index 38a2d1ab..00000000 --- a/include/selectable.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "selectable.h" diff --git a/include/windowobserver.cpp b/include/windowobserver.cpp deleted file mode 100644 index 16b4a006..00000000 --- a/include/windowobserver.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "windowobserver.h" diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 05055be5..03347d71 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -25,35 +25,36 @@ add_subdirectory(uilib) add_subdirectory(xml) add_library(libs - archivelib.cpp archivelib.h - bytebool.cpp bytebool.h - bytestreamutils.cpp bytestreamutils.h - character.cpp character.h - convert.cpp convert.h - dragplanes.cpp dragplanes.h - eclasslib.cpp eclasslib.h - entitylib.cpp entitylib.h - entityxml.cpp entityxml.h - fs_filesystem.cpp fs_filesystem.h - fs_path.cpp fs_path.h - imagelib.cpp imagelib.h - instancelib.cpp instancelib.h - maplib.cpp maplib.h - moduleobservers.cpp moduleobservers.h - pivot.cpp pivot.h - render.cpp render.h - scenelib.cpp scenelib.h - selectionlib.cpp selectionlib.h - shaderlib.cpp shaderlib.h - str.cpp str.h - stringio.cpp stringio.h - texturelib.cpp texturelib.h - transformlib.cpp transformlib.h - traverselib.cpp traverselib.h - typesystem.cpp typesystem.h - undolib.cpp undolib.h - uniquenames.cpp uniquenames.h - versionlib.cpp versionlib.h + _.cpp + archivelib.h + bytebool.h + bytestreamutils.h + character.h + convert.h + dragplanes.h + eclasslib.h + entitylib.h + entityxml.h + fs_filesystem.h + fs_path.h + imagelib.h + instancelib.h + maplib.h + moduleobservers.h + pivot.h + render.h + scenelib.h + selectionlib.h + shaderlib.h + str.h + stringio.h + texturelib.h + transformlib.h + traverselib.h + typesystem.h + undolib.h + uniquenames.h + versionlib.h ) find_package(GLIB REQUIRED) diff --git a/libs/_.cpp b/libs/_.cpp new file mode 100644 index 00000000..e69de29b diff --git a/libs/archivelib.cpp b/libs/archivelib.cpp deleted file mode 100644 index a66f1309..00000000 --- a/libs/archivelib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "archivelib.h" diff --git a/libs/bytebool.cpp b/libs/bytebool.cpp deleted file mode 100644 index d636f556..00000000 --- a/libs/bytebool.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "bytebool.h" diff --git a/libs/bytestreamutils.cpp b/libs/bytestreamutils.cpp deleted file mode 100644 index 87917d2c..00000000 --- a/libs/bytestreamutils.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "bytestreamutils.h" diff --git a/libs/character.cpp b/libs/character.cpp deleted file mode 100644 index cd36bc7b..00000000 --- a/libs/character.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "character.h" diff --git a/libs/container/CMakeLists.txt b/libs/container/CMakeLists.txt index bd3c8ce2..00bfbb4a 100644 --- a/libs/container/CMakeLists.txt +++ b/libs/container/CMakeLists.txt @@ -1,8 +1,8 @@ add_library(container array.cpp array.h - cache.cpp cache.h - container.cpp container.h - hashfunc.cpp hashfunc.h + cache.h + container.h + hashfunc.h hashtable.cpp hashtable.h - stack.cpp stack.h + stack.h ) diff --git a/libs/container/array.h b/libs/container/array.h index c359df15..390282a7 100644 --- a/libs/container/array.h +++ b/libs/container/array.h @@ -166,5 +166,4 @@ inline void swap( Array& self, Array& ot self.swap( other ); } } - #endif diff --git a/libs/container/cache.cpp b/libs/container/cache.cpp deleted file mode 100644 index 5cbdb00b..00000000 --- a/libs/container/cache.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "cache.h" diff --git a/libs/container/cache.h b/libs/container/cache.h index 880a7a7a..047e4ea8 100644 --- a/libs/container/cache.h +++ b/libs/container/cache.h @@ -95,83 +95,83 @@ pointer operator->() const { template, typename CreationPolicy = DefaultCreationPolicy > class HashedCache : public CreationPolicy { -typedef SharedValue Element; -typedef HashTable map_type; + typedef SharedValue Element; + typedef HashTable map_type; -map_type m_map; + map_type m_map; public: -explicit HashedCache( const CreationPolicy& creation = CreationPolicy() ) - : CreationPolicy( creation ), m_map( 256 ){ -} -~HashedCache(){ - ASSERT_MESSAGE( empty(), "HashedCache::~HashedCache: not empty" ); -} + explicit HashedCache( const CreationPolicy& creation = CreationPolicy() ) + : CreationPolicy( creation ), m_map( 256 ){ + } + ~HashedCache(){ + ASSERT_MESSAGE( empty(), "HashedCache::~HashedCache: not empty" ); + } -typedef typename map_type::iterator iterator; -typedef typename map_type::value_type value_type; + typedef typename map_type::iterator iterator; + typedef typename map_type::value_type value_type; -iterator begin(){ - return m_map.begin(); -} -iterator end(){ - return m_map.end(); -} + iterator begin(){ + return m_map.begin(); + } + iterator end(){ + return m_map.end(); + } -bool empty() const { - return m_map.empty(); -} + bool empty() const { + return m_map.empty(); + } -iterator find( const Key& key ){ - return m_map.find( key ); -} + iterator find( const Key& key ){ + return m_map.find( key ); + } -void capture( iterator i ){ + void capture( iterator i ){ ( *i ).value.increment(); -} -void release( iterator i ){ + } + void release( iterator i ){ if ( ( *i ).value.decrement() == 0 ) { CreationPolicy::destroy( ( *i ).value.get() ); - m_map.erase( i ); + m_map.erase( i ); + } } -} #if 1 -Element& capture( const Key& key ){ + Element& capture( const Key& key ){ #if 0 Element& elem = m_map[key]; - if ( elem.increment() == 1 ) { - elem.set( CreationPolicy::construct( key ) ); - } + if ( elem.increment() == 1 ) { + elem.set( CreationPolicy::construct( key ) ); + } return elem; #else iterator i = m_map.insert( key, Element() ); if ( ( *i ).value.increment() == 1 ) { ( *i ).value.set( CreationPolicy::construct( ( *i ).key ) ); - } + } return ( *i ).value; #endif -} + } #else value_type& capture( const Key& key ){ - iterator i = m_map.find( key ); - if ( i == m_map.end() ) { - i = m_map.insert( key, Element() ); + iterator i = m_map.find( key ); + if ( i == m_map.end() ) { + i = m_map.insert( key, Element() ); ( *i ).value.set( CreationPolicy::construct( ( *i ).key ) ); - } + } ( *i ).value.increment(); - return ( *i ); + return ( *i ); } #endif -void release( const Key& key ){ - iterator i = m_map.find( key ); - ASSERT_MESSAGE( i != m_map.end(), "releasing a non-existent object\n" ); - release( i ); -} + void release( const Key& key ){ + iterator i = m_map.find( key ); + ASSERT_MESSAGE( i != m_map.end(), "releasing a non-existent object\n" ); + release( i ); + } -void clear(){ - m_map.clear(); -} + void clear(){ + m_map.clear(); + } }; diff --git a/libs/container/container.cpp b/libs/container/container.cpp deleted file mode 100644 index 8790307e..00000000 --- a/libs/container/container.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "container.h" diff --git a/libs/container/hashfunc.cpp b/libs/container/hashfunc.cpp deleted file mode 100644 index 4c3d2e07..00000000 --- a/libs/container/hashfunc.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "hashfunc.h" diff --git a/libs/container/hashtable.h b/libs/container/hashtable.h index 0f174d20..7fa7907e 100644 --- a/libs/container/hashtable.h +++ b/libs/container/hashtable.h @@ -28,7 +28,6 @@ #include #include "debugging/debugging.h" - namespace HashTableDetail { inline std::size_t next_power_of_two( std::size_t size ){ diff --git a/libs/container/stack.cpp b/libs/container/stack.cpp deleted file mode 100644 index 81d79b27..00000000 --- a/libs/container/stack.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "stack.h" diff --git a/libs/convert.cpp b/libs/convert.cpp deleted file mode 100644 index c87038f5..00000000 --- a/libs/convert.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "convert.h" diff --git a/libs/debugging/debugging.h b/libs/debugging/debugging.h index c549a2f2..e05ff31b 100644 --- a/libs/debugging/debugging.h +++ b/libs/debugging/debugging.h @@ -117,6 +117,7 @@ inline DebugMessageHandler& globalDebugMessageHandler(){ if ( !globalDebugMessageHandler().handleMessage() ) { DEBUGGER_BREAKPOINT(); }} while ( 0 ) #define ASSERT_NOTNULL( ptr ) ASSERT_MESSAGE( ptr != 0, "pointer \"" # ptr "\" is null" ) +#define ASSERT_TRUE( flag ) ASSERT_MESSAGE( !!(flag) == true, "condition \"" # flag "\" is false" ) #else diff --git a/libs/dragplanes.cpp b/libs/dragplanes.cpp deleted file mode 100644 index 89da6662..00000000 --- a/libs/dragplanes.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "dragplanes.h" diff --git a/libs/eclasslib.cpp b/libs/eclasslib.cpp deleted file mode 100644 index 04d0d690..00000000 --- a/libs/eclasslib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "eclasslib.h" diff --git a/libs/entitylib.cpp b/libs/entitylib.cpp deleted file mode 100644 index 48f3138e..00000000 --- a/libs/entitylib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "entitylib.h" diff --git a/libs/entityxml.cpp b/libs/entityxml.cpp deleted file mode 100644 index 13b74088..00000000 --- a/libs/entityxml.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "entityxml.h" diff --git a/libs/fs_filesystem.cpp b/libs/fs_filesystem.cpp deleted file mode 100644 index 9b781a3d..00000000 --- a/libs/fs_filesystem.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "fs_filesystem.h" diff --git a/libs/fs_path.cpp b/libs/fs_path.cpp deleted file mode 100644 index f38bf1c5..00000000 --- a/libs/fs_path.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "fs_path.h" diff --git a/libs/generic/CMakeLists.txt b/libs/generic/CMakeLists.txt index 38004238..b872d874 100644 --- a/libs/generic/CMakeLists.txt +++ b/libs/generic/CMakeLists.txt @@ -1,14 +1,14 @@ add_library(generic - arrayrange.cpp arrayrange.h - bitfield.cpp bitfield.h + arrayrange.h + bitfield.h callback.cpp callback.h - callbackfwd.cpp callbackfwd.h + callbackfwd.h constant.cpp constant.h - enumeration.cpp enumeration.h - functional.cpp functional.h + enumeration.h + functional.h object.cpp object.h - reference.cpp reference.h - referencecounted.cpp referencecounted.h + reference.h + referencecounted.h static.cpp static.h - vector.cpp vector.h + vector.h ) diff --git a/libs/generic/arrayrange.cpp b/libs/generic/arrayrange.cpp deleted file mode 100644 index 0ee018b2..00000000 --- a/libs/generic/arrayrange.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "arrayrange.h" diff --git a/libs/generic/bitfield.cpp b/libs/generic/bitfield.cpp deleted file mode 100644 index 7e46a347..00000000 --- a/libs/generic/bitfield.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "bitfield.h" diff --git a/libs/generic/callbackfwd.cpp b/libs/generic/callbackfwd.cpp deleted file mode 100644 index af157742..00000000 --- a/libs/generic/callbackfwd.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "callbackfwd.h" diff --git a/libs/generic/enumeration.cpp b/libs/generic/enumeration.cpp deleted file mode 100644 index c6071cd4..00000000 --- a/libs/generic/enumeration.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "enumeration.h" diff --git a/libs/generic/functional.cpp b/libs/generic/functional.cpp deleted file mode 100644 index e6cc8572..00000000 --- a/libs/generic/functional.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "functional.h" diff --git a/libs/generic/reference.cpp b/libs/generic/reference.cpp deleted file mode 100644 index fd64f288..00000000 --- a/libs/generic/reference.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "reference.h" diff --git a/libs/generic/referencecounted.cpp b/libs/generic/referencecounted.cpp deleted file mode 100644 index 0c531bd7..00000000 --- a/libs/generic/referencecounted.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "referencecounted.h" diff --git a/libs/generic/vector.cpp b/libs/generic/vector.cpp deleted file mode 100644 index fbafd538..00000000 --- a/libs/generic/vector.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "vector.h" diff --git a/libs/gtkutil/CMakeLists.txt b/libs/gtkutil/CMakeLists.txt index bc5d772c..b62098c1 100644 --- a/libs/gtkutil/CMakeLists.txt +++ b/libs/gtkutil/CMakeLists.txt @@ -2,8 +2,8 @@ add_library(gtkutil accelerator.cpp accelerator.h button.cpp button.h clipboard.cpp clipboard.h - closure.cpp closure.h - container.cpp container.h + closure.h + container.h cursor.cpp cursor.h dialog.cpp dialog.h entry.cpp entry.h @@ -11,13 +11,13 @@ add_library(gtkutil frame.cpp frame.h glfont.cpp glfont.h glwidget.cpp glwidget.h - idledraw.cpp idledraw.h + idledraw.h image.cpp image.h menu.cpp menu.h messagebox.cpp messagebox.h nonmodal.cpp nonmodal.h paned.cpp paned.h - pointer.cpp pointer.h + pointer.h toolbar.cpp toolbar.h widget.cpp widget.h window.cpp window.h @@ -27,9 +27,11 @@ add_library(gtkutil target_include_directories(gtkutil PRIVATE uilib) target_link_libraries(gtkutil PRIVATE uilib) -target_include_directories(gtkutil PRIVATE ${${GTK_NS}_INCLUDE_DIRS}) -target_link_libraries(gtkutil PRIVATE ${${GTK_NS}_LIBRARIES}) +target_include_directories(gtkutil PRIVATE ${GTK${GTK_TARGET}_INCLUDE_DIRS}) +target_link_libraries(gtkutil PRIVATE ${GTK${GTK_TARGET}_LIBRARIES}) -find_package(GtkGLExt REQUIRED) -target_include_directories(gtkutil PRIVATE ${GTKGL_INCLUDE_DIRS}) -target_link_libraries(gtkutil PRIVATE ${GTKGL_LIBRARIES}) +if (GTK_TARGET EQUAL 2) + find_package(GtkGLExt REQUIRED) + target_include_directories(gtkutil PRIVATE ${GtkGLExt_INCLUDE_DIRS}) + target_link_libraries(gtkutil PRIVATE ${GtkGLExt_LIBRARIES}) +endif () diff --git a/libs/gtkutil/accelerator.cpp b/libs/gtkutil/accelerator.cpp index bba9ebe3..606f505e 100644 --- a/libs/gtkutil/accelerator.cpp +++ b/libs/gtkutil/accelerator.cpp @@ -25,8 +25,7 @@ #include #include -#include -#include +#include #include "generic/callback.h" #include "generic/bitfield.h" @@ -57,7 +56,7 @@ unsigned int global_keys_find( const char* name ){ return 0; } k = gdk_keyval_from_name( name ); - if ( k == GDK_VoidSymbol ) { + if ( k == GDK_KEY_VoidSymbol ) { return 0; } return k; @@ -110,8 +109,8 @@ bool accelerator_map_erase( AcceleratorMap& acceleratorMap, Accelerator accelera Accelerator accelerator_for_event_key( guint keyval, guint state ){ keyval = gdk_keyval_to_upper( keyval ); - if ( keyval == GDK_ISO_Left_Tab ) { - keyval = GDK_Tab; + if ( keyval == GDK_KEY_ISO_Left_Tab ) { + keyval = GDK_KEY_Tab; } return Accelerator( keyval, (GdkModifierType)( state & gtk_accelerator_get_default_mod_mask() ) ); } @@ -126,7 +125,7 @@ bool AcceleratorMap_activate( const AcceleratorMap& acceleratorMap, const Accele return false; } -static gboolean accelerator_key_event( GtkWindow* window, GdkEventKey* event, AcceleratorMap* acceleratorMap ){ +static gboolean accelerator_key_event( ui::Window window, GdkEventKey* event, AcceleratorMap* acceleratorMap ){ return AcceleratorMap_activate( *acceleratorMap, accelerator_for_event_key( event->keyval, event->state ) ); } @@ -173,7 +172,7 @@ ButtonMask ButtonMask_for_event_button( guint button ){ return 0; } -bool window_has_accel( GtkWindow* toplevel ){ +bool window_has_accel( ui::Window toplevel ){ return g_slist_length( gtk_accel_groups_from_object( G_OBJECT( toplevel ) ) ) != 0; } @@ -222,14 +221,7 @@ void globalQueuedAccelerators_commit(){ g_queuedAcceleratorsAdd.clear(); } -void accel_group_test( GtkWindow* toplevel, GtkAccelGroup* accel ){ - guint n_entries; - gtk_accel_group_query( accel, '4', (GdkModifierType)0, &n_entries ); - globalOutputStream() << "grid4: " << n_entries << "\n"; - globalOutputStream() << "toplevel accelgroups: " << g_slist_length( gtk_accel_groups_from_object( G_OBJECT( toplevel ) ) ) << "\n"; -} - -typedef std::set WindowSet; +typedef std::set WindowSet; WindowSet g_accel_windows; bool Buttons_press( ButtonMask& buttons, guint button, guint state ){ @@ -238,15 +230,12 @@ bool Buttons_press( ButtonMask& buttons, guint button, guint state ){ g_accel_enabled = false; for ( WindowSet::iterator i = g_accel_windows.begin(); i != g_accel_windows.end(); ++i ) { - GtkWindow* toplevel = *i; + ui::Window toplevel = *i; ASSERT_MESSAGE( window_has_accel( toplevel ), "ERROR" ); - ASSERT_MESSAGE( GTK_WIDGET_TOPLEVEL( toplevel ), "disabling accel for non-toplevel window" ); + ASSERT_MESSAGE( gtk_widget_is_toplevel( GTK_WIDGET(toplevel) ), "disabling accel for non-toplevel window" ); gtk_window_remove_accel_group( toplevel, global_accel ); #if 0 globalOutputStream() << reinterpret_cast( toplevel ) << ": disabled global accelerators\n"; -#endif -#if 0 - accel_group_test( toplevel, global_accel ); #endif } } @@ -264,15 +253,12 @@ bool Buttons_release( ButtonMask& buttons, guint button, guint state ){ g_accel_enabled = true; for ( WindowSet::iterator i = g_accel_windows.begin(); i != g_accel_windows.end(); ++i ) { - GtkWindow* toplevel = *i; + ui::Window toplevel = *i; ASSERT_MESSAGE( !window_has_accel( toplevel ), "ERROR" ); - ASSERT_MESSAGE( GTK_WIDGET_TOPLEVEL( toplevel ), "enabling accel for non-toplevel window" ); - gtk_window_add_accel_group( toplevel, global_accel ); + ASSERT_MESSAGE( gtk_widget_is_toplevel( GTK_WIDGET(toplevel) ), "enabling accel for non-toplevel window" ); + toplevel.add_accel_group( global_accel ); #if 0 globalOutputStream() << reinterpret_cast( toplevel ) << ": enabled global accelerators\n"; -#endif -#if 0 - accel_group_test( toplevel, global_accel ); #endif } globalQueuedAccelerators_commit(); @@ -317,16 +303,17 @@ gboolean PressedButtons_focus_out( GtkWidget* widget, GdkEventFocus* event, Pres return FALSE; } -void PressedButtons_connect( PressedButtons& pressedButtons, GtkWidget* widget ){ - g_signal_connect( G_OBJECT( widget ), "button_press_event", G_CALLBACK( PressedButtons_button_press ), &pressedButtons ); - g_signal_connect( G_OBJECT( widget ), "button_release_event", G_CALLBACK( PressedButtons_button_release ), &pressedButtons ); - g_signal_connect( G_OBJECT( widget ), "focus_out_event", G_CALLBACK( PressedButtons_focus_out ), &pressedButtons ); +void PressedButtons_connect( PressedButtons& pressedButtons, ui::Widget widget ){ + widget.connect( "button_press_event", G_CALLBACK( PressedButtons_button_press ), &pressedButtons ); + widget.connect( "button_release_event", G_CALLBACK( PressedButtons_button_release ), &pressedButtons ); + widget.connect( "focus_out_event", G_CALLBACK( PressedButtons_focus_out ), &pressedButtons ); } PressedButtons g_pressedButtons; #include +#include struct PressedKeys { @@ -391,18 +378,18 @@ void GlobalPressedKeys_releaseAll(){ Keys_releaseAll( g_pressedKeys.keys, 0 ); } -void GlobalPressedKeys_connect( GtkWindow* window ){ - unsigned int key_press_handler = g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( PressedKeys_key_press ), &g_pressedKeys ); - unsigned int key_release_handler = g_signal_connect( G_OBJECT( window ), "key_release_event", G_CALLBACK( PressedKeys_key_release ), &g_pressedKeys ); +void GlobalPressedKeys_connect( ui::Window window ){ + unsigned int key_press_handler = window.connect( "key_press_event", G_CALLBACK( PressedKeys_key_press ), &g_pressedKeys ); + unsigned int key_release_handler = window.connect( "key_release_event", G_CALLBACK( PressedKeys_key_release ), &g_pressedKeys ); g_object_set_data( G_OBJECT( window ), "key_press_handler", gint_to_pointer( key_press_handler ) ); g_object_set_data( G_OBJECT( window ), "key_release_handler", gint_to_pointer( key_release_handler ) ); - unsigned int focus_in_handler = g_signal_connect( G_OBJECT( window ), "focus_in_event", G_CALLBACK( PressedKeys_focus_in ), &g_pressedKeys ); - unsigned int focus_out_handler = g_signal_connect( G_OBJECT( window ), "focus_out_event", G_CALLBACK( PressedKeys_focus_out ), &g_pressedKeys ); + unsigned int focus_in_handler = window.connect( "focus_in_event", G_CALLBACK( PressedKeys_focus_in ), &g_pressedKeys ); + unsigned int focus_out_handler = window.connect( "focus_out_event", G_CALLBACK( PressedKeys_focus_out ), &g_pressedKeys ); g_object_set_data( G_OBJECT( window ), "focus_in_handler", gint_to_pointer( focus_in_handler ) ); g_object_set_data( G_OBJECT( window ), "focus_out_handler", gint_to_pointer( focus_out_handler ) ); } -void GlobalPressedKeys_disconnect( GtkWindow* window ){ +void GlobalPressedKeys_disconnect( ui::Window window ){ g_signal_handler_disconnect( G_OBJECT( window ), gpointer_to_int( g_object_get_data( G_OBJECT( window ), "key_press_handler" ) ) ); g_signal_handler_disconnect( G_OBJECT( window ), gpointer_to_int( g_object_get_data( G_OBJECT( window ), "key_release_handler" ) ) ); g_signal_handler_disconnect( G_OBJECT( window ), gpointer_to_int( g_object_get_data( G_OBJECT( window ), "focus_in_handler" ) ) ); @@ -481,15 +468,7 @@ void accel_group_remove_accelerator( GtkAccelGroup* group, Accelerator accelerat } } -GtkAccelGroup* global_accel = 0; - -void global_accel_init(){ - global_accel = gtk_accel_group_new(); -} - -void global_accel_destroy(){ - g_object_unref( global_accel ); -} +ui::AccelGroup global_accel = ui::AccelGroup(); GClosure* global_accel_group_add_accelerator( Accelerator accelerator, const Callback& callback ){ if ( !global_accel_enabled() ) { @@ -510,30 +489,30 @@ void global_accel_group_remove_accelerator( Accelerator accelerator ){ } /// \brief Propagates key events to the focus-widget, overriding global accelerators. -static gboolean override_global_accelerators( GtkWindow* window, GdkEventKey* event, gpointer data ){ +static gboolean override_global_accelerators( ui::Window window, GdkEventKey* event, gpointer data ){ gboolean b = gtk_window_propagate_key_event( window, event ); return b; } -void global_accel_connect_window( GtkWindow* window ){ +void global_accel_connect_window( ui::Window window ){ #if 1 - unsigned int override_handler = g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( override_global_accelerators ), 0 ); + unsigned int override_handler = window.connect( "key_press_event", G_CALLBACK( override_global_accelerators ), 0 ); g_object_set_data( G_OBJECT( window ), "override_handler", gint_to_pointer( override_handler ) ); - unsigned int special_key_press_handler = g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( accelerator_key_event ), &g_special_accelerators ); + unsigned int special_key_press_handler = window.connect( "key_press_event", G_CALLBACK( accelerator_key_event ), &g_special_accelerators ); g_object_set_data( G_OBJECT( window ), "special_key_press_handler", gint_to_pointer( special_key_press_handler ) ); GlobalPressedKeys_connect( window ); #else - unsigned int key_press_handler = g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( accelerator_key_event ), &g_keydown_accelerators ); - unsigned int key_release_handler = g_signal_connect( G_OBJECT( window ), "key_release_event", G_CALLBACK( accelerator_key_event ), &g_keyup_accelerators ); + unsigned int key_press_handler = window.connect( "key_press_event", G_CALLBACK( accelerator_key_event ), &g_keydown_accelerators ); + unsigned int key_release_handler = window.connect( "key_release_event", G_CALLBACK( accelerator_key_event ), &g_keyup_accelerators ); g_object_set_data( G_OBJECT( window ), "key_press_handler", gint_to_pointer( key_press_handler ) ); g_object_set_data( G_OBJECT( window ), "key_release_handler", gint_to_pointer( key_release_handler ) ); #endif g_accel_windows.insert( window ); - gtk_window_add_accel_group( window, global_accel ); + window.add_accel_group( global_accel ); } -void global_accel_disconnect_window( GtkWindow* window ){ +void global_accel_disconnect_window( ui::Window window ){ #if 1 GlobalPressedKeys_disconnect( window ); diff --git a/libs/gtkutil/accelerator.h b/libs/gtkutil/accelerator.h index d1cd344e..821830f4 100644 --- a/libs/gtkutil/accelerator.h +++ b/libs/gtkutil/accelerator.h @@ -22,9 +22,8 @@ #if !defined( INCLUDED_GTKUTIL_ACCELERATOR_H ) #define INCLUDED_GTKUTIL_ACCELERATOR_H -#include -#include -#include +#include +#include #include "generic/callback.h" @@ -86,17 +85,12 @@ void keydown_accelerators_remove( Accelerator accelerator ); void keyup_accelerators_add( Accelerator accelerator, const Callback& callback ); void keyup_accelerators_remove( Accelerator accelerator ); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -void global_accel_connect_window( GtkWindow* window ); -void global_accel_disconnect_window( GtkWindow* window ); +void global_accel_connect_window( ui::Window window ); +void global_accel_disconnect_window( ui::Window window ); void GlobalPressedKeys_releaseAll(); -typedef struct _GtkAccelGroup GtkAccelGroup; -extern GtkAccelGroup* global_accel; -void global_accel_init(); -void global_accel_destroy(); +extern ui::AccelGroup global_accel; GClosure* global_accel_group_find( Accelerator accelerator ); @@ -135,8 +129,7 @@ KeyEvent( const Accelerator& accelerator, const Callback& keyDown, const Callbac struct PressedButtons; -typedef struct _GtkWidget GtkWidget; -void PressedButtons_connect( PressedButtons& pressedButtons, GtkWidget* widget ); +void PressedButtons_connect( PressedButtons& pressedButtons, ui::Widget widget ); extern PressedButtons g_pressedButtons; diff --git a/libs/gtkutil/button.cpp b/libs/gtkutil/button.cpp index fc1e58d7..af19ef35 100644 --- a/libs/gtkutil/button.cpp +++ b/libs/gtkutil/button.cpp @@ -21,7 +21,7 @@ #include "button.h" -#include +#include #include "stream/textstream.h" #include "stream/stringstream.h" @@ -30,11 +30,11 @@ #include "image.h" #include "pointer.h" -void clicked_closure_callback( GtkWidget* widget, gpointer data ){ +void clicked_closure_callback( ui::Widget widget, gpointer data ){ ( *reinterpret_cast( data ) )( ); } -void button_connect_callback( GtkButton* button, const Callback& callback ){ +void button_connect_callback( ui::Button button, const Callback& callback ){ #if 1 g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); #else @@ -42,7 +42,15 @@ void button_connect_callback( GtkButton* button, const Callback& callback ){ #endif } -guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& callback ){ +void button_connect_callback( ui::ToolButton button, const Callback& callback ){ +#if 1 + g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); +#else + g_signal_connect_closure( G_OBJECT( button ), "clicked", create_cclosure( G_CALLBACK( clicked_closure_callback ), callback ), FALSE ); +#endif +} + +guint toggle_button_connect_callback( ui::ToggleButton button, const Callback& callback ){ #if 1 guint handler = g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); #else @@ -52,13 +60,23 @@ guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& c return handler; } -void button_set_icon( GtkButton* button, const char* icon ){ - GtkImage* image = new_local_image( icon ); - gtk_widget_show( GTK_WIDGET( image ) ); - gtk_container_add( GTK_CONTAINER( button ), GTK_WIDGET( image ) ); +guint toggle_button_connect_callback( ui::ToggleToolButton button, const Callback& callback ){ +#if 1 + guint handler = g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); +#else + guint handler = g_signal_connect_closure( G_OBJECT( button ), "toggled", create_cclosure( G_CALLBACK( clicked_closure_callback ), callback ), TRUE ); +#endif + g_object_set_data( G_OBJECT( button ), "handler", gint_to_pointer( handler ) ); + return handler; +} + +void button_set_icon( ui::Button button, const char* icon ){ + ui::Image image = ui::Image(new_local_image( icon )); + image.show(); + button.add(image); } -void toggle_button_set_active_no_signal( GtkToggleButton* button, gboolean active ){ +void toggle_button_set_active_no_signal( ui::ToggleButton button, gboolean active ){ //globalOutputStream() << "set active: " << active << "\n"; guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( button ), "handler" ) ); //guint signal_id = g_signal_lookup("toggled", G_OBJECT_TYPE (button)); @@ -70,28 +88,35 @@ void toggle_button_set_active_no_signal( GtkToggleButton* button, gboolean activ g_signal_handler_unblock( G_OBJECT( button ), handler_id ); } +void toggle_button_set_active_no_signal( ui::ToggleToolButton button, gboolean active ){ + guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( button ), "handler" ) ); + g_signal_handler_block( G_OBJECT( button ), handler_id ); + gtk_toggle_tool_button_set_active( button, active ); + g_signal_handler_unblock( G_OBJECT( button ), handler_id ); +} + -void radio_button_print_state( GtkRadioButton* button ){ +void radio_button_print_state( ui::RadioButton button ){ globalOutputStream() << "toggle button: "; - for ( GSList* radio = gtk_radio_button_group( button ); radio != 0; radio = g_slist_next( radio ) ) + for ( GSList* radio = gtk_radio_button_get_group( button ); radio != 0; radio = g_slist_next( radio ) ) { globalOutputStream() << gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio->data ) ); } globalOutputStream() << "\n"; } -GtkToggleButton* radio_button_get_nth( GtkRadioButton* radio, int index ){ - GSList *group = gtk_radio_button_group( radio ); +GtkToggleButton* radio_button_get_nth( ui::RadioButton radio, int index ){ + GSList *group = gtk_radio_button_get_group( radio ); return GTK_TOGGLE_BUTTON( g_slist_nth_data( group, g_slist_length( group ) - index - 1 ) ); } -void radio_button_set_active( GtkRadioButton* radio, int index ){ +void radio_button_set_active( ui::RadioButton radio, int index ){ //radio_button_print_state(radio); gtk_toggle_button_set_active( radio_button_get_nth( radio, index ), TRUE ); //radio_button_print_state(radio); } -void radio_button_set_active_no_signal( GtkRadioButton* radio, int index ){ +void radio_button_set_active_no_signal( ui::RadioButton radio, int index ){ { for ( GSList* l = gtk_radio_button_get_group( radio ); l != 0; l = g_slist_next( l ) ) { @@ -107,9 +132,9 @@ void radio_button_set_active_no_signal( GtkRadioButton* radio, int index ){ } } -int radio_button_get_active( GtkRadioButton* radio ){ +int radio_button_get_active( ui::RadioButton radio ){ //radio_button_print_state(radio); - GSList *group = gtk_radio_button_group( radio ); + GSList *group = gtk_radio_button_get_group( radio ); int index = g_slist_length( group ) - 1; for (; group != 0; group = g_slist_next( group ) ) { diff --git a/libs/gtkutil/button.h b/libs/gtkutil/button.h index 15a9f2e8..b7aa4127 100644 --- a/libs/gtkutil/button.h +++ b/libs/gtkutil/button.h @@ -22,23 +22,24 @@ #if !defined( INCLUDED_GTKUTIL_BUTTON_H ) #define INCLUDED_GTKUTIL_BUTTON_H +#include #include "generic/callbackfwd.h" -typedef struct _GtkButton GtkButton; -typedef struct _GtkToggleButton GtkToggleButton; -typedef struct _GtkRadioButton GtkRadioButton; typedef int gint; typedef gint gboolean; typedef unsigned int guint; -void button_connect_callback( GtkButton* button, const Callback& callback ); -guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& callback ); +void button_connect_callback( ui::Button button, const Callback& callback ); +void button_connect_callback( ui::ToolButton button, const Callback& callback ); +guint toggle_button_connect_callback( ui::ToggleButton button, const Callback& callback ); +guint toggle_button_connect_callback( ui::ToggleToolButton button, const Callback& callback ); -void button_set_icon( GtkButton* button, const char* icon ); -void toggle_button_set_active_no_signal( GtkToggleButton* item, gboolean active ); +void button_set_icon( ui::Button button, const char* icon ); +void toggle_button_set_active_no_signal( ui::ToggleButton item, gboolean active ); +void toggle_button_set_active_no_signal( ui::ToggleToolButton item, gboolean active ); -void radio_button_set_active( GtkRadioButton* radio, int index ); -void radio_button_set_active_no_signal( GtkRadioButton* radio, int index ); -int radio_button_get_active( GtkRadioButton* radio ); +void radio_button_set_active( ui::RadioButton radio, int index ); +void radio_button_set_active_no_signal( ui::RadioButton radio, int index ); +int radio_button_get_active( ui::RadioButton radio ); #endif diff --git a/libs/gtkutil/clipboard.cpp b/libs/gtkutil/clipboard.cpp index c8073aba..29148753 100644 --- a/libs/gtkutil/clipboard.cpp +++ b/libs/gtkutil/clipboard.cpp @@ -83,7 +83,7 @@ void clipboard_paste( ClipboardPasteFunc paste ){ #else -#include +#include enum { @@ -111,11 +111,11 @@ static void clipboard_clear( GtkClipboard *clipboard, gpointer data ){ } static void clipboard_received( GtkClipboard *clipboard, GtkSelectionData *data, gpointer user_data ){ - if ( data->length < 0 ) { + if ( gtk_selection_data_get_length(data) < 0 ) { globalErrorStream() << "Error retrieving selection\n"; } - else if ( strcmp( gdk_atom_name( data->type ), clipboard_targets[0].target ) == 0 ) { - BufferInputStream istream( reinterpret_cast( data->data ), data->length ); + else if ( strcmp( gdk_atom_name( gtk_selection_data_get_data_type(data) ), clipboard_targets[0].target ) == 0 ) { + BufferInputStream istream( reinterpret_cast( gtk_selection_data_get_data(data) ), gtk_selection_data_get_length(data) ); ( *reinterpret_cast( user_data ) )( istream ); } } diff --git a/libs/gtkutil/closure.cpp b/libs/gtkutil/closure.cpp deleted file mode 100644 index 09e2fab7..00000000 --- a/libs/gtkutil/closure.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "closure.h" diff --git a/libs/gtkutil/container.cpp b/libs/gtkutil/container.cpp deleted file mode 100644 index 8790307e..00000000 --- a/libs/gtkutil/container.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "container.h" diff --git a/libs/gtkutil/container.h b/libs/gtkutil/container.h index b6b6afa4..12d0ca99 100644 --- a/libs/gtkutil/container.h +++ b/libs/gtkutil/container.h @@ -22,19 +22,11 @@ #if !defined( INCLUDED_GTKUTIL_CONTAINER_H ) #define INCLUDED_GTKUTIL_CONTAINER_H -#include - -inline GtkWidget* container_add_widget( GtkContainer* container, GtkWidget* widget ){ - gtk_container_add( container, widget ); - return widget; -} - -inline void container_remove( GtkWidget* item, gpointer data ){ - gtk_container_remove( GTK_CONTAINER( data ), item ); -} - -inline void container_remove_all( GtkContainer* container ){ - gtk_container_foreach( container, container_remove, container ); +inline void container_remove_all(ui::Container container) +{ + container.foreach([=](ui::Widget it) mutable { + container.remove(it); + }); } #endif diff --git a/libs/gtkutil/cursor.cpp b/libs/gtkutil/cursor.cpp index f0538a50..69e95e88 100644 --- a/libs/gtkutil/cursor.cpp +++ b/libs/gtkutil/cursor.cpp @@ -24,43 +24,103 @@ #include "stream/textstream.h" #include -#include -#include +#include +#include GdkCursor* create_blank_cursor(){ - GdkPixmap *pixmap; - GdkBitmap *mask; - char buffer [( 32 * 32 ) / 8]; - memset( buffer, 0, ( 32 * 32 ) / 8 ); - GdkColor white = {0, 0xffff, 0xffff, 0xffff}; - GdkColor black = {0, 0x0000, 0x0000, 0x0000}; - pixmap = gdk_bitmap_create_from_data( 0, buffer, 32, 32 ); - mask = gdk_bitmap_create_from_data( 0, buffer, 32, 32 ); - GdkCursor *cursor = gdk_cursor_new_from_pixmap( pixmap, mask, &white, &black, 1, 1 ); - gdk_drawable_unref( pixmap ); - gdk_drawable_unref( mask ); - - return cursor; + return gdk_cursor_new(GDK_BLANK_CURSOR); } -void blank_cursor( GtkWidget* widget ){ +void blank_cursor( ui::Widget widget ){ GdkCursor* cursor = create_blank_cursor(); - gdk_window_set_cursor( widget->window, cursor ); + gdk_window_set_cursor( gtk_widget_get_window(widget), cursor ); gdk_cursor_unref( cursor ); } -void default_cursor( GtkWidget* widget ){ - gdk_window_set_cursor( widget->window, 0 ); +void default_cursor( ui::Widget widget ){ + gdk_window_set_cursor( gtk_widget_get_window(widget), 0 ); } -void Sys_GetCursorPos( GtkWindow* window, int *x, int *y ){ +void Sys_GetCursorPos( ui::Window window, int *x, int *y ){ gdk_display_get_pointer( gdk_display_get_default(), 0, x, y, 0 ); } -void Sys_SetCursorPos( GtkWindow* window, int x, int y ){ +void Sys_SetCursorPos( ui::Window window, int x, int y ){ GdkScreen *screen; gdk_display_get_pointer( gdk_display_get_default(), &screen, 0, 0, 0 ); gdk_display_warp_pointer( gdk_display_get_default(), screen, x, y ); } + +gboolean DeferredMotion::gtk_motion(ui::Widget widget, GdkEventMotion *event, DeferredMotion *self) +{ + self->motion( event->x, event->y, event->state ); + return FALSE; +} + +gboolean FreezePointer::motion_delta(ui::Widget widget, GdkEventMotion *event, FreezePointer *self) +{ + int current_x, current_y; + Sys_GetCursorPos( ui::Window(GTK_WINDOW( widget )), ¤t_x, ¤t_y ); + int dx = current_x - self->last_x; + int dy = current_y - self->last_y; + int ddx = current_x - self->recorded_x; + int ddy = current_y - self->recorded_y; + self->last_x = current_x; + self->last_y = current_y; + if ( dx != 0 || dy != 0 ) { + //globalOutputStream() << "motion x: " << dx << ", y: " << dy << "\n"; + if (ddx < -32 || ddx > 32 || ddy < -32 || ddy > 32) { + Sys_SetCursorPos( ui::Window(GTK_WINDOW( widget )), self->recorded_x, self->recorded_y ); + self->last_x = self->recorded_x; + self->last_y = self->recorded_y; + } + self->m_function( dx, dy, event->state, self->m_data ); + } + return FALSE; +} + +void FreezePointer::freeze_pointer(ui::Window window, FreezePointer::MotionDeltaFunction function, void *data) +{ + ASSERT_MESSAGE( m_function == 0, "can't freeze pointer" ); + + const GdkEventMask mask = static_cast( GDK_POINTER_MOTION_MASK + | GDK_POINTER_MOTION_HINT_MASK + | GDK_BUTTON_MOTION_MASK + | GDK_BUTTON1_MOTION_MASK + | GDK_BUTTON2_MOTION_MASK + | GDK_BUTTON3_MOTION_MASK + | GDK_BUTTON_PRESS_MASK + | GDK_BUTTON_RELEASE_MASK + | GDK_VISIBILITY_NOTIFY_MASK ); + + GdkCursor* cursor = create_blank_cursor(); + //GdkGrabStatus status = + gdk_pointer_grab( gtk_widget_get_window(GTK_WIDGET(window)), TRUE, mask, 0, cursor, GDK_CURRENT_TIME ); + gdk_cursor_unref( cursor ); + + Sys_GetCursorPos( window, &recorded_x, &recorded_y ); + + Sys_SetCursorPos( window, recorded_x, recorded_y ); + + last_x = recorded_x; + last_y = recorded_y; + + m_function = function; + m_data = data; + + handle_motion = window.connect( "motion_notify_event", G_CALLBACK( motion_delta ), this ); +} + +void FreezePointer::unfreeze_pointer(ui::Window window) +{ + g_signal_handler_disconnect( G_OBJECT( window ), handle_motion ); + + m_function = 0; + m_data = 0; + + Sys_SetCursorPos( window, recorded_x, recorded_y ); + + gdk_pointer_ungrab( GDK_CURRENT_TIME ); +} diff --git a/libs/gtkutil/cursor.h b/libs/gtkutil/cursor.h index dfcc962c..6f2c6cc7 100644 --- a/libs/gtkutil/cursor.h +++ b/libs/gtkutil/cursor.h @@ -22,22 +22,18 @@ #if !defined( INCLUDED_GTKUTIL_CURSOR_H ) #define INCLUDED_GTKUTIL_CURSOR_H -#include -#include -#include -#include +#include #include "debugging/debugging.h" typedef struct _GdkCursor GdkCursor; -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; +typedef struct _GdkEventMotion GdkEventMotion; GdkCursor* create_blank_cursor(); -void blank_cursor( GtkWidget* widget ); -void default_cursor( GtkWidget* widget ); -void Sys_GetCursorPos( GtkWindow* window, int *x, int *y ); -void Sys_SetCursorPos( GtkWindow* window, int x, int y ); +void blank_cursor( ui::Widget widget ); +void default_cursor( ui::Widget widget ); +void Sys_GetCursorPos( ui::Window window, int *x, int *y ); +void Sys_SetCursorPos( ui::Window window, int x, int y ); @@ -67,10 +63,7 @@ void motion( gdouble x, gdouble y, guint state ){ m_handler = g_idle_add( (GSourceFunc)deferred, this ); } } -static gboolean gtk_motion( GtkWidget *widget, GdkEventMotion *event, DeferredMotion* self ){ - self->motion( event->x, event->y, event->state ); - return FALSE; -} +static gboolean gtk_motion( ui::Widget widget, GdkEventMotion *event, DeferredMotion* self ); }; class DeferredMotionDelta @@ -121,68 +114,11 @@ void* m_data; public: FreezePointer() : handle_motion( 0 ), m_function( 0 ), m_data( 0 ){ } -static gboolean motion_delta( GtkWidget *widget, GdkEventMotion *event, FreezePointer* self ){ - int current_x, current_y; - Sys_GetCursorPos( GTK_WINDOW( widget ), ¤t_x, ¤t_y ); - int dx = current_x - self->last_x; - int dy = current_y - self->last_y; - int ddx = current_x - self->recorded_x; - int ddy = current_y - self->recorded_y; - self->last_x = current_x; - self->last_y = current_y; - if ( dx != 0 || dy != 0 ) { - //globalOutputStream() << "motion x: " << dx << ", y: " << dy << "\n"; - if (ddx < -32 || ddx > 32 || ddy < -32 || ddy > 32) { - Sys_SetCursorPos( GTK_WINDOW( widget ), self->recorded_x, self->recorded_y ); - self->last_x = self->recorded_x; - self->last_y = self->recorded_y; - } - self->m_function( dx, dy, event->state, self->m_data ); - } - return FALSE; -} - -void freeze_pointer( GtkWindow* window, MotionDeltaFunction function, void* data ){ - ASSERT_MESSAGE( m_function == 0, "can't freeze pointer" ); - - const GdkEventMask mask = static_cast( GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK - | GDK_BUTTON_MOTION_MASK - | GDK_BUTTON1_MOTION_MASK - | GDK_BUTTON2_MOTION_MASK - | GDK_BUTTON3_MOTION_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_VISIBILITY_NOTIFY_MASK ); - - GdkCursor* cursor = create_blank_cursor(); - //GdkGrabStatus status = - gdk_pointer_grab( GTK_WIDGET( window )->window, TRUE, mask, 0, cursor, GDK_CURRENT_TIME ); - gdk_cursor_unref( cursor ); - - Sys_GetCursorPos( window, &recorded_x, &recorded_y ); +static gboolean motion_delta( ui::Widget widget, GdkEventMotion *event, FreezePointer* self ); - Sys_SetCursorPos( window, recorded_x, recorded_y ); +void freeze_pointer( ui::Window window, MotionDeltaFunction function, void* data ); - last_x = recorded_x; - last_y = recorded_y; - - m_function = function; - m_data = data; - - handle_motion = g_signal_connect( G_OBJECT( window ), "motion_notify_event", G_CALLBACK( motion_delta ), this ); -} - -void unfreeze_pointer( GtkWindow* window ){ - g_signal_handler_disconnect( G_OBJECT( window ), handle_motion ); - - m_function = 0; - m_data = 0; - - Sys_SetCursorPos( window, recorded_x, recorded_y ); - - gdk_pointer_ungrab( GDK_CURRENT_TIME ); -} +void unfreeze_pointer( ui::Window window ); }; #endif diff --git a/libs/gtkutil/dialog.cpp b/libs/gtkutil/dialog.cpp index 59f5c5d9..9e272a15 100644 --- a/libs/gtkutil/dialog.cpp +++ b/libs/gtkutil/dialog.cpp @@ -21,80 +21,71 @@ #include "dialog.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "button.h" #include "window.h" -GtkVBox* create_dialog_vbox( int spacing, int border ){ - GtkVBox* vbox = GTK_VBOX( gtk_vbox_new( FALSE, spacing ) ); - gtk_widget_show( GTK_WIDGET( vbox ) ); +ui::VBox create_dialog_vbox( int spacing, int border ){ + auto vbox = ui::VBox( FALSE, spacing ); + vbox.show(); gtk_container_set_border_width( GTK_CONTAINER( vbox ), border ); return vbox; } -GtkHBox* create_dialog_hbox( int spacing, int border ){ - GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( FALSE, spacing ) ); - gtk_widget_show( GTK_WIDGET( hbox ) ); +ui::HBox create_dialog_hbox( int spacing, int border ){ + auto hbox = ui::HBox( FALSE, spacing ); + hbox.show(); gtk_container_set_border_width( GTK_CONTAINER( hbox ), border ); return hbox; } -GtkFrame* create_dialog_frame( const char* label, GtkShadowType shadow ){ - GtkFrame* frame = GTK_FRAME( gtk_frame_new( label ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); - gtk_frame_set_shadow_type( frame, shadow ); +ui::Frame create_dialog_frame( const char* label, ui::Shadow shadow ){ + auto frame = ui::Frame( label ); + frame.show(); + gtk_frame_set_shadow_type( frame, (GtkShadowType) shadow ); return frame; } -GtkTable* create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border ){ - GtkTable* table = GTK_TABLE( gtk_table_new( rows, columns, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); +ui::Table create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border ){ + auto table = ui::Table( rows, columns, FALSE ); + table.show(); gtk_table_set_row_spacings( table, row_spacing ); gtk_table_set_col_spacings( table, col_spacing ); gtk_container_set_border_width( GTK_CONTAINER( table ), border ); return table; } -GtkButton* create_dialog_button( const char* label, GCallback func, gpointer data ){ - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( label ) ); +ui::Button create_dialog_button( const char* label, GCallback func, gpointer data ){ + auto button = ui::Button( label ); gtk_widget_set_size_request( GTK_WIDGET( button ), 64, -1 ); - gtk_widget_show( GTK_WIDGET( button ) ); - g_signal_connect( G_OBJECT( button ), "clicked", func, data ); + button.show(); + button.connect( "clicked", func, data ); return button; } -GtkWindow* create_dialog_window( GtkWindow* parent, const char* title, GCallback func, gpointer data, int default_w, int default_h ){ - GtkWindow* window = create_floating_window( title, parent ); +ui::Window create_dialog_window( ui::Window parent, const char* title, GCallback func, gpointer data, int default_w, int default_h ){ + ui::Window window = create_floating_window( title, parent ); gtk_window_set_default_size( window, default_w, default_h ); gtk_window_set_position( window, GTK_WIN_POS_CENTER_ON_PARENT ); - g_signal_connect( G_OBJECT( window ), "delete_event", func, data ); + window.connect( "delete_event", func, data ); return window; } -gboolean modal_dialog_button_clicked( GtkWidget *widget, ModalDialogButton* button ){ +gboolean modal_dialog_button_clicked( ui::Widget widget, ModalDialogButton* button ){ button->m_dialog.loop = false; button->m_dialog.ret = button->m_value; return TRUE; } -gboolean modal_dialog_delete( GtkWidget *widget, GdkEvent* event, ModalDialog* dialog ){ +gboolean modal_dialog_delete( ui::Widget widget, GdkEvent* event, ModalDialog* dialog ){ dialog->loop = 0; dialog->ret = eIDCANCEL; return TRUE; } -EMessageBoxReturn modal_dialog_show( GtkWindow* window, ModalDialog& dialog ){ +EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog ){ gtk_grab_add( GTK_WIDGET( window ) ); gtk_widget_show( GTK_WIDGET( window ) ); @@ -110,16 +101,16 @@ EMessageBoxReturn modal_dialog_show( GtkWindow* window, ModalDialog& dialog ){ return dialog.ret; } -GtkButton* create_modal_dialog_button( const char* label, ModalDialogButton& button ){ +ui::Button create_modal_dialog_button( const char* label, ModalDialogButton& button ){ return create_dialog_button( label, G_CALLBACK( modal_dialog_button_clicked ), &button ); } -GtkWindow* create_modal_dialog_window( GtkWindow* parent, const char* title, ModalDialog& dialog, int default_w, int default_h ){ +ui::Window create_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int default_w, int default_h ){ return create_dialog_window( parent, title, G_CALLBACK( modal_dialog_delete ), &dialog, default_w, default_h ); } -GtkWindow* create_fixedsize_modal_dialog_window( GtkWindow* parent, const char* title, ModalDialog& dialog, int width, int height ){ - GtkWindow* window = create_modal_dialog_window( parent, title, dialog, width, height ); +ui::Window create_fixedsize_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int width, int height ){ + auto window = create_modal_dialog_window( parent, title, dialog, width, height ); gtk_window_set_resizable( window, FALSE ); gtk_window_set_modal( window, TRUE ); @@ -136,63 +127,63 @@ GtkWindow* create_fixedsize_modal_dialog_window( GtkWindow* parent, const char* return window; } -gboolean dialog_button_ok( GtkWidget *widget, ModalDialog* data ){ +gboolean dialog_button_ok( ui::Widget widget, ModalDialog* data ){ data->loop = false; data->ret = eIDOK; return TRUE; } -gboolean dialog_button_cancel( GtkWidget *widget, ModalDialog* data ){ +gboolean dialog_button_cancel( ui::Widget widget, ModalDialog* data ){ data->loop = false; data->ret = eIDCANCEL; return TRUE; } -gboolean dialog_button_yes( GtkWidget *widget, ModalDialog* data ){ +gboolean dialog_button_yes( ui::Widget widget, ModalDialog* data ){ data->loop = false; data->ret = eIDYES; return TRUE; } -gboolean dialog_button_no( GtkWidget *widget, ModalDialog* data ){ +gboolean dialog_button_no( ui::Widget widget, ModalDialog* data ){ data->loop = false; data->ret = eIDNO; return TRUE; } -gboolean dialog_delete_callback( GtkWidget *widget, GdkEventAny* event, ModalDialog* data ){ +gboolean dialog_delete_callback( ui::Widget widget, GdkEventAny* event, ModalDialog* data ){ gtk_widget_hide( widget ); data->loop = false; return TRUE; } -GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents ){ - GtkWindow* window = create_fixedsize_modal_dialog_window( 0, title, dialog ); +ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, ui::Widget contents ){ + ui::Window window = create_fixedsize_modal_dialog_window(ui::Window{ui::null}, title, dialog ); - GtkVBox* vbox1 = create_dialog_vbox( 8, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox1 ) ); + auto vbox1 = create_dialog_vbox( 8, 4 ); + window.add(vbox1); - gtk_container_add( GTK_CONTAINER( vbox1 ), contents ); + vbox1.add(contents); - GtkAlignment* alignment = GTK_ALIGNMENT( gtk_alignment_new( 0.5, 0.0, 0.0, 0.0 ) ); + ui::Alignment alignment = ui::Alignment( 0.5, 0.0, 0.0, 0.0 ); gtk_widget_show( GTK_WIDGET( alignment ) ); gtk_box_pack_start( GTK_BOX( vbox1 ), GTK_WIDGET( alignment ), FALSE, FALSE, 0 ); - GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); - gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( button ) ); + auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); + alignment.add(button); return window; } RadioHBox RadioHBox_new( StringArrayRange names ){ - GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( TRUE, 4 ) ); + auto hbox = ui::HBox( TRUE, 4 ); gtk_widget_show( GTK_WIDGET( hbox ) ); GSList* group = 0; - GtkRadioButton* radio = 0; + auto radio = ui::RadioButton(ui::null); for ( StringArrayRange::Iterator i = names.first; i != names.last; ++i ) { - radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( group, *i ) ); + radio = ui::RadioButton(GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( group, *i ) )); gtk_widget_show( GTK_WIDGET( radio ) ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( radio ), FALSE, FALSE, 0 ); @@ -204,26 +195,26 @@ RadioHBox RadioHBox_new( StringArrayRange names ){ PathEntry PathEntry_new(){ - GtkFrame* frame = GTK_FRAME( gtk_frame_new( NULL ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); + auto frame = ui::Frame(); + frame.show(); gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN ); // path entry - GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( FALSE, 0 ) ); + auto hbox = ui::HBox( FALSE, 0 ); gtk_widget_show( GTK_WIDGET( hbox ) ); - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); + auto entry = ui::Entry(); gtk_entry_set_has_frame( entry, FALSE ); gtk_widget_show( GTK_WIDGET( entry ) ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); // browse button - GtkButton* button = GTK_BUTTON( gtk_button_new() ); + auto button = ui::Button(); button_set_icon( button, "ellipsis.bmp" ); gtk_widget_show( GTK_WIDGET( button ) ); gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( hbox ) ); + frame.add(hbox); return PathEntry( frame, entry, button ); } @@ -233,28 +224,28 @@ void PathEntry_setPath( PathEntry& self, const char* path ){ } typedef ReferenceCaller1 PathEntrySetPathCaller; -void BrowsedPathEntry_clicked( GtkWidget* widget, BrowsedPathEntry* self ){ +void BrowsedPathEntry_clicked( ui::Widget widget, BrowsedPathEntry* self ){ self->m_browse( PathEntrySetPathCaller( self->m_entry ) ); } BrowsedPathEntry::BrowsedPathEntry( const BrowseCallback& browse ) : m_entry( PathEntry_new() ), m_browse( browse ){ - g_signal_connect( G_OBJECT( m_entry.m_button ), "clicked", G_CALLBACK( BrowsedPathEntry_clicked ), this ); + m_entry.m_button.connect( "clicked", G_CALLBACK( BrowsedPathEntry_clicked ), this ); } -GtkLabel* DialogLabel_new( const char* name ){ - GtkLabel* label = GTK_LABEL( gtk_label_new( name ) ); - gtk_widget_show( GTK_WIDGET( label ) ); +ui::Label DialogLabel_new( const char* name ){ + auto label = ui::Label( name ); + gtk_widget_show(label); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( label, GTK_JUSTIFY_LEFT ); return label; } -GtkTable* DialogRow_new( const char* name, GtkWidget* widget ){ - GtkTable* table = GTK_TABLE( gtk_table_new( 1, 3, TRUE ) ); +ui::Table DialogRow_new( const char* name, ui::Widget widget ){ + auto table = ui::Table( 1, 3, TRUE ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_table_set_col_spacings( table, 4 ); @@ -271,6 +262,6 @@ GtkTable* DialogRow_new( const char* name, GtkWidget* widget ){ return table; } -void DialogVBox_packRow( GtkVBox* vbox, GtkWidget* row ){ +void DialogVBox_packRow( ui::VBox vbox, ui::Widget row ){ gtk_box_pack_start( GTK_BOX( vbox ), row, FALSE, FALSE, 0 ); } diff --git a/libs/gtkutil/dialog.h b/libs/gtkutil/dialog.h index 5a87731e..7907e76b 100644 --- a/libs/gtkutil/dialog.h +++ b/libs/gtkutil/dialog.h @@ -25,20 +25,10 @@ #include "generic/callback.h" #include "generic/arrayrange.h" #include "qerplugin.h" -#include typedef int gint; typedef gint gboolean; typedef struct _GdkEventAny GdkEventAny; -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkHBox GtkHBox; -typedef struct _GtkVBox GtkVBox; -typedef struct _GtkRadioButton GtkRadioButton; -typedef struct _GtkFrame GtkFrame; -typedef struct _GtkEntry GtkEntry; -typedef struct _GtkButton GtkButton; -typedef struct _GtkLabel GtkLabel; -typedef struct _GtkTable GtkTable; struct ModalDialog @@ -61,42 +51,36 @@ struct ModalDialogButton typedef void ( *GCallback )( void ); typedef void* gpointer; -typedef struct _GtkWindow GtkWindow; -typedef struct _GtkTable GtkTable; -typedef struct _GtkButton GtkButton; -typedef struct _GtkVBox GtkVBox; -typedef struct _GtkHBox GtkHBox; -typedef struct _GtkFrame GtkFrame; -GtkWindow* create_fixedsize_modal_window( GtkWindow* parent, const char* title, int width, int height ); +ui::Window create_fixedsize_modal_window( ui::Window parent, const char* title, int width, int height ); -GtkWindow* create_dialog_window( GtkWindow* parent, const char* title, GCallback func, gpointer data, int default_w = -1, int default_h = -1 ); -GtkTable* create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border = 0 ); -GtkButton* create_dialog_button( const char* label, GCallback func, gpointer data ); -GtkVBox* create_dialog_vbox( int spacing, int border = 0 ); -GtkHBox* create_dialog_hbox( int spacing, int border = 0 ); -GtkFrame* create_dialog_frame( const char* label, GtkShadowType shadow = GTK_SHADOW_ETCHED_IN ); +ui::Window create_dialog_window( ui::Window parent, const char* title, GCallback func, gpointer data, int default_w = -1, int default_h = -1 ); +ui::Table create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border = 0 ); +ui::Button create_dialog_button( const char* label, GCallback func, gpointer data ); +ui::VBox create_dialog_vbox( int spacing, int border = 0 ); +ui::HBox create_dialog_hbox( int spacing, int border = 0 ); +ui::Frame create_dialog_frame( const char* label, ui::Shadow shadow = ui::Shadow::ETCHED_IN ); -GtkButton* create_modal_dialog_button( const char* label, ModalDialogButton& button ); -GtkWindow* create_modal_dialog_window( GtkWindow* parent, const char* title, ModalDialog& dialog, int default_w = -1, int default_h = -1 ); -GtkWindow* create_fixedsize_modal_dialog_window( GtkWindow* parent, const char* title, ModalDialog& dialog, int width = -1, int height = -1 ); -EMessageBoxReturn modal_dialog_show( GtkWindow* window, ModalDialog& dialog ); +ui::Button create_modal_dialog_button( const char* label, ModalDialogButton& button ); +ui::Window create_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int default_w = -1, int default_h = -1 ); +ui::Window create_fixedsize_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int width = -1, int height = -1 ); +EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog ); -gboolean dialog_button_ok( GtkWidget *widget, ModalDialog* data ); -gboolean dialog_button_cancel( GtkWidget *widget, ModalDialog* data ); -gboolean dialog_button_yes( GtkWidget *widget, ModalDialog* data ); -gboolean dialog_button_no( GtkWidget *widget, ModalDialog* data ); -gboolean dialog_delete_callback( GtkWidget *widget, GdkEventAny* event, ModalDialog* data ); +gboolean dialog_button_ok( ui::Widget widget, ModalDialog* data ); +gboolean dialog_button_cancel( ui::Widget widget, ModalDialog* data ); +gboolean dialog_button_yes( ui::Widget widget, ModalDialog* data ); +gboolean dialog_button_no( ui::Widget widget, ModalDialog* data ); +gboolean dialog_delete_callback( ui::Widget widget, GdkEventAny* event, ModalDialog* data ); -GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents ); +ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, ui::Widget contents ); class RadioHBox { public: -GtkHBox* m_hbox; -GtkRadioButton* m_radio; -RadioHBox( GtkHBox* hbox, GtkRadioButton* radio ) : +ui::HBox m_hbox; +ui::RadioButton m_radio; +RadioHBox( ui::HBox hbox, ui::RadioButton radio ) : m_hbox( hbox ), m_radio( radio ){ } @@ -108,10 +92,10 @@ RadioHBox RadioHBox_new( StringArrayRange names ); class PathEntry { public: -GtkFrame* m_frame; -GtkEntry* m_entry; -GtkButton* m_button; -PathEntry( GtkFrame* frame, GtkEntry* entry, GtkButton* button ) : +ui::Frame m_frame; +ui::Entry m_entry; +ui::Button m_button; +PathEntry( ui::Frame frame, ui::Entry entry, ui::Button button ) : m_frame( frame ), m_entry( entry ), m_button( button ){ @@ -132,10 +116,9 @@ BrowseCallback m_browse; BrowsedPathEntry( const BrowseCallback& browse ); }; -GtkLabel* DialogLabel_new( const char* name ); -GtkTable* DialogRow_new( const char* name, GtkWidget* widget ); -typedef struct _GtkVBox GtkVBox; -void DialogVBox_packRow( GtkVBox* vbox, GtkWidget* row ); +ui::Label DialogLabel_new( const char* name ); +ui::Table DialogRow_new( const char* name, ui::Widget widget ); +void DialogVBox_packRow( ui::VBox vbox, ui::Widget row ); #endif diff --git a/libs/gtkutil/entry.cpp b/libs/gtkutil/entry.cpp index 2640da0f..acb74db8 100644 --- a/libs/gtkutil/entry.cpp +++ b/libs/gtkutil/entry.cpp @@ -1,22 +1,37 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. +#include "entry.h" - This file is part of GtkRadiant. +#include - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +void entry_set_string(ui::Entry entry, const char *string) +{ + gtk_entry_set_text(entry, string); +} - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +void entry_set_int(ui::Entry entry, int i) +{ + char buf[32]; + sprintf(buf, "%d", i); + entry_set_string(entry, buf); +} - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ +void entry_set_float(ui::Entry entry, float f) +{ + char buf[32]; + sprintf(buf, "%g", f); + entry_set_string(entry, buf); +} -#include "entry.h" +const char *entry_get_string(ui::Entry entry) +{ + return gtk_entry_get_text(entry); +} + +int entry_get_int(ui::Entry entry) +{ + return atoi(entry_get_string(entry)); +} + +double entry_get_float(ui::Entry entry) +{ + return atof(entry_get_string(entry)); +} diff --git a/libs/gtkutil/entry.h b/libs/gtkutil/entry.h index 814be152..067157af 100644 --- a/libs/gtkutil/entry.h +++ b/libs/gtkutil/entry.h @@ -19,39 +19,21 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_GTKUTIL_ENTRY_H ) #define INCLUDED_GTKUTIL_ENTRY_H -#include -#include -#include - -inline void entry_set_string( GtkEntry* entry, const char* string ){ - gtk_entry_set_text( entry, string ); -} - -inline void entry_set_int( GtkEntry* entry, int i ){ - char buf[32]; - sprintf( buf, "%d", i ); - entry_set_string( entry, buf ); -} - -inline void entry_set_float( GtkEntry* entry, float f ){ - char buf[32]; - sprintf( buf, "%g", f ); - entry_set_string( entry, buf ); -} - -inline const char* entry_get_string( GtkEntry* entry ){ - return gtk_entry_get_text( entry ); -} - -inline int entry_get_int( GtkEntry* entry ){ - return atoi( entry_get_string( entry ) ); -} - -inline double entry_get_float( GtkEntry* entry ){ - return atof( entry_get_string( entry ) ); -} +void entry_set_string(ui::Entry entry, const char *string); + +void entry_set_int(ui::Entry entry, int i); + +void entry_set_float(ui::Entry entry, float f); + +const char *entry_get_string(ui::Entry entry); + +int entry_get_int(ui::Entry entry); + +double entry_get_float(ui::Entry entry); #endif diff --git a/libs/gtkutil/filechooser.cpp b/libs/gtkutil/filechooser.cpp index d65d310c..a06c4c93 100644 --- a/libs/gtkutil/filechooser.cpp +++ b/libs/gtkutil/filechooser.cpp @@ -25,11 +25,8 @@ #include #include -#include -#include -#include -#include -#include +#include +#include #include "string/string.h" #include "stream/stringstream.h" @@ -243,7 +240,7 @@ const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, c return g_file_dialog_file; } -char* dir_dialog( GtkWidget* parent, const char* title, const char* path ){ +char* dir_dialog( ui::Widget parent, const char* title, const char* path ){ GtkWidget* dialog = gtk_file_chooser_dialog_new( title, GTK_WINDOW( parent ), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, @@ -268,7 +265,7 @@ char* dir_dialog( GtkWidget* parent, const char* title, const char* path ){ return filename; } -const char* file_dialog( GtkWidget* parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){ +const char* file_dialog( ui::Widget parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){ for (;; ) { const char* file = file_dialog_show( parent, open, title, path, pattern, want_load, want_import, want_save ); @@ -276,7 +273,7 @@ const char* file_dialog( GtkWidget* parent, bool open, const char* title, const if ( open || file == 0 || !file_exists( file ) - || gtk_MessageBox( parent, "The file specified already exists.\nDo you want to replace it?", title, eMB_NOYES, eMB_ICONQUESTION ) == eIDYES ) { + || parent.alert("The file specified already exists.\nDo you want to replace it?", title, ui::alert_type::NOYES, ui::alert_icon::Question ) == ui::alert_response::YES ) { return file; } } diff --git a/libs/gtkutil/filechooser.h b/libs/gtkutil/filechooser.h index f4610bea..ae7c0b34 100644 --- a/libs/gtkutil/filechooser.h +++ b/libs/gtkutil/filechooser.h @@ -19,20 +19,21 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_GTKUTIL_FILECHOOSER_H ) #define INCLUDED_GTKUTIL_FILECHOOSER_H /// \file /// GTK+ file-chooser dialogs. -typedef struct _GtkWidget GtkWidget; -const char* file_dialog( GtkWidget *parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false ); +const char* file_dialog( ui::Widget parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false ); /// \brief Prompts the user to browse for a directory. /// The prompt window will be transient to \p parent. /// The directory will initially default to \p path, which must be an absolute path. /// The returned string is allocated with \c g_malloc and must be freed with \c g_free. -char* dir_dialog( GtkWidget *parent, const char* title = "Choose Directory", const char* path = "" ); +char* dir_dialog( ui::Widget parent, const char* title = "Choose Directory", const char* path = "" ); #endif diff --git a/libs/gtkutil/frame.cpp b/libs/gtkutil/frame.cpp index 8914fb70..6baab763 100644 --- a/libs/gtkutil/frame.cpp +++ b/libs/gtkutil/frame.cpp @@ -21,13 +21,14 @@ #include "frame.h" -#include +#include +#include -GtkFrame* create_framed_widget( GtkWidget* widget ){ - GtkFrame* frame = GTK_FRAME( gtk_frame_new( 0 ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); +ui::Frame create_framed_widget( ui::Widget widget ){ + auto frame = ui::Frame(); + frame.show(); gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN ); - gtk_container_add( GTK_CONTAINER( frame ), widget ); - gtk_widget_show( GTK_WIDGET( widget ) ); + frame.add(widget); + widget.show(); return frame; } diff --git a/libs/gtkutil/frame.h b/libs/gtkutil/frame.h index ebeccc28..ecdd7fcc 100644 --- a/libs/gtkutil/frame.h +++ b/libs/gtkutil/frame.h @@ -19,11 +19,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_GTKUTIL_FRAME_H ) #define INCLUDED_GTKUTIL_FRAME_H -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkFrame GtkFrame; -GtkFrame* create_framed_widget( GtkWidget* widget ); +ui::Frame create_framed_widget( ui::Widget widget ); #endif diff --git a/libs/gtkutil/glwidget.cpp b/libs/gtkutil/glwidget.cpp index 746b8f0f..20a82f30 100644 --- a/libs/gtkutil/glwidget.cpp +++ b/libs/gtkutil/glwidget.cpp @@ -23,235 +23,282 @@ #include "glwidget.h" -#include "debugging/debugging.h" - #include "igl.h" -#include -#include +void (*GLWidget_sharedContextCreated)() = 0; -#include "pointer.h" +void (*GLWidget_sharedContextDestroyed)() = 0; + +unsigned int g_context_count = 0; -void ( *GLWidget_sharedContextCreated )() = 0; -void ( *GLWidget_sharedContextDestroyed )() = 0; +ui::GLArea g_shared{ui::null}; +void _glwidget_context_created(ui::GLArea self, void *data) +{ + if (++g_context_count == 1) { + g_shared = self; + g_object_ref(g_shared._handle); + + glwidget_make_current(g_shared); + GlobalOpenGL().contextValid = true; + + GLWidget_sharedContextCreated(); + } +} + +void _glwidget_context_destroyed(ui::GLArea self, void *data) +{ + if (--g_context_count == 0) { + GlobalOpenGL().contextValid = false; + + GLWidget_sharedContextDestroyed(); + + g_shared.unref(); + g_shared = ui::GLArea(ui::null); + } +} + +void glwidget_destroy_context(ui::GLArea self) +{ +} -typedef int* attribs_t; -struct config_t +void glwidget_create_context(ui::GLArea self) { - const char* name; - attribs_t attribs; +} + +#if GTK_TARGET == 3 + +#include + +GdkGLContext *glwidget_context_created(ui::GLArea self) +{ + _glwidget_context_created(self, nullptr); + return gtk_gl_area_get_context(self); +} + +ui::GLArea glwidget_new(bool zbuffer) +{ + auto self = ui::GLArea(GTK_GL_AREA(gtk_gl_area_new())); + gtk_gl_area_set_has_depth_buffer(self, zbuffer); + gtk_gl_area_set_auto_render(self, false); + + self.connect("realize", G_CALLBACK(glwidget_context_created), nullptr); + return self; +} + +bool glwidget_make_current(ui::GLArea self) +{ +// if (!g_context_count) { +// glwidget_context_created(self); +// } + gtk_gl_area_make_current(self); + auto valid = GlobalOpenGL().contextValid; + return true; +} + +void glwidget_swap_buffers(ui::GLArea self) +{ + gtk_gl_area_queue_render(self); +} + +#endif + +#if GTK_TARGET == 2 + +#include +#include + +#include "pointer.h" + +struct config_t { + const char *name; + int *attribs; }; -typedef const config_t* configs_iterator; +typedef const config_t *configs_iterator; int config_rgba32[] = { - GDK_GL_RGBA, - GDK_GL_DOUBLEBUFFER, - GDK_GL_BUFFER_SIZE, 24, - GDK_GL_ATTRIB_LIST_NONE, + GDK_GL_RGBA, + GDK_GL_DOUBLEBUFFER, + GDK_GL_BUFFER_SIZE, 24, + GDK_GL_ATTRIB_LIST_NONE, }; int config_rgba[] = { - GDK_GL_RGBA, - GDK_GL_DOUBLEBUFFER, - GDK_GL_BUFFER_SIZE, 16, - GDK_GL_ATTRIB_LIST_NONE, + GDK_GL_RGBA, + GDK_GL_DOUBLEBUFFER, + GDK_GL_BUFFER_SIZE, 16, + GDK_GL_ATTRIB_LIST_NONE, }; const config_t configs[] = { - { - "colour-buffer = 32bpp, depth-buffer = none", - config_rgba32, - }, - { - "colour-buffer = 16bpp, depth-buffer = none", - config_rgba, - } + { + "colour-buffer = 32bpp, depth-buffer = none", + config_rgba32, + }, + { + "colour-buffer = 16bpp, depth-buffer = none", + config_rgba, + } }; -GdkGLConfig* glconfig_new(){ - GdkGLConfig* glconfig = 0; - - for ( configs_iterator i = configs, end = configs + 2; i != end; ++i ) - { - glconfig = gdk_gl_config_new( ( *i ).attribs ); - if ( glconfig != 0 ) { - globalOutputStream() << "OpenGL window configuration: " << ( *i ).name << "\n"; - return glconfig; - } - } - - globalOutputStream() << "OpenGL window configuration: colour-buffer = auto, depth-buffer = none\n"; - return gdk_gl_config_new_by_mode( (GdkGLConfigMode)( GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE ) ); +GdkGLConfig *glconfig_new() +{ + for (configs_iterator i = configs, end = configs + 2; i != end; ++i) { + if (auto glconfig = gdk_gl_config_new(i->attribs)) { + globalOutputStream() << "OpenGL window configuration: " << i->name << "\n"; + return glconfig; + } + } + globalOutputStream() << "OpenGL window configuration: colour-buffer = auto, depth-buffer = none\n"; + return gdk_gl_config_new_by_mode((GdkGLConfigMode) (GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE)); } int config_rgba32_depth32[] = { - GDK_GL_RGBA, - GDK_GL_DOUBLEBUFFER, - GDK_GL_BUFFER_SIZE, 24, - GDK_GL_DEPTH_SIZE, 32, - GDK_GL_ATTRIB_LIST_NONE, + GDK_GL_RGBA, + GDK_GL_DOUBLEBUFFER, + GDK_GL_BUFFER_SIZE, + 24, + GDK_GL_DEPTH_SIZE, + 32, + GDK_GL_ATTRIB_LIST_NONE, }; int config_rgba32_depth24[] = { - GDK_GL_RGBA, - GDK_GL_DOUBLEBUFFER, - GDK_GL_BUFFER_SIZE, 24, - GDK_GL_DEPTH_SIZE, 24, - GDK_GL_ATTRIB_LIST_NONE, + GDK_GL_RGBA, + GDK_GL_DOUBLEBUFFER, + GDK_GL_BUFFER_SIZE, 24, + GDK_GL_DEPTH_SIZE, 24, + GDK_GL_ATTRIB_LIST_NONE, }; int config_rgba32_depth16[] = { - GDK_GL_RGBA, - GDK_GL_DOUBLEBUFFER, - GDK_GL_BUFFER_SIZE, 24, - GDK_GL_DEPTH_SIZE, 16, - GDK_GL_ATTRIB_LIST_NONE, + GDK_GL_RGBA, + GDK_GL_DOUBLEBUFFER, + GDK_GL_BUFFER_SIZE, 24, + GDK_GL_DEPTH_SIZE, 16, + GDK_GL_ATTRIB_LIST_NONE, }; int config_rgba32_depth[] = { - GDK_GL_RGBA, - GDK_GL_DOUBLEBUFFER, - GDK_GL_BUFFER_SIZE, 24, - GDK_GL_DEPTH_SIZE, 1, - GDK_GL_ATTRIB_LIST_NONE, + GDK_GL_RGBA, + GDK_GL_DOUBLEBUFFER, + GDK_GL_BUFFER_SIZE, 24, + GDK_GL_DEPTH_SIZE, 1, + GDK_GL_ATTRIB_LIST_NONE, }; int config_rgba_depth16[] = { - GDK_GL_RGBA, - GDK_GL_DOUBLEBUFFER, - GDK_GL_BUFFER_SIZE, 16, - GDK_GL_DEPTH_SIZE, 16, - GDK_GL_ATTRIB_LIST_NONE, + GDK_GL_RGBA, + GDK_GL_DOUBLEBUFFER, + GDK_GL_BUFFER_SIZE, 16, + GDK_GL_DEPTH_SIZE, 16, + GDK_GL_ATTRIB_LIST_NONE, }; int config_rgba_depth[] = { - GDK_GL_RGBA, - GDK_GL_DOUBLEBUFFER, - GDK_GL_BUFFER_SIZE, 16, - GDK_GL_DEPTH_SIZE, 1, - GDK_GL_ATTRIB_LIST_NONE, + GDK_GL_RGBA, + GDK_GL_DOUBLEBUFFER, + GDK_GL_BUFFER_SIZE, 16, + GDK_GL_DEPTH_SIZE, 1, + GDK_GL_ATTRIB_LIST_NONE, }; const config_t configs_with_depth[] = + { + { + "colour-buffer = 32bpp, depth-buffer = 32bpp", + config_rgba32_depth32, + }, + { + "colour-buffer = 32bpp, depth-buffer = 24bpp", + config_rgba32_depth24, + }, + { + "colour-buffer = 32bpp, depth-buffer = 16bpp", + config_rgba32_depth16, + }, + { + "colour-buffer = 32bpp, depth-buffer = auto", + config_rgba32_depth, + }, + { + "colour-buffer = 16bpp, depth-buffer = 16bpp", + config_rgba_depth16, + }, + { + "colour-buffer = auto, depth-buffer = auto", + config_rgba_depth, + }, + }; + +GdkGLConfig *glconfig_new_with_depth() { - { - "colour-buffer = 32bpp, depth-buffer = 32bpp", - config_rgba32_depth32, - }, - { - "colour-buffer = 32bpp, depth-buffer = 24bpp", - config_rgba32_depth24, - }, - { - "colour-buffer = 32bpp, depth-buffer = 16bpp", - config_rgba32_depth16, - }, - { - "colour-buffer = 32bpp, depth-buffer = auto", - config_rgba32_depth, - }, - { - "colour-buffer = 16bpp, depth-buffer = 16bpp", - config_rgba_depth16, - }, - { - "colour-buffer = auto, depth-buffer = auto", - config_rgba_depth, - }, -}; - -GdkGLConfig* glconfig_new_with_depth(){ - GdkGLConfig* glconfig = 0; - - for ( configs_iterator i = configs_with_depth, end = configs_with_depth + 6; i != end; ++i ) - { - glconfig = gdk_gl_config_new( ( *i ).attribs ); - if ( glconfig != 0 ) { - globalOutputStream() << "OpenGL window configuration: " << ( *i ).name << "\n"; - return glconfig; - } - } - - globalOutputStream() << "OpenGL window configuration: colour-buffer = auto, depth-buffer = auto (fallback)\n"; - return gdk_gl_config_new_by_mode( (GdkGLConfigMode)( GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_DEPTH ) ); + for (configs_iterator i = configs_with_depth, end = configs_with_depth + 6; i != end; ++i) { + if (auto glconfig = gdk_gl_config_new(i->attribs)) { + globalOutputStream() << "OpenGL window configuration: " << i->name << "\n"; + return glconfig; + } + } + globalOutputStream() << "OpenGL window configuration: colour-buffer = auto, depth-buffer = auto (fallback)\n"; + return gdk_gl_config_new_by_mode((GdkGLConfigMode) (GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_DEPTH)); } -unsigned int g_context_count = 0; - -namespace +int glwidget_context_created(ui::GLArea self, void *data) { -GtkWidget* g_shared = 0; + _glwidget_context_created(self, data); + return false; } -gint glwidget_context_created( GtkWidget* widget, gpointer data ){ - if ( ++g_context_count == 1 ) { - g_shared = widget; - gtk_widget_ref( g_shared ); - - glwidget_make_current( g_shared ); - GlobalOpenGL().contextValid = true; - - GLWidget_sharedContextCreated(); - } - return FALSE; -} - -gint glwidget_context_destroyed( GtkWidget* widget, gpointer data ){ - if ( --g_context_count == 0 ) { - GlobalOpenGL().contextValid = false; - - GLWidget_sharedContextDestroyed(); - - gtk_widget_unref( g_shared ); - g_shared = 0; - } - return FALSE; +int glwidget_context_destroyed(ui::GLArea self, void *data) +{ + _glwidget_context_destroyed(self, data); + return false; } -gboolean glwidget_enable_gl( GtkWidget* widget, GtkWidget* widget2, gpointer data ){ - if ( widget2 == 0 && !gtk_widget_is_gl_capable( widget ) ) { - GdkGLConfig* glconfig = ( g_object_get_data( G_OBJECT( widget ), "zbuffer" ) ) ? glconfig_new_with_depth() : glconfig_new(); - ASSERT_MESSAGE( glconfig != 0, "failed to create OpenGL config" ); - - gtk_widget_set_gl_capability( widget, glconfig, g_shared != 0 ? gtk_widget_get_gl_context( g_shared ) : 0, TRUE, GDK_GL_RGBA_TYPE ); - - gtk_widget_realize( widget ); - if ( g_shared == 0 ) { - g_shared = widget; - } - - // free glconfig? - } - return FALSE; +bool glwidget_enable_gl(ui::GLArea self, ui::Widget root, gpointer data) +{ + if (!root && !gtk_widget_is_gl_capable(self)) { + const auto zbuffer = g_object_get_data(G_OBJECT(self), "zbuffer"); + GdkGLConfig *glconfig = zbuffer ? glconfig_new_with_depth() : glconfig_new(); + ASSERT_MESSAGE(glconfig, "failed to create OpenGL config"); + + const auto share_list = g_shared ? gtk_widget_get_gl_context(g_shared) : nullptr; + gtk_widget_set_gl_capability(self, glconfig, share_list, true, GDK_GL_RGBA_TYPE); + + gtk_widget_realize(self); + if (!g_shared) { + g_shared = self; + } + // free glconfig? + } + return false; } -GtkWidget* glwidget_new( gboolean zbuffer ){ - GtkWidget* widget = gtk_drawing_area_new(); - - g_object_set_data( G_OBJECT( widget ), "zbuffer", gint_to_pointer( zbuffer ) ); +ui::GLArea glwidget_new(bool zbuffer) +{ + auto self = ui::GLArea(GTK_DRAWING_AREA(gtk_drawing_area_new())); - g_signal_connect( G_OBJECT( widget ), "hierarchy-changed", G_CALLBACK( glwidget_enable_gl ), 0 ); + g_object_set_data(G_OBJECT(self), "zbuffer", gint_to_pointer(zbuffer)); - g_signal_connect( G_OBJECT( widget ), "realize", G_CALLBACK( glwidget_context_created ), 0 ); - g_signal_connect( G_OBJECT( widget ), "unrealize", G_CALLBACK( glwidget_context_destroyed ), 0 ); + self.connect("hierarchy-changed", G_CALLBACK(glwidget_enable_gl), 0); - return widget; -} + self.connect("realize", G_CALLBACK(glwidget_context_created), 0); + self.connect("unrealize", G_CALLBACK(glwidget_context_destroyed), 0); -void glwidget_destroy_context( GtkWidget *widget ){ + return self; } -void glwidget_create_context( GtkWidget *widget ){ +void glwidget_swap_buffers(ui::GLArea self) +{ + GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(self); + gdk_gl_drawable_swap_buffers(gldrawable); } -void glwidget_swap_buffers( GtkWidget *widget ){ - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable( widget ); - gdk_gl_drawable_swap_buffers( gldrawable ); +bool glwidget_make_current(ui::GLArea self) +{ + GdkGLContext *glcontext = gtk_widget_get_gl_context(self); + GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(self); + return gdk_gl_drawable_gl_begin(gldrawable, glcontext); } -gboolean glwidget_make_current( GtkWidget *widget ){ - GdkGLContext *glcontext = gtk_widget_get_gl_context( widget ); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable( widget ); - return gdk_gl_drawable_gl_begin( gldrawable, glcontext ); -} +#endif diff --git a/libs/gtkutil/glwidget.h b/libs/gtkutil/glwidget.h index 43e26dc7..6a43da88 100644 --- a/libs/gtkutil/glwidget.h +++ b/libs/gtkutil/glwidget.h @@ -19,21 +19,18 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_GTKUTIL_GLWIDGET_H ) #define INCLUDED_GTKUTIL_GLWIDGET_H -typedef struct _GtkWidget GtkWidget; -typedef int gint; -typedef gint gboolean; - -GtkWidget* glwidget_new( gboolean zbuffer ); -void glwidget_swap_buffers( GtkWidget* widget ); -gboolean glwidget_make_current( GtkWidget* widget ); -void glwidget_destroy_context( GtkWidget* widget ); -void glwidget_create_context( GtkWidget* widget ); - -extern void ( *GLWidget_sharedContextCreated )(); -extern void ( *GLWidget_sharedContextDestroyed )(); +extern void (*GLWidget_sharedContextCreated)(); +extern void (*GLWidget_sharedContextDestroyed)(); +ui::GLArea glwidget_new(bool zbuffer); +void glwidget_create_context(ui::GLArea self); +void glwidget_destroy_context(ui::GLArea self); +bool glwidget_make_current(ui::GLArea self); +void glwidget_swap_buffers(ui::GLArea self); #endif diff --git a/libs/gtkutil/idledraw.cpp b/libs/gtkutil/idledraw.cpp deleted file mode 100644 index b50d41f2..00000000 --- a/libs/gtkutil/idledraw.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "idledraw.h" diff --git a/libs/gtkutil/image.cpp b/libs/gtkutil/image.cpp index b8cd7bef..4164f031 100644 --- a/libs/gtkutil/image.cpp +++ b/libs/gtkutil/image.cpp @@ -21,8 +21,7 @@ #include "image.h" -#include -#include +#include #include "string/string.h" #include "stream/stringstream.h" @@ -46,40 +45,36 @@ GdkPixbuf* pixbuf_new_from_file_with_mask( const char* filename ){ else { GdkPixbuf* rgba = gdk_pixbuf_add_alpha( rgb, FALSE, 255, 0, 255 ); - gdk_pixbuf_unref( rgb ); + g_object_unref( rgb ); return rgba; } } -GtkImage* image_new_from_file_with_mask( const char* filename ){ +ui::Image image_new_from_file_with_mask( const char* filename ){ GdkPixbuf* rgba = pixbuf_new_from_file_with_mask( filename ); if ( rgba == 0 ) { - return 0; + return ui::Image(0); } else { - GtkImage* image = GTK_IMAGE( gtk_image_new_from_pixbuf( rgba ) ); - gdk_pixbuf_unref( rgba ); + auto image = ui::Image(GTK_IMAGE( gtk_image_new_from_pixbuf( rgba ) )); + g_object_unref( rgba ); return image; } } -GtkImage* image_new_missing(){ - return GTK_IMAGE( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ); +ui::Image image_new_missing(){ + return ui::Image(GTK_IMAGE( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) )); } -GtkImage* new_image( const char* filename ){ - { - GtkImage* image = image_new_from_file_with_mask( filename ); - if ( image != 0 ) { - return image; - } +ui::Image new_image( const char* filename ){ + if ( auto image = image_new_from_file_with_mask( filename ) ) { + return image; } - return image_new_missing(); } -GtkImage* new_local_image( const char* filename ){ +ui::Image new_local_image( const char* filename ){ StringOutputStream fullPath( 256 ); fullPath << g_bitmapsPath.c_str() << filename; return new_image( fullPath.c_str() ); diff --git a/libs/gtkutil/image.h b/libs/gtkutil/image.h index cf452559..6a8d419b 100644 --- a/libs/gtkutil/image.h +++ b/libs/gtkutil/image.h @@ -19,18 +19,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_GTKUTIL_IMAGE_H ) #define INCLUDED_GTKUTIL_IMAGE_H void BitmapsPath_set( const char* path ); -typedef struct _GtkImage GtkImage; typedef struct _GdkPixbuf GdkPixbuf; GdkPixbuf* pixbuf_new_from_file_with_mask( const char* filename ); -GtkImage* image_new_from_file_with_mask( const char* filename ); -GtkImage* image_new_missing(); -GtkImage* new_image( const char* filename ); // filename is full path to image file -GtkImage* new_local_image( const char* filename ); // filename is relative to local bitmaps path +ui::Image image_new_from_file_with_mask( const char* filename ); +ui::Image image_new_missing(); +ui::Image new_image( const char* filename ); // filename is full path to image file +ui::Image new_local_image( const char* filename ); // filename is relative to local bitmaps path #endif diff --git a/libs/gtkutil/menu.cpp b/libs/gtkutil/menu.cpp index cbb07df8..51e156e9 100644 --- a/libs/gtkutil/menu.cpp +++ b/libs/gtkutil/menu.cpp @@ -22,11 +22,9 @@ #include "menu.h" #include -#include -#include -#include -#include -#include +#include +#include +#include #include "generic/callback.h" @@ -35,55 +33,55 @@ #include "container.h" #include "pointer.h" -void menu_add_item( GtkMenu* menu, GtkMenuItem* item ){ - gtk_container_add( GTK_CONTAINER( menu ), GTK_WIDGET( item ) ); +void menu_add_item( ui::Menu menu, ui::MenuItem item ){ + menu.add(item); } -GtkMenuItem* menu_separator( GtkMenu* menu ){ - GtkMenuItem* menu_item = GTK_MENU_ITEM( gtk_menu_item_new() ); - container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( menu_item ) ); +ui::MenuItem menu_separator( ui::Menu menu ){ + auto menu_item = ui::MenuItem(GTK_MENU_ITEM( gtk_menu_item_new() )); + menu.add(menu_item); gtk_widget_set_sensitive( GTK_WIDGET( menu_item ), FALSE ); - gtk_widget_show( GTK_WIDGET( menu_item ) ); + menu_item.show(); return menu_item; } -GtkTearoffMenuItem* menu_tearoff( GtkMenu* menu ){ - GtkTearoffMenuItem* menu_item = GTK_TEAROFF_MENU_ITEM( gtk_tearoff_menu_item_new() ); - container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( menu_item ) ); +ui::TearoffMenuItem menu_tearoff( ui::Menu menu ){ + auto menu_item = ui::TearoffMenuItem(GTK_TEAROFF_MENU_ITEM( gtk_tearoff_menu_item_new() )); + menu.add(menu_item); // gtk_widget_set_sensitive(GTK_WIDGET(menu_item), FALSE); -- controls whether menu is detachable - gtk_widget_show( GTK_WIDGET( menu_item ) ); + menu_item.show(); return menu_item; } -GtkMenuItem* new_sub_menu_item_with_mnemonic( const char* mnemonic ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_mnemonic( mnemonic ) ); - gtk_widget_show( GTK_WIDGET( item ) ); +ui::MenuItem new_sub_menu_item_with_mnemonic( const char* mnemonic ){ + auto item = ui::MenuItem( mnemonic, true ); + item.show(); - GtkWidget* sub_menu = gtk_menu_new(); + auto sub_menu = ui::Menu(); gtk_menu_item_set_submenu( item, sub_menu ); return item; } -GtkMenu* create_sub_menu_with_mnemonic( GtkMenuShell* parent, const char* mnemonic ){ - GtkMenuItem* item = new_sub_menu_item_with_mnemonic( mnemonic ); - container_add_widget( GTK_CONTAINER( parent ), GTK_WIDGET( item ) ); - return GTK_MENU( gtk_menu_item_get_submenu( item ) ); +ui::Menu create_sub_menu_with_mnemonic( ui::MenuShell parent, const char* mnemonic ){ + auto item = new_sub_menu_item_with_mnemonic( mnemonic ); + parent.add(item); + return ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( item ) )); } -GtkMenu* create_sub_menu_with_mnemonic( GtkMenuBar* bar, const char* mnemonic ){ - return create_sub_menu_with_mnemonic( GTK_MENU_SHELL( bar ), mnemonic ); +ui::Menu create_sub_menu_with_mnemonic( ui::MenuBar bar, const char* mnemonic ){ + return create_sub_menu_with_mnemonic( ui::MenuShell(GTK_MENU_SHELL( bar )), mnemonic ); } -GtkMenu* create_sub_menu_with_mnemonic( GtkMenu* parent, const char* mnemonic ){ - return create_sub_menu_with_mnemonic( GTK_MENU_SHELL( parent ), mnemonic ); +ui::Menu create_sub_menu_with_mnemonic( ui::Menu parent, const char* mnemonic ){ + return create_sub_menu_with_mnemonic( ui::MenuShell(GTK_MENU_SHELL( parent )), mnemonic ); } -void activate_closure_callback( GtkWidget* widget, gpointer data ){ +void activate_closure_callback( ui::Widget widget, gpointer data ){ ( *reinterpret_cast( data ) )( ); } -guint menu_item_connect_callback( GtkMenuItem* item, const Callback& callback ){ +guint menu_item_connect_callback( ui::MenuItem item, const Callback& callback ){ #if 1 return g_signal_connect_swapped( G_OBJECT( item ), "activate", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); #else @@ -91,7 +89,7 @@ guint menu_item_connect_callback( GtkMenuItem* item, const Callback& callback ){ #endif } -guint check_menu_item_connect_callback( GtkCheckMenuItem* item, const Callback& callback ){ +guint check_menu_item_connect_callback( ui::CheckMenuItem item, const Callback& callback ){ #if 1 guint handler = g_signal_connect_swapped( G_OBJECT( item ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); #else @@ -101,50 +99,50 @@ guint check_menu_item_connect_callback( GtkCheckMenuItem* item, const Callback& return handler; } -GtkMenuItem* new_menu_item_with_mnemonic( const char *mnemonic, const Callback& callback ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_mnemonic( mnemonic ) ); - gtk_widget_show( GTK_WIDGET( item ) ); +ui::MenuItem new_menu_item_with_mnemonic( const char *mnemonic, const Callback& callback ){ + auto item = ui::MenuItem( mnemonic, true ); + item.show(); menu_item_connect_callback( item, callback ); return item; } -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char *mnemonic, const Callback& callback ){ - GtkMenuItem* item = new_menu_item_with_mnemonic( mnemonic, callback ); - container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) ); +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const Callback& callback ){ + auto item = new_menu_item_with_mnemonic( mnemonic, callback ); + menu.add(item); return item; } -GtkCheckMenuItem* new_check_menu_item_with_mnemonic( const char* mnemonic, const Callback& callback ){ - GtkCheckMenuItem* item = GTK_CHECK_MENU_ITEM( gtk_check_menu_item_new_with_mnemonic( mnemonic ) ); - gtk_widget_show( GTK_WIDGET( item ) ); +ui::CheckMenuItem new_check_menu_item_with_mnemonic( const char* mnemonic, const Callback& callback ){ + auto item = ui::CheckMenuItem(GTK_CHECK_MENU_ITEM( gtk_check_menu_item_new_with_mnemonic( mnemonic ) )); + item.show(); check_menu_item_connect_callback( item, callback ); return item; } -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Callback& callback ){ - GtkCheckMenuItem* item = new_check_menu_item_with_mnemonic( mnemonic, callback ); - container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) ); +ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Callback& callback ){ + auto item = new_check_menu_item_with_mnemonic( mnemonic, callback ); + menu.add(item); return item; } -GtkRadioMenuItem* new_radio_menu_item_with_mnemonic( GSList** group, const char* mnemonic, const Callback& callback ){ - GtkRadioMenuItem* item = GTK_RADIO_MENU_ITEM( gtk_radio_menu_item_new_with_mnemonic( *group, mnemonic ) ); +ui::RadioMenuItem new_radio_menu_item_with_mnemonic( GSList** group, const char* mnemonic, const Callback& callback ){ + auto item = ui::RadioMenuItem(GTK_RADIO_MENU_ITEM( gtk_radio_menu_item_new_with_mnemonic( *group, mnemonic ) )); if ( *group == 0 ) { - gtk_check_menu_item_set_state( GTK_CHECK_MENU_ITEM( item ), TRUE ); + gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( item ), TRUE ); } - *group = gtk_radio_menu_item_group( item ); - gtk_widget_show( GTK_WIDGET( item ) ); - check_menu_item_connect_callback( GTK_CHECK_MENU_ITEM( item ), callback ); + *group = gtk_radio_menu_item_get_group( item ); + item.show(); + check_menu_item_connect_callback( item, callback ); return item; } -GtkRadioMenuItem* create_radio_menu_item_with_mnemonic( GtkMenu* menu, GSList** group, const char* mnemonic, const Callback& callback ){ - GtkRadioMenuItem* item = new_radio_menu_item_with_mnemonic( group, mnemonic, callback ); - container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) ); +ui::RadioMenuItem create_radio_menu_item_with_mnemonic( ui::Menu menu, GSList** group, const char* mnemonic, const Callback& callback ){ + auto item = new_radio_menu_item_with_mnemonic( group, mnemonic, callback ); + menu.add(item); return item; } -void check_menu_item_set_active_no_signal( GtkCheckMenuItem* item, gboolean active ){ +void check_menu_item_set_active_no_signal( ui::CheckMenuItem item, gboolean active ){ guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( item ), "handler" ) ); g_signal_handler_block( G_OBJECT( item ), handler_id ); gtk_check_menu_item_set_active( item, active ); @@ -153,7 +151,7 @@ void check_menu_item_set_active_no_signal( GtkCheckMenuItem* item, gboolean acti -void radio_menu_item_set_active_no_signal( GtkRadioMenuItem* item, gboolean active ){ +void radio_menu_item_set_active_no_signal( ui::RadioMenuItem item, gboolean active ){ { for ( GSList* l = gtk_radio_menu_item_get_group( item ); l != 0; l = g_slist_next( l ) ) { @@ -170,7 +168,7 @@ void radio_menu_item_set_active_no_signal( GtkRadioMenuItem* item, gboolean acti } -void menu_item_set_accelerator( GtkMenuItem* item, GClosure* closure ){ +void menu_item_set_accelerator( ui::MenuItem item, GClosure* closure ){ GtkAccelLabel* accel_label = GTK_ACCEL_LABEL( gtk_bin_get_child( GTK_BIN( item ) ) ); gtk_accel_label_set_accel_closure( accel_label, closure ); } @@ -226,55 +224,29 @@ void accelerator_name( const Accelerator& accelerator, GString* gstring ){ } } -void menu_item_set_accelerator( GtkMenuItem* item, Accelerator accelerator ){ - GtkAccelLabel* accel_label = GTK_ACCEL_LABEL( gtk_bin_get_child( GTK_BIN( item ) ) ); - - g_free( accel_label->accel_string ); - accel_label->accel_string = 0; - - GString* gstring = g_string_new( accel_label->accel_string ); - g_string_append( gstring, " " ); - - accelerator_name( accelerator, gstring ); - - g_free( accel_label->accel_string ); - accel_label->accel_string = gstring->str; - g_string_free( gstring, FALSE ); - - if ( !accel_label->accel_string ) { - accel_label->accel_string = g_strdup( "" ); - } - - gtk_widget_queue_resize( GTK_WIDGET( accel_label ) ); -} - -void menu_item_add_accelerator( GtkMenuItem* item, Accelerator accelerator ){ - if ( accelerator.key != 0 ) { +void menu_item_add_accelerator( ui::MenuItem item, Accelerator accelerator ){ + if ( accelerator.key != 0 && gtk_accelerator_valid( accelerator.key, accelerator.modifiers )) { GClosure* closure = global_accel_group_find( accelerator ); - if ( closure != 0 ) { - menu_item_set_accelerator( item, closure ); - } - else - { - menu_item_set_accelerator( item, accelerator ); - } + ASSERT_NOTNULL(closure); + menu_item_set_accelerator( item, closure ); } } -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Command& command ){ - GtkMenuItem* item = create_menu_item_with_mnemonic( menu, mnemonic, command.m_callback ); +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Command& command ){ + auto item = create_menu_item_with_mnemonic( menu, mnemonic, command.m_callback ); menu_item_add_accelerator( item, command.m_accelerator ); return item; } -void check_menu_item_set_active_callback( GtkCheckMenuItem& item, bool enabled ){ - check_menu_item_set_active_no_signal( &item, enabled ); +void check_menu_item_set_active_callback( GtkCheckMenuItem &item, bool enabled ){ + check_menu_item_set_active_no_signal( ui::CheckMenuItem(&item), enabled ); } typedef ReferenceCaller1 CheckMenuItemSetActiveCaller; -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Toggle& toggle ){ - GtkCheckMenuItem* item = create_check_menu_item_with_mnemonic( menu, mnemonic, toggle.m_command.m_callback ); - menu_item_add_accelerator( GTK_MENU_ITEM( item ), toggle.m_command.m_accelerator ); - toggle.m_exportCallback( CheckMenuItemSetActiveCaller( *item ) ); +ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Toggle& toggle ){ + auto item = create_check_menu_item_with_mnemonic( menu, mnemonic, toggle.m_command.m_callback ); + menu_item_add_accelerator( item, toggle.m_command.m_accelerator ); + GtkCheckMenuItem *item_ = item; + toggle.m_exportCallback( CheckMenuItemSetActiveCaller( *item_ ) ); return item; } diff --git a/libs/gtkutil/menu.h b/libs/gtkutil/menu.h index a64291d4..9b040450 100644 --- a/libs/gtkutil/menu.h +++ b/libs/gtkutil/menu.h @@ -22,37 +22,30 @@ #if !defined( INCLUDED_GTKUTIL_MENU_H ) #define INCLUDED_GTKUTIL_MENU_H +#include #include "generic/callbackfwd.h" typedef int gint; typedef gint gboolean; typedef struct _GSList GSList; -typedef struct _GtkMenu GtkMenu; -typedef struct _GtkMenuBar GtkMenuBar; -typedef struct _GtkMenuItem GtkMenuItem; -typedef struct _GtkCheckMenuItem GtkCheckMenuItem; -typedef struct _GtkRadioMenuItem GtkRadioMenuItem; -typedef struct _GtkTearoffMenuItem GtkTearoffMenuItem; - -void menu_add_item( GtkMenu* menu, GtkMenuItem* item ); -GtkMenuItem* menu_separator( GtkMenu* menu ); -GtkTearoffMenuItem* menu_tearoff( GtkMenu* menu ); -GtkMenuItem* new_sub_menu_item_with_mnemonic( const char* mnemonic ); -GtkMenu* create_sub_menu_with_mnemonic( GtkMenuBar* bar, const char* mnemonic ); -GtkMenu* create_sub_menu_with_mnemonic( GtkMenu* parent, const char* mnemonic ); -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Callback& callback ); -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Callback& callback ); -GtkRadioMenuItem* create_radio_menu_item_with_mnemonic( GtkMenu* menu, GSList** group, const char* mnemonic, const Callback& callback ); + +void menu_add_item( ui::Menu menu, ui::MenuItem item ); +ui::MenuItem menu_separator( ui::Menu menu ); +ui::TearoffMenuItem menu_tearoff( ui::Menu menu ); +ui::MenuItem new_sub_menu_item_with_mnemonic( const char* mnemonic ); +ui::Menu create_sub_menu_with_mnemonic( ui::MenuBar bar, const char* mnemonic ); +ui::Menu create_sub_menu_with_mnemonic( ui::Menu parent, const char* mnemonic ); +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Callback& callback ); +ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Callback& callback ); +ui::RadioMenuItem create_radio_menu_item_with_mnemonic( ui::Menu menu, GSList** group, const char* mnemonic, const Callback& callback ); class Command; -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Command& command ); +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Command& command ); class Toggle; -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Toggle& toggle ); +ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Toggle& toggle ); -typedef struct _GtkCheckMenuItem GtkCheckMenuItem; -void check_menu_item_set_active_no_signal( GtkCheckMenuItem* item, gboolean active ); -typedef struct _GtkRadioMenuItem GtkRadioMenuItem; -void radio_menu_item_set_active_no_signal( GtkRadioMenuItem* item, gboolean active ); +void check_menu_item_set_active_no_signal( ui::CheckMenuItem item, gboolean active ); +void radio_menu_item_set_active_no_signal( ui::RadioMenuItem item, gboolean active ); #endif diff --git a/libs/gtkutil/messagebox.cpp b/libs/gtkutil/messagebox.cpp index 8f9fb7fa..97c77ee8 100644 --- a/libs/gtkutil/messagebox.cpp +++ b/libs/gtkutil/messagebox.cpp @@ -22,21 +22,13 @@ #include "messagebox.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "dialog.h" #include "widget.h" GtkWidget* create_padding( int width, int height ){ - GtkWidget* widget = gtk_alignment_new( 0.0, 0.0, 0.0, 0.0 ); + ui::Alignment widget = ui::Alignment( 0.0, 0.0, 0.0, 0.0 ); gtk_widget_show( widget ); gtk_widget_set_size_request( widget, width, height ); return widget; @@ -59,27 +51,27 @@ const char* messagebox_stock_icon( EMessageBoxIcon type ){ } } -EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){ +EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); ModalDialogButton yes_button( dialog, eIDYES ); ModalDialogButton no_button( dialog, eIDNO ); - GtkWindow* parentWindow = parent != 0 ? GTK_WINDOW( parent ) : 0; + ui::Window parentWindow = ui::Window(parent ? GTK_WINDOW( parent ) : 0); - GtkWindow* window = create_fixedsize_modal_dialog_window( parentWindow, title, dialog, 400, 100 ); + ui::Window window = create_fixedsize_modal_dialog_window( parentWindow, title, dialog, 400, 100 ); - if ( parentWindow != 0 ) { - //g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(floating_window_delete_present), parent); + if ( parentWindow ) { + //window.connect( "delete_event", G_CALLBACK(floating_window_delete_present), parent); gtk_window_deiconify( parentWindow ); } - GtkAccelGroup* accel = gtk_accel_group_new(); - gtk_window_add_accel_group( window, accel ); + auto accel = ui::AccelGroup(); + window.add_accel_group( accel ); - GtkVBox* vbox = create_dialog_vbox( 8, 8 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + auto vbox = create_dialog_vbox( 8, 8 ); + window.add(vbox); GtkHBox* hboxDummy = create_dialog_hbox( 0, 0 ); @@ -94,7 +86,7 @@ EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const cha gtk_widget_show( GTK_WIDGET( image ) ); gtk_box_pack_start( GTK_BOX( iconBox ), GTK_WIDGET( image ), FALSE, FALSE, 0 ); - GtkLabel* label = GTK_LABEL( gtk_label_new( text ) ); + GtkLabel* label = GTK_LABEL( ui::Label( text ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); gtk_label_set_justify( label, GTK_JUSTIFY_LEFT ); @@ -105,39 +97,39 @@ EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const cha GtkVBox* vboxDummy = create_dialog_vbox( 0, 0 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( vboxDummy ), FALSE, FALSE, 0 ); - GtkAlignment* alignment = GTK_ALIGNMENT( gtk_alignment_new( 0.5, 0.0, 0.0, 0.0 ) ); + auto alignment = ui::Alignment( 0.5, 0.0, 0.0, 0.0 ); gtk_widget_show( GTK_WIDGET( alignment ) ); gtk_box_pack_start( GTK_BOX( vboxDummy ), GTK_WIDGET( alignment ), FALSE, FALSE, 0 ); - GtkHBox* hbox = create_dialog_hbox( 8, 0 ); - gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 8, 0 ); + alignment.add(hbox); gtk_box_pack_start( GTK_BOX( vboxDummy ), create_padding( 400, 0 ), FALSE, FALSE, 0 ); // HACK to force minimum width if ( type == eMB_OK ) { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + widget_make_default( button ); + button.show(); dialog.ret = eIDOK; } else if ( type == eMB_OKCANCEL ) { { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + widget_make_default( button ); + button.show(); } { GtkButton* button = create_modal_dialog_button( "OK", cancel_button ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); gtk_widget_show( GTK_WIDGET( button ) ); } @@ -145,10 +137,10 @@ EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const cha } else if ( type == eMB_YESNOCANCEL ) { { - GtkButton* button = create_modal_dialog_button( "Yes", yes_button ); + auto button = create_modal_dialog_button( "Yes", yes_button ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + widget_make_default( button ); + button.show(); } { @@ -166,10 +158,10 @@ EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const cha } else if ( type == eMB_NOYES ) { { - GtkButton* button = create_modal_dialog_button( "No", no_button ); + auto button = create_modal_dialog_button( "No", no_button ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + widget_make_default( button ); + button.show(); } { GtkButton* button = create_modal_dialog_button( "Yes", yes_button ); @@ -182,9 +174,9 @@ EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const cha else /* if (type == eMB_YESNO) */ { { - GtkButton* button = create_modal_dialog_button( "Yes", yes_button ); + auto button = create_modal_dialog_button( "Yes", yes_button ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_show( GTK_WIDGET( button ) ); } diff --git a/libs/gtkutil/messagebox.h b/libs/gtkutil/messagebox.h index 8bdc0ba2..69939939 100644 --- a/libs/gtkutil/messagebox.h +++ b/libs/gtkutil/messagebox.h @@ -24,8 +24,7 @@ #include "qerplugin.h" -typedef struct _GtkWidget GtkWidget; /// \brief Shows a modal message-box. -EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT ); +EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT ); #endif diff --git a/libs/gtkutil/nonmodal.cpp b/libs/gtkutil/nonmodal.cpp index edca0b73..97c4bce2 100644 --- a/libs/gtkutil/nonmodal.cpp +++ b/libs/gtkutil/nonmodal.cpp @@ -1,22 +1,112 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. +#include "nonmodal.h" - This file is part of GtkRadiant. +#include +#include - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +gboolean escape_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data) +{ + if (event->keyval == GDK_KEY_Escape) { + gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(widget))), NULL); + return TRUE; + } + return FALSE; +} - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +void widget_connect_escape_clear_focus_widget(ui::Widget widget) +{ + widget.connect("key_press_event", G_CALLBACK(escape_clear_focus_widget), 0); +} - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ +gboolean NonModalEntry::focus_in(ui::Entry entry, GdkEventFocus *event, NonModalEntry *self) +{ + self->m_editing = false; + return FALSE; +} -#include "nonmodal.h" +gboolean NonModalEntry::focus_out(ui::Entry entry, GdkEventFocus *event, NonModalEntry *self) +{ + if (self->m_editing && gtk_widget_get_visible(GTK_WIDGET(entry))) { + self->m_apply(); + } + self->m_editing = false; + return FALSE; +} + +gboolean NonModalEntry::changed(ui::Entry entry, NonModalEntry *self) +{ + self->m_editing = true; + return FALSE; +} + +gboolean NonModalEntry::enter(ui::Entry entry, GdkEventKey *event, NonModalEntry *self) +{ + if (event->keyval == GDK_KEY_Return) { + self->m_apply(); + self->m_editing = false; + gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(entry))), NULL); + return TRUE; + } + return FALSE; +} + +gboolean NonModalEntry::escape(ui::Entry entry, GdkEventKey *event, NonModalEntry *self) +{ + if (event->keyval == GDK_KEY_Escape) { + self->m_cancel(); + self->m_editing = false; + gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(entry))), NULL); + return TRUE; + } + return FALSE; +} + +void NonModalEntry::connect(ui::Entry entry) +{ + entry.connect("focus_in_event", G_CALLBACK(focus_in), this); + entry.connect("focus_out_event", G_CALLBACK(focus_out), this); + entry.connect("key_press_event", G_CALLBACK(enter), this); + entry.connect("key_press_event", G_CALLBACK(escape), this); + entry.connect("changed", G_CALLBACK(changed), this); +} + +gboolean NonModalSpinner::changed(ui::SpinButton spin, NonModalSpinner *self) +{ + self->m_apply(); + return FALSE; +} + +gboolean NonModalSpinner::enter(ui::SpinButton spin, GdkEventKey *event, NonModalSpinner *self) +{ + if (event->keyval == GDK_KEY_Return) { + gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(spin))), NULL); + return TRUE; + } + return FALSE; +} + +gboolean NonModalSpinner::escape(ui::SpinButton spin, GdkEventKey *event, NonModalSpinner *self) +{ + if (event->keyval == GDK_KEY_Escape) { + self->m_cancel(); + gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(spin))), NULL); + return TRUE; + } + return FALSE; +} + +void NonModalSpinner::connect(ui::SpinButton spin) +{ + auto adj = ui::Adjustment(gtk_spin_button_get_adjustment(spin)); + guint handler = adj.connect("value_changed", G_CALLBACK(changed), this); + g_object_set_data(G_OBJECT(spin), "handler", gint_to_pointer(handler)); + spin.connect("key_press_event", G_CALLBACK(enter), this); + spin.connect("key_press_event", G_CALLBACK(escape), this); +} + +void NonModalRadio::connect(ui::RadioButton radio) +{ + GSList *group = gtk_radio_button_get_group(radio); + for (; group != 0; group = g_slist_next(group)) { + toggle_button_connect_callback(ui::ToggleButton(GTK_TOGGLE_BUTTON(group->data)), m_changed); + } +} diff --git a/libs/gtkutil/nonmodal.h b/libs/gtkutil/nonmodal.h index 864779bd..6fc043c7 100644 --- a/libs/gtkutil/nonmodal.h +++ b/libs/gtkutil/nonmodal.h @@ -22,142 +22,68 @@ #if !defined( INCLUDED_GTKUTIL_NONMODAL_H ) #define INCLUDED_GTKUTIL_NONMODAL_H -#include -#include -#include -#include - +#include #include "generic/callback.h" #include "pointer.h" #include "button.h" -typedef struct _GtkEntry GtkEntry; - - -inline gboolean escape_clear_focus_widget( GtkWidget* widget, GdkEventKey* event, gpointer data ){ - if ( event->keyval == GDK_Escape ) { - gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), NULL ); - return TRUE; - } - return FALSE; -} - -inline void widget_connect_escape_clear_focus_widget( GtkWidget* widget ){ - g_signal_connect( G_OBJECT( widget ), "key_press_event", G_CALLBACK( escape_clear_focus_widget ), 0 ); -} - - -class NonModalEntry -{ -bool m_editing; -Callback m_apply; -Callback m_cancel; - -static gboolean focus_in( GtkEntry* entry, GdkEventFocus *event, NonModalEntry* self ){ - self->m_editing = false; - return FALSE; -} - -static gboolean focus_out( GtkEntry* entry, GdkEventFocus *event, NonModalEntry* self ){ - if ( self->m_editing && GTK_WIDGET_VISIBLE( entry ) ) { - self->m_apply(); - } - self->m_editing = false; - return FALSE; -} - -static gboolean changed( GtkEntry* entry, NonModalEntry* self ){ - self->m_editing = true; - return FALSE; -} - -static gboolean enter( GtkEntry* entry, GdkEventKey* event, NonModalEntry* self ){ - if ( event->keyval == GDK_Return ) { - self->m_apply(); - self->m_editing = false; - gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( entry ) ) ), NULL ); - return TRUE; - } - return FALSE; -} - -static gboolean escape( GtkEntry* entry, GdkEventKey* event, NonModalEntry* self ){ - if ( event->keyval == GDK_Escape ) { - self->m_cancel(); - self->m_editing = false; - gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( entry ) ) ), NULL ); - return TRUE; - } - return FALSE; -} +gboolean escape_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data); + +void widget_connect_escape_clear_focus_widget(ui::Widget widget); + +class NonModalEntry { + bool m_editing; + Callback m_apply; + Callback m_cancel; + + static gboolean focus_in(ui::Entry entry, GdkEventFocus *event, NonModalEntry *self); + + static gboolean focus_out(ui::Entry entry, GdkEventFocus *event, NonModalEntry *self); + + static gboolean changed(ui::Entry entry, NonModalEntry *self); + + static gboolean enter(ui::Entry entry, GdkEventKey *event, NonModalEntry *self); + + static gboolean escape(ui::Entry entry, GdkEventKey *event, NonModalEntry *self); public: -NonModalEntry( const Callback& apply, const Callback& cancel ) : m_editing( false ), m_apply( apply ), m_cancel( cancel ){ -} -void connect( GtkEntry* entry ){ - g_signal_connect( G_OBJECT( entry ), "focus_in_event", G_CALLBACK( focus_in ), this ); - g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( focus_out ), this ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( enter ), this ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( escape ), this ); - g_signal_connect( G_OBJECT( entry ), "changed", G_CALLBACK( changed ), this ); -} + NonModalEntry(const Callback &apply, const Callback &cancel) : m_editing(false), m_apply(apply), m_cancel(cancel) + { + } + + void connect(ui::Entry entry); }; -class NonModalSpinner -{ -Callback m_apply; -Callback m_cancel; - -static gboolean changed( GtkSpinButton* spin, NonModalSpinner* self ){ - self->m_apply(); - return FALSE; -} - -static gboolean enter( GtkSpinButton* spin, GdkEventKey* event, NonModalSpinner* self ){ - if ( event->keyval == GDK_Return ) { - gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( spin ) ) ), NULL ); - return TRUE; - } - return FALSE; -} - -static gboolean escape( GtkSpinButton* spin, GdkEventKey* event, NonModalSpinner* self ){ - if ( event->keyval == GDK_Escape ) { - self->m_cancel(); - gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( spin ) ) ), NULL ); - return TRUE; - } - return FALSE; -} +class NonModalSpinner { + Callback m_apply; + Callback m_cancel; + + static gboolean changed(ui::SpinButton spin, NonModalSpinner *self); + + static gboolean enter(ui::SpinButton spin, GdkEventKey *event, NonModalSpinner *self); + + static gboolean escape(ui::SpinButton spin, GdkEventKey *event, NonModalSpinner *self); public: -NonModalSpinner( const Callback& apply, const Callback& cancel ) : m_apply( apply ), m_cancel( cancel ){ -} -void connect( GtkSpinButton* spin ){ - guint handler = g_signal_connect( G_OBJECT( gtk_spin_button_get_adjustment( spin ) ), "value_changed", G_CALLBACK( changed ), this ); - g_object_set_data( G_OBJECT( spin ), "handler", gint_to_pointer( handler ) ); - g_signal_connect( G_OBJECT( spin ), "key_press_event", G_CALLBACK( enter ), this ); - g_signal_connect( G_OBJECT( spin ), "key_press_event", G_CALLBACK( escape ), this ); -} + NonModalSpinner(const Callback &apply, const Callback &cancel) : m_apply(apply), m_cancel(cancel) + { + } + + void connect(ui::SpinButton spin); }; -class NonModalRadio -{ -Callback m_changed; +class NonModalRadio { + Callback m_changed; public: -NonModalRadio( const Callback& changed ) : m_changed( changed ){ -} -void connect( GtkRadioButton* radio ){ - GSList* group = gtk_radio_button_group( radio ); - for (; group != 0; group = g_slist_next( group ) ) - { - toggle_button_connect_callback( GTK_TOGGLE_BUTTON( group->data ), m_changed ); - } -} + NonModalRadio(const Callback &changed) : m_changed(changed) + { + } + + void connect(ui::RadioButton radio); }; diff --git a/libs/gtkutil/paned.cpp b/libs/gtkutil/paned.cpp index c5adc09c..a09df803 100644 --- a/libs/gtkutil/paned.cpp +++ b/libs/gtkutil/paned.cpp @@ -21,8 +21,8 @@ #include "paned.h" -#include -#include +#include +#include #include "frame.h" @@ -61,31 +61,31 @@ PanedState g_hpaned = { 0.5f, -1, }; PanedState g_vpaned1 = { 0.5f, -1, }; PanedState g_vpaned2 = { 0.5f, -1, }; -GtkHPaned* create_split_views( GtkWidget* topleft, GtkWidget* topright, GtkWidget* botleft, GtkWidget* botright ){ - GtkHPaned* hsplit = GTK_HPANED( gtk_hpaned_new() ); - gtk_widget_show( GTK_WIDGET( hsplit ) ); +ui::HPaned create_split_views( ui::Widget topleft, ui::Widget topright, ui::Widget botleft, ui::Widget botright ){ + auto hsplit = ui::HPaned(); + hsplit.show(); - g_signal_connect( G_OBJECT( hsplit ), "size_allocate", G_CALLBACK( hpaned_allocate ), &g_hpaned ); - g_signal_connect( G_OBJECT( hsplit ), "notify::position", G_CALLBACK( paned_position ), &g_hpaned ); + hsplit.connect( "size_allocate", G_CALLBACK( hpaned_allocate ), &g_hpaned ); + hsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_hpaned ); { - GtkVPaned* vsplit = GTK_VPANED( gtk_vpaned_new() ); + auto vsplit = ui::VPaned(); gtk_paned_add1( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) ); gtk_widget_show( GTK_WIDGET( vsplit ) ); - g_signal_connect( G_OBJECT( vsplit ), "size_allocate", G_CALLBACK( vpaned_allocate ), &g_vpaned1 ); - g_signal_connect( G_OBJECT( vsplit ), "notify::position", G_CALLBACK( paned_position ), &g_vpaned1 ); + vsplit.connect( "size_allocate", G_CALLBACK( vpaned_allocate ), &g_vpaned1 ); + vsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_vpaned1 ); gtk_paned_add1( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( topleft ) ) ); gtk_paned_add2( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( topright ) ) ); } { - GtkVPaned* vsplit = GTK_VPANED( gtk_vpaned_new() ); + auto vsplit = ui::VPaned(); gtk_paned_add2( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) ); gtk_widget_show( GTK_WIDGET( vsplit ) ); - g_signal_connect( G_OBJECT( vsplit ), "size_allocate", G_CALLBACK( vpaned_allocate ), &g_vpaned2 ); - g_signal_connect( G_OBJECT( vsplit ), "notify::position", G_CALLBACK( paned_position ), &g_vpaned2 ); + vsplit.connect( "size_allocate", G_CALLBACK( vpaned_allocate ), &g_vpaned2 ); + vsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_vpaned2 ); gtk_paned_add1( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( botleft ) ) ); gtk_paned_add2( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( botright ) ) ); diff --git a/libs/gtkutil/paned.h b/libs/gtkutil/paned.h index 8b79f931..842996ef 100644 --- a/libs/gtkutil/paned.h +++ b/libs/gtkutil/paned.h @@ -19,11 +19,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_GTKUTIL_PANED_H ) #define INCLUDED_GTKUTIL_PANED_H -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkHPaned GtkHPaned; -GtkHPaned* create_split_views( GtkWidget* topleft, GtkWidget* topright, GtkWidget* botleft, GtkWidget* botright ); +ui::HPaned create_split_views( ui::Widget topleft, ui::Widget topright, ui::Widget botleft, ui::Widget botright ); #endif diff --git a/libs/gtkutil/pointer.cpp b/libs/gtkutil/pointer.cpp deleted file mode 100644 index 503845a4..00000000 --- a/libs/gtkutil/pointer.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "pointer.h" diff --git a/libs/gtkutil/toolbar.cpp b/libs/gtkutil/toolbar.cpp index 3ac74f61..04863609 100644 --- a/libs/gtkutil/toolbar.cpp +++ b/libs/gtkutil/toolbar.cpp @@ -21,52 +21,50 @@ #include "toolbar.h" -#include -#include +#include +#include #include "generic/callback.h" #include "accelerator.h" #include "button.h" -#include "closure.h" -#include "pointer.h" +#include "image.h" -void toolbar_append( GtkToolbar* toolbar, GtkButton* button, const char* description ){ - gtk_widget_show( GTK_WIDGET( button ) ); - gtk_button_set_relief( button, GTK_RELIEF_NONE ); - GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_FOCUS ); - GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_DEFAULT ); - gtk_toolbar_append_element( toolbar, GTK_TOOLBAR_CHILD_WIDGET, GTK_WIDGET( button ), "", description, "", 0, 0, 0 ); +void toolbar_append( ui::Toolbar toolbar, ui::ToolItem button, const char* description ){ + gtk_widget_show_all(GTK_WIDGET(button)); + gtk_widget_set_tooltip_text(GTK_WIDGET(button), description); + toolbar.add(button); } -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){ - GtkButton* button = GTK_BUTTON( gtk_button_new() ); - button_set_icon( button, icon ); - button_connect_callback( button, callback ); - toolbar_append( toolbar, button, description ); +ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ){ + auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_tool_button_new(GTK_WIDGET(new_local_image(icon)), nullptr))); + button_connect_callback(button, callback); + toolbar_append(toolbar, button, description); return button; } -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){ - GtkToggleButton* button = GTK_TOGGLE_BUTTON( gtk_toggle_button_new() ); - button_set_icon( GTK_BUTTON( button ), icon ); - toggle_button_connect_callback( button, callback ); - toolbar_append( toolbar, GTK_BUTTON( button ), description ); +ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ){ + auto button = ui::ToggleToolButton(GTK_TOGGLE_TOOL_BUTTON(gtk_toggle_tool_button_new())); + toggle_button_connect_callback(button, callback); + gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), GTK_WIDGET(new_local_image(icon))); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), description); + toolbar_append(toolbar, button, description); return button; } -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ){ +ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Command& command ){ return toolbar_append_button( toolbar, description, icon, command.m_callback ); } -void toggle_button_set_active_callback( GtkToggleButton& button, bool active ){ - toggle_button_set_active_no_signal( &button, active ); +void toggle_button_set_active_callback( GtkToggleToolButton& button, bool active ){ + toggle_button_set_active_no_signal( ui::ToggleToolButton(&button), active ); } -typedef ReferenceCaller1 ToggleButtonSetActiveCaller; +using ToggleButtonSetActiveCaller = ReferenceCaller1; -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ){ - GtkToggleButton* button = toolbar_append_toggle_button( toolbar, description, icon, toggle.m_command.m_callback ); - toggle.m_exportCallback( ToggleButtonSetActiveCaller( *button ) ); +ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Toggle& toggle ){ + auto button = toolbar_append_toggle_button( toolbar, description, icon, toggle.m_command.m_callback ); + GtkToggleToolButton *button_ = button; + toggle.m_exportCallback( ToggleButtonSetActiveCaller( *button_ ) ); return button; } diff --git a/libs/gtkutil/toolbar.h b/libs/gtkutil/toolbar.h index 6b9e32fb..66f38805 100644 --- a/libs/gtkutil/toolbar.h +++ b/libs/gtkutil/toolbar.h @@ -22,17 +22,15 @@ #if !defined( INCLUDED_GTKUTIL_TOOLBAR_H ) #define INCLUDED_GTKUTIL_TOOLBAR_H +#include #include "generic/callbackfwd.h" -typedef struct _GtkButton GtkButton; -typedef struct _GtkToggleButton GtkToggleButton; -typedef struct _GtkToolbar GtkToolbar; class Command; class Toggle; -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ); -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ); -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ); -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ); +ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ); +ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Command& command ); +ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ); +ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Toggle& toggle ); #endif diff --git a/libs/gtkutil/widget.cpp b/libs/gtkutil/widget.cpp index e212fdf6..579ade80 100644 --- a/libs/gtkutil/widget.cpp +++ b/libs/gtkutil/widget.cpp @@ -1,22 +1,100 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. +#include "widget.h" +#include - This file is part of GtkRadiant. +void widget_set_visible(ui::Widget widget, bool shown) +{ + if (shown) { + widget.show(); + } else { + gtk_widget_hide(widget); + } +} - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +bool widget_is_visible(ui::Widget widget) +{ + return gtk_widget_get_visible(widget) != FALSE; +} - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +void widget_queue_draw(ui::Widget &widget) +{ + gtk_widget_queue_draw(widget); +} - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ +void widget_make_default(ui::Widget widget) +{ + gtk_widget_set_can_default(widget, true); + gtk_widget_grab_default(widget); +} -#include "widget.h" +gboolean ToggleShown::notify_visible(ui::Widget widget, gpointer dummy, ToggleShown *self) +{ + self->update(); + return FALSE; +} + +gboolean ToggleShown::destroy(ui::Widget widget, ToggleShown *self) +{ + self->m_shownDeferred = gtk_widget_get_visible(self->m_widget) != FALSE; + self->m_widget = ui::Widget(ui::null); + return FALSE; +} + +void ToggleShown::update() +{ + m_item.update(); +} + +bool ToggleShown::active() const +{ + if (!m_widget) { + return m_shownDeferred; + } else { + return gtk_widget_get_visible(m_widget) != FALSE; + } +} + +void ToggleShown::exportActive(const BoolImportCallback &importCallback) +{ + importCallback(active()); +} + +void ToggleShown::set(bool shown) +{ + if (!m_widget) { + m_shownDeferred = shown; + } else { + widget_set_visible(m_widget, shown); + } +} + +void ToggleShown::toggle() +{ + widget_toggle_visible(m_widget); +} + +void ToggleShown::connect(ui::Widget widget) +{ + m_widget = widget; + widget_set_visible(m_widget, m_shownDeferred); + m_widget.connect("notify::visible", G_CALLBACK(notify_visible), this); + m_widget.connect("destroy", G_CALLBACK(destroy), this); + update(); +} + +gboolean WidgetFocusPrinter::focus_in(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self) +{ + globalOutputStream() << self->m_name << " takes focus\n"; + return FALSE; +} + +gboolean WidgetFocusPrinter::focus_out(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self) +{ + globalOutputStream() << self->m_name << " loses focus\n"; + return FALSE; +} + +void WidgetFocusPrinter::connect(ui::Widget widget) +{ + widget.connect("focus_in_event", G_CALLBACK(focus_in), this); + widget.connect("focus_out_event", G_CALLBACK(focus_out), this); +} diff --git a/libs/gtkutil/widget.h b/libs/gtkutil/widget.h index ceb92409..a81054d4 100644 --- a/libs/gtkutil/widget.h +++ b/libs/gtkutil/widget.h @@ -23,144 +23,103 @@ #define INCLUDED_GTKUTIL_WIDGET_H #include -#include +#include +#include #include "generic/callback.h" #include "warnings.h" #include "debugging/debugging.h" -inline void widget_set_visible( GtkWidget* widget, bool shown ){ - if ( shown ) { - gtk_widget_show( widget ); - } - else - { - gtk_widget_hide( widget ); - } -} +void widget_set_visible(ui::Widget widget, bool shown); -inline bool widget_is_visible( GtkWidget* widget ){ - return GTK_WIDGET_VISIBLE( widget ) != FALSE; -} +bool widget_is_visible(ui::Widget widget); -inline void widget_toggle_visible( GtkWidget* widget ){ - widget_set_visible( widget, !widget_is_visible( widget ) ); +inline void widget_toggle_visible(ui::Widget widget) +{ + widget_set_visible(widget, !widget_is_visible(widget)); } -class ToggleItem -{ -BoolExportCallback m_exportCallback; -typedef std::list ImportCallbacks; -ImportCallbacks m_importCallbacks; +class ToggleItem { + BoolExportCallback m_exportCallback; + typedef std::list ImportCallbacks; + ImportCallbacks m_importCallbacks; public: -ToggleItem( const BoolExportCallback& exportCallback ) : m_exportCallback( exportCallback ){ -} + ToggleItem(const BoolExportCallback &exportCallback) : m_exportCallback(exportCallback) + { + } + + void update() + { + for (ImportCallbacks::iterator i = m_importCallbacks.begin(); i != m_importCallbacks.end(); ++i) { + m_exportCallback(*i); + } + } + + void addCallback(const BoolImportCallback &callback) + { + m_importCallbacks.push_back(callback); + m_exportCallback(callback); + } + + typedef MemberCaller1 AddCallbackCaller; +}; -void update(){ - for ( ImportCallbacks::iterator i = m_importCallbacks.begin(); i != m_importCallbacks.end(); ++i ) - { - m_exportCallback( *i ); - } -} +class ToggleShown { + bool m_shownDeferred; -void addCallback( const BoolImportCallback& callback ){ - m_importCallbacks.push_back( callback ); - m_exportCallback( callback ); -} -typedef MemberCaller1 AddCallbackCaller; -}; + ToggleShown(const ToggleShown &other); // NOT COPYABLE + ToggleShown &operator=(const ToggleShown &other); // NOT ASSIGNABLE -class ToggleShown -{ -bool m_shownDeferred; + static gboolean notify_visible(ui::Widget widget, gpointer dummy, ToggleShown *self); -ToggleShown( const ToggleShown& other ); // NOT COPYABLE -ToggleShown& operator=( const ToggleShown& other ); // NOT ASSIGNABLE + static gboolean destroy(ui::Widget widget, ToggleShown *self); -static gboolean notify_visible( GtkWidget* widget, gpointer dummy, ToggleShown* self ){ - self->update(); - return FALSE; -} -static gboolean destroy( GtkWidget* widget, ToggleShown* self ){ - self->m_shownDeferred = GTK_WIDGET_VISIBLE( self->m_widget ) != FALSE; - self->m_widget = 0; - return FALSE; -} public: -GtkWidget* m_widget; -ToggleItem m_item; + ui::Widget m_widget; + ToggleItem m_item; -ToggleShown( bool shown ) - : m_shownDeferred( shown ), m_widget( 0 ), m_item( ActiveCaller( *this ) ){ -} -void update(){ - m_item.update(); -} -bool active() const { - if ( m_widget == 0 ) { - return m_shownDeferred; - } - else - { - return GTK_WIDGET_VISIBLE( m_widget ) != FALSE; - } -} -void exportActive( const BoolImportCallback& importCallback ){ - importCallback( active() ); -} -typedef MemberCaller1 ActiveCaller; -void set( bool shown ){ - if ( m_widget == 0 ) { - m_shownDeferred = shown; - } - else - { - widget_set_visible( m_widget, shown ); - } -} -void toggle(){ - widget_toggle_visible( m_widget ); -} -typedef MemberCaller ToggleCaller; -void connect( GtkWidget* widget ){ - m_widget = widget; - widget_set_visible( m_widget, m_shownDeferred ); - g_signal_connect( G_OBJECT( m_widget ), "notify::visible", G_CALLBACK( notify_visible ), this ); - g_signal_connect( G_OBJECT( m_widget ), "destroy", G_CALLBACK( destroy ), this ); - update(); -} + ToggleShown(bool shown) + : m_shownDeferred(shown), m_widget(0), m_item(ActiveCaller(*this)) + { + } + + void update(); + + bool active() const; + + void exportActive(const BoolImportCallback &importCallback); + + typedef MemberCaller1 ActiveCaller; + + void set(bool shown); + + void toggle(); + + typedef MemberCaller ToggleCaller; + + void connect(ui::Widget widget); }; -inline void widget_queue_draw( GtkWidget& widget ){ - gtk_widget_queue_draw( &widget ); -} -typedef ReferenceCaller WidgetQueueDrawCaller; +void widget_queue_draw(ui::Widget &widget); +typedef ReferenceCaller WidgetQueueDrawCaller; -inline void widget_make_default( GtkWidget* widget ){ - GTK_WIDGET_SET_FLAGS( widget, GTK_CAN_DEFAULT ); - gtk_widget_grab_default( widget ); -} -class WidgetFocusPrinter -{ -const char* m_name; +void widget_make_default(ui::Widget widget); + +class WidgetFocusPrinter { + const char *m_name; + + static gboolean focus_in(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self); + + static gboolean focus_out(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self); -static gboolean focus_in( GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self ){ - globalOutputStream() << self->m_name << " takes focus\n"; - return FALSE; -} -static gboolean focus_out( GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self ){ - globalOutputStream() << self->m_name << " loses focus\n"; - return FALSE; -} public: -WidgetFocusPrinter( const char* name ) : m_name( name ){ -} -void connect( GtkWidget* widget ){ - g_signal_connect( G_OBJECT( widget ), "focus_in_event", G_CALLBACK( focus_in ), this ); - g_signal_connect( G_OBJECT( widget ), "focus_out_event", G_CALLBACK( focus_out ), this ); -} + WidgetFocusPrinter(const char *name) : m_name(name) + { + } + + void connect(ui::Widget widget); }; #endif diff --git a/libs/gtkutil/window.cpp b/libs/gtkutil/window.cpp index 48b174b3..bbeed5b9 100644 --- a/libs/gtkutil/window.cpp +++ b/libs/gtkutil/window.cpp @@ -21,126 +21,217 @@ #include "window.h" -#include +#include #include "pointer.h" #include "accelerator.h" -inline void CHECK_RESTORE( GtkWidget* w ){ +inline void CHECK_RESTORE( ui::Widget w ){ if ( gpointer_to_int( g_object_get_data( G_OBJECT( w ), "was_mapped" ) ) != 0 ) { gtk_widget_show( w ); } } -inline void CHECK_MINIMIZE( GtkWidget* w ){ - g_object_set_data( G_OBJECT( w ), "was_mapped", gint_to_pointer( GTK_WIDGET_VISIBLE( w ) ) ); +inline void CHECK_MINIMIZE( ui::Widget w ){ + g_object_set_data( G_OBJECT( w ), "was_mapped", gint_to_pointer( gtk_widget_get_visible( w ) ) ); gtk_widget_hide( w ); } -static gboolean main_window_iconified( GtkWidget* widget, GdkEventWindowState* event, gpointer data ){ +static gboolean main_window_iconified( ui::Widget widget, GdkEventWindowState* event, gpointer data ){ if ( ( event->changed_mask & ( GDK_WINDOW_STATE_ICONIFIED | GDK_WINDOW_STATE_WITHDRAWN ) ) != 0 ) { if ( ( event->new_window_state & ( GDK_WINDOW_STATE_ICONIFIED | GDK_WINDOW_STATE_WITHDRAWN ) ) != 0 ) { - CHECK_MINIMIZE( GTK_WIDGET( data ) ); + CHECK_MINIMIZE( ui::Widget(GTK_WIDGET( data )) ); } else { - CHECK_RESTORE( GTK_WIDGET( data ) ); + CHECK_RESTORE( ui::Widget(GTK_WIDGET( data )) ); } } return FALSE; } -unsigned int connect_floating( GtkWindow* main_window, GtkWindow* floating ){ - return g_signal_connect( G_OBJECT( main_window ), "window_state_event", G_CALLBACK( main_window_iconified ), floating ); +unsigned int connect_floating( ui::Window main_window, ui::Window floating ){ + return main_window.connect( "window_state_event", G_CALLBACK( main_window_iconified ), floating ); } -gboolean destroy_disconnect_floating( GtkWindow* widget, gpointer data ){ +gboolean destroy_disconnect_floating( ui::Window widget, gpointer data ){ g_signal_handler_disconnect( G_OBJECT( data ), gpointer_to_int( g_object_get_data( G_OBJECT( widget ), "floating_handler" ) ) ); return FALSE; } -gboolean floating_window_delete_present( GtkWindow* floating, GdkEventFocus *event, GtkWindow* main_window ){ +gboolean floating_window_delete_present( ui::Window floating, GdkEventFocus *event, ui::Window main_window ){ if ( gtk_window_is_active( floating ) || gtk_window_is_active( main_window ) ) { gtk_window_present( main_window ); } return FALSE; } -guint connect_floating_window_delete_present( GtkWindow* floating, GtkWindow* main_window ){ - return g_signal_connect( G_OBJECT( floating ), "delete_event", G_CALLBACK( floating_window_delete_present ), main_window ); +guint connect_floating_window_delete_present( ui::Window floating, ui::Window main_window ){ + return floating.connect( "delete_event", G_CALLBACK( floating_window_delete_present ), main_window ); } -gboolean floating_window_destroy_present( GtkWindow* floating, GtkWindow* main_window ){ +gboolean floating_window_destroy_present( ui::Window floating, ui::Window main_window ){ if ( gtk_window_is_active( floating ) || gtk_window_is_active( main_window ) ) { gtk_window_present( main_window ); } return FALSE; } -guint connect_floating_window_destroy_present( GtkWindow* floating, GtkWindow* main_window ){ - return g_signal_connect( G_OBJECT( floating ), "destroy", G_CALLBACK( floating_window_destroy_present ), main_window ); +guint connect_floating_window_destroy_present( ui::Window floating, ui::Window main_window ){ + return floating.connect( "destroy", G_CALLBACK( floating_window_destroy_present ), main_window ); } -GtkWindow* create_floating_window( const char* title, GtkWindow* parent ){ - GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ); +ui::Window create_floating_window( const char* title, ui::Window parent ){ + ui::Window window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( window, title ); - if ( parent != 0 ) { + if ( parent ) { gtk_window_set_transient_for( window, parent ); connect_floating_window_destroy_present( window, parent ); g_object_set_data( G_OBJECT( window ), "floating_handler", gint_to_pointer( connect_floating( parent, window ) ) ); - g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy_disconnect_floating ), parent ); + window.connect( "destroy", G_CALLBACK( destroy_disconnect_floating ), parent ); } return window; } -void destroy_floating_window( GtkWindow* window ){ +void destroy_floating_window( ui::Window window ){ gtk_widget_destroy( GTK_WIDGET( window ) ); } -gint window_realize_remove_sysmenu( GtkWidget* widget, gpointer data ){ - gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU ) ); +gint window_realize_remove_sysmenu( ui::Widget widget, gpointer data ){ + gdk_window_set_decorations( gtk_widget_get_window(widget), (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU ) ); return FALSE; } -gboolean persistent_floating_window_delete( GtkWindow* floating, GdkEvent *event, GtkWindow* main_window ){ +gboolean persistent_floating_window_delete( ui::Window floating, GdkEvent *event, ui::Window main_window ){ gtk_widget_hide( GTK_WIDGET( floating ) ); return TRUE; } -GtkWindow* create_persistent_floating_window( const char* title, GtkWindow* main_window ){ - GtkWindow* window = GTK_WINDOW( create_floating_window( title, main_window ) ); +ui::Window create_persistent_floating_window( const char* title, ui::Window main_window ){ + ui::Window window = ui::Window(GTK_WINDOW( create_floating_window( title, main_window ) )); gtk_widget_set_events( GTK_WIDGET( window ), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK ); connect_floating_window_delete_present( window, main_window ); - g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( persistent_floating_window_delete ), 0 ); + window.connect( "delete_event", G_CALLBACK( persistent_floating_window_delete ), 0 ); #if 0 if ( g_multimon_globals.m_bStartOnPrimMon && g_multimon_globals.m_bNoSysMenuPopups ) { - g_signal_connect( G_OBJECT( window ), "realize", G_CALLBACK( window_realize_remove_sysmenu ), 0 ); + window.connect( "realize", G_CALLBACK( window_realize_remove_sysmenu ), 0 ); } #endif return window; } -gint window_realize_remove_minmax( GtkWidget* widget, gpointer data ){ - gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); +gint window_realize_remove_minmax( ui::Widget widget, gpointer data ){ + gdk_window_set_decorations( gtk_widget_get_window(widget), (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); return FALSE; } -void window_remove_minmax( GtkWindow* window ){ - g_signal_connect( G_OBJECT( window ), "realize", G_CALLBACK( window_realize_remove_minmax ), 0 ); +void window_remove_minmax( ui::Window window ){ + window.connect( "realize", G_CALLBACK( window_realize_remove_minmax ), 0 ); } -GtkScrolledWindow* create_scrolled_window( GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, int border ){ - GtkScrolledWindow* scr = GTK_SCROLLED_WINDOW( gtk_scrolled_window_new( 0, 0 ) ); +ui::ScrolledWindow create_scrolled_window( ui::Policy hscrollbar_policy, ui::Policy vscrollbar_policy, int border ){ + auto scr = ui::ScrolledWindow(); gtk_widget_show( GTK_WIDGET( scr ) ); - gtk_scrolled_window_set_policy( scr, hscrollbar_policy, vscrollbar_policy ); + gtk_scrolled_window_set_policy( scr, (GtkPolicyType) hscrollbar_policy, (GtkPolicyType) vscrollbar_policy ); gtk_scrolled_window_set_shadow_type( scr, GTK_SHADOW_IN ); gtk_container_set_border_width( GTK_CONTAINER( scr ), border ); return scr; } + +gboolean window_focus_in_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data) +{ + gtk_window_set_focus( GTK_WINDOW( widget ), NULL ); + return FALSE; +} + +guint window_connect_focus_in_clear_focus_widget(ui::Window window) +{ + return window.connect( "focus_in_event", G_CALLBACK( window_focus_in_clear_focus_widget ), NULL ); +} + +void window_get_position(ui::Window window, WindowPosition &position) +{ + ASSERT_MESSAGE( window , "error saving window position" ); + + gtk_window_get_position( window, &position.x, &position.y ); + gtk_window_get_size( window, &position.w, &position.h ); +} + +void window_set_position(ui::Window window, const WindowPosition &position) +{ + gtk_window_set_gravity( window, GDK_GRAVITY_STATIC ); + + GdkScreen* screen = gdk_screen_get_default(); + if ( position.x < 0 + || position.y < 0 + || position.x > gdk_screen_get_width( screen ) + || position.y > gdk_screen_get_height( screen ) ) { + gtk_window_set_position( window, GTK_WIN_POS_CENTER_ON_PARENT ); + } + else + { + gtk_window_move( window, position.x, position.y ); + } + + gtk_window_set_default_size( window, position.w, position.h ); +} + +void WindowPosition_Parse(WindowPosition &position, const char *value) +{ + if ( sscanf( value, "%d %d %d %d", &position.x, &position.y, &position.w, &position.h ) != 4 ) { + position = WindowPosition( c_default_window_pos ); // ensure sane default value for window position + } +} + +void WindowPosition_Write(const WindowPosition &position, const StringImportCallback &importCallback) +{ + char buffer[64]; + sprintf( buffer, "%d %d %d %d", position.x, position.y, position.w, position.h ); + importCallback( buffer ); +} + +void WindowPositionTracker_importString(WindowPositionTracker &self, const char *value) +{ + WindowPosition position; + WindowPosition_Parse( position, value ); + self.setPosition( position ); +} + +void WindowPositionTracker_exportString(const WindowPositionTracker &self, const StringImportCallback &importer) +{ + WindowPosition_Write( self.getPosition(), importer ); +} + +gboolean WindowPositionTracker::configure(ui::Widget widget, GdkEventConfigure *event, WindowPositionTracker *self) +{ + self->m_position = WindowPosition( event->x, event->y, event->width, event->height ); + return FALSE; +} + +void WindowPositionTracker::sync(ui::Window window) +{ + window_set_position( window, m_position ); +} + +void WindowPositionTracker::connect(ui::Window window) +{ + sync( window ); + window.connect( "configure_event", G_CALLBACK( configure ), this ); +} + +const WindowPosition &WindowPositionTracker::getPosition() const +{ + return m_position; +} + +void WindowPositionTracker::setPosition(const WindowPosition &position) +{ + m_position = position; +} diff --git a/libs/gtkutil/window.h b/libs/gtkutil/window.h index 1a7161e6..2adc3caf 100644 --- a/libs/gtkutil/window.h +++ b/libs/gtkutil/window.h @@ -22,135 +22,88 @@ #if !defined( INCLUDED_GTKUTIL_WINDOW_H ) #define INCLUDED_GTKUTIL_WINDOW_H -#include +#include #include "debugging/debugging.h" #include "generic/callback.h" #include "widget.h" -inline gboolean window_focus_in_clear_focus_widget( GtkWidget* widget, GdkEventKey* event, gpointer data ){ - gtk_window_set_focus( GTK_WINDOW( widget ), NULL ); - return FALSE; -} +gboolean window_focus_in_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data); -inline guint window_connect_focus_in_clear_focus_widget( GtkWindow* window ){ - return g_signal_connect( G_OBJECT( window ), "focus_in_event", G_CALLBACK( window_focus_in_clear_focus_widget ), NULL ); -} +guint window_connect_focus_in_clear_focus_widget(ui::Window window); +unsigned int connect_floating(ui::Window main_window, ui::Window floating); -unsigned int connect_floating( GtkWindow* main_window, GtkWindow* floating ); -GtkWindow* create_floating_window( const char* title, GtkWindow* parent ); -void destroy_floating_window( GtkWindow* window ); +ui::Window create_floating_window(const char *title, ui::Window parent); -GtkWindow* create_persistent_floating_window( const char* title, GtkWindow* main_window ); -gboolean persistent_floating_window_delete( GtkWindow* floating, GdkEvent *event, GtkWindow* main_window ); +void destroy_floating_window(ui::Window window); -void window_remove_minmax( GtkWindow* window ); +ui::Window create_persistent_floating_window(const char *title, ui::Window main_window); -typedef struct _GtkScrolledWindow GtkScrolledWindow; -GtkScrolledWindow* create_scrolled_window( GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, int border = 0 ); +gboolean persistent_floating_window_delete(ui::Window floating, GdkEvent *event, ui::Window main_window); +void window_remove_minmax(ui::Window window); -struct WindowPosition -{ - int x, y, w, h; +ui::ScrolledWindow create_scrolled_window(ui::Policy hscrollbar_policy, ui::Policy vscrollbar_policy, int border = 0); - WindowPosition(){ - } - WindowPosition( int _x, int _y, int _w, int _h ) - : x( _x ), y( _y ), w( _w ), h( _h ){ - } -}; -const WindowPosition c_default_window_pos( 50, 25, 400, 300 ); +struct WindowPosition { + int x, y, w, h; + + WindowPosition() + { + } -inline void window_get_position( GtkWindow* window, WindowPosition& position ){ - ASSERT_MESSAGE( window != 0, "error saving window position" ); + WindowPosition(int _x, int _y, int _w, int _h) + : x(_x), y(_y), w(_w), h(_h) + { + } +}; - gtk_window_get_position( window, &position.x, &position.y ); - gtk_window_get_size( window, &position.w, &position.h ); -} +const WindowPosition c_default_window_pos(50, 25, 400, 300); -inline void window_set_position( GtkWindow* window, const WindowPosition& position ){ - gtk_window_set_gravity( window, GDK_GRAVITY_STATIC ); +void window_get_position(ui::Window window, WindowPosition &position); - GdkScreen* screen = gdk_screen_get_default(); - if ( position.x < 0 - || position.y < 0 - || position.x > gdk_screen_get_width( screen ) - || position.y > gdk_screen_get_height( screen ) ) { - gtk_window_set_position( window, GTK_WIN_POS_CENTER_ON_PARENT ); - } - else - { - gtk_window_move( window, position.x, position.y ); - } +void window_set_position(ui::Window window, const WindowPosition &position); - gtk_window_set_default_size( window, position.w, position.h ); -} +void WindowPosition_Parse(WindowPosition &position, const char *value); -inline void WindowPosition_Parse( WindowPosition& position, const char* value ){ - if ( sscanf( value, "%d %d %d %d", &position.x, &position.y, &position.w, &position.h ) != 4 ) { - position = WindowPosition( c_default_window_pos ); // ensure sane default value for window position - } -} -typedef ReferenceCaller1 WindowPositionImportStringCaller; +typedef ReferenceCaller1 WindowPositionImportStringCaller; -inline void WindowPosition_Write( const WindowPosition& position, const StringImportCallback& importCallback ){ - char buffer[64]; - sprintf( buffer, "%d %d %d %d", position.x, position.y, position.w, position.h ); - importCallback( buffer ); -} -typedef ConstReferenceCaller1 WindowPositionExportStringCaller; +void WindowPosition_Write(const WindowPosition &position, const StringImportCallback &importCallback); +typedef ConstReferenceCaller1 WindowPositionExportStringCaller; -class WindowPositionTracker -{ -WindowPosition m_position; +class WindowPositionTracker { + WindowPosition m_position; -static gboolean configure( GtkWidget* widget, GdkEventConfigure *event, WindowPositionTracker* self ){ - self->m_position = WindowPosition( event->x, event->y, event->width, event->height ); - return FALSE; -} + static gboolean configure(ui::Widget widget, GdkEventConfigure *event, WindowPositionTracker *self); public: -WindowPositionTracker() - : m_position( c_default_window_pos ){ -} + WindowPositionTracker() + : m_position(c_default_window_pos) + { + } -void sync( GtkWindow* window ){ - window_set_position( window, m_position ); -} + void sync(ui::Window window); -void connect( GtkWindow* window ){ - sync( window ); - g_signal_connect( G_OBJECT( window ), "configure_event", G_CALLBACK( configure ), this ); -} + void connect(ui::Window window); -const WindowPosition& getPosition() const { - return m_position; -} + const WindowPosition &getPosition() const; //hack -void setPosition( const WindowPosition& position ){ - m_position = position; -} + void setPosition(const WindowPosition &position); }; -inline void WindowPositionTracker_importString( WindowPositionTracker& self, const char* value ){ - WindowPosition position; - WindowPosition_Parse( position, value ); - self.setPosition( position ); -} -typedef ReferenceCaller1 WindowPositionTrackerImportStringCaller; +void WindowPositionTracker_importString(WindowPositionTracker &self, const char *value); + +typedef ReferenceCaller1 WindowPositionTrackerImportStringCaller; -inline void WindowPositionTracker_exportString( const WindowPositionTracker& self, const StringImportCallback& importer ){ - WindowPosition_Write( self.getPosition(), importer ); -} -typedef ConstReferenceCaller1 WindowPositionTrackerExportStringCaller; +void WindowPositionTracker_exportString(const WindowPositionTracker &self, const StringImportCallback &importer); +typedef ConstReferenceCaller1 WindowPositionTrackerExportStringCaller; #endif diff --git a/libs/gtkutil/xorrectangle.cpp b/libs/gtkutil/xorrectangle.cpp index e4f46c6b..c638e0e2 100644 --- a/libs/gtkutil/xorrectangle.cpp +++ b/libs/gtkutil/xorrectangle.cpp @@ -1,22 +1,50 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. +#include "xorrectangle.h" - This file is part of GtkRadiant. +#include - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +bool XORRectangle::initialised() const +{ + return !!cr; +} - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +void XORRectangle::lazy_init() +{ + if (!initialised()) { + cr = gdk_cairo_create(gtk_widget_get_window(m_widget)); + } +} - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ +void XORRectangle::draw() const +{ + const int x = float_to_integer(m_rectangle.x); + const int y = float_to_integer(m_rectangle.y); + const int w = float_to_integer(m_rectangle.w); + const int h = float_to_integer(m_rectangle.h); + GtkAllocation allocation; + gtk_widget_get_allocation(m_widget, &allocation); + cairo_rectangle(cr, x, -(h) - (y - allocation.height), w, h); + cairo_set_source_rgb(cr, 1, 1, 1); + cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); + cairo_stroke(cr); +} -#include "xorrectangle.h" +XORRectangle::XORRectangle(ui::GLArea widget) : m_widget(widget), cr(0) +{ +} + +XORRectangle::~XORRectangle() +{ + if (initialised()) { + cairo_destroy(cr); + } +} + +void XORRectangle::set(rectangle_t rectangle) +{ + if (gtk_widget_get_realized(m_widget)) { + lazy_init(); + draw(); + m_rectangle = rectangle; + draw(); + } +} diff --git a/libs/gtkutil/xorrectangle.h b/libs/gtkutil/xorrectangle.h index 6c4d64fc..2341f1f0 100644 --- a/libs/gtkutil/xorrectangle.h +++ b/libs/gtkutil/xorrectangle.h @@ -22,7 +22,8 @@ #if !defined ( INCLUDED_XORRECTANGLE_H ) #define INCLUDED_XORRECTANGLE_H -#include +#include +#include #include "math/vector.h" class rectangle_t @@ -63,50 +64,17 @@ class XORRectangle rectangle_t m_rectangle; -GtkWidget* m_widget; -GdkGC* m_gc; +ui::GLArea m_widget; +cairo_t *cr; -bool initialised() const { - return m_gc != 0; -} -void lazy_init(){ - if ( !initialised() ) { - m_gc = gdk_gc_new( m_widget->window ); - - GdkColor color = { 0, 0xffff, 0xffff, 0xffff, }; - GdkColormap* colormap = gdk_window_get_colormap( m_widget->window ); - gdk_colormap_alloc_color( colormap, &color, FALSE, TRUE ); - gdk_gc_copy( m_gc, m_widget->style->white_gc ); - gdk_gc_set_foreground( m_gc, &color ); - gdk_gc_set_background( m_gc, &color ); - - gdk_gc_set_function( m_gc, GDK_INVERT ); - } -} -void draw() const { - const int x = float_to_integer( m_rectangle.x ); - const int y = float_to_integer( m_rectangle.y ); - const int w = float_to_integer( m_rectangle.w ); - const int h = float_to_integer( m_rectangle.h ); - gdk_draw_rectangle( m_widget->window, m_gc, FALSE, x, -( h ) - ( y - m_widget->allocation.height ), w, h ); -} +bool initialised() const; +void lazy_init(); +void draw() const; public: -XORRectangle( GtkWidget* widget ) : m_widget( widget ), m_gc( 0 ){ -} -~XORRectangle(){ - if ( initialised() ) { - gdk_gc_unref( m_gc ); - } -} -void set( rectangle_t rectangle ){ - if ( GTK_WIDGET_REALIZED( m_widget ) ) { - lazy_init(); - draw(); - m_rectangle = rectangle; - draw(); - } -} +XORRectangle( ui::GLArea widget ); +~XORRectangle(); +void set( rectangle_t rectangle ); }; diff --git a/libs/imagelib.cpp b/libs/imagelib.cpp deleted file mode 100644 index 08e2d27e..00000000 --- a/libs/imagelib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "imagelib.h" diff --git a/libs/instancelib.cpp b/libs/instancelib.cpp deleted file mode 100644 index 52dfc8d4..00000000 --- a/libs/instancelib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "instancelib.h" diff --git a/libs/maplib.cpp b/libs/maplib.cpp deleted file mode 100644 index 7487a68a..00000000 --- a/libs/maplib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "maplib.h" diff --git a/libs/math/CMakeLists.txt b/libs/math/CMakeLists.txt index 4a5b4bdf..6cfedbef 100644 --- a/libs/math/CMakeLists.txt +++ b/libs/math/CMakeLists.txt @@ -1,11 +1,12 @@ add_library(math - aabb.cpp aabb.h - curve.cpp curve.h - frustum.cpp frustum.h - line.cpp line.h - matrix.cpp matrix.h - pi.cpp pi.h - plane.cpp plane.h - quaternion.cpp quaternion.h - vector.cpp vector.h + _.cpp + aabb.h + curve.h + frustum.h + line.h + matrix.h + pi.h + plane.h + quaternion.h + vector.h ) diff --git a/libs/math/_.cpp b/libs/math/_.cpp new file mode 100644 index 00000000..e69de29b diff --git a/libs/math/aabb.cpp b/libs/math/aabb.cpp deleted file mode 100644 index ad4ae00c..00000000 --- a/libs/math/aabb.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "aabb.h" diff --git a/libs/math/curve.cpp b/libs/math/curve.cpp deleted file mode 100644 index e38d2a11..00000000 --- a/libs/math/curve.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "curve.h" diff --git a/libs/math/frustum.cpp b/libs/math/frustum.cpp deleted file mode 100644 index b977549d..00000000 --- a/libs/math/frustum.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "frustum.h" diff --git a/libs/math/line.cpp b/libs/math/line.cpp deleted file mode 100644 index 0f4eb811..00000000 --- a/libs/math/line.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "line.h" diff --git a/libs/math/matrix.cpp b/libs/math/matrix.cpp deleted file mode 100644 index 6ed9a7e7..00000000 --- a/libs/math/matrix.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "matrix.h" diff --git a/libs/math/pi.cpp b/libs/math/pi.cpp deleted file mode 100644 index dd546531..00000000 --- a/libs/math/pi.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "pi.h" diff --git a/libs/math/plane.cpp b/libs/math/plane.cpp deleted file mode 100644 index 7b90b5ec..00000000 --- a/libs/math/plane.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "plane.h" diff --git a/libs/math/quaternion.cpp b/libs/math/quaternion.cpp deleted file mode 100644 index 5cef646e..00000000 --- a/libs/math/quaternion.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "quaternion.h" diff --git a/libs/math/vector.cpp b/libs/math/vector.cpp deleted file mode 100644 index 4893324e..00000000 --- a/libs/math/vector.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "vector.h" diff --git a/libs/moduleobservers.cpp b/libs/moduleobservers.cpp deleted file mode 100644 index 56150f91..00000000 --- a/libs/moduleobservers.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "moduleobservers.h" diff --git a/libs/modulesystem/CMakeLists.txt b/libs/modulesystem/CMakeLists.txt index 764d3eb4..d27aa633 100644 --- a/libs/modulesystem/CMakeLists.txt +++ b/libs/modulesystem/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(modulesystem - moduleregistry.cpp moduleregistry.h - modulesmap.cpp modulesmap.h + moduleregistry.h + modulesmap.h singletonmodule.cpp singletonmodule.h ) diff --git a/libs/modulesystem/moduleregistry.cpp b/libs/modulesystem/moduleregistry.cpp deleted file mode 100644 index 1e5bba6d..00000000 --- a/libs/modulesystem/moduleregistry.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "moduleregistry.h" diff --git a/libs/modulesystem/moduleregistry.h b/libs/modulesystem/moduleregistry.h index abea5a05..7cd84f97 100644 --- a/libs/modulesystem/moduleregistry.h +++ b/libs/modulesystem/moduleregistry.h @@ -28,23 +28,23 @@ class ModuleRegisterable { public: -virtual void selfRegister() = 0; + virtual void selfRegister() = 0; }; class ModuleRegistryList { -typedef std::list RegisterableModules; -RegisterableModules m_modules; + typedef std::list RegisterableModules; + RegisterableModules m_modules; public: -void addModule( ModuleRegisterable& module ){ - m_modules.push_back( &module ); -} -void registerModules() const { - for ( RegisterableModules::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i ) - { - ( *i )->selfRegister(); + void addModule( ModuleRegisterable& module ){ + m_modules.push_back( &module ); + } + void registerModules() const { + for ( RegisterableModules::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i ) + { + ( *i )->selfRegister(); + } } -} }; typedef SmartStatic StaticModuleRegistryList; @@ -53,9 +53,9 @@ typedef SmartStatic StaticModuleRegistryList; class StaticRegisterModule : public StaticModuleRegistryList { public: -StaticRegisterModule( ModuleRegisterable& module ){ - StaticModuleRegistryList::instance().addModule( module ); -} + StaticRegisterModule( ModuleRegisterable& module ){ + StaticModuleRegistryList::instance().addModule( module ); + } }; diff --git a/libs/modulesystem/modulesmap.cpp b/libs/modulesystem/modulesmap.cpp deleted file mode 100644 index a80f2135..00000000 --- a/libs/modulesystem/modulesmap.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "modulesmap.h" diff --git a/libs/modulesystem/singletonmodule.h b/libs/modulesystem/singletonmodule.h index 6dd9c52a..8dcd88de 100644 --- a/libs/modulesystem/singletonmodule.h +++ b/libs/modulesystem/singletonmodule.h @@ -88,7 +88,7 @@ explicit SingletonModule( const APIConstructor& constructor ) void selfRegister(){ globalModuleServer().registerModule( typename Type::Name(), typename Type::Version(), APIConstructor::getName(), *this ); -} + } Dependencies& getDependencies(){ return *m_dependencies; diff --git a/libs/os/CMakeLists.txt b/libs/os/CMakeLists.txt index c6a4eb4c..437b506c 100644 --- a/libs/os/CMakeLists.txt +++ b/libs/os/CMakeLists.txt @@ -1,7 +1,8 @@ add_library(os - dir.cpp dir.h - file.cpp file.h - path.cpp path.h + _.cpp + dir.h + file.h + path.h ) find_package(GLIB REQUIRED) diff --git a/libs/os/_.cpp b/libs/os/_.cpp new file mode 100644 index 00000000..e69de29b diff --git a/libs/os/dir.cpp b/libs/os/dir.cpp deleted file mode 100644 index 8ab81296..00000000 --- a/libs/os/dir.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "dir.h" diff --git a/libs/os/file.cpp b/libs/os/file.cpp deleted file mode 100644 index 1855b5d1..00000000 --- a/libs/os/file.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "file.h" diff --git a/libs/os/path.cpp b/libs/os/path.cpp deleted file mode 100644 index b62c219e..00000000 --- a/libs/os/path.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "path.h" diff --git a/libs/pivot.cpp b/libs/pivot.cpp deleted file mode 100644 index adc9ef21..00000000 --- a/libs/pivot.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "pivot.h" diff --git a/libs/render.cpp b/libs/render.cpp deleted file mode 100644 index be1c49a6..00000000 --- a/libs/render.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "render.h" diff --git a/libs/scenelib.cpp b/libs/scenelib.cpp deleted file mode 100644 index a1754d08..00000000 --- a/libs/scenelib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "scenelib.h" diff --git a/libs/script/CMakeLists.txt b/libs/script/CMakeLists.txt index ba2b00ec..6e49527d 100644 --- a/libs/script/CMakeLists.txt +++ b/libs/script/CMakeLists.txt @@ -1,4 +1,5 @@ add_library(script - scripttokeniser.cpp scripttokeniser.h - scripttokenwriter.cpp scripttokenwriter.h + _.cpp + scripttokeniser.h + scripttokenwriter.h ) diff --git a/libs/script/_.cpp b/libs/script/_.cpp new file mode 100644 index 00000000..e69de29b diff --git a/libs/script/scripttokeniser.cpp b/libs/script/scripttokeniser.cpp deleted file mode 100644 index 1b4ee4cb..00000000 --- a/libs/script/scripttokeniser.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "scripttokeniser.h" diff --git a/libs/script/scripttokenwriter.cpp b/libs/script/scripttokenwriter.cpp deleted file mode 100644 index 753aab7a..00000000 --- a/libs/script/scripttokenwriter.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "scripttokenwriter.h" diff --git a/libs/selectionlib.cpp b/libs/selectionlib.cpp deleted file mode 100644 index cc85fe65..00000000 --- a/libs/selectionlib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "selectionlib.h" diff --git a/libs/shaderlib.cpp b/libs/shaderlib.cpp deleted file mode 100644 index 454bd4f0..00000000 --- a/libs/shaderlib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "shaderlib.h" diff --git a/libs/signal/CMakeLists.txt b/libs/signal/CMakeLists.txt index 4b7cc94f..499a4838 100644 --- a/libs/signal/CMakeLists.txt +++ b/libs/signal/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(signal - isignal.cpp isignal.h + isignal.h signal.cpp signal.h - signalfwd.cpp signalfwd.h + signalfwd.h ) diff --git a/libs/signal/isignal.cpp b/libs/signal/isignal.cpp deleted file mode 100644 index 5eafd5e2..00000000 --- a/libs/signal/isignal.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "isignal.h" diff --git a/libs/signal/signalfwd.cpp b/libs/signal/signalfwd.cpp deleted file mode 100644 index fedf5157..00000000 --- a/libs/signal/signalfwd.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "signalfwd.h" diff --git a/libs/str.cpp b/libs/str.cpp deleted file mode 100644 index c63ef945..00000000 --- a/libs/str.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (c) 2001, Loki software, inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this list - of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - Neither the name of Loki software nor the names of its contributors may be used - to endorse or promote products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "str.h" diff --git a/libs/stream/CMakeLists.txt b/libs/stream/CMakeLists.txt index 9f8fb265..6ce79395 100644 --- a/libs/stream/CMakeLists.txt +++ b/libs/stream/CMakeLists.txt @@ -1,7 +1,8 @@ add_library(stream - filestream.cpp filestream.h - memstream.cpp memstream.h - stringstream.cpp stringstream.h - textfilestream.cpp textfilestream.h - textstream.cpp textstream.h + _.cpp + filestream.h + memstream.h + stringstream.h + textfilestream.h + textstream.h ) diff --git a/libs/stream/_.cpp b/libs/stream/_.cpp new file mode 100644 index 00000000..e69de29b diff --git a/libs/stream/filestream.cpp b/libs/stream/filestream.cpp deleted file mode 100644 index 33f12062..00000000 --- a/libs/stream/filestream.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "filestream.h" diff --git a/libs/stream/memstream.cpp b/libs/stream/memstream.cpp deleted file mode 100644 index c7c8d1b6..00000000 --- a/libs/stream/memstream.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "memstream.h" diff --git a/libs/stream/stringstream.cpp b/libs/stream/stringstream.cpp deleted file mode 100644 index 8e9da6e8..00000000 --- a/libs/stream/stringstream.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "stringstream.h" diff --git a/libs/stream/textfilestream.cpp b/libs/stream/textfilestream.cpp deleted file mode 100644 index e1024e47..00000000 --- a/libs/stream/textfilestream.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "textfilestream.h" diff --git a/libs/stream/textstream.cpp b/libs/stream/textstream.cpp deleted file mode 100644 index cfbdedd8..00000000 --- a/libs/stream/textstream.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "textstream.h" diff --git a/libs/string/CMakeLists.txt b/libs/string/CMakeLists.txt index d5e851ea..4b0720a5 100644 --- a/libs/string/CMakeLists.txt +++ b/libs/string/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(string pooledstring.cpp pooledstring.h - string.cpp string.h - stringfwd.cpp stringfwd.h + string.h + stringfwd.h ) diff --git a/libs/string/string.cpp b/libs/string/string.cpp deleted file mode 100644 index 59043014..00000000 --- a/libs/string/string.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "string.h" - -void TestString(){ - CopiedString bleh( "bleh" ); - SmartString blah( "blah" ); -} \ No newline at end of file diff --git a/libs/string/stringfwd.cpp b/libs/string/stringfwd.cpp deleted file mode 100644 index add6eeee..00000000 --- a/libs/string/stringfwd.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "stringfwd.h" diff --git a/libs/stringio.cpp b/libs/stringio.cpp deleted file mode 100644 index a6e741f0..00000000 --- a/libs/stringio.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "stringio.h" diff --git a/libs/texturelib.cpp b/libs/texturelib.cpp deleted file mode 100644 index 00bde65a..00000000 --- a/libs/texturelib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "texturelib.h" diff --git a/libs/transformlib.cpp b/libs/transformlib.cpp deleted file mode 100644 index ec82140c..00000000 --- a/libs/transformlib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "transformlib.h" diff --git a/libs/traverselib.cpp b/libs/traverselib.cpp deleted file mode 100644 index 57e1dfbe..00000000 --- a/libs/traverselib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "traverselib.h" diff --git a/libs/typesystem.cpp b/libs/typesystem.cpp deleted file mode 100644 index 755f05e0..00000000 --- a/libs/typesystem.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "typesystem.h" diff --git a/libs/uilib/CMakeLists.txt b/libs/uilib/CMakeLists.txt index f10ee3ad..080376b1 100644 --- a/libs/uilib/CMakeLists.txt +++ b/libs/uilib/CMakeLists.txt @@ -2,9 +2,17 @@ add_library(uilib uilib.cpp ) -find_package(GTK2 REQUIRED) -target_include_directories(uilib PUBLIC ${${GTK_NS}_INCLUDE_DIRS}) -target_link_libraries(uilib PUBLIC ${${GTK_NS}_LIBRARIES}) +find_package(GLIB REQUIRED) +target_include_directories(uilib PUBLIC ${GLIB_INCLUDE_DIRS}) +target_link_libraries(uilib PUBLIC ${GLIB_LIBRARIES}) + +find_package(Pango REQUIRED) +target_include_directories(uilib PUBLIC ${Pango_INCLUDE_DIRS} ${PangoFT2_INCLUDE_DIRS}) +target_link_libraries(uilib PUBLIC ${Pango_LIBRARIES} ${PangoFT2_LIBRARIES}) + +find_package(GTK${GTK_TARGET} REQUIRED) +target_include_directories(uilib PUBLIC ${GTK${GTK_TARGET}_INCLUDE_DIRS}) +target_link_libraries(uilib PUBLIC ${GTK${GTK_TARGET}_LIBRARIES}) target_include_directories(uilib PUBLIC gtkutil) target_link_libraries(uilib PUBLIC gtkutil) diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index e69de29b..f2517224 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -0,0 +1,350 @@ +#include "uilib.h" + +#include + +#include + +#include "gtkutil/dialog.h" +#include "gtkutil/filechooser.h" +#include "gtkutil/messagebox.h" +#include "gtkutil/window.h" + +namespace ui { + + bool init(int *argc, char **argv[], char const *parameter_string, char const **error) + { + gtk_disable_setlocale(); + static GOptionEntry entries[] = {{NULL}}; + char const *translation_domain = NULL; + GError *gerror = NULL; + bool ret = gtk_init_with_args(argc, argv, parameter_string, entries, translation_domain, &gerror) != 0; + if (!ret) { + *error = gerror->message; + } + return ret; + } + + void main() + { + gtk_main(); + } + + void process() + { + while (gtk_events_pending()) { + gtk_main_iteration(); + } + } + + Widget root; + +#define IMPL(T, F) template<> _IMPL(T, F) +#define _IMPL(T, F) struct verify { using self = T; static self test(self it) { return self(F(it)); } } + + template + struct verify; + + template _IMPL(T,); + +#define this (verify::test(*static_cast(this))) + + IMPL(Editable, GTK_EDITABLE); + + void IEditable::editable(bool value) + { + gtk_editable_set_editable(GTK_EDITABLE(this), value); + } + + IMPL(Widget, GTK_WIDGET); + + Widget::Widget() : Widget(nullptr) + {} + + alert_response IWidget::alert(std::string text, std::string title, alert_type type, alert_icon icon) + { + auto ret = gtk_MessageBox(this, text.c_str(), + title.c_str(), + type == alert_type::OK ? eMB_OK : + type == alert_type::OKCANCEL ? eMB_OKCANCEL : + type == alert_type::YESNO ? eMB_YESNO : + type == alert_type::YESNOCANCEL ? eMB_YESNOCANCEL : + type == alert_type::NOYES ? eMB_NOYES : + eMB_OK, + icon == alert_icon::Default ? eMB_ICONDEFAULT : + icon == alert_icon::Error ? eMB_ICONERROR : + icon == alert_icon::Warning ? eMB_ICONWARNING : + icon == alert_icon::Question ? eMB_ICONQUESTION : + icon == alert_icon::Asterisk ? eMB_ICONASTERISK : + eMB_ICONDEFAULT + ); + return + ret == eIDOK ? alert_response::OK : + ret == eIDCANCEL ? alert_response::CANCEL : + ret == eIDYES ? alert_response::YES : + ret == eIDNO ? alert_response::NO : + alert_response::OK; + } + + const char * + IWidget::file_dialog(bool open, const char *title, const char *path, const char *pattern, bool want_load, + bool want_import, bool want_save) + { + return ::file_dialog(this, open, title, path, pattern, want_load, want_import, want_save); + } + + void IWidget::show() + { + gtk_widget_show(this); + } + + IMPL(Container, GTK_CONTAINER); + + void IContainer::add(Widget widget) + { + gtk_container_add(this, widget); + } + + void IContainer::remove(Widget widget) + { + gtk_container_remove(this, widget); + } + + IMPL(Bin, GTK_BIN); + + IMPL(Window, GTK_WINDOW); + + Window::Window(window_type type) : Window(GTK_WINDOW(gtk_window_new( + type == window_type::TOP ? GTK_WINDOW_TOPLEVEL : + type == window_type::POPUP ? GTK_WINDOW_POPUP : + GTK_WINDOW_TOPLEVEL + ))) + {} + + Window IWindow::create_dialog_window(const char *title, void func(), void *data, int default_w, int default_h) + { + return Window(::create_dialog_window(this, title, func, data, default_w, default_h)); + } + + Window IWindow::create_modal_dialog_window(const char *title, ModalDialog &dialog, int default_w, int default_h) + { + return Window(::create_modal_dialog_window(this, title, dialog, default_w, default_h)); + } + + Window IWindow::create_floating_window(const char *title) + { + return Window(::create_floating_window(title, this)); + } + + std::uint64_t IWindow::on_key_press(bool (*f)(Widget widget, _GdkEventKey *event, void *extra), void *extra) + { + using f_t = decltype(f); + struct user_data { + f_t f; + void *extra; + } *pass = new user_data{f, extra}; + auto dtor = [](user_data *data, GClosure *) { + delete data; + }; + auto func = [](_GtkWidget *widget, GdkEventKey *event, user_data *args) -> bool { + return args->f(Widget(widget), event, args->extra); + }; + auto clos = g_cclosure_new(G_CALLBACK(+func), pass, reinterpret_cast(+dtor)); + return g_signal_connect_closure(G_OBJECT(this), "key-press-event", clos, false); + } + + void IWindow::add_accel_group(AccelGroup group) + { + gtk_window_add_accel_group(this, group); + } + + IMPL(Alignment, GTK_ALIGNMENT); + + Alignment::Alignment(float xalign, float yalign, float xscale, float yscale) + : Alignment(GTK_ALIGNMENT(gtk_alignment_new(xalign, yalign, xscale, yscale))) + {} + + IMPL(Frame, GTK_FRAME); + + Frame::Frame(const char *label) : Frame(GTK_FRAME(gtk_frame_new(label))) + {} + + IMPL(Button, GTK_BUTTON); + + Button::Button() : Button(GTK_BUTTON(gtk_button_new())) + {} + + Button::Button(const char *label) : Button(GTK_BUTTON(gtk_button_new_with_label(label))) + {} + + IMPL(ToggleButton, GTK_TOGGLE_BUTTON); + + bool IToggleButton::active() + { + return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(this)) != 0; + } + + IMPL(CheckButton, GTK_CHECK_BUTTON); + + CheckButton::CheckButton(const char *label) : CheckButton(GTK_CHECK_BUTTON(gtk_check_button_new_with_label(label))) + {} + + IMPL(MenuItem, GTK_MENU_ITEM); + + MenuItem::MenuItem() : MenuItem(GTK_MENU_ITEM(gtk_menu_item_new())) + {} + + MenuItem::MenuItem(const char *label, bool mnemonic) : MenuItem( + GTK_MENU_ITEM((mnemonic ? gtk_menu_item_new_with_mnemonic : gtk_menu_item_new_with_label)(label))) + {} + + IMPL(TearoffMenuItem, GTK_TEAROFF_MENU_ITEM); + + TearoffMenuItem::TearoffMenuItem() : TearoffMenuItem(GTK_TEAROFF_MENU_ITEM(gtk_tearoff_menu_item_new())) + {} + + IMPL(ComboBoxText, GTK_COMBO_BOX_TEXT); + + ComboBoxText::ComboBoxText() : ComboBoxText(GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new())) + {} + + IMPL(ScrolledWindow, GTK_SCROLLED_WINDOW); + + ScrolledWindow::ScrolledWindow() : ScrolledWindow(GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(nullptr, nullptr))) + {} + + IMPL(VBox, GTK_VBOX); + + VBox::VBox(bool homogenous, int spacing) : VBox(GTK_VBOX(gtk_vbox_new(homogenous, spacing))) + {} + + IMPL(HBox, GTK_HBOX); + + HBox::HBox(bool homogenous, int spacing) : HBox(GTK_HBOX(gtk_hbox_new(homogenous, spacing))) + {} + + IMPL(HPaned, GTK_HPANED); + + HPaned::HPaned() : HPaned(GTK_HPANED(gtk_hpaned_new())) + {} + + IMPL(VPaned, GTK_VPANED); + + VPaned::VPaned() : VPaned(GTK_VPANED(gtk_vpaned_new())) + {} + + IMPL(Menu, GTK_MENU); + + Menu::Menu() : Menu(GTK_MENU(gtk_menu_new())) + {} + + IMPL(Table, GTK_TABLE); + + Table::Table(std::size_t rows, std::size_t columns, bool homogenous) : Table( + GTK_TABLE(gtk_table_new(rows, columns, homogenous)) + ) + {} + + IMPL(TextView, GTK_TEXT_VIEW); + + TextView::TextView() : TextView(GTK_TEXT_VIEW(gtk_text_view_new())) + {} + + TreeView::TreeView() : TreeView(GTK_TREE_VIEW(gtk_tree_view_new())) + {} + + TreeView::TreeView(TreeModel model) : TreeView(GTK_TREE_VIEW(gtk_tree_view_new_with_model(model))) + {} + + IMPL(Label, GTK_LABEL); + + Label::Label(const char *label) : Label(GTK_LABEL(gtk_label_new(label))) + {} + + IMPL(Image, GTK_IMAGE); + + Image::Image() : Image(GTK_IMAGE(gtk_image_new())) + {} + + IMPL(Entry, GTK_ENTRY); + + Entry::Entry() : Entry(GTK_ENTRY(gtk_entry_new())) + {} + + Entry::Entry(std::size_t max_length) : Entry() + { + gtk_entry_set_max_length(this, static_cast(max_length)); + } + + IMPL(SpinButton, GTK_SPIN_BUTTON); + + SpinButton::SpinButton(Adjustment adjustment, double climb_rate, std::size_t digits) : SpinButton( + GTK_SPIN_BUTTON(gtk_spin_button_new(adjustment, climb_rate, digits))) + {} + + IMPL(HScale, GTK_HSCALE); + + HScale::HScale(Adjustment adjustment) : HScale(GTK_HSCALE(gtk_hscale_new(adjustment))) + {} + + HScale::HScale(double min, double max, double step) : HScale(GTK_HSCALE(gtk_hscale_new_with_range(min, max, step))) + {} + + IMPL(Adjustment, GTK_ADJUSTMENT); + + Adjustment::Adjustment(double value, + double lower, double upper, + double step_increment, double page_increment, + double page_size) + : Adjustment( + GTK_ADJUSTMENT(gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size))) + {} + + IMPL(CellRendererText, GTK_CELL_RENDERER_TEXT); + + CellRendererText::CellRendererText() : CellRendererText(GTK_CELL_RENDERER_TEXT(gtk_cell_renderer_text_new())) + {} + + IMPL(TreeViewColumn, GTK_TREE_VIEW_COLUMN); + + TreeViewColumn::TreeViewColumn(const char *title, CellRenderer renderer, + std::initializer_list attributes) + : TreeViewColumn(gtk_tree_view_column_new_with_attributes(title, renderer, nullptr)) + { + for (auto &it : attributes) { + gtk_tree_view_column_add_attribute(this, renderer, it.attribute, it.column); + } + }; + + IMPL(AccelGroup, GTK_ACCEL_GROUP); + + AccelGroup::AccelGroup() : AccelGroup(GTK_ACCEL_GROUP(gtk_accel_group_new())) + {} + + IMPL(ListStore, GTK_LIST_STORE); + + void IListStore::clear() + { + gtk_list_store_clear(this); + } + + // IMPL(TreePath, GTK_TREE_PATH); + + TreePath::TreePath() : TreePath(gtk_tree_path_new()) + {} + + TreePath::TreePath(const char *path) : TreePath(gtk_tree_path_new_from_string(path)) + {} + + // Custom + + guint IGLArea::on_render(GCallback pFunction, void *data) + { +#if GTK_TARGET == 3 + return this.connect("render", pFunction, data); +#endif +#if GTK_TARGET == 2 + return this.connect("expose_event", pFunction, data); +#endif + }; + +} diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h new file mode 100644 index 00000000..c6483515 --- /dev/null +++ b/libs/uilib/uilib.h @@ -0,0 +1,589 @@ +#ifndef INCLUDED_UILIB_H +#define INCLUDED_UILIB_H + +#include +#include + +struct _GdkEventKey; +struct _GtkAccelGroup; +struct _GtkAdjustment; +struct _GtkAlignment; +struct _GtkBin; +struct _GtkBox; +struct _GtkButton; +struct _GtkCellEditable; +struct _GtkCellRenderer; +struct _GtkCellRendererText; +struct _GtkCheckButton; +struct _GtkCheckMenuItem; +struct _GtkComboBox; +struct _GtkComboBoxText; +struct _GtkContainer; +struct _GtkDialog; +struct _GtkEditable; +struct _GtkEntry; +struct _GtkEntryCompletion; +struct _GtkFrame; +struct _GtkHBox; +struct _GtkHPaned; +struct _GtkHScale; +struct _GtkImage; +struct _GtkItem; +struct _GtkLabel; +struct _GtkListStore; +struct _GtkMenu; +struct _GtkMenuBar; +struct _GtkMenuItem; +struct _GtkMenuShell; +struct _GtkMisc; +struct _GtkObject; +struct _GtkPaned; +struct _GtkRadioButton; +struct _GtkRadioMenuItem; +struct _GtkRadioToolButton; +struct _GtkRange; +struct _GtkScale; +struct _GtkScrolledWindow; +struct _GtkSpinButton; +struct _GtkTable; +struct _GtkTearoffMenuItem; +struct _GtkTextView; +struct _GtkToggleButton; +struct _GtkToggleToolButton; +struct _GtkToolbar; +struct _GtkToolButton; +struct _GtkToolItem; +struct _GtkTreeModel; +struct _GtkTreePath; +struct _GtkTreeSelection; +struct _GtkTreeView; +struct _GtkTreeViewColumn; +struct _GtkVBox; +struct _GtkVPaned; +struct _GtkWidget; +struct _GtkWindow; +struct _GTypeInstance; + +#if GTK_TARGET == 3 +struct _GtkGLArea; +#endif + +#if GTK_TARGET == 2 +using _GtkGLArea = struct _GtkDrawingArea; +#endif + +struct ModalDialog; + +namespace ui { + + bool init(int *argc, char **argv[], char const *parameter_string, char const **error); + + void main(); + + void process(); + + extern class Widget root; + + enum class alert_type { + OK, + OKCANCEL, + YESNO, + YESNOCANCEL, + NOYES, + }; + + enum class alert_icon { + Default, + Error, + Warning, + Question, + Asterisk, + }; + + enum class alert_response { + OK, + CANCEL, + YES, + NO, + }; + + enum class window_type { + TOP, + POPUP + }; + + enum class Shadow { + NONE, + IN, + OUT, + ETCHED_IN, + ETCHED_OUT + }; + + enum class Policy { + ALWAYS, + AUTOMATIC, + NEVER + }; + + namespace details { + + enum class Convert { + Implicit, Explicit + }; + + template + struct Convertible; + + template + struct Convertible { + operator T() const + { return reinterpret_cast(static_cast(this)->_handle); } + }; + + template + struct Convertible { + explicit operator T() const + { return reinterpret_cast(static_cast(this)->_handle); } + }; + + template + struct All : T ... { + All() + {}; + }; + + template + struct Mixin; + template + struct Mixin { + using type = All; + }; + template + struct Mixin { + using type = All; + }; + } + + extern struct Null {} null; + + class Object : + public details::Convertible, + public details::Convertible { + public: + using self = Object *; + using native = _GtkObject *; + native _handle; + + Object(native h) : _handle(h) + {} + + explicit operator bool() const + { return _handle != nullptr; } + + explicit operator void *() const + { return _handle; } + + void unref() + { g_object_unref(_handle); } + + template + gulong connect(char const *detailed_signal, Lambda &&c_handler, void *data); + + template + gulong connect(char const *detailed_signal, Lambda &&c_handler, Object data); + }; + static_assert(sizeof(Object) == sizeof(Object::native), "object slicing"); + +#define WRAP(name, super, T, interfaces, ctors, methods) \ + class name; \ + class I##name : public details::Convertible { \ + public: \ + using self = name *; \ + methods \ + }; \ + class name : public super, public I##name, public details::Mixin::type { \ + public: \ + using self = name *; \ + using native = T *; \ + explicit name(native h) : super(reinterpret_cast(h)) {} \ + explicit name(Null n) : name((native) nullptr) {} \ + static name from(void *ptr) { return name((native) ptr); } \ + ctors \ + }; \ + inline bool operator<(name self, name other) { return self._handle < other._handle; } \ + static_assert(sizeof(name) == sizeof(super), "object slicing") + + // https://developer.gnome.org/gtk2/stable/ch01.html + + // GInterface + + WRAP(CellEditable, Object, _GtkCellEditable, (), + , + ); + + WRAP(Editable, Object, _GtkEditable, (), + Editable(); + , + void editable(bool value); + ); + + WRAP(TreeModel, Object, _GtkTreeModel, (), + , + ); + + // GObject + + WRAP(Widget, Object, _GtkWidget, (), + Widget(); + , + alert_response alert( + std::string text, + std::string title = "NetRadiant", + alert_type type = alert_type::OK, + alert_icon icon = alert_icon::Default + ); + const char *file_dialog( + bool open, + const char *title, + const char *path = nullptr, + const char *pattern = nullptr, + bool want_load = false, + bool want_import = false, + bool want_save = false + ); + void show(); + ); + + WRAP(Container, Widget, _GtkContainer, (), + , + void add(Widget widget); + + void remove(Widget widget); + + template + void foreach(Lambda &&lambda); + ); + + WRAP(Bin, Container, _GtkBin, (), + , + ); + + class AccelGroup; + WRAP(Window, Bin, _GtkWindow, (), + Window(window_type type); + , + Window create_dialog_window( + const char *title, + void func(), + void *data, + int default_w = -1, + int default_h = -1 + ); + + Window create_modal_dialog_window( + const char *title, + ModalDialog &dialog, + int default_w = -1, + int default_h = -1 + ); + + Window create_floating_window(const char *title); + + std::uint64_t on_key_press( + bool (*f)(Widget widget, _GdkEventKey *event, void *extra), + void *extra = nullptr + ); + + void add_accel_group(AccelGroup group); + ); + + WRAP(Dialog, Window, _GtkDialog, (), + , + ); + + WRAP(Alignment, Bin, _GtkAlignment, (), + Alignment(float xalign, float yalign, float xscale, float yscale); + , + ); + + WRAP(Frame, Bin, _GtkFrame, (), + Frame(const char *label = nullptr); + , + ); + + WRAP(Button, Bin, _GtkButton, (), + Button(); + Button(const char *label); + , + ); + + WRAP(ToggleButton, Button, _GtkToggleButton, (), + , + bool active(); + ); + + WRAP(CheckButton, ToggleButton, _GtkCheckButton, (), + CheckButton(const char *label); + , + ); + + WRAP(RadioButton, CheckButton, _GtkRadioButton, (), + , + ); + + WRAP(Item, Bin, _GtkItem, (), + , + ); + + WRAP(MenuItem, Item, _GtkMenuItem, (), + MenuItem(); + MenuItem(const char *label, bool mnemonic = false); + , + ); + + WRAP(CheckMenuItem, MenuItem, _GtkCheckMenuItem, (), + , + ); + + WRAP(RadioMenuItem, CheckMenuItem, _GtkRadioMenuItem, (), + , + ); + + WRAP(TearoffMenuItem, MenuItem, _GtkTearoffMenuItem, (), + TearoffMenuItem(); + , + ); + + WRAP(ComboBox, Bin, _GtkComboBox, (), + , + ); + + WRAP(ComboBoxText, ComboBox, _GtkComboBoxText, (), + ComboBoxText(); + , + ); + + WRAP(ToolItem, Bin, _GtkToolItem, (), + , + ); + + WRAP(ToolButton, ToolItem, _GtkToolButton, (), + , + ); + + WRAP(ToggleToolButton, ToolButton, _GtkToggleToolButton, (), + , + ); + + WRAP(RadioToolButton, ToggleToolButton, _GtkRadioToolButton, (), + , + ); + + WRAP(ScrolledWindow, Bin, _GtkScrolledWindow, (), + ScrolledWindow(); + , + ); + + WRAP(Box, Container, _GtkBox, (), + , + ); + + WRAP(VBox, Box, _GtkVBox, (), + VBox(bool homogenous, int spacing); + , + ); + + WRAP(HBox, Box, _GtkHBox, (), + HBox(bool homogenous, int spacing); + , + ); + + WRAP(Paned, Container, _GtkPaned, (), + , + ); + + WRAP(HPaned, Paned, _GtkHPaned, (), + HPaned(); + , + ); + + WRAP(VPaned, Paned, _GtkVPaned, (), + VPaned(); + , + ); + + WRAP(MenuShell, Container, _GtkMenuShell, (), + , + ); + + WRAP(MenuBar, MenuShell, _GtkMenuBar, (), + , + ); + + WRAP(Menu, MenuShell, _GtkMenu, (), + Menu(); + , + ); + + WRAP(Table, Container, _GtkTable, (), + Table(std::size_t rows, std::size_t columns, bool homogenous); + , + ); + + WRAP(TextView, Container, _GtkTextView, (), + TextView(); + , + ); + + WRAP(Toolbar, Container, _GtkToolbar, (), + , + ); + + class TreeModel; + WRAP(TreeView, Widget, _GtkTreeView, (), + TreeView(); + TreeView(TreeModel model); + , + ); + + WRAP(Misc, Widget, _GtkMisc, (), + , + ); + + WRAP(Label, Widget, _GtkLabel, (), + Label(const char *label); + , + ); + + WRAP(Image, Widget, _GtkImage, (), + Image(); + , + ); + + WRAP(Entry, Widget, _GtkEntry, (IEditable, ICellEditable), + Entry(); + Entry(std::size_t max_length); + , + ); + + class Adjustment; + WRAP(SpinButton, Entry, _GtkSpinButton, (), + SpinButton(Adjustment adjustment, double climb_rate, std::size_t digits); + , + ); + + WRAP(Range, Widget, _GtkRange, (), + , + ); + + WRAP(Scale, Range, _GtkScale, (), + , + ); + + WRAP(HScale, Scale, _GtkHScale, (), + HScale(Adjustment adjustment); + HScale(double min, double max, double step); + , + ); + + WRAP(Adjustment, Object, _GtkAdjustment, (), + Adjustment(double value, + double lower, double upper, + double step_increment, double page_increment, + double page_size); + , + ); + + WRAP(CellRenderer, Object, _GtkCellRenderer, (), + , + ); + + WRAP(CellRendererText, CellRenderer, _GtkCellRendererText, (), + CellRendererText(); + , + ); + + struct TreeViewColumnAttribute { + const char *attribute; + int column; + }; + WRAP(TreeViewColumn, Object, _GtkTreeViewColumn, (), + TreeViewColumn(const char *title, CellRenderer renderer, std::initializer_list attributes); + , + ); + + WRAP(AccelGroup, Object, _GtkAccelGroup, (), + AccelGroup(); + , + ); + + WRAP(EntryCompletion, Object, _GtkEntryCompletion, (), + , + ); + + WRAP(ListStore, Object, _GtkListStore, (ITreeModel), + , + void clear(); + ); + + WRAP(TreeSelection, Object, _GtkTreeSelection, (), + , + ); + + // GBoxed + + WRAP(TreePath, Object, _GtkTreePath, (), + TreePath(); + TreePath(const char *path); + , + ); + + // Custom + + WRAP(GLArea, Widget, _GtkGLArea, (), + , + guint on_render(GCallback pFunction, void *data); + ); + +#undef WRAP + + // callbacks + + namespace { + using GtkCallback = void (*)(_GtkWidget *, void *); + extern "C" { + void gtk_container_foreach(_GtkContainer *, GtkCallback, void *); + } + } + +#define this (*static_cast(this)) + + template + gulong Object::connect(char const *detailed_signal, Lambda &&c_handler, void *data) + { + return g_signal_connect(G_OBJECT(this), detailed_signal, c_handler, data); + } + + template + gulong Object::connect(char const *detailed_signal, Lambda &&c_handler, Object data) + { + return g_signal_connect(G_OBJECT(this), detailed_signal, c_handler, (_GtkObject *) data); + } + + template + void IContainer::foreach(Lambda &&lambda) + { + GtkCallback cb = [](_GtkWidget *widget, void *data) -> void { + using Function = typename std::decay::type; + Function *f = static_cast(data); + (*f)(Widget(widget)); + }; + gtk_container_foreach(this, cb, &lambda); + } + +#undef this + +} + +#endif diff --git a/libs/undolib.cpp b/libs/undolib.cpp deleted file mode 100644 index 8ebe6aa3..00000000 --- a/libs/undolib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "undolib.h" diff --git a/libs/uniquenames.cpp b/libs/uniquenames.cpp deleted file mode 100644 index 0515b68c..00000000 --- a/libs/uniquenames.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "uniquenames.h" diff --git a/libs/versionlib.cpp b/libs/versionlib.cpp deleted file mode 100644 index 74799acf..00000000 --- a/libs/versionlib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "versionlib.h" diff --git a/libs/xml/CMakeLists.txt b/libs/xml/CMakeLists.txt index e7cdb61c..96e1e216 100644 --- a/libs/xml/CMakeLists.txt +++ b/libs/xml/CMakeLists.txt @@ -1,9 +1,9 @@ add_library(xmllib - ixml.cpp ixml.h - xmlelement.cpp xmlelement.h - xmlparser.cpp xmlparser.h + ixml.h + xmlelement.h + xmlparser.h xmltextags.cpp xmltextags.h - xmlwriter.cpp xmlwriter.h + xmlwriter.h ) find_package(GLIB REQUIRED) diff --git a/libs/xml/ixml.cpp b/libs/xml/ixml.cpp deleted file mode 100644 index d4caeb55..00000000 --- a/libs/xml/ixml.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "ixml.h" diff --git a/libs/xml/xmlelement.cpp b/libs/xml/xmlelement.cpp deleted file mode 100644 index 2ba39437..00000000 --- a/libs/xml/xmlelement.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "xmlelement.h" diff --git a/libs/xml/xmlparser.cpp b/libs/xml/xmlparser.cpp deleted file mode 100644 index 8ef5d0b4..00000000 --- a/libs/xml/xmlparser.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "xmlparser.h" diff --git a/libs/xml/xmlwriter.cpp b/libs/xml/xmlwriter.cpp deleted file mode 100644 index 87668972..00000000 --- a/libs/xml/xmlwriter.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "xmlwriter.h" diff --git a/plugins/archivepak/CMakeLists.txt b/plugins/archivepak/CMakeLists.txt index 4b3657ed..817cc030 100644 --- a/plugins/archivepak/CMakeLists.txt +++ b/plugins/archivepak/CMakeLists.txt @@ -1,5 +1,5 @@ radiant_plugin(archivepak archive.cpp archive.h - pak.cpp pak.h - plugin.cpp plugin.h + pak.h + plugin.cpp ) diff --git a/plugins/archivepak/archive.cpp b/plugins/archivepak/archive.cpp index 785c2dda..ee193339 100644 --- a/plugins/archivepak/archive.cpp +++ b/plugins/archivepak/archive.cpp @@ -32,8 +32,6 @@ #include "archivelib.h" -#include "plugin.h" - #include #include "string/string.h" #include "fs_filesystem.h" diff --git a/plugins/archivepak/pak.cpp b/plugins/archivepak/pak.cpp deleted file mode 100644 index f0b9c483..00000000 --- a/plugins/archivepak/pak.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "pak.h" diff --git a/plugins/archivepak/plugin.cpp b/plugins/archivepak/plugin.cpp index e334248e..489af0b3 100644 --- a/plugins/archivepak/plugin.cpp +++ b/plugins/archivepak/plugin.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "plugin.h" - #include "iarchive.h" #include "debugging/debugging.h" diff --git a/plugins/archivepak/plugin.h b/plugins/archivepak/plugin.h deleted file mode 100644 index 443a80e6..00000000 --- a/plugins/archivepak/plugin.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_PLUGIN_H ) -#define INCLUDED_PLUGIN_H - -#endif diff --git a/plugins/archivewad/CMakeLists.txt b/plugins/archivewad/CMakeLists.txt index 27a3e95f..acafeee1 100644 --- a/plugins/archivewad/CMakeLists.txt +++ b/plugins/archivewad/CMakeLists.txt @@ -1,5 +1,5 @@ radiant_plugin(archivewad archive.cpp archive.h - plugin.cpp plugin.h - wad.cpp wad.h + plugin.cpp + wad.h ) diff --git a/plugins/archivewad/archive.cpp b/plugins/archivewad/archive.cpp index 793cb0e7..e67d19e8 100644 --- a/plugins/archivewad/archive.cpp +++ b/plugins/archivewad/archive.cpp @@ -31,8 +31,6 @@ #include "archivelib.h" -#include "plugin.h" - #include #include "string/string.h" diff --git a/plugins/archivewad/plugin.cpp b/plugins/archivewad/plugin.cpp index 2ade32ab..95813572 100644 --- a/plugins/archivewad/plugin.cpp +++ b/plugins/archivewad/plugin.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "plugin.h" - #include "iarchive.h" #include "debugging/debugging.h" diff --git a/plugins/archivewad/plugin.h b/plugins/archivewad/plugin.h deleted file mode 100644 index 443a80e6..00000000 --- a/plugins/archivewad/plugin.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_PLUGIN_H ) -#define INCLUDED_PLUGIN_H - -#endif diff --git a/plugins/archivewad/wad.cpp b/plugins/archivewad/wad.cpp deleted file mode 100644 index 778d0c66..00000000 --- a/plugins/archivewad/wad.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "wad.h" diff --git a/plugins/archivezip/CMakeLists.txt b/plugins/archivezip/CMakeLists.txt index e47b7f7d..7ed025d8 100644 --- a/plugins/archivezip/CMakeLists.txt +++ b/plugins/archivezip/CMakeLists.txt @@ -1,8 +1,8 @@ radiant_plugin(archivezip archive.cpp archive.h - pkzip.cpp pkzip.h - plugin.cpp plugin.h - zlibstream.cpp zlibstream.h + pkzip.h + plugin.cpp + zlibstream.h ) find_package(ZLIB REQUIRED) diff --git a/plugins/archivezip/pkzip.cpp b/plugins/archivezip/pkzip.cpp deleted file mode 100644 index 80c73d4f..00000000 --- a/plugins/archivezip/pkzip.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "pkzip.h" diff --git a/plugins/archivezip/plugin.cpp b/plugins/archivezip/plugin.cpp index c88886e6..69a344b9 100644 --- a/plugins/archivezip/plugin.cpp +++ b/plugins/archivezip/plugin.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "plugin.h" - #include "iarchive.h" #include "debugging/debugging.h" diff --git a/plugins/archivezip/plugin.h b/plugins/archivezip/plugin.h deleted file mode 100644 index 443a80e6..00000000 --- a/plugins/archivezip/plugin.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_PLUGIN_H ) -#define INCLUDED_PLUGIN_H - -#endif diff --git a/plugins/archivezip/zlibstream.cpp b/plugins/archivezip/zlibstream.cpp deleted file mode 100644 index c47fa2a3..00000000 --- a/plugins/archivezip/zlibstream.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "zlibstream.h" diff --git a/plugins/entity/CMakeLists.txt b/plugins/entity/CMakeLists.txt index b2911ed5..8e359919 100644 --- a/plugins/entity/CMakeLists.txt +++ b/plugins/entity/CMakeLists.txt @@ -1,25 +1,29 @@ radiant_plugin(entity - angle.cpp angle.h - angles.cpp angles.h - colour.cpp colour.h - curve.cpp curve.h + angle.h + angles.h + colour.h + curve.h doom3group.cpp doom3group.h eclassmodel.cpp eclassmodel.h entity.cpp entity.h filters.cpp filters.h generic.cpp generic.h group.cpp group.h - keyobservers.cpp keyobservers.h + keyobservers.h light.cpp light.h miscmodel.cpp miscmodel.h - model.cpp model.h - modelskinkey.cpp modelskinkey.h - namedentity.cpp namedentity.h - namekeys.cpp namekeys.h - origin.cpp origin.h - plugin.cpp plugin.h - rotation.cpp rotation.h - scale.cpp scale.h + model.h + modelskinkey.h + namedentity.h + namekeys.h + origin.h + plugin.cpp + rotation.h + scale.h skincache.cpp skincache.h targetable.cpp targetable.h ) + +target_include_directories(entity + PRIVATE $ +) diff --git a/plugins/entity/angle.cpp b/plugins/entity/angle.cpp deleted file mode 100644 index 7dcbd36a..00000000 --- a/plugins/entity/angle.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "angle.h" diff --git a/plugins/entity/angles.cpp b/plugins/entity/angles.cpp deleted file mode 100644 index c1149166..00000000 --- a/plugins/entity/angles.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "angles.h" diff --git a/plugins/entity/colour.cpp b/plugins/entity/colour.cpp deleted file mode 100644 index 8c959888..00000000 --- a/plugins/entity/colour.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "colour.h" diff --git a/plugins/entity/curve.cpp b/plugins/entity/curve.cpp deleted file mode 100644 index e38d2a11..00000000 --- a/plugins/entity/curve.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "curve.h" diff --git a/plugins/entity/keyobservers.cpp b/plugins/entity/keyobservers.cpp deleted file mode 100644 index 210b1385..00000000 --- a/plugins/entity/keyobservers.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "keyobservers.h" diff --git a/plugins/entity/model.cpp b/plugins/entity/model.cpp deleted file mode 100644 index 74717a5f..00000000 --- a/plugins/entity/model.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "model.h" diff --git a/plugins/entity/modelskinkey.cpp b/plugins/entity/modelskinkey.cpp deleted file mode 100644 index 4567578f..00000000 --- a/plugins/entity/modelskinkey.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "modelskinkey.h" diff --git a/plugins/entity/namedentity.cpp b/plugins/entity/namedentity.cpp deleted file mode 100644 index 5edbf1c1..00000000 --- a/plugins/entity/namedentity.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "namedentity.h" diff --git a/plugins/entity/namekeys.cpp b/plugins/entity/namekeys.cpp deleted file mode 100644 index 7351c57b..00000000 --- a/plugins/entity/namekeys.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "namekeys.h" diff --git a/plugins/entity/origin.cpp b/plugins/entity/origin.cpp deleted file mode 100644 index c0c9b112..00000000 --- a/plugins/entity/origin.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "origin.h" diff --git a/plugins/entity/plugin.cpp b/plugins/entity/plugin.cpp index e8131e0b..58b6fb37 100644 --- a/plugins/entity/plugin.cpp +++ b/plugins/entity/plugin.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "plugin.h" - #include "debugging/debugging.h" #include "iscenegraph.h" diff --git a/plugins/entity/plugin.h b/plugins/entity/plugin.h deleted file mode 100644 index 443a80e6..00000000 --- a/plugins/entity/plugin.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_PLUGIN_H ) -#define INCLUDED_PLUGIN_H - -#endif diff --git a/plugins/entity/rotation.cpp b/plugins/entity/rotation.cpp deleted file mode 100644 index 30d5b949..00000000 --- a/plugins/entity/rotation.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "rotation.h" diff --git a/plugins/entity/scale.cpp b/plugins/entity/scale.cpp deleted file mode 100644 index 3d5b989e..00000000 --- a/plugins/entity/scale.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "scale.h" diff --git a/plugins/image/CMakeLists.txt b/plugins/image/CMakeLists.txt index 07341c08..e1f40cc5 100644 --- a/plugins/image/CMakeLists.txt +++ b/plugins/image/CMakeLists.txt @@ -1,7 +1,7 @@ radiant_plugin(image bmp.cpp bmp.h dds.cpp dds.h - image.cpp image.h + image.cpp jpeg.cpp jpeg.h ktx.cpp ktx.h pcx.cpp pcx.h diff --git a/plugins/image/image.cpp b/plugins/image/image.cpp index 4f3e07a8..7d767f22 100644 --- a/plugins/image/image.cpp +++ b/plugins/image/image.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "image.h" - #include "ifilesystem.h" #include "iimage.h" diff --git a/plugins/image/image.h b/plugins/image/image.h deleted file mode 100644 index c61bcc20..00000000 --- a/plugins/image/image.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_IMAGE_H ) -#define INCLUDED_IMAGE_H - -#endif diff --git a/plugins/imagehl/CMakeLists.txt b/plugins/imagehl/CMakeLists.txt index f6541776..2e36ca19 100644 --- a/plugins/imagehl/CMakeLists.txt +++ b/plugins/imagehl/CMakeLists.txt @@ -1,6 +1,6 @@ radiant_plugin(imagehl hlw.cpp hlw.h - imagehl.cpp imagehl.h + imagehl.cpp mip.cpp mip.h sprite.cpp sprite.h ) diff --git a/plugins/imagehl/imagehl.cpp b/plugins/imagehl/imagehl.cpp index 479a0d99..dfdf98b9 100644 --- a/plugins/imagehl/imagehl.cpp +++ b/plugins/imagehl/imagehl.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "imagehl.h" - #include "debugging/debugging.h" #include "ifilesystem.h" #include "iimage.h" diff --git a/plugins/imagehl/imagehl.h b/plugins/imagehl/imagehl.h deleted file mode 100644 index 6d0b7765..00000000 --- a/plugins/imagehl/imagehl.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_IMAGEHL_H ) -#define INCLUDED_IMAGEHL_H - -#endif diff --git a/plugins/imagepng/CMakeLists.txt b/plugins/imagepng/CMakeLists.txt index ec03da60..a9c69931 100644 --- a/plugins/imagepng/CMakeLists.txt +++ b/plugins/imagepng/CMakeLists.txt @@ -1,5 +1,5 @@ radiant_plugin(imagepng - plugin.cpp plugin.h + plugin.cpp ) find_package(PNG REQUIRED) diff --git a/plugins/imagepng/plugin.cpp b/plugins/imagepng/plugin.cpp index bf087416..36a4fd05 100644 --- a/plugins/imagepng/plugin.cpp +++ b/plugins/imagepng/plugin.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "plugin.h" - #include "debugging/debugging.h" #include "ifilesystem.h" diff --git a/plugins/imagepng/plugin.h b/plugins/imagepng/plugin.h deleted file mode 100644 index 271a2ad2..00000000 --- a/plugins/imagepng/plugin.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_PLUGIN_H ) -#define INCLUDED_PLUGIN_H - -#endif diff --git a/plugins/imageq2/CMakeLists.txt b/plugins/imageq2/CMakeLists.txt index 7ba65cdd..942c7e09 100644 --- a/plugins/imageq2/CMakeLists.txt +++ b/plugins/imageq2/CMakeLists.txt @@ -1,5 +1,5 @@ radiant_plugin(imageq2 - imageq2.cpp imageq2.h + imageq2.cpp wal.cpp wal.h wal32.cpp wal32.h ) diff --git a/plugins/imageq2/imageq2.cpp b/plugins/imageq2/imageq2.cpp index 62101667..9ea5c635 100644 --- a/plugins/imageq2/imageq2.cpp +++ b/plugins/imageq2/imageq2.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "imageq2.h" - #include "debugging/debugging.h" #include "ifilesystem.h" #include "iimage.h" diff --git a/plugins/imageq2/imageq2.h b/plugins/imageq2/imageq2.h deleted file mode 100644 index 38374374..00000000 --- a/plugins/imageq2/imageq2.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_IMAGEQ2_H ) -#define INCLUDED_IMAGEQ2_H - -#endif diff --git a/plugins/mapq3/CMakeLists.txt b/plugins/mapq3/CMakeLists.txt index f743d076..880b653d 100644 --- a/plugins/mapq3/CMakeLists.txt +++ b/plugins/mapq3/CMakeLists.txt @@ -1,5 +1,9 @@ radiant_plugin(mapq3 parse.cpp parse.h - plugin.cpp plugin.h + plugin.cpp write.cpp write.h ) + +target_include_directories(mapq3 + PRIVATE $ +) diff --git a/plugins/mapq3/plugin.cpp b/plugins/mapq3/plugin.cpp index 2c3d99c5..b107f583 100644 --- a/plugins/mapq3/plugin.cpp +++ b/plugins/mapq3/plugin.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "plugin.h" - #include "iscriplib.h" #include "ibrush.h" #include "ipatch.h" diff --git a/plugins/mapq3/plugin.h b/plugins/mapq3/plugin.h deleted file mode 100644 index 443a80e6..00000000 --- a/plugins/mapq3/plugin.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_PLUGIN_H ) -#define INCLUDED_PLUGIN_H - -#endif diff --git a/plugins/mapxml/CMakeLists.txt b/plugins/mapxml/CMakeLists.txt index 47596d37..a6aae15f 100644 --- a/plugins/mapxml/CMakeLists.txt +++ b/plugins/mapxml/CMakeLists.txt @@ -1,5 +1,5 @@ radiant_plugin(mapxml - plugin.cpp plugin.h + plugin.cpp xmlparse.cpp xmlparse.h xmlwrite.cpp xmlwrite.h ) diff --git a/plugins/mapxml/plugin.cpp b/plugins/mapxml/plugin.cpp index ff776381..b144a415 100644 --- a/plugins/mapxml/plugin.cpp +++ b/plugins/mapxml/plugin.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "plugin.h" - #include "ibrush.h" #include "ipatch.h" #include "ifiletypes.h" diff --git a/plugins/mapxml/plugin.h b/plugins/mapxml/plugin.h deleted file mode 100644 index 443a80e6..00000000 --- a/plugins/mapxml/plugin.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_PLUGIN_H ) -#define INCLUDED_PLUGIN_H - -#endif diff --git a/plugins/md3model/CMakeLists.txt b/plugins/md3model/CMakeLists.txt index 23e51dba..1966759d 100644 --- a/plugins/md3model/CMakeLists.txt +++ b/plugins/md3model/CMakeLists.txt @@ -2,13 +2,13 @@ radiant_plugin(md3model ident.h md2.cpp md2.h md3.cpp md3.h - md3normals.cpp md3normals.h + md3normals.h md5.cpp md5.h mdc.cpp mdc.h mdl.cpp mdl.h - mdlformat.cpp mdlformat.h + mdlformat.h mdlimage.cpp mdlimage.h - mdlnormals.cpp mdlnormals.h - model.cpp model.h - plugin.cpp plugin.h + mdlnormals.h + model.h + plugin.cpp ) diff --git a/plugins/md3model/md3normals.cpp b/plugins/md3model/md3normals.cpp deleted file mode 100644 index 94de3eaa..00000000 --- a/plugins/md3model/md3normals.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "md3normals.h" diff --git a/plugins/md3model/mdlformat.cpp b/plugins/md3model/mdlformat.cpp deleted file mode 100644 index 36a64b1d..00000000 --- a/plugins/md3model/mdlformat.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mdlformat.h" diff --git a/plugins/md3model/mdlnormals.cpp b/plugins/md3model/mdlnormals.cpp deleted file mode 100644 index cea533d9..00000000 --- a/plugins/md3model/mdlnormals.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mdlnormals.h" diff --git a/plugins/md3model/model.cpp b/plugins/md3model/model.cpp deleted file mode 100644 index 74717a5f..00000000 --- a/plugins/md3model/model.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "model.h" diff --git a/plugins/md3model/plugin.cpp b/plugins/md3model/plugin.cpp index 95fb5477..58c97677 100644 --- a/plugins/md3model/plugin.cpp +++ b/plugins/md3model/plugin.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "plugin.h" - #include "iscenegraph.h" #include "irender.h" #include "iselection.h" diff --git a/plugins/md3model/plugin.h b/plugins/md3model/plugin.h deleted file mode 100644 index 443a80e6..00000000 --- a/plugins/md3model/plugin.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_PLUGIN_H ) -#define INCLUDED_PLUGIN_H - -#endif diff --git a/plugins/model/CMakeLists.txt b/plugins/model/CMakeLists.txt index 780cc080..4a23e28d 100644 --- a/plugins/model/CMakeLists.txt +++ b/plugins/model/CMakeLists.txt @@ -1,6 +1,6 @@ radiant_plugin(model model.cpp model.h - plugin.cpp plugin.h + plugin.cpp ) target_include_directories(model PRIVATE picomodel) diff --git a/plugins/model/plugin.cpp b/plugins/model/plugin.cpp index 61e77628..d23809a6 100644 --- a/plugins/model/plugin.cpp +++ b/plugins/model/plugin.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "plugin.h" - #include #include "picomodel.h" typedef unsigned char byte; diff --git a/plugins/model/plugin.h b/plugins/model/plugin.h deleted file mode 100644 index 443a80e6..00000000 --- a/plugins/model/plugin.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_PLUGIN_H ) -#define INCLUDED_PLUGIN_H - -#endif diff --git a/plugins/sample/sample.h b/plugins/sample/sample.h deleted file mode 100644 index c6bfe6ce..00000000 --- a/plugins/sample/sample.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_SAMPLE_H ) -#define INCLUDED_SAMPLE_H - -#endif diff --git a/plugins/shaders/CMakeLists.txt b/plugins/shaders/CMakeLists.txt index 8f91f0ba..b565c0ac 100644 --- a/plugins/shaders/CMakeLists.txt +++ b/plugins/shaders/CMakeLists.txt @@ -1,5 +1,5 @@ radiant_plugin(shaders - plugin.cpp plugin.h + plugin.cpp shaders.cpp shaders.h ) diff --git a/plugins/shaders/plugin.cpp b/plugins/shaders/plugin.cpp index ee021936..4576a641 100644 --- a/plugins/shaders/plugin.cpp +++ b/plugins/shaders/plugin.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "plugin.h" - #include "ishaders.h" #include "ifilesystem.h" #include "itextures.h" diff --git a/plugins/shaders/plugin.h b/plugins/shaders/plugin.h deleted file mode 100644 index 443a80e6..00000000 --- a/plugins/shaders/plugin.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_PLUGIN_H ) -#define INCLUDED_PLUGIN_H - -#endif diff --git a/plugins/textool/2DView.cpp b/plugins/textool/2DView.cpp index 4da3fab3..f6e10185 100644 --- a/plugins/textool/2DView.cpp +++ b/plugins/textool/2DView.cpp @@ -114,25 +114,25 @@ bool C2DView::OnRButtonUp( int x, int y ){ if ( m_bPopup ) { GtkWidget *menu, *item; - menu = gtk_menu_new(); + menu = ui::Menu(); - item = gtk_menu_item_new_with_label( "Validate (RETURN)" ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( Textool_Validate ), NULL ); + item = ui::MenuItem( "Validate (RETURN)" ); + item.connect( "activate", G_CALLBACK( Textool_Validate ), NULL ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); - item = gtk_menu_item_new_with_label( "Zoom in (INSERT)" ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( view_ZoomIn ), this ); + item = ui::MenuItem( "Zoom in (INSERT)" ); + item.connect( "activate", G_CALLBACK( view_ZoomIn ), this ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); - item = gtk_menu_item_new_with_label( "Zoom out (DELETE)" ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( view_ZoomOut ), this ); + item = ui::MenuItem( "Zoom out (DELETE)" ); + item.connect( "activate", G_CALLBACK( view_ZoomOut ), this ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); - item = gtk_menu_item_new_with_label( "Cancel (ESC)" ); - gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( Textool_Cancel ), NULL ); + item = ui::MenuItem( "Cancel (ESC)" ); + item.connect( "activate", G_CALLBACK( Textool_Cancel ), NULL ); gtk_widget_show( item ); gtk_menu_append( GTK_MENU( menu ), item ); diff --git a/plugins/textool/StdAfx.cpp b/plugins/textool/StdAfx.cpp deleted file mode 100644 index 7fc09059..00000000 --- a/plugins/textool/StdAfx.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 1999-2006 Id Software, Inc. and contributors. - For a list of contributors, see the accompanying CONTRIBUTORS file. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -// stdafx.cpp : source file that includes just the standard includes -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/plugins/textool/StdAfx.h b/plugins/textool/StdAfx.h index a31c0a6d..f884c53e 100644 --- a/plugins/textool/StdAfx.h +++ b/plugins/textool/StdAfx.h @@ -23,8 +23,6 @@ // precompiled headers // standard headers -#include -#include #include #include diff --git a/plugins/textool/TexTool.cpp b/plugins/textool/TexTool.cpp index 50fbf125..1a251b05 100644 --- a/plugins/textool/TexTool.cpp +++ b/plugins/textool/TexTool.cpp @@ -51,25 +51,25 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer } int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ - GtkWidget *window, *w, *vbox, *hbox; + GtkWidget *w, *vbox, *hbox; int mode = ( uType & MB_TYPEMASK ), ret, loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); - gtk_signal_connect( GTK_OBJECT( window ), "delete_event", - GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); - gtk_signal_connect( GTK_OBJECT( window ), "destroy", - GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL ); + auto window = ui::Window( ui::window_type::TOP ); + window.connect( "delete_event", + G_CALLBACK( dialog_delete_callback ), NULL ); + window.connect( "destroy", + G_CALLBACK( gtk_widget_destroy ), NULL ); gtk_window_set_title( GTK_WINDOW( window ), lpCaption ); - gtk_container_border_width( GTK_CONTAINER( window ), 10 ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = gtk_vbox_new( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); - w = gtk_label_new( lpText ); + w = ui::Label( lpText ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -78,72 +78,72 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_widget_show( w ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::HBox( FALSE, 10 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); if ( mode == MB_OK ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); ret = IDOK; } else if ( mode == MB_OKCANCEL ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Button( "Ok" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); gtk_widget_show( w ); ret = IDCANCEL; } else if ( mode == MB_YESNOCANCEL ) { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Button( "Cancel" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) ); gtk_widget_show( w ); ret = IDCANCEL; } else /* if (mode == MB_YESNO) */ { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Button( "Yes" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); - GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) ); + gtk_widget_set_can_default( w, true ); gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Button( "No" ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); - gtk_signal_connect( GTK_OBJECT( w ), "clicked", - GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); + w.connect( "clicked", + G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) ); gtk_widget_show( w ); ret = IDNO; } @@ -643,17 +643,17 @@ static GtkWidget* CreateOpenGLWidget(){ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ); // Connect signal handlers - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "expose_event", GTK_SIGNAL_FUNC( expose ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "motion_notify_event", - GTK_SIGNAL_FUNC( motion ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "button_press_event", - GTK_SIGNAL_FUNC( button_press ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "button_release_event", - GTK_SIGNAL_FUNC( button_release ), NULL ); - - gtk_signal_connect( GTK_OBJECT( g_pToolWnd ), "delete_event", GTK_SIGNAL_FUNC( close ), NULL ); - gtk_signal_connect( GTK_OBJECT( g_pToolWnd ), "key_press_event", - GTK_SIGNAL_FUNC( keypress ), NULL ); + g_pToolWidget.connect( "expose_event", G_CALLBACK( expose ), NULL ); + g_pToolWidget.connect( "motion_notify_event", + G_CALLBACK( motion ), NULL ); + g_pToolWidget.connect( "button_press_event", + G_CALLBACK( button_press ), NULL ); + g_pToolWidget.connect( "button_release_event", + G_CALLBACK( button_release ), NULL ); + + g_pToolWnd.connect( "delete_event", G_CALLBACK( close ), NULL ); + g_pToolWnd.connect( "key_press_event", + G_CALLBACK( keypress ), NULL ); return g_pToolWidget; } diff --git a/plugins/vfspk3/CMakeLists.txt b/plugins/vfspk3/CMakeLists.txt index 6b6b0c81..a55e9de0 100644 --- a/plugins/vfspk3/CMakeLists.txt +++ b/plugins/vfspk3/CMakeLists.txt @@ -1,7 +1,7 @@ radiant_plugin(vfspk3 archive.cpp archive.h vfs.cpp vfs.h - vfspk3.cpp vfspk3.h + vfspk3.cpp ) find_package(GLIB REQUIRED) diff --git a/plugins/vfspk3/archive.cpp b/plugins/vfspk3/archive.cpp index a77b0728..cf2bdeee 100644 --- a/plugins/vfspk3/archive.cpp +++ b/plugins/vfspk3/archive.cpp @@ -37,8 +37,6 @@ #include "archivelib.h" #include "fs_path.h" -#include "vfspk3.h" - class DirectoryArchive : public Archive { diff --git a/plugins/vfspk3/vfspk3.cpp b/plugins/vfspk3/vfspk3.cpp index 478ce8f1..55b273ec 100644 --- a/plugins/vfspk3/vfspk3.cpp +++ b/plugins/vfspk3/vfspk3.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "vfspk3.h" - #include "qerplugin.h" #include "iarchive.h" #include "ifilesystem.h" diff --git a/plugins/vfspk3/vfspk3.h b/plugins/vfspk3/vfspk3.h deleted file mode 100644 index f5fb5c0b..00000000 --- a/plugins/vfspk3/vfspk3.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. - - This file is part of GtkRadiant. - - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_VFSPK3_H ) -#define INCLUDED_VFSPK3_H - -#endif diff --git a/radiant/CMakeLists.txt b/radiant/CMakeLists.txt index 1e2040da..05d79830 100644 --- a/radiant/CMakeLists.txt +++ b/radiant/CMakeLists.txt @@ -100,7 +100,7 @@ target_link_libraries(radiant ${CMAKE_DL_LIBS} ${LIBXML2_LIBRARIES} ${OPENGL_gl_LIBRARY} - ${${GTK_NS}_LIBRARIES} + ${GTK${GTK_TARGET}_LIBRARIES} ${GTKGL_LIBRARIES} includes cmdlib diff --git a/radiant/autosave.cpp b/radiant/autosave.cpp index fe42687c..b9f9b824 100644 --- a/radiant/autosave.cpp +++ b/radiant/autosave.cpp @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include "autosave.h" #include "os/file.h" @@ -91,7 +92,7 @@ void Map_Snapshot(){ { StringOutputStream strMsg( 256 ); strMsg << "Snapshot save failed.. unabled to create directory\n" << snapshotsDir.c_str(); - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), strMsg.c_str() ); + MainFrame_getWindow().alert( strMsg.c_str() ); } } /* @@ -174,8 +175,8 @@ void QE_CheckAutoSave( void ){ } void Autosave_constructPreferences( PreferencesPage& page ){ - GtkWidget* autosave_enabled = page.appendCheckBox( "Autosave", "Enable Autosave", g_AutoSave_Enabled ); - GtkWidget* autosave_frequency = page.appendSpinner( "Autosave Frequency (minutes)", m_AutoSave_Frequency, 1, 1, 60 ); + ui::CheckButton autosave_enabled = page.appendCheckBox( "Autosave", "Enable Autosave", g_AutoSave_Enabled ); + ui::SpinButton autosave_frequency = page.appendSpinner( "Autosave Frequency (minutes)", m_AutoSave_Frequency, 1, 1, 60 ); Widget_connectToggleDependency( autosave_frequency, autosave_enabled ); page.appendCheckBox( "", "Save Snapshots", g_SnapShots_Enabled ); } diff --git a/radiant/brushmanip.cpp b/radiant/brushmanip.cpp index c49464be..43dc0e73 100644 --- a/radiant/brushmanip.cpp +++ b/radiant/brushmanip.cpp @@ -36,6 +36,7 @@ #include "preferences.h" #include +#include void Brush_ConstructCuboid( Brush& brush, const AABB& bounds, const char* shader, const TextureProjection& projection ){ const unsigned char box[3][2] = { { 0, 1 }, { 2, 0 }, { 1, 2 } }; @@ -1367,22 +1368,22 @@ void Brush_registerCommands(){ GlobalCommands_insert( "Brush8Sided", BrushMakeSided::SetCaller( g_brushmakesided8 ), Accelerator( '8', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "Brush9Sided", BrushMakeSided::SetCaller( g_brushmakesided9 ), Accelerator( '9', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "ClipSelected", FreeCaller(), Accelerator( GDK_Return ) ); - GlobalCommands_insert( "SplitSelected", FreeCaller(), Accelerator( GDK_Return, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "FlipClip", FreeCaller(), Accelerator( GDK_Return, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "ClipSelected", FreeCaller(), Accelerator( GDK_KEY_Return ) ); + GlobalCommands_insert( "SplitSelected", FreeCaller(), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "FlipClip", FreeCaller(), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "MakeDetail", FreeCaller(), Accelerator( 'M', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "MakeStructural", FreeCaller(), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); } -void Brush_constructMenu( GtkMenu* menu ){ +void Brush_constructMenu( ui::Menu menu ){ create_menu_item_with_mnemonic( menu, "Prism...", "BrushPrism" ); create_menu_item_with_mnemonic( menu, "Cone...", "BrushCone" ); create_menu_item_with_mnemonic( menu, "Sphere...", "BrushSphere" ); create_menu_item_with_mnemonic( menu, "Rock...", "BrushRock" ); menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "CSG" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "CSG" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -1392,7 +1393,7 @@ void Brush_constructMenu( GtkMenu* menu ){ } menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Clipper" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Clipper" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } diff --git a/radiant/brushmanip.h b/radiant/brushmanip.h index 06f67271..8795bf4e 100644 --- a/radiant/brushmanip.h +++ b/radiant/brushmanip.h @@ -23,6 +23,7 @@ #define INCLUDED_BRUSHWRAPPER_H #include +#include #include "string/stringfwd.h" #include "generic/callbackfwd.h" @@ -71,8 +72,7 @@ void Scene_BrushSelectByShader_Component( scene::Graph& graph, const char* name void Scene_BrushFitTexture_Selected( scene::Graph& graph, float s_repeat, float t_repeat ); void Scene_BrushFitTexture_Component_Selected( scene::Graph& graph, float s_repeat, float t_repeat ); -typedef struct _GtkMenu GtkMenu; -void Brush_constructMenu( GtkMenu* menu ); +void Brush_constructMenu( ui::Menu menu ); extern Callback g_texture_lock_status_changed; diff --git a/radiant/build.cpp b/radiant/build.cpp index 073e0ddf..05ca5645 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -22,6 +22,7 @@ #include "build.h" #include "debugging/debugging.h" +#include #include #include #include "stream/stringstream.h" @@ -633,25 +634,17 @@ void build_commands_write( const char* filename ){ #include -#include -#include -#include -#include -#include -#include -#include -#include #include "gtkutil/dialog.h" #include "gtkutil/closure.h" #include "gtkutil/window.h" #include "gtkdlgs.h" -void Build_refreshMenu( GtkMenu* menu ); +void Build_refreshMenu( ui::Menu menu ); -void BSPCommandList_Construct( GtkListStore* store, Project& project ){ - gtk_list_store_clear( store ); +void BSPCommandList_Construct( ui::ListStore store, Project& project ){ + store.clear(); for ( Project::iterator i = project.begin(); i != project.end(); ++i ) { @@ -670,7 +663,7 @@ class ProjectList { public: Project& m_project; -GtkListStore* m_store; +ui::ListStore m_store{ui::null}; bool m_changed; ProjectList( Project& project ) : m_project( project ), m_changed( false ){ } @@ -679,7 +672,7 @@ ProjectList( Project& project ) : m_project( project ), m_changed( false ){ gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, ProjectList* projectList ){ Project& project = projectList->m_project; - GtkTreePath* path = gtk_tree_path_new_from_string( path_string ); + GtkTreePath* path = ui::TreePath( path_string ); ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" ); @@ -715,10 +708,10 @@ gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gch return FALSE; } -gboolean project_key_press( GtkWidget* widget, GdkEventKey* event, ProjectList* projectList ){ +gboolean project_key_press( ui::Widget widget, GdkEventKey* event, ProjectList* projectList ){ Project& project = projectList->m_project; - if ( event->keyval == GDK_Delete ) { + if ( event->keyval == GDK_KEY_Delete ) { GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( widget ) ); GtkTreeIter iter; GtkTreeModel* model; @@ -742,7 +735,7 @@ gboolean project_key_press( GtkWidget* widget, GdkEventKey* event, ProjectList* Build* g_current_build = 0; -gboolean project_selection_changed( GtkTreeSelection* selection, GtkListStore* store ){ +gboolean project_selection_changed( GtkTreeSelection* selection, ui::ListStore store ){ Project& project = g_build_project; gtk_list_store_clear( store ); @@ -780,13 +773,13 @@ gboolean project_selection_changed( GtkTreeSelection* selection, GtkListStore* s return FALSE; } -gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, GtkListStore* store ){ +gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, ui::ListStore store ){ if ( g_current_build == 0 ) { return FALSE; } Build& build = *g_current_build; - GtkTreePath* path = gtk_tree_path_new_from_string( path_string ); + GtkTreePath* path = ui::TreePath( path_string ); ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" ); @@ -817,13 +810,13 @@ gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gc return FALSE; } -gboolean commands_key_press( GtkWidget* widget, GdkEventKey* event, GtkListStore* store ){ +gboolean commands_key_press( ui::Widget widget, GdkEventKey* event, ui::ListStore store ){ if ( g_current_build == 0 ) { return FALSE; } Build& build = *g_current_build; - if ( event->keyval == GDK_Delete ) { + if ( event->keyval == GDK_KEY_Delete ) { GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( widget ) ); GtkTreeIter iter; GtkTreeModel* model; @@ -844,14 +837,14 @@ gboolean commands_key_press( GtkWidget* widget, GdkEventKey* event, GtkListStore } -GtkWindow* BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectList ){ - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Build Menu", G_CALLBACK( dialog_delete_callback ), &modal, -1, 400 ); +ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectList ){ + ui::Window window = MainFrame_getWindow().create_dialog_window("Build Menu", G_CALLBACK(dialog_delete_callback ), &modal, -1, 400 ); - GtkWidget* buildView = 0; + ui::Widget buildView; { - GtkTable* table1 = create_dialog_table( 2, 2, 4, 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( table1 ) ); + auto table1 = create_dialog_table( 2, 2, 4, 4, 4 ); + window.add(table1); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_table_attach( table1, GTK_WIDGET( vbox ), 1, 2, 0, 1, @@ -867,76 +860,77 @@ GtkWindow* BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi } } { - GtkFrame* frame = create_dialog_frame( "Build menu" ); + auto frame = create_dialog_frame( "Build menu" ); gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); { - GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( scr ) ); + auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 ); + frame.add(scr); { - GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); + auto store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView( ui::TreeModel(GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE ); - g_signal_connect( renderer, "edited", G_CALLBACK( project_cell_edited ), &projectList ); + renderer.connect("edited", G_CALLBACK( project_cell_edited ), &projectList ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 ); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE ); - gtk_widget_show( view ); + view.show(); buildView = view; projectList.m_store = store; - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); - g_signal_connect( G_OBJECT( view ), "key_press_event", G_CALLBACK( project_key_press ), &projectList ); + view.connect( "key_press_event", G_CALLBACK( project_key_press ), &projectList ); - g_object_unref( G_OBJECT( store ) ); + store.unref(); } } } { - GtkFrame* frame = create_dialog_frame( "Commandline" ); + auto frame = create_dialog_frame( "Commandline" ); gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); { - GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( scr ) ); + auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 ); + frame.add(scr); { - GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); + ui::ListStore store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE ); - g_signal_connect( renderer, "edited", G_CALLBACK( commands_cell_edited ), store ); + renderer.connect( "edited", G_CALLBACK( commands_cell_edited ), store ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 ); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE ); - gtk_widget_show( view ); + view.show(); - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); - g_object_unref( G_OBJECT( store ) ); + store.unref(); - g_signal_connect( G_OBJECT( view ), "key_press_event", G_CALLBACK( commands_key_press ), store ); + view.connect( "key_press_event", G_CALLBACK( commands_key_press ), store ); - g_signal_connect( G_OBJECT( gtk_tree_view_get_selection( GTK_TREE_VIEW( buildView ) ) ), "changed", G_CALLBACK( project_selection_changed ), store ); + auto sel = ui::TreeSelection(gtk_tree_view_get_selection( GTK_TREE_VIEW( buildView ) )); + sel.connect( "changed", G_CALLBACK( project_selection_changed ), store ); } } } @@ -959,7 +953,7 @@ void DoBuildMenu(){ ProjectList projectList( g_build_project ); - GtkWindow* window = BuildMenuDialog_construct( modal, projectList ); + ui::Window window = BuildMenuDialog_construct( modal, projectList ); if ( modal_dialog_show( window, modal ) == eIDCANCEL ) { build_commands_clear(); @@ -981,8 +975,6 @@ void DoBuildMenu(){ #include "preferences.h" #include "qe3.h" -typedef struct _GtkMenuItem GtkMenuItem; - class BuildMenuItem { const char* m_name; @@ -1001,9 +993,9 @@ typedef std::list BuildMenuItems; BuildMenuItems g_BuildMenuItems; -GtkMenu* g_bsp_menu; +ui::Menu g_bsp_menu{ui::null}; -void Build_constructMenu( GtkMenu* menu ){ +void Build_constructMenu( ui::Menu menu ){ for ( Project::iterator i = g_build_project.begin(); i != g_build_project.end(); ++i ) { g_BuildMenuItems.push_back( BuildMenuItem( ( *i ).first.c_str(), 0 ) ); @@ -1018,10 +1010,10 @@ void Build_constructMenu( GtkMenu* menu ){ } -void Build_refreshMenu( GtkMenu* menu ){ +void Build_refreshMenu( ui::Menu menu ){ for ( BuildMenuItems::iterator i = g_BuildMenuItems.begin(); i != g_BuildMenuItems.end(); ++i ) { - gtk_container_remove( GTK_CONTAINER( menu ), GTK_WIDGET( ( *i ).m_item ) ); + gtk_container_remove( menu, GTK_WIDGET( ( *i ).m_item ) ); } g_BuildMenuItems.clear(); diff --git a/radiant/build.h b/radiant/build.h index 32a39718..4e494146 100644 --- a/radiant/build.h +++ b/radiant/build.h @@ -18,6 +18,8 @@ along with GtkRadiant; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_BUILD_H ) #define INCLUDED_BUILD_H @@ -36,9 +38,8 @@ void DoBuildMenu(); void BuildMenu_Construct(); void BuildMenu_Destroy(); -typedef struct _GtkMenu GtkMenu; -void Build_constructMenu( GtkMenu* menu ); -extern GtkMenu* g_bsp_menu; +void Build_constructMenu( ui::Menu menu ); +extern ui::Menu g_bsp_menu; #endif diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 9e97ce96..0f729b40 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -27,6 +27,9 @@ #include "camwindow.h" +#include +#include + #include "debugging/debugging.h" #include "iscenegraph.h" @@ -669,8 +672,8 @@ static Shader* m_state_select2; FreezePointer m_freezePointer; public: -GtkWidget* m_gl_widget; -GtkWindow* m_parent; +ui::GLArea m_gl_widget; +ui::Window m_parent{ui::null}; SelectionSystemWindowObserver* m_window_observer; XORRectangle m_XORRectangle; @@ -756,19 +759,19 @@ void GlobalCamera_setCamWnd( CamWnd& camwnd ){ } -GtkWidget* CamWnd_getWidget( CamWnd& camwnd ){ +ui::GLArea CamWnd_getWidget( CamWnd& camwnd ){ return camwnd.m_gl_widget; } -GtkWindow* CamWnd_getParent( CamWnd& camwnd ){ +ui::Window CamWnd_getParent( CamWnd& camwnd ){ return camwnd.m_parent; } ToggleShown g_camera_shown( true ); -void CamWnd_setParent( CamWnd& camwnd, GtkWindow* parent ){ +void CamWnd_setParent( CamWnd& camwnd, ui::Window parent ){ camwnd.m_parent = parent; - g_camera_shown.connect( GTK_WIDGET( camwnd.m_parent ) ); + g_camera_shown.connect( camwnd.m_parent ); } void CamWnd_Update( CamWnd& camwnd ){ @@ -799,7 +802,7 @@ void Camera_setAngles( CamWnd& camwnd, const Vector3& angles ){ // ============================================================================= // CamWnd class -gboolean enable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ +gboolean enable_freelook_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { camwnd->EnableFreeMove(); return TRUE; @@ -807,7 +810,7 @@ gboolean enable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, return FALSE; } -gboolean disable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ +gboolean disable_freelook_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { camwnd->DisableFreeMove(); return TRUE; @@ -816,7 +819,7 @@ gboolean disable_freelook_button_press( GtkWidget* widget, GdkEventButton* event } #if 0 -gboolean mousecontrol_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ +gboolean mousecontrol_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { Cam_MouseControl( camwnd->getCamera(), event->x, widget->allocation.height - 1 - event->y ); } @@ -825,20 +828,20 @@ gboolean mousecontrol_button_press( GtkWidget* widget, GdkEventButton* event, Ca #endif void camwnd_update_xor_rectangle( CamWnd& self, rect_t area ){ - if ( GTK_WIDGET_VISIBLE( self.m_gl_widget ) ) { + if ( gtk_widget_get_visible( self.m_gl_widget ) ) { self.m_XORRectangle.set( rectangle_from_area( area.min, area.max, self.getCamera().width, self.getCamera().height ) ); } } -gboolean selection_button_press( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_press( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_PRESS ) { observer->onMouseDown( WindowVector_forDouble( event->x, event->y ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } return FALSE; } -gboolean selection_button_release( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_release( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_RELEASE ) { observer->onMouseUp( WindowVector_forDouble( event->x, event->y ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } @@ -850,30 +853,32 @@ void selection_motion( gdouble x, gdouble y, guint state, void* data ){ reinterpret_cast( data )->onMouseMotion( WindowVector_forDouble( x, y ), modifiers_for_state( state ) ); } -inline WindowVector windowvector_for_widget_centre( GtkWidget* widget ){ - return WindowVector( static_cast( widget->allocation.width / 2 ), static_cast( widget->allocation.height / 2 ) ); +inline WindowVector windowvector_for_widget_centre( ui::Widget widget ){ + GtkAllocation allocation; + gtk_widget_get_allocation(widget, &allocation); + return WindowVector( static_cast( allocation.width / 2 ), static_cast(allocation.height / 2 ) ); } -gboolean selection_button_press_freemove( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_press_freemove( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_PRESS ) { observer->onMouseDown( windowvector_for_widget_centre( widget ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } return FALSE; } -gboolean selection_button_release_freemove( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_release_freemove( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_RELEASE ) { observer->onMouseUp( windowvector_for_widget_centre( widget ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } return FALSE; } -gboolean selection_motion_freemove( GtkWidget *widget, GdkEventMotion *event, WindowObserver* observer ){ +gboolean selection_motion_freemove( ui::Widget widget, GdkEventMotion *event, WindowObserver* observer ){ observer->onMouseMotion( windowvector_for_widget_centre( widget ), modifiers_for_state( event->state ) ); return FALSE; } -gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* camwnd ){ +gboolean wheelmove_scroll( ui::Widget widget, GdkEventScroll* event, CamWnd* camwnd ){ if ( event->direction == GDK_SCROLL_UP ) { Camera_Freemove_updateAxes( camwnd->getCamera() ); Camera_setOrigin( *camwnd, vector3_added( Camera_getOrigin( *camwnd ), vector3_scaled( camwnd->getCamera().forward, static_cast( g_camwindow_globals_private.m_nMoveSpeed ) ) ) ); @@ -886,7 +891,7 @@ gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* cam return FALSE; } -gboolean camera_size_allocate( GtkWidget* widget, GtkAllocation* allocation, CamWnd* camwnd ){ +gboolean camera_size_allocate( ui::Widget widget, GtkAllocation* allocation, CamWnd* camwnd ){ camwnd->getCamera().width = allocation->width; camwnd->getCamera().height = allocation->height; Camera_updateProjection( camwnd->getCamera() ); @@ -895,7 +900,7 @@ gboolean camera_size_allocate( GtkWidget* widget, GtkAllocation* allocation, Cam return FALSE; } -gboolean camera_expose( GtkWidget* widget, GdkEventExpose* event, gpointer data ){ +gboolean camera_expose( ui::Widget widget, GdkEventExpose* event, gpointer data ){ reinterpret_cast( data )->draw(); return FALSE; } @@ -913,27 +918,27 @@ void KeyEvent_disconnect( const char* name ){ } void CamWnd_registerCommands( CamWnd& camwnd ){ - GlobalKeyEvents_insert( "CameraForward", Accelerator( GDK_Up ), + GlobalKeyEvents_insert( "CameraForward", Accelerator( GDK_KEY_Up ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraBack", Accelerator( GDK_Down ), + GlobalKeyEvents_insert( "CameraBack", Accelerator( GDK_KEY_Down ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraLeft", Accelerator( GDK_Left ), + GlobalKeyEvents_insert( "CameraLeft", Accelerator( GDK_KEY_Left ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraRight", Accelerator( GDK_Right ), + GlobalKeyEvents_insert( "CameraRight", Accelerator( GDK_KEY_Right ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraStrafeRight", Accelerator( GDK_period ), + GlobalKeyEvents_insert( "CameraStrafeRight", Accelerator( GDK_KEY_period ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraStrafeLeft", Accelerator( GDK_comma ), + GlobalKeyEvents_insert( "CameraStrafeLeft", Accelerator( GDK_KEY_comma ), ReferenceCaller( camwnd.getCamera() ), ReferenceCaller( camwnd.getCamera() ) ); @@ -954,19 +959,19 @@ void CamWnd_registerCommands( CamWnd& camwnd ){ ReferenceCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraFreeMoveForward", Accelerator( GDK_Up ), + GlobalKeyEvents_insert( "CameraFreeMoveForward", Accelerator( GDK_KEY_Up ), FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraFreeMoveBack", Accelerator( GDK_Down ), + GlobalKeyEvents_insert( "CameraFreeMoveBack", Accelerator( GDK_KEY_Down ), FreeMoveCameraMoveBackKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveBackKeyUpCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraFreeMoveLeft", Accelerator( GDK_Left ), + GlobalKeyEvents_insert( "CameraFreeMoveLeft", Accelerator( GDK_KEY_Left ), FreeMoveCameraMoveLeftKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveLeftKeyUpCaller( camwnd.getCamera() ) ); - GlobalKeyEvents_insert( "CameraFreeMoveRight", Accelerator( GDK_Right ), + GlobalKeyEvents_insert( "CameraFreeMoveRight", Accelerator( GDK_KEY_Right ), FreeMoveCameraMoveRightKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveRightKeyUpCaller( camwnd.getCamera() ) ); @@ -979,12 +984,12 @@ void CamWnd_registerCommands( CamWnd& camwnd ){ FreeMoveCameraMoveDownKeyUpCaller( camwnd.getCamera() ) ); - GlobalCommands_insert( "CameraForward", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_Up ) ); - GlobalCommands_insert( "CameraBack", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_Down ) ); - GlobalCommands_insert( "CameraLeft", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_Left ) ); - GlobalCommands_insert( "CameraRight", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_Right ) ); - GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_period ) ); - GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_comma ) ); + GlobalCommands_insert( "CameraForward", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_KEY_Up ) ); + GlobalCommands_insert( "CameraBack", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_KEY_Down ) ); + GlobalCommands_insert( "CameraLeft", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_KEY_Left ) ); + GlobalCommands_insert( "CameraRight", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_KEY_Right ) ); + GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_KEY_period ) ); + GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller( camwnd.getCamera() ), Accelerator( GDK_KEY_comma ) ); GlobalCommands_insert( "CameraUp", ReferenceCaller( camwnd.getCamera() ), Accelerator( 'D' ) ); GlobalCommands_insert( "CameraDown", ReferenceCaller( camwnd.getCamera() ), Accelerator( 'C' ) ); @@ -1077,11 +1082,11 @@ void CamWnd_Move_Discrete_Import( bool value ){ void CamWnd_Add_Handlers_Move( CamWnd& camwnd ){ - camwnd.m_selection_button_press_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_press_event", G_CALLBACK( selection_button_press ), camwnd.m_window_observer ); - camwnd.m_selection_button_release_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_release_event", G_CALLBACK( selection_button_release ), camwnd.m_window_observer ); - camwnd.m_selection_motion_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "motion_notify_event", G_CALLBACK( DeferredMotion::gtk_motion ), &camwnd.m_deferred_motion ); + camwnd.m_selection_button_press_handler = camwnd.m_gl_widget.connect( "button_press_event", G_CALLBACK( selection_button_press ), camwnd.m_window_observer ); + camwnd.m_selection_button_release_handler = camwnd.m_gl_widget.connect( "button_release_event", G_CALLBACK( selection_button_release ), camwnd.m_window_observer ); + camwnd.m_selection_motion_handler = camwnd.m_gl_widget.connect( "motion_notify_event", G_CALLBACK( DeferredMotion::gtk_motion ), &camwnd.m_deferred_motion ); - camwnd.m_freelook_button_press_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_press_event", G_CALLBACK( enable_freelook_button_press ), &camwnd ); + camwnd.m_freelook_button_press_handler = camwnd.m_gl_widget.connect( "button_press_event", G_CALLBACK( enable_freelook_button_press ), &camwnd ); if ( g_camwindow_globals_private.m_bCamDiscrete ) { CamWnd_Move_Discrete_Enable( camwnd ); @@ -1109,11 +1114,11 @@ void CamWnd_Remove_Handlers_Move( CamWnd& camwnd ){ } void CamWnd_Add_Handlers_FreeMove( CamWnd& camwnd ){ - camwnd.m_selection_button_press_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_press_event", G_CALLBACK( selection_button_press_freemove ), camwnd.m_window_observer ); - camwnd.m_selection_button_release_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_release_event", G_CALLBACK( selection_button_release_freemove ), camwnd.m_window_observer ); - camwnd.m_selection_motion_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "motion_notify_event", G_CALLBACK( selection_motion_freemove ), camwnd.m_window_observer ); + camwnd.m_selection_button_press_handler = camwnd.m_gl_widget.connect( "button_press_event", G_CALLBACK( selection_button_press_freemove ), camwnd.m_window_observer ); + camwnd.m_selection_button_release_handler = camwnd.m_gl_widget.connect( "button_release_event", G_CALLBACK( selection_button_release_freemove ), camwnd.m_window_observer ); + camwnd.m_selection_motion_handler = camwnd.m_gl_widget.connect( "motion_notify_event", G_CALLBACK( selection_motion_freemove ), camwnd.m_window_observer ); - camwnd.m_freelook_button_press_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_press_event", G_CALLBACK( disable_freelook_button_press ), &camwnd ); + camwnd.m_freelook_button_press_handler = camwnd.m_gl_widget.connect( "button_press_event", G_CALLBACK( disable_freelook_button_press ), &camwnd ); KeyEvent_connect( "CameraFreeMoveForward" ); KeyEvent_connect( "CameraFreeMoveBack" ); @@ -1145,7 +1150,7 @@ CamWnd::CamWnd() : m_gl_widget( glwidget_new( TRUE ) ), m_window_observer( NewWindowObserver() ), m_XORRectangle( m_gl_widget ), - m_deferredDraw( WidgetQueueDrawCaller( *m_gl_widget ) ), + m_deferredDraw( WidgetQueueDrawCaller( m_gl_widget ) ), m_deferred_motion( selection_motion, m_window_observer ), m_selection_button_press_handler( 0 ), m_selection_button_release_handler( 0 ), @@ -1160,13 +1165,13 @@ CamWnd::CamWnd() : m_window_observer->setRectangleDrawCallback( ReferenceCaller1( *this ) ); m_window_observer->setView( m_view ); - gtk_widget_ref( m_gl_widget ); + g_object_ref( m_gl_widget._handle ); gtk_widget_set_events( m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK ); - GTK_WIDGET_SET_FLAGS( m_gl_widget, GTK_CAN_FOCUS ); + gtk_widget_set_can_focus( m_gl_widget, true ); - m_sizeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "size_allocate", G_CALLBACK( camera_size_allocate ), this ); - m_exposeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "expose_event", G_CALLBACK( camera_expose ), this ); + m_sizeHandler = m_gl_widget.connect( "size_allocate", G_CALLBACK( camera_size_allocate ), this ); + m_exposeHandler = m_gl_widget.on_render( G_CALLBACK( camera_expose ), this ); Map_addValidCallback( g_map, DeferredDrawOnMapValidChangedCaller( m_deferredDraw ) ); @@ -1174,7 +1179,7 @@ CamWnd::CamWnd() : CamWnd_Add_Handlers_Move( *this ); - g_signal_connect( G_OBJECT( m_gl_widget ), "scroll_event", G_CALLBACK( wheelmove_scroll ), this ); + m_gl_widget.connect( "scroll_event", G_CALLBACK( wheelmove_scroll ), this ); AddSceneChangeCallback( ReferenceCaller( *this ) ); @@ -1191,7 +1196,7 @@ CamWnd::~CamWnd(){ g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_sizeHandler ); g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_exposeHandler ); - gtk_widget_unref( m_gl_widget ); + m_gl_widget.unref(); m_window_observer->release(); } @@ -1278,7 +1283,7 @@ void CamWnd::Cam_PositionDrag(){ // NOTE TTimo if there's an OS-level focus out of the application // then we can release the camera cursor grab -static gboolean camwindow_freemove_focusout( GtkWidget* widget, GdkEventFocus* event, gpointer data ){ +static gboolean camwindow_freemove_focusout( ui::Widget widget, GdkEventFocus* event, gpointer data ){ reinterpret_cast( data )->DisableFreeMove(); return FALSE; } @@ -1294,7 +1299,7 @@ void CamWnd::EnableFreeMove(){ CamWnd_Add_Handlers_FreeMove( *this ); gtk_window_set_focus( m_parent, m_gl_widget ); - m_freemove_handle_focusout = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( camwindow_freemove_focusout ), this ); + m_freemove_handle_focusout = m_gl_widget.connect( "focus_out_event", G_CALLBACK( camwindow_freemove_focusout ), this ); m_freezePointer.freeze_pointer( m_parent, Camera_motionDelta, &m_Camera ); CamWnd_Update( *this ); @@ -1599,7 +1604,7 @@ void CamWnd::BenchMark(){ } -void fill_view_camera_menu( GtkMenu* menu ){ +void fill_view_camera_menu( ui::Menu menu ){ create_check_menu_item_with_mnemonic( menu, "Camera View", "ToggleCamera" ); } @@ -1663,7 +1668,7 @@ void Camera_ToggleFarClip(){ } -void CamWnd_constructToolbar( GtkToolbar* toolbar ){ +void CamWnd_constructToolbar( ui::Toolbar toolbar ){ toolbar_append_toggle_button( toolbar, "Cubic clip the camera view (\\)", "view_cubicclipping.png", "ToggleCubicClip" ); } @@ -1873,42 +1878,42 @@ void CameraSpeed_decrease(){ /// \brief Initialisation for things that have the same lifespan as this module. void CamWnd_Construct(){ - GlobalCommands_insert( "CenterView", FreeCaller(), Accelerator( GDK_End ) ); + GlobalCommands_insert( "CenterView", FreeCaller(), Accelerator( GDK_KEY_End ) ); GlobalToggles_insert( "ToggleCubicClip", FreeCaller(), ToggleItem::AddCallbackCaller( g_getfarclip_item ), Accelerator( '\\', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "CubicClipZoomIn", FreeCaller(), Accelerator( '[', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "CubicClipZoomOut", FreeCaller(), Accelerator( ']', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "UpFloor", FreeCaller(), Accelerator( GDK_Prior ) ); - GlobalCommands_insert( "DownFloor", FreeCaller(), Accelerator( GDK_Next ) ); + GlobalCommands_insert( "UpFloor", FreeCaller(), Accelerator( GDK_KEY_Prior ) ); + GlobalCommands_insert( "DownFloor", FreeCaller(), Accelerator( GDK_KEY_Next ) ); GlobalToggles_insert( "ToggleCamera", ToggleShown::ToggleCaller( g_camera_shown ), ToggleItem::AddCallbackCaller( g_camera_shown.m_item ), Accelerator( 'C', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalCommands_insert( "LookThroughSelected", FreeCaller() ); GlobalCommands_insert( "LookThroughCamera", FreeCaller() ); if ( g_pGameDescription->mGameType == "doom3" ) { - GlobalCommands_insert( "TogglePreview", FreeCaller(), Accelerator( GDK_F3 ) ); + GlobalCommands_insert( "TogglePreview", FreeCaller(), Accelerator( GDK_KEY_F3 ) ); } - GlobalCommands_insert( "CameraSpeedInc", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "CameraSpeedDec", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "CameraSpeedInc", FreeCaller(), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "CameraSpeedDec", FreeCaller(), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalShortcuts_insert( "CameraForward", Accelerator( GDK_Up ) ); - GlobalShortcuts_insert( "CameraBack", Accelerator( GDK_Down ) ); - GlobalShortcuts_insert( "CameraLeft", Accelerator( GDK_Left ) ); - GlobalShortcuts_insert( "CameraRight", Accelerator( GDK_Right ) ); - GlobalShortcuts_insert( "CameraStrafeRight", Accelerator( GDK_period ) ); - GlobalShortcuts_insert( "CameraStrafeLeft", Accelerator( GDK_comma ) ); + GlobalShortcuts_insert( "CameraForward", Accelerator( GDK_KEY_Up ) ); + GlobalShortcuts_insert( "CameraBack", Accelerator( GDK_KEY_Down ) ); + GlobalShortcuts_insert( "CameraLeft", Accelerator( GDK_KEY_Left ) ); + GlobalShortcuts_insert( "CameraRight", Accelerator( GDK_KEY_Right ) ); + GlobalShortcuts_insert( "CameraStrafeRight", Accelerator( GDK_KEY_period ) ); + GlobalShortcuts_insert( "CameraStrafeLeft", Accelerator( GDK_KEY_comma ) ); GlobalShortcuts_insert( "CameraUp", Accelerator( 'D' ) ); GlobalShortcuts_insert( "CameraDown", Accelerator( 'C' ) ); GlobalShortcuts_insert( "CameraAngleUp", Accelerator( 'A' ) ); GlobalShortcuts_insert( "CameraAngleDown", Accelerator( 'Z' ) ); - GlobalShortcuts_insert( "CameraFreeMoveForward", Accelerator( GDK_Up ) ); - GlobalShortcuts_insert( "CameraFreeMoveBack", Accelerator( GDK_Down ) ); - GlobalShortcuts_insert( "CameraFreeMoveLeft", Accelerator( GDK_Left ) ); - GlobalShortcuts_insert( "CameraFreeMoveRight", Accelerator( GDK_Right ) ); + GlobalShortcuts_insert( "CameraFreeMoveForward", Accelerator( GDK_KEY_Up ) ); + GlobalShortcuts_insert( "CameraFreeMoveBack", Accelerator( GDK_KEY_Down ) ); + GlobalShortcuts_insert( "CameraFreeMoveLeft", Accelerator( GDK_KEY_Left ) ); + GlobalShortcuts_insert( "CameraFreeMoveRight", Accelerator( GDK_KEY_Right ) ); GlobalToggles_insert( "ShowStats", ShowStatsToggleCaller(), ToggleItem::AddCallbackCaller( g_show_stats ) ); diff --git a/radiant/camwindow.h b/radiant/camwindow.h index 8e578c85..d0722a79 100644 --- a/radiant/camwindow.h +++ b/radiant/camwindow.h @@ -22,12 +22,10 @@ #if !defined( INCLUDED_CAMWINDOW_H ) #define INCLUDED_CAMWINDOW_H +#include #include "math/vector.h" #include "signal/signalfwd.h" -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; - class CamWnd; CamWnd* NewCamWnd(); void DeleteCamWnd( CamWnd* camwnd ); @@ -36,15 +34,13 @@ void AddCameraMovedCallback( const SignalHandler& handler ); void CamWnd_Update( CamWnd& camwnd ); -GtkWidget* CamWnd_getWidget( CamWnd& camwnd ); -void CamWnd_setParent( CamWnd& camwnd, GtkWindow* parent ); +ui::GLArea CamWnd_getWidget( CamWnd& camwnd ); +void CamWnd_setParent( CamWnd& camwnd, ui::Window parent ); void GlobalCamera_setCamWnd( CamWnd& camwnd ); -typedef struct _GtkMenu GtkMenu; -void fill_view_camera_menu( GtkMenu* menu ); -typedef struct _GtkToolbar GtkToolbar; -void CamWnd_constructToolbar( GtkToolbar* toolbar ); +void fill_view_camera_menu( ui::Menu menu ); +void CamWnd_constructToolbar( ui::Toolbar toolbar ); void CamWnd_registerShortcuts(); void GlobalCamera_Benchmark(); diff --git a/radiant/commands.cpp b/radiant/commands.cpp index f608ea49..027b0dc3 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -21,16 +21,14 @@ #include "commands.h" +#include "gtk/gtk.h" #include "debugging/debugging.h" #include "warnings.h" #include #include "string/string.h" #include "versionlib.h" -#include "gtkutil/accelerator.h" #include "gtkutil/messagebox.h" -#include -#include #include "gtkmisc.h" typedef std::pair ShortcutValue; // accelerator, isRegistered @@ -150,13 +148,8 @@ void connect_accelerator( const char *name ){ } -#include - -#include -#include -#include -#include -#include +#include +#include #include "gtkutil/dialog.h" #include "mainframe.h" @@ -239,7 +232,7 @@ void accelerator_edit_button_clicked( GtkButton *btn, gpointer dialogptr ){ dialog.m_waiting_for_key = true; } -gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gpointer dialogptr ){ +bool accelerator_window_key_press( ui::Widget widget, GdkEventKey *event, gpointer dialogptr ){ command_list_dialog_t &dialog = *(command_list_dialog_t *) dialogptr; if ( !dialog.m_waiting_for_key ) { @@ -253,20 +246,20 @@ gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gp #else switch ( event->keyval ) { - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Caps_Lock: - case GDK_Shift_Lock: - case GDK_Meta_L: - case GDK_Meta_R: - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Super_L: - case GDK_Super_R: - case GDK_Hyper_L: - case GDK_Hyper_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Caps_Lock: + case GDK_KEY_Shift_Lock: + case GDK_KEY_Meta_L: + case GDK_KEY_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Super_L: + case GDK_KEY_Super_R: + case GDK_KEY_Hyper_L: + case GDK_KEY_Hyper_R: return false; } #endif @@ -293,11 +286,11 @@ gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gp { const char *commandName; const Accelerator &newAccel; - GtkWidget *widget; + ui::Widget widget; GtkTreeModel *model; public: bool allow; - VerifyAcceleratorNotTaken( const char *name, const Accelerator &accelerator, GtkWidget *w, GtkTreeModel *m ) : commandName( name ), newAccel( accelerator ), widget( w ), model( m ), allow( true ){ + VerifyAcceleratorNotTaken( const char *name, const Accelerator &accelerator, ui::Widget w, GtkTreeModel *m ) : commandName( name ), newAccel( accelerator ), widget( w ), model( m ), allow( true ){ } void visit( const char* name, Accelerator& accelerator ){ if ( !strcmp( name, commandName ) ) { @@ -313,8 +306,8 @@ public: StringOutputStream msg; msg << "The command " << name << " is already assigned to the key " << accelerator << ".\n\n" << "Do you want to unassign " << name << " first?"; - EMessageBoxReturn r = gtk_MessageBox( widget, msg.c_str(), "Key already used", eMB_YESNOCANCEL ); - if ( r == eIDYES ) { + auto r = widget.alert( msg.c_str(), "Key already used", ui::alert_type::YESNOCANCEL ); + if ( r == ui::alert_response::YES ) { // clear the ACTUAL accelerator too! disconnect_accelerator( name ); // delete the modifier @@ -338,7 +331,7 @@ public: } } } - else if ( r == eIDCANCEL ) { + else if ( r == ui::alert_response::CANCEL ) { // aborted allow = false; } @@ -394,41 +387,43 @@ public: void DoCommandListDlg(){ command_list_dialog_t dialog; - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Mapped Commands", dialog, -1, 400 ); - g_signal_connect( G_OBJECT( window ), "key-press-event", (GCallback) accelerator_window_key_press, &dialog ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Mapped Commands", dialog, -1, 400); + window.on_key_press([](ui::Widget widget, GdkEventKey *event, gpointer dialogptr) { + return accelerator_window_key_press(widget, event, dialogptr); + }, &dialog); - GtkAccelGroup* accel = gtk_accel_group_new(); - gtk_window_add_accel_group( window, accel ); + auto accel = ui::AccelGroup(); + window.add_accel_group( accel ); - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { - GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); + auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( scr ), TRUE, TRUE, 0 ); { - GtkListStore* store = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT ); + ui::ListStore store = ui::ListStore(gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT )); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView(ui::TreeModel(GTK_TREE_MODEL(store))); dialog.m_list = GTK_TREE_VIEW( view ); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), false ); // annoying { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Command", renderer, "text", 0, "weight-set", 2, "weight", 3, NULL ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Command", renderer, {{"text", 0}, {"weight-set", 2}, {"weight", 3}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Key", renderer, "text", 1, "weight-set", 2, "weight", 3, NULL ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Key", renderer, {{"text", 1}, {"weight-set", 2}, {"weight", 3}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } - gtk_widget_show( view ); - gtk_container_add( GTK_CONTAINER( scr ), view ); + view.show(); + scr.add(view); { // Initialize dialog @@ -438,9 +433,9 @@ void DoCommandListDlg(){ class BuildCommandList : public CommandVisitor { TextFileOutputStream m_commandList; - GtkListStore* m_store; + ui::ListStore m_store; public: - BuildCommandList( const char* filename, GtkListStore* store ) : m_commandList( filename ), m_store( store ){ + BuildCommandList( const char* filename, ui::ListStore store ) : m_commandList( filename ), m_store( store ){ } void visit( const char* name, Accelerator& accelerator ){ StringOutputStream modifiers; @@ -465,7 +460,7 @@ public: GlobalShortcuts_foreach( visitor ); } - g_object_unref( G_OBJECT( store ) ); + store.unref(); } } @@ -478,16 +473,16 @@ public: GtkButton* clearbutton = create_dialog_button( "Clear", (GCallback) accelerator_clear_button_clicked, &dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( clearbutton ), FALSE, FALSE, 0 ); - GtkWidget *spacer = gtk_image_new(); - gtk_widget_show( spacer ); + ui::Widget spacer = ui::Image(); + spacer.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( spacer ), TRUE, TRUE, 0 ); - GtkButton* button = create_modal_dialog_button( "Close", dialog.m_close_button ); + auto button = create_modal_dialog_button( "Close", dialog.m_close_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_grab_default( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); } modal_dialog_show( window, dialog ); diff --git a/radiant/console.cpp b/radiant/console.cpp index 72a64140..d4202247 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -22,10 +22,8 @@ #include "console.h" #include -#include -#include -#include -#include +#include +#include #include "gtkutil/accelerator.h" #include "gtkutil/messagebox.h" @@ -69,8 +67,8 @@ void Sys_LogFile( bool enable ){ << "This is NetRadiant '" RADIANT_VERSION "' compiled " __DATE__ "\n" RADIANT_ABOUTMSG "\n"; } else{ - gtk_MessageBox( 0, "Failed to create log file, check write permissions in Radiant directory.\n", - "Console logging", eMB_OK, eMB_ICONERROR ); + ui::root.alert( "Failed to create log file, check write permissions in Radiant directory.\n", + "Console logging", ui::alert_type::OK, ui::alert_icon::Error ); } } else if ( !enable && g_hLogFile != 0 ) { @@ -83,42 +81,42 @@ void Sys_LogFile( bool enable ){ } } -GtkWidget* g_console = 0; +ui::Widget g_console; void console_clear(){ GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( g_console ) ); gtk_text_buffer_set_text( buffer, "", -1 ); } -void console_populate_popup( GtkTextView* textview, GtkMenu* menu, gpointer user_data ){ +void console_populate_popup( GtkTextView* textview, ui::Menu menu, gpointer user_data ){ menu_separator( menu ); - GtkWidget* item = gtk_menu_item_new_with_label( "Clear" ); - g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( console_clear ), 0 ); - gtk_widget_show( item ); - container_add_widget( GTK_CONTAINER( menu ), item ); + ui::Widget item(ui::MenuItem( "Clear" )); + item.connect( "activate", G_CALLBACK( console_clear ), 0 ); + item.show(); + menu.add(item); } -gboolean destroy_set_null( GtkWindow* widget, GtkWidget** p ){ - *p = 0; +gboolean destroy_set_null( ui::Window widget, ui::Widget* p ){ + *p = ui::Widget(); return FALSE; } WidgetFocusPrinter g_consoleWidgetFocusPrinter( "console" ); -GtkWidget* Console_constructWindow( GtkWindow* toplevel ){ - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); +ui::Widget Console_constructWindow( ui::Window toplevel ){ + auto scr = ui::ScrolledWindow(); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); - gtk_widget_show( scr ); + scr.show(); { - GtkWidget* text = gtk_text_view_new(); + ui::Widget text = ui::TextView(); gtk_widget_set_size_request( text, 0, -1 ); // allow shrinking gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text ), GTK_WRAP_WORD ); gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), FALSE ); - gtk_container_add( GTK_CONTAINER( scr ), text ); - gtk_widget_show( text ); + scr.add(text); + text.show(); g_console = text; //globalExtendedASCIICharacterSet().print(); @@ -127,8 +125,8 @@ GtkWidget* Console_constructWindow( GtkWindow* toplevel ){ //g_consoleWidgetFocusPrinter.connect(g_console); - g_signal_connect( G_OBJECT( g_console ), "populate-popup", G_CALLBACK( console_populate_popup ), 0 ); - g_signal_connect( G_OBJECT( g_console ), "destroy", G_CALLBACK( destroy_set_null ), &g_console ); + g_console.connect( "populate-popup", G_CALLBACK( console_populate_popup ), 0 ); + g_console.connect( "destroy", G_CALLBACK( destroy_set_null ), &g_console ); } gtk_container_set_focus_chain( GTK_CONTAINER( scr ), NULL ); @@ -212,7 +210,7 @@ std::size_t Sys_Print( int level, const char* buf, std::size_t length ){ if ( contains_newline ) { gtk_text_view_scroll_mark_onscreen( GTK_TEXT_VIEW( g_console ), end ); - if ( !ScreenUpdates_Enabled() && GTK_WIDGET_REALIZED( g_console ) ) { + if ( !ScreenUpdates_Enabled() && gtk_widget_get_realized( g_console ) ) { ScreenUpdates_process(); } } diff --git a/radiant/console.h b/radiant/console.h index 38e479fd..8bbe71e1 100644 --- a/radiant/console.h +++ b/radiant/console.h @@ -23,6 +23,7 @@ #define INCLUDED_CONSOLE_H #include +#include #define SYS_VRB 0 ///< verbose support (on/off) #define SYS_STD 1 ///< standard print level - this is the default @@ -35,9 +36,7 @@ class TextOutputStream; TextOutputStream& getSysPrintOutputStream(); TextOutputStream& getSysPrintErrorStream(); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -GtkWidget* Console_constructWindow( GtkWindow* toplevel ); +ui::Widget Console_constructWindow( ui::Window toplevel ); // will open/close the log file based on the parameter void Sys_LogFile( bool enable ); diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index e98cac92..01e58f7c 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -28,6 +28,8 @@ #include "dialog.h" +#include + #include "debugging/debugging.h" @@ -35,19 +37,6 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "stream/stringstream.h" #include "convert.h" #include "gtkutil/dialog.h" @@ -58,9 +47,9 @@ #include "gtkmisc.h" -GtkEntry* DialogEntry_new(){ - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); +ui::Entry DialogEntry_new(){ + auto entry = ui::Entry(); + entry.show(); gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 ); return entry; } @@ -68,32 +57,32 @@ GtkEntry* DialogEntry_new(){ class DialogEntryRow { public: -DialogEntryRow( GtkWidget* row, GtkEntry* entry ) : m_row( row ), m_entry( entry ){ +DialogEntryRow( ui::Widget row, ui::Entry entry ) : m_row( row ), m_entry( entry ){ } -GtkWidget* m_row; -GtkEntry* m_entry; +ui::Widget m_row; +ui::Entry m_entry; }; DialogEntryRow DialogEntryRow_new( const char* name ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); - gtk_widget_show( alignment ); + auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); + alignment.show(); - GtkEntry* entry = DialogEntry_new(); - gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( entry ) ); + auto entry = DialogEntry_new(); + alignment.add(entry); - return DialogEntryRow( GTK_WIDGET( DialogRow_new( name, alignment ) ), entry ); + return DialogEntryRow( ui::Widget(GTK_WIDGET( DialogRow_new( name, alignment ) )), entry ); } -GtkSpinButton* DialogSpinner_new( double value, double lower, double upper, int fraction ){ +ui::SpinButton DialogSpinner_new( double value, double lower, double upper, int fraction ){ double step = 1.0 / double(fraction); unsigned int digits = 0; for (; fraction > 1; fraction /= 10 ) { ++digits; } - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( value, lower, upper, step, 10, 0 ) ), step, digits ) ); - gtk_widget_show( GTK_WIDGET( spin ) ); + auto spin = ui::SpinButton( ui::Adjustment( value, lower, upper, step, 10, 0 ), step, digits ); + spin.show(); gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 ); return spin; } @@ -101,20 +90,20 @@ GtkSpinButton* DialogSpinner_new( double value, double lower, double upper, int class DialogSpinnerRow { public: -DialogSpinnerRow( GtkWidget* row, GtkSpinButton* spin ) : m_row( row ), m_spin( spin ){ +DialogSpinnerRow( ui::Widget row, GtkSpinButton* spin ) : m_row( row ), m_spin( spin ){ } -GtkWidget* m_row; -GtkSpinButton* m_spin; +ui::Widget m_row; +ui::SpinButton m_spin; }; DialogSpinnerRow DialogSpinnerRow_new( const char* name, double value, double lower, double upper, int fraction ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); - gtk_widget_show( alignment ); + auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); + alignment.show(); - GtkSpinButton* spin = DialogSpinner_new( value, lower, upper, fraction ); - gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( spin ) ); + auto spin = DialogSpinner_new( value, lower, upper, fraction ); + alignment.add(spin); - return DialogSpinnerRow( GTK_WIDGET( DialogRow_new( name, alignment ) ), spin ); + return DialogSpinnerRow( ui::Widget(GTK_WIDGET( DialogRow_new( name, alignment ) )), spin ); } @@ -153,10 +142,10 @@ typedef ImportExport void IntRadioImport( GtkRadioButton& widget, int index ){ - radio_button_set_active( &widget, index ); + radio_button_set_active( ui::RadioButton(&widget), index ); } void IntRadioExport( GtkRadioButton& widget, const IntImportCallback& importCallback ){ - importCallback( radio_button_get_active( &widget ) ); + importCallback( radio_button_get_active( ui::RadioButton(&widget) ) ); } typedef ImportExport IntRadioImportExport; @@ -170,7 +159,7 @@ typedef ImportExport Te void IntEntryImport( GtkEntry& widget, int value ){ - entry_set_int( &widget, value ); + entry_set_int( ui::Entry(&widget), value ); } void IntEntryExport( GtkEntry& widget, const IntImportCallback& importCallback ){ importCallback( atoi( gtk_entry_get_text( &widget ) ) ); @@ -179,7 +168,7 @@ typedef ImportExport IntEntryImpo void SizeEntryImport( GtkEntry& widget, std::size_t value ){ - entry_set_int( &widget, int(value) ); + entry_set_int( ui::Entry(&widget), int(value) ); } void SizeEntryExport( GtkEntry& widget, const SizeImportCallback& importCallback ){ int value = atoi( gtk_entry_get_text( &widget ) ); @@ -192,7 +181,7 @@ typedef ImportExport Si void FloatEntryImport( GtkEntry& widget, float value ){ - entry_set_float( &widget, value ); + entry_set_float( ui::Entry(&widget), value ); } void FloatEntryExport( GtkEntry& widget, const FloatImportCallback& importCallback ){ importCallback( (float)atof( gtk_entry_get_text( &widget ) ) ); @@ -204,7 +193,7 @@ void FloatSpinnerImport( GtkSpinButton& widget, float value ){ gtk_spin_button_set_value( &widget, value ); } void FloatSpinnerExport( GtkSpinButton& widget, const FloatImportCallback& importCallback ){ - importCallback( float(gtk_spin_button_get_value_as_float( &widget ) ) ); + importCallback( float(gtk_spin_button_get_value( &widget ) ) ); } typedef ImportExport FloatSpinnerImportExport; @@ -318,39 +307,39 @@ Dialog::~Dialog(){ ( *i )->release(); } - ASSERT_MESSAGE( m_window == 0, "dialog window not destroyed" ); + ASSERT_MESSAGE( !m_window, "dialog window not destroyed" ); } void Dialog::ShowDlg(){ - ASSERT_MESSAGE( m_window != 0, "dialog was not constructed" ); + ASSERT_MESSAGE( m_window, "dialog was not constructed" ); importData(); - gtk_widget_show( GTK_WIDGET( m_window ) ); + m_window.show(); } void Dialog::HideDlg(){ - ASSERT_MESSAGE( m_window != 0, "dialog was not constructed" ); + ASSERT_MESSAGE( m_window, "dialog was not constructed" ); exportData(); gtk_widget_hide( GTK_WIDGET( m_window ) ); } -static gint delete_event_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){ +static gint delete_event_callback( ui::Widget widget, GdkEvent* event, gpointer data ){ reinterpret_cast( data )->HideDlg(); reinterpret_cast( data )->EndModal( eIDCANCEL ); return TRUE; } void Dialog::Create(){ - ASSERT_MESSAGE( m_window == 0, "dialog cannot be constructed" ); + ASSERT_MESSAGE( !m_window, "dialog cannot be constructed" ); m_window = BuildDialog(); - g_signal_connect( G_OBJECT( m_window ), "delete_event", G_CALLBACK( delete_event_callback ), this ); + m_window.connect( "delete_event", G_CALLBACK( delete_event_callback ), this ); } void Dialog::Destroy(){ - ASSERT_MESSAGE( m_window != 0, "dialog cannot be destroyed" ); + ASSERT_MESSAGE( m_window, "dialog cannot be destroyed" ); gtk_widget_destroy( GTK_WIDGET( m_window ) ); - m_window = 0; + m_window = ui::Window{ui::null}; } @@ -451,7 +440,7 @@ EMessageBoxReturn Dialog::DoModal(){ PreModal(); EMessageBoxReturn ret = modal_dialog_show( m_window, m_modal ); - ASSERT_NOTNULL( m_window ); + ASSERT_TRUE( (bool) m_window ); if ( ret == eIDOK ) { exportData(); } @@ -464,120 +453,120 @@ EMessageBoxReturn Dialog::DoModal(){ } -GtkWidget* Dialog::addCheckBox( GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){ - GtkWidget* check = gtk_check_button_new_with_label( flag ); - gtk_widget_show( check ); +ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){ + auto check = ui::CheckButton( flag ); + check.show(); AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, check ) ) ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), ui::Widget(GTK_WIDGET( DialogRow_new( name, check ) ) )); return check; } -GtkWidget* Dialog::addCheckBox( GtkWidget* vbox, const char* name, const char* flag, bool& data ){ +ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, bool& data ){ return addCheckBox( vbox, name, flag, BoolImportCaller( data ), BoolExportCaller( data ) ); } -void Dialog::addCombo( GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); - gtk_widget_show( alignment ); +void Dialog::addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ + auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); + alignment.show(); { - GtkWidget* combo = gtk_combo_box_new_text(); + auto combo = ui::ComboBoxText(); for ( StringArrayRange::Iterator i = values.first; i != values.last; ++i ) { - gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), *i ); + gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( combo ), *i ); } AddIntComboData( *GTK_COMBO_BOX( combo ), importViewer, exportViewer ); - gtk_widget_show( combo ); - gtk_container_add( GTK_CONTAINER( alignment ), combo ); + combo.show(); + alignment.add(combo); } - GtkTable* row = DialogRow_new( name, alignment ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); + auto row = DialogRow_new( name, alignment ); + DialogVBox_packRow( ui::VBox(GTK_VBOX(vbox)), row ); } -void Dialog::addCombo( GtkWidget* vbox, const char* name, int& data, StringArrayRange values ){ +void Dialog::addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ){ addCombo( vbox, name, values, IntImportCaller( data ), IntExportCaller( data ) ); } -void Dialog::addSlider( GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){ +void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){ #if 0 if ( draw_value == FALSE ) { - GtkWidget* hbox2 = gtk_hbox_new( FALSE, 0 ); - gtk_widget_show( hbox2 ); + ui::Widget hbox2 = ui::HBox( FALSE, 0 ); + hbox2.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 ); { - GtkWidget* label = gtk_label_new( low ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( low ); + label.show(); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 ); } { - GtkWidget* label = gtk_label_new( high ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( high ); + label.show(); gtk_box_pack_end( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 ); } } #endif // adjustment - GtkObject* adj = gtk_adjustment_new( value, lower, upper, step_increment, page_increment, 0 ); - AddIntAdjustmentData( *GTK_ADJUSTMENT( adj ), IntImportCaller( data ), IntExportCaller( data ) ); + auto adj = ui::Adjustment( value, lower, upper, step_increment, page_increment, 0 ); + AddIntAdjustmentData( *GTK_ADJUSTMENT(adj), IntImportCaller( data ), IntExportCaller( data ) ); // scale - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 1.0, 0.0 ); - gtk_widget_show( alignment ); + auto alignment = ui::Alignment( 0.0, 0.5, 1.0, 0.0 ); + alignment.show(); - GtkWidget* scale = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + ui::Widget scale = ui::HScale( adj ); gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_LEFT ); - gtk_widget_show( scale ); - gtk_container_add( GTK_CONTAINER( alignment ), scale ); + scale.show(); + alignment.add(scale); gtk_scale_set_draw_value( GTK_SCALE( scale ), draw_value ); gtk_scale_set_digits( GTK_SCALE( scale ), 0 ); - GtkTable* row = DialogRow_new( name, alignment ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); + auto row = DialogRow_new( name, alignment ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row ); } -void Dialog::addRadio( GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); - gtk_widget_show( alignment ); +void Dialog::addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ + auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); + alignment.show();; { RadioHBox radioBox = RadioHBox_new( names ); - gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( radioBox.m_hbox ) ); + alignment.add(radioBox.m_hbox); AddIntRadioData( *GTK_RADIO_BUTTON( radioBox.m_radio ), importViewer, exportViewer ); } - GtkTable* row = DialogRow_new( name, alignment ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); + auto row = DialogRow_new( name, alignment ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row ); } -void Dialog::addRadio( GtkWidget* vbox, const char* name, int& data, StringArrayRange names ){ +void Dialog::addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ){ addRadio( vbox, name, names, IntImportCaller( data ), IntExportCaller( data ) ); } -void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ - GtkWidget* table = gtk_table_new( 2, static_cast( icons.last - icons.first ), FALSE ); - gtk_widget_show( table ); +void Dialog::addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ + ui::Widget table = ui::Table( 2, icons.last - icons.first, FALSE ); + table.show();; gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); GSList* group = 0; - GtkWidget* radio = 0; + ui::RadioButton radio{ui::null}; for ( StringArrayRange::Iterator icon = icons.first; icon != icons.last; ++icon ) { guint pos = static_cast( icon - icons.first ); - GtkImage* image = new_local_image( *icon ); - gtk_widget_show( GTK_WIDGET( image ) ); + auto image = new_local_image( *icon ); + image.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( image ), pos, pos + 1, 0, 1, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); - radio = gtk_radio_button_new( group ); - gtk_widget_show( radio ); + radio = ui::RadioButton(GTK_RADIO_BUTTON(gtk_radio_button_new( group ))); + radio.show(); gtk_table_attach( GTK_TABLE( table ), radio, pos, pos + 1, 1, 2, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -587,64 +576,64 @@ void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange AddIntRadioData( *GTK_RADIO_BUTTON( radio ), importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, table ) ) ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), DialogRow_new( name, table ) ); } -void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, int& data, StringArrayRange icons ){ +void Dialog::addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ){ addRadioIcons( vbox, name, icons, IntImportCaller( data ), IntExportCaller( data ) ); } -GtkWidget* Dialog::addIntEntry( GtkWidget* vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ +ui::Widget Dialog::addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); - AddIntEntryData( *row.m_entry, importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); + AddIntEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); return row.m_row; } -GtkWidget* Dialog::addSizeEntry( GtkWidget* vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){ +ui::Widget Dialog::addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); - AddSizeEntryData( *row.m_entry, importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); + AddSizeEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); return row.m_row; } -GtkWidget* Dialog::addFloatEntry( GtkWidget* vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ +ui::Widget Dialog::addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); - AddFloatEntryData( *row.m_entry, importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); + AddFloatEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); return row.m_row; } -GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){ +ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){ PathEntry pathEntry = PathEntry_new(); - g_signal_connect( G_OBJECT( pathEntry.m_button ), "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry ); + pathEntry.m_button.connect( "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry ); - AddTextEntryData( *GTK_ENTRY( pathEntry.m_entry ), importViewer, exportViewer ); + AddTextEntryData( *GTK_ENTRY(pathEntry.m_entry), importViewer, exportViewer ); - GtkTable* row = DialogRow_new( name, GTK_WIDGET( pathEntry.m_frame ) ); - DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); + auto row = DialogRow_new( name, ui::Widget(GTK_WIDGET( pathEntry.m_frame )) ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row ); - return GTK_WIDGET( row ); + return ui::Widget(GTK_WIDGET( row )); } -GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, CopiedString& data, bool browse_directory ){ +ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, CopiedString& data, bool browse_directory ){ return addPathEntry( vbox, name, browse_directory, StringImportCallback( StringImportCaller( data ) ), StringExportCallback( StringExportCaller( data ) ) ); } -GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ +ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) ); - AddIntSpinnerData( *row.m_spin, importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); - return row.m_row; + AddIntSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), importViewer, exportViewer ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); + return ui::SpinButton(row.m_spin); } -GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper ){ +ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, int& data, double value, double lower, double upper ){ return addSpinner( vbox, name, value, lower, upper, IntImportCallback( IntImportCaller( data ) ), IntExportCallback( IntExportCaller( data ) ) ); } -GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ +ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) ); - AddFloatSpinnerData( *row.m_spin, importViewer, exportViewer ); - DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); - return row.m_row; + AddFloatSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), importViewer, exportViewer ); + DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); + return ui::SpinButton(row.m_spin); } diff --git a/radiant/dialog.h b/radiant/dialog.h index 2a0454eb..f4ce1667 100644 --- a/radiant/dialog.h +++ b/radiant/dialog.h @@ -23,6 +23,7 @@ #define INCLUDED_DIALOG_H #include +#include #include "gtkutil/dialog.h" #include "generic/callback.h" @@ -92,13 +93,6 @@ struct DLG_DATA virtual void exportData() const = 0; }; -typedef struct _GtkWindow GtkWindow; -typedef struct _GtkToggleButton GtkToggleButton; -typedef struct _GtkRadioButton GtkRadioButton; -typedef struct _GtkSpinButton GtkSpinButton; -typedef struct _GtkComboBox GtkComboBox; -typedef struct _GtkEntry GtkEntry; -typedef struct _GtkAdjustment GtkAdjustment; template class CallbackDialogData; @@ -107,11 +101,11 @@ typedef std::list DialogDataList; class Dialog { -GtkWindow* m_window; +ui::Window m_window; DialogDataList m_data; public: ModalDialog m_modal; -GtkWindow* m_parent; +ui::Window m_parent; Dialog(); virtual ~Dialog(); @@ -122,7 +116,7 @@ virtual ~Dialog(); */ EMessageBoxReturn DoModal(); void EndModal( EMessageBoxReturn code ); -virtual GtkWindow* BuildDialog() = 0; +virtual ui::Window BuildDialog() = 0; virtual void exportData(); virtual void importData(); virtual void PreModal() { }; @@ -131,63 +125,63 @@ virtual void ShowDlg(); virtual void HideDlg(); void Create(); void Destroy(); -GtkWindow* GetWidget(){ +ui::Window GetWidget(){ return m_window; } -const GtkWindow* GetWidget() const { +const ui::Window GetWidget() const { return m_window; } -GtkWidget* addCheckBox( GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ); -GtkWidget* addCheckBox( GtkWidget* vbox, const char* name, const char* flag, bool& data ); -void addCombo( GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addCombo( GtkWidget* vbox, const char* name, int& data, StringArrayRange values ); -void addSlider( GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ); -void addRadio( GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addRadio( GtkWidget* vbox, const char* name, int& data, StringArrayRange names ); -void addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addRadioIcons( GtkWidget* vbox, const char* name, int& data, StringArrayRange icons ); -GtkWidget* addIntEntry( GtkWidget* vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -GtkWidget* addEntry( GtkWidget* vbox, const char* name, int& data ){ +ui::CheckButton addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ); +ui::CheckButton addCheckBox( ui::Widget vbox, const char* name, const char* flag, bool& data ); +void addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ); +void addSlider( ui::Widget vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ); +void addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ); +void addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ); +ui::Widget addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +ui::Widget addEntry( ui::Widget vbox, const char* name, int& data ){ return addIntEntry( vbox, name, IntImportCaller( data ), IntExportCaller( data ) ); } -GtkWidget* addSizeEntry( GtkWidget* vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ); -GtkWidget* addEntry( GtkWidget* vbox, const char* name, std::size_t& data ){ +ui::Widget addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ); +ui::Widget addEntry( ui::Widget vbox, const char* name, std::size_t& data ){ return addSizeEntry( vbox, name, SizeImportCaller( data ), SizeExportCaller( data ) ); } -GtkWidget* addFloatEntry( GtkWidget* vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); -GtkWidget* addEntry( GtkWidget* vbox, const char* name, float& data ){ +ui::Widget addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); +ui::Widget addEntry( ui::Widget vbox, const char* name, float& data ){ return addFloatEntry( vbox, name, FloatImportCaller( data ), FloatExportCaller( data ) ); } -GtkWidget* addPathEntry( GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ); -GtkWidget* addPathEntry( GtkWidget* vbox, const char* name, CopiedString& data, bool directory ); -GtkWidget* addSpinner( GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper ); -GtkWidget* addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -GtkWidget* addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); +ui::Widget addPathEntry( ui::Widget vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ); +ui::Widget addPathEntry( ui::Widget vbox, const char* name, CopiedString& data, bool directory ); +ui::SpinButton addSpinner( ui::Widget vbox, const char* name, int& data, double value, double lower, double upper ); +ui::SpinButton addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +ui::SpinButton addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); protected: -void AddBoolToggleData( GtkToggleButton& object, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ); -void AddIntRadioData( GtkRadioButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void AddTextEntryData( GtkEntry& object, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ); -void AddIntEntryData( GtkEntry& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void AddSizeEntryData( GtkEntry& object, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ); -void AddFloatEntryData( GtkEntry& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); -void AddFloatSpinnerData( GtkSpinButton& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); -void AddIntSpinnerData( GtkSpinButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void AddIntAdjustmentData( GtkAdjustment& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void AddIntComboData( GtkComboBox& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); - -void AddDialogData( GtkToggleButton& object, bool& data ); -void AddDialogData( GtkRadioButton& object, int& data ); -void AddDialogData( GtkEntry& object, CopiedString& data ); -void AddDialogData( GtkEntry& object, int& data ); -void AddDialogData( GtkEntry& object, std::size_t& data ); -void AddDialogData( GtkEntry& object, float& data ); -void AddDialogData( GtkSpinButton& object, float& data ); -void AddDialogData( GtkSpinButton& object, int& data ); -void AddDialogData( GtkAdjustment& object, int& data ); -void AddDialogData( GtkComboBox& object, int& data ); +void AddBoolToggleData( struct _GtkToggleButton& object, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ); +void AddIntRadioData( struct _GtkRadioButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void AddTextEntryData( struct _GtkEntry& object, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ); +void AddIntEntryData( struct _GtkEntry& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void AddSizeEntryData( struct _GtkEntry& object, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ); +void AddFloatEntryData( struct _GtkEntry& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); +void AddFloatSpinnerData( struct _GtkSpinButton& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); +void AddIntSpinnerData( struct _GtkSpinButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void AddIntAdjustmentData( struct _GtkAdjustment& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void AddIntComboData( struct _GtkComboBox& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); + +void AddDialogData( struct _GtkToggleButton& object, bool& data ); +void AddDialogData( struct _GtkRadioButton& object, int& data ); +void AddDialogData( struct _GtkEntry& object, CopiedString& data ); +void AddDialogData( struct _GtkEntry& object, int& data ); +void AddDialogData( struct _GtkEntry& object, std::size_t& data ); +void AddDialogData( struct _GtkEntry& object, float& data ); +void AddDialogData( struct _GtkSpinButton& object, float& data ); +void AddDialogData( struct _GtkSpinButton& object, int& data ); +void AddDialogData( struct _GtkAdjustment& object, int& data ); +void AddDialogData( struct _GtkComboBox& object, int& data ); }; #endif diff --git a/radiant/entity.cpp b/radiant/entity.cpp index ab3243b0..cf726aca 100644 --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@ -45,6 +45,8 @@ #include "qe3.h" #include "commands.h" +#include "uilib/uilib.h" + struct entity_globals_t { Vector3 color_entity; @@ -287,7 +289,7 @@ int g_iLastLightIntensity; void Entity_createFromSelection( const char* name, const Vector3& origin ){ #if 0 if ( string_equal_nocase( name, "worldspawn" ) ) { - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "Can't create an entity with worldspawn.", "info" ); + ui::alert( GTK_WIDGET( MainFrame_getWindow() ), "Can't create an entity with worldspawn.", "info" ); return; } #endif @@ -381,7 +383,7 @@ void Entity_createFromSelection( const char* name, const Vector3& origin ){ } if ( isModel ) { - const char* model = misc_model_dialog( GTK_WIDGET( MainFrame_getWindow() ) ); + const char* model = misc_model_dialog(MainFrame_getWindow()); if ( model != 0 ) { Node_getEntity( node )->setKeyValue( "model", model ); } @@ -501,7 +503,7 @@ void Entity_setColour(){ normalize = false; } - if ( color_dialog( GTK_WIDGET( MainFrame_getWindow() ), g_entity_globals.color_entity ) ) { + if ( color_dialog( MainFrame_getWindow(), g_entity_globals.color_entity ) ) { if ( normalize ) { NormalizeColor( g_entity_globals.color_entity ); } @@ -517,7 +519,7 @@ void Entity_setColour(){ } } -const char* misc_model_dialog( GtkWidget* parent ){ +const char* misc_model_dialog( ui::Widget parent ){ StringOutputStream buffer( 1024 ); buffer << g_qeglobals.m_userGamePath.c_str() << "models/"; @@ -528,7 +530,7 @@ const char* misc_model_dialog( GtkWidget* parent ){ buffer << g_qeglobals.m_userGamePath.c_str() << "/"; } - const char *filename = file_dialog( parent, TRUE, "Choose Model", buffer.c_str(), ModelLoader::Name() ); + const char *filename = parent.file_dialog( TRUE, "Choose Model", buffer.c_str(), ModelLoader::Name() ); if ( filename != 0 ) { // use VFS to get the correct relative path const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) ); @@ -567,7 +569,7 @@ void Entity_registerPreferencesPage(){ -void Entity_constructMenu( GtkMenu* menu ){ +void Entity_constructMenu( ui::Menu menu ){ create_menu_item_with_mnemonic( menu, "_Regroup", "GroupSelection" ); create_menu_item_with_mnemonic( menu, "_Ungroup", "UngroupSelection" ); create_menu_item_with_mnemonic( menu, "_Connect", "ConnectSelection" ); diff --git a/radiant/entity.h b/radiant/entity.h index eaf73cbb..fca38f92 100644 --- a/radiant/entity.h +++ b/radiant/entity.h @@ -22,6 +22,8 @@ #if !defined( INCLUDED_ENTITY_H ) #define INCLUDED_ENTITY_H +#include + template class BasicVector3; typedef BasicVector3 Vector3; void Entity_createFromSelection( const char* name, const Vector3& origin ); @@ -30,11 +32,9 @@ void Scene_EntitySetKeyValue_Selected( const char* key, const char* value ); void Scene_EntitySetClassname_Selected( const char* classname ); -typedef struct _GtkWidget GtkWidget; -const char* misc_model_dialog( GtkWidget* parent ); +const char* misc_model_dialog( ui::Widget parent ); -typedef struct _GtkMenu GtkMenu; -void Entity_constructMenu( GtkMenu* menu ); +void Entity_constructMenu( ui::Menu menu ); void Entity_Construct(); void Entity_Destroy(); diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 5c1c330b..82c0bb5f 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -22,6 +22,7 @@ #include "entityinspector.h" #include "debugging/debugging.h" +#include #include "ientity.h" #include "ifilesystem.h" @@ -33,22 +34,7 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "os/path.h" @@ -78,9 +64,9 @@ #include "textureentry.h" #include "groupdialog.h" -GtkEntry* numeric_entry_new(){ - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); +ui::Entry numeric_entry_new(){ + auto entry = ui::Entry(); + entry.show(); gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 ); return entry; } @@ -118,7 +104,7 @@ void Scene_EntitySetKeyValue_Selected_Undoable( const char* key, const char* val class EntityAttribute { public: -virtual GtkWidget* getWidget() const = 0; +virtual ui::Widget getWidget() const = 0; virtual void update() = 0; virtual void release() = 0; }; @@ -128,7 +114,7 @@ class BooleanAttribute : public EntityAttribute CopiedString m_key; GtkCheckButton* m_check; -static gboolean toggled( GtkWidget *widget, BooleanAttribute* self ){ +static gboolean toggled( ui::Widget widget, BooleanAttribute* self ){ self->apply(); return FALSE; } @@ -136,18 +122,18 @@ public: BooleanAttribute( const char* key ) : m_key( key ), m_check( 0 ){ - GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new() ); - gtk_widget_show( GTK_WIDGET( check ) ); + auto check = ui::CheckButton(GTK_CHECK_BUTTON( gtk_check_button_new() )); + check.show(); m_check = check; - guint handler = g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( toggled ), this ); + guint handler = check.connect( "toggled", G_CALLBACK( toggled ), this ); g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler ) ); update(); } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_check ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_check )); } void release(){ delete this; @@ -160,11 +146,11 @@ typedef MemberCaller ApplyCaller; void update(){ const char* value = SelectedEntity_getValueForKey( m_key.c_str() ); if ( !string_empty( value ) ) { - toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_check ), atoi( value ) != 0 ); + toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( m_check )), atoi( value ) != 0 ); } else { - toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_check ), false ); + toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( m_check )), false ); } } typedef MemberCaller UpdateCaller; @@ -174,24 +160,24 @@ typedef MemberCaller UpdateCaller; class StringAttribute : public EntityAttribute { CopiedString m_key; -GtkEntry* m_entry; +ui::Entry m_entry; NonModalEntry m_nonModal; public: StringAttribute( const char* key ) : m_key( key ), - m_entry( 0 ), + m_entry( ui::null ), m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){ - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_entry = entry; m_nonModal.connect( m_entry ); } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry )); } -GtkEntry* getEntry() const { +ui::Entry getEntry() const { return m_entry; } @@ -237,8 +223,8 @@ ModelAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry.m_entry.m_frame ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry.m_entry.m_frame )); } void apply(){ StringOutputStream value( 64 ); @@ -253,7 +239,7 @@ void update(){ } typedef MemberCaller UpdateCaller; void browse( const BrowsedPathEntry::SetPathCallback& setPath ){ - const char *filename = misc_model_dialog( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) ); + const char *filename = misc_model_dialog( ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) )); if ( filename != 0 ) { setPath( filename ); @@ -263,7 +249,7 @@ void browse( const BrowsedPathEntry::SetPathCallback& setPath ){ typedef MemberCaller1 BrowseCaller; }; -const char* browse_sound( GtkWidget* parent ){ +const char* browse_sound( ui::Widget parent ){ StringOutputStream buffer( 1024 ); buffer << g_qeglobals.m_userGamePath.c_str() << "sound/"; @@ -274,7 +260,7 @@ const char* browse_sound( GtkWidget* parent ){ buffer << g_qeglobals.m_userGamePath.c_str() << "/"; } - const char* filename = file_dialog( parent, TRUE, "Open Wav File", buffer.c_str(), "sound" ); + const char* filename = parent.file_dialog(TRUE, "Open Wav File", buffer.c_str(), "sound" ); if ( filename != 0 ) { const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) ); if ( relative == filename ) { @@ -300,8 +286,8 @@ SoundAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry.m_entry.m_frame ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry.m_entry.m_frame )); } void apply(){ StringOutputStream value( 64 ); @@ -316,7 +302,7 @@ void update(){ } typedef MemberCaller UpdateCaller; void browse( const BrowsedPathEntry::SetPathCallback& setPath ){ - const char *filename = browse_sound( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) ); + const char *filename = browse_sound( ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) )) ); if ( filename != 0 ) { setPath( filename ); @@ -333,22 +319,22 @@ inline double angle_normalised( double angle ){ class AngleAttribute : public EntityAttribute { CopiedString m_key; -GtkEntry* m_entry; +ui::Entry m_entry; NonModalEntry m_nonModal; public: AngleAttribute( const char* key ) : m_key( key ), - m_entry( 0 ), + m_entry( ui::null ), m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){ - GtkEntry* entry = numeric_entry_new(); + auto entry = numeric_entry_new(); m_entry = entry; m_nonModal.connect( m_entry ); } void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry )); } void apply(){ StringOutputStream angle( 32 ); @@ -381,26 +367,26 @@ const String buttons[] = { "up", "down", "z-axis" }; class DirectionAttribute : public EntityAttribute { CopiedString m_key; -GtkEntry* m_entry; +ui::Entry m_entry; NonModalEntry m_nonModal; RadioHBox m_radio; NonModalRadio m_nonModalRadio; -GtkHBox* m_hbox; +ui::HBox m_hbox{ui::null}; public: DirectionAttribute( const char* key ) : m_key( key ), - m_entry( 0 ), + m_entry( ui::null ), m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ), m_radio( RadioHBox_new( STRING_ARRAY_RANGE( buttons ) ) ), m_nonModalRadio( ApplyRadioCaller( *this ) ){ - GtkEntry* entry = numeric_entry_new(); + auto entry = numeric_entry_new(); m_entry = entry; m_nonModal.connect( m_entry ); m_nonModalRadio.connect( m_radio.m_radio ); - m_hbox = GTK_HBOX( gtk_hbox_new( FALSE, 4 ) ); - gtk_widget_show( GTK_WIDGET( m_hbox ) ); + m_hbox = ui::HBox( FALSE, 4 ); + m_hbox.show(); gtk_box_pack_start( GTK_BOX( m_hbox ), GTK_WIDGET( m_radio.m_hbox ), TRUE, TRUE, 0 ); gtk_box_pack_start( GTK_BOX( m_hbox ), GTK_WIDGET( m_entry ), TRUE, TRUE, 0 ); @@ -408,8 +394,8 @@ DirectionAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_hbox ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_hbox )); } void apply(){ StringOutputStream angle( 32 ); @@ -467,10 +453,10 @@ typedef MemberCaller ApplyR class AnglesEntry { public: -GtkEntry* m_roll; -GtkEntry* m_pitch; -GtkEntry* m_yaw; -AnglesEntry() : m_roll( 0 ), m_pitch( 0 ), m_yaw( 0 ){ +ui::Entry m_roll; +ui::Entry m_pitch; +ui::Entry m_yaw; +AnglesEntry() : m_roll( ui::null ), m_pitch( ui::null ), m_yaw( ui::null ){ } }; @@ -481,27 +467,28 @@ class AnglesAttribute : public EntityAttribute CopiedString m_key; AnglesEntry m_angles; NonModalEntry m_nonModal; -GtkBox* m_hbox; +ui::HBox m_hbox; public: AnglesAttribute( const char* key ) : m_key( key ), - m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){ - m_hbox = GTK_BOX( gtk_hbox_new( TRUE, 4 ) ); - gtk_widget_show( GTK_WIDGET( m_hbox ) ); + m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ), + m_hbox(ui::HBox( TRUE, 4 )) +{ + m_hbox.show(); { - GtkEntry* entry = numeric_entry_new(); + auto entry = numeric_entry_new(); gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 ); m_angles.m_pitch = entry; m_nonModal.connect( m_angles.m_pitch ); } { - GtkEntry* entry = numeric_entry_new(); + auto entry = numeric_entry_new(); gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 ); m_angles.m_yaw = entry; m_nonModal.connect( m_angles.m_yaw ); } { - GtkEntry* entry = numeric_entry_new(); + auto entry = numeric_entry_new(); gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 ); m_angles.m_roll = entry; m_nonModal.connect( m_angles.m_roll ); @@ -510,8 +497,8 @@ AnglesAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_hbox ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_hbox )); } void apply(){ StringOutputStream angles( 64 ); @@ -556,10 +543,10 @@ typedef MemberCaller UpdateCaller; class Vector3Entry { public: -GtkEntry* m_x; -GtkEntry* m_y; -GtkEntry* m_z; -Vector3Entry() : m_x( 0 ), m_y( 0 ), m_z( 0 ){ +ui::Entry m_x; +ui::Entry m_y; +ui::Entry m_z; +Vector3Entry() : m_x( ui::null ), m_y( ui::null ), m_z( ui::null ){ } }; @@ -568,27 +555,27 @@ class Vector3Attribute : public EntityAttribute CopiedString m_key; Vector3Entry m_vector3; NonModalEntry m_nonModal; -GtkBox* m_hbox; +ui::Box m_hbox{ui::null}; public: Vector3Attribute( const char* key ) : m_key( key ), m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){ - m_hbox = GTK_BOX( gtk_hbox_new( TRUE, 4 ) ); - gtk_widget_show( GTK_WIDGET( m_hbox ) ); + m_hbox = ui::HBox( TRUE, 4 ); + m_hbox.show(); { - GtkEntry* entry = numeric_entry_new(); + auto entry = numeric_entry_new(); gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 ); m_vector3.m_x = entry; m_nonModal.connect( m_vector3.m_x ); } { - GtkEntry* entry = numeric_entry_new(); + auto entry = numeric_entry_new(); gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 ); m_vector3.m_y = entry; m_nonModal.connect( m_vector3.m_y ); } { - GtkEntry* entry = numeric_entry_new(); + auto entry = numeric_entry_new(); gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 ); m_vector3.m_z = entry; m_nonModal.connect( m_vector3.m_z ); @@ -597,8 +584,8 @@ Vector3Attribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_hbox ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_hbox )); } void apply(){ StringOutputStream vector3( 64 ); @@ -653,10 +640,10 @@ static gboolean changed( GtkComboBox *widget, NonModalComboBox* self ){ public: NonModalComboBox( const Callback& changed ) : m_changed( changed ), m_changedHandler( 0 ){ } -void connect( GtkComboBox* combo ){ - m_changedHandler = g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( changed ), this ); +void connect( ui::ComboBox combo ){ + m_changedHandler = combo.connect( "changed", G_CALLBACK( changed ), this ); } -void setActive( GtkComboBox* combo, int value ){ +void setActive( ui::ComboBox combo, int value ){ g_signal_handler_disconnect( G_OBJECT( combo ), m_changedHandler ); gtk_combo_box_set_active( combo, value ); connect( combo ); @@ -666,7 +653,7 @@ void setActive( GtkComboBox* combo, int value ){ class ListAttribute : public EntityAttribute { CopiedString m_key; -GtkComboBox* m_combo; +ui::ComboBox m_combo; NonModalComboBox m_nonModal; const ListAttributeType& m_type; public: @@ -675,14 +662,14 @@ ListAttribute( const char* key, const ListAttributeType& type ) : m_combo( 0 ), m_nonModal( ApplyCaller( *this ) ), m_type( type ){ - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); + auto combo = ui::ComboBoxText(); for ( ListAttributeType::const_iterator i = type.begin(); i != type.end(); ++i ) { - gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), ( *i ).first.c_str() ); + gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( combo ), ( *i ).first.c_str() ); } - gtk_widget_show( GTK_WIDGET( combo ) ); + combo.show(); m_nonModal.connect( combo ); m_combo = combo; @@ -690,8 +677,8 @@ ListAttribute( const char* key, const ListAttributeType& type ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_combo ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_combo )); } void apply(){ Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), m_type[gtk_combo_box_get_active( m_combo )].second.c_str() ); @@ -715,8 +702,8 @@ typedef MemberCaller UpdateCaller; namespace { -GtkWidget* g_entity_split1 = 0; -GtkWidget* g_entity_split2 = 0; +ui::Widget g_entity_split1; +ui::Widget g_entity_split2; int g_entitysplit1_position; int g_entitysplit2_position; @@ -730,8 +717,8 @@ GtkCheckButton* g_entitySpawnflagsCheck[MAX_FLAGS]; GtkEntry* g_entityKeyEntry; GtkEntry* g_entityValueEntry; -GtkListStore* g_entlist_store; -GtkListStore* g_entprops_store; +ui::ListStore g_entlist_store{ui::null}; +ui::ListStore g_entprops_store{ui::null}; const EntityClass* g_current_flags = 0; const EntityClass* g_current_comment = 0; const EntityClass* g_current_attributes = 0; @@ -744,7 +731,7 @@ int spawn_table[MAX_FLAGS]; // the table is a 4x4 in which we need to put the comment box g_entityClassComment and the spawn flags.. GtkTable* g_spawnflagsTable; -GtkVBox* g_attributeBox = 0; +ui::VBox g_attributeBox{ui::null}; typedef std::vector EntityAttributes; EntityAttributes g_entityAttributes; } @@ -817,9 +804,9 @@ const char* keyvalues_valueforkey( KeyValues& keyvalues, const char* key ){ class EntityClassListStoreAppend : public EntityClassVisitor { -GtkListStore* store; +ui::ListStore store; public: -EntityClassListStoreAppend( GtkListStore* store_ ) : store( store_ ){ +EntityClassListStoreAppend( ui::ListStore store_ ) : store( store_ ){ } void visit( EntityClass* e ){ GtkTreeIter iter; @@ -873,10 +860,10 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ { for ( int i = 0; i < g_spawnflag_count; ++i ) { - GtkWidget* widget = GTK_WIDGET( g_entitySpawnflagsCheck[i] ); - gtk_label_set_text( GTK_LABEL( GTK_BIN( widget )->child ), " " ); + ui::Widget widget = ui::Widget(GTK_WIDGET( g_entitySpawnflagsCheck[i] )); + gtk_label_set_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN(widget)) ), " " ); gtk_widget_hide( widget ); - gtk_widget_ref( widget ); + g_object_ref( widget ); gtk_container_remove( GTK_CONTAINER( g_spawnflagsTable ), widget ); } } @@ -886,8 +873,8 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ { for ( int i = 0; i < g_spawnflag_count; ++i ) { - GtkWidget* widget = GTK_WIDGET( g_entitySpawnflagsCheck[i] ); - gtk_widget_show( widget ); + ui::Widget widget = ui::Widget(GTK_WIDGET( g_entitySpawnflagsCheck[i] )); + widget.show(); StringOutputStream str( 16 ); str << LowerCase( eclass->flagnames[spawn_table[i]] ); @@ -895,9 +882,9 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ gtk_table_attach( g_spawnflagsTable, widget, i % 4, i % 4 + 1, i / 4, i / 4 + 1, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( GTK_FILL ), 0, 0 ); - gtk_widget_unref( widget ); + widget.unref(); - gtk_label_set_text( GTK_LABEL( GTK_BIN( widget )->child ), str.c_str() ); + gtk_label_set_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN(widget)) ), str.c_str() ); } } } @@ -913,7 +900,7 @@ void EntityClassList_selectEntityClass( EntityClass* eclass ){ GtkTreeView* view = g_entityClassList; GtkTreePath* path = gtk_tree_model_get_path( model, &iter ); gtk_tree_selection_select_path( gtk_tree_view_get_selection( view ), path ); - if ( GTK_WIDGET_REALIZED( view ) ) { + if ( gtk_widget_get_realized( GTK_WIDGET(view) ) ) { gtk_tree_view_scroll_to_cell( view, path, 0, FALSE, 0, 0 ); } gtk_tree_path_free( path ); @@ -924,8 +911,8 @@ void EntityClassList_selectEntityClass( EntityClass* eclass ){ } void EntityInspector_appendAttribute( const char* name, EntityAttribute& attribute ){ - GtkTable* row = DialogRow_new( name, attribute.getWidget() ); - DialogVBox_packRow( g_attributeBox, GTK_WIDGET( row ) ); + auto row = DialogRow_new( name, attribute.getWidget() ); + DialogVBox_packRow( ui::VBox(g_attributeBox), row ); } @@ -981,7 +968,7 @@ void EntityInspector_setEntityClass( EntityClass *eclass ){ if ( eclass != g_current_attributes ) { g_current_attributes = eclass; - container_remove_all( GTK_CONTAINER( g_attributeBox ) ); + container_remove_all( g_attributeBox ); GlobalEntityAttributes_clear(); for ( EntityClassAttributes::const_iterator i = eclass->m_attributes.begin(); i != eclass->m_attributes.end(); ++i ) @@ -1002,14 +989,14 @@ void EntityInspector_updateSpawnflags(){ { int v = !!( f & ( 1 << spawn_table[i] ) ); - toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] ), v ); + toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] )), v ); } } { // take care of the remaining ones for ( int i = g_spawnflag_count; i < MAX_FLAGS; ++i ) { - toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] ), FALSE ); + toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] )), FALSE ); } } } @@ -1047,7 +1034,7 @@ void EntityInspector_updateKeyValues(){ EntityInspector_updateSpawnflags(); - GtkListStore* store = g_entprops_store; + ui::ListStore store = g_entprops_store; // save current key/val pair around filling epair box // row_select wipes it and sets to first in list @@ -1106,7 +1093,7 @@ void EntityClassList_createEntity(){ GtkTreeModel* model; GtkTreeIter iter; if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( view ), &model, &iter ) == FALSE ) { - gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityClassList ) ), "You must have a selected class to create an entity", "info" ); + ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( g_entityClassList ) )).alert( "You must have a selected class to create an entity", "info" ); return; } @@ -1134,14 +1121,14 @@ void EntityInspector_applyKeyValue(){ // TTimo: if you change the classname to worldspawn you won't merge back in the structural brushes but create a parasite entity if ( !strcmp( key.c_str(), "classname" ) && !strcmp( value.c_str(), "worldspawn" ) ) { - gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry ) ), "Cannot change \"classname\" key back to worldspawn.", 0, eMB_OK ); + ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry )) ).alert( "Cannot change \"classname\" key back to worldspawn.", 0, ui::alert_type::OK ); return; } // RR2DO2: we don't want spaces in entity keys if ( strstr( key.c_str(), " " ) ) { - gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry ) ), "No spaces are allowed in entity keys.", 0, eMB_OK ); + ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry )) ).alert( "No spaces are allowed in entity keys.", 0, ui::alert_type::OK ); return; } @@ -1197,7 +1184,7 @@ static void EntityClassList_selection_changed( GtkTreeSelection* selection, gpoi } } -static gint EntityClassList_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){ +static gint EntityClassList_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){ if ( event->type == GDK_2BUTTON_PRESS ) { EntityClassList_createEntity(); return TRUE; @@ -1205,10 +1192,10 @@ static gint EntityClassList_button_press( GtkWidget *widget, GdkEventButton *eve return FALSE; } -static gint EntityClassList_keypress( GtkWidget* widget, GdkEventKey* event, gpointer data ){ +static gint EntityClassList_keypress( ui::Widget widget, GdkEventKey* event, gpointer data ){ unsigned int code = gdk_keyval_to_upper( event->keyval ); - if ( event->keyval == GDK_Return ) { + if ( event->keyval == GDK_KEY_Return ) { EntityClassList_createEntity(); return TRUE; } @@ -1231,7 +1218,7 @@ static gint EntityClassList_keypress( GtkWidget* widget, GdkEventKey* event, gpo if ( toupper( text[0] ) == (int)code ) { GtkTreePath* path = gtk_tree_model_get_path( model, &iter ); gtk_tree_selection_select_path( gtk_tree_view_get_selection( view ), path ); - if ( GTK_WIDGET_REALIZED( view ) ) { + if ( gtk_widget_get_realized( GTK_WIDGET(view) ) ) { gtk_tree_view_scroll_to_cell( view, path, 0, FALSE, 0, 0 ); } gtk_tree_path_free( path ); @@ -1269,12 +1256,12 @@ static void EntityProperties_selection_changed( GtkTreeSelection* selection, gpo g_free( val ); } -static void SpawnflagCheck_toggled( GtkWidget *widget, gpointer data ){ +static void SpawnflagCheck_toggled( ui::Widget widget, gpointer data ){ EntityInspector_applySpawnflags(); } static gint EntityEntry_keypress( GtkEntry* widget, GdkEventKey* event, gpointer data ){ - if ( event->keyval == GDK_Return ) { + if ( event->keyval == GDK_KEY_Return ) { if ( widget == g_entityKeyEntry ) { gtk_entry_set_text( g_entityValueEntry, "" ); gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), GTK_WIDGET( g_entityValueEntry ) ); @@ -1285,7 +1272,7 @@ static gint EntityEntry_keypress( GtkEntry* widget, GdkEventKey* event, gpointer } return TRUE; } - if ( event->keyval == GDK_Escape ) { + if ( event->keyval == GDK_KEY_Escape ) { gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), NULL ); return TRUE; } @@ -1293,7 +1280,7 @@ static gint EntityEntry_keypress( GtkEntry* widget, GdkEventKey* event, gpointer return FALSE; } -void EntityInspector_destroyWindow( GtkWidget* widget, gpointer data ){ +void EntityInspector_destroyWindow( ui::Widget widget, gpointer data ){ g_entitysplit1_position = gtk_paned_get_position( GTK_PANED( g_entity_split1 ) ); g_entitysplit2_position = gtk_paned_get_position( GTK_PANED( g_entity_split2 ) ); @@ -1301,148 +1288,148 @@ void EntityInspector_destroyWindow( GtkWidget* widget, gpointer data ){ GlobalEntityAttributes_clear(); } -GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ - GtkWidget* vbox = gtk_vbox_new( FALSE, 2 ); - gtk_widget_show( vbox ); +ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ + ui::Widget vbox = ui::VBox( FALSE, 2 ); + vbox.show(); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 2 ); - g_signal_connect( G_OBJECT( vbox ), "destroy", G_CALLBACK( EntityInspector_destroyWindow ), 0 ); + vbox.connect( "destroy", G_CALLBACK( EntityInspector_destroyWindow ), 0 ); { - GtkWidget* split1 = gtk_vpaned_new(); + ui::Widget split1 = ui::VPaned(); gtk_box_pack_start( GTK_BOX( vbox ), split1, TRUE, TRUE, 0 ); - gtk_widget_show( split1 ); + split1.show(); g_entity_split1 = split1; { - GtkWidget* split2 = gtk_vpaned_new(); + ui::Widget split2 = ui::VPaned(); gtk_paned_add1( GTK_PANED( split1 ), split2 ); - gtk_widget_show( split2 ); + split2.show(); g_entity_split2 = split2; { // class list - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); - gtk_widget_show( scr ); + auto scr = ui::ScrolledWindow(); + scr.show(); gtk_paned_add1( GTK_PANED( split2 ), scr ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); { - GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ); + ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER )); - GtkTreeView* view = GTK_TREE_VIEW( gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ) ); + auto view = ui::TreeView( ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE ); gtk_tree_view_set_headers_visible( view, FALSE ); - g_signal_connect( G_OBJECT( view ), "button_press_event", G_CALLBACK( EntityClassList_button_press ), 0 ); - g_signal_connect( G_OBJECT( view ), "key_press_event", G_CALLBACK( EntityClassList_keypress ), 0 ); + view.connect( "button_press_event", G_CALLBACK( EntityClassList_button_press ), 0 ); + view.connect( "key_press_event", G_CALLBACK( EntityClassList_keypress ), 0 ); { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Key", renderer, "text", 0, 0 ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Key", renderer, {{"text", 0}} ); gtk_tree_view_append_column( view, column ); } { - GtkTreeSelection* selection = gtk_tree_view_get_selection( view ); - g_signal_connect( G_OBJECT( selection ), "changed", G_CALLBACK( EntityClassList_selection_changed ), 0 ); + auto selection = ui::TreeSelection(gtk_tree_view_get_selection( view )); + selection.connect( "changed", G_CALLBACK( EntityClassList_selection_changed ), 0 ); } - gtk_widget_show( GTK_WIDGET( view ) ); + view.show(); - gtk_container_add( GTK_CONTAINER( scr ), GTK_WIDGET( view ) ); + scr.add(view); - g_object_unref( G_OBJECT( store ) ); + store.unref(); g_entityClassList = view; g_entlist_store = store; } } { - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); - gtk_widget_show( scr ); + auto scr = ui::ScrolledWindow(); + scr.show(); gtk_paned_add2( GTK_PANED( split2 ), scr ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); { - GtkTextView* text = GTK_TEXT_VIEW( gtk_text_view_new() ); + auto text = ui::TextView(); gtk_widget_set_size_request( GTK_WIDGET( text ), 0, -1 ); // allow shrinking gtk_text_view_set_wrap_mode( text, GTK_WRAP_WORD ); gtk_text_view_set_editable( text, FALSE ); - gtk_widget_show( GTK_WIDGET( text ) ); - gtk_container_add( GTK_CONTAINER( scr ), GTK_WIDGET( text ) ); + text.show(); + scr.add(text); g_entityClassComment = text; } } } { - GtkWidget* split2 = gtk_vpaned_new(); + ui::Widget split2 = ui::VPaned(); gtk_paned_add2( GTK_PANED( split1 ), split2 ); - gtk_widget_show( split2 ); + split2.show(); { - GtkWidget* vbox2 = gtk_vbox_new( FALSE, 2 ); - gtk_widget_show( vbox2 ); + ui::Widget vbox2 = ui::VBox( FALSE, 2 ); + vbox2.show(); gtk_paned_pack1( GTK_PANED( split2 ), vbox2, FALSE, FALSE ); { // Spawnflags (4 colums wide max, or window gets too wide.) - GtkTable* table = GTK_TABLE( gtk_table_new( 4, 4, FALSE ) ); + auto table = ui::Table( 4, 4, FALSE ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), FALSE, TRUE, 0 ); - gtk_widget_show( GTK_WIDGET( table ) ); + table.show(); g_spawnflagsTable = table; for ( int i = 0; i < MAX_FLAGS; i++ ) { - GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new_with_label( "" ) ); - gtk_widget_ref( GTK_WIDGET( check ) ); - g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( SpawnflagCheck_toggled ), 0 ) ) ); + auto check = ui::CheckButton( "" ); + g_object_ref( GTK_WIDGET( check ) ); + g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( check.connect( "toggled", G_CALLBACK( SpawnflagCheck_toggled ), 0 ) ) ); g_entitySpawnflagsCheck[i] = check; } } { // key/value list - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); - gtk_widget_show( scr ); + auto scr = ui::ScrolledWindow(); + scr.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), scr, TRUE, TRUE, 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); { - GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ); + ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING )); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 1, 0 ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 1}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } { - GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); - g_signal_connect( G_OBJECT( selection ), "changed", G_CALLBACK( EntityProperties_selection_changed ), 0 ); + auto selection = ui::TreeSelection(gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) )); + selection.connect( "changed", G_CALLBACK( EntityProperties_selection_changed ), 0 ); } - gtk_widget_show( view ); + view.show(); - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); - g_object_unref( G_OBJECT( store ) ); + store.unref(); g_entprops_store = store; } @@ -1450,37 +1437,37 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ { // key/value entry - GtkTable* table = GTK_TABLE( gtk_table_new( 2, 2, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); + auto table = ui::Table( 2, 2, FALSE ); + table.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), FALSE, TRUE, 0 ); gtk_table_set_row_spacings( table, 3 ); gtk_table_set_col_spacings( table, 5 ); { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); gtk_widget_set_events( GTK_WIDGET( entry ), GDK_KEY_PRESS_MASK ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 ); g_entityKeyEntry = entry; } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); gtk_widget_set_events( GTK_WIDGET( entry ), GDK_KEY_PRESS_MASK ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 ); g_entityValueEntry = entry; } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Value" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Value" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); @@ -1488,8 +1475,8 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Key" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Key" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); @@ -1498,39 +1485,39 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkBox* hbox = GTK_BOX( gtk_hbox_new( TRUE, 4 ) ); - gtk_widget_show( GTK_WIDGET( hbox ) ); + auto hbox = ui::HBox( TRUE, 4 ); + hbox.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( hbox ), FALSE, TRUE, 0 ); { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Clear All" ) ); - gtk_widget_show( GTK_WIDGET( button ) ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( EntityInspector_clearAllKeyValues ), 0 ); + auto button = ui::Button( "Clear All" ); + button.show(); + button.connect( "clicked", G_CALLBACK( EntityInspector_clearAllKeyValues ), 0 ); gtk_box_pack_start( hbox, GTK_WIDGET( button ), TRUE, TRUE, 0 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Delete Key" ) ); - gtk_widget_show( GTK_WIDGET( button ) ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( EntityInspector_clearKeyValue ), 0 ); + auto button = ui::Button( "Delete Key" ); + button.show(); + button.connect( "clicked", G_CALLBACK( EntityInspector_clearKeyValue ), 0 ); gtk_box_pack_start( hbox, GTK_WIDGET( button ), TRUE, TRUE, 0 ); } } } { - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); - gtk_widget_show( scr ); + auto scr = ui::ScrolledWindow(); + scr.show(); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); - GtkWidget* viewport = gtk_viewport_new( 0, 0 ); - gtk_widget_show( viewport ); + auto viewport = ui::Container(GTK_CONTAINER(gtk_viewport_new( 0, 0 ))); + viewport.show(); gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport ), GTK_SHADOW_NONE ); - g_attributeBox = GTK_VBOX( gtk_vbox_new( FALSE, 2 ) ); - gtk_widget_show( GTK_WIDGET( g_attributeBox ) ); + g_attributeBox = ui::VBox( FALSE, 2 ); + g_attributeBox.show(); - gtk_container_add( GTK_CONTAINER( viewport ), GTK_WIDGET( g_attributeBox ) ); - gtk_container_add( GTK_CONTAINER( scr ), viewport ); + viewport.add(g_attributeBox); + scr.add(viewport); gtk_paned_pack2( GTK_PANED( split2 ), scr, FALSE, FALSE ); } } diff --git a/radiant/entityinspector.h b/radiant/entityinspector.h index 1afa2584..e0d359ec 100644 --- a/radiant/entityinspector.h +++ b/radiant/entityinspector.h @@ -19,12 +19,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_ENTITYINSPECTOR_H ) #define INCLUDED_ENTITYINSPECTOR_H -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -GtkWidget* EntityInspector_constructWindow( GtkWindow* parent ); +ui::Widget EntityInspector_constructWindow( ui::Window parent ); void EntityInspector_construct(); void EntityInspector_destroy(); const char *EntityInspector_getCurrentKey(); diff --git a/radiant/entitylist.cpp b/radiant/entitylist.cpp index 4fdc5b4e..35cbc847 100644 --- a/radiant/entitylist.cpp +++ b/radiant/entitylist.cpp @@ -23,10 +23,8 @@ #include "iselection.h" -#include -#include -#include -#include +#include +#include #include "string/string.h" #include "scenelib.h" @@ -45,7 +43,6 @@ void RedrawEntityList(); typedef FreeCaller RedrawEntityListCaller; -typedef struct _GtkTreeView GtkTreeView; class EntityList { @@ -62,7 +59,7 @@ EDirty m_dirty; IdleDraw m_idleDraw; WindowPositionTracker m_positionTracker; -GtkWindow* m_window; +ui::Window m_window; GtkTreeView* m_tree_view; GraphTreeModel* m_tree_model; bool m_selection_disabled; @@ -75,7 +72,7 @@ EntityList() : } bool visible() const { - return GTK_WIDGET_VISIBLE( GTK_WIDGET( m_window ) ); + return gtk_widget_get_visible( m_window ); } }; @@ -247,7 +244,7 @@ void entitylist_treeview_row_expanded( GtkTreeView* view, GtkTreeIter* iter, Gtk void EntityList_SetShown( bool shown ){ - widget_set_visible( GTK_WIDGET( getEntityList().m_window ), shown ); + widget_set_visible( getEntityList().m_window, shown ); } void EntityList_toggleShown(){ @@ -282,12 +279,12 @@ void DetachEntityTreeModel(){ gtk_tree_view_set_model( getEntityList().m_tree_view, 0 ); } -void EntityList_constructWindow( GtkWindow* main_window ){ - ASSERT_MESSAGE( getEntityList().m_window == 0, "error" ); +void EntityList_constructWindow( ui::Window main_window ){ + ASSERT_TRUE( !getEntityList().m_window ); - GtkWindow* window = create_persistent_floating_window( "Entity List", main_window ); + auto window = ui::Window(create_persistent_floating_window( "Entity List", main_window )); - gtk_window_add_accel_group( window, global_accel ); + window.add_accel_group(global_accel); getEntityList().m_positionTracker.connect( window ); @@ -295,14 +292,14 @@ void EntityList_constructWindow( GtkWindow* main_window ){ getEntityList().m_window = window; { - GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( scr ) ); + auto scr = create_scrolled_window( ui::Policy::AUTOMATIC, ui::Policy::AUTOMATIC ); + window.add(scr); { - GtkWidget* view = gtk_tree_view_new(); + ui::Widget view = ui::TreeView(); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); GtkTreeViewColumn* column = gtk_tree_view_column_new(); gtk_tree_view_column_pack_start( column, renderer, TRUE ); gtk_tree_view_column_set_cell_data_func( column, renderer, entitylist_treeviewcolumn_celldatafunc, 0, 0 ); @@ -310,13 +307,13 @@ void EntityList_constructWindow( GtkWindow* main_window ){ GtkTreeSelection* select = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); gtk_tree_selection_set_mode( select, GTK_SELECTION_MULTIPLE ); - g_signal_connect( G_OBJECT( view ), "row_expanded", G_CALLBACK( entitylist_treeview_row_expanded ), 0 ); - g_signal_connect( G_OBJECT( view ), "row_collapsed", G_CALLBACK( entitylist_treeview_rowcollapsed ), 0 ); + view.connect( "row_expanded", G_CALLBACK( entitylist_treeview_row_expanded ), 0 ); + view.connect( "row_collapsed", G_CALLBACK( entitylist_treeview_rowcollapsed ), 0 ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); - gtk_widget_show( view ); - gtk_container_add( GTK_CONTAINER( scr ), view ); + view.show(); + scr.add(view); getEntityList().m_tree_view = GTK_TREE_VIEW( view ); } } diff --git a/radiant/entitylist.h b/radiant/entitylist.h index e29f1b9a..4830bb8d 100644 --- a/radiant/entitylist.h +++ b/radiant/entitylist.h @@ -19,14 +19,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_ENTITYLIST_H ) #define INCLUDED_ENTITYLIST_H void EntityList_Construct(); void EntityList_Destroy(); -typedef struct _GtkWindow GtkWindow; -void EntityList_constructWindow( GtkWindow* main_window ); +void EntityList_constructWindow( ui::Window main_window ); void EntityList_destroyWindow(); void EntityList_toggleShown(); diff --git a/radiant/feedback.cpp b/radiant/feedback.cpp index 1d2856f5..e1c3c48c 100644 --- a/radiant/feedback.cpp +++ b/radiant/feedback.cpp @@ -27,18 +27,13 @@ #include "feedback.h" +#include + #include "debugging/debugging.h" #include "igl.h" #include "iselection.h" -#include -#include -#include -#include -#include -#include - #include "map.h" #include "dialog.h" #include "mainframe.h" @@ -270,7 +265,7 @@ void CDbgDlg::Init(){ g_ptr_array_remove_index( m_pFeedbackElements, 0 ); } - if ( m_clist != NULL ) { + if ( m_clist ) { gtk_list_store_clear( m_clist ); } } @@ -279,7 +274,7 @@ void CDbgDlg::Push( ISAXHandler *pHandler ){ // push in the list g_ptr_array_add( m_pFeedbackElements, (void *)pHandler ); - if ( GetWidget() == 0 ) { + if ( !GetWidget() ) { Create(); } @@ -295,38 +290,38 @@ void CDbgDlg::Push( ISAXHandler *pHandler ){ ShowDlg(); } -GtkWindow* CDbgDlg::BuildDialog(){ - GtkWindow* window = create_floating_window( "Q3Map debug window", MainFrame_getWindow() ); +ui::Window CDbgDlg::BuildDialog(){ + auto window = MainFrame_getWindow().create_floating_window("Q3Map debug window" ); - GtkWidget* scr = gtk_scrolled_window_new( NULL, NULL ); - gtk_widget_show( scr ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( scr ) ); + auto scr = ui::ScrolledWindow(); + scr.show(); + window.add(scr); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); { - GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); + ui::ListStore store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, NULL ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } { - GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); + auto selection = ui::TreeSelection(gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) )); gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE ); - g_signal_connect( G_OBJECT( selection ), "changed", G_CALLBACK( feedback_selection_changed ), NULL ); + selection.connect( "changed", G_CALLBACK( feedback_selection_changed ), NULL ); } - gtk_widget_show( view ); + view.show(); - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); - g_object_unref( G_OBJECT( store ) ); + store.unref(); m_clist = store; } diff --git a/radiant/feedback.h b/radiant/feedback.h index 04e98bb2..a9271755 100644 --- a/radiant/feedback.h +++ b/radiant/feedback.h @@ -30,7 +30,6 @@ #include "math/vector.h" #include "stream/stringstream.h" -#include #include "xmlstuff.h" #include "dialog.h" #include "xywindow.h" @@ -143,13 +142,12 @@ void DecRef() { void Draw2D( VIEWTYPE vt ); }; -typedef struct _GtkListStore GtkListStore; class CDbgDlg : public Dialog { GPtrArray *m_pFeedbackElements; // the list widget we use in the dialog -GtkListStore* m_clist; +ui::ListStore m_clist{ui::null}; ISAXHandler *m_pHighlight; IGL2DWindow* m_pDraw2D; public: @@ -171,13 +169,13 @@ void draw2D( VIEWTYPE viewType ){ } } void destroyWindow(){ - if ( GetWidget() != 0 ) { + if ( GetWidget() ) { Destroy(); } } // void HideDlg(); protected: -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); }; extern CDbgDlg g_DbgDlg; diff --git a/radiant/filters.cpp b/radiant/filters.cpp index 3ff4ddd0..14eec0cd 100644 --- a/radiant/filters.cpp +++ b/radiant/filters.cpp @@ -171,7 +171,7 @@ void ResetFilters(){ } } -void Filters_constructMenu( GtkMenu* menu_in_menu ){ +void Filters_constructMenu( ui::Menu menu_in_menu ){ create_check_menu_item_with_mnemonic( menu_in_menu, "World", "FilterWorldBrushes" ); create_check_menu_item_with_mnemonic( menu_in_menu, "Entities", "FilterEntities" ); if ( g_pGameDescription->mGameType == "doom3" ) { diff --git a/radiant/filters.h b/radiant/filters.h index 97766ab8..9779585a 100644 --- a/radiant/filters.h +++ b/radiant/filters.h @@ -19,10 +19,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_FILTERS_H ) #define INCLUDED_FILTERS_H -typedef struct _GtkMenu GtkMenu; -void Filters_constructMenu( GtkMenu* menu_in_menu ); +void Filters_constructMenu( ui::Menu menu_in_menu ); #endif diff --git a/radiant/findtexturedialog.cpp b/radiant/findtexturedialog.cpp index 5fd58f7c..9766843a 100644 --- a/radiant/findtexturedialog.cpp +++ b/radiant/findtexturedialog.cpp @@ -27,22 +27,12 @@ #include "findtexturedialog.h" +#include + #include "debugging/debugging.h" #include "ishaders.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "gtkutil/window.h" #include "stream/stringstream.h" @@ -65,9 +55,9 @@ static void updateTextures( const char* name ); FindTextureDialog(); virtual ~FindTextureDialog(); -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); -void constructWindow( GtkWindow* parent ){ +void constructWindow( ui::Window parent ){ m_parent = parent; Create(); } @@ -95,7 +85,7 @@ void FindTextureDialog_apply(){ FindReplaceTextures( find.c_str(), replace.c_str(), g_FindTextureDialog.m_bSelectedOnly ); } -static void OnApply( GtkWidget* widget, gpointer data ){ +static void OnApply( ui::Widget widget, gpointer data ){ g_FindTextureDialog.exportData(); FindTextureDialog_apply(); } @@ -111,17 +101,17 @@ static void OnOK( GtkWidget* widget, gpointer data ){ g_FindTextureDialog.HideDlg(); } -static void OnClose( GtkWidget* widget, gpointer data ){ +static void OnClose( ui::Widget widget, gpointer data ){ g_FindTextureDialog.HideDlg(); } -static gint find_focus_in( GtkWidget* widget, GdkEventFocus *event, gpointer data ){ +static gint find_focus_in( ui::Widget widget, GdkEventFocus *event, gpointer data ){ g_bFindActive = true; return FALSE; } -static gint replace_focus_in( GtkWidget* widget, GdkEventFocus *event, gpointer data ){ +static gint replace_focus_in( ui::Widget widget, GdkEventFocus *event, gpointer data ){ g_bFindActive = false; return FALSE; } @@ -137,83 +127,84 @@ FindTextureDialog::FindTextureDialog(){ FindTextureDialog::~FindTextureDialog(){ } -GtkWindow* FindTextureDialog::BuildDialog(){ - GtkWidget* vbox, *hbox, *table, *label; - GtkWidget* button, *check, *entry; +ui::Window FindTextureDialog::BuildDialog(){ + ui::Widget vbox, hbox, table, label; + ui::Widget button; + ui::Entry entry{ui::null}; - GtkWindow* dlg = create_floating_window( "Find / Replace Texture(s)", m_parent ); + auto dlg = ui::Window(create_floating_window( "Find / Replace Texture(s)", m_parent )); - hbox = gtk_hbox_new( FALSE, 5 ); - gtk_widget_show( hbox ); - gtk_container_add( GTK_CONTAINER( dlg ), GTK_WIDGET( hbox ) ); + hbox = ui::HBox( FALSE, 5 ); + hbox.show(); + dlg.add(hbox); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 5 ); - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_widget_show( vbox ); + vbox = ui::VBox( FALSE, 5 ); + vbox.show(); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); - table = gtk_table_new( 2, 2, FALSE ); - gtk_widget_show( table ); + table = ui::Table( 2, 2, FALSE ); + table.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Find:" ); - gtk_widget_show( label ); + label = ui::Label( "Find:" ); + label.show(); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); - label = gtk_label_new( "Replace:" ); - gtk_widget_show( label ); + label = ui::Label( "Replace:" ); + label.show(); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); - entry = gtk_entry_new(); - gtk_widget_show( entry ); + entry = ui::Entry(); + entry.show(); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( entry ), "focus_in_event", + entry.connect( "focus_in_event", G_CALLBACK( find_focus_in ), 0 ); - AddDialogData( *GTK_ENTRY( entry ), m_strFind ); - GlobalTextureEntryCompletion::instance().connect( GTK_ENTRY( entry ) ); + AddDialogData( *GTK_ENTRY(entry), m_strFind ); + GlobalTextureEntryCompletion::instance().connect( entry ); - entry = gtk_entry_new(); - gtk_widget_show( entry ); + entry = ui::Entry(); + entry.show(); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( entry ), "focus_in_event", + entry.connect( "focus_in_event", G_CALLBACK( replace_focus_in ), 0 ); - AddDialogData( *GTK_ENTRY( entry ), m_strReplace ); - GlobalTextureEntryCompletion::instance().connect( GTK_ENTRY( entry ) ); + AddDialogData( *GTK_ENTRY(entry), m_strReplace ); + GlobalTextureEntryCompletion::instance().connect( entry ); - check = gtk_check_button_new_with_label( "Within selected brushes only" ); - gtk_widget_show( check ); + auto check = ui::CheckButton( "Within selected brushes only" ); + check.show(); gtk_box_pack_start( GTK_BOX( vbox ), check, TRUE, TRUE, 0 ); - AddDialogData( *GTK_TOGGLE_BUTTON( check ), m_bSelectedOnly ); + AddDialogData( *GTK_TOGGLE_BUTTON(check), m_bSelectedOnly ); - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_widget_show( vbox ); + vbox = ui::VBox( FALSE, 5 ); + vbox.show(); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); - button = gtk_button_new_with_label( "Apply" ); - gtk_widget_show( button ); + button = ui::Button( "Apply" ); + button.show(); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + button.connect( "clicked", G_CALLBACK( OnApply ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); - button = gtk_button_new_with_label( "Close" ); - gtk_widget_show( button ); + button = ui::Button( "Close" ); + button.show(); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + button.connect( "clicked", G_CALLBACK( OnClose ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); return dlg; } @@ -231,7 +222,7 @@ void FindTextureDialog::updateTextures( const char* name ){ } bool FindTextureDialog::isOpen(){ - return GTK_WIDGET_VISIBLE( g_FindTextureDialog.GetWidget() ) == TRUE; + return gtk_widget_get_visible( g_FindTextureDialog.GetWidget() ) == TRUE; } void FindTextureDialog::setFindStr( const char* name ){ @@ -251,7 +242,7 @@ void FindTextureDialog::show(){ } -void FindTextureDialog_constructWindow( GtkWindow* main_window ){ +void FindTextureDialog_constructWindow( ui::Window main_window ){ g_FindTextureDialog.constructWindow( main_window ); } diff --git a/radiant/findtexturedialog.h b/radiant/findtexturedialog.h index 2bf06dbb..66022e8b 100644 --- a/radiant/findtexturedialog.h +++ b/radiant/findtexturedialog.h @@ -19,14 +19,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_FINDTEXTUREDIALOG_H ) #define INCLUDED_FINDTEXTUREDIALOG_H void FindTextureDialog_Construct(); void FindTextureDialog_Destroy(); -typedef struct _GtkWindow GtkWindow; -void FindTextureDialog_constructWindow( GtkWindow* main_window ); +void FindTextureDialog_constructWindow( ui::Window main_window ); void FindTextureDialog_destroyWindow(); bool FindTextureDialog_isOpen(); void FindTextureDialog_selectTexture( const char* name ); diff --git a/radiant/grid.cpp b/radiant/grid.cpp index 148fa4fa..8ede1a22 100644 --- a/radiant/grid.cpp +++ b/radiant/grid.cpp @@ -212,7 +212,7 @@ void Grid_registerCommands(){ } -void Grid_constructMenu( GtkMenu* menu ){ +void Grid_constructMenu( ui::Menu menu ){ create_check_menu_item_with_mnemonic( menu, "Grid0.125", "SetGrid0.125" ); create_check_menu_item_with_mnemonic( menu, "Grid0.25", "SetGrid0.25" ); create_check_menu_item_with_mnemonic( menu, "Grid0.5", "SetGrid0.5" ); diff --git a/radiant/grid.h b/radiant/grid.h index 53b717c1..d3c28ec2 100644 --- a/radiant/grid.h +++ b/radiant/grid.h @@ -22,6 +22,7 @@ #if !defined( INCLUDED_GRID_H ) #define INCLUDED_GRID_H +#include #include "signal/signalfwd.h" float GetSnapGridSize(); @@ -31,8 +32,7 @@ int Grid_getPower(); void AddGridChangeCallback( const SignalHandler& handler ); void Grid_registerCommands(); -typedef struct _GtkMenu GtkMenu; -void Grid_constructMenu( GtkMenu* menu ); +void Grid_constructMenu( ui::Menu menu ); void Grid_registerShortcuts(); diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index 2e717d12..7a301ce8 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -31,11 +31,7 @@ #include "debugging/debugging.h" #include - -#include -#include -#include -#include +#include #include "gtkutil/widget.h" #include "gtkutil/accelerator.h" @@ -46,22 +42,21 @@ #include "commands.h" -#include #include "gtkutil/window.h" class GroupDlg { public: -GtkWidget* m_pNotebook; -GtkWindow* m_window; +ui::Widget m_pNotebook; +ui::Window m_window; GroupDlg(); -void Create( GtkWindow* parent ); +void Create( ui::Window parent ); void Show(){ // workaround for strange gtk behaviour - modifying the contents of a window while it is not visible causes the window position to change without sending a configure_event m_position_tracker.sync( m_window ); - gtk_widget_show( GTK_WIDGET( m_window ) ); + m_window.show(); } void Hide(){ gtk_widget_hide( GTK_WIDGET( m_window ) ); @@ -78,14 +73,14 @@ std::size_t g_current_page; std::vector g_pages; } -void GroupDialog_updatePageTitle( GtkWindow* window, std::size_t pageIndex ){ +void GroupDialog_updatePageTitle( ui::Window window, std::size_t pageIndex ){ if ( pageIndex < g_pages.size() ) { g_pages[pageIndex]( PointerCaller1( window ) ); } } -static gboolean switch_page( GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data ){ - GroupDialog_updatePageTitle( GTK_WINDOW( data ), page_num ); +static gboolean switch_page( GtkNotebook *notebook, gpointer page, guint page_num, gpointer data ){ + GroupDialog_updatePageTitle( ui::Window(GTK_WINDOW( data )), page_num ); g_current_page = page_num; return FALSE; @@ -95,10 +90,10 @@ GroupDlg::GroupDlg() : m_window( 0 ){ m_position_tracker.setPosition( c_default_window_pos ); } -void GroupDlg::Create( GtkWindow* parent ){ - ASSERT_MESSAGE( m_window == 0, "dialog already created" ); +void GroupDlg::Create( ui::Window parent ){ + ASSERT_MESSAGE( !m_window, "dialog already created" ); - GtkWindow* window = create_persistent_floating_window( "Entities", parent ); + auto window = ui::Window(create_persistent_floating_window( "Entities", parent )); global_accel_connect_window( window ); @@ -116,21 +111,21 @@ void GroupDlg::Create( GtkWindow* parent ){ m_position_tracker.connect( window ); { - GtkWidget* notebook = gtk_notebook_new(); - gtk_widget_show( notebook ); - gtk_container_add( GTK_CONTAINER( window ), notebook ); + ui::Widget notebook = ui::Widget(gtk_notebook_new()); + notebook.show(); + window.add(notebook); gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_BOTTOM ); m_pNotebook = notebook; - g_signal_connect( G_OBJECT( notebook ), "switch_page", G_CALLBACK( switch_page ), window ); + notebook.connect( "switch_page", G_CALLBACK( switch_page ), (gpointer) window ); } } -GtkWidget* GroupDialog_addPage( const char* tabLabel, GtkWidget* widget, const StringExportCallback& title ){ - GtkWidget* w = gtk_label_new( tabLabel ); - gtk_widget_show( w ); - GtkWidget* page = gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gtk_notebook_insert_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), widget, w, -1 ) ); +ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const StringExportCallback& title ){ + ui::Widget w = ui::Label( tabLabel ); + w.show(); + ui::Widget page = ui::Widget(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gtk_notebook_insert_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), widget, w, -1 ) )); g_pages.push_back( title ); return page; @@ -138,7 +133,7 @@ GtkWidget* GroupDialog_addPage( const char* tabLabel, GtkWidget* widget, const S bool GroupDialog_isShown(){ - return widget_is_visible( GTK_WIDGET( g_GroupDlg.m_window ) ); + return widget_is_visible( g_GroupDlg.m_window ); } void GroupDialog_setShown( bool shown ){ shown ? g_GroupDlg.Show() : g_GroupDlg.Hide(); @@ -147,39 +142,39 @@ void GroupDialog_ToggleShow(){ GroupDialog_setShown( !GroupDialog_isShown() ); } -void GroupDialog_constructWindow( GtkWindow* main_window ){ +void GroupDialog_constructWindow( ui::Window main_window ){ g_GroupDlg.Create( main_window ); } void GroupDialog_destroyWindow(){ - ASSERT_NOTNULL( g_GroupDlg.m_window ); + ASSERT_TRUE( g_GroupDlg.m_window ); destroy_floating_window( g_GroupDlg.m_window ); - g_GroupDlg.m_window = 0; + g_GroupDlg.m_window = ui::Window{ui::null}; } -GtkWindow* GroupDialog_getWindow(){ - return g_GroupDlg.m_window; +ui::Window GroupDialog_getWindow(){ + return ui::Window(g_GroupDlg.m_window); } void GroupDialog_show(){ g_GroupDlg.Show(); } -GtkWidget* GroupDialog_getPage(){ - return gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ); +ui::Widget GroupDialog_getPage(){ + return ui::Widget(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) )); } -void GroupDialog_setPage( GtkWidget* page ){ +void GroupDialog_setPage( ui::Widget page ){ g_current_page = gtk_notebook_page_num( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), page ); gtk_notebook_set_current_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ); } -void GroupDialog_showPage( GtkWidget* page ){ +void GroupDialog_showPage( ui::Widget page ){ if ( GroupDialog_getPage() == page ) { GroupDialog_ToggleShow(); } else { - gtk_widget_show( GTK_WIDGET( g_GroupDlg.m_window ) ); + g_GroupDlg.m_window.show(); GroupDialog_setPage( page ); } } @@ -189,7 +184,7 @@ void GroupDialog_cycle(){ gtk_notebook_set_current_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ); } -void GroupDialog_updatePageTitle( GtkWidget* page ){ +void GroupDialog_updatePageTitle( ui::Widget page ){ if ( GroupDialog_getPage() == page ) { GroupDialog_updatePageTitle( g_GroupDlg.m_window, g_current_page ); } diff --git a/radiant/groupdialog.h b/radiant/groupdialog.h index 349802b1..50e880b4 100644 --- a/radiant/groupdialog.h +++ b/radiant/groupdialog.h @@ -22,28 +22,26 @@ #if !defined( INCLUDED_GROUPDIALOG_H ) #define INCLUDED_GROUPDIALOG_H +#include #include "generic/callback.h" -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; - void GroupDialog_Construct(); void GroupDialog_Destroy(); -void GroupDialog_constructWindow( GtkWindow* main_window ); +void GroupDialog_constructWindow( ui::Window main_window ); void GroupDialog_destroyWindow(); -GtkWindow* GroupDialog_getWindow(); +ui::Window GroupDialog_getWindow(); void GroupDialog_show(); inline void RawStringExport( const char* string, const StringImportCallback& importer ){ importer( string ); } typedef ConstPointerCaller1 RawStringExportCaller; -GtkWidget* GroupDialog_addPage( const char* tabLabel, GtkWidget* widget, const StringExportCallback& title ); +ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const StringExportCallback& title ); -void GroupDialog_showPage( GtkWidget* page ); -void GroupDialog_updatePageTitle( GtkWidget* page ); +void GroupDialog_showPage( ui::Widget page ); +void GroupDialog_updatePageTitle( ui::Widget page ); bool GroupDialog_isShown(); -GtkWidget* GroupDialog_getPage(); +ui::Widget GroupDialog_getPage(); #endif diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index dbc3abd6..a5e03e31 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -36,6 +36,8 @@ #include "gtkdlgs.h" +#include + #include "debugging/debugging.h" #include "version.h" #include "aboutmsg.h" @@ -45,22 +47,7 @@ #include "iselection.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "os/path.h" #include "math/aabb.h" @@ -167,11 +154,11 @@ inline void path_copy_clean( char* destination, const char* source ){ struct GameCombo { - GtkComboBox* game_select; + ui::ComboBoxText game_select; GtkEntry* fsgame_entry; }; -gboolean OnSelchangeComboWhatgame( GtkWidget *widget, GameCombo* combo ){ +gboolean OnSelchangeComboWhatgame( ui::Widget widget, GameCombo* combo ){ const char *gamename; { GtkTreeIter iter; @@ -214,12 +201,12 @@ GameCombo game_combo; GtkComboBox* gamemode_combo; }; -GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){ - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Project Settings", G_CALLBACK( dialog_delete_callback ), &modal ); +ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){ + auto window = MainFrame_getWindow().create_dialog_window("Project Settings", G_CALLBACK(dialog_delete_callback ), &modal ); { - GtkTable* table1 = create_dialog_table( 1, 2, 4, 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( table1 ) ); + auto table1 = create_dialog_table( 1, 2, 4, 4, 4 ); + window.add(table1); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_table_attach( table1, GTK_WIDGET( vbox ), 1, 2, 0, 1, @@ -235,50 +222,50 @@ GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal } } { - GtkFrame* frame = create_dialog_frame( "Project settings" ); + auto frame = create_dialog_frame( "Project settings" ); gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); { - GtkTable* table2 = create_dialog_table( ( globalMappingMode().do_mapping_mode ) ? 4 : 3, 2, 4, 4, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table2 ) ); + auto table2 = create_dialog_table( ( globalMappingMode().do_mapping_mode ) ? 4 : 3, 2, 4, 4, 4 ); + frame.add(table2); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Select mod" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Select mod" ); + label.show(); gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); } { - dialog.game_combo.game_select = GTK_COMBO_BOX( gtk_combo_box_new_text() ); + dialog.game_combo.game_select = ui::ComboBoxText(); - gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().basegame ); + gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().basegame ); if ( globalGameComboConfiguration().known[0] != '\0' ) { - gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().known ); + gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().known ); } - gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().custom ); + gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().custom ); - gtk_widget_show( GTK_WIDGET( dialog.game_combo.game_select ) ); + dialog.game_combo.game_select.show(); gtk_table_attach( table2, GTK_WIDGET( dialog.game_combo.game_select ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( dialog.game_combo.game_select ), "changed", G_CALLBACK( OnSelchangeComboWhatgame ), &dialog.game_combo ); + dialog.game_combo.game_select.connect( "changed", G_CALLBACK( OnSelchangeComboWhatgame ), &dialog.game_combo ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "fs_game" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "fs_game" ); + label.show(); gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table2, GTK_WIDGET( entry ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -287,18 +274,18 @@ GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal } if ( globalMappingMode().do_mapping_mode ) { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Mapping mode" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Mapping mode" ); + label.show(); gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); - gtk_combo_box_append_text( combo, globalMappingMode().sp_mapping_mode ); - gtk_combo_box_append_text( combo, globalMappingMode().mp_mapping_mode ); + auto combo = ui::ComboBoxText(); + gtk_combo_box_text_append_text( combo, globalMappingMode().sp_mapping_mode ); + gtk_combo_box_text_append_text( combo, globalMappingMode().mp_mapping_mode ); - gtk_widget_show( GTK_WIDGET( combo ) ); + combo.show(); gtk_table_attach( table2, GTK_WIDGET( combo ), 1, 2, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -366,7 +353,7 @@ void DoProjectSettings(){ ModalDialog modal; ProjectSettingsDialog dialog; - GtkWindow* window = ProjectSettingsDialog_construct( dialog, modal ); + ui::Window window = ProjectSettingsDialog_construct( dialog, modal ); if ( modal_dialog_show( window, modal ) == eIDOK ) { ProjectSettingsDialog_ok( dialog ); @@ -383,22 +370,22 @@ void DoSides( int type, int axis ){ ModalDialog dialog; GtkEntry* sides_entry; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Arbitrary sides", G_CALLBACK( dialog_delete_callback ), &dialog ); + auto window = MainFrame_getWindow().create_dialog_window("Arbitrary sides", G_CALLBACK(dialog_delete_callback ), &dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); - gtk_window_add_accel_group( window, accel ); + auto accel = ui::AccelGroup(); + window.add_accel_group( accel ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Sides:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Sides:" ); + label.show(); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( entry ), FALSE, FALSE, 0 ); sides_entry = entry; gtk_widget_grab_focus( GTK_WIDGET( entry ) ); @@ -407,15 +394,15 @@ void DoSides( int type, int axis ){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); + auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + widget_make_default( button ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); } } } @@ -432,13 +419,13 @@ void DoSides( int type, int axis ){ // ============================================================================= // About dialog (no program is complete without one) -void about_button_changelog( GtkWidget *widget, gpointer data ){ +void about_button_changelog( ui::Widget widget, gpointer data ){ StringOutputStream log( 256 ); log << "https://gitlab.com/xonotic/netradiant/commits/master"; OpenURL( log.c_str() ); } -void about_button_credits( GtkWidget *widget, gpointer data ){ +void about_button_credits( ui::Widget widget, gpointer data ){ StringOutputStream cred( 256 ); cred << "https://gitlab.com/xonotic/netradiant/graphs/master"; OpenURL( cred.c_str() ); @@ -454,11 +441,11 @@ void DoAbout(){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "About NetRadiant", dialog ); + auto window = MainFrame_getWindow().create_modal_dialog_window("About NetRadiant", dialog ); { - GtkVBox* vbox = create_dialog_vbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + auto vbox = create_dialog_vbox( 4, 4 ); + window.add(vbox); { GtkHBox* hbox = create_dialog_hbox( 4 ); @@ -468,28 +455,29 @@ void DoAbout(){ GtkVBox* vbox2 = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), TRUE, FALSE, 0 ); { - GtkFrame* frame = create_dialog_frame( 0, GTK_SHADOW_IN ); + auto frame = create_dialog_frame( 0, ui::Shadow::IN ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); { - GtkImage* image = new_local_image( "logo.png" ); - gtk_widget_show( GTK_WIDGET( image ) ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( image ) ); + auto image = new_local_image( "logo.png" ); + image.show(); + frame.add(image); } } } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "NetRadiant " RADIANT_VERSION "\n" - __DATE__ "\n\n" - RADIANT_ABOUTMSG "\n\n" - "By xonotic.org\n\n" - "This program is free software\n" - "licensed under the GNU GPL.\n\n" - "NetRadiant is unsupported, however\n" - "you may report your problems on issue tracker.\n" - ) ); - - gtk_widget_show( GTK_WIDGET( label ) ); + char const *label_text = "NetRadiant " RADIANT_VERSION "\n" + __DATE__ "\n\n" + RADIANT_ABOUTMSG "\n\n" + "This program is free software\n" + "licensed under the GNU GPL.\n\n" + "NetRadiant is unsupported, however\n" + "you may report your problems at\n" + "https://gitlab.com/xonotic/netradiant/issues"; + + auto label = ui::Label( label_text ); + + label.show(); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( label, GTK_JUSTIFY_LEFT ); @@ -517,54 +505,54 @@ void DoAbout(){ } } { - GtkFrame* frame = create_dialog_frame( "OpenGL Properties" ); + auto frame = create_dialog_frame( "OpenGL Properties" ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); { - GtkTable* table = create_dialog_table( 3, 2, 4, 4, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table ) ); + auto table = create_dialog_table( 3, 2, 4, 4, 4 ); + frame.add(table); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vendor:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Vendor:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Version:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Version:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Renderer:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Renderer:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast( glGetString( GL_VENDOR ) ) ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( reinterpret_cast( glGetString( GL_VENDOR ) ) ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast( glGetString( GL_VERSION ) ) ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( reinterpret_cast( glGetString( GL_VERSION ) ) ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast( glGetString( GL_RENDERER ) ) ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( reinterpret_cast( glGetString( GL_RENDERER ) ) ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -572,19 +560,19 @@ void DoAbout(){ } } { - GtkFrame* frame = create_dialog_frame( "OpenGL Extensions" ); + auto frame = create_dialog_frame( "OpenGL Extensions" ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkScrolledWindow* sc_extensions = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( sc_extensions ) ); + auto sc_extensions = create_scrolled_window( ui::Policy::AUTOMATIC, ui::Policy::ALWAYS, 4 ); + frame.add(sc_extensions); { - GtkWidget* text_extensions = gtk_text_view_new(); + auto text_extensions = ui::TextView(); gtk_text_view_set_editable( GTK_TEXT_VIEW( text_extensions ), FALSE ); - gtk_container_add( GTK_CONTAINER( sc_extensions ), text_extensions ); + sc_extensions.add(text_extensions); GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_extensions ) ); gtk_text_buffer_set_text( buffer, reinterpret_cast( glGetString( GL_EXTENSIONS ) ), -1 ); gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text_extensions ), GTK_WRAP_WORD ); - gtk_widget_show( text_extensions ); + text_extensions.show(); } } } @@ -610,49 +598,49 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ GtkEntry* x; GtkEntry* y; - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Patch texture layout", dialog ); + auto window = MainFrame_getWindow().create_modal_dialog_window("Patch texture layout", dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); - gtk_window_add_accel_group( window, accel ); + auto accel = ui::AccelGroup(); + window.add_accel_group( accel ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture will be fit across the patch based\n" + auto label = ui::Label( "Texture will be fit across the patch based\n" "on the x and y values given. Values of 1x1\n" "will \"fit\" the texture. 2x2 will repeat\n" - "it twice, etc." ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + "it twice, etc." ); + label.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), TRUE, TRUE, 0 ); gtk_label_set_justify( label, GTK_JUSTIFY_LEFT ); } { - GtkTable* table = create_dialog_table( 2, 2, 4, 4 ); - gtk_widget_show( GTK_WIDGET( table ) ); + auto table = create_dialog_table( 2, 2, 4, 4 ); + table.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture x:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Texture x:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture y:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Texture y:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -660,8 +648,8 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ x = entry; } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -674,15 +662,15 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + widget_make_default( button ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); } } } @@ -718,11 +706,11 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ // Text Editor dialog // master window widget -static GtkWidget *text_editor = 0; -static GtkWidget *text_widget; // slave, text widget from the gtk editor +static ui::Widget text_editor; +static ui::Widget text_widget; // slave, text widget from the gtk editor -static gint editor_delete( GtkWidget *widget, gpointer data ){ - if ( gtk_MessageBox( widget, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) { +static gint editor_delete( ui::Widget widget, gpointer data ){ + if ( widget.alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) { return TRUE; } @@ -731,12 +719,12 @@ static gint editor_delete( GtkWidget *widget, gpointer data ){ return TRUE; } -static void editor_save( GtkWidget *widget, gpointer data ){ +static void editor_save( ui::Widget widget, gpointer data ){ FILE *f = fopen( (char*)g_object_get_data( G_OBJECT( data ), "filename" ), "w" ); gpointer text = g_object_get_data( G_OBJECT( data ), "text" ); if ( f == 0 ) { - gtk_MessageBox( GTK_WIDGET( data ), "Error saving file !" ); + ui::Widget(GTK_WIDGET( data )).alert( "Error saving file !" ); return; } @@ -745,8 +733,8 @@ static void editor_save( GtkWidget *widget, gpointer data ){ fclose( f ); } -static void editor_close( GtkWidget *widget, gpointer data ){ - if ( gtk_MessageBox( text_editor, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) { +static void editor_close( ui::Widget widget, gpointer data ){ + if ( text_editor.alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) { return; } @@ -754,49 +742,48 @@ static void editor_close( GtkWidget *widget, gpointer data ){ } static void CreateGtkTextEditor(){ - GtkWidget *dlg; - GtkWidget *vbox, *hbox, *button, *scr, *text; + ui::Widget vbox, hbox, button, text; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + auto dlg = ui::Window( ui::window_type::TOP ); - g_signal_connect( G_OBJECT( dlg ), "delete_event", + dlg.connect( "delete_event", G_CALLBACK( editor_delete ), 0 ); gtk_window_set_default_size( GTK_WINDOW( dlg ), 600, 300 ); - vbox = gtk_vbox_new( FALSE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( dlg ), GTK_WIDGET( vbox ) ); + vbox = ui::VBox( FALSE, 5 ); + vbox.show(); + dlg.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - scr = gtk_scrolled_window_new( 0, 0 ); - gtk_widget_show( scr ); + auto scr = ui::ScrolledWindow(); + scr.show(); gtk_box_pack_start( GTK_BOX( vbox ), scr, TRUE, TRUE, 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); - text = gtk_text_view_new(); - gtk_container_add( GTK_CONTAINER( scr ), text ); - gtk_widget_show( text ); - g_object_set_data( G_OBJECT( dlg ), "text", text ); + text = ui::TextView(); + scr.add(text); + text.show(); + g_object_set_data( G_OBJECT( dlg ), "text", (gpointer) text ); gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), TRUE ); - hbox = gtk_hbox_new( FALSE, 5 ); - gtk_widget_show( hbox ); + hbox = ui::HBox( FALSE, 5 ); + hbox.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, TRUE, 0 ); - button = gtk_button_new_with_label( "Close" ); - gtk_widget_show( button ); + button = ui::Button( "Close" ); + button.show(); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + button.connect( "clicked", G_CALLBACK( editor_close ), dlg ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); - button = gtk_button_new_with_label( "Save" ); - gtk_widget_show( button ); + button = ui::Button( "Save" ); + button.show(); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + button.connect( "clicked", G_CALLBACK( editor_save ), dlg ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); text_editor = dlg; text_widget = text; @@ -836,10 +823,10 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos ){ g_object_set_data( G_OBJECT( text_editor ), "filename", strdup( filename ) ); // trying to show later - gtk_widget_show( text_editor ); + text_editor.show(); #ifdef WIN32 - process_gui(); + ui::process(); #endif // only move the cursor if it's not exceeding the size.. @@ -871,25 +858,25 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Light intensity", dialog, -1, -1 ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Light intensity", dialog, -1, -1 ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); - gtk_window_add_accel_group( window, accel_group ); + auto accel_group = ui::AccelGroup(); + window.add_accel_group( accel_group ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "ESC for default, ENTER to validate" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "ESC for default, ENTER to validate" ); + label.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); gtk_widget_grab_focus( GTK_WIDGET( entry ) ); @@ -902,15 +889,15 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); + widget_make_default( button ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); } { GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_KEY_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); } } } @@ -938,26 +925,26 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, char* title ){ ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), title, dialog, -1, -1 ); + auto window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); - gtk_window_add_accel_group( window, accel_group ); + auto accel_group = ui::AccelGroup(); + window.add_accel_group( accel_group ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { //GtkLabel* label = GTK_LABEL(gtk_label_new("Enter one ore more tags separated by spaces")); - GtkLabel* label = GTK_LABEL( gtk_label_new( "ESC to cancel, ENTER to validate" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "ESC to cancel, ENTER to validate" ); + label.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); gtk_widget_grab_focus( GTK_WIDGET( entry ) ); @@ -970,15 +957,15 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, char* title ){ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); + widget_make_default( button ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); } { GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_KEY_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); } } } @@ -997,42 +984,42 @@ EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), title, dialog, -1, -1 ); + auto window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); - gtk_window_add_accel_group( window, accel_group ); + auto accel_group = ui::AccelGroup(); + window.add_accel_group( accel_group ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "The selected shader" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "The selected shader" ); + label.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( name ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( name ); + label.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "is located in file" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "is located in file" ); + label.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( filename ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( filename ); + label.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); + widget_make_default( button ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); } } } @@ -1063,7 +1050,7 @@ void DoTextEditor( const char* filename, int cursorpos ){ #ifdef WIN32 if ( g_TextEditor_useWin32Editor ) { globalOutputStream() << "opening file '" << filename << "' (line " << cursorpos << " info ignored)\n"; - ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", filename, 0, 0, SW_SHOW ); + ShellExecute( (HWND)GDK_WINDOW_HWND( gtk_widget_get_window( MainFrame_getWindow() ) ), "open", filename, 0, 0, SW_SHOW ); return; } #else diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 59dab2a9..693d569f 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -32,10 +32,10 @@ // Small functions to help with GTK // +#include #include "gtkmisc.h" -#include -#include +#include "uilib/uilib.h" #include "math/vector.h" #include "os/path.h" @@ -72,61 +72,54 @@ void toggle_remove_accelerator( const char* name ){ global_accel_group_disconnect( toggle.m_command.m_accelerator, toggle.m_command.m_callback ); } -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const char* commandName ){ +ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const char* commandName ){ GlobalShortcuts_register( commandName, 2 ); const Toggle& toggle = GlobalToggles_find( commandName ); global_accel_group_connect( toggle.m_command.m_accelerator, toggle.m_command.m_callback ); return create_check_menu_item_with_mnemonic( menu, mnemonic, toggle ); } -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char *mnemonic, const char* commandName ){ +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const char* commandName ){ GlobalShortcuts_register( commandName, 1 ); const Command& command = GlobalCommands_find( commandName ); global_accel_group_connect( command.m_accelerator, command.m_callback ); return create_menu_item_with_mnemonic( menu, mnemonic, command ); } -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ){ +ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const char* commandName ){ return toolbar_append_button( toolbar, description, icon, GlobalCommands_find( commandName ) ); } -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ){ +ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const char* commandName ){ return toolbar_append_toggle_button( toolbar, description, icon, GlobalToggles_find( commandName ) ); } // ============================================================================= // File dialog -bool color_dialog( GtkWidget *parent, Vector3& color, const char* title ){ - GtkWidget* dlg; - double clr[3]; +bool color_dialog( ui::Widget parent, Vector3& color, const char* title ){ + ui::Widget dlg; + GdkColor clr = { 0, guint16(color[0] * 65535), guint16(color[1] * 65535), guint16(color[2] * 65535) }; ModalDialog dialog; - clr[0] = color[0]; - clr[1] = color[1]; - clr[2] = color[2]; + dlg = ui::Widget(gtk_color_selection_dialog_new( title )); + gtk_color_selection_set_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG( dlg )) ), &clr ); + dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), &dialog ); + GtkWidget *ok_button, *cancel_button; + g_object_get(dlg, "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr); + ui::Widget(ok_button).connect( "clicked", G_CALLBACK( dialog_button_ok ), &dialog ); + ui::Widget(cancel_button).connect( "clicked", G_CALLBACK( dialog_button_cancel ), &dialog ); - dlg = gtk_color_selection_dialog_new( title ); - gtk_color_selection_set_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr ); - g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( dialog_delete_callback ), &dialog ); - g_signal_connect( G_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->ok_button ), "clicked", G_CALLBACK( dialog_button_ok ), &dialog ); - g_signal_connect( G_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->cancel_button ), "clicked", G_CALLBACK( dialog_button_cancel ), &dialog ); - - if ( parent != 0 ) { + if ( parent ) { gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( parent ) ); } - bool ok = modal_dialog_show( GTK_WINDOW( dlg ), dialog ) == eIDOK; + bool ok = modal_dialog_show( ui::Window(GTK_WINDOW( dlg )), dialog ) == eIDOK; if ( ok ) { - GdkColor gdkcolor; - gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), &gdkcolor ); - clr[0] = gdkcolor.red / 65535.0; - clr[1] = gdkcolor.green / 65535.0; - clr[2] = gdkcolor.blue / 65535.0; - - color[0] = (float)clr[0]; - color[1] = (float)clr[1]; - color[2] = (float)clr[2]; + gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG( dlg )) ), &clr ); + color[0] = clr.red / 65535.0f; + color[1] = clr.green / 65535.0f; + color[2] = clr.blue / 65535.0f; } gtk_widget_destroy( dlg ); @@ -134,17 +127,17 @@ bool color_dialog( GtkWidget *parent, Vector3& color, const char* title ){ return ok; } -void button_clicked_entry_browse_file( GtkWidget* widget, GtkEntry* entry ){ - const char *filename = file_dialog( gtk_widget_get_toplevel( widget ), TRUE, "Choose File", gtk_entry_get_text( entry ) ); +void button_clicked_entry_browse_file( ui::Widget widget, ui::Entry entry ){ + const char *filename = ui::Widget(gtk_widget_get_toplevel( widget )).file_dialog( TRUE, "Choose File", gtk_entry_get_text( entry ) ); if ( filename != 0 ) { gtk_entry_set_text( entry, filename ); } } -void button_clicked_entry_browse_directory( GtkWidget* widget, GtkEntry* entry ){ +void button_clicked_entry_browse_directory( ui::Widget widget, ui::Entry entry ){ const char* text = gtk_entry_get_text( entry ); - char *dir = dir_dialog( gtk_widget_get_toplevel( widget ), "Choose Directory", path_is_absolute( text ) ? text : "" ); + char *dir = dir_dialog( ui::Widget(gtk_widget_get_toplevel( widget )), "Choose Directory", path_is_absolute( text ) ? text : "" ); if ( dir != 0 ) { gchar* converted = g_filename_to_utf8( dir, -1, 0, 0, 0 ); diff --git a/radiant/gtkmisc.h b/radiant/gtkmisc.h index 14cdd816..ed6114ce 100644 --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@ -31,45 +31,30 @@ #if !defined( INCLUDED_GTKMISC_H ) #define INCLUDED_GTKMISC_H -#include - -inline void process_gui(){ - while ( gtk_events_pending() ) - { - gtk_main_iteration(); - } -} +#include void command_connect_accelerator( const char* commandName ); void command_disconnect_accelerator( const char* commandName ); void toggle_add_accelerator( const char* commandName ); void toggle_remove_accelerator( const char* name ); -typedef struct _GtkMenu GtkMenu; -typedef struct _GtkMenuItem GtkMenuItem; -typedef struct _GtkCheckMenuItem GtkCheckMenuItem; - // this also sets up the shortcut using command_connect_accelerator -GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu *menu, const char *mnemonic, const char* commandName ); +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const char* commandName ); // this also sets up the shortcut using command_connect_accelerator -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const char* commandName ); +ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const char* commandName ); -typedef struct _GtkButton GtkButton; -typedef struct _GtkToggleButton GtkToggleButton; -typedef struct _GtkToolbar GtkToolbar; // this DOES NOT set up the shortcut using command_connect_accelerator -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ); +ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const char* commandName ); // this DOES NOT set up the shortcut using command_connect_accelerator -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ); +ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const char* commandName ); template class BasicVector3; typedef BasicVector3 Vector3; -bool color_dialog( GtkWidget *parent, Vector3& color, const char* title = "Choose Color" ); +bool color_dialog( ui::Widget parent, Vector3& color, const char* title = "Choose Color" ); -typedef struct _GtkEntry GtkEntry; -void button_clicked_entry_browse_file( GtkWidget* widget, GtkEntry* entry ); -void button_clicked_entry_browse_directory( GtkWidget* widget, GtkEntry* entry ); +void button_clicked_entry_browse_file( ui::Widget widget, ui::Entry entry ); +void button_clicked_entry_browse_directory( ui::Widget widget, ui::Entry entry ); #endif diff --git a/radiant/help.cpp b/radiant/help.cpp index 07b51603..82e5f667 100644 --- a/radiant/help.cpp +++ b/radiant/help.cpp @@ -51,13 +51,13 @@ void HandleHelpCommand( CopiedString& str ){ OpenURL( str.c_str() ); } -void process_xlink( const char* filename, const char *menu_name, const char *base_url, GtkMenu *menu ){ +void process_xlink( const char* filename, const char *menu_name, const char *base_url, ui::Menu menu ){ if ( file_exists( filename ) ) { xmlDocPtr pDoc = xmlParseFile( filename ); if ( pDoc ) { globalOutputStream() << "Processing .xlink file '" << filename << "'\n"; // create sub menu - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, menu_name ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, menu_name ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -113,7 +113,7 @@ void process_xlink( const char* filename, const char *menu_name, const char *bas } } -void create_game_help_menu( GtkMenu *menu ){ +void create_game_help_menu( ui::Menu menu ){ StringOutputStream filename( 256 ); filename << AppPath_get() << "global.xlink"; process_xlink( filename.c_str(), "General", AppPath_get(), menu ); diff --git a/radiant/help.h b/radiant/help.h index d7e6263c..1e85100a 100644 --- a/radiant/help.h +++ b/radiant/help.h @@ -19,10 +19,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_HELP_H ) #define INCLUDED_HELP_H -typedef struct _GtkMenu GtkMenu; -void create_game_help_menu( GtkMenu *menu ); +void create_game_help_menu( ui::Menu menu ); #endif diff --git a/radiant/main.cpp b/radiant/main.cpp index e46d903f..f86b1895 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -69,7 +69,7 @@ #include "iundo.h" -#include +#include "uilib/uilib.h" #include "cmdlib.h" #include "os/file.h" @@ -303,12 +303,12 @@ bool handleMessage(){ ScopedLock lock( m_lock ); #if defined _DEBUG m_buffer << "Break into the debugger?\n"; - bool handled = gtk_MessageBox( 0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_YESNO, eMB_ICONERROR ) == eIDNO; + bool handled = ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::Error ) == ui::alert_response::NO; m_buffer.clear(); return handled; #else m_buffer << "Please report this error to the developers\n"; - gtk_MessageBox( 0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_OK, eMB_ICONERROR ); + ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::OK, ui::alert_icon::Error ); m_buffer.clear(); #endif } @@ -394,9 +394,9 @@ bool check_version(){ if ( !bVerIsGood ) { StringOutputStream msg( 256 ); msg << "This editor binary (" RADIANT_VERSION ") doesn't match what the latest setup has configured in this directory\n" - "Make sure you run the right/latest editor binary you installed\n" + "Make sure you run the right/latest editor binary you installed\n" << AppPath_get(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONDEFAULT ); + ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Default); } return bVerIsGood; #else @@ -424,7 +424,7 @@ void create_global_pid(){ if ( remove( g_pidFile.c_str() ) == -1 ) { StringOutputStream msg( 256 ); msg << "WARNING: Could not delete " << g_pidFile.c_str(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR ); + ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); } // in debug, never prompt to clean registry, turn console logging auto after a failed start @@ -434,14 +434,14 @@ void create_global_pid(){ "The failure may be related to current global preferences.\n" "Do you want to reset global preferences to defaults?"; - if ( gtk_MessageBox( 0, msg.c_str(), "Radiant - Startup Failure", eMB_YESNO, eMB_ICONQUESTION ) == eIDYES ) { + if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) { g_GamesDialog.Reset(); } msg.clear(); msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again."; - gtk_MessageBox( 0, msg.c_str(), "Radiant - Console Log", eMB_OK ); + ui::root.alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK ); #endif // set without saving, the class is not in a coherent state yet @@ -465,7 +465,7 @@ void remove_global_pid(){ if ( remove( g_pidFile.c_str() ) == -1 ) { StringOutputStream msg( 256 ); msg << "WARNING: Could not delete " << g_pidFile.c_str(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR ); + ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); } } @@ -483,7 +483,7 @@ void create_local_pid(){ if ( remove( g_pidGameFile.c_str() ) == -1 ) { StringOutputStream msg; msg << "WARNING: Could not delete " << g_pidGameFile.c_str(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR ); + ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); } // in debug, never prompt to clean registry, turn console logging auto after a failed start @@ -493,14 +493,14 @@ void create_local_pid(){ "The failure may be caused by current preferences.\n" "Do you want to reset all preferences to defaults?"; - if ( gtk_MessageBox( 0, msg.c_str(), "Radiant - Startup Failure", eMB_YESNO, eMB_ICONQUESTION ) == eIDYES ) { + if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) { Preferences_Reset(); } msg.clear(); msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again."; - gtk_MessageBox( 0, msg.c_str(), "Radiant - Console Log", eMB_OK ); + ui::root.alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK ); #endif // force console logging on! (will go in prefs too) @@ -558,15 +558,10 @@ int main( int argc, char* argv[] ){ } #endif - static GOptionEntry entries[] = { - { NULL } - }; - GError *error = NULL; const char* mapname = NULL; - - gtk_disable_setlocale(); - if ( !gtk_init_with_args( &argc, &argv, "", entries, NULL, &error) ) { - g_print( "%s\n", error->message ); + char const *error = NULL; + if ( !ui::init( &argc, &argv, "", &error) ) { + g_print( "%s\n", error ); return -1; } @@ -641,8 +636,6 @@ int main( int argc, char* argv[] ){ Radiant_Initialise(); - global_accel_init(); - user_shortcuts_init(); g_pParentWnd = 0; @@ -668,7 +661,7 @@ int main( int argc, char* argv[] ){ remove_local_pid(); - gtk_main(); + ui::main(); // avoid saving prefs when the app is minimized if ( g_pParentWnd->IsSleeping() ) { @@ -686,8 +679,6 @@ int main( int argc, char* argv[] ){ user_shortcuts_save(); - global_accel_destroy(); - Radiant_Shutdown(); // close the log file if any diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 53ef24a6..8d652ef2 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -27,13 +27,10 @@ #include "mainframe.h" -#include "debugging/debugging.h" -#include "version.h" +#include #include "ifilesystem.h" #include "iundo.h" -#include "ifilter.h" -#include "itoolbar.h" #include "editable.h" #include "ientity.h" #include "ishaders.h" @@ -43,20 +40,9 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "cmdlib.h" -#include "scenelib.h" #include "stream/stringstream.h" #include "signal/isignal.h" #include "os/path.h" @@ -65,14 +51,11 @@ #include "moduleobservers.h" #include "gtkutil/clipboard.h" -#include "gtkutil/container.h" #include "gtkutil/frame.h" -#include "gtkutil/glfont.h" #include "gtkutil/glwidget.h" #include "gtkutil/image.h" #include "gtkutil/menu.h" #include "gtkutil/paned.h" -#include "gtkutil/widget.h" #include "autosave.h" #include "build.h" @@ -101,7 +84,6 @@ #include "pluginmanager.h" #include "pluginmenu.h" #include "plugintoolbar.h" -#include "points.h" #include "preferences.h" #include "qe3.h" #include "qgl.h" @@ -452,18 +434,18 @@ void Paths_registerPreferencesPage(){ class PathsDialog : public Dialog { public: -GtkWindow* BuildDialog(){ - GtkFrame* frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN ); +ui::Window BuildDialog(){ + auto frame = create_dialog_frame( "Path settings", ui::Shadow::ETCHED_IN ); - GtkVBox* vbox2 = create_dialog_vbox( 0, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); + auto vbox2 = create_dialog_vbox( 0, 4 ); + frame.add(vbox2); { - PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) ); + PreferencesPage preferencesPage( *this, ui::Widget(GTK_WIDGET( vbox2 )) ); Paths_constructPreferences( preferencesPage ); } - return create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, GTK_WIDGET( frame ) ); + return ui::Window(create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, frame )); } }; @@ -828,7 +810,7 @@ ChooseColour( const GetColourCallback& get, const SetColourCallback& set ) void operator()(){ Vector3 colour; m_get( colour ); - color_dialog( GTK_WIDGET( MainFrame_getWindow() ), colour ); + color_dialog( MainFrame_getWindow(), colour ); m_set( colour ); } }; @@ -909,14 +891,14 @@ ColoursMenu() : ColoursMenu g_ColoursMenu; -GtkMenuItem* create_colours_menu(){ - GtkMenuItem* colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" ); - GtkMenu* menu_in_menu = GTK_MENU( gtk_menu_item_get_submenu( colours_menu_item ) ); +ui::MenuItem create_colours_menu(){ + auto colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" ); + auto menu_in_menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( colours_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } - GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Themes" ); + auto menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Themes" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_3 ); } @@ -973,13 +955,13 @@ void OpenBugReportURL(){ } -GtkWidget* g_page_console; +ui::Widget g_page_console; void Console_ToggleShow(){ GroupDialog_showPage( g_page_console ); } -GtkWidget* g_page_entity; +ui::Widget g_page_entity; void EntityInspector_ToggleShow(){ GroupDialog_showPage( g_page_entity ); @@ -1608,47 +1590,47 @@ guint s_qe_every_second_id = 0; void EverySecondTimer_enable(){ if ( s_qe_every_second_id == 0 ) { - s_qe_every_second_id = gtk_timeout_add( 1000, qe_every_second, 0 ); + s_qe_every_second_id = g_timeout_add( 1000, qe_every_second, 0 ); } } void EverySecondTimer_disable(){ if ( s_qe_every_second_id != 0 ) { - gtk_timeout_remove( s_qe_every_second_id ); + g_source_remove( s_qe_every_second_id ); s_qe_every_second_id = 0; } } -gint window_realize_remove_decoration( GtkWidget* widget, gpointer data ){ - gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); +gint window_realize_remove_decoration( ui::Widget widget, gpointer data ){ + gdk_window_set_decorations( gtk_widget_get_window(widget), (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); return FALSE; } class WaitDialog { public: -GtkWindow* m_window; -GtkLabel* m_label; +ui::Window m_window{ui::null}; +ui::Label m_label{ui::null}; }; WaitDialog create_wait_dialog( const char* title, const char* text ){ WaitDialog dialog; - dialog.m_window = create_floating_window( title, MainFrame_getWindow() ); + dialog.m_window = MainFrame_getWindow().create_floating_window(title); gtk_window_set_resizable( dialog.m_window, FALSE ); gtk_container_set_border_width( GTK_CONTAINER( dialog.m_window ), 0 ); gtk_window_set_position( dialog.m_window, GTK_WIN_POS_CENTER_ON_PARENT ); - g_signal_connect( G_OBJECT( dialog.m_window ), "realize", G_CALLBACK( window_realize_remove_decoration ), 0 ); + dialog.m_window.connect( "realize", G_CALLBACK( window_realize_remove_decoration ), 0 ); { - dialog.m_label = GTK_LABEL( gtk_label_new( text ) ); + dialog.m_label = ui::Label( text ); gtk_misc_set_alignment( GTK_MISC( dialog.m_label ), 0.0, 0.5 ); gtk_label_set_justify( dialog.m_label, GTK_JUSTIFY_LEFT ); - gtk_widget_show( GTK_WIDGET( dialog.m_label ) ); + dialog.m_label.show(); gtk_widget_set_size_request( GTK_WIDGET( dialog.m_label ), 200, -1 ); - gtk_container_add( GTK_CONTAINER( dialog.m_window ), GTK_WIDGET( dialog.m_label ) ); + dialog.m_window.add(dialog.m_label); } return dialog; } @@ -1692,8 +1674,8 @@ bool ScreenUpdates_Enabled(){ } void ScreenUpdates_process(){ - if ( redrawRequired() && GTK_WIDGET_VISIBLE( g_wait.m_window ) ) { - process_gui(); + if ( redrawRequired() && gtk_widget_get_visible( g_wait.m_window ) ) { + ui::process(); } } @@ -1702,7 +1684,7 @@ void ScreenUpdates_Disable( const char* message, const char* title ){ if ( g_wait_stack.empty() ) { EverySecondTimer_disable(); - process_gui(); + ui::process(); bool isActiveApp = MainFrame_isActiveApp(); @@ -1710,11 +1692,11 @@ void ScreenUpdates_Disable( const char* message, const char* title ){ gtk_grab_add( GTK_WIDGET( g_wait.m_window ) ); if ( isActiveApp ) { - gtk_widget_show( GTK_WIDGET( g_wait.m_window ) ); + g_wait.m_window.show(); ScreenUpdates_process(); } } - else if ( GTK_WIDGET_VISIBLE( g_wait.m_window ) ) { + else if ( gtk_widget_get_visible( g_wait.m_window ) ) { gtk_label_set_text( g_wait.m_label, message ); ScreenUpdates_process(); } @@ -1730,11 +1712,11 @@ void ScreenUpdates_Enable(){ gtk_grab_remove( GTK_WIDGET( g_wait.m_window ) ); destroy_floating_window( g_wait.m_window ); - g_wait.m_window = 0; + g_wait.m_window = ui::Window{ui::null}; //gtk_window_present(MainFrame_getWindow()); } - else if ( GTK_WIDGET_VISIBLE( g_wait.m_window ) ) { + else if ( gtk_widget_get_visible( g_wait.m_window ) ) { gtk_label_set_text( g_wait.m_label, g_wait_stack.back().c_str() ); ScreenUpdates_process(); } @@ -1801,10 +1783,10 @@ LatchedBool g_Layout_enablePluginToolbar( true, "Plugin Toolbar" ); -GtkMenuItem* create_file_menu(){ +ui::MenuItem create_file_menu(){ // File menu - GtkMenuItem* file_menu_item = new_sub_menu_item_with_mnemonic( "_File" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( file_menu_item ) ); + auto file_menu_item = new_sub_menu_item_with_mnemonic( "_File" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( file_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -1841,10 +1823,10 @@ GtkMenuItem* create_file_menu(){ return file_menu_item; } -GtkMenuItem* create_edit_menu(){ +ui::MenuItem create_edit_menu(){ // Edit menu - GtkMenuItem* edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( edit_menu_item ) ); + auto edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( edit_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -1866,7 +1848,7 @@ GtkMenuItem* create_edit_menu(){ create_menu_item_with_mnemonic( menu, "Select i_nside", "SelectInside" ); create_menu_item_with_mnemonic( menu, "Select _touching", "SelectTouching" ); - GtkMenu* convert_menu = create_sub_menu_with_mnemonic( menu, "E_xpand Selection" ); + auto convert_menu = create_sub_menu_with_mnemonic( menu, "E_xpand Selection" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( convert_menu ); } @@ -1878,30 +1860,30 @@ GtkMenuItem* create_edit_menu(){ return edit_menu_item; } -void fill_view_xy_top_menu( GtkMenu* menu ){ +void fill_view_xy_top_menu( ui::Menu menu ){ create_check_menu_item_with_mnemonic( menu, "XY (Top) View", "ToggleView" ); } -void fill_view_yz_side_menu( GtkMenu* menu ){ +void fill_view_yz_side_menu( ui::Menu menu ){ create_check_menu_item_with_mnemonic( menu, "YZ (Side) View", "ToggleSideView" ); } -void fill_view_xz_front_menu( GtkMenu* menu ){ +void fill_view_xz_front_menu( ui::Menu menu ){ create_check_menu_item_with_mnemonic( menu, "XZ (Front) View", "ToggleFrontView" ); } -GtkWidget* g_toggle_z_item = 0; -GtkWidget* g_toggle_console_item = 0; -GtkWidget* g_toggle_entity_item = 0; -GtkWidget* g_toggle_entitylist_item = 0; +ui::Widget g_toggle_z_item; +ui::Widget g_toggle_console_item; +ui::Widget g_toggle_entity_item; +ui::Widget g_toggle_entitylist_item; -GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ +ui::MenuItem create_view_menu( MainFrame::EViewStyle style ){ // View menu - GtkMenuItem* view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( view_menu_item ) ); + auto view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( view_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -1926,7 +1908,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ menu_separator( menu ); { - GtkMenu* camera_menu = create_sub_menu_with_mnemonic( menu, "Camera" ); + auto camera_menu = create_sub_menu_with_mnemonic( menu, "Camera" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( camera_menu ); } @@ -1945,7 +1927,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ } menu_separator( menu ); { - GtkMenu* orthographic_menu = create_sub_menu_with_mnemonic( menu, "Orthographic" ); + auto orthographic_menu = create_sub_menu_with_mnemonic( menu, "Orthographic" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( orthographic_menu ); } @@ -1965,7 +1947,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Show" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Show" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -1980,7 +1962,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ } { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Filter" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Filter" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -1988,7 +1970,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ } menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Hide/Show" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Hide/Show" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -1997,7 +1979,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ } menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Region" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Region" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -2012,16 +1994,16 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ return view_menu_item; } -GtkMenuItem* create_selection_menu(){ +ui::MenuItem create_selection_menu(){ // Selection menu - GtkMenuItem* selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( selection_menu_item ) ); + auto selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( selection_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Components" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Components" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -2033,7 +2015,7 @@ GtkMenuItem* create_selection_menu(){ menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Nudge" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Nudge" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -2043,7 +2025,7 @@ GtkMenuItem* create_selection_menu(){ create_menu_item_with_mnemonic( menu_in_menu, "Nudge Down", "SelectNudgeDown" ); } { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Rotate" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Rotate" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -2052,7 +2034,7 @@ GtkMenuItem* create_selection_menu(){ create_menu_item_with_mnemonic( menu_in_menu, "Rotate Z", "RotateSelectionZ" ); } { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Flip" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Flip" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -2067,10 +2049,10 @@ GtkMenuItem* create_selection_menu(){ return selection_menu_item; } -GtkMenuItem* create_bsp_menu(){ +ui::MenuItem create_bsp_menu(){ // BSP menu - GtkMenuItem* bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( bsp_menu_item ) ); + auto bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( bsp_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -2087,10 +2069,10 @@ GtkMenuItem* create_bsp_menu(){ return bsp_menu_item; } -GtkMenuItem* create_grid_menu(){ +ui::MenuItem create_grid_menu(){ // Grid menu - GtkMenuItem* grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( grid_menu_item ) ); + auto grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( grid_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2100,10 +2082,10 @@ GtkMenuItem* create_grid_menu(){ return grid_menu_item; } -GtkMenuItem* create_misc_menu(){ +ui::MenuItem create_misc_menu(){ // Misc menu - GtkMenuItem* misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( misc_menu_item ) ); + auto misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( misc_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2111,7 +2093,7 @@ GtkMenuItem* create_misc_menu(){ #if 0 create_menu_item_with_mnemonic( menu, "_Benchmark", FreeCaller() ); #endif - gtk_container_add( GTK_CONTAINER( menu ), GTK_WIDGET( create_colours_menu() ) ); + menu.add(create_colours_menu()); create_menu_item_with_mnemonic( menu, "Find brush...", "FindBrush" ); create_menu_item_with_mnemonic( menu, "Map Info...", "MapInfo" ); @@ -2121,10 +2103,10 @@ GtkMenuItem* create_misc_menu(){ return misc_menu_item; } -GtkMenuItem* create_entity_menu(){ +ui::MenuItem create_entity_menu(){ // Brush menu - GtkMenuItem* entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( entity_menu_item ) ); + auto entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( entity_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2134,10 +2116,10 @@ GtkMenuItem* create_entity_menu(){ return entity_menu_item; } -GtkMenuItem* create_brush_menu(){ +ui::MenuItem create_brush_menu(){ // Brush menu - GtkMenuItem* brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( brush_menu_item ) ); + auto brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( brush_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2147,10 +2129,10 @@ GtkMenuItem* create_brush_menu(){ return brush_menu_item; } -GtkMenuItem* create_patch_menu(){ +ui::MenuItem create_patch_menu(){ // Curve menu - GtkMenuItem* patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( patch_menu_item ) ); + auto patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( patch_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2160,10 +2142,10 @@ GtkMenuItem* create_patch_menu(){ return patch_menu_item; } -GtkMenuItem* create_help_menu(){ +ui::MenuItem create_help_menu(){ // Help menu - GtkMenuItem* help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( help_menu_item ) ); + auto help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( help_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } @@ -2182,21 +2164,21 @@ GtkMenuItem* create_help_menu(){ } GtkMenuBar* create_main_menu( MainFrame::EViewStyle style ){ - GtkMenuBar* menu_bar = GTK_MENU_BAR( gtk_menu_bar_new() ); - gtk_widget_show( GTK_WIDGET( menu_bar ) ); - - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_file_menu() ) ); - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_edit_menu() ) ); - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_view_menu( style ) ) ); - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_selection_menu() ) ); - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_bsp_menu() ) ); - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_grid_menu() ) ); - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_misc_menu() ) ); - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_entity_menu() ) ); - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_brush_menu() ) ); - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_patch_menu() ) ); - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_plugins_menu() ) ); - gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_help_menu() ) ); + auto menu_bar = ui::MenuBar(GTK_MENU_BAR( gtk_menu_bar_new() )); + menu_bar.show(); + + menu_bar.add(create_file_menu()); + menu_bar.add(create_edit_menu()); + menu_bar.add(create_view_menu(style)); + menu_bar.add(create_selection_menu()); + menu_bar.add(create_bsp_menu()); + menu_bar.add(create_grid_menu()); + menu_bar.add(create_misc_menu()); + menu_bar.add(create_entity_menu()); + menu_bar.add(create_brush_menu()); + menu_bar.add(create_patch_menu()); + menu_bar.add(create_plugins_menu()); + menu_bar.add(create_help_menu()); return menu_bar; } @@ -2274,17 +2256,17 @@ void register_shortcuts(){ SelectByType_registerShortcuts(); } -void File_constructToolbar( GtkToolbar* toolbar ){ +void File_constructToolbar( ui::Toolbar toolbar ){ toolbar_append_button( toolbar, "Open an existing map (CTRL + O)", "file_open.png", "OpenMap" ); toolbar_append_button( toolbar, "Save the active map (CTRL + S)", "file_save.png", "SaveMap" ); } -void UndoRedo_constructToolbar( GtkToolbar* toolbar ){ +void UndoRedo_constructToolbar( ui::Toolbar toolbar ){ toolbar_append_button( toolbar, "Undo (CTRL + Z)", "undo.png", "Undo" ); toolbar_append_button( toolbar, "Redo (CTRL + Y)", "redo.png", "Redo" ); } -void RotateFlip_constructToolbar( GtkToolbar* toolbar ){ +void RotateFlip_constructToolbar( ui::Toolbar toolbar ){ toolbar_append_button( toolbar, "x-axis Flip", "brush_flipx.png", "MirrorSelectionX" ); toolbar_append_button( toolbar, "x-axis Rotate", "brush_rotatex.png", "RotateSelectionX" ); toolbar_append_button( toolbar, "y-axis Flip", "brush_flipy.png", "MirrorSelectionY" ); @@ -2293,33 +2275,33 @@ void RotateFlip_constructToolbar( GtkToolbar* toolbar ){ toolbar_append_button( toolbar, "z-axis Rotate", "brush_rotatez.png", "RotateSelectionZ" ); } -void Select_constructToolbar( GtkToolbar* toolbar ){ +void Select_constructToolbar( ui::Toolbar toolbar ){ toolbar_append_button( toolbar, "Select touching", "selection_selecttouching.png", "SelectTouching" ); toolbar_append_button( toolbar, "Select inside", "selection_selectinside.png", "SelectInside" ); } -void CSG_constructToolbar( GtkToolbar* toolbar ){ +void CSG_constructToolbar( ui::Toolbar toolbar ){ toolbar_append_button( toolbar, "CSG Subtract (SHIFT + U)", "selection_csgsubtract.png", "CSGSubtract" ); toolbar_append_button( toolbar, "CSG Merge (CTRL + U)", "selection_csgmerge.png", "CSGMerge" ); toolbar_append_button( toolbar, "Hollow", "selection_makehollow.png", "CSGHollow" ); } -void ComponentModes_constructToolbar( GtkToolbar* toolbar ){ +void ComponentModes_constructToolbar( ui::Toolbar toolbar ){ toolbar_append_toggle_button( toolbar, "Select Vertices (V)", "modify_vertices.png", "DragVertices" ); toolbar_append_toggle_button( toolbar, "Select Edges (E)", "modify_edges.png", "DragEdges" ); toolbar_append_toggle_button( toolbar, "Select Faces (F)", "modify_faces.png", "DragFaces" ); } -void Clipper_constructToolbar( GtkToolbar* toolbar ){ +void Clipper_constructToolbar( ui::Toolbar toolbar ){ toolbar_append_toggle_button( toolbar, "Clipper (X)", "view_clipper.png", "ToggleClipper" ); } -void XYWnd_constructToolbar( GtkToolbar* toolbar ){ +void XYWnd_constructToolbar( ui::Toolbar toolbar ){ toolbar_append_button( toolbar, "Change views", "view_change.png", "NextView" ); } -void Manipulators_constructToolbar( GtkToolbar* toolbar ){ +void Manipulators_constructToolbar( ui::Toolbar toolbar ){ toolbar_append_toggle_button( toolbar, "Translate (W)", "select_mousetranslate.png", "MouseTranslate" ); toolbar_append_toggle_button( toolbar, "Rotate (R)", "select_mouserotate.png", "MouseRotate" ); toolbar_append_toggle_button( toolbar, "Scale", "select_mousescale.png", "MouseScale" ); @@ -2328,69 +2310,75 @@ void Manipulators_constructToolbar( GtkToolbar* toolbar ){ Clipper_constructToolbar( toolbar ); } -GtkToolbar* create_main_toolbar( MainFrame::EViewStyle style ){ - GtkToolbar* toolbar = GTK_TOOLBAR( gtk_toolbar_new() ); - gtk_toolbar_set_orientation( toolbar, GTK_ORIENTATION_HORIZONTAL ); +ui::Toolbar create_main_toolbar( MainFrame::EViewStyle style ){ + auto toolbar = ui::Toolbar(GTK_TOOLBAR( gtk_toolbar_new() )); + gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL ); gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS ); - gtk_widget_show( GTK_WIDGET( toolbar ) ); + toolbar.show(); + + auto space = [&]() { + auto btn = ui::Widget(GTK_WIDGET(gtk_separator_tool_item_new())); + btn.show(); + toolbar.add(btn); + }; File_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); UndoRedo_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); RotateFlip_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); Select_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); CSG_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); ComponentModes_constructToolbar( toolbar ); if ( style == MainFrame::eRegular || style == MainFrame::eRegularLeft || style == MainFrame::eFloating ) { - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); XYWnd_constructToolbar( toolbar ); } - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); CamWnd_constructToolbar( toolbar ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); Manipulators_constructToolbar( toolbar ); if ( g_Layout_enablePatchToolbar.m_value ) { - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); Patch_constructToolbar( toolbar ); } - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); toolbar_append_toggle_button( toolbar, "Texture Lock (SHIFT +T)", "texture_lock.png", "TogTexLock" ); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); + space(); - GtkButton* g_view_entities_button = toolbar_append_button( toolbar, "Entities (N)", "entities.png", "ToggleEntityInspector" ); - GtkButton* g_view_console_button = toolbar_append_button( toolbar, "Console (O)", "console.png", "ToggleConsole" ); - GtkButton* g_view_textures_button = toolbar_append_button( toolbar, "Texture Browser (T)", "texture_browser.png", "ToggleTextures" ); + /*auto g_view_entities_button =*/ toolbar_append_button( toolbar, "Entities (N)", "entities.png", "ToggleEntityInspector" ); + auto g_view_console_button = toolbar_append_button( toolbar, "Console (O)", "console.png", "ToggleConsole" ); + auto g_view_textures_button = toolbar_append_button( toolbar, "Texture Browser (T)", "texture_browser.png", "ToggleTextures" ); // TODO: call light inspector //GtkButton* g_view_lightinspector_button = toolbar_append_button(toolbar, "Light Inspector", "lightinspector.png", "ToggleLightInspector"); - gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) ); - GtkButton* g_refresh_models_button = toolbar_append_button( toolbar, "Refresh Models", "refresh_models.png", "RefreshReferences" ); + space(); + /*auto g_refresh_models_button =*/ toolbar_append_button( toolbar, "Refresh Models", "refresh_models.png", "RefreshReferences" ); // disable the console and texture button in the regular layouts @@ -2402,36 +2390,36 @@ GtkToolbar* create_main_toolbar( MainFrame::EViewStyle style ){ return toolbar; } -GtkWidget* create_main_statusbar( GtkWidget *pStatusLabel[c_count_status] ){ - GtkTable* table = GTK_TABLE( gtk_table_new( 1, c_count_status, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); +ui::Widget create_main_statusbar( ui::Widget pStatusLabel[c_count_status] ){ + auto table = ui::Table( 1, c_count_status, FALSE ); + table.show(); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) ); + auto label = ui::Label( "Label" ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); gtk_misc_set_padding( GTK_MISC( label ), 4, 2 ); - gtk_widget_show( GTK_WIDGET( label ) ); + label.show(); gtk_table_attach_defaults( table, GTK_WIDGET( label ), 0, 1, 0, 1 ); - pStatusLabel[c_command_status] = GTK_WIDGET( label ); + pStatusLabel[c_command_status] = ui::Widget(GTK_WIDGET( label )); } for ( int i = 1; i < c_count_status; ++i ) { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( 0 ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); + auto frame = ui::Frame(); + frame.show(); gtk_table_attach_defaults( table, GTK_WIDGET( frame ), i, i + 1, 0, 1 ); gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN ); - GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) ); + auto label = ui::Label( "Label" ); gtk_label_set_ellipsize( label, PANGO_ELLIPSIZE_END ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); gtk_misc_set_padding( GTK_MISC( label ), 4, 2 ); - gtk_widget_show( GTK_WIDGET( label ) ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( label ) ); - pStatusLabel[i] = GTK_WIDGET( label ); + label.show(); + frame.add(label); + pStatusLabel[i] = ui::Widget(GTK_WIDGET( label )); } - return GTK_WIDGET( table ); + return ui::Widget(GTK_WIDGET( table )); } #if 0 @@ -2443,15 +2431,15 @@ class WindowFocusPrinter { const char* m_name; -static gboolean frame_event( GtkWidget *widget, GdkEvent* event, WindowFocusPrinter* self ){ +static gboolean frame_event( ui::Widget widget, GdkEvent* event, WindowFocusPrinter* self ){ globalOutputStream() << self->m_name << " frame_event\n"; return FALSE; } -static gboolean keys_changed( GtkWidget *widget, WindowFocusPrinter* self ){ +static gboolean keys_changed( ui::Widget widget, WindowFocusPrinter* self ){ globalOutputStream() << self->m_name << " keys_changed\n"; return FALSE; } -static gboolean notify( GtkWindow* window, gpointer dummy, WindowFocusPrinter* self ){ +static gboolean notify( ui::Window window, gpointer dummy, WindowFocusPrinter* self ){ if ( gtk_window_is_active( window ) ) { globalOutputStream() << self->m_name << " takes toplevel focus\n"; } @@ -2464,11 +2452,11 @@ static gboolean notify( GtkWindow* window, gpointer dummy, WindowFocusPrinter* s public: WindowFocusPrinter( const char* name ) : m_name( name ){ } -void connect( GtkWindow* toplevel_window ){ - g_signal_connect( G_OBJECT( toplevel_window ), "notify::has_toplevel_focus", G_CALLBACK( notify ), this ); - g_signal_connect( G_OBJECT( toplevel_window ), "notify::is_active", G_CALLBACK( notify ), this ); - g_signal_connect( G_OBJECT( toplevel_window ), "keys_changed", G_CALLBACK( keys_changed ), this ); - g_signal_connect( G_OBJECT( toplevel_window ), "frame_event", G_CALLBACK( frame_event ), this ); +void connect( ui::Window toplevel_window ){ + toplevel_window.connect( "notify::has_toplevel_focus", G_CALLBACK( notify ), this ); + toplevel_window.connect( "notify::is_active", G_CALLBACK( notify ), this ); + toplevel_window.connect( "keys_changed", G_CALLBACK( keys_changed ), this ); + toplevel_window.connect( "frame_event", G_CALLBACK( frame_event ), this ); } }; @@ -2478,16 +2466,16 @@ WindowFocusPrinter g_mainframeFocusPrinter( "mainframe" ); class MainWindowActive { -static gboolean notify( GtkWindow* window, gpointer dummy, MainWindowActive* self ){ - if ( g_wait.m_window != 0 && gtk_window_is_active( window ) && !GTK_WIDGET_VISIBLE( g_wait.m_window ) ) { - gtk_widget_show( GTK_WIDGET( g_wait.m_window ) ); +static gboolean notify( ui::Window window, gpointer dummy, MainWindowActive* self ){ + if ( g_wait.m_window && gtk_window_is_active( window ) && !gtk_widget_get_visible( g_wait.m_window ) ) { + g_wait.m_window.show(); } return FALSE; } public: -void connect( GtkWindow* toplevel_window ){ - g_signal_connect( G_OBJECT( toplevel_window ), "notify::is-active", G_CALLBACK( notify ), this ); +void connect( ui::Window toplevel_window ){ + toplevel_window.connect( "notify::is-active", G_CALLBACK( notify ), this ); } }; @@ -2514,14 +2502,12 @@ void XYWindowMouseDown_disconnect( MouseEventHandlerId id ){ MainFrame* g_pParentWnd = 0; -GtkWindow* MainFrame_getWindow(){ - if ( g_pParentWnd == 0 ) { - return 0; - } - return g_pParentWnd->m_window; +ui::Window MainFrame_getWindow() +{ + return g_pParentWnd ? g_pParentWnd->m_window : ui::Window{ui::null}; } -std::vector g_floating_windows; +std::vector g_floating_windows; MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusTextCaller( *this ) ){ m_pXYWnd = 0; @@ -2533,7 +2519,7 @@ MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusText for ( int n = 0; n < c_count_status; n++ ) { - m_pStatusLabel[n] = 0; + m_pStatusLabel[n] = ui::root; } m_bSleeping = false; @@ -2548,7 +2534,7 @@ MainFrame::~MainFrame(){ Shutdown(); - for ( std::vector::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i ) + for ( std::vector::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i ) { gtk_widget_destroy( *i ); } @@ -2673,8 +2659,8 @@ void MainFrame::OnSleep(){ } -GtkWindow* create_splash(){ - GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ); +ui::Window create_splash(){ + ui::Window window = ui::Window( ui::window_type::TOP ); gtk_window_set_decorated( window, FALSE ); gtk_window_set_resizable( window, FALSE ); gtk_window_set_modal( window, TRUE ); @@ -2682,22 +2668,22 @@ GtkWindow* create_splash(){ gtk_window_set_position( window, GTK_WIN_POS_CENTER ); gtk_container_set_border_width( GTK_CONTAINER( window ), 0 ); - GtkImage* image = new_local_image( "splash.png" ); - gtk_widget_show( GTK_WIDGET( image ) ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( image ) ); + auto image = new_local_image( "splash.png" ); + image.show(); + window.add(image); gtk_widget_set_size_request( GTK_WIDGET( window ), -1, -1 ); - gtk_widget_show( GTK_WIDGET( window ) ); + window.show(); return window; } -static GtkWindow *splash_screen = 0; +static ui::Window splash_screen{ui::null}; void show_splash(){ splash_screen = create_splash(); - process_gui(); + ui::process(); } void hide_splash(){ @@ -2709,7 +2695,7 @@ WindowPositionTracker g_posXYWnd; WindowPositionTracker g_posXZWnd; WindowPositionTracker g_posYZWnd; -static gint mainframe_delete( GtkWidget *widget, GdkEvent *event, gpointer data ){ +static gint mainframe_delete( ui::Widget widget, GdkEvent *event, gpointer data ){ if ( ConfirmModified( "Exit Radiant" ) ) { gtk_main_quit(); } @@ -2718,7 +2704,7 @@ static gint mainframe_delete( GtkWidget *widget, GdkEvent *event, gpointer data } void MainFrame::Create(){ - GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ); + ui::Window window = ui::Window( ui::window_type::TOP ); GlobalWindowObservers_connectTopLevel( window ); @@ -2729,13 +2715,13 @@ void MainFrame::Create(){ GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.png" ); if ( pixbuf != 0 ) { gtk_window_set_icon( window, pixbuf ); - gdk_pixbuf_unref( pixbuf ); + g_object_unref( pixbuf ); } } #endif gtk_widget_add_events( GTK_WIDGET( window ), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK ); - g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( mainframe_delete ), this ); + window.connect( "delete_event", G_CALLBACK( mainframe_delete ), this ); m_position_tracker.connect( window ); @@ -2746,11 +2732,11 @@ void MainFrame::Create(){ g_MainWindowActive.connect( window ); - GetPlugInMgr().Init( GTK_WIDGET( window ) ); + GetPlugInMgr().Init( window ); - GtkWidget* vbox = gtk_vbox_new( FALSE, 0 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + ui::Widget vbox = ui::VBox( FALSE, 0 ); + window.add(vbox); + vbox.show(); global_accel_connect_window( window ); @@ -2770,7 +2756,7 @@ void MainFrame::Create(){ } gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( plugin_toolbar ), FALSE, FALSE, 0 ); - GtkWidget* main_statusbar = create_main_statusbar( m_pStatusLabel ); + ui::Widget main_statusbar = create_main_statusbar( m_pStatusLabel ); gtk_box_pack_end( GTK_BOX( vbox ), main_statusbar, FALSE, TRUE, 2 ); GroupDialog_constructWindow( window ); @@ -2799,33 +2785,33 @@ void MainFrame::Create(){ m_window = window; - gtk_widget_show( GTK_WIDGET( window ) ); + window.show(); if ( CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft ) { { - GtkWidget* vsplit = gtk_vpaned_new(); + ui::Widget vsplit = ui::VPaned(); m_vSplit = vsplit; gtk_box_pack_start( GTK_BOX( vbox ), vsplit, TRUE, TRUE, 0 ); - gtk_widget_show( vsplit ); + vsplit.show(); // console - GtkWidget* console_window = Console_constructWindow( window ); + ui::Widget console_window = Console_constructWindow( window ); gtk_paned_pack2( GTK_PANED( vsplit ), console_window, FALSE, TRUE ); { - GtkWidget* hsplit = gtk_hpaned_new(); - gtk_widget_show( hsplit ); + ui::Widget hsplit = ui::HPaned(); + hsplit.show(); m_hSplit = hsplit; gtk_paned_add1( GTK_PANED( vsplit ), hsplit ); // xy m_pXYWnd = new XYWnd(); m_pXYWnd->SetViewType( XY ); - GtkWidget* xy_window = GTK_WIDGET( create_framed_widget( m_pXYWnd->GetWidget() ) ); + ui::Widget xy_window = ui::Widget(GTK_WIDGET( create_framed_widget( m_pXYWnd->GetWidget() ) )); { - GtkWidget* vsplit2 = gtk_vpaned_new(); - gtk_widget_show( vsplit2 ); + ui::Widget vsplit2 = ui::VPaned(); + vsplit2.show(); m_vSplit2 = vsplit2; if ( CurrentStyle() == eRegular ) { @@ -2869,26 +2855,26 @@ void MainFrame::Create(){ } else if ( CurrentStyle() == eFloating ) { { - GtkWindow* window = create_persistent_floating_window( "Camera", m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( "Camera", m_window )); global_accel_connect_window( window ); g_posCamWnd.connect( window ); - gtk_widget_show( GTK_WIDGET( window ) ); + window.show(); m_pCamWnd = NewCamWnd(); GlobalCamera_setCamWnd( *m_pCamWnd ); { - GtkFrame* frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + auto frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) ); + window.add(frame); } CamWnd_setParent( *m_pCamWnd, window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { - GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XY ), m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XY ), m_window )); global_accel_connect_window( window ); g_posXYWnd.connect( window ); @@ -2898,16 +2884,16 @@ void MainFrame::Create(){ { - GtkFrame* frame = create_framed_widget( m_pXYWnd->GetWidget() ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + auto frame = create_framed_widget( m_pXYWnd->GetWidget() ); + window.add(frame); } XY_Top_Shown_Construct( window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { - GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XZ ), m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XZ ), m_window )); global_accel_connect_window( window ); g_posXZWnd.connect( window ); @@ -2916,17 +2902,17 @@ void MainFrame::Create(){ m_pXZWnd->SetViewType( XZ ); { - GtkFrame* frame = create_framed_widget( m_pXZWnd->GetWidget() ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + auto frame = create_framed_widget( m_pXZWnd->GetWidget() ); + window.add(frame); } XZ_Front_Shown_Construct( window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { - GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( YZ ), m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( YZ ), m_window )); global_accel_connect_window( window ); g_posYZWnd.connect( window ); @@ -2935,18 +2921,18 @@ void MainFrame::Create(){ m_pYZWnd->SetViewType( YZ ); { - GtkFrame* frame = create_framed_widget( m_pYZWnd->GetWidget() ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + auto frame = create_framed_widget( m_pYZWnd->GetWidget() ); + window.add(frame); } YZ_Side_Shown_Construct( window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) ); - g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() ); + g_page_textures = GroupDialog_addPage( "Textures", ui::Widget(GTK_WIDGET( frame )), TextureBrowserExportTitleCaller() ); } GroupDialog_show(); @@ -2957,29 +2943,29 @@ void MainFrame::Create(){ GlobalCamera_setCamWnd( *m_pCamWnd ); CamWnd_setParent( *m_pCamWnd, window ); - GtkWidget* camera = CamWnd_getWidget( *m_pCamWnd ); + ui::Widget camera = CamWnd_getWidget( *m_pCamWnd ); m_pYZWnd = new XYWnd(); m_pYZWnd->SetViewType( YZ ); - GtkWidget* yz = m_pYZWnd->GetWidget(); + ui::Widget yz = m_pYZWnd->GetWidget(); m_pXYWnd = new XYWnd(); m_pXYWnd->SetViewType( XY ); - GtkWidget* xy = m_pXYWnd->GetWidget(); + ui::Widget xy = m_pXYWnd->GetWidget(); m_pXZWnd = new XYWnd(); m_pXZWnd->SetViewType( XZ ); - GtkWidget* xz = m_pXZWnd->GetWidget(); + ui::Widget xz = m_pXZWnd->GetWidget(); GtkHPaned* split = create_split_views( camera, yz, xy, xz ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( split ), TRUE, TRUE, 0 ); { GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( window ) ); - g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() ); + g_page_textures = GroupDialog_addPage( "Textures", ui::Widget(GTK_WIDGET( frame )), TextureBrowserExportTitleCaller() ); } } @@ -3020,7 +3006,7 @@ void MainFrame::SaveWindowInfo(){ g_layout_globals.m_position = m_position_tracker.getPosition(); - g_layout_globals.nState = gdk_window_get_state( GTK_WIDGET( m_window )->window ); + g_layout_globals.nState = gdk_window_get_state( gtk_widget_get_window(GTK_WIDGET( m_window )) ); } void MainFrame::Shutdown(){ @@ -3110,7 +3096,8 @@ void GlobalGL_sharedContextCreated(){ globalOutputStream() << "GL_VENDOR: " << reinterpret_cast( glGetString( GL_VENDOR ) ) << "\n"; globalOutputStream() << "GL_RENDERER: " << reinterpret_cast( glGetString( GL_RENDERER ) ) << "\n"; globalOutputStream() << "GL_VERSION: " << reinterpret_cast( glGetString( GL_VERSION ) ) << "\n"; - globalOutputStream() << "GL_EXTENSIONS: " << reinterpret_cast( glGetString( GL_EXTENSIONS ) ) << "\n"; + const auto extensions = reinterpret_cast( glGetString(GL_EXTENSIONS ) ); + globalOutputStream() << "GL_EXTENSIONS: " << (extensions ? extensions : "") << "\n"; QGL_sharedContextCreated( GlobalOpenGL() ); @@ -3183,7 +3170,7 @@ void Layout_registerPreferencesPage(){ #include "stringio.h" void MainFrame_Construct(){ - GlobalCommands_insert( "OpenManual", FreeCaller(), Accelerator( GDK_F1 ) ); + GlobalCommands_insert( "OpenManual", FreeCaller(), Accelerator( GDK_KEY_F1 ) ); GlobalCommands_insert( "Sleep", FreeCaller(), Accelerator( 'P', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalCommands_insert( "NewMap", FreeCaller() ); @@ -3202,11 +3189,11 @@ void MainFrame_Construct(){ GlobalCommands_insert( "Copy", FreeCaller(), Accelerator( 'C', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "Paste", FreeCaller(), Accelerator( 'V', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "PasteToCamera", FreeCaller(), Accelerator( 'V', (GdkModifierType)GDK_MOD1_MASK ) ); - GlobalCommands_insert( "CloneSelection", FreeCaller(), Accelerator( GDK_space ) ); - GlobalCommands_insert( "CloneSelectionAndMakeUnique", FreeCaller(), Accelerator( GDK_space, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "DeleteSelection", FreeCaller(), Accelerator( GDK_BackSpace ) ); + GlobalCommands_insert( "CloneSelection", FreeCaller(), Accelerator( GDK_KEY_space ) ); + GlobalCommands_insert( "CloneSelectionAndMakeUnique", FreeCaller(), Accelerator( GDK_KEY_space, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "DeleteSelection", FreeCaller(), Accelerator( GDK_KEY_BackSpace ) ); GlobalCommands_insert( "ParentSelection", FreeCaller() ); - GlobalCommands_insert( "UnSelectSelection", FreeCaller(), Accelerator( GDK_Escape ) ); + GlobalCommands_insert( "UnSelectSelection", FreeCaller(), Accelerator( GDK_KEY_Escape ) ); GlobalCommands_insert( "InvertSelection", FreeCaller(), Accelerator( 'I' ) ); GlobalCommands_insert( "SelectInside", FreeCaller() ); GlobalCommands_insert( "SelectTouching", FreeCaller() ); @@ -3278,24 +3265,24 @@ void MainFrame_Construct(){ GlobalCommands_insert( "SelectAllOfType", FreeCaller(), Accelerator( 'A', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexRotateClock", FreeCaller(), Accelerator( GDK_Next, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexRotateCounter", FreeCaller(), Accelerator( GDK_Prior, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexScaleUp", FreeCaller(), Accelerator( GDK_Up, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "TexScaleDown", FreeCaller(), Accelerator( GDK_Down, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "TexScaleLeft", FreeCaller(), Accelerator( GDK_Left, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "TexScaleRight", FreeCaller(), Accelerator( GDK_Right, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "TexShiftUp", FreeCaller(), Accelerator( GDK_Up, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexShiftDown", FreeCaller(), Accelerator( GDK_Down, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexShiftLeft", FreeCaller(), Accelerator( GDK_Left, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexShiftRight", FreeCaller(), Accelerator( GDK_Right, (GdkModifierType)GDK_SHIFT_MASK ) ); - - GlobalCommands_insert( "MoveSelectionDOWN", FreeCaller(), Accelerator( GDK_KP_Subtract ) ); - GlobalCommands_insert( "MoveSelectionUP", FreeCaller(), Accelerator( GDK_KP_Add ) ); - - GlobalCommands_insert( "SelectNudgeLeft", FreeCaller(), Accelerator( GDK_Left, (GdkModifierType)GDK_MOD1_MASK ) ); - GlobalCommands_insert( "SelectNudgeRight", FreeCaller(), Accelerator( GDK_Right, (GdkModifierType)GDK_MOD1_MASK ) ); - GlobalCommands_insert( "SelectNudgeUp", FreeCaller(), Accelerator( GDK_Up, (GdkModifierType)GDK_MOD1_MASK ) ); - GlobalCommands_insert( "SelectNudgeDown", FreeCaller(), Accelerator( GDK_Down, (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "TexRotateClock", FreeCaller(), Accelerator( GDK_KEY_Next, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexRotateCounter", FreeCaller(), Accelerator( GDK_KEY_Prior, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexScaleUp", FreeCaller(), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexScaleDown", FreeCaller(), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexScaleLeft", FreeCaller(), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexScaleRight", FreeCaller(), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexShiftUp", FreeCaller(), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexShiftDown", FreeCaller(), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexShiftLeft", FreeCaller(), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexShiftRight", FreeCaller(), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_SHIFT_MASK ) ); + + GlobalCommands_insert( "MoveSelectionDOWN", FreeCaller(), Accelerator( GDK_KEY_KP_Subtract ) ); + GlobalCommands_insert( "MoveSelectionUP", FreeCaller(), Accelerator( GDK_KEY_KP_Add ) ); + + GlobalCommands_insert( "SelectNudgeLeft", FreeCaller(), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "SelectNudgeRight", FreeCaller(), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "SelectNudgeUp", FreeCaller(), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "SelectNudgeDown", FreeCaller(), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_MOD1_MASK ) ); Patch_registerCommands(); XYShow_registerCommands(); diff --git a/radiant/mainframe.h b/radiant/mainframe.h index c450fd54..27d09c01 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -22,6 +22,7 @@ #if !defined( INCLUDED_MAINFRAME_H ) #define INCLUDED_MAINFRAME_H +#include #include "gtkutil/window.h" #include "gtkutil/idledraw.h" #include "gtkutil/widget.h" @@ -36,8 +37,6 @@ class XYWnd; class CamWnd; class ZWnd; -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; const int c_command_status = 0; const int c_position_status = 1; @@ -60,7 +59,7 @@ enum EViewStyle MainFrame(); ~MainFrame(); -GtkWindow* m_window; +ui::Window m_window; CopiedString m_command_status; CopiedString m_position_status; @@ -73,9 +72,9 @@ void Create(); void SaveWindowInfo(); void Shutdown(); -GtkWidget* m_vSplit; -GtkWidget* m_hSplit; -GtkWidget* m_vSplit2; +ui::Widget m_vSplit; +ui::Widget m_hSplit; +ui::Widget m_vSplit2; XYWnd* m_pXYWnd; XYWnd* m_pYZWnd; @@ -86,7 +85,7 @@ XYWnd* m_pActiveXY; bool m_bSleeping; -GtkWidget *m_pStatusLabel[c_count_status]; +ui::Widget m_pStatusLabel[c_count_status]; EViewStyle m_nCurrentStyle; @@ -142,7 +141,7 @@ bool FloatingGroupDialog(){ extern MainFrame* g_pParentWnd; -GtkWindow* MainFrame_getWindow(); +ui::Window MainFrame_getWindow(); enum EMouseButtonMode { @@ -271,6 +270,6 @@ void XYWindowDestroyed_disconnect( SignalHandlerId id ); MouseEventHandlerId XYWindowMouseDown_connect( const MouseEventHandler& handler ); void XYWindowMouseDown_disconnect( MouseEventHandlerId id ); -extern GtkWidget* g_page_entity; +extern ui::Widget g_page_entity; #endif diff --git a/radiant/map.cpp b/radiant/map.cpp index 147cfa98..056f3ecf 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -21,6 +21,8 @@ #include "map.h" +#include + #include "debugging/debugging.h" #include "imap.h" @@ -42,15 +44,8 @@ MapModules& ReferenceAPI_getMapModules(); #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include "uilib/uilib.h" #include "scenelib.h" #include "transformlib.h" @@ -770,15 +765,15 @@ void DoMapInfo(){ ModalDialog dialog; GtkEntry* brushes_entry; GtkEntry* entities_entry; - GtkListStore* EntityBreakdownWalker; + ui::ListStore EntityBreakdownWalker{ui::null}; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Map Info", G_CALLBACK( dialog_delete_callback ), &dialog ); + ui::Window window = MainFrame_getWindow().create_dialog_window("Map Info", G_CALLBACK(dialog_delete_callback ), &dialog ); window_set_position( window, g_posMapInfoWnd ); { - GtkVBox* vbox = create_dialog_vbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + auto vbox = create_dialog_vbox( 4, 4 ); + window.add(vbox); { GtkHBox* hbox = create_dialog_hbox( 4 ); @@ -789,36 +784,36 @@ void DoMapInfo(){ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_entry_set_editable( entry, FALSE ); + gtk_editable_set_editable( GTK_EDITABLE(entry), FALSE ); brushes_entry = entry; } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_entry_set_editable( entry, FALSE ); + gtk_editable_set_editable( GTK_EDITABLE(entry), FALSE ); entities_entry = entry; } { - GtkWidget* label = gtk_label_new( "Total Brushes" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Total Brushes" ); + label.show(); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkWidget* label = gtk_label_new( "Total Entities" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Total Entities" ); + label.show(); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -836,38 +831,38 @@ void DoMapInfo(){ } } { - GtkWidget* label = gtk_label_new( "Entity breakdown" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Entity breakdown" ); + label.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, TRUE, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 ); + auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( scr ), TRUE, TRUE, 0 ); { - GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ); + ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING )); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_clickable( GTK_TREE_VIEW( view ), TRUE ); { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Entity", renderer, "text", 0, 0 ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Entity", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); gtk_tree_view_column_set_sort_column_id( column, 0 ); } { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Count", renderer, "text", 1, 0 ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Count", renderer, {{"text", 1}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); gtk_tree_view_column_set_sort_column_id( column, 1 ); } - gtk_widget_show( view ); + view.show(); - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); EntityBreakdownWalker = store; } @@ -890,7 +885,7 @@ void DoMapInfo(){ } } - g_object_unref( G_OBJECT( EntityBreakdownWalker ) ); + EntityBreakdownWalker.unref(); char tmp[16]; sprintf( tmp, "%u", Unsigned( g_brushCount.get() ) ); @@ -1812,15 +1807,15 @@ const char* getLastFolderPath(){ } const char* map_open( const char* title ){ - return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getLastFolderPath(), MapFormat::Name(), false, true, false ); + return MainFrame_getWindow().file_dialog( TRUE, title, getLastFolderPath(), MapFormat::Name(), true, false, false ); } const char* map_import( const char* title ){ - return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getLastFolderPath(), MapFormat::Name(), false, true, false ); + return MainFrame_getWindow().file_dialog( TRUE, title, getLastFolderPath(), MapFormat::Name(), false, true, false ); } const char* map_save( const char* title ){ - return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, title, getLastFolderPath(), MapFormat::Name(), false, false, true ); + return MainFrame_getWindow().file_dialog( FALSE, title, getLastFolderPath(), MapFormat::Name(), false, false, true ); } void OpenMap(){ @@ -2044,34 +2039,34 @@ void DoFind(){ GtkEntry* entity; GtkEntry* brush; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Find Brush", G_CALLBACK( dialog_delete_callback ), &dialog ); + ui::Window window = MainFrame_getWindow().create_dialog_window("Find Brush", G_CALLBACK(dialog_delete_callback ), &dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); - gtk_window_add_accel_group( window, accel ); + auto accel = ui::AccelGroup(); + window.add_accel_group( accel ); { - GtkVBox* vbox = create_dialog_vbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + auto vbox = create_dialog_vbox( 4, 4 ); + window.add(vbox); { GtkTable* table = create_dialog_table( 2, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkWidget* label = gtk_label_new( "Entity number" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Entity number" ); + label.show(); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Brush number" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Brush number" ); + label.show(); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -2079,8 +2074,8 @@ void DoFind(){ entity = entry; } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -2092,15 +2087,15 @@ void DoFind(){ GtkHBox* hbox = create_dialog_hbox( 4 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), TRUE, TRUE, 0 ); { - GtkButton* button = create_dialog_button( "Find", G_CALLBACK( dialog_button_ok ), &dialog ); + auto button = create_dialog_button( "Find", G_CALLBACK( dialog_button_ok ), &dialog ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + widget_make_default( button ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { GtkButton* button = create_dialog_button( "Close", G_CALLBACK( dialog_button_cancel ), &dialog ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); } } } diff --git a/radiant/mru.cpp b/radiant/mru.cpp index cb833010..50d89bf1 100644 --- a/radiant/mru.cpp +++ b/radiant/mru.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include "os/file.h" #include "generic/callback.h" @@ -121,7 +121,7 @@ void MRU_AddFile( const char *str ){ MRU_SetText( 0, str ); gtk_widget_set_sensitive( GTK_WIDGET( MRU_items[0] ), TRUE ); - gtk_widget_show( GTK_WIDGET( MRU_items[MRU_used - 1] ) ); + ui::Widget(GTK_WIDGET( MRU_items[MRU_used - 1] )).show(); } void MRU_Init(){ @@ -136,7 +136,7 @@ void MRU_AddWidget( GtkMenuItem *widget, std::size_t pos ){ if ( pos < MRU_used ) { MRU_updateWidget( pos, MRU_GetText( pos ) ); gtk_widget_set_sensitive( GTK_WIDGET( MRU_items[0] ), TRUE ); - gtk_widget_show( GTK_WIDGET( MRU_items[pos] ) ); + ui::Widget(GTK_WIDGET( MRU_items[pos] )).show(); } } } @@ -159,7 +159,7 @@ void MRU_Activate( std::size_t index ){ MRU_SetText( i, MRU_GetText( i + 1 ) ); if ( MRU_used == 0 ) { - gtk_label_set_text( GTK_LABEL( GTK_BIN( MRU_items[0] )->child ), "Recent Files" ); + gtk_label_set_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN( MRU_items[0] )) ), "Recent Files" ); gtk_widget_set_sensitive( GTK_WIDGET( MRU_items[0] ), FALSE ); } else @@ -191,7 +191,7 @@ LoadMRU g_load_mru2( 2 ); LoadMRU g_load_mru3( 3 ); LoadMRU g_load_mru4( 4 ); -void MRU_constructMenu( GtkMenu* menu ){ +void MRU_constructMenu( ui::Menu menu ){ { GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_1", LoadMRUCaller( g_load_mru1 ) ); gtk_widget_set_sensitive( GTK_WIDGET( item ), FALSE ); diff --git a/radiant/mru.h b/radiant/mru.h index 273c97f1..33627d80 100644 --- a/radiant/mru.h +++ b/radiant/mru.h @@ -19,13 +19,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_MRU_H ) #define INCLUDED_MRU_H void MRU_AddFile( const char *str ); -typedef struct _GtkMenu GtkMenu; -void MRU_constructMenu( GtkMenu* menu ); +void MRU_constructMenu( ui::Menu menu ); void MRU_Construct(); void MRU_Destroy(); diff --git a/radiant/multimon.cpp b/radiant/multimon.cpp index 04407591..6fd41003 100644 --- a/radiant/multimon.cpp +++ b/radiant/multimon.cpp @@ -32,8 +32,8 @@ multimon_globals_t g_multimon_globals; LatchedBool g_Multimon_enableSysMenuPopups( false, "Floating windows sysmenu icons" ); void MultiMonitor_constructPreferences( PreferencesPage& page ){ - GtkWidget* primary_monitor = page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon ); - GtkWidget* popup = page.appendCheckBox( + ui::CheckButton primary_monitor = page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon ); + ui::CheckButton popup = page.appendCheckBox( "", "Disable system menu on popup windows", LatchedBoolImportCaller( g_Multimon_enableSysMenuPopups ), BoolExportCaller( g_Multimon_enableSysMenuPopups.m_latched ) @@ -44,7 +44,7 @@ void MultiMonitor_constructPreferences( PreferencesPage& page ){ #include "preferencesystem.h" #include "stringio.h" -#include +#include namespace { diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index 73639e54..96e60eac 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -27,20 +27,12 @@ #include "patchdialog.h" +#include + #include "itexdef.h" #include "debugging/debugging.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "gtkutil/idledraw.h" #include "gtkutil/entry.h" #include "gtkutil/button.h" @@ -161,21 +153,20 @@ void Scene_PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions Scene_forEachVisibleSelectedPatch( PatchSetFixedSubdivisions( subdivisions ) ); } -typedef struct _GtkCheckButton GtkCheckButton; class Subdivisions { public: -GtkCheckButton* m_enabled; -GtkEntry* m_horizontal; -GtkEntry* m_vertical; -Subdivisions() : m_enabled( 0 ), m_horizontal( 0 ), m_vertical( 0 ){ +ui::CheckButton m_enabled; +ui::Entry m_horizontal; +ui::Entry m_vertical; +Subdivisions() : m_enabled( (GtkCheckButton *) 0 ), m_horizontal( ui::null ), m_vertical( ui::null ){ } void update(){ PatchFixedSubdivisions subdivisions; Scene_PatchGetFixedSubdivisions( subdivisions ); - toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_enabled ), subdivisions.m_enabled ); + toggle_button_set_active_no_signal( m_enabled, subdivisions.m_enabled ); if ( subdivisions.m_enabled ) { entry_set_int( m_horizontal, static_cast( subdivisions.m_x ) ); @@ -212,7 +203,7 @@ static void applyGtk( GtkToggleButton* toggle, Subdivisions* self ){ class PatchInspector : public Dialog { -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); Subdivisions m_subdivisions; NonModalEntry m_horizontalSubdivisionsEntry; NonModalEntry m_verticalSubdivisionsEntry; @@ -235,8 +226,8 @@ float m_fZ; float m_fVShift; */ int m_nCol; int m_nRow; -GtkComboBox *m_pRowCombo; -GtkComboBox *m_pColCombo; +ui::ComboBoxText m_pRowCombo{ui::null}; +ui::ComboBoxText m_pColCombo{ui::null}; std::size_t m_countRows; std::size_t m_countCols; @@ -265,7 +256,7 @@ PatchInspector() : } bool visible(){ - return GTK_WIDGET_VISIBLE( GetWidget() ); + return gtk_widget_get_visible( GetWidget() ); } // void UpdateInfo(); @@ -284,7 +275,7 @@ void exportData(); PatchInspector g_PatchInspector; -void PatchInspector_constructWindow( GtkWindow* main_window ){ +void PatchInspector_constructWindow( ui::Window main_window ){ g_PatchInspector.m_parent = main_window; g_PatchInspector.Create(); } @@ -320,7 +311,7 @@ void PatchInspector_toggleShown(){ // static functions // memorize the current state (that is don't try to undo our do before changing something else) -static void OnApply( GtkWidget *widget, gpointer data ){ +static void OnApply( ui::Widget widget, gpointer data ){ g_PatchInspector.exportData(); if ( g_PatchInspector.m_Patch != 0 ) { UndoableCommand command( "patchSetTexture" ); @@ -347,7 +338,7 @@ static void OnApply( GtkWidget *widget, gpointer data ){ } } -static void OnSelchangeComboColRow( GtkWidget *widget, gpointer data ){ +static void OnSelchangeComboColRow( ui::Widget widget, gpointer data ){ if ( !g_PatchInspector.m_bListenChanged ) { return; } @@ -375,27 +366,27 @@ void Scene_PatchTileTexture_Selected( scene::Graph& graph, float s, float t ){ SceneChangeNotify(); } -static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){ Patch_CapTexture(); } -static void OnBtnPatchfit( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchfit( ui::Widget widget, gpointer data ){ Patch_FitTexture(); } -static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){ Patch_NaturalTexture(); } -static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchreset( ui::Widget widget, gpointer data ){ Patch_ResetTexture(); } -static void OnBtnPatchFlipX( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchFlipX( ui::Widget widget, gpointer data ){ Patch_FlipTextureX(); } -static void OnBtnPatchFlipY( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchFlipY( ui::Widget widget, gpointer data ){ Patch_FlipTextureY(); } @@ -455,7 +446,7 @@ void Scene_PatchTranslateTexture_Selected( scene::Graph& graph, float s, float t Scene_forEachVisibleSelectedPatch( PatchTranslateTexture( s, t ) ); } -static void OnBtnPatchAutoCap( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchAutoCap( ui::Widget widget, gpointer data ){ Patch_AutoCapTexture(); } @@ -466,14 +457,14 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ td.scale[0] = td.scale[1] = 0; td.shift[0] = td.shift[1] = 0; - if ( adj->value == 0 ) { + if ( gtk_adjustment_get_value(adj) == 0 ) { return; } if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "hshift_adj" ) ) { g_pi_globals.shift[0] = static_cast( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) ); - if ( adj->value > 0 ) { + if ( gtk_adjustment_get_value(adj) > 0 ) { td.shift[0] = g_pi_globals.shift[0]; } else{ @@ -483,7 +474,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "vshift_adj" ) ) { g_pi_globals.shift[1] = static_cast( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) ); - if ( adj->value > 0 ) { + if ( gtk_adjustment_get_value(adj) > 0 ) { td.shift[1] = g_pi_globals.shift[1]; } else{ @@ -495,7 +486,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ if ( g_pi_globals.scale[0] == 0.0f ) { return; } - if ( adj->value > 0 ) { + if ( gtk_adjustment_get_value(adj) > 0 ) { td.scale[0] = g_pi_globals.scale[0]; } else{ @@ -507,7 +498,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ if ( g_pi_globals.scale[1] == 0.0f ) { return; } - if ( adj->value > 0 ) { + if ( gtk_adjustment_get_value(adj) > 0 ) { td.scale[1] = g_pi_globals.scale[1]; } else{ @@ -517,7 +508,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "rotate_adj" ) ) { g_pi_globals.rotate = static_cast( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) ); - if ( adj->value > 0 ) { + if ( gtk_adjustment_get_value(adj) > 0 ) { td.rotate = g_pi_globals.rotate; } else{ @@ -525,7 +516,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ } } - adj->value = 0; + gtk_adjustment_set_value(adj, 0); // will scale shift rotate the patch accordingly @@ -544,15 +535,15 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ } // update the point-by-point view - OnSelchangeComboColRow( 0,0 ); + OnSelchangeComboColRow( ui::root ,0 ); } -static gint OnDialogKey( GtkWidget* widget, GdkEventKey* event, gpointer data ){ - if ( event->keyval == GDK_Return ) { - OnApply( 0, 0 ); +static gint OnDialogKey( ui::Widget widget, GdkEventKey* event, gpointer data ){ + if ( event->keyval == GDK_KEY_Return ) { + OnApply( ui::root, 0 ); return TRUE; } - else if ( event->keyval == GDK_Escape ) { + else if ( event->keyval == GDK_KEY_Escape ) { g_PatchInspector.GetPatchInfo(); return TRUE; } @@ -562,8 +553,8 @@ static gint OnDialogKey( GtkWidget* widget, GdkEventKey* event, gpointer data ){ // ============================================================================= // PatchInspector class -GtkWindow* PatchInspector::BuildDialog(){ - GtkWindow* window = create_floating_window( "Patch Properties", m_parent ); +ui::Window PatchInspector::BuildDialog(){ + ui::Window window = ui::Window(create_floating_window( "Patch Properties", m_parent )); m_position_tracker.connect( window ); @@ -573,208 +564,208 @@ GtkWindow* PatchInspector::BuildDialog(){ { - GtkVBox* vbox = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) ); + auto vbox = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - gtk_widget_show( GTK_WIDGET( vbox ) ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + vbox.show(); + window.add(vbox); { - GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( FALSE, 5 ) ); - gtk_widget_show( GTK_WIDGET( hbox ) ); + auto hbox = ui::HBox( FALSE, 5 ); + hbox.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), TRUE, TRUE, 0 ); { - GtkVBox* vbox2 = GTK_VBOX( gtk_vbox_new( FALSE, 0 ) ); + auto vbox2 = ui::VBox( FALSE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 0 ); - gtk_widget_show( GTK_WIDGET( vbox2 ) ); + vbox2.show(); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), TRUE, TRUE, 0 ); { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Details" ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); + auto frame = ui::Frame( "Details" ); + frame.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) ); + auto vbox3 = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 ); - gtk_widget_show( GTK_WIDGET( vbox3 ) ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + vbox3.show(); + frame.add(vbox3); { - GtkTable* table = GTK_TABLE( gtk_table_new( 2, 2, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); + auto table = ui::Table( 2, 2, FALSE ); + table.show(); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Row:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Row:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Column:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Column:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); - g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); - AddDialogData( *combo, m_nRow ); + auto combo = ui::ComboBoxText(); + combo.connect( "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); + AddDialogData( *GTK_COMBO_BOX(combo), m_nRow ); - gtk_widget_show( GTK_WIDGET( combo ) ); + combo.show(); gtk_table_attach( table, GTK_WIDGET( combo ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( combo ), 60, -1 ); + gtk_widget_set_size_request( GTK_WIDGET( combo ), 60, -1 ); m_pRowCombo = combo; } { - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); - g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); - AddDialogData( *combo, m_nCol ); + auto combo = ui::ComboBoxText(); + combo.connect( "changed", G_CALLBACK( OnSelchangeComboColRow ), this ); + AddDialogData( *GTK_COMBO_BOX(combo), m_nCol ); - gtk_widget_show( GTK_WIDGET( combo ) ); + combo.show(); gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( combo ), 60, -1 ); + gtk_widget_set_size_request( GTK_WIDGET( combo ), 60, -1 ); m_pColCombo = combo; } } - GtkTable* table = GTK_TABLE( gtk_table_new( 5, 2, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); + auto table = ui::Table( 5, 2, FALSE ); + table.show(); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "X:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "X:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Y:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Y:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Z:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Z:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "S:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "S:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 3, 4, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "T:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "T:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 4, 5, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - AddDialogData( *entry, m_fX ); + AddDialogData( *GTK_ENTRY(entry), m_fX ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - AddDialogData( *entry, m_fY ); + AddDialogData( *GTK_ENTRY(entry), m_fY ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - AddDialogData( *entry, m_fZ ); + AddDialogData( *GTK_ENTRY(entry), m_fZ ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 3, 4, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - AddDialogData( *entry, m_fS ); + AddDialogData( *GTK_ENTRY(entry), m_fS ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 4, 5, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - AddDialogData( *entry, m_fT ); + AddDialogData( *GTK_ENTRY(entry), m_fT ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } } } if ( g_pGameDescription->mGameType == "doom3" ) { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Tesselation" ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); + auto frame = ui::Frame( "Tesselation" ); + frame.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) ); + auto vbox3 = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 ); - gtk_widget_show( GTK_WIDGET( vbox3 ) ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + vbox3.show(); + frame.add(vbox3); { - GtkTable* table = GTK_TABLE( gtk_table_new( 3, 2, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); + auto table = ui::Table( 3, 2, FALSE ); + table.show(); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Fixed" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Fixed" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new() ); - gtk_widget_show( GTK_WIDGET( check ) ); + auto check = ui::CheckButton(GTK_CHECK_BUTTON( gtk_check_button_new() )); + check.show(); gtk_table_attach( table, GTK_WIDGET( check ), 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); m_subdivisions.m_enabled = check; - guint handler_id = g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( &Subdivisions::applyGtk ), &m_subdivisions ); + guint handler_id = check.connect( "toggled", G_CALLBACK( &Subdivisions::applyGtk ), &m_subdivisions ); g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Horizontal" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); @@ -782,15 +773,15 @@ GtkWindow* PatchInspector::BuildDialog(){ m_horizontalSubdivisionsEntry.connect( entry ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Vertical" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); @@ -802,240 +793,240 @@ GtkWindow* PatchInspector::BuildDialog(){ } } { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Texturing" ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); + auto frame = ui::Frame( "Texturing" ); + frame.show(); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox2 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) ); - gtk_widget_show( GTK_WIDGET( vbox2 ) ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); + auto vbox2 = ui::VBox( FALSE, 5 ); + vbox2.show(); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Name:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Name:" ); + label.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( label ), TRUE, TRUE, 0 ); gtk_label_set_justify( label, GTK_JUSTIFY_LEFT ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - // gtk_entry_set_editable (GTK_ENTRY (entry), false); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + // gtk_editable_set_editable (GTK_ENTRY (entry), false); + entry.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); - AddDialogData( *entry, m_strName ); + AddDialogData( *GTK_ENTRY(entry), m_strName ); - g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); + entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - GtkTable* table = GTK_TABLE( gtk_table_new( 5, 4, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); + auto table = ui::Table( 5, 4, FALSE ); + table.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal Shift Step" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Horizontal Shift Step" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 0, 1, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), (GtkAttachOptions)( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Shift Step" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Vertical Shift Step" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 1, 2, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), (GtkAttachOptions)( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal Stretch Step" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Horizontal Stretch Step" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 2, 3, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), (GtkAttachOptions)( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Flip" ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + auto button = ui::Button( "Flip" ); + button.show(); gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 2, 3, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipX ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchFlipX ), 0 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Stretch Step" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Vertical Stretch Step" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 3, 4, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), (GtkAttachOptions)( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Flip" ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + auto button = ui::Button( "Flip" ); + button.show(); gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 3, 4, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipY ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchFlipY ), 0 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Rotate Step" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Rotate Step" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 4, 5, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), (GtkAttachOptions)( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); - g_object_set_data( G_OBJECT( window ), "hshift_entry", entry ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); + g_object_set_data( G_OBJECT( window ), "hshift_entry", (void *) entry ); // we fill in this data, if no patch is selected the widgets are unmodified when the inspector is raised // so we need to have at least one initialisation somewhere entry_set_float( entry, g_pi_globals.shift[0] ); - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 ) ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "hshift_adj", adj ); + auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 ); + adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), (gpointer) entry ); + g_object_set_data( G_OBJECT( window ), "hshift_adj", (gpointer) adj ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); - gtk_widget_show( GTK_WIDGET( spin ) ); + auto spin = ui::SpinButton( adj, 1, 0 ); + spin.show(); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1, (GtkAttachOptions)( 0 ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 ); - GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + gtk_widget_set_can_focus( spin, false ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); entry_set_float( entry, g_pi_globals.shift[1] ); - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 ) ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "vshift_adj", adj ); + auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 ); + adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry ); + g_object_set_data( G_OBJECT( window ), "vshift_adj", (gpointer) adj ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); - gtk_widget_show( GTK_WIDGET( spin ) ); + auto spin = ui::SpinButton( adj, 1, 0 ); + spin.show(); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2, (GtkAttachOptions)( 0 ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 ); - GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + gtk_widget_set_can_focus( spin, false ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 2, 3, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); entry_set_float( entry, g_pi_globals.scale[0] ); - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ) ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "hscale_adj", adj ); + auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); + adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry ); + g_object_set_data( G_OBJECT( window ), "hscale_adj", (gpointer) adj ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); - gtk_widget_show( GTK_WIDGET( spin ) ); + auto spin = ui::SpinButton( adj, 1, 0 ); + spin.show(); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3, (GtkAttachOptions)( 0 ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 ); - GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + gtk_widget_set_can_focus( spin, false ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 3, 4, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); entry_set_float( entry, g_pi_globals.scale[1] ); - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ) ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "vscale_adj", adj ); + auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); + adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry ); + g_object_set_data( G_OBJECT( window ), "vscale_adj", (gpointer) adj ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); - gtk_widget_show( GTK_WIDGET( spin ) ); + auto spin = ui::SpinButton( adj, 1, 0 ); + spin.show(); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 3, 4, (GtkAttachOptions)( 0 ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 ); - GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + gtk_widget_set_can_focus( spin, false ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 4, 5, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); entry_set_float( entry, g_pi_globals.rotate ); - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ) ); // NOTE: Arnout - this really should be 360 but can't change it anymore as it could break existing maps - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "rotate_adj", adj ); + auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); // NOTE: Arnout - this really should be 360 but can't change it anymore as it could break existing maps + adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry ); + g_object_set_data( G_OBJECT( window ), "rotate_adj", (gpointer) adj ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); - gtk_widget_show( GTK_WIDGET( spin ) ); + auto spin = ui::SpinButton( adj, 1, 0 ); + spin.show(); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 4, 5, (GtkAttachOptions)( 0 ), (GtkAttachOptions)( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 ); - GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 ); + gtk_widget_set_can_focus( spin, false ); } } - GtkHBox* hbox2 = GTK_HBOX( gtk_hbox_new( TRUE, 5 ) ); - gtk_widget_show( GTK_WIDGET( hbox2 ) ); + auto hbox2 = ui::HBox( TRUE, 5 ); + hbox2.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( hbox2 ), TRUE, FALSE, 0 ); { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Auto Cap" ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + auto button = ui::Button( "Auto Cap" ); + button.show(); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchAutoCap ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchAutoCap ), 0 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "CAP" ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + auto button = ui::Button( "CAP" ); + button.show(); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Set..." ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + auto button = ui::Button( "Set..." ); + button.show(); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchreset ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchreset ), 0 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Natural" ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + auto button = ui::Button( "Natural" ); + button.show(); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } { - GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Fit" ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + auto button = ui::Button( "Fit" ); + button.show(); gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchfit ), 0 ); - gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + button.connect( "clicked", G_CALLBACK( OnBtnPatchfit ), 0 ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 ); } } } @@ -1082,7 +1073,7 @@ void PatchInspector::GetPatchInfo(){ for ( std::size_t i = 0; i < m_countRows; ++i ) { - gtk_combo_box_remove_text( m_pRowCombo, gint( m_countRows - i - 1 ) ); + gtk_combo_box_text_remove( m_pRowCombo, gint( m_countRows - i - 1 ) ); } m_countRows = m_Patch->getHeight(); @@ -1090,7 +1081,7 @@ void PatchInspector::GetPatchInfo(){ { char buffer[16]; sprintf( buffer, "%u", Unsigned( i ) ); - gtk_combo_box_append_text( m_pRowCombo, buffer ); + gtk_combo_box_text_append_text( m_pRowCombo, buffer ); } gtk_combo_box_set_active( m_pRowCombo, 0 ); @@ -1101,7 +1092,7 @@ void PatchInspector::GetPatchInfo(){ for ( std::size_t i = 0; i < m_countCols; ++i ) { - gtk_combo_box_remove_text( m_pColCombo, gint( m_countCols - i - 1 ) ); + gtk_combo_box_text_remove( m_pColCombo, gint( m_countCols - i - 1 ) ); } m_countCols = m_Patch->getWidth(); @@ -1109,7 +1100,7 @@ void PatchInspector::GetPatchInfo(){ { char buffer[16]; sprintf( buffer, "%u", Unsigned( i ) ); - gtk_combo_box_append_text( m_pColCombo, buffer ); + gtk_combo_box_text_append_text( m_pColCombo, buffer ); } gtk_combo_box_set_active( m_pColCombo, 0 ); diff --git a/radiant/patchdialog.h b/radiant/patchdialog.h index 1304ccbe..ca1f6c9e 100644 --- a/radiant/patchdialog.h +++ b/radiant/patchdialog.h @@ -19,15 +19,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_PATCHDIALOG_H ) #define INCLUDED_PATCHDIALOG_H void PatchInspector_Construct(); void PatchInspector_Destroy(); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -void PatchInspector_constructWindow( GtkWindow* main_window ); +void PatchInspector_constructWindow( ui::Window main_window ); void PatchInspector_destroyWindow(); namespace scene diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 909e3466..6d6a5c4d 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -21,6 +21,9 @@ #include "patchmanip.h" +#include +#include + #include "debugging/debugging.h" @@ -723,13 +726,13 @@ void Patch_registerCommands(){ GlobalCommands_insert( "PatchCone", FreeCaller() ); GlobalCommands_insert( "PatchSphere", FreeCaller() ); GlobalCommands_insert( "SimplePatchMesh", FreeCaller(), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller(), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalCommands_insert( "PatchInsertAddColumn", FreeCaller() ); - GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller(), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "PatchInsertAddRow", FreeCaller() ); GlobalCommands_insert( "PatchDeleteFirstColumn", FreeCaller() ); - GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller(), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller(), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller() ); GlobalCommands_insert( "InvertCurve", FreeCaller(), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "RedisperseRows", FreeCaller(), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) ); @@ -743,14 +746,14 @@ void Patch_registerCommands(){ GlobalCommands_insert( "ClearPatchOverlays", FreeCaller(), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) ); } -void Patch_constructToolbar( GtkToolbar* toolbar ){ +void Patch_constructToolbar( ui::Toolbar toolbar ){ toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "cap_curve.png", "CapCurrentCurve" ); } -void Patch_constructMenu( GtkMenu* menu ){ +void Patch_constructMenu( ui::Menu menu ){ create_menu_item_with_mnemonic( menu, "Cylinder", "PatchCylinder" ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -763,7 +766,7 @@ void Patch_constructMenu( GtkMenu* menu ){ create_menu_item_with_mnemonic( menu, "End cap", "PatchEndCap" ); create_menu_item_with_mnemonic( menu, "Bevel", "PatchBevel" ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -780,7 +783,7 @@ void Patch_constructMenu( GtkMenu* menu ){ create_menu_item_with_mnemonic( menu, "Simple Patch Mesh...", "SimplePatchMesh" ); menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -791,7 +794,7 @@ void Patch_constructMenu( GtkMenu* menu ){ create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Rows", "PatchInsertAddRow" ); } { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -803,18 +806,18 @@ void Patch_constructMenu( GtkMenu* menu ){ } menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Matrix" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Matrix" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } create_menu_item_with_mnemonic( menu_in_menu, "Invert", "InvertCurve" ); - GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" ); + auto menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_3 ); } create_menu_item_with_mnemonic( menu_3, "Rows", "RedisperseRows" ); create_menu_item_with_mnemonic( menu_3, "Columns", "RedisperseCols" ); - GtkMenu* menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" ); + auto menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_4 ); } @@ -827,7 +830,7 @@ void Patch_constructMenu( GtkMenu* menu ){ create_menu_item_with_mnemonic( menu, "Cycle Cap Texture", "CycleCapTexturePatch" ); menu_separator( menu ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@ -837,12 +840,6 @@ void Patch_constructMenu( GtkMenu* menu ){ } -#include -#include -#include -#include -#include -#include #include "gtkutil/dialog.h" #include "gtkutil/widget.h" @@ -851,28 +848,28 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, GtkComboBox* width; GtkComboBox* height; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch density", G_CALLBACK( dialog_delete_callback ), &dialog ); + ui::Window window = MainFrame_getWindow().create_dialog_window("Patch density", G_CALLBACK(dialog_delete_callback ), &dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); - gtk_window_add_accel_group( window, accel ); + auto accel = ui::AccelGroup(); + window.add_accel_group( accel ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { GtkTable* table = create_dialog_table( 2, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Width:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Width:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Height:" ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + auto label = ui::Label( "Height:" ); + label.show(); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -880,8 +877,8 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, } { - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); -#define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_append_text( combo, # x ) + auto combo = ui::ComboBoxText(); +#define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_text_append_text( combo, # x ) D_ITEM( 3 ); D_ITEM( 5 ); D_ITEM( 7 ); @@ -898,7 +895,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, D_ITEM( 29 ); D_ITEM( 31 ); // MAX_PATCH_SIZE is 32, so we should be able to do 31... #undef D_ITEM - gtk_widget_show( GTK_WIDGET( combo ) ); + combo.show(); gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -906,8 +903,8 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, width = combo; } { - GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() ); -#define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_append_text( combo, # x ) + auto combo = ui::ComboBoxText(); +#define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_text_append_text( combo, # x ) D_ITEM( 3 ); D_ITEM( 5 ); D_ITEM( 7 ); @@ -924,7 +921,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, D_ITEM( 29 ); D_ITEM( 31 ); // MAX_PATCH_SIZE is 32, so we should be able to do 31... #undef D_ITEM - gtk_widget_show( GTK_WIDGET( combo ) ); + combo.show(); gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -937,16 +934,16 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); + auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_grab_focus( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); } } } @@ -972,64 +969,64 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); - GtkWidget* bevel; - GtkWidget* ibevel; - GtkWidget* endcap; - GtkWidget* iendcap; - GtkWidget* cylinder; + ui::Widget bevel; + ui::Widget ibevel; + ui::Widget endcap; + ui::Widget iendcap; + ui::Widget cylinder; - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Cap", dialog ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window( "Cap", dialog ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); - gtk_window_add_accel_group( window, accel_group ); + auto accel_group = ui::AccelGroup(); + window.add_accel_group( accel_group ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { // Gef: Added a vbox to contain the toggle buttons - GtkVBox* radio_vbox = create_dialog_vbox( 4 ); - gtk_container_add( GTK_CONTAINER( hbox ), GTK_WIDGET( radio_vbox ) ); + auto radio_vbox = create_dialog_vbox( 4 ); + hbox.add(radio_vbox); { - GtkTable* table = GTK_TABLE( gtk_table_new( 5, 2, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); + auto table = ui::Table( 5, 2, FALSE ); + table.show(); gtk_box_pack_start( GTK_BOX( radio_vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkImage* image = new_local_image( "cap_bevel.png" ); - gtk_widget_show( GTK_WIDGET( image ) ); + auto image = new_local_image( "cap_bevel.png" ); + image.show(); gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkImage* image = new_local_image( "cap_endcap.png" ); - gtk_widget_show( GTK_WIDGET( image ) ); + auto image = new_local_image( "cap_endcap.png" ); + image.show(); gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkImage* image = new_local_image( "cap_ibevel.png" ); - gtk_widget_show( GTK_WIDGET( image ) ); + auto image = new_local_image( "cap_ibevel.png" ); + image.show(); gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkImage* image = new_local_image( "cap_iendcap.png" ); - gtk_widget_show( GTK_WIDGET( image ) ); + auto image = new_local_image( "cap_iendcap.png" ); + image.show(); gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkImage* image = new_local_image( "cap_cylinder.png" ); - gtk_widget_show( GTK_WIDGET( image ) ); + auto image = new_local_image( "cap_cylinder.png" ); + image.show(); gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 4, 5, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1037,52 +1034,52 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ GSList* group = 0; { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Bevel" ); - gtk_widget_show( button ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Bevel" )); + button.show(); gtk_table_attach( table, button, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), (GtkAttachOptions) ( 0 ), 0, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); bevel = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Endcap" ); - gtk_widget_show( button ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Endcap" )); + button.show(); gtk_table_attach( table, button, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), (GtkAttachOptions) ( 0 ), 0, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); endcap = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Bevel" ); - gtk_widget_show( button ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Bevel" )); + button.show(); gtk_table_attach( table, button, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), (GtkAttachOptions) ( 0 ), 0, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); ibevel = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Endcap" ); - gtk_widget_show( button ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Endcap" )); + button.show(); gtk_table_attach( table, button, 1, 2, 3, 4, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), (GtkAttachOptions) ( 0 ), 0, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); iendcap = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Cylinder" ); - gtk_widget_show( button ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Cylinder" )); + button.show(); gtk_table_attach( table, button, 1, 2, 4, 5, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), (GtkAttachOptions) ( 0 ), 0, 0 ); - group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) ); + group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) ); cylinder = button; } @@ -1093,15 +1090,15 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); + widget_make_default( button ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); } { GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_KEY_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); } } } diff --git a/radiant/patchmanip.h b/radiant/patchmanip.h index 47f7f224..512a3f95 100644 --- a/radiant/patchmanip.h +++ b/radiant/patchmanip.h @@ -22,13 +22,12 @@ #if !defined ( INCLUDED_PATCHMANIP_H ) #define INCLUDED_PATCHMANIP_H +#include #include "string/stringfwd.h" void Patch_registerCommands(); -typedef struct _GtkToolbar GtkToolbar; -typedef struct _GtkMenu GtkMenu; -void Patch_constructToolbar( GtkToolbar* toolbar ); -void Patch_constructMenu( GtkMenu* menu ); +void Patch_constructToolbar( ui::Toolbar toolbar ); +void Patch_constructMenu( ui::Menu menu ); namespace scene { diff --git a/radiant/pluginmanager.cpp b/radiant/pluginmanager.cpp index 30cc0c23..91e9f9ae 100644 --- a/radiant/pluginmanager.cpp +++ b/radiant/pluginmanager.cpp @@ -53,7 +53,7 @@ public: /*! build directly from a SYN_PROVIDE interface */ -CPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table ); +CPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ); /*! dispatching a command by name to the plugin */ @@ -69,7 +69,7 @@ bool ownsCommandID( std::size_t n ); }; -CPluginSlot::CPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table ){ +CPluginSlot::CPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ){ mpTable = &table; m_menu_name = name; @@ -149,7 +149,7 @@ std::list mSlots; public: virtual ~CPluginSlots(); -void AddPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table ){ +void AddPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ){ mSlots.push_back( new CPluginSlot( main_window, name, table ) ); } @@ -190,13 +190,13 @@ bool CPluginSlots::Dispatch( std::size_t n, const char* p ){ CPluginSlots g_plugin_slots; -void FillPluginSlots( CPluginSlots& slots, GtkWidget* main_window ){ +void FillPluginSlots( CPluginSlots& slots, ui::Widget main_window ){ class AddPluginVisitor : public PluginModules::Visitor { CPluginSlots& m_slots; - GtkWidget* m_main_window; + ui::Widget m_main_window; public: - AddPluginVisitor( CPluginSlots& slots, GtkWidget* main_window ) + AddPluginVisitor( CPluginSlots& slots, ui::Widget main_window ) : m_slots( slots ), m_main_window( main_window ){ } void visit( const char* name, const _QERPluginTable& table ) const { @@ -220,7 +220,7 @@ void CPlugInManager::Dispatch( std::size_t n, const char * p ){ g_plugin_slots.Dispatch( n, p ); } -void CPlugInManager::Init( GtkWidget* main_window ){ +void CPlugInManager::Init( ui::Widget main_window ){ FillPluginSlots( g_plugin_slots, main_window ); } diff --git a/radiant/pluginmanager.h b/radiant/pluginmanager.h index d7943fb3..6603f6e1 100644 --- a/radiant/pluginmanager.h +++ b/radiant/pluginmanager.h @@ -23,8 +23,8 @@ #define INCLUDED_PLUGINMANAGER_H #include +#include -typedef struct _GtkWidget GtkWidget; /*! \class IPlugin @@ -55,7 +55,7 @@ class CPlugInManager { public: void Dispatch( std::size_t n, const char *p ); -void Init( GtkWidget* main_window ); +void Init( ui::Widget main_window ); void constructMenu( PluginsVisitor& menu ); void Shutdown(); }; diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index 4708a78c..e2af3b97 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -21,10 +21,9 @@ #include "pluginmenu.h" -#include "stream/textstream.h" +#include -#include -#include +#include "stream/textstream.h" #include "gtkutil/pointer.h" #include "gtkutil/menu.h" @@ -36,28 +35,28 @@ int m_nNextPlugInID = 0; -void plugin_activated( GtkWidget* widget, gpointer data ){ +void plugin_activated( ui::Widget widget, gpointer data ){ const char* str = (const char*)g_object_get_data( G_OBJECT( widget ),"command" ); GetPlugInMgr().Dispatch( gpointer_to_int( data ), str ); } #include -typedef std::stack WidgetStack; -void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ - GtkWidget *menu, *item, *parent, *subMenu; +void PlugInMenu_Add( ui::Menu plugin_menu, IPlugIn* pPlugIn ){ + ui::Widget item, parent; + ui::Menu menu{ui::null}, subMenu{ui::null}; const char *menuText, *menuCommand; - WidgetStack menuStack; + std::stack menuStack; - parent = gtk_menu_item_new_with_label( pPlugIn->getMenuName() ); - gtk_widget_show( parent ); - gtk_container_add( GTK_CONTAINER( plugin_menu ), parent ); + parent = ui::MenuItem( pPlugIn->getMenuName() ); + parent.show(); + plugin_menu.add(parent); std::size_t nCount = pPlugIn->getCommandCount(); if ( nCount > 0 ) { - menu = gtk_menu_new(); + menu = ui::Menu(); if ( g_Layout_enableDetachableMenus.m_value ) { - menu_tearoff( GTK_MENU( menu ) ); + menu_tearoff( menu ); } while ( nCount > 0 ) { @@ -66,7 +65,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ if ( menuText != 0 && strlen( menuText ) > 0 ) { if ( !strcmp( menuText, "-" ) ) { - item = gtk_menu_item_new(); + item = ui::Widget(gtk_menu_item_new()); gtk_widget_set_sensitive( item, FALSE ); } else if ( !strcmp( menuText, ">" ) ) { @@ -77,11 +76,11 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ continue; } - item = gtk_menu_item_new_with_label( menuText ); - gtk_widget_show( item ); - gtk_container_add( GTK_CONTAINER( menu ), item ); + item = ui::MenuItem( menuText ); + item.show(); + menu.add(item); - subMenu = gtk_menu_new(); + subMenu = ui::Menu(); gtk_menu_item_set_submenu( GTK_MENU_ITEM( item ), subMenu ); menuStack.push( menu ); menu = subMenu; @@ -100,12 +99,12 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ } else { - item = gtk_menu_item_new_with_label( menuText ); + item = ui::MenuItem( menuText ); g_object_set_data( G_OBJECT( item ),"command", const_cast( static_cast( menuCommand ) ) ); - g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( plugin_activated ), gint_to_pointer( m_nNextPlugInID ) ); + item.connect( "activate", G_CALLBACK( plugin_activated ), gint_to_pointer( m_nNextPlugInID ) ); } - gtk_widget_show( item ); - gtk_container_add( GTK_CONTAINER( menu ), item ); + item.show(); + menu.add(item); pPlugIn->addMenuID( m_nNextPlugInID++ ); } } @@ -125,15 +124,15 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ } } -GtkMenu* g_plugins_menu = 0; +ui::Menu g_plugins_menu{ui::null}; GtkMenuItem* g_plugins_menu_separator = 0; void PluginsMenu_populate(){ class PluginsMenuConstructor : public PluginsVisitor { - GtkMenu* m_menu; + ui::Menu m_menu; public: - PluginsMenuConstructor( GtkMenu* menu ) : m_menu( menu ){ + PluginsMenuConstructor( ui::Menu menu ) : m_menu( menu ){ } void visit( IPlugIn& plugin ){ PlugInMenu_Add( m_menu, &plugin ); @@ -147,18 +146,18 @@ public: void PluginsMenu_clear(){ m_nNextPlugInID = 0; - GList* lst = g_list_find( gtk_container_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) ); + GList* lst = g_list_find( gtk_container_get_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) ); while ( lst->next ) { gtk_container_remove( GTK_CONTAINER( g_plugins_menu ), GTK_WIDGET( lst->next->data ) ); - lst = g_list_find( gtk_container_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) ); + lst = g_list_find( gtk_container_get_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) ); } } -GtkMenuItem* create_plugins_menu(){ +ui::MenuItem create_plugins_menu(){ // Plugins menu - GtkMenuItem* plugins_menu_item = new_sub_menu_item_with_mnemonic( "_Plugins" ); - GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( plugins_menu_item ) ); + auto plugins_menu_item = new_sub_menu_item_with_mnemonic( "_Plugins" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( plugins_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); } diff --git a/radiant/pluginmenu.h b/radiant/pluginmenu.h index 254db777..b1685a61 100644 --- a/radiant/pluginmenu.h +++ b/radiant/pluginmenu.h @@ -19,14 +19,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_PLUGINMENU_H ) #define INCLUDED_PLUGINMENU_H -typedef struct _GtkMenuItem GtkMenuItem; -GtkMenuItem* create_plugins_menu(); +ui::MenuItem create_plugins_menu(); -typedef struct _GtkMenu GtkMenu; -typedef struct _GtkMenuItem GtkMenuItem; void PluginsMenu_populate(); void PluginsMenu_clear(); diff --git a/radiant/plugintoolbar.cpp b/radiant/plugintoolbar.cpp index 03ef2074..32b31c5a 100644 --- a/radiant/plugintoolbar.cpp +++ b/radiant/plugintoolbar.cpp @@ -21,12 +21,11 @@ #include "plugintoolbar.h" +#include #include "itoolbar.h" #include "modulesystem.h" -#include - #include "stream/stringstream.h" #include "gtkutil/image.h" #include "gtkutil/container.h" @@ -34,73 +33,72 @@ #include "mainframe.h" #include "plugin.h" -GtkImage* new_plugin_image( const char* filename ){ +ui::Image new_plugin_image( const char* filename ){ { StringOutputStream fullpath( 256 ); fullpath << GameToolsPath_get() << g_pluginsDir << "bitmaps/" << filename; - GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() ); - if ( image != 0 ) { - return image; - } + if ( auto image = image_new_from_file_with_mask(fullpath.c_str()) ) return image; } { StringOutputStream fullpath( 256 ); fullpath << AppPath_get() << g_pluginsDir << "bitmaps/" << filename; - GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() ); - if ( image != 0 ) { - return image; - } + if ( auto image = image_new_from_file_with_mask(fullpath.c_str()) ) return image; } { StringOutputStream fullpath( 256 ); fullpath << AppPath_get() << g_modulesDir << "bitmaps/" << filename; - GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() ); - if ( image != 0 ) { - return image; - } + if ( auto image = image_new_from_file_with_mask(fullpath.c_str()) ) return image; } return image_new_missing(); } -inline GtkToolbarChildType gtktoolbarchildtype_for_toolbarbuttontype( IToolbarButton::EType type ){ - switch ( type ) - { - case IToolbarButton::eSpace: - return GTK_TOOLBAR_CHILD_SPACE; - case IToolbarButton::eButton: - return GTK_TOOLBAR_CHILD_BUTTON; - case IToolbarButton::eToggleButton: - return GTK_TOOLBAR_CHILD_TOGGLEBUTTON; - case IToolbarButton::eRadioButton: - return GTK_TOOLBAR_CHILD_RADIOBUTTON; +void toolbar_insert( ui::Toolbar toolbar, const char* icon, const char* text, const char* tooltip, IToolbarButton::EType type, GCallback handler, gpointer data ){ + if (type == IToolbarButton::eSpace) { + auto it = ui::Widget(GTK_WIDGET(gtk_separator_tool_item_new())); + it.show(); + toolbar.add(it); + return; + } + if (type == IToolbarButton::eButton) { + auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_tool_button_new(GTK_WIDGET(new_plugin_image(icon)), text))); + gtk_widget_set_tooltip_text(button, tooltip); + gtk_widget_show_all(button); + button.connect("clicked", G_CALLBACK(handler), data); + toolbar.add(button); + return; + } + if (type == IToolbarButton::eToggleButton) { + auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_toggle_tool_button_new())); + gtk_tool_button_set_icon_widget(button, GTK_WIDGET(new_plugin_image(icon))); + gtk_tool_button_set_label(button, text); + gtk_widget_set_tooltip_text(button, tooltip); + gtk_widget_show_all(button); + button.connect("toggled", G_CALLBACK(handler), data); + toolbar.add(button); + return; } ERROR_MESSAGE( "invalid toolbar button type" ); - return (GtkToolbarChildType)0; -} - -void toolbar_insert( GtkToolbar *toolbar, const char* icon, const char* text, const char* tooltip, IToolbarButton::EType type, GtkSignalFunc handler, gpointer data ){ - gtk_toolbar_append_element( toolbar, gtktoolbarchildtype_for_toolbarbuttontype( type ), 0, text, tooltip, "", GTK_WIDGET( new_plugin_image( icon ) ), handler, data ); } -void ActivateToolbarButton( GtkWidget *widget, gpointer data ){ - const_cast( reinterpret_cast( data ) )->activate(); +void ActivateToolbarButton( GtkToolButton *widget, gpointer data ){ + (const_cast( reinterpret_cast( data )))->activate(); } -void PlugInToolbar_AddButton( GtkToolbar* toolbar, const IToolbarButton* button ){ - toolbar_insert( toolbar, button->getImage(), button->getText(), button->getTooltip(), button->getType(), GTK_SIGNAL_FUNC( ActivateToolbarButton ), reinterpret_cast( const_cast( button ) ) ); +void PlugInToolbar_AddButton( ui::Toolbar toolbar, const IToolbarButton* button ){ + toolbar_insert( toolbar, button->getImage(), button->getText(), button->getTooltip(), button->getType(), G_CALLBACK( ActivateToolbarButton ), reinterpret_cast( const_cast( button ) ) ); } -GtkToolbar* g_plugin_toolbar = 0; +ui::Toolbar g_plugin_toolbar{ui::null}; void PluginToolbar_populate(){ class AddToolbarItemVisitor : public ToolbarModules::Visitor { - GtkToolbar* m_toolbar; + ui::Toolbar m_toolbar; public: - AddToolbarItemVisitor( GtkToolbar* toolbar ) + AddToolbarItemVisitor( ui::Toolbar toolbar ) : m_toolbar( toolbar ){ } void visit( const char* name, const _QERPlugToolbarTable& table ) const { @@ -117,16 +115,15 @@ public: } void PluginToolbar_clear(){ - container_remove_all( GTK_CONTAINER( g_plugin_toolbar ) ); + container_remove_all( g_plugin_toolbar ); } -GtkToolbar* create_plugin_toolbar(){ - GtkToolbar *toolbar; +ui::Toolbar create_plugin_toolbar(){ - toolbar = GTK_TOOLBAR( gtk_toolbar_new() ); - gtk_toolbar_set_orientation( toolbar, GTK_ORIENTATION_HORIZONTAL ); + auto toolbar = ui::Toolbar(GTK_TOOLBAR( gtk_toolbar_new() )); + gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL ); gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS ); - gtk_widget_show( GTK_WIDGET( toolbar ) ); + toolbar.show(); g_plugin_toolbar = toolbar; diff --git a/radiant/plugintoolbar.h b/radiant/plugintoolbar.h index 7621cfd2..ca35b1bc 100644 --- a/radiant/plugintoolbar.h +++ b/radiant/plugintoolbar.h @@ -19,15 +19,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_PLUGINTOOLBAR_H ) #define INCLUDED_PLUGINTOOLBAR_H -typedef struct _GtkToolbar GtkToolbar; -GtkToolbar* create_plugin_toolbar(); +ui::Toolbar create_plugin_toolbar(); void PluginToolbar_populate(); void PluginToolbar_clear(); -typedef struct _GtkImage GtkImage; -GtkImage* new_plugin_image( const char* filename ); // filename is relative to plugin bitmaps path +ui::Image new_plugin_image( const char* filename ); // filename is relative to plugin bitmaps path #endif diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 46d15c7a..ba5e75cb 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -26,25 +26,12 @@ // #include "preferences.h" + +#include #include "environment.h" #include "debugging/debugging.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "generic/callback.h" #include "math/vector.h" #include "string/string.h" @@ -74,8 +61,8 @@ void Interface_constructPreferences( PreferencesPage& page ){ page.appendCheckBox( "", "Default Text Editor", g_TextEditor_useWin32Editor ); #else { - GtkWidget* use_custom = page.appendCheckBox( "Text Editor", "Custom", g_TextEditor_useCustomEditor ); - GtkWidget* custom_editor = page.appendPathEntry( "Text Editor Command", g_TextEditor_editorCommand, true ); + ui::CheckButton use_custom = page.appendCheckBox( "Text Editor", "Custom", g_TextEditor_useCustomEditor ); + ui::Widget custom_editor = page.appendPathEntry( "Text Editor Command", g_TextEditor_editorCommand, true ); Widget_connectToggleDependency( custom_editor, use_custom ); } #endif @@ -104,6 +91,7 @@ void Mouse_registerPreferencesPage(){ */ #include +#include inline const char* xmlAttr_getName( xmlAttrPtr attr ){ return reinterpret_cast( attr->name ); @@ -330,19 +318,19 @@ void CGameDialog::CreateGlobalFrame( PreferencesPage& page ){ page.appendCheckBox( "Startup", "Show Global Preferences", m_bGamePrompt ); } -GtkWindow* CGameDialog::BuildDialog(){ - GtkFrame* frame = create_dialog_frame( "Game settings", GTK_SHADOW_ETCHED_IN ); +ui::Window CGameDialog::BuildDialog(){ + auto frame = create_dialog_frame( "Game settings", ui::Shadow::ETCHED_IN ); - GtkVBox* vbox2 = create_dialog_vbox( 0, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); + auto vbox2 = create_dialog_vbox( 0, 4 ); + frame.add(vbox2); { - PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) ); + PreferencesPage preferencesPage( *this, ui::Widget(GTK_WIDGET( vbox2 )) ); Global_constructPreferences( preferencesPage ); CreateGlobalFrame( preferencesPage ); } - return create_simple_modal_dialog_window( "Global Preferences", m_modal, GTK_WIDGET( frame ) ); + return create_simple_modal_dialog_window( "Global Preferences", m_modal, frame ); } class LoadGameFile @@ -471,7 +459,7 @@ CGameDialog::~CGameDialog(){ delete ( *iGame ); *iGame = 0; } - if ( GetWidget() != 0 ) { + if ( GetWidget() ) { Destroy(); } } @@ -491,11 +479,11 @@ CGameDialog g_GamesDialog; // ============================================================================= // Widget callbacks for PrefsDlg -static void OnButtonClean( GtkWidget *widget, gpointer data ){ +static void OnButtonClean( ui::Widget widget, gpointer data ){ // make sure this is what the user wants - if ( gtk_MessageBox( GTK_WIDGET( g_Preferences.GetWidget() ), "This will close Radiant and clean the corresponding registry entries.\n" + if ( ui::Widget(GTK_WIDGET( g_Preferences.GetWidget() )).alert( "This will close Radiant and clean the corresponding registry entries.\n" "Next time you start Radiant it will be good as new. Do you wish to continue?", - "Reset Registry", eMB_YESNO, eMB_ICONASTERISK ) == eIDYES ) { + "Reset Registry", ui::alert_type::YESNO, ui::alert_icon::Asterisk ) == ui::alert_response::YES ) { PrefsDlg *dlg = (PrefsDlg*)data; dlg->EndModal( eIDCANCEL ); @@ -541,14 +529,14 @@ void PrefsDlg::Init(){ g_string_append( m_inipath, PREFS_LOCAL_FILENAME ); } -void notebook_set_page( GtkWidget* notebook, GtkWidget* page ){ +void notebook_set_page( ui::Widget notebook, ui::Widget page ){ int pagenum = gtk_notebook_page_num( GTK_NOTEBOOK( notebook ), page ); if ( gtk_notebook_get_current_page( GTK_NOTEBOOK( notebook ) ) != pagenum ) { gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook ), pagenum ); } } -void PrefsDlg::showPrefPage( GtkWidget* prefpage ){ +void PrefsDlg::showPrefPage( ui::Widget prefpage ){ notebook_set_page( m_notebook, prefpage ); return; } @@ -559,7 +547,7 @@ static void treeSelection( GtkTreeSelection* selection, gpointer data ){ GtkTreeModel* model; GtkTreeIter selected; if ( gtk_tree_selection_get_selected( selection, &model, &selected ) ) { - GtkWidget* prefpage; + ui::Widget prefpage; gtk_tree_model_get( model, &selected, 1, (gpointer*)&prefpage, -1 ); dlg->showPrefPage( prefpage ); } @@ -619,50 +607,50 @@ void PreferencesDialog_addSettingsPage( const PreferenceGroupCallback& callback PreferenceGroupCallbacks_pushBack( g_settingsCallbacks, callback ); } -void Widget_updateDependency( GtkWidget* self, GtkWidget* toggleButton ){ - gtk_widget_set_sensitive( self, gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggleButton ) ) && GTK_WIDGET_IS_SENSITIVE( toggleButton ) ); +void Widget_updateDependency( ui::Widget self, ui::Widget toggleButton ){ + gtk_widget_set_sensitive( self, gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggleButton ) ) && gtk_widget_is_sensitive( toggleButton ) ); } -void ToggleButton_toggled_Widget_updateDependency( GtkWidget *toggleButton, GtkWidget* self ){ +void ToggleButton_toggled_Widget_updateDependency( ui::Widget toggleButton, ui::Widget self ){ Widget_updateDependency( self, toggleButton ); } -void ToggleButton_state_changed_Widget_updateDependency( GtkWidget* toggleButton, GtkStateType state, GtkWidget* self ){ +void ToggleButton_state_changed_Widget_updateDependency( ui::Widget toggleButton, GtkStateType state, ui::Widget self ){ if ( state == GTK_STATE_INSENSITIVE ) { Widget_updateDependency( self, toggleButton ); } } -void Widget_connectToggleDependency( GtkWidget* self, GtkWidget* toggleButton ){ - g_signal_connect( G_OBJECT( toggleButton ), "state_changed", G_CALLBACK( ToggleButton_state_changed_Widget_updateDependency ), self ); - g_signal_connect( G_OBJECT( toggleButton ), "toggled", G_CALLBACK( ToggleButton_toggled_Widget_updateDependency ), self ); +void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton ){ + toggleButton.connect( "state_changed", G_CALLBACK( ToggleButton_state_changed_Widget_updateDependency ), self ); + toggleButton.connect( "toggled", G_CALLBACK( ToggleButton_toggled_Widget_updateDependency ), self ); Widget_updateDependency( self, toggleButton ); } -inline GtkWidget* getVBox( GtkWidget* page ){ - return gtk_bin_get_child( GTK_BIN( page ) ); +inline ui::Widget getVBox( ui::Widget page ){ + return ui::Widget(gtk_bin_get_child( GTK_BIN( page ) )); } -GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, const char* name, GtkWidget* page ){ +GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, const char* name, ui::Widget page ){ GtkTreeIter group; gtk_tree_store_append( store, &group, parent ); gtk_tree_store_set( store, &group, 0, name, 1, page, -1 ); return group; } -GtkWidget* PreferencePages_addPage( GtkWidget* notebook, const char* name ){ - GtkWidget* preflabel = gtk_label_new( name ); - gtk_widget_show( preflabel ); +ui::Widget PreferencePages_addPage( ui::Widget notebook, const char* name ){ + ui::Widget preflabel = ui::Label( name ); + preflabel.show(); - GtkWidget* pageframe = gtk_frame_new( name ); + auto pageframe = ui::Frame( name ); gtk_container_set_border_width( GTK_CONTAINER( pageframe ), 4 ); - gtk_widget_show( pageframe ); + pageframe.show(); - GtkWidget* vbox = gtk_vbox_new( FALSE, 4 ); - gtk_widget_show( vbox ); + ui::Widget vbox = ui::VBox( FALSE, 4 ); + vbox.show(); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 4 ); - gtk_container_add( GTK_CONTAINER( pageframe ), vbox ); + pageframe.add(vbox); // Add the page to the notebook gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), pageframe, preflabel ); @@ -673,38 +661,38 @@ GtkWidget* PreferencePages_addPage( GtkWidget* notebook, const char* name ){ class PreferenceTreeGroup : public PreferenceGroup { Dialog& m_dialog; -GtkWidget* m_notebook; +ui::Widget m_notebook; GtkTreeStore* m_store; GtkTreeIter m_group; public: -PreferenceTreeGroup( Dialog& dialog, GtkWidget* notebook, GtkTreeStore* store, GtkTreeIter group ) : +PreferenceTreeGroup( Dialog& dialog, ui::Widget notebook, GtkTreeStore* store, GtkTreeIter group ) : m_dialog( dialog ), m_notebook( notebook ), m_store( store ), m_group( group ){ } PreferencesPage createPage( const char* treeName, const char* frameName ){ - GtkWidget* page = PreferencePages_addPage( m_notebook, frameName ); + ui::Widget page = PreferencePages_addPage( m_notebook, frameName ); PreferenceTree_appendPage( m_store, &m_group, treeName, page ); return PreferencesPage( m_dialog, getVBox( page ) ); } }; -GtkWindow* PrefsDlg::BuildDialog(){ +ui::Window PrefsDlg::BuildDialog(){ PreferencesDialog_addInterfacePreferences( FreeCaller1() ); Mouse_registerPreferencesPage(); - GtkWindow* dialog = create_floating_window( "NetRadiant Preferences", m_parent ); + ui::Window dialog = ui::Window(create_floating_window( "NetRadiant Preferences", m_parent )); { - GtkWidget* mainvbox = gtk_vbox_new( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( dialog ), mainvbox ); + ui::Widget mainvbox = ui::VBox( FALSE, 5 ); + dialog.add(mainvbox); gtk_container_set_border_width( GTK_CONTAINER( mainvbox ), 5 ); - gtk_widget_show( mainvbox ); + mainvbox.show(); { - GtkWidget* hbox = gtk_hbox_new( FALSE, 5 ); - gtk_widget_show( hbox ); + ui::Widget hbox = ui::HBox( FALSE, 5 ); + hbox.show(); gtk_box_pack_end( GTK_BOX( mainvbox ), hbox, FALSE, TRUE, 0 ); { @@ -722,45 +710,45 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* hbox = gtk_hbox_new( FALSE, 5 ); + ui::Widget hbox = ui::HBox( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( mainvbox ), hbox, TRUE, TRUE, 0 ); - gtk_widget_show( hbox ); + hbox.show(); { - GtkWidget* sc_win = gtk_scrolled_window_new( 0, 0 ); + auto sc_win = ui::ScrolledWindow(); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( sc_win ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); gtk_box_pack_start( GTK_BOX( hbox ), sc_win, FALSE, FALSE, 0 ); - gtk_widget_show( sc_win ); + sc_win.show(); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( sc_win ), GTK_SHADOW_IN ); // prefs pages notebook - m_notebook = gtk_notebook_new(); + m_notebook = ui::Widget(gtk_notebook_new()); // hide the notebook tabs since its not supposed to look like a notebook gtk_notebook_set_show_tabs( GTK_NOTEBOOK( m_notebook ), FALSE ); gtk_box_pack_start( GTK_BOX( hbox ), m_notebook, TRUE, TRUE, 0 ); - gtk_widget_show( m_notebook ); + m_notebook.show(); { - GtkTreeStore* store = gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ); + auto store = gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); { - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Preferences", renderer, "text", 0, NULL ); + auto renderer = ui::CellRendererText(); + GtkTreeViewColumn* column = ui::TreeViewColumn( "Preferences", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } { - GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); - g_signal_connect( G_OBJECT( selection ), "changed", G_CALLBACK( treeSelection ), this ); + auto selection = ui::TreeSelection(gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) )); + selection.connect( "changed", G_CALLBACK( treeSelection ), this ); } - gtk_widget_show( view ); + view.show(); - gtk_container_add( GTK_CONTAINER( sc_win ), view ); + sc_win.add(view); { /********************************************************************/ @@ -771,14 +759,14 @@ GtkWindow* PrefsDlg::BuildDialog(){ PreferencePages_addPage( m_notebook, "Front Page" ); { - GtkWidget* global = PreferencePages_addPage( m_notebook, "Global Preferences" ); + ui::Widget global = PreferencePages_addPage( m_notebook, "Global Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( global ) ); Global_constructPreferences( preferencesPage ); } GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Global", global ); { - GtkWidget* game = PreferencePages_addPage( m_notebook, "Game" ); + ui::Widget game = PreferencePages_addPage( m_notebook, "Game" ); PreferencesPage preferencesPage( *this, getVBox( game ) ); g_GamesDialog.CreateGlobalFrame( preferencesPage ); @@ -787,7 +775,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" ); + ui::Widget interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( interfacePage ) ); PreferencesPageCallbacks_constructPage( g_interfacePreferences, preferencesPage ); @@ -800,7 +788,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* display = PreferencePages_addPage( m_notebook, "Display Preferences" ); + ui::Widget display = PreferencePages_addPage( m_notebook, "Display Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( display ) ); PreferencesPageCallbacks_constructPage( g_displayPreferences, preferencesPage ); @@ -812,7 +800,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* settings = PreferencePages_addPage( m_notebook, "General Settings" ); + ui::Widget settings = PreferencePages_addPage( m_notebook, "General Settings" ); { PreferencesPage preferencesPage( *this, getVBox( settings ) ); PreferencesPageCallbacks_constructPage( g_settingsPreferences, preferencesPage ); @@ -833,7 +821,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ } } - gtk_notebook_set_page( GTK_NOTEBOOK( m_notebook ), 0 ); + gtk_notebook_set_current_page( GTK_NOTEBOOK( m_notebook ), 0 ); return dialog; } @@ -843,7 +831,7 @@ preferences_globals_t g_preferences_globals; PrefsDlg g_Preferences; // global prefs instance -void PreferencesDialog_constructWindow( GtkWindow* main_window ){ +void PreferencesDialog_constructWindow( ui::Window main_window ){ g_Preferences.m_parent = main_window; g_Preferences.Create(); } @@ -931,7 +919,7 @@ void PreferencesDialog_showDialog(){ { message << ( *i ) << '\n'; } - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), message.c_str() ); + MainFrame_getWindow().alert( message.c_str() ); g_restart_required.clear(); } } diff --git a/radiant/preferences.h b/radiant/preferences.h index 293541a5..8ece483f 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -34,19 +34,19 @@ #include #include -void Widget_connectToggleDependency( GtkWidget* self, GtkWidget* toggleButton ); +void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton ); class PreferencesPage { Dialog& m_dialog; -GtkWidget* m_vbox; +ui::Widget m_vbox; public: -PreferencesPage( Dialog& dialog, GtkWidget* vbox ) : m_dialog( dialog ), m_vbox( vbox ){ +PreferencesPage( Dialog& dialog, ui::Widget vbox ) : m_dialog( dialog ), m_vbox( vbox ){ } -GtkWidget* appendCheckBox( const char* name, const char* flag, bool& data ){ +ui::CheckButton appendCheckBox( const char* name, const char* flag, bool& data ){ return m_dialog.addCheckBox( m_vbox, name, flag, data ); } -GtkWidget* appendCheckBox( const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ){ +ui::CheckButton appendCheckBox( const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ){ return m_dialog.addCheckBox( m_vbox, name, flag, importCallback, exportCallback ); } void appendCombo( const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ @@ -70,37 +70,37 @@ void appendRadioIcons( const char* name, StringArrayRange icons, const IntImport void appendRadioIcons( const char* name, int& data, StringArrayRange icons ){ m_dialog.addRadioIcons( m_vbox, name, data, icons ); } -GtkWidget* appendEntry( const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ +ui::Widget appendEntry( const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ return m_dialog.addIntEntry( m_vbox, name, importCallback, exportCallback ); } -GtkWidget* appendEntry( const char* name, int& data ){ +ui::Widget appendEntry( const char* name, int& data ){ return m_dialog.addEntry( m_vbox, name, data ); } -GtkWidget* appendEntry( const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ){ +ui::Widget appendEntry( const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ){ return m_dialog.addSizeEntry( m_vbox, name, importCallback, exportCallback ); } -GtkWidget* appendEntry( const char* name, std::size_t& data ){ +ui::Widget appendEntry( const char* name, std::size_t& data ){ return m_dialog.addEntry( m_vbox, name, data ); } -GtkWidget* appendEntry( const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ +ui::Widget appendEntry( const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ return m_dialog.addFloatEntry( m_vbox, name, importCallback, exportCallback ); } -GtkWidget* appendEntry( const char* name, float& data ){ +ui::Widget appendEntry( const char* name, float& data ){ return m_dialog.addEntry( m_vbox, name, data ); } -GtkWidget* appendPathEntry( const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ){ +ui::Widget appendPathEntry( const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ){ return m_dialog.addPathEntry( m_vbox, name, browse_directory, importCallback, exportCallback ); } -GtkWidget* appendPathEntry( const char* name, CopiedString& data, bool directory ){ +ui::Widget appendPathEntry( const char* name, CopiedString& data, bool directory ){ return m_dialog.addPathEntry( m_vbox, name, data, directory ); } -GtkWidget* appendSpinner( const char* name, int& data, double value, double lower, double upper ){ +ui::SpinButton appendSpinner( const char* name, int& data, double value, double lower, double upper ){ return m_dialog.addSpinner( m_vbox, name, data, value, lower, upper ); } -GtkWidget* appendSpinner( const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ +ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback ); } -GtkWidget* appendSpinner( const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ +ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback ); } }; @@ -197,7 +197,6 @@ void Dump(); extern CGameDescription *g_pGameDescription; -typedef struct _GtkWidget GtkWidget; class PrefsDlg; class PreferencesPage; @@ -270,7 +269,7 @@ void DoGameDialog(); Dialog API this is only called when the dialog is built at startup for main engine select */ -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); void GameFileImport( int value ); void GameFileExport( const IntImportCallback& importCallback ) const; @@ -329,7 +328,7 @@ std::list mGames; public: -GtkWidget *m_notebook; +ui::Widget m_notebook; virtual ~PrefsDlg(){ g_string_free( m_rc_path, true ); @@ -362,12 +361,12 @@ GString *m_inipath; void Init(); /*! Utility function for swapping notebook pages for tree list selections */ -void showPrefPage( GtkWidget* prefpage ); +void showPrefPage( ui::Widget prefpage ); protected: /*! Dialog API */ -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); void PostModal( EMessageBoxReturn code ); }; @@ -382,8 +381,7 @@ struct preferences_globals_t }; extern preferences_globals_t g_preferences_globals; -typedef struct _GtkWindow GtkWindow; -void PreferencesDialog_constructWindow( GtkWindow* main_window ); +void PreferencesDialog_constructWindow( ui::Window main_window ); void PreferencesDialog_destroyWindow(); void PreferencesDialog_showDialog(); diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index 1bce60b9..7d685bae 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -34,6 +34,8 @@ #include "qe3.h" +#include + #include "debugging/debugging.h" #include "ifilesystem.h" @@ -41,7 +43,7 @@ #include -#include +#include #include "stream/textfilestream.h" #include "cmdlib.h" @@ -140,11 +142,11 @@ bool ConfirmModified( const char* title ){ return true; } - EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "The current map has changed since it was last saved.\nDo you want to save the current map before continuing?", title, eMB_YESNOCANCEL, eMB_ICONQUESTION ); - if ( result == eIDCANCEL ) { + auto result = MainFrame_getWindow().alert( "The current map has changed since it was last saved.\nDo you want to save the current map before continuing?", title, ui::alert_type::YESNOCANCEL, ui::alert_icon::Question ); + if ( result == ui::alert_response::CANCEL ) { return false; } - if ( result == eIDYES ) { + if ( result == ui::alert_response::YES ) { if ( Map_Unnamed( g_map ) ) { return Map_SaveAs(); } @@ -324,7 +326,7 @@ void Sys_SetTitle( const char *text, bool modified ){ title << " *"; } - gtk_window_set_title( MainFrame_getWindow(), title.c_str() ); + gtk_window_set_title(MainFrame_getWindow(), title.c_str() ); } bool g_bWaitCursor = false; @@ -332,14 +334,14 @@ bool g_bWaitCursor = false; void Sys_BeginWait( void ){ ScreenUpdates_Disable( "Processing...", "Please Wait" ); GdkCursor *cursor = gdk_cursor_new( GDK_WATCH ); - gdk_window_set_cursor( GTK_WIDGET( MainFrame_getWindow() )->window, cursor ); + gdk_window_set_cursor( gtk_widget_get_window(MainFrame_getWindow()), cursor ); gdk_cursor_unref( cursor ); g_bWaitCursor = true; } void Sys_EndWait( void ){ ScreenUpdates_Enable(); - gdk_window_set_cursor( GTK_WIDGET( MainFrame_getWindow() )->window, 0 ); + gdk_window_set_cursor(gtk_widget_get_window(MainFrame_getWindow()), 0 ); g_bWaitCursor = false; } diff --git a/radiant/qgl.cpp b/radiant/qgl.cpp index 6cc9d7ca..a352b8d0 100644 --- a/radiant/qgl.cpp +++ b/radiant/qgl.cpp @@ -59,7 +59,6 @@ PROC ( WINAPI * qwglGetProcAddress )( LPCSTR ); #include #include -#include Bool ( *qglXQueryExtension )( Display *dpy, int *errorb, int *event ); void* ( *qglXGetProcAddressARB )( const GLubyte * procName ); @@ -555,7 +554,7 @@ int QGL_Init( OpenGLBinding& table ){ qwglGetProcAddress = wglGetProcAddress; #elif defined( XWINDOWS ) qglXGetProcAddressARB = (glXGetProcAddressARBProc)dlsym( RTLD_DEFAULT, "glXGetProcAddressARB" ); - if ( ( qglXQueryExtension == 0 ) || ( qglXQueryExtension( GDK_DISPLAY(),0,0 ) != True ) ) { + if ( ( qglXQueryExtension == 0 ) || ( qglXQueryExtension(XOpenDisplay(nullptr), 0, 0) != True ) ) { return 0; } #elif defined (__APPLE__) diff --git a/radiant/select.cpp b/radiant/select.cpp index 5d34645a..eff55f51 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -21,6 +21,8 @@ #include "select.h" +#include + #include "debugging/debugging.h" #include "ientity.h" @@ -830,10 +832,6 @@ void Selection_destroy(){ #include "gtkdlgs.h" -#include -#include -#include -#include #include @@ -870,10 +868,10 @@ struct RotateDialog GtkSpinButton* x; GtkSpinButton* y; GtkSpinButton* z; - GtkWindow *window; + ui::Window window{ui::null}; }; -static gboolean rotatedlg_apply( GtkWidget *widget, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_apply( ui::Widget widget, RotateDialog* rotateDialog ){ Vector3 eulerXYZ; eulerXYZ[0] = static_cast( gtk_spin_button_get_value( rotateDialog->x ) ); @@ -888,7 +886,7 @@ static gboolean rotatedlg_apply( GtkWidget *widget, RotateDialog* rotateDialog ) return TRUE; } -static gboolean rotatedlg_cancel( GtkWidget *widget, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_cancel( ui::Widget widget, RotateDialog* rotateDialog ){ gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) ); gtk_spin_button_set_value( rotateDialog->x, 0.0f ); // reset to 0 on close @@ -898,56 +896,56 @@ static gboolean rotatedlg_cancel( GtkWidget *widget, RotateDialog* rotateDialog return TRUE; } -static gboolean rotatedlg_ok( GtkWidget *widget, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_ok( ui::Widget widget, RotateDialog* rotateDialog ){ rotatedlg_apply( widget, rotateDialog ); gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) ); return TRUE; } -static gboolean rotatedlg_delete( GtkWidget *widget, GdkEventAny *event, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_delete( ui::Widget widget, GdkEventAny *event, RotateDialog* rotateDialog ){ rotatedlg_cancel( widget, rotateDialog ); return TRUE; } RotateDialog g_rotate_dialog; void DoRotateDlg(){ - if ( g_rotate_dialog.window == NULL ) { - g_rotate_dialog.window = create_dialog_window( MainFrame_getWindow(), "Arbitrary rotation", G_CALLBACK( rotatedlg_delete ), &g_rotate_dialog ); + if ( !g_rotate_dialog.window ) { + g_rotate_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary rotation", G_CALLBACK(rotatedlg_delete ), &g_rotate_dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); - gtk_window_add_accel_group( g_rotate_dialog.window, accel ); + auto accel = ui::AccelGroup(); + g_rotate_dialog.window.add_accel_group( accel ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( g_rotate_dialog.window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + g_rotate_dialog.window.add(hbox); { GtkTable* table = create_dialog_table( 3, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkWidget* label = gtk_label_new( " X " ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( " X " ); + label.show(); gtk_table_attach( table, label, 0, 1, 0, 1, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Y " ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( " Y " ); + label.show(); gtk_table_attach( table, label, 0, 1, 1, 2, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Z " ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( " Z " ); + label.show(); gtk_table_attach( table, label, 0, 1, 2, 3, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); - gtk_widget_show( GTK_WIDGET( spin ) ); + auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 ); + auto spin = ui::SpinButton( adj, 1, 0 ); + spin.show(); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -959,9 +957,9 @@ void DoRotateDlg(){ g_rotate_dialog.x = spin; } { - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); - gtk_widget_show( GTK_WIDGET( spin ) ); + auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 ); + auto spin = ui::SpinButton( adj, 1, 0 ); + spin.show(); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -971,9 +969,9 @@ void DoRotateDlg(){ g_rotate_dialog.y = spin; } { - GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) ); - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); - gtk_widget_show( GTK_WIDGET( spin ) ); + auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 ); + auto spin = ui::SpinButton( adj, 1, 0 ); + spin.show(); gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -987,15 +985,15 @@ void DoRotateDlg(){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkButton* button = create_dialog_button( "OK", G_CALLBACK( rotatedlg_ok ), &g_rotate_dialog ); + auto button = create_dialog_button( "OK", G_CALLBACK( rotatedlg_ok ), &g_rotate_dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + widget_make_default( button ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( rotatedlg_cancel ), &g_rotate_dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); } { GtkButton* button = create_dialog_button( "Apply", G_CALLBACK( rotatedlg_apply ), &g_rotate_dialog ); @@ -1005,7 +1003,7 @@ void DoRotateDlg(){ } } - gtk_widget_show( GTK_WIDGET( g_rotate_dialog.window ) ); + g_rotate_dialog.window.show(); } @@ -1018,13 +1016,13 @@ void DoRotateDlg(){ struct ScaleDialog { - GtkWidget* x; - GtkWidget* y; - GtkWidget* z; - GtkWindow *window; + ui::Widget x; + ui::Widget y; + ui::Widget z; + ui::Window window{ui::null}; }; -static gboolean scaledlg_apply( GtkWidget *widget, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_apply( ui::Widget widget, ScaleDialog* scaleDialog ){ float sx, sy, sz; sx = static_cast( atof( gtk_entry_get_text( GTK_ENTRY( scaleDialog->x ) ) ) ); @@ -1040,7 +1038,7 @@ static gboolean scaledlg_apply( GtkWidget *widget, ScaleDialog* scaleDialog ){ return TRUE; } -static gboolean scaledlg_cancel( GtkWidget *widget, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_cancel( ui::Widget widget, ScaleDialog* scaleDialog ){ gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) ); gtk_entry_set_text( GTK_ENTRY( scaleDialog->x ), "1.0" ); @@ -1050,13 +1048,13 @@ static gboolean scaledlg_cancel( GtkWidget *widget, ScaleDialog* scaleDialog ){ return TRUE; } -static gboolean scaledlg_ok( GtkWidget *widget, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_ok( ui::Widget widget, ScaleDialog* scaleDialog ){ scaledlg_apply( widget, scaleDialog ); gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) ); return TRUE; } -static gboolean scaledlg_delete( GtkWidget *widget, GdkEventAny *event, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_delete( ui::Widget widget, GdkEventAny *event, ScaleDialog* scaleDialog ){ scaledlg_cancel( widget, scaleDialog ); return TRUE; } @@ -1064,43 +1062,43 @@ static gboolean scaledlg_delete( GtkWidget *widget, GdkEventAny *event, ScaleDia ScaleDialog g_scale_dialog; void DoScaleDlg(){ - if ( g_scale_dialog.window == NULL ) { - g_scale_dialog.window = create_dialog_window( MainFrame_getWindow(), "Arbitrary scale", G_CALLBACK( scaledlg_delete ), &g_scale_dialog ); + if ( !g_scale_dialog.window ) { + g_scale_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary scale", G_CALLBACK(scaledlg_delete ), &g_scale_dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); - gtk_window_add_accel_group( g_scale_dialog.window, accel ); + auto accel = ui::AccelGroup(); + g_scale_dialog.window.add_accel_group( accel ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( g_scale_dialog.window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + g_scale_dialog.window.add(hbox); { GtkTable* table = create_dialog_table( 3, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkWidget* label = gtk_label_new( " X " ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( " X " ); + label.show(); gtk_table_attach( table, label, 0, 1, 0, 1, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Y " ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( " Y " ); + label.show(); gtk_table_attach( table, label, 0, 1, 1, 2, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Z " ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( " Z " ); + label.show(); gtk_table_attach( table, label, 0, 1, 2, 3, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* entry = gtk_entry_new(); + ui::Widget entry = ui::Entry(); gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" ); - gtk_widget_show( entry ); + entry.show(); gtk_table_attach( table, entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1108,9 +1106,9 @@ void DoScaleDlg(){ g_scale_dialog.x = entry; } { - GtkWidget* entry = gtk_entry_new(); + ui::Widget entry = ui::Entry(); gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" ); - gtk_widget_show( entry ); + entry.show(); gtk_table_attach( table, entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1118,9 +1116,9 @@ void DoScaleDlg(){ g_scale_dialog.y = entry; } { - GtkWidget* entry = gtk_entry_new(); + ui::Widget entry = ui::Entry(); gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" ); - gtk_widget_show( entry ); + entry.show(); gtk_table_attach( table, entry, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1132,15 +1130,15 @@ void DoScaleDlg(){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkButton* button = create_dialog_button( "OK", G_CALLBACK( scaledlg_ok ), &g_scale_dialog ); + auto button = create_dialog_button( "OK", G_CALLBACK( scaledlg_ok ), &g_scale_dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + widget_make_default( button ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( scaledlg_cancel ), &g_scale_dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); } { GtkButton* button = create_dialog_button( "Apply", G_CALLBACK( scaledlg_apply ), &g_scale_dialog ); @@ -1150,5 +1148,5 @@ void DoScaleDlg(){ } } - gtk_widget_show( GTK_WIDGET( g_scale_dialog.window ) ); + g_scale_dialog.window.show(); } diff --git a/radiant/server.cpp b/radiant/server.cpp index c58ad879..12997d4d 100644 --- a/radiant/server.cpp +++ b/radiant/server.cpp @@ -144,9 +144,8 @@ FunctionPointer findSymbol( const char* symbol ){ #include -class DynamicLibrary -{ -void* m_library; +class DynamicLibrary { + void *m_library; public: typedef int ( *FunctionPointer )(); diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index 73312a07..f9774559 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -27,6 +27,8 @@ #include "surfacedialog.h" +#include + #include "debugging/debugging.h" #include "warnings.h" @@ -35,15 +37,7 @@ #include "iundo.h" #include "iselection.h" -#include -#include -#include -#include -#include -#include -#include #include -#include //Shamus: For Textool #include "signal/isignal.h" #include "generic/object.h" @@ -89,18 +83,18 @@ namespace TexTool { //Shamus: Textool function prototypes -gboolean size_allocate( GtkWidget *, GtkAllocation *, gpointer ); -gboolean expose( GtkWidget *, GdkEventExpose *, gpointer ); -gboolean button_press( GtkWidget *, GdkEventButton *, gpointer ); -gboolean button_release( GtkWidget *, GdkEventButton *, gpointer ); -gboolean motion( GtkWidget *, GdkEventMotion *, gpointer ); +gboolean size_allocate( ui::Widget, GtkAllocation *, gpointer ); +gboolean expose( ui::Widget, GdkEventExpose *, gpointer ); +gboolean button_press( ui::Widget, GdkEventButton *, gpointer ); +gboolean button_release( ui::Widget, GdkEventButton *, gpointer ); +gboolean motion( ui::Widget, GdkEventMotion *, gpointer ); void flipX( GtkToggleButton *, gpointer ); void flipY( GtkToggleButton *, gpointer ); //End Textool function prototypes //Shamus: Textool globals -GtkWidget * g_textoolWin; +ui::Widget g_textoolWin; //End Textool globals void queueDraw(){ @@ -113,7 +107,7 @@ void queueDraw(){ inline void spin_button_set_step( GtkSpinButton* spin, gfloat step ){ #if 1 - gtk_spin_button_get_adjustment( spin )->step_increment = step; + gtk_adjustment_set_step_increment(gtk_spin_button_get_adjustment( spin ), step); #else GValue gvalue = GValue_default(); g_value_init( &gvalue, G_TYPE_DOUBLE ); @@ -127,8 +121,8 @@ class Increment float& m_f; public: GtkSpinButton* m_spin; -GtkEntry* m_entry; -Increment( float& f ) : m_f( f ), m_spin( 0 ), m_entry( 0 ){ +ui::Entry m_entry; +Increment( float& f ) : m_f( f ), m_spin( 0 ), m_entry( ui::null ){ } void cancel(){ entry_set_float( m_entry, m_f ); @@ -145,7 +139,7 @@ void SurfaceInspector_GridChange(); class SurfaceInspector : public Dialog { -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); NonModalEntry m_textureEntry; NonModalSpinner m_hshiftSpinner; @@ -165,7 +159,7 @@ GtkCheckButton* m_surfaceFlags[32]; GtkCheckButton* m_contentFlags[32]; NonModalEntry m_valueEntry; -GtkEntry* m_valueEntryWidget; +ui::Entry m_valueEntryWidget{ui::null}; public: WindowPositionTracker m_positionTracker; WindowPositionTrackerImportStringCaller m_importPosition; @@ -208,7 +202,7 @@ SurfaceInspector() : m_positionTracker.setPosition( c_default_window_pos ); } -void constructWindow( GtkWindow* main_window ){ +void constructWindow( ui::Window main_window ){ m_parent = main_window; Create(); AddGridChangeCallback( FreeCaller() ); @@ -217,7 +211,7 @@ void destroyWindow(){ Destroy(); } bool visible() const { - return GTK_WIDGET_VISIBLE( const_cast( GetWidget() ) ); + return gtk_widget_get_visible( GetWidget() ); } void queueDraw(){ if ( visible() ) { @@ -245,7 +239,7 @@ inline SurfaceInspector& getSurfaceInspector(){ } } -void SurfaceInspector_constructWindow( GtkWindow* main_window ){ +void SurfaceInspector_constructWindow( ui::Window main_window ){ getSurfaceInspector().constructWindow( main_window ); } void SurfaceInspector_destroyWindow(){ @@ -400,10 +394,10 @@ void SurfaceInspector_GridChange(){ // we move the textures in pixels, not world units. (i.e. increment values are in pixel) // depending on the texture scale it doesn't take the same amount of pixels to move of GetGridSize() // increment * scale = gridsize -static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){ +static void OnBtnMatchGrid( ui::Widget widget, gpointer data ){ float hscale, vscale; - hscale = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_hscaleIncrement.m_spin ) ); - vscale = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_vscaleIncrement.m_spin ) ); + hscale = static_cast( gtk_spin_button_get_value( getSurfaceInspector().m_hscaleIncrement.m_spin ) ); + vscale = static_cast( gtk_spin_button_get_value( getSurfaceInspector().m_vscaleIncrement.m_spin ) ); if ( hscale == 0.0f || vscale == 0.0f ) { globalOutputStream() << "ERROR: unexpected scale == 0.0f\n"; @@ -417,7 +411,7 @@ static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){ // or update it because something new has been selected // Shamus: It does get called when the SI is hidden, but not when you select something new. ;-) void DoSurface( void ){ - if ( getSurfaceInspector().GetWidget() == 0 ) { + if ( !getSurfaceInspector().GetWidget() ) { getSurfaceInspector().Create(); } @@ -441,23 +435,23 @@ void SurfaceInspector_FitTexture(){ Select_FitTexture( getSurfaceInspector().m_fitHorizontal, getSurfaceInspector().m_fitVertical ); } -static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){ Patch_CapTexture(); } -static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){ Patch_NaturalTexture(); } -static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchreset( ui::Widget widget, gpointer data ){ Patch_ResetTexture(); } -static void OnBtnPatchFit( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchFit( ui::Widget widget, gpointer data ){ Patch_FitTexture(); } -static void OnBtnAxial( GtkWidget *widget, gpointer data ){ +static void OnBtnAxial( ui::Widget widget, gpointer data ){ //globalOutputStream() << "--> [OnBtnAxial]...\n"; UndoableCommand undo( "textureDefault" ); TextureProjection projection; @@ -486,7 +480,7 @@ static void OnBtnAxial( GtkWidget *widget, gpointer data ){ Select_SetTexdef( projection ); } -static void OnBtnFaceFit( GtkWidget *widget, gpointer data ){ +static void OnBtnFaceFit( ui::Widget widget, gpointer data ){ getSurfaceInspector().exportData(); SurfaceInspector_FitTexture(); } @@ -587,8 +581,8 @@ guint togglebutton_connect_toggled( GtkToggleButton* button, const Callback& cal return g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); } -GtkWindow* SurfaceInspector::BuildDialog(){ - GtkWindow* window = create_floating_window( "Surface Inspector", m_parent ); +ui::Window SurfaceInspector::BuildDialog(){ + ui::Window window = ui::Window(create_floating_window( "Surface Inspector", m_parent )); m_positionTracker.connect( window ); @@ -599,24 +593,24 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { // replaced by only the vbox: - GtkWidget* vbox = gtk_vbox_new( FALSE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + ui::Widget vbox = ui::VBox( FALSE, 5 ); + vbox.show(); + window.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); { - GtkWidget* hbox2 = gtk_hbox_new( FALSE, 5 ); - gtk_widget_show( hbox2 ); + ui::Widget hbox2 = ui::HBox( FALSE, 5 ); + hbox2.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 ); { - GtkWidget* label = gtk_label_new( "Texture" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Texture" ); + label.show(); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_box_pack_start( GTK_BOX( hbox2 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); m_texture = entry; m_textureEntry.connect( entry ); @@ -626,335 +620,335 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { - GtkWidget* table = gtk_table_new( 6, 4, FALSE ); - gtk_widget_show( table ); + ui::Widget table = ui::Table( 6, 4, FALSE ); + table.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), FALSE, FALSE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); { - GtkWidget* label = gtk_label_new( "Horizontal shift" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Horizontal shift" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_hshiftIncrement.m_spin = spin; m_hshiftSpinner.connect( spin ); - gtk_widget_show( GTK_WIDGET( spin ) ); + spin.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 60, -1 ); } { - GtkWidget* label = gtk_label_new( "Step" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Step" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_hshiftIncrement.m_entry = entry; m_hshiftEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Vertical shift" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Vertical shift" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_vshiftIncrement.m_spin = spin; m_vshiftSpinner.connect( spin ); - gtk_widget_show( GTK_WIDGET( spin ) ); + spin.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 60, -1 ); } { - GtkWidget* label = gtk_label_new( "Step" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Step" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_vshiftIncrement.m_entry = entry; m_vshiftEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Horizontal stretch" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Horizontal stretch" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 5 ) ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 ); m_hscaleIncrement.m_spin = spin; m_hscaleSpinner.connect( spin ); - gtk_widget_show( GTK_WIDGET( spin ) ); + spin.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 60, -1 ); } { - GtkWidget* label = gtk_label_new( "Step" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Step" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 2, 3 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 2, 3 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_hscaleIncrement.m_entry = entry; m_hscaleEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Vertical stretch" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Vertical stretch" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 5 ) ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 ); m_vscaleIncrement.m_spin = spin; m_vscaleSpinner.connect( spin ); - gtk_widget_show( GTK_WIDGET( spin ) ); + spin.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 60, -1 ); } { - GtkWidget* label = gtk_label_new( "Step" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Step" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_vscaleIncrement.m_entry = entry; m_vscaleEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Rotate" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Rotate" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 4, 5, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_rotateIncrement.m_spin = spin; m_rotateSpinner.connect( spin ); - gtk_widget_show( GTK_WIDGET( spin ) ); + spin.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 4, 5, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( spin ), 60, -1 ); gtk_spin_button_set_wrap( spin, TRUE ); } { - GtkWidget* label = gtk_label_new( "Step" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Step" ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 4, 5, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 4, 5, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 ); + gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 ); m_rotateIncrement.m_entry = entry; m_rotateEntry.connect( entry ); } { // match grid button - GtkWidget* button = gtk_button_new_with_label( "Match Grid" ); - gtk_widget_show( button ); + ui::Widget button = ui::Button( "Match Grid" ); + button.show(); gtk_table_attach( GTK_TABLE( table ), button, 2, 4, 5, 6, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnMatchGrid ), 0 ); + button.connect( "clicked", G_CALLBACK( OnBtnMatchGrid ), 0 ); } } { - GtkWidget* frame = gtk_frame_new( "Texturing" ); - gtk_widget_show( frame ); + auto frame = ui::Frame( "Texturing" ); + frame.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); { - GtkWidget* table = gtk_table_new( 4, 4, FALSE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + ui::Widget table = ui::Table( 4, 4, FALSE ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); { - GtkWidget* label = gtk_label_new( "Brush" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Brush" ); + label.show(); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Patch" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Patch" ); + label.show(); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Width" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Width" ); + label.show(); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Height" ); - gtk_widget_show( label ); + ui::Widget label = ui::Label( "Height" ); + label.show(); gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* button = gtk_button_new_with_label( "Axial" ); - gtk_widget_show( button ); + ui::Widget button = ui::Button( "Axial" ); + button.show(); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + button.connect( "clicked", G_CALLBACK( OnBtnAxial ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* button = gtk_button_new_with_label( "Fit" ); - gtk_widget_show( button ); + ui::Widget button = ui::Button( "Fit" ); + button.show(); gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + button.connect( "clicked", G_CALLBACK( OnBtnFaceFit ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* button = gtk_button_new_with_label( "CAP" ); - gtk_widget_show( button ); + ui::Widget button = ui::Button( "CAP" ); + button.show(); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + button.connect( "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* button = gtk_button_new_with_label( "Set..." ); - gtk_widget_show( button ); + ui::Widget button = ui::Button( "Set..." ); + button.show(); gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + button.connect( "clicked", G_CALLBACK( OnBtnPatchreset ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* button = gtk_button_new_with_label( "Natural" ); - gtk_widget_show( button ); + ui::Widget button = ui::Button( "Natural" ); + button.show(); gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + button.connect( "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* button = gtk_button_new_with_label( "Fit" ); - gtk_widget_show( button ); + ui::Widget button = ui::Button( "Fit" ); + button.show(); gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", + button.connect( "clicked", G_CALLBACK( OnBtnPatchFit ), 0 ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); } { - GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 ); - gtk_widget_show( spin ); + auto spin = ui::SpinButton( ui::Adjustment( 1, 0, 1 << 16, 1, 10, 0 ), 0, 6 ); + spin.show(); gtk_table_attach( GTK_TABLE( table ), spin, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitHorizontal ); } { - GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 ); - gtk_widget_show( spin ); + auto spin = ui::SpinButton( ui::Adjustment( 1, 0, 1 << 16, 1, 10, 0 ), 0, 6 ); + spin.show(); gtk_table_attach( GTK_TABLE( table ), spin, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_usize( spin, 60, -2 ); + gtk_widget_set_size_request( spin, 60, -1 ); AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitVertical ); } } } if ( !string_empty( g_pGameDescription->getKeyValue( "si_flags" ) ) ) { { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Surface Flags" ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); + auto frame = ui::Frame( "Surface Flags" ); + frame.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) ); + auto vbox3 = ui::VBox( FALSE, 4 ); //gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4); - gtk_widget_show( GTK_WIDGET( vbox3 ) ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + vbox3.show(); + frame.add(vbox3); { - GtkTable* table = GTK_TABLE( gtk_table_new( 8, 4, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); + auto table = ui::Table( 8, 4, FALSE ); + table.show(); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 0 ); gtk_table_set_col_spacings( table, 0 ); @@ -965,8 +959,8 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { for ( int r = 0; r != 8; ++r ) { - GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new_with_label( getSurfaceFlagName( c * 8 + r ) ) ); - gtk_widget_show( GTK_WIDGET( check ) ); + auto check = ui::CheckButton( getSurfaceFlagName( c * 8 + r ) ); + check.show(); gtk_table_attach( table, GTK_WIDGET( check ), c, c + 1, r, r + 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); @@ -979,18 +973,18 @@ GtkWindow* SurfaceInspector::BuildDialog(){ } } { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Content Flags" ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); + auto frame = ui::Frame( "Content Flags" ); + frame.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) ); + auto vbox3 = ui::VBox( FALSE, 4 ); //gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4); - gtk_widget_show( GTK_WIDGET( vbox3 ) ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + vbox3.show(); + frame.add(vbox3); { - GtkTable* table = GTK_TABLE( gtk_table_new( 8, 4, FALSE ) ); - gtk_widget_show( GTK_WIDGET( table ) ); + auto table = ui::Table( 8, 4, FALSE ); + table.show(); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 0 ); gtk_table_set_col_spacings( table, 0 ); @@ -1001,8 +995,8 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { for ( int r = 0; r != 8; ++r ) { - GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new_with_label( getContentFlagName( c * 8 + r ) ) ); - gtk_widget_show( GTK_WIDGET( check ) ); + auto check = ui::CheckButton( getContentFlagName( c * 8 + r ) ); + check.show(); gtk_table_attach( table, GTK_WIDGET( check ), c, c + 1, r, r + 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); @@ -1018,18 +1012,18 @@ GtkWindow* SurfaceInspector::BuildDialog(){ } } { - GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Value" ) ); - gtk_widget_show( GTK_WIDGET( frame ) ); + auto frame = ui::Frame( "Value" ); + frame.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) ); + auto vbox3 = ui::VBox( FALSE, 4 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 4 ); - gtk_widget_show( GTK_WIDGET( vbox3 ) ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + vbox3.show(); + frame.add(vbox3); { - GtkEntry* entry = GTK_ENTRY( gtk_entry_new() ); - gtk_widget_show( GTK_WIDGET( entry ) ); + auto entry = ui::Entry(); + entry.show(); gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 ); m_valueEntryWidget = entry; m_valueEntry.connect( entry ); @@ -1041,49 +1035,49 @@ GtkWindow* SurfaceInspector::BuildDialog(){ #if TEXTOOL_ENABLED if ( g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_BRUSHPRIMITIVES ) { // Shamus: Textool goodies... - GtkWidget * frame = gtk_frame_new( "Textool" ); - gtk_widget_show( frame ); + ui::Widget frame = ui::Frame( "Textool" ); + frame.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); { //Prolly should make this a member or global var, so the SI can draw on it... TexTool::g_textoolWin = glwidget_new( FALSE ); // --> Dunno, but this stuff may be necessary... (Looks like it!) - gtk_widget_ref( TexTool::g_textoolWin ); + g_object_ref( TexTool::g_textoolWin ); gtk_widget_set_events( TexTool::g_textoolWin, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ); - GTK_WIDGET_SET_FLAGS( TexTool::g_textoolWin, GTK_CAN_FOCUS ); + gtk_widget_set_can_focus( TexTool::g_textoolWin, true ); // <-- end stuff... - gtk_widget_show( TexTool::g_textoolWin ); - gtk_widget_set_usize( TexTool::g_textoolWin, -1, 240 ); //Yeah! - gtk_container_add( GTK_CONTAINER( frame ), TexTool::g_textoolWin ); - - g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "size_allocate", G_CALLBACK( TexTool::size_allocate ), NULL ); - g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "expose_event", G_CALLBACK( TexTool::expose ), NULL ); - g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "button_press_event", G_CALLBACK( TexTool::button_press ), NULL ); - g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "button_release_event", G_CALLBACK( TexTool::button_release ), NULL ); - g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "motion_notify_event", G_CALLBACK( TexTool::motion ), NULL ); + TexTool::g_textoolWin.show(); + gtk_widget_set_size_request( TexTool::g_textoolWin, -1, 240 ); //Yeah! + frame.add(TexTool::g_textoolWin); + + TexTool::g_textoolWin.connect( "size_allocate", G_CALLBACK( TexTool::size_allocate ), NULL ); + TexTool::g_textoolWin.connect( "expose_event", G_CALLBACK( TexTool::expose ), NULL ); + TexTool::g_textoolWin.connect( "button_press_event", G_CALLBACK( TexTool::button_press ), NULL ); + TexTool::g_textoolWin.connect( "button_release_event", G_CALLBACK( TexTool::button_release ), NULL ); + TexTool::g_textoolWin.connect( "motion_notify_event", G_CALLBACK( TexTool::motion ), NULL ); } { - GtkWidget * hbox = gtk_hbox_new( FALSE, 5 ); - gtk_widget_show( hbox ); + ui::Widget hbox = ui::HBox( FALSE, 5 ); + hbox.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, FALSE, 0 ); // Checkboxes go here... (Flip X/Y) - GtkWidget * flipX = gtk_check_button_new_with_label( "Flip X axis" ); - GtkWidget * flipY = gtk_check_button_new_with_label( "Flip Y axis" ); - gtk_widget_show( flipX ); - gtk_widget_show( flipY ); + ui::Widget flipX = ui::CheckButton( "Flip X axis" ); + ui::Widget flipY = ui::CheckButton( "Flip Y axis" ); + flipX.show(); + flipY.show(); gtk_box_pack_start( GTK_BOX( hbox ), flipX, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( hbox ), flipY, FALSE, FALSE, 0 ); //Instead of this, we probably need to create a vbox to put into the frame, then the //window, then the hbox. !!! FIX !!! -// gtk_container_add(GTK_CONTAINER(frame), hbox); +// frame.add(hbox); //Hmm. Do we really need g_object_set_data? Mebbe not... And we don't! :-) -// g_object_set_data(G_OBJECT(flipX), "handler", gint_to_pointer(g_signal_connect(G_OBJECT(flipX), "toggled", G_CALLBACK(TexTool::flipX), 0))); -// g_object_set_data(G_OBJECT(flipY), "handler", gint_to_pointer(g_signal_connect(G_OBJECT(flipY), "toggled", G_CALLBACK(TexTool::flipY), 0))); +// g_object_set_data(G_OBJECT(flipX), "handler", gint_to_pointer(flipX.connect("toggled", G_CALLBACK(TexTool::flipX), 0))); +// g_object_set_data(G_OBJECT(flipY), "handler", gint_to_pointer(flipY.connect("toggled", G_CALLBACK(TexTool::flipY), 0))); //Instead, just do: - g_signal_connect( G_OBJECT( flipX ), "toggled", G_CALLBACK( TexTool::flipX ), NULL ); - g_signal_connect( G_OBJECT( flipY ), "toggled", G_CALLBACK( TexTool::flipY ), NULL ); + flipX.connect( "toggled", G_CALLBACK( TexTool::flipX ), NULL ); + flipY.connect( "toggled", G_CALLBACK( TexTool::flipY ), NULL ); } } #endif @@ -1111,7 +1105,7 @@ void spin_button_set_value_no_signal( GtkSpinButton* spin, gdouble value ){ void spin_button_set_step_increment( GtkSpinButton* spin, gdouble value ){ GtkAdjustment* adjust = gtk_spin_button_get_adjustment( spin ); - adjust->step_increment = value; + gtk_adjustment_set_step_increment(adjust, value); } void SurfaceInspector::Update(){ @@ -1178,12 +1172,12 @@ void SurfaceInspector::Update(){ for ( GtkCheckButton** p = m_surfaceFlags; p != m_surfaceFlags + 32; ++p ) { - toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) ); + toggle_button_set_active_no_signal( ui::CheckButton( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) ); } for ( GtkCheckButton** p = m_contentFlags; p != m_contentFlags + 32; ++p ) { - toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) ); + toggle_button_set_active_no_signal( ui::CheckButton( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) ); } } } @@ -1214,11 +1208,11 @@ void SurfaceInspector::ApplyShader(){ void SurfaceInspector::ApplyTexdef(){ texdef_t shiftScaleRotate; - shiftScaleRotate.shift[0] = static_cast( gtk_spin_button_get_value_as_float( m_hshiftIncrement.m_spin ) ); - shiftScaleRotate.shift[1] = static_cast( gtk_spin_button_get_value_as_float( m_vshiftIncrement.m_spin ) ); - shiftScaleRotate.scale[0] = static_cast( gtk_spin_button_get_value_as_float( m_hscaleIncrement.m_spin ) ); - shiftScaleRotate.scale[1] = static_cast( gtk_spin_button_get_value_as_float( m_vscaleIncrement.m_spin ) ); - shiftScaleRotate.rotate = static_cast( gtk_spin_button_get_value_as_float( m_rotateIncrement.m_spin ) ); + shiftScaleRotate.shift[0] = static_cast( gtk_spin_button_get_value( m_hshiftIncrement.m_spin ) ); + shiftScaleRotate.shift[1] = static_cast( gtk_spin_button_get_value( m_vshiftIncrement.m_spin ) ); + shiftScaleRotate.scale[0] = static_cast( gtk_spin_button_get_value( m_hscaleIncrement.m_spin ) ); + shiftScaleRotate.scale[1] = static_cast( gtk_spin_button_get_value( m_vscaleIncrement.m_spin ) ); + shiftScaleRotate.rotate = static_cast( gtk_spin_button_get_value( m_rotateIncrement.m_spin ) ); TextureProjection projection; //Shamus: This is the other place that screws up, it seems, since it doesn't seem to do the @@ -1877,14 +1871,14 @@ void focus(){ // << extents.maxX << ", " << extents.minY << ", " << extents.maxY << "\n"; } -gboolean size_allocate( GtkWidget * win, GtkAllocation * a, gpointer ){ +gboolean size_allocate( ui::Widget win, GtkAllocation * a, gpointer ){ windowSize.x() = a->width; windowSize.y() = a->height; queueDraw(); return false; } -gboolean expose( GtkWidget * win, GdkEventExpose * e, gpointer ){ +gboolean expose( ui::Widget win, GdkEventExpose * e, gpointer ){ // globalOutputStream() << "--> Textool Window was exposed!\n"; // globalOutputStream() << " (window width/height: " << cc << "/" << e->area.height << ")\n"; @@ -1983,7 +1977,7 @@ Vector2 trans; Vector2 trans2; Vector2 dragPoint; // Defined in terms of window space (+x/-y) Vector2 oldTrans; -gboolean button_press( GtkWidget * win, GdkEventButton * e, gpointer ){ +gboolean button_press( ui::Widget win, GdkEventButton * e, gpointer ){ // globalOutputStream() << "--> Textool button press...\n"; if ( e->button == 1 ) { @@ -2045,7 +2039,7 @@ gboolean button_press( GtkWidget * win, GdkEventButton * e, gpointer ){ return false; } -gboolean button_release( GtkWidget * win, GdkEventButton * e, gpointer ){ +gboolean button_release( ui::Widget win, GdkEventButton * e, gpointer ){ // globalOutputStream() << "--> Textool button release...\n"; if ( e->button == 1 ) { @@ -2107,7 +2101,7 @@ gboolean button_release( GtkWidget * win, GdkEventButton * e, gpointer ){ c[1] = ((float)(y))/((float)(m_rect.bottom-m_rect.top))*(m_Maxs[1]-m_Mins[1])+m_Mins[1]; } */ -gboolean motion( GtkWidget * win, GdkEventMotion * e, gpointer ){ +gboolean motion( ui::Widget win, GdkEventMotion * e, gpointer ){ // globalOutputStream() << "--> Textool motion...\n"; if ( lButtonDown ) { diff --git a/radiant/surfacedialog.h b/radiant/surfacedialog.h index 0e0ed24a..2c1d945d 100644 --- a/radiant/surfacedialog.h +++ b/radiant/surfacedialog.h @@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_SURFACEDIALOG_H ) #define INCLUDED_SURFACEDIALOG_H @@ -26,9 +28,7 @@ void SurfaceInspector_Construct(); void SurfaceInspector_Destroy(); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -void SurfaceInspector_constructWindow( GtkWindow* widget ); +void SurfaceInspector_constructWindow( ui::Window widget ); void SurfaceInspector_destroyWindow(); bool SelectedFaces_empty(); diff --git a/radiant/textureentry.cpp b/radiant/textureentry.cpp index 781dcbe4..96a46dcd 100644 --- a/radiant/textureentry.cpp +++ b/radiant/textureentry.cpp @@ -20,3 +20,55 @@ */ #include "textureentry.h" + +#include + +template +void EntryCompletion::connect(ui::Entry entry) +{ + if (!m_store) { + m_store = ui::ListStore(gtk_list_store_new(1, G_TYPE_STRING)); + + fill(); + + StringList().connect(IdleDraw::QueueDrawCaller(m_idleUpdate)); + } + + auto completion = ui::EntryCompletion(gtk_entry_completion_new()); + gtk_entry_set_completion(entry, completion); + gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(m_store)); + gtk_entry_completion_set_text_column(completion, 0); +} + +template +void EntryCompletion::append(const char *string) +{ + GtkTreeIter iter; + gtk_list_store_append(m_store, &iter); + gtk_list_store_set(m_store, &iter, 0, string, -1); +} + +template +void EntryCompletion::fill() +{ + StringList().forEach(AppendCaller(*this)); +} + +template +void EntryCompletion::clear() +{ + gtk_list_store_clear(m_store); +} + +template +void EntryCompletion::update() +{ + clear(); + fill(); +} + +template +class EntryCompletion; + +template +class EntryCompletion; diff --git a/radiant/textureentry.h b/radiant/textureentry.h index 3406d2a0..d36aff6b 100644 --- a/radiant/textureentry.h +++ b/radiant/textureentry.h @@ -22,9 +22,6 @@ #if !defined( INCLUDED_TEXTUREENTRY_H ) #define INCLUDED_TEXTUREENTRY_H - -#include -#include #include "gtkutil/idledraw.h" #include "generic/static.h" @@ -34,84 +31,65 @@ #include "texwindow.h" template -class EntryCompletion -{ -GtkListStore* m_store; -IdleDraw m_idleUpdate; +class EntryCompletion { + ui::ListStore m_store; + IdleDraw m_idleUpdate; public: -EntryCompletion() : m_store( 0 ), m_idleUpdate( UpdateCaller( *this ) ){ -} - -void connect( GtkEntry* entry ){ - if ( m_store == 0 ) { - m_store = gtk_list_store_new( 1, G_TYPE_STRING ); - - fill(); - - StringList().connect( IdleDraw::QueueDrawCaller( m_idleUpdate ) ); - } - - GtkEntryCompletion* completion = gtk_entry_completion_new(); - gtk_entry_set_completion( entry, completion ); - gtk_entry_completion_set_model( completion, GTK_TREE_MODEL( m_store ) ); - gtk_entry_completion_set_text_column( completion, 0 ); -} - -void append( const char* string ){ - GtkTreeIter iter; - gtk_list_store_append( m_store, &iter ); - gtk_list_store_set( m_store, &iter, 0, string, -1 ); -} -typedef MemberCaller1 AppendCaller; - -void fill(){ - StringList().forEach( AppendCaller( *this ) ); -} - -void clear(){ - gtk_list_store_clear( m_store ); -} - -void update(){ - clear(); - fill(); -} -typedef MemberCaller UpdateCaller; + EntryCompletion() : m_store(0), m_idleUpdate(UpdateCaller(*this)) + { + } + + void connect(ui::Entry entry); + + void append(const char *string); + + using AppendCaller = MemberCaller1; + + void fill(); + + void clear(); + + void update(); + + using UpdateCaller = MemberCaller; }; -class TextureNameList -{ +class TextureNameList { public: -void forEach( const ShaderNameCallback& callback ) const { - for ( QERApp_ActiveShaders_IteratorBegin(); !QERApp_ActiveShaders_IteratorAtEnd(); QERApp_ActiveShaders_IteratorIncrement() ) - { - IShader *shader = QERApp_ActiveShaders_IteratorCurrent(); - - if ( shader_equal_prefix( shader->getName(), "textures/" ) ) { - callback( shader->getName() + 9 ); - } - } -} -void connect( const SignalHandler& update ) const { - TextureBrowser_addActiveShadersChangedCallback( update ); -} + void forEach(const ShaderNameCallback &callback) const + { + for (QERApp_ActiveShaders_IteratorBegin(); !QERApp_ActiveShaders_IteratorAtEnd(); QERApp_ActiveShaders_IteratorIncrement()) { + IShader *shader = QERApp_ActiveShaders_IteratorCurrent(); + + if (shader_equal_prefix(shader->getName(), "textures/")) { + callback(shader->getName() + 9); + } + } + } + + void connect(const SignalHandler &update) const + { + TextureBrowser_addActiveShadersChangedCallback(update); + } }; -typedef Static< EntryCompletion > GlobalTextureEntryCompletion; +typedef Static > GlobalTextureEntryCompletion; -class ShaderList -{ +class ShaderList { public: -void forEach( const ShaderNameCallback& callback ) const { - GlobalShaderSystem().foreachShaderName( callback ); -} -void connect( const SignalHandler& update ) const { - TextureBrowser_addShadersRealiseCallback( update ); -} + void forEach(const ShaderNameCallback &callback) const + { + GlobalShaderSystem().foreachShaderName(callback); + } + + void connect(const SignalHandler &update) const + { + TextureBrowser_addShadersRealiseCallback(update); + } }; -typedef Static< EntryCompletion > GlobalShaderEntryCompletion; +typedef Static > GlobalShaderEntryCompletion; #endif diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 1ab87084..7d1782ec 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -27,6 +27,8 @@ #include "texwindow.h" +#include + #include "debugging/debugging.h" #include "warnings.h" @@ -40,12 +42,7 @@ #include #include -#include -#include -#include -#include -#include -#include +#include #include "signal/signal.h" #include "math/vector.h" @@ -210,7 +207,7 @@ void value_changed( gdouble value ){ } } static void adjustment_value_changed( GtkAdjustment *adjustment, DeferredAdjustment* self ){ - self->value_changed( adjustment->value ); + self->value_changed( gtk_adjustment_get_value(adjustment) ); } }; @@ -259,24 +256,24 @@ int m_nTotalHeight; CopiedString shader; -GtkWindow* m_parent; -GtkWidget* m_gl_widget; -GtkWidget* m_texture_scroll; -GtkWidget* m_treeViewTree; -GtkWidget* m_treeViewTags; -GtkWidget* m_tag_frame; -GtkListStore* m_assigned_store; -GtkListStore* m_available_store; -GtkWidget* m_assigned_tree; -GtkWidget* m_available_tree; -GtkWidget* m_scr_win_tree; -GtkWidget* m_scr_win_tags; -GtkWidget* m_tag_notebook; -GtkWidget* m_search_button; -GtkWidget* m_shader_info_item; +ui::Window m_parent{ui::null}; +ui::GLArea m_gl_widget{ui::null}; +ui::Widget m_texture_scroll; +ui::Widget m_treeViewTree; +ui::Widget m_treeViewTags; +ui::Frame m_tag_frame{ui::null}; +ui::ListStore m_assigned_store{ui::null}; +ui::ListStore m_available_store{ui::null}; +ui::Widget m_assigned_tree; +ui::Widget m_available_tree; +ui::Widget m_scr_win_tree; +ui::Widget m_scr_win_tags; +ui::Widget m_tag_notebook; +ui::Button m_search_button{ui::null}; +ui::Widget m_shader_info_item; std::set m_all_tags; -GtkListStore* m_all_tags_list; +ui::ListStore m_all_tags_list{ui::null}; std::vector m_copied_tags; std::set m_found_shaders; @@ -741,7 +738,7 @@ void visit( const char* name ){ void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused ); -GtkWidget* g_page_textures; +ui::Widget g_page_textures; void TextureBrowser_toggleShow(){ GroupDialog_showPage( g_page_textures ); @@ -1258,7 +1255,7 @@ void Texture_Draw( TextureBrowser& textureBrowser ){ } void TextureBrowser_queueDraw( TextureBrowser& textureBrowser ){ - if ( textureBrowser.m_gl_widget != 0 ) { + if ( textureBrowser.m_gl_widget ) { gtk_widget_queue_draw( textureBrowser.m_gl_widget ); } } @@ -1299,7 +1296,7 @@ enum N_COLUMNS }; -void BuildStoreAssignedTags( GtkListStore* store, const char* shader, TextureBrowser* textureBrowser ){ +void BuildStoreAssignedTags( ui::ListStore store, const char* shader, TextureBrowser* textureBrowser ){ GtkTreeIter iter; gtk_list_store_clear( store ); @@ -1314,8 +1311,8 @@ void BuildStoreAssignedTags( GtkListStore* store, const char* shader, TextureBro } } -void BuildStoreAvailableTags( GtkListStore* storeAvailable, - GtkListStore* storeAssigned, +void BuildStoreAvailableTags( ui::ListStore storeAvailable, + ui::ListStore storeAssigned, const std::set& allTags, TextureBrowser* textureBrowser ){ GtkTreeIter iterAssigned; @@ -1359,7 +1356,7 @@ void BuildStoreAvailableTags( GtkListStore* storeAvailable, } } -gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_button_press( ui::Widget widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ if ( event->type == GDK_BUTTON_PRESS ) { if ( event->button == 3 ) { if ( GlobalTextureBrowser().m_tags ) { @@ -1369,9 +1366,9 @@ gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event, BuildStoreAssignedTags( textureBrowser->m_assigned_store, textureBrowser->shader.c_str(), textureBrowser ); BuildStoreAvailableTags( textureBrowser->m_available_store, textureBrowser->m_assigned_store, textureBrowser->m_all_tags, textureBrowser ); textureBrowser->m_heightChanged = true; - gtk_widget_show( textureBrowser->m_tag_frame ); + textureBrowser->m_tag_frame.show(); - process_gui(); + ui::process(); TextureBrowser_Focus( *textureBrowser, textureBrowser->shader.c_str() ); } @@ -1392,7 +1389,7 @@ gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event, return FALSE; } -gboolean TextureBrowser_button_release( GtkWidget* widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_button_release( ui::Widget widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ if ( event->type == GDK_BUTTON_RELEASE ) { if ( event->button == 3 ) { if ( !GlobalTextureBrowser().m_tags ) { @@ -1403,11 +1400,11 @@ gboolean TextureBrowser_button_release( GtkWidget* widget, GdkEventButton* event return FALSE; } -gboolean TextureBrowser_motion( GtkWidget *widget, GdkEventMotion *event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_motion( ui::Widget widget, GdkEventMotion *event, TextureBrowser* textureBrowser ){ return FALSE; } -gboolean TextureBrowser_scroll( GtkWidget* widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_scroll( ui::Widget widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){ if ( event->direction == GDK_SCROLL_UP ) { TextureBrowser_MouseWheel( *textureBrowser, true ); } @@ -1423,7 +1420,7 @@ void TextureBrowser_scrollChanged( void* data, gdouble value ){ } static void TextureBrowser_verticalScroll( GtkAdjustment *adjustment, TextureBrowser* textureBrowser ){ - textureBrowser->m_scrollAdjustment.value_changed( adjustment->value ); + textureBrowser->m_scrollAdjustment.value_changed( gtk_adjustment_get_value(adjustment) ); } void TextureBrowser_updateScroll( TextureBrowser& textureBrowser ){ @@ -1434,18 +1431,18 @@ void TextureBrowser_updateScroll( TextureBrowser& textureBrowser ){ GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( textureBrowser.m_texture_scroll ) ); - vadjustment->value = -TextureBrowser_getOriginY( textureBrowser ); - vadjustment->page_size = textureBrowser.height; - vadjustment->page_increment = textureBrowser.height / 2; - vadjustment->step_increment = 20; - vadjustment->lower = 0; - vadjustment->upper = totalHeight; + gtk_adjustment_set_value(vadjustment, -TextureBrowser_getOriginY( textureBrowser )); + gtk_adjustment_set_page_size(vadjustment, textureBrowser.height); + gtk_adjustment_set_page_increment(vadjustment, textureBrowser.height / 2); + gtk_adjustment_set_step_increment(vadjustment, 20); + gtk_adjustment_set_lower(vadjustment, 0); + gtk_adjustment_set_upper(vadjustment, totalHeight); g_signal_emit_by_name( G_OBJECT( vadjustment ), "changed" ); } } -gboolean TextureBrowser_size_allocate( GtkWidget* widget, GtkAllocation* allocation, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_size_allocate( ui::Widget widget, GtkAllocation* allocation, TextureBrowser* textureBrowser ){ textureBrowser->width = allocation->width; textureBrowser->height = allocation->height; TextureBrowser_heightChanged( *textureBrowser ); @@ -1454,7 +1451,7 @@ gboolean TextureBrowser_size_allocate( GtkWidget* widget, GtkAllocation* allocat return FALSE; } -gboolean TextureBrowser_expose( GtkWidget* widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_expose( ui::Widget widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){ if ( glwidget_make_current( textureBrowser->m_gl_widget ) != FALSE ) { GlobalOpenGL_debugAssertNoErrors(); TextureBrowser_evaluateHeight( *textureBrowser ); @@ -1590,14 +1587,13 @@ void TreeView_onRowActivated( GtkTreeView* treeview, GtkTreePath* path, GtkTreeV } void TextureBrowser_createTreeViewTree(){ - GtkCellRenderer* renderer; - g_TextureBrowser.m_treeViewTree = GTK_WIDGET( gtk_tree_view_new() ); + g_TextureBrowser.m_treeViewTree = ui::TreeView(); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE ); - g_signal_connect( g_TextureBrowser.m_treeViewTree, "row-activated", (GCallback) TreeView_onRowActivated, NULL ); + g_TextureBrowser.m_treeViewTree.connect( "row-activated", (GCallback) TreeView_onRowActivated, NULL ); - renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), -1, "", renderer, "text", 0, NULL ); TextureBrowser_constructTreeStore(); @@ -1607,19 +1603,19 @@ void TextureBrowser_addTag(); void TextureBrowser_renameTag(); void TextureBrowser_deleteTag(); -void TextureBrowser_createContextMenu( GtkWidget *treeview, GdkEventButton *event ){ - GtkWidget* menu = gtk_menu_new(); +void TextureBrowser_createContextMenu( ui::Widget treeview, GdkEventButton *event ){ + ui::Widget menu = ui::Menu(); - GtkWidget* menuitem = gtk_menu_item_new_with_label( "Add tag" ); - g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_addTag, treeview ); + ui::Widget menuitem = ui::MenuItem( "Add tag" ); + menuitem.connect( "activate", (GCallback)TextureBrowser_addTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); - menuitem = gtk_menu_item_new_with_label( "Rename tag" ); - g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_renameTag, treeview ); + menuitem = ui::MenuItem( "Rename tag" ); + menuitem.connect( "activate", (GCallback)TextureBrowser_renameTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); - menuitem = gtk_menu_item_new_with_label( "Delete tag" ); - g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_deleteTag, treeview ); + menuitem = ui::MenuItem( "Delete tag" ); + menuitem.connect( "activate", (GCallback)TextureBrowser_deleteTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); gtk_widget_show_all( menu ); @@ -1629,7 +1625,7 @@ void TextureBrowser_createContextMenu( GtkWidget *treeview, GdkEventButton *even gdk_event_get_time( (GdkEvent*)event ) ); } -gboolean TreeViewTags_onButtonPressed( GtkWidget *treeview, GdkEventButton *event ){ +gboolean TreeViewTags_onButtonPressed( ui::Widget treeview, GdkEventButton *event ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { GtkTreePath *path; GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( treeview ) ); @@ -1647,22 +1643,21 @@ gboolean TreeViewTags_onButtonPressed( GtkWidget *treeview, GdkEventButton *even } void TextureBrowser_createTreeViewTags(){ - GtkCellRenderer* renderer; - g_TextureBrowser.m_treeViewTags = GTK_WIDGET( gtk_tree_view_new() ); + g_TextureBrowser.m_treeViewTags = ui::TreeView(); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), FALSE ); - g_signal_connect( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), "button-press-event", (GCallback)TreeViewTags_onButtonPressed, NULL ); + g_TextureBrowser.m_treeViewTags.connect( "button-press-event", (GCallback)TreeViewTags_onButtonPressed, NULL ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), FALSE ); - renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), -1, "", renderer, "text", 0, NULL ); TextureBrowser_constructTreeStoreTags(); } -GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){ - GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "_View" ); +ui::MenuItem TextureBrowser_constructViewMenu( ui::Menu menu ){ + ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_View" )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -1702,7 +1697,7 @@ GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){ if ( string_empty( g_pGameDescription->getKeyValue( "show_wads" ) ) ) { menu_separator( menu ); - g_TextureBrowser.m_shader_info_item = GTK_WIDGET( create_menu_item_with_mnemonic( menu, "Shader Info", "ShaderInfo" ) ); + g_TextureBrowser.m_shader_info_item = ui::Widget(GTK_WIDGET( create_menu_item_with_mnemonic( menu, "Shader Info", "ShaderInfo" ) )); gtk_widget_set_sensitive( g_TextureBrowser.m_shader_info_item, FALSE ); } @@ -1710,8 +1705,8 @@ GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){ return textures_menu_item; } -GtkMenuItem* TextureBrowser_constructToolsMenu( GtkMenu* menu ){ - GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "_Tools" ); +ui::MenuItem TextureBrowser_constructToolsMenu( ui::Menu menu ){ + ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_Tools" )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -1723,8 +1718,8 @@ GtkMenuItem* TextureBrowser_constructToolsMenu( GtkMenu* menu ){ return textures_menu_item; } -GtkMenuItem* TextureBrowser_constructTagsMenu( GtkMenu* menu ){ - GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "T_ags" ); +ui::MenuItem TextureBrowser_constructTagsMenu( ui::Menu menu ){ + ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "T_ags" )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -1926,31 +1921,29 @@ void TextureBrowser_toggleSearchButton(){ gtk_widget_show_all( g_TextureBrowser.m_search_button ); } else { - gtk_widget_hide_all( g_TextureBrowser.m_search_button ); + gtk_widget_hide( g_TextureBrowser.m_search_button ); } } void TextureBrowser_constructTagNotebook(){ - g_TextureBrowser.m_tag_notebook = gtk_notebook_new(); - GtkWidget* labelTags = gtk_label_new( "Tags" ); - GtkWidget* labelTextures = gtk_label_new( "Textures" ); + g_TextureBrowser.m_tag_notebook = ui::Widget(gtk_notebook_new()); + ui::Widget labelTags = ui::Label( "Tags" ); + ui::Widget labelTextures = ui::Label( "Textures" ); gtk_notebook_append_page( GTK_NOTEBOOK( g_TextureBrowser.m_tag_notebook ), g_TextureBrowser.m_scr_win_tree, labelTextures ); gtk_notebook_append_page( GTK_NOTEBOOK( g_TextureBrowser.m_tag_notebook ), g_TextureBrowser.m_scr_win_tags, labelTags ); - g_signal_connect( G_OBJECT( g_TextureBrowser.m_tag_notebook ), "switch-page", G_CALLBACK( TextureBrowser_toggleSearchButton ), NULL ); + g_TextureBrowser.m_tag_notebook.connect( "switch-page", G_CALLBACK( TextureBrowser_toggleSearchButton ), NULL ); gtk_widget_show_all( g_TextureBrowser.m_tag_notebook ); } void TextureBrowser_constructSearchButton(){ - GtkTooltips* tooltips = gtk_tooltips_new(); - - GtkWidget* image = gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR ); - g_TextureBrowser.m_search_button = gtk_button_new(); - g_signal_connect( G_OBJECT( g_TextureBrowser.m_search_button ), "clicked", G_CALLBACK( TextureBrowser_searchTags ), NULL ); - gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), g_TextureBrowser.m_search_button, "Search with selected tags", "Search with selected tags" ); - gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_search_button ), image ); + ui::Widget image = ui::Widget(gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR )); + g_TextureBrowser.m_search_button = ui::Button(); + g_TextureBrowser.m_search_button.connect( "clicked", G_CALLBACK( TextureBrowser_searchTags ), NULL ); + gtk_widget_set_tooltip_text(g_TextureBrowser.m_search_button, "Search with selected tags"); + g_TextureBrowser.m_search_button.add(image); } void TextureBrowser_checkTagFile(){ @@ -2001,7 +1994,7 @@ void TextureBrowser_SetNotex(){ g_shadernotex = name.c_str(); } -GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ +ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ // The gl_widget and the tag assignment frame should be packed into a GtkVPaned with the slider // position stored in local.pref. gtk_paned_get_position() and gtk_paned_set_position() don't // seem to work in gtk 2.4 and the arrow buttons don't handle GTK_FILL, so here's another thing @@ -2014,77 +2007,77 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ g_TextureBrowser.m_parent = toplevel; - GtkWidget* table = gtk_table_new( 3, 3, FALSE ); - GtkWidget* frame_table = NULL; - GtkWidget* vbox = gtk_vbox_new( FALSE, 0 ); + ui::Widget table = ui::Table( 3, 3, FALSE ); + ui::Widget frame_table; + ui::Widget vbox = ui::VBox( FALSE, 0 ); gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); - gtk_widget_show( vbox ); + vbox.show(); - GtkWidget* menu_bar; + ui::Widget menu_bar; { // menu bar - menu_bar = gtk_menu_bar_new(); - GtkWidget* menu_view = gtk_menu_new(); - GtkWidget* view_item = (GtkWidget*)TextureBrowser_constructViewMenu( GTK_MENU( menu_view ) ); + menu_bar = ui::Widget(gtk_menu_bar_new()); + auto menu_view = ui::Menu(); + auto view_item = TextureBrowser_constructViewMenu( menu_view ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view ); - gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), view_item ); + gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), view_item ); - GtkWidget* menu_tools = gtk_menu_new(); - GtkWidget* tools_item = (GtkWidget*)TextureBrowser_constructToolsMenu( GTK_MENU( menu_tools ) ); + auto menu_tools = ui::Menu(); + auto tools_item = TextureBrowser_constructToolsMenu( menu_tools ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( tools_item ), menu_tools ); - gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tools_item ); + gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tools_item ); gtk_table_attach( GTK_TABLE( table ), menu_bar, 0, 3, 0, 1, GTK_FILL, GTK_SHRINK, 0, 0 ); - gtk_widget_show( menu_bar ); + menu_bar.show(); } { // Texture TreeView - g_TextureBrowser.m_scr_win_tree = gtk_scrolled_window_new( NULL, NULL ); + g_TextureBrowser.m_scr_win_tree = ui::ScrolledWindow(); gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tree ), 0 ); // vertical only scrolling for treeview gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); - gtk_widget_show( g_TextureBrowser.m_scr_win_tree ); + g_TextureBrowser.m_scr_win_tree.show(); TextureBrowser_createTreeViewTree(); gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) ); - gtk_widget_show( GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) ); + g_TextureBrowser.m_treeViewTree.show(); } { // gl_widget scrollbar - GtkWidget* w = gtk_vscrollbar_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,0,1,1,0 ) ) ); + ui::Widget w = ui::Widget(gtk_vscrollbar_new( ui::Adjustment( 0,0,0,1,1,0 ) )); gtk_table_attach( GTK_TABLE( table ), w, 2, 3, 1, 2, GTK_SHRINK, GTK_FILL, 0, 0 ); - gtk_widget_show( w ); + w.show(); g_TextureBrowser.m_texture_scroll = w; - GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) ); - g_signal_connect( G_OBJECT( vadjustment ), "value_changed", G_CALLBACK( TextureBrowser_verticalScroll ), &g_TextureBrowser ); + auto vadjustment = ui::Adjustment(gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) )); + vadjustment.connect( "value_changed", G_CALLBACK( TextureBrowser_verticalScroll ), &g_TextureBrowser ); widget_set_visible( g_TextureBrowser.m_texture_scroll, g_TextureBrowser.m_showTextureScrollbar ); } { // gl_widget g_TextureBrowser.m_gl_widget = glwidget_new( FALSE ); - gtk_widget_ref( g_TextureBrowser.m_gl_widget ); + g_object_ref( g_TextureBrowser.m_gl_widget._handle ); gtk_widget_set_events( g_TextureBrowser.m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK ); - GTK_WIDGET_SET_FLAGS( g_TextureBrowser.m_gl_widget, GTK_CAN_FOCUS ); + gtk_widget_set_can_focus( g_TextureBrowser.m_gl_widget, true ); gtk_table_attach_defaults( GTK_TABLE( table ), g_TextureBrowser.m_gl_widget, 1, 2, 1, 2 ); - gtk_widget_show( g_TextureBrowser.m_gl_widget ); + g_TextureBrowser.m_gl_widget.show(); - g_TextureBrowser.m_sizeHandler = g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "size_allocate", G_CALLBACK( TextureBrowser_size_allocate ), &g_TextureBrowser ); - g_TextureBrowser.m_exposeHandler = g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "expose_event", G_CALLBACK( TextureBrowser_expose ), &g_TextureBrowser ); + g_TextureBrowser.m_sizeHandler = g_TextureBrowser.m_gl_widget.connect( "size_allocate", G_CALLBACK( TextureBrowser_size_allocate ), &g_TextureBrowser ); + g_TextureBrowser.m_exposeHandler = g_TextureBrowser.m_gl_widget.on_render( G_CALLBACK( TextureBrowser_expose ), &g_TextureBrowser ); - g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "button_press_event", G_CALLBACK( TextureBrowser_button_press ), &g_TextureBrowser ); - g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "button_release_event", G_CALLBACK( TextureBrowser_button_release ), &g_TextureBrowser ); - g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "motion_notify_event", G_CALLBACK( TextureBrowser_motion ), &g_TextureBrowser ); - g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "scroll_event", G_CALLBACK( TextureBrowser_scroll ), &g_TextureBrowser ); + g_TextureBrowser.m_gl_widget.connect( "button_press_event", G_CALLBACK( TextureBrowser_button_press ), &g_TextureBrowser ); + g_TextureBrowser.m_gl_widget.connect( "button_release_event", G_CALLBACK( TextureBrowser_button_release ), &g_TextureBrowser ); + g_TextureBrowser.m_gl_widget.connect( "motion_notify_event", G_CALLBACK( TextureBrowser_motion ), &g_TextureBrowser ); + g_TextureBrowser.m_gl_widget.connect( "scroll_event", G_CALLBACK( TextureBrowser_scroll ), &g_TextureBrowser ); } // tag stuff if ( g_TextureBrowser.m_tags ) { { // fill tag GtkListStore - g_TextureBrowser.m_all_tags_list = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ); + g_TextureBrowser.m_all_tags_list = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_all_tags_list ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); @@ -2092,13 +2085,13 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ TextureBrowser_buildTagList(); } { // tag menu bar - GtkWidget* menu_tags = gtk_menu_new(); - GtkWidget* tags_item = (GtkWidget*)TextureBrowser_constructTagsMenu( GTK_MENU( menu_tags ) ); + auto menu_tags = ui::Menu(); + auto tags_item = TextureBrowser_constructTagsMenu( menu_tags ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags ); - gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tags_item ); + gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tags_item ); } { // Tag TreeView - g_TextureBrowser.m_scr_win_tags = gtk_scrolled_window_new( NULL, NULL ); + g_TextureBrowser.m_scr_win_tags = ui::ScrolledWindow(); gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tags ), 0 ); // vertical only scrolling for treeview @@ -2110,7 +2103,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE ); gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tags ), GTK_WIDGET( g_TextureBrowser.m_treeViewTags ) ); - gtk_widget_show( GTK_WIDGET( g_TextureBrowser.m_treeViewTags ) ); + g_TextureBrowser.m_treeViewTags.show(); } { // Texture/Tag notebook TextureBrowser_constructTagNotebook(); @@ -2121,82 +2114,82 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_box_pack_end( GTK_BOX( vbox ), g_TextureBrowser.m_search_button, FALSE, FALSE, 0 ); } { // Tag frame - frame_table = gtk_table_new( 3, 3, FALSE ); + frame_table = ui::Table( 3, 3, FALSE ); - g_TextureBrowser.m_tag_frame = gtk_frame_new( "Tag assignment" ); + g_TextureBrowser.m_tag_frame = ui::Frame( "Tag assignment" ); gtk_frame_set_label_align( GTK_FRAME( g_TextureBrowser.m_tag_frame ), 0.5, 0.5 ); gtk_frame_set_shadow_type( GTK_FRAME( g_TextureBrowser.m_tag_frame ), GTK_SHADOW_NONE ); gtk_table_attach( GTK_TABLE( table ), g_TextureBrowser.m_tag_frame, 1, 3, 2, 3, GTK_FILL, GTK_SHRINK, 0, 0 ); - gtk_widget_show( frame_table ); + frame_table.show(); - gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_tag_frame ), frame_table ); + g_TextureBrowser.m_tag_frame.add(frame_table); } { // assigned tag list - GtkWidget* scrolled_win = gtk_scrolled_window_new( NULL, NULL ); + ui::Widget scrolled_win = ui::ScrolledWindow(); gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); - g_TextureBrowser.m_assigned_store = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ); + g_TextureBrowser.m_assigned_store = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_assigned_store ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); - g_TextureBrowser.m_assigned_tree = gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) ); - g_object_unref( G_OBJECT( g_TextureBrowser.m_assigned_store ) ); - g_signal_connect( g_TextureBrowser.m_assigned_tree, "row-activated", (GCallback) TextureBrowser_removeTags, NULL ); + g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) )); + g_TextureBrowser.m_assigned_store.unref(); + g_TextureBrowser.m_assigned_tree.connect( "row-activated", (GCallback) TextureBrowser_removeTags, NULL ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), FALSE ); GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ) ); gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL ); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), column ); - gtk_widget_show( g_TextureBrowser.m_assigned_tree ); + g_TextureBrowser.m_assigned_tree.show(); - gtk_widget_show( scrolled_win ); + scrolled_win.show(); gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_assigned_tree ) ); gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); } { // available tag list - GtkWidget* scrolled_win = gtk_scrolled_window_new( NULL, NULL ); + ui::Widget scrolled_win = ui::ScrolledWindow(); gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); - g_TextureBrowser.m_available_store = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ); + g_TextureBrowser.m_available_store = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_available_store ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(); - g_TextureBrowser.m_available_tree = gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) ); - g_object_unref( G_OBJECT( g_TextureBrowser.m_available_store ) ); - g_signal_connect( g_TextureBrowser.m_available_tree, "row-activated", (GCallback) TextureBrowser_assignTags, NULL ); + g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) )); + g_TextureBrowser.m_available_store.unref(); + g_TextureBrowser.m_available_tree.connect( "row-activated", (GCallback) TextureBrowser_assignTags, NULL ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), FALSE ); GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ) ); gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL ); + GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), column ); - gtk_widget_show( g_TextureBrowser.m_available_tree ); + g_TextureBrowser.m_available_tree.show(); - gtk_widget_show( scrolled_win ); + scrolled_win.show(); gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_available_tree ) ); gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 2, 3, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); } { // tag arrow buttons - GtkWidget* m_btn_left = gtk_button_new(); - GtkWidget* m_btn_right = gtk_button_new(); - GtkWidget* m_arrow_left = gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT ); - GtkWidget* m_arrow_right = gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT ); - gtk_container_add( GTK_CONTAINER( m_btn_left ), m_arrow_left ); - gtk_container_add( GTK_CONTAINER( m_btn_right ), m_arrow_right ); + auto m_btn_left = ui::Button(); + auto m_btn_right = ui::Button(); + auto m_arrow_left = ui::Widget(gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT )); + auto m_arrow_right = ui::Widget(gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT )); + m_btn_left.add(m_arrow_left); + m_btn_right.add(m_arrow_right); // workaround. the size of the tag frame depends of the requested size of the arrow buttons. gtk_widget_set_size_request( m_arrow_left, -1, 68 ); @@ -2205,23 +2198,23 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_table_attach( GTK_TABLE( frame_table ), m_btn_left, 1, 2, 1, 2, GTK_SHRINK, GTK_EXPAND, 0, 0 ); gtk_table_attach( GTK_TABLE( frame_table ), m_btn_right, 1, 2, 2, 3, GTK_SHRINK, GTK_EXPAND, 0, 0 ); - g_signal_connect( G_OBJECT( m_btn_left ), "clicked", G_CALLBACK( TextureBrowser_assignTags ), NULL ); - g_signal_connect( G_OBJECT( m_btn_right ), "clicked", G_CALLBACK( TextureBrowser_removeTags ), NULL ); + m_btn_left.connect( "clicked", G_CALLBACK( TextureBrowser_assignTags ), NULL ); + m_btn_right.connect( "clicked", G_CALLBACK( TextureBrowser_removeTags ), NULL ); - gtk_widget_show( m_btn_left ); - gtk_widget_show( m_btn_right ); - gtk_widget_show( m_arrow_left ); - gtk_widget_show( m_arrow_right ); + m_btn_left.show(); + m_btn_right.show(); + m_arrow_left.show(); + m_arrow_right.show(); } { // tag fram labels - GtkWidget* m_lbl_assigned = gtk_label_new( "Assigned" ); - GtkWidget* m_lbl_unassigned = gtk_label_new( "Available" ); + ui::Widget m_lbl_assigned = ui::Label( "Assigned" ); + ui::Widget m_lbl_unassigned = ui::Label( "Available" ); gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_assigned, 0, 1, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 ); gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_unassigned, 2, 3, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 ); - gtk_widget_show( m_lbl_assigned ); - gtk_widget_show( m_lbl_unassigned ); + m_lbl_assigned.show(); + m_lbl_unassigned.show(); } } else { // no tag support, show the texture tree only @@ -2240,7 +2233,7 @@ void TextureBrowser_destroyWindow(){ g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_sizeHandler ); g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_exposeHandler ); - gtk_widget_unref( g_TextureBrowser.m_gl_widget ); + g_TextureBrowser.m_gl_widget.unref(); } const Vector3& TextureBrowser_getBackgroundColour( TextureBrowser& textureBrowser ){ @@ -2334,7 +2327,7 @@ void TextureBrowser_renameTag(){ } else { - gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Select a single tag for renaming." ); + ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Select a single tag for renaming." ); } } @@ -2345,9 +2338,9 @@ void TextureBrowser_deleteTag(){ gtk_tree_selection_selected_foreach( selection, GtkTreeSelectionForeachFunc( TextureBrowser_selectionHelper ), &selected ); if ( g_slist_length( selected ) == 1 ) { // we only delete a single tag - EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Are you sure you want to delete the selected tag?", "Delete Tag", eMB_YESNO, eMB_ICONQUESTION ); + auto result = ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Are you sure you want to delete the selected tag?", "Delete Tag", ui::alert_type::YESNO, ui::alert_icon::Question ); - if ( result == eIDYES ) { + if ( result == ui::alert_response::YES ) { GtkTreeIter iterSelected; gchar *rowTag; @@ -2374,7 +2367,7 @@ void TextureBrowser_deleteTag(){ } } else { - gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Select a single tag for deletion." ); + ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Select a single tag for deletion." ); } } @@ -2426,7 +2419,7 @@ void TextureBrowser_RefreshShaders(){ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" ); GlobalShaderSystem().refresh(); UpdateAllWindows(); - GtkTreeSelection* selection = gtk_tree_view_get_selection((GtkTreeView*)GlobalTextureBrowser().m_treeViewTree); + GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(GlobalTextureBrowser().m_treeViewTree)); GtkTreeModel* model = NULL; GtkTreeIter iter; if ( gtk_tree_selection_get_selected (selection, &model, &iter) ) @@ -2466,9 +2459,9 @@ void TextureBrowser_showAll(){ } void TextureBrowser_showUntagged(){ - EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", eMB_YESNO, eMB_ICONWARNING ); + auto result = ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", ui::alert_type::YESNO, ui::alert_icon::Warning ); - if ( result == eIDYES ) { + if ( result == ui::alert_response::YES ) { g_TextureBrowser.m_found_shaders.clear(); TagBuilder.GetUntagged( g_TextureBrowser.m_found_shaders ); std::set::iterator iter; diff --git a/radiant/texwindow.h b/radiant/texwindow.h index edc67b22..15ec907c 100644 --- a/radiant/texwindow.h +++ b/radiant/texwindow.h @@ -22,18 +22,16 @@ #if !defined( INCLUDED_TEXWINDOW_H ) #define INCLUDED_TEXWINDOW_H +#include #include "math/vector.h" #include "generic/callbackfwd.h" #include "signal/signalfwd.h" #include "xml/xmltextags.h" -typedef struct _GtkWidget GtkWidget; - class TextureBrowser; TextureBrowser& GlobalTextureBrowser(); -typedef struct _GtkWindow GtkWindow; -GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ); +ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ); void TextureBrowser_destroyWindow(); @@ -49,7 +47,7 @@ typedef Callback1 StringImportCallback; template class FreeCaller1; -extern GtkWidget* g_page_textures; +extern ui::Widget g_page_textures; void TextureBrowser_exportTitle( const StringImportCallback& importer ); typedef FreeCaller1 TextureBrowserExportTitleCaller; diff --git a/radiant/treemodel.cpp b/radiant/treemodel.cpp index d36e492a..9e1f20cf 100644 --- a/radiant/treemodel.cpp +++ b/radiant/treemodel.cpp @@ -24,9 +24,8 @@ #include "debugging/debugging.h" #include -#include -#include -#include +#include +#include #include "iscenegraph.h" #include "nameable.h" @@ -280,7 +279,7 @@ static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTree graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph; graph_type::iterator i = graph_iterator_read_tree_iter( iter ); - GtkTreePath* path = gtk_tree_path_new(); + GtkTreePath* path = ui::TreePath(); for ( std::size_t depth = ( *i ).first.get().size(); depth != 0; --depth ) { @@ -882,7 +881,7 @@ static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTree ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); GraphTreeNode* graph = GRAPH_TREE_MODEL( tree_model )->m_graph; - GtkTreePath* path = gtk_tree_path_new(); + GtkTreePath* path = ui::TreePath(); for ( GraphTreeNode* node = ( *graph_iterator_read_tree_iter( iter ) ).second; node != graph; node = node->m_parent ) { @@ -1369,7 +1368,7 @@ TestGraphTreeModel(){ { GtkTreeIter iter; - GtkTreePath* path = gtk_tree_path_new_from_string( "0" ); + GtkTreePath* path = ui::TreePath( "0" ); gtk_tree_model_get_iter( model, &iter, path ); gtk_tree_path_free( path ); @@ -1379,7 +1378,7 @@ TestGraphTreeModel(){ { GtkTreeIter iter; - GtkTreePath* path = gtk_tree_path_new_from_string( "1" ); + GtkTreePath* path = ui::TreePath( "1" ); gtk_tree_model_get_iter( model, &iter, path ); gtk_tree_path_free( path ); diff --git a/radiant/url.cpp b/radiant/url.cpp index b86702e7..b1603ecc 100644 --- a/radiant/url.cpp +++ b/radiant/url.cpp @@ -25,10 +25,11 @@ #include "gtkutil/messagebox.h" #ifdef WIN32 +#include #include #include bool open_url( const char* url ){ - return ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", url, 0, 0, SW_SHOW ) > (HINSTANCE)32; + return ShellExecute( (HWND)GDK_WINDOW_HWND( gtk_widget_get_window( MainFrame_getWindow() ) ), "open", url, 0, 0, SW_SHOW ) > (HINSTANCE)32; } #endif @@ -55,6 +56,6 @@ void OpenURL( const char *url ){ // let's put a little comment globalOutputStream() << "OpenURL: " << url << "\n"; if ( !open_url( url ) ) { - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "Failed to launch browser!" ); + MainFrame_getWindow().alert( "Failed to launch browser!" ); } } diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index f3d1ae6f..4824d23e 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -36,7 +36,6 @@ #include "watchbsp.h" #include -#include #include "cmdlib.h" #include "convert.h" @@ -77,86 +76,87 @@ void message_print( message_info_t* self, const char* characters, std::size_t le #include +#include #include "xmlstuff.h" class CWatchBSP { private: -// a flag we have set to true when using an external BSP plugin -// the resulting code with that is a bit dirty, cleaner solution would be to seperate the succession of commands from the listening loop -// (in two seperate classes probably) -bool m_bBSPPlugin; - -// EIdle: we are not listening -// DoMonitoringLoop will change state to EBeginStep -// EBeginStep: the socket is up for listening, we are expecting incoming connection -// incoming connection will change state to EWatching -// EWatching: we have a connection, monitor it -// connection closed will see if we start a new step (EBeginStep) or launch Quake3 and end (EIdle) -enum EWatchBSPState { EIdle, EBeginStep, EWatching } m_eState; -socket_t *m_pListenSocket; -socket_t *m_pInSocket; -netmessage_t msg; -GPtrArray *m_pCmd; -// used to timeout EBeginStep -GTimer *m_pTimer; -std::size_t m_iCurrentStep; -// name of the map so we can run the engine -char *m_sBSPName; -// buffer we use in push mode to receive data directly from the network -xmlParserInputBufferPtr m_xmlInputBuffer; -xmlParserInputPtr m_xmlInput; -xmlParserCtxtPtr m_xmlParserCtxt; -// call this to switch the set listening mode -bool SetupListening(); -// start a new EBeginStep -void DoEBeginStep(); -// the xml and sax parser state -char m_xmlBuf[MAX_NETMESSAGE]; -bool m_bNeedCtxtInit; -message_info_t m_message_info; + // a flag we have set to true when using an external BSP plugin + // the resulting code with that is a bit dirty, cleaner solution would be to seperate the succession of commands from the listening loop + // (in two seperate classes probably) + bool m_bBSPPlugin; + + // EIdle: we are not listening + // DoMonitoringLoop will change state to EBeginStep + // EBeginStep: the socket is up for listening, we are expecting incoming connection + // incoming connection will change state to EWatching + // EWatching: we have a connection, monitor it + // connection closed will see if we start a new step (EBeginStep) or launch Quake3 and end (EIdle) + enum EWatchBSPState { EIdle, EBeginStep, EWatching } m_eState; + socket_t *m_pListenSocket; + socket_t *m_pInSocket; + netmessage_t msg; + GPtrArray *m_pCmd; + // used to timeout EBeginStep + GTimer *m_pTimer; + std::size_t m_iCurrentStep; + // name of the map so we can run the engine + char *m_sBSPName; + // buffer we use in push mode to receive data directly from the network + xmlParserInputBufferPtr m_xmlInputBuffer; + xmlParserInputPtr m_xmlInput; + xmlParserCtxtPtr m_xmlParserCtxt; + // call this to switch the set listening mode + bool SetupListening(); + // start a new EBeginStep + void DoEBeginStep(); + // the xml and sax parser state + char m_xmlBuf[MAX_NETMESSAGE]; + bool m_bNeedCtxtInit; + message_info_t m_message_info; public: -CWatchBSP(){ - m_pCmd = 0; - m_bBSPPlugin = false; - m_pListenSocket = NULL; - m_pInSocket = NULL; - m_eState = EIdle; - m_pTimer = g_timer_new(); - m_sBSPName = NULL; - m_xmlInputBuffer = NULL; - m_bNeedCtxtInit = true; -} -virtual ~CWatchBSP(){ - EndMonitoringLoop(); - Net_Shutdown(); - - g_timer_destroy( m_pTimer ); -} - -bool HasBSPPlugin() const -{ return m_bBSPPlugin; } + CWatchBSP(){ + m_pCmd = 0; + m_bBSPPlugin = false; + m_pListenSocket = NULL; + m_pInSocket = NULL; + m_eState = EIdle; + m_pTimer = g_timer_new(); + m_sBSPName = NULL; + m_xmlInputBuffer = NULL; + m_bNeedCtxtInit = true; + } + virtual ~CWatchBSP(){ + EndMonitoringLoop(); + Net_Shutdown(); -// called regularly to keep listening -void RoutineProcessing(); -// start a monitoring loop with the following steps -void DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ); -void EndMonitoringLoop(){ - Reset(); - if ( m_sBSPName ) { - string_release( m_sBSPName, string_length( m_sBSPName ) ); - m_sBSPName = 0; + g_timer_destroy( m_pTimer ); } - if ( m_pCmd ) { - g_ptr_array_free( m_pCmd, TRUE ); - m_pCmd = 0; + + bool HasBSPPlugin() const + { return m_bBSPPlugin; } + + // called regularly to keep listening + void RoutineProcessing(); + // start a monitoring loop with the following steps + void DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ); + void EndMonitoringLoop(){ + Reset(); + if ( m_sBSPName ) { + string_release( m_sBSPName, string_length( m_sBSPName ) ); + m_sBSPName = 0; + } + if ( m_pCmd ) { + g_ptr_array_free( m_pCmd, TRUE ); + m_pCmd = 0; + } } -} -// close everything - may be called from the outside to abort the process -void Reset(); -// start a listening loop for an external process, possibly a BSP plugin -void ExternalListen(); + // close everything - may be called from the outside to abort the process + void Reset(); + // start a listening loop for an external process, possibly a BSP plugin + void ExternalListen(); }; CWatchBSP* g_pWatchBSP; @@ -176,10 +176,10 @@ int g_WatchBSP_Timeout = 10; void Build_constructPreferences( PreferencesPage& page ){ - GtkWidget* monitorbsp = page.appendCheckBox( "", "Enable Build Process Monitoring", g_WatchBSP_Enabled ); - GtkWidget* leakstop = page.appendCheckBox( "", "Stop Compilation on Leak", g_WatchBSP_LeakStop ); - GtkWidget* runengine = page.appendCheckBox( "", "Run Engine After Compile", g_WatchBSP_RunQuake ); - GtkWidget* sleep = page.appendCheckBox ( "", "Sleep When Running the Engine", g_WatchBSP_DoSleep ); + ui::CheckButton monitorbsp = page.appendCheckBox( "", "Enable Build Process Monitoring", g_WatchBSP_Enabled ); + ui::CheckButton leakstop = page.appendCheckBox( "", "Stop Compilation on Leak", g_WatchBSP_LeakStop ); + ui::CheckButton runengine = page.appendCheckBox( "", "Run Engine After Compile", g_WatchBSP_RunQuake ); + ui::CheckButton sleep = page.appendCheckBox ( "", "Sleep When Running the Engine", g_WatchBSP_DoSleep ); Widget_connectToggleDependency( leakstop, monitorbsp ); Widget_connectToggleDependency( runengine, monitorbsp ); Widget_connectToggleDependency( sleep, runengine ); @@ -359,29 +359,30 @@ static void saxEndElement( message_info_t *data, const xmlChar *name ){ class MessageOutputStream : public TextOutputStream { -message_info_t* m_data; + message_info_t* m_data; public: -MessageOutputStream( message_info_t* data ) : m_data( data ){ -} -std::size_t write( const char* buffer, std::size_t length ){ - if ( m_data->pGeometry != 0 ) { - m_data->pGeometry->saxCharacters( m_data, reinterpret_cast( buffer ), int(length) ); + MessageOutputStream( message_info_t* data ) : m_data( data ){ } - else - { - if ( m_data->ignore_depth == 0 ) { - // output the message using the level - message_print( m_data, buffer, length ); - // if this message has error level flag, we mark the depth to stop the compilation when we get out - // we don't set the msg level if we don't stop on leak - if ( m_data->msg_level == 3 ) { - m_data->stop_depth = m_data->recurse - 1; + + std::size_t write( const char* buffer, std::size_t length ){ + if ( m_data->pGeometry != 0 ) { + m_data->pGeometry->saxCharacters( m_data, reinterpret_cast( buffer ), int(length) ); + } + else + { + if ( m_data->ignore_depth == 0 ) { + // output the message using the level + message_print( m_data, buffer, length ); + // if this message has error level flag, we mark the depth to stop the compilation when we get out + // we don't set the msg level if we don't stop on leak + if ( m_data->msg_level == 3 ) { + m_data->stop_depth = m_data->recurse - 1; + } } } - } - return length; -} + return length; + } }; template @@ -488,7 +489,7 @@ void CWatchBSP::Reset(){ } m_eState = EIdle; if ( s_routine_id ) { - gtk_timeout_remove( s_routine_id ); + g_source_remove( s_routine_id ); } } @@ -514,7 +515,7 @@ void CWatchBSP::DoEBeginStep(){ if ( SetupListening() == false ) { const char* msg = "Failed to get a listening socket on port 39000.\nTry running with Build monitoring disabled if you can't fix this.\n"; globalOutputStream() << msg; - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg, "Build monitoring", eMB_OK, eMB_ICONERROR ); + MainFrame_getWindow().alert( msg, "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error ); return; } // set the timer for timeouts and step cancellation @@ -531,7 +532,7 @@ void CWatchBSP::DoEBeginStep(){ msg << reinterpret_cast( g_ptr_array_index( m_pCmd, m_iCurrentStep ) ); msg << "\nCheck that the file exists and that you don't run out of system resources.\n"; globalOutputStream() << msg.c_str(); - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg.c_str(), "Build monitoring", eMB_OK, eMB_ICONERROR ); + MainFrame_getWindow().alert( msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error ); return; } // re-initialise the debug window @@ -540,7 +541,7 @@ void CWatchBSP::DoEBeginStep(){ } } m_eState = EBeginStep; - s_routine_id = gtk_timeout_add( 25, watchbsp_routine, this ); + s_routine_id = g_timeout_add( 25, watchbsp_routine, this ); } @@ -560,15 +561,15 @@ void CWatchBSP::DoEBeginStep(){ class RunEngineConfiguration { public: -const char* executable; -const char* mp_executable; -bool do_sp_mp; - -RunEngineConfiguration() : - executable( g_pGameDescription->getRequiredKeyValue( ENGINE_ATTRIBUTE ) ), - mp_executable( g_pGameDescription->getKeyValue( MP_ENGINE_ATTRIBUTE ) ){ - do_sp_mp = !string_empty( mp_executable ); -} + const char* executable; + const char* mp_executable; + bool do_sp_mp; + + RunEngineConfiguration() : + executable( g_pGameDescription->getRequiredKeyValue( ENGINE_ATTRIBUTE ) ), + mp_executable( g_pGameDescription->getKeyValue( MP_ENGINE_ATTRIBUTE ) ){ + do_sp_mp = !string_empty( mp_executable ); + } }; inline void GlobalGameDescription_string_write_mapparameter( StringOutputStream& string, const char* mapname ){ @@ -611,7 +612,7 @@ void CWatchBSP::RoutineProcessing(){ case EBeginStep: // timeout: if we don't get an incoming connection fast enough, go back to idle if ( g_timer_elapsed( m_pTimer, NULL ) > g_WatchBSP_Timeout ) { - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", eMB_OK ); + MainFrame_getWindow().alert( "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", ui::alert_type::OK ); EndMonitoringLoop(); #if 0 if ( m_bBSPPlugin ) { @@ -744,7 +745,7 @@ void CWatchBSP::RoutineProcessing(){ StringOutputStream msg; msg << "Failed to execute the following command: " << cmd.c_str() << cmdline.c_str(); globalOutputStream() << msg.c_str(); - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg.c_str(), "Build monitoring", eMB_OK, eMB_ICONERROR ); + MainFrame_getWindow().alert( msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error ); } } EndMonitoringLoop(); @@ -772,8 +773,8 @@ void CWatchBSP::DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ){ if ( m_eState != EIdle ) { globalOutputStream() << "WatchBSP got a monitoring request while not idling...\n"; // prompt the user, should we cancel the current process and go ahead? - if ( gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?", - "Build process monitoring", eMB_YESNO ) == eIDYES ) { + if ( MainFrame_getWindow().alert( "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?", + "Build process monitoring", ui::alert_type::YESNO ) == ui::alert_response::YES ) { // disconnect and set EIdle state Reset(); } diff --git a/radiant/windowobservers.cpp b/radiant/windowobservers.cpp index 989c1196..3bd2334d 100644 --- a/radiant/windowobservers.cpp +++ b/radiant/windowobservers.cpp @@ -22,7 +22,7 @@ #include "windowobservers.h" #include -#include +#include #include "generic/bitfield.h" namespace @@ -50,21 +50,21 @@ inline void WindowObservers_OnModifierUp( WindowObservers& observers, ModifierFl #include -gboolean selection_modifier_key_press( GtkWidget* widget, GdkEventKey* event, WindowObservers& observers ){ +gboolean selection_modifier_key_press( ui::Widget widget, GdkEventKey* event, WindowObservers& observers ){ switch ( event->keyval ) { - case GDK_Alt_L: - case GDK_Alt_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: //globalOutputStream() << "Alt PRESSED\n"; WindowObservers_OnModifierDown( observers, c_modifierAlt ); break; - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: //globalOutputStream() << "Shift PRESSED\n"; WindowObservers_OnModifierDown( observers, c_modifierShift ); break; - case GDK_Control_L: - case GDK_Control_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: //globalOutputStream() << "Control PRESSED\n"; WindowObservers_OnModifierDown( observers, c_modifierControl ); break; @@ -72,21 +72,21 @@ gboolean selection_modifier_key_press( GtkWidget* widget, GdkEventKey* event, Wi return FALSE; } -gboolean selection_modifier_key_release( GtkWidget* widget, GdkEventKey* event, WindowObservers& observers ){ +gboolean selection_modifier_key_release( ui::Widget widget, GdkEventKey* event, WindowObservers& observers ){ switch ( event->keyval ) { - case GDK_Alt_L: - case GDK_Alt_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: //globalOutputStream() << "Alt RELEASED\n"; WindowObservers_OnModifierUp( observers, c_modifierAlt ); break; - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: //globalOutputStream() << "Shift RELEASED\n"; WindowObservers_OnModifierUp( observers, c_modifierShift ); break; - case GDK_Control_L: - case GDK_Control_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: //globalOutputStream() << "Control RELEASED\n"; WindowObservers_OnModifierUp( observers, c_modifierControl ); break; @@ -109,21 +109,21 @@ void WindowObservers_UpdateModifiers( WindowObservers& observers, ModifierFlags WindowObservers_UpdateModifier( observers, modifiers, c_modifierControl ); } -gboolean modifiers_button_press( GtkWidget* widget, GdkEventButton* event, WindowObservers* observers ){ +gboolean modifiers_button_press( ui::Widget widget, GdkEventButton* event, WindowObservers* observers ){ if ( event->type == GDK_BUTTON_PRESS ) { WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) ); } return FALSE; } -gboolean modifiers_button_release( GtkWidget* widget, GdkEventButton* event, WindowObservers* observers ){ +gboolean modifiers_button_release( ui::Widget widget, GdkEventButton* event, WindowObservers* observers ){ if ( event->type == GDK_BUTTON_RELEASE ) { WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) ); } return FALSE; } -gboolean modifiers_motion( GtkWidget *widget, GdkEventMotion *event, WindowObservers* observers ){ +gboolean modifiers_motion( ui::Widget widget, GdkEventMotion *event, WindowObservers* observers ){ WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) ); return FALSE; } @@ -139,13 +139,28 @@ void GlobalWindowObservers_add( WindowObserver* observer ){ g_window_observers.push_back( observer ); } -void GlobalWindowObservers_connectTopLevel( GtkWindow* window ){ - g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( selection_modifier_key_press ), &g_window_observers ); - g_signal_connect( G_OBJECT( window ), "key_release_event", G_CALLBACK( selection_modifier_key_release ), &g_window_observers ); +void GlobalWindowObservers_connectTopLevel( ui::Window window ){ + window.connect( "key_press_event", G_CALLBACK( selection_modifier_key_press ), &g_window_observers ); + window.connect( "key_release_event", G_CALLBACK( selection_modifier_key_release ), &g_window_observers ); } -void GlobalWindowObservers_connectWidget( GtkWidget* widget ){ - g_signal_connect( G_OBJECT( widget ), "button_press_event", G_CALLBACK( modifiers_button_press ), &g_window_observers ); - g_signal_connect( G_OBJECT( widget ), "button_release_event", G_CALLBACK( modifiers_button_release ), &g_window_observers ); - g_signal_connect( G_OBJECT( widget ), "motion_notify_event", G_CALLBACK( modifiers_motion ), &g_window_observers ); +void GlobalWindowObservers_connectWidget( ui::Widget widget ){ + widget.connect( "button_press_event", G_CALLBACK( modifiers_button_press ), &g_window_observers ); + widget.connect( "button_release_event", G_CALLBACK( modifiers_button_release ), &g_window_observers ); + widget.connect( "motion_notify_event", G_CALLBACK( modifiers_motion ), &g_window_observers ); +} + +ModifierFlags modifiers_for_state(unsigned int state) +{ + ModifierFlags modifiers = c_modifierNone; + if ( state & GDK_SHIFT_MASK ) { + modifiers |= c_modifierShift; + } + if ( state & GDK_CONTROL_MASK ) { + modifiers |= c_modifierControl; + } + if ( state & GDK_MOD1_MASK ) { + modifiers |= c_modifierAlt; + } + return modifiers; } diff --git a/radiant/windowobservers.h b/radiant/windowobservers.h index eab5fe59..37fe2f15 100644 --- a/radiant/windowobservers.h +++ b/radiant/windowobservers.h @@ -24,16 +24,14 @@ #include "windowobserver.h" -#include +#include #include "math/vector.h" class WindowObserver; void GlobalWindowObservers_add( WindowObserver* observer ); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -void GlobalWindowObservers_connectWidget( GtkWidget* widget ); -void GlobalWindowObservers_connectTopLevel( GtkWindow* window ); +void GlobalWindowObservers_connectWidget( ui::Widget widget ); +void GlobalWindowObservers_connectTopLevel( ui::Window window ); inline ButtonIdentifier button_for_button( unsigned int button ){ switch ( button ) @@ -48,19 +46,7 @@ inline ButtonIdentifier button_for_button( unsigned int button ){ return c_buttonInvalid; } -inline ModifierFlags modifiers_for_state( unsigned int state ){ - ModifierFlags modifiers = c_modifierNone; - if ( state & GDK_SHIFT_MASK ) { - modifiers |= c_modifierShift; - } - if ( state & GDK_CONTROL_MASK ) { - modifiers |= c_modifierControl; - } - if ( state & GDK_MOD1_MASK ) { - modifiers |= c_modifierAlt; - } - return modifiers; -} +ModifierFlags modifiers_for_state( unsigned int state ); inline WindowVector WindowVector_forDouble( double x, double y ){ return WindowVector( static_cast( x ), static_cast( y ) ); diff --git a/radiant/xmlstuff.h b/radiant/xmlstuff.h index a30303f4..b51f3cd3 100644 --- a/radiant/xmlstuff.h +++ b/radiant/xmlstuff.h @@ -68,8 +68,7 @@ class IGL2DWindow; class ISAXHandler { public: -virtual void Release(){ -} +virtual void Release(){} virtual void saxStartElement( message_info_t* ctx, const xmlChar* name, const xmlChar** attrs ) = 0; virtual void saxEndElement( message_info_t* ctx, const xmlChar* name ) = 0; virtual void saxCharacters( message_info_t* ctx, const xmlChar* ch, int len ) = 0; diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index b094b774..eb275baf 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -27,6 +27,8 @@ #include "xywindow.h" +#include + #include "debugging/debugging.h" #include "ientity.h" @@ -39,8 +41,8 @@ #include "image.h" #include "gtkutil/messagebox.h" -#include -#include +#include +#include #include "generic/callback.h" #include "string/string.h" @@ -536,7 +538,7 @@ VIEWTYPE GlobalXYWnd_getCurrentViewType(){ bool g_bCrossHairs = false; -GtkMenu* XYWnd::m_mnuDrop = 0; +ui::Menu XYWnd::m_mnuDrop(ui::null); // this is disabled, and broken // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394 @@ -548,7 +550,7 @@ void WXY_Print(){ unsigned char* img; const char* filename; - filename = file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, "Save Image", 0, FILTER_BMP ); + filename = ui::file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, "Save Image", 0, FILTER_BMP ); if ( !filename ) { return; } @@ -705,12 +707,12 @@ bool XYWnd::chaseMouseMotion( int pointx, int pointy ){ Shader* XYWnd::m_state_selected = 0; void xy_update_xor_rectangle( XYWnd& self, rect_t area ){ - if ( GTK_WIDGET_VISIBLE( self.GetWidget() ) ) { + if ( gtk_widget_get_visible( self.GetWidget() ) ) { self.m_XORRectangle.set( rectangle_from_area( area.min, area.max, self.Width(), self.Height() ) ); } } -gboolean xywnd_button_press( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){ +gboolean xywnd_button_press( ui::Widget widget, GdkEventButton* event, XYWnd* xywnd ){ if ( event->type == GDK_BUTTON_PRESS ) { g_pParentWnd->SetActiveXY( xywnd ); @@ -721,7 +723,7 @@ gboolean xywnd_button_press( GtkWidget* widget, GdkEventButton* event, XYWnd* xy return FALSE; } -gboolean xywnd_button_release( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){ +gboolean xywnd_button_release( ui::Widget widget, GdkEventButton* event, XYWnd* xywnd ){ if ( event->type == GDK_BUTTON_RELEASE ) { xywnd->XY_MouseUp( static_cast( event->x ), static_cast( event->y ), buttons_for_event_button( event ) ); @@ -730,7 +732,7 @@ gboolean xywnd_button_release( GtkWidget* widget, GdkEventButton* event, XYWnd* return FALSE; } -gboolean xywnd_focus_in( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){ +gboolean xywnd_focus_in( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){ if ( event->type == GDK_FOCUS_CHANGE ) { if ( event->in ) { g_pParentWnd->SetActiveXY( xywnd ); @@ -746,7 +748,7 @@ void xywnd_motion( gdouble x, gdouble y, guint state, void* data ){ reinterpret_cast( data )->XY_MouseMoved( static_cast( x ), static_cast( y ), buttons_for_state( state ) ); } -gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xywnd ){ +gboolean xywnd_wheel_scroll( ui::Widget widget, GdkEventScroll* event, XYWnd* xywnd ){ if ( event->direction == GDK_SCROLL_UP ) { XYWnd_ZoomIn( xywnd ); } @@ -756,7 +758,7 @@ gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xy return FALSE; } -gboolean xywnd_size_allocate( GtkWidget* widget, GtkAllocation* allocation, XYWnd* xywnd ){ +gboolean xywnd_size_allocate( ui::Widget widget, GtkAllocation* allocation, XYWnd* xywnd ){ xywnd->m_nWidth = allocation->width; xywnd->m_nHeight = allocation->height; xywnd->updateProjection(); @@ -764,7 +766,7 @@ gboolean xywnd_size_allocate( GtkWidget* widget, GtkAllocation* allocation, XYWn return FALSE; } -gboolean xywnd_expose( GtkWidget* widget, GdkEventExpose* event, XYWnd* xywnd ){ +gboolean xywnd_expose( ui::Widget widget, GdkEventExpose* event, XYWnd* xywnd ){ if ( glwidget_make_current( xywnd->GetWidget() ) != FALSE ) { if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) { GlobalOpenGL_debugAssertNoErrors(); @@ -787,7 +789,7 @@ void XYWnd_CameraMoved( XYWnd& xywnd ){ XYWnd::XYWnd() : m_gl_widget( glwidget_new( FALSE ) ), - m_deferredDraw( WidgetQueueDrawCaller( *m_gl_widget ) ), + m_deferredDraw( WidgetQueueDrawCaller( m_gl_widget ) ), m_deferred_motion( xywnd_motion, this ), m_parent( 0 ), m_window_observer( NewWindowObserver() ), @@ -818,7 +820,7 @@ XYWnd::XYWnd() : m_entityCreate = false; - m_mnuDrop = 0; + m_mnuDrop = ui::Menu(ui::null); GlobalWindowObservers_add( m_window_observer ); GlobalWindowObservers_connectWidget( m_gl_widget ); @@ -826,20 +828,20 @@ XYWnd::XYWnd() : m_window_observer->setRectangleDrawCallback( ReferenceCaller1( *this ) ); m_window_observer->setView( m_view ); - gtk_widget_ref( m_gl_widget ); + g_object_ref( m_gl_widget._handle ); gtk_widget_set_events( m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK ); - GTK_WIDGET_SET_FLAGS( m_gl_widget, GTK_CAN_FOCUS ); + gtk_widget_set_can_focus( m_gl_widget, true ); - m_sizeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "size_allocate", G_CALLBACK( xywnd_size_allocate ), this ); - m_exposeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "expose_event", G_CALLBACK( xywnd_expose ), this ); + m_sizeHandler = m_gl_widget.connect( "size_allocate", G_CALLBACK( xywnd_size_allocate ), this ); + m_exposeHandler = m_gl_widget.on_render( G_CALLBACK( xywnd_expose ), this ); - g_signal_connect( G_OBJECT( m_gl_widget ), "button_press_event", G_CALLBACK( xywnd_button_press ), this ); - g_signal_connect( G_OBJECT( m_gl_widget ), "button_release_event", G_CALLBACK( xywnd_button_release ), this ); - g_signal_connect( G_OBJECT( m_gl_widget ), "focus_in_event", G_CALLBACK( xywnd_focus_in ), this ); - g_signal_connect( G_OBJECT( m_gl_widget ), "motion_notify_event", G_CALLBACK( DeferredMotion::gtk_motion ), &m_deferred_motion ); + m_gl_widget.connect( "button_press_event", G_CALLBACK( xywnd_button_press ), this ); + m_gl_widget.connect( "button_release_event", G_CALLBACK( xywnd_button_release ), this ); + m_gl_widget.connect( "focus_in_event", G_CALLBACK( xywnd_focus_in ), this ); + m_gl_widget.connect( "motion_notify_event", G_CALLBACK( DeferredMotion::gtk_motion ), &m_deferred_motion ); - g_signal_connect( G_OBJECT( m_gl_widget ), "scroll_event", G_CALLBACK( xywnd_wheel_scroll ), this ); + m_gl_widget.connect( "scroll_event", G_CALLBACK( xywnd_wheel_scroll ), this ); Map_addValidCallback( g_map, DeferredDrawOnMapValidChangedCaller( m_deferredDraw ) ); @@ -857,15 +859,15 @@ XYWnd::XYWnd() : XYWnd::~XYWnd(){ onDestroyed(); - if ( m_mnuDrop != 0 ) { + if ( m_mnuDrop ) { gtk_widget_destroy( GTK_WIDGET( m_mnuDrop ) ); - m_mnuDrop = 0; + m_mnuDrop = ui::Menu(ui::null); } g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_sizeHandler ); g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_exposeHandler ); - gtk_widget_unref( m_gl_widget ); + m_gl_widget.unref(); m_window_observer->release(); } @@ -944,12 +946,12 @@ void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){ if ( ClipMode() && GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ) != 0 ) { GdkCursor *cursor; cursor = gdk_cursor_new( GDK_CROSSHAIR ); - gdk_window_set_cursor( m_gl_widget->window, cursor ); + gdk_window_set_cursor( gtk_widget_get_window(m_gl_widget), cursor ); gdk_cursor_unref( cursor ); } else { - gdk_window_set_cursor( m_gl_widget->window, 0 ); + gdk_window_set_cursor( gtk_widget_get_window(m_gl_widget), 0 ); } } @@ -1058,15 +1060,15 @@ void XYWnd::NewBrushDrag( int x, int y ){ "textures/common/caulk" : TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) ); } -void entitycreate_activated( GtkWidget* item ){ +void entitycreate_activated( ui::Widget item ){ scene::Node* world_node = Map_FindWorldspawn( g_map ); - const char* entity_name = gtk_label_get_text( GTK_LABEL( GTK_BIN( item )->child ) ); + const char* entity_name = gtk_label_get_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN( item )) ) ); if ( !( world_node && string_equal( entity_name, "worldspawn" ) ) ) { g_pParentWnd->ActiveXY()->OnEntityCreate( entity_name ); } else { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( MainFrame_getWindow() ), "There's already a worldspawn in your map!" + GlobalRadiant().m_pfnMessageBox( MainFrame_getWindow(), "There's already a worldspawn in your map!" "", "Info", eMB_OK, @@ -1074,21 +1076,21 @@ void entitycreate_activated( GtkWidget* item ){ } } -void EntityClassMenu_addItem( GtkMenu* menu, const char* name ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_label( name ) ); - g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( entitycreate_activated ), item ); - gtk_widget_show( GTK_WIDGET( item ) ); +void EntityClassMenu_addItem( ui::Menu menu, const char* name ){ + auto item = ui::MenuItem( name ); + item.connect( "activate", G_CALLBACK( entitycreate_activated ), item ); + item.show(); menu_add_item( menu, item ); } class EntityClassMenuInserter : public EntityClassVisitor { -typedef std::pair MenuPair; +typedef std::pair MenuPair; typedef std::vector MenuStack; MenuStack m_stack; CopiedString m_previous; public: -EntityClassMenuInserter( GtkMenu* menu ){ +EntityClassMenuInserter( ui::Menu menu ){ m_stack.reserve( 2 ); m_stack.push_back( MenuPair( menu, "" ) ); } @@ -1105,11 +1107,11 @@ void visit( EntityClass* e ){ m_previous = e->name(); } void pushMenu( const CopiedString& name ){ - GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_label( name.c_str() ) ); - gtk_widget_show( GTK_WIDGET( item ) ); - container_add_widget( GTK_CONTAINER( m_stack.back().first ), GTK_WIDGET( item ) ); + auto item = ui::MenuItem( name.c_str() ); + item.show(); + m_stack.back().first.add(item); - GtkMenu* submenu = GTK_MENU( gtk_menu_new() ); + auto submenu = ui::Menu(); gtk_menu_item_set_submenu( item, GTK_WIDGET( submenu ) ); m_stack.push_back( MenuPair( submenu, name ) ); @@ -1151,8 +1153,8 @@ void XYWnd::OnContextMenu(){ return; } - if ( m_mnuDrop == 0 ) { // first time, load it up - GtkMenu* menu = m_mnuDrop = GTK_MENU( gtk_menu_new() ); + if ( !m_mnuDrop ) { // first time, load it up + auto menu = m_mnuDrop = ui::Menu(); EntityClassMenuInserter inserter( menu ); GlobalEntityClassManager().forEach( inserter ); @@ -1172,7 +1174,7 @@ void XYWnd_moveDelta( int x, int y, unsigned int state, void* data ){ reinterpret_cast( data )->Scroll( -x, y ); } -gboolean XYWnd_Move_focusOut( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){ +gboolean XYWnd_Move_focusOut( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){ xywnd->Move_End(); return FALSE; } @@ -1182,13 +1184,13 @@ void XYWnd::Move_Begin(){ Move_End(); } m_move_started = true; - g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), XYWnd_moveDelta, this ); - m_move_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this ); + g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), XYWnd_moveDelta, this ); + m_move_focusOut = m_gl_widget.connect( "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this ); } void XYWnd::Move_End(){ m_move_started = false; - g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow() ); + g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow() ); g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_move_focusOut ); } @@ -1217,7 +1219,7 @@ void XYWnd_zoomDelta( int x, int y, unsigned int state, void* data ){ } } -gboolean XYWnd_Zoom_focusOut( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){ +gboolean XYWnd_Zoom_focusOut( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){ xywnd->Zoom_End(); return FALSE; } @@ -1228,13 +1230,13 @@ void XYWnd::Zoom_Begin(){ } m_zoom_started = true; g_dragZoom = 0; - g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), XYWnd_zoomDelta, this ); - m_zoom_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this ); + g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), XYWnd_zoomDelta, this ); + m_zoom_focusOut = m_gl_widget.connect( "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this ); } void XYWnd::Zoom_End(){ m_zoom_started = false; - g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow() ); + g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow() ); g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_zoom_focusOut ); } @@ -1255,7 +1257,7 @@ void XYWnd::SetViewType( VIEWTYPE viewType ){ m_viewType = viewType; updateModelview(); - if ( m_parent != 0 ) { + if ( m_parent ) { gtk_window_set_title( m_parent, ViewType_getTitle( m_viewType ) ); } } @@ -1485,12 +1487,12 @@ void XYWnd::XY_DisableBackground( void ){ void WXY_BackgroundSelect( void ){ bool brushesSelected = Scene_countSelectedBrushes( GlobalSceneGraph() ) != 0; if ( !brushesSelected ) { - gtk_MessageBox( 0, "You have to select some brushes to get the bounding box for.\n", - "No selection", eMB_OK, eMB_ICONERROR ); + ui::root.alert( "You have to select some brushes to get the bounding box for.\n", + "No selection", ui::alert_type::OK, ui::alert_icon::Error ); return; } - const char *filename = file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, "Background Image", NULL, NULL ); + const char *filename = MainFrame_getWindow().file_dialog( TRUE, "Background Image", NULL, NULL ); g_pParentWnd->ActiveXY()->XY_DisableBackground(); if ( filename ) { g_pParentWnd->ActiveXY()->XY_LoadBackgroundImage( filename ); @@ -2537,20 +2539,20 @@ void ToggleShowGrid(){ ToggleShown g_xy_top_shown( true ); -void XY_Top_Shown_Construct( GtkWindow* parent ){ - g_xy_top_shown.connect( GTK_WIDGET( parent ) ); +void XY_Top_Shown_Construct( ui::Window parent ){ + g_xy_top_shown.connect( parent ); } ToggleShown g_yz_side_shown( false ); -void YZ_Side_Shown_Construct( GtkWindow* parent ){ - g_yz_side_shown.connect( GTK_WIDGET( parent ) ); +void YZ_Side_Shown_Construct( ui::Window parent ){ + g_yz_side_shown.connect( parent ); } ToggleShown g_xz_front_shown( false ); -void XZ_Front_Shown_Construct( GtkWindow* parent ){ - g_xz_front_shown.connect( GTK_WIDGET( parent ) ); +void XZ_Front_Shown_Construct( ui::Window parent ){ + g_xz_front_shown.connect( parent ); } @@ -2566,9 +2568,9 @@ void realise(){ } void unrealise(){ if ( ++m_unrealised == 1 ) { - if ( XYWnd::m_mnuDrop != 0 ) { + if ( XYWnd::m_mnuDrop ) { gtk_widget_destroy( GTK_WIDGET( XYWnd::m_mnuDrop ) ); - XYWnd::m_mnuDrop = 0; + XYWnd::m_mnuDrop = ui::Menu(ui::null); } } } @@ -2744,14 +2746,14 @@ void XYWindow_Construct(){ GlobalToggles_insert( "ToggleView", ToggleShown::ToggleCaller( g_xy_top_shown ), ToggleItem::AddCallbackCaller( g_xy_top_shown.m_item ), Accelerator( 'V', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalToggles_insert( "ToggleSideView", ToggleShown::ToggleCaller( g_yz_side_shown ), ToggleItem::AddCallbackCaller( g_yz_side_shown.m_item ) ); GlobalToggles_insert( "ToggleFrontView", ToggleShown::ToggleCaller( g_xz_front_shown ), ToggleItem::AddCallbackCaller( g_xz_front_shown.m_item ) ); - GlobalCommands_insert( "NextView", FreeCaller(), Accelerator( GDK_Tab, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "ZoomIn", FreeCaller(), Accelerator( GDK_Delete ) ); - GlobalCommands_insert( "ZoomOut", FreeCaller(), Accelerator( GDK_Insert ) ); - GlobalCommands_insert( "ViewTop", FreeCaller(), Accelerator( GDK_KP_Home ) ); - GlobalCommands_insert( "ViewSide", FreeCaller(), Accelerator( GDK_KP_Page_Down ) ); - GlobalCommands_insert( "ViewFront", FreeCaller(), Accelerator( GDK_KP_End ) ); + GlobalCommands_insert( "NextView", FreeCaller(), Accelerator( GDK_KEY_Tab, (GdkModifierType)GDK_CONTROL_MASK ) ); // fixme: doesn't show its shortcut + GlobalCommands_insert( "ZoomIn", FreeCaller(), Accelerator( GDK_KEY_Delete ) ); + GlobalCommands_insert( "ZoomOut", FreeCaller(), Accelerator( GDK_KEY_Insert ) ); + GlobalCommands_insert( "ViewTop", FreeCaller(), Accelerator( GDK_KEY_KP_Home ) ); + GlobalCommands_insert( "ViewSide", FreeCaller(), Accelerator( GDK_KEY_KP_Page_Down ) ); + GlobalCommands_insert( "ViewFront", FreeCaller(), Accelerator( GDK_KEY_KP_End ) ); GlobalCommands_insert( "Zoom100", FreeCaller() ); - GlobalCommands_insert( "CenterXYView", FreeCaller(), Accelerator( GDK_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "CenterXYView", FreeCaller(), Accelerator( GDK_KEY_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalPreferenceSystem().registerPreference( "ClipCaulk", BoolImportStringCaller( g_clip_useCaulk ), BoolExportStringCaller( g_clip_useCaulk ) ); diff --git a/radiant/xywindow.h b/radiant/xywindow.h index cbf37b43..cfe8f036 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -40,8 +40,6 @@ namespace scene { class Node; } -typedef struct _GtkWindow GtkWindow; -typedef struct _GtkMenu GtkMenu; void FlipClip(); @@ -65,21 +63,21 @@ inline const char* ViewType_getTitle( VIEWTYPE viewtype ){ class XYWnd { -GtkWidget* m_gl_widget; +ui::GLArea m_gl_widget; guint m_sizeHandler; guint m_exposeHandler; DeferredDraw m_deferredDraw; DeferredMotion m_deferred_motion; public: -GtkWindow* m_parent; +ui::Window m_parent; XYWnd(); ~XYWnd(); void queueDraw(){ m_deferredDraw.draw(); } -GtkWidget* GetWidget(){ +ui::GLArea GetWidget(){ return m_gl_widget; } @@ -142,7 +140,7 @@ void DropClipPoint( int pointx, int pointy ); void SetViewType( VIEWTYPE n ); bool m_bActive; -static GtkMenu* m_mnuDrop; +static ui::Menu m_mnuDrop; int m_chasemouse_current_x, m_chasemouse_current_y; int m_chasemouse_delta_x, m_chasemouse_delta_y; @@ -281,10 +279,9 @@ extern xywindow_globals_t g_xywindow_globals; VIEWTYPE GlobalXYWnd_getCurrentViewType(); -typedef struct _GtkWindow GtkWindow; -void XY_Top_Shown_Construct( GtkWindow* parent ); -void YZ_Side_Shown_Construct( GtkWindow* parent ); -void XZ_Front_Shown_Construct( GtkWindow* parent ); +void XY_Top_Shown_Construct( ui::Window parent ); +void YZ_Side_Shown_Construct( ui::Window parent ); +void XZ_Front_Shown_Construct( ui::Window parent ); void XYWindow_Construct(); void XYWindow_Destroy(); diff --git a/tools/quake3/common/vfs.c b/tools/quake3/common/vfs.c index 0c3ca69f..775f9bd0 100644 --- a/tools/quake3/common/vfs.c +++ b/tools/quake3/common/vfs.c @@ -51,6 +51,7 @@ #include "inout.h" #include "vfs.h" #include +#include typedef struct { diff --git a/tools/quake3/common/vfs.h b/tools/quake3/common/vfs.h index 51ac6ddd..7c4a4464 100644 --- a/tools/quake3/common/vfs.h +++ b/tools/quake3/common/vfs.h @@ -43,7 +43,6 @@ #define S_ISDIR( mode ) ( mode & _S_IFDIR ) #define PATH_MAX 260 #endif -#include #define VFS_MAXDIRS 64 diff --git a/tools/quake3/q3map2/lightmaps_ydnar.c b/tools/quake3/q3map2/lightmaps_ydnar.c index 83f0776d..c437bcaf 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -35,7 +35,7 @@ /* dependencies */ #include "q3map2.h" - +#include diff --git a/tools/quake3/q3map2/main.c b/tools/quake3/q3map2/main.c index 2710128b..85f2f491 100644 --- a/tools/quake3/q3map2/main.c +++ b/tools/quake3/q3map2/main.c @@ -35,7 +35,7 @@ /* dependencies */ #include "q3map2.h" - +#include /*