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