From 7d3b7f96eb56dd57ab027f1831f6d7fbeaa5adb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 8 May 2018 15:00:37 +0200 Subject: [PATCH] Main Window and list clear * designed basic window * implemented free function to clear library structures --- CMakeLists.txt | 10 ++-- gdsparse.c | 39 ++++++++++++++- gdsparse.h | 2 +- glade/main.glade | 126 +++++++++++++++++++++++++++++++++++++++++++++++ main.c | 41 ++++++++++++--- 5 files changed, 206 insertions(+), 12 deletions(-) create mode 100644 glade/main.glade diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b1326f..01063c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,14 @@ cmake_minimum_required(VERSION 2.8) find_package(PkgConfig REQUIRED) pkg_search_module(GLIB REQUIRED glib-2.0) +pkg_check_modules(GTK3 REQUIRED gtk+-3.0) - -include_directories(${GLIB_INCLUDE_DIRS}) -link_directories(${GLIB_LINK_DIRS}) +include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS}) +link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS}) +configure_file(glade/main.glade glade/main.glade COPYONLY) project(gds-render) add_executable(${PROJECT_NAME} "main.c" "gdsparse.c") -target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} m) + +target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} m) diff --git a/gdsparse.c b/gdsparse.c index ba15ba4..477e5af 100644 --- a/gdsparse.c +++ b/gdsparse.c @@ -1,3 +1,13 @@ +/* + * What's missing? - A lot: + * Support for Boxes + * Support for 4 Byte real + * Support for pathtypes + * Support for datatypes (only layer so far) + * etc... + */ + + #include "gdsparse.h" #include #include @@ -420,7 +430,7 @@ int parse_gds_from_file(const char *filename, GList **library_list) current_cell = NULL; printf("Leaving Cell\n"); break; - //case BOX: + //case BOX: case BOUNDARY: if (current_cell == NULL) { GDS_ERROR("Boundary outside of cell"); @@ -600,3 +610,30 @@ int parse_gds_from_file(const char *filename, GList **library_list) } + +static void delete_cell_inst_element(struct gds_cell_instance *cell_inst) +{ + free(cell_inst); +} + +static void delete_cell_element(struct gds_cell *cell) +{ + g_list_free_full(cell->child_cells, (GDestroyNotify)delete_cell_inst_element); + free(cell); +} + +static void delete_library_element(struct gds_library *lib) +{ + g_list_free(lib->cell_names); + g_list_free_full(lib->cells, (GDestroyNotify)delete_cell_element); + free(lib); +} + + +int clear_lib_list(GList **library_list) +{ + if (*library_list == NULL) return 0; + g_list_free_full(*library_list, (GDestroyNotify)delete_library_element); + *library_list = NULL; + return 0; +} diff --git a/gdsparse.h b/gdsparse.h index 5624390..f8162c8 100644 --- a/gdsparse.h +++ b/gdsparse.h @@ -57,6 +57,6 @@ struct gds_library { int parse_gds_from_file(const char *filename, GList **library_array); - +int clear_lib_list(GList **library_list); #endif /* __GDSPARSE_H__ */ diff --git a/glade/main.glade b/glade/main.glade new file mode 100644 index 0000000..8faea93 --- /dev/null +++ b/glade/main.glade @@ -0,0 +1,126 @@ + + + + + + True + False + + + + header + True + False + GDS Renderer + GDSII to PDF Converter + True + + + gtk-open + True + True + True + True + True + + + + + + + + True + False + + + True + False + vertical + + + True + True + edit-find-symbolic + False + False + + + False + True + 0 + + + + + True + False + browse + + + True + True + 1 + + + + + False + True + 0 + + + + + layer-list + True + False + + + True + True + 1 + + + + + True + False + vertical + + + gtk-convert + button-convert + True + True + True + True + True + + + + False + True + 0 + + + + + + + + + + + False + True + 2 + + + + + + diff --git a/main.c b/main.c index bc1c02b..fbbe1ee 100644 --- a/main.c +++ b/main.c @@ -1,14 +1,43 @@ #include #include "gdsparse.h" +#include - -int main() +gboolean on_window_close(gpointer window, gpointer user) { - GList *libs = NULL; - unsigned int count = 0; - int i = 0; + gtk_widget_destroy(GTK_WIDGET(window)); + gtk_main_quit(); + return TRUE; +} - parse_gds_from_file("/home/mari/Desktop/test.gds", &libs); +void on_load_gds(gpointer button, gpointer user) +{ + GList **list_ptr = (GList **)user; + + // TODO: File dialog + clear_lib_list(list_ptr); + parse_gds_from_file("/home/mari/Desktop/test.gds", list_ptr); +} + +void on_convert_clicked(gpointer button, gpointer user) +{ + printf("convert\n"); +} + +int main(int argc, char **argv) +{ + GtkBuilder *main_builder; + GList *gds_libs = NULL; + + gtk_init(&argc, &argv); + + main_builder = gtk_builder_new_from_file("glade/main.glade"); + gtk_builder_connect_signals(main_builder, NULL); + + g_signal_connect(GTK_WIDGET(gtk_builder_get_object(main_builder, "button-load-gds")), + "clicked", G_CALLBACK(on_load_gds), (gpointer)&gds_libs); + + + gtk_main(); return 0; }