]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * viking -- GPS Data and Topo Analyzer, Explorer, and Manager | |
3 | * | |
4 | * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program 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 this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 | * | |
20 | */ | |
21 | ||
22 | /* gtk status bars: just plain dumb. this file | |
23 | shouldn't have to exist. */ | |
24 | #include <gtk/gtk.h> | |
25 | ||
26 | #include "vikstatus.h" | |
27 | ||
28 | #define STATUS_COUNT 5 | |
29 | ||
30 | struct _VikStatusbar { | |
31 | GtkStatusbar parent; | |
32 | gint num_extra_bars; | |
33 | GtkWidget *status[STATUS_COUNT-1]; | |
34 | gboolean empty[STATUS_COUNT]; | |
35 | }; | |
36 | ||
37 | GType vik_statusbar_get_type (void) | |
38 | { | |
39 | static GType vs_type = 0; | |
40 | ||
41 | if (!vs_type) | |
42 | { | |
43 | static const GTypeInfo vs_info = | |
44 | { | |
45 | sizeof (VikStatusbarClass), | |
46 | NULL, /* base_init */ | |
47 | NULL, /* base_finalize */ | |
48 | NULL, /* class init */ | |
49 | NULL, /* class_finalize */ | |
50 | NULL, /* class_data */ | |
51 | sizeof (VikStatusbar), | |
52 | 0, | |
53 | NULL /* instance init */ | |
54 | }; | |
55 | vs_type = g_type_register_static ( GTK_TYPE_STATUSBAR, "VikStatusbar", &vs_info, 0 ); | |
56 | } | |
57 | ||
58 | return vs_type; | |
59 | } | |
60 | ||
61 | VikStatusbar *vik_statusbar_new () | |
62 | { | |
63 | VikStatusbar *vs = VIK_STATUSBAR ( g_object_new ( VIK_STATUSBAR_TYPE, NULL ) ); | |
64 | gint i; | |
65 | ||
66 | gtk_statusbar_set_has_resize_grip ( GTK_STATUSBAR(vs), FALSE ); | |
67 | ||
68 | vs->status[0] = gtk_statusbar_new(); | |
69 | gtk_statusbar_set_has_resize_grip ( GTK_STATUSBAR(vs->status[0]), FALSE ); | |
70 | gtk_box_pack_start ( GTK_BOX(vs), vs->status[0], FALSE, FALSE, 1); | |
71 | gtk_widget_set_size_request ( vs->status[0], 100, -1 ); | |
72 | ||
73 | vs->status[1] = gtk_statusbar_new(); | |
74 | gtk_statusbar_set_has_resize_grip ( GTK_STATUSBAR(vs->status[1]), FALSE ); | |
75 | gtk_box_pack_start ( GTK_BOX(vs), vs->status[1], FALSE, FALSE, 1); | |
76 | gtk_widget_set_size_request ( vs->status[1], 100, -1 ); | |
77 | ||
78 | vs->status[2] = gtk_statusbar_new(); | |
79 | gtk_statusbar_set_has_resize_grip ( GTK_STATUSBAR(vs->status[2]), FALSE ); | |
80 | gtk_box_pack_end ( GTK_BOX(vs), vs->status[2], TRUE, TRUE, 1); | |
81 | ||
82 | vs->status[3] = gtk_statusbar_new(); | |
83 | gtk_statusbar_set_has_resize_grip ( GTK_STATUSBAR(vs->status[3]), FALSE ); | |
84 | gtk_box_pack_end ( GTK_BOX(vs), vs->status[3], TRUE, TRUE, 1); | |
85 | ||
86 | for ( i = 0; i < STATUS_COUNT; i++ ) | |
87 | vs->empty[i] = TRUE; | |
88 | ||
89 | return vs; | |
90 | } | |
91 | ||
92 | void vik_statusbar_set_message ( VikStatusbar *vs, gint field, const gchar *message ) | |
93 | { | |
94 | if ( field >= 0 && field < STATUS_COUNT ) | |
95 | { | |
96 | GtkStatusbar *gsb; | |
97 | if ( field == 0 ) | |
98 | gsb = GTK_STATUSBAR(vs); | |
99 | else | |
100 | gsb = GTK_STATUSBAR(vs->status[field-1]); | |
101 | ||
102 | if ( !vs->empty[field] ) | |
103 | gtk_statusbar_pop ( gsb, 0 ); | |
104 | else | |
105 | vs->empty[field] = FALSE; | |
106 | ||
107 | gtk_statusbar_push ( gsb, 0, message ); | |
108 | } | |
109 | } |