Commit 261f0ba9 authored by Ross Golder's avatar Ross Golder

Various compiler warning fixes (-Wall). Don't open the file if there are...

Various compiler warning fixes (-Wall). Don't open the file if there are parser errors. Free errors when set in various places.
parent 060b5ef1
2006-02-07 Ross Golder <ross@golder.org>
* main.c: Include necessary headers to avoid compiler warnings.
* messages-table.c: Removed some unused variables.
* gui.c, page.c, prefs.c: Fix a couple of compiler warnings (w/ -Wall)
* parse.c: Don't open the file if there are parser errors.
* history.c, bookmark.c, dnd.c, dialogs.c, parse.c: Handle error from
gtranslator_open sensibly.
* utils.c: Use 'gnome_app_warning' instead of 'gtr.._error_dialog'.
* parse.c: Ensure that correct tab is focussed when file is opened.
* gui.c: Add callback to set current_page on page switch.
* message.c: Add 'gtranslator_message_translation_update' method.
......
......@@ -589,10 +589,12 @@ void gtranslator_open_file_dialog_from_bookmark(GtkWidget *widget, gchar *filena
{
GError *error;
if(!gtranslator_open(filename, &error))
{
gnome_app_warning(GNOME_APP(gtranslator_application),
error->message);
if(!gtranslator_open(filename, &error)) {
if(error) {
gnome_app_warning(GNOME_APP(gtranslator_application),
error->message);
g_error_free(error);
}
}
}
......
......@@ -205,8 +205,6 @@ void gtranslator_save_file_as_dialog(GtkWidget * widget, gpointer useless)
}
else
{
gchar *filename=NULL;
dialog = gtranslator_file_chooser_new(NULL,
FILESEL_SAVE,
_("Save local copy of file as..."));
......@@ -974,9 +972,13 @@ void gtranslator_open_uri_dialog_clicked(GtkDialog *dialog, gint button,
}
else
{
gtk_widget_destroy(GTK_WIDGET(dialog));
gtk_widget_destroy(GTK_WIDGET(dialog));
if(!gtranslator_open(uri->str, &error)) {
gtranslator_utils_error_dialog(error->message);
if(error) {
gnome_app_warning(GNOME_APP(gtranslator_application),
error->message);
g_error_free(error);
}
}
}
}
......@@ -1059,8 +1061,11 @@ and may contain your hard work!\n"),
original_filename);
if(!gtranslator_open(original_filename, &error)) {
gnome_app_warning(GNOME_APP(gtranslator_application),
error->message);
if(error) {
gnome_app_warning(GNOME_APP(gtranslator_application),
error->message);
g_error_free(error);
}
}
}
else if(reply==GTK_RESPONSE_REJECT)
......
......@@ -41,6 +41,11 @@ void gtranslator_dnd(GtkWidget * widget, GdkDragContext * context, int x,
{
GError *error = NULL;
if(!gtranslator_open(file, &error)) {
if(error) {
gnome_app_warning(GNOME_APP(gtranslator_application),
error->message);
g_error_free(error);
}
return;
}
gtk_drag_finish(context, TRUE, FALSE, time);
......
......@@ -714,7 +714,7 @@ GtkWidget *gtranslator_gui_new_page(GtrPo *po)
GtkWidget *original_text_scrolled_window;
GtkWidget *translation_text_scrolled_window;
g_return_if_fail(po!=NULL);
g_return_val_if_fail(po!=NULL, NULL);
/*
* Set up a document view structure to contain the widgets related
......
......@@ -254,8 +254,11 @@ void gtranslator_open_file_dialog_from_history(GtkWidget *widget, gchar *filenam
GError *error = NULL;
if(!gtranslator_open(filename, &error)) {
gnome_app_warning(GNOME_APP(gtranslator_application),
if(error) {
gnome_app_warning(GNOME_APP(gtranslator_application),
error->message);
g_error_free(error);
}
}
}
......
......@@ -25,12 +25,16 @@
#endif
#include <gnome.h>
#include "bookmark.h"
#include "dialogs.h"
#include "gui.h"
#include "learn.h"
#include "prefs.h"
#include "runtime-config.h"
#include "session.h"
#include "sighandling.h"
#include "translator.h"
#include "utils.h"
#include <locale.h>
#include <libintl.h>
......@@ -42,13 +46,13 @@
#include <libgnomevfs/gnome-vfs-init.h>
#include <gconf/gconf.h>
/*
* The static variables used in the poptTable.
*/
static gchar *gtranslator_geometry=NULL;
static gboolean learn_statistics=FALSE;
/*
* List of files that are currently open
*/
......
......@@ -148,7 +148,6 @@ gtranslator_messages_table_selection_changed(GtkTreeSelection *selection, gpoint
GtkTreeIter iter;
GtkTreeModel* model;
GtrMsg* msg;
GList* messages;
/* Ignore 'null' selections */
if(!selection) return;
......@@ -166,11 +165,9 @@ gtranslator_messages_table_selection_changed(GtkTreeSelection *selection, gpoint
*/
GtrMessagesTable *gtranslator_messages_table_new()
{
GtkWidget *tree;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
GtkTreeSelection *selection;
GtrMsg *msg;
GtrMessagesTable *table;
/*
......@@ -331,7 +328,6 @@ void gtranslator_messages_table_populate(GtrMessagesTable *table, GList *message
*/
void gtranslator_messages_table_update_row(GtrMessagesTable *table, GtrMsg *msg)
{
GtkTreeStore *model;
const char *msgid, *msgstr;
g_assert(table != NULL);
......
......@@ -30,6 +30,8 @@
#include "dialogs.h"
#include "prefs.h"
#include <libgen.h>
/*
* The currently active pages
*/
......@@ -54,9 +56,7 @@ GtrPage *gtranslator_page_new(GtrPo *po)
GtkWidget *original_text_scrolled_window;
GtkWidget *translation_text_scrolled_window;
gchar *title;
g_return_if_fail(po!=NULL);
g_return_val_if_fail(po!=NULL, NULL);
/* Allocate a new page */
page = g_new0(GtrPage, 1);
......
......@@ -69,6 +69,7 @@ GQuark gtranslator_parser_error_quark (void)
/* Parser dialog components */
GtkWidget *parser_dialog;
GtkTextBuffer *parser_dialog_buffer;
gboolean parser_errors;
void gtranslator_parser_dialog_destroy(GtkWidget *widget);
......@@ -90,7 +91,7 @@ void gtranslator_parser_dialog_create(void) {
NULL);
g_signal_connect_swapped (parser_dialog, "response",
G_CALLBACK (gtranslator_parser_dialog_destroy),
parser_dialog);
NULL);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(parser_dialog)->vbox), view);
gtk_widget_show_all (parser_dialog);
......@@ -123,6 +124,9 @@ void gettext_error(int status, int errnum, const char *format, ...) {
g_free(buf);
va_end(args);
/* Don't open the file after all */
parser_errors = TRUE;
/* According to gettext-po.h, we must do this */
error_message_count++;
}
......@@ -140,6 +144,12 @@ void gettext_error_at_line(int status, int errnum, const char *filename,
g_free(errmsg);
g_free(buf);
va_end(args);
/* Don't open the file after all */
parser_errors = TRUE;
/* According to gettext-po.h, we must do this */
error_message_count++;
}
void gettext_multiline_warning(char *prefix, char *message) {
......@@ -157,8 +167,8 @@ void gettext_multiline_warning(char *prefix, char *message) {
g_free(buf);
/* According to gettext-po.h, we must do this */
if(prefix != NULL)
error_message_count++;
g_free(prefix);
g_free(message);
}
void gettext_multiline_error(char *prefix, char *message) {
......@@ -174,6 +184,16 @@ void gettext_multiline_error(char *prefix, char *message) {
gtk_text_buffer_get_iter_at_offset (parser_dialog_buffer, &iter, -1);
gtk_text_buffer_insert (parser_dialog_buffer, &iter, buf, -1);
g_free(buf);
/* Don't open the file after all */
parser_errors = TRUE;
/* According to gettext-po.h, we must do this */
g_free(message);
if(prefix != NULL) {
error_message_count++;
g_free(prefix);
}
}
struct po_error_handler gettext_error_handler = {
......@@ -225,6 +245,7 @@ GtrPo *gtranslator_parse(const gchar *filename, GError **error)
/*
* Open the PO file, using gettext's utility function
*/
parser_errors = FALSE;
po->gettext_po_file = po_file_read(po->filename, &gettext_error_handler);
if(po->gettext_po_file == NULL) {
g_set_error(error,
......@@ -235,7 +256,15 @@ GtrPo *gtranslator_parse(const gchar *filename, GError **error)
gtranslator_po_free(po);
return NULL;
}
/*
* If there were errors, abandon this page
*/
if(parser_errors) {
gtranslator_po_free(po);
return NULL;
}
/*
* Determine the message domains to track
*/
......@@ -487,8 +516,11 @@ void gtranslator_parse_the_file_from_file_dialog(GtkWidget * dialog)
* Open the file via our centralized opening function.
*/
if(!gtranslator_open(po_file, &error)) {
gnome_app_warning(GNOME_APP(gtranslator_application),
error->message);
if(error) {
gnome_app_warning(GNOME_APP(gtranslator_application),
error->message);
g_error_free(error);
}
}
/*
......@@ -690,7 +722,11 @@ void gtranslator_file_revert(GtkWidget * widget, gpointer useless)
*/
if(!gtranslator_open(current_page->po->filename, &error))
{
gnome_app_warning(GNOME_APP(gtranslator_application), error->message);
if(error) {
gnome_app_warning(GNOME_APP(gtranslator_application),
error->message);
g_error_free(error);
}
return;
}
}
......
......@@ -44,7 +44,9 @@ static void gtranslator_preferences_dialog_changed(GtkWidget * widget, gpointer
static void gtranslator_preferences_dialog_close(GtkWidget * widget, gint response_id,
gpointer useless);
static void toggle_sensitive(GtkWidget *widget, gpointer data);
#ifdef GTR_ABOUT_ME
static void toggle_insensitive(GtkWidget *widget, gpointer data);
#endif
typedef struct {
GtkTreeIter file_node;
......@@ -108,7 +110,7 @@ static GtkWidget
*own_fonts, *instant_spell_checking,
*keep_obsolete, *autosave, *autosave_with_suffix,
*sweep_compile_file, *use_learn_buffer,
*show_messages_table, *rambo_function, *use_own_mt_colors,
*show_messages_table, *rambo_function,
*collapse_all_entries, *auto_learn, *fuzzy_matching,
#ifdef GTR_ABOUT_ME
*use_about_me,
......@@ -290,7 +292,7 @@ gtranslator_preferences_combo_new(GList *list,
GtkWidget*
gtranslator_preferences_hotkey_char_widget_new()
{
GtkWidget *box, *label, *rb_1, *rb_2;
GtkWidget *box, *rb_1, *rb_2;
GtkSizeGroup *size_group;
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
......@@ -510,7 +512,7 @@ a suggested value for your language.");
}
#ifdef GTR_ABOUT_ME
void gtransaltor_preferences_no_aboutme(gchar *message)
void gtranslator_preferences_no_aboutme(gchar *message)
{
GtkWidget *about_me_note;
about_me_note = gtk_label_new(message);
......@@ -526,7 +528,6 @@ void gtransaltor_preferences_no_aboutme(gchar *message)
void gtranslator_preferences_dialog_create(GtkWidget *widget, gpointer useless)
{
gchar *old_colorscheme=NULL;
GtkObject *adjustment;
GtkWidget *page, *category_box, *hbox, *control, *dialog_hbox, *label;
......@@ -813,7 +814,7 @@ void gtranslator_preferences_dialog_create(GtkWidget *widget, gpointer useless)
gtk_label_set_use_markup(GTK_LABEL(another_info), TRUE);
gtk_box_pack_start (GTK_BOX(personal_info_box), another_info, FALSE, FALSE, 5);
} else {
gtransaltor_preferences_no_aboutme(_("<i>Unable to get personal info from Evolution Data Server.</i>"));
gtranslator_preferences_no_aboutme(_("<i>Unable to get personal info from Evolution Data Server.</i>"));
}
gtk_box_pack_start (GTK_BOX(category_box), about_me_box, FALSE, FALSE, 0);
gtk_widget_set_sensitive(about_me_box, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_about_me)));
......@@ -850,8 +851,7 @@ void gtranslator_preferences_dialog_create(GtkWidget *widget, gpointer useless)
/* Language item */
gchar *language_str = _("Language settings");
GtkSizeGroup *language_label_size_group, *language_control_size_group,
*language_short_label_size_group, *language_short_control_size_group;
GtkSizeGroup *language_label_size_group, *language_control_size_group;
language_label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
language_control_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
......@@ -1358,6 +1358,7 @@ void toggle_sensitive(GtkWidget *widget, gpointer data)
prefs_changed = TRUE;
}
#ifdef GTR_ABOUT_ME
void toggle_insensitive(GtkWidget *widget, gpointer data)
{
gboolean active;
......@@ -1365,6 +1366,7 @@ void toggle_insensitive(GtkWidget *widget, gpointer data)
gtk_widget_set_sensitive(GTK_WIDGET(data), !active);
prefs_changed = TRUE;
}
#endif
void gtranslator_preferences_read(void)
{
......
......@@ -316,6 +316,8 @@ gboolean gtranslator_utils_autosave(gpointer data)
gtranslator_page_autosave(page);
pagelist = pagelist->next;
}
return TRUE;
}
/*
......@@ -868,7 +870,8 @@ gtranslator_get_plural_form_string(gchar *lang)
* Check if msginit is available on the system.
*/
if(!g_find_program_in_path("msginit")) {
gtranslator_utils_error_dialog(_("Sorry, msginit isn't available on your system!"));
gnome_app_warning(GNOME_APP(gtranslator_application),
_("Sorry, msginit isn't available on your system!"));
return NULL;
}
po_test_file = g_strconcat ("# SOME DESCRIPTIVE TITLE.\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment