00001
00002
00003
00004
00005 #ifdef HAVE_CONFIG_H
00006 # include <config.h>
00007 #endif
00008
00009 #include <sys/types.h>
00010 #include <sys/stat.h>
00011 #include <unistd.h>
00012 #include <string.h>
00013 #include <stdio.h>
00014
00015 #include <bonobo.h>
00016 #include <gnome.h>
00017
00018 #include "morse_stats_cb.h"
00019 #include "morse_stats_i.h"
00020 #include "support.h"
00021
00022 #define GLADE_HOOKUP_OBJECT(component,widget,name) \
00023 g_object_set_data_full (G_OBJECT (component), name, \
00024 gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
00025
00026 #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
00027 g_object_set_data (G_OBJECT (component), name, widget)
00028
00029 GtkWidget*
00030 create_stats_window (void)
00031 {
00032 GtkWidget *stats_window;
00033 GtkWidget *stats_table;
00034 GtkWidget *label1;
00035 GtkWidget *label2;
00036 GtkWidget *label3;
00037 GtkWidget *dah_dit_ratio_entry;
00038 GtkWidget *avg_dah_length_entry;
00039 GtkWidget *avg_dit_length_entry;
00040 GtkWidget *label4;
00041 GtkWidget *words_per_minute_entry;
00042
00043 stats_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
00044 gtk_widget_set_name (stats_window, "stats_window");
00045 gtk_window_set_title (GTK_WINDOW (stats_window), _("Morse Statistics"));
00046 gtk_window_set_resizable (GTK_WINDOW (stats_window), FALSE);
00047
00048 stats_table = gtk_table_new (4, 2, FALSE);
00049 gtk_widget_set_name (stats_table, "stats_table");
00050 gtk_widget_show (stats_table);
00051 gtk_container_add (GTK_CONTAINER (stats_window), stats_table);
00052
00053 label1 = gtk_label_new (_("Average Dit Length (S)"));
00054 gtk_widget_set_name (label1, "label1");
00055 gtk_widget_show (label1);
00056 gtk_table_attach (GTK_TABLE (stats_table), label1, 0, 1, 0, 1,
00057 (GtkAttachOptions) (GTK_FILL),
00058 (GtkAttachOptions) (0), 3, 3);
00059 gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5);
00060
00061 label2 = gtk_label_new (_("Average Dah Length (S)"));
00062 gtk_widget_set_name (label2, "label2");
00063 gtk_widget_show (label2);
00064 gtk_table_attach (GTK_TABLE (stats_table), label2, 0, 1, 1, 2,
00065 (GtkAttachOptions) (GTK_FILL),
00066 (GtkAttachOptions) (0), 3, 3);
00067 gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);
00068
00069 label3 = gtk_label_new (_("Dah / Dit Ratio"));
00070 gtk_widget_set_name (label3, "label3");
00071 gtk_widget_show (label3);
00072 gtk_table_attach (GTK_TABLE (stats_table), label3, 0, 1, 2, 3,
00073 (GtkAttachOptions) (GTK_FILL),
00074 (GtkAttachOptions) (0), 3, 3);
00075 gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5);
00076
00077 dah_dit_ratio_entry = gtk_entry_new ();
00078 gtk_widget_set_name (dah_dit_ratio_entry, "dah_dit_ratio_entry");
00079 gtk_widget_show (dah_dit_ratio_entry);
00080 gtk_table_attach (GTK_TABLE (stats_table), dah_dit_ratio_entry, 1, 2, 2, 3,
00081 (GtkAttachOptions) (0),
00082 (GtkAttachOptions) (0), 3, 3);
00083 gtk_editable_set_editable (GTK_EDITABLE (dah_dit_ratio_entry), FALSE);
00084 gtk_entry_set_invisible_char (GTK_ENTRY (dah_dit_ratio_entry), 8226);
00085 gtk_entry_set_width_chars (GTK_ENTRY (dah_dit_ratio_entry), 10);
00086
00087 avg_dah_length_entry = gtk_entry_new ();
00088 gtk_widget_set_name (avg_dah_length_entry, "avg_dah_length_entry");
00089 gtk_widget_show (avg_dah_length_entry);
00090 gtk_table_attach (GTK_TABLE (stats_table), avg_dah_length_entry, 1, 2, 1, 2,
00091 (GtkAttachOptions) (0),
00092 (GtkAttachOptions) (0), 3, 3);
00093 gtk_editable_set_editable (GTK_EDITABLE (avg_dah_length_entry), FALSE);
00094 gtk_entry_set_invisible_char (GTK_ENTRY (avg_dah_length_entry), 8226);
00095 gtk_entry_set_width_chars (GTK_ENTRY (avg_dah_length_entry), 10);
00096
00097 avg_dit_length_entry = gtk_entry_new ();
00098 gtk_widget_set_name (avg_dit_length_entry, "avg_dit_length_entry");
00099 gtk_widget_show (avg_dit_length_entry);
00100 gtk_table_attach (GTK_TABLE (stats_table), avg_dit_length_entry, 1, 2, 0, 1,
00101 (GtkAttachOptions) (0),
00102 (GtkAttachOptions) (0), 3, 3);
00103 gtk_editable_set_editable (GTK_EDITABLE (avg_dit_length_entry), FALSE);
00104 gtk_entry_set_invisible_char (GTK_ENTRY (avg_dit_length_entry), 8226);
00105 gtk_entry_set_width_chars (GTK_ENTRY (avg_dit_length_entry), 10);
00106
00107 label4 = gtk_label_new (_("Words per Minute"));
00108 gtk_widget_set_name (label4, "label4");
00109 gtk_widget_show (label4);
00110 gtk_table_attach (GTK_TABLE (stats_table), label4, 0, 1, 3, 4,
00111 (GtkAttachOptions) (GTK_FILL),
00112 (GtkAttachOptions) (0), 3, 3);
00113 gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5);
00114
00115 words_per_minute_entry = gtk_entry_new ();
00116 gtk_widget_set_name (words_per_minute_entry, "words_per_minute_entry");
00117 gtk_widget_show (words_per_minute_entry);
00118 gtk_table_attach (GTK_TABLE (stats_table), words_per_minute_entry, 1, 2, 3, 4,
00119 (GtkAttachOptions) (0),
00120 (GtkAttachOptions) (0), 3, 3);
00121 gtk_editable_set_editable (GTK_EDITABLE (words_per_minute_entry), FALSE);
00122 gtk_entry_set_invisible_char (GTK_ENTRY (words_per_minute_entry), 8226);
00123 gtk_entry_set_width_chars (GTK_ENTRY (words_per_minute_entry), 10);
00124
00125 g_signal_connect ((gpointer) stats_window, "show",
00126 G_CALLBACK (on_stats_window_show),
00127 NULL);
00128 g_signal_connect ((gpointer) stats_window, "delete_event",
00129 G_CALLBACK (on_stats_window_delete_event),
00130 NULL);
00131
00132
00133 GLADE_HOOKUP_OBJECT_NO_REF (stats_window, stats_window, "stats_window");
00134 GLADE_HOOKUP_OBJECT (stats_window, stats_table, "stats_table");
00135 GLADE_HOOKUP_OBJECT (stats_window, label1, "label1");
00136 GLADE_HOOKUP_OBJECT (stats_window, label2, "label2");
00137 GLADE_HOOKUP_OBJECT (stats_window, label3, "label3");
00138 GLADE_HOOKUP_OBJECT (stats_window, dah_dit_ratio_entry, "dah_dit_ratio_entry");
00139 GLADE_HOOKUP_OBJECT (stats_window, avg_dah_length_entry, "avg_dah_length_entry");
00140 GLADE_HOOKUP_OBJECT (stats_window, avg_dit_length_entry, "avg_dit_length_entry");
00141 GLADE_HOOKUP_OBJECT (stats_window, label4, "label4");
00142 GLADE_HOOKUP_OBJECT (stats_window, words_per_minute_entry, "words_per_minute_entry");
00143
00144 return stats_window;
00145 }
00146