void Update_TextureReseter();
-static void dialog_button_callback_texreset_update( GtkWidget *widget, gpointer data ){
+static void dialog_button_callback_texreset_update(ui::Widget widget, gpointer data ){
Update_TextureReseter();
}
return TRUE;
}
-static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){
+static void dialog_button_callback_settex(ui::Widget widget, gpointer data ){
TwinWidget* tw = (TwinWidget*)data;
- GtkEntry* entry = GTK_ENTRY( tw->one );
- auto* combo = GTK_BIN(tw->two);
+ auto entry = ui::Entry::from( tw->one );
+ auto combo = tw->two;
const gchar *tex = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(combo)));
gtk_entry_set_text( entry, tex );
gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
w.show();
- w = ui::Widget(gtk_hseparator_new());
+ w = ui::Widget::from(gtk_hseparator_new());
vbox.pack_start( w, FALSE, FALSE, 2 );
w.show();
// ---- vbox ----
- auto radio1 = ui::Widget(gtk_radio_button_new_with_label( NULL, "Use Whole Map" ));
+ auto radio1 = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Use Whole Map" ));
vbox.pack_start( radio1, FALSE, FALSE, 2 );
radio1.show();
- auto radio2 = ui::Widget(gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" ));
+ auto radio2 = ui::Widget::from(gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" ));
vbox.pack_start( radio2, FALSE, FALSE, 2 );
radio2.show();
- auto hsep = ui::Widget(gtk_hseparator_new());
+ auto hsep = ui::Widget::from(gtk_hseparator_new());
vbox.pack_start( hsep, FALSE, FALSE, 2 );
hsep.show();
// ---- hbox2 ----
auto text1 = ui::Entry( 256 );
- gtk_entry_set_text( (GtkEntry*)text1, "3" );
+ gtk_entry_set_text( text1, "3" );
hbox2.pack_start( text1, FALSE, FALSE, 2 );
text1.show();
// ---- hbox2 ----
auto text2 = ui::Entry( 256 );
- gtk_entry_set_text( (GtkEntry*)text2, "8" );
+ gtk_entry_set_text( text2, "8" );
hbox2.pack_start( text2, FALSE, FALSE, 2 );
text2.show();
rs->bInverse = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check2) ) ? true : false;
rs->bAlignTop = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check3) ) ? true : false;
- if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
+ if ( !ValidateTextIntRange( gtk_entry_get_text( text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
dialogError = TRUE;
}
if ( rs->bUseBorder ) {
- if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) {
+ if ( !ValidateTextIntRange( gtk_entry_get_text( text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) {
dialogError = TRUE;
}
}
hbox.pack_start( w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ...
w.show();
- w = ui::Widget(gtk_hseparator_new());
+ w = ui::Widget::from(gtk_hseparator_new());
vbox.pack_start( w, FALSE, FALSE, 0 );
w.show();
// djbob: actually it looks very nice :), slightly better than the way i did it
// edit: actually it doesn't work :P, you must pass the last radio item each time, ugh
- auto radioNorth = ui::Widget(gtk_radio_button_new_with_label( NULL, "North" ));
+ auto radioNorth = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North" ));
hbox.pack_start( radioNorth, FALSE, FALSE, 3 );
radioNorth.show();
radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNorth ) );
- auto radioSouth = ui::Widget(gtk_radio_button_new_with_label( radioDirection, "South" ));
+ auto radioSouth = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "South" ));
hbox.pack_start( radioSouth, FALSE, FALSE, 2 );
radioSouth.show();
radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioSouth ) );
- auto radioEast = ui::Widget(gtk_radio_button_new_with_label( radioDirection, "East" ));
+ auto radioEast = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "East" ));
hbox.pack_start( radioEast, FALSE, FALSE, 1 );
radioEast.show();
radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioEast ) );
- auto radioWest = ui::Widget(gtk_radio_button_new_with_label( radioDirection, "West" ));
+ auto radioWest = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "West" ));
hbox.pack_start( radioWest, FALSE, FALSE, 0 );
radioWest.show();
vbox.pack_start( hbox, FALSE, FALSE, 0 );
hbox.show();
- auto radioOldStyle = ui::Widget(gtk_radio_button_new_with_label( NULL, "Original" ));
+ auto radioOldStyle = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Original" ));
hbox.pack_start( radioOldStyle, FALSE, FALSE, 0 );
radioOldStyle.show();
radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioOldStyle ) );
- auto radioBobStyle = ui::Widget(gtk_radio_button_new_with_label( radioStyle, "Bob's Style" ));
+ auto radioBobStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Bob's Style" ));
hbox.pack_start( radioBobStyle, FALSE, FALSE, 0 );
radioBobStyle.show();
radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioBobStyle ) );
- auto radioCornerStyle = ui::Widget(gtk_radio_button_new_with_label( radioStyle, "Corner Style" ));
+ auto radioCornerStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Corner Style" ));
hbox.pack_start( radioCornerStyle, FALSE, FALSE, 0 );
radioCornerStyle.show();
w.show();
// -------------------------- //
- w = ui::Widget(gtk_hseparator_new());
+ w = ui::Widget::from(gtk_hseparator_new());
vbox.pack_start( w, FALSE, FALSE, 0 );
w.show();
if ( ret == eIDOK ) {
rs->bUseDetail = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(checkUseDetail) ) ? true : false;
- strcpy( rs->riserTexture, gtk_entry_get_text( (GtkEntry*)textRiserTex ) );
- strcpy( rs->mainTexture, gtk_entry_get_text( (GtkEntry*)textMainTex ) );
+ strcpy( rs->riserTexture, gtk_entry_get_text( textRiserTex ) );
+ strcpy( rs->mainTexture, gtk_entry_get_text( textMainTex ) );
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioNorth) ) ) {
rs->direction = MOVE_NORTH;
rs->direction = MOVE_WEST;
}
- if ( !ValidateTextInt( gtk_entry_get_text( (GtkEntry*)textStairHeight ), "Stair Height", &rs->stairHeight ) ) {
+ if ( !ValidateTextInt( gtk_entry_get_text( textStairHeight ), "Stair Height", &rs->stairHeight ) ) {
dialogError = TRUE;
}
gtk_widget_realize( window );
char buffer[256];
- 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 ));
+ auto listMainTextures = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
+ auto listTrimTextures = ui::ListStore::from(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 );
// djbob: lists added
- auto comboMain = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(listMainTextures)));
+ auto comboMain = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listMainTextures));
gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
hbox.pack_start( comboMain, FALSE, FALSE, 0 );
comboMain.show();
vbox.pack_start( hbox, FALSE, FALSE, 0 );
hbox.show();
- auto comboTrim = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(listTrimTextures)));
+ auto comboTrim = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listTrimTextures));
gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
hbox.pack_start( comboTrim, FALSE, FALSE, 0 );
comboTrim.show();
w.show();
// argh more radio buttons!
- auto radioNS = ui::Widget(gtk_radio_button_new_with_label( NULL, "North - South" ));
+ auto radioNS = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North - South" ));
hbox.pack_start( radioNS, FALSE, FALSE, 0 );
radioNS.show();
radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) );
- auto radioEW = ui::Widget(gtk_radio_button_new_with_label( radioOrientation, "East - West" ));
+ auto radioEW = ui::Widget::from(gtk_radio_button_new_with_label( radioOrientation, "East - West" ));
hbox.pack_start( radioEW, FALSE, FALSE, 0 );
radioEW.show();
// ----------------- //
- w = ui::Widget(gtk_hseparator_new());
+ w = ui::Widget::from(gtk_hseparator_new());
vbox.pack_start( w, FALSE, FALSE, 0 );
w.show();
// ---- /hbox ----
- w = ui::Widget(gtk_hseparator_new());
+ w = ui::Widget::from(gtk_hseparator_new());
vbox.pack_start( w, FALSE, FALSE, 0 );
w.show();
// ----------------- //
- w = ui::Widget(gtk_hseparator_new());
+ w = ui::Widget::from(gtk_hseparator_new());
vbox.pack_start( w, FALSE, FALSE, 0 );
w.show();
hbox.pack_start( w, FALSE, FALSE, 0 );
w.show();
- w = ui::Widget(gtk_hseparator_new());
+ w = ui::Widget::from(gtk_hseparator_new());
vbox.pack_start( w, FALSE, FALSE, 0 );
w.show();
// collapse mode
collapsemode mode = COLLAPSE_NONE;
- GtkWidget* radio = lookup_widget( button , "r_collapse" );
- ASSERT_NOTNULL( radio );
+ auto radio = lookup_widget( button , "r_collapse" );
+ ASSERT_TRUE( radio );
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ) {
mode = COLLAPSE_ALL;
else
{
radio = lookup_widget( button , "r_collapsebymaterial" );
- ASSERT_NOTNULL( radio );
+ ASSERT_TRUE( radio );
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ) {
mode = COLLAPSE_BY_MATERIAL;
}
else
{
radio = lookup_widget( button , "r_nocollapse" );
- ASSERT_NOTNULL( radio );
+ ASSERT_TRUE( radio );
ASSERT_TRUE( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) );
mode = COLLAPSE_NONE;
}
}
// export materials?
- GtkWidget* toggle = lookup_widget( button , "t_exportmaterials" );
- ASSERT_NOTNULL( toggle );
+ auto toggle = lookup_widget( button , "t_exportmaterials" );
+ ASSERT_TRUE( toggle );
bool exportmat = FALSE;
// limit material names?
toggle = lookup_widget( button , "t_limitmatnames" );
- ASSERT_NOTNULL( toggle );
+ ASSERT_TRUE( toggle );
bool limitMatNames = FALSE;
// create objects instead of groups?
toggle = lookup_widget( button , "t_objects" );
- ASSERT_NOTNULL( toggle );
+ ASSERT_TRUE( toggle );
bool objects = FALSE;
}
void OnAddMaterial( ui::Button button, gpointer user_data ){
- GtkEntry* edit = GTK_ENTRY( lookup_widget( button , "ed_materialname" ) );
- ASSERT_NOTNULL( edit );
+ auto edit = ui::Entry::from( lookup_widget( button , "ed_materialname" ) );
+ ASSERT_TRUE( edit );
const gchar* name = gtk_entry_get_text( edit );
if ( g_utf8_strlen( name, -1 ) > 0 ) {
}
void OnRemoveMaterial( ui::Button button, gpointer user_data ){
- GtkTreeView* view = ui::TreeView::from(lookup_widget(button, "t_materialist"));
+ ui::TreeView view = ui::TreeView::from(lookup_widget(button, "t_materialist"));
ui::ListStore list = ui::ListStore::from( gtk_tree_view_get_model( view ) );
- GtkTreeSelection* sel = gtk_tree_view_get_selection( view );
+ auto sel = ui::TreeSelection::from(gtk_tree_view_get_selection( view ));
GtkTreeIter iter;
if ( gtk_tree_selection_get_selected( sel, 0, &iter ) ) {
}
void OnExportMatClicked( ui::Button button, gpointer user_data ){
- GtkWidget* toggleLimit = lookup_widget( button , "t_limitmatnames" );
- GtkWidget* toggleObject = lookup_widget( button , "t_objects" );
+ ui::Widget toggleLimit = lookup_widget( button , "t_limitmatnames" );
+ ui::Widget toggleObject = lookup_widget( button , "t_objects" );
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ) ) ) {
gtk_widget_set_sensitive( toggleLimit , TRUE );
g_object_set_data( G_OBJECT( component ), name, (void *) widget )
// created by glade
-GtkWidget*
-create_w_plugplug2( void ){
+ui::Widget create_w_plugplug2( void ){
GSList *r_collapse_group = NULL;
auto w_plugplug2 = ui::Window( ui::window_type::TOP );
vbox4.show();
hbox2.pack_start( vbox4, TRUE, FALSE, 0 );
- auto r_collapse = ui::Widget(gtk_radio_button_new_with_mnemonic( NULL, "Collapse mesh" ));
+ auto r_collapse = ui::Widget::from(gtk_radio_button_new_with_mnemonic( NULL, "Collapse mesh" ));
gtk_widget_set_name( r_collapse, "r_collapse" );
gtk_widget_set_tooltip_text(r_collapse, "Collapse all brushes into a single group");
r_collapse.show();
gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_collapse ), r_collapse_group );
r_collapse_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( r_collapse ) );
- auto r_collapsebymaterial = ui::Widget(gtk_radio_button_new_with_mnemonic( NULL, "Collapse by material" ));
+ auto r_collapsebymaterial = ui::Widget::from(gtk_radio_button_new_with_mnemonic( NULL, "Collapse by material" ));
gtk_widget_set_name( r_collapsebymaterial, "r_collapsebymaterial" );
gtk_widget_set_tooltip_text(r_collapsebymaterial, "Collapse into groups by material");
r_collapsebymaterial.show();
gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_collapsebymaterial ), r_collapse_group );
r_collapse_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( r_collapsebymaterial ) );
- auto r_nocollapse = ui::Widget(gtk_radio_button_new_with_mnemonic( NULL, "Don't collapse" ));
+ auto r_nocollapse = ui::Widget::from(gtk_radio_button_new_with_mnemonic( NULL, "Don't collapse" ));
gtk_widget_set_name( r_nocollapse, "r_nocollapse" );
gtk_widget_set_tooltip_text(r_nocollapse, "Every brush is stored in its own group");
r_nocollapse.show();
vbox3.show();
hbox2.pack_start( vbox3, FALSE, FALSE, 0 );
- auto b_export = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-save" )));
+ auto b_export = ui::Button::from(gtk_button_new_from_stock( "gtk-save" ));
gtk_widget_set_name( b_export, "b_export" );
b_export.show();
vbox3.pack_start( b_export, TRUE, FALSE, 0 );
gtk_container_set_border_width( GTK_CONTAINER( b_export ), 5 );
- auto b_close = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-cancel" )));
+ auto b_close = ui::Button::from(gtk_button_new_from_stock( "gtk-cancel" ));
gtk_widget_set_name( b_close, "b_close" );
b_close.show();
vbox3.pack_start( b_close, TRUE, FALSE, 0 );
hbox1.show();
vbox2.pack_start( hbox1, FALSE, FALSE, 0 );
- auto b_addmaterial = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-add" )));
+ auto b_addmaterial = ui::Button::from(gtk_button_new_from_stock( "gtk-add" ));
gtk_widget_set_name( b_addmaterial, "b_addmaterial" );
b_addmaterial.show();
hbox1.pack_start( b_addmaterial, FALSE, FALSE, 0 );
- auto b_removematerial = ui::Button(GTK_BUTTON(gtk_button_new_from_stock( "gtk-remove" )));
+ auto b_removematerial = ui::Button::from(gtk_button_new_from_stock( "gtk-remove" ));
gtk_widget_set_name( b_removematerial, "b_removematerial" );
b_removematerial.show();
hbox1.pack_start( b_removematerial, FALSE, FALSE, 0 );
- auto t_limitmatnames = ui::Widget(gtk_check_button_new_with_mnemonic( "Use short material names (max. 20 chars)" ));
+ auto t_limitmatnames = ui::Widget::from(gtk_check_button_new_with_mnemonic( "Use short material names (max. 20 chars)" ));
gtk_widget_set_name( t_limitmatnames, "t_limitmatnames" );
t_limitmatnames.show();
vbox2.pack_end( t_limitmatnames, FALSE, FALSE, 0 );
- auto t_objects = ui::Widget(gtk_check_button_new_with_mnemonic( "Create (o)bjects instead of (g)roups" ));
+ auto t_objects = ui::Widget::from(gtk_check_button_new_with_mnemonic( "Create (o)bjects instead of (g)roups" ));
gtk_widget_set_name( t_objects, "t_objects" );
t_objects.show();
vbox2.pack_end(t_objects, FALSE, FALSE, 0);
- auto t_exportmaterials = ui::CheckButton(GTK_CHECK_BUTTON(gtk_check_button_new_with_mnemonic( "Create material information (.mtl file)" )));
+ auto t_exportmaterials = ui::CheckButton::from(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" );
t_exportmaterials.show();
}
// global main window, is 0 when not created
-GtkWidget* g_brushexp_window = 0;
+ui::Widget g_brushexp_window{ui::null};
// spawn plugin window (and make sure it got destroyed first or never created)
void CreateWindow( void ){
ASSERT_TRUE( !g_brushexp_window );
- GtkWidget* wnd = create_w_plugplug2();
+ ui::Widget wnd = create_w_plugplug2();
// column & renderer
- GtkTreeViewColumn* col = gtk_tree_view_column_new();
+ auto col = ui::TreeViewColumn::from(gtk_tree_view_column_new());
gtk_tree_view_column_set_title( col, "materials" );
auto view = ui::TreeView::from(lookup_widget(wnd, "t_materialist"));
gtk_tree_view_append_column(view, col );
gtk_tree_view_insert_column_with_attributes(view, -1, "", renderer, "text", 0, NULL );
// list store
- ui::ListStore ignorelist = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
+ auto ignorelist = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
gtk_tree_view_set_model(view, ignorelist );
ignorelist.unref();
g_brushexp_window = wnd;
}
-void DestroyWindow( void ){
- ASSERT_NOTNULL( g_brushexp_window );
+void DestroyWindow(){
+ ASSERT_TRUE( g_brushexp_window );
ui::Widget(g_brushexp_window).destroy();
- g_brushexp_window = 0;
+ g_brushexp_window = ui::Widget(ui::null);
}
-bool IsWindowOpen( void ){
- return g_brushexp_window != 0;
+bool IsWindowOpen(){
+ return g_brushexp_window;
}
#include "support.h"
ui::Widget
-lookup_widget( GtkWidget *widget,
+lookup_widget(ui::Widget widget,
const gchar *widget_name ){
- GtkWidget *parent, *found_widget;
+ ui::Widget parent{ui::null};
for (;; )
{
if ( GTK_IS_MENU( widget ) ) {
- parent = gtk_menu_get_attach_widget( GTK_MENU( widget ) );
+ parent = ui::Widget::from(gtk_menu_get_attach_widget( GTK_MENU( widget ) ));
}
else{
- parent = gtk_widget_get_parent(widget);
+ parent = ui::Widget::from(gtk_widget_get_parent(widget));
}
if ( !parent ) {
- parent = (GtkWidget*) g_object_get_data( G_OBJECT( widget ), "GladeParentKey" );
+ parent = ui::Widget::from(g_object_get_data( G_OBJECT( widget ), "GladeParentKey" ));
}
if ( parent == NULL ) {
break;
widget = parent;
}
- found_widget = (GtkWidget*) g_object_get_data( G_OBJECT( widget ),
- widget_name );
+ auto found_widget = ui::Widget::from(g_object_get_data( G_OBJECT( widget ), widget_name ));
if ( !found_widget ) {
g_warning( "Widget not found: %s", widget_name );
}
- return ui::Widget(found_widget);
+ return found_widget;
}
* or alternatively any widget in the component, and the name of the widget
* you want returned.
*/
-ui::Widget lookup_widget( GtkWidget *widget,
+ui::Widget lookup_widget(ui::Widget widget,
const gchar *widget_name );
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" ));
+ auto dlg = ui::Widget::from(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 ) );
+ ui::Widget::from(ok_button).connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
+ ui::Widget::from(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 );
return ret;
}
-static void Set2DText( GtkWidget* label ){
+static void Set2DText(ui::Widget label ){
char s[40];
sprintf( s, "Line Width = %6.3f", portals.width_2d * 0.5f );
gtk_label_set_text( GTK_LABEL( label ), s );
}
-static void Set3DText( GtkWidget* label ){
+static void Set3DText(ui::Widget label ){
char s[40];
sprintf( s, "Line Width = %6.3f", portals.width_3d * 0.5f );
gtk_label_set_text( GTK_LABEL( label ), s );
}
-static void Set3DTransText( GtkWidget* label ){
+static void Set3DTransText(ui::Widget label ){
char s[40];
sprintf( s, "Polygon transparency = %d%%", (int)portals.trans_3d );
gtk_label_set_text( GTK_LABEL( label ), s );
}
-static void SetClipText( GtkWidget* label ){
+static void SetClipText(ui::Widget label ){
char s[40];
sprintf( s, "Cubic clip range = %d", (int)portals.clip_range * 64 );
gtk_label_set_text( GTK_LABEL( label ), s );
}
-static void OnScroll2d( GtkAdjustment *adj, gpointer data ){
+static void OnScroll2d(ui::Adjustment adj, gpointer data ){
portals.width_2d = static_cast<float>( gtk_adjustment_get_value(adj) );
Set2DText( ui::Widget::from(data) );
SceneChangeNotify();
}
-static void OnScroll3d( GtkAdjustment *adj, gpointer data ){
+static void OnScroll3d(ui::Adjustment adj, gpointer data ){
portals.width_3d = static_cast<float>( gtk_adjustment_get_value(adj) );
Set3DText( ui::Widget::from( data ) );
SceneChangeNotify();
}
-static void OnScrollTrans( GtkAdjustment *adj, gpointer data ){
+static void OnScrollTrans(ui::Adjustment adj, gpointer data ){
portals.trans_3d = static_cast<float>( gtk_adjustment_get_value(adj) );
Set3DTransText( ui::Widget::from( data ) );
SceneChangeNotify();
}
-static void OnScrollClip( GtkAdjustment *adj, gpointer data ){
+static void OnScrollClip(ui::Adjustment adj, gpointer data ){
portals.clip_range = static_cast<float>( gtk_adjustment_get_value(adj) );
SetClipText( ui::Widget::from( data ) );
SceneChangeNotify();
}
-static void OnAntiAlias2d( GtkWidget *widget, gpointer data ){
+static void OnAntiAlias2d(ui::Widget widget, gpointer data ){
portals.aa_2d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
Portals_shadersChanged();
SceneChangeNotify();
}
-static void OnConfig2d( GtkWidget *widget, gpointer data ){
+static void OnConfig2d(ui::Widget widget, gpointer data ){
portals.show_2d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
SceneChangeNotify();
}
-static void OnColor2d( GtkWidget *widget, gpointer data ){
+static void OnColor2d(ui::Widget widget, gpointer data ){
if ( DoColor( &portals.color_2d ) == IDOK ) {
Portals_shadersChanged();
}
}
-static void OnConfig3d( GtkWidget *widget, gpointer data ){
+static void OnConfig3d(ui::Widget widget, gpointer data ){
portals.show_3d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
SceneChangeNotify();
}
-static void OnAntiAlias3d( GtkWidget *widget, gpointer data ){
+static void OnAntiAlias3d(ui::Widget widget, gpointer data ){
portals.aa_3d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
Portals_shadersChanged();
SceneChangeNotify();
}
-static void OnColor3d( GtkWidget *widget, gpointer data ){
+static void OnColor3d(ui::Widget widget, gpointer data ){
if ( DoColor( &portals.color_3d ) == IDOK ) {
Portals_shadersChanged();
}
}
-static void OnColorFog( GtkWidget *widget, gpointer data ){
+static void OnColorFog(ui::Widget widget, gpointer data ){
if ( DoColor( &portals.color_fog ) == IDOK ) {
Portals_shadersChanged();
}
}
-static void OnFog( GtkWidget *widget, gpointer data ){
+static void OnFog(ui::Widget widget, gpointer data ){
portals.fog = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
Portals_shadersChanged();
SceneChangeNotify();
}
-static void OnSelchangeZbuffer( GtkWidget *widget, gpointer data ){
+static void OnSelchangeZbuffer(ui::Widget widget, gpointer data ){
portals.zbuffer = gpointer_to_int( data );
Portals_shadersChanged();
SceneChangeNotify();
}
-static void OnPoly( GtkWidget *widget, gpointer data ){
+static void OnPoly(ui::Widget widget, gpointer data ){
portals.polygons = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) );
SceneChangeNotify();
}
-static void OnLines( GtkWidget *widget, gpointer data ){
+static void OnLines(ui::Widget widget, gpointer data ){
portals.lines = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) );
SceneChangeNotify();
}
-static void OnClip( GtkWidget *widget, gpointer data ){
+static void OnClip(ui::Widget widget, gpointer data ){
portals.clip = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
SceneChangeNotify();
return TRUE;
}
-static void change_clicked( GtkWidget *widget, gpointer data ){
- GtkWidget* file_sel;
+static void change_clicked(ui::Widget widget, gpointer data ){
char* filename = NULL;
- file_sel = gtk_file_chooser_dialog_new ( "Locate portal (.prt) file", nullptr, GTK_FILE_CHOOSER_ACTION_OPEN,
+ auto file_sel = ui::Widget::from(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);
+ nullptr));
gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(file_sel), portals.fn );
#endif
typedef struct _mapcoord_setting_packet {
- GtkSpinButton *spinner1, *spinner2, *spinner3, *spinner4;
+ ui::SpinButton spinner1{ui::null}, spinner2{ui::null}, spinner3{ui::null}, spinner4{ui::null};
Entity* worldspawn;
} mapcoord_setting_packet;
// ** GTK callback functions **
// **************************
-static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ){
+static gboolean delete_event(ui::Widget widget, GdkEvent *event, gpointer data ){
/* If you return FALSE in the "delete_event" signal handler,
* GTK will emit the "destroy" signal. Returning TRUE means
* you don't want the window to be destroyed.
}
// callback function to assign the optimal mapcoords to the spinboxes
-static void input_optimal( GtkWidget *widget, gpointer data ){
+static void input_optimal(ui::Widget widget, gpointer data ){
gtk_spin_button_set_value( msp.spinner1, minX );
gtk_spin_button_set_value( msp.spinner2, maxY );
gtk_spin_button_set_value( msp.spinner3, maxX );
}
// Spinner return value function
-gint grab_int_value( GtkSpinButton *a_spinner, gpointer user_data ) {
+gint grab_int_value(ui::SpinButton a_spinner, gpointer user_data ) {
return gtk_spin_button_get_value_as_int( a_spinner );
}
button.connect( "clicked", G_CALLBACK( input_optimal ), NULL ); // connect button with callback function
vbox.pack_start( button, FALSE, FALSE, 2 ); // insert button into vbox
- vbox.pack_start( ui::Widget(gtk_hseparator_new()), FALSE, FALSE, 2 ); // insert separator into vbox
+ vbox.pack_start( ui::Widget::from(gtk_hseparator_new()), FALSE, FALSE, 2 ); // insert separator into vbox
auto table = ui::Table( 4, 3, TRUE ); // create table
gtk_table_set_row_spacings(table, 8); // set row spacings
* This is useful for popping up 'are you sure you want to quit?'
* type dialogs.
*/
-static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ){
+static gboolean delete_event(ui::Widget widget, GdkEvent *event, gpointer data ){
return FALSE;
}
class ListAttributeType
{
-typedef std::pair<CopiedString, CopiedString> ListItem;
-typedef std::vector<ListItem> ListItems;
+using ListItem = std::pair<CopiedString, CopiedString>;
+using ListItems = std::vector<ListItem>;
ListItems m_items;
public:
}
-GClosure* accel_group_add_accelerator( GtkAccelGroup* group, Accelerator accelerator, const Callback<void()>& callback );
-void accel_group_remove_accelerator( GtkAccelGroup* group, Accelerator accelerator );
+GClosure* accel_group_add_accelerator(ui::AccelGroup group, Accelerator accelerator, const Callback<void()>& callback );
+void accel_group_remove_accelerator(ui::AccelGroup group, Accelerator accelerator );
AcceleratorMap g_queuedAcceleratorsAdd;
AcceleratorSet g_queuedAcceleratorsRemove;
}
};
-gboolean PressedButtons_button_press( GtkWidget* widget, GdkEventButton* event, PressedButtons* pressed ){
+gboolean PressedButtons_button_press(ui::Widget widget, GdkEventButton* event, PressedButtons* pressed ){
if ( event->type == GDK_BUTTON_PRESS ) {
return Buttons_press( pressed->buttons, event->button, event->state );
}
return FALSE;
}
-gboolean PressedButtons_button_release( GtkWidget* widget, GdkEventButton* event, PressedButtons* pressed ){
+gboolean PressedButtons_button_release(ui::Widget widget, GdkEventButton* event, PressedButtons* pressed ){
if ( event->type == GDK_BUTTON_RELEASE ) {
return Buttons_release( pressed->buttons, event->button, event->state );
}
return FALSE;
}
-gboolean PressedButtons_focus_out( GtkWidget* widget, GdkEventFocus* event, PressedButtons* pressed ){
+gboolean PressedButtons_focus_out(ui::Widget widget, GdkEventFocus* event, PressedButtons* pressed ){
Buttons_releaseAll( pressed->buttons );
return FALSE;
}
keys.clear();
}
-gboolean PressedKeys_key_press( GtkWidget* widget, GdkEventKey* event, PressedKeys* pressedKeys ){
+gboolean PressedKeys_key_press(ui::Widget widget, GdkEventKey* event, PressedKeys* pressedKeys ){
//globalOutputStream() << "pressed: " << event->keyval << "\n";
return event->state == 0 && Keys_press( pressedKeys->keys, event->keyval );
}
-gboolean PressedKeys_key_release( GtkWidget* widget, GdkEventKey* event, PressedKeys* pressedKeys ){
+gboolean PressedKeys_key_release(ui::Widget widget, GdkEventKey* event, PressedKeys* pressedKeys ){
//globalOutputStream() << "released: " << event->keyval << "\n";
return Keys_release( pressedKeys->keys, event->keyval );
}
-gboolean PressedKeys_focus_in( GtkWidget* widget, GdkEventFocus* event, PressedKeys* pressedKeys ){
+gboolean PressedKeys_focus_in(ui::Widget widget, GdkEventFocus* event, PressedKeys* pressedKeys ){
++pressedKeys->refcount;
return FALSE;
}
-gboolean PressedKeys_focus_out( GtkWidget* widget, GdkEventFocus* event, PressedKeys* pressedKeys ){
+gboolean PressedKeys_focus_out(ui::Widget widget, GdkEventFocus* event, PressedKeys* pressedKeys ){
if ( --pressedKeys->refcount == 0 ) {
Keys_releaseAll( pressedKeys->keys, 0 );
}
}
-gboolean accel_closure_callback( GtkAccelGroup* group, GtkWidget* widget, guint key, GdkModifierType modifiers, gpointer data ){
+gboolean accel_closure_callback(ui::AccelGroup group, ui::Widget widget, guint key, GdkModifierType modifiers, gpointer data ){
( *reinterpret_cast<Callback<void()>*>( data ) )( );
return TRUE;
}
-GClosure* accel_group_add_accelerator( GtkAccelGroup* group, Accelerator accelerator, const Callback<void()>& callback ){
+GClosure* accel_group_add_accelerator(ui::AccelGroup group, Accelerator accelerator, const Callback<void()>& callback ){
if ( accelerator.key != 0 && gtk_accelerator_valid( accelerator.key, accelerator.modifiers ) ) {
//globalOutputStream() << "global_accel_connect: " << makeQuoted(accelerator) << "\n";
GClosure* closure = create_cclosure( G_CALLBACK( accel_closure_callback ), callback );
}
}
-void accel_group_remove_accelerator( GtkAccelGroup* group, Accelerator accelerator ){
+void accel_group_remove_accelerator(ui::AccelGroup group, Accelerator accelerator ){
if ( accelerator.key != 0 && gtk_accelerator_valid( accelerator.key, accelerator.modifiers ) ) {
//globalOutputStream() << "global_accel_disconnect: " << makeQuoted(accelerator) << "\n";
gtk_accel_group_disconnect_key( group, accelerator.key, accelerator.modifiers );
globalOutputStream() << "\n";
}
-GtkToggleButton* radio_button_get_nth( ui::RadioButton radio, int index ){
+ui::ToggleButton 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 ) );
+ return ui::ToggleButton::from( g_slist_nth_data( group, g_slist_length( group ) - index - 1 ) );
}
void radio_button_set_active( ui::RadioButton radio, int index ){
auto radio = ui::RadioButton(ui::null);
for ( StringArrayRange::Iterator i = names.first; i != names.last; ++i )
{
- radio = ui::RadioButton(GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( group, *i ) ));
+ radio = ui::RadioButton::from( gtk_radio_button_new_with_label( group, *i ) );
radio.show();
hbox.pack_start( radio, FALSE, FALSE, 0 );
ui::GLArea glwidget_new(bool zbuffer)
{
- auto self = ui::GLArea(GTK_DRAWING_AREA(gtk_drawing_area_new()));
+ auto self = ui::GLArea::from(gtk_drawing_area_new());
g_object_set_data(G_OBJECT(self), "zbuffer", gint_to_pointer(zbuffer));
ui::Image image_new_from_file_with_mask( const char* filename ){
GdkPixbuf* rgba = pixbuf_new_from_file_with_mask( filename );
if ( rgba == 0 ) {
- return ui::Image(0);
+ return ui::Image(ui::null);
}
else
{
- auto image = ui::Image(GTK_IMAGE( gtk_image_new_from_pixbuf( rgba ) ));
+ auto image = ui::Image::from( gtk_image_new_from_pixbuf( rgba ) );
g_object_unref( rgba );
return image;
}
}
ui::Image image_new_missing(){
- return ui::Image(GTK_IMAGE( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ));
+ return ui::Image::from( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) );
}
ui::Image new_image( const char* filename ){
}
ui::MenuItem menu_separator( ui::Menu menu ){
- auto menu_item = ui::MenuItem(GTK_MENU_ITEM( gtk_menu_item_new() ));
+ auto menu_item = ui::MenuItem::from( gtk_menu_item_new() );
menu.add(menu_item);
gtk_widget_set_sensitive( menu_item , FALSE );
menu_item.show();
}
ui::TearoffMenuItem menu_tearoff( ui::Menu menu ){
- auto menu_item = ui::TearoffMenuItem(GTK_TEAROFF_MENU_ITEM( gtk_tearoff_menu_item_new() ));
+ auto menu_item = ui::TearoffMenuItem::from( gtk_tearoff_menu_item_new() );
menu.add(menu_item);
// gtk_widget_set_sensitive(menu_item, FALSE); -- controls whether menu is detachable
menu_item.show();
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 ) ));
+ return ui::Menu::from( gtk_menu_item_get_submenu( item ) );
}
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 );
+ return create_sub_menu_with_mnemonic( ui::MenuShell::from( bar._handle ), 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 );
+ return create_sub_menu_with_mnemonic( ui::MenuShell::from( parent._handle ), mnemonic );
}
void activate_closure_callback( ui::Widget widget, gpointer data ){
}
ui::CheckMenuItem new_check_menu_item_with_mnemonic( const char* mnemonic, const Callback<void()>& callback ){
- auto item = ui::CheckMenuItem(GTK_CHECK_MENU_ITEM( gtk_check_menu_item_new_with_mnemonic( mnemonic ) ));
+ auto item = ui::CheckMenuItem::from( gtk_check_menu_item_new_with_mnemonic( mnemonic ) );
item.show();
check_menu_item_connect_callback( item, callback );
return item;
}
ui::RadioMenuItem new_radio_menu_item_with_mnemonic( GSList** group, const char* mnemonic, const Callback<void()>& callback ){
- auto item = ui::RadioMenuItem(GTK_RADIO_MENU_ITEM( gtk_radio_menu_item_new_with_mnemonic( *group, mnemonic ) ));
+ auto item = ui::RadioMenuItem::from( gtk_radio_menu_item_new_with_mnemonic( *group, mnemonic ) );
if ( *group == 0 ) {
gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( item ), TRUE );
}
return item;
}
-void check_menu_item_set_active_callback( GtkCheckMenuItem &item, bool enabled ){
- check_menu_item_set_active_no_signal( ui::CheckMenuItem(&item), enabled );
+void check_menu_item_set_active_callback(void *it, bool enabled ){
+ auto item = ui::CheckMenuItem::from(it);
+ check_menu_item_set_active_no_signal( item, enabled );
}
-typedef ReferenceCaller<GtkCheckMenuItem, void(bool), check_menu_item_set_active_callback> CheckMenuItemSetActiveCaller;
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_ ) );
+ toggle.m_exportCallback( PointerCaller<void, void(bool), check_menu_item_set_active_callback>( item._handle ) );
return item;
}
auto iconBox = create_dialog_hbox( 16, 0 );
hboxDummy.pack_start( iconBox, FALSE, FALSE, 0 );
- auto image = ui::Image(GTK_IMAGE( gtk_image_new_from_stock( messagebox_stock_icon( icon ), GTK_ICON_SIZE_DIALOG ) ));
+ auto image = ui::Image::from( gtk_image_new_from_stock( messagebox_stock_icon( icon ), GTK_ICON_SIZE_DIALOG ) );
image.show();
iconBox.pack_start( image, FALSE, FALSE, 0 );
void NonModalSpinner::connect(ui::SpinButton spin)
{
- auto adj = ui::Adjustment(gtk_spin_button_get_adjustment(spin));
+ auto adj = ui::Adjustment::from(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);
{
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);
+ toggle_button_connect_callback(ui::ToggleButton::from(group->data), m_changed);
}
}
int size;
};
-gboolean hpaned_allocate( GtkWidget* widget, GtkAllocation* allocation, PanedState* paned ){
+gboolean hpaned_allocate(ui::Widget widget, GtkAllocation* allocation, PanedState* paned ){
if ( paned->size != allocation->width ) {
paned->size = allocation->width;
gtk_paned_set_position( GTK_PANED( widget ), static_cast<int>( paned->size * paned->position ) );
return FALSE;
}
-gboolean vpaned_allocate( GtkWidget* widget, GtkAllocation* allocation, PanedState* paned ){
+gboolean vpaned_allocate(ui::Widget widget, GtkAllocation* allocation, PanedState* paned ){
if ( paned->size != allocation->height ) {
paned->size = allocation->height;
gtk_paned_set_position( GTK_PANED( widget ), static_cast<int>( paned->size * paned->position ) );
return FALSE;
}
-gboolean paned_position( GtkWidget* widget, gpointer dummy, PanedState* paned ){
+gboolean paned_position(ui::Widget widget, gpointer dummy, PanedState* paned ){
if ( paned->size != -1 ) {
paned->position = gtk_paned_get_position( GTK_PANED( widget ) ) / static_cast<float>( paned->size );
}
}
ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback<void()>& callback ){
- auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_tool_button_new(new_local_image(icon), nullptr)));
+ auto button = ui::ToolButton::from(gtk_tool_button_new(new_local_image(icon), nullptr));
button_connect_callback(button, callback);
toolbar_append(toolbar, button, description);
return button;
}
ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback<void()>& callback ){
- auto button = ui::ToggleToolButton(GTK_TOGGLE_TOOL_BUTTON(gtk_toggle_tool_button_new()));
+ auto button = ui::ToggleToolButton::from(gtk_toggle_tool_button_new());
toggle_button_connect_callback(button, callback);
gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), new_local_image(icon));
gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), description);
return toolbar_append_button( toolbar, description, icon, command.m_callback );
}
-void toggle_button_set_active_callback( GtkToggleToolButton& button, bool active ){
- toggle_button_set_active_no_signal( ui::ToggleToolButton(&button), active );
+void toggle_button_set_active_callback(ui::ToggleToolButton& button, bool active ){
+ toggle_button_set_active_no_signal( button, active );
}
-using ToggleButtonSetActiveCaller = ReferenceCaller<GtkToggleToolButton, void(bool), toggle_button_set_active_callback>;
+using ToggleButtonSetActiveCaller = ReferenceCaller<ui::ToggleToolButton, void(bool), toggle_button_set_active_callback>;
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_ ) );
+ toggle.m_exportCallback( ToggleButtonSetActiveCaller( button ) );
return button;
}
ToggleItem m_item;
ToggleShown(bool shown)
- : m_shownDeferred(shown), m_widget(0), m_item(ActiveCaller(*this))
+ : m_shownDeferred(shown), m_widget(ui::null), m_item(ActiveCaller(*this))
{
}
Widget root{ui::null};
#define IMPL(T, F) template<> _IMPL(T, F)
-#define _IMPL(T, F) struct verify<T *> { using self = T; static self test(self it) { return self(F(it)); } }
+#define _IMPL(T, F) struct verify<T *> { using self = T; static self test(self it) { return self::from(F(it)); } }
template<class T>
struct verify;
delete data;
};
auto func = [](_GtkWidget *widget, GdkEventKey *event, user_data *args) -> bool {
- return args->f(Widget(widget), event, args->extra);
+ return args->f(Widget::from(widget), event, args->extra);
};
auto clos = g_cclosure_new(G_CALLBACK(+func), pass, reinterpret_cast<GClosureNotify>(+dtor));
return g_signal_connect_closure(G_OBJECT(this), "key-press-event", clos, false);
// Custom
+#if GTK_TARGET == 3
+
+ IMPL(GLArea, (void *));
+
+#elif GTK_TARGET == 2
+
+ IMPL(GLArea, GTK_DRAWING_AREA);
+
+#endif
+
guint IGLArea::on_render(GCallback pFunction, void *data)
{
#if GTK_TARGET == 3
public: \
using self = name *; \
using native = T *; \
+ protected: \
explicit name(native h) : super(reinterpret_cast<super::native>(h)) {} \
+ public: \
explicit name(Null n) : name((native) nullptr) {} \
explicit name(New_t); \
+ static name from(native h) { return name(h); } \
static name from(void *ptr) { return name((native) ptr); } \
ctors \
}; \
GtkCallback cb = [](_GtkWidget *widget, void *data) -> void {
using Function = typename std::decay<Lambda>::type;
Function *f = static_cast<Function *>(data);
- (*f)(Widget(widget));
+ (*f)(Widget::from(widget));
};
gtk_container_foreach(this, cb, &lambda);
}
}
};
-gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, ProjectList* projectList ){
+gboolean project_cell_edited(ui::CellRendererText cell, gchar* path_string, gchar* new_text, ProjectList* projectList ){
Project& project = projectList->m_project;
auto path = ui::TreePath( path_string );
Project& project = projectList->m_project;
if ( event->keyval == GDK_KEY_Delete ) {
- auto selection = ui::TreeSelection(gtk_tree_view_get_selection(widget));
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(widget));
GtkTreeIter iter;
GtkTreeModel* model;
if ( gtk_tree_selection_get_selected( selection, &model, &iter ) ) {
return FALSE;
}
-gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, ui::ListStore store ){
+gboolean commands_cell_edited(ui::CellRendererText cell, gchar* path_string, gchar* new_text, ui::ListStore store ){
if ( g_current_build == 0 ) {
return FALSE;
}
vbox.pack_start( button, FALSE, FALSE, 0 );
}
}
- auto buildViewStore = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
- auto buildView = ui::TreeView( ui::TreeModel( buildViewStore ));
+ auto buildViewStore = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
+ auto buildView = ui::TreeView( ui::TreeModel::from( buildViewStore._handle ));
{
auto frame = create_dialog_frame( "Build menu" );
table1.attach(frame, {0, 1, 0, 1});
frame.add(scr);
{
- auto store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
+ auto store = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
- auto view = ui::TreeView(ui::TreeModel( store ));
+ auto view = ui::TreeView(ui::TreeModel::from( store._handle ));
gtk_tree_view_set_headers_visible(view, FALSE );
auto renderer = ui::CellRendererText(ui::New);
view.connect( "key_press_event", G_CALLBACK( commands_key_press ), store );
- auto sel = ui::TreeSelection(gtk_tree_view_get_selection(buildView ));
+ auto sel = ui::TreeSelection::from(gtk_tree_view_get_selection(buildView ));
sel.connect( "changed", G_CALLBACK( project_selection_changed ), store );
}
}
struct command_list_dialog_t : public ModalDialog
{
command_list_dialog_t()
- : m_close_button( *this, eIDCANCEL ), m_list( NULL ), m_command_iter(), m_model( NULL ), m_waiting_for_key( false ){
+ : m_close_button( *this, eIDCANCEL ), m_list( ui::null ), m_command_iter(), m_model( ui::null ), m_waiting_for_key( false ){
}
ModalDialogButton m_close_button;
return;
}
dialog.m_command_iter = iter;
- dialog.m_model = ui::TreeModel(model);
+ dialog.m_model = ui::TreeModel::from(model);
// 2. disallow changing the row
//gtk_widget_set_sensitive(dialog.m_list, false);
hbox.pack_start( scr, TRUE, TRUE, 0 );
{
- ui::ListStore store = ui::ListStore(gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT ));
+ auto store = ui::ListStore::from(gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT ));
- auto view = ui::TreeView(ui::TreeModel(store));
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
dialog.m_list = view;
gtk_tree_view_set_enable_search(view, false ); // annoying
struct Wrapper {
static void Export(const native &self, const Callback<void(T)> &returnz) {
native *p = &const_cast<native &>(self);
- auto widget = Self(p);
+ auto widget = Self::from(p);
Widget::Get::thunk_(widget, returnz);
}
static void Import(native &self, T value) {
native *p = &self;
- auto widget = Self(p);
+ auto widget = Self::from(p);
Widget::Set::thunk_(widget, value);
}
};
// =============================================================================
// Dialog class
-Dialog::Dialog() : m_window( 0 ), m_parent( 0 ){
+Dialog::Dialog() : m_window( ui::null ), m_parent( ui::null ){
}
Dialog::~Dialog(){
image.show();
table.attach(image, {pos, pos + 1, 0, 1}, {0, 0});
- radio = ui::RadioButton(GTK_RADIO_BUTTON(gtk_radio_button_new( group )));
+ radio = ui::RadioButton::from(gtk_radio_button_new( group ));
radio.show();
table.attach(radio, {pos, pos + 1, 1, 2}, {0, 0});
public:
ListAttribute( const char* key, const ListAttributeType& type ) :
m_key( key ),
- m_combo( 0 ),
+ m_combo( ui::null ),
m_nonModal( ApplyCaller( *this ) ),
m_type( type ){
auto combo = ui::ComboBoxText(ui::New);
{
for ( int i = 0; i < g_spawnflag_count; ++i )
{
- auto widget = ui::CheckButton(g_entitySpawnflagsCheck[i]);
- auto label = ui::Label(GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget))));
+ auto widget = ui::CheckButton::from(g_entitySpawnflagsCheck[i]);
+ auto label = ui::Label::from(gtk_bin_get_child(GTK_BIN(widget)));
label.text(" ");
widget.hide();
widget.ref();
- ui::Container(GTK_CONTAINER(g_spawnflagsTable)).remove(widget);
+ g_spawnflagsTable.remove(widget);
}
}
{
for (unsigned int i = 0; (int) i < g_spawnflag_count; ++i)
{
- auto widget = ui::CheckButton(g_entitySpawnflagsCheck[i] );
+ auto widget = ui::CheckButton::from(g_entitySpawnflagsCheck[i] );
widget.show();
StringOutputStream str( 16 );
g_spawnflagsTable.attach(widget, {i % 4, i % 4 + 1, i / 4, i / 4 + 1}, {GTK_FILL, GTK_FILL});
widget.unref();
- auto label = ui::Label(GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget)) ));
+ auto label = ui::Label::from(gtk_bin_get_child(GTK_BIN(widget)) );
label.text(str.c_str());
}
}
{
int v = !!( f & ( 1 << spawn_table[i] ) );
- toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] )), v );
+ toggle_button_set_active_no_signal( ui::ToggleButton::from( 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( ui::ToggleButton(GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] )), FALSE );
+ toggle_button_set_active_no_signal( ui::ToggleButton::from( g_entitySpawnflagsCheck[i] ), FALSE );
}
}
}
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
{
- ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ));
+ ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ));
- auto view = ui::TreeView( ui::TreeModel(store ));
+ auto view = ui::TreeView( ui::TreeModel::from( store._handle ));
gtk_tree_view_set_enable_search(view, FALSE );
gtk_tree_view_set_headers_visible( view, FALSE );
view.connect( "button_press_event", G_CALLBACK( EntityClassList_button_press ), 0 );
}
{
- auto selection = ui::TreeSelection(gtk_tree_view_get_selection( view ));
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection( view ));
selection.connect( "changed", G_CALLBACK( EntityClassList_selection_changed ), 0 );
}
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
{
- ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ));
+ ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ));
- auto view = ui::TreeView(ui::TreeModel(store ));
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
gtk_tree_view_set_enable_search(view, FALSE );
gtk_tree_view_set_headers_visible(view, FALSE );
}
{
- auto selection = ui::TreeSelection(gtk_tree_view_get_selection(view ));
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view));
selection.connect( "changed", G_CALLBACK( EntityProperties_selection_changed ), 0 );
}
scr.show();
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
- auto viewport = ui::Container(GTK_CONTAINER(gtk_viewport_new( 0, 0 )));
+ auto viewport = ui::Container::from(gtk_viewport_new( 0, 0 ));
viewport.show();
gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport ), GTK_SHADOW_NONE );
EntityList() :
m_dirty( EntityList::eDefault ),
m_idleDraw( RedrawEntityListCaller() ),
- m_window( 0 ),
+ m_window( ui::null ),
m_selection_disabled( false ){
}
-void entitylist_treeviewcolumn_celldatafunc( ui::TreeViewColumn column, GtkCellRenderer* renderer, ui::TreeModel model, GtkTreeIter* iter, gpointer data ){
+void entitylist_treeviewcolumn_celldatafunc( ui::TreeViewColumn column, ui::CellRenderer renderer, ui::TreeModel model, GtkTreeIter* iter, gpointer data ){
scene::Node* node;
gtk_tree_model_get_pointer( model, iter, 0, &node );
scene::Instance* instance;
gboolean treemodel_update_selection( ui::TreeModel model, ui::TreePath path, GtkTreeIter* iter, gpointer data ){
- auto view = reinterpret_cast<GtkTreeView*>( data );
+ auto view = ui::TreeView::from( data );
scene::Instance* instance;
gtk_tree_model_get_pointer( model, iter, 1, &instance );
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
{
- ui::ListStore store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
+ ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
- auto view = ui::TreeView(ui::TreeModel(store ));
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
gtk_tree_view_set_headers_visible(view, FALSE );
{
}
{
- auto selection = ui::TreeSelection(gtk_tree_view_get_selection(view ));
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view ));
gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE );
selection.connect( "changed", G_CALLBACK( feedback_selection_changed ), NULL );
}
return FALSE;
}
-GroupDlg::GroupDlg() : m_window( 0 ){
+GroupDlg::GroupDlg() : m_window( ui::null ){
m_position_tracker.setPosition( c_default_window_pos );
}
m_position_tracker.connect( window );
{
- ui::Widget notebook = ui::Widget(gtk_notebook_new());
+ ui::Widget notebook = ui::Widget::from(gtk_notebook_new());
notebook.show();
window.add(notebook);
gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_BOTTOM );
ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const Callback<void(const Callback<void(const char *)> &)>& 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 ) ));
+ auto page = ui::Widget::from(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;
}
ui::Widget GroupDialog_getPage(){
- return ui::Widget(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ));
+ return ui::Widget::from(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ));
}
void GroupDialog_setPage( ui::Widget page ){
void DoSides( int type, int axis ){
ModalDialog dialog;
- GtkEntry* sides_entry;
auto window = MainFrame_getWindow().create_dialog_window("Arbitrary sides", G_CALLBACK(dialog_delete_callback ), &dialog );
auto accel = ui::AccelGroup(ui::New);
window.add_accel_group( accel );
+ auto sides_entry = ui::Entry(ui::New);
{
auto hbox = create_dialog_hbox( 4, 4 );
window.add(hbox);
hbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- auto entry = ui::Entry(ui::New);
+ auto entry = sides_entry;
entry.show();
hbox.pack_start( entry, FALSE, FALSE, 0 );
- sides_entry = entry;
gtk_widget_grab_focus( entry );
}
{
EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, const char* title ){
ModalDialog dialog;
- GtkEntry* textentry;
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
auto accel_group = ui::AccelGroup(ui::New);
window.add_accel_group( accel_group );
+ auto textentry = ui::Entry(ui::New);
{
auto hbox = create_dialog_hbox( 4, 4 );
window.add(hbox);
vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- auto entry = ui::Entry(ui::New);
+ auto entry = textentry;
entry.show();
vbox.pack_start( entry, TRUE, TRUE, 0 );
gtk_widget_grab_focus( entry );
-
- textentry = entry;
}
}
{
dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), &dialog );
GtkWidget *ok_button, *cancel_button;
g_object_get(G_OBJECT(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 );
+ ui::Widget::from(ok_button).connect( "clicked", G_CALLBACK( dialog_button_ok ), &dialog );
+ ui::Widget::from(cancel_button).connect( "clicked", G_CALLBACK( dialog_button_cancel ), &dialog );
if ( parent ) {
gtk_window_set_transient_for( dlg, parent );
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 ) ));
+ auto menu_in_menu = ui::Menu::from( gtk_menu_item_get_submenu( colours_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
ui::MenuItem create_file_menu(){
// File menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( file_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
ui::MenuItem create_edit_menu(){
// Edit menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( edit_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
ui::MenuItem create_view_menu( MainFrame::EViewStyle style ){
// View menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( view_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
ui::MenuItem create_selection_menu(){
// Selection menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( selection_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
ui::MenuItem create_bsp_menu(){
// BSP menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( bsp_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
ui::MenuItem create_grid_menu(){
// Grid menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( grid_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
ui::MenuItem create_misc_menu(){
// Misc menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( misc_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
ui::MenuItem create_entity_menu(){
// Brush menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( entity_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
ui::MenuItem create_brush_menu(){
// Brush menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( brush_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
ui::MenuItem create_patch_menu(){
// Curve menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( patch_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
ui::MenuItem create_help_menu(){
// Help menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( help_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
}
ui::MenuBar create_main_menu( MainFrame::EViewStyle style ){
- auto menu_bar = ui::MenuBar(GTK_MENU_BAR( gtk_menu_bar_new() ));
+ auto menu_bar = ui::MenuBar::from( gtk_menu_bar_new() );
menu_bar.show();
menu_bar.add(create_file_menu());
}
ui::Toolbar create_main_toolbar( MainFrame::EViewStyle style ){
- auto toolbar = ui::Toolbar(GTK_TOOLBAR( gtk_toolbar_new() ));
+ auto toolbar = ui::Toolbar::from( gtk_toolbar_new() );
gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL );
gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS );
toolbar.show();
auto space = [&]() {
- auto btn = ui::ToolItem(gtk_separator_tool_item_new());
+ auto btn = ui::ToolItem::from(gtk_separator_tool_item_new());
btn.show();
toolbar.add(btn);
};
vbox.pack_start( scr, TRUE, TRUE, 0 );
{
- ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ));
+ auto store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ));
- auto view = ui::TreeView(ui::TreeModel(store ));
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
gtk_tree_view_set_headers_clickable(view, TRUE );
{
MRU_SetText( i, MRU_GetText( i - 1 ) );
MRU_SetText( 0, str );
- gtk_widget_set_sensitive( ui::MenuItem(MRU_items[0]) , TRUE );
- ui::MenuItem(MRU_items[MRU_used - 1] ).show();
+ gtk_widget_set_sensitive( ui::MenuItem::from(MRU_items[0]) , TRUE );
+ ui::MenuItem::from(MRU_items[MRU_used - 1] ).show();
}
void MRU_Init(){
MRU_items[pos] = widget;
if ( pos < MRU_used ) {
MRU_updateWidget( pos, MRU_GetText( pos ) );
- gtk_widget_set_sensitive( ui::MenuItem(MRU_items[0]) , TRUE );
- ui::MenuItem(MRU_items[pos]).show();
+ gtk_widget_set_sensitive( ui::MenuItem::from(MRU_items[0]) , TRUE );
+ ui::MenuItem::from(MRU_items[pos]).show();
}
}
}
MRU_SetText( i, MRU_GetText( i + 1 ) );
if ( MRU_used == 0 ) {
- auto label = ui::Label(GTK_LABEL(gtk_bin_get_child(GTK_BIN(MRU_items[0] )) ));
+ auto label = ui::Label::from(gtk_bin_get_child(GTK_BIN(MRU_items[0] )) );
label.text("Recent Files");
- gtk_widget_set_sensitive( ui::MenuItem(MRU_items[0]), FALSE );
+ gtk_widget_set_sensitive( ui::MenuItem::from(MRU_items[0]), FALSE );
}
else
{
- ui::MenuItem(MRU_items[MRU_used]).hide();
+ ui::MenuItem::from(MRU_items[MRU_used]).hide();
}
}
}
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 ){
+Subdivisions() : m_enabled( ui::null ), m_horizontal( ui::null ), m_vertical( ui::null ){
}
void update(){
PatchFixedSubdivisions subdivisions;
Patch_AutoCapTexture();
}
-static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){
+static void OnSpinChanged(ui::Adjustment adj, gpointer data ){
texdef_t td;
td.rotate = 0;
table.attach(label, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
}
{
- auto check = ui::CheckButton(GTK_CHECK_BUTTON( gtk_check_button_new() ));
+ auto check = ui::CheckButton::from( gtk_check_button_new() );
check.show();
table.attach(check, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
m_subdivisions.m_enabled = check;
void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, int defcols, int maxrows, int maxcols ){
ModalDialog dialog;
- GtkComboBox* width;
- GtkComboBox* height;
ui::Window window = MainFrame_getWindow().create_dialog_window("Patch density", G_CALLBACK(dialog_delete_callback ), &dialog );
auto accel = ui::AccelGroup(ui::New);
window.add_accel_group( accel );
-
+ auto width = ui::ComboBoxText(ui::New);
+ auto height = ui::ComboBoxText(ui::New);
{
auto hbox = create_dialog_hbox( 4, 4 );
window.add(hbox);
}
{
- auto combo = ui::ComboBoxText(ui::New);
+ auto combo = width;
#define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_text_append_text( combo, #x )
D_ITEM( 3 );
D_ITEM( 5 );
#undef D_ITEM
combo.show();
table.attach(combo, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
-
- width = combo;
}
{
- auto combo = ui::ComboBoxText(ui::New);
+ auto combo = height;
#define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_text_append_text( combo, #x )
D_ITEM( 3 );
D_ITEM( 5 );
#undef D_ITEM
combo.show();
table.attach(combo, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
-
- height = combo;
}
}
GSList* group = 0;
{
- ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Bevel" ));
+ ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Bevel" ));
button.show();
table.attach(button, {1, 2, 0, 1}, {GTK_FILL | GTK_EXPAND, 0});
group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
bevel = button;
}
{
- ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Endcap" ));
+ ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Endcap" ));
button.show();
table.attach(button, {1, 2, 1, 2}, {GTK_FILL | GTK_EXPAND, 0});
group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
endcap = button;
}
{
- ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Bevel" ));
+ ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Inverted Bevel" ));
button.show();
table.attach(button, {1, 2, 2, 3}, {GTK_FILL | GTK_EXPAND, 0});
group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
ibevel = button;
}
{
- ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Endcap" ));
+ ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Inverted Endcap" ));
button.show();
table.attach(button, {1, 2, 3, 4}, {GTK_FILL | GTK_EXPAND, 0});
group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
iendcap = button;
}
{
- ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Cylinder" ));
+ ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Cylinder" ));
button.show();
table.attach(button, {1, 2, 4, 5}, {GTK_FILL | GTK_EXPAND, 0});
group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
if ( menuText != 0 && strlen( menuText ) > 0 ) {
if ( !strcmp( menuText, "-" ) ) {
- item = ui::Widget(gtk_menu_item_new());
+ item = ui::Widget::from(gtk_menu_item_new());
gtk_widget_set_sensitive( item, FALSE );
}
else if ( !strcmp( menuText, ">" ) ) {
ui::MenuItem create_plugins_menu(){
// Plugins menu
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 ) ));
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( plugins_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
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::ToolItem(gtk_separator_tool_item_new());
+ auto it = ui::ToolItem::from(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(new_plugin_image(icon), text)));
+ auto button = ui::ToolButton::from(gtk_tool_button_new(new_plugin_image(icon), text));
gtk_widget_set_tooltip_text(button, tooltip);
gtk_widget_show_all(button);
button.connect("clicked", G_CALLBACK(handler), data);
return;
}
if (type == IToolbarButton::eToggleButton) {
- auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_toggle_tool_button_new()));
+ auto button = ui::ToolButton::from(gtk_toggle_tool_button_new());
gtk_tool_button_set_icon_widget(button, new_plugin_image(icon));
gtk_tool_button_set_label(button, text);
gtk_widget_set_tooltip_text(button, tooltip);
ui::Toolbar create_plugin_toolbar(){
- auto toolbar = ui::Toolbar(GTK_TOOLBAR( gtk_toolbar_new() ));
+ auto toolbar = ui::Toolbar::from( gtk_toolbar_new() );
gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL );
gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS );
toolbar.show();
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( sc_win ), GTK_SHADOW_IN );
// prefs pages notebook
- m_notebook = ui::Widget(gtk_notebook_new());
+ m_notebook = ui::Widget::from(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 );
hbox.pack_start( m_notebook, TRUE, TRUE, 0 );
{
- auto store = ui::TreeStore(gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ));
+ auto store = ui::TreeStore::from(gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ));
- auto view = ui::TreeView(ui::TreeModel(store));
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
gtk_tree_view_set_headers_visible(view, FALSE );
{
}
{
- auto selection = ui::TreeSelection(gtk_tree_view_get_selection(view ));
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view));
selection.connect( "changed", G_CALLBACK( treeSelection ), this );
}
public:
ui::SpinButton m_spin;
ui::Entry m_entry;
-Increment( float& f ) : m_f( f ), m_spin( 0 ), m_entry( ui::null ){
+Increment( float& f ) : m_f( f ), m_spin( ui::null ), m_entry( ui::null ){
}
void cancel(){
entry_set_float( m_entry, m_f );
}
// not allowed to modify detail flag using Surface Inspector
- gtk_widget_set_sensitive( ui::CheckButton(m_contentFlags[BRUSH_DETAIL_FLAG]), FALSE );
+ gtk_widget_set_sensitive( ui::CheckButton::from(m_contentFlags[BRUSH_DETAIL_FLAG]), FALSE );
}
}
}
for ( GtkCheckButton** p = m_surfaceFlags; p != m_surfaceFlags + 32; ++p )
{
- toggle_button_set_active_no_signal( ui::CheckButton( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) );
+ toggle_button_set_active_no_signal( ui::CheckButton::from( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) );
}
for ( GtkCheckButton** p = m_contentFlags; p != m_contentFlags + 32; ++p )
{
- toggle_button_set_active_no_signal( ui::CheckButton( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) );
+ toggle_button_set_active_no_signal( ui::CheckButton::from( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) );
}
}
}
void EntryCompletion<StringList>::connect(ui::Entry entry)
{
if (!m_store) {
- m_store = ui::ListStore(gtk_list_store_new(1, G_TYPE_STRING));
+ m_store = ui::ListStore::from(gtk_list_store_new(1, G_TYPE_STRING));
fill();
StringList().connect(IdleDraw::QueueDrawCaller(m_idleUpdate));
}
- auto completion = ui::EntryCompletion(gtk_entry_completion_new());
+ auto completion = ui::EntryCompletion::from(gtk_entry_completion_new());
gtk_entry_set_completion(entry, completion);
gtk_entry_completion_set_model(completion, m_store);
gtk_entry_completion_set_text_column(completion, 0);
ui::ListStore m_store;
IdleDraw m_idleUpdate;
public:
- EntryCompletion() : m_store(0), m_idleUpdate(UpdateCaller(*this))
+ EntryCompletion() : m_store(ui::null), m_idleUpdate(UpdateCaller(*this))
{
}
m_handler = g_idle_add( deferred_value_changed, this );
}
}
-static void adjustment_value_changed( GtkAdjustment *adjustment, DeferredAdjustment* self ){
+static void adjustment_value_changed(ui::Adjustment adjustment, DeferredAdjustment* self ){
self->value_changed( gtk_adjustment_get_value(adjustment) );
}
};
}
TextureBrowser() :
- m_texture_scroll( 0 ),
+ m_texture_scroll( ui::null ),
m_hideunused_item( TextureBrowserHideUnusedExport() ),
m_hidenotex_item( TextureBrowserFilterFallbackExport() ),
m_showshaders_item( TextureBrowserShowShadersExport() ),
TextureBrowser_setOriginY( *reinterpret_cast<TextureBrowser*>( data ), -(int)value );
}
-static void TextureBrowser_verticalScroll( GtkAdjustment *adjustment, TextureBrowser* textureBrowser ){
+static void TextureBrowser_verticalScroll(ui::Adjustment adjustment, TextureBrowser* textureBrowser ){
textureBrowser->m_scrollAdjustment.value_changed( gtk_adjustment_get_value(adjustment) );
}
void TextureBrowser_constructTreeStore(){
TextureGroups groups = TextureGroups_constructTreeView();
- auto store = ui::TreeStore(gtk_tree_store_new( 1, G_TYPE_STRING ));
+ auto store = ui::TreeStore::from(gtk_tree_store_new( 1, G_TYPE_STRING ));
TextureGroups_constructTreeModel( groups, store );
gtk_tree_view_set_model(g_TextureBrowser.m_treeViewTree, store);
void TextureBrowser_constructTreeStoreTags(){
TextureGroups groups;
- auto store = ui::TreeStore(gtk_tree_store_new( 1, G_TYPE_STRING ));
+ auto store = ui::TreeStore::from(gtk_tree_store_new( 1, G_TYPE_STRING ));
auto model = g_TextureBrowser.m_all_tags_list;
gtk_tree_view_set_model(g_TextureBrowser.m_treeViewTags, model );
g_object_unref( G_OBJECT( store ) );
}
-void TreeView_onRowActivated( ui::TreeView treeview, GtkTreePath* path, ui::TreeViewColumn col, gpointer userdata ){
+void TreeView_onRowActivated( ui::TreeView treeview, ui::TreePath path, ui::TreeViewColumn col, gpointer userdata ){
GtkTreeIter iter;
auto model = gtk_tree_view_get_model(treeview );
return textures_menu_item;
}
-gboolean TextureBrowser_tagMoveHelper( ui::TreeModel model, ui::TreePath path, GtkTreeIter* iter, GSList** selected ){
+gboolean TextureBrowser_tagMoveHelper( ui::TreeModel model, ui::TreePath path, GtkTreeIter iter, GSList** selected ){
g_assert( selected != NULL );
auto rowref = gtk_tree_row_reference_new( model, path );
}
void TextureBrowser_constructTagNotebook(){
- g_TextureBrowser.m_tag_notebook = ui::Widget(gtk_notebook_new());
+ g_TextureBrowser.m_tag_notebook = ui::Widget::from(gtk_notebook_new());
ui::Widget labelTags = ui::Label( "Tags" );
ui::Widget labelTextures = ui::Label( "Textures" );
}
void TextureBrowser_constructSearchButton(){
- ui::Widget image = ui::Widget(gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR ));
+ auto image = ui::Widget::from(gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR ));
g_TextureBrowser.m_search_button = ui::Button(ui::New);
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");
ui::Widget menu_bar{ui::null};
{ // menu bar
- menu_bar = ui::Widget(gtk_menu_bar_new());
+ menu_bar = ui::Widget::from(gtk_menu_bar_new());
auto menu_view = ui::Menu(ui::New);
auto view_item = TextureBrowser_constructViewMenu( menu_view );
gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view );
g_TextureBrowser.m_treeViewTree.show();
}
{ // gl_widget scrollbar
- ui::Widget w = ui::Widget(gtk_vscrollbar_new( ui::Adjustment( 0,0,0,1,1,0 ) ));
+ auto w = ui::Widget::from(gtk_vscrollbar_new( ui::Adjustment( 0,0,0,1,1,0 ) ));
table.attach(w, {2, 3, 1, 2}, {GTK_SHRINK, GTK_FILL});
w.show();
g_TextureBrowser.m_texture_scroll = w;
- auto vadjustment = ui::Adjustment(gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) ));
+ auto vadjustment = ui::Adjustment::from(gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) ));
vadjustment.connect( "value_changed", G_CALLBACK( TextureBrowser_verticalScroll ), &g_TextureBrowser );
g_TextureBrowser.m_texture_scroll.visible(g_TextureBrowser.m_showTextureScrollbar);
// tag stuff
if ( g_TextureBrowser.m_tags ) {
{ // fill tag GtkListStore
- g_TextureBrowser.m_all_tags_list = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ));
+ g_TextureBrowser.m_all_tags_list = ui::ListStore::from(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ));
auto sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_all_tags_list );
gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING );
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 = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ));
+ g_TextureBrowser.m_assigned_store = ui::ListStore::from(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ));
auto sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_assigned_store );
gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING );
auto renderer = ui::CellRendererText(ui::New);
- g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel(g_TextureBrowser.m_assigned_store ));
+ g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel::from(g_TextureBrowser.m_assigned_store._handle));
g_TextureBrowser.m_assigned_store.unref();
g_TextureBrowser.m_assigned_tree.connect( "row-activated", (GCallback) TextureBrowser_removeTags, NULL );
gtk_tree_view_set_headers_visible(g_TextureBrowser.m_assigned_tree, FALSE );
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 = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ));
+ g_TextureBrowser.m_available_store = ui::ListStore::from(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ));
auto sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_available_store );
gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING );
auto renderer = ui::CellRendererText(ui::New);
- g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel(g_TextureBrowser.m_available_store ));
+ g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel::from(g_TextureBrowser.m_available_store._handle));
g_TextureBrowser.m_available_store.unref();
g_TextureBrowser.m_available_tree.connect( "row-activated", (GCallback) TextureBrowser_assignTags, NULL );
gtk_tree_view_set_headers_visible(g_TextureBrowser.m_available_tree, FALSE );
{ // tag arrow buttons
auto m_btn_left = ui::Button(ui::New);
auto m_btn_right = ui::Button(ui::New);
- 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 ));
+ auto m_arrow_left = ui::Widget::from(gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT ));
+ auto m_arrow_right = ui::Widget::from(gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT ));
m_btn_left.add(m_arrow_left);
m_btn_right.add(m_arrow_right);
m_gl_widget( glwidget_new( FALSE ) ),
m_deferredDraw( WidgetQueueDrawCaller( m_gl_widget ) ),
m_deferred_motion( xywnd_motion, this ),
- m_parent( 0 ),
+ m_parent( ui::null ),
m_window_observer( NewWindowObserver() ),
m_XORRectangle( m_gl_widget ),
m_chasemouse_handler( 0 ){