37 #include <glib/gi18n.h> 40 #include <gdk/gdkkeysyms.h> 46 #include "dialog-options.h" 48 #include "dialog-reset-warnings.h" 49 #include "dialog-transfer.h" 50 #include "dialog-utils.h" 51 #include "engine-helpers.h" 53 #include "gnc-component-manager.h" 54 #include "dialog-doclink-utils.h" 62 #include "gnc-gui-query.h" 64 #include "gnc-hooks.h" 65 #include "gnc-icons.h" 66 #include "gnc-session.h" 73 #include "gnc-warnings.h" 76 #include "option-util.h" 79 #include "gnc-autosave.h" 81 #ifdef MAC_INTEGRATION 82 #include <gtkmacintegration/gtkosxapplication.h> 84 #ifdef HAVE_SYS_STAT_H 85 # define __need_system_sys_stat_h //To block Guile-2.0's evil substitute 86 # include <sys/types.h> 87 # include <sys/stat.h> 100 #define PLUGIN_PAGE_LABEL "plugin-page" 102 #define PLUGIN_PAGE_CLOSE_BUTTON "close-button" 103 #define PLUGIN_PAGE_TAB_LABEL "label" 105 #define GNC_PREF_SHOW_CLOSE_BUTTON "tab-close-buttons" 106 #define GNC_PREF_TAB_NEXT_RECENT "tab-next-recent" 107 #define GNC_PREF_TAB_POSITION_TOP "tab-position-top" 108 #define GNC_PREF_TAB_POSITION_BOTTOM "tab-position-bottom" 109 #define GNC_PREF_TAB_POSITION_LEFT "tab-position-left" 110 #define GNC_PREF_TAB_POSITION_RIGHT "tab-position-right" 111 #define GNC_PREF_TAB_WIDTH "tab-width" 112 #define GNC_PREF_TAB_COLOR "show-account-color-tabs" 113 #define GNC_PREF_SAVE_CLOSE_EXPIRES "save-on-close-expires" 114 #define GNC_PREF_SAVE_CLOSE_WAIT_TIME "save-on-close-wait-time" 115 #define GNC_PREF_TAB_OPEN_ADJACENT "tab-open-adjacent" 117 #define GNC_MAIN_WINDOW_NAME "GncMainWindow" 119 #define DIALOG_BOOK_OPTIONS_CM_CLASS "dialog-book-options" 124 static QofLogModule log_module = GNC_MOD_GUI;
126 static GObjectClass *parent_class = NULL;
128 static GQuark window_type = 0;
131 static GList *active_windows = NULL;
134 static guint secs_to_save = 0;
135 #define MSG_AUTO_SAVE _("Changes will be saved automatically in %u seconds") 141 static void gnc_main_window_finalize (GObject *
object);
142 static void gnc_main_window_destroy (GtkWidget *widget);
144 static void gnc_main_window_setup_window (
GncMainWindow *window);
146 #ifndef MAC_INTEGRATION 147 static void gnc_main_window_update_all_menu_items (
void);
151 static void gnc_main_window_add_widget (GtkUIManager *merge, GtkWidget *widget,
GncMainWindow *window);
152 static void gnc_main_window_switch_page (GtkNotebook *notebook, gpointer *notebook_page, gint pos,
GncMainWindow *window);
153 static void gnc_main_window_page_reordered (GtkNotebook *notebook, GtkWidget *child, guint pos,
GncMainWindow *window);
156 static void gnc_main_window_engine_commit_error_callback( gpointer data,
QofBackendError errcode );
159 static void gnc_main_window_cmd_page_setup (GtkAction *action,
GncMainWindow *window);
160 static void gnc_main_window_cmd_file_properties (GtkAction *action,
GncMainWindow *window);
161 static void gnc_main_window_cmd_file_close (GtkAction *action,
GncMainWindow *window);
162 static void gnc_main_window_cmd_file_quit (GtkAction *action,
GncMainWindow *window);
163 static void gnc_main_window_cmd_edit_cut (GtkAction *action,
GncMainWindow *window);
164 static void gnc_main_window_cmd_edit_copy (GtkAction *action,
GncMainWindow *window);
165 static void gnc_main_window_cmd_edit_paste (GtkAction *action,
GncMainWindow *window);
166 static void gnc_main_window_cmd_edit_preferences (GtkAction *action,
GncMainWindow *window);
167 static void gnc_main_window_cmd_view_refresh (GtkAction *action,
GncMainWindow *window);
168 static void gnc_main_window_cmd_view_toolbar (GtkAction *action,
GncMainWindow *window);
169 static void gnc_main_window_cmd_view_summary (GtkAction *action,
GncMainWindow *window);
170 static void gnc_main_window_cmd_view_statusbar (GtkAction *action,
GncMainWindow *window);
171 static void gnc_main_window_cmd_view_tab_position (GtkAction *action, GtkRadioAction *current,
GncMainWindow *window);
172 static void gnc_main_window_cmd_actions_reset_warnings (GtkAction *action,
GncMainWindow *window);
173 static void gnc_main_window_cmd_actions_rename_page (GtkAction *action,
GncMainWindow *window);
174 static void gnc_main_window_cmd_window_new (GtkAction *action,
GncMainWindow *window);
175 static void gnc_main_window_cmd_window_move_page (GtkAction *action,
GncMainWindow *window);
176 #ifndef MAC_INTEGRATION 177 static void gnc_main_window_cmd_window_raise (GtkAction *action, GtkRadioAction *current,
GncMainWindow *window);
179 static void gnc_main_window_cmd_help_tutorial (GtkAction *action,
GncMainWindow *window);
180 static void gnc_main_window_cmd_help_contents (GtkAction *action,
GncMainWindow *window);
181 static void gnc_main_window_cmd_help_about (GtkAction *action,
GncMainWindow *window);
183 static void do_popup_menu(
GncPluginPage *page, GdkEventButton *event);
184 static GtkWidget *gnc_main_window_get_statusbar (GncWindow *window_in);
185 static void statusbar_notification_lastmodified(
void);
186 static void gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_data);
187 static void gnc_main_window_remove_prefs (
GncMainWindow *window);
189 #ifdef MAC_INTEGRATION 190 static void gnc_quartz_shutdown(GtkosxApplication *theApp, gpointer data);
191 static gboolean gnc_quartz_should_quit(GtkosxApplication *theApp,
GncMainWindow *window);
246 G_IMPLEMENT_INTERFACE (GNC_TYPE_WINDOW,
247 gnc_window_main_window_init))
249 #define GNC_MAIN_WINDOW_GET_PRIVATE(o) \ 250 ((GncMainWindowPrivate*)gnc_main_window_get_instance_private((GncMainWindow*)o)) 261 GtkActionGroup *action_group;
266 static guint main_window_signals[LAST_SIGNAL] = { 0 };
273 static GtkActionEntry gnc_menu_actions [] =
277 {
"FileAction", NULL, N_(
"_File"), NULL, NULL, NULL, },
278 {
"EditAction", NULL, N_(
"_Edit"), NULL, NULL, NULL },
279 {
"ViewAction", NULL, N_(
"_View"), NULL, NULL, NULL },
280 {
"ActionsAction", NULL, N_(
"_Actions"), NULL, NULL, NULL },
281 {
"TransactionAction", NULL, N_(
"Tra_nsaction"), NULL, NULL, NULL },
282 {
"ReportsAction", NULL, N_(
"_Reports"), NULL, NULL, NULL },
283 {
"ToolsAction", NULL, N_(
"_Tools"), NULL, NULL, NULL },
284 {
"ExtensionsAction", NULL, N_(
"E_xtensions"), NULL, NULL, NULL },
285 {
"WindowsAction", NULL, N_(
"_Windows"), NULL, NULL, NULL },
286 {
"HelpAction", NULL, N_(
"_Help"), NULL, NULL, NULL },
290 {
"FileImportAction", NULL, N_(
"_Import"), NULL, NULL, NULL },
291 {
"FileExportAction", NULL, N_(
"_Export"), NULL, NULL, NULL },
293 "FilePrintAction",
"document-print", N_(
"_Print..."),
"<primary>p",
294 N_(
"Print the currently active page"), NULL
296 #ifndef GTK_STOCK_PAGE_SETUP 297 # define GTK_STOCK_PAGE_SETUP NULL 300 "FilePageSetupAction",
"document-page-setup", N_(
"Pa_ge Setup"),
"<primary><shift>p",
301 N_(
"Specify the page size and orientation for printing"),
302 G_CALLBACK (gnc_main_window_cmd_page_setup)
305 "FilePropertiesAction",
"document-properties", N_(
"Proper_ties"),
"<Alt>Return",
306 N_(
"Edit the properties of the current file"),
307 G_CALLBACK (gnc_main_window_cmd_file_properties)
310 "FileCloseAction",
"window-close", N_(
"_Close"),
"<primary>W",
311 N_(
"Close the currently active page"),
312 G_CALLBACK (gnc_main_window_cmd_file_close)
315 "FileQuitAction",
"application-exit", N_(
"_Quit"),
"<primary>Q",
316 N_(
"Quit this application"),
317 G_CALLBACK (gnc_main_window_cmd_file_quit)
323 "EditCutAction",
"edit-cut", N_(
"Cu_t"),
"<primary>X",
324 N_(
"Cut the current selection and copy it to clipboard"),
325 G_CALLBACK (gnc_main_window_cmd_edit_cut)
328 "EditCopyAction",
"edit-copy", N_(
"_Copy"),
"<primary>C",
329 N_(
"Copy the current selection to clipboard"),
330 G_CALLBACK (gnc_main_window_cmd_edit_copy)
333 "EditPasteAction",
"edit-paste", N_(
"_Paste"),
"<primary>V",
334 N_(
"Paste the clipboard content at the cursor position"),
335 G_CALLBACK (gnc_main_window_cmd_edit_paste)
338 "EditPreferencesAction",
"preferences-system", N_(
"Pr_eferences"), NULL,
339 N_(
"Edit the global preferences of GnuCash"),
340 G_CALLBACK (gnc_main_window_cmd_edit_preferences)
345 {
"ViewTabPositionAction", NULL, N_(
"Tab P_osition"), NULL, NULL, NULL },
347 "ViewSortByAction", NULL, N_(
"_Sort By..."), NULL,
348 N_(
"Select sorting criteria for this page view"), NULL
351 "ViewFilterByAction", NULL, N_(
"_Filter By..."), NULL,
352 N_(
"Select the account types that should be displayed."), NULL
355 "ViewRefreshAction",
"view-refresh", N_(
"_Refresh"),
"<primary>r",
356 N_(
"Refresh this window"),
357 G_CALLBACK (gnc_main_window_cmd_view_refresh)
362 {
"ScrubMenuAction", NULL, N_(
"_Check & Repair"), NULL, NULL, NULL },
364 "ActionsForgetWarningsAction", NULL, N_(
"Reset _Warnings..."), NULL,
365 N_(
"Reset the state of all warning messages so they will be shown again."),
366 G_CALLBACK (gnc_main_window_cmd_actions_reset_warnings)
369 "ActionsRenamePageAction", NULL, N_(
"Re_name Page"), NULL,
370 N_(
"Rename this page."),
371 G_CALLBACK (gnc_main_window_cmd_actions_rename_page)
377 "WindowNewAction", NULL, N_(
"_New Window"), NULL,
378 N_(
"Open a new top-level GnuCash window."),
379 G_CALLBACK (gnc_main_window_cmd_window_new)
382 "WindowMovePageAction", NULL, N_(
"New Window with _Page"), NULL,
383 N_(
"Move the current page to a new top-level GnuCash window."),
384 G_CALLBACK (gnc_main_window_cmd_window_move_page)
390 "HelpTutorialAction",
"help-browser", N_(
"Tutorial and Concepts _Guide"),
"<primary>H",
391 N_(
"Open the GnuCash Tutorial"),
392 G_CALLBACK (gnc_main_window_cmd_help_tutorial)
395 "HelpContentsAction",
"help-browser", N_(
"_Contents"),
"F1",
396 N_(
"Open the GnuCash Help"),
397 G_CALLBACK (gnc_main_window_cmd_help_contents)
400 "HelpAboutAction",
"help-about", N_(
"_About"), NULL,
402 G_CALLBACK (gnc_main_window_cmd_help_about)
406 static guint gnc_menu_n_actions = G_N_ELEMENTS (gnc_menu_actions);
410 static GtkToggleActionEntry toggle_actions [] =
413 "ViewToolbarAction", NULL, N_(
"_Toolbar"), NULL,
414 N_(
"Show/hide the toolbar on this window"),
415 G_CALLBACK (gnc_main_window_cmd_view_toolbar), TRUE
418 "ViewSummaryAction", NULL, N_(
"Su_mmary Bar"), NULL,
419 N_(
"Show/hide the summary bar on this window"),
420 G_CALLBACK (gnc_main_window_cmd_view_summary), TRUE
423 "ViewStatusbarAction", NULL, N_(
"Stat_us Bar"), NULL,
424 N_(
"Show/hide the status bar on this window"),
425 G_CALLBACK (gnc_main_window_cmd_view_statusbar), TRUE
429 static guint n_toggle_actions = G_N_ELEMENTS (toggle_actions);
433 static GtkRadioActionEntry tab_pos_radio_entries [] =
436 "ViewTabPositionTopAction", NULL, N_(
"To_p"), NULL,
437 N_(
"Display the notebook tabs at the top of the window."), GTK_POS_TOP
440 "ViewTabPositionBottomAction", NULL, N_(
"B_ottom"), NULL,
441 N_(
"Display the notebook tabs at the bottom of the window."), GTK_POS_BOTTOM
444 "ViewTabPositionLeftAction", NULL, N_(
"_Left"), NULL,
445 N_(
"Display the notebook tabs at the left of the window."), GTK_POS_LEFT
448 "ViewTabPositionRightAction", NULL, N_(
"_Right"), NULL,
449 N_(
"Display the notebook tabs at the right of the window."), GTK_POS_RIGHT
455 static guint n_tab_pos_radio_entries = G_N_ELEMENTS (tab_pos_radio_entries);
457 #ifndef MAC_INTEGRATION 460 static GtkRadioActionEntry radio_entries [] =
462 {
"Window0Action", NULL, N_(
"Window _1"), NULL, NULL, 0 },
463 {
"Window1Action", NULL, N_(
"Window _2"), NULL, NULL, 1 },
464 {
"Window2Action", NULL, N_(
"Window _3"), NULL, NULL, 2 },
465 {
"Window3Action", NULL, N_(
"Window _4"), NULL, NULL, 3 },
466 {
"Window4Action", NULL, N_(
"Window _5"), NULL, NULL, 4 },
467 {
"Window5Action", NULL, N_(
"Window _6"), NULL, NULL, 5 },
468 {
"Window6Action", NULL, N_(
"Window _7"), NULL, NULL, 6 },
469 {
"Window7Action", NULL, N_(
"Window _8"), NULL, NULL, 7 },
470 {
"Window8Action", NULL, N_(
"Window _9"), NULL, NULL, 8 },
471 {
"Window9Action", NULL, N_(
"Window _0"), NULL, NULL, 9 },
475 static guint n_radio_entries = G_N_ELEMENTS (radio_entries);
481 static const gchar *gnc_menu_important_actions[] =
492 static const gchar *always_insensitive_actions[] =
502 static const gchar *initially_insensitive_actions[] =
513 static const gchar *always_hidden_actions[] =
516 "ViewFilterByAction",
523 static const gchar *immutable_page_actions[] =
532 static const gchar *multiple_page_actions[] =
534 "WindowMovePageAction",
542 #define WINDOW_COUNT "WindowCount" 543 #define WINDOW_STRING "Window %d" 544 #define WINDOW_GEOMETRY "WindowGeometry" 545 #define WINDOW_POSITION "WindowPosition" 546 #define WINDOW_MAXIMIZED "WindowMaximized" 547 #define TOOLBAR_VISIBLE "ToolbarVisible" 548 #define STATUSBAR_VISIBLE "StatusbarVisible" 549 #define SUMMARYBAR_VISIBLE "SummarybarVisible" 550 #define WINDOW_FIRSTPAGE "FirstPage" 551 #define WINDOW_PAGECOUNT "PageCount" 552 #define WINDOW_PAGEORDER "PageOrder" 553 #define PAGE_TYPE "PageType" 554 #define PAGE_NAME "PageName" 555 #define PAGE_STRING "Page %d" 560 const gchar *group_name;
578 gnc_main_window_foreach_page (GncMainWindowPageFunc fn, gpointer user_data)
586 for (w = active_windows; w; w = g_list_next(w))
589 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
617 gchar *page_group, *page_type = NULL, *name = NULL;
618 const gchar *class_type;
619 GError *error = NULL;
621 ENTER(
"window %p, data %p (key file %p, window %d, page start %d, page num %d)",
622 window, data, data->key_file, data->window_num, data->page_offset,
625 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
626 page_group = g_strdup_printf(PAGE_STRING,
627 data->page_offset + data->page_num);
628 page_type = g_key_file_get_string(data->key_file, page_group,
632 g_warning(
"error reading group %s key %s: %s",
633 page_group, PAGE_TYPE, error->message);
641 class_type = GNC_PLUGIN_PAGE_GET_CLASS(page)->plugin_name;
642 if (strcmp(page_type, class_type) != 0)
644 g_warning(
"error: page types don't match: state %s, existing page %s",
645 page_type, class_type);
653 data->key_file, page_group);
664 name = g_key_file_get_string(data->key_file, page_group,
668 g_warning(
"error reading group %s key %s: %s",
669 page_group, PAGE_NAME, error->message);
674 DEBUG(
"updating page name for %p to %s.", page, name);
704 gint *pos, *geom, *order;
706 gboolean max, visible, desired_visibility;
708 gint page_start, page_count, i;
709 GError *error = NULL;
712 ENTER(
"window %p, data %p (key file %p, window %d)",
713 window, data, data->key_file, data->window_num);
714 window_group = g_strdup_printf(WINDOW_STRING, data->window_num + 1);
723 if (!g_key_file_has_group (data->key_file, window_group) ||
724 !g_key_file_has_key (data->key_file, window_group, WINDOW_PAGECOUNT, &error))
729 PINFO (
"saved state had an empty first main window\n" 730 "an account hierarchy page was added automatically to avoid confusion");
733 PINFO (
"saved state had an empty main window, skipping restore");
740 page_count = g_key_file_get_integer(data->key_file,
741 window_group, WINDOW_PAGECOUNT, &error);
744 g_warning(
"error reading group %s key %s: %s",
745 window_group, WINDOW_PAGECOUNT, error->message);
754 page_start = g_key_file_get_integer(data->key_file,
755 window_group, WINDOW_FIRSTPAGE, &error);
758 g_warning(
"error reading group %s key %s: %s",
759 window_group, WINDOW_FIRSTPAGE, error->message);
766 DEBUG(
"Window %d doesn't exist. Creating new window.", data->window_num);
767 DEBUG(
"active_windows %p.", active_windows);
769 DEBUG(
"first window %p.", active_windows->data);
773 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
776 geom = g_key_file_get_integer_list(data->key_file, window_group,
777 WINDOW_GEOMETRY, &length, &error);
780 g_warning(
"error reading group %s key %s: %s",
781 window_group, WINDOW_GEOMETRY, error->message);
785 else if (length != 2)
787 g_warning(
"invalid number of values for group %s key %s",
788 window_group, WINDOW_GEOMETRY);
792 gtk_window_resize(GTK_WINDOW(window), geom[0], geom[1]);
793 DEBUG(
"window (%p) size %dx%d", window, geom[0], geom[1]);
798 pos = g_key_file_get_integer_list(data->key_file, window_group,
799 WINDOW_POSITION, &length, &error);
802 g_warning(
"error reading group %s key %s: %s",
803 window_group, WINDOW_POSITION, error->message);
807 else if (length != 2)
809 g_warning(
"invalid number of values for group %s key %s",
810 window_group, WINDOW_POSITION);
813 else if ((pos[0] + (geom ? geom[0] : 0) < 0) ||
814 (pos[0] > gdk_screen_width()) ||
815 (pos[1] + (geom ? geom[1] : 0) < 0) ||
816 (pos[1] > gdk_screen_height()))
818 DEBUG(
"position %dx%d, size%dx%d is offscreen; will not move",
819 pos[0], pos[1], geom ? geom[0] : 0, geom ? geom[1] : 0);
823 gtk_window_move(GTK_WINDOW(window), pos[0], pos[1]);
824 priv->
pos[0] = pos[0];
825 priv->
pos[1] = pos[1];
826 DEBUG(
"window (%p) position %dx%d", window, pos[0], pos[1]);
837 max = g_key_file_get_boolean(data->key_file, window_group,
838 WINDOW_MAXIMIZED, &error);
841 g_warning(
"error reading group %s key %s: %s",
842 window_group, WINDOW_MAXIMIZED, error->message);
848 gtk_window_maximize(GTK_WINDOW(window));
853 visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
854 desired_visibility = g_key_file_get_boolean(data->key_file, window_group,
855 TOOLBAR_VISIBLE, &error);
858 g_warning(
"error reading group %s key %s: %s",
859 window_group, TOOLBAR_VISIBLE, error->message);
863 else if (visible != desired_visibility)
865 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility);
869 visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
870 desired_visibility = g_key_file_get_boolean(data->key_file, window_group,
871 SUMMARYBAR_VISIBLE, &error);
874 g_warning(
"error reading group %s key %s: %s",
875 window_group, TOOLBAR_VISIBLE, error->message);
879 else if (visible != desired_visibility)
881 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility);
885 visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
886 desired_visibility = g_key_file_get_boolean(data->key_file, window_group,
887 STATUSBAR_VISIBLE, &error);
890 g_warning(
"error reading group %s key %s: %s",
891 window_group, TOOLBAR_VISIBLE, error->message);
895 else if (visible != desired_visibility)
897 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility);
901 for (i = 0; i < page_count; i++)
903 data->page_offset = page_start;
905 gnc_main_window_restore_page(window, data);
908 while (gtk_events_pending ())
909 gtk_main_iteration ();
915 order = g_key_file_get_integer_list(data->key_file, window_group,
916 WINDOW_PAGEORDER, &length, &error);
919 g_warning(
"error reading group %s key %s: %s",
920 window_group, WINDOW_PAGEORDER, error->message);
924 else if (length != page_count)
926 g_warning(
"%s key %s length %" G_GSIZE_FORMAT
" differs from window page count %d",
927 window_group, WINDOW_PAGEORDER, length, page_count);
935 for (i = 0; i < length; i++)
943 gtk_notebook_set_current_page (GTK_NOTEBOOK(priv->
notebook),
946 g_signal_emit_by_name (window,
"page_changed",
954 LEAVE(
"window %p", window);
958 g_free(window_group);
960 gtk_widget_show (GTK_WIDGET(window));
966 gint i, window_count;
967 GError *error = NULL;
973 data.key_file = (GKeyFile *) keyfile;
974 window_count = g_key_file_get_integer(data.key_file, STATE_FILE_TOP,
975 WINDOW_COUNT, &error);
978 g_warning(
"error reading group %s key %s: %s",
979 STATE_FILE_TOP, WINDOW_COUNT, error->message);
981 LEAVE(
"can't read count");
987 gnc_set_busy_cursor (NULL, TRUE);
988 for (i = 0; i < window_count; i++)
991 window = g_list_nth_data(active_windows, i);
992 gnc_main_window_restore_window(window, &data);
994 gnc_unset_busy_cursor (NULL);
996 statusbar_notification_lastmodified();
1006 DEBUG(
"no saved state file");
1008 window = g_list_nth_data(active_windows, 0);
1009 gtk_widget_show (GTK_WIDGET(window));
1011 gtk_action_activate(action);
1027 const gchar *plugin_name, *page_name;
1029 ENTER(
"page %p, data %p (key file %p, window %d, page %d)",
1030 page, data, data->key_file, data->window_num, data->page_num);
1033 if (!plugin_name || !page_name)
1035 LEAVE(
"not saving invalid page");
1038 page_group = g_strdup_printf(PAGE_STRING, data->page_num++);
1039 g_key_file_set_string(data->key_file, page_group, PAGE_TYPE, plugin_name);
1040 g_key_file_set_string(data->key_file, page_group, PAGE_NAME, page_name);
1061 gint i, num_pages, coords[4], *order;
1062 gboolean maximized, minimized, visible;
1063 gchar *window_group;
1066 ENTER(
"window %p, data %p (key file %p, window %d)",
1067 window, data, data->key_file, data->window_num);
1068 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1071 num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(priv->
notebook));
1074 LEAVE(
"empty window %p", window);
1079 window_group = g_strdup_printf(WINDOW_STRING, data->window_num++);
1080 g_key_file_set_integer(data->key_file, window_group,
1081 WINDOW_PAGECOUNT, num_pages);
1082 g_key_file_set_integer(data->key_file, window_group,
1083 WINDOW_FIRSTPAGE, data->page_num);
1088 order = g_malloc(
sizeof(gint) * num_pages);
1089 for (i = 0; i < num_pages; i++)
1091 gpointer page = g_list_nth_data(priv->
usage_order, i);
1094 g_key_file_set_integer_list(data->key_file, window_group,
1095 WINDOW_PAGEORDER, order, num_pages);
1099 gtk_window_get_position(GTK_WINDOW(window), &coords[0], &coords[1]);
1100 gtk_window_get_size(GTK_WINDOW(window), &coords[2], &coords[3]);
1101 maximized = (gdk_window_get_state(gtk_widget_get_window ((GTK_WIDGET(window))))
1102 & GDK_WINDOW_STATE_MAXIMIZED) != 0;
1103 minimized = (gdk_window_get_state(gtk_widget_get_window ((GTK_WIDGET(window))))
1104 & GDK_WINDOW_STATE_ICONIFIED) != 0;
1108 gint *pos = priv->
pos;
1109 g_key_file_set_integer_list(data->key_file, window_group,
1110 WINDOW_POSITION, &pos[0], 2);
1111 DEBUG(
"window minimized (%p) position %dx%d", window, pos[0], pos[1]);
1114 g_key_file_set_integer_list(data->key_file, window_group,
1115 WINDOW_POSITION, &coords[0], 2);
1116 g_key_file_set_integer_list(data->key_file, window_group,
1117 WINDOW_GEOMETRY, &coords[2], 2);
1118 g_key_file_set_boolean(data->key_file, window_group,
1119 WINDOW_MAXIMIZED, maximized);
1120 DEBUG(
"window (%p) position %dx%d, size %dx%d, %s", window, coords[0], coords[1],
1121 coords[2], coords[3],
1122 maximized ?
"maximized" :
"not maximized");
1126 visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
1127 g_key_file_set_boolean(data->key_file, window_group,
1128 TOOLBAR_VISIBLE, visible);
1130 visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
1131 g_key_file_set_boolean(data->key_file, window_group,
1132 SUMMARYBAR_VISIBLE, visible);
1134 visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
1135 g_key_file_set_boolean(data->key_file, window_group,
1136 STATUSBAR_VISIBLE, visible);
1139 g_list_foreach(priv->
installed_pages, (GFunc)gnc_main_window_save_page, data);
1141 g_free(window_group);
1142 LEAVE(
"window %p", window);
1151 data.key_file = keyfile;
1152 data.window_num = 1;
1155 g_key_file_set_integer(data.key_file,
1156 STATE_FILE_TOP, WINDOW_COUNT,
1157 g_list_length(active_windows));
1159 g_list_foreach(active_windows, (GFunc)gnc_main_window_save_window, &data);
1169 g_return_val_if_fail(GNC_IS_MAIN_WINDOW(window), TRUE);
1171 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1186 const GList *windows, *item;
1189 for (item = windows; item; item = g_list_next(item))
1196 if (gnc_gui_refresh_suspended ())
1198 gnc_warning_dialog (NULL,
"%s",
"An operation is still running, wait for it to complete before quitting.");
1222 for (walker = active_windows; walker; walker = g_list_next(walker))
1224 window = walker->data;
1225 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1234 static gboolean auto_save_countdown (GtkWidget *dialog)
1237 gchar *timeoutstr = NULL;
1240 if (!GTK_IS_DIALOG (dialog))
1244 label = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog),
"count-down-label"));
1245 if (!GTK_IS_LABEL (label))
1251 DEBUG (
"Counting down: %d seconds", secs_to_save);
1253 timeoutstr = g_strdup_printf (MSG_AUTO_SAVE, secs_to_save);
1254 gtk_label_set_text (GTK_LABEL (label), timeoutstr);
1255 g_free (timeoutstr);
1260 gtk_dialog_response (GTK_DIALOG(dialog), GTK_RESPONSE_APPLY);
1279 gnc_main_window_prompt_for_save (GtkWidget *window)
1281 QofSession *session;
1283 GtkWidget *dialog, *msg_area, *label;
1285 const gchar *filename, *tmp;
1286 const gchar *title = _(
"Save changes to file %s before closing?");
1288 const gchar *message_hours =
1289 _(
"If you don't save, changes from the past %d hours and %d minutes will be discarded.");
1290 const gchar *message_days =
1291 _(
"If you don't save, changes from the past %d days and %d hours will be discarded.");
1293 gint minutes, hours, days;
1294 guint timer_source = 0;
1295 if (!gnc_current_session_exist())
1297 session = gnc_get_current_session();
1301 filename = qof_session_get_url(session);
1302 if (!strlen (filename))
1303 filename = _(
"<unknown>");
1304 if ((tmp = strrchr(filename,
'/')) != NULL)
1308 gnc_autosave_remove_timer(book);
1310 dialog = gtk_message_dialog_new(GTK_WINDOW(window),
1312 GTK_MESSAGE_WARNING,
1317 minutes = (
gnc_time (NULL) - oldest_change) / 60 + 1;
1318 hours = minutes / 60;
1319 minutes = minutes % 60;
1324 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
1325 message_days, days, hours);
1329 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
1330 message_hours, hours, minutes);
1334 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
1335 ngettext(
"If you don't save, changes from the past %d minute will be discarded.",
1336 "If you don't save, changes from the past %d minutes will be discarded.",
1339 gtk_dialog_add_buttons(GTK_DIALOG(dialog),
1340 _(
"Close _Without Saving"), GTK_RESPONSE_CLOSE,
1341 _(
"_Cancel"), GTK_RESPONSE_CANCEL,
1342 _(
"_Save"), GTK_RESPONSE_APPLY,
1344 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_APPLY);
1351 gchar *timeoutstr = NULL;
1353 secs_to_save =
gnc_prefs_get_int (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_CLOSE_WAIT_TIME);
1354 timeoutstr = g_strdup_printf (MSG_AUTO_SAVE, secs_to_save);
1355 label = GTK_WIDGET(gtk_label_new (timeoutstr));
1356 g_free (timeoutstr);
1357 gtk_widget_show (label);
1359 msg_area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG(dialog));
1360 gtk_box_pack_end (GTK_BOX(msg_area), label, TRUE, TRUE, 0);
1361 g_object_set (G_OBJECT (label),
"xalign", 0.0, NULL);
1363 g_object_set_data (G_OBJECT (dialog),
"count-down-label", label);
1364 timer_source = g_timeout_add_seconds (1, (GSourceFunc)auto_save_countdown, dialog);
1367 response = gtk_dialog_run (GTK_DIALOG (dialog));
1369 g_source_remove (timer_source);
1370 gtk_widget_destroy(dialog);
1374 case GTK_RESPONSE_APPLY:
1375 gnc_file_save (GTK_WINDOW (window));
1378 case GTK_RESPONSE_CLOSE:
1389 gnc_main_window_add_plugin (gpointer plugin,
1392 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
1393 g_return_if_fail (GNC_IS_PLUGIN (plugin));
1397 GNC_MAIN_WINDOW (window),
1403 gnc_main_window_remove_plugin (gpointer plugin,
1406 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
1407 g_return_if_fail (GNC_IS_PLUGIN (plugin));
1411 GNC_MAIN_WINDOW (window),
1418 gnc_main_window_timed_quit (gpointer dummy)
1420 if (gnc_file_save_in_progress())
1430 QofSession *session;
1431 gboolean needs_save, do_shutdown = TRUE;
1432 if (gnc_current_session_exist())
1434 session = gnc_get_current_session();
1437 !gnc_file_save_in_progress();
1438 do_shutdown = !needs_save ||
1440 !gnc_main_window_prompt_for_save(GTK_WIDGET(window)));
1450 for (w = active_windows; w; w = next)
1455 next = g_list_next (w);
1459 priv = GNC_MAIN_WINDOW_GET_PRIVATE(wind);
1463 gtk_widget_destroy (GTK_WIDGET(wind));
1466 gnc_main_window_remove_prefs (window);
1467 g_timeout_add(250, gnc_main_window_timed_quit, NULL);
1474 gnc_main_window_delete_event (GtkWidget *window,
1478 static gboolean already_dead = FALSE;
1487 gchar *message = _(
"This window is closing and will not be restored.");
1489 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
1490 GTK_DIALOG_DESTROY_WITH_PARENT,
1491 GTK_MESSAGE_QUESTION,
1493 "%s", _(
"Close Window?"));
1494 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog),
1497 gtk_dialog_add_buttons (GTK_DIALOG(dialog),
1498 _(
"_Cancel"), GTK_RESPONSE_CANCEL,
1499 _(
"_OK"), GTK_RESPONSE_YES,
1501 gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_YES);
1502 response = gnc_dialog_run (GTK_DIALOG(dialog), GNC_PREF_WARN_CLOSING_WINDOW_QUESTION);
1503 gtk_widget_destroy (dialog);
1505 if (response == GTK_RESPONSE_CANCEL)
1518 already_dead = gnc_main_window_quit(GNC_MAIN_WINDOW(window));
1543 gnc_main_window_event_handler (QofInstance *entity,
QofEventId event_type,
1544 gpointer user_data, gpointer event_data)
1552 g_return_if_fail(GNC_IS_MAIN_WINDOW(user_data));
1557 if (event_type != QOF_EVENT_DESTROY)
1560 ENTER(
"entity %p, event %d, window %p, event data %p",
1561 entity, event_type, user_data, event_data);
1562 window = GNC_MAIN_WINDOW(user_data);
1563 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1570 next = g_list_next(item);
1571 page = GNC_PLUGIN_PAGE(item->data);
1576 if (GTK_IS_WIDGET(window) && window->window_quitting)
1577 gtk_widget_destroy (GTK_WIDGET(window));
1606 gchar *filename = NULL;
1607 const gchar *uri = NULL;
1608 const gchar *dirty =
"";
1609 const gchar *readonly_text = NULL;
1613 if (gnc_current_session_exist())
1615 uri = qof_session_get_url (gnc_get_current_session ());
1616 book = gnc_get_current_book();
1623 readonly_text = _(
"(read-only)");
1626 readonly = (readonly_text != NULL)
1627 ? g_strdup_printf(
" %s", readonly_text)
1630 if (!uri || g_strcmp0 (uri,
"") == 0)
1631 filename = g_strdup(_(
"Unsaved Book"));
1639 filename = g_path_get_basename ( path );
1650 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1656 title = g_strdup_printf(
"%s%s%s - %s - GnuCash", dirty, filename, readonly,
1661 title = g_strdup_printf(
"%s%s%s - GnuCash", dirty, filename, readonly);
1665 g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE);
1667 immutable_page_actions,
1668 "sensitive", !immutable);
1670 g_signal_emit_by_name (window,
"page_changed", page);
1692 title = gnc_main_window_generate_title(window);
1693 gtk_window_set_title(GTK_WINDOW(window), title);
1698 gnc_main_window_update_all_titles (
void)
1700 g_list_foreach(active_windows,
1701 (GFunc)gnc_main_window_update_title,
1706 gnc_main_window_book_dirty_cb (QofBook *book,
1710 gnc_main_window_update_all_titles();
1713 gnc_autosave_dirty_handler(book, dirty);
1717 gnc_main_window_attach_to_book (QofSession *session)
1721 g_return_if_fail(session);
1725 gnc_main_window_update_all_titles();
1726 #ifndef MAC_INTEGRATION 1727 gnc_main_window_update_all_menu_items();
1731 static guint gnc_statusbar_notification_messageid = 0;
1733 #ifdef STATUSBAR_NOTIFICATION_AUTOREMOVAL 1736 static gboolean statusbar_notification_off(gpointer user_data_unused)
1740 if (gnc_statusbar_notification_messageid == 0)
1745 GtkWidget *statusbar = gnc_main_window_get_statusbar(GNC_WINDOW(mainwindow));
1746 gtk_statusbar_remove(GTK_STATUSBAR(statusbar), 0, gnc_statusbar_notification_messageid);
1747 gnc_statusbar_notification_messageid = 0;
1751 g_warning(
"oops, no GncMainWindow obtained\n");
1755 #endif // STATUSBAR_NOTIFICATION_AUTOREMOVAL 1759 static gchar *generate_statusbar_lastmodified_message()
1761 gchar *message = NULL;
1762 const gchar *uri = NULL;
1764 if (gnc_current_session_exist())
1766 uri = qof_session_get_url (gnc_get_current_session ());
1769 if (!(uri && strlen (uri)))
1777 gchar *filename = g_path_get_basename ( filepath );
1778 GFile *file = g_file_new_for_uri (uri);
1779 GFileInfo *info = g_file_query_info (file,
1780 G_FILE_ATTRIBUTE_TIME_MODIFIED,
1781 G_FILE_QUERY_INFO_NONE,
1784 if (info && g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
1786 guint64 modtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
1794 _(
"Last modified on %a, %b %d, %Y at %I:%M %p"));
1797 message = g_strdup_printf(_(
"File %s opened. %s"),
1798 filename, time_string);
1803 g_warning(
"Unable to read mtime for file %s\n", filepath);
1808 g_object_unref (info);
1809 g_object_unref (file);
1818 statusbar_notification_lastmodified()
1822 GtkWidget *widget = NULL;
1823 for (iter = active_windows; iter && !(widget && GNC_IS_MAIN_WINDOW(widget));
1824 iter = g_list_next(iter))
1826 widget = iter->data;
1828 if (widget && GNC_IS_MAIN_WINDOW(widget))
1832 GtkWidget *statusbar = gnc_main_window_get_statusbar(GNC_WINDOW(mainwindow));
1834 gchar *msg = generate_statusbar_lastmodified_message();
1837 gnc_statusbar_notification_messageid = gtk_statusbar_push(GTK_STATUSBAR(statusbar), 0, msg);
1841 #ifdef STATUSBAR_NOTIFICATION_AUTOREMOVAL 1844 g_timeout_add(10 * 1000, statusbar_notification_off, NULL);
1849 g_warning(
"uh oh, no GNC_IS_MAIN_WINDOW\n");
1869 #ifndef MAC_INTEGRATION 1884 gnc_main_window_update_one_menu_action (
GncMainWindow *window,
1890 ENTER(
"window %p, action %s, label %s, visible %d", window,
1891 data->action_name, data->label, data->visible);
1892 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1893 action = gtk_action_group_get_action(priv->
action_group, data->action_name);
1895 g_object_set(G_OBJECT(action),
1896 "label", data->label,
1897 "visible", data->visible,
1918 GtkAction *action, *first_action;
1919 GSList *action_list;
1923 ENTER(
"window %p", window);
1926 index = g_list_index(active_windows, window);
1927 if (index >= n_radio_entries)
1929 LEAVE(
"window %d, only %d actions", index, n_radio_entries);
1933 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1934 action_name = g_strdup_printf(
"Window%dAction", index);
1935 action = gtk_action_group_get_action(priv->
action_group, action_name);
1939 action_list = gtk_radio_action_get_group(GTK_RADIO_ACTION(action));
1942 first_action = g_slist_last(action_list)->data;
1943 g_signal_handlers_block_by_func(G_OBJECT(first_action),
1944 G_CALLBACK(gnc_main_window_cmd_window_raise),
1946 DEBUG(
"blocked signal on %p, set %p active, window %p", first_action,
1948 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
1949 g_signal_handlers_unblock_by_func(G_OBJECT(first_action),
1950 G_CALLBACK(gnc_main_window_cmd_window_raise),
1953 g_free(action_name);
1974 gchar **strings, *title, *expanded;
1977 ENTER(
"window %p", window);
1978 index = g_list_index(active_windows, window);
1979 if (index > n_radio_entries)
1981 LEAVE(
"skip window %d (only %d entries)", index, n_radio_entries);
1986 title = gnc_main_window_generate_title(window);
1987 strings = g_strsplit(title,
"_", 0);
1989 expanded = g_strjoinv(
"__", strings);
1992 data.label = g_strdup_printf(
"_%d %s", (index + 1) % 10, expanded);
1997 data.label = expanded;
1999 g_strfreev(strings);
2001 data.visible = TRUE;
2002 data.action_name = g_strdup_printf(
"Window%dAction", index);
2003 g_list_foreach(active_windows,
2004 (GFunc)gnc_main_window_update_one_menu_action,
2006 g_free(data.action_name);
2021 #ifndef MAC_INTEGRATION 2023 gnc_main_window_update_all_menu_items (
void)
2031 g_list_foreach(active_windows,
2032 (GFunc)gnc_main_window_update_menu_item,
2034 g_list_foreach(active_windows,
2035 (GFunc)gnc_main_window_update_radio_button,
2039 data.visible = FALSE;
2040 for (i = g_list_length(active_windows); i < n_radio_entries; i++)
2042 data.action_name = g_strdup_printf(
"Window%dAction", i);
2043 label = g_strdup_printf(
"Window _%d", (i - 1) % 10);
2044 data.label = gettext(
label);
2046 g_list_foreach(active_windows,
2047 (GFunc)gnc_main_window_update_one_menu_action,
2050 g_free(data.action_name);
2069 gnc_main_window_update_tab_close_one_page (
GncPluginPage *page,
2072 gboolean *new_value = user_data;
2073 GtkWidget * close_button;
2075 ENTER(
"page %p, visible %d", page, *new_value);
2076 close_button = g_object_get_data(G_OBJECT (page), PLUGIN_PAGE_CLOSE_BUTTON);
2079 LEAVE(
"no close button");
2084 gtk_widget_show (close_button);
2086 gtk_widget_hide (close_button);
2104 gnc_main_window_update_tab_close (gpointer prefs, gchar *pref, gpointer user_data)
2109 new_value =
gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SHOW_CLOSE_BUTTON);
2110 gnc_main_window_foreach_page(
2111 gnc_main_window_update_tab_close_one_page,
2126 gnc_main_window_update_tab_color_one_page (
GncPluginPage *page,
2129 const gchar *color_string;
2131 ENTER(
"page %p", page);
2149 gnc_main_window_update_tab_color (gpointer gsettings, gchar *pref, gpointer user_data)
2155 g_return_if_fail(GNC_IS_MAIN_WINDOW(user_data));
2157 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2158 if (g_strcmp0 (GNC_PREF_TAB_COLOR, pref) == 0)
2160 gnc_main_window_foreach_page (gnc_main_window_update_tab_color_one_page, window);
2171 gboolean tabs_left_right;
2175 populate_tab_width_struct (
void)
2181 tw->tabs_left_right =
gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT) ||
2209 gnc_main_window_set_tab_ellipsize (GtkWidget *
label, gint tab_width, gboolean tab_left_right)
2211 const gchar *lab_text = gtk_label_get_text (GTK_LABEL(
label));
2215 gint text_length = g_utf8_strlen (lab_text, -1);
2216 if (text_length < tab_width)
2219 gtk_label_set_width_chars (GTK_LABEL(
label), tab_width);
2221 gtk_label_set_width_chars (GTK_LABEL(
label), text_length);
2223 gtk_label_set_ellipsize (GTK_LABEL(
label), PANGO_ELLIPSIZE_NONE);
2227 gtk_label_set_width_chars (GTK_LABEL(
label), tab_width);
2228 gtk_label_set_ellipsize (GTK_LABEL(
label), PANGO_ELLIPSIZE_MIDDLE);
2233 gtk_label_set_width_chars (GTK_LABEL(
label), 15);
2234 gtk_label_set_ellipsize (GTK_LABEL(
label), PANGO_ELLIPSIZE_NONE);
2250 gnc_main_window_update_tab_width_one_page (
GncPluginPage *page,
2256 ENTER(
"page %p, tab width %d, tabs on left or right %d",
2257 page, tw->tab_width, tw->tabs_left_right);
2259 label = g_object_get_data(G_OBJECT (page), PLUGIN_PAGE_TAB_LABEL);
2265 gnc_main_window_set_tab_ellipsize (
label, tw->tab_width, tw->tabs_left_right);
2283 gnc_main_window_update_tab_width (gpointer prefs, gchar *pref, gpointer user_data)
2289 tw = populate_tab_width_struct ();
2291 gnc_main_window_foreach_page (gnc_main_window_update_tab_width_one_page, tw);
2304 GtkWidget **label_p,
2305 GtkWidget **entry_p)
2308 GtkWidget *tab_hbox, *widget, *tab_widget;
2309 GList *children, *tmp;
2311 ENTER(
"window %p, page %p, label_p %p, entry_p %p",
2312 window, page, label_p, entry_p);
2313 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2314 *label_p = *entry_p = NULL;
2318 LEAVE(
"invalid notebook_page");
2322 tab_widget = gtk_notebook_get_tab_label(GTK_NOTEBOOK(priv->
notebook),
2324 if (GTK_IS_EVENT_BOX (tab_widget))
2325 tab_hbox = gtk_bin_get_child(GTK_BIN(tab_widget));
2326 else if (GTK_IS_BOX (tab_widget))
2327 tab_hbox = tab_widget;
2330 PWARN (
"Unknown widget for tab label %p", tab_widget);
2334 children = gtk_container_get_children(GTK_CONTAINER(tab_hbox));
2335 for (tmp = children; tmp; tmp = g_list_next(tmp))
2338 if (GTK_IS_LABEL(widget))
2342 else if (GTK_IS_ENTRY(widget))
2347 g_list_free(children);
2349 LEAVE(
"label %p, entry %p", *label_p, *entry_p);
2350 return (*label_p && *entry_p);
2356 GtkWidget **widget_p)
2360 ENTER(
"window %p, page %p, widget %p",
2361 window, page, widget_p);
2366 LEAVE(
"invalid notebook_page");
2370 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2371 *widget_p = gtk_notebook_get_tab_label(GTK_NOTEBOOK(priv->
notebook),
2374 LEAVE(
"widget %p", *widget_p);
2380 const gchar *name_in)
2384 GtkWidget *
label, *entry;
2385 gchar *name, *old_page_name, *old_page_long_name;
2390 if ((name_in == NULL) || (*name_in ==
'\0'))
2395 name = g_strstrip(g_strdup(name_in));
2401 LEAVE(
"empty string or name unchanged");
2412 window = GNC_MAIN_WINDOW(page->
window);
2415 g_free(old_page_name);
2416 g_free(old_page_long_name);
2418 LEAVE(
"no window widget available");
2422 if (main_window_find_tab_items(window, page, &
label, &entry))
2423 gtk_label_set_text(GTK_LABEL(
label), name);
2426 tw = populate_tab_width_struct ();
2427 gnc_main_window_update_tab_width_one_page (page, tw);
2431 if (old_page_long_name && old_page_name
2432 && g_strrstr(old_page_long_name, old_page_name) != NULL)
2434 gchar *new_page_long_name;
2435 gint string_position;
2436 GtkWidget *tab_widget;
2438 string_position = strlen(old_page_long_name) - strlen(old_page_name);
2439 new_page_long_name = g_strconcat(g_strndup(old_page_long_name, string_position), name, NULL);
2443 if (main_window_find_tab_widget(window, page, &tab_widget))
2444 gtk_widget_set_tooltip_text(tab_widget, new_page_long_name);
2446 g_free(new_page_long_name);
2452 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2453 label = gtk_notebook_get_menu_label (GTK_NOTEBOOK(priv->
notebook),
2455 gtk_label_set_text(GTK_LABEL(
label), name);
2459 gnc_main_window_update_title(window);
2460 g_free(old_page_long_name);
2461 g_free(old_page_name);
2469 const gchar *color_in)
2473 GtkWidget *tab_widget;
2475 gchar *color_string = NULL;
2476 gboolean want_color = FALSE;
2480 color_string = g_strstrip(g_strdup(color_in));
2482 if (color_string && *color_string !=
'\0')
2486 window = GNC_MAIN_WINDOW(page->
window);
2493 main_window_find_tab_widget (window, page, &tab_widget);
2494 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2496 if (want_color && gdk_rgba_parse(&tab_color, color_string) && priv->
show_color_tabs)
2498 GtkCssProvider *provider = gtk_css_provider_new();
2499 GtkStyleContext *stylectxt;
2500 gchar *col_str, *widget_css;
2502 if (!GTK_IS_EVENT_BOX (tab_widget))
2504 GtkWidget *event_box = gtk_event_box_new ();
2505 g_object_ref (tab_widget);
2506 gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->
notebook),
2508 gtk_container_add (GTK_CONTAINER(event_box), tab_widget);
2509 g_object_unref (tab_widget);
2510 tab_widget = event_box;
2513 stylectxt = gtk_widget_get_style_context (GTK_WIDGET (tab_widget));
2514 col_str = gdk_rgba_to_string (&tab_color);
2515 widget_css = g_strconcat (
"*{\n background-color:", col_str,
";\n}\n", NULL);
2517 gtk_css_provider_load_from_data (provider, widget_css, -1, NULL);
2518 gtk_style_context_add_provider (stylectxt, GTK_STYLE_PROVIDER (provider),
2519 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
2520 g_object_unref (provider);
2522 g_free (widget_css);
2526 if (GTK_IS_EVENT_BOX (tab_widget))
2528 GtkWidget *tab_hbox = gtk_bin_get_child(GTK_BIN(tab_widget));
2529 g_object_ref (tab_hbox);
2530 gtk_container_remove (GTK_CONTAINER(tab_widget), tab_hbox);
2531 gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->
notebook),
2533 g_object_unref (tab_hbox);
2536 g_free(color_string);
2547 GtkWidget *tab_widget;
2548 GtkWidget *image = NULL;
2550 gchar *image_name = NULL;
2551 const gchar *icon_name;
2555 g_return_if_fail (page && page->
window);
2557 if (!GNC_IS_MAIN_WINDOW (page->
window))
2560 window = GNC_MAIN_WINDOW(page->
window);
2563 main_window_find_tab_widget (window, page, &tab_widget);
2564 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2568 LEAVE(
"no tab widget");
2572 if (GTK_IS_EVENT_BOX(tab_widget))
2573 tab_widget = gtk_bin_get_child (GTK_BIN(tab_widget));
2575 children = gtk_container_get_children (GTK_CONTAINER(tab_widget));
2577 for (GList *child = children; child; child = g_list_next (child))
2579 GtkWidget *widget = child->data;
2580 if (GTK_IS_IMAGE(widget))
2583 g_list_free (children);
2587 LEAVE(
"no image to replace");
2591 g_object_get (image,
"icon-name", &image_name, NULL);
2594 icon_name =
"changes-prevent-symbolic";
2596 icon_name = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
2598 if (g_strcmp0 (icon_name, image_name) == 0)
2600 LEAVE(
"page icon the same, no need to replace");
2601 g_free (image_name);
2604 gtk_container_remove (GTK_CONTAINER(tab_widget), image);
2605 image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
2606 gtk_widget_show (image);
2608 gtk_container_add (GTK_CONTAINER(tab_widget), image);
2609 gtk_widget_set_margin_start (GTK_WIDGET(image), 5);
2610 gtk_box_reorder_child (GTK_BOX(tab_widget), image, 0);
2612 g_free (image_name);
2618 gnc_main_window_tab_entry_activate (GtkWidget *entry,
2621 GtkWidget *
label, *entry2;
2623 g_return_if_fail(GTK_IS_ENTRY(entry));
2624 g_return_if_fail(GNC_IS_PLUGIN_PAGE(page));
2627 if (!main_window_find_tab_items(GNC_MAIN_WINDOW(page->
window),
2628 page, &
label, &entry2))
2630 LEAVE(
"can't find required widgets");
2636 gtk_widget_hide(entry);
2637 gtk_widget_show(
label);
2643 gnc_main_window_tab_entry_editing_done (GtkWidget *entry,
2647 gnc_main_window_tab_entry_activate(entry, page);
2653 gnc_main_window_tab_entry_focus_out_event (GtkWidget *entry,
2658 gtk_cell_editable_editing_done(GTK_CELL_EDITABLE(entry));
2664 gnc_main_window_tab_entry_key_press_event (GtkWidget *entry,
2668 if (event->keyval == GDK_KEY_Escape)
2670 GtkWidget *
label, *entry2;
2672 g_return_val_if_fail(GTK_IS_ENTRY(entry), FALSE);
2673 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
2676 if (!main_window_find_tab_items(GNC_MAIN_WINDOW(page->
window),
2677 page, &
label, &entry2))
2679 LEAVE(
"can't find required widgets");
2683 gtk_entry_set_text(GTK_ENTRY(entry), gtk_label_get_text(GTK_LABEL(
label)));
2684 gtk_widget_hide(entry);
2685 gtk_widget_show(
label);
2707 GObjectClass *object_class = G_OBJECT_CLASS (klass);
2708 GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS(klass);
2710 parent_class = g_type_class_peek_parent (klass);
2712 window_type = g_quark_from_static_string (
"gnc-main-window");
2714 object_class->finalize = gnc_main_window_finalize;
2717 gtkwidget_class->destroy = gnc_main_window_destroy;
2730 main_window_signals[PAGE_ADDED] =
2731 g_signal_new (
"page_added",
2732 G_OBJECT_CLASS_TYPE (object_class),
2736 g_cclosure_marshal_VOID__OBJECT,
2750 main_window_signals[PAGE_CHANGED] =
2751 g_signal_new (
"page_changed",
2752 G_OBJECT_CLASS_TYPE (object_class),
2756 g_cclosure_marshal_VOID__OBJECT,
2761 GNC_PREF_SHOW_CLOSE_BUTTON,
2762 gnc_main_window_update_tab_close,
2766 gnc_main_window_update_tab_width,
2769 gnc_hook_add_dangler(HOOK_BOOK_SAVED,
2770 (GFunc)gnc_main_window_update_all_titles, NULL, NULL);
2771 gnc_hook_add_dangler(HOOK_BOOK_OPENED,
2772 (GFunc)gnc_main_window_attach_to_book, NULL, NULL);
2792 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2794 g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
2797 gtk_widget_set_name (GTK_WIDGET(window),
"gnc-id-main-window");
2809 gnc_main_window_update_tab_color,
2812 gnc_main_window_setup_window (window);
2814 G_OBJECT_CLASS(klass));
2829 gnc_main_window_finalize (GObject *
object)
2831 g_return_if_fail (
object != NULL);
2832 g_return_if_fail (GNC_IS_MAIN_WINDOW (
object));
2834 if (active_windows == NULL)
2841 G_OBJECT_CLASS (parent_class)->finalize (
object);
2851 gnc_main_window_update_tab_color,
2855 GNC_PREF_SHOW_CLOSE_BUTTON,
2856 gnc_main_window_update_tab_close,
2861 gnc_main_window_update_tab_width,
2865 GNC_PREF_TAB_POSITION_TOP,
2866 gnc_main_window_update_tab_position,
2870 GNC_PREF_TAB_POSITION_BOTTOM,
2871 gnc_main_window_update_tab_position,
2875 GNC_PREF_TAB_POSITION_LEFT,
2876 gnc_main_window_update_tab_position,
2880 GNC_PREF_TAB_POSITION_RIGHT,
2881 gnc_main_window_update_tab_position,
2889 gnc_prefs_set_reg_negative_color_pref_id (0);
2897 gnc_prefs_set_reg_auto_raise_lists_id (0);
2903 gnc_main_window_destroy (GtkWidget *widget)
2910 g_return_if_fail (widget != NULL);
2911 g_return_if_fail (GNC_IS_MAIN_WINDOW (widget));
2913 window = GNC_MAIN_WINDOW (widget);
2915 active_windows = g_list_remove (active_windows, window);
2918 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2926 if (gnc_window_get_progressbar_window() == GNC_WINDOW(window))
2927 gnc_window_set_progressbar_window(NULL);
2928 #ifndef MAC_INTEGRATION 2930 gnc_main_window_update_all_menu_items();
2933 gnc_main_window_remove_prefs (window);
2944 g_list_foreach (plugins, gnc_main_window_remove_plugin, window);
2945 g_list_free (plugins);
2947 GTK_WIDGET_CLASS (parent_class)->destroy (widget);
2952 gnc_main_window_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
2955 GdkModifierType modifiers;
2957 g_return_val_if_fail (GNC_IS_MAIN_WINDOW(widget), FALSE);
2959 priv = GNC_MAIN_WINDOW_GET_PRIVATE(widget);
2961 modifiers = gtk_accelerator_get_default_mod_mask ();
2963 if ((event->state & modifiers) == (GDK_CONTROL_MASK | GDK_MOD1_MASK))
2965 const gchar *account_key = C_ (
"lower case key for short cut to 'Accounts'",
"a");
2966 guint account_keyval = gdk_keyval_from_name (account_key);
2968 if ((account_keyval == event->keyval) || (account_keyval == gdk_keyval_to_lower (event->keyval)))
2972 for (GList *item = priv->
installed_pages; item; item = g_list_next (item))
2976 if (g_strcmp0 (pname,
"GncPluginPageAccountTree") == 0)
2978 gtk_notebook_set_current_page (GTK_NOTEBOOK(priv->
notebook), page);
2984 else if ((GDK_KEY_Menu == event->keyval) || (GDK_KEY_space == event->keyval))
2986 GList *menu = gtk_menu_get_for_attach_widget (GTK_WIDGET(priv->
notebook));
2990 gtk_menu_popup_at_widget (GTK_MENU(menu->data),
3009 GtkWindow *old_window;
3011 window = g_object_new (GNC_TYPE_MAIN_WINDOW, NULL);
3012 gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
3018 gtk_window_get_size (old_window, &width, &height);
3019 gtk_window_resize (GTK_WINDOW (window), width, height);
3020 if ((gdk_window_get_state((gtk_widget_get_window (GTK_WIDGET(old_window))))
3021 & GDK_WINDOW_STATE_MAXIMIZED) != 0)
3023 gtk_window_maximize (GTK_WINDOW (window));
3026 active_windows = g_list_append (active_windows, window);
3027 gnc_main_window_update_title(window);
3028 window->window_quitting = FALSE;
3029 window->just_plugin_prefs = FALSE;
3030 #ifdef MAC_INTEGRATION 3031 gnc_quartz_set_menu(window);
3033 gnc_main_window_update_all_menu_items();
3038 g_signal_connect (G_OBJECT(window),
"key-press-event",
3039 G_CALLBACK(gnc_main_window_key_press_event),
3050 gnc_main_window_engine_commit_error_callback( gpointer data,
3055 const gchar *reason = _(
"Unable to save to database.");
3057 reason = _(
"Unable to save to database: Book is marked read-only.");
3058 dialog = gtk_message_dialog_new( GTK_WINDOW(window),
3059 GTK_DIALOG_DESTROY_WITH_PARENT,
3064 gtk_dialog_run(GTK_DIALOG (dialog));
3065 gtk_widget_destroy(dialog);
3089 GtkWidget *tab_hbox,
3090 GtkWidget *menu_label)
3093 GtkNotebook *notebook;
3094 gint current_position = -1;
3096 page->
window = GTK_WIDGET(window);
3097 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3098 notebook = GTK_NOTEBOOK (priv->
notebook);
3105 gtk_notebook_insert_page_menu (notebook, page->
notebook_page,
3106 tab_hbox, menu_label, current_position);
3107 gtk_notebook_set_tab_reorderable (notebook, page->
notebook_page, TRUE);
3108 gnc_plugin_page_inserted (page);
3109 gtk_notebook_set_current_page (notebook, current_position);
3111 if (GNC_PLUGIN_PAGE_GET_CLASS(page)->window_changed)
3112 (GNC_PLUGIN_PAGE_GET_CLASS(page)->window_changed)(page, GTK_WIDGET(window));
3113 g_signal_emit (window, main_window_signals[PAGE_ADDED], 0, page);
3115 g_signal_connect(G_OBJECT(page->
notebook_page),
"popup-menu",
3117 g_signal_connect_after(G_OBJECT(page->
notebook_page),
"button-press-event",
3140 GtkNotebook *notebook;
3145 g_signal_handlers_disconnect_by_func(G_OBJECT(page->
notebook_page),
3147 g_signal_handlers_disconnect_by_func(G_OBJECT(page->
notebook_page),
3154 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3158 gnc_plugin_page_unselected (page);
3167 notebook = GTK_NOTEBOOK (priv->
notebook);
3170 new_page = g_list_nth_data (priv->
usage_order, 0);
3173 page_num = gtk_notebook_page_num(notebook, new_page->
notebook_page);
3174 gtk_notebook_set_current_page(notebook, page_num);
3179 while (gtk_events_pending())
3180 gtk_main_iteration();
3185 page_num = gtk_notebook_page_num(notebook, page->
notebook_page);
3186 gtk_notebook_remove_page (notebook, page_num);
3188 if ( gtk_notebook_get_current_page(notebook) == -1)
3194 gnc_main_window_switch_page(notebook, NULL, -1, window);
3198 gnc_plugin_page_removed (page);
3200 gtk_ui_manager_ensure_update (window->ui_merge);
3201 gnc_window_set_status (GNC_WINDOW(window), page, NULL);
3215 GtkNotebook *notebook;
3218 window = GNC_MAIN_WINDOW (page->
window);
3219 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3220 notebook = GTK_NOTEBOOK (priv->
notebook);
3221 page_num = gtk_notebook_page_num(notebook, page->
notebook_page);
3222 gtk_notebook_set_current_page (notebook, page_num);
3223 gtk_window_present(GTK_WINDOW(window));
3239 GtkWidget *tab_hbox;
3240 GtkWidget *
label, *entry;
3241 const gchar *icon, *text, *color_string, *lab_text;
3246 ENTER(
"window %p, page %p", window, page);
3248 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3249 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
3252 if (gnc_main_window_page_exists(page))
3262 for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
3264 window = GNC_MAIN_WINDOW(tmp->data);
3265 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3273 gtk_widget_show(GTK_WIDGET(window));
3275 else if ((window == NULL) && active_windows)
3277 window = active_windows->data;
3280 page->
window = GTK_WIDGET(window);
3288 icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
3290 label = gtk_label_new (lab_text);
3291 g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_TAB_LABEL,
label);
3293 tw = populate_tab_width_struct ();
3294 gnc_main_window_update_tab_width_one_page (page, tw);
3297 gtk_widget_show (
label);
3299 tab_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
3302 gtk_widget_set_name (GTK_WIDGET(tab_hbox),
"gnc-id-account-page-tab-box");
3304 gtk_box_set_homogeneous (GTK_BOX (tab_hbox), FALSE);
3305 gtk_widget_show (tab_hbox);
3309 image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU);
3310 gtk_widget_show (image);
3311 gtk_box_pack_start (GTK_BOX (tab_hbox), image, FALSE, FALSE, 0);
3312 gtk_widget_set_margin_start (GTK_WIDGET(image), 5);
3313 gtk_box_pack_start (GTK_BOX (tab_hbox),
label, TRUE, TRUE, 0);
3316 gtk_box_pack_start (GTK_BOX (tab_hbox),
label, TRUE, TRUE, 0);
3321 gtk_widget_set_tooltip_text(tab_hbox, text);
3324 entry = gtk_entry_new();
3325 gtk_widget_hide (entry);
3326 gtk_box_pack_start (GTK_BOX (tab_hbox), entry, TRUE, TRUE, 0);
3327 g_signal_connect(G_OBJECT(entry),
"activate",
3328 G_CALLBACK(gnc_main_window_tab_entry_activate), page);
3329 g_signal_connect(G_OBJECT(entry),
"focus-out-event",
3330 G_CALLBACK(gnc_main_window_tab_entry_focus_out_event),
3332 g_signal_connect(G_OBJECT(entry),
"key-press-event",
3333 G_CALLBACK(gnc_main_window_tab_entry_key_press_event),
3335 g_signal_connect(G_OBJECT(entry),
"editing-done",
3336 G_CALLBACK(gnc_main_window_tab_entry_editing_done),
3340 if (!g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE))
3342 GtkWidget *close_image, *close_button;
3343 GtkRequisition requisition;
3345 close_button = gtk_button_new();
3346 gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
3347 close_image = gtk_image_new_from_icon_name (
"window-close", GTK_ICON_SIZE_MENU);
3348 gtk_widget_show(close_image);
3349 gtk_widget_get_preferred_size (close_image, &requisition, NULL);
3350 gtk_widget_set_size_request(close_button, requisition.width + 4,
3351 requisition.height + 2);
3352 gtk_container_add(GTK_CONTAINER(close_button), close_image);
3354 gtk_widget_show (close_button);
3356 gtk_widget_hide (close_button);
3358 g_signal_connect_swapped (G_OBJECT (close_button),
"clicked",
3361 gtk_box_pack_start (GTK_BOX (tab_hbox), close_button, FALSE, FALSE, 0);
3362 gtk_widget_set_margin_end (GTK_WIDGET(close_button), 5);
3363 g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_CLOSE_BUTTON, close_button);
3374 gnc_main_window_connect(window, page, tab_hbox,
label);
3399 if (!GNC_IS_MAIN_WINDOW (page->
window))
3402 window = GNC_MAIN_WINDOW (page->
window);
3405 g_warning(
"Page is not in a window.");
3409 gnc_main_window_disconnect(window, page);
3411 g_object_unref(page);
3414 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3417 if (window->window_quitting)
3423 window->just_plugin_prefs = TRUE;
3424 g_list_foreach (plugins, gnc_main_window_remove_plugin, window);
3425 window->just_plugin_prefs = FALSE;
3426 g_list_free (plugins);
3429 gnc_main_window_remove_prefs (window);
3432 gtk_widget_destroy (GTK_WIDGET(window));
3449 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3461 const gchar *group_name,
3462 GtkActionGroup *group,
3466 MergedActionEntry *entry;
3468 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3469 g_return_if_fail (group_name != NULL);
3470 g_return_if_fail (GTK_IS_ACTION_GROUP(group));
3471 g_return_if_fail (merge_id > 0);
3473 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3474 entry = g_new0 (MergedActionEntry, 1);
3475 entry->action_group = group;
3476 entry->merge_id = merge_id;
3477 gtk_ui_manager_ensure_update (window->ui_merge);
3490 const gchar *group_name,
3491 GtkActionEntry *actions,
3493 GtkToggleActionEntry *toggle_actions,
3494 guint n_toggle_actions,
3495 const gchar *filename,
3500 MergedActionEntry *entry;
3501 GError *error = NULL;
3504 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3505 g_return_if_fail (group_name != NULL);
3506 g_return_if_fail (actions != NULL);
3507 g_return_if_fail (n_actions > 0);
3508 g_return_if_fail (filename != NULL);
3511 if (pathname == NULL)
3515 data->window = window;
3516 data->data = user_data;
3518 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3519 entry = g_new0 (MergedActionEntry, 1);
3520 entry->action_group = gtk_action_group_new (group_name);
3521 gtk_action_group_set_translation_domain (entry->action_group, PROJECT_NAME);
3522 gtk_action_group_add_actions (entry->action_group, actions, n_actions, data);
3523 if (toggle_actions != NULL && n_toggle_actions > 0)
3525 gtk_action_group_add_toggle_actions (entry->action_group,
3526 toggle_actions, n_toggle_actions,
3529 gtk_ui_manager_insert_action_group (window->ui_merge, entry->action_group, 0);
3530 entry->merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, pathname, &error);
3531 g_assert(entry->merge_id || error);
3532 if (entry->merge_id)
3534 gtk_ui_manager_ensure_update (window->ui_merge);
3539 g_critical(
"Failed to load ui file.\n Filename %s\n Error %s",
3540 filename, error->message);
3541 g_error_free(error);
3555 const gchar *group_name)
3558 MergedActionEntry *entry;
3560 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3561 g_return_if_fail (group_name != NULL);
3563 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3571 gtk_ui_manager_remove_action_group (window->ui_merge, entry->action_group);
3572 gtk_ui_manager_remove_ui (window->ui_merge, entry->merge_id);
3573 gtk_ui_manager_ensure_update (window->ui_merge);
3587 GtkActionGroup *force;
3589 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3595 force = gtk_action_group_new(
"force_update");
3596 gtk_ui_manager_insert_action_group (window->ui_merge, force, 0);
3597 gtk_ui_manager_ensure_update (window->ui_merge);
3598 gtk_ui_manager_remove_action_group (window->ui_merge, force);
3599 g_object_unref(force);
3606 GtkAction *action = NULL;
3607 const GList *groups, *tmp;
3609 groups = gtk_ui_manager_get_action_groups(window->ui_merge);
3610 for (tmp = groups; tmp; tmp = g_list_next(tmp))
3612 action = gtk_action_group_get_action(GTK_ACTION_GROUP(tmp->data), name);
3626 const gchar *group_name)
3629 MergedActionEntry *entry;
3631 g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), NULL);
3632 g_return_val_if_fail (group_name != NULL, NULL);
3634 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3642 return entry->action_group;
3646 gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_data)
3649 GtkPositionType position = GTK_POS_TOP;
3651 GtkAction *first_action;
3652 GtkAction *position_action;
3655 g_return_if_fail (GNC_IS_MAIN_WINDOW(user_data));
3657 window = GNC_MAIN_WINDOW(user_data);
3659 ENTER (
"window %p", window);
3667 position = GTK_POS_BOTTOM;
3669 position = GTK_POS_LEFT;
3671 position = GTK_POS_RIGHT;
3673 priv = GNC_MAIN_WINDOW_GET_PRIVATE (window);
3674 gtk_notebook_set_tab_pos (GTK_NOTEBOOK (priv->
notebook), position);
3678 first_action = gtk_action_group_get_action (priv->
action_group,
3679 tab_pos_radio_entries[0].name);
3681 for (i = n_tab_pos_radio_entries - 1; i > 0; i--)
3682 if (tab_pos_radio_entries[i].value == position)
3685 position_action = gtk_action_group_get_action (priv->
action_group,
3686 tab_pos_radio_entries[i].name);
3688 g_signal_handlers_block_by_func (G_OBJECT (first_action),
3689 G_CALLBACK (gnc_main_window_cmd_view_tab_position),
3691 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (position_action), TRUE);
3692 g_signal_handlers_unblock_by_func (G_OBJECT (first_action),
3693 G_CALLBACK (gnc_main_window_cmd_view_tab_position),
3696 gnc_main_window_update_tab_width (NULL, GNC_PREF_TAB_WIDTH, NULL);
3705 gnc_main_window_update_edit_actions_sensitivity (
GncMainWindow *window, gboolean hide)
3709 GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
3711 gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE;
3713 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3715 if (page && GNC_PLUGIN_PAGE_GET_CLASS(page)->update_edit_menu_actions)
3717 (GNC_PLUGIN_PAGE_GET_CLASS(page)->update_edit_menu_actions)(page, hide);
3721 if (GTK_IS_EDITABLE (widget))
3723 gboolean has_selection;
3725 has_selection = gtk_editable_get_selection_bounds
3726 (GTK_EDITABLE (widget), NULL, NULL);
3728 can_copy = has_selection;
3729 can_cut = has_selection;
3732 else if (GTK_IS_TEXT_VIEW (widget))
3734 gboolean has_selection;
3735 GtkTextBuffer *text_buffer;
3737 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(widget));
3738 has_selection = gtk_text_buffer_get_selection_bounds
3739 (text_buffer, NULL, NULL);
3741 can_copy = has_selection;
3742 can_cut = has_selection;
3747 #ifdef ORIGINAL_EPIPHANY_CODE 3749 can_copy = can_cut = can_paste = TRUE;
3753 can_copy = can_cut = can_paste = FALSE;
3758 gtk_action_set_sensitive (action, can_copy);
3759 gtk_action_set_visible (action, !hide || can_copy);
3761 gtk_action_set_sensitive (action, can_cut);
3762 gtk_action_set_visible (action, !hide || can_cut);
3764 gtk_action_set_sensitive (action, can_paste);
3765 gtk_action_set_visible (action, !hide || can_paste);
3769 gnc_main_window_enable_edit_actions_sensitivity (
GncMainWindow *window)
3774 gtk_action_set_sensitive (action, TRUE);
3775 gtk_action_set_visible (action, TRUE);
3777 gtk_action_set_sensitive (action, TRUE);
3778 gtk_action_set_visible (action, TRUE);
3780 gtk_action_set_sensitive (action, TRUE);
3781 gtk_action_set_visible (action, TRUE);
3785 gnc_main_window_edit_menu_show_cb (GtkWidget *menu,
3788 gnc_main_window_update_edit_actions_sensitivity (window, FALSE);
3792 gnc_main_window_edit_menu_hide_cb (GtkWidget *menu,
3795 gnc_main_window_enable_edit_actions_sensitivity (window);
3801 GtkWidget *edit_menu_item, *edit_menu;
3803 edit_menu_item = gtk_ui_manager_get_widget
3804 (window->ui_merge,
"/menubar/Edit");
3805 edit_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (edit_menu_item));
3807 g_signal_connect (edit_menu,
"show",
3808 G_CALLBACK (gnc_main_window_edit_menu_show_cb), window);
3809 g_signal_connect (edit_menu,
"hide",
3810 G_CALLBACK (gnc_main_window_edit_menu_hide_cb), window);
3817 #ifdef MAC_INTEGRATION 3823 GError *error = NULL;
3825 merge_id = gtk_ui_manager_add_ui_from_file(window->ui_merge, filename,
3829 #ifndef MAC_INTEGRATION 3830 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3831 gtk_action_group_add_radio_actions (priv->
action_group,
3832 radio_entries, n_radio_entries,
3834 G_CALLBACK(gnc_main_window_cmd_window_raise),
3841 gnc_main_window_page_focus_in (GtkWidget *widget, GdkEvent *event,
3847 g_signal_emit (window, main_window_signals[PAGE_CHANGED], 0, page);
3855 GtkWidget *main_vbox;
3859 GError *error = NULL;
3865 g_signal_connect (G_OBJECT (window),
"delete-event",
3866 G_CALLBACK (gnc_main_window_delete_event), window);
3869 main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
3870 gtk_box_set_homogeneous (GTK_BOX (main_vbox), FALSE);
3871 gtk_widget_show (main_vbox);
3872 gtk_container_add (GTK_CONTAINER (window), main_vbox);
3874 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3875 priv->
menu_dock = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
3876 gtk_box_set_homogeneous (GTK_BOX (priv->
menu_dock), FALSE);
3878 gtk_box_pack_start (GTK_BOX (main_vbox), priv->
menu_dock,
3881 priv->
notebook = gtk_notebook_new ();
3882 g_object_set(G_OBJECT(priv->
notebook),
3884 "enable-popup", TRUE,
3887 g_signal_connect (G_OBJECT (priv->
notebook),
"switch-page",
3888 G_CALLBACK (gnc_main_window_switch_page), window);
3889 g_signal_connect (G_OBJECT (priv->
notebook),
"page-reordered",
3890 G_CALLBACK (gnc_main_window_page_reordered), window);
3891 g_signal_connect (G_OBJECT (priv->
notebook),
"focus-in-event",
3892 G_CALLBACK (gnc_main_window_page_focus_in), window);
3893 gtk_box_pack_start (GTK_BOX (main_vbox), priv->
notebook,
3898 gtk_box_pack_start (GTK_BOX (main_vbox), priv->
statusbar,
3902 gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR(priv->
progressbar), TRUE);
3903 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(priv->
progressbar),
" ");
3907 gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(priv->
progressbar),
3910 window->ui_merge = gtk_ui_manager_new ();
3913 priv->
action_group = gtk_action_group_new (
"MainWindowActions");
3914 gtk_action_group_set_translation_domain (priv->
action_group, PROJECT_NAME);
3915 gtk_action_group_add_actions (priv->
action_group, gnc_menu_actions,
3916 gnc_menu_n_actions, window);
3917 gtk_action_group_add_toggle_actions (priv->
action_group,
3918 toggle_actions, n_toggle_actions,
3921 initially_insensitive_actions,
3922 "sensitive", FALSE);
3924 always_insensitive_actions,
3925 "sensitive", FALSE);
3927 always_hidden_actions,
3930 gnc_menu_important_actions);
3931 gtk_ui_manager_insert_action_group (window->ui_merge, priv->
action_group, 0);
3933 g_signal_connect (G_OBJECT (window->ui_merge),
"add_widget",
3934 G_CALLBACK (gnc_main_window_add_widget), window);
3937 g_signal_connect (G_OBJECT (window->ui_merge),
"connect-proxy",
3943 g_assert (filename);
3945 merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge,
3947 g_assert(merge_id || error);
3950 gtk_action_group_add_radio_actions (priv->
action_group,
3951 tab_pos_radio_entries,
3952 n_tab_pos_radio_entries,
3954 G_CALLBACK(gnc_main_window_cmd_view_tab_position),
3956 gtk_window_add_accel_group (GTK_WINDOW (window),
3957 gtk_ui_manager_get_accel_group(window->ui_merge));
3958 gtk_ui_manager_ensure_update (window->ui_merge);
3962 g_critical(
"Failed to load ui file.\n Filename %s\n Error %s",
3963 filename, error->message);
3964 g_error_free(error);
3965 g_assert(merge_id != 0);
3968 gnc_main_window_window_menu(window);
3970 GNC_PREF_TAB_POSITION_TOP,
3971 gnc_main_window_update_tab_position,
3974 GNC_PREF_TAB_POSITION_BOTTOM,
3975 gnc_main_window_update_tab_position,
3978 GNC_PREF_TAB_POSITION_LEFT,
3979 gnc_main_window_update_tab_position,
3982 GNC_PREF_TAB_POSITION_RIGHT,
3983 gnc_main_window_update_tab_position,
3985 gnc_main_window_update_tab_position(NULL, NULL, window);
3987 gnc_main_window_init_menu_updaters(window);
3991 if (!gnc_prefs_is_extra_enabled())
3995 action = gtk_action_group_get_action(priv->
action_group,
3996 "ExtensionsAction");
3997 gtk_action_set_visible(action, FALSE);
4003 g_list_foreach (plugins, gnc_main_window_add_plugin, window);
4004 g_list_free (plugins);
4006 g_signal_connect (G_OBJECT (manager),
"plugin-added",
4007 G_CALLBACK (gnc_main_window_plugin_added), window);
4008 g_signal_connect (G_OBJECT (manager),
"plugin-removed",
4009 G_CALLBACK (gnc_main_window_plugin_removed), window);
4014 #ifdef MAC_INTEGRATION 4023 gnc_quartz_shutdown (GtkosxApplication *theApp, gpointer data)
4034 gnc_quartz_should_quit (GtkosxApplication *theApp,
GncMainWindow *window)
4037 gnc_main_window_quit (window);
4044 GtkosxApplication *theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
4048 menu = gtk_ui_manager_get_widget (window->ui_merge,
"/menubar");
4049 if (GTK_IS_MENU_ITEM (menu))
4050 menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu));
4051 gtk_widget_hide(menu);
4052 gtkosx_application_set_menu_bar (theApp, GTK_MENU_SHELL (menu));
4054 item = gtk_ui_manager_get_widget (window->ui_merge,
4055 "/menubar/File/FileQuit");
4056 if (GTK_IS_MENU_ITEM (item))
4057 gtk_widget_hide (GTK_WIDGET (item));
4059 item = gtk_ui_manager_get_widget (window->ui_merge,
4060 "/menubar/Help/HelpAbout");
4061 if (GTK_IS_MENU_ITEM (item))
4063 gtkosx_application_insert_app_menu_item (theApp, GTK_WIDGET (item), 0);
4066 item = gtk_ui_manager_get_widget (window->ui_merge,
4067 "/menubar/Edit/EditPreferences");
4068 if (GTK_IS_MENU_ITEM (item))
4070 gtkosx_application_insert_app_menu_item (theApp,
4071 gtk_separator_menu_item_new (), 1);
4072 gtkosx_application_insert_app_menu_item (theApp, GTK_WIDGET (item), 2);
4075 item = gtk_ui_manager_get_widget (window->ui_merge,
4077 gtkosx_application_set_help_menu(theApp, GTK_MENU_ITEM(item));
4078 item = gtk_ui_manager_get_widget (window->ui_merge,
4079 "/menubar/Windows");
4080 gtkosx_application_set_window_menu(theApp, GTK_MENU_ITEM(item));
4081 g_signal_connect(theApp,
"NSApplicationBlockTermination",
4082 G_CALLBACK(gnc_quartz_should_quit), window);
4083 gtkosx_application_set_use_quartz_accelerators (theApp, FALSE);
4084 g_object_unref (theApp);
4087 #endif //MAC_INTEGRATION 4091 gnc_main_window_add_widget (GtkUIManager *merge,
4097 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
4098 if (GTK_IS_TOOLBAR (widget))
4101 gtk_toolbar_set_style (GTK_TOOLBAR(priv->
toolbar),
4103 gtk_toolbar_set_icon_size (GTK_TOOLBAR(priv->
toolbar),
4104 GTK_ICON_SIZE_SMALL_TOOLBAR);
4107 gtk_box_pack_start (GTK_BOX (priv->
menu_dock), widget, FALSE, FALSE, 0);
4108 gtk_widget_show (widget);
4124 gnc_main_window_show_summarybar (
GncMainWindow *window, GtkAction *action)
4128 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
4130 action = gtk_action_group_get_action(priv->
action_group,
4131 "ViewSummaryAction");
4134 return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
4147 gnc_main_window_switch_page (GtkNotebook *notebook,
4148 gpointer *notebook_page,
4157 ENTER(
"Notebook %p, page, %p, index %d, window %p",
4158 notebook, notebook_page, pos, window);
4159 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
4161 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
4166 gnc_plugin_page_unselected (page);
4169 child = gtk_notebook_get_nth_page (notebook, pos);
4185 visible = gnc_main_window_show_summarybar(window, NULL);
4189 gnc_plugin_page_selected (page);
4190 gnc_window_update_status (GNC_WINDOW(window), page);
4198 multiple_page_actions,
4202 gnc_main_window_update_title(window);
4203 #ifndef MAC_INTEGRATION 4204 gnc_main_window_update_menu_item(window);
4206 g_signal_emit (window, main_window_signals[PAGE_CHANGED], 0, page);
4217 gnc_main_window_page_reordered (GtkNotebook *notebook,
4226 ENTER(
"Notebook %p, child %p, index %d, window %p",
4227 notebook, child, pos, window);
4228 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
4232 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
4238 if (!old_link)
return;
4249 gnc_main_window_plugin_added (
GncPlugin *manager,
4253 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
4254 g_return_if_fail (GNC_IS_PLUGIN (plugin));
4260 gnc_main_window_plugin_removed (
GncPlugin *manager,
4264 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
4265 g_return_if_fail (GNC_IS_PLUGIN (plugin));
4273 gnc_main_window_cmd_page_setup (GtkAction *action,
4276 GtkWindow *gtk_window;
4278 g_return_if_fail(GNC_IS_MAIN_WINDOW(window));
4280 gtk_window = gnc_window_get_gtk_window(GNC_WINDOW(window));
4287 QofBook *book = gnc_get_current_book ();
4288 gboolean use_split_action_for_num_before =
4290 gboolean use_book_currency_before =
4292 gint use_read_only_threshold_before =
4294 gboolean use_split_action_for_num_after;
4295 gboolean use_book_currency_after;
4296 gint use_read_only_threshold_after;
4297 gboolean return_val = FALSE;
4298 GList *results = NULL, *iter;
4300 if (!options)
return return_val;
4302 results = gnc_option_db_commit (options);
4303 for (iter = results; iter; iter = iter->next)
4311 gtk_dialog_run(GTK_DIALOG(dialog));
4312 gtk_widget_destroy(dialog);
4313 g_free (iter->data);
4315 g_list_free (results);
4316 qof_book_begin_edit (book);
4318 use_split_action_for_num_after =
4323 book->cached_num_days_autoreadonly_isvalid = FALSE;
4326 if (use_split_action_for_num_before != use_split_action_for_num_after)
4329 use_split_action_for_num_after);
4332 if (use_book_currency_before != use_book_currency_after)
4337 if (use_read_only_threshold_before != use_read_only_threshold_after)
4340 qof_book_commit_edit (book);
4345 gnc_book_options_dialog_apply_cb(GNCOptionWin * optionwin,
4348 GNCOptionDB * options = user_data;
4350 if (!options)
return;
4353 gnc_gui_refresh_all ();
4357 gnc_book_options_dialog_close_cb(GNCOptionWin * optionwin,
4360 GNCOptionDB * options = user_data;
4362 gnc_options_dialog_destroy(optionwin);
4363 gnc_option_db_destroy(options);
4372 gnc_suspend_gui_refresh ();
4379 GNC_FEATURE_NUM_FIELD_SOURCE);
4381 gnc_book_option_num_field_source_change (num_action);
4382 gnc_resume_gui_refresh ();
4391 gnc_suspend_gui_refresh ();
4392 if (use_book_currency)
4398 GNC_FEATURE_BOOK_CURRENCY);
4400 gnc_book_option_book_currency_selected (use_book_currency);
4401 gnc_resume_gui_refresh ();
4405 show_handler (
const char *class_name, gint component_id,
4406 gpointer user_data, gpointer iter_data)
4408 GNCOptionWin *optwin = user_data;
4414 widget = gnc_options_dialog_widget(optwin);
4416 gtk_window_present(GTK_WINDOW(widget));
4423 QofBook *book = gnc_get_current_book ();
4424 GNCOptionDB *options;
4425 GNCOptionWin *optionwin;
4427 options = gnc_option_db_new_for_type (QOF_ID_BOOK);
4429 gnc_option_db_clean (options);
4433 if (gnc_forall_gui_components(DIALOG_BOOK_OPTIONS_CM_CLASS,
4434 show_handler, NULL))
4438 optionwin = gnc_options_dialog_new_modal (
4440 (title ? title : _(
"Book Options")),
4441 DIALOG_BOOK_OPTIONS_CM_CLASS, parent);
4442 gnc_options_dialog_build_contents (optionwin, options);
4446 gnc_options_dialog_set_apply_cb (optionwin,
4447 gnc_book_options_dialog_apply_cb,
4449 gnc_options_dialog_set_close_cb (optionwin,
4450 gnc_book_options_dialog_close_cb,
4454 return gnc_options_dialog_widget (optionwin);
4458 gnc_main_window_cmd_file_properties (GtkAction *action,
GncMainWindow *window)
4464 gnc_main_window_cmd_file_close (GtkAction *action,
GncMainWindow *window)
4469 g_return_if_fail(GNC_IS_MAIN_WINDOW(window));
4471 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
4477 gnc_main_window_cmd_file_quit (GtkAction *action,
GncMainWindow *window)
4482 gnc_main_window_quit(window);
4486 gnc_main_window_cmd_edit_cut (GtkAction *action,
GncMainWindow *window)
4488 GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window));
4490 if (GTK_IS_EDITABLE(widget))
4492 gtk_editable_cut_clipboard (GTK_EDITABLE(widget));
4494 else if (GTK_IS_TEXT_VIEW(widget))
4496 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(widget));
4497 GtkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET(widget),
4498 GDK_SELECTION_CLIPBOARD);
4499 gboolean editable = gtk_text_view_get_editable (GTK_TEXT_VIEW(widget));
4502 gtk_text_buffer_cut_clipboard (text_buffer, clipboard, editable);
4507 gnc_main_window_cmd_edit_copy (GtkAction *action,
GncMainWindow *window)
4509 GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window));
4511 if (GTK_IS_EDITABLE(widget))
4513 gtk_editable_copy_clipboard (GTK_EDITABLE(widget));
4515 else if (GTK_IS_TEXT_VIEW(widget))
4517 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(widget));
4518 GtkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET(widget),
4519 GDK_SELECTION_CLIPBOARD);
4521 gtk_text_buffer_copy_clipboard (text_buffer, clipboard);
4526 gnc_main_window_cmd_edit_paste (GtkAction *action,
GncMainWindow *window)
4528 GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window));
4530 if (GTK_IS_EDITABLE(widget))
4532 gtk_editable_paste_clipboard (GTK_EDITABLE(widget));
4534 else if (GTK_IS_TEXT_VIEW(widget))
4536 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(widget));
4537 GtkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET(widget),
4538 GDK_SELECTION_CLIPBOARD);
4539 gboolean editable = gtk_text_view_get_editable (GTK_TEXT_VIEW(widget));
4542 gtk_text_buffer_paste_clipboard (text_buffer, clipboard, NULL, editable);
4547 gnc_main_window_cmd_edit_preferences (GtkAction *action,
GncMainWindow *window)
4553 gnc_main_window_cmd_view_refresh (GtkAction *action,
GncMainWindow *window)
4558 gnc_main_window_cmd_actions_reset_warnings (GtkAction *action,
GncMainWindow *window)
4560 gnc_reset_warnings_dialog(GTK_WINDOW(window));
4564 gnc_main_window_cmd_actions_rename_page (GtkAction *action,
GncMainWindow *window)
4568 GtkWidget *
label, *entry;
4571 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
4575 LEAVE(
"No current page");
4579 if (!main_window_find_tab_items(window, page, &
label, &entry))
4581 LEAVE(
"can't find required widgets");
4585 gtk_entry_set_text(GTK_ENTRY(entry), gtk_label_get_text(GTK_LABEL(
label)));
4586 gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1);
4587 gtk_widget_hide(
label);
4588 gtk_widget_show(entry);
4589 gtk_widget_grab_focus(entry);
4590 LEAVE(
"opened for editing");
4594 gnc_main_window_cmd_view_toolbar (GtkAction *action,
GncMainWindow *window)
4598 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
4599 if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))
4601 gtk_widget_show (priv->
toolbar);
4605 gtk_widget_hide (priv->
toolbar);
4610 gnc_main_window_cmd_view_summary (GtkAction *action,
GncMainWindow *window)
4616 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
4617 visible = gnc_main_window_show_summarybar(window, action);
4625 gnc_main_window_cmd_view_statusbar (GtkAction *action,
GncMainWindow *window)
4629 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
4630 if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))
4641 gnc_main_window_cmd_window_new (GtkAction *action,
GncMainWindow *window)
4648 gtk_widget_show(GTK_WIDGET(new_window));
4653 gnc_main_window_cmd_window_move_page (GtkAction *action,
GncMainWindow *window)
4658 GtkNotebook *notebook;
4659 GtkWidget *tab_widget, *menu_widget;
4661 ENTER(
"action %p,window %p", action, window);
4664 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
4668 LEAVE(
"invalid page");
4673 LEAVE(
"invalid notebook_page");
4677 notebook = GTK_NOTEBOOK (priv->
notebook);
4678 tab_widget = gtk_notebook_get_tab_label (notebook, page->
notebook_page);
4679 menu_widget = gtk_notebook_get_menu_label (notebook, page->
notebook_page);
4686 g_object_ref(tab_widget);
4687 g_object_ref(menu_widget);
4689 gnc_main_window_disconnect(window, page);
4693 gtk_widget_show(GTK_WIDGET(new_window));
4696 gnc_main_window_connect (new_window, page, tab_widget, menu_widget);
4700 g_object_unref(menu_widget);
4701 g_object_unref(tab_widget);
4702 g_object_unref(page);
4705 DEBUG(
"Moved page %p from window %p to new window %p",
4706 page, window, new_window);
4707 DEBUG(
"Old window current is %p, new window current is %p",
4710 LEAVE(
"page moved");
4714 gnc_main_window_cmd_view_tab_position (GtkAction *action,
4715 GtkRadioAction *current,
4718 GtkPositionType value = gtk_radio_action_get_current_value(current);
4720 if (value != GTK_POS_TOP &&
gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP))
4723 if (value != GTK_POS_BOTTOM &&
gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM))
4726 if (value != GTK_POS_LEFT &&
gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT))
4729 if (value != GTK_POS_RIGHT &&
gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT))
4738 case GTK_POS_BOTTOM:
4752 #ifndef MAC_INTEGRATION 4754 gnc_main_window_cmd_window_raise (GtkAction *action,
4755 GtkRadioAction *current,
4761 g_return_if_fail(GTK_IS_ACTION(action));
4762 g_return_if_fail(GTK_IS_RADIO_ACTION(current));
4763 g_return_if_fail(GNC_IS_MAIN_WINDOW(old_window));
4765 ENTER(
"action %p, current %p, window %p", action, current, old_window);
4766 value = gtk_radio_action_get_current_value(current);
4767 new_window = g_list_nth_data(active_windows, value);
4768 gtk_window_present(GTK_WINDOW(new_window));
4771 g_idle_add((GSourceFunc)gnc_main_window_update_radio_button, old_window);
4777 gnc_main_window_cmd_help_tutorial (GtkAction *action,
GncMainWindow *window)
4783 gnc_main_window_cmd_help_contents (GtkAction *action,
GncMainWindow *window)
4798 get_file (
const gchar *partial)
4800 gchar *filename, *text = NULL;
4804 if (filename && g_file_get_contents(filename, &text, &length, NULL))
4828 get_file_strsplit (
const gchar *partial)
4830 gchar *text, **lines;
4832 text = get_file(partial);
4836 lines = g_strsplit_set(text,
"\r\n", -1);
4847 url_signal_cb (GtkAboutDialog *dialog, gchar *uri, gpointer data)
4854 link_button_cb (GtkLinkButton *button, gpointer user_data)
4856 const gchar *uri = gtk_link_button_get_uri (button);
4862 add_about_paths (GtkDialog *dialog)
4871 PWARN(
"Unable to find AboutDialog 'page_vbox' Widget");
4875 grid = gtk_grid_new ();
4878 for (GList *path_node = paths; path_node; path_node = g_list_next (path_node))
4882 gchar *env_name = g_strconcat (ep->env_name,
":", NULL);
4883 GtkWidget *
label = gtk_label_new (env_name);
4885 gchar *display_uri = gnc_doclink_get_unescaped_just_uri (uri);
4886 GtkWidget *widget = gtk_link_button_new_with_label (uri, display_uri);
4888 gtk_grid_attach (GTK_GRID(grid),
label, 0, i, 1, 1);
4889 gtk_widget_set_halign (
label, GTK_ALIGN_END);
4890 gtk_grid_attach (GTK_GRID(grid), widget, 1, i, 1, 1);
4891 gtk_widget_set_halign (widget, GTK_ALIGN_START);
4892 gtk_widget_set_margin_top (widget, 0);
4893 gtk_widget_set_margin_bottom (widget, 0);
4897 GtkWidget *mod_lab = gtk_label_new (_(
"(user modifiable)"));
4898 gtk_grid_attach (GTK_GRID(grid), mod_lab, 2, i, 1, 1);
4899 gtk_widget_show (mod_lab);
4901 g_signal_connect (widget,
"activate-link",
4902 G_CALLBACK(link_button_cb), dialog);
4905 g_free (display_uri);
4908 gtk_container_add_with_properties (GTK_CONTAINER(page_vbox), grid,
4909 "position", 1, NULL);
4910 gtk_widget_show_all (grid);
4911 g_list_free_full (paths, g_free);
4921 gnc_main_window_cmd_help_about (GtkAction *action,
GncMainWindow *window)
4924 gchar *copyright = g_strdup_printf(_(
"Copyright © 1997-%s The GnuCash contributors."),
4926 gchar **authors = get_file_strsplit(
"AUTHORS");
4927 gchar **documenters = get_file_strsplit(
"DOCUMENTERS");
4928 gchar *license = get_file(
"LICENSE");
4929 GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
4930 GdkPixbuf *logo = gtk_icon_theme_load_icon (icon_theme,
4933 GTK_ICON_LOOKUP_USE_BUILTIN,
4935 gchar *version = g_strdup_printf (
"%s: %s\n%s: %s\nFinance::Quote: %s",
4937 _(
"Build ID"), gnc_build_id(),
4941 GtkDialog *dialog = GTK_DIALOG (gtk_about_dialog_new ());
4942 g_object_set (G_OBJECT (dialog),
4944 "documenters", documenters,
4945 "comments", _(
"Accounting for personal and small business finance."),
4946 "copyright", copyright,
4954 "translator-credits", _(
"translator-credits"),
4956 "website", PACKAGE_URL,
4957 "website-label", _(
"Visit the GnuCash website."),
4965 g_strfreev(documenters);
4967 g_strfreev(authors);
4968 g_object_unref (logo);
4969 g_signal_connect (dialog,
"activate-link",
4970 G_CALLBACK (url_signal_cb), NULL);
4973 add_about_paths (dialog);
4976 gtk_window_set_resizable(GTK_WINDOW (dialog), TRUE);
4978 gtk_window_set_transient_for (GTK_WINDOW (dialog),
4979 GTK_WINDOW (window));
4980 gtk_dialog_run (dialog);
4981 gtk_widget_destroy (GTK_WIDGET (dialog));
4993 #ifdef MAC_INTEGRATION 4994 GtkosxApplication *theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
4996 for (window_iter = active_windows; window_iter != NULL; window_iter = window_iter->next)
4998 gtk_widget_show(GTK_WIDGET(window_iter->data));
5000 #ifdef MAC_INTEGRATION 5001 g_signal_connect(theApp,
"NSApplicationWillTerminate",
5002 G_CALLBACK(gnc_quartz_shutdown), NULL);
5003 gtkosx_application_ready(theApp);
5004 g_object_unref (theApp);
5011 GtkWidget *toplevel;
5016 toplevel = gtk_widget_get_toplevel (widget);
5017 if (toplevel && GTK_IS_WINDOW (toplevel))
5018 return GTK_WINDOW (toplevel);
5029 while (toplevel && !GNC_IS_MAIN_WINDOW (toplevel))
5030 toplevel = gtk_window_get_transient_for(toplevel);
5035 for (window = active_windows; window; window = window->next)
5036 if (gtk_window_is_active (GTK_WINDOW (window->data)))
5037 return window->data;
5039 for (window = active_windows; window; window = window->next)
5040 if (gtk_widget_get_mapped (GTK_WIDGET(window->data)))
5041 return window->data;
5053 gnc_main_window_get_gtk_window (GncWindow *window)
5055 g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), NULL);
5056 return GTK_WINDOW(window);
5066 gnc_main_window_get_statusbar (GncWindow *window_in)
5071 g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window_in), NULL);
5073 window = GNC_MAIN_WINDOW(window_in);
5074 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
5085 gnc_main_window_get_progressbar (GncWindow *window_in)
5090 g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window_in), NULL);
5092 window = GNC_MAIN_WINDOW(window_in);
5093 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
5099 gnc_main_window_all_ui_set_sensitive (GncWindow *unused, gboolean sensitive)
5103 GList *groupp, *groups, *winp, *tmp;
5104 GtkWidget *close_button;
5106 for (winp = active_windows; winp; winp = g_list_next(winp))
5108 window = winp->data;
5109 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
5111 groups = gtk_ui_manager_get_action_groups(window->ui_merge);
5112 for (groupp = groups; groupp; groupp = g_list_next(groupp))
5114 gtk_action_group_set_sensitive(GTK_ACTION_GROUP(groupp->data), sensitive);
5119 close_button = g_object_get_data(tmp->data, PLUGIN_PAGE_CLOSE_BUTTON);
5122 gtk_widget_set_sensitive (close_button, sensitive);
5135 iface->get_gtk_window = gnc_main_window_get_gtk_window;
5136 iface->get_statusbar = gnc_main_window_get_statusbar;
5137 iface->get_progressbar = gnc_main_window_get_progressbar;
5138 iface->ui_set_sensitive = gnc_main_window_all_ui_set_sensitive;
5150 gncwin = GNC_WINDOW(window);
5151 gnc_window_set_progressbar_window(gncwin);
5170 GtkUIManager *ui_merge;
5173 g_return_if_fail(GNC_IS_PLUGIN_PAGE(page));
5175 ENTER(
"page %p, event %p", page, event);
5177 if (ui_merge == NULL)
5179 LEAVE(
"no ui merge");
5183 menu = gtk_ui_manager_get_widget(ui_merge,
"/MainPopup");
5189 gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event);
5212 ENTER(
"widget %p, page %p", widget, page);
5213 do_popup_menu(page, NULL);
5225 GdkEventButton *event,
5228 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
5230 ENTER(
"widget %p, event %p, page %p", whatever, event, page);
5232 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
5234 do_popup_menu(page, event);
5235 LEAVE(
"menu shown");
5239 LEAVE(
"other click");
5250 for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
5253 gtk_action_set_sensitive (action, sensitive);
5260 return window->ui_merge;
void gnc_preferences_dialog(GtkWindow *parent)
This function creates the preferences dialog and presents it to the user.
GtkActionGroup * action_group
The group of all actions provided by the main window itself.
GncPluginPage * gnc_plugin_page_recreate_page(GtkWidget *window, const gchar *page_type, GKeyFile *key_file, const gchar *page_group)
This function looks up a specific plugin type by name, and then calls a plugin specific function to c...
GtkWidget * statusbar
A pointer to the status bar at the bottom edge of the window.
Functions to load, save and get gui state.
gboolean gnc_plugin_page_has_books(GncPluginPage *page)
Query a page to see if it has a reference to any book.
gboolean gnc_plugin_page_get_use_new_window(GncPluginPage *page)
Retrieve the "use new window" setting associated with this page.
gboolean gnc_plugin_page_finish_pending(GncPluginPage *page)
Tell a page to finish any outstanding activities.
void gnc_main_window_restore_all_windows(const GKeyFile *keyfile)
Restore the persistent state of all windows.
void gnc_plugin_page_destroy_widget(GncPluginPage *plugin_page)
Destroy the display widget that corresponds to this plugin.
The instance data structure for a content plugin.
void qof_book_set_dirty_cb(QofBook *book, QofBookDirtyCB cb, gpointer user_data)
Set the function to call when a book transitions from clean to dirty, or vice versa.
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
gboolean gnc_main_window_button_press_cb(GtkWidget *whatever, GdkEventButton *event, GncPluginPage *page)
Callback function invoked when the user clicks in the content of any Gnucash window.
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
Register a callback that gets triggered when the given preference changes.
gboolean gnc_book_use_book_currency(QofBook *book)
Returns TRUE if both book-currency and default gain/loss policy KVPs exist and are valid and trading ...
GtkWindow * gnc_ui_get_main_window(GtkWidget *widget)
Get a pointer to the final GncMainWindow widget is rooted in.
utility functions for the GnuCash UI
#define PINFO(format, args...)
Print an informational note.
void gnc_gobject_tracking_remember(GObject *object, GObjectClass *klass)
Tell gnucash to remember this object in the database.
functions to query various version related strings that were set at build time.
QofBackendError
The errors that can be reported to the GUI & other front-end users.
void gnc_main_window_merge_actions(GncMainWindow *window, const gchar *group_name, GtkActionEntry *actions, guint n_actions, GtkToggleActionEntry *toggle_actions, guint n_toggle_actions, const gchar *filename, gpointer user_data)
Add a set of actions to the specified window.
const gchar * gnc_plugin_page_get_page_long_name(GncPluginPage *page)
Retrieve the long name of this page.
gulong gnc_prefs_get_reg_negative_color_pref_id(void)
Get and Set registered preference id for register negative_color_pref.
void gnc_gobject_tracking_forget(GObject *object)
Tell gnucash to remember this object in the database.
time64 qof_book_get_session_dirty_time(const QofBook *book)
Retrieve the earliest modification time on the book.
gboolean gnc_book_options_dialog_apply_helper(GNCOptionDB *options)
Processes selected options in the Book Options dialog: checks book_currency and use_split_action_for_...
This data structure allows the passing of the tab width and whether the tab layout is on the left or ...
#define DEBUG(format, args...)
Print a debugging message.
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
Retrieve the name of this page.
gint qof_book_get_num_days_autoreadonly(const QofBook *book)
Returns the number of days for auto-read-only transactions.
Functions that are supported by all types of windows.
void gnc_features_set_used(QofBook *book, const gchar *feature)
Indicate that the current book uses the given feature.
gboolean qof_book_use_split_action_for_num_field(const QofBook *book)
Returns TRUE if this book uses split action field as the 'Num' field, FALSE if it uses transaction nu...
GtkWidget * toolbar
The toolbar created by the UI manager.
GKeyFile helper routines.
gboolean restoring_pages
Set when restoring plugin pages.
gint pos[2]
Array for window position.
Plugin management functions for the GnuCash UI.
GtkWidget * window
The window that contains the display widget for this plugin.
gint event_handler_id
The identifier for this window's engine event handler.
gchar * gnc_uri_get_path(const gchar *uri)
Extracts the path part from a uri.
const gchar * gnc_plugin_page_get_page_color(GncPluginPage *page)
Retrieve the color of this page.
gboolean gnc_main_window_is_restoring_pages(GncMainWindow *window)
Check if the main window is restoring the plugin pages.
GtkWidget * gnc_book_options_dialog_cb(gboolean modal, gchar *title, GtkWindow *parent)
Opens the Book Options dialog.
void gnc_plugin_page_unmerge_actions(GncPluginPage *page, GtkUIManager *ui_merge)
Remove the actions for a content page from the specified window.
void gnc_plugin_page_set_page_long_name(GncPluginPage *page, const char *name)
Set the long name of this page.
gchar * gnc_filepath_locate_ui_file(const gchar *name)
Given a ui file name, find the file in the ui directory associated with this application.
void gnc_engine_add_commit_error_callback(EngineCommitErrorCallback cb, gpointer data)
Set a callback function to be called in case an engine commit fails.
void gnc_shutdown(int exit_status)
Shutdown gnucash.
void gnc_ui_page_setup(GtkWindow *parent)
Run a page setup dialog and save the resulting GtkPageSetup in a static variable. ...
void gnc_main_window_unmerge_actions(GncMainWindow *window, const gchar *group_name)
Remove a set of actions from the specified window.
#define ENTER(format, args...)
Print a function entry debugging message.
GtkWindow * gnc_ui_get_gtk_window(GtkWidget *widget)
Get a pointer to the widget's immediate top level GtkWindow.
void gnc_main_window_show_all_windows(void)
Shows all main windows.
void gnc_book_option_num_field_source_change_cb(gboolean num_action)
Calls gnc_book_option_num_field_source_change to initiate registered callbacks when num_field_source ...
void gnc_main_window_display_page(GncPluginPage *page)
Bring the window containing the specified page to the top of the window stack, then switch the notebo...
void gnc_main_window_save_all_windows(GKeyFile *keyfile)
Save the persistent state of all windows.
GncPluginPage * gnc_main_window_get_current_page(GncMainWindow *window)
Retrieve a pointer to the page that is currently at the front of the specified window.
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
gint gnc_prefs_get_int(const gchar *group, const gchar *pref_name)
Get an integer value from the preferences backend.
Functions for adding content to a window.
GtkWidget * gnc_get_dialog_widget_from_id(GtkDialog *dialog, const gchar *id)
Find the Widget defined by 'id' in the dialog.
gint qof_event_register_handler(QofEventHandler handler, gpointer user_data)
Register a handler for events.
#define PWARN(format, args...)
Log a warning.
void gnc_prefs_remove_cb_by_id(const gchar *group, guint id)
Remove a function that was registered for a callback when a specific preference in the settings group...
void gnc_main_window_all_action_set_sensitive(const gchar *action_name, gboolean sensitive)
Change the sensitivity of a command in all windows.
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
#define QOF_CHECK_TYPE(obj, type)
return TRUE if object is of the given type
void main_window_update_page_color(GncPluginPage *page, const gchar *color_in)
Update the color on the page tabs in the main window.
gchar * gnc_uri_normalize_uri(const gchar *uri, gboolean allow_password)
Composes a normalized uri starting from any uri (filename, db spec,...).
gchar * gnc_filepath_locate_doc_file(const gchar *name)
Given a documentation file name, find the file in the doc directory associated with this application...
gint QofEventId
Define the type of events allowed.
void qof_book_mark_session_saved(QofBook *book)
The qof_book_mark_saved() routine marks the book as having been saved (to a file, to a database)...
void gnc_plugin_page_set_use_new_window(GncPluginPage *page, gboolean use_new)
Set the "use new window" setting associated with this page.
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...
gboolean gnc_prefs_set_bool(const gchar *group, const gchar *pref_name, gboolean value)
Store a boolean value into the preferences backend.
GtkWidget * notebook
The notebook containing all the pages in this window.
void gnc_plugin_page_disconnect_page_changed(GncPluginPage *page)
Disconnect the page_changed_id signal callback.
void gnc_book_option_book_currency_selected_cb(gboolean use_book_currency)
Calls gnc_book_option_book_currency_selected to initiate registered callbacks when currency accountin...
gboolean gnc_plugin_page_has_book(GncPluginPage *page, QofBook *book)
Query a page to see if it has a reference to a given book.
char * gnc_print_time64(time64 time, const char *format)
print a time64 as a date string per format
gboolean gnc_main_window_popup_menu_cb(GtkWidget *widget, GncPluginPage *page)
Callback function invoked when the user requests that Gnucash popup the contextual menu via the keybo...
The instance private data structure for an embedded window object.
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 O...
void qof_event_unregister_handler(gint handler_id)
Unregister an event handler.
gboolean window_quitting
Set to TRUE when quitting from this window.
GncPluginManager * gnc_plugin_manager_get(void)
Retrieve a pointer to the plugin manager.
GList * usage_order
A list of pages in order of use (most recent -> least recent)
Gnome specific utility functions.
void gnc_plugin_page_save_page(GncPluginPage *page, GKeyFile *key_file, const gchar *group_name)
Call the plugin specific function that will save the state of a content page to a disk...
#define PLUGIN_PAGE_LABEL
This label is used to provide a mapping from a visible page widget back to the corresponding GncPlugi...
gboolean show_color_tabs
Show account color as background on tabs.
Dialog for handling user preferences.
gboolean qof_book_session_not_saved(const QofBook *book)
qof_book_not_saved() returns the value of the session_dirty flag, set when changes to any object in t...
All type declarations for the whole Gnucash engine.
const char * gnc_quote_source_fq_version(void)
This function returns the version of the Finance::Quote module installed on a user's computer...
gboolean gnc_main_window_finish_pending(GncMainWindow *window)
Tell a window to finish any outstanding activities.
Generic api to store and retrieve preferences.
Utility functions for file access.
gboolean gnc_uri_targets_local_fs(const gchar *uri)
Checks if the given uri is either a valid file uri or a local filesystem path.
GList * gnc_list_all_paths(void)
Returns a GList* of the environment variables used by GnuCash.
GtkActionGroup * gnc_main_window_get_action_group(GncMainWindow *window, const gchar *group_name)
Retrieve a specific set of user interface actions from a window.
void main_window_update_page_set_read_only_icon(GncPluginPage *page, gboolean read_only)
Update the icon on the page tabs in the main window.
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
GncMainWindow * gnc_main_window_new(void)
Create a new gnc main window plugin.
void qof_book_load_options(QofBook *book, GNCOptionLoad load_cb, GNCOptionDB *odb)
Load a GNCOptionsDB from KVP data.
void gnc_plugin_page_set_page_color(GncPluginPage *page, const char *color)
Set the color of this page.
void gnc_plugin_page_merge_actions(GncPluginPage *page, GtkUIManager *ui_merge)
Add the actions for a content page to the specified window.
void gnc_main_window_manual_merge_actions(GncMainWindow *window, const gchar *group_name, GtkActionGroup *group, guint merge_id)
Manually add a set of actions to the specified window.
void gnc_options_dialog_set_new_book_option_values(GNCOptionDB *odb)
Set the initial values of new book options to values specified in user preferences.
The instance data structure for a menu-only plugin.
cannot write to file/directory
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
GHashTable * merged_actions_table
A hash table of all action groups that have been installed into this window.
const char * gnc_version(void)
Parse <prefix>/etc/gnucash/environment and set environment variables based on the contents of that fi...
void gnc_main_window_close_page(GncPluginPage *page)
Remove a data plugin page from a window and display the previous page.
Functions for adding plugins to a GnuCash window.
void qof_book_save_options(QofBook *book, GNCOptionSave save_cb, GNCOptionDB *odb, gboolean clear)
Save a GNCOptionsDB back to the book's KVP.
GNC_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_WINDOW, G_IMPLEMENT_INTERFACE(GNC_TYPE_WINDOW, gnc_window_main_window_init))
This data structure maintains information about one action groups that has been installed in this win...
#define LEAVE(format, args...)
Print a function exit debugging message.
GList * gnc_plugin_manager_get_plugins(GncPluginManager *manager)
Get a list of all plugins being held by the plugin manager.
void gnc_plugin_page_set_page_name(GncPluginPage *page, const char *name)
Set the name of this page.
GList * installed_pages
A list of all pages that are installed in this window.
GtkWidget * progressbar
A pointer to the progress bar at the bottom right of the window that is contained in the status bar...
time64 gnc_time(time64 *tbuf)
get the current local time
Utility functions for convert uri in separate components and back.
GncPluginPage * current_page
The currently selected page.
gint64 time64
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
gulong gnc_prefs_get_reg_auto_raise_lists_id(void)
Get and Set registered preference id for register auto_raise_lists.
void gnc_launch_doclink(GtkWindow *parent, const char *uri)
Launch the default browser and open the provided URI.
GtkUIManager * gnc_plugin_page_get_ui_merge(GncPluginPage *page)
Retrieve the GtkUIManager object associated with this page.
The instance data structure for a main window object.
void gnc_main_window_restore_default_state(GncMainWindow *window)
Restore the persistent state of one window to a sane default.
The class data structure for a main window object.
File path resolution utility functions.
gboolean gnc_main_window_all_finish_pending(void)
Tell all pages in all windows to finish any outstanding activities.
gint gnc_list_length_cmp(const GList *list, size_t len)
Scans the GList elements the minimum number of iterations required to test it against a specified siz...
void gnc_main_window_actions_updated(GncMainWindow *window)
Force a full update of the user interface for the specified window.
void main_window_update_page_name(GncPluginPage *page, const gchar *name_in)
Update the name of the page in the main window.
GtkWidget * notebook_page
The display widget for this plugin.
GtkWidget * menu_dock
The dock (vbox) at the top of the window containing the menubar and toolbar.
gchar * gnc_uri_create_uri(const gchar *scheme, const gchar *hostname, gint32 port, const gchar *username, const gchar *password, const gchar *path)
Composes a normalized uri starting from its separate components.
void gnc_plugin_page_show_summarybar(GncPluginPage *page, gboolean visible)
Show/hide the summarybar associated with this page.
GtkUIManager * gnc_main_window_get_uimanager(GncMainWindow *window)
Returns the pointer to the GtkUIManager which is used for the menu item merging.
GtkAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *name)
Find action in main window.
void gnc_window_connect_proxy(GtkUIManager *merge, GtkAction *action, GtkWidget *proxy, GtkWidget *statusbar)
This callback functions will set the statusbar text to the "tooltip" property of the currently select...
GtkWidget * gnc_plugin_page_create_widget(GncPluginPage *plugin_page)
Create the display widget that corresponds to this plugin.
void gnc_main_window_set_progressbar_window(GncMainWindow *window)
Set the window where all progressbar updates should occur.
void gnc_prefs_remove_cb_by_func(const gchar *group, const gchar *pref_name, gpointer func, gpointer user_data)
Remove a function that was registered for a callback when the given preference changed.
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Get an float value from the preferences backend.
const gchar * gnc_plugin_page_get_plugin_name(GncPluginPage *plugin_page)
Retrieve the textual name of a plugin.
Utility functions for file access.