Пример #1
0
void traitement_sigsegv ( gint signal_nb )
{
    gchar *gsb_file_default_dir;
    gchar *errmsg = g_strdup ( "" );
	gchar *old_errmsg;
    gchar *tmpstr;
    GtkWidget * dialog;
#ifdef HAVE_BACKTRACE
    GtkWidget * expander;
#endif

    /*   il y a 3 possibilités : */
    /*     soit on était en train de charger un fichier, c'est que celui-ci est corrompu */
    /* soit on était en train de sauver un fichier, et là on peut rien faire */
    /* sinon on essaie de sauver le fichier sous le nom entouré de # */

    if ( run.is_loading || 
	 run.is_saving || 
	 !gsb_file_get_modified ( ) )
    {

	if ( run.is_loading )
	{
	    old_errmsg = errmsg;
	    errmsg = g_strconcat ( errmsg, _("File is corrupted."), NULL );
	    g_free ( old_errmsg );
	}

	if ( run.is_saving )
	{
	    old_errmsg = errmsg;
	    errmsg = g_strconcat ( errmsg, _("Error occured saving file."), NULL );
	    g_free ( old_errmsg );
	}
    }
    else 
    {
	/* c'est un bug pendant le fonctionnement de Grisbi s'il n'y a
	   pas de nom de fichier, on le crée, sinon on rajoute #
	   autour */

        gsb_file_default_dir = (gchar *) my_get_gsb_file_default_dir();

	if ( nom_fichier_comptes )
	    /* set # around the filename */
	    nom_fichier_comptes = g_path_get_basename (nom_fichier_comptes);
	else
	    /* no name for the file, create it */
	    nom_fichier_comptes = g_strconcat ( gsb_file_default_dir,
						"/#grisbi_crash_no_name#",
						NULL );

	gsb_status_message ( _("Save file") );

	gsb_file_save_save_file ( nom_fichier_comptes,
				  conf.compress_file,
				  FALSE );

	gsb_status_clear();

    old_errmsg = errmsg;
	errmsg = g_strconcat ( errmsg, 
			       g_strdup_printf ( _("Grisbi made a backup file at '%s'."),
						 nom_fichier_comptes ),
			       NULL );
	g_free ( old_errmsg );
    }

    old_errmsg = errmsg;
    errmsg = g_strconcat ( errmsg, 
			   "\n\n",
			   _("Please report this problem to <tt>http://www.grisbi.org/bugtracking/</tt>.  "),
			   NULL );
     g_free ( old_errmsg );

#ifdef HAVE_BACKTRACE
    old_errmsg = errmsg;
    errmsg = g_strconcat ( errmsg, _("Copy and paste the following backtrace with your bug "
                        "report."),
			   NULL );
     g_free ( old_errmsg );
#endif

    dialog = dialogue_special_no_run ( GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
				       make_hint ( _("Grisbi terminated due to a segmentation fault."),
						   errmsg ));
    g_free ( errmsg );

#ifdef HAVE_BACKTRACE
    tmpstr = g_strconcat ( "<b>", _("Backtrace"), "</b>", NULL );
    expander = gtk_expander_new ( tmpstr );
    g_free ( tmpstr );

    gtk_expander_set_use_markup ( GTK_EXPANDER ( expander ), TRUE );
    gtk_container_add ( GTK_CONTAINER ( expander ), print_backtrace() );
    gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG(dialog)->vbox ), expander, FALSE, FALSE, 6 );

    gtk_widget_show_all ( dialog );
#endif
    gtk_dialog_run ( GTK_DIALOG ( dialog ) );

    /*     on évite le message du fichier ouvert à la prochaine ouverture */

    gsb_file_util_modify_lock ( FALSE );

    exit(1);
}
Пример #2
0
/**
 * Display a tip.
 *
 * \param force  Forcefully display the tip even if show_tip option
 *		 has been disabled.
 */
void display_tip ( gboolean force )
{
    GtkWidget * checkbox;
    GtkWidget * dialog = NULL;
    GtkWidget *btn_back, *btn_forward, *btn_close;
    gchar *tmpstr;

    if ( !force && !conf.show_tip )
        return;

    conf.last_tip = CLAMP ( conf.last_tip+1, 0, sizeof(tips)/sizeof(gpointer)-1);

    dialog = dialogue_special_no_run ( GTK_MESSAGE_INFO, GTK_BUTTONS_NONE,
                        make_hint ( _("Did you know that..."),
                        /* We use the Grisbi-tips catalog */
                        g_dgettext(NULL, tips[conf.last_tip]) ) );
    gtk_window_set_modal ( GTK_WINDOW ( dialog ), FALSE );

    checkbox = gsb_automem_checkbutton_new ( _("Display tips at next start"),
                        &(conf.show_tip), NULL, NULL );
    gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG(dialog) -> vbox ), checkbox, FALSE, FALSE, 6 );
    gtk_widget_show ( checkbox );

    btn_back =    gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_GO_BACK, 1);
    btn_forward = gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_GO_FORWARD, 2);
    btn_close =   gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_CLOSE, 3);

    /* gtk_widget_set_size_request ( dialog, 450, -1 ); */
    /* We iterate as user can select several tips. */
    while ( TRUE )
    {
    if ( conf.last_tip == sizeof(tips)/sizeof(gpointer)-1)
        gtk_widget_set_sensitive (btn_forward, FALSE);
    if ( conf.last_tip == 0)
        gtk_widget_set_sensitive (btn_back, FALSE);

    switch ( gtk_dialog_run ( GTK_DIALOG(dialog) ) )
    {
        case 1:
        if ( conf.last_tip > 0 )
            conf.last_tip--;
        gtk_widget_set_sensitive (btn_forward, TRUE);
        tmpstr = g_strconcat ( make_pango_attribut (
                        "size=\"larger\" weight=\"bold\"", _("Did you know that...") ),
                        "\n\n",
                        g_dgettext (NULL, tips[conf.last_tip] ),
                        NULL );

        gtk_label_set_markup ( GTK_LABEL ( GTK_MESSAGE_DIALOG(dialog) -> label ),
                        tmpstr );
        g_free ( tmpstr );
        break;

        case 2:
        if ( conf.last_tip < sizeof(tips)/sizeof(gpointer)-1)
            conf.last_tip++;
        tmpstr = g_strconcat ( make_pango_attribut (
                        "size=\"larger\" weight=\"bold\"", _("Did you know that...") ),
                        "\n\n",
                        g_dgettext (NULL, tips[conf.last_tip] ),
                        NULL );

        gtk_label_set_markup ( GTK_LABEL ( GTK_MESSAGE_DIALOG(dialog) -> label ),
                        tmpstr );
        g_free ( tmpstr );
        gtk_widget_set_sensitive (btn_back, TRUE);
        break;

        default:
        gtk_widget_destroy ( dialog );
        return;
    }
    }
}