layer element created, dialog for multiple files added
This commit is contained in:
parent
1539348cc6
commit
aea3b490ca
@ -9,7 +9,7 @@ link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS})
|
|||||||
configure_file(glade/main.glade glade/main.glade COPYONLY)
|
configure_file(glade/main.glade glade/main.glade COPYONLY)
|
||||||
|
|
||||||
project(gds-render)
|
project(gds-render)
|
||||||
add_executable(${PROJECT_NAME} "main.c" "gdsparse.c")
|
add_executable(${PROJECT_NAME} "main.c" "gdsparse.c" "layer-element.c")
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} m)
|
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} m)
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox" id="button-box">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
|
20
layer-element.c
Normal file
20
layer-element.c
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include "layer-element.h"
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (LayerElement, layer_element, GTK_TYPE_BOX)
|
||||||
|
|
||||||
|
static void layer_element_class_init(LayerElementClass *klass)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void layer_element_init(LayerElement *self)
|
||||||
|
{
|
||||||
|
self->button = gtk_button_new();
|
||||||
|
gtk_box_pack_start(GTK_BOX(self), self->button, TRUE, TRUE, 0);
|
||||||
|
gtk_widget_show(self->button);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *layer_element_new(void)
|
||||||
|
{
|
||||||
|
return GTK_WIDGET(g_object_new(layer_element_get_type(), NULL));
|
||||||
|
}
|
26
layer-element.h
Normal file
26
layer-element.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef __LAYER_ELEMENT_H__
|
||||||
|
#define __LAYER_ELEMENT_H__
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
// #include <gdk/gdk.h>
|
||||||
|
|
||||||
|
#define LAYER_ELEMENT(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, layer_element_get_type(), LayerElement)
|
||||||
|
#define LAYER_ELEMENT_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, layer_element_get_type(), LayerElementClass)
|
||||||
|
#define IS_LAYE_RELEMENT(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, layer_element_get_type())
|
||||||
|
|
||||||
|
typedef struct _LayerElement {
|
||||||
|
/* Inheritance */
|
||||||
|
GtkBox hbox;
|
||||||
|
/* Custom Elements */
|
||||||
|
GtkWidget *button;
|
||||||
|
} LayerElement;
|
||||||
|
|
||||||
|
typedef struct _LayerElementClass {
|
||||||
|
GtkBoxClass parent_class;
|
||||||
|
} LayerElementClass;
|
||||||
|
|
||||||
|
|
||||||
|
GType layer_element_get_type(void);
|
||||||
|
GtkWidget *layer_element_new(void);
|
||||||
|
|
||||||
|
#endif /* __LAYER_ELEMENT_H__ */
|
22
main.c
22
main.c
@ -20,6 +20,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "gdsparse.h"
|
#include "gdsparse.h"
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include "layer-element.h"
|
||||||
|
|
||||||
|
|
||||||
enum cell_store_columns {
|
enum cell_store_columns {
|
||||||
LIBRARY,
|
LIBRARY,
|
||||||
@ -58,6 +60,7 @@ void on_load_gds(gpointer button, gpointer user)
|
|||||||
GtkTreeStore *store = ptr->cell_store;
|
GtkTreeStore *store = ptr->cell_store;
|
||||||
GtkWidget *open_dialog;
|
GtkWidget *open_dialog;
|
||||||
GtkFileChooser *file_chooser;
|
GtkFileChooser *file_chooser;
|
||||||
|
GtkWidget *msg_dialog;
|
||||||
GtkFileFilter *filter;
|
GtkFileFilter *filter;
|
||||||
GtkStyleContext *button_style;
|
GtkStyleContext *button_style;
|
||||||
gint dialog_result;
|
gint dialog_result;
|
||||||
@ -80,11 +83,24 @@ void on_load_gds(gpointer button, gpointer user)
|
|||||||
/* Get File name */
|
/* Get File name */
|
||||||
filename = gtk_file_chooser_get_filename(file_chooser);
|
filename = gtk_file_chooser_get_filename(file_chooser);
|
||||||
|
|
||||||
/* Clear Display */
|
if (*ptr->list_ptr) {
|
||||||
|
/* Libraries present */
|
||||||
|
msg_dialog =
|
||||||
|
gtk_message_dialog_new(ptr->main_window, GTK_DIALOG_USE_HEADER_BAR,
|
||||||
|
GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
|
||||||
|
"There's already data present? Delete old data?");
|
||||||
|
dialog_result = gtk_dialog_run(GTK_DIALOG(msg_dialog));
|
||||||
|
gtk_widget_destroy(msg_dialog);
|
||||||
|
} else
|
||||||
|
dialog_result = GTK_RESPONSE_YES;
|
||||||
|
|
||||||
|
/* Clear Display Will be completely refreshed in any case */
|
||||||
gtk_tree_store_clear(store);
|
gtk_tree_store_clear(store);
|
||||||
|
|
||||||
|
if (dialog_result == GTK_RESPONSE_YES) {
|
||||||
/* Delete parsed GDS data */
|
/* Delete parsed GDS data */
|
||||||
clear_lib_list(ptr->list_ptr);
|
clear_lib_list(ptr->list_ptr);
|
||||||
|
}
|
||||||
/* Parse new GDSII file */
|
/* Parse new GDSII file */
|
||||||
gds_result = parse_gds_from_file(filename, ptr->list_ptr);
|
gds_result = parse_gds_from_file(filename, ptr->list_ptr);
|
||||||
|
|
||||||
@ -145,6 +161,7 @@ int main(int argc, char **argv)
|
|||||||
GList *gds_libs = NULL;
|
GList *gds_libs = NULL;
|
||||||
GtkTreeView *cell_tree;
|
GtkTreeView *cell_tree;
|
||||||
GtkTreeStore *cell_store;
|
GtkTreeStore *cell_store;
|
||||||
|
|
||||||
struct open_button_data open_data;
|
struct open_button_data open_data;
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
@ -165,6 +182,7 @@ int main(int argc, char **argv)
|
|||||||
"clicked", G_CALLBACK(on_load_gds), (gpointer)&open_data);
|
"clicked", G_CALLBACK(on_load_gds), (gpointer)&open_data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user