Add ActivityBar widget
This commit is contained in:
parent
082a823575
commit
9b0f268bbd
6
doxygen/activity-bar.dox
Normal file
6
doxygen/activity-bar.dox
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* @defgroup ActivityBar
|
||||||
|
* @ingroup Widgets
|
||||||
|
*
|
||||||
|
* Activity Status Bar
|
||||||
|
*/
|
@ -34,6 +34,7 @@
|
|||||||
#include <gds-render/gds-utils/gds-parser.h>
|
#include <gds-render/gds-utils/gds-parser.h>
|
||||||
#include <gds-render/gds-utils/gds-tree-checker.h>
|
#include <gds-render/gds-utils/gds-tree-checker.h>
|
||||||
#include <gds-render/layer/layer-selector.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/tree-store.h>
|
||||||
#include <gds-render/tree-renderer/lib-cell-renderer.h>
|
#include <gds-render/tree-renderer/lib-cell-renderer.h>
|
||||||
#include <gds-render/latex-renderer/latex-output.h>
|
#include <gds-render/latex-renderer/latex-output.h>
|
||||||
@ -58,6 +59,7 @@ struct _GdsRenderGui {
|
|||||||
LayerSelector *layer_selector;
|
LayerSelector *layer_selector;
|
||||||
GtkTreeView *cell_tree_view;
|
GtkTreeView *cell_tree_view;
|
||||||
GList *gds_libraries;
|
GList *gds_libraries;
|
||||||
|
ActivityBar *activity_status_bar;
|
||||||
struct render_settings render_dialog_settings;
|
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->layer_selector);
|
||||||
g_clear_object(&self->cell_tree_store);
|
g_clear_object(&self->cell_tree_store);
|
||||||
g_clear_object(&self->cell_search_entry);
|
g_clear_object(&self->cell_search_entry);
|
||||||
|
g_clear_object(&self->activity_status_bar);
|
||||||
|
|
||||||
if (self->main_window) {
|
if (self->main_window) {
|
||||||
g_signal_handlers_destroy(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;
|
struct tree_stores *cell_selector_stores;
|
||||||
GtkWidget *sort_up_button;
|
GtkWidget *sort_up_button;
|
||||||
GtkWidget *sort_down_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("/gui/main.glade");
|
||||||
|
|
||||||
@ -505,6 +509,7 @@ static void gds_render_gui_init(GdsRenderGui *self)
|
|||||||
/* Create layer selector */
|
/* Create layer selector */
|
||||||
self->layer_selector = layer_selector_new(GTK_LIST_BOX(listbox));
|
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 */
|
/* Callback for selection change of cell selector */
|
||||||
g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(self->cell_tree_view)), "changed",
|
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);
|
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 */
|
/* Set default conversion/rendering settings */
|
||||||
self->render_dialog_settings.scale = 1000;
|
self->render_dialog_settings.scale = 1000;
|
||||||
self->render_dialog_settings.renderer = RENDERER_LATEX_TIKZ;
|
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 */
|
/* Reference all objects referenced by this object */
|
||||||
|
g_object_ref(self->activity_status_bar);
|
||||||
g_object_ref(self->main_window);
|
g_object_ref(self->main_window);
|
||||||
g_object_ref(self->cell_tree_view);
|
g_object_ref(self->cell_tree_view);
|
||||||
g_object_ref(self->convert_button);
|
g_object_ref(self->convert_button);
|
||||||
|
60
include/gds-render/widgets/activity-bar.h
Normal file
60
include/gds-render/widgets/activity-bar.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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__ */
|
||||||
|
|
||||||
|
/** @} */
|
109
widgets/activity-bar.c
Normal file
109
widgets/activity-bar.c
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
* 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** @} */
|
Loading…
Reference in New Issue
Block a user