/[xlog]/xlog/src/log.c
ViewVC logotype

Diff of /xlog/src/log.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by fillods, Sun Aug 10 16:37:43 2003 UTC revision 1.9 by pa4tu, Mon Aug 11 15:21:15 2003 UTC
# Line 93  fillin_clist (LOGDB * handle, qso_t q[], Line 93  fillin_clist (LOGDB * handle, qso_t q[],
93          GtkTreeIter iter;          GtkTreeIter iter;
94          GtkTreeModel *model;          GtkTreeModel *model;
95          logtype *logw = (logtype *) arg;          logtype *logw = (logtype *) arg;
96            gchar *date = NULL, *name = NULL, *qth = NULL, *u1 = NULL,
97                    *u2 = NULL, *remarks = NULL;
98            GError *error = NULL;
99    
100          state.qsos++;          state.qsos++;
101          logw->qsos++;          logw->qsos++;
# Line 100  fillin_clist (LOGDB * handle, qso_t q[], Line 103  fillin_clist (LOGDB * handle, qso_t q[],
103    
104          model = gtk_tree_view_get_model (GTK_TREE_VIEW (logw->treeview));          model = gtk_tree_view_get_model (GTK_TREE_VIEW (logw->treeview));
105          gtk_tree_store_prepend (GTK_TREE_STORE (model), &iter, NULL);          gtk_tree_store_prepend (GTK_TREE_STORE (model), &iter, NULL);
106    
107            if (!g_utf8_validate (q[DATE], -1, NULL ))
108            {
109                    date = g_locale_to_utf8 (q[DATE], -1, NULL, NULL, &error);
110                    if (!date)
111                    {
112                            g_print (_("Unable to convert '%s' to UTF-8: %s"), q[DATE],
113                                            error->message);
114                            g_error_free (error);
115                    }
116            }
117            else date = g_strdup (q[DATE]);
118    
119            if (q[NAME] && !g_utf8_validate (q[NAME], -1, NULL ))
120            {
121                    name = g_locale_to_utf8 (q[NAME], -1, NULL, NULL, &error);
122                    if (!name)
123                    {
124                            g_print (_("Unable to convert '%s' to UTF-8: %s"), q[NAME],
125                                            error->message);
126                            g_error_free (error);
127                    }
128            }
129            else name = g_strdup (q[NAME]);
130    
131            if (q[QTH] && !g_utf8_validate (q[QTH], -1, NULL ))
132            {
133                    qth = g_locale_to_utf8 (q[QTH], -1, NULL, NULL, &error);
134                    if (!qth)
135                    {
136                            g_print (_("Unable to convert '%s' to UTF-8: %s"), q[QTH],
137                                            error->message);
138                            g_error_free (error);
139                    }
140            }
141            else qth = g_strdup (q[QTH]);
142    
143            if (q[U1] && !g_utf8_validate (q[U1], -1, NULL ))
144            {
145                    u1 = g_locale_to_utf8 (q[U1], -1, NULL, NULL, &error);
146                    if (!u1)
147                    {
148                            g_print (_("Unable to convert '%s' to UTF-8: %s"), q[U1],
149                                            error->message);
150                            g_error_free (error);
151                    }
152            }
153            else u1 = g_strdup (q[U1]);
154    
155            if (q[U2] && !g_utf8_validate (q[U2], -1, NULL ))
156            {
157                    u2 = g_locale_to_utf8 (q[U2], -1, NULL, NULL, &error);
158                    if (!u2)
159                    {
160                            g_print (_("Unable to convert '%s' to UTF-8: %s"), q[U2],
161                                            error->message);
162                            g_error_free (error);
163                    }
164            }
165            else u2 = g_strdup (q[U2]);
166    
167            if (q[REMARKS] && !g_utf8_validate (q[REMARKS], -1, NULL ))
168            {
169                    remarks = g_locale_to_utf8 (q[REMARKS], -1, NULL, NULL, &error);
170                    if (!remarks)
171                    {
172                            g_print (_("Unable to convert '%s' to UTF-8: %s"), q[REMARKS],
173                                            error->message);
174                            g_error_free (error);
175                    }
176            }
177            else remarks = g_strdup (q[REMARKS]);
178    
179          gtk_tree_store_set (GTK_TREE_STORE (model), &iter, NR, q[NR],          gtk_tree_store_set (GTK_TREE_STORE (model), &iter, NR, q[NR],
180                              DATE, q[DATE], GMT, q[GMT], GMTEND, q[GMTEND],                              DATE, date, GMT, q[GMT], GMTEND, q[GMTEND],
181                              CALL, q[CALL], BAND, q[BAND], MODE, q[MODE], RST,                              CALL, q[CALL], BAND, q[BAND], MODE, q[MODE], RST,
182                              q[RST], MYRST, q[MYRST], QSLOUT, q[QSLOUT], QSLIN,                              q[RST], MYRST, q[MYRST], QSLOUT, q[QSLOUT], QSLIN,
183                              q[QSLIN], POWER, q[POWER], NAME, q[NAME], QTH,                              q[QSLIN], POWER, q[POWER], NAME, name, QTH,
184                              q[QTH], LOCATOR, q[LOCATOR], U1, q[U1], U2, q[U2],                              qth, LOCATOR, q[LOCATOR], U1, u1, U2, u2,
185                              REMARKS, q[REMARKS], -1);                              REMARKS, remarks, -1);
186    
187            if (date) g_free (date);
188            if (remarks) g_free (remarks);
189            if (name) g_free (name);
190            if (qth) g_free (qth);
191            if (u1) g_free (u1);
192            if (u2) g_free (u2);
193          return 0;          return 0;
194  }  }
195    
# Line 305  savelog (gpointer arg, gchar * logfile, Line 388  savelog (gpointer arg, gchar * logfile,
388                  widths[i] = parse_field_width (fields[i]);                  widths[i] = parse_field_width (fields[i]);
389          }          }
390    
391          lp = log_file_create (logfile, type, logw->columns, fields,          lp = log_file_create (logfile, type, logw->columns, fields, widths);
                                       widths);  
392    
393          if (lp)          if (lp)
394          {          {
# Line 318  savelog (gpointer arg, gchar * logfile, Line 400  savelog (gpointer arg, gchar * logfile,
400                          path = gtk_tree_path_new_from_string (pathstr);                          path = gtk_tree_path_new_from_string (pathstr);
401                          gtk_tree_model_get_iter (model, &iter, path);                          gtk_tree_model_get_iter (model, &iter, path);
402                          for (j = 0; j < logw->columns; j++)                          for (j = 0; j < logw->columns; j++)
403                                  gtk_tree_model_get (model, &iter,                          {
404                                                      logw->logfields[j],                                  gtk_tree_model_get (model, &iter, logw->logfields[j],
405                                                      &item[fields[j]], -1);                                          &item[fields[j]], -1);
406                                    if (fields[j] == DATE || fields[j] == NAME || fields[j] == QTH ||
407                                                    fields[j] == U1 || fields[j] == U2 || fields[j] == REMARKS)
408                                            item[fields[j]] =
409                                                    g_locale_from_utf8 (item[fields[j]], -1, NULL, NULL, NULL);
410                            }
411                          log_file_qso_append (lp, item);                          log_file_qso_append (lp, item);
412                          gtk_tree_path_free (path);                          gtk_tree_path_free (path);
413                          g_free (pathstr);                          g_free (pathstr);
# Line 353  getlogs (gchar * path, gint filetype) Line 440  getlogs (gchar * path, gint filetype)
440                          if (filetype == 0)      /* type xlog */                          if (filetype == 0)      /* type xlog */
441                          {                          {
442                                  g_strreverse (filen);                                  g_strreverse (filen);
443                                  if (g_ascii_strncasecmp (filen, "golx.", 5) == 0)                                  if (g_ascii_strncasecmp (filen, "golx.", 5) ==
444                                        0)
445                                  {                                  {
446                                          g_string_append (logs, dirEntry->d_name);                                          g_string_append (logs,
447                                                             dirEntry->d_name);
448                                          g_string_append_c (logs, '\n');                                          g_string_append_c (logs, '\n');
449                                  }                                  }
450          g_free (filen);                                  g_free (filen);
451                          }                          }
452                          else    /* other types */                          else    /* other types */
453                          {                          {
454                                  if ((g_ascii_strcasecmp (filen, "..") != 0)                                  if ((g_ascii_strcasecmp (filen, "..") != 0)
455                                      && (g_ascii_strcasecmp (filen, ".") != 0))                                      && (g_ascii_strcasecmp (filen, ".") != 0))
456                                  {                                  {
457                                          g_string_append (logs, dirEntry->d_name);                                          g_string_append (logs,
458                                                             dirEntry->d_name);
459                                          g_string_append_c (logs, '\n');                                          g_string_append_c (logs, '\n');
460                                  }                                  }
461                          }                          }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26