From: TimePath Date: Fri, 21 Jul 2017 15:41:45 +0000 (+1000) Subject: Wrap gtkutil/toolbar X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=63e6d1aae2ebee29a076b463d055995f64454967;p=xonotic%2Fnetradiant.git Wrap gtkutil/toolbar --- diff --git a/libs/gtkutil/toolbar.cpp b/libs/gtkutil/toolbar.cpp index 2f7cf5ff..85e371ad 100644 --- a/libs/gtkutil/toolbar.cpp +++ b/libs/gtkutil/toolbar.cpp @@ -30,20 +30,20 @@ #include "image.h" -void toolbar_append( GtkToolbar* toolbar, GtkToolItem* button, const char* description ){ +void toolbar_append( ui::Toolbar toolbar, GtkToolItem* button, const char* description ){ gtk_widget_show_all(GTK_WIDGET(button)); gtk_widget_set_tooltip_text(GTK_WIDGET(button), description); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); } -ui::ToolButton toolbar_append_button( GtkToolbar* 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 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, GTK_TOOL_ITEM(button), description); return button; } -ui::ToggleToolButton toolbar_append_toggle_button( GtkToolbar* 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 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))); @@ -52,7 +52,7 @@ ui::ToggleToolButton toolbar_append_toggle_button( GtkToolbar* toolbar, const ch return button; } -ui::ToolButton 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 ); } @@ -61,7 +61,7 @@ void toggle_button_set_active_callback( GtkToggleToolButton& button, bool active } using ToggleButtonSetActiveCaller = ReferenceCaller1; -ui::ToggleToolButton toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ){ +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_ ) ); diff --git a/libs/gtkutil/toolbar.h b/libs/gtkutil/toolbar.h index 421e20a5..993314fb 100644 --- a/libs/gtkutil/toolbar.h +++ b/libs/gtkutil/toolbar.h @@ -26,15 +26,12 @@ #include #include "generic/callbackfwd.h" -typedef struct _GtkButton GtkButton; -typedef struct _GtkToggleButton GtkToggleButton; -typedef struct _GtkToolbar GtkToolbar; class Command; class Toggle; -ui::ToolButton toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ); -ui::ToolButton toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ); -ui::ToggleToolButton toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ); -ui::ToggleToolButton 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/uilib/uilib.h b/libs/uilib/uilib.h index 39fd8006..70ae9a07 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -48,6 +48,7 @@ struct _GtkTearoffMenuItem; struct _GtkTextView; struct _GtkToggleButton; struct _GtkToggleToolButton; +struct _GtkToolbar; struct _GtkToolButton; struct _GtkToolItem; struct _GtkTreeModel; @@ -381,6 +382,10 @@ namespace ui { , ); + WRAP(Toolbar, Widget, _GtkToolbar, (), + , + ); + class TreeModel; WRAP(TreeView, Widget, _GtkTreeView, (), TreeView(); diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index b047b8b5..97d5fc1c 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -1666,7 +1666,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" ); } diff --git a/radiant/camwindow.h b/radiant/camwindow.h index 5040e51c..7f802970 100644 --- a/radiant/camwindow.h +++ b/radiant/camwindow.h @@ -41,7 +41,7 @@ void GlobalCamera_setCamWnd( CamWnd& camwnd ); void fill_view_camera_menu( ui::Menu menu ); typedef struct _GtkToolbar GtkToolbar; -void CamWnd_constructToolbar( GtkToolbar* toolbar ); +void CamWnd_constructToolbar( ui::Toolbar toolbar ); void CamWnd_registerShortcuts(); void GlobalCamera_Benchmark(); diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index fc14013b..d124e06b 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -86,11 +86,11 @@ GtkMenuItem* create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic return create_menu_item_with_mnemonic( menu, mnemonic, command ); } -GtkToolButton* 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 ) ); } -GtkToggleToolButton* 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 ) ); } diff --git a/radiant/gtkmisc.h b/radiant/gtkmisc.h index 3bdfff7a..1de1aa4a 100644 --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@ -60,9 +60,9 @@ typedef struct _GtkToggleButton GtkToggleButton; typedef struct _GtkToolbar GtkToolbar; // this DOES NOT set up the shortcut using command_connect_accelerator -GtkToolButton* 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 -GtkToggleToolButton* 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; diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 21493fff..c1de6670 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -2265,17 +2265,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" ); @@ -2284,33 +2284,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" ); @@ -2319,8 +2319,8 @@ void Manipulators_constructToolbar( GtkToolbar* toolbar ){ Clipper_constructToolbar( toolbar ); } -GtkToolbar* create_main_toolbar( MainFrame::EViewStyle style ){ - GtkToolbar* toolbar = GTK_TOOLBAR( gtk_toolbar_new() ); +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 ); diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 851e384b..c2a8b627 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -744,7 +744,7 @@ 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" ); } diff --git a/radiant/patchmanip.h b/radiant/patchmanip.h index 5227fb10..512a3f95 100644 --- a/radiant/patchmanip.h +++ b/radiant/patchmanip.h @@ -26,9 +26,7 @@ #include "string/stringfwd.h" void Patch_registerCommands(); -typedef struct _GtkToolbar GtkToolbar; -typedef struct _GtkMenu GtkMenu; -void Patch_constructToolbar( GtkToolbar* toolbar ); +void Patch_constructToolbar( ui::Toolbar toolbar ); void Patch_constructMenu( ui::Menu menu ); namespace scene