GnuCash 2.4.99
Data Structures | Files | Defines | Functions
Setup Assistant for GConf
Assistants

Data Structures

struct  gconf_data

Files

file  assistant-gconf-setup.c
 

Check for gconf. Help user set up if needed.


file  assistant-gconf-setup.h
 

Check for gconf. Help user set up if needed.


Defines

#define WHO_DOES   "who_does"
#define WHO_GNUCASH   1
#define WHO_USER   2
#define WHO_ALREADY_DONE   3
#define HOW   "how"
#define HOW_UPDATE   1
#define HOW_INSTALL   2
#define SCRIPT_NAME   "update-gnucash-gconf"
#define PATH_STRING1   "xml:readwrite:$(HOME)/.gconf\n"
#define PATH_STRING2   "xml:readonly:%s\n"

Functions

void assistant_gconf_prepare (GtkAssistant *assistant, GtkWidget *page, gconf_data *data)
void assistant_gconf_cancel (GtkAssistant *gtkassistant, gpointer user_data)
void assistant_gconf_finish (GtkAssistant *assistant, gpointer user_data)
void assistant_gconf_update_cb (GtkToggleButton *button, gpointer user_data)
void assistant_gconf_install_cb (GtkToggleButton *button, gpointer user_data)
void assistant_gconf_update_prep (GtkAssistant *assistant, gpointer user_data)
void assistant_gconf_step_prep (GtkAssistant *assistant, gpointer user_data)
void assistant_gconf_install_prep (GtkAssistant *assistant, gpointer user_data)
void assistant_gconf_finish_prep (GtkAssistant *assistant, gpointer user_data)
void assistant_gconf_install_check_schemas (void)

Function Documentation

void assistant_gconf_cancel ( GtkAssistant *  gtkassistant,
gpointer  user_data 
)

This function is called when the Cancel button is clicked on any page of the assistant. It destroys the dialog and kills gnucash.

Definition at line 509 of file assistant-gconf-setup.c.

{
    gconf_data *data = user_data;
    gtk_widget_destroy(GTK_WIDGET(data->dialog));
    exit(41);
}
void assistant_gconf_finish ( GtkAssistant *  assistant,
gpointer  user_data 
)

This function is called when the Apply button is clicked on the Finish Page of the assistant. It determines whether or not there is any work to be performed by Gnucash, and if so it calls other functions to carry out the work.

Definition at line 417 of file assistant-gconf-setup.c.

{
    gconf_data *data = user_data;
    GtkWidget *window;
    gint value, value2;
    GError *error = NULL;
    gboolean keep_going = TRUE;

    /* What to do... what to do... */
    value = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(assistant), WHO_DOES));
    switch (value)
    {
    case WHO_ALREADY_DONE:
        break;

    case WHO_USER:
        keep_going = FALSE;
        break;

    default:
        value2 = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(assistant), HOW));
        switch (value2)
        {
        case HOW_INSTALL:
            if (!assistant_gconf_install_keys(&error))
            {
                keep_going = FALSE;
                gnc_error_dialog(NULL, "%s", error->message);
                g_error_free(error);
            }
            break;

        default:
            if (!assistant_gconf_update_path(&error))
            {
                keep_going = FALSE;
                gnc_error_dialog(NULL, "%s", error->message);
                g_error_free(error);
            }
            break;
        }
        break;
    }
    /* Hide the Assistant */
    gtk_widget_hide(GTK_WIDGET(data->dialog));

    if (keep_going)
    {
        gtk_main_quit();
    }
    else
    {
        exit(42);
    }
}
void assistant_gconf_finish_prep ( GtkAssistant *  assistant,
gpointer  user_data 
)

This function is called before the finish page is presented to the user. It populates the page with text based on previous page options taken.

Definition at line 344 of file assistant-gconf-setup.c.

{
    gconf_data *data = user_data;
    gint who, how;
    gchar *text;

    const gchar *pgm_path =
        _("When you click Apply, GnuCash will modify your ~/.gconf.path file "
          "and restart the gconf backend. There will be a short delay before "
          "GnuCash is loaded.");
    const gchar *pgm_install =
        _("When you click Apply, GnuCash will install the gconf data into your "
          "local ~/.gconf file and restart the gconf backend. The %s script "
          "must be found in your search path for this to work correctly.");
    const gchar *user_path =
        _("You have chosen to correct the problem by yourself. When you click "
          "Apply, GnuCash will exit. Please correct the problem and restart "
          "the gconf backend with the command 'gconftool-2 --shutdown' before "
          "restarting GnuCash. If you have not already done so, you can click "
          "the Back button and copy the necessary text from the dialog.");
    const gchar *user_install =
        _("You have chosen to correct the problem by yourself. When you "
          "click Apply, GnuCash will exit. Please run the %s script which "
          "will install the configuration data and restart the gconf backend.");
    const gchar *user_did =
        _("You have already corrected the problem and restarted the gconf "
          "backend with the command 'gconftool-2 --shutdown'. When you click "
          "Apply, there will be a short delay before GnuCash is loaded.");

    who = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(assistant), WHO_DOES));
    switch (who)
    {
    case WHO_ALREADY_DONE:
        gtk_label_set_text(GTK_LABEL(data->finish_page), user_did);
        break;

    case WHO_USER:
        how = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(assistant), HOW));
        if (how == HOW_INSTALL)
        {
            text = g_strdup_printf(user_install, SCRIPT_NAME);
            gtk_label_set_text(GTK_LABEL(data->finish_page), text);
            g_free(text);
        }
        else
        {
            gtk_label_set_text(GTK_LABEL(data->finish_page), user_path);
        }
        break;

    default:
        how = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(assistant), HOW));
        if (how == HOW_INSTALL)
        {
            text = g_strdup_printf(pgm_install, SCRIPT_NAME);
            gtk_label_set_text(GTK_LABEL(data->finish_page), text);
            g_free(text);
        }
        else
        {
            gtk_label_set_text(GTK_LABEL(data->finish_page), pgm_path);
        }
        break;
    }
}
void assistant_gconf_install_check_schemas ( void  )

This routine checks to see if GnuCash's gconf schemas are visible to the user. The schemas typically should be visible, as rpm and deb installs will put the schemas in the default system location. For things like network installs or developers, this function will present a warning dialog that asks the user whether to setup gconf, continue without the schemas, or quit. If the user chooses to set up the schemas, this function will invoke a assistant to walk the user through making the schemas visible.

Definition at line 622 of file assistant-gconf-setup.c.

{
    GtkBuilder *builder;
    GtkWidget *dialog;
    gboolean done = FALSE;
    gint response;

    if (gnc_gconf_schemas_found())
    {
        gnc_gconf_unset_dir(GCONF_WARNINGS_TEMP, NULL);
        return;
    }

#ifdef G_OS_WIN32
    {
        /* automatically update the search path on windows */
        GError *error = NULL;
        if (!assistant_gconf_update_path (&error))
        {
            gnc_error_dialog (NULL, error->message);
            g_error_free (error);
            exit(42);
        }
        else
        {
            if (!g_spawn_command_line_sync("gconftool-2 --shutdown", NULL, NULL,
                                           NULL, &error))
            {
                gnc_warning_dialog(NULL, error->message);
                g_error_free(error);
            }
            return;
        }
    }
#endif /* G_OS_WIN32 */

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "assistant-gconf-setup.glade", "GConf Query");

    if (!builder)
    {
        gnc_error_dialog(NULL, "The glade UI files were not found. Your installation is incomplete and cannot be run.");
        exit(-1); /* quit immediately */
    }
    g_assert(builder);
    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "GConf Query"));
    g_assert(dialog);
    do
    {
        response = gtk_dialog_run(GTK_DIALOG(dialog));

        switch (response)
        {
        case GTK_RESPONSE_CANCEL:
        default:
            exit(42);
            /* never returns */

        case GTK_RESPONSE_NO:
            /* User wants to run without setting up gconf */
            done = TRUE;
            break;

        case GTK_RESPONSE_ACCEPT:
            gtk_widget_hide(dialog);
            gnc_gnome_install_gconf_schemas();
            done = TRUE;
            break;

        case GTK_RESPONSE_HELP:
            gnc_gnome_help(HF_HELP, HL_GCONF);
            break;
        }
    }
    while (!done);

    g_object_unref(G_OBJECT(builder));
    gtk_widget_destroy(dialog);
}
void assistant_gconf_install_prep ( GtkAssistant *  assistant,
gpointer  user_data 
)

This function is called before the Install page is presented to the user. It populates the install_text with the script name.

Definition at line 323 of file assistant-gconf-setup.c.

{
    gconf_data *data = user_data;
    GtkTextBuffer *textbuffer;
    GtkWidget *textview;

    textview = data->install_text;
    textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
    gtk_text_buffer_set_text(textbuffer, SCRIPT_NAME, -1);
}
void assistant_gconf_step_prep ( GtkAssistant *  assistant,
gpointer  user_data 
)

This function is called before the Step over page is presented to the user. It allows the jumping of the install page.

Definition at line 306 of file assistant-gconf-setup.c.

{
    gconf_data *data = user_data;
    gint num = gtk_assistant_get_current_page (assistant);
    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
    gtk_assistant_set_current_page (assistant, num + 2);
}
void assistant_gconf_update_prep ( GtkAssistant *  assistant,
gpointer  user_data 
)

This function is called before the Update page is presented to the user. It gets the active button from the Method page and uses this to either add the path strings or jump to the install page.

Definition at line 225 of file assistant-gconf-setup.c.

{
    gconf_data *data = user_data;
    GtkTextBuffer *textbuffer;
    GtkWidget *textview;
    gchar *msg;
    gchar *gconfdir = gnc_path_get_gconfdir (TRUE);

    gint num = gtk_assistant_get_current_page (assistant);
    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);

    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->update_path)))
    {
        g_object_set_data(G_OBJECT(assistant), HOW, GINT_TO_POINTER(HOW_UPDATE));

        textview = data->update_text;
        textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
        msg = g_strdup_printf(PATH_STRING1 PATH_STRING2, gconfdir);
        gtk_text_buffer_set_text(textbuffer, msg, -1);
        g_free (gconfdir);
    }
    else
    {
        g_object_set_data(G_OBJECT(assistant), HOW, GINT_TO_POINTER(HOW_INSTALL));
        gtk_assistant_set_current_page (assistant, num + 2);
    }
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines