Main Window and list clear

* designed basic window
* implemented free function to clear library structures
This commit is contained in:
Mario Hüttel 2018-05-08 15:00:37 +02:00
parent 3cfdc86ef8
commit 7d3b7f96eb
5 changed files with 206 additions and 12 deletions

View File

@ -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)

View File

@ -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 <stdlib.h>
#include <stdio.h>
@ -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;
}

View File

@ -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__ */

126
glade/main.glade Normal file
View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="delete-event" handler="on_window_close" swapped="no"/>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="name">header</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">GDS Renderer</property>
<property name="subtitle" translatable="yes">GDSII to PDF Converter</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkButton" id="button-load-gds">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkListBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">browse</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkListBox">
<property name="name">layer-list</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton">
<property name="label">gtk-convert</property>
<property name="name">button-convert</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

41
main.c
View File

@ -1,14 +1,43 @@
#include <stdio.h>
#include "gdsparse.h"
#include <gtk/gtk.h>
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;
}