Parent Directory | Revision Log
Initial import
1 | harbaum | 1 | /* |
2 | * Copyright (C) 2008 Till Harbaum <till@harbaum.org>. | ||
3 | * | ||
4 | * This file is part of OSM2Go. | ||
5 | * | ||
6 | * OSM2Go 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 3 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * OSM2Go 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 OSM2Go. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | #include "appdata.h" | ||
21 | |||
22 | void statusbar_highlight(appdata_t *appdata, gboolean highlight) { | ||
23 | if(highlight) { | ||
24 | GdkColor color; | ||
25 | gdk_color_parse("red", &color); | ||
26 | gtk_widget_modify_bg(appdata->statusbar->eventbox, GTK_STATE_NORMAL, &color); | ||
27 | gtk_widget_modify_base(appdata->statusbar->eventbox, GTK_STATE_NORMAL, &color); | ||
28 | gtk_widget_modify_fg(appdata->statusbar->eventbox, GTK_STATE_NORMAL, &color); | ||
29 | } else | ||
30 | gtk_widget_modify_bg(appdata->statusbar->eventbox, GTK_STATE_NORMAL, NULL); | ||
31 | } | ||
32 | |||
33 | void statusbar_set(appdata_t *appdata, const char *msg, gboolean highlight) { | ||
34 | statusbar_highlight(appdata, highlight); | ||
35 | |||
36 | printf("statusbar set: %s\n", msg); | ||
37 | |||
38 | static guint mid = 0; | ||
39 | if(mid) | ||
40 | gtk_statusbar_pop(GTK_STATUSBAR(appdata->statusbar->widget), | ||
41 | appdata->statusbar->cid); | ||
42 | |||
43 | if(msg) | ||
44 | mid = gtk_statusbar_push(GTK_STATUSBAR(appdata->statusbar->widget), | ||
45 | appdata->statusbar->cid, msg); | ||
46 | } | ||
47 | |||
48 | GtkWidget *statusbar_new(appdata_t *appdata) { | ||
49 | appdata->statusbar = (statusbar_t*)g_new0(statusbar_t, 1); | ||
50 | |||
51 | appdata->statusbar->eventbox = gtk_event_box_new(); | ||
52 | appdata->statusbar->widget = gtk_statusbar_new(); | ||
53 | |||
54 | #ifdef USE_HILDON | ||
55 | /* why the heck does hildon show this by default? It's useless!! */ | ||
56 | g_object_set(appdata->statusbar->widget, | ||
57 | "has-resize-grip", FALSE, | ||
58 | NULL ); | ||
59 | #endif | ||
60 | gtk_container_add(GTK_CONTAINER(appdata->statusbar->eventbox), | ||
61 | appdata->statusbar->widget); | ||
62 | |||
63 | appdata->statusbar->cid = gtk_statusbar_get_context_id( | ||
64 | GTK_STATUSBAR(appdata->statusbar->widget), "Msg"); | ||
65 | |||
66 | return appdata->statusbar->eventbox; | ||
67 | } | ||
68 | |||
69 | void statusbar_free(statusbar_t *statusbar) { | ||
70 | if(statusbar) | ||
71 | g_free(statusbar); | ||
72 | } |