]> git.street.me.uk Git - andy/viking.git/blame_incremental - src/vikstatus.c
Scale waypoint icons to give large or small icons as necessary.
[andy/viking.git] / src / vikstatus.c
... / ...
CommitLineData
1/*
2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3 *
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
5 * Copyright (C) 2011, Rob Norris <rw_norris@hotmail.com>
6 *
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.
11 *
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.
16 *
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
20 *
21 */
22
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... */
25#include <gtk/gtk.h>
26
27#include "vikstatus.h"
28
29struct _VikStatusbar {
30 GtkHBox hbox;
31 GtkWidget *status[VIK_STATUSBAR_NUM_TYPES];
32 gboolean empty[VIK_STATUSBAR_NUM_TYPES];
33};
34
35GType vik_statusbar_get_type (void)
36{
37 static GType vs_type = 0;
38
39 if (!vs_type)
40 {
41 static const GTypeInfo vs_info =
42 {
43 sizeof (VikStatusbarClass),
44 NULL, /* base_init */
45 NULL, /* base_finalize */
46 NULL, /* class init */
47 NULL, /* class_finalize */
48 NULL, /* class_data */
49 sizeof (VikStatusbar),
50 0,
51 NULL /* instance init */
52 };
53 vs_type = g_type_register_static ( GTK_TYPE_HBOX, "VikStatusbar", &vs_info, 0 );
54 }
55
56 return vs_type;
57}
58
59VikStatusbar *vik_statusbar_new ()
60{
61 VikStatusbar *vs = VIK_STATUSBAR ( g_object_new ( VIK_STATUSBAR_TYPE, NULL ) );
62 gint i;
63
64 for ( i = 0; i < VIK_STATUSBAR_NUM_TYPES; i++ ) {
65 vs->empty[i] = TRUE;
66 vs->status[i] = gtk_statusbar_new();
67 gtk_statusbar_set_has_resize_grip ( GTK_STATUSBAR(vs->status[i]), FALSE );
68 }
69
70 gtk_box_pack_start ( GTK_BOX(vs), vs->status[VIK_STATUSBAR_TOOL], FALSE, FALSE, 1);
71 gtk_widget_set_size_request ( vs->status[VIK_STATUSBAR_TOOL], 150, -1 );
72
73 gtk_box_pack_start ( GTK_BOX(vs), vs->status[VIK_STATUSBAR_ITEMS], FALSE, FALSE, 1);
74 gtk_widget_set_size_request ( vs->status[VIK_STATUSBAR_ITEMS], 100, -1 );
75
76 gtk_box_pack_start ( GTK_BOX(vs), vs->status[VIK_STATUSBAR_ZOOM], FALSE, FALSE, 1);
77 gtk_widget_set_size_request ( vs->status[VIK_STATUSBAR_ZOOM], 100, -1 );
78
79 gtk_box_pack_start ( GTK_BOX(vs), vs->status[VIK_STATUSBAR_POSITION], FALSE, FALSE, 1);
80 gtk_widget_set_size_request ( vs->status[VIK_STATUSBAR_POSITION], 250, -1 );
81
82 gtk_box_pack_end ( GTK_BOX(vs), vs->status[VIK_STATUSBAR_INFO], TRUE, TRUE, 1);
83
84 // Set minimum overall size
85 // otherwise the individual size_requests above create an implicit overall size,
86 // and so one can't downsize horizontally as much as may be desired when the statusbar is on
87 gtk_widget_set_size_request ( GTK_WIDGET(vs), 50, -1 );
88
89 return vs;
90}
91
92void vik_statusbar_set_message ( VikStatusbar *vs, vik_statusbar_type_t field, const gchar *message )
93{
94 if ( field >= 0 && field < VIK_STATUSBAR_NUM_TYPES )
95 {
96 GtkStatusbar *gsb = GTK_STATUSBAR(vs->status[field]);
97
98 if ( !vs->empty[field] )
99 gtk_statusbar_pop ( gsb, 0 );
100 else
101 vs->empty[field] = FALSE;
102
103 gtk_statusbar_push ( gsb, 0, message );
104 }
105}