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 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 215 of file druid-gconf-setup.c.

00217 {
00218   GtkWidget *window;
00219 
00220   window = gnc_glade_lookup_widget(GTK_WIDGET(druid), "GConf Install Druid");
00221   gtk_widget_destroy(GTK_WIDGET(window));
00222   exit(41);
00223 }

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 260 of file druid-gconf-setup.c.

00263 {
00264   GtkWidget *page, *button;
00265 
00266   button = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_path");
00267   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) {
00268     page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_page");
00269     g_object_set_data(G_OBJECT(druid), HOW, GINT_TO_POINTER(HOW_UPDATE));
00270   } else {
00271     page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "install_page");
00272     g_object_set_data(G_OBJECT(druid), HOW, GINT_TO_POINTER(HOW_INSTALL));
00273   }
00274 
00275   gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
00276   return TRUE;
00277 }

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 236 of file druid-gconf-setup.c.

00239 {
00240   GtkWidget *textview;
00241 
00242   textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "textview1");
00243   gtk_widget_modify_base(textview, GTK_STATE_INSENSITIVE,
00244                          &GNOME_DRUID_PAGE_STANDARD(druidpage)->contents_background);
00245   textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "textview2");
00246   gtk_widget_modify_base(textview, GTK_STATE_INSENSITIVE,
00247                          &GNOME_DRUID_PAGE_STANDARD(druidpage)->contents_background);
00248   textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "textview3");
00249   gtk_widget_modify_base(textview, GTK_STATE_INSENSITIVE,
00250                          &GNOME_DRUID_PAGE_STANDARD(druidpage)->contents_background);
00251 }

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 202 of file druid-gconf-setup.c.

00205 {
00206   gtk_widget_destroy(GTK_WIDGET(window));
00207   exit(40);
00208 }

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 465 of file druid-gconf-setup.c.

00468 {
00469   return druid_gconf_choose_page_next(druidpage, druid, user_data);
00470 }

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 479 of file druid-gconf-setup.c.

00482 {
00483   GtkWidget *window;
00484   gint value, value2;
00485   GError *error = NULL;
00486   gboolean keep_going = TRUE;
00487 
00488   /* What to do... what to do... */
00489   value = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), WHO_DOES));
00490   switch (value) {
00491     case WHO_ALREADY_DONE:
00492       break;
00493 
00494     case WHO_USER:
00495       keep_going = FALSE;
00496       break;
00497 
00498     default:
00499       value2 = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), HOW));
00500       switch(value2) {
00501       case HOW_INSTALL:
00502         if (!druid_gconf_install_keys(&error)) {
00503           keep_going = FALSE;
00504           gnc_error_dialog(NULL, error->message);
00505           g_error_free(error);
00506         }
00507         break;
00508 
00509       default:
00510         if (!druid_gconf_update_path(&error)) {
00511           keep_going = FALSE;
00512           gnc_error_dialog(NULL, error->message);
00513           g_error_free(error);
00514         }
00515         break;
00516       }
00517       break;
00518   }
00519 
00520   window = gnc_glade_lookup_widget(GTK_WIDGET(druid), "GConf Install Druid");
00521   gtk_widget_destroy(GTK_WIDGET(window));
00522   if (keep_going) {
00523     gtk_main_quit();
00524   } else {
00525     exit(42);
00526   }
00527 }

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 411 of file druid-gconf-setup.c.

00414 {
00415   gint who, how;
00416   const gchar *text;
00417   const gchar *pgm_path =
00418     "When you click Appply, Gnucash will modify your ~/.gconf.path file "
00419     "and restart the gconf backend.";
00420   const gchar *pgm_install =
00421     "When you click Appply, Gnucash will install the gconf data into your "
00422     "local ~/.gconf file and restart the gconf backend.";
00423   const gchar *user_does =
00424     "You have chosen to correct the problem by yourself.  When you click "
00425     "Apply, Gnucash will exit.  Please correct the problem and restart "
00426     "the gconf backend before restarting Gnucash.  If you have not already "
00427     "done so, you can click the Back button and copy the necessary text "
00428     "from the dialog.";
00429   const gchar *user_did =
00430     "You have already corrected the problem.  When you click Apply, Gnucash "
00431     "will continue loading.";
00432 
00433   who = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), WHO_DOES));
00434   switch (who) {
00435     case WHO_ALREADY_DONE:
00436       text = user_did;
00437       break;
00438 
00439     case WHO_USER:
00440       text = user_does;
00441       break;
00442 
00443     default:
00444       how = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), HOW));
00445       switch(how) {
00446       case HOW_INSTALL:
00447         text = pgm_install;
00448         break;
00449 
00450       default:
00451         text = pgm_path;
00452         break;
00453       }
00454   }
00455 
00456   gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage), text);
00457 }

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 577 of file druid-gconf-setup.c.

00578 {
00579   GladeXML *xml;
00580   GtkWidget *dialog;
00581   gboolean done = FALSE;
00582   gint response;
00583 
00584   if (gnc_gconf_schemas_found()) {
00585     gnc_gconf_unset_dir(GCONF_WARNINGS_TEMP, NULL);
00586     return;
00587   }
00588 
00589   xml = gnc_glade_xml_new ("druid-gconf-setup.glade", "GConf Query");
00590   dialog = glade_xml_get_widget (xml, "GConf Query");
00591   do {
00592     response = gtk_dialog_run(GTK_DIALOG(dialog));
00593 
00594     switch (response) {
00595     case GTK_RESPONSE_CANCEL:
00596     default:
00597       gnc_shutdown(42);
00598       /* never returns */
00599 
00600     case GTK_RESPONSE_NO:
00601       /* User wants to run without setting up gconf */
00602       done = TRUE;
00603       break;
00604 
00605     case GTK_RESPONSE_ACCEPT:
00606       gtk_widget_hide(dialog);
00607       gnc_gnome_install_gconf_schemas();
00608       done = TRUE;
00609       break;
00610 
00611     case GTK_RESPONSE_HELP:
00612       gnc_gnome_help(HF_HELP, HL_GCONF);
00613       break;
00614     }
00615   } while (!done);
00616 
00617   gtk_widget_destroy(dialog);
00618 }

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 389 of file druid-gconf-setup.c.

00392 {
00393   GtkWidget *page;
00394 
00395   page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "choose_page");
00396   gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
00397   return TRUE;
00398 }

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 363 of file druid-gconf-setup.c.

00366 {
00367   GtkWidget *page, *button1, *button2;
00368 
00369   button1 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "program2");
00370   button2 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "user2");
00371   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button1))) {
00372     g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_GNUCASH));
00373   } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button2))) {
00374     g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_USER));
00375   } else {
00376     g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_ALREADY_DONE));
00377   }
00378 
00379   page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "finish_page");
00380   gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
00381   return TRUE;
00382 }

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 346 of file druid-gconf-setup.c.

00349 {
00350   GtkWidget *textview;
00351 
00352   textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "textview5");
00353   gtk_widget_modify_base(textview, GTK_STATE_INSENSITIVE,
00354                          &GNOME_DRUID_PAGE_STANDARD(druidpage)->contents_background);
00355 }

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 316 of file druid-gconf-setup.c.

00319 {
00320   GtkWidget *page, *button1, *button2;
00321 
00322   button1 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "program1");
00323   button2 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "user1");
00324   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button1))) {
00325     g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_GNUCASH));
00326   } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button2))) {
00327     g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_USER));
00328   } else {
00329     g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_ALREADY_DONE));
00330   }
00331 
00332   page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "finish_page");
00333   gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
00334   return TRUE;
00335 }

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 291 of file druid-gconf-setup.c.

00294 {
00295   GtkTextBuffer *textbuffer;
00296   GtkWidget *textview;
00297   gchar *msg;
00298 
00299   /* The text views don't have the right background color for some reason. */
00300   textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "textview4");
00301   gtk_widget_modify_base(textview, GTK_STATE_INSENSITIVE,
00302                          &GNOME_DRUID_PAGE_STANDARD(druidpage)->contents_background);
00303 
00304   textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_text");
00305   textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
00306   msg = g_strdup_printf(PATH_STRING1 PATH_STRING2, GNC_GCONF_DIR);
00307   gtk_text_buffer_set_text(textbuffer, msg, -1);
00308 }


Generated on Sun Sep 4 18:09:20 2005 for GnuCash by  doxygen 1.4.3-20050530