File: interface.c

package info (click to toggle)
netmon-applet 0.4-11
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 524 kB
  • ctags: 115
  • sloc: sh: 3,348; ansic: 684; makefile: 79
file content (358 lines) | stat: -rw-r--r-- 14,169 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
/*
 * DO NOT EDIT THIS FILE - it is generated by Glade.
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>

#include <gnome.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"

#define GLADE_HOOKUP_OBJECT(component,widget,name) \
  gtk_object_set_data_full (GTK_OBJECT (component), name, \
    gtk_widget_ref (widget), (GtkDestroyNotify) gtk_widget_unref)

#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
  gtk_object_set_data (GTK_OBJECT (component), name, widget)

GtkWidget*
create_propwin (void)
{
  GtkWidget *propwin;
  GtkWidget *table1;
  GtkWidget *label1;
  GtkWidget *label2;
  GtkWidget *label3;
  GtkWidget *label4;
  GtkWidget *horizbtn;
  GSList *horizbtn_group = NULL;
  GtkWidget *alignment2;
  GtkWidget *hbox4;
  GtkWidget *image2;
  GtkWidget *label6;
  GtkWidget *vertbtn;
  GtkWidget *alignment3;
  GtkWidget *hbox5;
  GtkWidget *image3;
  GtkWidget *label7;
  GtkWidget *show_borderbtn;
  GSList *show_borderbtn_group = NULL;
  GtkWidget *noshow_borderbtn;
  GtkWidget *font_button;
  GtkWidget *alignment1;
  GtkWidget *hbox3;
  GtkWidget *image1;
  GtkWidget *label5;
  GtkWidget *interface_entry;
  GtkWidget *button4;
  GtkWidget *hseparator1;
  GtkWidget *button2;

  propwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (propwin, "propwin");
  gtk_window_set_title (GTK_WINDOW (propwin), "Properties");
  gtk_window_set_modal (GTK_WINDOW (propwin), TRUE);

  table1 = gtk_table_new (6, 3, FALSE);
  gtk_widget_set_name (table1, "table1");
  gtk_widget_show (table1);
  gtk_container_add (GTK_CONTAINER (propwin), table1);
  gtk_container_set_border_width (GTK_CONTAINER (table1), 10);
  gtk_table_set_row_spacings (GTK_TABLE (table1), 5);
  gtk_table_set_col_spacings (GTK_TABLE (table1), 10);

  label1 = gtk_label_new ("Device:");
  gtk_widget_set_name (label1, "label1");
  gtk_widget_show (label1);
  gtk_table_attach (GTK_TABLE (table1), label1, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);
  gtk_misc_set_alignment (GTK_MISC (label1), 1, 0.5);

  label2 = gtk_label_new ("Layout:");
  gtk_widget_set_name (label2, "label2");
  gtk_widget_show (label2);
  gtk_table_attach (GTK_TABLE (table1), label2, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_LEFT);
  gtk_misc_set_alignment (GTK_MISC (label2), 1, 0.5);

  label3 = gtk_label_new ("Show Border:");
  gtk_widget_set_name (label3, "label3");
  gtk_widget_show (label3);
  gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_label_set_justify (GTK_LABEL (label3), GTK_JUSTIFY_LEFT);
  gtk_misc_set_alignment (GTK_MISC (label3), 0.81, 0.5);

  label4 = gtk_label_new ("Font:");
  gtk_widget_set_name (label4, "label4");
  gtk_widget_show (label4);
  gtk_table_attach (GTK_TABLE (table1), label4, 0, 1, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_label_set_justify (GTK_LABEL (label4), GTK_JUSTIFY_LEFT);
  gtk_misc_set_alignment (GTK_MISC (label4), 1, 0.5);

  horizbtn = gtk_radio_button_new (NULL);
  gtk_widget_set_name (horizbtn, "horizbtn");
  gtk_widget_show (horizbtn);
  gtk_table_attach (GTK_TABLE (table1), horizbtn, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (horizbtn), horizbtn_group);
  horizbtn_group = gtk_radio_button_group (GTK_RADIO_BUTTON (horizbtn));

  alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_set_name (alignment2, "alignment2");
  gtk_widget_show (alignment2);
  gtk_container_add (GTK_CONTAINER (horizbtn), alignment2);

  hbox4 = gtk_hbox_new (FALSE, 2);
  gtk_widget_set_name (hbox4, "hbox4");
  gtk_widget_show (hbox4);
  gtk_container_add (GTK_CONTAINER (alignment2), hbox4);

  image2 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_BUTTON);
  gtk_widget_set_name (image2, "image2");
  gtk_widget_show (image2);
  gtk_box_pack_start (GTK_BOX (hbox4), image2, FALSE, FALSE, 0);

  label6 = gtk_label_new_with_mnemonic ("Horizontal");
  gtk_widget_set_name (label6, "label6");
  gtk_widget_show (label6);
  gtk_box_pack_start (GTK_BOX (hbox4), label6, FALSE, FALSE, 0);
  gtk_label_set_justify (GTK_LABEL (label6), GTK_JUSTIFY_LEFT);

  vertbtn = gtk_radio_button_new (NULL);
  gtk_widget_set_name (vertbtn, "vertbtn");
  gtk_widget_show (vertbtn);
  gtk_table_attach (GTK_TABLE (table1), vertbtn, 2, 3, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (vertbtn), horizbtn_group);
  horizbtn_group = gtk_radio_button_group (GTK_RADIO_BUTTON (vertbtn));

  alignment3 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_set_name (alignment3, "alignment3");
  gtk_widget_show (alignment3);
  gtk_container_add (GTK_CONTAINER (vertbtn), alignment3);

  hbox5 = gtk_hbox_new (FALSE, 2);
  gtk_widget_set_name (hbox5, "hbox5");
  gtk_widget_show (hbox5);
  gtk_container_add (GTK_CONTAINER (alignment3), hbox5);

  image3 = gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_BUTTON);
  gtk_widget_set_name (image3, "image3");
  gtk_widget_show (image3);
  gtk_box_pack_start (GTK_BOX (hbox5), image3, FALSE, FALSE, 0);

  label7 = gtk_label_new_with_mnemonic ("Vertical");
  gtk_widget_set_name (label7, "label7");
  gtk_widget_show (label7);
  gtk_box_pack_start (GTK_BOX (hbox5), label7, FALSE, FALSE, 0);
  gtk_label_set_justify (GTK_LABEL (label7), GTK_JUSTIFY_LEFT);

  show_borderbtn = gtk_radio_button_new_with_mnemonic (NULL, "gtk-yes");
  gtk_button_set_use_stock (GTK_BUTTON (show_borderbtn), TRUE);
  gtk_widget_set_name (show_borderbtn, "show_borderbtn");
  gtk_widget_show (show_borderbtn);
  gtk_table_attach (GTK_TABLE (table1), show_borderbtn, 1, 2, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (show_borderbtn), show_borderbtn_group);
  show_borderbtn_group = gtk_radio_button_group (GTK_RADIO_BUTTON (show_borderbtn));

  noshow_borderbtn = gtk_radio_button_new_with_mnemonic (NULL, "gtk-no");
  gtk_button_set_use_stock (GTK_BUTTON (noshow_borderbtn), TRUE);
  gtk_widget_set_name (noshow_borderbtn, "noshow_borderbtn");
  gtk_widget_show (noshow_borderbtn);
  gtk_table_attach (GTK_TABLE (table1), noshow_borderbtn, 2, 3, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (noshow_borderbtn), show_borderbtn_group);
  show_borderbtn_group = gtk_radio_button_group (GTK_RADIO_BUTTON (noshow_borderbtn));

  font_button = gtk_button_new ();
  gtk_widget_set_name (font_button, "font_button");
  gtk_widget_show (font_button);
  gtk_table_attach (GTK_TABLE (table1), font_button, 1, 3, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_widget_set_usize (font_button, 202, -2);

  alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_set_name (alignment1, "alignment1");
  gtk_widget_show (alignment1);
  gtk_container_add (GTK_CONTAINER (font_button), alignment1);

  hbox3 = gtk_hbox_new (FALSE, 2);
  gtk_widget_set_name (hbox3, "hbox3");
  gtk_widget_show (hbox3);
  gtk_container_add (GTK_CONTAINER (alignment1), hbox3);

  image1 = gtk_image_new_from_stock ("gtk-select-font", GTK_ICON_SIZE_BUTTON);
  gtk_widget_set_name (image1, "image1");
  gtk_widget_show (image1);
  gtk_box_pack_start (GTK_BOX (hbox3), image1, FALSE, FALSE, 0);

  label5 = gtk_label_new_with_mnemonic ("Font");
  gtk_widget_set_name (label5, "label5");
  gtk_widget_show (label5);
  gtk_box_pack_start (GTK_BOX (hbox3), label5, FALSE, FALSE, 0);
  gtk_label_set_justify (GTK_LABEL (label5), GTK_JUSTIFY_LEFT);

  interface_entry = gtk_entry_new_with_max_length (8);
  gtk_widget_set_name (interface_entry, "interface_entry");
  gtk_widget_show (interface_entry);
  gtk_table_attach (GTK_TABLE (table1), interface_entry, 1, 3, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_entry_set_width_chars (GTK_ENTRY (interface_entry), 8);

  button4 = gtk_button_new_from_stock ("gtk-close");
  gtk_widget_set_name (button4, "button4");
  gtk_widget_show (button4);
  gtk_table_attach (GTK_TABLE (table1), button4, 2, 3, 5, 6,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  hseparator1 = gtk_hseparator_new ();
  gtk_widget_set_name (hseparator1, "hseparator1");
  gtk_widget_show (hseparator1);
  gtk_table_attach (GTK_TABLE (table1), hseparator1, 0, 3, 4, 5,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);

  button2 = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_set_name (button2, "button2");
  gtk_widget_show (button2);
  gtk_table_attach (GTK_TABLE (table1), button2, 1, 2, 5, 6,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  gtk_signal_connect (GTK_OBJECT (font_button), "clicked",
                      GTK_SIGNAL_FUNC (property_choose_font),
                      NULL);
  gtk_signal_connect_object (GTK_OBJECT (button4), "pressed",
                             GTK_SIGNAL_FUNC (property_close_cb),
                             GTK_OBJECT (propwin));
  gtk_signal_connect (GTK_OBJECT (button2), "clicked",
                      GTK_SIGNAL_FUNC (property_ok_cb),
                      NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (propwin, propwin, "propwin");
  GLADE_HOOKUP_OBJECT (propwin, table1, "table1");
  GLADE_HOOKUP_OBJECT (propwin, label1, "label1");
  GLADE_HOOKUP_OBJECT (propwin, label2, "label2");
  GLADE_HOOKUP_OBJECT (propwin, label3, "label3");
  GLADE_HOOKUP_OBJECT (propwin, label4, "label4");
  GLADE_HOOKUP_OBJECT (propwin, horizbtn, "horizbtn");
  GLADE_HOOKUP_OBJECT (propwin, alignment2, "alignment2");
  GLADE_HOOKUP_OBJECT (propwin, hbox4, "hbox4");
  GLADE_HOOKUP_OBJECT (propwin, image2, "image2");
  GLADE_HOOKUP_OBJECT (propwin, label6, "label6");
  GLADE_HOOKUP_OBJECT (propwin, vertbtn, "vertbtn");
  GLADE_HOOKUP_OBJECT (propwin, alignment3, "alignment3");
  GLADE_HOOKUP_OBJECT (propwin, hbox5, "hbox5");
  GLADE_HOOKUP_OBJECT (propwin, image3, "image3");
  GLADE_HOOKUP_OBJECT (propwin, label7, "label7");
  GLADE_HOOKUP_OBJECT (propwin, show_borderbtn, "show_borderbtn");
  GLADE_HOOKUP_OBJECT (propwin, noshow_borderbtn, "noshow_borderbtn");
  GLADE_HOOKUP_OBJECT (propwin, font_button, "font_button");
  GLADE_HOOKUP_OBJECT (propwin, alignment1, "alignment1");
  GLADE_HOOKUP_OBJECT (propwin, hbox3, "hbox3");
  GLADE_HOOKUP_OBJECT (propwin, image1, "image1");
  GLADE_HOOKUP_OBJECT (propwin, label5, "label5");
  GLADE_HOOKUP_OBJECT (propwin, interface_entry, "interface_entry");
  GLADE_HOOKUP_OBJECT (propwin, button4, "button4");
  GLADE_HOOKUP_OBJECT (propwin, hseparator1, "hseparator1");
  GLADE_HOOKUP_OBJECT (propwin, button2, "button2");

  return propwin;
}

GtkWidget*
create_fontwin (void)
{
  GtkWidget *fontwin;
  GtkWidget *vbox1;
  GtkWidget *fontsel;
  GtkWidget *hseparator2;
  GtkWidget *hbox6;
  GtkWidget *button5;
  GtkWidget *button7;

  fontwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (fontwin, "fontwin");
  gtk_container_set_border_width (GTK_CONTAINER (fontwin), 10);
  gtk_window_set_title (GTK_WINDOW (fontwin), "Choose Font");
  gtk_window_set_modal (GTK_WINDOW (fontwin), TRUE);
  gtk_window_set_destroy_with_parent (GTK_WINDOW (fontwin), TRUE);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_set_name (vbox1, "vbox1");
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (fontwin), vbox1);

  fontsel = gtk_font_selection_new ();
  gtk_widget_set_name (fontsel, "fontsel");
  gtk_widget_show (fontsel);
  gtk_box_pack_start (GTK_BOX (vbox1), fontsel, TRUE, TRUE, 0);
  gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (fontsel),
                                       "rx: 311.37M/s  tx: 0.0k/s");

  hseparator2 = gtk_hseparator_new ();
  gtk_widget_set_name (hseparator2, "hseparator2");
  gtk_widget_show (hseparator2);
  gtk_box_pack_start (GTK_BOX (vbox1), hseparator2, TRUE, TRUE, 0);

  hbox6 = gtk_hbox_new (TRUE, 0);
  gtk_widget_set_name (hbox6, "hbox6");
  gtk_widget_show (hbox6);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox6, FALSE, TRUE, 0);

  button5 = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_set_name (button5, "button5");
  gtk_widget_show (button5);
  gtk_box_pack_start (GTK_BOX (hbox6), button5, FALSE, FALSE, 0);

  button7 = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_set_name (button7, "button7");
  gtk_widget_show (button7);
  gtk_box_pack_start (GTK_BOX (hbox6), button7, FALSE, FALSE, 0);

  gtk_signal_connect_object (GTK_OBJECT (button5), "clicked",
                             GTK_SIGNAL_FUNC (property_set_font),
                             GTK_OBJECT (fontsel));
  gtk_signal_connect_object (GTK_OBJECT (button7), "clicked",
                             GTK_SIGNAL_FUNC (gtk_widget_destroy),
                             GTK_OBJECT (fontwin));

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (fontwin, fontwin, "fontwin");
  GLADE_HOOKUP_OBJECT (fontwin, vbox1, "vbox1");
  GLADE_HOOKUP_OBJECT (fontwin, fontsel, "fontsel");
  GLADE_HOOKUP_OBJECT (fontwin, hseparator2, "hseparator2");
  GLADE_HOOKUP_OBJECT (fontwin, hbox6, "hbox6");
  GLADE_HOOKUP_OBJECT (fontwin, button5, "button5");
  GLADE_HOOKUP_OBJECT (fontwin, button7, "button7");

  return fontwin;
}