m_string = string;
}
void evaluate( StringBuffer& output ){
+ // replace ".[ExecutableType]" with "[ExecutableExt]"
+ {
+ StringBuffer output;
+ const char *pattern = ".[ExecutableType]";
+ for ( const char *i = m_string.c_str(); *i != '\0'; ++i )
+ {
+ if ( strncmp( pattern, i, sizeof( pattern ) ) == 0 )
+ {
+ output.push_string("[ExecutableExt]");
+ i += strlen( pattern ) - 1;
+ }
+ else
+ {
+ output.push_back(*i);
+ }
+ }
+ setString(output.c_str());
+ }
+
StringBuffer variable;
bool in_variable = false;
for ( const char* i = m_string.c_str(); *i != '\0'; ++i )
}
-class BuildPairEqual
-{
-const char* m_name;
-public:
-BuildPairEqual( const char* name ) : m_name( name ){
-}
-bool operator()( const BuildPair& self ) const {
- return string_equal( self.first.c_str(), m_name );
-}
-};
-
typedef std::list<BuildPair> Project;
Project::iterator Project_find( Project& project, const char* name ){
- return std::find_if( project.begin(), project.end(), BuildPairEqual( name ) );
+ return std::find_if(project.begin(), project.end(), [&](const BuildPair &self) {
+ return string_equal(self.first.c_str(), name);
+ });
}
Project::iterator Project_find( Project& project, std::size_t index ){
}
};
-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;
- GtkTreePath* path = ui::TreePath( path_string );
+ auto path = ui::TreePath( path_string );
ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" );
GtkTreeIter iter;
- gtk_tree_model_get_iter( GTK_TREE_MODEL( projectList->m_store ), &iter, path );
+ gtk_tree_model_get_iter(projectList->m_store, &iter, path );
Project::iterator i = Project_find( project, gtk_tree_path_get_indices( path )[0] );
if ( i != project.end() ) {
return FALSE;
}
-gboolean project_key_press( ui::Widget widget, GdkEventKey* event, ProjectList* projectList ){
+gboolean project_key_press( ui::TreeView widget, GdkEventKey* event, ProjectList* projectList ){
Project& project = projectList->m_project;
if ( event->keyval == GDK_KEY_Delete ) {
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( 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 ) ) {
- GtkTreePath* path = gtk_tree_model_get_path( model, &iter );
+ auto path = gtk_tree_model_get_path( model, &iter );
Project::iterator x = Project_find( project, gtk_tree_path_get_indices( path )[0] );
gtk_tree_path_free( path );
Build* g_current_build = 0;
-gboolean project_selection_changed( GtkTreeSelection* selection, ui::ListStore store ){
+gboolean project_selection_changed( ui::TreeSelection selection, ui::ListStore store ){
Project& project = g_build_project;
store.clear();
GtkTreeIter iter;
GtkTreeModel* model;
if ( gtk_tree_selection_get_selected( selection, &model, &iter ) ) {
- GtkTreePath* path = gtk_tree_model_get_path( model, &iter );
+ auto path = gtk_tree_model_get_path( model, &iter );
Project::iterator x = Project_find( project, gtk_tree_path_get_indices( path )[0] );
gtk_tree_path_free( path );
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;
}
Build& build = *g_current_build;
- GtkTreePath* path = ui::TreePath( path_string );
+ auto path = ui::TreePath( path_string );
ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" );
GtkTreeIter iter;
- gtk_tree_model_get_iter( GTK_TREE_MODEL( store ), &iter, path );
+ gtk_tree_model_get_iter(store, &iter, path );
Build::iterator i = Build_find( build, gtk_tree_path_get_indices( path )[0] );
if ( i != build.end() ) {
return FALSE;
}
-gboolean commands_key_press( ui::Widget widget, GdkEventKey* event, ui::ListStore store ){
+gboolean commands_key_press( ui::TreeView widget, GdkEventKey* event, ui::ListStore store ){
if ( g_current_build == 0 ) {
return FALSE;
}
Build& build = *g_current_build;
if ( event->keyval == GDK_KEY_Delete ) {
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( widget ) );
+ auto selection = gtk_tree_view_get_selection(widget );
GtkTreeIter iter;
GtkTreeModel* model;
if ( gtk_tree_selection_get_selected( selection, &model, &iter ) ) {
- GtkTreePath* path = gtk_tree_model_get_path( model, &iter );
+ auto path = gtk_tree_model_get_path( model, &iter );
Build::iterator i = Build_find( build, gtk_tree_path_get_indices( path )[0] );
gtk_tree_path_free( path );
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 );
- ui::Widget buildView{ui::null};
+ // FIXME: GTK_WIN_POS_CENTER_ON_PARENT must be used instead but does not work
+ // for unknown reason.
+ // It's possible MaingFrame_getWindow() does not return the main window.
+ // It's known the preferences window has same issue when using MaingFrame_getWindow().
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER_ALWAYS );
{
auto table1 = create_dialog_table( 2, 2, 4, 4, 4 );
window.add(table1);
{
auto vbox = create_dialog_vbox( 4 );
- gtk_table_attach( table1, GTK_WIDGET( vbox ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ table1.attach(vbox, {1, 2, 0, 1}, {GTK_FILL, GTK_FILL});
{
auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &modal );
vbox.pack_start( button, FALSE, FALSE, 0 );
vbox.pack_start( button, FALSE, FALSE, 0 );
}
}
+ 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" );
- gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ table1.attach(frame, {0, 1, 0, 1});
{
auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 );
frame.add(scr);
{
- auto store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
-
- ui::Widget view = ui::TreeView( ui::TreeModel(GTK_TREE_MODEL( store ) ));
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
+ auto view = buildView;
+ auto store = buildViewStore;
+ gtk_tree_view_set_headers_visible(view, FALSE );
auto renderer = ui::CellRendererText(ui::New);
object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE );
renderer.connect("edited", G_CALLBACK( project_cell_edited ), &projectList );
- GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column(view, column );
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
+ auto selection = gtk_tree_view_get_selection(view );
gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE );
view.show();
- buildView = view;
projectList.m_store = store;
scr.add(view);
}
{
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 );
+ table1.attach(frame, {0, 1, 1, 2});
{
auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 );
frame.add(scr);
{
- ui::ListStore store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
+ auto store = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
- ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) ));
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
+ auto view = ui::TreeView(ui::TreeModel::from( store._handle ));
+ gtk_tree_view_set_headers_visible(view, FALSE );
auto renderer = ui::CellRendererText(ui::New);
object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE );
renderer.connect( "edited", G_CALLBACK( commands_cell_edited ), store );
- GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column(view, column );
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
+ auto selection = gtk_tree_view_get_selection(view );
gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE );
view.show();
view.connect( "key_press_event", G_CALLBACK( commands_key_press ), store );
- auto sel = ui::TreeSelection(gtk_tree_view_get_selection( GTK_TREE_VIEW( buildView ) ));
+ auto sel = ui::TreeSelection::from(gtk_tree_view_get_selection(buildView ));
sel.connect( "changed", G_CALLBACK( project_selection_changed ), store );
}
}
{
const char* m_name;
public:
-GtkMenuItem* m_item;
-BuildMenuItem( const char* name, GtkMenuItem* item )
+ui::MenuItem m_item;
+BuildMenuItem( const char* name, ui::MenuItem item )
: m_name( name ), m_item( item ){
}
void run(){
RunBSP( m_name );
}
-typedef MemberCaller<BuildMenuItem, &BuildMenuItem::run> RunCaller;
+typedef MemberCaller<BuildMenuItem, void(), &BuildMenuItem::run> RunCaller;
};
typedef std::list<BuildMenuItem> BuildMenuItems;
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 ) );
+ g_BuildMenuItems.push_back( BuildMenuItem( ( *i ).first.c_str(), ui::MenuItem(ui::null) ) );
if ( is_separator( *i ) ) {
g_BuildMenuItems.back().m_item = menu_separator( menu );
}
void Build_refreshMenu( ui::Menu menu ){
- for ( BuildMenuItems::iterator i = g_BuildMenuItems.begin(); i != g_BuildMenuItems.end(); ++i )
+ for (auto i = g_BuildMenuItems.begin(); i != g_BuildMenuItems.end(); ++i )
{
- menu.remove(ui::Widget(GTK_WIDGET((*i).m_item)));
+ menu.remove(ui::MenuItem(i->m_item));
}
g_BuildMenuItems.clear();
#include "stringio.h"
void BuildMenu_Construct(){
- GlobalPreferenceSystem().registerPreference( "BuildMenu", CopiedStringImportStringCaller( g_buildMenu ), CopiedStringExportStringCaller( g_buildMenu ) );
+ GlobalPreferenceSystem().registerPreference( "BuildMenu", make_property_string( g_buildMenu ) );
LoadBuildMenu();
}
void BuildMenu_Destroy(){