Crossfire Client, Branches  R11627
menubar.c
Go to the documentation of this file.
1 const char * const rcsid_gtk2_menubar_c =
2  "$Id: menubar.c 9193 2008-06-01 14:26:32Z anmaster $";
3 /*
4  Crossfire client, a client program for the crossfire program.
5 
6  Copyright (C) 2005 Mark Wedel & Crossfire Development Team
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 
22  The author can be reached via e-mail to crossfire@metalforge.org
23 */
24 
35 #ifdef HAVE_CONFIG_H
36 # include <config.h>
37 #endif
38 
39 #ifdef WIN32
40 #include <windows.h>
41 #endif
42 #include <gtk/gtk.h>
43 #include <glade/glade.h>
44 
45 #include "client.h"
46 
47 #include "p_cmd.h"
48 #include "main.h"
49 #include "image.h"
50 #include "gtk2proto.h"
51 
59 void
60 on_disconnect_activate (GtkMenuItem *menuitem,
61  gpointer user_data)
62 {
63  extern gint csocket_fd;
64 
65 #ifdef WIN32
66  closesocket(csocket.fd);
67 #else
68  close(csocket.fd);
69 #endif
70  csocket.fd = -1;
71  if (csocket_fd) {
72  gdk_input_remove(csocket_fd);
73  csocket_fd=0;
74  gtk_main_quit();
75  }
76 }
77 
85 void
86 menu_quit_program (GtkMenuItem *menuitem,
87  gpointer user_data)
88 {
89 #ifdef WIN32
90  script_killall();
91 #endif
92 
93  LOG(LOG_INFO,"gtk::client_exit","Exiting with return value 0.");
94  exit(0);
95 
96 }
97 
105 void
106 menu_quit_character (GtkMenuItem *menuitem,
107  gpointer user_data)
108 {
109  extended_command("quit");
110 }
111 
121 void enable_menu_items(int enable)
122 {
123  GladeXML *xml_tree;
124  GtkWidget *widget;
125 
126  xml_tree = glade_get_widget_tree(GTK_WIDGET(window_root));
127 
128  widget = glade_xml_get_widget(xml_tree, "quit_character1");
129  g_signal_connect ((gpointer) widget, "activate",
130  G_CALLBACK (menu_quit_character), NULL);
131 
132  widget = glade_xml_get_widget(xml_tree, "quit2");
133  g_signal_connect ((gpointer) widget, "activate",
134  G_CALLBACK (menu_quit_program), NULL);
135 
136  widget = glade_xml_get_widget(xml_tree, "configure1");
137  g_signal_connect ((gpointer) widget, "activate",
138  G_CALLBACK (on_configure_activate), NULL);
139 
140  widget = glade_xml_get_widget(xml_tree, "disconnect");
141  g_signal_connect ((gpointer) widget, "activate",
142  G_CALLBACK (on_disconnect_activate), NULL);
143 
144  widget = glade_xml_get_widget(xml_tree, "keybindings");
145  g_signal_connect ((gpointer) widget, "activate",
146  G_CALLBACK (on_keybindings_activate), NULL);
147 
148  widget = glade_xml_get_widget(xml_tree, "save_window_position");
149  g_signal_connect ((gpointer) widget, "activate",
150  G_CALLBACK (on_save_window_position_activate), NULL);
151 
152  widget = glade_xml_get_widget(xml_tree, "spells");
153  g_signal_connect ((gpointer) widget, "activate",
154  G_CALLBACK (on_spells_activate), NULL);
155 
156  widget = glade_xml_get_widget(xml_tree, "do_not_pickup");
157  g_signal_connect ((gpointer) widget, "activate",
158  G_CALLBACK (on_menu_dont_pickup_activate), NULL);
159 
160  widget = glade_xml_get_widget(xml_tree, "stop_before_pickup1");
161  g_signal_connect ((gpointer) widget, "activate",
162  G_CALLBACK (on_menu_stop_before_pickup_activate), NULL);
163 
164  widget = glade_xml_get_widget(xml_tree, "body_armor1");
165  g_signal_connect ((gpointer) widget, "activate",
166  G_CALLBACK (on_menu_body_armor_activate), NULL);
167 
168  widget = glade_xml_get_widget(xml_tree, "boots1");
169  g_signal_connect ((gpointer) widget, "activate",
170  G_CALLBACK (on_menu_boots_activate), NULL);
171 
172  widget = glade_xml_get_widget(xml_tree, "cloaks1");
173  g_signal_connect ((gpointer) widget, "activate",
174  G_CALLBACK (on_menu_cloaks_activate), NULL);
175 
176  widget = glade_xml_get_widget(xml_tree, "gloves1");
177  g_signal_connect ((gpointer) widget, "activate",
178  G_CALLBACK (on_menu_gloves_activate), NULL);
179 
180  widget = glade_xml_get_widget(xml_tree, "helmets1");
181  g_signal_connect ((gpointer) widget, "activate",
182  G_CALLBACK (on_menu_helmets_activate), NULL);
183 
184  widget = glade_xml_get_widget(xml_tree, "shields1");
185  g_signal_connect ((gpointer) widget, "activate",
186  G_CALLBACK (on_menu_shields_activate), NULL);
187 
188  widget = glade_xml_get_widget(xml_tree, "skillscrolls1");
189  g_signal_connect ((gpointer) widget, "activate",
190  G_CALLBACK (on_menu_skillscrolls_activate), NULL);
191 
192  widget = glade_xml_get_widget(xml_tree, "normal_book_scrolls1");
193  g_signal_connect ((gpointer) widget, "activate",
194  G_CALLBACK (on_menu_normal_book_scrolls_activate), NULL);
195 
196  widget = glade_xml_get_widget(xml_tree, "spellbooks1");
197  g_signal_connect ((gpointer) widget, "activate",
198  G_CALLBACK (on_menu_spellbooks_activate), NULL);
199 
200  widget = glade_xml_get_widget(xml_tree, "drinks1");
201  g_signal_connect ((gpointer) widget, "activate",
202  G_CALLBACK (on_menu_drinks_activate), NULL);
203 
204  widget = glade_xml_get_widget(xml_tree, "food1");
205  g_signal_connect ((gpointer) widget, "activate",
206  G_CALLBACK (on_menu_food_activate), NULL);
207 
208  widget = glade_xml_get_widget(xml_tree, "flesh1");
209  g_signal_connect ((gpointer) widget, "activate",
210  G_CALLBACK (on_menu_flesh_activate), NULL);
211 
212  widget = glade_xml_get_widget(xml_tree, "keys1");
213  g_signal_connect ((gpointer) widget, "activate",
214  G_CALLBACK (on_menu_keys_activate), NULL);
215 
216  widget = glade_xml_get_widget(xml_tree, "magical_items");
217  g_signal_connect ((gpointer) widget, "activate",
218  G_CALLBACK (on_menu_magical_items_activate), NULL);
219 
220  widget = glade_xml_get_widget(xml_tree, "potions");
221  g_signal_connect ((gpointer) widget, "activate",
222  G_CALLBACK (on_menu_potions_activate), NULL);
223 
224  widget = glade_xml_get_widget(xml_tree, "valuables");
225  g_signal_connect ((gpointer) widget, "activate",
226  G_CALLBACK (on_menu_valuables_activate), NULL);
227 
228  widget = glade_xml_get_widget(xml_tree, "wands_rods_horns");
229  g_signal_connect ((gpointer) widget, "activate",
230  G_CALLBACK (on_menu_wands_rods_horns_activate), NULL);
231 
232  widget = glade_xml_get_widget(xml_tree, "jewels1");
233  g_signal_connect ((gpointer) widget, "activate",
234  G_CALLBACK (on_menu_jewels_activate), NULL);
235 
236  widget = glade_xml_get_widget(xml_tree, "all_weapons");
237  g_signal_connect ((gpointer) widget, "activate",
238  G_CALLBACK (on_menu_all_weapons_activate), NULL);
239 
240  widget = glade_xml_get_widget(xml_tree, "missile_weapons1");
241  g_signal_connect ((gpointer) widget, "activate",
242  G_CALLBACK (on_menu_missile_weapons_activate), NULL);
243 
244  widget = glade_xml_get_widget(xml_tree, "bows1");
245  g_signal_connect ((gpointer) widget, "activate",
246  G_CALLBACK (on_menu_bows_activate), NULL);
247 
248  widget = glade_xml_get_widget(xml_tree, "arrows1");
249  g_signal_connect ((gpointer) widget, "activate",
250  G_CALLBACK (on_menu_arrows_activate), NULL);
251 
252  widget = glade_xml_get_widget(xml_tree, "ratio_pickup_off1");
253  g_signal_connect ((gpointer) widget, "activate",
254  G_CALLBACK (on_menu_ratio_pickup_off_activate), NULL);
255 
256  widget = glade_xml_get_widget(xml_tree, "ratio_5");
257  g_signal_connect ((gpointer) widget, "activate",
258  G_CALLBACK (on_menu_ratio_5_activate), NULL);
259 
260  widget = glade_xml_get_widget(xml_tree, "ratio_10");
261  g_signal_connect ((gpointer) widget, "activate",
262  G_CALLBACK (on_menu_ratio_10_activate), NULL);
263 
264  widget = glade_xml_get_widget(xml_tree, "ratio_15");
265  g_signal_connect ((gpointer) widget, "activate",
266  G_CALLBACK (on_menu_ratio_15_activate), NULL);
267 
268  widget = glade_xml_get_widget(xml_tree, "ratio_20");
269  g_signal_connect ((gpointer) widget, "activate",
270  G_CALLBACK (on_menu_ratio_20_activate), NULL);
271 
272  widget = glade_xml_get_widget(xml_tree, "ratio_25");
273  g_signal_connect ((gpointer) widget, "activate",
274  G_CALLBACK (on_menu_ratio_25_activate), NULL);
275 
276  widget = glade_xml_get_widget(xml_tree, "ratio_30");
277  g_signal_connect ((gpointer) widget, "activate",
278  G_CALLBACK (on_menu_ratio_35_activate), NULL);
279 
280  widget = glade_xml_get_widget(xml_tree, "ratio_35");
281  g_signal_connect ((gpointer) widget, "activate",
282  G_CALLBACK (on_menu_ratio_35_activate), NULL);
283 
284  widget = glade_xml_get_widget(xml_tree, "ratio_40");
285  g_signal_connect ((gpointer) widget, "activate",
286  G_CALLBACK (on_menu_ratio_40_activate), NULL);
287 
288  widget = glade_xml_get_widget(xml_tree, "ratio_45");
289  g_signal_connect ((gpointer) widget, "activate",
290  G_CALLBACK (on_menu_ratio_45_activate), NULL);
291 
292  widget = glade_xml_get_widget(xml_tree, "ratio_50");
293  g_signal_connect ((gpointer) widget, "activate",
294  G_CALLBACK (on_menu_ratio_50_activate), NULL);
295 
296  widget = glade_xml_get_widget(xml_tree, "not_cursed1");
297  g_signal_connect ((gpointer) widget, "activate",
298  G_CALLBACK (on_menu_not_cursed_activate), NULL);
299 
300  widget = glade_xml_get_widget(xml_tree, "about1");
301  g_signal_connect ((gpointer) widget, "activate",
302  G_CALLBACK (menu_about), NULL);
303 }
void on_menu_bows_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:305
void on_menu_boots_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:153
void on_menu_ratio_25_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:358
void on_menu_ratio_5_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:330
void on_keybindings_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: keys.c:1752
void menu_about(GtkMenuItem *menuitem, gpointer user_data)
Definition: about.c:55
void on_menu_gloves_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:167
void on_menu_body_armor_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:146
ClientSocket csocket
Definition: client.c:78
void on_menu_ratio_40_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:379
void on_menu_normal_book_scrolls_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:200
void on_menu_keys_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:231
void on_menu_cloaks_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:160
void on_menu_food_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:224
void on_menu_skillscrolls_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:192
gint csocket_fd
Definition: main.c:107
void on_menu_all_weapons_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:291
void on_menu_potions_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:245
void on_configure_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: config.c:968
void on_menu_ratio_50_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:393
void LOG(LogLevel level, const char *origin, const char *format,...)
Definition: misc.c:178
void on_menu_ratio_45_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:386
GtkWidget * window_root
Definition: main.c:56
void on_menu_shields_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:181
void on_menu_flesh_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:280
void on_menu_spellbooks_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:208
void on_menu_not_cursed_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:266
void on_menu_stop_before_pickup_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:135
void on_menu_dont_pickup_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:128
void on_menu_helmets_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:174
int fd
Definition: client.h:97
void on_spells_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: spells.c:198
void on_menu_ratio_20_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:351
void on_menu_jewels_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:273
void extended_command(const char *ocommand)
Definition: p_cmd.c:890
void on_menu_ratio_10_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:337
void on_menu_missile_weapons_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:298
void on_menu_ratio_35_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:372
void on_menu_ratio_pickup_off_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:323
void on_menu_valuables_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:252
void on_menu_magical_items_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:238
void on_menu_ratio_15_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:344
void on_save_window_position_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: config.c:1048
void on_menu_wands_rods_horns_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:259
void on_menu_drinks_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:217
void on_menu_arrows_activate(GtkMenuItem *menuitem, gpointer user_data)
Definition: pickup.c:312