GnuCash  5.6-150-g038405b370+
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 gnu@gnu.org *
21  * *
22 \********************************************************************/
23 
24 #include <config.h>
25 
26 #include <glib/gi18n.h>
27 #include <libxml/xmlIO.h>
28 
29 #include "gnc-prefs-utils.h"
30 #include "gnc-prefs.h"
31 #include "gnc-gnome-utils.h"
32 #include "gnc-engine.h"
33 #include "gnc-path.h"
34 #include "gnc-ui.h"
35 #include "gnc-file.h"
36 #include "gnc-hooks.h"
37 #include "gnc-filepath-utils.h"
38 #include "gnc-menu-extensions.h"
39 #include "gnc-component-manager.h"
40 #include "gnc-splash.h"
41 #include "gnc-window.h"
42 #include "gnc-icons.h"
43 #include "dialog-doclink-utils.h"
44 #include "dialog-commodity.h"
45 #include "dialog-totd.h"
46 #include "gnc-ui-util.h"
47 #include "gnc-uri-utils.h"
48 #include "gnc-session.h"
49 #include "qofbookslots.h"
50 #ifdef G_OS_WIN32
51 #include <windows.h>
52 #include "gnc-help-utils.h"
53 #endif
54 #ifdef MAC_INTEGRATION
55 #import <Cocoa/Cocoa.h>
56 #endif
57 
58 extern SCM scm_init_sw_gnome_utils_module(void);
59 
60 static QofLogModule log_module = GNC_MOD_GUI;
61 static int gnome_is_running = FALSE;
62 static int gnome_is_terminating = FALSE;
63 static int gnome_is_initialized = FALSE;
64 
65 
66 #define ACCEL_MAP_NAME "accelerator-map"
67 
68 const gchar *msg_no_help_found =
69  N_("GnuCash could not find the files of the help documentation.");
70 const gchar *msg_no_help_reason =
71  N_("This is likely because the \"gnucash-docs\" package is not properly installed.");
72  /* Translators: URI of missing help files */
73 const gchar *msg_no_help_location = N_("Expected location");
74 
75 void
77 {
78  gnc_component_manager_init ();
79 
80  scm_init_sw_gnome_utils_module();
81  scm_c_use_module ("sw_gnome_utils");
82  scm_c_use_module("gnucash gnome-utils");
83 }
84 
85 
86 /* gnc_configure_date_format
87  * sets dateFormat to the current value on the scheme side
88  *
89  * Args: Nothing
90  * Returns: Nothing
91  */
92 static void
93 gnc_configure_date_format (void)
94 {
95  QofDateFormat df = gnc_prefs_get_int(GNC_PREFS_GROUP_GENERAL,
96  GNC_PREF_DATE_FORMAT);
97 
98  /* Only a subset of the qof date formats is currently
99  * supported for date entry.
100  */
101  if (df > QOF_DATE_FORMAT_LOCALE)
102  {
103  PERR("Incorrect date format");
104  return;
105  }
106 
108 }
109 
110 /* gnc_configure_date_completion
111  * sets dateCompletion to the current value on the scheme side.
112  * QOF_DATE_COMPLETION_THISYEAR: use current year
113  * QOF_DATE_COMPLETION_SLIDING: use a sliding 12-month window
114  * backmonths 0-11: windows starts this many months before current month
115  *
116  * Args: Nothing
117  * Returns: Nothing
118  */
119 static void
120 gnc_configure_date_completion (void)
121 {
123  int backmonths = gnc_prefs_get_float(GNC_PREFS_GROUP_GENERAL,
124  GNC_PREF_DATE_BACKMONTHS);
125 
126  if (backmonths < 0)
127  backmonths = 0;
128  else if (backmonths > 11)
129  backmonths = 11;
130 
131  if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_COMPL_SLIDING))
133 
134  qof_date_completion_set(dc, backmonths);
135 }
136 
137 void
139 {
140  GtkCssProvider *provider_user, *provider_app, *provider_fallback;
141  GdkDisplay *display;
142  GdkScreen *screen;
143  const gchar *var;
144  GError *error = 0;
145 
146  provider_user = gtk_css_provider_new ();
147  provider_app = gtk_css_provider_new ();
148  provider_fallback = gtk_css_provider_new ();
149  display = gdk_display_get_default ();
150  screen = gdk_display_get_default_screen (display);
151 
152  gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider_fallback), GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
153  gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider_app), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
154  gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider_user), GTK_STYLE_PROVIDER_PRIORITY_USER);
155 
156  gtk_css_provider_load_from_resource (provider_app, GNUCASH_RESOURCE_PREFIX "/gnucash.css");
157  gtk_css_provider_load_from_resource (provider_fallback, GNUCASH_RESOURCE_PREFIX "/gnucash-fallback.css");
158 
159  var = gnc_userconfig_dir ();
160  if (var)
161  {
162  gchar *str;
163  str = g_build_filename (var, "gtk-3.0.css", (char *)NULL);
164  if (!gtk_css_provider_load_from_path (provider_user, str, &error))
165  {
166  PWARN ("Could not load user CSS '%s': %s", str, error->message);
167  g_clear_error (&error);
168  }
169  g_free (str);
170  }
171  g_object_unref (provider_user);
172  g_object_unref (provider_app);
173  g_object_unref (provider_fallback);
174 }
175 
176 #ifdef MAC_INTEGRATION
177 
178 /* Don't be alarmed if this function looks strange to you: It's
179  * written in Objective-C, the native language of the OSX Cocoa
180  * toolkit.
181  */
182 void
183 gnc_gnome_help (GtkWindow *parent, const char *dir, const char *detail)
184 {
185  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
186  NSString *subdir = [NSString stringWithUTF8String: dir];
187  NSString *tag;
188  NSURL *url = NULL;
189 
190  if (detail)
191  tag = [NSString stringWithUTF8String: detail];
192  else
193  tag = @"index";
194 
195  if (![[NSBundle mainBundle] bundleIdentifier])
196  {
197  /* If bundleIdentifier is NULL, then we're running from the
198  * commandline and must construct a file path to the resource. We can
199  * still get the resource path, but it will point to the "bin"
200  * directory so we chop that off, break up what's left into pieces,
201  * add some more pieces, and put it all back together again. Then,
202  * because the gettext way of handling localizations is different from
203  * OSX's, we have to figure out which translation to use. */
204  NSArray *components = [NSArray arrayWithObjects: @"share", @"doc", @"gnucash-docs", nil ];
205  NSString *prefix = [[[NSBundle mainBundle] resourcePath]
206  stringByDeletingLastPathComponent];
207  NSArray *prefix_comps = [[prefix pathComponents]
208  arrayByAddingObjectsFromArray: components];
209  NSString *docs_dir = [NSString pathWithComponents: prefix_comps];
210  NSArray *languages = [[NSUserDefaults standardUserDefaults]
211  objectForKey: @"AppleLanguages"];
212  BOOL dir;
213  subdir = [[[subdir lowercaseString] componentsSeparatedByString: @" "]
214  componentsJoinedByString: @"-"];
215  if (![[NSFileManager defaultManager] fileExistsAtPath: docs_dir])
216  {
217  gnc_error_dialog (parent, "%s\n%s\n%s: %s", _(msg_no_help_found),
218  _(msg_no_help_reason),
219  _(msg_no_help_location), [docs_dir UTF8String]);
220  [pool release];
221  return;
222  }
223  if ([languages count] > 0)
224  {
225  NSEnumerator *lang_iter = [languages objectEnumerator];
226  NSString *path;
227  NSString *this_lang;
228  while ((this_lang = [lang_iter nextObject]))
229  {
230  NSArray *elements;
231  unsigned int paths;
232  NSString *completed_path = [NSString alloc];
233  this_lang = [this_lang stringByTrimmingCharactersInSet:
234  [NSCharacterSet characterSetWithCharactersInString:
235  @"\""]];
236  elements = [this_lang componentsSeparatedByString: @"-"];
237  this_lang = [elements objectAtIndex: 0];
238  path = [docs_dir stringByAppendingPathComponent: this_lang];
239  paths = [path completePathIntoString: &completed_path
240  caseSensitive: FALSE
241  matchesIntoArray: NULL filterTypes: NULL];
242  if (paths > 1 &&
243  [[NSFileManager defaultManager]
244  fileExistsAtPath: completed_path
245  isDirectory: &dir])
246  if (dir)
247  {
248  @try
249  {
250  url = [NSURL fileURLWithPath:
251  [[[completed_path
252  stringByAppendingPathComponent: subdir]
253  stringByAppendingPathComponent: tag]
254  stringByAppendingPathExtension: @"html"]];
255  }
256  @catch (NSException *e)
257  {
258  PWARN("fileURLWithPath threw %s: %s",
259  [[e name] UTF8String], [[e reason] UTF8String]);
260  return;
261  }
262  break;
263  }
264  if ([this_lang compare: @"en"] == NSOrderedSame)
265  break; /* Special case, forces use of "C" locale */
266  }
267  }
268  if (!url)
269  {
270  @try
271  {
272  url = [NSURL
273  fileURLWithPath: [[[[docs_dir
274  stringByAppendingPathComponent: @"C"]
275  stringByAppendingPathComponent: subdir]
276  stringByAppendingPathComponent: tag]
277  stringByAppendingPathExtension: @"html"]];
278  }
279  @catch (NSException *e)
280  {
281  PWARN("fileURLWithPath threw %s: %s",
282  [[e name] UTF8String], [[e reason] UTF8String]);
283  return;
284  }
285  }
286  }
287  /* It's a lot easier in a bundle! OSX finds the best translation for us. */
288  else
289  {
290  @try
291  {
292  url = [NSURL fileURLWithPath: [[NSBundle mainBundle]
293  pathForResource: tag
294  ofType: @"html"
295  inDirectory: subdir ]];
296  }
297  @catch (NSException *e)
298  {
299  PWARN("fileURLWithPath threw %s: %s",
300  [[e name] UTF8String], [[e reason] UTF8String]);
301  return;
302  }
303  }
304  /* Now just open the URL in the default app for opening URLs */
305  if (url)
306  [[NSWorkspace sharedWorkspace] openURL: url];
307  else
308  {
309  gnc_error_dialog (parent, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
310  }
311  [pool release];
312 }
313 #elif defined G_OS_WIN32 /* G_OS_WIN32 */
314 void
315 gnc_gnome_help (GtkWindow *parent, const char *file_name, const char *anchor)
316 {
317  const gchar * const *lang;
318  gchar *pkgdatadir, *fullpath, *found = NULL;
319 
320  pkgdatadir = gnc_path_get_pkgdatadir ();
321  for (lang = g_get_language_names (); *lang; lang++)
322  {
323  fullpath = g_build_filename (pkgdatadir, "help", *lang, file_name,
324  (gchar*) NULL);
325  if (g_file_test (fullpath, G_FILE_TEST_IS_REGULAR))
326  {
327  found = g_strdup (fullpath);
328  g_free (fullpath);
329  break;
330  }
331  g_free (fullpath);
332  }
333  g_free (pkgdatadir);
334 
335  if (!found)
336  {
337  gnc_error_dialog (parent, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
338  }
339  else
340  {
341  gnc_show_htmlhelp (found, anchor);
342  }
343  g_free (found);
344 }
345 #else
346 void
347 gnc_gnome_help (GtkWindow *parent, const char *file_name, const char *anchor)
348 {
349  GError *error = NULL;
350  gchar *uri = NULL;
351  gboolean success = TRUE;
352 
353  if (anchor)
354  uri = g_strconcat ("help:", file_name, "/", anchor, NULL);
355  else
356  uri = g_strconcat ("help:", file_name, NULL);
357 
358  DEBUG ("Attempting to opening help uri %s", uri);
359 
360  if (uri)
361  success = gtk_show_uri_on_window (NULL, uri, gtk_get_current_event_time (), &error);
362 
363  g_free (uri);
364  if (success)
365  return;
366 
367  g_assert(error != NULL);
368  {
369  gnc_error_dialog (parent, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
370  }
371  PERR ("%s", error->message);
372  g_error_free(error);
373 }
374 
375 
376 #endif
377 
378 #ifdef MAC_INTEGRATION
379 
380 /* Don't be alarmed if this function looks strange to you: It's
381  * written in Objective-C, the native language of the OSX Cocoa
382  * toolkit.
383  */
384 void
385 gnc_launch_doclink (GtkWindow *parent, const char *uri)
386 {
387  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
388  NSString *uri_str = [NSString stringWithUTF8String: uri];
389  NSURL *url = [[[NSURL alloc] initWithString: uri_str] autorelease];
390  const gchar *message =
391  _("GnuCash could not find the linked document.");
392 
393  if (url)
394  {
395  [[NSWorkspace sharedWorkspace] openURL: url];
396  [pool release];
397  return;
398  }
399 
400  gnc_error_dialog (parent, "%s", message);
401 
402  [pool release];
403  return;
404 }
405 #elif defined G_OS_WIN32 /* G_OS_WIN32 */
406 void
407 gnc_launch_doclink (GtkWindow *parent, const char *uri)
408 {
409  wchar_t *winuri = NULL;
410  gchar *filename = NULL;
411  /* ShellExecuteW open doesn't decode http escapes if it's passed a
412  * file URI so we have to do it. */
413  if (gnc_uri_is_file_uri (uri))
414  {
415  gchar *uri_scheme = gnc_uri_get_scheme (uri);
416  filename = gnc_doclink_get_unescape_uri (NULL, uri, uri_scheme);
417  winuri = (wchar_t *)g_utf8_to_utf16(filename, -1, NULL, NULL, NULL);
418  g_free (uri_scheme);
419  }
420  else
421  winuri = (wchar_t *)g_utf8_to_utf16(uri, -1, NULL, NULL, NULL);
422 
423  if (winuri)
424  {
425  wchar_t *wincmd = (wchar_t *)g_utf8_to_utf16("open", -1,
426  NULL, NULL, NULL);
427  if ((INT_PTR)ShellExecuteW(NULL, wincmd, winuri,
428  NULL, NULL, SW_SHOWNORMAL) <= 32)
429  {
430  const gchar *message =
431  _("GnuCash could not find the linked document.");
432  gnc_error_dialog (parent, "%s:\n%s", message, filename);
433  }
434  g_free (wincmd);
435  g_free (winuri);
436  g_free (filename);
437  }
438 }
439 
440 #else
441 void
442 gnc_launch_doclink (GtkWindow *parent, const char *uri)
443 {
444  GError *error = NULL;
445  gboolean success;
446 
447  if (!uri)
448  return;
449 
450  DEBUG ("Attempting to open uri %s", uri);
451 
452  success = gtk_show_uri_on_window (NULL, uri, gtk_get_current_event_time (), &error);
453 
454  if (success)
455  return;
456 
457  g_assert (error != NULL);
458  {
459  gchar *error_uri = NULL;
460  const gchar *message =
461  _("GnuCash could not open the linked document:");
462 
463  if (gnc_uri_is_file_uri (uri))
464  {
465  gchar *uri_scheme = gnc_uri_get_scheme (uri);
466  error_uri = gnc_doclink_get_unescape_uri (NULL, uri, uri_scheme);
467  g_free (uri_scheme);
468  }
469  else
470  error_uri = g_strdup (uri);
471 
472  gnc_error_dialog (parent, "%s\n%s", message, error_uri);
473  g_free (error_uri);
474  }
475  PERR ("%s", error->message);
476  g_error_free (error);
477 }
478 
479 #endif
480 
481 /********************************************************************\
482  * gnc_gnome_get_pixmap *
483  * returns a GtkWidget given a pixmap filename *
484  * *
485  * Args: none *
486  * Returns: GtkWidget or NULL if there was a problem *
487  \*******************************************************************/
488 GtkWidget *
489 gnc_gnome_get_pixmap (const char *name)
490 {
491  GtkWidget *pixmap;
492  char *fullname;
493 
494  g_return_val_if_fail (name != NULL, NULL);
495 
496  fullname = gnc_filepath_locate_pixmap (name);
497  if (fullname == NULL)
498  return NULL;
499 
500  DEBUG ("Loading pixmap file %s", fullname);
501 
502  pixmap = gtk_image_new_from_file (fullname);
503  if (pixmap == NULL)
504  {
505  PERR ("Could not load pixmap");
506  }
507  g_free (fullname);
508 
509  return pixmap;
510 }
511 
512 /********************************************************************\
513  * gnc_gnome_get_gdkpixbuf *
514  * returns a GdkImlibImage object given a pixmap filename *
515  * *
516  * Args: none *
517  * Returns: GdkPixbuf or NULL if there was a problem *
518  \*******************************************************************/
519 GdkPixbuf *
520 gnc_gnome_get_gdkpixbuf (const char *name)
521 {
522  GdkPixbuf *pixbuf;
523  GError *error = NULL;
524  char *fullname;
525 
526  g_return_val_if_fail (name != NULL, NULL);
527 
528  fullname = gnc_filepath_locate_pixmap (name);
529  if (fullname == NULL)
530  return NULL;
531 
532  DEBUG ("Loading pixbuf file %s", fullname);
533  pixbuf = gdk_pixbuf_new_from_file (fullname, &error);
534  if (error != NULL)
535  {
536  g_assert (pixbuf == NULL);
537  PERR ("Could not load pixbuf: %s", error->message);
538  g_error_free (error);
539  }
540  g_free (fullname);
541 
542  return pixbuf;
543 }
544 
545 static gboolean
546 gnc_ui_check_events (gpointer not_used)
547 {
548  QofSession *session;
549  gboolean force;
550 
551  if (gtk_main_level() != 1)
552  return TRUE;
553 
554  if (!gnc_current_session_exist())
555  return TRUE;
556  session = gnc_get_current_session ();
557 
558  if (gnc_gui_refresh_suspended ())
559  return TRUE;
560 
561  if (!qof_session_events_pending (session))
562  return TRUE;
563 
564  gnc_suspend_gui_refresh ();
565 
566  force = qof_session_process_events (session);
567 
568  gnc_resume_gui_refresh ();
569 
570  if (force)
571  gnc_gui_refresh_all ();
572 
573  return TRUE;
574 }
575 
576 
577 int
578 gnc_ui_start_event_loop (void)
579 {
580  guint id;
581 
582  gnome_is_running = TRUE;
583 
584  id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 10000, /* 10 secs */
585  gnc_ui_check_events, NULL, NULL);
586 
587  scm_call_1(scm_c_eval_string("gnc:set-ui-status"), SCM_BOOL_T);
588 
589  /* Enter gnome event loop */
590  gtk_main ();
591 
592  g_source_remove (id);
593 
594  scm_call_1(scm_c_eval_string("gnc:set-ui-status"), SCM_BOOL_F);
595 
596  gnome_is_running = FALSE;
597  gnome_is_terminating = FALSE;
598 
599  return 0;
600 }
601 
602 GncMainWindow *
603 gnc_gui_init(void)
604 {
605  static GncMainWindow *main_window;
606  gchar *map;
607 
608  ENTER ("");
609 
610  if (gnome_is_initialized)
611  return main_window;
612 
613  /* use custom icon */
614  gnc_load_app_icons();
615  gtk_window_set_default_icon_name(GNC_ICON_APP);
616 
617  g_set_application_name(PACKAGE_NAME);
618 
619  gnc_prefs_init();
620  gnc_show_splash_screen();
621 
622  gnome_is_initialized = TRUE;
623 
624  gnc_ui_util_init();
625  gnc_configure_date_format();
626  gnc_configure_date_completion();
627 
628  gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
629  GNC_PREF_DATE_FORMAT,
630  gnc_configure_date_format,
631  NULL);
632  gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
633  GNC_PREF_DATE_COMPL_THISYEAR,
634  gnc_configure_date_completion,
635  NULL);
636  gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
637  GNC_PREF_DATE_COMPL_SLIDING,
638  gnc_configure_date_completion,
639  NULL);
640  gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
641  GNC_PREF_DATE_BACKMONTHS,
642  gnc_configure_date_completion,
643  NULL);
644  gnc_prefs_register_group_cb (GNC_PREFS_GROUP_GENERAL,
645  gnc_gui_refresh_all,
646  NULL);
647 
648  gnc_file_set_shutdown_callback (gnc_shutdown);
649 
650  main_window = gnc_main_window_new ();
651  // Bug#350993:
652  // gtk_widget_show (GTK_WIDGET (main_window));
653  gnc_window_set_progressbar_window (GNC_WINDOW(main_window));
654 
655 
656  map = gnc_build_userdata_path(ACCEL_MAP_NAME);
657  if (!g_file_test (map, G_FILE_TEST_EXISTS))
658  {
659  gchar *text = NULL;
660  gsize length;
661  gchar *map_source;
662  gchar *data_dir = gnc_path_get_pkgdatadir();
663 #ifdef MAC_INTEGRATION
664  map_source = g_build_filename (data_dir, "ui", "accelerator-map-osx", NULL);
665 #else
666  map_source = g_build_filename (data_dir, "ui", "accelerator-map", NULL);
667 #endif /* MAC_INTEGRATION */
668 
669  if (map_source && g_file_get_contents (map_source, &text, &length, NULL))
670  {
671  if (length)
672  g_file_set_contents (map, text, length, NULL);
673  g_free (text);
674  }
675  g_free (map_source);
676  g_free(data_dir);
677  }
678 
679  gtk_accel_map_load(map);
680  g_free(map);
681 
682  /* Load css configuration file */
683  gnc_add_css_file ();
684 
685  gnc_totd_dialog (gnc_get_splash_screen (), TRUE);
686 
687  LEAVE ("");
688  return main_window;
689 }
690 
691 gboolean
692 gnucash_ui_is_running(void)
693 {
694  return gnome_is_running;
695 }
696 
697 static void
698 gnc_gui_destroy (void)
699 {
700  if (!gnome_is_initialized)
701  return;
702 
703  if (gnc_prefs_is_set_up())
704  {
705  gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
706  GNC_PREF_DATE_FORMAT,
707  gnc_configure_date_format,
708  NULL);
709  gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
710  GNC_PREF_DATE_COMPL_THISYEAR,
711  gnc_configure_date_completion,
712  NULL);
713  gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
714  GNC_PREF_DATE_COMPL_SLIDING,
715  gnc_configure_date_completion,
716  NULL);
717  gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
718  GNC_PREF_DATE_BACKMONTHS,
719  gnc_configure_date_completion,
720  NULL);
721  gnc_prefs_remove_group_cb_by_func (GNC_PREFS_GROUP_GENERAL,
722  gnc_gui_refresh_all,
723  NULL);
724 
725  gnc_ui_util_remove_registered_prefs ();
726  gnc_prefs_remove_registered ();
727  }
728  gnc_extensions_shutdown ();
729 }
730 
731 static void
732 gnc_gui_shutdown (void)
733 {
734 // gchar *map;
735 
736  if (gnome_is_running && !gnome_is_terminating)
737  {
738  gnome_is_terminating = TRUE;
739 // map = gnc_build_userdata_path(ACCEL_MAP_NAME);
740 // gtk_accel_map_save(map);
741 // g_free(map);
742  gnc_component_manager_shutdown ();
743  gtk_main_quit();
744  }
745 }
746 
747 /* shutdown gnucash. This function will initiate an orderly
748  * shutdown, and when that has finished it will exit the program.
749  */
750 void
751 gnc_shutdown (int exit_status)
752 {
753  if (gnucash_ui_is_running())
754  {
755  if (!gnome_is_terminating)
756  {
757  if (gnc_file_query_save (gnc_ui_get_main_window (NULL), FALSE))
758  {
759  gnc_hook_run(HOOK_UI_SHUTDOWN, NULL);
760  gnc_gui_shutdown();
761  }
762  }
763  }
764  else
765  {
766  gnc_gui_destroy();
767  gnc_hook_run(HOOK_SHUTDOWN, NULL);
768  gnc_engine_shutdown();
769  exit(exit_status);
770  }
771 }
772 
QofDateCompletion
Enum for date completion modes (for dates entered without year)
Definition: gnc-date.h:138
utility functions for the GnuCash UI
Functions that are supported by all types of windows.
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:244
void qof_date_completion_set(QofDateCompletion dc, int backmonths)
The qof_date_completion_set() routing sets the date completion method to one of QOF_DATE_COMPLETION_T...
Definition: gnc-date.cpp:468
gint gnc_prefs_get_int(const gchar *group, const gchar *pref_name)
Get an integer value from the preferences backend.
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250
use sliding 12-month window
Definition: gnc-date.h:141
void gnc_gnome_help(GtkWindow *parent, const char *file_name, const char *anchor)
Launch the systems default help browser, gnome&#39;s yelp for linux, and open to a given link within a gi...
Preferences initialization function.
Gnome specific utility functions.
Definition: init.py:1
void gnc_add_css_file(void)
Load a gtk resource configuration file to customize gtk appearance and behaviour. ...
All type declarations for the whole Gnucash engine.
void gnc_gnome_utils_init(void)
Initialize the gnome-utils library Should be run once before using any gnome-utils features...
Generic api to store and retrieve preferences.
const gchar * gnc_userconfig_dir(void)
Return the user&#39;s config directory for gnucash.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
Utility functions for convert uri in separate components and back.
use current year
Definition: gnc-date.h:140
File path resolution utility functions.
Take from locale information.
Definition: gnc-date.h:128
void qof_date_format_set(QofDateFormat df)
The qof_date_format_set() routine sets date format to one of US, UK, CE, OR ISO.
Definition: gnc-date.cpp:433
QofDateFormat
Enum for determining a date format.
Definition: gnc-date.h:122
"select" and "new" commodity windows
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Get an float value from the preferences backend.