1999-01-20 06:02:12 +00:00
|
|
|
/********************************************************************\
|
1999-10-24 21:31:35 +00:00
|
|
|
* top-level.c -- Gnome GUI main for GnuCash *
|
1998-11-24 07:10:22 +00:00
|
|
|
* Copyright (C) 1997 Robin D. Clark *
|
2000-03-01 10:09:57 +00:00
|
|
|
* Copyright (C) 1998-2000 Linas Vepstas *
|
1998-11-24 07:10:22 +00:00
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
|
* published by the Free Software Foundation; either version 2 of *
|
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License*
|
2000-04-27 05:34:38 +00:00
|
|
|
* along with this program; if not, contact: *
|
|
|
|
|
* *
|
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
2005-11-17 05:35:02 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
1998-11-24 07:10:22 +00:00
|
|
|
* *
|
|
|
|
|
\********************************************************************/
|
|
|
|
|
|
2000-11-01 08:52:30 +00:00
|
|
|
#include "config.h"
|
2000-01-10 03:33:23 +00:00
|
|
|
|
2005-11-19 23:53:34 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
#include <glib/gi18n.h>
|
2003-02-22 08:15:53 +00:00
|
|
|
#include <libguile.h>
|
2000-12-11 23:05:54 +00:00
|
|
|
#include <popt.h>
|
2000-12-09 08:17:55 +00:00
|
|
|
#include <stdlib.h>
|
2002-01-09 21:51:25 +00:00
|
|
|
#include <g-wrap-wct.h>
|
2001-06-02 09:56:54 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
|
1999-01-20 06:02:12 +00:00
|
|
|
#include "TransLog.h"
|
2000-12-09 08:17:55 +00:00
|
|
|
#include "combocell.h"
|
2003-10-24 06:49:56 +00:00
|
|
|
#include "dialog-account.h"
|
2001-09-14 07:01:40 +00:00
|
|
|
#include "dialog-commodity.h"
|
2001-09-26 08:32:29 +00:00
|
|
|
#include "dialog-options.h"
|
2005-11-02 03:32:36 +00:00
|
|
|
#include "dialog-scheduledxaction.h"
|
2000-12-09 08:17:55 +00:00
|
|
|
#include "dialog-transfer.h"
|
2005-11-02 03:32:36 +00:00
|
|
|
#include "dialog-totd.h"
|
|
|
|
|
#include "druid-hierarchy.h"
|
2001-09-12 21:03:58 +00:00
|
|
|
#include "file-utils.h"
|
2000-12-09 08:17:55 +00:00
|
|
|
#include "gnc-component-manager.h"
|
2005-11-02 03:32:36 +00:00
|
|
|
#include "gnc-engine.h"
|
|
|
|
|
#include "gnc-gconf-utils.h"
|
2001-09-20 02:38:15 +00:00
|
|
|
#include "gnc-file.h"
|
2005-11-23 23:28:44 +00:00
|
|
|
#include "gnc-filepath-utils.h"
|
2005-11-02 03:32:36 +00:00
|
|
|
#include "gnc-hooks.h"
|
|
|
|
|
#include "gnc-main-window.h"
|
2001-09-10 07:01:57 +00:00
|
|
|
#include "gnc-menu-extensions.h"
|
2005-11-02 03:32:36 +00:00
|
|
|
#include "gnc-plugin-menu-additions.h" /* FIXME Remove this line*/
|
|
|
|
|
#include "gnc-plugin-account-tree.h" /* FIXME Remove this line*/
|
|
|
|
|
#include "gnc-plugin-basic-commands.h" /* FIXME Remove this line*/
|
|
|
|
|
#include "gnc-plugin-file-history.h" /* FIXME Remove this line*/
|
|
|
|
|
#include "gnc-plugin-register.h" /* FIXME Remove this line*/
|
|
|
|
|
#include "gnc-plugin-budget.h"
|
|
|
|
|
#include "gnc-plugin-page-register.h"
|
|
|
|
|
#include "gnc-plugin-manager.h" /* FIXME Remove this line*/
|
|
|
|
|
#include "gnc-icons.h" /* FIXME Remove this line*/
|
2001-09-10 07:01:57 +00:00
|
|
|
#include "gnc-splash.h"
|
2001-09-12 21:03:58 +00:00
|
|
|
#include "gnc-html.h"
|
2001-12-21 07:43:12 +00:00
|
|
|
#include "gnc-gnome-utils.h"
|
2001-03-08 00:37:13 +00:00
|
|
|
#include "gnc-gpg.h"
|
2001-09-12 21:03:58 +00:00
|
|
|
#include "gnc-report.h"
|
2002-11-15 08:26:43 +00:00
|
|
|
#include "gnc-split-reg.h"
|
2000-12-09 08:17:55 +00:00
|
|
|
#include "gnc-ui.h"
|
2005-11-02 03:32:36 +00:00
|
|
|
#include "gnc-ui-util.h"
|
2000-12-09 08:17:55 +00:00
|
|
|
#include "gnucash-color.h"
|
|
|
|
|
#include "gnucash-sheet.h"
|
|
|
|
|
#include "gnucash-style.h"
|
2000-05-17 11:08:49 +00:00
|
|
|
#include "guile-util.h"
|
2001-04-13 06:41:45 +00:00
|
|
|
#include "top-level.h"
|
2000-12-09 08:17:55 +00:00
|
|
|
#include "window-report.h"
|
1999-11-10 16:28:05 +00:00
|
|
|
|
1998-11-24 07:10:22 +00:00
|
|
|
|
2005-11-23 23:28:44 +00:00
|
|
|
#define ACCEL_MAP_NAME "accelerator-map"
|
|
|
|
|
|
1998-11-24 07:10:22 +00:00
|
|
|
/** PROTOTYPES ******************************************************/
|
1999-12-31 00:05:41 +00:00
|
|
|
static void gnc_configure_date_format(void);
|
2000-06-28 21:24:28 +00:00
|
|
|
|
2001-03-04 11:14:17 +00:00
|
|
|
|
1998-11-24 07:10:22 +00:00
|
|
|
/** GLOBALS *********************************************************/
|
1999-03-01 04:48:33 +00:00
|
|
|
/* This static indicates the debugging module that this .o belongs to. */
|
2005-11-02 03:32:36 +00:00
|
|
|
static QofLogModule log_module = GNC_MOD_GUI;
|
1998-11-24 07:10:22 +00:00
|
|
|
|
1999-10-18 03:05:47 +00:00
|
|
|
static int gnome_is_running = FALSE;
|
2002-09-14 18:10:42 +00:00
|
|
|
static int splash_is_initialized = FALSE;
|
1999-10-18 03:05:47 +00:00
|
|
|
static int gnome_is_initialized = FALSE;
|
|
|
|
|
static int gnome_is_terminating = FALSE;
|
|
|
|
|
|
2001-03-04 11:14:17 +00:00
|
|
|
|
2001-05-10 22:55:08 +00:00
|
|
|
gboolean
|
2000-09-13 22:33:15 +00:00
|
|
|
gnucash_ui_is_running(void)
|
2000-03-01 10:09:57 +00:00
|
|
|
{
|
1999-10-18 03:05:47 +00:00
|
|
|
return gnome_is_running;
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-10 22:55:08 +00:00
|
|
|
gboolean
|
2000-09-13 22:33:15 +00:00
|
|
|
gnucash_ui_is_terminating(void)
|
2000-03-01 10:09:57 +00:00
|
|
|
{
|
1999-10-18 03:05:47 +00:00
|
|
|
return gnome_is_terminating;
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-24 08:03:42 +00:00
|
|
|
static void
|
|
|
|
|
gnc_global_options_help_cb (GNCOptionWin *win, gpointer dat)
|
|
|
|
|
{
|
2005-11-02 03:32:36 +00:00
|
|
|
gnc_gnome_help (HF_CUSTOM, HL_GLOBPREFS);
|
2001-09-24 08:03:42 +00:00
|
|
|
}
|
|
|
|
|
|
2004-05-31 20:10:49 +00:00
|
|
|
static void
|
|
|
|
|
gnc_commodity_help_cb (void)
|
|
|
|
|
{
|
2005-11-02 03:32:36 +00:00
|
|
|
gnc_gnome_help (HF_USAGE, HL_COMMODITY);
|
2004-05-31 20:10:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ============================================================== */
|
|
|
|
|
/* HTML Hadler for reports. */
|
|
|
|
|
|
|
|
|
|
#define IF_TYPE(URL_TYPE_STR,ENTITY_TYPE) \
|
|
|
|
|
if (strncmp (URL_TYPE_STR, location, strlen (URL_TYPE_STR)) == 0) \
|
|
|
|
|
{ \
|
|
|
|
|
GUID guid; \
|
|
|
|
|
QofCollection *col; \
|
|
|
|
|
QofEntity *entity; \
|
|
|
|
|
if (!string_to_guid (location + strlen(URL_TYPE_STR), &guid)) \
|
|
|
|
|
{ \
|
|
|
|
|
result->error_message = g_strdup_printf (_("Bad URL: %s"), location); \
|
|
|
|
|
return FALSE; \
|
|
|
|
|
} \
|
|
|
|
|
col = qof_book_get_collection (book, ENTITY_TYPE); \
|
|
|
|
|
entity = qof_collection_lookup_entity (col, &guid); \
|
|
|
|
|
if (NULL == entity) \
|
|
|
|
|
{ \
|
|
|
|
|
result->error_message = g_strdup_printf (_("Entity Not Found: %s"), location); \
|
|
|
|
|
return FALSE; \
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
|
|
|
2001-09-13 08:28:12 +00:00
|
|
|
static gboolean
|
|
|
|
|
gnc_html_register_url_cb (const char *location, const char *label,
|
|
|
|
|
gboolean new_window, GNCURLResult *result)
|
|
|
|
|
{
|
2005-11-02 03:32:36 +00:00
|
|
|
GncPluginPage *page = NULL;
|
2002-11-15 08:26:43 +00:00
|
|
|
GNCSplitReg * gsr = NULL;
|
2001-09-13 08:28:12 +00:00
|
|
|
Split * split = NULL;
|
2004-05-31 20:10:49 +00:00
|
|
|
Account * account = NULL;
|
2001-09-13 08:28:12 +00:00
|
|
|
Transaction * trans;
|
|
|
|
|
GList * node;
|
2004-05-31 20:10:49 +00:00
|
|
|
QofBook * book = gnc_get_current_book();
|
2001-09-13 08:28:12 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (location != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (result != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
result->load_to_stream = FALSE;
|
|
|
|
|
|
|
|
|
|
/* href="gnc-register:account=My Bank Account" */
|
|
|
|
|
if (strncmp("account=", location, 8) == 0)
|
|
|
|
|
{
|
2001-09-20 02:38:15 +00:00
|
|
|
account = xaccGetAccountFromFullName (gnc_get_current_group (),
|
2001-09-13 08:28:12 +00:00
|
|
|
location + 8,
|
|
|
|
|
gnc_get_account_separator ());
|
|
|
|
|
}
|
2004-05-31 20:10:49 +00:00
|
|
|
|
2001-09-13 08:28:12 +00:00
|
|
|
/* href="gnc-register:guid=12345678901234567890123456789012" */
|
2004-05-31 20:10:49 +00:00
|
|
|
else IF_TYPE ("acct-guid=", GNC_ID_ACCOUNT)
|
|
|
|
|
account = GNC_ACCOUNT(entity);
|
|
|
|
|
}
|
2001-09-13 08:28:12 +00:00
|
|
|
|
2004-05-31 20:10:49 +00:00
|
|
|
else IF_TYPE ("trans-guid=", GNC_ID_TRANS)
|
|
|
|
|
trans = (Transaction *) entity;
|
2001-09-13 08:28:12 +00:00
|
|
|
|
2004-05-31 20:10:49 +00:00
|
|
|
for (node = xaccTransGetSplitList (trans); node; node = node->next)
|
2001-11-25 02:20:34 +00:00
|
|
|
{
|
2004-05-31 20:10:49 +00:00
|
|
|
split = node->data;
|
|
|
|
|
account = xaccSplitGetAccount(split);
|
|
|
|
|
if (account) break;
|
2001-11-25 02:20:34 +00:00
|
|
|
}
|
2004-05-31 20:10:49 +00:00
|
|
|
|
|
|
|
|
if (!account)
|
2001-11-25 02:20:34 +00:00
|
|
|
{
|
2004-05-31 20:10:49 +00:00
|
|
|
result->error_message =
|
|
|
|
|
g_strdup_printf (_("Transaction with no Accounts: %s"), location);
|
|
|
|
|
return FALSE;
|
2001-09-13 08:28:12 +00:00
|
|
|
}
|
2004-05-31 20:10:49 +00:00
|
|
|
}
|
|
|
|
|
else IF_TYPE ("split-guid=", GNC_ID_SPLIT)
|
|
|
|
|
split = (Split *) entity;
|
|
|
|
|
account = xaccSplitGetAccount(split);
|
2001-09-13 08:28:12 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-05-31 20:10:49 +00:00
|
|
|
result->error_message =
|
|
|
|
|
g_strdup_printf (_("Unsupported entity type: %s"), location);
|
2001-09-13 08:28:12 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-02 03:32:36 +00:00
|
|
|
page = gnc_plugin_page_register_new (account, FALSE);
|
|
|
|
|
gnc_main_window_open_page (NULL, page);
|
|
|
|
|
if (split) {
|
|
|
|
|
gsr = gnc_plugin_page_register_get_gsr(page);
|
2004-05-31 20:10:49 +00:00
|
|
|
gnc_split_reg_jump_to_split( gsr, split );
|
2005-11-02 03:32:36 +00:00
|
|
|
}
|
2004-05-31 20:10:49 +00:00
|
|
|
|
2001-09-13 08:28:12 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-31 20:10:49 +00:00
|
|
|
/* ============================================================== */
|
|
|
|
|
|
2002-05-07 03:36:11 +00:00
|
|
|
static gboolean
|
|
|
|
|
gnc_html_price_url_cb (const char *location, const char *label,
|
2004-05-31 20:10:49 +00:00
|
|
|
gboolean new_window, GNCURLResult *result)
|
2002-05-07 03:36:11 +00:00
|
|
|
{
|
2004-05-31 20:10:49 +00:00
|
|
|
QofBook * book = gnc_get_current_book();
|
2002-05-07 03:36:11 +00:00
|
|
|
g_return_val_if_fail (location != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (result != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
result->load_to_stream = FALSE;
|
|
|
|
|
|
|
|
|
|
/* href="gnc-register:guid=12345678901234567890123456789012" */
|
2004-05-31 20:10:49 +00:00
|
|
|
IF_TYPE ("price-guid=", GNC_ID_PRICE)
|
|
|
|
|
if (!gnc_price_edit_by_guid (NULL, &guid))
|
|
|
|
|
{
|
|
|
|
|
result->error_message = g_strdup_printf (_("No such price: %s"),
|
|
|
|
|
location);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2002-05-07 03:36:11 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result->error_message = g_strdup_printf (_("Badly formed URL %s"),
|
2004-05-31 20:10:49 +00:00
|
|
|
location);
|
2002-05-07 03:36:11 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-18 03:05:47 +00:00
|
|
|
/* ============================================================== */
|
|
|
|
|
|
2002-09-14 18:10:42 +00:00
|
|
|
SCM
|
|
|
|
|
gnc_gui_init_splash (SCM command_line)
|
|
|
|
|
{
|
|
|
|
|
SCM ret = command_line;
|
|
|
|
|
|
|
|
|
|
ENTER (" ");
|
|
|
|
|
|
|
|
|
|
if (!splash_is_initialized)
|
|
|
|
|
{
|
|
|
|
|
splash_is_initialized = TRUE;
|
|
|
|
|
|
|
|
|
|
ret = gnc_gnome_init ("gnucash", "GnuCash", VERSION, command_line);
|
|
|
|
|
|
|
|
|
|
/* put up splash screen */
|
|
|
|
|
gnc_show_splash_screen ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LEAVE (" ");
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-21 07:43:12 +00:00
|
|
|
SCM
|
|
|
|
|
gnc_gui_init (SCM command_line)
|
1998-11-24 07:10:22 +00:00
|
|
|
{
|
2001-12-21 07:43:12 +00:00
|
|
|
SCM ret = command_line;
|
2005-11-02 03:32:36 +00:00
|
|
|
GncMainWindow *main_window;
|
2005-11-23 23:28:44 +00:00
|
|
|
gchar *map;
|
2001-03-29 12:38:38 +00:00
|
|
|
|
2001-07-20 19:33:32 +00:00
|
|
|
ENTER (" ");
|
1999-10-18 03:05:47 +00:00
|
|
|
|
1999-10-24 21:31:35 +00:00
|
|
|
if (!gnome_is_initialized)
|
|
|
|
|
{
|
2002-09-14 18:10:42 +00:00
|
|
|
/* Make sure the splash (and hense gnome) was initialized */
|
|
|
|
|
if (!splash_is_initialized)
|
|
|
|
|
ret = gnc_gui_init_splash (ret);
|
|
|
|
|
|
1999-10-18 03:05:47 +00:00
|
|
|
gnome_is_initialized = TRUE;
|
2000-12-09 08:17:55 +00:00
|
|
|
|
2005-11-02 03:32:36 +00:00
|
|
|
gnc_ui_util_init();
|
1999-12-31 00:05:41 +00:00
|
|
|
gnc_configure_date_format();
|
2005-11-02 03:32:36 +00:00
|
|
|
gnc_gconf_general_register_cb(KEY_DATE_FORMAT,
|
|
|
|
|
(GncGconfGeneralCb)gnc_configure_date_format, NULL);
|
|
|
|
|
gnc_gconf_general_register_any_cb((GncGconfGeneralAnyCb)gnc_gui_refresh_all, NULL);
|
2000-06-28 21:24:28 +00:00
|
|
|
|
2002-09-14 23:27:39 +00:00
|
|
|
if (!gnucash_style_init())
|
|
|
|
|
gnc_shutdown(1);
|
1999-11-10 16:28:05 +00:00
|
|
|
gnucash_color_init();
|
2001-04-12 23:03:42 +00:00
|
|
|
|
2001-09-13 08:28:12 +00:00
|
|
|
gnc_html_register_url_handler (URL_TYPE_REGISTER,
|
|
|
|
|
gnc_html_register_url_cb);
|
2001-09-14 07:01:40 +00:00
|
|
|
|
2002-05-07 03:36:11 +00:00
|
|
|
gnc_html_register_url_handler (URL_TYPE_PRICE,
|
|
|
|
|
gnc_html_price_url_cb);
|
|
|
|
|
|
2001-09-14 07:01:40 +00:00
|
|
|
gnc_ui_commodity_set_help_callback (gnc_commodity_help_cb);
|
|
|
|
|
|
2002-09-26 03:33:31 +00:00
|
|
|
gnc_file_set_shutdown_callback (gnc_shutdown);
|
2001-09-24 07:22:02 +00:00
|
|
|
|
2001-09-24 08:03:42 +00:00
|
|
|
gnc_options_dialog_set_global_help_cb (gnc_global_options_help_cb, NULL);
|
|
|
|
|
|
2005-11-02 03:32:36 +00:00
|
|
|
gnc_totd_dialog(NULL, TRUE);
|
|
|
|
|
gnc_ui_sx_initialize();
|
|
|
|
|
|
|
|
|
|
main_window = gnc_main_window_new ();
|
|
|
|
|
gtk_widget_show (GTK_WIDGET (main_window));
|
|
|
|
|
|
2005-11-23 23:28:44 +00:00
|
|
|
map = gnc_build_dotgnucash_path(ACCEL_MAP_NAME);
|
|
|
|
|
gtk_accel_map_load(map);
|
|
|
|
|
g_free(map);
|
|
|
|
|
|
2005-11-02 03:32:36 +00:00
|
|
|
/* FIXME Remove this test code */
|
|
|
|
|
gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), gnc_plugin_account_tree_new ());
|
|
|
|
|
gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), gnc_plugin_basic_commands_new ());
|
|
|
|
|
gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), gnc_plugin_file_history_new ());
|
|
|
|
|
gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), gnc_plugin_menu_additions_new ());
|
|
|
|
|
gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), gnc_plugin_register_new ());
|
|
|
|
|
/* I'm not sure why the FIXME note says to remove this. Maybe
|
|
|
|
|
each module should be adding its own plugin to the manager?
|
|
|
|
|
Anyway... Oh, maybe... nah */
|
|
|
|
|
gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (),
|
|
|
|
|
gnc_plugin_budget_new ());
|
|
|
|
|
gnc_load_stock_icons ();
|
|
|
|
|
gnc_ui_hierarchy_druid_initialize();
|
2001-09-25 10:06:33 +00:00
|
|
|
|
2001-04-12 23:03:42 +00:00
|
|
|
/* Run the ui startup hooks. */
|
2005-11-02 03:32:36 +00:00
|
|
|
gnc_hook_run(HOOK_UI_STARTUP, NULL);
|
|
|
|
|
|
|
|
|
|
// return ( main_window . command_line )
|
2001-04-12 23:03:42 +00:00
|
|
|
{
|
2005-11-02 03:32:36 +00:00
|
|
|
SCM gncMainWindowType;
|
|
|
|
|
gncMainWindowType = scm_c_eval_string("<gnc:MainWindow*>");
|
|
|
|
|
ret = scm_cons( gw_wcp_assimilate_ptr(main_window, gncMainWindowType), ret );
|
|
|
|
|
}
|
1999-10-18 03:05:47 +00:00
|
|
|
}
|
|
|
|
|
|
2001-07-20 19:33:32 +00:00
|
|
|
LEAVE (" ");
|
1999-10-18 03:05:47 +00:00
|
|
|
|
2001-12-21 07:43:12 +00:00
|
|
|
return ret;
|
1998-11-24 07:10:22 +00:00
|
|
|
}
|
|
|
|
|
|
1999-10-18 03:05:47 +00:00
|
|
|
/* ============================================================== */
|
|
|
|
|
|
|
|
|
|
void
|
2001-12-21 07:43:12 +00:00
|
|
|
gnc_gui_shutdown (void)
|
1999-10-18 03:05:47 +00:00
|
|
|
{
|
2005-11-23 23:28:44 +00:00
|
|
|
gchar *map;
|
|
|
|
|
|
1999-11-22 05:15:30 +00:00
|
|
|
if (gnome_is_running && !gnome_is_terminating)
|
|
|
|
|
{
|
1999-10-18 03:05:47 +00:00
|
|
|
gnome_is_terminating = TRUE;
|
2001-09-25 10:06:33 +00:00
|
|
|
|
2005-11-23 23:28:44 +00:00
|
|
|
map = gnc_build_dotgnucash_path(ACCEL_MAP_NAME);
|
|
|
|
|
gtk_accel_map_save(map);
|
|
|
|
|
g_free(map);
|
|
|
|
|
|
1999-10-18 03:05:47 +00:00
|
|
|
gtk_main_quit();
|
2001-09-25 10:06:33 +00:00
|
|
|
|
2001-12-21 07:43:12 +00:00
|
|
|
gnc_gnome_shutdown ();
|
1999-10-18 03:05:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ============================================================== */
|
|
|
|
|
|
|
|
|
|
void
|
2001-12-21 07:43:12 +00:00
|
|
|
gnc_gui_destroy (void)
|
1999-10-18 03:05:47 +00:00
|
|
|
{
|
|
|
|
|
if (!gnome_is_initialized)
|
|
|
|
|
return;
|
|
|
|
|
|
2000-12-09 08:17:55 +00:00
|
|
|
gnc_extensions_shutdown ();
|
1999-10-18 03:05:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ============================================================== */
|
|
|
|
|
|
2001-03-07 11:18:01 +00:00
|
|
|
static gboolean
|
|
|
|
|
gnc_ui_check_events (gpointer not_used)
|
|
|
|
|
{
|
2003-06-27 02:53:07 +00:00
|
|
|
QofSession *session;
|
2001-03-07 11:18:01 +00:00
|
|
|
gboolean force;
|
|
|
|
|
|
|
|
|
|
if (gtk_main_level() != 1)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-27 02:53:07 +00:00
|
|
|
session = qof_session_get_current_session ();
|
2001-10-02 09:10:35 +00:00
|
|
|
if (!session)
|
2001-03-07 11:18:01 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (gnc_gui_refresh_suspended ())
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-27 02:53:07 +00:00
|
|
|
if (!qof_session_events_pending (session))
|
2001-03-07 11:18:01 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
gnc_suspend_gui_refresh ();
|
|
|
|
|
|
2003-06-27 02:53:07 +00:00
|
|
|
force = qof_session_process_events (session);
|
2001-03-07 11:18:01 +00:00
|
|
|
|
|
|
|
|
gnc_resume_gui_refresh ();
|
|
|
|
|
|
|
|
|
|
if (force)
|
|
|
|
|
gnc_gui_refresh_all ();
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-02 09:56:54 +00:00
|
|
|
static int
|
2004-05-31 20:10:49 +00:00
|
|
|
gnc_x_error (Display *display, XErrorEvent *error)
|
2001-06-02 09:56:54 +00:00
|
|
|
{
|
|
|
|
|
if (error->error_code)
|
|
|
|
|
{
|
|
|
|
|
char buf[64];
|
|
|
|
|
|
|
|
|
|
XGetErrorText (display, error->error_code, buf, 63);
|
|
|
|
|
|
|
|
|
|
g_warning ("X-ERROR **: %s\n serial %ld error_code %d "
|
|
|
|
|
"request_code %d minor_code %d\n",
|
|
|
|
|
buf,
|
|
|
|
|
error->serial,
|
|
|
|
|
error->error_code,
|
|
|
|
|
error->request_code,
|
|
|
|
|
error->minor_code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2001-01-11 22:32:22 +00:00
|
|
|
int
|
2001-03-07 11:18:01 +00:00
|
|
|
gnc_ui_start_event_loop (void)
|
2001-01-11 22:32:22 +00:00
|
|
|
{
|
2001-03-07 11:18:01 +00:00
|
|
|
guint id;
|
|
|
|
|
|
2001-01-11 22:32:22 +00:00
|
|
|
gnome_is_running = TRUE;
|
2000-09-18 00:14:46 +00:00
|
|
|
|
2001-06-03 01:43:22 +00:00
|
|
|
id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 10000, /* 10 secs */
|
2001-03-07 11:18:01 +00:00
|
|
|
gnc_ui_check_events, NULL, NULL);
|
|
|
|
|
|
2001-06-02 09:56:54 +00:00
|
|
|
XSetErrorHandler (gnc_x_error);
|
|
|
|
|
|
1998-11-24 07:10:22 +00:00
|
|
|
/* Enter gnome event loop */
|
2001-03-07 11:18:01 +00:00
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
|
|
g_source_remove (id);
|
1998-11-24 07:10:22 +00:00
|
|
|
|
1999-10-18 03:05:47 +00:00
|
|
|
gnome_is_running = FALSE;
|
|
|
|
|
gnome_is_terminating = FALSE;
|
|
|
|
|
|
1998-11-24 07:10:22 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-18 03:05:47 +00:00
|
|
|
/* ============================================================== */
|
1999-01-20 06:02:12 +00:00
|
|
|
|
1999-12-31 00:05:41 +00:00
|
|
|
/* gnc_configure_date_format
|
|
|
|
|
* sets dateFormat to the current value on the scheme side
|
2000-03-01 10:09:57 +00:00
|
|
|
*
|
1999-12-31 00:05:41 +00:00
|
|
|
* Args: Nothing
|
|
|
|
|
* Returns: Nothing
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
gnc_configure_date_format (void)
|
|
|
|
|
{
|
2005-11-02 03:32:36 +00:00
|
|
|
char *format_code = gnc_gconf_get_string(GCONF_GENERAL, KEY_DATE_FORMAT, NULL);
|
|
|
|
|
|
|
|
|
|
QofDateFormat df;
|
1999-12-31 00:05:41 +00:00
|
|
|
|
2005-11-02 03:32:36 +00:00
|
|
|
if (format_code == NULL)
|
|
|
|
|
format_code = g_strdup("locale");
|
|
|
|
|
if (*format_code == '\0') {
|
|
|
|
|
g_free(format_code);
|
|
|
|
|
format_code = g_strdup("locale");
|
|
|
|
|
}
|
1999-12-31 00:05:41 +00:00
|
|
|
|
2003-06-09 03:42:52 +00:00
|
|
|
if (gnc_date_string_to_dateformat(format_code, &df))
|
1999-12-31 00:05:41 +00:00
|
|
|
{
|
|
|
|
|
PERR("Incorrect date format code");
|
2003-06-09 03:42:52 +00:00
|
|
|
if (format_code != NULL)
|
|
|
|
|
free(format_code);
|
1999-12-31 00:05:41 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-02 03:32:36 +00:00
|
|
|
qof_date_format_set(df);
|
2000-02-07 05:27:35 +00:00
|
|
|
|
|
|
|
|
if (format_code != NULL)
|
|
|
|
|
free(format_code);
|
1999-12-31 00:05:41 +00:00
|
|
|
}
|
|
|
|
|
|
1998-11-24 07:10:22 +00:00
|
|
|
/****************** END OF FILE **********************/
|