Update background dialog

This commit is contained in:
daleclack 2021-06-11 22:52:46 +08:00
parent 5babb7b3ac
commit e2763c1043
2 changed files with 28 additions and 6 deletions

20
Gtk3/CMakeLists.txt Normal file
View File

@ -0,0 +1,20 @@
set(CMAKE_CXX_STANDARD 17)
cmake_minimum_required(VERSION 3.0.0)
project(My_GtkUi VERSION 2.1.0)
include(CTest)
enable_testing()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
find_package (PkgConfig REQUIRED)
pkg_check_modules (GTK3 REQUIRED gtk+-3.0)
include_directories (${GTK3_INCLUDE_DIRS})
link_directories (${GTK3_LIBRARY_DIRS})
add_executable(My_GtkUi src/main.cpp src/background.cpp src/game.cpp
src/panel1.cpp src/panel2.cpp src/win1.cpp src/winconf.cpp src/resources.cpp)
add_definitions (${GTK3_CFLAGS_OTHER})
target_link_libraries (${PROJECT_NAME} ${GTK3_LIBRARIES} -lpthread -lm)

View File

@ -11,12 +11,14 @@ void fileopen(GtkWidget *widget,GtkBuilder *builder){
"OK",GTK_RESPONSE_OK,"Cancel",GTK_RESPONSE_CANCEL,NULL);
//Use GtkFileFilter to select image file
GtkFileFilter *filter=gtk_file_filter_new();
gtk_file_filter_add_pattern(filter,"*.png");
gtk_file_filter_add_pattern(filter,"*.jpg");
gtk_file_filter_add_pattern(filter,"*.jpeg");
gtk_file_filter_add_pattern(filter,"*.bmp");
gtk_file_filter_add_pattern(filter,"*.xpm");
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog),filter);
gtk_file_filter_set_name(filter,"Image Files");
gtk_file_filter_add_mime_type(filter,"image/*");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
//Filter For All Files
filter=gtk_file_filter_new();
gtk_file_filter_set_name(filter,"All Files");
gtk_file_filter_add_pattern(filter,"*");
gtk_file_chooser_add_filter((GtkFileChooser*)dialog,filter);
gtk_widget_show(dialog);
g_signal_connect(dialog,"response",G_CALLBACK(dialog_response),builder);
}