Compare commits
	
		
			3 Commits
		
	
	
		
			master
			...
			46-open-fi
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| ce50fb708a | |||
| 14b1e8e22f | |||
| bc2fe92e07 | 
							
								
								
									
										136
									
								
								gds-render-gui.c
									
									
									
									
									
								
							
							
						
						
									
										136
									
								
								gds-render-gui.c
									
									
									
									
									
								
							@@ -274,25 +274,13 @@ const struct gds_cell_statistics cc =  {
 | 
			
		||||
 */
 | 
			
		||||
static void on_load_gds(gpointer button, gpointer user)
 | 
			
		||||
{
 | 
			
		||||
	GList *cell;
 | 
			
		||||
	GtkTreeIter libiter;
 | 
			
		||||
	GtkTreeIter celliter;
 | 
			
		||||
	GList *lib;
 | 
			
		||||
	struct gds_library *gds_lib;
 | 
			
		||||
	struct gds_cell *gds_c;
 | 
			
		||||
	(void)button;
 | 
			
		||||
	GdsRenderGui *self;
 | 
			
		||||
	GtkWidget *open_dialog;
 | 
			
		||||
	GtkFileChooser *file_chooser;
 | 
			
		||||
	GtkFileFilter *filter;
 | 
			
		||||
	GtkStyleContext *button_style;
 | 
			
		||||
	gint dialog_result;
 | 
			
		||||
	int gds_result;
 | 
			
		||||
	char *filename;
 | 
			
		||||
	unsigned int cell_error_level;
 | 
			
		||||
 | 
			
		||||
	const struct gds_library_parsing_opts gds_parsing_options = {
 | 
			
		||||
		.simplified_polygons = 1,
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	self = RENDERER_GUI(user);
 | 
			
		||||
	if (!self)
 | 
			
		||||
@@ -319,59 +307,9 @@ static void on_load_gds(gpointer button, gpointer user)
 | 
			
		||||
	/* Get File name */
 | 
			
		||||
	filename = gtk_file_chooser_get_filename(file_chooser);
 | 
			
		||||
 | 
			
		||||
	gtk_tree_store_clear(self->cell_tree_store);
 | 
			
		||||
	clear_lib_list(&self->gds_libraries);
 | 
			
		||||
	gds_render_gui_open_gds(self, filename);
 | 
			
		||||
 | 
			
		||||
	/* Parse new GDSII file */
 | 
			
		||||
	gds_result = parse_gds_from_file(filename, &self->gds_libraries, &gds_parsing_options);
 | 
			
		||||
 | 
			
		||||
	/* Delete file name afterwards */
 | 
			
		||||
	g_free(filename);
 | 
			
		||||
	if (gds_result)
 | 
			
		||||
		goto end_destroy;
 | 
			
		||||
 | 
			
		||||
	/* remove suggested action from Open button */
 | 
			
		||||
	button_style = gtk_widget_get_style_context(GTK_WIDGET(button));
 | 
			
		||||
	gtk_style_context_remove_class(button_style, "suggested-action");
 | 
			
		||||
 | 
			
		||||
	for (lib = self->gds_libraries; lib != NULL; lib = lib->next) {
 | 
			
		||||
		gds_lib = (struct gds_library *)lib->data;
 | 
			
		||||
		/* Create top level iter */
 | 
			
		||||
		gtk_tree_store_append(self->cell_tree_store, &libiter, NULL);
 | 
			
		||||
 | 
			
		||||
		gtk_tree_store_set(self->cell_tree_store, &libiter,
 | 
			
		||||
				   CELL_SEL_LIBRARY, gds_lib,
 | 
			
		||||
				   -1);
 | 
			
		||||
 | 
			
		||||
		/* Check this library. This might take a while */
 | 
			
		||||
		(void)gds_tree_check_cell_references(gds_lib);
 | 
			
		||||
		(void)gds_tree_check_reference_loops(gds_lib);
 | 
			
		||||
 | 
			
		||||
		for (cell = gds_lib->cells; cell != NULL; cell = cell->next) {
 | 
			
		||||
			gds_c = (struct gds_cell *)cell->data;
 | 
			
		||||
			gtk_tree_store_append(self->cell_tree_store, &celliter, &libiter);
 | 
			
		||||
 | 
			
		||||
			/* Get the checking results for this cell */
 | 
			
		||||
			cell_error_level = 0;
 | 
			
		||||
			if (gds_c->checks.unresolved_child_count)
 | 
			
		||||
				cell_error_level |= LIB_CELL_RENDERER_ERROR_WARN;
 | 
			
		||||
 | 
			
		||||
			/* Check if it is completely b0rken */
 | 
			
		||||
			if (gds_c->checks.affected_by_reference_loop)
 | 
			
		||||
				cell_error_level |= LIB_CELL_RENDERER_ERROR_ERR;
 | 
			
		||||
 | 
			
		||||
			/* Add cell to tree store model */
 | 
			
		||||
			gtk_tree_store_set(self->cell_tree_store, &celliter,
 | 
			
		||||
					   CELL_SEL_CELL, gds_c,
 | 
			
		||||
					   CELL_SEL_CELL_ERROR_STATE, cell_error_level,
 | 
			
		||||
					   CELL_SEL_LIBRARY, gds_c->parent_library,
 | 
			
		||||
					   CELL_SEL_STAT, &gds_c->stats,
 | 
			
		||||
					   -1);
 | 
			
		||||
		} /* for cells */
 | 
			
		||||
	} /* for libraries */
 | 
			
		||||
 | 
			
		||||
	/* Create Layers in Layer Box */
 | 
			
		||||
	layer_selector_generate_layer_widgets(self->layer_selector, self->gds_libraries);
 | 
			
		||||
 | 
			
		||||
end_destroy:
 | 
			
		||||
	/* Destroy dialog and filter */
 | 
			
		||||
@@ -758,6 +696,76 @@ GtkWindow *gds_render_gui_get_main_window(GdsRenderGui *gui)
 | 
			
		||||
	return gui->main_window;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void gds_render_gui_open_gds(GdsRenderGui *self, const char *path)
 | 
			
		||||
{
 | 
			
		||||
	GList *cell;
 | 
			
		||||
	GtkTreeIter libiter;
 | 
			
		||||
	GtkTreeIter celliter;
 | 
			
		||||
	GList *lib;
 | 
			
		||||
	struct gds_library *gds_lib;
 | 
			
		||||
	struct gds_cell *gds_c;
 | 
			
		||||
	GtkStyleContext *button_style;
 | 
			
		||||
	int gds_result;
 | 
			
		||||
	unsigned int cell_error_level;
 | 
			
		||||
 | 
			
		||||
	const struct gds_library_parsing_opts gds_parsing_options = {
 | 
			
		||||
		.simplified_polygons = 1,
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	gtk_tree_store_clear(self->cell_tree_store);
 | 
			
		||||
	clear_lib_list(&self->gds_libraries);
 | 
			
		||||
 | 
			
		||||
	/* Parse new GDSII file */
 | 
			
		||||
	gds_result = parse_gds_from_file(path, &self->gds_libraries, &gds_parsing_options);
 | 
			
		||||
 | 
			
		||||
	/* Delete file name afterwards */
 | 
			
		||||
	if (gds_result)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	/* remove suggested action from Open button */
 | 
			
		||||
	button_style = gtk_widget_get_style_context(self->open_button);
 | 
			
		||||
	gtk_style_context_remove_class(button_style, "suggested-action");
 | 
			
		||||
 | 
			
		||||
	for (lib = self->gds_libraries; lib != NULL; lib = lib->next) {
 | 
			
		||||
		gds_lib = (struct gds_library *)lib->data;
 | 
			
		||||
		/* Create top level iter */
 | 
			
		||||
		gtk_tree_store_append(self->cell_tree_store, &libiter, NULL);
 | 
			
		||||
 | 
			
		||||
		gtk_tree_store_set(self->cell_tree_store, &libiter,
 | 
			
		||||
				   CELL_SEL_LIBRARY, gds_lib,
 | 
			
		||||
				   -1);
 | 
			
		||||
 | 
			
		||||
		/* Check this library. This might take a while */
 | 
			
		||||
		(void)gds_tree_check_cell_references(gds_lib);
 | 
			
		||||
		(void)gds_tree_check_reference_loops(gds_lib);
 | 
			
		||||
 | 
			
		||||
		for (cell = gds_lib->cells; cell != NULL; cell = cell->next) {
 | 
			
		||||
			gds_c = (struct gds_cell *)cell->data;
 | 
			
		||||
			gtk_tree_store_append(self->cell_tree_store, &celliter, &libiter);
 | 
			
		||||
 | 
			
		||||
			/* Get the checking results for this cell */
 | 
			
		||||
			cell_error_level = 0;
 | 
			
		||||
			if (gds_c->checks.unresolved_child_count)
 | 
			
		||||
				cell_error_level |= LIB_CELL_RENDERER_ERROR_WARN;
 | 
			
		||||
 | 
			
		||||
			/* Check if it is completely b0rken */
 | 
			
		||||
			if (gds_c->checks.affected_by_reference_loop)
 | 
			
		||||
				cell_error_level |= LIB_CELL_RENDERER_ERROR_ERR;
 | 
			
		||||
 | 
			
		||||
			/* Add cell to tree store model */
 | 
			
		||||
			gtk_tree_store_set(self->cell_tree_store, &celliter,
 | 
			
		||||
					   CELL_SEL_CELL, gds_c,
 | 
			
		||||
					   CELL_SEL_CELL_ERROR_STATE, cell_error_level,
 | 
			
		||||
					   CELL_SEL_LIBRARY, gds_c->parent_library,
 | 
			
		||||
					   CELL_SEL_STAT, &gds_c->stats,
 | 
			
		||||
					   -1);
 | 
			
		||||
		} /* for cells */
 | 
			
		||||
	} /* for libraries */
 | 
			
		||||
 | 
			
		||||
	/* Create Layers in Layer Box */
 | 
			
		||||
	layer_selector_generate_layer_widgets(self->layer_selector, self->gds_libraries);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void gds_render_gui_init(GdsRenderGui *self)
 | 
			
		||||
{
 | 
			
		||||
	GtkBuilder *main_builder;
 | 
			
		||||
 
 | 
			
		||||
@@ -54,6 +54,13 @@ GdsRenderGui *gds_render_gui_new();
 | 
			
		||||
 */
 | 
			
		||||
GtkWindow *gds_render_gui_get_main_window(GdsRenderGui *gui);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief gds_render_gui_open_gds Open a GDS file. Emulates the manual load via GUI open button
 | 
			
		||||
 * @param self GUI instance
 | 
			
		||||
 * @param path file path
 | 
			
		||||
 */
 | 
			
		||||
void gds_render_gui_open_gds(GdsRenderGui *self, const char *path);
 | 
			
		||||
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										36
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								main.c
									
									
									
									
									
								
							@@ -40,6 +40,8 @@
 | 
			
		||||
struct application_data {
 | 
			
		||||
		GtkApplication *app;
 | 
			
		||||
		GList *gui_list;
 | 
			
		||||
		gint num_files_to_open;
 | 
			
		||||
		GFile **files;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -158,6 +160,7 @@ static void gapp_activate(GApplication *app, gpointer user_data)
 | 
			
		||||
{
 | 
			
		||||
	GtkWindow *main_window;
 | 
			
		||||
	GdsRenderGui *gui;
 | 
			
		||||
	char *open_file_path;
 | 
			
		||||
	struct application_data * const appdata = (struct application_data *)user_data;
 | 
			
		||||
 | 
			
		||||
	gui = gds_render_gui_new();
 | 
			
		||||
@@ -166,11 +169,32 @@ static void gapp_activate(GApplication *app, gpointer user_data)
 | 
			
		||||
	g_signal_connect(gui, "window-closed", G_CALLBACK(gui_window_closed_callback), &appdata->gui_list);
 | 
			
		||||
 | 
			
		||||
	main_window = gds_render_gui_get_main_window(gui);
 | 
			
		||||
 | 
			
		||||
	if (appdata->num_files_to_open >= 1) {
 | 
			
		||||
		/* Open first file. Multiple files are not supported and ignored */
 | 
			
		||||
		open_file_path = g_file_get_path(appdata->files[0]);
 | 
			
		||||
		gds_render_gui_open_gds(gui, open_file_path);
 | 
			
		||||
		g_free(open_file_path);
 | 
			
		||||
	}
 | 
			
		||||
	gtk_application_add_window(GTK_APPLICATION(app), main_window);
 | 
			
		||||
	gtk_widget_show(GTK_WIDGET(main_window));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Activation of GUI when opening a file from commandline
 | 
			
		||||
 * @param app he GApplication reference
 | 
			
		||||
 * @param user_data Used to store the individual GUI instances.
 | 
			
		||||
 */
 | 
			
		||||
static void gapp_activate_open(GApplication *app, GFile** files, gint n_files, const gchar* hint, gpointer user_data)
 | 
			
		||||
{
 | 
			
		||||
	(void)hint;
 | 
			
		||||
	struct application_data *appdata = (struct application_data *)user_data;
 | 
			
		||||
 | 
			
		||||
	appdata->files = files;
 | 
			
		||||
	appdata->num_files_to_open = n_files;
 | 
			
		||||
 | 
			
		||||
	gapp_activate(app, user_data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Start the graphical interface.
 | 
			
		||||
 *
 | 
			
		||||
@@ -188,7 +212,9 @@ static int start_gui(int argc, char **argv)
 | 
			
		||||
	GString *application_domain;
 | 
			
		||||
	int app_status;
 | 
			
		||||
	static struct application_data appdata = {
 | 
			
		||||
		.gui_list = NULL
 | 
			
		||||
		.gui_list = NULL,
 | 
			
		||||
		.num_files_to_open = 0,
 | 
			
		||||
		.files = NULL,
 | 
			
		||||
	};
 | 
			
		||||
	GMenu *menu;
 | 
			
		||||
	GMenu *m_quit;
 | 
			
		||||
@@ -201,10 +227,11 @@ static int start_gui(int argc, char **argv)
 | 
			
		||||
	application_domain = g_string_new(NULL);
 | 
			
		||||
	g_string_printf(application_domain, "de.shimatta.gds_render_%s", _app_git_commit);
 | 
			
		||||
 | 
			
		||||
	gapp = gtk_application_new(application_domain->str, G_APPLICATION_FLAGS_NONE);
 | 
			
		||||
	gapp = gtk_application_new(application_domain->str, G_APPLICATION_HANDLES_OPEN);
 | 
			
		||||
	g_string_free(application_domain, TRUE);
 | 
			
		||||
 | 
			
		||||
	g_application_register(G_APPLICATION(gapp), NULL, NULL);
 | 
			
		||||
	g_signal_connect(gapp, "open", G_CALLBACK(gapp_activate_open), &appdata);
 | 
			
		||||
	g_signal_connect(gapp, "activate", G_CALLBACK(gapp_activate), &appdata);
 | 
			
		||||
 | 
			
		||||
	if (g_application_get_is_remote(G_APPLICATION(gapp)) == TRUE) {
 | 
			
		||||
@@ -311,7 +338,8 @@ int main(int argc, char **argv)
 | 
			
		||||
		goto ret_status;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (argc >= 2) {
 | 
			
		||||
	/* A minimum of a file name and a cell or analyze command are needed to use CLI */
 | 
			
		||||
	if (argc >= 2 && (analyze || cellname || output_paths)) {
 | 
			
		||||
		if (scale < 1) {
 | 
			
		||||
			printf(_("Scale < 1 not allowed. Setting to 1\n"));
 | 
			
		||||
			scale = 1;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user