diff --git a/doxygen/activity-bar.dox b/doxygen/activity-bar.dox new file mode 100644 index 0000000..34432ac --- /dev/null +++ b/doxygen/activity-bar.dox @@ -0,0 +1,6 @@ +/** + * @defgroup ActivityBar + * @ingroup Widgets + * + * Activity Status Bar + */ diff --git a/gds-render-gui.c b/gds-render-gui.c index 54e7938..a0df455 100644 --- a/gds-render-gui.c +++ b/gds-render-gui.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,7 @@ struct _GdsRenderGui { LayerSelector *layer_selector; GtkTreeView *cell_tree_view; GList *gds_libraries; + ActivityBar *activity_status_bar; struct render_settings render_dialog_settings; }; @@ -442,6 +444,7 @@ 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); @@ -484,6 +487,7 @@ 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"); @@ -505,6 +509,7 @@ 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", @@ -535,6 +540,11 @@ 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; @@ -543,6 +553,7 @@ 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); diff --git a/include/gds-render/widgets/activity-bar.h b/include/gds-render/widgets/activity-bar.h new file mode 100644 index 0000000..37ef801 --- /dev/null +++ b/include/gds-render/widgets/activity-bar.h @@ -0,0 +1,60 @@ +/* + * GDSII-Converter + * Copyright (C) 2019 Mario Hüttel + * + * 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 . + */ + +/** + * @file activity-bar.h + * @brief Header file for activity bar widget + * @author Mario Hüttel + */ + +/** + * @addtogroup ActivityBar + * @ingroup Widgets + * @{ + */ + +#ifndef __LAYER_ELEMENT_H__ +#define __LAYER_ELEMENT_H__ + +#include + +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__ */ + +/** @} */ diff --git a/widgets/activity-bar.c b/widgets/activity-bar.c new file mode 100644 index 0000000..94e2474 --- /dev/null +++ b/widgets/activity-bar.c @@ -0,0 +1,109 @@ +/* + * GDSII-Converter + * Copyright (C) 2019 Mario Hüttel + * + * 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 . + */ + +/* + * 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 + */ + +/** + * @addtogroup ActivityBar + * @ingroup Widgets + * @{ + */ + +#include + +/** @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)); +} + + +/** @} */