--- Begin Message ---
Package: jpilot
Version: 0.99.7-9
Severity: wishlist
Tags: patch
This patch from Luc Wastiaux adds an "automatic export" checkbox to the
datebook export window and remembers the text/csv/ical choice. Each
time a hotsync occurs the datebook is exported.
http://lists.jpilot.org/pipermail/jpilot/2004-August/004189.html
The attached .dpatch applies cleanly to 0.99.7-9 and builds. It works,
too!
Thanks,
Alec
-- System Information:
Debian Release: 3.1
APT prefers testing
APT policy: (990, 'testing'), (400, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.8-1-686
Locale: LANG=en_US, LC_CTYPE=en_US
Versions of packages jpilot depends on:
ii debconf 1.4.32 Debian configuration management sy
ii libatk1.0-0 1.6.1-3 The ATK accessibility toolkit
ii libc6 2.3.2.ds1-16 GNU C Library: Shared libraries an
ii libglib2.0-0 2.4.6-2 The GLib library of C routines
ii libgtk2.0-0 2.4.9-1 The GTK+ graphical user interface
ii libncurses5 5.4-4 Shared libraries for terminal hand
ii libpango1.0-0 1.4.1-2 Layout and rendering of internatio
ii libpisock8 0.11.8-10 Library for communicating with a P
ii libreadline4 4.3-11 GNU readline and history libraries
-- debconf information excluded
*** /home/alec/debian/24_export_datebook.dpatch
#!/bin/sh -e
## 24_export_datebook.dpatch by Luc Wastiaux <[email protected]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Automatically exports the datebook after each hotsync
if [ $# -lt 1 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
case "$1" in
-patch) patch $patch_opts -p1 < $0;;
-unpatch) patch $patch_opts -p1 -R < $0;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as
argument"
exit 1;;
esac
exit 0
@DPATCH@
--- jpilot-0.99.7/datebook.h 2003-12-08 03:20:27.000000000 +0100
+++ jpilot-0.99.7-patch_luc/datebook.h 2004-08-23 12:40:21.768100416 +0200
@@ -138,4 +138,7 @@
int datebook_import(GtkWidget *window);
int datebook_export(GtkWidget *window);
+/* Perform automatic datebook export if needed */
+void datebook_auto_export();
+
#endif
--- jpilot-0.99.7/datebook_gui.c 2004-02-22 20:36:04.000000000 +0100
+++ jpilot-0.99.7-patch_luc/datebook_gui.c 2004-08-23 12:39:48.058225096
+0200
@@ -638,7 +638,7 @@
GtkWidget *export_window;
-void appt_export_ok(int type, const char *filename)
+void appt_export_ok(int type, const char *filename, int overwrite)
{
MyAppointment *ma;
AppointmentList *al, *temp_list;
@@ -657,6 +657,7 @@
const char *svalue;
long userid;
+
al=NULL;
/* this stuff is for ical only. */
@@ -679,13 +680,16 @@
"Directory", text, 1, button_text);
return;
}
- g_snprintf(text, sizeof(text), _("Do you want to overwrite file %s?"),
filename);
- r = dialog_generic(GTK_WINDOW(export_window),
- 0, 0, _("Overwrite File?"),
- _("Overwrite File"), text, 2, button_overwrite_text);
- if (r!=DIALOG_SAID_1) {
- return;
- }
+ if ( !overwrite)
+ {
+ g_snprintf(text, sizeof(text), _("Do you want to overwrite file
%s?"), filename);
+ r = dialog_generic(GTK_WINDOW(export_window),
+ 0, 0, _("Overwrite File?"),
+ _("Overwrite File"), text, 2,
button_overwrite_text);
+ if (r!=DIALOG_SAID_1) {
+ return;
+ }
+ }
}
out = fopen(filename, "w");
@@ -974,6 +978,28 @@
}
/*
+ Check if auto-export is desired, and proceed
+ */
+void datebook_auto_export()
+{
+ long pref_export_auto;
+ long pref_export_type;
+ char *pref_export_filename;
+
+
+ get_pref(PREF_DATEBOOK_EXPORT_AUTO, &pref_export_auto, NULL);
+ if ( !pref_export_auto)
+ return;
+
+
+ /* retrieve export filename and type, then export */
+ get_pref(PREF_DATEBOOK_EXPORT_FILENAME, NULL, &pref_export_filename);
+ get_pref(PREF_DATEBOOK_EXPORT_TYPE, &pref_export_type, NULL);
+
+ appt_export_ok((int) pref_export_type, pref_export_filename, 1);
+}
+
+/*
* Start Export GUI
*/
#define BROWSE_OK 1
@@ -985,6 +1011,7 @@
static GtkWidget *save_as_entry;
static GtkWidget *export_radio_type[NUM_EXPORT_TYPES+1];
static int glob_export_type;
+static int glob_export_auto;
static int datebook_export_gui(GtkWidget *main_window, int x, int y);
@@ -1020,7 +1047,12 @@
filename = gtk_entry_get_text(GTK_ENTRY(save_as_entry));
- appt_export_ok(glob_export_type, filename);
+ /* store export type to preferences */
+ set_pref(PREF_DATEBOOK_EXPORT_TYPE, glob_export_type, NULL, TRUE);
+ /* store "auto export" setting to preferences */
+ set_pref(PREF_DATEBOOK_EXPORT_AUTO, glob_export_auto, NULL, TRUE);
+
+ appt_export_ok(glob_export_type, filename, 0);
gtk_widget_destroy(data);
}
@@ -1053,17 +1085,30 @@
glob_export_type=GPOINTER_TO_INT(data);
}
+static void
+cb_export_auto(GtkWidget *widget,
+ gpointer data)
+{
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)))
+ glob_export_auto = 1;
+ else
+ glob_export_auto = 0;
+}
+
static int datebook_export_gui(GtkWidget *main_window, int x, int y)
{
GtkWidget *button;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
+ GtkWidget *checkbutton;
GSList *group;
char *type_text[]={"Text", "CSV", "iCalendar", NULL};
int type_int[]={EXPORT_TYPE_TEXT, EXPORT_TYPE_CSV, EXPORT_TYPE_ICALENDAR};
int i;
const char *svalue;
+ long pref_export_type;
+ long pref_export_auto;
jp_logf(JP_LOG_DEBUG, "datebook_export_gui()\n");
@@ -1104,6 +1149,36 @@
}
export_radio_type[i] = NULL;
+ /* pre-select export type */
+ jp_logf(JP_LOG_DEBUG, "pre-setting export type\n");
+ get_pref(PREF_DATEBOOK_EXPORT_TYPE, &pref_export_type, NULL);
+ for (i=0; i<NUM_EXPORT_TYPES; i++)
+ {
+ if (pref_export_type == type_int[i])
+ {
+ /* "press" radio button for that export type */
+ jp_logf(JP_LOG_DEBUG, "found export type in preferences: %d\n",
pref_export_type);
+
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(export_radio_type[i]), TRUE);
+ glob_export_type = pref_export_type;
+ }
+ }
+
+ /* "automatically export" checkbox */
+ checkbutton = gtk_check_button_new_with_label(_("Export Datebook after each
HotSync"));
+ gtk_box_pack_start(GTK_BOX(vbox), checkbutton, FALSE, FALSE, 0);
+
+ gtk_signal_connect(GTK_OBJECT(checkbutton), "toggled",
+ GTK_SIGNAL_FUNC(cb_export_auto),
+ NULL);
+
+ get_pref(PREF_DATEBOOK_EXPORT_AUTO, &pref_export_auto, NULL);
+ jp_logf(JP_LOG_DEBUG, "pref_export_auto: %d\n", pref_export_auto);
+ if (pref_export_auto == 1)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbutton), TRUE);
+ }
+
+
/* Save As entry */
hbox = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
@@ -1122,6 +1197,8 @@
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(cb_export_browse), export_window);
+
+
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
--- jpilot-0.99.7/jpilot.c 2004-03-01 01:09:03.000000000 +0100
+++ jpilot-0.99.7-patch_luc/jpilot.c 2004-08-23 12:58:39.692190584 +0200
@@ -956,6 +956,8 @@
if (Pstr1) {
cb_app_button(NULL, GINT_TO_POINTER(REDRAW));
}
+ /* auto-export datebook if needed */
+ datebook_auto_export();
break;
default:
jp_logf(JP_LOG_WARN, "unknown command from sync process\n");
--- jpilot-0.99.7/prefs.c 2004-02-23 04:54:05.000000000 +0100
+++ jpilot-0.99.7-patch_luc/prefs.c 2004-08-23 11:56:48.466382664 +0200
@@ -108,6 +108,8 @@
{"last_todo_category", INTTYPE, INTTYPE, CATEGORY_ALL, NULL, 0},
{"last_memo_category", INTTYPE, INTTYPE, CATEGORY_ALL, NULL, 0},
{"version", CHARTYPE, CHARTYPE, 0, NULL, 0},
+ {"datebook_export_type", INTTYPE, INTTYPE, 0, NULL, 0},
+ {"datebook_export_auto", INTTYPE, INTTYPE, 0, NULL, 0},
};
struct name_list {
--- jpilot-0.99.7/prefs.h 2004-02-23 04:53:30.000000000 +0100
+++ jpilot-0.99.7-patch_luc/prefs.h 2004-08-23 11:56:31.906900088 +0200
@@ -97,8 +97,10 @@
#define PREF_LAST_TODO_CATEGORY 73
#define PREF_LAST_MEMO_CATEGORY 74
#define PREF_VERSION 75
+#define PREF_DATEBOOK_EXPORT_TYPE 76
+#define PREF_DATEBOOK_EXPORT_AUTO 77
-#define NUM_PREFS 76
+#define NUM_PREFS 78
#define MAX_PREF_NUM_BACKUPS 99
--- jpilot-0.99.7/sync.c 2004-02-22 20:38:28.000000000 +0100
+++ jpilot-0.99.7-patch_luc/sync.c 2004-08-23 12:58:36.430686408 +0200
@@ -936,7 +936,7 @@
jp_logf(JP_LOG_GUI, _("Finished.\n"));
write_to_parent(PIPE_FINISHED, "\n");
-
+
return 0;
}
--- End Message ---