GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-gnome-utils.c
1 /********************************************************************\
2  * gnc-gnome-utils.c -- utility functions for gnome for GnuCash *
3  * Copyright (C) 2001 Linux Developers Group *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License*
16  * along with this program; if not, contact: *
17  * *
18  * Free Software Foundation Voice: +1-617-542-5942 *
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
20  * Boston, MA 02110-1301, USA [email protected] *
21  * *
22 \********************************************************************/
23 
24 #include "config.h"
25 
26 #include <glib/gi18n.h>
27 #ifdef HAVE_X11_XLIB_H
28 # include <X11/Xlib.h>
29 #endif
30 #include <libxml/xmlIO.h>
31 
32 #include "gnc-prefs-utils.h"
33 #include "gnc-prefs.h"
34 #include "gnc-gnome-utils.h"
35 //#include "gnc-html.h"
36 #include "gnc-engine.h"
37 #include "gnc-path.h"
38 #include "gnc-ui.h"
39 #include "gnc-file.h"
40 #include "gnc-hooks.h"
41 #include "gnc-filepath-utils.h"
42 #include "gnc-menu-extensions.h"
43 #include "gnc-component-manager.h"
44 #include "gnc-splash.h"
45 #include "gnc-window.h"
46 #include "gnc-icons.h"
47 #include "dialog-options.h"
48 #include "dialog-commodity.h"
49 #include "dialog-totd.h"
50 #include "gnc-ui-util.h"
51 #include "gnc-session.h"
52 #include "qofbookslots.h"
53 #ifdef G_OS_WIN32
54 #include <windows.h>
55 #include "gnc-help-utils.h"
56 #endif
57 #ifdef MAC_INTEGRATION
58 #import <Cocoa/Cocoa.h>
59 #endif
60 
61 static QofLogModule log_module = GNC_MOD_GUI;
62 static int gnome_is_running = FALSE;
63 static int gnome_is_terminating = FALSE;
64 static int gnome_is_initialized = FALSE;
65 
66 
67 #define ACCEL_MAP_NAME "accelerator-map"
68 
69 static void gnc_book_options_help_cb (GNCOptionWin *win, gpointer dat);
70 
71 static void
72 gnc_global_options_help_cb (GNCOptionWin *win, gpointer dat)
73 {
74  gnc_gnome_help (HF_HELP, HL_GLOBPREFS);
75 }
76 
77 static void
78 gnc_book_options_help_cb (GNCOptionWin *win, gpointer dat)
79 {
80  gnc_gnome_help (HF_HELP, HL_BOOK_OPTIONS);
81 }
82 
83 void
85 {
86  gnc_options_dialog_set_help_cb(win,
87  (GNCOptionWinCallback)gnc_book_options_help_cb,
88  NULL);
89 }
90 
91 void
93 {
94  GNCOption *num_source_option;
95  GtkWidget *num_source_is_split_action_button;
96  gboolean num_source_is_split_action;
97 
98  if (!odb) return;
99  num_source_is_split_action = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL,
100  GNC_PREF_NUM_SOURCE);
101  if (num_source_is_split_action)
102  {
103  num_source_option = gnc_option_db_get_option_by_name(odb,
104  OPTION_SECTION_ACCOUNTS,
105  OPTION_NAME_NUM_FIELD_SOURCE);
106  num_source_is_split_action_button =
107  gnc_option_get_gtk_widget (num_source_option);
108  gtk_toggle_button_set_active
109  (GTK_TOGGLE_BUTTON (num_source_is_split_action_button),
110  num_source_is_split_action);
111  }
112 }
113 
114 static void
115 gnc_commodity_help_cb (void)
116 {
117  gnc_gnome_help (HF_HELP, HL_COMMODITY);
118 }
119 
120 /* gnc_configure_date_format
121  * sets dateFormat to the current value on the scheme side
122  *
123  * Args: Nothing
124  * Returns: Nothing
125  */
126 static void
127 gnc_configure_date_format (void)
128 {
129  QofDateFormat df = gnc_prefs_get_int(GNC_PREFS_GROUP_GENERAL,
130  GNC_PREF_DATE_FORMAT);
131 
132  /* Only a subset of the qof date formats is currently
133  * supported for date entry.
134  */
135  if ((df > QOF_DATE_FORMAT_LOCALE)
136  || (df > QOF_DATE_FORMAT_LOCALE))
137  {
138  PERR("Incorrect date format");
139  return;
140  }
141 
143 }
144 
145 /* gnc_configure_date_completion
146  * sets dateCompletion to the current value on the scheme side.
147  * QOF_DATE_COMPLETION_THISYEAR: use current year
148  * QOF_DATE_COMPLETION_SLIDING: use a sliding 12-month window
149  * backmonths 0-11: windows starts this many months before current month
150  *
151  * Args: Nothing
152  * Returns: Nothing
153  */
154 static void
155 gnc_configure_date_completion (void)
156 {
158  int backmonths = gnc_prefs_get_float(GNC_PREFS_GROUP_GENERAL,
159  GNC_PREF_DATE_BACKMONTHS);
160 
161  if (backmonths < 0)
162  backmonths = 0;
163  else if (backmonths > 11)
164  backmonths = 11;
165 
166  if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_COMPL_SLIDING))
168 
169  qof_date_completion_set(dc, backmonths);
170 }
171 
172 void
174 {
175  const gchar *var;
176  gchar *str;
177 
178  var = g_get_home_dir ();
179  if (var)
180  {
181  str = g_build_filename (var, ".gtkrc-2.0.gnucash", (char *)NULL);
182  gtk_rc_add_default_file (str);
183  g_free (str);
184  }
185 }
186 
187 #ifdef MAC_INTEGRATION
188 
189 /* Don't be alarmed if this function looks strange to you: It's
190  * written in Objective-C, the native language of the OSX Cocoa
191  * toolkit.
192  */
193 void
194 gnc_gnome_help (const char *dir, const char *detail)
195 {
196  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
197 NSString *subdir = [NSString stringWithUTF8String: dir];
198 NSString *tag, *subdirectory;
199  NSURL *url = NULL;
200 
201  if (detail)
202 tag = [NSString stringWithUTF8String: detail];
203 else if ([subdir compare: @HF_HELP] == NSOrderedSame)
204  tag = @"help";
205 else if ([subdir compare: @HF_GUIDE] == NSOrderedSame)
206  tag = @"index";
207  else
208  {
209  PWARN("gnc_gnome_help called with unknown subdirectory %s", dir);
210  return;
211  }
212 
213  if (![[NSBundle mainBundle] bundleIdentifier])
214  {
215  /* If bundleIdentifier is NULL, then we're running from the
216  * commandline and must construct a file path to the resource. We can
217  * still get the resource path, but it will point to the "bin"
218  * directory so we chop that off, break up what's left into pieces,
219  * add some more pieces, and put it all back together again. Then,
220  * because the gettext way of handling localizations is different from
221  * OSX's, we have to figure out which translation to use. */
222 NSArray *components = [NSArray arrayWithObjects: @"share", @"doc", @"gnucash-docs", nil ];
223  NSString *prefix = [[[NSBundle mainBundle] resourcePath]
224  stringByDeletingLastPathComponent];
225  NSArray *prefix_comps = [[prefix pathComponents]
226  arrayByAddingObjectsFromArray: components];
227 NSString *docs_dir = [NSString pathWithComponents: prefix_comps];
228  NSArray *languages = [[NSUserDefaults standardUserDefaults]
229  objectForKey: @"AppleLanguages"];
230  BOOL dir;
231 subdir = [[[subdir lowercaseString] componentsSeparatedByString: @" "]
232  componentsJoinedByString: @"-"];
233 if (![[NSFileManager defaultManager] fileExistsAtPath: docs_dir])
234  {
235  const gchar *message =
236  _("GnuCash could not find the files for the help documentation. "
237  "This is likely because the 'gnucash-docs' package is not installed");
238  gnc_error_dialog(NULL, "%s at %s", message, [docs_dir UTF8String]);
239  [pool release];
240  return;
241  }
242  if ([languages count] > 0)
243  {
244  NSEnumerator *lang_iter = [languages objectEnumerator];
245  NSString *path;
246  NSString *this_lang;
247  while ((this_lang = [lang_iter nextObject]))
248  {
249  NSArray *elements;
250  unsigned int paths;
251  NSString *completed_path = [NSString alloc];
252 this_lang = [this_lang stringByTrimmingCharactersInSet:
253  [NSCharacterSet characterSetWithCharactersInString:
254  @"\""]];
255 elements = [this_lang componentsSeparatedByString: @"-"];
256  this_lang = [elements objectAtIndex: 0];
257 path = [docs_dir stringByAppendingPathComponent: this_lang];
258 paths = [path completePathIntoString: &completed_path
259  caseSensitive: FALSE
260  matchesIntoArray: NULL filterTypes: NULL];
261  if (paths > 1 &&
262  [[NSFileManager defaultManager]
263  fileExistsAtPath: completed_path
264  isDirectory: &dir])
265  if (dir)
266  {
267  @try
268  {
269 url = [NSURL fileURLWithPath:
270  [[[completed_path
271  stringByAppendingPathComponent: subdir]
272  stringByAppendingPathComponent: tag]
273  stringByAppendingPathExtension: @"html"]];
274  }
275  @catch (NSException *e)
276  {
277  PWARN("fileURLWithPath threw %s: %s",
278  [[e name] UTF8String], [[e reason] UTF8String]);
279  return;
280  }
281  break;
282  }
283 if ([this_lang compare: @"en"] == NSOrderedSame)
284  break; /* Special case, forces use of "C" locale */
285  }
286  }
287  if (!url)
288  {
289  @try
290  {
291  url = [NSURL
292  fileURLWithPath: [[[[docs_dir
293  stringByAppendingPathComponent: @"C"]
294  stringByAppendingPathComponent: subdir]
295  stringByAppendingPathComponent: tag]
296  stringByAppendingPathExtension: @"html"]];
297  }
298  @catch (NSException *e)
299  {
300  PWARN("fileURLWithPath threw %s: %s",
301  [[e name] UTF8String], [[e reason] UTF8String]);
302  return;
303  }
304  }
305  }
306  /* It's a lot easier in a bundle! OSX finds the best translation for us. */
307  else
308  {
309  @try
310  {
311 url = [NSURL fileURLWithPath: [[NSBundle mainBundle]
312  pathForResource: tag
313  ofType: @"html"
314  inDirectory: subdir ]];
315  }
316  @catch (NSException *e)
317  {
318  PWARN("fileURLWithPath threw %s: %s",
319  [[e name] UTF8String], [[e reason] UTF8String]);
320  return;
321  }
322  }
323  /* Now just open the URL in the default app for opening URLs */
324  if (url)
325 [[NSWorkspace sharedWorkspace] openURL: url];
326  else
327  {
328  const gchar *message =
329  _("GnuCash could not find the files for the help documentation. "
330  "This is likely because the 'gnucash-docs' package is not installed.");
331  gnc_error_dialog(NULL, "%s", message);
332  }
333  [pool release];
334 }
335 #elif defined G_OS_WIN32 /* G_OS_WIN32 */
336 void
337 gnc_gnome_help (const char *file_name, const char *anchor)
338 {
339  const gchar * const *lang;
340  gchar *pkgdatadir, *fullpath, *found = NULL;
341 
342  pkgdatadir = gnc_path_get_pkgdatadir ();
343  for (lang = g_get_language_names (); *lang; lang++)
344  {
345  fullpath = g_build_filename (pkgdatadir, "help", *lang, file_name,
346  (gchar*) NULL);
347  if (g_file_test (fullpath, G_FILE_TEST_IS_REGULAR))
348  {
349  found = g_strdup (fullpath);
350  g_free (fullpath);
351  break;
352  }
353  g_free (fullpath);
354  }
355  g_free (pkgdatadir);
356 
357  if (!found)
358  {
359  const gchar *message =
360  _("GnuCash could not find the files for the help documentation.");
361  gnc_error_dialog (NULL, message);
362  }
363  else
364  {
365  gnc_show_htmlhelp (found, anchor);
366  }
367  g_free (found);
368 }
369 #else
370 void
371 gnc_gnome_help (const char *file_name, const char *anchor)
372 {
373  GError *error = NULL;
374  gchar *uri = NULL;
375  gboolean success;
376 
377  if (anchor)
378  uri = g_strconcat ("ghelp:", file_name, "?", anchor, NULL);
379  else
380  uri = g_strconcat ("ghelp:", file_name, NULL);
381 
382  DEBUG ("Attempting to opening help uri %s", uri);
383  success = gtk_show_uri (NULL, uri, gtk_get_current_event_time (), &error);
384  g_free (uri);
385  if (success)
386  return;
387 
388  g_assert(error != NULL);
389  {
390  const gchar *message =
391  _("GnuCash could not find the files for the help documentation. "
392  "This is likely because the 'gnucash-docs' package is not installed.");
393  gnc_error_dialog(NULL, "%s", message);
394  }
395  PERR ("%s", error->message);
396  g_error_free(error);
397 }
398 
399 
400 #endif
401 
402 #ifdef MAC_INTEGRATION
403 
404 /* Don't be alarmed if this function looks strange to you: It's
405  * written in Objective-C, the native language of the OSX Cocoa
406  * toolkit.
407  */
408 void
409 gnc_launch_assoc (const char *uri)
410 {
411  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
412  NSString *uri_str = [NSString stringWithUTF8String: uri];
413  NSURL *url = [[[NSURL alloc] initWithString: uri_str] autorelease];
414  const gchar *message =
415  _("GnuCash could not find the associated file.");
416 
417  if (url)
418  {
419  [[NSWorkspace sharedWorkspace] openURL: url];
420  [pool release];
421  return;
422  }
423 
424  gnc_error_dialog(NULL, "%s", message);
425 
426  [pool release];
427  return;
428 }
429 #elif defined G_OS_WIN32 /* G_OS_WIN32 */
430 void
431 gnc_launch_assoc (const char *uri)
432 {
433  wchar_t *winuri = (wchar_t *)g_utf8_to_utf16(uri, -1, NULL, NULL, NULL);
434  wchar_t *wincmd = (wchar_t *)g_utf8_to_utf16("open", -1, NULL, NULL, NULL);
435  if (winuri)
436  {
437  if ((INT_PTR)ShellExecuteW(NULL, wincmd, winuri, NULL, NULL, SW_SHOWNORMAL) <= 32)
438  {
439  const gchar *message =
440  _("GnuCash could not find the associated file.");
441  gnc_error_dialog(NULL, "%s", message);
442  }
443  g_free (winuri);
444  }
445  g_free (wincmd);
446 }
447 
448 #else
449 void
450 gnc_launch_assoc (const char *uri)
451 {
452  GError *error = NULL;
453  gboolean success;
454 
455  if (!uri)
456  return;
457 
458  DEBUG ("Attempting to open uri %s", uri);
459  success = gtk_show_uri (NULL, uri, gtk_get_current_event_time (), &error);
460  if (success)
461  return;
462 
463  g_assert(error != NULL);
464  {
465  const gchar *message =
466  _("GnuCash could not open the associated URI:");
467  gnc_error_dialog(NULL, "%s\n%s", message, uri);
468  }
469  PERR ("%s", error->message);
470  g_error_free(error);
471 }
472 
473 #endif
474 
475 /********************************************************************\
476  * gnc_gnome_get_pixmap *
477  * returns a GtkWidget given a pixmap filename *
478  * *
479  * Args: none *
480  * Returns: GtkWidget or NULL if there was a problem *
481  \*******************************************************************/
482 GtkWidget *
483 gnc_gnome_get_pixmap (const char *name)
484 {
485  GtkWidget *pixmap;
486  char *fullname;
487 
488  g_return_val_if_fail (name != NULL, NULL);
489 
490  fullname = gnc_filepath_locate_pixmap (name);
491  if (fullname == NULL)
492  return NULL;
493 
494  DEBUG ("Loading pixmap file %s", fullname);
495 
496  pixmap = gtk_image_new_from_file (fullname);
497  if (pixmap == NULL)
498  {
499  PERR ("Could not load pixmap");
500  }
501  g_free (fullname);
502 
503  return pixmap;
504 }
505 
506 /********************************************************************\
507  * gnc_gnome_get_gdkpixbuf *
508  * returns a GdkImlibImage object given a pixmap filename *
509  * *
510  * Args: none *
511  * Returns: GdkPixbuf or NULL if there was a problem *
512  \*******************************************************************/
513 GdkPixbuf *
514 gnc_gnome_get_gdkpixbuf (const char *name)
515 {
516  GdkPixbuf *pixbuf;
517  GError *error = NULL;
518  char *fullname;
519 
520  g_return_val_if_fail (name != NULL, NULL);
521 
522  fullname = gnc_filepath_locate_pixmap (name);
523  if (fullname == NULL)
524  return NULL;
525 
526  DEBUG ("Loading pixbuf file %s", fullname);
527  pixbuf = gdk_pixbuf_new_from_file (fullname, &error);
528  if (error != NULL)
529  {
530  g_assert (pixbuf == NULL);
531  PERR ("Could not load pixbuf: %s", error->message);
532  g_error_free (error);
533  }
534  g_free (fullname);
535 
536  return pixbuf;
537 }
538 
539 static gboolean
540 gnc_ui_check_events (gpointer not_used)
541 {
542  QofSession *session;
543  gboolean force;
544 
545  if (gtk_main_level() != 1)
546  return TRUE;
547 
548  if (!gnc_current_session_exist())
549  return TRUE;
550  session = gnc_get_current_session ();
551 
552  if (gnc_gui_refresh_suspended ())
553  return TRUE;
554 
555  if (!qof_session_events_pending (session))
556  return TRUE;
557 
558  gnc_suspend_gui_refresh ();
559 
560  force = qof_session_process_events (session);
561 
562  gnc_resume_gui_refresh ();
563 
564  if (force)
565  gnc_gui_refresh_all ();
566 
567  return TRUE;
568 }
569 
570 #ifdef HAVE_X11_XLIB_H
571 static int
572 gnc_x_error (Display *display, XErrorEvent *error)
573 {
574  if (error->error_code)
575  {
576  char buf[64];
577 
578  XGetErrorText (display, error->error_code, buf, 63);
579 
580  g_warning ("X-ERROR **: %s\n serial %ld error_code %d "
581  "request_code %d minor_code %d\n",
582  buf,
583  error->serial,
584  error->error_code,
585  error->request_code,
586  error->minor_code);
587  }
588 
589  return 0;
590 }
591 #endif
592 
593 int
594 gnc_ui_start_event_loop (void)
595 {
596  guint id;
597 
598  gnome_is_running = TRUE;
599 
600  id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 10000, /* 10 secs */
601  gnc_ui_check_events, NULL, NULL);
602 
603 #ifdef HAVE_X11_XLIB_H
604  XSetErrorHandler (gnc_x_error);
605 #endif
606 
607  /* Enter gnome event loop */
608  gtk_main ();
609 
610  g_source_remove (id);
611 
612  gnome_is_running = FALSE;
613  gnome_is_terminating = FALSE;
614 
615  return 0;
616 }
617 
620 {
621  static GncMainWindow *main_window;
622  gchar *map;
623 #ifdef MAC_INTEGRATION
624  gchar *data_dir;
625 #endif
626  int idx;
627  char *icon_filenames[] = {"gnucash-icon-16x16.png",
628  "gnucash-icon-32x32.png",
629  "gnucash-icon-48x48.png",
630  NULL
631  };
632  GList *icons = NULL;
633  char *fullname;
634 
635  ENTER ("");
636 
637  if (gnome_is_initialized)
638  return main_window;
639 
640  /* use custom icon */
641  for (idx = 0; icon_filenames[idx] != NULL; idx++)
642  {
643  GdkPixbuf *buf = NULL;
644 
645  fullname = gnc_filepath_locate_pixmap(icon_filenames[idx]);
646  if (fullname == NULL)
647  {
648  g_warning("couldn't find icon file [%s]", icon_filenames[idx]);
649  continue;
650  }
651 
652  buf = gnc_gnome_get_gdkpixbuf(fullname);
653  if (buf == NULL)
654  {
655  g_warning("error loading image from [%s]", fullname);
656  g_free(fullname);
657  continue;
658  }
659  g_free(fullname);
660  icons = g_list_append(icons, buf);
661  }
662 
663  gtk_window_set_default_icon_list(icons);
664  g_list_foreach(icons, (GFunc)g_object_unref, NULL);
665  g_list_free(icons);
666 
667  /* initialization required for gtkhtml (is it also needed for webkit?) */
668  gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());
669 
670  g_set_application_name(PACKAGE_NAME);
671 
672  gnc_prefs_init();
673  gnc_show_splash_screen();
674 
675  gnome_is_initialized = TRUE;
676 
677  gnc_ui_util_init();
678  gnc_configure_date_format();
679  gnc_configure_date_completion();
680 
681  gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
682  GNC_PREF_DATE_FORMAT,
683  gnc_configure_date_format,
684  NULL);
685  gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
686  GNC_PREF_DATE_COMPL_THISYEAR,
687  gnc_configure_date_completion,
688  NULL);
689  gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
690  GNC_PREF_DATE_COMPL_SLIDING,
691  gnc_configure_date_completion,
692  NULL);
693  gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
694  GNC_PREF_DATE_BACKMONTHS,
695  gnc_configure_date_completion,
696  NULL);
697  gnc_prefs_register_group_cb (GNC_PREFS_GROUP_GENERAL,
698  gnc_gui_refresh_all,
699  NULL);
700 
701  gnc_ui_commodity_set_help_callback (gnc_commodity_help_cb);
702  gnc_file_set_shutdown_callback (gnc_shutdown);
703 
704  gnc_options_dialog_set_global_help_cb (gnc_global_options_help_cb, NULL);
705 
706  main_window = gnc_main_window_new ();
707  // Bug#350993:
708  // gtk_widget_show (GTK_WIDGET (main_window));
709  gnc_window_set_progressbar_window (GNC_WINDOW(main_window));
710 
711 #ifdef MAC_INTEGRATION
712  map = gnc_build_dotgnucash_path(ACCEL_MAP_NAME);
713  if (!g_file_test (map, G_FILE_TEST_EXISTS))
714  {
715  g_free (map);
716  data_dir = gnc_path_get_pkgdatadir();
717  map = g_build_filename(data_dir, "ui", "osx_accel_map", NULL);
718  g_free(data_dir);
719  }
720 #else
721  map = gnc_build_dotgnucash_path(ACCEL_MAP_NAME);
722 #endif /* MAC_INTEGRATION */
723  gtk_accel_map_load(map);
724  g_free(map);
725 
726  gnc_load_stock_icons();
727  gnc_totd_dialog(GTK_WINDOW(main_window), TRUE);
728 
729  LEAVE ("");
730  return main_window;
731 }
732 
733 gboolean
734 gnucash_ui_is_running(void)
735 {
736  return gnome_is_running;
737 }
738 
739 static void
740 gnc_gui_destroy (void)
741 {
742  if (!gnome_is_initialized)
743  return;
744 
745  gnc_extensions_shutdown ();
746 }
747 
748 static void
749 gnc_gui_shutdown (void)
750 {
751  gchar *map;
752 
753  if (gnome_is_running && !gnome_is_terminating)
754  {
755  gnome_is_terminating = TRUE;
756  map = gnc_build_dotgnucash_path(ACCEL_MAP_NAME);
757  gtk_accel_map_save(map);
758  g_free(map);
759  gtk_main_quit();
760  }
761 }
762 
763 /* shutdown gnucash. This function will initiate an orderly
764  * shutdown, and when that has finished it will exit the program.
765  */
766 void
767 gnc_shutdown (int exit_status)
768 {
769  if (gnucash_ui_is_running())
770  {
771  if (!gnome_is_terminating)
772  {
773  if (gnc_file_query_save(FALSE))
774  {
775  gnc_hook_run(HOOK_UI_SHUTDOWN, NULL);
776  gnc_gui_shutdown();
777  }
778  }
779  }
780  else
781  {
782  gnc_gui_destroy();
783  gnc_hook_run(HOOK_SHUTDOWN, NULL);
785  exit(exit_status);
786  }
787 }
788 
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
Definition: gnc-prefs.c:128
QofDateCompletion
Definition: gnc-date.h:136
utility functions for the GnuCash UI
GtkWidget * gnc_gnome_get_pixmap(const char *name)
void gnc_engine_shutdown(void)
Definition: gnc-engine.c:160
void gnc_ui_commodity_set_help_callback(gnc_commodity_help_callback cb)
#define DEBUG(format, args...)
Definition: qoflog.h:255
Functions that are supported by all types of windows.
gboolean qof_session_events_pending(const QofSession *session)
void gnc_shutdown(int exit_status)
gchar * gnc_build_dotgnucash_path(const gchar *filename)
Make a path to filename in the user's configuration directory.
#define PERR(format, args...)
Definition: qoflog.h:237
#define ENTER(format, args...)
Definition: qoflog.h:261
gint gnc_prefs_get_int(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:206
#define PWARN(format, args...)
Definition: qoflog.h:243
void qof_date_completion_set(QofDateCompletion dc, int backmonths)
Preferences initialization function.
void gnc_options_dialog_set_book_options_help_cb(GNCOptionWin *win)
Gnome specific utility functions.
void gnc_gnome_help(const char *file_name, const char *anchor)
gchar * gnc_filepath_locate_pixmap(const gchar *name)
All type declarations for the whole Gnucash engine.
Generic api to store and retrieve preferences.
gboolean qof_session_process_events(QofSession *session)
guint gnc_prefs_register_group_cb(const gchar *group, gpointer func, gpointer user_data)
Definition: gnc-prefs.c:166
void gnc_launch_assoc(const char *uri)
GncMainWindow * gnc_main_window_new(void)
void gnc_prefs_init(void)
void gnc_gtk_add_rc_file(void)
void gnc_options_dialog_set_new_book_option_values(GNCOptionDB *odb)
GdkPixbuf * gnc_gnome_get_gdkpixbuf(const char *name)
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:196
GncMainWindow * gnc_gui_init(void)
#define LEAVE(format, args...)
Definition: qoflog.h:271
void qof_date_format_set(QofDateFormat df)
File path resolution utility functions.
QofDateFormat
Definition: gnc-date.h:121
"select" and "new" commodity windows
const gchar * QofLogModule
Definition: qofid.h:89
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:227