4 Commits

25 changed files with 119 additions and 858 deletions

View File

@@ -6,7 +6,7 @@ pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(CAIRO REQUIRED cairo)
add_subdirectory(resources)
add_subdirectory(glade)
add_subdirectory(doxygen)
add_subdirectory(version)
@@ -36,10 +36,10 @@ set(SOURCE
add_compile_options(-Wall)
add_executable(${PROJECT_NAME} ${SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/resources/resources.c)
add_executable(${PROJECT_NAME} ${SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/glade/resources.c)
add_dependencies(${PROJECT_NAME} glib-resources)
add_dependencies(${PROJECT_NAME} version)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/resources/resources.c PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/glade/resources.c PROPERTIES GENERATED 1)
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m version ${CMAKE_DL_LIBS})
install (TARGETS ${PROJECT_NAME} DESTINATION bin)

View File

@@ -33,8 +33,6 @@
#include <cairo-svg.h>
#include <gds-render/cairo-renderer/cairo-output.h>
#include <sys/wait.h>
#include <unistd.h>
/**
* @brief The cairo_layer struct
@@ -183,8 +181,8 @@ static void render_cell(struct gds_cell *cell, struct cairo_layer *layers, doubl
void cairo_render_cell_to_vector_file(struct gds_cell *cell, GList *layer_infos, char *pdf_file, char *svg_file, double scale)
{
cairo_surface_t *pdf_surface = NULL, *svg_surface = NULL;
cairo_t *pdf_cr = NULL, *svg_cr = NULL;
cairo_surface_t *pdf_surface, *svg_surface;
cairo_t *pdf_cr, *svg_cr;
struct layer_info *linfo;
struct cairo_layer *layers;
struct cairo_layer *lay;
@@ -192,26 +190,12 @@ void cairo_render_cell_to_vector_file(struct gds_cell *cell, GList *layer_infos,
int i;
double rec_x0, rec_y0, rec_width, rec_height;
double xmin = INT32_MAX, xmax = INT32_MIN, ymin = INT32_MAX, ymax = INT32_MIN;
pid_t process_id;
if (pdf_file == NULL && svg_file == NULL) {
/* No output specified */
return;
}
/* Fork to a new child process. This ensures the memory leaks (see issue #16) in Cairo don't
* brick everything.
*
* And by the way: This now bricks all Windows compatibility. Deal with it.
*/
process_id = fork();
if (process_id < 0) {
/* Well... shit... We have to run it in our process. */
} else if (process_id > 0) {
/* Woohoo... Successfully dumped the shitty code to an unknowing victim */
goto ret_parent;
}
layers = (struct cairo_layer *)calloc(MAX_LAYERS, sizeof(struct cairo_layer));
/* Clear layers */
@@ -292,15 +276,16 @@ void cairo_render_cell_to_vector_file(struct gds_cell *cell, GList *layer_infos,
continue;
}
if (pdf_file && pdf_cr) {
if (pdf_file) {
cairo_set_source_surface(pdf_cr, layers[linfo->layer].rec, -xmin, -ymin);
cairo_paint_with_alpha(pdf_cr, linfo->color.alpha);
}
if (svg_file && svg_cr) {
if (svg_file) {
cairo_set_source_surface(svg_cr, layers[linfo->layer].rec, -xmin, -ymin);
cairo_paint_with_alpha(svg_cr, linfo->color.alpha);
}
}
if (pdf_file) {
@@ -325,17 +310,7 @@ ret_clear_layers:
}
free(layers);
printf("Cairo export finished. It might still be buggy!\n");
/* If forked, suspend process */
if (process_id == 0)
exit(0);
/* Fork didn't work. Just return here */
return;
ret_parent:
waitpid(process_id, NULL, 0);
return;
printf("cairo export finished. It might still be buggy!\n");
}
/** @} */

View File

@@ -234,7 +234,7 @@ SEPARATE_MEMBER_PAGES = NO
# uses this value to replace tabs by spaces in code fragments.
# Minimum value: 1, maximum value: 16, default value: 4.
TAB_SIZE = 8
TAB_SIZE = 4
# This tag can be used to specify a number of aliases that act as commands in
# the documentation. An alias has the form:

View File

@@ -1,6 +0,0 @@
/**
* @defgroup ActivityBar Activity Bar
* @ingroup Widgets
*
* Activity Status Bar
*/

View File

@@ -31,6 +31,6 @@ In tabular form: *v1.0-rc4-41-gaa41373-dirty*
| 1.0-rc4 | 41 | aa41373 | yes |
This git-based version number is automatically put into the application and this documentation during the application's compilation / the documentation's generation. For this *git* is needed. Therefore, it is highly recommended to have 'git' installed for compilation although it is no build dependency. In case of a missing git installation, the string "! version not set !" is compiled into the application.
This git-based version number is automatically put into the application and this doxumentation during the application's compilation / the documentation's generation. For this *git* is needed. Therefore, it is highly recommended to have 'git' installed for compilation although it is no build dependency. In case of a missing git installation, the string "! version not set !" is compiled into the application.
**/

View File

@@ -34,7 +34,6 @@
#include <gds-render/gds-utils/gds-parser.h>
#include <gds-render/gds-utils/gds-tree-checker.h>
#include <gds-render/layer/layer-selector.h>
#include <gds-render/widgets/activity-bar.h>
#include <gds-render/tree-renderer/tree-store.h>
#include <gds-render/tree-renderer/lib-cell-renderer.h>
#include <gds-render/latex-renderer/latex-output.h>
@@ -59,7 +58,6 @@ struct _GdsRenderGui {
LayerSelector *layer_selector;
GtkTreeView *cell_tree_view;
GList *gds_libraries;
ActivityBar *activity_status_bar;
struct render_settings render_dialog_settings;
};
@@ -444,7 +442,6 @@ static void gds_render_gui_dispose(GObject *gobject)
g_clear_object(&self->layer_selector);
g_clear_object(&self->cell_tree_store);
g_clear_object(&self->cell_search_entry);
g_clear_object(&self->activity_status_bar);
if (self->main_window) {
g_signal_handlers_destroy(self->main_window);
@@ -487,9 +484,8 @@ static void gds_render_gui_init(GdsRenderGui *self)
struct tree_stores *cell_selector_stores;
GtkWidget *sort_up_button;
GtkWidget *sort_down_button;
GtkWidget *activity_bar_box;
main_builder = gtk_builder_new_from_resource("/gui/main.glade");
main_builder = gtk_builder_new_from_resource("/main.glade");
self->cell_tree_view = GTK_TREE_VIEW(gtk_builder_get_object(main_builder, "cell-tree"));
self->cell_search_entry = GTK_WIDGET(gtk_builder_get_object(main_builder, "cell-search"));
@@ -509,7 +505,6 @@ static void gds_render_gui_init(GdsRenderGui *self)
/* Create layer selector */
self->layer_selector = layer_selector_new(GTK_LIST_BOX(listbox));
activity_bar_box = GTK_WIDGET(gtk_builder_get_object(main_builder, "activity-bar"));
/* Callback for selection change of cell selector */
g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(self->cell_tree_view)), "changed",
@@ -540,11 +535,6 @@ static void gds_render_gui_init(GdsRenderGui *self)
g_object_unref(main_builder);
/* Create and apply ActivityBar */
self->activity_status_bar = activity_bar_new();
gtk_container_add(GTK_CONTAINER(activity_bar_box), GTK_WIDGET(self->activity_status_bar));
gtk_widget_show(GTK_WIDGET(self->activity_status_bar));
/* Set default conversion/rendering settings */
self->render_dialog_settings.scale = 1000;
self->render_dialog_settings.renderer = RENDERER_LATEX_TIKZ;
@@ -553,7 +543,6 @@ static void gds_render_gui_init(GdsRenderGui *self)
/* Reference all objects referenced by this object */
g_object_ref(self->activity_status_bar);
g_object_ref(self->main_window);
g_object_ref(self->cell_tree_view);
g_object_ref(self->convert_button);

View File

@@ -53,8 +53,7 @@
#define GDS_WARN(fmt, ...) printf("[PARSE_WARNING] " fmt "\n", ##__VA_ARGS__) /**< @brief Print GDS warning */
#if GDS_PRINT_DEBUG_INFOS
/**< @brief standard printf. But can be disabled in code. */
#define GDS_INF(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define GDS_INF(fmt, ...) printf(fmt, ##__VA_ARGS__) /**< @brief standard printf. But can be disabled in code */
#else
#define GDS_INF(fmt, ...)
#endif
@@ -980,7 +979,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
} else if (current_a_reference) {
name_array_cell_ref(current_a_reference, (unsigned int)read, workbuff);
} else {
GDS_ERROR("Reference name set outside of cell reference");
GDS_ERROR("reference name set outside of cell reference.\n");
}
break;
case WIDTH:

View File

@@ -184,6 +184,7 @@ int gds_tree_check_reference_loops(struct gds_library *lib)
if (res == 0)
fprintf(stderr, "Visited cell list should be empty. This is a bug. Please report this.\n");
g_list_free(visited_cells);
visited_cells = NULL;
}
if (res < 0) {

View File

@@ -2,7 +2,6 @@ add_custom_target(glib-resources DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resources.c
add_custom_command(DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/*.glade
${CMAKE_CURRENT_SOURCE_DIR}/resources.xml
${CMAKE_CURRENT_SOURCE_DIR}/color-palette.txt
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/resources.c
COMMAND

View File

@@ -2,20 +2,15 @@
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="color-img">
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-select-color</property>
<property name="stock">gtk-go-up</property>
</object>
<object class="GtkImage" id="load-mapping-img">
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-open</property>
</object>
<object class="GtkImage" id="save-mapping-img">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-save-as</property>
<property name="stock">gtk-go-down</property>
</object>
<object class="GtkWindow" id="main-window">
<property name="height_request">250</property>
@@ -48,8 +43,6 @@
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">load-mapping-img</property>
<property name="always_show_image">True</property>
<style>
<class name="suggested-action"/>
</style>
@@ -65,8 +58,6 @@
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">save-mapping-img</property>
<property name="always_show_image">True</property>
<style>
<class name="suggested-action"/>
</style>
@@ -99,144 +90,42 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<object class="GtkSearchEntry" id="cell-search">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchEntry" id="cell-search">
<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="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="cell-tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="enable_search">False</property>
<property name="enable_grid_lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<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">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="button-up-sort">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">sort-up-img</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button-down-sort">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">sort-down-img</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="auto-color-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">color-img</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<object class="GtkTreeView" id="cell-tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="layer-list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
</object>
</child>
</object>
<property name="headers_clickable">False</property>
<property name="enable_search">False</property>
<property name="enable_grid_lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
@@ -253,31 +142,83 @@
</packing>
</child>
<child>
<object class="GtkBox" id="activity-bar">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="button-up-sort">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image1</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button-down-sort">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image2</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="layer-list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
</object>
</child>
</object>
</child>
</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">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkImage" id="sort-down-img">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-sort-ascending</property>
</object>
<object class="GtkImage" id="sort-up-img">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-sort-descending</property>
</object>
</interface>

12
glade/resources.xml Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/">
<file compressed="true">main.glade</file>
<file compressed="true">about.glade</file>
<file>layer-widget.glade</file>
<file>dialog.glade</file>
<file compressed="true" alias="logo.svg">../icon/gds-render.svg</file>
</gresource>
</gresources>

View File

@@ -37,21 +37,7 @@
#define GDS_PRINT_DEBUG_INFOS (0) /**< @brief 1: Print infos, 0: Don't print */
/**
* @brief Parse a GDS file
*
* This function parses a GDS File and creates a list of libraries,
* which then contain the different cells.
*
* The function appends The detected libraries to the \p library_array list.
* The library array may be empty, meaning *library_list may be NULL.
*
* @param[in] filename Path to the GDS file
* @param[in,out] library_array GList Pointer.
* @return 0 if successful
*/
int parse_gds_from_file(const char *filename, GList **library_array);
/**
* @brief Deletes all libraries including cells, references etc.
* @param library_list Pointer to a list of #gds_library. Is set to NULL after completion.

View File

@@ -1,70 +0,0 @@
/*
* GDSII-Converter
* Copyright (C) 2019 Mario Hüttel <mario.huettel@gmx.net>
*
* This file is part of GDSII-Converter.
*
* GDSII-Converter is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* GDSII-Converter is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file color-palette.h
* @brief Class representing a color palette
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
#ifndef _COLOR_PALETTE_H_
#define _COLOR_PALETTE_H_
#include <glib.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE(ColorPalette, color_palette, GDS_RENDER, COLOR_PALETTE, GObject);
#define TYPE_GDS_RENDER_COLOR_PALETTE (color_palette_get_type())
/**
* @brief Create a new object with from a resource containing the html hex color scheme
* @param resource_name Name of the resource
* @return New object
*/
ColorPalette *color_palette_new_from_resource(char *resource_name);
/**
* @brief Get the n-th color in the palette identified by the index.
*
* This function fills the nth color into the supplied \p color.
* \p color is returned.
*
* If \p color is NULL, a new GdkRGBA is created and returned.
* This element must be freed afterwards.
*
* @param palette Color palette
* @param color GdkRGBA struct to fill data in. May be NULL.
* @param index Index of color. Starts at 0
* @return GdkRGBA color. If \p color is NULL, the returned color must be freed afterwards
*/
GdkRGBA *color_palette_get_color(ColorPalette *palette, GdkRGBA *color, unsigned int index);
/**
* @brief Return amount of stored colors in \p palette
* @param palette Color palette
* @return Count of colors
*/
unsigned int color_palette_get_color_count(ColorPalette *palette);
G_END_DECLS
#endif /* _COLOR_PALETTE_H_ */

View File

@@ -1,60 +0,0 @@
/*
* GDSII-Converter
* Copyright (C) 2019 Mario Hüttel <mario.huettel@gmx.net>
*
* This file is part of GDSII-Converter.
*
* GDSII-Converter is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* GDSII-Converter is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file activity-bar.h
* @brief Header file for activity bar widget
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
/**
* @addtogroup ActivityBar
* @ingroup Widgets
* @{
*/
#ifndef __LAYER_ELEMENT_H__
#define __LAYER_ELEMENT_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
/* Creates Class structure etc */
G_DECLARE_FINAL_TYPE(ActivityBar, activity_bar, ACTIVITY, BAR, GtkBox)
#define TYPE_ACTIVITY_BAR (activity_bar_get_type())
/**
* @brief Create new Object ActivityBar
* @return New object. In case of error: NULL.
*/
ActivityBar *activity_bar_new();
/**
* @brief Deletes all applied tasks and sets bar to "Ready".
* @param[in] bar AcitivityBar object.
*/
void activity_bar_set_ready(ActivityBar *bar);
G_END_DECLS
#endif /* __LAYER_ELEMENT_H__ */
/** @} */

View File

@@ -19,7 +19,7 @@
/**
* @file layer-element.h
* @brief Implementation of the layer element used for configuring layer colors etc.
* @brief Omplementation of the layer element used for configuring layer colors etc.
* @author Mario Hüttel <mario.huettel@gmx.net>
*/

View File

@@ -1,124 +0,0 @@
/*
* GDSII-Converter
* Copyright (C) 2019 Mario Hüttel <mario.huettel@gmx.net>
*
* This file is part of GDSII-Converter.
*
* GDSII-Converter is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* GDSII-Converter is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file color-palette.c
* @brief Class representing a color palette
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
#include <gds-render/layer/color-palette.h>
struct _ColorPalette {
/* Inheritance */
GObject parent;
/* Custom fields */
/** @brief The internal array to store the colors */
GdkRGBA *color_array;
/** @brief The length of the _ColorPalette::color_array array */
unsigned int color_array_length;
gpointer dummy[4];
};
G_DEFINE_TYPE(ColorPalette, color_palette, G_TYPE_OBJECT)
/**
* @brief color_palette_fill_with_resource
* @param palette
* @param resource_name
* @return 0 if successful
*/
static int color_palette_fill_with_resource(ColorPalette *palette, char *resource_name)
{
GBytes *data;
char *char_array;
if (!palette || !resource_name)
return -1;
data = g_resources_lookup_data(resource_name, 0, NULL);
if (!data)
return -2;
g_bytes_unref(data);
return 0;
}
ColorPalette *color_palette_new_from_resource(char *resource_name)
{
ColorPalette *palette;
palette = GDS_RENDER_COLOR_PALETTE(g_object_new(TYPE_GDS_RENDER_COLOR_PALETTE, NULL));
if (palette)
(void)color_palette_fill_with_resource(palette, resource_name);
return palette;
}
GdkRGBA *color_palette_get_color(ColorPalette *palette, GdkRGBA *color, unsigned int index)
{
GdkRGBA *c = NULL;
if (!palette)
goto ret_c;
if (index >= palette->color_array_length)
goto ret_c;
if (color)
c = color;
else
c = (GdkRGBA *)malloc(sizeof(GdkRGBA));
/* Copy color */
c->red = palette->color_array[index].red;
c->green = palette->color_array[index].green;
c->blue = palette->color_array[index].blue;
c->alpha = palette->color_array[index].alpha;
ret_c:
return c;
}
unsigned int color_palette_get_color_count(ColorPalette *palette)
{
unsigned int return_val = 0;
if (palette)
return_val = palette->color_array_length;
return return_val;
}
static void color_palette_class_init(ColorPaletteClass *klass)
{
(void)klass;
/* Nothing to do for now */
return;
}
static void color_palette_init(ColorPalette *self)
{
self->color_array = NULL;
self->color_array_length = 0;
}

4
main.c
View File

@@ -90,13 +90,13 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_
(void)action;
(void)parameter;
builder = gtk_builder_new_from_resource("/gui/about.glade");
builder = gtk_builder_new_from_resource("/about.glade");
dialog = GTK_DIALOG(gtk_builder_get_object(builder, "about-dialog"));
gtk_window_set_transient_for(GTK_WINDOW(dialog), NULL);
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), _app_version_string);
/* Load icon from resource */
logo_buf = gdk_pixbuf_new_from_resource_at_scale("/images/logo.svg", 100, 100, TRUE, &error);
logo_buf = gdk_pixbuf_new_from_resource_at_scale("/logo.svg", 100, 100, TRUE, &error);
if (logo_buf) {
/* Set logo */
gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), logo_buf);

View File

@@ -1,255 +0,0 @@
800000
008000
808000
000080
800080
008080
c0c0c0
808080
ff0000
00ff00
ffff00
0000ff
ff00ff
00ffff
f105f5
000000
00005f
000087
0000af
0000d7
0000ff
005f00
005f5f
005f87
005faf
005fd7
005fff
008700
00875f
008787
0087af
0087d7
0087ff
00af00
00af5f
00af87
00afaf
00afd7
00afff
00d700
00d75f
00d787
00d7af
00d7d7
00d7ff
00ff00
00ff5f
00ff87
00ffaf
00ffd7
00ffff
5f0000
5f005f
5f0087
5f00af
5f00d7
5f00ff
5f5f00
5f5f5f
5f5f87
5f5faf
5f5fd7
5f5fff
5f8700
5f875f
5f8787
5f87af
5f87d7
5f87ff
5faf00
5faf5f
5faf87
5fafaf
5fafd7
5fafff
5fd700
5fd75f
5fd787
5fd7af
5fd7d7
5fd7ff
5fff00
5fff5f
5fff87
5fffaf
5fffd7
5fffff
870000
87005f
870087
8700af
8700d7
8700ff
875f00
875f5f
875f87
875faf
875fd7
875fff
878700
87875f
878787
8787af
8787d7
8787ff
87af00
87af5f
87af87
87afaf
87afd7
87afff
87d700
87d75f
87d787
87d7af
87d7d7
87d7ff
87ff00
87ff5f
87ff87
87ffaf
87ffd7
87ffff
af0000
af005f
af0087
af00af
af00d7
af00ff
af5f00
af5f5f
af5f87
af5faf
af5fd7
af5fff
af8700
af875f
af8787
af87af
af87d7
af87ff
afaf00
afaf5f
afaf87
afafaf
afafd7
afafff
afd700
afd75f
afd787
afd7af
afd7d7
afd7ff
afff00
afff5f
afff87
afffaf
afffd7
afffff
d70000
d7005f
d70087
d700af
d700d7
d700ff
d75f00
d75f5f
d75f87
d75faf
d75fd7
d75fff
d78700
d7875f
d78787
d787af
d787d7
d787ff
d7af00
d7af5f
d7af87
d7afaf
d7afd7
d7afff
d7d700
d7d75f
d7d787
d7d7af
d7d7d7
d7d7ff
d7ff00
d7ff5f
d7ff87
d7ffaf
d7ffd7
d7ffff
ff0000
ff005f
ff0087
ff00af
ff00d7
ff00ff
ff5f00
ff5f5f
ff5f87
ff5faf
ff5fd7
ff5fff
ff8700
ff875f
ff8787
ff87af
ff87d7
ff87ff
ffaf00
ffaf5f
ffaf87
ffafaf
ffafd7
ffafff
ffd700
ffd75f
ffd787
ffd7af
ffd7d7
ffd7ff
ffff00
ffff5f
ffff87
ffffaf
ffffd7
ffffff
080808
121212
1c1c1c
262626
303030
3a3a3a
444444
4e4e4e
585858
626262
6c6c6c
767676
808080
8a8a8a
949494
9e9e9e
a8a8a8
b2b2b2
bcbcbc
c6c6c6
d0d0d0
dadada
e4e4e4
eeeeee

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/gui">
<file compressed="true">main.glade</file>
<file compressed="true">about.glade</file>
<file>layer-widget.glade</file>
<file>dialog.glade</file>
</gresource>
<gresource prefix="/data">
<file compressed="true">color-palette.txt</file>
</gresource>
<gresource prefix="/images">
<file compressed="true" alias="logo.svg">../icon/gds-render.svg</file>
</gresource>
</gresources>

View File

@@ -1,109 +0,0 @@
/*
* GDSII-Converter
* Copyright (C) 2019 Mario Hüttel <mario.huettel@gmx.net>
*
* This file is part of GDSII-Converter.
*
* GDSII-Converter is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* GDSII-Converter is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* The drag and drop implementation is adapted from
* https://gitlab.gnome.org/GNOME/gtk/blob/gtk-3-22/tests/testlist3.c
*
* Thanks to the GTK3 people for creating these examples.
*/
/**
* @file activity-bar.c
* @brief Status bar indicating activity of the program
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
/**
* @addtogroup ActivityBar
* @ingroup Widgets
* @{
*/
#include <gds-render/widgets/activity-bar.h>
/** @brief Opaque ActivityBar object. Not viewable outside this source file. */
struct _ActivityBar {
GtkBox super;
/* Private stuff */
GtkWidget *spinner;
GtkWidget *label;
};
G_DEFINE_TYPE(ActivityBar, activity_bar, GTK_TYPE_BOX)
static void activity_bar_dispose(GObject *obj)
{
ActivityBar *bar;
bar = ACTIVITY_BAR(obj);
/* Clear references on owned objects */
g_clear_object(&bar->label);
g_clear_object(&bar->spinner);
/* Chain up */
G_OBJECT_CLASS(activity_bar_parent_class)->dispose(obj);
}
static void activity_bar_class_init(ActivityBarClass *klass)
{
GObjectClass *oclass = G_OBJECT_CLASS(klass);
oclass->dispose = activity_bar_dispose;
}
static void activity_bar_init(ActivityBar *self)
{
GtkContainer *box = GTK_CONTAINER(self);
/* Create Widgets */
self->label = gtk_label_new("");
self->spinner = gtk_spinner_new();
/* Add to this widget and show */
gtk_container_add(box, self->spinner);
gtk_container_add(box, self->label);
gtk_widget_show(self->label);
gtk_widget_show(self->spinner);
g_object_ref(self->spinner);
g_object_ref(self->label);
}
ActivityBar *activity_bar_new()
{
ActivityBar *bar;
bar = ACTIVITY_BAR(g_object_new(TYPE_ACTIVITY_BAR, "orientation", GTK_ORIENTATION_HORIZONTAL, NULL));
if (bar)
activity_bar_set_ready(bar);
return bar;
}
/* TODO: Complete this once the task list is fully implemented */
void activity_bar_set_ready(ActivityBar *bar)
{
gtk_label_set_text(GTK_LABEL(bar->label), "Ready");
gtk_spinner_stop(GTK_SPINNER(bar->spinner));
}
/** @} */

View File

@@ -270,7 +270,7 @@ static void renderer_settings_dialog_init(RendererSettingsDialog *self)
dialog = &self->parent;
builder = gtk_builder_new_from_resource("/gui/dialog.glade");
builder = gtk_builder_new_from_resource("/dialog.glade");
box = GTK_WIDGET(gtk_builder_get_object(builder, "dialog-box"));
self->radio_latex = GTK_WIDGET(gtk_builder_get_object(builder, "latex-radio"));
self->radio_cairo_pdf = GTK_WIDGET(gtk_builder_get_object(builder, "cairo-pdf-radio"));

View File

@@ -62,7 +62,7 @@ static void layer_element_init(LayerElement *self)
{
GtkBuilder *builder;
GtkWidget *glade_box;
builder = gtk_builder_new_from_resource("/gui/layer-widget.glade");
builder = gtk_builder_new_from_resource("/layer-widget.glade");
glade_box = GTK_WIDGET(gtk_builder_get_object(builder, "box"));
gtk_container_add(GTK_CONTAINER(self), glade_box);