gui: split gui/main.c into smaller parts
[ladish.git] / gui / statusbar.c
blob30b6c923599e4abab534ec6f518453f773155124
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains implementation of the statusbar helpers
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "statusbar.h"
28 #include "gtk_builder.h"
30 static GtkStatusbar * g_statusbar;
31 static GtkWidget * g_studio_status_label;
32 static GtkWidget * g_status_image;
33 static GtkWidget * g_sample_rate_label;
34 static GtkWidget * g_latency_label;
35 static GtkWidget * g_xruns_label;
36 static GtkWidget * g_dsp_load_label;
38 static void pack_statusbar_widget(GtkWidget * widget)
40 static int index;
42 gtk_widget_show(widget);
43 gtk_box_pack_start(GTK_BOX(g_statusbar), widget, FALSE, TRUE, 10);
44 gtk_box_reorder_child(GTK_BOX(g_statusbar), widget, index++);
47 static void init_statusbar_label_widget(const char * id, GtkWidget ** widget_ptr_ptr)
49 *widget_ptr_ptr = gtk_label_new(id);
50 pack_statusbar_widget(*widget_ptr_ptr);
53 void init_statusbar(void)
55 g_statusbar = GTK_STATUSBAR(get_gtk_builder_widget("statusbar"));
57 init_statusbar_label_widget("studioname", &g_studio_status_label);
59 g_status_image = gtk_image_new();
60 pack_statusbar_widget(g_status_image);
62 init_statusbar_label_widget("srate", &g_sample_rate_label);
63 init_statusbar_label_widget("latency", &g_latency_label);
64 init_statusbar_label_widget("xruns", &g_xruns_label);
65 init_statusbar_label_widget("load", &g_dsp_load_label);
68 void set_studio_status_text(const char * text)
70 gtk_label_set_text(GTK_LABEL(g_studio_status_label), text);
73 GtkImage * get_status_image(void)
75 return GTK_IMAGE(g_status_image);
78 void set_latency_text(const char * text)
80 gtk_label_set_text(GTK_LABEL(g_latency_label), text);
83 void clear_latency_text(void)
85 gtk_label_set_text(GTK_LABEL(g_latency_label), "");
88 void set_dsp_load_text(const char * text)
90 gtk_label_set_text(GTK_LABEL(g_dsp_load_label), text);
93 void clear_dsp_load_text(void)
95 gtk_label_set_text(GTK_LABEL(g_dsp_load_label), "");
98 void set_xruns_text(const char * text)
100 gtk_label_set_text(GTK_LABEL(g_xruns_label), text);
103 void clear_xruns_text(void)
105 gtk_label_set_text(GTK_LABEL(g_xruns_label), "");
108 void set_sample_rate_text(const char * text)
110 gtk_label_set_text(GTK_LABEL(g_sample_rate_label), text);
113 void clear_sample_rate_text(void)
115 gtk_label_set_text(GTK_LABEL(g_sample_rate_label), "");