[Gnucash-changes] r12979 - gnucash/trunk/src - Move dialog-totd
from gnome to gnome-utils.
Chris Shoemaker
chris at cvs.gnucash.org
Wed Jan 25 22:07:04 EST 2006
Author: chris
Date: 2006-01-25 22:07:03 -0500 (Wed, 25 Jan 2006)
New Revision: 12979
Trac: http://svn.gnucash.org/trac/changeset/12979
Added:
gnucash/trunk/src/gnome-utils/dialog-totd.c
gnucash/trunk/src/gnome-utils/dialog-totd.h
Removed:
gnucash/trunk/src/gnome/dialog-totd.c
gnucash/trunk/src/gnome/dialog-totd.h
Modified:
gnucash/trunk/src/bin/gnucash-bin.c
gnucash/trunk/src/gnome-utils/Makefile.am
gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
gnucash/trunk/src/gnome/Makefile.am
gnucash/trunk/src/gnome/top-level.c
Log:
Move dialog-totd from gnome to gnome-utils.
Do low-level application initialization even before booting guile.
This means the splash and totd come up almost instantly.
Modified: gnucash/trunk/src/bin/gnucash-bin.c
===================================================================
--- gnucash/trunk/src/bin/gnucash-bin.c 2006-01-25 04:54:12 UTC (rev 12978)
+++ gnucash/trunk/src/bin/gnucash-bin.c 2006-01-26 03:07:03 UTC (rev 12979)
@@ -353,7 +353,7 @@
/* TODO: After some more guile-extraction, this should happen even
before booting guile. */
gnc_main_gui_init();
-
+
qof_log_set_level_global(loglevel);
load_system_config();
@@ -420,6 +420,7 @@
}
gnc_gnome_init (argc, argv, VERSION);
+ gnc_gui_init();
scm_boot_guile(argc, argv, inner_main, 0);
exit(0); /* never reached */
}
Modified: gnucash/trunk/src/gnome/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome/Makefile.am 2006-01-25 04:54:12 UTC (rev 12978)
+++ gnucash/trunk/src/gnome/Makefile.am 2006-01-26 03:07:03 UTC (rev 12979)
@@ -35,7 +35,6 @@
dialog-sx-from-trans.c \
dialog-sxsincelast.c \
dialog-tax-info.c \
- dialog-totd.c \
dialog-userpass.c \
dialog-scheduledxaction.c \
druid-acct-period.c \
@@ -98,7 +97,6 @@
dialog-progress.h \
dialog-sx-from-trans.h \
dialog-sxsincelast.h \
- dialog-totd.h \
dialog-scheduledxaction.h \
druid-acct-period.h \
druid-hierarchy.h \
Deleted: gnucash/trunk/src/gnome/dialog-totd.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-totd.c 2006-01-25 04:54:12 UTC (rev 12978)
+++ gnucash/trunk/src/gnome/dialog-totd.c 2006-01-26 03:07:03 UTC (rev 12979)
@@ -1,267 +0,0 @@
-/*
- * dialog-totd.c : dialog to display a "tip of the day"
- *
- * Initial copyright not recorded.
- * Copyright (c) 2006 David Hampton <hampton at employees.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation Voice: +1-617-542-5942
- * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
- * Boston, MA 02110-1301, USA gnu at gnu.org
- */
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <glade/glade-xml.h>
-
-#include "dialog-totd.h"
-#include "dialog-utils.h"
-#include "gnc-component-manager.h"
-#include "gnc-gconf-utils.h"
-#include "gnc-gnome-utils.h"
-#include "gnc-engine.h"
-
-
-#define GCONF_SECTION "dialogs/tip_of_the_day"
-#define KEY_CURRENT_TIP "current_tip"
-#define KEY_SHOW_TIPS "show_at_startup"
-#define DIALOG_TOTD_CM_CLASS "dialog-totd"
-
-#define GNC_RESPONSE_FORWARD 1
-#define GNC_RESPONSE_BACK 2
-
-/* Callbacks */
-void gnc_totd_dialog_response (GtkDialog *dialog, gint reponse, gpointer user_data);
-void gnc_totd_dialog_startup_toggled (GtkToggleButton *button, gpointer user_data);
-
-/* The Tips */
-static gchar **tip_list;
-static gint tip_count = -1;
-static gint current_tip_number = -1;
-
-/* This static indicates the debugging module that this .o belongs to. */
-static QofLogModule log_module = GNC_MOD_GUI;
-
-
-/*********************/
-/* Utility Functions */
-/*********************/
-
-/** This function should be called to change the tip number. It
- * handles clamping the number to the range of tips available, saving
- * the number in the GConf database, and updating the dialog window
- * with the text of the newly selected tip.
- *
- * @param widget A pointer to any widget in the dialog. This widget
- * is used as a starting point to find the GtkTextView widget that
- * holds the text of the tip.
- *
- * @param offset Which tip to show. If the value is zero then the
- * current tip will be shown. If the value is negative the previous
- * tip will be shown. If the value is positive the next tip will be
- * shown.
- */
-static void
-gnc_new_tip_number (GtkWidget *widget,
- gint offset)
-{
- GtkWidget *textview;
-
- ENTER("widget %p, offset %d", widget, offset);
- current_tip_number += offset;
- DEBUG("clamp %d to '0 <= x < %d'", current_tip_number, tip_count);
- if (current_tip_number < 0)
- current_tip_number = tip_count - 1;
- if (current_tip_number >= tip_count)
- current_tip_number = 0;
- gnc_gconf_set_int(GCONF_SECTION, KEY_CURRENT_TIP, current_tip_number, NULL);
-
- textview = gnc_glade_lookup_widget(widget, "tip_textview");
- gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)),
- _(tip_list[current_tip_number]), -1);
- LEAVE("");
-}
-
-
-/********************/
-/* Callbacks */
-/********************/
-
-void gnc_totd_dialog_response (GtkDialog *dialog,
- gint response,
- gpointer user_data)
-{
- ENTER("dialog %p, response %d, user_data %p", dialog, response, user_data);
- switch (response) {
- case GNC_RESPONSE_FORWARD:
- gnc_new_tip_number(GTK_WIDGET(dialog), 1);
- break;
-
- case GNC_RESPONSE_BACK:
- gnc_new_tip_number(GTK_WIDGET(dialog), -1);
- break;
-
- case GTK_RESPONSE_CLOSE:
- gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
- /* fall through */
-
- default:
- gnc_unregister_gui_component_by_data(DIALOG_TOTD_CM_CLASS, dialog);
- gtk_widget_destroy(GTK_WIDGET(dialog));
- break;
- }
- LEAVE("");
-}
-
-void
-gnc_totd_dialog_startup_toggled (GtkToggleButton *button,
- gpointer user_data)
-{
- gboolean active;
-
- active = gtk_toggle_button_get_active(button);
- gnc_gconf_set_bool(GCONF_SECTION, KEY_SHOW_TIPS, active, NULL);
-}
-
-/********************/
-/* Parser */
-/********************/
-
-static gboolean
-gnc_totd_initialize (void)
-{
- gchar *filename, *contents, *new;
- gsize length;
- GError *error;
-
- /* Find the file */
- filename = gnc_gnome_locate_data_file("tip_of_the_day.list");
- if (!filename)
- return FALSE;
-
- /* Read it */
- if (!g_file_get_contents(filename, &contents, &length, &error)) {
- printf("Unable to read file: %s\n", error->message);
- g_error_free(error);
- g_free(filename);
- return FALSE;
- }
-
- /* Split into multiple strings */
- tip_list = g_strsplit(contents, "\n\n", 0);
-
- /* Convert any escaped characters while counting the strings */
- for (tip_count = 0; tip_list[tip_count] != NULL; tip_count++) {
-
- new = g_strcompress(g_strdelimit(tip_list[tip_count], "\n", ' '));
- g_free(tip_list[tip_count]);
- tip_list[tip_count] = new;
- }
-
- g_free(contents);
- g_free(filename);
- return TRUE;
-}
-
-/** Raise the totd dialog to the top of the window stack. This
- * function is called if the user attempts to create a second totd
- * dialog.
- *
- * @internal
- *
- * @param class Unused.
- *
- * @param component_id Unused.
- *
- * @param user_data A pointer to the totd dialog.
- *
- * @param iter_data Unused.
- */
-static gboolean
-show_handler (const char *class, gint component_id,
- gpointer user_data, gpointer iter_data)
-{
- GtkWidget *dialog;
-
- ENTER(" ");
- dialog = GTK_WIDGET(user_data);
- gtk_window_present(GTK_WINDOW(dialog));
- LEAVE(" ");
- return(TRUE);
-}
-
-/** Close the totd dialog.
- *
- * @internal
- *
- * @param user_data A pointer to the totd dialog.
- */
-static void
-close_handler (gpointer user_data)
-{
- GtkWidget *dialog;
-
- ENTER(" ");
- dialog = GTK_WIDGET(user_data);
- gnc_unregister_gui_component_by_data(DIALOG_TOTD_CM_CLASS, dialog);
- gtk_widget_destroy(dialog);
- LEAVE(" ");
-}
-
-
-/********************/
-/* Main */
-/********************/
-
-void
-gnc_totd_dialog (GtkWindow *parent, gboolean startup)
-{
- GladeXML *xml;
- GtkWidget *dialog, *button;
- gboolean show_tips;
-
- show_tips = gnc_gconf_get_bool(GCONF_SECTION, KEY_SHOW_TIPS, NULL);
- if (startup && !show_tips)
- return;
-
- if (tip_count == -1) {
- if (!gnc_totd_initialize())
- return;
- current_tip_number = gnc_gconf_get_int(GCONF_SECTION, KEY_CURRENT_TIP, NULL);
- }
-
- if (gnc_forall_gui_components(DIALOG_TOTD_CM_CLASS, show_handler, NULL)) {
- return;
- }
-
- xml = gnc_glade_xml_new ("totd.glade", "totd_dialog");
- dialog = glade_xml_get_widget (xml, "totd_dialog");
- gtk_window_set_transient_for(GTK_WINDOW (dialog), parent);
- glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
- dialog);
-
- gnc_new_tip_number(dialog, 0);
-
- button = glade_xml_get_widget(xml, "show_checkbutton");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), show_tips);
-
- gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
- gtk_widget_show(GTK_WIDGET (dialog));
-
- gnc_register_gui_component(DIALOG_TOTD_CM_CLASS,
- NULL, close_handler, dialog);
-}
Deleted: gnucash/trunk/src/gnome/dialog-totd.h
===================================================================
--- gnucash/trunk/src/gnome/dialog-totd.h 2006-01-25 04:54:12 UTC (rev 12978)
+++ gnucash/trunk/src/gnome/dialog-totd.h 2006-01-26 03:07:03 UTC (rev 12979)
@@ -1,29 +0,0 @@
-/*
- * dialog-totd.h : dialog to display a "tip of the day"
- *
- * Copyright (c) 2005 David Hampton <hampton at employees.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation Voice: +1-617-542-5942
- * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
- * Boston, MA 02110-1301, USA gnu at gnu.org
- */
-
-#ifndef DIALOG_TOTD_H
-#define DIALOG_TOTD_H
-
-void gnc_totd_dialog (GtkWindow *parent, gboolean startup);
-
-#endif
Modified: gnucash/trunk/src/gnome/top-level.c
===================================================================
--- gnucash/trunk/src/gnome/top-level.c 2006-01-25 04:54:12 UTC (rev 12978)
+++ gnucash/trunk/src/gnome/top-level.c 2006-01-26 03:07:03 UTC (rev 12979)
@@ -198,10 +198,7 @@
void
gnc_main_gui_init (void)
{
- GncMainWindow *main_window;
-
ENTER(" ");
- main_window = gnc_gui_init();
if (!gnucash_style_init())
gnc_shutdown(1);
@@ -215,8 +212,6 @@
gnc_ui_sx_initialize();
- gnc_totd_dialog(GTK_WINDOW(main_window), TRUE);
-
/* FIXME Remove this test code */
gnc_plugin_manager_add_plugin (
gnc_plugin_manager_get (), gnc_plugin_account_tree_new ());
Modified: gnucash/trunk/src/gnome-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome-utils/Makefile.am 2006-01-25 04:54:12 UTC (rev 12978)
+++ gnucash/trunk/src/gnome-utils/Makefile.am 2006-01-26 03:07:03 UTC (rev 12979)
@@ -40,6 +40,7 @@
dialog-preferences.c \
dialog-query-list.c \
dialog-reset-warnings.c \
+ dialog-totd.c \
dialog-transfer.c \
dialog-utils.c \
druid-utils.c \
@@ -104,6 +105,7 @@
dialog-options.h \
dialog-query-list.h \
dialog-reset-warnings.h \
+ dialog-totd.h \
dialog-transfer.h \
dialog-utils.h \
druid-utils.h \
Copied: gnucash/trunk/src/gnome-utils/dialog-totd.c (from rev 12978, gnucash/trunk/src/gnome/dialog-totd.c)
Copied: gnucash/trunk/src/gnome-utils/dialog-totd.h (from rev 12978, gnucash/trunk/src/gnome/dialog-totd.h)
Modified: gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c 2006-01-25 04:54:12 UTC (rev 12978)
+++ gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c 2006-01-26 03:07:03 UTC (rev 12979)
@@ -47,6 +47,7 @@
#include "gnc-icons.h"
#include "dialog-options.h"
#include "dialog-commodity.h"
+#include "dialog-totd.h"
#include "gnc-ui-util.h"
#include <gnc-dir.h>
@@ -403,6 +404,7 @@
g_free(map);
gnc_load_stock_icons();
+ gnc_totd_dialog(GTK_WINDOW(main_window), TRUE);
return main_window;
}
More information about the gnucash-changes
mailing list