21 |
* main.c - start of gtk main loop and initialization |
* main.c - start of gtk main loop and initialization |
22 |
*/ |
*/ |
23 |
|
|
|
#ifdef HAVE_CONFIG_H |
|
|
# include <config.h> |
|
|
#endif |
|
|
|
|
24 |
#include <stdlib.h> |
#include <stdlib.h> |
25 |
#include <stdio.h> |
#include <stdio.h> |
26 |
#include <unistd.h> |
#include <unistd.h> |
39 |
#include "callbacks_qsoframe.h" |
#include "callbacks_qsoframe.h" |
40 |
#include "callbacks_mainwindow.h" |
#include "callbacks_mainwindow.h" |
41 |
#include "callbacks_clist.h" |
#include "callbacks_clist.h" |
42 |
|
#include "callbacks_otherdialogs.h" |
43 |
#include "types.h" |
#include "types.h" |
44 |
#include "preferences.h" |
#include "preferences.h" |
45 |
#include "log.h" |
#include "log.h" |
48 |
#include "dxcc.h" |
#include "dxcc.h" |
49 |
#include "remote.h" |
#include "remote.h" |
50 |
#include "history.h" |
#include "history.h" |
|
#include "pixmaps/xlog.xpm" |
|
51 |
|
|
52 |
#if WANT_HAMLIB |
#if WANT_HAMLIB |
53 |
# include <string.h> |
# include <string.h> |
81 |
|
|
82 |
for (i = 1; i < argc; i++) |
for (i = 1; i < argc; i++) |
83 |
{ |
{ |
84 |
if (g_strncasecmp (argv[i], "--version", 9) == 0) |
if (g_ascii_strncasecmp (argv[i], "--version", 9) == 0) |
85 |
{ |
{ |
86 |
versionstr = g_strdup_printf (_("%s version %s\n"), |
versionstr = g_strdup_printf (_("%s version %s\n"), |
87 |
g_basename (argv[0]), VERSION); |
g_path_get_basename (argv[0]), VERSION); |
88 |
g_print (versionstr); |
g_print (versionstr); |
89 |
g_free (versionstr); |
g_free (versionstr); |
90 |
exit (0); |
exit (0); |
91 |
} |
} |
92 |
else if (g_strncasecmp (argv[i], "--help", 6) == 0) |
else if (g_ascii_strncasecmp (argv[i], "--help", 6) == 0) |
93 |
{ |
{ |
94 |
g_print (_("Usage: %s [option]...\n"), g_basename (argv[0])); |
g_print (_("Usage: %s [option]...\n"), |
95 |
g_print (_ |
g_path_get_basename (argv[0])); |
96 |
(" --version Output version information and exit\n")); |
g_print (_(" --version Output version information and exit\n")); |
97 |
g_print (_(" --help Display this help and exit\n")); |
g_print (_(" --help Display this help and exit\n")); |
98 |
exit (0); |
exit (0); |
99 |
} |
} |
100 |
else |
else |
101 |
{ |
{ |
102 |
g_print (_ |
g_print (_("Unknown argument, type %s --help for a list of options\n"), |
103 |
("Unknown argument, type %s --help for a list of options\n"), |
g_path_get_basename (argv[0])); |
|
g_basename (argv[0])); |
|
104 |
exit (1); |
exit (1); |
105 |
} |
} |
106 |
} |
} |
115 |
gchar *labeltext; |
gchar *labeltext; |
116 |
GtkWidget *setupdialog, *setuplabel; |
GtkWidget *setupdialog, *setuplabel; |
117 |
|
|
118 |
g_string_sprintf (packagedir, "%s.", G_DIR_SEPARATOR_S); |
g_string_printf (packagedir, "%s.", G_DIR_SEPARATOR_S); |
119 |
g_string_append (packagedir, PACKAGE); |
g_string_append (packagedir, PACKAGE); |
120 |
setupdialog = create_setupdialog (); |
setupdialog = create_setupdialog (); |
121 |
setuplabel = lookup_widget (setupdialog, "setuplabel"); |
setuplabel = lookup_widget (setupdialog, "setuplabel"); |
173 |
g_strfreev (versionsplit); |
g_strfreev (versionsplit); |
174 |
state.mylocation = setlocation (preferences.latitude, preferences.NS, |
state.mylocation = setlocation (preferences.latitude, preferences.NS, |
175 |
preferences.longitude, preferences.EW); |
preferences.longitude, preferences.EW); |
176 |
state.searchqso = 0; |
state.searchstr = g_strdup(""); |
|
state.searchlog = 0; |
|
177 |
state.dupecheck = 0; |
state.dupecheck = 0; |
178 |
state.notdupecheckmode = FALSE; |
state.notdupecheckmode = FALSE; |
179 |
state.notdupecheckband = FALSE; |
state.notdupecheckband = FALSE; |
188 |
*clockhandlebox, *clockhbox, *mhzlabel, *mhzbutton, |
*clockhandlebox, *clockhbox, *mhzlabel, *mhzbutton, |
189 |
*frequencypixmap, *frequencylabel, *frequencyhbox, |
*frequencypixmap, *frequencylabel, *frequencyhbox, |
190 |
*frequencyhandlebox, *modelabel, *modebutton, *rstlabel, |
*frequencyhandlebox, *modelabel, *modebutton, *rstlabel, |
191 |
*rstbutton, *smeterhandlebox, *smeterhbox, *smeterdrawingarea, |
*rstbutton, *smeterhandlebox, *smeterhbox, *smeterlabel, |
192 |
*smeterpixmap, *hpaned, *powerlabel, *powerbutton, |
*smeterpixmap, *hpaned, *powerlabel, *powerbutton, |
193 |
*locatorframe, *unknownlabel1, *unknownlabel2, *b4clist; |
*locatorframe, *unknownlabel1, *unknownlabel2, |
194 |
GdkPixmap *icon_pixmap; |
*b4dialogvbox, *b4scrolledwindow, *b4treeview; |
|
GdkBitmap *mask; |
|
195 |
gchar *xlogfile, *xlogbackupfile, *temp, *rcpath, *logstoload, |
gchar *xlogfile, *xlogbackupfile, *temp, *rcpath, *logstoload, |
196 |
**loglist = NULL; |
**loglist = NULL; |
197 |
gint i, ctyresult; |
gint i, j, ctyresult; |
198 |
gboolean showmainwindow = TRUE, logsfromprefs = FALSE; |
gboolean showmainwindow = TRUE, logsfromprefs = FALSE; |
|
GtkStyle *windowstyle; |
|
199 |
GString *logs; |
GString *logs; |
200 |
logtype *logwindow; |
logtype *logwindow; |
201 |
LOGDB *lp; |
LOGDB *lp; |
202 |
|
GtkTreeStore *model; |
203 |
|
GtkCellRenderer *renderer; |
204 |
|
GtkTreeViewColumn *column; |
205 |
|
GObject *selection; |
206 |
|
|
207 |
#if WANT_HAMLIB |
#if WANT_HAMLIB |
208 |
gint rigid, retcode; |
gint rigid, retcode; |
210 |
|
|
211 |
parsecommandline (argc, argv); |
parsecommandline (argc, argv); |
212 |
|
|
213 |
|
#ifdef ENABLE_NLS |
214 |
|
bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR); |
215 |
|
bind_textdomain_codeset (PACKAGE, "UTF-8"); |
216 |
|
textdomain (PACKAGE); |
217 |
|
#endif |
218 |
|
|
219 |
gtk_set_locale (); |
gtk_set_locale (); |
220 |
gtk_init (&argc, &argv); |
gtk_init (&argc, &argv); |
221 |
setlocale(LC_NUMERIC, "C"); |
setlocale(LC_NUMERIC, "C"); |
268 |
gtk_paned_pack2 (GTK_PANED (hpaned), mainnotebook, TRUE, FALSE); |
gtk_paned_pack2 (GTK_PANED (hpaned), mainnotebook, TRUE, FALSE); |
269 |
|
|
270 |
/* check for multiple *.xlog */ |
/* check for multiple *.xlog */ |
271 |
if (g_strncasecmp (preferences.logstoload, "*", 1) == 0) |
if (g_ascii_strncasecmp (preferences.logstoload, "*", 1) == 0) |
272 |
logs = getlogs (preferences.savedir, 0); /* read all logs of type xlog */ |
logs = getlogs (preferences.savedir, 0); /* read all logs of type xlog */ |
273 |
else |
else |
274 |
{ /* read logs from preferences.logstoload */ |
{ /* read logs from preferences.logstoload */ |
315 |
logwindowlist = g_list_append (logwindowlist, logwindow); |
logwindowlist = g_list_append (logwindowlist, logwindow); |
316 |
/* backup */ |
/* backup */ |
317 |
xlogbackupfile = g_strconcat (xlogfile, ".backup", NULL); |
xlogbackupfile = g_strconcat (xlogfile, ".backup", NULL); |
318 |
savelog (logwindow, xlogbackupfile, TYPE_FLOG); |
unlink(xlogbackupfile); |
319 |
|
backuplog (xlogfile, xlogbackupfile); |
320 |
g_free (xlogbackupfile); |
g_free (xlogbackupfile); |
321 |
} |
} |
322 |
g_free (xlogfile); |
g_free (xlogfile); |
325 |
g_strfreev (loglist); |
g_strfreev (loglist); |
326 |
g_string_free (logs, TRUE); |
g_string_free (logs, TRUE); |
327 |
|
|
328 |
gtk_signal_connect (GTK_OBJECT (mainnotebook), "switch_page", |
g_signal_connect (G_OBJECT (mainnotebook), "switch_page", |
329 |
GTK_SIGNAL_FUNC (on_mainnotebook_switch_page), NULL); |
G_CALLBACK (on_mainnotebook_switch_page), NULL); |
330 |
|
|
331 |
/* first page has focus */ |
/* first page has focus */ |
332 |
logwindow = g_list_nth_data (logwindowlist, 0); |
logwindow = g_list_nth_data (logwindowlist, 0); |
425 |
frequencyhandlebox = lookup_widget (mainwindow, "frequencyhandlebox"); |
frequencyhandlebox = lookup_widget (mainwindow, "frequencyhandlebox"); |
426 |
smeterhandlebox = lookup_widget (mainwindow, "smeterhandlebox"); |
smeterhandlebox = lookup_widget (mainwindow, "smeterhandlebox"); |
427 |
smeterhbox = lookup_widget (mainwindow, "smeterhbox"); |
smeterhbox = lookup_widget (mainwindow, "smeterhbox"); |
428 |
smeterdrawingarea = lookup_widget (mainwindow, "smeterdrawingarea"); |
smeterlabel = lookup_widget (mainwindow, "smeterlabel"); |
429 |
smeterpixmap = lookup_widget (mainwindow, "smeterpixmap"); |
smeterpixmap = lookup_widget (mainwindow, "smeterpixmap"); |
430 |
powerlabel = lookup_widget (mainwindow, "powerlabel"); |
powerlabel = lookup_widget (mainwindow, "powerlabel"); |
431 |
powerbutton = lookup_widget (mainwindow, "powerbutton"); |
powerbutton = lookup_widget (mainwindow, "powerbutton"); |
436 |
|
|
437 |
setlabelstyle (frequencylabel, preferences.themecolor, |
setlabelstyle (frequencylabel, preferences.themecolor, |
438 |
preferences.themefont); |
preferences.themefont); |
439 |
|
setlabelstyle (smeterlabel, preferences.themecolor, |
440 |
|
preferences.themefont); |
441 |
/* clickable buttons and events for hamlib */ |
/* clickable buttons and events for hamlib */ |
442 |
gtk_signal_connect (GTK_OBJECT (mhzbutton), "clicked", |
g_signal_connect (G_OBJECT (mhzbutton), "clicked", |
443 |
GTK_SIGNAL_FUNC (on_mhzbutton_clicked), NULL); |
G_CALLBACK (on_mhzbutton_clicked), NULL); |
444 |
gtk_signal_connect (GTK_OBJECT (modebutton), "clicked", |
g_signal_connect (G_OBJECT (modebutton), "clicked", |
445 |
GTK_SIGNAL_FUNC (on_modebutton_clicked), NULL); |
G_CALLBACK (on_modebutton_clicked), NULL); |
446 |
gtk_signal_connect (GTK_OBJECT (rstbutton), "clicked", |
g_signal_connect (G_OBJECT (rstbutton), "clicked", |
447 |
GTK_SIGNAL_FUNC (on_rstbutton_clicked), NULL); |
G_CALLBACK (on_rstbutton_clicked), NULL); |
448 |
gtk_signal_connect (GTK_OBJECT (powerbutton), "clicked", |
g_signal_connect (G_OBJECT (powerbutton), "clicked", |
449 |
GTK_SIGNAL_FUNC (on_powerbutton_clicked), NULL); |
G_CALLBACK (on_powerbutton_clicked), NULL); |
|
gtk_signal_connect (GTK_OBJECT (smeterdrawingarea), "configure_event", |
|
|
GTK_SIGNAL_FUNC (on_smeterdrawingarea_configure_event), |
|
|
NULL); |
|
|
gtk_signal_connect (GTK_OBJECT (smeterdrawingarea), "expose_event", |
|
|
GTK_SIGNAL_FUNC (on_smeterdrawingarea_expose_event), |
|
|
NULL); |
|
|
gtk_signal_connect (GTK_OBJECT (mainwindow), "show", |
|
|
GTK_SIGNAL_FUNC (on_mainwindow_show), NULL); |
|
450 |
|
|
451 |
/* init rig if hamlib is enabled and show/hide some widgets */ |
/* init rig if hamlib is enabled and show/hide some widgets */ |
452 |
if (preferences.hamlib > 0) |
if (preferences.hamlib > 0) |
482 |
gtk_widget_hide (frequencylabel); |
gtk_widget_hide (frequencylabel); |
483 |
gtk_widget_hide (smeterhandlebox); |
gtk_widget_hide (smeterhandlebox); |
484 |
gtk_widget_hide (smeterhbox); |
gtk_widget_hide (smeterhbox); |
485 |
gtk_widget_hide (smeterdrawingarea); |
gtk_widget_hide (smeterlabel); |
486 |
gtk_widget_hide (smeterpixmap); |
gtk_widget_hide (smeterpixmap); |
487 |
#endif |
#endif |
488 |
|
|
489 |
if ((preferences.autosave > 0) && (preferences.saving == 1)) |
if ((preferences.autosave > 0) && (preferences.saving == 1)) |
490 |
savetimer = gtk_timeout_add (preferences.autosave * 60 * 1000, |
savetimer = gtk_timeout_add (preferences.autosave * 60 * 1000, |
491 |
(GtkFunction) autosave, NULL); |
(GtkFunction) autosave, NULL); |
492 |
|
|
|
/* set icon */ |
|
|
gtk_widget_realize (mainwindow); |
|
|
windowstyle = gtk_widget_get_style (mainwindow); |
|
|
icon_pixmap = gdk_pixmap_create_from_xpm_d (mainwindow->window, &mask, |
|
|
&windowstyle-> |
|
|
bg[GTK_STATE_NORMAL], |
|
|
(gchar **) & xlog_xpm); |
|
|
gdk_window_set_icon (mainwindow->window, NULL, icon_pixmap, mask); |
|
|
|
|
493 |
g_free (temp); |
g_free (temp); |
494 |
|
|
495 |
/* create wkd B4 dialog and set some options */ |
/* create wkd B4 dialog and set some options */ |
496 |
b4dialog = create_b4dialog (); |
b4dialog = create_b4dialog (); |
497 |
b4clist = lookup_widget (b4dialog, "b4clist"); |
b4scrolledwindow = gtk_scrolled_window_new (NULL, NULL); |
498 |
gtk_clist_set_sort_column (GTK_CLIST (b4clist), CALL + 1); |
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(b4scrolledwindow), |
499 |
gtk_clist_set_auto_sort (GTK_CLIST (b4clist), TRUE); |
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
500 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), 0, 40); |
gtk_widget_show (b4scrolledwindow); |
501 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), NR + 1, 40); |
b4dialogvbox = lookup_widget(b4dialog, "b4dialogvbox"); |
502 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), DATE + 1, 100); |
gtk_box_pack_start (GTK_BOX (b4dialogvbox), b4scrolledwindow, TRUE, TRUE, 0); |
503 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), GMT + 1, 40); |
gtk_box_reorder_child (GTK_BOX (b4dialogvbox), b4scrolledwindow, 0); |
504 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), GMTEND + 1, 40); |
model = gtk_tree_store_new (QSO_FIELDS + 1, |
505 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), CALL + 1, 80); |
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, |
506 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), BAND + 1, 60); |
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, |
507 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), MODE + 1, 60); |
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, |
508 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), RST + 1, 60); |
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
509 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), MYRST + 1, 60); |
b4treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL(model)); |
510 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), QSLOUT + 1, 30); |
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(model), |
511 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), QSLIN + 1, 30); |
CALL + 1, GTK_SORT_ASCENDING); |
512 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), POWER + 1, 40); |
g_object_unref (G_OBJECT (model)); |
513 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), NAME + 1, 100); |
gtk_widget_show (b4treeview); |
514 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), QTH + 1, 100); |
gtk_container_add (GTK_CONTAINER (b4scrolledwindow), b4treeview); |
515 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), LOCATOR + 1, 60); |
|
516 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), U1 + 1, 100); |
/* add callback for selecting a row */ |
517 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), U2 + 1, 100); |
selection = G_OBJECT (gtk_tree_view_get_selection |
518 |
gtk_clist_set_column_width (GTK_CLIST (b4clist), REMARKS + 1, 200); |
(GTK_TREE_VIEW (b4treeview))); |
519 |
for (i = 0; i < 19; i++) |
gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection), |
520 |
gtk_clist_set_column_resizeable (GTK_CLIST (b4clist), i, TRUE); |
GTK_SELECTION_SINGLE); |
521 |
|
g_signal_connect (selection, "changed", |
522 |
/* pixmap for this dialog */ |
G_CALLBACK (on_b4treeview_select_row), NULL); |
523 |
gtk_widget_realize(b4dialog); |
|
524 |
windowstyle = gtk_widget_get_style (b4dialog); |
/* one extra column compared to the log */ |
525 |
icon_pixmap = gdk_pixmap_create_from_xpm_d (b4dialog->window, &mask, |
renderer = gtk_cell_renderer_text_new (); |
526 |
&windowstyle-> |
column = gtk_tree_view_column_new_with_attributes |
527 |
bg[GTK_STATE_NORMAL], |
("LOG", renderer, "text", 0, NULL); |
528 |
(gchar **) & xlog_xpm); |
gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column), |
529 |
gdk_window_set_icon (b4dialog->window, NULL, icon_pixmap, mask); |
GTK_TREE_VIEW_COLUMN_GROW_ONLY ); |
530 |
|
gtk_tree_view_append_column (GTK_TREE_VIEW (b4treeview), column); |
531 |
|
|
532 |
|
renderer = gtk_cell_renderer_text_new (); |
533 |
|
column = gtk_tree_view_column_new_with_attributes |
534 |
|
("NR", renderer, "text", NR + 1, NULL); |
535 |
|
gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column), |
536 |
|
GTK_TREE_VIEW_COLUMN_GROW_ONLY ); |
537 |
|
gtk_tree_view_append_column (GTK_TREE_VIEW (b4treeview), column); |
538 |
|
|
539 |
|
for (j = 1; j < QSO_FIELDS; j++) |
540 |
|
{ |
541 |
|
renderer = gtk_cell_renderer_text_new (); |
542 |
|
if (j == U1) |
543 |
|
column = gtk_tree_view_column_new_with_attributes |
544 |
|
(preferences.freefield1, renderer, "text", j + 1, NULL); |
545 |
|
else if (j == U2) |
546 |
|
column = gtk_tree_view_column_new_with_attributes |
547 |
|
(preferences.freefield2, renderer, "text", j + 1, NULL); |
548 |
|
else |
549 |
|
column = gtk_tree_view_column_new_with_attributes |
550 |
|
(strfield(j), renderer, "text", j + 1, NULL); |
551 |
|
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN(column), |
552 |
|
GTK_TREE_VIEW_COLUMN_GROW_ONLY); |
553 |
|
if (j == CALL) |
554 |
|
gtk_tree_view_column_set_sort_column_id (column, CALL + 1); |
555 |
|
gtk_tree_view_append_column (GTK_TREE_VIEW (b4treeview), column); |
556 |
|
} |
557 |
|
g_object_set_data_full (G_OBJECT (b4dialog), "b4treeview", |
558 |
|
gtk_widget_ref (b4treeview), (GDestroyNotify) gtk_widget_unref); |
559 |
|
|
560 |
if (showmainwindow) |
if (showmainwindow) |
561 |
{ |
{ |