17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 |
*/ |
*/ |
19 |
|
|
20 |
/* callbacks.c |
/* callbacks.c - placeholder for glade */ |
|
* |
|
|
* This is where the callbacks for all the different dialogs reside. |
|
|
* For callbacks related to the widgets in the main window, see the files |
|
|
* called callbacks_<widgetname>.[c|h]. |
|
|
*/ |
|
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
#include <stdlib.h> |
|
|
#include <string.h> |
|
|
#include <libgen.h> |
|
|
#include <gtk/gtk.h> |
|
|
#include <gdk/gdkkeysyms.h> |
|
|
|
|
|
#ifdef HAVE_CONFIG_H |
|
|
# include <config.h> |
|
|
#endif |
|
|
|
|
|
#include "callbacks.h" |
|
|
#include "interface.h" |
|
|
#include "support.h" |
|
|
#include "types.h" |
|
|
#include "log.h" |
|
|
#include "utils.h" |
|
|
#include "gtkutils.h" |
|
|
|
|
|
#define SEARCHHISTORY 10 |
|
|
|
|
|
#if WANT_HAMLIB |
|
|
# include <string.h> |
|
|
# include <hamlib-utils.h> |
|
|
# include <hamlib/rig.h> |
|
|
#endif |
|
|
|
|
|
extern GtkWidget *mainwindow; |
|
|
extern GtkWidget *mainnotebook; |
|
|
extern gchar *xlogdir; |
|
|
extern preferencestype preferences; |
|
|
extern statetype state; |
|
|
extern gchar **bandsplit; |
|
|
extern gchar **modesplit; |
|
|
extern gchar **qso; |
|
|
extern GtkWidget *preferencesdialog; |
|
|
extern GtkWidget *printdialog; |
|
|
extern GtkWidget *b4dialog; |
|
|
extern gint clocktimer, savetimer; |
|
|
extern GList *searchhistory; |
|
|
extern GList *logwindowlist; |
|
|
gchar *globtemp; |
|
|
gint globtype = 1; |
|
|
|
|
|
#if WANT_HAMLIB |
|
|
extern GList *riglist; |
|
|
extern gint hamlibtimer; |
|
|
extern RIG *myrig; |
|
|
#endif |
|
|
|
|
|
/* ABOUT DIALOG */ |
|
|
void |
|
|
on_aboutbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
} |
|
|
|
|
|
|
|
|
/* PREFERENCES DIALOG */ |
|
|
|
|
|
#if WANT_HAMLIB |
|
|
/* return value for setting widgets */ |
|
|
static gint |
|
|
whichhamlibwidgets (gboolean frequency, gboolean smeter) |
|
|
{ |
|
|
if (frequency && smeter) |
|
|
return (4); |
|
|
else if (frequency && (!smeter)) |
|
|
return (2); |
|
|
else if ((!frequency) && smeter) |
|
|
return (3); |
|
|
else |
|
|
return (1); |
|
|
} |
|
|
#endif |
|
|
|
|
|
/* check autosave value, if larger than 0 start timer */ |
|
|
static void |
|
|
set_autosave (gint value) |
|
|
{ |
|
|
if (preferences.autosave == 0) |
|
|
{ |
|
|
if (value > 0) |
|
|
savetimer = |
|
|
gtk_timeout_add (value * 60 * 1000, (GtkFunction) autosave, NULL); |
|
|
} |
|
|
else |
|
|
{ |
|
|
if (value == 0) |
|
|
{ |
|
|
gdk_input_remove (savetimer); |
|
|
savetimer = -1; |
|
|
} |
|
|
else if (value != preferences.autosave) |
|
|
{ /* new value, stop and start timer */ |
|
|
gdk_input_remove (savetimer); |
|
|
savetimer = |
|
|
gtk_timeout_add (value * 60 * 1000, (GtkFunction) autosave, NULL); |
|
|
} |
|
|
} |
|
|
preferences.autosave = value; |
|
|
} |
|
|
|
|
|
/* set the theme if changed */ |
|
|
static void |
|
|
set_theme (gchar * color, gchar * font, gboolean alsoforlog) |
|
|
{ |
|
|
GtkWidget *clocklabel, *qsoframe, *dxccframe; |
|
|
gint i, row; |
|
|
logtype *logwindow; |
|
|
gint logcolor; |
|
|
gboolean logcolordone = FALSE; |
|
|
GtkStyle *cellstyle; |
|
|
#if WANT_HAMLIB |
|
|
GtkWidget *frequencylabel; |
|
|
#endif |
|
|
|
|
|
logcolor = alsoforlog ? 1 : 0; |
|
|
|
|
|
if (g_strcasecmp (color, preferences.themecolor) || |
|
|
g_strcasecmp (font, preferences.themefont)) |
|
|
{ |
|
|
clocklabel = lookup_widget (mainwindow, "clocklabel"); |
|
|
setlabelstyle (clocklabel, color, font); |
|
|
#if WANT_HAMLIB |
|
|
frequencylabel = lookup_widget (mainwindow, "frequencylabel"); |
|
|
setlabelstyle (frequencylabel, color, font); |
|
|
#endif |
|
|
qsoframe = lookup_widget (mainwindow, "qsoframe"); |
|
|
dxccframe = lookup_widget (mainwindow, "dxccframe"); |
|
|
setframestyle (qsoframe, color, font); |
|
|
setframestyle (dxccframe, color, font); |
|
|
for (i = 0; i < g_list_length (logwindowlist); i++) |
|
|
{ |
|
|
logwindow = g_list_nth_data (logwindowlist, i); |
|
|
setlabelstyle (logwindow->label, color, font); |
|
|
} |
|
|
if (alsoforlog) /* apply to the log if needed */ |
|
|
{ |
|
|
for (i = 0; i < g_list_length (logwindowlist); i++) |
|
|
{ |
|
|
logwindow = g_list_nth_data (logwindowlist, i); |
|
|
gtk_clist_freeze (GTK_CLIST (logwindow->clist)); |
|
|
for (row = 0; row < logwindow->qsos; row++) |
|
|
setcallstyle (logwindow->clist, row, color, font); |
|
|
gtk_clist_thaw (GTK_CLIST (logwindow->clist)); |
|
|
} |
|
|
logcolordone = TRUE; |
|
|
} |
|
|
preferences.themecolor = color; |
|
|
preferences.themefont = g_strdup (font); |
|
|
} |
|
|
|
|
|
/* does the log need color? */ |
|
|
if (logcolor != preferences.logcolor) |
|
|
{ |
|
|
if ((logcolor == 1) && (!logcolordone)) |
|
|
{ |
|
|
for (i = 0; i < g_list_length (logwindowlist); i++) |
|
|
{ |
|
|
logwindow = g_list_nth_data (logwindowlist, i); |
|
|
gtk_clist_freeze (GTK_CLIST (logwindow->clist)); |
|
|
for (row = 0; row < logwindow->qsos; row++) |
|
|
setcallstyle (logwindow->clist, row, |
|
|
preferences.themecolor, preferences.themefont); |
|
|
gtk_clist_thaw (GTK_CLIST (logwindow->clist)); |
|
|
} |
|
|
} |
|
|
if (logcolor == 0) |
|
|
{ |
|
|
for (i = 0; i < g_list_length (logwindowlist); i++) |
|
|
{ |
|
|
logwindow = g_list_nth_data (logwindowlist, i); |
|
|
gtk_clist_freeze (GTK_CLIST (logwindow->clist)); |
|
|
cellstyle = |
|
|
gtk_clist_get_cell_style (GTK_CLIST (logwindow->clist), 0, 0); |
|
|
for (row = 0; row < logwindow->qsos; row++) |
|
|
gtk_clist_set_cell_style (GTK_CLIST (logwindow->clist), row, |
|
|
CALL, cellstyle); |
|
|
gtk_clist_thaw (GTK_CLIST (logwindow->clist)); |
|
|
} |
|
|
} |
|
|
preferences.logcolor = logcolor; |
|
|
} |
|
|
} |
|
|
|
|
|
/* set savepath if changed */ |
|
|
static void |
|
|
set_path (gchar * pathstr) |
|
|
{ |
|
|
gchar *str, *fpathstr; |
|
|
GString *path; |
|
|
|
|
|
if (strlen (pathstr) > 0) |
|
|
{ |
|
|
path = g_string_new (pathstr); |
|
|
str = g_strdup (path->str); |
|
|
/* remove trailing slash */ |
|
|
g_strreverse (str); |
|
|
if (!g_strncasecmp (str, "/", 1)) |
|
|
{ |
|
|
path = g_string_erase (path, (path->len) - 1, 1); |
|
|
} |
|
|
else /* in case a file is selected */ |
|
|
{ |
|
|
fpathstr = g_strdup (path->str); |
|
|
path = g_string_new (dirname (fpathstr)); |
|
|
g_free (fpathstr); |
|
|
} |
|
|
g_free (str); |
|
|
if (g_strcasecmp (preferences.savedir, path->str)) |
|
|
preferences.savedir = g_strdup (path->str); |
|
|
g_string_free (path, TRUE); |
|
|
} |
|
|
} |
|
|
|
|
|
/* set logs to load if changed */ |
|
|
static void |
|
|
set_logstoload (gchar * logs) |
|
|
{ |
|
|
gchar **logsplit; |
|
|
|
|
|
if (g_strcasecmp (logs, preferences.logstoload) != 0) |
|
|
{ |
|
|
if (strlen (logs) == 0) |
|
|
logs = g_strdup ("*"); |
|
|
logsplit = g_strsplit (logs, ",", -1); /* delete spaces */ |
|
|
deletespaces (logsplit); |
|
|
preferences.logstoload = g_strjoinv (",", logsplit); |
|
|
g_strfreev (logsplit); |
|
|
} |
|
|
} |
|
|
|
|
|
/* set QTH locator */ |
|
|
static void |
|
|
set_qthlocator (gchar * locator) |
|
|
{ |
|
|
if (g_strcasecmp (locator, preferences.locator) != 0) |
|
|
{ |
|
|
if (strlen (locator) == 0) |
|
|
locator = g_strdup ("AA00AA"); |
|
|
preferences.locator = g_strdup (locator); |
|
|
} |
|
|
} |
|
|
|
|
|
/* set callsign */ |
|
|
static void |
|
|
set_callsign (gchar * callsign) |
|
|
{ |
|
|
if (g_strcasecmp (callsign, preferences.callsign) != 0) |
|
|
{ |
|
|
if (strlen (callsign) == 0) |
|
|
callsign = g_strdup ("N0CALL"); |
|
|
preferences.callsign = g_strdup (callsign); |
|
|
} |
|
|
} |
|
|
|
|
|
/* enable/disable clock */ |
|
|
static void |
|
|
set_clock (gboolean on) |
|
|
{ |
|
|
GtkWidget *clocklabel, *clockpixmap, *clockhbox, *clockhandlebox; |
|
|
|
|
|
clocklabel = lookup_widget (mainwindow, "clocklabel"); |
|
|
clockpixmap = lookup_widget (mainwindow, "clockpixmap"); |
|
|
clockhbox = lookup_widget (mainwindow, "clockhbox"); |
|
|
clockhandlebox = lookup_widget (mainwindow, "clockhandlebox"); |
|
|
if (on) |
|
|
{ /* yes, we want clock */ |
|
|
if (preferences.clock == 0) |
|
|
clocktimer = gtk_timeout_add (1000, (GtkFunction) updateclock, NULL); |
|
|
gtk_widget_show (clocklabel); |
|
|
gtk_widget_show (clockpixmap); |
|
|
gtk_widget_show (clockhbox); |
|
|
gtk_widget_show (clockhandlebox); |
|
|
preferences.clock = 1; |
|
|
} |
|
|
else |
|
|
{ /* no clock */ |
|
|
if (preferences.clock > 0) |
|
|
gdk_input_remove (clocktimer); |
|
|
clocktimer = -1; |
|
|
gtk_widget_hide (clocklabel); |
|
|
gtk_widget_hide (clockpixmap); |
|
|
gtk_widget_hide (clockhbox); |
|
|
gtk_widget_hide (clockhandlebox); |
|
|
preferences.clock = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
/* ok button clicked */ |
|
|
void |
|
|
on_preferencesokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *latentry, *longentry, *NScomboentry, *EWcomboentry, |
|
|
*unitscomboentry, *bandsentry, *bandoptionmenu, *modesentry, |
|
|
*modeoptionmenu, *bandsradiobutton1, *modesradiobutton1, |
|
|
*clockcheckbutton, *examplelabel, *autosavecomboentry, |
|
|
*themecheckbutton, *pathentry, *logsentry, *qthlocatorentry, |
|
|
*callsignentry, *fontentry, *bandentry, *modeentry; |
|
|
gchar *temp, *bandcopy, *font; |
|
|
gboolean toggletrue, logcoloryesno; |
|
|
gint bandindex = 0, modeindex = 0, autosavevalue; |
|
|
#if WANT_HAMLIB |
|
|
GtkWidget *hamlibcheckbutton, *radiocomboentry, *devicecomboentry, |
|
|
*frequencycheckbutton, *digitscomboentry, *smetercheckbutton, |
|
|
*drawingarea; |
|
|
gchar *radio = NULL, *device = NULL, *digits = NULL; |
|
|
gboolean hamlibyes, frequencyyesno, smeteryesno; |
|
|
gint rigid, retcode; |
|
|
gint hamlibwidgets = 0; |
|
|
#endif |
|
|
|
|
|
/* check autosave value */ |
|
|
autosavecomboentry = |
|
|
lookup_widget (preferencesdialog, "autosavecomboentry"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (autosavecomboentry), 0, -1); |
|
|
autosavevalue = atoi (temp); |
|
|
set_autosave (autosavevalue); |
|
|
|
|
|
/* apply theme color */ |
|
|
fontentry = lookup_widget (preferencesdialog, "fontentry"); |
|
|
examplelabel = lookup_widget (preferencesdialog, "examplelabel"); |
|
|
themecheckbutton = lookup_widget (preferencesdialog, "themecheckbutton"); |
|
|
logcoloryesno = gtk_toggle_button_get_active |
|
|
(GTK_TOGGLE_BUTTON (themecheckbutton)); |
|
|
temp = getlabelcolor (examplelabel); |
|
|
font = gtk_editable_get_chars (GTK_EDITABLE (fontentry), 0, -1); |
|
|
set_theme (temp, font, logcoloryesno); |
|
|
g_free (font); |
|
|
|
|
|
/* get path for the logs */ |
|
|
pathentry = lookup_widget (preferencesdialog, "pathentry"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (pathentry), 0, -1); |
|
|
set_path (temp); |
|
|
|
|
|
/* get logs to load */ |
|
|
logsentry = lookup_widget (preferencesdialog, "logsentry"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (logsentry), 0, -1); |
|
|
set_logstoload (temp); |
|
|
|
|
|
/* locator */ |
|
|
qthlocatorentry = lookup_widget (preferencesdialog, "qthlocatorentry"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (qthlocatorentry), 0, -1); |
|
|
set_qthlocator (temp); |
|
|
|
|
|
/* callsign */ |
|
|
callsignentry = lookup_widget (preferencesdialog, "callsignentry"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (callsignentry), 0, -1); |
|
|
set_callsign (temp); |
|
|
|
|
|
/* set latitude, longitude and units */ |
|
|
latentry = lookup_widget (preferencesdialog, "latentry"); |
|
|
longentry = lookup_widget (preferencesdialog, "longentry"); |
|
|
NScomboentry = lookup_widget (preferencesdialog, "NScomboentry"); |
|
|
EWcomboentry = lookup_widget (preferencesdialog, "EWcomboentry"); |
|
|
unitscomboentry = lookup_widget (preferencesdialog, "unitscomboentry"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (latentry), 0, -1); |
|
|
g_strstrip (temp); |
|
|
if (strlen (temp) == 0) |
|
|
preferences.latitude = 0.0; |
|
|
else |
|
|
preferences.latitude = atof (temp); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (longentry), 0, -1); |
|
|
g_strstrip (temp); |
|
|
if (strlen (temp) == 0) |
|
|
preferences.longitude = 0.0; |
|
|
else |
|
|
preferences.longitude = atof (temp); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (NScomboentry), 0, 1); |
|
|
if (g_strncasecmp (temp, _("N"), 1) == 0) |
|
|
preferences.NS = 1; |
|
|
else |
|
|
preferences.NS = 2; |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (EWcomboentry), 0, 1); |
|
|
if (g_strncasecmp (temp, _("E"), 1) == 0) |
|
|
preferences.EW = 1; |
|
|
else |
|
|
preferences.EW = 2; |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (unitscomboentry), 0, -1); |
|
|
if (g_strncasecmp (temp, "K", 1) == 0) |
|
|
preferences.units = 1; |
|
|
else |
|
|
preferences.units = 0; |
|
|
state.mylocation = setlocation (preferences.latitude, preferences.NS, |
|
|
preferences.longitude, preferences.EW); |
|
|
/* get the comma seperated list of modes and assign to the optionmenu */ |
|
|
modesentry = lookup_widget (preferencesdialog, "modesentry"); |
|
|
modeoptionmenu = lookup_widget (mainwindow, "modeoptionmenu"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (modesentry), 0, -1); |
|
|
modesplit = g_strsplit (temp, ",", 0); |
|
|
deletespaces (modesplit); |
|
|
updateoptionmenu (modeoptionmenu, modesplit); |
|
|
|
|
|
/* set the optionmenu for modes */ |
|
|
modeentry = lookup_widget (mainwindow, "modeentry"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (modeentry), 0, -1); |
|
|
if (strlen (temp) > 0) |
|
|
{ |
|
|
for (;;) |
|
|
{ |
|
|
if (g_strcasecmp (temp, modesplit[modeindex]) == 0) |
|
|
{ |
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU (modeoptionmenu), |
|
|
modeindex); |
|
|
break; |
|
|
} |
|
|
modeindex++; |
|
|
} |
|
|
} |
|
|
|
|
|
/* get the comma seperated list of bands and assign to the optionmenu */ |
|
|
bandsentry = lookup_widget (preferencesdialog, "bandsentry"); |
|
|
bandoptionmenu = lookup_widget (mainwindow, "bandoptionmenu"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (bandsentry), 0, -1); |
|
|
bandsplit = g_strsplit (temp, ",", 0); |
|
|
deletespaces (bandsplit); |
|
|
updateoptionmenu (bandoptionmenu, bandsplit); |
|
|
|
|
|
/* set the optionmenu for bands in the main window */ |
|
|
bandentry = lookup_widget (mainwindow, "bandentry"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (bandentry), 0, -1); |
|
|
if (strlen (temp) > 0) |
|
|
{ |
|
|
if (strlen (temp) <= 2) |
|
|
bandcopy = g_strdup (temp); |
|
|
else |
|
|
bandcopy = finddot (temp); |
|
|
if (atoi (bandcopy) < 29) |
|
|
{ /* only support HF bands for now */ |
|
|
for (;;) |
|
|
{ |
|
|
if (g_strcasecmp (bandcopy, bandsplit[bandindex]) == 0) |
|
|
{ |
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU |
|
|
(bandoptionmenu), bandindex); |
|
|
break; |
|
|
} |
|
|
bandindex++; |
|
|
} |
|
|
} |
|
|
g_free (bandcopy); |
|
|
} |
|
|
|
|
|
preferences.modes = g_strjoinv (",", modesplit); |
|
|
preferences.bands = g_strjoinv (",", bandsplit); |
|
|
|
|
|
/* set visibility of widgets in QSO frame depending on state of toggle buttons */ |
|
|
bandsradiobutton1 = lookup_widget (preferencesdialog, "bandsradiobutton1"); |
|
|
toggletrue = |
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (bandsradiobutton1)); |
|
|
if (toggletrue) |
|
|
{ |
|
|
preferences.bandseditbox = 1; |
|
|
gtk_widget_hide (bandoptionmenu); |
|
|
gtk_widget_show (bandentry); |
|
|
} |
|
|
else |
|
|
{ |
|
|
preferences.bandseditbox = 0; |
|
|
gtk_widget_hide (bandentry); |
|
|
gtk_widget_show (bandoptionmenu); |
|
|
} |
|
|
modesradiobutton1 = lookup_widget (preferencesdialog, "modesradiobutton1"); |
|
|
toggletrue = |
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (modesradiobutton1)); |
|
|
if (toggletrue) |
|
|
{ |
|
|
preferences.modeseditbox = 1; |
|
|
gtk_widget_hide (modeoptionmenu); |
|
|
gtk_widget_show (modeentry); |
|
|
} |
|
|
else |
|
|
{ |
|
|
preferences.modeseditbox = 0; |
|
|
gtk_widget_hide (modeentry); |
|
|
gtk_widget_show (modeoptionmenu); |
|
|
} |
|
|
|
|
|
#if WANT_HAMLIB |
|
|
hamlibcheckbutton = lookup_widget (preferencesdialog, "hamlibcheckbutton"); |
|
|
frequencycheckbutton = |
|
|
lookup_widget (preferencesdialog, "frequencycheckbutton"); |
|
|
smetercheckbutton = lookup_widget (preferencesdialog, "smetercheckbutton"); |
|
|
radiocomboentry = lookup_widget (preferencesdialog, "radiocomboentry"); |
|
|
devicecomboentry = lookup_widget (preferencesdialog, "devicecomboentry"); |
|
|
digitscomboentry = lookup_widget (preferencesdialog, "digitscomboentry"); |
|
|
hamlibyes = gtk_toggle_button_get_active |
|
|
(GTK_TOGGLE_BUTTON (hamlibcheckbutton)); |
|
|
frequencyyesno = gtk_toggle_button_get_active |
|
|
(GTK_TOGGLE_BUTTON (frequencycheckbutton)); |
|
|
smeteryesno = gtk_toggle_button_get_active |
|
|
(GTK_TOGGLE_BUTTON (smetercheckbutton)); |
|
|
radio = gtk_editable_get_chars (GTK_EDITABLE (radiocomboentry), 0, -1); |
|
|
device = gtk_editable_get_chars (GTK_EDITABLE (devicecomboentry), 0, -1); |
|
|
digits = gtk_editable_get_chars (GTK_EDITABLE (digitscomboentry), 0, -1); |
|
|
|
|
|
if ((preferences.hamlib == 0) && hamlibyes) |
|
|
{ |
|
|
/* first use of hamlib, open radio */ |
|
|
rigid = get_rigid (radio); |
|
|
if (rigid != -1) |
|
|
{ |
|
|
myrig = rig_init (rigid); |
|
|
strncpy (myrig->state.rigport.pathname, device, FILPATHLEN); |
|
|
retcode = rig_open (myrig); |
|
|
if (retcode != RIG_OK) |
|
|
{ |
|
|
temp = |
|
|
g_strdup_printf (_ |
|
|
("An error occured while opening port %s: %s"), |
|
|
myrig->state.rigport.pathname, |
|
|
rigerror (retcode)); |
|
|
update_statusbar (temp); |
|
|
} |
|
|
else |
|
|
{ |
|
|
hamlibtimer = |
|
|
gtk_timeout_add (200, (GtkFunction) get_riginfo, NULL); |
|
|
} |
|
|
preferences.radio = g_strdup (radio); |
|
|
preferences.device = g_strdup (device); |
|
|
preferences.round = atoi (digits); |
|
|
hamlibwidgets = whichhamlibwidgets (frequencyyesno, smeteryesno); |
|
|
} |
|
|
else |
|
|
{ |
|
|
update_statusbar (_("Hamlib error: get_rigid failed")); |
|
|
} |
|
|
} |
|
|
else if ((preferences.hamlib > 0) && hamlibyes) |
|
|
{ |
|
|
/* see if we have selected another radio or port */ |
|
|
if ((g_strcasecmp (radio, preferences.radio) != 0) |
|
|
|| (g_strcasecmp (device, preferences.device) != 0)) |
|
|
{ |
|
|
gdk_input_remove (hamlibtimer); |
|
|
rig_close ((RIG *) myrig); |
|
|
rig_cleanup ((RIG *) myrig); |
|
|
rigid = get_rigid (radio); |
|
|
myrig = rig_init (rigid); |
|
|
strncpy (myrig->state.rigport.pathname, device, FILPATHLEN); |
|
|
retcode = rig_open (myrig); |
|
|
if (retcode != RIG_OK) |
|
|
{ |
|
|
temp = |
|
|
g_strdup_printf ("An error occured while opening port %s: %s", |
|
|
myrig->state.rigport.pathname, |
|
|
rigerror (retcode)); |
|
|
update_statusbar (temp); |
|
|
} |
|
|
else |
|
|
{ |
|
|
hamlibtimer = |
|
|
gtk_timeout_add (200, (GtkFunction) get_riginfo, NULL); |
|
|
} |
|
|
} |
|
|
preferences.radio = g_strdup (radio); |
|
|
preferences.device = g_strdup (device); |
|
|
preferences.round = atoi (digits); |
|
|
hamlibwidgets = whichhamlibwidgets (frequencyyesno, smeteryesno); |
|
|
} |
|
|
else if ((preferences.hamlib > 0) && !hamlibyes) |
|
|
{ |
|
|
/* hamlib disabled, close rig */ |
|
|
hamlibwidgets = 0; |
|
|
gdk_input_remove (hamlibtimer); |
|
|
hamlibtimer = -1; |
|
|
rig_close ((RIG *) myrig); |
|
|
rig_cleanup ((RIG *) myrig); |
|
|
preferences.radio = g_strdup ("Dummy"); |
|
|
preferences.device = g_strdup ("/dev/ttyS1"); |
|
|
preferences.round = 0; |
|
|
} |
|
|
else if ((preferences.hamlib = 0) && !hamlibyes) |
|
|
{ |
|
|
preferences.radio = g_strdup ("Dummy"); |
|
|
preferences.device = g_strdup ("/dev/ttyS1"); |
|
|
preferences.round = 0; |
|
|
} |
|
|
|
|
|
/* set widgets if they are changed */ |
|
|
if (hamlibwidgets != preferences.hamlib) |
|
|
{ |
|
|
sethamlibwidgets (hamlibwidgets); |
|
|
/* pixmaps need to be loaded if s-meter is enabled and was disabled before */ |
|
|
if (((hamlibwidgets == 3) || (hamlibwidgets == 4)) |
|
|
&& ((preferences.hamlib == 0) || (preferences.hamlib == 1) |
|
|
|| (preferences.hamlib == 2))) |
|
|
{ |
|
|
drawingarea = lookup_widget (mainwindow, "smeterdrawingarea"); |
|
|
loadsmeter (drawingarea); |
|
|
} |
|
|
preferences.hamlib = hamlibwidgets; |
|
|
} |
|
|
g_free (radio); |
|
|
g_free (device); |
|
|
g_free (digits); |
|
|
#endif |
|
|
|
|
|
/* clock */ |
|
|
clockcheckbutton = lookup_widget (preferencesdialog, "clockcheckbutton"); |
|
|
toggletrue = |
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (clockcheckbutton)); |
|
|
set_clock (toggletrue); |
|
|
|
|
|
g_free (temp); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
gtk_widget_destroy (preferencesdialog); |
|
|
} |
|
|
|
|
|
/* toggle hamlib widgets in the preferences dialog */ |
|
|
void |
|
|
on_hamlibcheckbutton_toggled (GtkToggleButton * togglebutton, |
|
|
gpointer user_data) |
|
|
{ |
|
|
GtkWidget *hamlibframe; |
|
|
gboolean toggletrue; |
|
|
|
|
|
hamlibframe = lookup_widget (preferencesdialog, "hamlibframe"); |
|
|
toggletrue = gtk_toggle_button_get_active (togglebutton); |
|
|
if (toggletrue) |
|
|
gtk_widget_set_sensitive (hamlibframe, 1); |
|
|
else |
|
|
gtk_widget_set_sensitive (hamlibframe, 0); |
|
|
} |
|
|
|
|
|
/* cancel the preferences dialog */ |
|
|
void |
|
|
on_preferencescancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
} |
|
|
|
|
|
/* the preferences dialog is deleted */ |
|
|
gboolean |
|
|
on_preferencesdialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* toggle sensistivity of band widgets in preferences dialog */ |
|
|
void |
|
|
on_bandsradiobutton_toggled (GtkToggleButton * togglebutton, |
|
|
gpointer user_data) |
|
|
{ |
|
|
GtkWidget *bandslabel, *bandsentry; |
|
|
|
|
|
bandslabel = lookup_widget (preferencesdialog, "bandslabel"); |
|
|
bandsentry = lookup_widget (preferencesdialog, "bandsentry"); |
|
|
switch (atoi (user_data)) |
|
|
{ |
|
|
case 1: |
|
|
gtk_widget_set_sensitive (bandslabel, 0); |
|
|
gtk_widget_set_sensitive (bandsentry, 0); |
|
|
break; |
|
|
case 2: |
|
|
gtk_widget_set_sensitive (bandslabel, 1); |
|
|
gtk_widget_set_sensitive (bandsentry, 1); |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
/* toggle sensistivity of modes widgets in preferences dialog */ |
|
|
void |
|
|
on_modesradiobutton_toggled (GtkToggleButton * togglebutton, |
|
|
gpointer user_data) |
|
|
{ |
|
|
GtkWidget *modeslabel, *modesentry; |
|
|
|
|
|
modeslabel = lookup_widget (preferencesdialog, "modeslabel"); |
|
|
modesentry = lookup_widget (preferencesdialog, "modesentry"); |
|
|
switch (atoi (user_data)) |
|
|
{ |
|
|
case 1: |
|
|
gtk_widget_set_sensitive (modeslabel, 0); |
|
|
gtk_widget_set_sensitive (modesentry, 0); |
|
|
break; |
|
|
case 2: |
|
|
gtk_widget_set_sensitive (modeslabel, 1); |
|
|
gtk_widget_set_sensitive (modesentry, 1); |
|
|
break; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
/* show color selection dialog and apply the theme color */ |
|
|
void |
|
|
on_themebutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *colorselectiondialog; |
|
|
gdouble rgb[3]; |
|
|
gchar *themecolor; |
|
|
GdkColor color; |
|
|
|
|
|
colorselectiondialog = create_colorselectiondialog (); |
|
|
gtk_widget_destroy (GTK_COLOR_SELECTION_DIALOG (colorselectiondialog)-> |
|
|
help_button); |
|
|
|
|
|
themecolor = color_parse (preferences.themecolor); |
|
|
gdk_color_parse (themecolor, &color); |
|
|
g_free (themecolor); |
|
|
rgb[0] = color.red / 65535.0; |
|
|
rgb[1] = color.green / 65535.0; |
|
|
rgb[2] = color.blue / 65535.0; |
|
|
gtk_color_selection_set_color (GTK_COLOR_SELECTION |
|
|
(GTK_COLOR_SELECTION_DIALOG |
|
|
(colorselectiondialog)->colorsel), rgb); |
|
|
|
|
|
gtk_widget_set_sensitive (preferencesdialog, 0); |
|
|
gtk_widget_show (colorselectiondialog); |
|
|
} |
|
|
|
|
|
/* change theme font */ |
|
|
void |
|
|
on_fontbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *fontselectiondialog; |
|
|
|
|
|
fontselectiondialog = create_fontselectiondialog (); |
|
|
gtk_widget_destroy (GTK_FONT_SELECTION_DIALOG (fontselectiondialog)-> |
|
|
apply_button); |
|
|
gtk_font_selection_dialog_set_preview_text (GTK_FONT_SELECTION_DIALOG |
|
|
(fontselectiondialog), |
|
|
_("How about this font?")); |
|
|
gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG |
|
|
(fontselectiondialog), |
|
|
preferences.themefont); |
|
|
gtk_widget_set_sensitive (preferencesdialog, 0); |
|
|
gtk_widget_show (fontselectiondialog); |
|
|
} |
|
|
|
|
|
/* change path for the logs */ |
|
|
void |
|
|
on_pathbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *pathselection; |
|
|
|
|
|
pathselection = create_pathselection (); |
|
|
gtk_entry_set_editable (GTK_ENTRY |
|
|
(GTK_FILE_SELECTION (pathselection)-> |
|
|
selection_entry), FALSE); |
|
|
gtk_widget_set_sensitive (preferencesdialog, 0); |
|
|
gtk_widget_show (pathselection); |
|
|
} |
|
|
|
|
|
|
|
|
/* SETUP DIALOG */ |
|
|
void |
|
|
on_setupbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_show (mainwindow); |
|
|
gdk_window_move_resize (mainwindow->window, preferences.x, preferences.y, |
|
|
preferences.width, preferences.height); |
|
|
} |
|
|
|
|
|
/* setup dialog is deleted */ |
|
|
gboolean |
|
|
on_setupdialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_show (mainwindow); |
|
|
gdk_window_move_resize (mainwindow->window, preferences.x, preferences.y, |
|
|
preferences.width, preferences.height); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* SAVE DIALOG */ |
|
|
void |
|
|
on_saveokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_exit (0); |
|
|
} |
|
|
|
|
|
/* cancel clicked, nothing saved */ |
|
|
void |
|
|
on_savecancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
/* save dialog is deleted */ |
|
|
gboolean |
|
|
on_savedialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* PRINT DIALOG */ |
|
|
void |
|
|
on_printokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *printallradiobutton, *printrangeradiobutton, *printlowentry, |
|
|
*printhighentry, *sizecomboentry, *pointcomboentry, |
|
|
*conteststyleradiobutton, *normalstyleradiobutton, |
|
|
*filedestinationradiobutton, *printerdestinationradiobutton, *endhbox, |
|
|
*qslhbox, *powerhbox, *namehbox, *qthhbox, *locatorhbox, *unknown1hbox, |
|
|
*unknown2hbox, *remarksvbox; |
|
|
gchar *temp, *texpoint, *texorientation, *texsize, *texfile, *printstring = |
|
|
NULL, **item; |
|
|
FILE *fp; |
|
|
gint i, j, k = 0, printhigh, printlow; |
|
|
gboolean printok = FALSE; |
|
|
logtype *logwindow; |
|
|
|
|
|
printallradiobutton = lookup_widget (printdialog, "printallradiobutton"); |
|
|
printrangeradiobutton = |
|
|
lookup_widget (printdialog, "printrangeradiobutton"); |
|
|
printlowentry = lookup_widget (printdialog, "printlowentry"); |
|
|
printhighentry = lookup_widget (printdialog, "printhighentry"); |
|
|
sizecomboentry = lookup_widget (printdialog, "sizecomboentry"); |
|
|
pointcomboentry = lookup_widget (printdialog, "pointcomboentry"); |
|
|
filedestinationradiobutton = lookup_widget (printdialog, |
|
|
"filedestinationradiobutton"); |
|
|
printerdestinationradiobutton = lookup_widget (printdialog, |
|
|
"printerdestinationradiobutton"); |
|
|
normalstyleradiobutton = |
|
|
lookup_widget (printdialog, "normalstyleradiobutton"); |
|
|
conteststyleradiobutton = |
|
|
lookup_widget (printdialog, "conteststyleradiobutton"); |
|
|
|
|
|
/* save settings of the print dialog */ |
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (printallradiobutton))) |
|
|
preferences.printall = 0; |
|
|
else |
|
|
preferences.printall = 1; |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (printlowentry), 0, -1); |
|
|
printlow = atoi (temp); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (printhighentry), 0, -1); |
|
|
printhigh = atoi (temp); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (sizecomboentry), 0, -1); |
|
|
if (g_strcasecmp (temp, "a4") == 0) |
|
|
preferences.printsize = 0; |
|
|
else |
|
|
preferences.printsize = 1; |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (pointcomboentry), 0, -1); |
|
|
if (g_strcasecmp (temp, "10") == 0) |
|
|
preferences.printpoint = 0; |
|
|
else if (g_strcasecmp (temp, "11") == 0) |
|
|
preferences.printpoint = 1; |
|
|
else if (g_strcasecmp (temp, "12") == 0) |
|
|
preferences.printpoint = 2; |
|
|
if (gtk_toggle_button_get_active |
|
|
(GTK_TOGGLE_BUTTON (printerdestinationradiobutton))) |
|
|
preferences.printdestination = 0; |
|
|
else |
|
|
preferences.printdestination = 1; |
|
|
if (gtk_toggle_button_get_active |
|
|
(GTK_TOGGLE_BUTTON (normalstyleradiobutton))) |
|
|
preferences.printstyle = 0; |
|
|
else |
|
|
preferences.printstyle = 1; |
|
|
|
|
|
/* tex strings that may differ */ |
|
|
if (preferences.printsize == 0) |
|
|
texsize = g_strdup ("a4paper"); |
|
|
else |
|
|
texsize = g_strdup ("letterpaper"); |
|
|
if (preferences.printstyle == 0) |
|
|
texorientation = g_strdup ("landscape"); |
|
|
else |
|
|
texorientation = g_strdup ("portrait"); |
|
|
if (preferences.printpoint == 0) |
|
|
texpoint = g_strdup ("10pt"); |
|
|
else if (preferences.printpoint == 1) |
|
|
texpoint = g_strdup ("11pt"); |
|
|
else |
|
|
texpoint = g_strdup ("12pt"); |
|
|
|
|
|
logwindow = g_list_nth_data (logwindowlist, |
|
|
gtk_notebook_get_current_page (GTK_NOTEBOOK |
|
|
(mainnotebook))); |
|
|
gtk_clist_freeze (GTK_CLIST (logwindow->clist)); |
|
|
|
|
|
item = g_new0 (gchar *, QSO_FIELDS); |
|
|
texfile = g_strconcat (xlogdir, G_DIR_SEPARATOR_S, "log.tex", NULL); |
|
|
fp = fopen (texfile, "w"); |
|
|
if (fp) |
|
|
{ /* widgets which may be visible */ |
|
|
endhbox = lookup_widget (mainwindow, "endhbox"); |
|
|
qslhbox = lookup_widget (mainwindow, "qslhbox"); |
|
|
powerhbox = lookup_widget (mainwindow, "powerhbox"); |
|
|
namehbox = lookup_widget (mainwindow, "namehbox"); |
|
|
qthhbox = lookup_widget (mainwindow, "qthhbox"); |
|
|
locatorhbox = lookup_widget (mainwindow, "locatorhbox"); |
|
|
unknown1hbox = lookup_widget (mainwindow, "unknown1hbox"); |
|
|
unknown2hbox = lookup_widget (mainwindow, "unknown2hbox"); |
|
|
remarksvbox = lookup_widget (mainwindow, "remarksvbox"); |
|
|
|
|
|
fprintf (fp, "\\documentclass[%s,%s,%s]{article}\n", texsize, |
|
|
texorientation, texpoint); |
|
|
fprintf (fp, "\\pagestyle{empty}\n"); |
|
|
fprintf (fp, |
|
|
"\\usepackage[%s,left=15mm,right=15mm,top=10mm,bottom=10mm]{geometry}\n", |
|
|
texsize); |
|
|
fprintf (fp, "\\begin{document}\n"); |
|
|
if (preferences.printstyle == 0) |
|
|
{ |
|
|
fprintf (fp, "\\begin{tabular}{||l|l|l"); /* nr, date, gmt */ |
|
|
if (GTK_WIDGET_VISIBLE (endhbox)) |
|
|
fprintf (fp, "|l"); /* gmtend */ |
|
|
fprintf (fp, "|l|l|l|l|l"); /* call band mode rst myrst */ |
|
|
if (GTK_WIDGET_VISIBLE (qslhbox)) |
|
|
fprintf (fp, "|c|c"); /* qslin, qslout */ |
|
|
if (GTK_WIDGET_VISIBLE (powerhbox)) |
|
|
fprintf (fp, "|l"); /* power */ |
|
|
if (GTK_WIDGET_VISIBLE (namehbox)) |
|
|
fprintf (fp, "|l"); /* name */ |
|
|
if (GTK_WIDGET_VISIBLE (qthhbox)) |
|
|
fprintf (fp, "|l"); /* qth */ |
|
|
if (GTK_WIDGET_VISIBLE (locatorhbox)) |
|
|
fprintf (fp, "|l"); /* locator */ |
|
|
if (GTK_WIDGET_VISIBLE (unknown1hbox)) |
|
|
fprintf (fp, "|l"); /* unknown1 */ |
|
|
if (GTK_WIDGET_VISIBLE (unknown2hbox)) |
|
|
fprintf (fp, "|l"); /* unknown2 */ |
|
|
if (GTK_WIDGET_VISIBLE (remarksvbox)) |
|
|
fprintf (fp, "|l"); /*remarks */ |
|
|
fprintf (fp, "||}\n"); |
|
|
} |
|
|
else |
|
|
fprintf (fp, "\\begin{tabular}{||l|l|l|l|l|l|l|l||l|l||}\n"); |
|
|
fprintf (fp, "\\hline\n"); |
|
|
if (preferences.printstyle == 0) |
|
|
{ |
|
|
fprintf (fp, "\\textbf{Nr} &\\textbf{Date} &\\textbf{GMT}"); |
|
|
if (GTK_WIDGET_VISIBLE (endhbox)) |
|
|
fprintf (fp, "&\\textbf{END}"); |
|
|
fprintf (fp, |
|
|
"&\\textbf{Callsign} &\\textbf{MHz} &\\textbf{Mode} &\\textbf{TX} &\\textbf{RX}"); |
|
|
if (GTK_WIDGET_VISIBLE (qslhbox)) |
|
|
fprintf (fp, "&\\textbf{Out} &\\textbf{In}"); |
|
|
if (GTK_WIDGET_VISIBLE (powerhbox)) |
|
|
fprintf (fp, "&\\textbf{Pwr}"); |
|
|
if (GTK_WIDGET_VISIBLE (namehbox)) |
|
|
fprintf (fp, "&\\textbf{Name}"); |
|
|
if (GTK_WIDGET_VISIBLE (qthhbox)) |
|
|
fprintf (fp, "&\\textbf{QTH}"); |
|
|
if (GTK_WIDGET_VISIBLE (locatorhbox)) |
|
|
fprintf (fp, "&\\textbf{Locator}"); |
|
|
if (GTK_WIDGET_VISIBLE (unknown1hbox)) |
|
|
{ |
|
|
fprintf (fp, "&\\textbf{"); |
|
|
fprintf (fp, preferences.freefield1); |
|
|
fprintf (fp, "}"); |
|
|
} |
|
|
if (GTK_WIDGET_VISIBLE (unknown2hbox)) |
|
|
{ |
|
|
fprintf (fp, "&\\textbf{"); |
|
|
fprintf (fp, preferences.freefield2); |
|
|
fprintf (fp, "}"); |
|
|
} |
|
|
if (GTK_WIDGET_VISIBLE (remarksvbox)) |
|
|
fprintf (fp, "&\\textbf{Remarks}"); |
|
|
fprintf (fp, "\\\\\n"); |
|
|
} |
|
|
else |
|
|
fprintf (fp, |
|
|
"\\textbf{Nr} &\\textbf{Date} &\\textbf{GMT} &\\textbf{Callsign} &\\textbf{MHz} &\\textbf{Mode} &\\textbf{TX} &\\textbf{RX} &\\textbf{Multiplier} &\\textbf{Points}\\\\\n"); |
|
|
fprintf (fp, "\\hline\n"); |
|
|
fprintf (fp, "\\hline\n"); |
|
|
|
|
|
if (preferences.printall == 0) |
|
|
{ |
|
|
printlow = 1; |
|
|
printhigh = logwindow->qsos; |
|
|
} |
|
|
|
|
|
if (GTK_CLIST (logwindow->clist)->rows > 0) |
|
|
{ |
|
|
for (i = GTK_CLIST (logwindow->clist)->rows - printlow; |
|
|
i >= GTK_CLIST (logwindow->clist)->rows - printhigh; i--) |
|
|
{ |
|
|
for (j = 0; j < QSO_FIELDS; j++) |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), i, j, |
|
|
&item[j]); |
|
|
if (preferences.printstyle == 0) |
|
|
{ |
|
|
fprintf (fp, "%s&%s&%s", item[NR], item[DATE], item[GMT]); |
|
|
if (GTK_WIDGET_VISIBLE (endhbox)) |
|
|
fprintf (fp, "&%s", item[GMTEND]); |
|
|
fprintf (fp, "&\\textbf{%s}&%s&%s&%s&%s", |
|
|
item[CALL], item[BAND], item[MODE], item[RST], |
|
|
item[MYRST]); |
|
|
if (GTK_WIDGET_VISIBLE (qslhbox)) |
|
|
fprintf (fp, "&%s&%s", item[QSLOUT], item[QSLIN]); |
|
|
if (GTK_WIDGET_VISIBLE (powerhbox)) |
|
|
fprintf (fp, "&%s", item[POWER]); |
|
|
if (GTK_WIDGET_VISIBLE (namehbox)) |
|
|
fprintf (fp, "&%s", item[NAME]); |
|
|
if (GTK_WIDGET_VISIBLE (qthhbox)) |
|
|
fprintf (fp, "&%s", item[QTH]); |
|
|
if (GTK_WIDGET_VISIBLE (locatorhbox)) |
|
|
fprintf (fp, "&%s", item[LOCATOR]); |
|
|
if (GTK_WIDGET_VISIBLE (unknown1hbox)) |
|
|
fprintf (fp, "&%s", item[U1]); |
|
|
if (GTK_WIDGET_VISIBLE (unknown2hbox)) |
|
|
fprintf (fp, "&%s", item[U2]); |
|
|
if (GTK_WIDGET_VISIBLE (remarksvbox)) |
|
|
{ /* escape # for latex, TODO: &, _, %, $, \, {, }, ^ */ |
|
|
if (strstr (item[REMARKS], "#")) |
|
|
temp = strreplace (item[REMARKS], "#", "\\#"); |
|
|
fprintf (fp, "&%s", temp); |
|
|
} |
|
|
fprintf (fp, "\\\\\n"); |
|
|
} |
|
|
else |
|
|
fprintf (fp, "%d&%s&%s&\\textbf{%s}&%s&%s&%s&%s&~&~\\\\\n", |
|
|
k + 1, item[DATE], item[GMT], item[CALL], item[BAND], |
|
|
item[MODE], item[RST], item[MYRST]); |
|
|
k++; |
|
|
if ((k % 30 == 0 && preferences.printstyle == 0 |
|
|
&& k != printhigh - printlow + 1) || (k % 50 == 0 |
|
|
&& preferences. |
|
|
printstyle == 1 |
|
|
&& k != |
|
|
printhigh - |
|
|
printlow + 1)) |
|
|
{ |
|
|
fprintf (fp, "\\hline\n"); |
|
|
fprintf (fp, "\\end{tabular}\n"); |
|
|
fprintf (fp, "\\begin{center}\n"); |
|
|
fprintf (fp, "\\emph{Printed by xlog version %s}\n", |
|
|
VERSION); |
|
|
fprintf (fp, "\\end{center}\n"); |
|
|
fprintf (fp, "\\newpage\n"); |
|
|
if (preferences.printstyle == 0) |
|
|
fprintf (fp, |
|
|
"\\begin{tabular}{||l|l|l|l|l|l|l|l||l|c|c||}\n"); |
|
|
else |
|
|
fprintf (fp, |
|
|
"\\begin{tabular}{||l|l|l|l|l|l|l|l||l|l||}\n"); |
|
|
fprintf (fp, "\\hline\n"); |
|
|
if (preferences.printstyle == 0) |
|
|
{ |
|
|
fprintf (fp, |
|
|
"\\textbf{Nr} &\\textbf{Date} &\\textbf{GMT}"); |
|
|
if (GTK_WIDGET_VISIBLE (endhbox)) |
|
|
fprintf (fp, "&\\textbf{END}"); |
|
|
fprintf (fp, |
|
|
"&\\textbf{Callsign} &\\textbf{MHz} &\\textbf{Mode} &\\textbf{TX} &\\textbf{RX}"); |
|
|
if (GTK_WIDGET_VISIBLE (qslhbox)) |
|
|
fprintf (fp, "&\\textbf{Out} &\\textbf{In} "); |
|
|
if (GTK_WIDGET_VISIBLE (powerhbox)) |
|
|
fprintf (fp, "&\\textbf{Pwr}"); |
|
|
if (GTK_WIDGET_VISIBLE (namehbox)) |
|
|
fprintf (fp, "&\\textbf{Name}"); |
|
|
if (GTK_WIDGET_VISIBLE (qthhbox)) |
|
|
fprintf (fp, "&\\textbf{QTH}"); |
|
|
if (GTK_WIDGET_VISIBLE (locatorhbox)) |
|
|
fprintf (fp, "&\\textbf{Locator}"); |
|
|
if (GTK_WIDGET_VISIBLE (unknown1hbox)) |
|
|
{ |
|
|
fprintf (fp, "&\\textbf{"); |
|
|
fprintf (fp, preferences.freefield1); |
|
|
fprintf (fp, "}"); |
|
|
} |
|
|
if (GTK_WIDGET_VISIBLE (unknown2hbox)) |
|
|
{ |
|
|
fprintf (fp, "&\\textbf{"); |
|
|
fprintf (fp, preferences.freefield2); |
|
|
fprintf (fp, "}"); |
|
|
} |
|
|
if (GTK_WIDGET_VISIBLE (remarksvbox)) |
|
|
fprintf (fp, "&\\textbf{Remarks}"); |
|
|
fprintf (fp, "\\\\\n"); |
|
|
} |
|
|
else |
|
|
fprintf (fp, |
|
|
"\\textbf{Nr} &\\textbf{Date} &\\textbf{GMT} &\\textbf{Callsign} &\\textbf{MHz} &\\textbf{Mode} &\\textbf{TX} &\\textbf{RX} &\\textbf{Multiplier} &\\textbf{Points}\\\\\n"); |
|
|
fprintf (fp, "\\hline\n"); |
|
|
fprintf (fp, "\\hline\n"); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
fprintf (fp, "\\hline\n"); |
|
|
fprintf (fp, "\\end{tabular}\n"); |
|
|
fprintf (fp, "\\begin{center}\n"); |
|
|
fprintf (fp, "\\emph{Printed by xlog version %s}\n", VERSION); |
|
|
fprintf (fp, "\\end{center}\n"); |
|
|
fprintf (fp, "\\end{document}\n"); |
|
|
fclose (fp); |
|
|
} |
|
|
|
|
|
gtk_clist_thaw (GTK_CLIST (logwindow->clist)); |
|
|
g_free (item); |
|
|
|
|
|
if ((printok = latexavailable ()) == FALSE) |
|
|
{ |
|
|
update_statusbar (_ |
|
|
("Latex is not available, install the tetex package")); |
|
|
} |
|
|
|
|
|
if (printok) |
|
|
{ |
|
|
if (preferences.printdestination == 0 && preferences.printstyle == 0) |
|
|
printstring = |
|
|
g_strdup_printf |
|
|
("cd %s; latex -interaction=nonstopmode log.tex; dvips -t landscape log.dvi", |
|
|
xlogdir); |
|
|
else if (preferences.printdestination == 1 |
|
|
&& preferences.printstyle == 0) |
|
|
printstring = |
|
|
g_strdup_printf |
|
|
("cd %s; latex -interaction=nonstopmode log.tex; dvips -t landscape -o log.ps log.dvi", |
|
|
xlogdir); |
|
|
else if (preferences.printdestination == 0 |
|
|
&& preferences.printstyle == 1) |
|
|
printstring = |
|
|
g_strdup_printf |
|
|
("cd %s; latex -interaction=nonstopmode log.tex; dvips log.dvi", |
|
|
xlogdir); |
|
|
else if (preferences.printdestination == 1 |
|
|
&& preferences.printstyle == 1) |
|
|
printstring = |
|
|
g_strdup_printf |
|
|
("cd %s; latex -interaction=nonstopmode log.tex; dvips -o log.ps log.dvi", |
|
|
xlogdir); |
|
|
if (preferences.printdestination == 0) |
|
|
temp = g_strdup_printf (_("Log send to printer")); |
|
|
else |
|
|
temp = |
|
|
g_strdup_printf (_("Log printed to %s%slog.ps"), xlogdir, G_DIR_SEPARATOR_S); |
|
|
system (printstring); |
|
|
update_statusbar (temp); |
|
|
g_free (printstring); |
|
|
} |
|
|
|
|
|
g_free (texsize); |
|
|
g_free (texorientation); |
|
|
g_free (texpoint); |
|
|
g_free (texfile); |
|
|
g_free (temp); |
|
|
|
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
} |
|
|
|
|
|
/* cancel clicked, nothing printed */ |
|
|
void |
|
|
on_printcancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
} |
|
|
|
|
|
/* print dialog is deleted */ |
|
|
gboolean |
|
|
on_printdialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* set sensitivity of range widgets in print dialog */ |
|
|
void |
|
|
on_printradiobutton_toggled (GtkToggleButton * togglebutton, |
|
|
gpointer user_data) |
|
|
{ |
|
|
GtkWidget *printlowentry, *printrangelabel, *printhighentry; |
|
|
|
|
|
printlowentry = lookup_widget (printdialog, "printlowentry"); |
|
|
printhighentry = lookup_widget (printdialog, "printhighentry"); |
|
|
printrangelabel = lookup_widget (printdialog, "printrangelabel"); |
|
|
switch (atoi (user_data)) |
|
|
{ |
|
|
case 1: |
|
|
gtk_widget_set_sensitive (printlowentry, 0); |
|
|
gtk_widget_set_sensitive (printhighentry, 0); |
|
|
gtk_widget_set_sensitive (printrangelabel, 0); |
|
|
break; |
|
|
case 2: |
|
|
gtk_widget_set_sensitive (printlowentry, 1); |
|
|
gtk_widget_set_sensitive (printhighentry, 1); |
|
|
gtk_widget_set_sensitive (printrangelabel, 1); |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* SEARCH DIALOG */ |
|
|
void |
|
|
on_searchokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gchar *searchstr, *upsearchstr, *callsign, *labeltext; |
|
|
GtkWidget *searchdialog, *searchresultdialog, *searchcomboentry, |
|
|
*resultlabel, *searchcheckbutton; |
|
|
gint i, row; |
|
|
gboolean result = FALSE, searchopen; |
|
|
GList *node; |
|
|
logtype *logwindow; |
|
|
|
|
|
searchdialog = gtk_widget_get_toplevel (GTK_WIDGET (button)); |
|
|
searchcomboentry = lookup_widget (searchdialog, "searchcomboentry"); |
|
|
searchcheckbutton = lookup_widget (searchdialog, "searchcheckbutton"); |
|
|
|
|
|
searchopen = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON |
|
|
(searchcheckbutton)); |
|
|
|
|
|
searchstr = gtk_editable_get_chars (GTK_EDITABLE (searchcomboentry), 0, -1); |
|
|
|
|
|
/* add to the searchlist if it is a new one */ |
|
|
node = g_list_find_custom (searchhistory, g_strdup (searchstr), |
|
|
(GCompareFunc) strncmp); |
|
|
if (!node) |
|
|
searchhistory = g_list_prepend (searchhistory, g_strdup (searchstr)); |
|
|
if (g_list_length (searchhistory) > SEARCHHISTORY) |
|
|
searchhistory = g_list_remove (searchhistory, |
|
|
g_list_last (searchhistory)->data); |
|
|
|
|
|
upsearchstr = g_strdup (searchstr); |
|
|
g_strup (upsearchstr); |
|
|
|
|
|
/* search all logs and select corresponding QSO */ |
|
|
for (i = state.searchlog; i < g_list_length (logwindowlist); i++) |
|
|
{ |
|
|
logwindow = g_list_nth_data (logwindowlist, i); |
|
|
for (row = state.searchqso; row < logwindow->qsos; row++) |
|
|
{ |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, |
|
|
CALL, &callsign); |
|
|
if (strstr (callsign, upsearchstr)) |
|
|
{ |
|
|
gtk_notebook_set_page (GTK_NOTEBOOK (mainnotebook), i); |
|
|
gtk_clist_moveto (GTK_CLIST (logwindow->clist), row, 0, 0.5, 0); |
|
|
gtk_clist_select_row (GTK_CLIST (logwindow->clist), row, 0); |
|
|
result = TRUE; |
|
|
} |
|
|
if (result) |
|
|
break; |
|
|
} |
|
|
/* reset search */ |
|
|
if (row == logwindow->qsos |
|
|
&& state.searchlog < g_list_length (logwindowlist)) |
|
|
{ |
|
|
state.searchqso = 0; |
|
|
state.searchlog++; |
|
|
if (state.searchlog == g_list_length (logwindowlist)) |
|
|
state.searchlog = 0; |
|
|
} |
|
|
else |
|
|
state.searchqso = row + 1; |
|
|
if (result) |
|
|
break; |
|
|
} |
|
|
|
|
|
/* not found, show the result */ |
|
|
if (!result) |
|
|
{ |
|
|
state.searchqso = 0; |
|
|
searchresultdialog = create_searchresultdialog (); |
|
|
resultlabel = lookup_widget (searchresultdialog, "resultlabel"); |
|
|
labeltext = g_strdup_printf (_("\'%s\' was not found"), searchstr); |
|
|
gtk_label_set_text (GTK_LABEL (resultlabel), labeltext); |
|
|
g_free (labeltext); |
|
|
gtk_widget_show (searchresultdialog); |
|
|
} |
|
|
|
|
|
g_free (searchstr); |
|
|
g_free (upsearchstr); |
|
|
|
|
|
if (!searchopen) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
gtk_widget_destroy (searchdialog); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* search cancel */ |
|
|
void |
|
|
on_searchcancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
} |
|
|
|
|
|
/* search changed, reset saved state */ |
|
|
void |
|
|
on_searchcomboentry_changed (GtkEditable * editable, gpointer user_data) |
|
|
{ |
|
|
state.searchqso = 0; |
|
|
state.searchlog = 0; |
|
|
} |
|
|
|
|
|
/* toggle 'keep this dialog open' */ |
|
|
void |
|
|
on_searchcheckbutton_toggled (GtkToggleButton * togglebutton, |
|
|
gpointer user_data) |
|
|
{ |
|
|
GtkWidget *searchdialog, *searchcheckbutton; |
|
|
gboolean searchopen; |
|
|
|
|
|
searchdialog = gtk_widget_get_toplevel (GTK_WIDGET (togglebutton)); |
|
|
searchcheckbutton = lookup_widget (searchdialog, "searchcheckbutton"); |
|
|
searchopen = |
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (searchcheckbutton)); |
|
|
if (searchopen) |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
else |
|
|
gtk_widget_set_sensitive (mainwindow, 0); |
|
|
} |
|
|
|
|
|
gboolean |
|
|
on_searchdialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* SEARCHRESULT DIALOG */ |
|
|
void |
|
|
on_searchresultokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
} |
|
|
|
|
|
/* COLOR SELECTION DIALOG */ |
|
|
void |
|
|
on_colorokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *colorselectiondialog, *examplelabel, *exampleframe; |
|
|
gdouble rgb[3]; |
|
|
gchar *colorred, *colorgreen, *colorblue, *color; |
|
|
|
|
|
colorselectiondialog = gtk_widget_get_toplevel (GTK_WIDGET (button)); |
|
|
gtk_color_selection_get_color (GTK_COLOR_SELECTION |
|
|
(GTK_COLOR_SELECTION_DIALOG |
|
|
(colorselectiondialog)->colorsel), rgb); |
|
|
colorred = g_strdup_printf ("%04X", (gint) (rgb[0] * 65535)); |
|
|
colorgreen = g_strdup_printf ("%04X", (gint) (rgb[1] * 65535)); |
|
|
colorblue = g_strdup_printf ("%04X", (gint) (rgb[2] * 65535)); |
|
|
color = g_strconcat (colorred, ",", colorgreen, ",", colorblue, NULL); |
|
|
exampleframe = lookup_widget (preferencesdialog, "exampleframe"); |
|
|
setframestyle (exampleframe, color, preferences.themefont); |
|
|
examplelabel = lookup_widget (preferencesdialog, "examplelabel"); |
|
|
setlabelstyle (examplelabel, color, preferences.themefont); |
|
|
g_free (colorblue); |
|
|
g_free (colorgreen); |
|
|
g_free (colorred); |
|
|
g_free (color); |
|
|
gtk_widget_set_sensitive (preferencesdialog, 1); |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
} |
|
|
|
|
|
|
|
|
/* cancel color selection */ |
|
|
void |
|
|
on_colorcancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (preferencesdialog, 1); |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
} |
|
|
|
|
|
/* color selection dialog is deleted */ |
|
|
gboolean |
|
|
on_colorselectiondialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (preferencesdialog, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* NEW LOG DIALOG */ |
|
|
void |
|
|
on_newlogokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *newlogentry, *newlogdialog, *menubar, *log_editor_menu; |
|
|
gchar *entry, *filename, *xlogbackupfile; |
|
|
logtype *logwindow = NULL; |
|
|
gint i; |
|
|
LOGDB *lp; |
|
|
gboolean logopen = FALSE, logexist = FALSE; |
|
|
GString *logs; |
|
|
|
|
|
newlogdialog = gtk_widget_get_toplevel (GTK_WIDGET (button)); |
|
|
newlogentry = lookup_widget (newlogdialog, "newlogentry"); |
|
|
entry = gtk_editable_get_chars (GTK_EDITABLE (newlogentry), 0, -1); |
|
|
|
|
|
if (strlen (entry) > 0) |
|
|
{ |
|
|
for (i = 0; i < g_list_length (logwindowlist); i++) |
|
|
{ /* see if the log is already open */ |
|
|
logwindow = g_list_nth_data (logwindowlist, i); |
|
|
if (g_strcasecmp (entry, logwindow->logname) == 0) |
|
|
{ |
|
|
gtk_notebook_set_page (GTK_NOTEBOOK (mainnotebook), i); |
|
|
set_qsoframe (logwindow); |
|
|
logopen = TRUE; |
|
|
break; |
|
|
} |
|
|
} |
|
|
if (!logopen) |
|
|
{ /* check if the log exists and open it */ |
|
|
filename = g_strconcat (entry, ".xlog", 0); |
|
|
logs = getlogs (preferences.savedir, 0); |
|
|
if (((logs->len) > 0) && (strstr (logs->str, filename))) |
|
|
{ |
|
|
logexist = TRUE; |
|
|
filename = |
|
|
g_strconcat (preferences.savedir, G_DIR_SEPARATOR_S, entry, |
|
|
".xlog", NULL); |
|
|
lp = log_file_open (filename, TYPE_FLOG); |
|
|
if (lp) |
|
|
{ |
|
|
logwindow = openlog (lp, entry, state.logwindows++); |
|
|
log_file_qso_foreach (lp, fillin_clist, logwindow); |
|
|
log_file_close (lp); |
|
|
logwindowlist = g_list_append (logwindowlist, logwindow); |
|
|
gtk_notebook_set_page (GTK_NOTEBOOK (mainnotebook), |
|
|
state.logwindows - 1); |
|
|
set_qsoframe (logwindow); |
|
|
xlogbackupfile = g_strconcat (filename, ".backup", NULL); |
|
|
savelog (logwindow, xlogbackupfile, TYPE_FLOG); |
|
|
g_free (xlogbackupfile); |
|
|
} |
|
|
g_free (filename); |
|
|
g_string_free (logs, TRUE); |
|
|
} |
|
|
} |
|
|
if ((!logopen) && (!logexist)) |
|
|
{ /* create a new log */ |
|
|
filename = |
|
|
g_strconcat (preferences.savedir, G_DIR_SEPARATOR_S, entry, |
|
|
".xlog", NULL); |
|
|
lp = |
|
|
log_file_create (filename, TYPE_FLOG, qso_field_nr, qso_fields, |
|
|
qso_widths); |
|
|
if (lp) |
|
|
{ |
|
|
logwindow = openlog (lp, entry, state.logwindows++); |
|
|
log_file_close (lp); |
|
|
logwindowlist = g_list_append (logwindowlist, logwindow); |
|
|
gtk_notebook_set_page (GTK_NOTEBOOK (mainnotebook), |
|
|
state.logwindows - 1); |
|
|
set_qsoframe (logwindow); |
|
|
} |
|
|
g_free (filename); |
|
|
} |
|
|
g_free (entry); |
|
|
} |
|
|
|
|
|
gtk_widget_destroy (newlogdialog); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
|
|
|
/* fire up the logeditor */ |
|
|
if ((!logopen) && (!logexist)) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 0); |
|
|
menubar = lookup_widget (mainwindow, "menubar"); |
|
|
log_editor_menu = lookup_widget (menubar, "log_editor"); |
|
|
gtk_signal_emit_by_name (GTK_OBJECT (log_editor_menu), "activate"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* no new log */ |
|
|
void |
|
|
on_newlogcancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
} |
|
|
|
|
|
/* new log dialog is deleted */ |
|
|
gboolean |
|
|
on_newlogdialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* OPEN DIALOG */ |
|
|
void |
|
|
on_fileselection_ok_button_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *fileselection, *filemenu, *menu, *item; |
|
|
gchar *logn, *sellog, *xlogbackupfile, *temp; |
|
|
gpointer filen; |
|
|
gboolean logexist = FALSE; |
|
|
gint i, filetype; |
|
|
logtype *logwindow; |
|
|
LOGDB *lp; |
|
|
|
|
|
fileselection = gtk_widget_get_toplevel (GTK_WIDGET (button)); |
|
|
|
|
|
/* skip all if nothing filled in */ |
|
|
if (strlen |
|
|
(gtk_editable_get_chars |
|
|
(GTK_EDITABLE (GTK_FILE_SELECTION (fileselection)->selection_entry), 0, |
|
|
-1)) > 0) |
|
|
{ |
|
|
filemenu = lookup_widget (fileselection, "filemenu"); |
|
|
menu = GTK_OPTION_MENU (filemenu)->menu; |
|
|
item = gtk_menu_get_active (GTK_MENU (menu)); |
|
|
/* skip old log format (0) */ |
|
|
filetype = g_list_index (GTK_MENU_SHELL (menu)->children, item) + 1; |
|
|
|
|
|
/* don't free sellog */ |
|
|
sellog = |
|
|
gtk_file_selection_get_filename (GTK_FILE_SELECTION (fileselection)); |
|
|
filen = basename (sellog); |
|
|
logn = logname ((gchar *) filen); |
|
|
|
|
|
/* if log exist jump to the page in the notebook */ |
|
|
for (i = 0; i < g_list_length (logwindowlist); i++) |
|
|
{ |
|
|
logwindow = g_list_nth_data (logwindowlist, i); |
|
|
if (g_strcasecmp (logn, logwindow->logname) == 0) |
|
|
{ |
|
|
gtk_notebook_set_page (GTK_NOTEBOOK (mainnotebook), i); |
|
|
set_qsoframe (logwindow); |
|
|
logexist = TRUE; |
|
|
break; |
|
|
} |
|
|
} |
|
|
if (!logexist) |
|
|
{ |
|
|
lp = log_file_open (sellog, filetype); |
|
|
if (lp) |
|
|
{ |
|
|
logwindow = openlog (lp, logn, state.logwindows++); |
|
|
log_file_qso_foreach (lp, fillin_clist, logwindow); |
|
|
log_file_close (lp); |
|
|
if ((lp->type) == TYPE_FLOG) |
|
|
{ |
|
|
xlogbackupfile = g_strconcat (sellog, ".backup", NULL); |
|
|
savelog (logwindow, xlogbackupfile, TYPE_FLOG); |
|
|
g_free (xlogbackupfile); |
|
|
} |
|
|
logwindowlist = g_list_append (logwindowlist, logwindow); |
|
|
gtk_notebook_set_page (GTK_NOTEBOOK (mainnotebook), |
|
|
state.logwindows - 1); |
|
|
set_qsoframe (logwindow); |
|
|
} |
|
|
} |
|
|
g_free (logn); |
|
|
} |
|
|
else |
|
|
{ |
|
|
temp = g_strdup_printf (_("No filename entered, open cancelled")); |
|
|
update_statusbar (temp); |
|
|
g_free (temp); |
|
|
} |
|
|
gtk_widget_destroy (fileselection); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
|
|
|
/* file selection cancelled */ |
|
|
void |
|
|
on_fileselection_cancel_button_clicked (GtkButton * button, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
/* file selection dialog is deleted */ |
|
|
gboolean |
|
|
on_fileselection_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* PATH SELECTION DIALOG */ |
|
|
gboolean |
|
|
on_pathselection_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (preferencesdialog, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
on_pathselection_ok_button_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *pathselection, *pathentry; |
|
|
gchar *selpath; |
|
|
|
|
|
pathselection = gtk_widget_get_toplevel (GTK_WIDGET (button)); |
|
|
selpath = |
|
|
gtk_file_selection_get_filename (GTK_FILE_SELECTION (pathselection)); |
|
|
pathentry = lookup_widget (preferencesdialog, "pathentry"); |
|
|
gtk_entry_set_text (GTK_ENTRY (pathentry), selpath); |
|
|
gtk_widget_destroy (pathselection); |
|
|
gtk_widget_set_sensitive (preferencesdialog, 1); |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
on_pathselection_cancel_button_clicked (GtkButton * button, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (preferencesdialog, 1); |
|
|
} |
|
|
|
|
|
/* CLOSE DIALOG */ |
|
|
gboolean |
|
|
on_closedialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
on_closeokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
logtype *logwindow; |
|
|
gint page; |
|
|
|
|
|
page = gtk_notebook_get_current_page (GTK_NOTEBOOK (mainnotebook)); |
|
|
logwindow = g_list_nth_data (logwindowlist, page); |
|
|
logwindowlist = g_list_remove (logwindowlist, logwindow); |
|
|
g_free (logwindow->logname); |
|
|
g_free (logwindow); |
|
|
state.logwindows--; |
|
|
gtk_notebook_remove_page (GTK_NOTEBOOK (mainnotebook), page); |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
on_closecancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
/* LOG EDITOR */ |
|
|
gboolean |
|
|
on_logeditorwindow_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* update logfields and return number of columns */ |
|
|
static gint |
|
|
update_logfields (gint column, gint logfields[], gchar * showhide) |
|
|
{ |
|
|
gint i, j; |
|
|
|
|
|
for (i = 0; i < QSO_FIELDS; i++) |
|
|
{ |
|
|
if (logfields[i] == column) |
|
|
break; |
|
|
} |
|
|
/* |
|
|
* If the column is not present, add it to the end of the array |
|
|
* if 'Show' is selected |
|
|
*/ |
|
|
if (i == QSO_FIELDS) |
|
|
{ |
|
|
if (g_strcasecmp (showhide, _("Show")) == 0) |
|
|
{ |
|
|
for (j = 0; j < QSO_FIELDS; j++) |
|
|
if (logfields[j] == 0) |
|
|
{ |
|
|
logfields[j] = column; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
/* |
|
|
* If the column is present, remove from the array |
|
|
* if 'Hide' is selected |
|
|
*/ |
|
|
else |
|
|
{ |
|
|
if (g_strcasecmp (showhide, _("Hide")) == 0) |
|
|
{ |
|
|
logfields[i] = 0; |
|
|
for (j = 0; j < QSO_FIELDS; j++) |
|
|
{ |
|
|
if (logfields[j] == 0) |
|
|
{ |
|
|
if (logfields[j + 1] == 0) |
|
|
break; |
|
|
/* Shift '0' to the right */ |
|
|
logfields[j] = logfields[j + 1]; |
|
|
logfields[j + 1] = 0; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
for (i = 0; i < QSO_FIELDS; i++) |
|
|
{ |
|
|
if (logfields[i] == 0) |
|
|
break; |
|
|
} |
|
|
return (i); |
|
|
} |
|
|
|
|
|
static gint |
|
|
compare_fields (void *f1, void *f2) |
|
|
{ |
|
|
gint *p = f1, *q = f2; |
|
|
if (*p - *q == *p) |
|
|
return 0; |
|
|
else |
|
|
return (*p - *q); |
|
|
} |
|
|
|
|
|
void |
|
|
on_logeditorokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
logtype *logw; |
|
|
GtkWidget *logeditor, *lecomboentry3, *lecomboentry9_10, *lecomboentry11, |
|
|
*lecomboentry12, *lecomboentry13, *lecomboentry14, *lecomboentry15, |
|
|
*lecomboentry16, *leentry15, *leentry16, *lecomboentry17; |
|
|
GtkWidget *unknownlabel1, *unknownlabel2, *columnlabel; |
|
|
gchar *temp; |
|
|
gint i, columns, fields[QSO_FIELDS]; |
|
|
|
|
|
logw = g_list_nth_data (logwindowlist, |
|
|
gtk_notebook_get_current_page (GTK_NOTEBOOK |
|
|
(mainnotebook))); |
|
|
|
|
|
/* fill the field array, unused columns with '0' */ |
|
|
for (i = 0; i < logw->columns; i++) |
|
|
fields[i] = logw->logfields[i]; |
|
|
for (i = logw->columns; i < QSO_FIELDS; i++) |
|
|
fields[i] = 0; |
|
|
|
|
|
logeditor = gtk_widget_get_toplevel (GTK_WIDGET (button)); |
|
|
|
|
|
lecomboentry3 = lookup_widget (logeditor, "lecomboentry3"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (lecomboentry3), 0, -1); |
|
|
if (g_strcasecmp (temp, _("Hide")) == 0) |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), GMTEND, FALSE); |
|
|
else |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), GMTEND, TRUE); |
|
|
columns = update_logfields (GMTEND, fields, temp); |
|
|
|
|
|
lecomboentry9_10 = lookup_widget (logeditor, "lecomboentry9_10"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (lecomboentry9_10), 0, -1); |
|
|
if (g_strcasecmp (temp, _("Hide")) == 0) |
|
|
{ |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), QSLOUT, |
|
|
FALSE); |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), QSLIN, FALSE); |
|
|
} |
|
|
else |
|
|
{ |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), QSLOUT, TRUE); |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), QSLIN, TRUE); |
|
|
} |
|
|
columns = update_logfields (QSLOUT, fields, temp); |
|
|
columns = update_logfields (QSLIN, fields, temp); |
|
|
|
|
|
lecomboentry11 = lookup_widget (logeditor, "lecomboentry11"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (lecomboentry11), 0, -1); |
|
|
if (g_strcasecmp (temp, _("Hide")) == 0) |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), POWER, FALSE); |
|
|
else |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), POWER, TRUE); |
|
|
columns = update_logfields (POWER, fields, temp); |
|
|
|
|
|
lecomboentry12 = lookup_widget (logeditor, "lecomboentry12"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (lecomboentry12), 0, -1); |
|
|
if (g_strcasecmp (temp, _("Hide")) == 0) |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), NAME, FALSE); |
|
|
else |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), NAME, TRUE); |
|
|
columns = update_logfields (NAME, fields, temp); |
|
|
|
|
|
lecomboentry13 = lookup_widget (logeditor, "lecomboentry13"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (lecomboentry13), 0, -1); |
|
|
if (g_strcasecmp (temp, _("Hide")) == 0) |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), QTH, FALSE); |
|
|
else |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), QTH, TRUE); |
|
|
columns = update_logfields (QTH, fields, temp); |
|
|
|
|
|
lecomboentry14 = lookup_widget (logeditor, "lecomboentry14"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (lecomboentry14), 0, -1); |
|
|
if (g_strcasecmp (temp, _("Hide")) == 0) |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), LOCATOR, FALSE); |
|
|
else |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), LOCATOR, TRUE); |
|
|
columns = update_logfields (LOCATOR, fields, temp); |
|
|
|
|
|
lecomboentry15 = lookup_widget (logeditor, "lecomboentry15"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (lecomboentry15), 0, -1); |
|
|
if (g_strcasecmp (temp, _("Hide")) == 0) |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), U1, FALSE); |
|
|
else |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), U1, TRUE); |
|
|
columns = update_logfields (U1, fields, temp); |
|
|
|
|
|
lecomboentry16 = lookup_widget (logeditor, "lecomboentry16"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (lecomboentry16), 0, -1); |
|
|
if (g_strcasecmp (temp, _("Hide")) == 0) |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), U2, FALSE); |
|
|
else |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), U2, TRUE); |
|
|
columns = update_logfields (U2, fields, temp); |
|
|
|
|
|
lecomboentry17 = lookup_widget (logeditor, "lecomboentry17"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (lecomboentry17), 0, -1); |
|
|
if (g_strcasecmp (temp, _("Hide")) == 0) |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), REMARKS, FALSE); |
|
|
else |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (logw->clist), REMARKS, TRUE); |
|
|
columns = update_logfields (REMARKS, fields, temp); |
|
|
|
|
|
/* see if the array has changed */ |
|
|
for (i = 0; i < QSO_FIELDS; i++) |
|
|
if (fields[i] != logw->logfields[i]) |
|
|
break; |
|
|
|
|
|
/* copy and re-order the array */ |
|
|
qsort (fields, QSO_FIELDS, sizeof (gint), (__compar_fn_t) compare_fields); |
|
|
if (i < QSO_FIELDS) |
|
|
{ |
|
|
for (i = 0; i < QSO_FIELDS; i++) |
|
|
logw->logfields[i] = fields[i]; |
|
|
logw->columns = columns; |
|
|
} |
|
|
|
|
|
/* check names of free fields and set column labels and labels on the QSO frame */ |
|
|
leentry15 = lookup_widget (logeditor, "leentry15"); |
|
|
leentry16 = lookup_widget (logeditor, "leentry16"); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (leentry15), 0, -1); |
|
|
if (g_strcasecmp (temp, preferences.freefield1) != 0) |
|
|
{ |
|
|
if (strlen (temp) == 0) |
|
|
temp = g_strdup ("UNKNOWN"); |
|
|
preferences.freefield1 = g_strdup (temp); |
|
|
unknownlabel1 = lookup_widget (mainwindow, "unknownlabel1"); |
|
|
gtk_label_set_text (GTK_LABEL (unknownlabel1), temp); |
|
|
columnlabel = gtk_label_new (temp); |
|
|
gtk_clist_set_column_widget (GTK_CLIST (logw->clist), U1, columnlabel); |
|
|
} |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (leentry16), 0, -1); |
|
|
if (g_strcasecmp (temp, preferences.freefield2) != 0) |
|
|
{ |
|
|
if (strlen (temp) == 0) |
|
|
temp = g_strdup ("UNKNOWN"); |
|
|
preferences.freefield2 = g_strdup (temp); |
|
|
unknownlabel2 = lookup_widget (mainwindow, "unknownlabel2"); |
|
|
gtk_label_set_text (GTK_LABEL (unknownlabel2), temp); |
|
|
columnlabel = gtk_label_new (temp); |
|
|
gtk_clist_set_column_widget (GTK_CLIST (logw->clist), U2, columnlabel); |
|
|
} |
|
|
|
|
|
g_free (temp); |
|
|
gtk_widget_destroy (logeditor); |
|
|
set_qsoframe (logw); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
on_logeditorcancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
/* SAVE AS DIALOG */ |
|
|
void |
|
|
on_saveasok_button_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *saveasdialog, *saveasmenu, *menu, *item, *savewarningdialog, |
|
|
*savewarninglabel; |
|
|
gchar *temp, *rev; |
|
|
gint index; |
|
|
logtype *logwindow; |
|
|
gboolean warning = FALSE; |
|
|
|
|
|
saveasdialog = gtk_widget_get_toplevel (GTK_WIDGET (button)); |
|
|
saveasmenu = lookup_widget (saveasdialog, "saveasmenu"); |
|
|
menu = GTK_OPTION_MENU (saveasmenu)->menu; |
|
|
item = gtk_menu_get_active (GTK_MENU (menu)); |
|
|
index = g_list_index (GTK_MENU_SHELL (menu)->children, item); |
|
|
|
|
|
if (index == 0) |
|
|
globtype = 1; |
|
|
else if (index == 1) |
|
|
globtype = 3; |
|
|
else |
|
|
globtype = 4; |
|
|
|
|
|
globtemp = |
|
|
g_strdup (gtk_file_selection_get_filename |
|
|
(GTK_FILE_SELECTION (saveasdialog))); |
|
|
rev = g_strdup (globtemp); |
|
|
g_strreverse (rev); |
|
|
if (!g_strncasecmp (rev, "/", 1)) |
|
|
{ |
|
|
temp = g_strdup_printf (_("No filename entered, log not saved")); |
|
|
update_statusbar (temp); |
|
|
} |
|
|
else |
|
|
{ |
|
|
if (!fileexist (globtemp)) |
|
|
{ |
|
|
logwindow = g_list_nth_data (logwindowlist, |
|
|
gtk_notebook_get_current_page |
|
|
(GTK_NOTEBOOK (mainnotebook))); |
|
|
savelog (logwindow, globtemp, globtype); |
|
|
temp = g_strdup_printf (_("Log saved to %s"), globtemp); |
|
|
update_statusbar (temp); |
|
|
} |
|
|
else |
|
|
{ |
|
|
savewarningdialog = create_savewarningdialog (); |
|
|
savewarninglabel = |
|
|
lookup_widget (savewarningdialog, "savewarninglabel"); |
|
|
temp = |
|
|
g_strdup_printf (_("%s already exist, do want to overwrite it?"), |
|
|
globtemp); |
|
|
gtk_label_set_text (GTK_LABEL (savewarninglabel), temp); |
|
|
gtk_widget_show (savewarningdialog); |
|
|
warning = TRUE; |
|
|
} |
|
|
} |
|
|
g_free (temp); |
|
|
g_free (rev); |
|
|
|
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
if (!warning) |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
/* delete save as dialog */ |
|
|
gboolean |
|
|
on_saveasdialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
|
|
|
/* cancel save as */ |
|
|
void |
|
|
on_saveas_cancel_button_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
/* FONT SELECTION DIALOG */ |
|
|
void |
|
|
on_fontokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *fontselectiondialog, *fontentry, *exampleframe, *examplelabel; |
|
|
gchar *font; |
|
|
|
|
|
fontselectiondialog = gtk_widget_get_toplevel (GTK_WIDGET (button)); |
|
|
font = gtk_font_selection_dialog_get_font_name |
|
|
(GTK_FONT_SELECTION_DIALOG (fontselectiondialog)); |
|
|
fontentry = lookup_widget (preferencesdialog, "fontentry"); |
|
|
gtk_entry_set_text (GTK_ENTRY (fontentry), font); |
|
|
exampleframe = lookup_widget (preferencesdialog, "exampleframe"); |
|
|
setframestyle (exampleframe, preferences.themecolor, font); |
|
|
examplelabel = lookup_widget (preferencesdialog, "examplelabel"); |
|
|
setlabelstyle (examplelabel, preferences.themecolor, font); |
|
|
gtk_widget_set_sensitive (preferencesdialog, 1); |
|
|
gtk_widget_destroy (fontselectiondialog); |
|
|
} |
|
|
|
|
|
|
|
|
/* delete font selection dialog */ |
|
|
gboolean |
|
|
on_fontselectiondialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (preferencesdialog, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* cancel font selection */ |
|
|
void |
|
|
on_fontcancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (preferencesdialog, 1); |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
} |
|
|
|
|
|
/* DUPE CHECK DIALOG */ |
|
|
void |
|
|
on_dupecheckokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *dupecheckdialog, *dupecheckthisradiobutton, *dupelistdialog, |
|
|
*duperesultclist, *dupecheckstatusbar, *dupecheckprogressbar, |
|
|
*dupecheckbuttonmode, *dupecheckbuttonband, *duperesultdialog; |
|
|
GList *dupelist = NULL; |
|
|
logtype *logwindow; |
|
|
gint i, page, savedpage, pages, row, step, duperow = 0; |
|
|
gchar *logn, *prevlogn, *nr, *prevnr, *date, *gmt, *callsign, *band, |
|
|
*mode, *temp, *str, *dupestr; |
|
|
gchar **dupe = NULL; |
|
|
gfloat new_val; |
|
|
GtkAdjustment *adj; |
|
|
gboolean dupefound = FALSE; |
|
|
|
|
|
dupe = g_new0 (gchar *, 7); |
|
|
for (i = 0; i < 7; i++) |
|
|
dupe[i] = g_new0 (gchar, 100); |
|
|
|
|
|
dupecheckdialog = gtk_widget_get_toplevel (GTK_WIDGET (button)); |
|
|
dupecheckthisradiobutton = lookup_widget (dupecheckdialog, |
|
|
"dupecheckthisradiobutton"); |
|
|
dupecheckbuttonmode = |
|
|
lookup_widget (dupecheckdialog, "dupecheckbuttonmode"); |
|
|
dupecheckbuttonband = |
|
|
lookup_widget (dupecheckdialog, "dupecheckbuttonband"); |
|
|
dupecheckstatusbar = lookup_widget (dupecheckdialog, "dupecheckstatusbar"); |
|
|
dupecheckprogressbar = |
|
|
lookup_widget (dupecheckdialog, "dupecheckprogressbar"); |
|
|
gtk_statusbar_pop (GTK_STATUSBAR (dupecheckstatusbar), 1); |
|
|
gtk_statusbar_push (GTK_STATUSBAR (dupecheckstatusbar), 1, |
|
|
_("Searching ...")); |
|
|
gtkut_widget_wait_for_draw (GTK_WIDGET (dupecheckstatusbar)->parent); |
|
|
|
|
|
/* this or all logs ? */ |
|
|
if (gtk_toggle_button_get_active |
|
|
(GTK_TOGGLE_BUTTON (dupecheckthisradiobutton))) |
|
|
state.dupecheck = 0; |
|
|
else |
|
|
state.dupecheck = 1; |
|
|
state.notdupecheckmode = |
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dupecheckbuttonmode)); |
|
|
state.notdupecheckband = |
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dupecheckbuttonband)); |
|
|
|
|
|
/* set autosort and sort item for the result dialog */ |
|
|
dupelistdialog = create_dupelistdialog (); |
|
|
duperesultclist = lookup_widget (dupelistdialog, "duperesultclist"); |
|
|
gtk_clist_set_sort_column (GTK_CLIST (duperesultclist), 4); |
|
|
gtk_clist_set_auto_sort (GTK_CLIST (duperesultclist), TRUE); |
|
|
for (i = 0; i < 7; i++) |
|
|
gtk_clist_set_column_auto_resize (GTK_CLIST (duperesultclist), i, TRUE); |
|
|
|
|
|
if (state.dupecheck == 0) |
|
|
{ |
|
|
page = gtk_notebook_get_current_page (GTK_NOTEBOOK (mainnotebook)); |
|
|
pages = page + 1; |
|
|
} |
|
|
else |
|
|
{ |
|
|
page = 0; |
|
|
pages = g_list_length (logwindowlist); |
|
|
} |
|
|
|
|
|
/* traverse 2 times down the log(s) */ |
|
|
savedpage = page; |
|
|
while (page < pages) |
|
|
{ |
|
|
logwindow = g_list_nth_data (logwindowlist, page); |
|
|
/* compose a list with items to scan for */ |
|
|
for (row = 0; row < logwindow->qsos; row++) |
|
|
{ |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, CALL, &temp); |
|
|
if (!state.notdupecheckband) |
|
|
{ |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, BAND, |
|
|
&band); |
|
|
str = findband (g_strdup (band)); |
|
|
temp = g_strconcat (temp, str, NULL); |
|
|
g_free (str); |
|
|
} |
|
|
if (!state.notdupecheckmode) |
|
|
{ |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, MODE, |
|
|
&mode); |
|
|
temp = g_strconcat (temp, mode, NULL); |
|
|
} |
|
|
dupelist = g_list_append (dupelist, temp); |
|
|
} |
|
|
page++; |
|
|
} |
|
|
|
|
|
page = savedpage; |
|
|
while (page < pages) |
|
|
{ |
|
|
logwindow = g_list_nth_data (logwindowlist, page); |
|
|
for (row = 0; row < logwindow->qsos; row++) |
|
|
{ |
|
|
if (row % 10 == 0) /* advance progress bar */ |
|
|
{ |
|
|
new_val = |
|
|
gtk_progress_get_value (GTK_PROGRESS (dupecheckprogressbar)) + |
|
|
1; |
|
|
adj = GTK_PROGRESS (dupecheckprogressbar)->adjustment; |
|
|
if (new_val > adj->upper) |
|
|
new_val = adj->lower; |
|
|
gtk_progress_set_value (GTK_PROGRESS (dupecheckprogressbar), |
|
|
new_val); |
|
|
while (gtk_events_pending ()) |
|
|
gtk_main_iteration (); |
|
|
} |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, CALL, &temp); |
|
|
if (!state.notdupecheckband) |
|
|
{ |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, BAND, |
|
|
&band); |
|
|
str = findband (g_strdup (band)); |
|
|
temp = g_strconcat (temp, str, NULL); |
|
|
g_free (str); |
|
|
} |
|
|
if (!state.notdupecheckmode) |
|
|
{ |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, MODE, |
|
|
&mode); |
|
|
temp = g_strconcat (temp, mode, NULL); |
|
|
} |
|
|
dupestr = g_strdup (temp); |
|
|
for (step = 0; step < logwindow->qsos; step++) |
|
|
{ |
|
|
if (g_strcasecmp (dupestr, g_list_nth_data (dupelist, step)) == |
|
|
0) |
|
|
{ /* dupe found ? */ |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, NR, |
|
|
&nr); |
|
|
if ((logwindow->qsos) - step != atoi (nr)) |
|
|
{ |
|
|
dupe[0] = g_strdup (logwindow->logname); |
|
|
dupe[1] = g_strdup (nr); |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, |
|
|
DATE, &date); |
|
|
dupe[2] = g_strdup (date); |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, |
|
|
GMT, &gmt); |
|
|
dupe[3] = g_strdup (gmt); |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, |
|
|
CALL, &callsign); |
|
|
dupe[4] = g_strdup (callsign); |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, |
|
|
BAND, &band); |
|
|
dupe[5] = g_strdup (band); |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), row, |
|
|
MODE, &mode); |
|
|
dupe[6] = g_strdup (mode); |
|
|
gtk_clist_append (GTK_CLIST (duperesultclist), dupe); |
|
|
dupefound = TRUE; |
|
|
} |
|
|
} |
|
|
duperow++; |
|
|
} |
|
|
} |
|
|
page++; |
|
|
} |
|
|
|
|
|
g_list_free (dupelist); |
|
|
g_free (temp); |
|
|
for (i = 0; i < 7; i++) |
|
|
g_free (dupe[i]); |
|
|
g_free (dupe); |
|
|
|
|
|
/* show result */ |
|
|
gtk_widget_destroy (dupecheckdialog); |
|
|
if (dupefound) |
|
|
{ /* remove double entries (this happens with more than 2 dupes) */ |
|
|
for (row = 0; row < GTK_CLIST (duperesultclist)->rows; row++) |
|
|
{ |
|
|
gtk_clist_get_text (GTK_CLIST (duperesultclist), row, 0, &logn); |
|
|
gtk_clist_get_text (GTK_CLIST (duperesultclist), row, 1, &nr); |
|
|
if (row > 0) |
|
|
{ |
|
|
gtk_clist_get_text (GTK_CLIST (duperesultclist), row - 1, 0, |
|
|
&prevlogn); |
|
|
gtk_clist_get_text (GTK_CLIST (duperesultclist), row - 1, 1, |
|
|
&prevnr); |
|
|
if ((g_strcasecmp (prevnr, nr) == 0) |
|
|
&& (g_strcasecmp (prevlogn, logn) == 0)) |
|
|
gtk_clist_remove (GTK_CLIST (duperesultclist), row - 1); |
|
|
} |
|
|
} |
|
|
gtk_widget_show (dupelistdialog); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
else |
|
|
{ |
|
|
duperesultdialog = create_duperesultdialog (); |
|
|
gtk_widget_destroy (dupelistdialog); |
|
|
gtk_widget_show (duperesultdialog); |
|
|
} |
|
|
} |
|
|
|
|
|
/* delete the dupecheck dialog */ |
|
|
gboolean |
|
|
on_dupecheckdialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
/* cancel dupe check */ |
|
|
void |
|
|
on_dupecheckcancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
|
|
|
/* DUPE LIST DIALOG */ |
|
|
void |
|
|
on_dupelistokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
} |
|
|
|
|
|
/* entry is selected in the duperesult list, select corresponding entry in |
|
|
the main log */ |
|
|
void |
|
|
on_duperesultclist_select_row (GtkCList * clist, gint row, gint column, |
|
|
GdkEvent * event, gpointer user_data) |
|
|
{ |
|
|
gchar *nr, *lognr, *logn; |
|
|
gint i, logrow = -1; |
|
|
logtype *logwindow = NULL; |
|
|
gboolean qsofound = FALSE; |
|
|
|
|
|
gtk_clist_get_text (GTK_CLIST (clist), row, 1, &nr); |
|
|
gtk_clist_get_text (GTK_CLIST (clist), row, 0, &logn); |
|
|
|
|
|
for (i = 0; i < g_list_length (logwindowlist); i++) |
|
|
{ |
|
|
logwindow = g_list_nth_data (logwindowlist, i); |
|
|
for (logrow = 0; logrow < logwindow->qsos; logrow++) |
|
|
{ |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), logrow, 0, |
|
|
&lognr); |
|
|
if ((g_strcasecmp (nr, lognr) == 0) |
|
|
&& (g_strcasecmp (logn, logwindow->logname) == 0)) |
|
|
{ |
|
|
qsofound = TRUE; |
|
|
break; |
|
|
} |
|
|
} |
|
|
if (qsofound) |
|
|
break; |
|
|
} |
|
|
if (qsofound) |
|
|
{ |
|
|
gtk_notebook_set_page (GTK_NOTEBOOK (mainnotebook), i); |
|
|
gtk_clist_moveto (GTK_CLIST (logwindow->clist), logrow, 0, 0.5, 0); |
|
|
gtk_clist_select_row (GTK_CLIST (logwindow->clist), logrow, 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* DUPE RESULT DIALOG */ |
|
|
void |
|
|
on_duperesultdialogokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
/* delete the duperesult dialog */ |
|
|
gboolean |
|
|
on_duperesultdialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
|
|
|
/* SAVE AS WARNING DIALOG */ |
|
|
gboolean |
|
|
on_savewarningdialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
on_savewarningokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gchar *temp; |
|
|
logtype *logwindow; |
|
|
|
|
|
logwindow = g_list_nth_data (logwindowlist, |
|
|
gtk_notebook_get_current_page (GTK_NOTEBOOK |
|
|
(mainnotebook))); |
|
|
savelog (logwindow, globtemp, globtype); |
|
|
temp = g_strdup_printf (_("Log saved to %s"), globtemp); |
|
|
update_statusbar (temp); |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
on_savewarningcancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
|
|
|
/* DEFAULTS DIALOG */ |
|
|
|
|
|
gboolean |
|
|
on_defaultsdialog_delete_event (GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
on_defaultsokbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *defaultsmhzentry, *defaultsmodeentry, *defaultstxrstentry, |
|
|
*defaultsrxrstentry, *defaultspowerentry, *defaultsdialog, |
|
|
*defaultsfreefield1entry, *defaultsfreefield2entry, *defaultsremarksentry; |
|
|
gchar *temp; |
|
|
|
|
|
defaultsdialog = gtk_widget_get_toplevel (GTK_WIDGET (button)); |
|
|
defaultsmhzentry = lookup_widget (defaultsdialog, "defaultsmhzentry"); |
|
|
defaultsmodeentry = lookup_widget (defaultsdialog, "defaultsmodeentry"); |
|
|
defaultstxrstentry = lookup_widget (defaultsdialog, "defaultstxrstentry"); |
|
|
defaultsrxrstentry = lookup_widget (defaultsdialog, "defaultsrxrstentry"); |
|
|
defaultspowerentry = lookup_widget (defaultsdialog, "defaultspowerentry"); |
|
|
defaultsfreefield1entry = |
|
|
lookup_widget (defaultsdialog, "defaultsfreefield1entry"); |
|
|
defaultsfreefield2entry = |
|
|
lookup_widget (defaultsdialog, "defaultsfreefield2entry"); |
|
|
defaultsremarksentry = |
|
|
lookup_widget (defaultsdialog, "defaultsremarksentry"); |
|
|
|
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (defaultsmhzentry), 0, -1); |
|
|
if (strlen (temp) == 0) |
|
|
preferences.defaultmhz = g_strdup ("?"); |
|
|
else if (g_strcasecmp (preferences.defaultmhz, temp)) |
|
|
preferences.defaultmhz = g_strdup (temp); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (defaultsmodeentry), 0, -1); |
|
|
if (strlen (temp) == 0) |
|
|
preferences.defaultmode = g_strdup ("?"); |
|
|
else if (g_strcasecmp (preferences.defaultmode, temp)) |
|
|
preferences.defaultmode = g_strdup (temp); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (defaultstxrstentry), 0, -1); |
|
|
if (strlen (temp) == 0) |
|
|
preferences.defaulttxrst = g_strdup ("?"); |
|
|
else if (g_strcasecmp (preferences.defaulttxrst, temp)) |
|
|
preferences.defaulttxrst = g_strdup (temp); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (defaultsrxrstentry), 0, -1); |
|
|
if (strlen (temp) == 0) |
|
|
preferences.defaultrxrst = g_strdup ("?"); |
|
|
else if (g_strcasecmp (preferences.defaultrxrst, temp)) |
|
|
preferences.defaultrxrst = g_strdup (temp); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (defaultspowerentry), 0, -1); |
|
|
if (strlen (temp) == 0) |
|
|
preferences.defaultpower = g_strdup ("?"); |
|
|
else if (g_strcasecmp (preferences.defaultpower, temp)) |
|
|
preferences.defaultpower = g_strdup (temp); |
|
|
temp = |
|
|
gtk_editable_get_chars (GTK_EDITABLE (defaultsfreefield1entry), 0, -1); |
|
|
if (strlen (temp) == 0) |
|
|
preferences.defaultfreefield1 = g_strdup ("?"); |
|
|
else if (g_strcasecmp (preferences.defaultfreefield1, temp)) |
|
|
preferences.defaultfreefield1 = g_strdup (temp); |
|
|
temp = |
|
|
gtk_editable_get_chars (GTK_EDITABLE (defaultsfreefield2entry), 0, -1); |
|
|
if (strlen (temp) == 0) |
|
|
preferences.defaultfreefield2 = g_strdup ("?"); |
|
|
else if (g_strcasecmp (preferences.defaultfreefield2, temp)) |
|
|
preferences.defaultfreefield2 = g_strdup (temp); |
|
|
temp = gtk_editable_get_chars (GTK_EDITABLE (defaultsremarksentry), 0, -1); |
|
|
if (strlen (temp) == 0) |
|
|
preferences.defaultremarks = g_strdup ("?"); |
|
|
else if (g_strcasecmp (preferences.defaultremarks, temp)) |
|
|
preferences.defaultremarks = g_strdup (temp); |
|
|
|
|
|
g_free (temp); |
|
|
gtk_widget_destroy (defaultsdialog); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
on_defaultscancelbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
|
|
|
|
/* WORKED B4 DIALOG */ |
|
|
|
|
|
void |
|
|
on_b4clist_select_row (GtkCList * clist, gint row, gint column, |
|
|
GdkEvent * event, gpointer user_data) |
|
|
{ |
|
|
gchar *nr, *lognr, *logn; |
|
|
gint i, logrow = -1; |
|
|
logtype *logwindow = NULL; |
|
|
gboolean qsofound = FALSE; |
|
|
|
|
|
gtk_clist_get_text (GTK_CLIST (clist), row, 1, &nr); |
|
|
gtk_clist_get_text (GTK_CLIST (clist), row, 0, &logn); |
|
|
|
|
|
for (i = 0; i < g_list_length (logwindowlist); i++) |
|
|
{ |
|
|
logwindow = g_list_nth_data (logwindowlist, i); |
|
|
for (logrow = 0; logrow < logwindow->qsos; logrow++) |
|
|
{ |
|
|
gtk_clist_get_text (GTK_CLIST (logwindow->clist), logrow, 0, |
|
|
&lognr); |
|
|
if ((g_strcasecmp (nr, lognr) == 0) |
|
|
&& (g_strcasecmp (logn, logwindow->logname) == 0)) |
|
|
{ |
|
|
qsofound = TRUE; |
|
|
break; |
|
|
} |
|
|
} |
|
|
if (qsofound) |
|
|
break; |
|
|
} |
|
|
if (qsofound) |
|
|
{ |
|
|
gtk_notebook_set_page (GTK_NOTEBOOK (mainnotebook), i); |
|
|
gtk_clist_moveto (GTK_CLIST (logwindow->clist), logrow, 0, 0.5, 0); |
|
|
gtk_clist_select_row (GTK_CLIST (logwindow->clist), logrow, 0); |
|
|
} |
|
|
} |
|
|
|
|
|
void |
|
|
on_b4okbutton_clicked (GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_hide (b4dialog); |
|
|
} |
|
|
|
|
|
/* DIALOGS DIALOG */ |
|
|
|
|
|
gboolean |
|
|
on_dialogsdialog_delete_event(GtkWidget * widget, GdkEvent * event, |
|
|
gpointer user_data) |
|
|
{ |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
on_dialogsokbutton_clicked(GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
GtkWidget *dialogsdialog, *checkbutton, *b4clist; |
|
|
gchar *widgetname, **states; |
|
|
gboolean check; |
|
|
gint i; |
|
|
|
|
|
states = g_new0 (gchar *, 20); |
|
|
dialogsdialog = gtk_widget_get_toplevel (GTK_WIDGET (button)); |
|
|
b4clist = lookup_widget(b4dialog, "b4clist"); |
|
|
for (i = 0; i < 19; i++) |
|
|
{ /* look up name of the button and get it's togglestate */ |
|
|
widgetname = g_strdup_printf("b4%d", i); |
|
|
checkbutton = lookup_widget(dialogsdialog, widgetname); |
|
|
check = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)); |
|
|
if (GTK_WIDGET_VISIBLE (b4dialog)) |
|
|
gtk_clist_set_column_visibility (GTK_CLIST (b4clist), i, check); |
|
|
states[i] = g_strdup(check ? "1" : "0"); |
|
|
g_free(widgetname); |
|
|
} |
|
|
states[19] = NULL; /* terminator for g_strjoinv */ |
|
|
preferences.b4columns = g_strjoinv (",", states); |
|
|
|
|
|
for (i = 0; i < 19; i++) |
|
|
g_free(states[i]); |
|
|
g_free(states); |
|
|
|
|
|
gtk_widget_destroy (dialogsdialog); |
|
|
if (GTK_WIDGET_VISIBLE (b4dialog)) |
|
|
gtk_widget_set_sensitive (b4dialog, 1); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
21 |
|
|
22 |
|
|
|
void |
|
|
on_dialogscancelbutton_clicked(GtkButton * button, gpointer user_data) |
|
|
{ |
|
|
gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (button))); |
|
|
gtk_widget_set_sensitive (mainwindow, 1); |
|
|
} |
|
23 |
|
|
24 |
/* end of file */ |
/* end of file */ |