mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
More changed from Jan Petersen (hopefully I didn't miss anything)
See the ChangeLog for more information. * Move egg from gnome-utils to lib * New "Tip of the day" dialog. * Some small fixes. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@8462 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
30
ChangeLog
30
ChangeLog
@@ -1,3 +1,33 @@
|
||||
2003-05-30 Jan Arne Petersen <jpetersen@uni-bonn.de>
|
||||
|
||||
Move egg to lib.
|
||||
* configure.in:
|
||||
* lib/Makefile.am:
|
||||
* lib/egg
|
||||
* src/gnome-utils/Makefile.am:
|
||||
* src/import-export/qif-import/Makefile.am:
|
||||
|
||||
* src/gnome-utils/gnc-dense-cal.c: Fix some Gtk 2 incompatibilty problems.
|
||||
(gnc_dense_cal_class_init), (gnc_dense_cal_init):
|
||||
|
||||
Create a new tip of the day dialog.
|
||||
* src/gnome/Makefile.am:
|
||||
* src/gnome/gnc-totd-dialog.[ch]:
|
||||
* src/gnome/glade/Makefile.am:
|
||||
* src/gnome/glade/totd.glade:
|
||||
* src/gnome/gw-gnc-spec.scm:
|
||||
* src/gnome/window-main.c: (gnc_main_window_totd_cb):
|
||||
* src/scm/tip-of-the-day.scm:
|
||||
|
||||
Replace GnomeDialog by GtkDialog.
|
||||
* src/gnome/dialog-price-edit-db.c: (prices_response),
|
||||
(remove_old_clicked), (gnc_prices_dialog_create), (close_handler):
|
||||
|
||||
Fix a bug (multiple tabs) in the main window.
|
||||
* src/gnome/gnc-main-window.c: (gnc_main_window_close_page),
|
||||
(gnc_main_window_setup_window), (gnc_main_window_switch_page),
|
||||
(gnc_main_window_cmd_help_totd):
|
||||
|
||||
2003-05-27 Jan Arne Petersen <jpetersen@uni-bonn.de>
|
||||
|
||||
* configure.in: Requires gtk+-2.0 >= 2.2 and libgnomeui-2.0 >= 2.2
|
||||
|
||||
@@ -1069,6 +1069,7 @@ AC_OUTPUT( m4/Makefile
|
||||
doc/examples/Makefile
|
||||
intl-scm/Makefile
|
||||
lib/Makefile
|
||||
lib/egg/Makefile
|
||||
lib/guile-www/Makefile
|
||||
lib/srfi/Makefile
|
||||
lib/libc/Makefile
|
||||
@@ -1117,7 +1118,6 @@ AC_OUTPUT( m4/Makefile
|
||||
src/gnome/glade/Makefile
|
||||
src/gnome/ui/Makefile
|
||||
src/gnome-utils/Makefile
|
||||
src/gnome-utils/egg/Makefile
|
||||
src/gnome-utils/test/Makefile
|
||||
src/gnome-search/Makefile
|
||||
src/import-export/Makefile
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
SUBDIRS = libc guile-www srfi
|
||||
SUBDIRS = libc guile-www srfi egg
|
||||
|
||||
EXTRA_DIST = README
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SUBDIRS = egg . test
|
||||
SUBDIRS = . test
|
||||
|
||||
pkglib_LTLIBRARIES = libgncmod-gnome-utils.la libgw-gnome-utils.la
|
||||
|
||||
@@ -8,7 +8,7 @@ AM_CFLAGS = \
|
||||
-I${top_srcdir}/src/backend/file \
|
||||
-I${top_srcdir}/src/network-utils \
|
||||
-I${top_srcdir}/src/app-utils \
|
||||
-I${top_srcdir}/src/gnome-utils/egg \
|
||||
-I${top_srcdir}/lib/egg \
|
||||
-I${top_srcdir}/src \
|
||||
${GUILE_INCS} \
|
||||
${LIBGUPPI_CFLAGS} \
|
||||
@@ -104,7 +104,7 @@ libgncmod_gnome_utils_la_LIBADD = \
|
||||
${top_builddir}/src/calculation/libgncmod-calculation.la \
|
||||
${top_builddir}/src/network-utils/libgncmod-network-utils.la \
|
||||
${top_builddir}/src/app-utils/libgncmod-app-utils.la \
|
||||
${top_builddir}/src/gnome-utils/egg/libegg.la \
|
||||
${top_builddir}/lib/egg/libegg.la \
|
||||
${GUILE_LIBS} \
|
||||
${LIBGUPPI_LIBS} \
|
||||
${GNOMEUI_LIBS} \
|
||||
|
||||
@@ -224,22 +224,26 @@ gnc_dense_cal_get_type ()
|
||||
static void
|
||||
gnc_dense_cal_class_init (GncDenseCalClass *class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GObjectClass *object_class;
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
parent_class = gtk_type_class (gtk_widget_get_type ());
|
||||
object_class = G_OBJECT_CLASS (class);
|
||||
gtkobject_class = GTK_OBJECT_CLASS (class);
|
||||
widget_class = GTK_WIDGET_CLASS (class);
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
gnc_dense_cal_signals[MARKS_LOST_SIGNAL] =
|
||||
gtk_signal_new( MARKS_LOST_SIGNAL_NAME,
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET( GncDenseCalClass, marks_lost_cb ),
|
||||
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0 );
|
||||
gtk_object_class_add_signals (object_class, gnc_dense_cal_signals, LAST_SIGNAL);
|
||||
g_signal_new (MARKS_LOST_SIGNAL_NAME,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GncDenseCalClass, marks_lost_cb),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
object_class->destroy = gnc_dense_cal_destroy;
|
||||
gtkobject_class->destroy = gnc_dense_cal_destroy;
|
||||
widget_class->realize = gnc_dense_cal_realize;
|
||||
widget_class->expose_event = gnc_dense_cal_expose;
|
||||
widget_class->size_request = gnc_dense_cal_size_request;
|
||||
@@ -314,7 +318,8 @@ gnc_dense_cal_init (GncDenseCal *dcal)
|
||||
dcal->monthLabelFont = gdk_font_load( LABEL_FONT_NAME );
|
||||
g_assert( dcal->monthLabelFont );
|
||||
|
||||
dcal->dayLabelFont = GTK_WIDGET(dcal)->style->font;
|
||||
/* FIXME GNOME 2 port (rework the complete font code) */
|
||||
/* dcal->dayLabelFont = GTK_WIDGET(dcal)->style->font; */
|
||||
gdk_font_ref( dcal->dayLabelFont );
|
||||
g_assert( dcal->dayLabelFont );
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ libgncgnome_la_LIBADD = \
|
||||
${top_builddir}/src/report/report-gnome/libgncmod-report-gnome.la \
|
||||
${top_builddir}/src/register/ledger-core/libgncmod-ledger-core.la \
|
||||
${top_builddir}/src/gnome-search/libgncmod-gnome-search.la \
|
||||
${top_builddir}/src/gnome-utils/egg/libegg.la \
|
||||
${top_builddir}/lib/egg/libegg.la \
|
||||
${GUILE_LIBS} ${GNOME_LIBDIR} ${GNOMEUI_LIBS} ${GLIB_LIBS}
|
||||
|
||||
libgw_gnc_la_SOURCES = gw-gnc.c
|
||||
@@ -35,7 +35,7 @@ libgncgnome_la_SOURCES = \
|
||||
dialog-sx-from-trans.c \
|
||||
dialog-sxsincelast.c \
|
||||
dialog-tax-info.c \
|
||||
dialog-totd.c \
|
||||
gnc-totd-dialog.c \
|
||||
dialog-userpass.c \
|
||||
dialog-scheduledxaction.c \
|
||||
druid-hierarchy.c \
|
||||
@@ -78,7 +78,7 @@ noinst_HEADERS = \
|
||||
dialog-progress.h \
|
||||
dialog-sx-from-trans.h \
|
||||
dialog-sxsincelast.h \
|
||||
dialog-totd.h \
|
||||
gnc-totd-dialog.h \
|
||||
dialog-scheduledxaction.h \
|
||||
druid-hierarchy.h \
|
||||
druid-loan.h \
|
||||
@@ -125,7 +125,7 @@ AM_CFLAGS = \
|
||||
-I${top_srcdir}/src/backend/file \
|
||||
-I${top_srcdir}/src/g-wrap \
|
||||
-I${top_srcdir}/src/gnome-utils \
|
||||
-I${top_srcdir}/src/gnome-utils/egg \
|
||||
-I${top_srcdir}/lib/egg \
|
||||
-I${top_srcdir}/src/gnome-search \
|
||||
-I${top_srcdir}/src/register/ledger-core \
|
||||
-I${top_srcdir}/src/register/register-core \
|
||||
|
||||
@@ -286,11 +286,13 @@ window_destroy_cb (GtkObject *object, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
prices_close_clicked (GtkWidget *widget, gpointer data)
|
||||
prices_response (GtkDialog *dialog, gint response_id, gpointer data)
|
||||
{
|
||||
PricesDialog *pdb_dialog = data;
|
||||
|
||||
gnc_close_gui_component_by_data (DIALOG_PRICE_DB_CM_CLASS, pdb_dialog);
|
||||
if (response_id == GTK_RESPONSE_CLOSE) {
|
||||
gnc_close_gui_component_by_data (DIALOG_PRICE_DB_CM_CLASS, pdb_dialog);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -335,16 +337,16 @@ remove_old_clicked (GtkWidget *widget, gpointer data)
|
||||
GtkWidget *vbox;
|
||||
gint result;
|
||||
|
||||
dialog = gnome_dialog_new (_("Remove old prices"),
|
||||
GNOME_STOCK_BUTTON_OK,
|
||||
GNOME_STOCK_BUTTON_CANCEL,
|
||||
NULL);
|
||||
dialog = gtk_dialog_new_with_buttons (_("Remove old prices"),
|
||||
GTK_WINDOW (pdb_dialog->dialog),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_STOCK_OK,
|
||||
GTK_RESPONSE_ACCEPT,
|
||||
GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_REJECT,
|
||||
NULL);
|
||||
|
||||
gnome_dialog_set_parent (GNOME_DIALOG (dialog),
|
||||
GTK_WINDOW (pdb_dialog->dialog));
|
||||
gnome_dialog_close_hides (GNOME_DIALOG (dialog), FALSE);
|
||||
|
||||
vbox = GNOME_DIALOG (dialog)->vbox;
|
||||
vbox = GTK_DIALOG (dialog)->vbox;
|
||||
|
||||
gtk_box_set_spacing (GTK_BOX (vbox), 3);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
|
||||
@@ -356,14 +358,14 @@ remove_old_clicked (GtkWidget *widget, gpointer data)
|
||||
gtk_widget_show (label);
|
||||
|
||||
date = gnc_date_edit_new (time (NULL), FALSE, FALSE);
|
||||
g_object_ref (GTK_OBJECT (date));
|
||||
g_object_ref (G_OBJECT (date));
|
||||
gtk_object_sink (GTK_OBJECT (date));
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), date, FALSE, FALSE, 0);
|
||||
gtk_widget_show (date);
|
||||
|
||||
result = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
|
||||
if (result == 0)
|
||||
result = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
if (result == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
GNCBook *book = gnc_get_current_book ();
|
||||
GNCPriceDB *pdb = gnc_book_get_pricedb (book);
|
||||
@@ -385,7 +387,7 @@ remove_old_clicked (GtkWidget *widget, gpointer data)
|
||||
gnc_gui_refresh_all ();
|
||||
}
|
||||
|
||||
g_object_unref (GTK_OBJECT (date));
|
||||
g_object_unref (G_OBJECT (date));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -527,19 +529,18 @@ gnc_prices_dialog_create (GtkWidget * parent, PricesDialog *pdb_dialog)
|
||||
dialog = glade_xml_get_widget (xml, "Prices Dialog");
|
||||
pdb_dialog->dialog = dialog;
|
||||
|
||||
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0,
|
||||
GTK_SIGNAL_FUNC (prices_close_clicked),
|
||||
pdb_dialog);
|
||||
g_signal_connect (G_OBJECT (dialog), "response",
|
||||
G_CALLBACK (prices_response), pdb_dialog);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
|
||||
GTK_SIGNAL_FUNC (window_destroy_cb), pdb_dialog);
|
||||
g_signal_connect (G_OBJECT (dialog), "destroy",
|
||||
G_CALLBACK (window_destroy_cb), pdb_dialog);
|
||||
|
||||
/* parent */
|
||||
if (parent != NULL)
|
||||
gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (parent));
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
|
||||
|
||||
/* default to 'close' button */
|
||||
gnome_dialog_set_default (GNOME_DIALOG(dialog), 0);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
|
||||
|
||||
/* price tree */
|
||||
{
|
||||
@@ -554,16 +555,16 @@ gnc_prices_dialog_create (GtkWidget * parent, PricesDialog *pdb_dialog)
|
||||
gtk_clist_column_title_active(GTK_CLIST(list), COMMODITY_COLUMN);
|
||||
gtk_clist_column_title_active(GTK_CLIST(list), DATE_COLUMN);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(list), "select_row",
|
||||
GTK_SIGNAL_FUNC(gnc_prices_select_price_cb),
|
||||
g_signal_connect (G_OBJECT(list), "select_row",
|
||||
G_CALLBACK(gnc_prices_select_price_cb),
|
||||
pdb_dialog);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(list), "unselect_row",
|
||||
GTK_SIGNAL_FUNC(gnc_prices_unselect_price_cb),
|
||||
g_signal_connect (G_OBJECT(list), "unselect_row",
|
||||
G_CALLBACK(gnc_prices_unselect_price_cb),
|
||||
pdb_dialog);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(list), "click_column",
|
||||
GTK_SIGNAL_FUNC(gnc_prices_click_column_cb),
|
||||
g_signal_connect (G_OBJECT(list), "click_column",
|
||||
G_CALLBACK(gnc_prices_click_column_cb),
|
||||
pdb_dialog);
|
||||
}
|
||||
|
||||
@@ -574,30 +575,30 @@ gnc_prices_dialog_create (GtkWidget * parent, PricesDialog *pdb_dialog)
|
||||
button = glade_xml_get_widget (xml, "edit_button");
|
||||
pdb_dialog->edit_button = button;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (edit_clicked), pdb_dialog);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (edit_clicked), pdb_dialog);
|
||||
|
||||
button = glade_xml_get_widget (xml, "remove_button");
|
||||
pdb_dialog->remove_button = button;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (remove_clicked), pdb_dialog);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (remove_clicked), pdb_dialog);
|
||||
|
||||
button = glade_xml_get_widget (xml, "remove_old_button");
|
||||
pdb_dialog->remove_old_button = button;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (remove_old_clicked), pdb_dialog);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (remove_old_clicked), pdb_dialog);
|
||||
|
||||
button = glade_xml_get_widget (xml, "add_button");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (add_clicked), pdb_dialog);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (add_clicked), pdb_dialog);
|
||||
|
||||
button = glade_xml_get_widget (xml, "get_quotes_button");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (get_quotes_clicked), pdb_dialog);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (get_quotes_clicked), pdb_dialog);
|
||||
}
|
||||
|
||||
/* arrows */
|
||||
@@ -634,7 +635,7 @@ close_handler (gpointer user_data)
|
||||
|
||||
gnc_save_window_size ("prices_win", last_width, last_height);
|
||||
|
||||
gnome_dialog_close (GNOME_DIALOG (pdb_dialog->dialog));
|
||||
gtk_widget_destroy (GTK_WIDGET (pdb_dialog->dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -1,310 +0,0 @@
|
||||
/********************************************************************\
|
||||
* dialog-totd.c -- Dialog to display a "tip of the day" *
|
||||
* Copyright (C) 2000 Robert Merkel <rgmerk@mira.net> *
|
||||
* Large fractions borrowed from gnome-hint (Copyright (C) 2000) *
|
||||
* Free Software Foundation *
|
||||
* *
|
||||
* 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 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
\********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
#include "dialog-totd.h"
|
||||
#include "dialog-utils.h" /* remove with GTK 2.0 */
|
||||
#include "global-options.h"
|
||||
#include "gnc-gui-query.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "messages.h"
|
||||
#include "tip-of-the-day.h"
|
||||
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
/* static short module = MOD_GUI; */
|
||||
|
||||
static GtkWidget *win = NULL;
|
||||
static GtkWidget *disable_cb = NULL;
|
||||
static GtkWidget *canvas = NULL;
|
||||
static GtkWidget *scrollwin = NULL;
|
||||
|
||||
static GnomeCanvasItem *hint_item;
|
||||
static GnomeCanvasItem *blue_background;
|
||||
static GnomeCanvasItem *white_background;
|
||||
static gboolean old_enabled;
|
||||
|
||||
static int width = 400, height = 200;
|
||||
|
||||
|
||||
/** Prototypes *********************************************************/
|
||||
static void draw_on_canvas(GtkWidget *canvas, char *hint);
|
||||
static void grow_text_if_necessary(void);
|
||||
static GtkWidget *gnc_ui_totd_dialog_create(void);
|
||||
static void totd_previous_cb(GtkWidget *widget, gpointer data);
|
||||
static void totd_next_cb(GtkWidget * widget, gpointer data);
|
||||
static void totd_close_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** Implementations ***************************************************/
|
||||
|
||||
/************************************************************************\
|
||||
* gnc_ui_totd_dialog_create_and_run *
|
||||
* display and run the "Tip of the Day" dialog *
|
||||
* *
|
||||
* Returns: nothing *
|
||||
\************************************************************************/
|
||||
|
||||
void gnc_ui_totd_dialog_create_and_run(void)
|
||||
{
|
||||
if(win == NULL)
|
||||
{
|
||||
gnc_ui_totd_dialog_create();
|
||||
gtk_widget_show_all(win);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_window_present(GTK_WINDOW(win));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gnc_ui_totd_dialog_create(void)
|
||||
{
|
||||
char *new_hint;
|
||||
|
||||
win = gnome_dialog_new(_("Tip of the Day"),
|
||||
GNOME_STOCK_BUTTON_PREV,
|
||||
GNOME_STOCK_BUTTON_NEXT,
|
||||
GNOME_STOCK_BUTTON_CLOSE,
|
||||
NULL);
|
||||
|
||||
gnome_dialog_set_default(GNOME_DIALOG(win), 2);
|
||||
gnome_dialog_close_hides(GNOME_DIALOG(win), FALSE);
|
||||
|
||||
scrollwin = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_NEVER);
|
||||
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(win)->vbox),
|
||||
scrollwin, TRUE, TRUE, 0);
|
||||
canvas = gnome_canvas_new();
|
||||
gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas),
|
||||
0.0,0.0,width,height);
|
||||
gtk_widget_set_usize(canvas,width,height);
|
||||
gtk_widget_ensure_style(canvas);
|
||||
gtk_container_add(GTK_CONTAINER(scrollwin), canvas);
|
||||
new_hint = gnc_get_current_tip();
|
||||
draw_on_canvas(canvas, new_hint);
|
||||
free(new_hint);
|
||||
gtk_widget_show_all(scrollwin);
|
||||
|
||||
old_enabled = gnc_lookup_boolean_option("General",
|
||||
"Display \"Tip of the Day\"",
|
||||
TRUE);
|
||||
{
|
||||
const char *message = _("Display this dialog next time");
|
||||
disable_cb = gtk_check_button_new_with_label(message);
|
||||
}
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (disable_cb), old_enabled);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(win)->vbox),
|
||||
disable_cb, TRUE, TRUE, 0);
|
||||
gtk_widget_show(disable_cb);
|
||||
|
||||
gnome_dialog_button_connect(GNOME_DIALOG(win), 0,
|
||||
GTK_SIGNAL_FUNC(totd_previous_cb), NULL);
|
||||
gnome_dialog_button_connect(GNOME_DIALOG(win), 1,
|
||||
GTK_SIGNAL_FUNC(totd_next_cb), NULL);
|
||||
gnome_dialog_button_connect(GNOME_DIALOG(win), 2,
|
||||
GTK_SIGNAL_FUNC(totd_close_cb), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(win), "close",
|
||||
GTK_SIGNAL_FUNC(totd_close_cb), NULL);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
static void
|
||||
totd_previous_cb(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
char *new_hint;
|
||||
gnc_decrement_tip();
|
||||
new_hint = gnc_get_current_tip();
|
||||
gnome_canvas_item_set(hint_item,
|
||||
"text",new_hint,
|
||||
NULL);
|
||||
grow_text_if_necessary();
|
||||
free(new_hint);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
totd_next_cb(GtkWidget * widget, gpointer data)
|
||||
{
|
||||
char *new_hint;
|
||||
gnc_increment_tip();
|
||||
new_hint = gnc_get_current_tip();
|
||||
gnome_canvas_item_set(hint_item,
|
||||
"text", new_hint, NULL);
|
||||
grow_text_if_necessary();
|
||||
free(new_hint);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
totd_close_cb(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
gboolean new_enabled =
|
||||
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(disable_cb));
|
||||
|
||||
gnc_increment_tip();
|
||||
|
||||
gtk_widget_destroy(GTK_WIDGET(win));
|
||||
win = NULL;
|
||||
if (new_enabled != old_enabled)
|
||||
{
|
||||
gnc_set_boolean_option("General",
|
||||
"Display \"Tip of the Day\"",
|
||||
new_enabled);
|
||||
gnc_option_refresh_ui_by_name("General", "Display \"Tip of the Day\"");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* increases the size of the canvas and enables scrolling if the text
|
||||
gets big enough */
|
||||
|
||||
static void
|
||||
grow_text_if_necessary(void)
|
||||
{
|
||||
double w,h;
|
||||
int ww,hh;
|
||||
int changed = FALSE;
|
||||
|
||||
gtk_object_get(GTK_OBJECT(hint_item),
|
||||
"text_width",&w,
|
||||
"text_height",&h,
|
||||
NULL);
|
||||
/*add border, and 10 pixels around*/
|
||||
w+=75+10;
|
||||
h+=50+10;
|
||||
/*some sanity limits*/
|
||||
/*if(w>800) w = 800;
|
||||
if(h>600) h = 600;*/
|
||||
|
||||
if(w>width) {
|
||||
width = w;
|
||||
changed = TRUE;
|
||||
}
|
||||
if(h>height) {
|
||||
height = h;
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
if(!changed)
|
||||
return;
|
||||
|
||||
/*limits on size*/
|
||||
ww = width; hh = height;
|
||||
if(ww>720) ww = 720;
|
||||
if(hh>450) hh = 450;
|
||||
|
||||
if(ww != width || hh != height)
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
else
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_NEVER);
|
||||
|
||||
/*here we grow the canvas*/
|
||||
gtk_widget_set_usize(canvas,ww,hh);
|
||||
gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas),
|
||||
0.0,0.0,width,height);
|
||||
|
||||
gnome_canvas_item_set(blue_background,
|
||||
"x2",(double)width,
|
||||
"y2",(double)height,
|
||||
NULL);
|
||||
gnome_canvas_item_set(white_background,
|
||||
"x2",(double)width,
|
||||
"y2",(double)height,
|
||||
NULL);
|
||||
gnome_canvas_item_set(hint_item,
|
||||
"x",(double)(((width-75)/2)+75),
|
||||
"y",(double)(((height-50)/2)+50),
|
||||
"clip_width",(double)(width-75),
|
||||
"clip_height",(double)(height-50),
|
||||
NULL);
|
||||
}
|
||||
|
||||
/* places items on the canvas to make up the tip of the day */
|
||||
|
||||
static void
|
||||
draw_on_canvas(GtkWidget *canvas, char *hint)
|
||||
{
|
||||
GnomeCanvasItem *item;
|
||||
|
||||
blue_background = gnome_canvas_item_new(
|
||||
gnome_canvas_root(GNOME_CANVAS(canvas)),
|
||||
gnome_canvas_rect_get_type(),
|
||||
"x1",(double)0.0,
|
||||
"y1",(double)0.0,
|
||||
"x2",(double)400.0,
|
||||
"y2",(double)200.0,
|
||||
"fill_color","sea green",
|
||||
NULL);
|
||||
|
||||
white_background = gnome_canvas_item_new(
|
||||
gnome_canvas_root(GNOME_CANVAS(canvas)),
|
||||
gnome_canvas_rect_get_type(),
|
||||
"x1",(double)75.0,
|
||||
"y1",(double)50.0,
|
||||
"x2",(double)400.0,
|
||||
"y2",(double)200.0,
|
||||
"fill_color","white",
|
||||
NULL);
|
||||
|
||||
hint_item = gnome_canvas_item_new(
|
||||
gnome_canvas_root(GNOME_CANVAS(canvas)),
|
||||
gnome_canvas_text_get_type(),
|
||||
"x",(double)237.5,
|
||||
"y",(double)125.0,
|
||||
"fill_color","black",
|
||||
"font_gdk",gdk_font_from_description (canvas->style->font_desc),
|
||||
"clip_width",(double)325.0,
|
||||
"clip_height",(double)150.0,
|
||||
"clip",TRUE,
|
||||
"text",hint,
|
||||
NULL);
|
||||
|
||||
item = gnome_canvas_item_new(
|
||||
gnome_canvas_root(GNOME_CANVAS(canvas)),
|
||||
gnome_canvas_text_get_type(),
|
||||
"x",(double)200.0,
|
||||
"y",(double)25.0,
|
||||
"fill_color","white",
|
||||
"font",_("-*-helvetica-bold-r-normal-*-*-180-*-*-p-*-*-*"),
|
||||
"text",_("Tip of the Day:"),
|
||||
NULL);
|
||||
|
||||
grow_text_if_necessary();
|
||||
}
|
||||
/********************** END OF FILE *********************************\
|
||||
\********************************************************************/
|
||||
@@ -1,28 +0,0 @@
|
||||
/********************************************************************\
|
||||
* dialog-totd.h : dialog to display a "tip of the day" *
|
||||
* Copyright (C) 2000 Robert Merkel <rgmerk@mira.net> *
|
||||
* *
|
||||
* 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 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef DIALOG_TOTD_H
|
||||
#define DIALOG_TOTD_H
|
||||
|
||||
void gnc_ui_totd_dialog_create_and_run(void);
|
||||
|
||||
#endif
|
||||
@@ -11,6 +11,7 @@ glade_DATA = \
|
||||
register.glade \
|
||||
stocks.glade \
|
||||
tax.glade \
|
||||
totd.glade \
|
||||
userpass.glade \
|
||||
sched-xact.glade
|
||||
|
||||
|
||||
136
src/gnome/glade/totd.glade
Normal file
136
src/gnome/glade/totd.glade
Normal file
@@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
|
||||
<widget class="GtkWindow" id="placeholder_window">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">window1</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="totd_vbox">
|
||||
<property name="border_width">12</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">18</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><span weight="bold">Tip of the Day:</span></property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"> </property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTextView" id="tip_textview">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="justification">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap_mode">GTK_WRAP_WORD</property>
|
||||
<property name="cursor_visible">False</property>
|
||||
<property name="pixels_above_lines">0</property>
|
||||
<property name="pixels_below_lines">0</property>
|
||||
<property name="pixels_inside_wrap">0</property>
|
||||
<property name="left_margin">0</property>
|
||||
<property name="right_margin">0</property>
|
||||
<property name="indent">0</property>
|
||||
<property name="text" translatable="yes">Warning This is a DEVELOPMENT version of GnuCash. It probably has lots of bugs and unstable features!
|
||||
If you are looking for a stable personal finance application, you should use the latest release of GnuCash 1.8</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="show_checkbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Show tips at startup</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "dialog-options.h"
|
||||
#include "dialog-scheduledxaction.h"
|
||||
#include "dialog-sxsincelast.h"
|
||||
#include "dialog-totd.h"
|
||||
#include "dialog-transfer.h"
|
||||
#include "dialog-utils.h"
|
||||
#include "druid-loan.h"
|
||||
@@ -34,6 +33,7 @@
|
||||
#include "gnc-plugin.h"
|
||||
#include "gnc-plugin-manager.h"
|
||||
#include "gnc-split-reg.h"
|
||||
#include "gnc-totd-dialog.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-version.h"
|
||||
#include "mainwindow-account-tree.h"
|
||||
@@ -55,6 +55,7 @@ static void gnc_main_window_setup_window (GncMainWindow *window);
|
||||
/* Callbacks */
|
||||
static void gnc_main_window_add_widget (EggMenuMerge *merge, GtkWidget *widget, GncMainWindow *window);
|
||||
static void gnc_main_window_change_current_page (GtkNotebook *notebook, gint pos, GncMainWindow *window);
|
||||
static void gnc_main_window_switch_page (GtkNotebook *notebook, GtkNotebookPage *notebook_page, gint pos, GncMainWindow *window);
|
||||
static void gnc_main_window_plugin_added (GncPlugin *manager, GncPlugin *plugin, GncMainWindow *window);
|
||||
static void gnc_main_window_plugin_removed (GncPlugin *manager, GncPlugin *plugin, GncMainWindow *window);
|
||||
|
||||
@@ -86,7 +87,7 @@ static void gnc_main_window_cmd_tools_commodity_editor (EggAction *action, GncMa
|
||||
static void gnc_main_window_cmd_tools_financial_calculator (EggAction *action, GncMainWindow *window);
|
||||
static void gnc_main_window_cmd_tools_find_transactions (EggAction *action, GncMainWindow *window);
|
||||
static void gnc_main_window_cmd_help_tutorial (EggAction *action, GncMainWindow *window);
|
||||
static void gnc_main_window_cmd_help_tips_of_the_day (EggAction *action, GncMainWindow *window);
|
||||
static void gnc_main_window_cmd_help_totd (EggAction *action, GncMainWindow *window);
|
||||
static void gnc_main_window_cmd_help_contents (EggAction *action, GncMainWindow *window);
|
||||
static void gnc_main_window_cmd_help_about (EggAction *action, GncMainWindow *window);
|
||||
|
||||
@@ -217,7 +218,7 @@ static EggActionGroupEntry gnc_menu_entries [] = {
|
||||
G_CALLBACK (gnc_main_window_cmd_help_tutorial), NULL },
|
||||
{ "HelpTipsOfTheDayAction", N_("_Tips Of The Day"), NULL, NULL,
|
||||
N_("View the Tips of the Day"),
|
||||
G_CALLBACK (gnc_main_window_cmd_help_tips_of_the_day), NULL },
|
||||
G_CALLBACK (gnc_main_window_cmd_help_totd), NULL },
|
||||
{ "HelpContentsAction", N_("_Contents"), GTK_STOCK_HELP, NULL,
|
||||
N_("Open the GnuCash Help"),
|
||||
G_CALLBACK (gnc_main_window_cmd_help_contents), NULL },
|
||||
@@ -336,6 +337,24 @@ gnc_main_window_close_page (GncMainWindow *window,
|
||||
gtk_notebook_remove_page (GTK_NOTEBOOK (window->priv->notebook), i);
|
||||
|
||||
gnc_plugin_page_removed (page);
|
||||
|
||||
egg_menu_merge_ensure_update (window->ui_merge);
|
||||
|
||||
/* */
|
||||
i = gtk_notebook_get_current_page (GTK_NOTEBOOK (window->priv->notebook));
|
||||
child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->priv->notebook), i);
|
||||
if (child == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
page = g_object_get_data (G_OBJECT (child), "page-plugin");
|
||||
|
||||
window->priv->current_page = page;
|
||||
|
||||
if (page != NULL) {
|
||||
gnc_plugin_page_merge_actions (page, window->ui_merge);
|
||||
gnc_plugin_page_selected (page);
|
||||
}
|
||||
}
|
||||
|
||||
GncPluginPage *
|
||||
@@ -504,6 +523,8 @@ gnc_main_window_setup_window (GncMainWindow *window)
|
||||
gtk_widget_show (window->priv->notebook);
|
||||
g_signal_connect (G_OBJECT (window->priv->notebook), "change-current-page",
|
||||
G_CALLBACK (gnc_main_window_change_current_page), window);
|
||||
g_signal_connect (G_OBJECT (window->priv->notebook), "switch-page",
|
||||
G_CALLBACK (gnc_main_window_switch_page), window);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), window->priv->notebook,
|
||||
TRUE, TRUE, 0);
|
||||
|
||||
@@ -554,6 +575,15 @@ gnc_main_window_add_widget (EggMenuMerge *merge,
|
||||
gtk_widget_show (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_main_window_switch_page (GtkNotebook *notebook,
|
||||
GtkNotebookPage *notebook_page,
|
||||
gint pos,
|
||||
GncMainWindow *window)
|
||||
{
|
||||
/* FIXME Use switch_page instead of change_current_page */
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_main_window_change_current_page (GtkNotebook *notebook,
|
||||
gint pos,
|
||||
@@ -830,9 +860,13 @@ gnc_main_window_cmd_help_tutorial (EggAction *action, GncMainWindow *window)
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_main_window_cmd_help_tips_of_the_day (EggAction *action, GncMainWindow *window)
|
||||
gnc_main_window_cmd_help_totd (EggAction *action, GncMainWindow *window)
|
||||
{
|
||||
gnc_ui_totd_dialog_create_and_run();
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gnc_totd_dialog_new (GTK_WINDOW (window));
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
221
src/gnome/gnc-totd-dialog.c
Normal file
221
src/gnome/gnc-totd-dialog.c
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* gnc-totd-dialog.c : dialog to display a "tip of the day"
|
||||
* Copyright (C) 2003 Jan Arne Petersen
|
||||
* Author: Jan Arne Petersen <jpetersen@uni-bonn.de>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glade/glade.h>
|
||||
#include <gtk/gtkdialog.h>
|
||||
#include <gtk/gtkcheckbutton.h>
|
||||
|
||||
#include "gnc-totd-dialog.h"
|
||||
#include "dialog-utils.h"
|
||||
#include "global-options.h"
|
||||
#include "tip-of-the-day.h"
|
||||
|
||||
#include "messages.h"
|
||||
|
||||
static void gnc_totd_dialog_class_init (GncTotdDialogClass *klass);
|
||||
static void gnc_totd_dialog_init (GncTotdDialog *dialog);
|
||||
static void gnc_totd_dialog_dispose (GObject *object);
|
||||
static void gnc_totd_dialog_finalize (GObject *object);
|
||||
|
||||
static void gnc_totd_dialog_next_activated (GtkButton *button, GncTotdDialog *dialog);
|
||||
static void gnc_totd_dialog_previous_activated (GtkButton *button, GncTotdDialog *dialog);
|
||||
static void gnc_totd_dialog_button_toggled (GtkToggleButton *button, GncTotdDialog *dialog);
|
||||
|
||||
#define GNC_RESPONSE_NEXT 0
|
||||
#define GNC_RESPONSE_PREVIOUS 1
|
||||
|
||||
struct GncTotdDialogPrivate {
|
||||
GtkCheckButton *show_checkbutton;
|
||||
GtkTextView *tip_textview;
|
||||
};
|
||||
|
||||
static GtkDialogClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
gnc_totd_dialog_get_type (void)
|
||||
{
|
||||
static GType gnc_totd_dialog_type = 0;
|
||||
|
||||
if (gnc_totd_dialog_type == 0) {
|
||||
static const GTypeInfo our_info = {
|
||||
sizeof (GncTotdDialogClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) gnc_totd_dialog_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GncTotdDialog),
|
||||
0,
|
||||
(GInstanceInitFunc) gnc_totd_dialog_init
|
||||
};
|
||||
|
||||
gnc_totd_dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
|
||||
"GncTotdDialog",
|
||||
&our_info, 0);
|
||||
}
|
||||
|
||||
return gnc_totd_dialog_type;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gnc_totd_dialog_new (GtkWindow *parent)
|
||||
{
|
||||
GncTotdDialog *dialog;
|
||||
|
||||
dialog = g_object_new (GNC_TYPE_TOTD_DIALOG, NULL);
|
||||
|
||||
if (parent != NULL) {
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
|
||||
}
|
||||
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_totd_dialog_create_and_run (void)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gnc_totd_dialog_new (NULL);
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_totd_dialog_class_init (GncTotdDialogClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_totd_dialog_finalize;
|
||||
object_class->dispose = gnc_totd_dialog_dispose;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gnc_totd_dialog_create_button (const gchar *image_id, const gchar *text)
|
||||
{
|
||||
GtkWidget *image;
|
||||
GtkWidget *label;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *button;
|
||||
|
||||
image = gtk_image_new_from_stock (image_id, GTK_ICON_SIZE_BUTTON);
|
||||
gtk_widget_show (image);
|
||||
label = gtk_label_new_with_mnemonic (text);
|
||||
gtk_widget_show (label);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), hbox);
|
||||
gtk_widget_show (alignment);
|
||||
|
||||
button = gtk_button_new ();
|
||||
gtk_container_add (GTK_CONTAINER (button), alignment);
|
||||
gtk_widget_show (button);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_totd_dialog_init (GncTotdDialog *dialog)
|
||||
{
|
||||
GladeXML *xml;
|
||||
gchar *new_tip;
|
||||
GtkWidget *button;
|
||||
|
||||
dialog->priv = g_new0 (GncTotdDialogPrivate, 1);
|
||||
|
||||
button = gnc_totd_dialog_create_button (GTK_STOCK_GO_BACK, _("_Previous Tip"));
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (gnc_totd_dialog_previous_activated), dialog);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), button);
|
||||
|
||||
button = gnc_totd_dialog_create_button (GTK_STOCK_GO_FORWARD, _("_Next Tip"));
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (gnc_totd_dialog_next_activated), dialog);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), button);
|
||||
|
||||
gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE,
|
||||
GTK_RESPONSE_CLOSE);
|
||||
|
||||
xml = gnc_glade_xml_new ("totd.glade", "totd_vbox");
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
|
||||
glade_xml_get_widget (xml, "totd_vbox"));
|
||||
|
||||
dialog->priv->show_checkbutton = GTK_CHECK_BUTTON (glade_xml_get_widget (xml, "show_checkbutton"));
|
||||
g_signal_connect (G_OBJECT (dialog->priv->show_checkbutton), "toggled",
|
||||
G_CALLBACK (gnc_totd_dialog_button_toggled), dialog);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->show_checkbutton),
|
||||
gnc_lookup_boolean_option("General",
|
||||
"Display \"Tip of the Day\"",
|
||||
TRUE));
|
||||
|
||||
dialog->priv->tip_textview = GTK_TEXT_VIEW (glade_xml_get_widget (xml, "tip_textview"));
|
||||
new_tip = gnc_get_current_tip();
|
||||
gtk_text_buffer_set_text (gtk_text_view_get_buffer (dialog->priv->tip_textview),
|
||||
new_tip, -1);
|
||||
g_free (new_tip);
|
||||
|
||||
g_object_unref (G_OBJECT (xml));
|
||||
|
||||
gtk_widget_set_size_request (GTK_WIDGET (dialog), -1, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_totd_dialog_finalize (GObject *object)
|
||||
{
|
||||
g_free (GNC_TOTD_DIALOG (object)->priv);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_totd_dialog_dispose (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_totd_dialog_next_activated (GtkButton *button, GncTotdDialog *dialog)
|
||||
{
|
||||
gchar *new_tip;
|
||||
|
||||
gnc_increment_tip ();
|
||||
new_tip = gnc_get_current_tip();
|
||||
gtk_text_buffer_set_text (gtk_text_view_get_buffer (dialog->priv->tip_textview),
|
||||
new_tip, -1);
|
||||
g_free (new_tip);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_totd_dialog_previous_activated (GtkButton *button, GncTotdDialog *dialog)
|
||||
{
|
||||
gchar *new_tip;
|
||||
|
||||
gnc_decrement_tip ();
|
||||
new_tip = gnc_get_current_tip();
|
||||
gtk_text_buffer_set_text (gtk_text_view_get_buffer (dialog->priv->tip_textview),
|
||||
new_tip, -1);
|
||||
g_free (new_tip);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_totd_dialog_button_toggled (GtkToggleButton *button, GncTotdDialog *dialog)
|
||||
{
|
||||
gnc_set_boolean_option("General",
|
||||
"Display \"Tip of the Day\"",
|
||||
gtk_toggle_button_get_active (button));
|
||||
gnc_option_refresh_ui_by_name("General", "Display \"Tip of the Day\"");
|
||||
}
|
||||
47
src/gnome/gnc-totd-dialog.h
Normal file
47
src/gnome/gnc-totd-dialog.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* gnc-totd-dialog.h : dialog to display a "tip of the day"
|
||||
* Copyright (C) 2003 Jan Arne Petersen
|
||||
* Author: Jan Arne Petersen <jpetersen@uni-bonn.de>
|
||||
*/
|
||||
|
||||
#ifndef DIALOG_TOTD_H
|
||||
#define DIALOG_TOTD_H
|
||||
|
||||
#include <gtk/gtkdialog.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* type macros */
|
||||
#define GNC_TYPE_TOTD_DIALOG (gnc_totd_dialog_get_type ())
|
||||
#define GNC_TOTD_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TOTD_DIALOG, GncTotdDialog))
|
||||
#define GNC_TOTD_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TOTD_DIALOG, GncTotdDialogClass))
|
||||
#define GNC_IS_TOTD_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TOTD_DIALOG))
|
||||
#define GNC_IS_TOTD_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TOTD_DIALOG))
|
||||
#define GNC_TOTD_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TOTD_DIALOG, GncTotdDialogClass))
|
||||
|
||||
/* typedefs & structures */
|
||||
typedef struct GncTotdDialogPrivate GncTotdDialogPrivate;
|
||||
|
||||
typedef struct {
|
||||
GtkDialog parent;
|
||||
|
||||
GncTotdDialogPrivate *priv;
|
||||
} GncTotdDialog;
|
||||
|
||||
typedef struct {
|
||||
GtkDialogClass parent;
|
||||
|
||||
/* Signals */
|
||||
void (* close) (GncTotdDialog *dialog);
|
||||
} GncTotdDialogClass;
|
||||
|
||||
/* function prototypes */
|
||||
GType gnc_totd_dialog_get_type (void);
|
||||
|
||||
GtkWidget *gnc_totd_dialog_new (GtkWindow *parent);
|
||||
|
||||
void gnc_totd_dialog_create_and_run (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -35,11 +35,11 @@
|
||||
"#include <gnc-engine.h>\n"
|
||||
"#include <gnc-commodity.h>\n"
|
||||
"#include <gnc-numeric.h>\n"
|
||||
"#include <gnc-totd-dialog.h>\n"
|
||||
"#include <window-main.h>\n"
|
||||
"#include <gnc-gui-query.h>\n"
|
||||
"#include <dialog-new-user.h>\n"
|
||||
"#include <dialog-progress.h>\n"
|
||||
"#include <dialog-totd.h>\n"
|
||||
"#include <dialog-commodity.h>\n"
|
||||
"#include <druid-hierarchy.h>\n"
|
||||
"#include <top-level.h>\n"
|
||||
@@ -142,7 +142,7 @@
|
||||
ws
|
||||
'gnc:ui-totd-dialog-create-and-run
|
||||
'<gw:void>
|
||||
"gnc_ui_totd_dialog_create_and_run"
|
||||
"gnc_totd_dialog_create_and_run"
|
||||
'()
|
||||
"Create and run the \"Tip Of The Day\" dialog")
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "dialog-options.h"
|
||||
#include "dialog-scheduledxaction.h"
|
||||
#include "dialog-sxsincelast.h"
|
||||
#include "dialog-totd.h"
|
||||
#include "dialog-transfer.h"
|
||||
#include "dialog-utils.h"
|
||||
#include "druid-loan.h"
|
||||
@@ -778,7 +777,6 @@ void
|
||||
gnc_main_window_totd_cb (GtkWidget *widget, gpointer data)
|
||||
|
||||
{
|
||||
gnc_ui_totd_dialog_create_and_run();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ AM_CFLAGS = \
|
||||
-I${top_srcdir}/src/app-file \
|
||||
-I${top_srcdir}/src/gnome \
|
||||
-I${top_srcdir}/src/gnome-utils \
|
||||
-I${top_srcdir}/src/gnome-utils/egg \
|
||||
-I${top_srcdir}/lib/egg \
|
||||
-DGNC_UI_DIR=\"$(GNC_UI_DIR)\" \
|
||||
${G_WRAP_COMPILE_ARGS} \
|
||||
${GUILE_INCS} \
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
(let ((tip-opt (gnc:lookup-global-option "General"
|
||||
"Display \"Tip of the Day\"")))
|
||||
(if (gnc:option-value tip-opt)
|
||||
(gnc:ui-totd-dialog-create-and-run))))
|
||||
(gnc:totd-dialog-create-and-run))))
|
||||
|
||||
(define (gnc:initialize-tip-of-the-day)
|
||||
(set! gnc:*tip-file*
|
||||
|
||||
Reference in New Issue
Block a user