6 #include "destination.h"
16 zoom_in(GtkWidget *w, struct toolbar *tb)
19 graphics_get_view(tb->gui->co, NULL, NULL, &scale);
23 graphics_set_view(tb->gui->co, NULL, NULL, &scale);
27 zoom_out(GtkWidget *w, struct toolbar *tb)
30 graphics_get_view(tb->gui->co, NULL, NULL, &scale);
32 graphics_set_view(tb->gui->co, NULL, NULL, &scale);
36 refresh_route(GtkWidget *w, struct toolbar *tb)
38 menu_route_update(tb->gui->co);
42 track(GtkWidget *w, struct toolbar *tb)
44 if (tb->gui->co->flags->track) {
45 tb->gui->co->flags->track=0;
46 gtk_widget_set_state(w, GTK_STATE_ACTIVE);
48 tb->gui->co->flags->track=1;
49 gtk_widget_set_state(w, GTK_STATE_ACTIVE);
54 orient_north(GtkWidget *w, struct toolbar *tb)
56 if (tb->gui->co->flags->orient_north) {
57 tb->gui->co->flags->orient_north=0;
58 gtk_widget_set_state(w, GTK_STATE_ACTIVE);
60 tb->gui->co->flags->orient_north=1;
61 gtk_widget_set_state(w, GTK_STATE_ACTIVE);
66 destination(GtkWidget *w, struct toolbar *tb)
68 destination_address(tb->gui->co);
73 /* Drawn by Mark Donohoe for the K Desktop Environment */
74 /* See http://www.kde.org */
75 static char*viewmag_plus_xpm[]={
82 "......................",
83 "......................",
84 "......................",
85 "......................",
86 "......................",
87 ".......####...........",
88 "......#abba#..........",
89 ".....#abcbba#.........",
90 ".....#bcbbbb#.........",
91 ".....#bbbbbb#.........",
92 ".....#abbbba#.........",
93 "......#abba##.........",
94 ".......#######........",
95 "............###.......",
96 ".....#.......###......",
97 ".....#........###.....",
98 "...#####.......##.....",
99 ".....#................",
100 ".....#................",
101 "......................",
102 "......................",
103 "......................"};
107 /* Drawn by Mark Donohoe for the K Desktop Environment */
108 /* See http://www.kde.org */
109 static char*viewmag_minus_xpm[]={
116 "......................",
117 "......................",
118 "......................",
119 "......................",
120 "......................",
121 ".......####...........",
122 "......#abba#..........",
123 ".....#abcbba#.........",
124 ".....#bcbbbb#.........",
125 ".....#bbbbbb#.........",
126 ".....#abbbba#.........",
127 "......#abba##.........",
128 ".......#######........",
129 "............###.......",
130 ".............###......",
131 "..............###.....",
132 "...#####.......##.....",
133 "......................",
134 "......................",
135 "......................",
136 "......................",
137 "......................"};
141 /* Drawn by Mark Donohoe for the K Desktop Environment */
142 /* See http://www.kde.org */
143 static char*reload_xpm[]={
148 "......................",
149 "......................",
150 "......................",
151 "......................",
152 "........##aaa#........",
153 ".......#aaaaaaa.......",
154 "......#aa#....#a......",
155 "......aa#.............",
156 ".....aaa.......a......",
157 "...aaaaaaa....aaa.....",
158 "....aaaaa....aaaaa....",
159 ".....aaa....aaaaaaa...",
160 "......a.......aaa.....",
161 ".............#aa......",
162 "......a#....#aa#......",
163 ".......aaaaaaa#.......",
164 "........#aaa##........",
165 "......................",
166 "......................",
167 "......................",
168 "......................",
169 "......................"};
173 static char * cursor_xpm[] = {
202 static char * north_xpm[] = {
231 static char * flag_xpm[] = {
259 xpm_to_widget(GtkWidget *draw, gchar **xpm_data)
261 /* GtkWidget is the storage type for widgets */
267 style = gtk_widget_get_style(draw);
269 /* In order for this to not create a warning, window has to be a
270 * gtk_realize_widget (realized) widget
272 pixmap = gdk_pixmap_create_from_xpm_d(draw->window, &mask,
273 &style->bg[GTK_STATE_NORMAL],
274 (gchar **)xpm_data );
276 /* a pixmap widget to contain the pixmap */
277 imagewid = gtk_image_new_from_pixmap(pixmap, mask);
278 gtk_widget_show(imagewid);
286 toolbar_button(GtkWidget *window, GtkWidget *toolbar, char **icon_data, char *text, void (*func)(GtkWidget *w, struct toolbar *tb), void *data)
289 GtkToolItem *toolitem;
291 icon=xpm_to_widget(window, icon_data);
292 toolitem=gtk_tool_button_new(icon,text);
293 gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolitem,-1);
294 g_signal_connect(G_OBJECT(toolitem), "clicked", G_CALLBACK(func), data);
298 toolbar_button_toggle(GtkWidget *window, GtkWidget *toolbar, char **icon_data, char *text, void (*func)(GtkWidget *w, struct toolbar *tb), void *data, int *flag)
301 GtkToolItem *toggleitem;
303 icon=xpm_to_widget(window, icon_data);
304 toggleitem=gtk_toggle_tool_button_new();
305 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toggleitem),icon);
306 gtk_tool_button_set_label(GTK_TOOL_BUTTON(toggleitem),text);
307 gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toggleitem,-1);
309 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(toggleitem),TRUE);
311 g_signal_connect(G_OBJECT(toggleitem), "clicked", G_CALLBACK(func), data);
316 gui_gtk_toolbar_new(struct container *co, GtkWidget **widget)
318 GtkWidget *toolbar,*window;
319 struct toolbar *this=g_new0(struct toolbar, 1);
321 this->gui=g_new0(struct toolbar_gui, 1);
324 toolbar=gtk_toolbar_new();
325 window=(GtkWidget *)(co->win);
328 co->flags->orient_north=1;
330 toolbar_button(window, toolbar, viewmag_plus_xpm, "Zoom In", zoom_in, this);
331 toolbar_button(window, toolbar, viewmag_minus_xpm, "Zoom Out", zoom_out, this);
332 toolbar_button(window, toolbar, reload_xpm, "Refresh Route", refresh_route, this);
333 toolbar_button_toggle(window, toolbar, cursor_xpm, "Cursor on/off", track, this, &co->flags->track);
334 toolbar_button_toggle(window, toolbar, north_xpm, "Orientate North on/off", orient_north, this, &co->flags->orient_north);
335 toolbar_button(window, toolbar, flag_xpm, "Destination", destination, this);