GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Files | Functions
Gnome-specific GUI handling.

Files

file  gnc-gnome-utils.h
 Gnome specific utility functions.
 

Functions

void gnc_gtk_add_rc_file (void)
 
void gnc_gnome_help (const char *file_name, const char *anchor)
 
void gnc_launch_assoc (const char *uri)
 
void gnc_options_dialog_set_book_options_help_cb (GNCOptionWin *win)
 
void gnc_options_dialog_set_new_book_option_values (GNCOptionDB *odb)
 
GtkWidget * gnc_gnome_get_pixmap (const char *name)
 
GdkPixbuf * gnc_gnome_get_gdkpixbuf (const char *name)
 
void gnc_shutdown (int exit_status)
 
GncMainWindowgnc_gui_init (void)
 
int gnc_ui_start_event_loop (void)
 
gboolean gnucash_ui_is_running (void)
 

Detailed Description

Function Documentation

GdkPixbuf* gnc_gnome_get_gdkpixbuf ( const char *  name)

Given a file name, find and load the requested pixbuf. This routine will display an error message if it can't find the file or load the pixbuf.

Parameters
nameThe name of the pixbuf file to load.
Returns
A pointer to the pixbuf, or NULL of the file couldn't be found or loaded..

Definition at line 514 of file gnc-gnome-utils.c.

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 }
#define DEBUG(format, args...)
Definition: qoflog.h:255
#define PERR(format, args...)
Definition: qoflog.h:237
gchar * gnc_filepath_locate_pixmap(const gchar *name)
GtkWidget* gnc_gnome_get_pixmap ( const char *  name)

Given a file name, find and load the requested pixmap. This routine will display an error message if it can't find the file or load the pixmap.

Parameters
nameThe name of the pixmap file to load.
Returns
A pointer to the pixmap, or NULL of the file couldn't be found or loaded..

Definition at line 483 of file gnc-gnome-utils.c.

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 }
#define DEBUG(format, args...)
Definition: qoflog.h:255
#define PERR(format, args...)
Definition: qoflog.h:237
gchar * gnc_filepath_locate_pixmap(const gchar *name)
void gnc_gnome_help ( const char *  file_name,
const char *  anchor 
)

Launch the default gnome help browser and open to a given link within a given file. This routine will display an error message if it can't find the help file or can't open the help browser.

Parameters
file_nameThe name of the help file.
anchorThe anchor the help browser should scroll to..
Returns
the full path name of the file, or NULL of the file can't be found.

Definition at line 371 of file gnc-gnome-utils.c.

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 }
#define DEBUG(format, args...)
Definition: qoflog.h:255
#define PERR(format, args...)
Definition: qoflog.h:237
void gnc_gtk_add_rc_file ( void  )

Load a gtk resource configuration file to customize gtk appearance and behviour.

Definition at line 173 of file gnc-gnome-utils.c.

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 }
GncMainWindow* gnc_gui_init ( void  )

Initialize the gnucash gui

Definition at line 619 of file gnc-gnome-utils.c.

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 }
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
Definition: gnc-prefs.c:128
void gnc_ui_commodity_set_help_callback(gnc_commodity_help_callback cb)
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 ENTER(format, args...)
Definition: qoflog.h:261
gchar * gnc_filepath_locate_pixmap(const gchar *name)
guint gnc_prefs_register_group_cb(const gchar *group, gpointer func, gpointer user_data)
Definition: gnc-prefs.c:166
GncMainWindow * gnc_main_window_new(void)
void gnc_prefs_init(void)
GdkPixbuf * gnc_gnome_get_gdkpixbuf(const char *name)
#define LEAVE(format, args...)
Definition: qoflog.h:271
void gnc_launch_assoc ( const char *  uri)

Launch the default gnome browser and open the provided URI.

Definition at line 450 of file gnc-gnome-utils.c.

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 }
#define DEBUG(format, args...)
Definition: qoflog.h:255
#define PERR(format, args...)
Definition: qoflog.h:237
void gnc_options_dialog_set_book_options_help_cb ( GNCOptionWin win)

Set the help callback to 'gnc_book_options_help_cb' to open a help browser and point it to the Book Options link in the Help file.

Definition at line 84 of file gnc-gnome-utils.c.

85 {
86  gnc_options_dialog_set_help_cb(win,
87  (GNCOptionWinCallback)gnc_book_options_help_cb,
88  NULL);
89 }
void gnc_options_dialog_set_new_book_option_values ( GNCOptionDB odb)

Set the intial values of new book options to values specified in user preferences.

Definition at line 92 of file gnc-gnome-utils.c.

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 }
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:196
void gnc_shutdown ( int  exit_status)

Shutdown gnucash. This function will initiate an orderly shutdown, and when that has finished it will exit the program.

Parameters
exit_statusThe exit status for the program.

Definition at line 767 of file gnc-gnome-utils.c.

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 }
void gnc_engine_shutdown(void)
Definition: gnc-engine.c:160