GDS-Render v1.2.1
activity-bar.c
Go to the documentation of this file.
1/*
2 * GDSII-Converter
3 * Copyright (C) 2019 Mario Hüttel <mario.huettel@gmx.net>
4 *
5 * This file is part of GDSII-Converter.
6 *
7 * GDSII-Converter is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * GDSII-Converter is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/*
21 * The drag and drop implementation is adapted from
22 * https://gitlab.gnome.org/GNOME/gtk/blob/gtk-3-22/tests/testlist3.c
23 *
24 * Thanks to the GTK3 people for creating these examples.
25 */
26
40#include <glib/gi18n.h>
41
44 GtkBox super;
45 /* Private stuff */
46 GtkWidget *spinner;
47 GtkWidget *label;
48};
49
50G_DEFINE_TYPE(ActivityBar, activity_bar, GTK_TYPE_BOX)
51
52static void activity_bar_dispose(GObject *obj)
53{
54 ActivityBar *bar;
55
56 bar = ACTIVITY_BAR(obj);
57
58 /* Clear references on owned objects */
59 g_clear_object(&bar->label);
60 g_clear_object(&bar->spinner);
61
62 /* Chain up */
63 G_OBJECT_CLASS(activity_bar_parent_class)->dispose(obj);
64}
65
66static void activity_bar_class_init(ActivityBarClass *klass)
67{
68 GObjectClass *oclass = G_OBJECT_CLASS(klass);
69
70 oclass->dispose = activity_bar_dispose;
71}
72
73static void activity_bar_init(ActivityBar *self)
74{
75 GtkContainer *box = GTK_CONTAINER(self);
76
77 /* Create Widgets */
78 self->label = gtk_label_new("");
79 self->spinner = gtk_spinner_new();
80
81 /* Add to this widget and show */
82 gtk_container_add(box, self->spinner);
83 gtk_container_add(box, self->label);
84 gtk_widget_show(self->label);
85 gtk_widget_show(self->spinner);
86
87 g_object_ref(self->spinner);
88 g_object_ref(self->label);
89}
90
91ActivityBar *activity_bar_new()
92{
93 ActivityBar *bar;
94
95 bar = ACTIVITY_BAR(g_object_new(TYPE_ACTIVITY_BAR, "orientation", GTK_ORIENTATION_HORIZONTAL, NULL));
96 if (bar)
98
99 return bar;
100}
101
102void activity_bar_set_ready(ActivityBar *bar)
103{
104 gtk_label_set_text(GTK_LABEL(bar->label), _("Ready"));
105 gtk_spinner_stop(GTK_SPINNER(bar->spinner));
106}
107
108void activity_bar_set_busy(ActivityBar *bar, const char *text)
109{
110 gtk_label_set_text(GTK_LABEL(bar->label), (text ? text : _("Working...")));
111 gtk_spinner_start(GTK_SPINNER(bar->spinner));
112}
113
114
Header file for activity bar widget.
static void activity_bar_init(ActivityBar *self)
Definition: activity-bar.c:73
void activity_bar_set_ready(ActivityBar *bar)
Deletes all applied tasks and sets bar to "Ready".
Definition: activity-bar.c:102
static void activity_bar_class_init(ActivityBarClass *klass)
Definition: activity-bar.c:66
static void activity_bar_dispose(GObject *obj)
Definition: activity-bar.c:52
#define TYPE_ACTIVITY_BAR
Definition: activity-bar.h:42
ActivityBar * activity_bar_new()
Create new Object ActivityBar.
Definition: activity-bar.c:91
void activity_bar_set_busy(ActivityBar *bar, const char *text)
Enable spinner and set text. If text is NULL, 'Working...' is displayed.
Definition: activity-bar.c:108
Opaque ActivityBar object. Not viewable outside this source file.
Definition: activity-bar.c:43
GtkWidget * spinner
Definition: activity-bar.c:46
GtkBox super
Definition: activity-bar.c:44
GtkWidget * label
Definition: activity-bar.c:47