GnuCash 2.3.0
Files | Defines | Functions
Setup Druid for GConf
Druids

Files

file  druid-gconf-setup.c
 

Check for gconf. Help user set up if needed.


file  druid-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

gboolean druid_gconf_delete_event (GtkWidget *window, GdkEvent *event, gpointer user_data)
void druid_gconf_cancel (GnomeDruid *druid, gpointer user_data)
void druid_gconf_choose_page_prepare (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data)
gboolean druid_gconf_choose_page_next (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data)
void druid_gconf_update_page_prepare (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data)
gboolean druid_gconf_update_page_next (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data)
void druid_gconf_install_page_prepare (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data)
gboolean druid_gconf_install_page_next (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data)
gboolean druid_gconf_install_page_back (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data)
void druid_gconf_finish_page_prepare (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data)
gboolean druid_gconf_finish_page_back (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data)
void druid_gconf_finish_page_finish (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data)
void druid_gconf_install_check_schemas (void)

Function Documentation

void druid_gconf_cancel ( GnomeDruid *  druid,
gpointer  user_data 
)

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

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

{
    GtkWidget *window;

    window = gnc_glade_lookup_widget(GTK_WIDGET(druid), "GConf Install Druid");
    gtk_widget_destroy(GTK_WIDGET(window));
    exit(41);
}
gboolean druid_gconf_choose_page_next ( GnomeDruidPage *  druidpage,
GnomeDruid *  druid,
gpointer  user_data 
)

This function is called when the Next button is clicked on the Choose page of the druid. It save the user selection on the dialog widget, and uses that selection to determines whether to go to the the "Update Path" or "Install" page.

Definition at line 259 of file druid-gconf-setup.c.

{
    GtkWidget *page, *button;

    button = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_path");
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
    {
        page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_page");
        g_object_set_data(G_OBJECT(druid), HOW, GINT_TO_POINTER(HOW_UPDATE));
    }
    else
    {
        page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "install_page");
        g_object_set_data(G_OBJECT(druid), HOW, GINT_TO_POINTER(HOW_INSTALL));
    }

    gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
    return TRUE;
}
void druid_gconf_choose_page_prepare ( GnomeDruidPage *  druidpage,
GnomeDruid *  druid,
gpointer  user_data 
)

This function is called before the Choose page is presented to the user. Its sole purpose is to change the background color of the GtkTextView widgets to match the color of the druid.

Definition at line 246 of file druid-gconf-setup.c.

{
}
gboolean druid_gconf_delete_event ( GtkWidget *  window,
GdkEvent *  event,
gpointer  user_data 
)

This function is called when the window manager close button is clicked on any page of the druid. It destroys the dialog and kills gnucash.

Definition at line 212 of file druid-gconf-setup.c.

{
    gtk_widget_destroy(GTK_WIDGET(window));
    exit(40);
}
gboolean druid_gconf_finish_page_back ( GnomeDruidPage *  druidpage,
GnomeDruid *  druid,
gpointer  user_data 
)

This function is called when the Back button is clicked on the Finish page of the druid. It determines whether to go back the the "Update Path" or "Install" pages.

Definition at line 495 of file druid-gconf-setup.c.

{
    return druid_gconf_choose_page_next(druidpage, druid, user_data);
}
void druid_gconf_finish_page_finish ( GnomeDruidPage *  druidpage,
GnomeDruid *  druid,
gpointer  user_data 
)

This function is called when the Apply button is clicked on the Finish Page end of the druid. 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 509 of file druid-gconf-setup.c.

{
    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(druid), 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(druid), HOW));
        switch (value2)
        {
        case HOW_INSTALL:
            if (!druid_gconf_install_keys(&error))
            {
                keep_going = FALSE;
                gnc_error_dialog(NULL, "%s", error->message);
                g_error_free(error);
            }
            break;

        default:
            if (!druid_gconf_update_path(&error))
            {
                keep_going = FALSE;
                gnc_error_dialog(NULL, "%s", error->message);
                g_error_free(error);
            }
            break;
        }
        break;
    }

    window = gnc_glade_lookup_widget(GTK_WIDGET(druid), "GConf Install Druid");
    gtk_widget_destroy(GTK_WIDGET(window));
    if (keep_going)
    {
        gtk_main_quit();
    }
    else
    {
        exit(42);
    }
}
void druid_gconf_finish_page_prepare ( GnomeDruidPage *  druidpage,
GnomeDruid *  druid,
gpointer  user_data 
)

This function is called before the Finish page is presented to the user. Its determines which of four messages will be presented to the user based upon their previous selections.

Definition at line 421 of file druid-gconf-setup.c.

{
    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.");
    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, GnuCash will continue loading.");

    who = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), WHO_DOES));
    switch (who)
    {
    case WHO_ALREADY_DONE:
        gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage),
                                       user_did);
        break;

    case WHO_USER:
        how = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), HOW));
        if (how == HOW_INSTALL)
        {
            text = g_strdup_printf(user_install, SCRIPT_NAME);
            gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage), text);
            g_free(text);
        }
        else
        {
            gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage),
                                           user_path);
        }
        break;

    default:
        how = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), HOW));
        if (how == HOW_INSTALL)
        {
            text = g_strdup_printf(pgm_install, SCRIPT_NAME);
            gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage), text);
            g_free(text);
        }
        else
        {
            gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage),
                                           pgm_path);
        }
        break;
    }
}
void druid_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 druid to walk the user through making the schemas visible.

Definition at line 642 of file druid-gconf-setup.c.

{
    GladeXML *xml;
    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 (!druid_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 */

    xml = gnc_glade_xml_new ("druid-gconf-setup.glade", "GConf Query");
    if (!xml)
    {
        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(xml);
    dialog = glade_xml_get_widget (xml, "GConf Query");
    g_assert(dialog);
    do
    {
        response = gtk_dialog_run(GTK_DIALOG(dialog));

        switch (response)
        {
        case GTK_RESPONSE_CANCEL:
        default:
            gnc_shutdown(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);

    gtk_widget_destroy(dialog);
}
gboolean druid_gconf_install_page_back ( GnomeDruidPage *  druidpage,
GnomeDruid *  druid,
gpointer  user_data 
)

This function is called when the Back button is clicked on the Install page of the druid. It skips back to the Choose page.

Definition at line 399 of file druid-gconf-setup.c.

{
    GtkWidget *page;

    page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "choose_page");
    gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
    return TRUE;
}
gboolean druid_gconf_install_page_next ( GnomeDruidPage *  druidpage,
GnomeDruid *  druid,
gpointer  user_data 
)

This function is called when the Next button is clicked on the Install page of the druid. It save the user selection on the dialog widget, and moves to the Finish page.

Definition at line 368 of file druid-gconf-setup.c.

{
    GtkWidget *page, *button1, *button2;

    button1 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "program2");
    button2 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "user2");
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button1)))
    {
        g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_GNUCASH));
    }
    else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button2)))
    {
        g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_USER));
    }
    else
    {
        g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_ALREADY_DONE));
    }

    page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "finish_page");
    gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
    return TRUE;
}
void druid_gconf_install_page_prepare ( GnomeDruidPage *  druidpage,
GnomeDruid *  druid,
gpointer  user_data 
)

This function is called before the Install page is presented to the user. Its sole purpose is to change the background color of the GtkTextView widgets to match the color of the druid.

Definition at line 350 of file druid-gconf-setup.c.

{
    GtkTextBuffer *textbuffer;
    GtkWidget *textview;

    textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "install_text");
    textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
    gtk_text_buffer_set_text(textbuffer, SCRIPT_NAME, -1);
}
gboolean druid_gconf_update_page_next ( GnomeDruidPage *  druidpage,
GnomeDruid *  druid,
gpointer  user_data 
)

This function is called when the Next button is clicked on the Update Path page of the druid. It save the user selection on the dialog widget, and skips to the Finish page.

Definition at line 315 of file druid-gconf-setup.c.

{
    GtkWidget *page, *button1, *button2;

    button1 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "program1");
    button2 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "user1");
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button1)))
    {
        g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_GNUCASH));
    }
    else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button2)))
    {
        g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_USER));
    }
    else
    {
        g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_ALREADY_DONE));
    }

    page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "finish_page");
    gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
    return TRUE;
}
void druid_gconf_update_page_prepare ( GnomeDruidPage *  druidpage,
GnomeDruid *  druid,
gpointer  user_data 
)

This function is called before the Choose page is presented to the user. Its changes the background color of the GtkTextView widgets to match the color of the druid, and fills in the text of one of the textview widgets based upon the installed path of gnucash.

Definition at line 293 of file druid-gconf-setup.c.

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

    textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "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);
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines