2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
5 * Copyright (C) 2011, Rob Norris <rw_norris@hotmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 /* gtk status bars: just plain dumb. this file shouldn't have to exist.
24 NB as of gtk 2.18 there are 'info bars' that could be useful... */
27 #include "vikstatus.h"
29 struct _VikStatusbar {
31 GtkWidget *status[VIK_STATUSBAR_NUM_TYPES];
32 gboolean empty[VIK_STATUSBAR_NUM_TYPES];
35 GType vik_statusbar_get_type (void)
37 static GType vs_type = 0;
41 static const GTypeInfo vs_info =
43 sizeof (VikStatusbarClass),
45 NULL, /* base_finalize */
46 NULL, /* class init */
47 NULL, /* class_finalize */
48 NULL, /* class_data */
49 sizeof (VikStatusbar),
51 NULL /* instance init */
53 vs_type = g_type_register_static ( GTK_TYPE_HBOX, "VikStatusbar", &vs_info, 0 );
62 * Creates a new #VikStatusbar widget.
64 * Return value: the new #VikStatusbar widget.
66 VikStatusbar *vik_statusbar_new ()
68 VikStatusbar *vs = VIK_STATUSBAR ( g_object_new ( VIK_STATUSBAR_TYPE, NULL ) );
71 for ( i = 0; i < VIK_STATUSBAR_NUM_TYPES; i++ ) {
73 vs->status[i] = gtk_statusbar_new();
74 gtk_statusbar_set_has_resize_grip ( GTK_STATUSBAR(vs->status[i]), FALSE );
77 gtk_box_pack_start ( GTK_BOX(vs), vs->status[VIK_STATUSBAR_TOOL], FALSE, FALSE, 1);
78 gtk_widget_set_size_request ( vs->status[VIK_STATUSBAR_TOOL], 150, -1 );
80 gtk_box_pack_start ( GTK_BOX(vs), vs->status[VIK_STATUSBAR_ITEMS], FALSE, FALSE, 1);
81 gtk_widget_set_size_request ( vs->status[VIK_STATUSBAR_ITEMS], 100, -1 );
83 gtk_box_pack_start ( GTK_BOX(vs), vs->status[VIK_STATUSBAR_ZOOM], FALSE, FALSE, 1);
84 gtk_widget_set_size_request ( vs->status[VIK_STATUSBAR_ZOOM], 100, -1 );
86 gtk_box_pack_start ( GTK_BOX(vs), vs->status[VIK_STATUSBAR_POSITION], FALSE, FALSE, 1);
87 gtk_widget_set_size_request ( vs->status[VIK_STATUSBAR_POSITION], 250, -1 );
89 gtk_box_pack_end ( GTK_BOX(vs), vs->status[VIK_STATUSBAR_INFO], TRUE, TRUE, 1);
91 // Set minimum overall size
92 // otherwise the individual size_requests above create an implicit overall size,
93 // and so one can't downsize horizontally as much as may be desired when the statusbar is on
94 gtk_widget_set_size_request ( GTK_WIDGET(vs), 50, -1 );
100 * vik_statusbar_set_message:
101 * @vs: the #VikStatusbar itself
102 * @field: the field to update
103 * @message: the message to use
105 * Update the message of the given field.
107 void vik_statusbar_set_message ( VikStatusbar *vs, vik_statusbar_type_t field, const gchar *message )
109 if ( field >= 0 && field < VIK_STATUSBAR_NUM_TYPES )
111 GtkStatusbar *gsb = GTK_STATUSBAR(vs->status[field]);
113 if ( !vs->empty[field] )
114 gtk_statusbar_pop ( gsb, 0 );
116 vs->empty[field] = FALSE;
118 gtk_statusbar_push ( gsb, 0, message );