source: trunk/third/gnome-applets/modemlights/properties.c @ 20910

Revision 20910, 24.0 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20909, which included commits to RCS files with non-trunk default branches.
Line 
1/* GNOME modemlights applet
2 * (C) 2000 John Ellis
3 *
4 * Authors: John Ellis
5 *          Martin Baulig
6 *
7 */
8
9#include <config.h>
10#include "modemlights.h"
11#include <panel-applet.h>
12#include <panel-applet-gconf.h>
13#include <gconf/gconf-client.h>
14
15#define NEVER_SENSITIVE "never_sensitive"
16
17static void show_extra_info_cb(GtkWidget *widget, gpointer data);
18static void verify_lock_file_cb(GtkWidget *widget, gpointer data);
19static void update_delay_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data);
20static void confirm_checkbox_cb(GtkWidget *widget, gpointer data);
21static void isdn_checkbox_cb(GtkWidget *widget, gpointer data);
22
23static gchar *color_rc_names[] = {
24        "color_rx",
25        "color_rx_bg",
26        "color_tx",
27        "color_tx_bg",
28        "color_status_bg",
29        "color_status_ok",
30        "color_status_wait",
31        "color_text_bg",
32        "color_text_fg",
33        "color_text_mid",
34        NULL
35};
36
37/* the default colors */
38static gchar *color_defaults[] = {
39        "#FF0000",
40        "#4D0000",
41        "#00FF00",
42        "#004D00",
43        "#004D00",
44        "#00FF00",
45        "#FEF06B",
46        "#000000",
47        "#00FF00",
48        "#004D00",
49        NULL
50};
51
52/* set sensitive and setup NEVER_SENSITIVE appropriately */
53static void
54hard_set_sensitive (GtkWidget *w, gboolean sensitivity)
55{
56        gtk_widget_set_sensitive (w, sensitivity);
57        g_object_set_data (G_OBJECT (w), NEVER_SENSITIVE,
58                           GINT_TO_POINTER ( ! sensitivity));
59}
60
61
62/* set sensitive, but always insensitive if NEVER_SENSITIVE is set */
63static void
64soft_set_sensitive (GtkWidget *w, gboolean sensitivity)
65{
66        if (g_object_get_data (G_OBJECT (w), NEVER_SENSITIVE))
67                gtk_widget_set_sensitive (w, FALSE);
68        else
69                gtk_widget_set_sensitive (w, sensitivity);
70}
71
72
73static gboolean
74key_writable (PanelApplet *applet, const char *key)
75{
76        gboolean writable;
77        char *fullkey;
78        static GConfClient *client = NULL;
79        if (client == NULL)
80                client = gconf_client_get_default ();
81
82        fullkey = panel_applet_gconf_get_full_key (applet, key);
83
84        writable = gconf_client_key_is_writable (client, fullkey, NULL);
85
86        g_free (fullkey);
87
88        return writable;
89}
90
91void property_load(MLData *mldata)
92{
93        PanelApplet *applet = PANEL_APPLET (mldata->applet);
94        GError *error = NULL;
95        gchar *buf;
96        gint i;
97
98        g_free(mldata->command_connect);
99        g_free(mldata->command_disconnect);
100        g_free(mldata->device_name);
101
102        mldata->UPDATE_DELAY = panel_applet_gconf_get_int (applet, "delay", &error);
103        if (error) {
104                g_print ("%s \n", error->message);
105                g_error_free (error);
106                error = NULL;
107        }
108        mldata->UPDATE_DELAY = MAX (mldata->UPDATE_DELAY, 1);
109       
110        buf = panel_applet_gconf_get_string(applet, "lockfile", NULL);
111        if (buf && strlen(buf) > 0)
112                {
113                g_free(mldata->lock_file);
114                mldata->lock_file = g_strdup(buf);
115                }
116        g_free(buf);
117
118        mldata->command_connect    = panel_applet_gconf_get_string(applet, "connect", NULL);
119        if (!mldata->command_connect)
120                mldata->command_connect = g_strdup ("pppon");
121        mldata->command_disconnect = panel_applet_gconf_get_string(applet, "disconnect", NULL);
122        if (!mldata->command_disconnect)
123                mldata->command_disconnect = g_strdup ("pppoff");
124        mldata->ask_for_confirmation = panel_applet_gconf_get_int(applet, "confirmation", NULL);
125        mldata->device_name = panel_applet_gconf_get_string(applet, "device", NULL);
126        if (!mldata->device_name)
127                mldata->device_name = g_strdup ("ppp0");
128        mldata->use_ISDN = panel_applet_gconf_get_int(applet, "isdn", NULL);
129        mldata->verify_lock_file  = panel_applet_gconf_get_int(applet, "verify_lock", NULL);
130        mldata->show_extra_info  = panel_applet_gconf_get_int(applet, "extra_info", NULL);
131        mldata->status_wait_blink  = panel_applet_gconf_get_int(applet, "wait_blink", NULL);
132       
133        for (i = 0; i < COLOR_COUNT; i++)
134                {
135                g_free(mldata->display_color_text[i]);
136               
137                mldata->display_color_text[i] = panel_applet_gconf_get_string(applet,
138                                                                      color_rc_names[i],
139                                                                      NULL);
140               
141
142                }
143
144}
145
146static void connect_changed_cb(GtkEntry *entry, GdkEventFocus *event, gpointer data)
147{
148        MLData *mldata = data;
149        PanelApplet *applet = PANEL_APPLET (mldata->applet);
150       
151        if (mldata->command_connect) g_free(mldata->command_connect);
152        mldata->command_connect = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
153        panel_applet_gconf_set_string (applet, "connect", mldata->command_connect, NULL);
154}
155
156static void disconnect_changed_cb(GtkEntry *entry, GdkEventFocus *event, gpointer data)
157{
158        MLData *mldata = data;
159        PanelApplet *applet = PANEL_APPLET (mldata->applet);
160       
161        if (mldata->command_disconnect) g_free(mldata->command_disconnect);
162        mldata->command_disconnect = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
163        panel_applet_gconf_set_string (applet, "disconnect", mldata->command_disconnect, NULL);
164}
165
166static void lockfile_changed_cb(GtkEntry *entry, GdkEventFocus *event, gpointer data)
167{
168        MLData *mldata = data;
169        PanelApplet *applet = PANEL_APPLET (mldata->applet);
170       
171        if (mldata->lock_file) g_free(mldata->lock_file);
172        mldata->lock_file = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
173        panel_applet_gconf_set_string (applet, "lockfile", mldata->lock_file, NULL);
174}
175
176static void device_changed_cb(GtkEntry *entry, GdkEventFocus *event, gpointer data)
177{
178        MLData *mldata = data;
179        PanelApplet *applet = PANEL_APPLET (mldata->applet);
180       
181        if (mldata->device_name) g_free(mldata->device_name);
182        mldata->device_name = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
183        panel_applet_gconf_set_string (applet, "device", mldata->device_name, NULL);
184}
185
186static void show_extra_info_cb(GtkWidget *widget, gpointer data)
187{
188        MLData *mldata = data;
189        PanelApplet *applet = PANEL_APPLET (mldata->applet);
190       
191        gint tmp = GTK_TOGGLE_BUTTON (widget)->active;
192        if (tmp != mldata->show_extra_info)
193                {
194                mldata->show_extra_info = tmp;
195                /* change display */
196                reset_orientation(mldata);
197                panel_applet_gconf_set_int (applet, "extra_info", mldata->show_extra_info, NULL);
198                }
199}
200
201static void verify_lock_file_cb(GtkWidget *widget, gpointer data)
202{
203        MLData *mldata = data;
204        PanelApplet *applet = PANEL_APPLET (mldata->applet);
205       
206        mldata->verify_lock_file = GTK_TOGGLE_BUTTON (widget)->active;
207        panel_applet_gconf_set_int (applet, "verify_lock", mldata->verify_lock_file, NULL);
208
209}
210
211static void update_delay_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data)
212{
213        MLData *mldata = data;
214        PanelApplet *applet = PANEL_APPLET (mldata->applet);
215        gchar *key;
216       
217        mldata->UPDATE_DELAY = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
218        start_callback_update(mldata);
219        panel_applet_gconf_set_int (applet, "delay", mldata->UPDATE_DELAY, NULL);
220}
221
222static void confirm_checkbox_cb(GtkWidget *widget, gpointer data)
223{
224        MLData *mldata = data;
225        PanelApplet *applet = PANEL_APPLET (mldata->applet);
226       
227        mldata->ask_for_confirmation = GTK_TOGGLE_BUTTON (widget)->active;
228        panel_applet_gconf_set_int (applet, "confirmation", mldata->ask_for_confirmation, NULL);
229}
230
231static void wait_blink_cb(GtkWidget *widget, gpointer data)
232{
233        MLData *mldata = data;
234        PanelApplet *applet = PANEL_APPLET (mldata->applet);
235       
236        mldata->status_wait_blink = GTK_TOGGLE_BUTTON (widget)->active;
237        panel_applet_gconf_set_int (applet, "wait_blink", mldata->status_wait_blink, NULL);
238}
239
240static void isdn_checkbox_cb(GtkWidget *widget, gpointer data)
241{
242        MLData *mldata = data;
243        PanelApplet *applet = PANEL_APPLET (mldata->applet);
244       
245        mldata->use_ISDN = GTK_TOGGLE_BUTTON (widget)->active;
246
247        soft_set_sensitive(mldata->lockfile_entry, !mldata->use_ISDN);
248        soft_set_sensitive(mldata->device_entry, !mldata->use_ISDN);
249        soft_set_sensitive(mldata->verify_checkbox, !mldata->use_ISDN);
250        panel_applet_gconf_set_int (applet, "isdn", mldata->use_ISDN, NULL);
251}
252
253static void set_default_cb(GtkWidget *widget, gpointer data)
254{
255       
256}
257
258static void box_color_cb(GtkColorButton *cp, gpointer data)
259{
260        MLData *mldata;
261        PanelApplet *applet;
262        ColorType color = (ColorType)GPOINTER_TO_INT(data);
263        GdkColor new_color;
264
265        gtk_color_button_get_color(cp, &new_color);
266        mldata = g_object_get_data (G_OBJECT (cp), "mldata");
267       
268        g_free(mldata->display_color_text[color]);
269        mldata->display_color_text[color] = g_strdup_printf("#%02X%02X%02X",
270                                                            new_color.red / 256,
271                                                            new_color.green / 256,
272                                                            new_color.blue / 256);
273       
274        reset_colors (mldata);
275       
276        applet = PANEL_APPLET (mldata->applet);
277        panel_applet_gconf_set_string (applet, color_rc_names[color],
278                                       mldata->display_color_text[color], NULL);
279}
280
281static GtkWidget *box_add_color(MLData *mldata, GtkWidget *box,
282                                const gchar *text, ColorType color)
283{
284        PanelApplet *applet = PANEL_APPLET (mldata->applet);
285        GtkWidget *hbox;
286        GtkWidget *label;
287        GtkWidget *color_sel;
288        GdkColor c;
289
290        hbox = gtk_hbox_new (FALSE, 12);
291        gtk_box_pack_start (GTK_BOX(box), hbox, FALSE, FALSE, 0);
292        gtk_widget_show (hbox);
293
294        if (mldata->display_color_text[color] != NULL)
295                {
296                gdk_color_parse(mldata->display_color_text[color], &c);
297                }
298        else
299                {
300                c.red = c.green = c.blue = 0;
301                }
302
303        label = gtk_label_new_with_mnemonic (text);
304        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
305        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
306        gtk_widget_show (label);
307
308        color_sel = gtk_color_button_new();
309        gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel), &c);
310        gtk_label_set_mnemonic_widget (GTK_LABEL (label), color_sel);
311        g_signal_connect(G_OBJECT(color_sel), "color_set",
312                         G_CALLBACK (box_color_cb), GINT_TO_POINTER((gint)color));
313        g_object_set_data (G_OBJECT (color_sel), "mldata", mldata);
314        gtk_box_pack_start(GTK_BOX(hbox), color_sel, FALSE, FALSE, 0);
315        gtk_widget_show(color_sel);
316
317        if ( ! key_writable (PANEL_APPLET (mldata->applet), color_rc_names[color]))
318                hard_set_sensitive (hbox, FALSE);
319
320        return label;
321}
322
323static GtkWidget *create_hig_category (GtkWidget *main_box, gchar *title)
324{
325        GtkWidget *vbox, *vbox2, *hbox;
326        GtkWidget *label;
327        gchar *tmp;
328               
329        vbox = gtk_vbox_new (FALSE, 6);
330        gtk_box_pack_start (GTK_BOX (main_box), vbox, FALSE, FALSE, 0);
331       
332        tmp = g_strdup_printf ("<b>%s</b>", title);
333        label = gtk_label_new (NULL);
334        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
335        gtk_label_set_markup (GTK_LABEL (label), tmp);
336        g_free (tmp);
337        gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0);
338
339        hbox = gtk_hbox_new (FALSE, 0);
340        gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
341       
342        label = gtk_label_new ("    ");
343        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
344       
345        vbox2 = gtk_vbox_new (FALSE, 6);
346        gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
347
348        return vbox2;   
349}
350
351static GtkWidget *color_frame_new(GtkWidget *vbox, const gchar *text)
352        {
353        GtkWidget *category;
354        GtkWidget *hbox;
355
356        category = create_hig_category (vbox, (gchar *)text);
357        gtk_widget_show (category);
358
359        hbox = gtk_hbox_new (FALSE, 12);
360        gtk_box_pack_start (GTK_BOX (category), hbox, FALSE, FALSE, 0);
361        gtk_widget_show(hbox);
362
363        return hbox;
364        }
365
366static void
367phelp_cb (GtkDialog *dialog)
368{
369        GError *error = NULL;
370
371        gnome_help_display_on_screen (
372                "modemlights", "modemlights-prefs",
373                gtk_window_get_screen (GTK_WINDOW (dialog)),
374                &error);
375
376        if (error) {
377                g_warning ("help error: %s\n", error->message);
378                g_error_free (error);
379                error = NULL;
380        }
381}
382
383static void
384property_response_cb (GtkDialog *dialog, gint id, gpointer data)
385{
386        MLData *mldata = data;
387        if (id == GTK_RESPONSE_HELP) {
388                phelp_cb (dialog);
389                return;
390        }
391       
392        gtk_widget_destroy (GTK_WIDGET (dialog));
393        mldata->propwindow = NULL;
394}
395
396void property_show (BonoboUIComponent *uic,
397                    MLData       *mldata,
398                    const gchar       *verbname)
399{
400        PanelApplet *applet = PANEL_APPLET (mldata->applet);
401        GtkWidget *frame;
402        GtkWidget *hbox, *hbox2, *hbox3;
403        GtkWidget *notebook;
404        GtkWidget *vbox, *vbox2;
405        GtkWidget *label;
406        GtkWidget *delay_w;
407        GtkObject *delay_adj;
408        GtkWidget *checkbox;
409        GtkSizeGroup *size_group;
410        GConfClient *client;
411        gboolean inhibit_command_line;
412
413        if (mldata->propwindow) {
414                gtk_window_set_screen (GTK_WINDOW (mldata->propwindow),
415                                       gtk_widget_get_screen (GTK_WIDGET (applet)));
416                gtk_window_present (GTK_WINDOW (mldata->propwindow));
417                return;
418        }
419
420        client = gconf_client_get_default ();
421        inhibit_command_line = gconf_client_get_bool (client, "/desktop/gnome/lockdown/inhibit_command_line", NULL);
422
423        mldata->propwindow = gtk_dialog_new_with_buttons (_("Modem Lights Preferences"), NULL,
424                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
425                                                  GTK_STOCK_HELP, GTK_RESPONSE_HELP,
426                                                  GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
427                                                  NULL);
428        gtk_window_set_screen (GTK_WINDOW (mldata->propwindow),
429                               gtk_widget_get_screen (GTK_WIDGET (applet)));
430        gtk_dialog_set_default_response (GTK_DIALOG (mldata->propwindow), GTK_RESPONSE_CLOSE);
431        gtk_dialog_set_has_separator (GTK_DIALOG (mldata->propwindow), FALSE);
432        gtk_container_set_border_width (GTK_CONTAINER (mldata->propwindow), 5);
433        gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (mldata->propwindow)->vbox), 2);
434        gtk_window_set_resizable (GTK_WINDOW (mldata->propwindow), FALSE);
435
436        notebook = gtk_notebook_new ();
437        gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
438        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (mldata->propwindow)->vbox), notebook,
439                            TRUE, TRUE, 0);
440       
441        vbox = gtk_vbox_new (FALSE, 18);
442        gtk_container_set_border_width (GTK_CONTAINER(vbox), 12);
443
444        frame = create_hig_category (vbox, _("Display"));
445
446        /* update adjustment */
447        hbox = gtk_hbox_new (FALSE, 12);
448        gtk_box_pack_start (GTK_BOX (frame), hbox, FALSE, FALSE, 0);
449        gtk_widget_show (hbox);
450
451        label = gtk_label_new_with_mnemonic (_("U_pdate every:"));
452        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
453        gtk_widget_show (label);
454
455        hbox2 = gtk_hbox_new (FALSE, 6);
456        gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
457        gtk_widget_show (hbox2);
458
459        delay_adj = gtk_adjustment_new( mldata->UPDATE_DELAY, 1.0, 20.0, 1, 1, 1 );
460        delay_w  = gtk_spin_button_new( GTK_ADJUSTMENT(delay_adj), 1, 0 );
461        gtk_label_set_mnemonic_widget (GTK_LABEL (label), delay_w);
462        gtk_box_pack_start (GTK_BOX (hbox2), delay_w, FALSE, FALSE, 0);
463        g_signal_connect (G_OBJECT (delay_w), "focus-out-event",
464                          G_CALLBACK (update_delay_cb), mldata);
465        gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (delay_w),GTK_UPDATE_ALWAYS );
466        gtk_widget_show (delay_w);
467
468        label = gtk_label_new_with_mnemonic (_("seconds"));
469        gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
470        gtk_widget_show (label);
471
472        if ( ! key_writable (PANEL_APPLET (mldata->applet), "delay"))
473                hard_set_sensitive (hbox, FALSE);
474
475        /* extra info checkbox */
476        checkbox = gtk_check_button_new_with_mnemonic (_("Sho_w connect time and throughput"));
477        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), mldata->show_extra_info);
478        g_signal_connect (G_OBJECT (checkbox), "toggled",
479                         G_CALLBACK (show_extra_info_cb), mldata);
480        gtk_box_pack_start (GTK_BOX (frame), checkbox, FALSE, FALSE, 0);
481        gtk_widget_show (checkbox);
482
483        if ( ! key_writable (PANEL_APPLET (mldata->applet), "extra_info"))
484                hard_set_sensitive (checkbox, FALSE);
485
486        checkbox = gtk_check_button_new_with_mnemonic (_("B_link connection status when connecting"));
487        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), mldata->status_wait_blink);
488        g_signal_connect (G_OBJECT (checkbox), "toggled",
489                         G_CALLBACK (wait_blink_cb), mldata);
490        gtk_box_pack_start (GTK_BOX (frame), checkbox, FALSE, FALSE, 0);
491        gtk_widget_show (checkbox);
492
493        if ( ! key_writable (PANEL_APPLET (mldata->applet), "wait_blink"))
494                hard_set_sensitive (checkbox, FALSE);
495
496        frame = create_hig_category (vbox, _("Connections"));
497
498        size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
499
500        /* connect entry */
501        hbox = gtk_hbox_new (FALSE, 12);
502        gtk_box_pack_start (GTK_BOX (frame), hbox, FALSE, FALSE, 0);
503        gtk_widget_show(hbox);
504
505        label = gtk_label_new_with_mnemonic (_("Co_nnection command:"));
506        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
507        gtk_size_group_add_widget (size_group, label);
508        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
509        gtk_widget_show(label);
510
511        mldata->connect_entry = gtk_entry_new ();
512        gtk_entry_set_max_length (GTK_ENTRY (mldata->connect_entry), 255);
513        gtk_label_set_mnemonic_widget (GTK_LABEL (label), mldata->connect_entry);
514        gtk_entry_set_text(GTK_ENTRY(mldata->connect_entry), mldata->command_connect);
515        g_signal_connect (G_OBJECT (mldata->connect_entry), "focus_out_event",
516                          G_CALLBACK (connect_changed_cb), mldata);                       
517        gtk_box_pack_start(GTK_BOX(hbox), mldata->connect_entry , TRUE, TRUE, 0);
518        gtk_widget_show(mldata->connect_entry);
519
520        if ( ! key_writable (PANEL_APPLET (mldata->applet), "connect") ||
521            inhibit_command_line) {
522                hard_set_sensitive (label, FALSE);
523                hard_set_sensitive (mldata->connect_entry, FALSE);
524        }
525
526        /* disconnect entry */
527        hbox = gtk_hbox_new(FALSE, 12);
528        gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0);
529        gtk_widget_show(hbox);
530
531        label = gtk_label_new_with_mnemonic(_("_Disconnection command:"));
532        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
533        gtk_size_group_add_widget (size_group, label);
534        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
535        gtk_widget_show(label);
536
537        mldata->disconnect_entry = gtk_entry_new ();
538        gtk_entry_set_max_length (GTK_ENTRY (mldata->disconnect_entry), 255);
539        gtk_label_set_mnemonic_widget (GTK_LABEL (label), mldata->disconnect_entry);
540        gtk_entry_set_text(GTK_ENTRY(mldata->disconnect_entry), mldata->command_disconnect);
541        g_signal_connect (G_OBJECT (mldata->disconnect_entry), "focus_out_event",
542                          G_CALLBACK (disconnect_changed_cb), mldata);
543        gtk_box_pack_start(GTK_BOX(hbox), mldata->disconnect_entry, TRUE, TRUE, 0);
544        gtk_widget_show(mldata->disconnect_entry);
545
546        if ( ! key_writable (PANEL_APPLET (mldata->applet), "disconnect") ||
547            inhibit_command_line) {
548                hard_set_sensitive (label, FALSE);
549                hard_set_sensitive (mldata->disconnect_entry, FALSE);
550        }
551
552        /* confirmation checkbox */
553        checkbox = gtk_check_button_new_with_mnemonic(_("Con_firm connection"));
554        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), mldata->ask_for_confirmation);
555        g_signal_connect (G_OBJECT (checkbox), "toggled",
556                          G_CALLBACK (confirm_checkbox_cb), mldata);
557        gtk_box_pack_start (GTK_BOX (frame), checkbox, FALSE, FALSE, 0);
558        gtk_widget_show(checkbox);
559
560        if ( ! key_writable (PANEL_APPLET (mldata->applet), "confirmation"))
561                hard_set_sensitive (checkbox, FALSE);
562
563        label = gtk_label_new (_("General"));
564        gtk_widget_show (vbox);
565        gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
566
567        /* color settings */
568
569        vbox = gtk_vbox_new (FALSE, 18);
570        gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
571
572        hbox = color_frame_new (vbox, _("Receive Data"));
573        size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
574
575        hbox2 = gtk_hbox_new (FALSE, 24);
576        gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
577
578        hbox3 = box_add_color (mldata, hbox2, _("_Foreground:"), COLOR_RX);
579        gtk_size_group_add_widget (size_group, hbox3);
580        hbox3 = box_add_color (mldata, hbox2, _("_Background:"), COLOR_RX_BG);
581        gtk_size_group_add_widget (size_group, hbox3);
582       
583        hbox = color_frame_new(vbox, _("Send Data"));
584       
585        hbox2 = gtk_hbox_new (FALSE, 24);
586        gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
587       
588        hbox3 = box_add_color (mldata, hbox2, _("Foregroun_d:"), COLOR_TX);
589        gtk_size_group_add_widget (size_group, hbox3);
590        hbox3 = box_add_color (mldata, hbox2, _("Backg_round:"), COLOR_TX_BG);
591        gtk_size_group_add_widget (size_group, hbox3);
592       
593        hbox = color_frame_new (vbox, _("Connection Status"));
594       
595        vbox2 = gtk_vbox_new (FALSE, 6);
596        gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
597       
598        hbox2 = gtk_hbox_new (FALSE, 24);
599        gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
600       
601        hbox3 = box_add_color (mldata, hbox2, _("Co_nnected:"), COLOR_STATUS_OK);
602        gtk_size_group_add_widget (size_group, hbox3);
603        hbox3 = box_add_color (mldata, hbox2, _("Disconnec_ted:"), COLOR_STATUS_BG);
604        gtk_size_group_add_widget (size_group, hbox3);
605               
606        hbox3 = box_add_color (mldata, vbox2, _("C_onnecting:"), COLOR_STATUS_WAIT);
607        gtk_size_group_add_widget (size_group, hbox3);
608       
609        hbox = color_frame_new (vbox, _("Text"));
610       
611        vbox2 = gtk_vbox_new (FALSE, 6);
612        gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
613       
614        hbox2 = gtk_hbox_new (FALSE, 24);
615        gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
616       
617        hbox3 = box_add_color (mldata, hbox2, _("For_eground:"), COLOR_TEXT_FG);
618        gtk_size_group_add_widget (size_group, hbox3);
619        hbox3 = box_add_color (mldata, hbox2, _("Bac_kground:"), COLOR_TEXT_BG);
620        gtk_size_group_add_widget (size_group, hbox3);
621        hbox3 = box_add_color (mldata, vbox2, _("O_utline:"), COLOR_TEXT_MID);
622        gtk_size_group_add_widget (size_group, hbox3);
623
624        label = gtk_label_new (_("Colors"));
625        gtk_widget_show (vbox);
626        gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
627
628        /* advanced settings */
629
630        vbox = gtk_vbox_new (FALSE, 18);
631        gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
632
633        frame = create_hig_category (vbox, _("Modem Options"));
634
635        size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
636
637        /* device entry */
638        hbox = gtk_hbox_new (FALSE, 12);
639        gtk_box_pack_start (GTK_BOX (frame), hbox, FALSE, FALSE, 0);
640        gtk_widget_show (hbox);
641
642        label = gtk_label_new_with_mnemonic (_("_Device:"));
643        gtk_size_group_add_widget (size_group, label);
644        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
645        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
646        gtk_widget_show (label);
647
648        mldata->device_entry = gtk_entry_new ();
649        gtk_entry_set_max_length (GTK_ENTRY(mldata->device_entry), 16);
650        gtk_label_set_mnemonic_widget (GTK_LABEL (label), mldata->device_entry);
651        gtk_entry_set_text (GTK_ENTRY (mldata->device_entry), mldata->device_name);
652        g_signal_connect (G_OBJECT (mldata->device_entry), "focus_out_event",
653                          G_CALLBACK (device_changed_cb), mldata);
654        gtk_box_pack_start (GTK_BOX (hbox), mldata->device_entry, TRUE, TRUE, 0);
655        gtk_widget_show (mldata->device_entry);
656
657        if ( ! key_writable (PANEL_APPLET (mldata->applet), "device") ||
658            inhibit_command_line) {
659                hard_set_sensitive (label, FALSE);
660                hard_set_sensitive (mldata->device_entry, FALSE);
661        }
662       
663        /* lock file entry */
664        hbox = gtk_hbox_new(FALSE, 12);
665        gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0);
666        gtk_widget_show(hbox);
667
668        label = gtk_label_new_with_mnemonic (_("_Lock file:"));
669        gtk_size_group_add_widget (size_group, label);
670        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
671        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
672        gtk_widget_show (label);
673
674        mldata->lockfile_entry = gtk_entry_new ();
675        gtk_entry_set_max_length (GTK_ENTRY (mldata->lockfile_entry), 255);
676        gtk_label_set_mnemonic_widget (GTK_LABEL (label), mldata->lockfile_entry);
677        gtk_entry_set_text(GTK_ENTRY(mldata->lockfile_entry), mldata->lock_file);
678        g_signal_connect (G_OBJECT (mldata->lockfile_entry), "focus_out_event",
679                          G_CALLBACK (lockfile_changed_cb), mldata);
680        gtk_box_pack_start(GTK_BOX(hbox), mldata->lockfile_entry, TRUE, TRUE, 0);
681        gtk_widget_show(mldata->lockfile_entry);
682
683        if ( ! key_writable (PANEL_APPLET (mldata->applet), "lockfile") ||
684            inhibit_command_line) {
685                hard_set_sensitive (label, FALSE);
686                hard_set_sensitive (mldata->lockfile_entry, FALSE);
687        }
688
689        mldata->verify_checkbox = gtk_check_button_new_with_mnemonic(_("_Verify owner of lock file"));
690        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mldata->verify_checkbox), mldata->verify_lock_file);
691        g_signal_connect(G_OBJECT(mldata->verify_checkbox), "toggled",
692                         G_CALLBACK(verify_lock_file_cb), mldata);
693        gtk_box_pack_start (GTK_BOX (frame), mldata->verify_checkbox, FALSE, FALSE, 0);
694        gtk_widget_show(mldata->verify_checkbox);
695
696        if ( ! key_writable (PANEL_APPLET (mldata->applet), "verify_lock"))
697                hard_set_sensitive (mldata->verify_checkbox, FALSE);
698
699        /* ISDN checkbox */
700        checkbox = gtk_check_button_new_with_mnemonic(_("U_se ISDN"));
701        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), mldata->use_ISDN);
702        g_signal_connect(G_OBJECT(checkbox), "toggled",
703                           G_CALLBACK(isdn_checkbox_cb), mldata);
704        gtk_box_pack_start (GTK_BOX (frame), checkbox, FALSE, FALSE, 0);
705        gtk_widget_show(checkbox);
706
707        if ( ! key_writable (PANEL_APPLET (mldata->applet), "isdn"))
708                hard_set_sensitive (checkbox, FALSE);
709
710        if (mldata->use_ISDN)
711                {
712                soft_set_sensitive(mldata->lockfile_entry, FALSE);
713                soft_set_sensitive(mldata->device_entry, FALSE);
714                soft_set_sensitive(mldata->verify_checkbox, FALSE);
715                }
716
717        label = gtk_label_new(_("Advanced"));
718        gtk_widget_show(vbox);
719        gtk_notebook_append_page( GTK_NOTEBOOK(notebook), vbox, label);
720
721        g_signal_connect (G_OBJECT (mldata->propwindow), "response",
722                          G_CALLBACK (property_response_cb), mldata);
723
724        gtk_widget_show_all(mldata->propwindow);
725}
Note: See TracBrowser for help on using the repository browser.