"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "jpilot.c" between
jpilot-1.8.2.tar.gz and jpilot-2_0_1.tar.gz

About: J-Pilot is a desktop organizer application for Palm Pilot (PalmOS) devices. Ported to GTK3.

jpilot.c  (jpilot-1.8.2):jpilot.c  (jpilot-2_0_1)
skipping to change at line 32 skipping to change at line 32
#include "config.h" #include "config.h"
#include <time.h> #include <time.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_LOCALE_H #ifdef HAVE_LOCALE_H
# include <locale.h> # include <locale.h>
#endif #endif
#ifdef HAVE_LANGINFO_H #ifdef HAVE_LANGINFO_H
# include <langinfo.h> # include <langinfo.h>
#endif #endif
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include "utils.h" #include "utils.h"
#include "i18n.h" #include "i18n.h"
#include "otherconv.h" #include "otherconv.h"
#include "libplugin.h" #include "libplugin.h"
#include "datebook.h" #include "datebook.h"
#include "address.h" #include "address.h"
#include "install_user.h" #include "install_user.h"
skipping to change at line 83 skipping to change at line 89
/********************************* Constants **********************************/ /********************************* Constants **********************************/
#define OUTPUT_MINIMIZE 383 #define OUTPUT_MINIMIZE 383
#define OUTPUT_RESIZE 384 #define OUTPUT_RESIZE 384
#define OUTPUT_SETSIZE 385 #define OUTPUT_SETSIZE 385
#define OUTPUT_CLEAR 386 #define OUTPUT_CLEAR 386
#define MASK_WIDTH 0x08 #define MASK_WIDTH 0x08
#define MASK_HEIGHT 0x04 #define MASK_HEIGHT 0x04
#define MASK_X 0x02 #define MASK_X 0x02
#define MASK_Y 0x01 #define MASK_Y 0x01
#define PIPE_DEBUG 1
/* #define PIPE_DEBUG */ /* #define PIPE_DEBUG */
/******************************* Global vars **********************************/ /******************************* Global vars **********************************/
/* Application-wide globals */ /* Application-wide globals */
int pipe_from_child, pipe_to_parent; int pipe_from_child, pipe_to_parent;
int pipe_from_parent, pipe_to_child; int pipe_from_parent, pipe_to_child;
/* Main GTK window for application */ /* Main GTK window for application */
GtkWidget *window; GtkWidget *window;
GtkWidget *glob_date_label; GtkWidget *glob_date_label;
GtkTooltips *glob_tooltips; GtkWidget *glob_dialog = NULL;
GtkWidget *glob_dialog=NULL;
int glob_app = 0; int glob_app = 0;
unsigned char skip_plugins; unsigned char skip_plugins;
gint glob_date_timer_tag; gint glob_date_timer_tag;
pid_t glob_child_pid; pid_t glob_child_pid;
pid_t jpilot_master_pid; pid_t jpilot_master_pid;
int plugin_number = DATEBOOK + 100;
/* jpilot.c file globals */ /* jpilot.c file globals */
static GtkWidget *g_hbox, *g_vbox0; static GtkWidget *g_hbox, *g_vbox0;
static GtkWidget *g_hbox2, *g_vbox0_1; static GtkWidget *g_hbox2, *g_vbox0_1;
static GtkWidget *g_output_text_scrolled_window;
static GtkTextView *g_output_text; static GtkTextView *g_output_text;
static GtkTextBuffer *g_output_text_buffer; static GtkTextBuffer *g_output_text_buffer;
static GtkWidget *output_pane; static GtkWidget *output_pane;
static GtkWidget *button_locked; static GtkWidget *button_locked;
static GtkWidget *button_masklocked; static GtkWidget *button_masklocked;
static GtkWidget *button_unlocked; static GtkWidget *button_unlocked;
static GtkWidget *button_sync; static GtkWidget *button_sync;
static GtkWidget *button_cancel_sync; static GtkWidget *button_cancel_sync;
static GtkWidget *button_backup; static GtkWidget *button_backup;
static GtkCheckMenuItem *menu_hide_privates; static GtkWidget *menu_hide_privates;
static GtkCheckMenuItem *menu_show_privates; static GtkWidget *menu_show_privates;
static GtkCheckMenuItem *menu_mask_privates; static GtkWidget *menu_mask_privates;
extern GtkWidget *weekview_window; extern GtkWidget *weekview_window;
extern GtkWidget *monthview_window; extern GtkWidget *monthview_window;
/****************************** Prototypes ************************************/ /****************************** Prototypes ************************************/
static void cb_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data); static void cb_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data);
static void install_gui_and_size(GtkWidget *main_window); static void install_gui_and_size(GtkWidget *main_window);
static void cb_private(GtkWidget *widget, gpointer data);
char *getViewMenuXmlString();
#ifdef ENABLE_PLUGINS
static void call_plugin_help(int number);
#endif
/****************************** Main Code *************************************/ /****************************** Main Code *************************************/
static int create_main_boxes(void) static int create_main_boxes(void) {
{ g_hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
g_hbox2 = gtk_hbox_new(FALSE, 0); g_vbox0_1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
g_vbox0_1 = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(g_hbox), g_hbox2, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(g_hbox), g_hbox2, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(g_vbox0), g_vbox0_1, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(g_vbox0), g_vbox0_1, FALSE, FALSE, 0);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
static int gui_cleanup(void) static int gui_cleanup(void) {
{
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
struct plugin_s *plugin; struct plugin_s *plugin;
GList *plugin_list, *temp_list; GList *plugin_list, *temp_list;
#endif #endif
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
plugin_list = NULL; plugin_list = NULL;
plugin_list = get_plugin_list(); plugin_list = get_plugin_list();
/* Find out which (if any) plugin to call a gui_cleanup on */ /* Find out which (if any) plugin to call a gui_cleanup on */
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) { for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
plugin = (struct plugin_s *)temp_list->data; plugin = (struct plugin_s *) temp_list->data;
if (plugin) { if (plugin) {
if (plugin->number == glob_app) { if (plugin->number == glob_app) {
if (plugin->plugin_gui_cleanup) { if (plugin->plugin_gui_cleanup) {
plugin->plugin_gui_cleanup(); plugin->plugin_gui_cleanup();
}
break;
} }
break; }
} }
}
}
#endif #endif
switch (glob_app) { // if you uncomment this line, changing themes will switch live
case DATEBOOK: // however, there are some side effects that I haven't figured out
datebook_gui_cleanup(); // how to overcome. (things overridden in a theme, but not defined in anothe
break; r
case ADDRESS: // do not revert back to default.)
address_gui_cleanup(); // read_gtkrc_file();
break; switch (glob_app) {
case TODO: case DATEBOOK:
todo_gui_cleanup(); datebook_gui_cleanup();
break; break;
case MEMO: case ADDRESS:
memo_gui_cleanup(); address_gui_cleanup();
break; break;
default: case TODO:
break; todo_gui_cleanup();
} break;
return EXIT_SUCCESS; case MEMO:
memo_gui_cleanup();
break;
default:
break;
}
return EXIT_SUCCESS;
} }
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
void call_plugin_gui(int number, int unique_id)
{
struct plugin_s *plugin;
GList *plugin_list, *temp_list;
if (!number) {
return;
}
gui_cleanup();
plugin_list = NULL; void call_plugin_gui(int number, int unique_id) {
plugin_list = get_plugin_list(); struct plugin_s *plugin;
GList *plugin_list, *temp_list;
/* Destroy main boxes and recreate them */
gtk_widget_destroy(g_vbox0_1); if (!number) {
gtk_widget_destroy(g_hbox2); return;
create_main_boxes(); }
if (glob_date_timer_tag) {
gtk_timeout_remove(glob_date_timer_tag); gui_cleanup();
}
plugin_list = NULL;
/* Find out which plugin we are calling */ plugin_list = get_plugin_list();
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
plugin = (struct plugin_s *)temp_list->data; /* Destroy main boxes and recreate them */
if (plugin) { gtk_widget_destroy(g_vbox0_1);
if (plugin->number == number) { gtk_widget_destroy(g_hbox2);
glob_app = plugin->number; create_main_boxes();
if (plugin->plugin_gui) { if (glob_date_timer_tag) {
plugin->plugin_gui(g_vbox0_1, g_hbox2, unique_id); g_source_remove(glob_date_timer_tag);
glob_date_timer_tag = 0;
}
/* Find out which plugin we are calling */
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
plugin = (struct plugin_s *) temp_list->data;
if (plugin) {
if (plugin->number == number) {
glob_app = plugin->number;
if (plugin->plugin_gui) {
plugin->plugin_gui(g_vbox0_1, g_hbox2, unique_id);
}
break;
} }
break; }
} }
}
}
} }
static void cb_plugin_gui(GtkWidget *widget, int number) //static void cb_plugin_setup() {
{ // call_plugin_gui(plugin_number++, 0);
call_plugin_gui(number, 0); //}
static void cb_plugin_gui(GtkAction *action, int number) {
call_plugin_gui(number, 0);
} }
/* Redraws plugin GUI after structure changing event such as category editing */ /* Redraws plugin GUI after structure changing event such as category editing */
void plugin_gui_refresh(int unique_id) void plugin_gui_refresh(int unique_id) {
{ call_plugin_gui(glob_app, unique_id);
call_plugin_gui(glob_app, unique_id);
} }
static void cb_plugin_help(GtkAction *action,
static void call_plugin_help(int number) gpointer user_data){
{ call_plugin_help(GPOINTER_TO_INT(user_data));
struct plugin_s *plugin; }
GList *plugin_list, *temp_list; static void call_plugin_help(int number) {
char *button_text[]={N_("OK")}; struct plugin_s *plugin;
char *text; GList *plugin_list, *temp_list;
int width, height; char *button_text[] = {N_("OK")};
char *text;
if (!number) { int width, height;
return;
} if (!number) {
return;
plugin_list = NULL; }
plugin_list = get_plugin_list();
plugin_list = NULL;
/* Find out which plugin we are calling */ plugin_list = get_plugin_list();
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
plugin = (struct plugin_s *)temp_list->data; /* Find out which plugin we are calling */
if (plugin) { for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
if (plugin->number == number) { plugin = (struct plugin_s *) temp_list->data;
if (plugin->plugin_help) { if (plugin) {
text = NULL; if (plugin->number == number) {
plugin->plugin_help(&text, &width, &height); if (plugin->plugin_help) {
if (text) { text = NULL;
dialog_generic(GTK_WINDOW(window), plugin->plugin_help(&text, &width, &height);
plugin->help_name, DIALOG_INFO, text, 1, button if (text) {
_text); dialog_generic(GTK_WINDOW(window),
free(text); plugin->help_name, DIALOG_INFO, text, 1,
} button_text);
free(text);
}
}
break;
} }
break; }
} }
}
}
}
static void cb_plugin_help(GtkWidget *widget, int number)
{
call_plugin_help(number);
} }
#endif #endif
static void cb_print(GtkWidget *widget, gpointer data) static void cb_print(GtkWidget *widget, gpointer data) {
{
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
struct plugin_s *plugin; struct plugin_s *plugin;
GList *plugin_list, *temp_list; GList *plugin_list, *temp_list;
#endif #endif
char *button_text[]={N_("OK")}; char *button_text[] = {N_("OK")};
switch (glob_app) { switch (glob_app) {
case DATEBOOK: case DATEBOOK:
if (print_gui(window, DATEBOOK, 1, 0x07) == DIALOG_SAID_PRINT) { if (print_gui(window, DATEBOOK, 1, 0x07) == DIALOG_SAID_PRINT) {
datebook_print(print_day_week_month); datebook_print(print_day_week_month);
} }
return; return;
case ADDRESS: case ADDRESS:
if (print_gui(window, ADDRESS, 0, 0x00) == DIALOG_SAID_PRINT) { if (print_gui(window, ADDRESS, 0, 0x00) == DIALOG_SAID_PRINT) {
address_print(); address_print();
} }
return; return;
case TODO: case TODO:
if (print_gui(window, TODO, 0, 0x00) == DIALOG_SAID_PRINT) { if (print_gui(window, TODO, 0, 0x00) == DIALOG_SAID_PRINT) {
todo_print(); todo_print();
} }
return; return;
case MEMO: case MEMO:
if (print_gui(window, MEMO, 0, 0x00) == DIALOG_SAID_PRINT) { if (print_gui(window, MEMO, 0, 0x00) == DIALOG_SAID_PRINT) {
memo_print(); memo_print();
} }
return; return;
} }
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
plugin_list = NULL; plugin_list = NULL;
plugin_list = get_plugin_list(); plugin_list = get_plugin_list();
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) { for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
plugin = (struct plugin_s *)temp_list->data; plugin = (struct plugin_s *) temp_list->data;
if (plugin) { if (plugin) {
if (glob_app == plugin->number) { if (glob_app == plugin->number) {
if (plugin->plugin_print) { if (plugin->plugin_print) {
plugin->plugin_print(); plugin->plugin_print();
return; return;
}
} }
} }
} }
}
#endif #endif
dialog_generic(GTK_WINDOW(window), dialog_generic(GTK_WINDOW(window),
_("Print"), DIALOG_WARNING, _("Print"), DIALOG_WARNING,
_("There is no print support for this conduit."), _("There is no print support for this conduit."),
1, button_text); 1, button_text);
} }
static void cb_restore(GtkWidget *widget, gpointer data) static void cb_restore(GtkWidget *widget, gpointer data) {
{ int r;
int r; int w, h, x, y;
int w, h, x, y;
jp_logf(JP_LOG_DEBUG, "cb_restore()\n"); jp_logf(JP_LOG_DEBUG, "cb_restore()\n");
gdk_window_get_size(window->window, &w, &h); w = gdk_window_get_width(gtk_widget_get_window(window));
gdk_window_get_root_origin(window->window, &x, &y); h = gdk_window_get_height(gtk_widget_get_window(window));
w = w/2; gdk_window_get_root_origin(gtk_widget_get_window(window), &x, &y);
x+=40;
r = restore_gui(window, w, h, x, y); w = w / 2;
x += 40;
/* Fork successful, child sync process started */ r = restore_gui(window, w, h, x, y);
if (glob_child_pid && (r == EXIT_SUCCESS)) {
gtk_widget_hide(button_sync); /* Fork successful, child sync process started */
gtk_widget_show(button_cancel_sync); if (glob_child_pid && (r == EXIT_SUCCESS)) {
} gtk_widget_hide(button_sync);
gtk_widget_show(button_cancel_sync);
}
} }
static void cb_import(GtkWidget *widget, gpointer data) static void cb_import(GtkWidget *widget, gpointer data) {
{
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
struct plugin_s *plugin; struct plugin_s *plugin;
GList *plugin_list, *temp_list; GList *plugin_list, *temp_list;
#endif #endif
char *button_text[]={N_("OK")}; char *button_text[] = {N_("OK")};
switch (glob_app) { switch (glob_app) {
case DATEBOOK: case DATEBOOK:
datebook_import(window); datebook_import(window);
return; return;
case ADDRESS: case ADDRESS:
address_import(window); address_import(window);
return; return;
case TODO: case TODO:
todo_import(window); todo_import(window);
return; return;
case MEMO: case MEMO:
memo_import(window); memo_import(window);
return; return;
} }
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
plugin_list = NULL; plugin_list = NULL;
plugin_list = get_plugin_list(); plugin_list = get_plugin_list();
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) { for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
plugin = (struct plugin_s *)temp_list->data; plugin = (struct plugin_s *) temp_list->data;
if (plugin) { if (plugin) {
if (glob_app == plugin->number) { if (glob_app == plugin->number) {
if (plugin->plugin_import) { if (plugin->plugin_import) {
plugin->plugin_import(window); plugin->plugin_import(window);
return; return;
}
} }
} }
} }
}
#endif #endif
dialog_generic(GTK_WINDOW(window), dialog_generic(GTK_WINDOW(window),
_("Import"), DIALOG_WARNING, _("Import"), DIALOG_WARNING,
_("There is no import support for this conduit."), _("There is no import support for this conduit."),
1, button_text); 1, button_text);
} }
static void cb_export(GtkWidget *widget, gpointer data) static void cb_export(GtkWidget *widget, gpointer data) {
{
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
struct plugin_s *plugin; struct plugin_s *plugin;
GList *plugin_list, *temp_list; GList *plugin_list, *temp_list;
#endif #endif
char *button_text[]={N_("OK")}; char *button_text[] = {N_("OK")};
switch (glob_app) { switch (glob_app) {
case DATEBOOK: case DATEBOOK:
datebook_export(window); datebook_export(window);
return; return;
case ADDRESS: case ADDRESS:
address_export(window); address_export(window);
return; return;
case TODO: case TODO:
todo_export(window); todo_export(window);
return; return;
case MEMO: case MEMO:
memo_export(window); memo_export(window);
return; return;
} }
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
plugin_list = NULL; plugin_list = NULL;
plugin_list = get_plugin_list(); plugin_list = get_plugin_list();
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) { for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
plugin = (struct plugin_s *)temp_list->data; plugin = (struct plugin_s *) temp_list->data;
if (plugin) { if (plugin) {
if (glob_app == plugin->number) { if (glob_app == plugin->number) {
if (plugin->plugin_export) { if (plugin->plugin_export) {
plugin->plugin_export(window); plugin->plugin_export(window);
return; return;
}
} }
} }
} }
}
#endif #endif
dialog_generic(GTK_WINDOW(window), dialog_generic(GTK_WINDOW(window),
_("Export"), DIALOG_WARNING, _("Export"), DIALOG_WARNING,
_("There is no export support for this conduit."), _("There is no export support for this conduit."),
1, button_text); 1, button_text);
} }
static void cb_private(GtkWidget *widget, gpointer data) //FIX remove
{ //static void cb_private_from_radio(GtkRadioAction *action) {
int privates, was_privates; // cb_private(NULL, GINT_TO_POINTER(gtk_radio_action_get_current_value(action
int r_dialog = 0; )));
static int skip_false_call = 0; //}
static void cb_private(GtkWidget *widget, gpointer data) {
int privates, was_privates;
int r_dialog = 0;
static int skip_false_call = 0;
#ifdef ENABLE_PRIVATE #ifdef ENABLE_PRIVATE
char ascii_password[64]; char ascii_password[64];
int r_pass; int r_pass;
int retry; int retry;
#endif
if (skip_false_call) {
skip_false_call = 0;
return;
}
was_privates = show_privates(GET_PRIVATES);
privates = show_privates(GPOINTER_TO_INT(data));
/* no changes */
if (was_privates == privates)
return;
switch (privates) {
case MASK_PRIVATES:
gtk_widget_hide(button_locked);
gtk_widget_show(button_masklocked);
gtk_widget_hide(button_unlocked);
if (! gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_mask_p
rivates))) {
skip_false_call = 1;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_mask_pri
vates), TRUE);
}
break;
case HIDE_PRIVATES:
gtk_widget_show(button_locked);
gtk_widget_hide(button_masklocked);
gtk_widget_hide(button_unlocked);
if (! gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_hide_p
rivates))) {
skip_false_call = 1;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_hide_pri
vates), TRUE);
}
break;
case SHOW_PRIVATES:
/* Ask for the password, or don't depending on configure option */
#ifdef ENABLE_PRIVATE
memset(ascii_password, 0, sizeof(ascii_password));
if (was_privates != SHOW_PRIVATES) {
retry = FALSE;
do {
r_dialog = dialog_password(GTK_WINDOW(window),
ascii_password, retry);
r_pass = verify_password(ascii_password);
retry = TRUE;
} while ((r_pass == FALSE) && (r_dialog == 2));
}
#else
r_dialog = 2;
#endif #endif
if (r_dialog == 2) {
gtk_widget_hide(button_locked);
gtk_widget_hide(button_masklocked);
gtk_widget_show(button_unlocked);
if (! gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_sh
ow_privates))) {
skip_false_call = 1;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_show
_privates), TRUE);
}
} else {
/* wrong or canceled password, hide the entries */
privates = show_privates(HIDE_PRIVATES);
if (! gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_hi
de_privates))) {
skip_false_call = 1;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_hide
_privates), TRUE);
}
cb_app_button(NULL, GINT_TO_POINTER(REDRAW));
return;
}
break;
}
if (skip_false_call) { if (was_privates != privates)
skip_false_call = 0; cb_app_button(NULL, GINT_TO_POINTER(REDRAW));
return; }
}
was_privates = show_privates(GET_PRIVATES); static void cb_install_user(GtkWidget *widget, gpointer data) {
privates = show_privates(GPOINTER_TO_INT(data)); int r;
/* no changes */ r = install_user_gui(window);
if (was_privates == privates)
return;
switch (privates) {
case MASK_PRIVATES:
gtk_widget_hide(button_locked);
gtk_widget_show(button_masklocked);
gtk_widget_hide(button_unlocked);
break;
case HIDE_PRIVATES:
gtk_widget_show(button_locked);
gtk_widget_hide(button_masklocked);
gtk_widget_hide(button_unlocked);
break;
case SHOW_PRIVATES:
/* Ask for the password, or don't depending on configure option */
#ifdef ENABLE_PRIVATE
memset(ascii_password, 0, sizeof(ascii_password));
if (was_privates != SHOW_PRIVATES) {
retry=FALSE;
do {
r_dialog = dialog_password(GTK_WINDOW(window),
ascii_password, retry);
r_pass = verify_password(ascii_password);
retry=TRUE;
} while ((r_pass==FALSE) && (r_dialog==2));
}
#else
r_dialog = 2;
#endif
if (r_dialog==2) {
gtk_widget_hide(button_locked);
gtk_widget_hide(button_masklocked);
gtk_widget_show(button_unlocked);
}
else {
/* wrong or canceled password, hide the entries */
gtk_check_menu_item_set_active(menu_hide_privates, TRUE);
cb_private(NULL, GINT_TO_POINTER(HIDE_PRIVATES));
return;
}
break;
}
if (widget) { /* Fork successful, child sync process started */
/* Setting the state of the menu causes a signal to be emitted if (glob_child_pid && (r == EXIT_SUCCESS)) {
* which calls cb_private again. gtk_widget_hide(button_sync);
* This second call needs to be ignored */ gtk_widget_show(button_cancel_sync);
skip_false_call = 1; }
switch (privates) { }
case MASK_PRIVATES:
gtk_check_menu_item_set_active(menu_mask_privates, TRUE);
break;
case HIDE_PRIVATES:
gtk_check_menu_item_set_active(menu_hide_privates, TRUE);
break;
case SHOW_PRIVATES:
gtk_check_menu_item_set_active(menu_show_privates, TRUE);
break;
}
}
if (was_privates != privates) void cb_datebook_app_button() {
cb_app_button(NULL, GINT_TO_POINTER(REDRAW)); cb_app_button(NULL, GINT_TO_POINTER(DATEBOOK));
} }
static void cb_install_user(GtkWidget *widget, gpointer data) void cb_address_app_button() {
{ cb_app_button(NULL, GINT_TO_POINTER(ADDRESS));
int r; }
r = install_user_gui(window); void cb_todo_app_button() {
cb_app_button(NULL, GINT_TO_POINTER(TODO));
}
/* Fork successful, child sync process started */ void cb_memo_app_button() {
if (glob_child_pid && (r == EXIT_SUCCESS)) { cb_app_button(NULL, GINT_TO_POINTER(MEMO));
gtk_widget_hide(button_sync);
gtk_widget_show(button_cancel_sync);
}
} }
void cb_app_button(GtkWidget *widget, gpointer data) void cb_app_button(GtkWidget *widget, gpointer data) {
{ int app;
int app; int refresh;
int refresh;
app = GPOINTER_TO_INT(data); app = GPOINTER_TO_INT(data);
/* If the current and selected apps are the same then just refresh screen */ /* If the current and selected apps are the same then just refresh screen */
refresh = (app==glob_app); refresh = (app == glob_app);
/* Tear down GUI when switching apps or on forced REDRAW */ /* Tear down GUI when switching apps or on forced REDRAW */
if ((!refresh) || (app==REDRAW)) { if ((!refresh) || (app == REDRAW)) {
gui_cleanup(); gui_cleanup();
if (glob_date_timer_tag) { if (glob_date_timer_tag) {
gtk_timeout_remove(glob_date_timer_tag); g_source_remove(glob_date_timer_tag);
} glob_date_timer_tag = 0;
gtk_widget_destroy(g_vbox0_1); }
gtk_widget_destroy(g_hbox2); gtk_widget_destroy(g_vbox0_1);
create_main_boxes(); gtk_widget_destroy(g_hbox2);
if (app==REDRAW) { create_main_boxes();
app = glob_app; if (app == REDRAW) {
} app = glob_app;
} }
}
switch (app) { switch (app) {
case DATEBOOK: case DATEBOOK:
if (refresh) { if (refresh) {
datebook_refresh(TRUE, TRUE); datebook_refresh(TRUE, TRUE);
} else { } else {
glob_app = DATEBOOK; glob_app = DATEBOOK;
datebook_gui(g_vbox0_1, g_hbox2); datebook_gui(g_vbox0_1, g_hbox2);
} }
break; break;
case ADDRESS: case ADDRESS:
if (refresh) { if (refresh) {
address_cycle_cat(); address_cycle_cat();
address_refresh(); address_refresh();
} else { } else {
glob_app = ADDRESS; glob_app = ADDRESS;
address_gui(g_vbox0_1, g_hbox2); address_gui(g_vbox0_1, g_hbox2);
} }
break; break;
case TODO: case TODO:
if (refresh) { if (refresh) {
todo_cycle_cat(); todo_cycle_cat();
todo_refresh(); todo_refresh();
} else { } else {
glob_app = TODO; glob_app = TODO;
todo_gui(g_vbox0_1, g_hbox2); todo_gui(g_vbox0_1, g_hbox2);
} }
break; break;
case MEMO: case MEMO:
if (refresh) { if (refresh) {
memo_cycle_cat(); memo_cycle_cat();
memo_refresh(); memo_refresh();
} else { } else {
glob_app = MEMO; glob_app = MEMO;
memo_gui(g_vbox0_1, g_hbox2); memo_gui(g_vbox0_1, g_hbox2);
} }
break; break;
default: default:
/* recursion */ /* recursion */
if ((glob_app==DATEBOOK) || if ((glob_app == DATEBOOK) ||
(glob_app==ADDRESS) || (glob_app == ADDRESS) ||
(glob_app==TODO) || (glob_app == TODO) ||
(glob_app==MEMO) ) (glob_app == MEMO))
cb_app_button(NULL, GINT_TO_POINTER(glob_app)); cb_app_button(NULL, GINT_TO_POINTER(glob_app));
break; break;
} }
} }
static void sync_sig_handler (int sig) static void sync_sig_handler(int sig) {
{ unsigned int flags;
unsigned int flags; int r;
int r;
flags = skip_plugins ? SYNC_NO_PLUGINS : 0; flags = skip_plugins ? SYNC_NO_PLUGINS : 0;
r = setup_sync(flags); r = setup_sync(flags);
/* Fork successful, child sync process started */ /* Fork successful, child sync process started */
if (glob_child_pid && (r == EXIT_SUCCESS)) { if (glob_child_pid && (r == EXIT_SUCCESS)) {
gtk_widget_hide(button_sync); gtk_widget_hide(button_sync);
gtk_widget_show(button_cancel_sync); gtk_widget_show(button_cancel_sync);
} }
} }
static void cb_sync(GtkWidget *widget, unsigned int flags) static void cb_sync(GtkWidget *widget, unsigned int flags) {
{ long ivalue;
long ivalue; int r;
int r;
/* confirm file installation */ /* confirm file installation */
get_pref(PREF_CONFIRM_FILE_INSTALL, &ivalue, NULL); get_pref(PREF_CONFIRM_FILE_INSTALL, &ivalue, NULL);
if (ivalue) if (ivalue) {
{ char file[FILENAME_MAX];
char file[FILENAME_MAX]; char home_dir[FILENAME_MAX];
char home_dir[FILENAME_MAX]; struct stat buf;
struct stat buf;
/* If there are files to be installed, ask the user right before sync */
get_home_file_name("", home_dir, sizeof(home_dir));
g_snprintf(file, sizeof(file), "%s/"EPN".install", home_dir);
if (!stat(file, &buf)) {
if (buf.st_size > 0) {
install_gui_and_size(window);
}
}
}
r = setup_sync(flags); /* If there are files to be installed, ask the user right before sync */
get_home_file_name("", home_dir, sizeof(home_dir));
g_snprintf(file, sizeof(file), "%s/"EPN".install", home_dir);
/* Fork successful, child sync process started */ if (!stat(file, &buf)) {
if (glob_child_pid && (r == EXIT_SUCCESS)) { if (buf.st_size > 0) {
gtk_widget_hide(button_sync); install_gui_and_size(window);
gtk_widget_show(button_cancel_sync); }
} }
}
r = setup_sync(flags);
/* Fork successful, child sync process started */
if (glob_child_pid && (r == EXIT_SUCCESS)) {
gtk_widget_hide(button_sync);
gtk_widget_show(button_cancel_sync);
}
} }
void cb_cancel_sync(GtkWidget *widget, unsigned int flags); void cb_cancel_sync(GtkWidget *widget, unsigned int flags);
void cb_cancel_sync(GtkWidget *widget, unsigned int flags)
{ char *getFileMenuXmlString();
if (glob_child_pid) {
jp_logf(JP_LOG_GUI, "****************************************\n"); void addUiFromString(const GtkUIManager *uiManager, const char *menuXml);
jp_logf(JP_LOG_GUI, _(" Cancelling HotSync\n"));
jp_logf(JP_LOG_GUI, "****************************************\n"); #ifdef WEBMENU
kill(glob_child_pid, SIGTERM); static const char *getWebMenuXmlString();
} #endif
gtk_widget_hide(button_cancel_sync);
gtk_widget_show(button_sync); void cb_cancel_sync(GtkWidget *widget, unsigned int flags) {
if (glob_child_pid) {
jp_logf(JP_LOG_GUI, "****************************************\n");
jp_logf(JP_LOG_GUI, _(" Cancelling HotSync\n"));
jp_logf(JP_LOG_GUI, "****************************************\n");
kill(glob_child_pid, SIGTERM);
}
gtk_widget_hide(button_cancel_sync);
gtk_widget_show(button_sync);
} }
/* /*
* This is called when the user name from the palm doesn't match * This is called when the user name from the palm doesn't match
* or the user ID from the palm is 0 * or the user ID from the palm is 0
*/ */
static int bad_sync_exit_status(int exit_status) static int bad_sync_exit_status(int exit_status) {
{ char text1[] =
char text1[] = /*-------------------------------------------*/
/*-------------------------------------------*/ N_("This handheld does not have the same user name or user ID\n"
N_("This handheld does not have the same user name or user ID\n" "as the one that was synced the last time.\n"
"as the one that was synced the last time.\n" "Syncing could have unwanted effects including data loss.\n"
"Syncing could have unwanted effects including data loss.\n" "\n"
"\n" "Read the user manual if you are uncertain.");
"Read the user manual if you are uncertain."); char text2[] =
char text2[] = /*-------------------------------------------*/
/*-------------------------------------------*/ N_("This handheld has a NULL user ID.\n"
N_("This handheld has a NULL user ID.\n" "Every handheld must have a unique user ID in order to sync prope
"Every handheld must have a unique user ID in order to sync properly.\n rly.\n"
" "If the handheld has been hard reset, \n"
"If the handheld has been hard reset, \n" " use restore from the menu to restore it.\n"
" use restore from the menu to restore it.\n" "Otherwise, to add a new user name and ID\n"
"Otherwise, to add a new user name and ID\n" " use install-user from the menu.\n"
" use install-user from the menu.\n" "\n"
"\n" "Read the user manual if you are uncertain.");
"Read the user manual if you are uncertain."); char *button_text[] = {N_("Cancel Sync"), N_("Sync Anyway")
char *button_text[]={N_("Cancel Sync"), N_("Sync Anyway") };
};
if (!GTK_IS_WINDOW(window)) {
if (!GTK_IS_WINDOW(window)) { return EXIT_FAILURE;
return EXIT_FAILURE; }
} if ((exit_status == SYNC_ERROR_NOT_SAME_USERID) ||
if ((exit_status == SYNC_ERROR_NOT_SAME_USERID) || (exit_status == SYNC_ERROR_NOT_SAME_USER)) {
(exit_status == SYNC_ERROR_NOT_SAME_USER)) { return dialog_generic(GTK_WINDOW(window),
return dialog_generic(GTK_WINDOW(window),
_("Sync Problem"), DIALOG_WARNING, _(text1), 2, bu tton_text); _("Sync Problem"), DIALOG_WARNING, _(text1), 2, bu tton_text);
} }
if (exit_status == SYNC_ERROR_NULL_USERID) { if (exit_status == SYNC_ERROR_NULL_USERID) {
return dialog_generic(GTK_WINDOW(window), return dialog_generic(GTK_WINDOW(window),
_("Sync Problem"), DIALOG_ERROR, _(text2), 1, button _("Sync Problem"), DIALOG_ERROR, _(text2), 1, butt
_text); on_text);
} }
return EXIT_FAILURE; return EXIT_FAILURE;
} }
void output_to_pane(const char *str) void output_to_pane(const char *str) {
{ int h, new_y;
int w, h, new_y; long ivalue;
long ivalue; GtkWidget *pane_hbox;
GtkWidget *pane_hbox; GtkRequisition size_requisition;
GtkRequisition size_requisition;
/* Adjust window height to user preference or minimum size */
/* Adjust window height to user preference or minimum size */ get_pref(PREF_OUTPUT_HEIGHT, &ivalue, NULL);
get_pref(PREF_OUTPUT_HEIGHT, &ivalue, NULL); /* Make them look at something if output happens */
/* Make them look at something if output happens */ if (ivalue < 50) {
if (ivalue < 50) { /* Ask GTK for size which is just large enough to show both buttons */
/* Ask GTK for size which is just large enough to show both buttons */ pane_hbox = gtk_paned_get_child2(GTK_PANED(output_pane));
pane_hbox = gtk_paned_get_child2(GTK_PANED(output_pane)); //gtk2 gtk_widget_size_request(pane_hbox, &size_requisition);
gtk_widget_size_request(pane_hbox, &size_requisition); gtk_widget_get_preferred_size(pane_hbox, NULL, &size_requisition);
ivalue = size_requisition.height + 1; ivalue = size_requisition.height + 1;
set_pref(PREF_OUTPUT_HEIGHT, ivalue, NULL, TRUE); set_pref(PREF_OUTPUT_HEIGHT, ivalue, NULL, TRUE);
} }
gdk_window_get_size(window->window, &w, &h); //w = gdk_window_get_width(gtk_widget_get_window(window));
new_y = h - ivalue; h = gdk_window_get_height(gtk_widget_get_window(window));
gtk_paned_set_position(GTK_PANED(output_pane), new_y); new_y = h - ivalue;
gtk_paned_set_position(GTK_PANED(output_pane), new_y);
/* Output text to window */
GtkTextIter end_iter; /* Output text to window */
GtkTextMark *end_mark; GtkTextIter end_iter;
gboolean scroll_to_end = FALSE; GtkTextMark *end_mark;
gdouble sbar_value, sbar_page_size, sbar_upper; gboolean scroll_to_end = FALSE;
gdouble sbar_value, sbar_page_size, sbar_upper;
/* The window position scrolls with new input if the user has left
* the scrollbar at the bottom of the window. Otherwise, if the user /* The window position scrolls with new input if the user has left
* is scrolling back through the log then jpilot does nothing and defers * the scrollbar at the bottom of the window. Otherwise, if the user
* to the user. */ * is scrolling back through the log then jpilot does nothing and defers
* to the user. */
/* Get position of scrollbar */
sbar_value = g_output_text->vadjustment->value; /* Get position of scrollbar */
sbar_page_size = g_output_text->vadjustment->page_size; //gtk2 GtkAdjustment * vadjustment = gtk_text_view_get_vadjustment (g_outpu
sbar_upper = g_output_text->vadjustment->upper; t_text);
/* Keep scrolling to the end only if we are already near(1 window) of the end GtkAdjustment * vadjustment = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(
* OR the window has just been created and is blank */ g_output_text));
if ((abs((sbar_value+sbar_page_size) - sbar_upper) < sbar_page_size) sbar_value = gtk_adjustment_get_value(vadjustment);
|| sbar_page_size == 1) { sbar_page_size = gtk_adjustment_get_page_size(vadjustment);
scroll_to_end = TRUE; sbar_upper = gtk_adjustment_get_upper(vadjustment);
} /* Keep scrolling to the end only if we are already near(1 window) of the en
d
gtk_text_buffer_get_end_iter(g_output_text_buffer, &end_iter); * OR the window has just been created and is blank */
if ((abs((sbar_value + sbar_page_size) - sbar_upper) < sbar_page_size)
if (! g_utf8_validate(str, -1, NULL)) { || sbar_page_size == 1) {
gchar *utf8_text; scroll_to_end = TRUE;
}
utf8_text = g_locale_to_utf8 (str, -1, NULL, NULL, NULL);
gtk_text_buffer_insert(g_output_text_buffer, &end_iter, utf8_text, -1); gtk_text_buffer_get_end_iter(g_output_text_buffer, &end_iter);
g_free(utf8_text);
} else if (!g_utf8_validate(str, -1, NULL)) {
gtk_text_buffer_insert(g_output_text_buffer, &end_iter, str, -1); gchar *utf8_text;
if (scroll_to_end) { utf8_text = g_locale_to_utf8(str, -1, NULL, NULL, NULL);
end_mark = gtk_text_buffer_create_mark(g_output_text_buffer, NULL, &end_it gtk_text_buffer_insert(g_output_text_buffer, &end_iter, utf8_text, -1);
er, TRUE); g_free(utf8_text);
gtk_text_buffer_move_mark(g_output_text_buffer, end_mark, &end_iter); } else
gtk_text_view_scroll_to_mark(g_output_text, end_mark, 0, TRUE, 0.0, 0.0); gtk_text_buffer_insert(g_output_text_buffer, &end_iter, str, -1);
gtk_text_buffer_delete_mark(g_output_text_buffer, end_mark);
} if (scroll_to_end) {
} end_mark = gtk_text_buffer_create_mark(g_output_text_buffer, NULL, &end_
iter, TRUE);
static void cb_read_pipe_from_child(gpointer data, gtk_text_buffer_move_mark(g_output_text_buffer, end_mark, &end_iter);
gint in, gtk_text_view_scroll_to_mark(g_output_text, end_mark, 0, TRUE, 0.0, 0.0)
GdkInputCondition condition) ;
{ gtk_text_buffer_delete_mark(g_output_text_buffer, end_mark);
int num; }
char buf_space[1026]; }
char *buf;
int buf_len; gboolean cb_read_pipe_from_child(GIOChannel *channel, GIOCondition cond, gpointe
fd_set fds; r data) {
struct timeval tv; int num;
int ret, done; char buf_space[1026];
char *Pstr1, *Pstr2, *Pstr3; char *buf;
int user_len; int buf_len;
char password[MAX_PREF_LEN]; fd_set fds;
int password_len; struct timeval tv;
unsigned long user_id; int ret, done;
int i, reason; char *Pstr1, *Pstr2, *Pstr3;
int command; int user_len;
char user[MAX_PREF_LEN]; char password[MAX_PREF_LEN];
char command_str[80]; int password_len;
long char_set; unsigned long user_id;
const char *svalue; int i, reason;
char title[MAX_PREF_LEN+256]; int command;
char *user_name; char user[MAX_PREF_LEN];
char command_str[80];
/* This is so we can always look at the previous char in buf */ long char_set;
buf = &buf_space[1]; const char *svalue;
buf[-1]='A'; /* that looks weird */ char title[MAX_PREF_LEN + 256];
char *user_name;
done=0; gint in = g_io_channel_unix_get_fd(channel);
while (!done) {
buf[0]='\0'; /* This is so we can always look at the previous char in buf */
buf_len=0; buf = &buf_space[1];
/* Read until "\0\n", or buffer full */ buf[-1] = 'A'; /* that looks weird */
for (i=0; i<1022; i++) { done = 0;
buf[i]='\0'; while (!done) {
/* Linux modifies tv in the select call */ buf[0] = '\0';
tv.tv_sec=0; buf_len = 0;
tv.tv_usec=0; /* Read until "\0\n", or buffer full */
FD_ZERO(&fds);
FD_SET(in, &fds); for (i = 0; i < 1022; i++) {
ret=select(in+1, &fds, NULL, NULL, &tv); buf[i] = '\0';
if ((ret<1) || (!FD_ISSET(in, &fds))) { /* Linux modifies tv in the select call */
done=1; break; tv.tv_sec = 0;
} tv.tv_usec = 0;
ret = read(in, &(buf[i]), 1); FD_ZERO(&fds);
if (ret <= 0) { FD_SET(in, &fds);
done=1; break; ret = select(in + 1, &fds, NULL, NULL, &tv);
} if ((ret < 1) || (!FD_ISSET(in, &fds))) {
if ((buf[i-1]=='\0')&&(buf[i]=='\n')) { done = 1;
buf_len=buf_len-1; break;
break; }
} ret = read(in, &(buf[i]), 1);
buf_len++; if (ret <= 0) {
if (buf_len >= 1022) { done = 1;
buf[buf_len]='\0'; break;
break; }
} if ((buf[i - 1] == '\0') && (buf[i] == '\n')) {
} buf_len = buf_len - 1;
break;
}
buf_len++;
if (buf_len >= 1022) {
buf[buf_len] = '\0';
break;
}
}
if (buf_len < 1) break; if (buf_len < 1) break;
/* Look for the command */ /* Look for the command */
command=0; command = 0;
sscanf(buf, "%d:", &command); sscanf(buf, "%d:", &command);
Pstr1 = strstr(buf, ":"); Pstr1 = strstr(buf, ":");
if (Pstr1 != NULL) { if (Pstr1 != NULL) {
Pstr1++; Pstr1++;
} }
#ifdef PIPE_DEBUG #ifdef PIPE_DEBUG
printf("command=%d [%s]\n", command, Pstr1); printf("command=%d [%s]\n", command, Pstr1);
#endif #endif
if (Pstr1) { if (Pstr1) {
switch (command) { switch (command) {
case PIPE_PRINT: case PIPE_PRINT:
/* Output the text to the Sync window */ /* Output the text to the Sync window */
output_to_pane(Pstr1); output_to_pane(Pstr1);
break; break;
case PIPE_USERID: case PIPE_USERID:
/* Save user ID as pref */ /* Save user ID as pref */
num = sscanf(Pstr1, "%lu", &user_id); num = sscanf(Pstr1, "%lu", &user_id);
if (num > 0) { if (num > 0) {
jp_logf(JP_LOG_DEBUG, "pipe_read: user id = %lu\n", user_id); jp_logf(JP_LOG_DEBUG, "pipe_read: user id = %lu\n", user
set_pref(PREF_USER_ID, user_id, NULL, TRUE); _id);
} else { set_pref(PREF_USER_ID, user_id, NULL, TRUE);
jp_logf(JP_LOG_DEBUG, "pipe_read: trouble reading user id\n"); } else {
} jp_logf(JP_LOG_DEBUG, "pipe_read: trouble reading user i
break; d\n");
case PIPE_USERNAME: }
/* Save username as pref */ break;
Pstr2 = strchr(Pstr1, '\"'); case PIPE_USERNAME:
if (Pstr2) { /* Save username as pref */
Pstr2++; Pstr2 = strchr(Pstr1, '\"');
Pstr3 = strchr(Pstr2, '\"'); if (Pstr2) {
if (Pstr3) { Pstr2++;
user_len = Pstr3 - Pstr2; Pstr3 = strchr(Pstr2, '\"');
if (user_len > MAX_PREF_LEN) { if (Pstr3) {
user_len = MAX_PREF_LEN; user_len = Pstr3 - Pstr2;
} if (user_len > MAX_PREF_LEN) {
g_strlcpy(user, Pstr2, user_len+1); user_len = MAX_PREF_LEN;
jp_logf(JP_LOG_DEBUG, "pipe_read: user = %s\n", user); }
set_pref(PREF_USER, 0, user, TRUE); g_strlcpy(user, Pstr2, user_len + 1);
} jp_logf(JP_LOG_DEBUG, "pipe_read: user = %s\n", user
} );
break; set_pref(PREF_USER, 0, user, TRUE);
case PIPE_PASSWORD: }
/* Save password as pref */ }
Pstr2 = strchr(Pstr1, '\"'); break;
if (Pstr2) { case PIPE_PASSWORD:
Pstr2++; /* Save password as pref */
Pstr3 = strchr(Pstr2, '\"'); Pstr2 = strchr(Pstr1, '\"');
if (Pstr3) { if (Pstr2) {
password_len = Pstr3 - Pstr2; Pstr2++;
if (password_len > MAX_PREF_LEN) { Pstr3 = strchr(Pstr2, '\"');
password_len = MAX_PREF_LEN; if (Pstr3) {
} password_len = Pstr3 - Pstr2;
g_strlcpy(password, Pstr2, password_len+1); if (password_len > MAX_PREF_LEN) {
jp_logf(JP_LOG_DEBUG, "pipe_read: password = %s\n", password); password_len = MAX_PREF_LEN;
set_pref(PREF_PASSWORD, 0, password, TRUE); }
} g_strlcpy(password, Pstr2, password_len + 1);
} jp_logf(JP_LOG_DEBUG, "pipe_read: password = %s\n",
break; password);
case PIPE_WAITING_ON_USER: set_pref(PREF_PASSWORD, 0, password, TRUE);
}
}
break;
case PIPE_WAITING_ON_USER:
#ifdef PIPE_DEBUG #ifdef PIPE_DEBUG
printf("waiting on user\n"); printf("waiting on user\n");
#endif #endif
/* Look for the reason */ /* Look for the reason */
num = sscanf(Pstr1, "%d", &reason); num = sscanf(Pstr1, "%d", &reason);
#ifdef PIPE_DEBUG #ifdef PIPE_DEBUG
printf("reason %d\n", reason); printf("reason %d\n", reason);
#endif #endif
if (num > 0) { if (num > 0) {
jp_logf(JP_LOG_DEBUG, "pipe_read: reason = %d\n", reason); jp_logf(JP_LOG_DEBUG, "pipe_read: reason = %d\n", reason
} else { );
jp_logf(JP_LOG_DEBUG, "pipe_read: trouble reading reason\n"); } else {
} jp_logf(JP_LOG_DEBUG, "pipe_read: trouble reading reason
if ((reason == SYNC_ERROR_NOT_SAME_USERID) || \n");
(reason == SYNC_ERROR_NOT_SAME_USER) || }
(reason == SYNC_ERROR_NULL_USERID)) { if ((reason == SYNC_ERROR_NOT_SAME_USERID) ||
/* Future code */ (reason == SYNC_ERROR_NOT_SAME_USER) ||
/* This is where to add an option for adding user or (reason == SYNC_ERROR_NULL_USERID)) {
user id to possible ids to sync with. */ /* Future code */
ret = bad_sync_exit_status(reason); /* This is where to add an option for adding user or
user id to possible ids to sync with. */
ret = bad_sync_exit_status(reason);
#ifdef PIPE_DEBUG #ifdef PIPE_DEBUG
printf("ret=%d\n", ret); printf("ret=%d\n", ret);
#endif #endif
if (ret == DIALOG_SAID_2) { if (ret == DIALOG_SAID_2) {
sprintf(command_str, "%d:\n", PIPE_SYNC_CONTINUE); sprintf(command_str, "%d:\n", PIPE_SYNC_CONTINUE);
} else { } else {
sprintf(command_str, "%d:\n", PIPE_SYNC_CANCEL); sprintf(command_str, "%d:\n", PIPE_SYNC_CANCEL);
} }
if (write(pipe_to_child, command_str, strlen(command_str)) < 0) { if (write(pipe_to_child, command_str, strlen(command_str
jp_logf(JP_LOG_WARN, "write failed %s %d\n", __FILE__, __LINE_ )) < 0) {
_); jp_logf(JP_LOG_WARN, "write failed %s %d\n", __FILE_
} _, __LINE__);
fsync(pipe_to_child); }
fsync(pipe_to_child);
}
break;
case PIPE_FINISHED:
/* Update main window title as user name may have changed */
get_pref(PREF_CHAR_SET, &char_set, NULL);
get_pref(PREF_USER, NULL, &svalue);
strcpy(title, PN" "VERSION);
if ((svalue) && (svalue[0])) {
strcat(title, _(" User: "));
user_name = charset_p2newj(svalue, -1, char_set);
strcat(title, user_name);
gtk_window_set_title(GTK_WINDOW(window), title);
free(user_name);
}
/* And redraw GUI */
if (Pstr1) {
cb_app_button(NULL, GINT_TO_POINTER(REDRAW));
}
break;
default:
jp_logf(JP_LOG_WARN, _("Unknown command from sync process\n"
));
jp_logf(JP_LOG_WARN, "buf=[%s]\n", buf);
} }
break; }
case PIPE_FINISHED: }
/* Update main window title as user name may have changed */ return TRUE;
get_pref(PREF_CHAR_SET, &char_set, NULL);
get_pref(PREF_USER, NULL, &svalue);
strcpy(title, PN" "VERSION);
if ((svalue) && (svalue[0])) {
strcat(title, _(" User: "));
user_name = charset_p2newj(svalue, -1, char_set);
strcat(title, user_name);
gtk_window_set_title(GTK_WINDOW(window), title);
free(user_name);
}
/* And redraw GUI */
if (Pstr1) {
cb_app_button(NULL, GINT_TO_POINTER(REDRAW));
}
break;
default:
jp_logf(JP_LOG_WARN, _("Unknown command from sync process\n"));
jp_logf(JP_LOG_WARN, "buf=[%s]\n", buf);
}
}
}
} }
static void cb_about(GtkWidget *widget, gpointer data) static void cb_about(GtkWidget *widget, gpointer data) {
{ char *button_text[] = {N_("OK")};
char *button_text[]={N_("OK")}; char about[256];
char about[256]; char options[1024];
char options[1024]; int w;
int w, h;
gdk_window_get_size(window->window, &w, &h); w = gdk_window_get_width(gtk_widget_get_window(window));
//h = gdk_window_get_height(gtk_widget_get_window(window));
w = w/2; w = w / 2;
h = 1; //h = 1;
g_snprintf(about, sizeof(about), _("About %s"), PN); g_snprintf(about, sizeof(about), _("About %s"), PN);
get_compile_options(options, sizeof(options)); get_compile_options(options, sizeof(options));
if (GTK_IS_WINDOW(window)) { if (GTK_IS_WINDOW(window)) {
dialog_generic(GTK_WINDOW(window), dialog_generic(GTK_WINDOW(window),
about, DIALOG_INFO, options, 1, button_text); about, DIALOG_INFO, options, 1, button_text);
} }
} }
/* Experimental webmenu that has never been used in practice */ /* Experimental webmenu that has never been used in practice */
#ifdef WEBMENU #ifdef WEBMENU
#define NETSCAPE_EXISTING 0 #define NETSCAPE_EXISTING 0
#define NETSCAPE_NEW_WINDOW 1 #define NETSCAPE_NEW_WINDOW 1
#define NETSCAPE_NEW 2 #define NETSCAPE_NEW 2
#define MOZILLA_EXISTING 3 #define MOZILLA_EXISTING 3
#define MOZILLA_NEW_WINDOW 4 #define MOZILLA_NEW_WINDOW 4
skipping to change at line 1033 skipping to change at line 1074
{LYNX_NEW, "/Web/Lynx/Lynx jpilot.org", "xterm -e lynx http://jpilot.org &" }, {LYNX_NEW, "/Web/Lynx/Lynx jpilot.org", "xterm -e lynx http://jpilot.org &" },
{LINKS_NEW, "/Web/Links/Links jpilot.org", "xterm -e links http://jpilot.or g &"}, {LINKS_NEW, "/Web/Links/Links jpilot.org", "xterm -e links http://jpilot.or g &"},
{W3M_NEW, "/Web/W3M/w3m jpilot.org", "xterm -e w3m http://jpilot.org &"}, {W3M_NEW, "/Web/W3M/w3m jpilot.org", "xterm -e w3m http://jpilot.org &"},
{KONQUEROR_NEW, "/Web/Konqueror/Konqueror jpilot.org", "konqueror http://jp ilot.org"} {KONQUEROR_NEW, "/Web/Konqueror/Konqueror jpilot.org", "konqueror http://jp ilot.org"}
}; };
static void cb_web(GtkWidget *widget, gpointer data);
void openNetscapeExisting(){
cb_web(NULL,GINT_TO_POINTER(NETSCAPE_EXISTING));
}
void openNetscapeNewWindow(){
cb_web(NULL,GINT_TO_POINTER(NETSCAPE_NEW_WINDOW));
}
void openNetscapeNew(){
cb_web(NULL,GINT_TO_POINTER(NETSCAPE_NEW));
}
void openMozillaExisting(){
cb_web(NULL,GINT_TO_POINTER(MOZILLA_EXISTING));
}
void openMozillaNewWindow(){
cb_web(NULL,GINT_TO_POINTER(MOZILLA_NEW_WINDOW));
}
void openMozillaNewTab(){
cb_web(NULL,GINT_TO_POINTER(MOZILLA_NEW_TAB));
}
void openMozillaNew(){
cb_web(NULL,GINT_TO_POINTER(MOZILLA_NEW));
}
void openGaleonExisting(){
cb_web(NULL,GINT_TO_POINTER(GALEON_EXISTING));
}
void openGaleonNewWindow(){
cb_web(NULL,GINT_TO_POINTER(GALEON_NEW_WINDOW));
}
void openGaleonNewTab(){
cb_web(NULL,GINT_TO_POINTER(GALEON_NEW_TAB));
}
void openGaleonNew(){
cb_web(NULL,GINT_TO_POINTER(GALEON_NEW));
}
void openOperaExisting(){
cb_web(NULL,GINT_TO_POINTER(OPERA_EXISTING));
}
void openOperaNewWindow(){
cb_web(NULL,GINT_TO_POINTER(OPERA_NEW_WINDOW));
}
void openOperaNew(){
cb_web(NULL,GINT_TO_POINTER(OPERA_NEW));
}
void openGnomeNew(){
cb_web(NULL,GINT_TO_POINTER(GNOME_URL));
}
void openLynxNew(){
cb_web(NULL,GINT_TO_POINTER(LYNX_NEW));
}
void openLinksNew(){
cb_web(NULL,GINT_TO_POINTER(LINKS_NEW));
}
void openW3MNew(){
cb_web(NULL,GINT_TO_POINTER(W3M_NEW));
}
void openKonquerorNew(){
cb_web(NULL,GINT_TO_POINTER(KONQUEROR_NEW));
}
static void cb_web(GtkWidget *widget, gpointer data) static void cb_web(GtkWidget *widget, gpointer data)
{ {
int sel; int sel;
sel=GPOINTER_TO_INT(data); sel=GPOINTER_TO_INT(data);
jp_logf(JP_LOG_INFO, PN": executing %s\n", url_commands[sel].command); jp_logf(JP_LOG_INFO, PN": executing %s\n", url_commands[sel].command);
if (system(url_commands[sel].command) == -1) { if (system(url_commands[sel].command) == -1) {
jp_logf(JP_LOG_WARN, "system call failed %s %d\n", __FILE__, __LINE__); jp_logf(JP_LOG_WARN, "system call failed %s %d\n", __FILE__, __LINE__);
} }
} }
#endif #endif
static void install_gui_and_size(GtkWidget *main_window) static void install_gui_and_size(GtkWidget *main_window) {
{ int w, h, x, y;
int w, h, x, y;
gdk_window_get_size(window->window, &w, &h);
gdk_window_get_root_origin(window->window, &x, &y);
w = w/2; w = gdk_window_get_width(gtk_widget_get_window(window));
x+=40; h = gdk_window_get_height(gtk_widget_get_window(window));
gdk_window_get_root_origin(gtk_widget_get_window(window), &x, &y);
w = w / 2;
x += 40;
install_gui(main_window, w, h, x, y);
}
static void cb_install_gui(GtkWidget *widget, gpointer data) {
jp_logf(JP_LOG_DEBUG, "cb_install_gui()\n");
install_gui_and_size(window);
}
static GtkWidget* create_menu_item(GtkWidget *menu,
GtkAccelGroup *accel_group,
gchar *icon_name,
const char **pixbuf_data,
gchar *text,
guint accel_key,
GdkModifierType accel_mods,
void *callback,
gpointer *data)
{
GtkWidget *box;
GtkWidget *icon;
GtkWidget *label;
GtkWidget *menu_item;
if (accel_key > 0) {
label = gtk_accel_label_new(text);
} else {
label = gtk_label_new(text);
}
menu_item = gtk_menu_item_new();
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
if (pixbuf_data) {
GtkWidget *image;
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new_from_xpm_data(pixbuf_data);
image = gtk_image_new_from_pixbuf(pixbuf);
gtk_container_add(GTK_CONTAINER(box), image);
// FIX - Do I need to unref?
// g_object_unref(pixbuf);
} else {
icon = gtk_image_new_from_icon_name(icon_name, GTK_ICON_SIZE_MENU);
gtk_container_add(GTK_CONTAINER(box), icon);
}
//gtk_label_set_use_underline(GTK_LABEL(label), TRUE);
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
if ((accel_key > 0) && (accel_group)) {
gtk_widget_add_accelerator(menu_item, "activate", accel_group,
accel_key, accel_mods, GTK_ACCEL_VISIBLE);
gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), menu_item);
}
gtk_box_pack_end(GTK_BOX(box), label, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(menu_item), box);
g_signal_connect(G_OBJECT(menu_item), "activate", callback, data);
gtk_widget_show(menu_item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
install_gui(main_window, w, h, x, y); return menu_item;
} }
static void cb_install_gui(GtkWidget *widget, gpointer data) static void get_main_menu(GtkWidget *my_window,
{
jp_logf(JP_LOG_DEBUG, "cb_install_gui()\n");
install_gui_and_size(window);
}
#include <gdk-pixbuf/gdk-pixdata.h>
static guint8 *get_inline_pixbuf_data(const char **xpm_icon_data,
gint icon_size)
{
GdkPixbuf *pixbuf;
GdkPixdata *pixdata;
GdkPixbuf *scaled_pb;
guint8 *data;
guint len;
pixbuf = gdk_pixbuf_new_from_xpm_data(xpm_icon_data);
if (!pixbuf)
return NULL;
if (gdk_pixbuf_get_width(pixbuf) != icon_size ||
gdk_pixbuf_get_height(pixbuf) != icon_size) {
scaled_pb = gdk_pixbuf_scale_simple(pixbuf, icon_size, icon_size,
GDK_INTERP_BILINEAR);
g_object_unref(pixbuf);
pixbuf = scaled_pb;
}
pixdata = (GdkPixdata*)g_malloc(sizeof(GdkPixdata));
gdk_pixdata_from_pixbuf(pixdata, pixbuf, FALSE);
data = gdk_pixdata_serialize(pixdata, &len);
g_object_unref(pixbuf);
g_free(pixdata);
return data;
}
static void get_main_menu(GtkWidget *my_window,
GtkWidget **menubar, GtkWidget **menubar,
GList *plugin_list) GtkWidget **menubar_help,
{ GList *plugin_list) {
#define ICON(icon) "<StockItem>", icon #ifdef ENABLE_PLUGINS
#define ICON_XPM(icon, size) "<ImageItem>", get_inline_pixbuf_data(icon, size) int count, help_count;
struct plugin_s *p;
GtkItemFactoryEntry menu_items1[]={ GList *temp_list;
{ _("/_File"), NULL, NULL, 0, int F_KEYS[]={GDK_KEY_F5,GDK_KEY_F6,GDK_KEY_F7,GDK_KEY_F8,GDK_KEY_F9,GDK_
"<Branch>", NULL }, KEY_F10,GDK_KEY_F11,GDK_KEY_F12};
{ _("/File/tear"), NULL, NULL, 0, #endif
"<Tearoff>", NULL }, /*
{ _("/File/_Find"), "<control>F", cb_search_gui, 0, * New Menu Code
ICON(GTK_STOCK_FIND) }, */
{ _("/File/sep1"), NULL, NULL, 0, *menubar = gtk_menu_bar_new();
"<Separator>", NULL }, *menubar_help = gtk_menu_bar_new();
{ _("/File/_Install"), "<control>I", cb_install_gui, 0, gtk_widget_set_hexpand(*menubar, FALSE);
ICON(GTK_STOCK_OPEN) }, gtk_widget_set_hexpand(*menubar_help, FALSE);
{ _("/File/Import"), NULL, cb_import, 0,
ICON(GTK_STOCK_GO_FORWARD) },
{ _("/File/Export"), NULL, cb_export, 0,
ICON(GTK_STOCK_GO_BACK) },
{ _("/File/Preferences"), "<control>S", cb_prefs_gui, 0,
ICON(GTK_STOCK_PREFERENCES) },
{ _("/File/_Print"), "<control>P", cb_print, 0,
ICON(GTK_STOCK_PRINT) },
{ _("/File/sep1"), NULL, NULL, 0,
"<Separator>", NULL },
{ _("/File/Install User"), NULL, cb_install_user,0,
ICON_XPM(user_icon, 16) },
{ _("/File/Restore Handheld"), NULL, cb_restore, 0,
ICON(GTK_STOCK_REDO) },
{ _("/File/sep1"), NULL, NULL, 0,
"<Separator>", NULL },
{ _("/File/_Quit"), "<control>Q", cb_delete_event,0,
ICON(GTK_STOCK_QUIT) },
{ _("/_View"), NULL, NULL, 0,
"<Branch>", NULL },
{ _("/View/Hide Private Records"), NULL, cb_private, HIDE_P
RIVATES, "<RadioItem>", NULL },
{ _("/View/Show Private Records"), NULL, cb_private, SHOW_P
RIVATES, _("/View/Hide Private Records"), NULL },
{ _("/View/Mask Private Records"), NULL, cb_private, MASK_P
RIVATES, _("/View/Hide Private Records"), NULL },
{ _("/View/sep1"), NULL, NULL, 0,
"<Separator>", NULL },
{ _("/View/Datebook"), "F1", cb_app_button, DATEBO
OK, ICON_XPM(date_menu_icon, 16) },
{ _("/View/Addresses"), "F2", cb_app_button, ADDRES
S, ICON_XPM(addr_menu_icon, 16) },
{ _("/View/Todos"), "F3", cb_app_button, TODO,
ICON_XPM(todo_menu_icon, 14) },
{ _("/View/Memos"), "F4", cb_app_button, MEMO,
ICON(GTK_STOCK_JUSTIFY_LEFT) },
{ _("/_Plugins"), NULL, NULL, 0,
"<Branch>", NULL },
#ifdef WEBMENU
{ _("/_Web"), NULL, NULL, 0,
"<Branch>", NULL },/* web */
{ _("/Web/Netscape"), NULL, NULL, 0,
"<Branch>", NULL },
{ url_commands[NETSCAPE_EXISTING].desc, NULL, cb_web, NETSCA
PE_EXISTING, NULL, NULL },
{ url_commands[NETSCAPE_NEW_WINDOW].desc,NULL, cb_web, NETSCA
PE_NEW_WINDOW,NULL, NULL },
{ url_commands[NETSCAPE_NEW].desc, NULL, cb_web, NETSCA
PE_NEW, NULL, NULL },
{ _("/Web/Mozilla"), NULL, NULL, 0,
"<Branch>", NULL },
{ url_commands[MOZILLA_EXISTING].desc, NULL, cb_web, MOZILL
A_EXISTING, NULL, NULL },
{ url_commands[MOZILLA_NEW_WINDOW].desc, NULL, cb_web, MOZILL
A_NEW_WINDOW, NULL, NULL },
{ url_commands[MOZILLA_NEW_TAB].desc, NULL, cb_web, MOZILL
A_NEW_TAB, NULL, NULL },
{ url_commands[MOZILLA_NEW].desc, NULL, cb_web, MOZILL
A_NEW, NULL, NULL },
{ _("/Web/Galeon"), NULL, NULL, 0,
"<Branch>", NULL },
{ url_commands[GALEON_EXISTING].desc, NULL, cb_web, GALEON
_EXISTING, NULL, NULL },
{ url_commands[GALEON_NEW_WINDOW].desc, NULL, cb_web, GALEON
_NEW_WINDOW, NULL, NULL },
{ url_commands[GALEON_NEW_TAB].desc, NULL, cb_web, GALEON
_NEW_TAB, NULL, NULL },
{ url_commands[GALEON_NEW].desc, NULL, cb_web, GALEON
_NEW, NULL, NULL },
{ _("/Web/Opera"), NULL, NULL, 0,
"<Branch>", NULL },
{ url_commands[OPERA_EXISTING].desc, NULL, cb_web, OPERA_
EXISTING, NULL, NULL },
{ url_commands[OPERA_NEW_WINDOW].desc, NULL, cb_web, OPERA_
NEW_WINDOW, NULL, NULL },
{ url_commands[OPERA_NEW].desc, NULL, cb_web, OPERA_
NEW, NULL, NULL },
{ _("/Web/GnomeUrl"), NULL, NULL, 0,
"<Branch>", NULL },
{ url_commands[GNOME_URL].desc, NULL, cb_web, GNOME_
URL, NULL, NULL },
{ _("/Web/Lynx"), NULL, NULL, 0,
"<Branch>", NULL },
{ url_commands[LYNX_NEW].desc, NULL, cb_web, LYNX_N
EW, NULL, NULL },
{ _("/Web/Links"), NULL, NULL, 0,
"<Branch>", NULL },
{ url_commands[LINKS_NEW].desc, NULL, cb_web, LINKS_
NEW, NULL, NULL },
{ _("/Web/W3M"), NULL, NULL, 0,
"<Branch>", NULL },
{ url_commands[W3M_NEW].desc, NULL, cb_web, W3M_NE
W, NULL, NULL },
{ _("/Web/Konqueror"), NULL, NULL, 0,
"<Branch>", NULL },
{ url_commands[KONQUEROR_NEW].desc, NULL, cb_web, KONQUE
ROR_NEW, NULL, NULL },
#endif
{ _("/_Help"), NULL, NULL, 0,
"<LastBranch>", NULL },
{ _("/Help/About J-Pilot"), NULL, cb_about, 0,
ICON(GTK_STOCK_DIALOG_INFO) },
{ "END", NULL, NULL, 0,
NULL, NULL }
};
GtkItemFactory *item_factory;
GtkAccelGroup *accel_group;
gint nmenu_items;
GtkItemFactoryEntry *menu_items2;
int i1, i2;
unsigned int i;
char temp_str[255];
GtkWidget *menu1 = gtk_menu_new();
GtkWidget *menu2 = gtk_menu_new();
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
int count, help_count; GtkWidget *menu3 = gtk_menu_new();
struct plugin_s *p;
int str_i;
char **plugin_menu_strings;
char **plugin_help_strings;
GList *temp_list;
char *F_KEYS[]={"F5","F6","F7","F8","F9","F10","F11","F12"};
int f_key_count;
#endif
/* Irix doesn't like non-constant expressions in a static initializer */
/* So we have to do this to keep the compiler happy */
for (i=0; i<sizeof(menu_items1)/sizeof(menu_items1[0]); i++) {
if (menu_items1[i].callback==cb_prefs_gui) {
menu_items1[i].callback_action = GPOINTER_TO_INT(my_window);
break;
}
}
#ifdef ENABLE_PLUGINS
/* Count the plugin/ entries */
for (count=0, temp_list = plugin_list;
temp_list;
temp_list = temp_list->next) {
p = (struct plugin_s *)temp_list->data;
if (p->menu_name) {
count++;
}
}
/* Count the help/ entries */
for (help_count=0, temp_list = plugin_list;
temp_list;
temp_list = temp_list->next) {
p = (struct plugin_s *)temp_list->data;
if (p->help_name) {
help_count++;
}
}
plugin_menu_strings = plugin_help_strings = NULL;
if (count) {
plugin_menu_strings = malloc(count * sizeof(char *));
}
if (help_count) {
plugin_help_strings = malloc(help_count * sizeof(char *));
}
/* Create plugin menu strings */
str_i = 0;
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
p = (struct plugin_s *)temp_list->data;
if (p->menu_name) {
g_snprintf(temp_str, sizeof(temp_str), _("/_Plugins/%s"), p->menu_name)
;
plugin_menu_strings[str_i++]=strdup(temp_str);
}
}
/* Create help menu strings */
str_i = 0;
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
p = (struct plugin_s *)temp_list->data;
if (p->help_name) {
g_snprintf(temp_str, sizeof(temp_str), _("/_Help/%s"), p->help_name);
plugin_help_strings[str_i++]=strdup(temp_str);
}
}
#endif #endif
GtkWidget *menu4 = gtk_menu_new();
nmenu_items = (sizeof (menu_items1) / sizeof (menu_items1[0])) - 2; GtkWidget *m = gtk_menu_item_new_with_mnemonic("_File");
gtk_menu_item_set_submenu(GTK_MENU_ITEM(m), menu1);
#ifdef ENABLE_PLUGINS gtk_menu_shell_append(GTK_MENU_SHELL(*menubar), m);
if (count) { gtk_widget_show(m);
nmenu_items = nmenu_items + count + 1;
} m = gtk_menu_item_new_with_mnemonic("_View");
nmenu_items = nmenu_items + help_count; gtk_menu_item_set_submenu(GTK_MENU_ITEM(m), menu2);
#endif gtk_menu_shell_append(GTK_MENU_SHELL(*menubar), m);
gtk_widget_show(m);
menu_items2=malloc(nmenu_items * sizeof(GtkItemFactoryEntry));
if (!menu_items2) {
jp_logf(JP_LOG_WARN, "get_main_menu(): %s\n", _("Out of memory"));
return;
}
/* Copy the first part of the array until Plugins */
for (i1=i2=0; ; i1++, i2++) {
if (!strcmp(menu_items1[i1].path, _("/_Plugins"))) {
break;
}
menu_items2[i2]=menu_items1[i1];
}
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
if (count) { /* plugin_list will be NULL if there are none */
/* This is the /_Plugins entry */ if (plugin_list) {
menu_items2[i2]=menu_items1[i1]; m = gtk_menu_item_new_with_mnemonic("_Plugins");
i1++; i2++; gtk_menu_item_set_submenu(GTK_MENU_ITEM(m), menu3);
str_i=0; gtk_menu_shell_append(GTK_MENU_SHELL(*menubar), m);
for (temp_list = plugin_list, f_key_count=0; gtk_widget_show(m);
temp_list; }
temp_list = temp_list->next, f_key_count++) { #endif
p = (struct plugin_s *)temp_list->data;
if (!p->menu_name) { m = gtk_menu_item_new_with_mnemonic("_Help");
f_key_count--; gtk_menu_item_set_submenu(GTK_MENU_ITEM(m), menu4);
continue; gtk_menu_shell_append(GTK_MENU_SHELL(*menubar_help), m);
} gtk_widget_show(m);
menu_items2[i2].path=plugin_menu_strings[str_i];
if (f_key_count < 8) { GtkAccelGroup *accel_group = gtk_accel_group_new();
menu_items2[i2].accelerator=F_KEYS[f_key_count]; gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
} else {
menu_items2[i2].accelerator=NULL; // First menu ("File")
} create_menu_item(menu1, accel_group, "gtk-find", NULL, "Find", GDK_KEY_f, GD
menu_items2[i2].callback=cb_plugin_gui; K_CONTROL_MASK, cb_search_gui, NULL);
menu_items2[i2].callback_action=p->number; GtkWidget *sep = gtk_separator_menu_item_new();
menu_items2[i2].item_type=0; gtk_menu_shell_append(GTK_MENU_SHELL(menu1), sep);
str_i++; create_menu_item(menu1, accel_group, "gtk-open", NULL, "Install", GDK_KEY_i,
i2++; GDK_CONTROL_MASK, cb_install_gui, NULL);
} create_menu_item(menu1, NULL, "gtk-go-forward", NULL, "Import", -1, GDK_CONT
} else { ROL_MASK, cb_import, NULL);
/* Skip the /_Plugins entry */ create_menu_item(menu1, NULL, "gtk-go-back", NULL, "Export", -1, GDK_CONTROL
i1++; _MASK, cb_export, NULL);
} create_menu_item(menu1, accel_group, "gtk-preferences", NULL, "Preferences",
#else GDK_KEY_s, GDK_CONTROL_MASK, cb_prefs_gui, NULL);
/* Skip the /_Plugins entry */ create_menu_item(menu1, accel_group, "gtk-print", NULL, "Print", GDK_KEY_p,
i1++; GDK_CONTROL_MASK, cb_print, NULL);
#endif sep = gtk_separator_menu_item_new();
/* Copy the last part of the array until END */ gtk_menu_shell_append(GTK_MENU_SHELL(menu1), sep);
for (; strcmp(menu_items1[i1].path, "END"); i1++, i2++) { create_menu_item(menu1, NULL, "", user_icon, "Install User", -1, GDK_CONTROL
menu_items2[i2]=menu_items1[i1]; _MASK, cb_install_user, NULL);
} create_menu_item(menu1, NULL, "gtk-redo", NULL, "Restore Handheld", -1, GDK_
CONTROL_MASK, cb_restore, NULL);
sep = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(menu1), sep);
create_menu_item(menu1, accel_group, "gtk-quit", NULL, "Quit", GDK_KEY_q, GD
K_CONTROL_MASK, cb_delete_event, NULL);
// First menu ("View")
// RADIO
GSList *group = NULL;
char *private_menu_text[] = {N_("Hide Private Records"), N_("Show Private Re
cords"), N_("Mask Private Records")};
int params[] = {HIDE_PRIVATES, SHOW_PRIVATES, MASK_PRIVATES};
GtkWidget *last_item = NULL;
GtkWidget *radio_item[3];
int i;
for (i = 0; i < 3; i++) {
radio_item[i] = gtk_radio_menu_item_new_with_label(group, private_menu_t
ext[i]);
g_signal_connect(G_OBJECT(radio_item[i]), "activate", G_CALLBACK(cb_priv
ate), GINT_TO_POINTER(params[i]));
gtk_radio_menu_item_join_group(GTK_RADIO_MENU_ITEM(radio_item[i]), GTK_R
ADIO_MENU_ITEM(last_item));
last_item = radio_item[i];
gtk_menu_shell_append(GTK_MENU_SHELL(menu2), radio_item[i]);
}
menu_hide_privates = radio_item[0];
menu_show_privates = radio_item[1];
menu_mask_privates = radio_item[2];
sep = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(menu2), sep);
create_menu_item(menu2, accel_group, "", date_menu_icon, "Datebook", GDK_KEY
_F1, 0, cb_app_button, GINT_TO_POINTER(DATEBOOK));
create_menu_item(menu2, accel_group, "", addr_menu_icon, "Address", GDK_KEY_
F2, 0, cb_app_button, GINT_TO_POINTER(ADDRESS));
create_menu_item(menu2, accel_group, "", todo_menu_icon, "Todos", GDK_KEY_F3
, 0, cb_app_button, GINT_TO_POINTER(TODO));
create_menu_item(menu2, accel_group, "gtk-justify-left", NULL, "Memos", GDK_
KEY_F4, 0, cb_app_button, GINT_TO_POINTER(MEMO));
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
if (help_count) { /* Count the plugin entries */
str_i=0; for (count=0, temp_list = plugin_list;
for (temp_list = plugin_list; temp_list;
temp_list; temp_list = temp_list->next) {
temp_list = temp_list->next) { p = (struct plugin_s *)temp_list->data;
p = (struct plugin_s *)temp_list->data; if (p->menu_name) {
if (!p->help_name) { count++;
continue; }
} }
menu_items2[i2].path=plugin_help_strings[str_i];
menu_items2[i2].accelerator=NULL; /* Count the plugin help entries */
menu_items2[i2].callback=cb_plugin_help; for (help_count=0, temp_list = plugin_list;
menu_items2[i2].callback_action=p->number; temp_list;
menu_items2[i2].item_type=0; temp_list = temp_list->next) {
str_i++; p = (struct plugin_s *)temp_list->data;
i2++; if (p->help_name) {
} help_count++;
} }
}
/* Create plugin menu */
for (i=0, temp_list = plugin_list; temp_list; temp_list = temp_list->next, i
++) {
p = (struct plugin_s *)temp_list->data;
if (p->menu_name) {
create_menu_item(menu3, accel_group, "package_system", NULL, p->menu
_name, F_KEYS[i], 0, cb_plugin_gui, GINT_TO_POINTER(p->number));
}
}
// About menu
create_menu_item(menu4, accel_group, "gtk-info", NULL, "About J-Pilot", 0, 0
, cb_about, NULL);
/* Append plugin help menu strings */
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
p = (struct plugin_s *)temp_list->data;
if (p->help_name) {
create_menu_item(menu4, accel_group, "gtk-info", NULL, p->help_name,
0, 0, cb_plugin_help, GINT_TO_POINTER(p->number));
}
}
#endif #endif
accel_group = gtk_accel_group_new();
/* This function initializes the item factory.
* Param 1: The type of menu - can be GTK_TYPE_MENU_BAR, GTK_TYPE_MENU,
* or GTK_TYPE_OPTION_MENU.
* Param 2: The path of the menu.
* Param 3: A pointer to a gtk_accel_group. The item factory sets up
* the accelerator table while generating menus. */
item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>",
accel_group);
/* This function generates the menu items. Pass the item factory,
* the number of items in the array, the array itself, and any
* callback data for the the menu items. */
gtk_item_factory_create_items(item_factory, nmenu_items, menu_items2, NULL);
/* Attach the new accelerator group to the window. */
gtk_window_add_accel_group(GTK_WINDOW(my_window), accel_group);
if (menubar) {
/* Finally, return the actual menu bar created by the item factory. */
*menubar = gtk_item_factory_get_widget (item_factory, "<main>");
}
free(menu_items2);
#ifdef ENABLE_PLUGINS
if (count) {
for (str_i=0; str_i < count; str_i++) {
free(plugin_menu_strings[str_i]);
}
free(plugin_menu_strings);
}
if (help_count) {
for (str_i=0; str_i < help_count; str_i++) {
free(plugin_help_strings[str_i]);
}
free(plugin_help_strings);
}
#endif
menu_hide_privates = GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(
item_factory,
_("/View/Hide Private Records")));
menu_show_privates = GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(
item_factory,
_("/View/Show Private Records")));
menu_mask_privates = GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(
item_factory,
_("/View/Mask Private Records")));
} }
static void cb_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) static void cb_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) {
{ int pw, ph;
int pw, ph; int x, y;
int x,y;
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
struct plugin_s *plugin; struct plugin_s *plugin;
GList *plugin_list, *temp_list; GList *plugin_list, *temp_list;
#endif #endif
/* gdk_window_get_deskrelative_origin(window->window, &x, &y); */ /* gdk_window_get_deskrelative_origin(window->window, &x, &y); */
gdk_window_get_origin(window->window, &x, &y); gdk_window_get_origin(gtk_widget_get_window(window), &x, &y);
jp_logf(JP_LOG_DEBUG, "x=%d, y=%d\n", x, y); jp_logf(JP_LOG_DEBUG, "x=%d, y=%d\n", x, y);
gdk_window_get_size(window->window, &pw, &ph); pw = gdk_window_get_width(gtk_widget_get_window(window));
set_pref(PREF_WINDOW_WIDTH, pw, NULL, FALSE); ph = gdk_window_get_height(gtk_widget_get_window(window));
set_pref(PREF_WINDOW_HEIGHT, ph, NULL, FALSE); set_pref(PREF_WINDOW_WIDTH, pw, NULL, FALSE);
set_pref(PREF_LAST_APP, glob_app, NULL, TRUE); set_pref(PREF_WINDOW_HEIGHT, ph, NULL, FALSE);
set_pref(PREF_LAST_APP, glob_app, NULL, TRUE);
gui_cleanup();
gui_cleanup();
if (weekview_window)
cb_weekview_quit(weekview_window, NULL); if (weekview_window)
if (monthview_window) cb_weekview_quit(weekview_window, NULL);
cb_monthview_quit(monthview_window, NULL); if (monthview_window)
cb_monthview_quit(monthview_window, NULL);
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
plugin_list = get_plugin_list(); plugin_list = get_plugin_list();
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) { for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
plugin = (struct plugin_s *)temp_list->data; plugin = (struct plugin_s *) temp_list->data;
if (plugin) { if (plugin) {
if (plugin->plugin_exit_cleanup) { if (plugin->plugin_exit_cleanup) {
jp_logf(JP_LOG_DEBUG, "calling plugin_exit_cleanup\n"); jp_logf(JP_LOG_DEBUG, "calling plugin_exit_cleanup\n");
plugin->plugin_exit_cleanup(); plugin->plugin_exit_cleanup();
} }
} }
} }
#endif #endif
if (glob_child_pid) { if (glob_child_pid) {
jp_logf(JP_LOG_DEBUG, "killing %d\n", glob_child_pid); jp_logf(JP_LOG_DEBUG, "killing %d\n", glob_child_pid);
kill(glob_child_pid, SIGTERM); kill(glob_child_pid, SIGTERM);
} }
/* Save preferences in jpilot.rc */ /* Save preferences in jpilot.rc */
pref_write_rc_file(); pref_write_rc_file();
cleanup_pc_files(); cleanup_pc_files();
cleanup_pidfile(); cleanup_pidfile();
gtk_main_quit(); gtk_main_quit();
} }
static void cb_output(GtkWidget *widget, gpointer data) static void cb_output(GtkWidget *widget, gpointer data) {
{ int flags;
int flags; int h, output_height;
int w, h, output_height;
flags=GPOINTER_TO_INT(data); flags = GPOINTER_TO_INT(data);
if ((flags==OUTPUT_MINIMIZE) || (flags==OUTPUT_RESIZE)) { if ((flags == OUTPUT_MINIMIZE) || (flags == OUTPUT_RESIZE)) {
jp_logf(JP_LOG_DEBUG,"paned pos = %d\n", gtk_paned_get_position(GTK_PANED( jp_logf(JP_LOG_DEBUG, "paned pos = %d\n", gtk_paned_get_position(GTK_PAN
output_pane))); ED(output_pane)));
gdk_window_get_size(window->window, &w, &h); h = gdk_window_get_height(gtk_widget_get_window(window));
output_height = (h - gtk_paned_get_position(GTK_PANED(output_pane))); output_height = (h - gtk_paned_get_position(GTK_PANED(output_pane)));
set_pref(PREF_OUTPUT_HEIGHT, output_height, NULL, TRUE); set_pref(PREF_OUTPUT_HEIGHT, output_height, NULL, TRUE);
if (flags==OUTPUT_MINIMIZE) { if (flags == OUTPUT_MINIMIZE) {
gtk_paned_set_position(GTK_PANED(output_pane), h); gtk_paned_set_position(GTK_PANED(output_pane), h);
} }
jp_logf(JP_LOG_DEBUG,"output height = %d\n", output_height); jp_logf(JP_LOG_DEBUG, "output height = %d\n", output_height);
} }
if (flags==OUTPUT_CLEAR) { if (flags == OUTPUT_CLEAR) {
gtk_text_buffer_set_text(g_output_text_buffer, "", -1); gtk_text_buffer_set_text(g_output_text_buffer, "", -1);
} }
} }
static gint cb_output_idle(gpointer data) static gint cb_output_idle(gpointer data) {
{ cb_output(NULL, data);
cb_output(NULL, data); /* returning false removes this handler from being called again */
/* returning false removes this handler from being called again */ return FALSE;
return FALSE;
} }
static gint cb_output2(GtkWidget *widget, GdkEventButton *event, gpointer data) static gint cb_output2(GtkWidget *widget, GdkEventButton *event, gpointer data)
{ {
/* Because the pane isn't redrawn yet we can't get positions from it. /* Because the pane isn't redrawn yet we can't get positions from it.
* So we have to call back after everything is drawn */ * So we have to call back after everything is drawn */
gtk_idle_add(cb_output_idle, data); g_idle_add(cb_output_idle, data);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
static gint cb_check_version(gpointer main_window) static gint cb_check_version(gpointer main_window) {
{ int major, minor, micro;
int major, minor, micro; int r;
int r; char str_ver[8];
char str_ver[8];
jp_logf(JP_LOG_DEBUG, "cb_check_version\n");
jp_logf(JP_LOG_DEBUG, "cb_check_version\n");
r = sscanf(VERSION, "%d.%d.%d", &major, &minor, &micro);
if (r!=3) {
jp_logf(JP_LOG_DEBUG, "couldn't parse VERSION\n");
return FALSE;
}
/* These shouldn't be greater than 100, but just in case */
major %= 100;
minor %= 100;
micro %= 100;
sprintf(str_ver, "%02d%02d%02d", major, minor, micro); r = sscanf(VERSION, "%d.%d.%d", &major, &minor, &micro);
if (r != 3) {
jp_logf(JP_LOG_DEBUG, "couldn't parse VERSION\n");
return FALSE;
}
/* These shouldn't be greater than 100, but just in case */
major %= 100;
minor %= 100;
micro %= 100;
set_pref(PREF_VERSION, 0, str_ver, 1); sprintf(str_ver, "%02d%02d%02d", major, minor, micro);
return FALSE; set_pref(PREF_VERSION, 0, str_ver, 1);
return FALSE;
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[]) {
{ GtkWidget *main_vbox;
GtkWidget *main_vbox; GtkWidget *temp_hbox;
GtkWidget *temp_hbox; GtkWidget *temp_vbox;
GtkWidget *temp_vbox; GtkWidget *button_datebook, *button_address, *button_todo, *button_memo;
GtkWidget *button_datebook,*button_address,*button_todo,*button_memo; GtkWidget *button;
GtkWidget *button; GtkWidget *separator;
GtkWidget *separator; //gtk2 GtkStyle *style;
GtkStyle *style; GtkWidget *pixbufwid;
GdkBitmap *mask; GdkPixbuf *pixbuf;
GtkWidget *pixmapwid; GtkWidget *menubar = NULL;
GdkPixmap *pixmap; GtkWidget *menubar_help = NULL;
GtkWidget *menubar = NULL; GtkAccelGroup *accel_group;
GtkWidget *scrolled_window;
GtkAccelGroup *accel_group;
/* Extract first day of week preference from locale in GTK2 */ /* Extract first day of week preference from locale in GTK2 */
int pref_fdow = 0; int pref_fdow = 0;
#ifdef HAVE__NL_TIME_FIRST_WEEKDAY #ifdef HAVE__NL_TIME_FIRST_WEEKDAY
char *langinfo; char *langinfo;
int week_1stday = 0; int week_1stday = 0;
int first_weekday = 1; int first_weekday = 1;
unsigned int week_origin; unsigned int week_origin;
#else #else
# ifdef ENABLE_NLS # ifdef ENABLE_NLS
char *week_start; char *week_start;
# endif # endif
#endif #endif
unsigned char skip_past_alarms; unsigned char skip_past_alarms;
unsigned char skip_all_alarms; unsigned char skip_all_alarms;
int filedesc[2]; int filedesc[2];
long ivalue; long ivalue;
const char *svalue; const char *svalue;
int i, ret, height, width; int i, height;
char title[MAX_PREF_LEN+256]; char title[MAX_PREF_LEN + 256];
long pref_width, pref_height, show_tooltips; long pref_width, pref_height, show_tooltips;
long char_set; long char_set;
char *geometry_str=NULL; #ifdef PARSE_GEOMETRY
int iconify = 0; char *geometry_str = NULL;
#ifdef ENABLE_PLUGINS
GList *plugin_list;
GList *temp_list;
struct plugin_s *plugin;
jp_startup_info info;
#endif
int pid;
int remote_sync = FALSE;
#if defined(ENABLE_NLS)
# ifdef HAVE_LOCALE_H
char *current_locale;
# endif
#endif #endif
int iconify = 0;
#ifdef ENABLE_PLUGINS
GList *plugin_list;
GList *temp_list;
struct plugin_s *plugin;
jp_startup_info info;
#endif
int pid;
int remote_sync = FALSE;
skip_plugins = FALSE;
skip_past_alarms = FALSE;
skip_all_alarms = FALSE;
/* log all output to a file */
glob_log_file_mask = JP_LOG_INFO | JP_LOG_WARN | JP_LOG_FATAL | JP_LOG_STDOU
T;
glob_log_stdout_mask = JP_LOG_INFO | JP_LOG_WARN | JP_LOG_FATAL | JP_LOG_STD
OUT;
glob_log_gui_mask = JP_LOG_FATAL | JP_LOG_WARN | JP_LOG_GUI;
glob_find_id = 0;
/* Directory ~/.jpilot is created with permissions of 700 to prevent anyone
* but the user from looking at potentially sensitive files.
* Files within the directory have permission 600 */
umask(0077);
skip_plugins=FALSE; /* enable internationalization(i18n) before printing any output */
skip_past_alarms=FALSE;
skip_all_alarms=FALSE;
/* log all output to a file */
glob_log_file_mask = JP_LOG_INFO | JP_LOG_WARN | JP_LOG_FATAL | JP_LOG_STDOUT
;
glob_log_stdout_mask = JP_LOG_INFO | JP_LOG_WARN | JP_LOG_FATAL | JP_LOG_STDO
UT;
glob_log_gui_mask = JP_LOG_FATAL | JP_LOG_WARN | JP_LOG_GUI;
glob_find_id = 0;
/* Directory ~/.jpilot is created with permissions of 700 to prevent anyone
* but the user from looking at potentially sensitive files.
* Files within the directory have permission 600 */
umask(0077);
/* enable internationalization(i18n) before printing any output */
#if defined(ENABLE_NLS) #if defined(ENABLE_NLS)
# ifdef HAVE_LOCALE_H # ifdef HAVE_LOCALE_H
current_locale = setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
# endif # endif
bindtextdomain(EPN, LOCALEDIR); bindtextdomain(EPN, LOCALEDIR);
textdomain(EPN); textdomain(EPN);
#endif #endif
pref_init(); pref_init();
/* read jpilot.rc file for preferences */ /* read jpilot.rc file for preferences */
pref_read_rc_file(); pref_read_rc_file();
/* Extract first day of week preference from locale in GTK2 */ /* Extract first day of week preference from locale in GTK2 */
# ifdef HAVE__NL_TIME_FIRST_WEEKDAY # ifdef HAVE__NL_TIME_FIRST_WEEKDAY
/* GTK 2.8 libraries */ /* GTK 2.8 libraries */
langinfo = nl_langinfo(_NL_TIME_FIRST_WEEKDAY); langinfo = nl_langinfo(_NL_TIME_FIRST_WEEKDAY);
first_weekday = langinfo[0]; first_weekday = langinfo[0];
langinfo = nl_langinfo(_NL_TIME_WEEK_1STDAY); langinfo = nl_langinfo(_NL_TIME_WEEK_1STDAY);
week_origin = GPOINTER_TO_INT(langinfo); week_origin = GPOINTER_TO_INT(langinfo);
if (week_origin == 19971130) /* Sunday */ if (week_origin == 19971130) /* Sunday */
week_1stday = 0; week_1stday = 0;
else if (week_origin == 19971201) /* Monday */ else if (week_origin == 19971201) /* Monday */
week_1stday = 1; week_1stday = 1;
else else
g_warning ("Unknown value of _NL_TIME_WEEK_1STDAY.\n"); g_warning ("Unknown value of _NL_TIME_WEEK_1STDAY.\n");
pref_fdow = (week_1stday + first_weekday - 1) % 7; pref_fdow = (week_1stday + first_weekday - 1) % 7;
# else # else
/* GTK 2.6 libraries */ /* GTK 2.6 libraries */
# if defined(ENABLE_NLS) # if defined(ENABLE_NLS)
week_start = dgettext("gtk20", "calendar:week_start:0"); week_start = dgettext("gtk20", "calendar:week_start:0");
if (strncmp("calendar:week_start:", week_start, 20) == 0) { if (strncmp("calendar:week_start:", week_start, 20) == 0) {
pref_fdow = *(week_start + 20) - '0'; pref_fdow = *(week_start + 20) - '0';
} else { } else {
pref_fdow = -1; pref_fdow = -1;
} }
# endif # endif
# endif # endif
if (pref_fdow > 1) if (pref_fdow > 1)
pref_fdow = 1; pref_fdow = 1;
if (pref_fdow < 0) if (pref_fdow < 0)
pref_fdow = 0; pref_fdow = 0;
set_pref_possibility(PREF_FDOW, pref_fdow, TRUE); set_pref_possibility(PREF_FDOW, pref_fdow, TRUE);
if (otherconv_init()) { if (otherconv_init()) {
printf("Error: could not set character encoding\n"); printf("Error: could not set character encoding\n");
exit(0); exit(0);
} }
get_pref(PREF_WINDOW_WIDTH, &pref_width, NULL); get_pref(PREF_WINDOW_WIDTH, &pref_width, NULL);
get_pref(PREF_WINDOW_HEIGHT, &pref_height, NULL); get_pref(PREF_WINDOW_HEIGHT, &pref_height, NULL);
/* parse command line options */ /* parse command line options */
for (i=1; i<argc; i++) { for (i = 1; i < argc; i++) {
if (!strncasecmp(argv[i], "-v", 3)) { if (!strncasecmp(argv[i], "-v", 3)) {
char options[1024]; char options[1024];
get_compile_options(options, sizeof(options)); get_compile_options(options, sizeof(options));
printf("\n%s\n", options); printf("\n%s\n", options);
exit(0); exit(0);
} }
if ( (!strncasecmp(argv[i], "-h", 3)) || if ((!strncasecmp(argv[i], "-h", 3)) ||
(!strncasecmp(argv[i], "-?", 3)) ) { (!strncasecmp(argv[i], "-?", 3))) {
fprint_usage_string(stderr); fprint_usage_string(stderr);
exit(0); exit(0);
} }
if (!strncasecmp(argv[i], "-d", 3)) { if (!strncasecmp(argv[i], "-d", 3)) {
glob_log_stdout_mask = 0xFFFF; glob_log_stdout_mask = 0xFFFF;
glob_log_file_mask = 0xFFFF; glob_log_file_mask = 0xFFFF;
jp_logf(JP_LOG_DEBUG, "Debug messages on.\n"); jp_logf(JP_LOG_DEBUG, "Debug messages on.\n");
} }
if (!strncasecmp(argv[i], "-p", 3)) { if (!strncasecmp(argv[i], "-p", 3)) {
skip_plugins = TRUE; skip_plugins = TRUE;
jp_logf(JP_LOG_INFO, _("Not loading plugins.\n")); jp_logf(JP_LOG_INFO, _("Not loading plugins.\n"));
} }
if (!strncmp(argv[i], "-A", 3)) { if (!strncmp(argv[i], "-A", 3)) {
skip_all_alarms = TRUE; skip_all_alarms = TRUE;
jp_logf(JP_LOG_INFO, _("Ignoring all alarms.\n")); jp_logf(JP_LOG_INFO, _("Ignoring all alarms.\n"));
} }
if (!strncmp(argv[i], "-a", 3)) { if (!strncmp(argv[i], "-a", 3)) {
skip_past_alarms = TRUE; skip_past_alarms = TRUE;
jp_logf(JP_LOG_INFO, _("Ignoring past alarms.\n")); jp_logf(JP_LOG_INFO, _("Ignoring past alarms.\n"));
} }
if ( (!strncmp(argv[i], "-s", 3)) || if ((!strncmp(argv[i], "-s", 3)) ||
(!strncmp(argv[i], "--remote-sync", 14))) { (!strncmp(argv[i], "--remote-sync", 14))) {
remote_sync = TRUE; remote_sync = TRUE;
} }
if ( (!strncasecmp(argv[i], "-i", 3)) || if ((!strncasecmp(argv[i], "-i", 3)) ||
(!strncasecmp(argv[i], "--iconic", 9))){ (!strncasecmp(argv[i], "--iconic", 9))) {
iconify = 1; iconify = 1;
} }
if (!strncasecmp(argv[i], "-geometry", 9)) { if (!strncasecmp(argv[i], "-geometry", 9)) {
/* The '=' isn't specified in `man X`, but we will be nice */ #ifdef PARSE_GEOMETRY
if (argv[i][9]=='=') { /* The '=' isn't specified in `man X`, but we will be nice */
geometry_str=argv[i]+9; if (argv[i][9] == '=') {
} else { geometry_str = argv[i] + 9;
if (i<argc) { } else {
geometry_str=argv[i+1]; if (i < argc) {
geometry_str = argv[i + 1];
}
} }
} #endif
} fprintf(stdout, "Geometry handling in GTK is deprecated as of versio
} n 3.20\n");
fprintf(stdout, "J-Pilot can be compiled with define PARSE_GEOMETRY
to use it if its available.\n");
}
}
/* Enable UTF8 *AFTER* potential printf to stdout for -h or -v */ /* Enable UTF8 *AFTER* potential printf to stdout for -h or -v */
/* Not all terminals(xterm, rxvt, etc.) are UTF8 compliant */ /* Not all terminals(xterm, rxvt, etc.) are UTF8 compliant */
#if defined(ENABLE_NLS) #if defined(ENABLE_NLS)
/* generate UTF-8 strings from gettext() & _() */ /* generate UTF-8 strings from gettext() & _() */
bind_textdomain_codeset(EPN, "UTF-8"); bind_textdomain_codeset(EPN, "UTF-8");
#endif #endif
/* Check to see if ~/.jpilot is there, or create it */ /* Check to see if ~/.jpilot is there, or create it */
jp_logf(JP_LOG_DEBUG, "calling check_hidden_dir\n"); jp_logf(JP_LOG_DEBUG, "calling check_hidden_dir\n");
if (check_hidden_dir()) { if (check_hidden_dir()) {
exit(1); exit(1);
} }
/* Setup the pid file and check for a running jpilot */ /* Setup the pid file and check for a running jpilot */
setup_pidfile(); setup_pidfile();
pid = check_for_jpilot(); pid = check_for_jpilot();
if (remote_sync) { if (remote_sync) {
if (pid) { if (pid) {
printf ("jpilot: syncing jpilot at %d\n", pid); printf("jpilot: syncing jpilot at %d\n", pid);
kill (pid, SIGUSR1); kill(pid, SIGUSR1);
exit (0); exit(0);
} } else {
else { fprintf(stderr, "%s\n", "J-Pilot not running.");
fprintf (stderr, "%s\n", "J-Pilot not running."); exit(1);
exit (1); }
} } else if (!pid) {
} /* JPilot not running, install signal handler and write pid file */
else if (!pid) { signal(SIGUSR1, sync_sig_handler);
/* JPilot not running, install signal handler and write pid file */ write_pid();
signal(SIGUSR1, sync_sig_handler); }
write_pid();
} /* Check to see if DB files are there */
/* If not copy some empty ones over */
/* Check to see if DB files are there */ check_copy_DBs_to_home();
/* If not copy some empty ones over */
check_copy_DBs_to_home();
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
plugin_list=NULL; plugin_list = NULL;
if (!skip_plugins) { if (!skip_plugins) {
load_plugins(); load_plugins();
} }
plugin_list = get_plugin_list(); plugin_list = get_plugin_list();
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) { for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
plugin = (struct plugin_s *)temp_list->data; plugin = (struct plugin_s *) temp_list->data;
jp_logf(JP_LOG_DEBUG, "plugin: [%s] was loaded\n", plugin->name); jp_logf(JP_LOG_DEBUG, "plugin: [%s] was loaded\n", plugin->name);
if (plugin) { if (plugin) {
if (plugin->plugin_startup) { if (plugin->plugin_startup) {
info.base_dir = strdup(BASE_DIR); info.base_dir = strdup(BASE_DIR);
jp_logf(JP_LOG_DEBUG, "calling plugin_startup for [%s]\n", plugin->n jp_logf(JP_LOG_DEBUG, "calling plugin_startup for [%s]\n", plugi
ame); n->name);
plugin->plugin_startup(&info); plugin->plugin_startup(&info);
if (info.base_dir) { if (info.base_dir) {
free(info.base_dir); free(info.base_dir);
}
} }
} }
} }
}
#endif #endif
glob_date_timer_tag=0; glob_date_timer_tag = 0;
glob_child_pid=0; glob_child_pid = 0;
/* Create a pipe to send data from sync child to parent */ /* Create a pipe to send data from sync child to parent */
if (pipe(filedesc) < 0) { if (pipe(filedesc) < 0) {
jp_logf(JP_LOG_FATAL, _("Unable to open pipe\n")); jp_logf(JP_LOG_FATAL, _("Unable to open pipe\n"));
exit(-1); exit(-1);
} }
pipe_from_child = filedesc[0]; pipe_from_child = filedesc[0];
pipe_to_parent = filedesc[1]; pipe_to_parent = filedesc[1];
/* Create a pipe to send data from parent to sync child */
if (pipe(filedesc) < 0) {
jp_logf(JP_LOG_FATAL, _("Unable to open pipe\n"));
exit(-1);
}
pipe_from_parent = filedesc[0];
pipe_to_child = filedesc[1];
/* Create a pipe to send data from parent to sync child */ get_pref(PREF_CHAR_SET, &char_set, NULL);
if (pipe(filedesc) < 0) { /* Deprecated in GTK3 */
jp_logf(JP_LOG_FATAL, _("Unable to open pipe\n"));
exit(-1);
}
pipe_from_parent = filedesc[0];
pipe_to_child = filedesc[1];
get_pref(PREF_CHAR_SET, &char_set, NULL);
switch (char_set) {
case CHAR_SET_JAPANESE:
gtk_rc_parse("gtkrc.ja");
break;
case CHAR_SET_TRADITIONAL_CHINESE:
gtk_rc_parse("gtkrc.zh_TW.Big5");
break;
case CHAR_SET_KOREAN:
gtk_rc_parse("gtkrc.ko");
break;
/* Since Now, these are not supported yet. */
#if 0 #if 0
case CHAR_SET_SIMPLIFIED_CHINESE: switch (char_set) {
gtk_rc_parse("gtkrc.zh_CN"); case CHAR_SET_JAPANESE:
break; gtk_rc_parse("gtkrc.ja");
case CHAR_SET_1250: break;
gtk_rc_parse("gtkrc.???"); case CHAR_SET_TRADITIONAL_CHINESE:
break; gtk_rc_parse("gtkrc.zh_TW.Big5");
case CHAR_SET_1251: break;
gtk_rc_parse("gtkrc.iso-8859-5"); case CHAR_SET_KOREAN:
break; gtk_rc_parse("gtkrc.ko");
case CHAR_SET_1251_B: break;
gtk_rc_parse("gtkrc.ru"); /* Since Now, these are not supported yet. */
break; #if 0
#endif case CHAR_SET_SIMPLIFIED_CHINESE:
default: gtk_rc_parse("gtkrc.zh_CN");
break; break;
/* do nothing */ case CHAR_SET_1250:
} gtk_rc_parse("gtkrc.???");
break;
jpilot_master_pid = getpid(); case CHAR_SET_1251:
gtk_rc_parse("gtkrc.iso-8859-5");
gtk_init(&argc, &argv); break;
case CHAR_SET_1251_B:
read_gtkrc_file(); gtk_rc_parse("gtkrc.ru");
break;
get_pref(PREF_USER, NULL, &svalue); #endif
default:
break;
/* do nothing */
}
#endif
strcpy(title, PN" "VERSION); jpilot_master_pid = getpid();
if ((svalue) && (svalue[0])) {
strcat(title, _(" User: "));
/* Convert user name so that it can be displayed in window title */
/* We assume user name is coded in jpilot.rc as it is on the Palm Pilot */
{
char *newvalue;
newvalue = charset_p2newj(svalue, -1, char_set);
strcat(title, newvalue);
free(newvalue);
}
}
window = gtk_widget_new(GTK_TYPE_WINDOW, gtk_init(&argc, &argv);
"type", GTK_WINDOW_TOPLEVEL,
"title", title,
NULL);
/* Set default size and position of main window */
ret = 0;
if (geometry_str) {
ret = gtk_window_parse_geometry(GTK_WINDOW(window), geometry_str);
}
if ((!geometry_str) || (ret != 1)) {
gtk_window_set_default_size(GTK_WINDOW(window), pref_width, pref_height);
}
if (iconify) { read_gtkrc_file();
gtk_window_iconify(GTK_WINDOW(window));
} get_pref(PREF_USER, NULL, &svalue);
strcpy(title, PN" "VERSION);
if ((svalue) && (svalue[0])) {
strcat(title, _(" User: "));
/* Convert user name so that it can be displayed in window title */
/* We assume user name is coded in jpilot.rc as it is on the Palm Pilot
*/
{
char *newvalue;
newvalue = charset_p2newj(svalue, -1, char_set);
strcat(title, newvalue);
free(newvalue);
}
}
window = gtk_widget_new(GTK_TYPE_WINDOW,
"type", GTK_WINDOW_TOPLEVEL,
"title", title,
NULL);
/* Set default size and position of main window */
#ifdef PARSE_GEOMETRY
int ret = 0;
if (geometry_str) {
ret = gtk_window_parse_geometry(GTK_WINDOW(window), geometry_str);
}
if ((!geometry_str) || (ret != 1)) {
gtk_window_set_default_size(GTK_WINDOW(window), pref_width, pref_height)
;
}
#else
gtk_window_set_default_size(GTK_WINDOW(window), pref_width, pref_height);
#endif
if (iconify) {
gtk_window_iconify(GTK_WINDOW(window));
}
/* Set a handler for delete_event that immediately exits GTK. */ /* Set a handler for delete_event that immediately exits GTK. */
gtk_signal_connect(GTK_OBJECT(window), "delete_event", g_signal_connect(G_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(cb_delete_event), NULL); G_CALLBACK(cb_delete_event), NULL);
gtk_container_set_border_width(GTK_CONTAINER(window), 0); gtk_container_set_border_width(GTK_CONTAINER(window), 0);
main_vbox = gtk_vbox_new(FALSE, 0); main_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
g_hbox = gtk_hbox_new(FALSE, 0); g_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
g_vbox0 = gtk_vbox_new(FALSE, 0); g_vbox0 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
/* Output Pane */ /* Output Pane */
output_pane = gtk_vpaned_new(); output_pane = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
gtk_signal_connect(GTK_OBJECT(output_pane), "button_release_event", g_signal_connect(G_OBJECT(output_pane), "button_release_event",
GTK_SIGNAL_FUNC(cb_output2), G_CALLBACK(cb_output2),
GINT_TO_POINTER(OUTPUT_RESIZE)); GINT_TO_POINTER(OUTPUT_RESIZE));
gtk_container_add(GTK_CONTAINER(window), output_pane); gtk_container_add(GTK_CONTAINER(window), output_pane);
gtk_paned_pack1(GTK_PANED(output_pane), main_vbox, FALSE, FALSE); gtk_paned_pack1(GTK_PANED(output_pane), main_vbox, FALSE, FALSE);
/* Create the Menu Bar at the top */ /* Create the Menu Bar at the top */
#ifdef ENABLE_PLUGINS #ifdef ENABLE_PLUGINS
get_main_menu(window, &menubar, plugin_list); get_main_menu(window, &menubar, &menubar_help, plugin_list);
#else #else
get_main_menu(window, &menubar, NULL); get_main_menu(window, &menubar, &menubar_help, NULL);
#endif #endif
gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(main_vbox), g_hbox, TRUE, TRUE, 3); temp_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_set_border_width(GTK_CONTAINER(g_hbox), 10); gtk_box_pack_start(GTK_BOX(main_vbox), temp_hbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(g_hbox), g_vbox0, FALSE, FALSE, 3); gtk_box_pack_start(GTK_BOX(temp_hbox), menubar, FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(temp_hbox), menubar_help, FALSE, FALSE, 0);
/* Output Text scrolled window */
temp_hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(main_vbox), g_hbox, TRUE, TRUE, 3);
gtk_container_set_border_width(GTK_CONTAINER(temp_hbox), 5); gtk_container_set_border_width(GTK_CONTAINER(g_hbox), 10);
gtk_paned_pack2(GTK_PANED(output_pane), temp_hbox, FALSE, TRUE); gtk_box_pack_start(GTK_BOX(g_hbox), g_vbox0, FALSE, FALSE, 3);
temp_vbox = gtk_vbox_new(FALSE, 3); /* Output Text scrolled window */
gtk_container_set_border_width(GTK_CONTAINER(temp_vbox), 6); temp_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_end(GTK_BOX(temp_hbox), temp_vbox, FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(temp_hbox), 5);
gtk_paned_pack2(GTK_PANED(output_pane), temp_hbox, FALSE, TRUE);
g_output_text = GTK_TEXT_VIEW(gtk_text_view_new());
g_output_text_buffer = gtk_text_view_get_buffer(g_output_text); temp_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
gtk_text_view_set_cursor_visible(g_output_text, FALSE); gtk_container_set_border_width(GTK_CONTAINER(temp_vbox), 6);
gtk_text_view_set_editable(g_output_text, FALSE); gtk_box_pack_end(GTK_BOX(temp_hbox), temp_vbox, FALSE, FALSE, 0);
gtk_text_view_set_wrap_mode(g_output_text, GTK_WRAP_WORD);
g_output_text = GTK_TEXT_VIEW(gtk_text_view_new());
scrolled_window = gtk_scrolled_window_new(NULL, NULL); g_output_text_buffer = gtk_text_view_get_buffer(g_output_text);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), gtk_text_view_set_cursor_visible(g_output_text, FALSE);
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_text_view_set_editable(g_output_text, FALSE);
gtk_text_view_set_wrap_mode(g_output_text, GTK_WRAP_WORD);
gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(g_output_text));
gtk_box_pack_start_defaults(GTK_BOX(temp_hbox), scrolled_window); g_output_text_scrolled_window = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(g_output_text_scrolled_wi
button = gtk_button_new_from_stock(GTK_STOCK_CLEAR); ndow),
gtk_box_pack_start(GTK_BOX(temp_vbox), button, TRUE, TRUE, 3); GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(cb_output), gtk_container_add(GTK_CONTAINER(g_output_text_scrolled_window), GTK_WIDGET(g
GINT_TO_POINTER(OUTPUT_CLEAR)); _output_text));
gtk_box_pack_start(GTK_BOX(temp_hbox), GTK_WIDGET(g_output_text_scrolled_win
button = gtk_button_new_from_stock(GTK_STOCK_REMOVE); dow), TRUE, TRUE,0);
gtk_box_pack_start(GTK_BOX(temp_vbox), button, TRUE, TRUE, 3);
gtk_signal_connect(GTK_OBJECT(button), "clicked", button = gtk_button_new_with_label("Clear");
GTK_SIGNAL_FUNC(cb_output), gtk_box_pack_start(GTK_BOX(temp_vbox), button, TRUE, TRUE, 3);
GINT_TO_POINTER(OUTPUT_MINIMIZE)); g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(cb_output),
/* "Datebook" button */ GINT_TO_POINTER(OUTPUT_CLEAR));
temp_hbox = gtk_hbox_new(FALSE, 0);
button_datebook = gtk_button_new(); button = gtk_button_new_with_label("Remove");
gtk_signal_connect(GTK_OBJECT(button_datebook), "clicked", gtk_box_pack_start(GTK_BOX(temp_vbox), button, TRUE, TRUE, 3);
GTK_SIGNAL_FUNC(cb_app_button), GINT_TO_POINTER(DATEBOOK)) g_signal_connect(G_OBJECT(button), "clicked",
; G_CALLBACK(cb_output),
gtk_box_pack_start(GTK_BOX(g_vbox0), temp_hbox, FALSE, FALSE, 0); GINT_TO_POINTER(OUTPUT_MINIMIZE));
gtk_box_pack_start(GTK_BOX(temp_hbox), button_datebook, TRUE, FALSE, 0);
/* "Datebook" button */
/* "Address" button */ temp_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
temp_hbox = gtk_hbox_new(FALSE, 0); button_datebook = gtk_button_new();
button_address = gtk_button_new(); g_signal_connect(G_OBJECT(button_datebook), "clicked",
gtk_signal_connect(GTK_OBJECT(button_address), "clicked", G_CALLBACK(cb_app_button), GINT_TO_POINTER(DATEBOOK));
GTK_SIGNAL_FUNC(cb_app_button), GINT_TO_POINTER(ADDRESS)); gtk_box_pack_start(GTK_BOX(g_vbox0), temp_hbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(g_vbox0), temp_hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(temp_hbox), button_datebook, TRUE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(temp_hbox), button_address, TRUE, FALSE, 0);
/* "Address" button */
/* "Todo" button */ temp_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
temp_hbox = gtk_hbox_new(FALSE, 0); button_address = gtk_button_new();
button_todo = gtk_button_new(); g_signal_connect(G_OBJECT(button_address), "clicked",
gtk_signal_connect(GTK_OBJECT(button_todo), "clicked", G_CALLBACK(cb_app_button), GINT_TO_POINTER(ADDRESS));
GTK_SIGNAL_FUNC(cb_app_button), GINT_TO_POINTER(TODO)); gtk_box_pack_start(GTK_BOX(g_vbox0), temp_hbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(g_vbox0), temp_hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(temp_hbox), button_address, TRUE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(temp_hbox), button_todo, TRUE, FALSE, 0);
/* "Todo" button */
/* "Memo" button */ temp_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
temp_hbox = gtk_hbox_new(FALSE, 0); button_todo = gtk_button_new();
button_memo = gtk_button_new(); g_signal_connect(G_OBJECT(button_todo), "clicked",
gtk_signal_connect(GTK_OBJECT(button_memo), "clicked", G_CALLBACK(cb_app_button), GINT_TO_POINTER(TODO));
GTK_SIGNAL_FUNC(cb_app_button), GINT_TO_POINTER(MEMO)); gtk_box_pack_start(GTK_BOX(g_vbox0), temp_hbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(g_vbox0), temp_hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(temp_hbox), button_todo, TRUE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(temp_hbox), button_memo, TRUE, FALSE, 0);
/* "Memo" button */
gtk_widget_set_name(button_datebook, "button_app"); temp_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_name(button_address, "button_app"); button_memo = gtk_button_new();
gtk_widget_set_name(button_todo, "button_app"); g_signal_connect(G_OBJECT(button_memo), "clicked",
gtk_widget_set_name(button_memo, "button_app"); G_CALLBACK(cb_app_button), GINT_TO_POINTER(MEMO));
gtk_box_pack_start(GTK_BOX(g_vbox0), temp_hbox, FALSE, FALSE, 0);
/* Create tooltips */ gtk_box_pack_start(GTK_BOX(temp_hbox), button_memo, TRUE, FALSE, 0);
glob_tooltips = gtk_tooltips_new();
gtk_widget_set_name(button_datebook, "button_app");
/* Get preference to show tooltips */ gtk_widget_set_name(button_address, "button_app");
get_pref(PREF_SHOW_TOOLTIPS, &show_tooltips, NULL); gtk_widget_set_name(button_todo, "button_app");
gtk_widget_set_name(button_memo, "button_app");
/* Create key accelerator */
accel_group = gtk_accel_group_new(); /* Get preference to show tooltips */
gtk_window_add_accel_group(GTK_WINDOW(window), accel_group); get_pref(PREF_SHOW_TOOLTIPS, &show_tooltips, NULL);
/* Lock/Unlock/Mask buttons */ /* Create key accelerator */
button_locked = gtk_button_new(); accel_group = gtk_accel_group_new();
button_masklocked = gtk_button_new(); gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
button_unlocked = gtk_button_new();
gtk_signal_connect(GTK_OBJECT(button_locked), "clicked", /* Lock/Unlock/Mask buttons */
GTK_SIGNAL_FUNC(cb_private), button_locked = gtk_button_new();
GINT_TO_POINTER(SHOW_PRIVATES)); button_masklocked = gtk_button_new();
gtk_signal_connect(GTK_OBJECT(button_masklocked), "clicked", button_unlocked = gtk_button_new();
GTK_SIGNAL_FUNC(cb_private), g_signal_connect(G_OBJECT(button_locked), "clicked",
GINT_TO_POINTER(HIDE_PRIVATES)); G_CALLBACK(cb_private),
gtk_signal_connect(GTK_OBJECT(button_unlocked), "clicked", GINT_TO_POINTER(SHOW_PRIVATES));
GTK_SIGNAL_FUNC(cb_private), g_signal_connect(G_OBJECT(button_masklocked), "clicked",
GINT_TO_POINTER(MASK_PRIVATES)); G_CALLBACK(cb_private),
gtk_box_pack_start(GTK_BOX(g_vbox0), button_locked, FALSE, FALSE, 20); GINT_TO_POINTER(HIDE_PRIVATES));
gtk_box_pack_start(GTK_BOX(g_vbox0), button_masklocked, FALSE, FALSE, 20); g_signal_connect(G_OBJECT(button_unlocked), "clicked",
gtk_box_pack_start(GTK_BOX(g_vbox0), button_unlocked, FALSE, FALSE, 20); G_CALLBACK(cb_private),
GINT_TO_POINTER(MASK_PRIVATES));
set_tooltip(show_tooltips, glob_tooltips, gtk_box_pack_start(GTK_BOX(g_vbox0), button_locked, FALSE, FALSE, 20);
button_locked, _("Show private records Ctrl+Z"), NULL); gtk_box_pack_start(GTK_BOX(g_vbox0), button_masklocked, FALSE, FALSE, 20);
gtk_widget_add_accelerator(button_locked, "clicked", accel_group, gtk_box_pack_start(GTK_BOX(g_vbox0), button_unlocked, FALSE, FALSE, 20);
GDK_z, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
set_tooltip(show_tooltips,
set_tooltip(show_tooltips, glob_tooltips, button_locked, _("Show private records Ctrl+Z"));
button_masklocked, _("Hide private records Ctrl+Z"), NULL); gtk_widget_add_accelerator(button_locked, "clicked", accel_group,
gtk_widget_add_accelerator(button_masklocked, "clicked", accel_group, GDK_KEY_z, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GDK_z, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
set_tooltip(show_tooltips,
set_tooltip(show_tooltips, glob_tooltips, button_masklocked, _("Hide private records Ctrl+Z"));
button_unlocked, _("Mask private records Ctrl+Z"), NULL); gtk_widget_add_accelerator(button_masklocked, "clicked", accel_group,
gtk_widget_add_accelerator(button_unlocked, "clicked", accel_group, GDK_KEY_z, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GDK_z, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
set_tooltip(show_tooltips,
/* "Sync" button */ button_unlocked, _("Mask private records Ctrl+Z"));
button_sync = gtk_button_new(); gtk_widget_add_accelerator(button_unlocked, "clicked", accel_group,
gtk_signal_connect(GTK_OBJECT(button_sync), "clicked", GDK_KEY_z, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GTK_SIGNAL_FUNC(cb_sync),
GINT_TO_POINTER(skip_plugins ? SYNC_NO_PLUGINS : 0)); /* "Sync" button */
gtk_box_pack_start(GTK_BOX(g_vbox0), button_sync, FALSE, FALSE, 3); button_sync = gtk_button_new();
g_signal_connect(G_OBJECT(button_sync), "clicked",
set_tooltip(show_tooltips, glob_tooltips, G_CALLBACK(cb_sync),
button_sync, _("Sync your palm to the desktop Ctrl+Y"), NULL); GINT_TO_POINTER(skip_plugins ? SYNC_NO_PLUGINS : 0));
gtk_widget_add_accelerator(button_sync, "clicked", accel_group, GDK_y, gtk_box_pack_start(GTK_BOX(g_vbox0), button_sync, FALSE, FALSE, 3);
GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
set_tooltip(show_tooltips,
/* "Cancel Sync" button */ button_sync, _("Sync your palm to the desktop Ctrl+Y"));
button_cancel_sync = gtk_button_new(); gtk_widget_add_accelerator(button_sync, "clicked", accel_group, GDK_KEY_y,
gtk_signal_connect(GTK_OBJECT(button_cancel_sync), "clicked", GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GTK_SIGNAL_FUNC(cb_cancel_sync),
NULL); /* "Cancel Sync" button */
gtk_box_pack_start(GTK_BOX(g_vbox0), button_cancel_sync, FALSE, FALSE, 3); button_cancel_sync = gtk_button_new();
g_signal_connect(G_OBJECT(button_cancel_sync), "clicked",
set_tooltip(show_tooltips, glob_tooltips, G_CALLBACK(cb_cancel_sync),
button_cancel_sync, _("Stop Sync process"), NULL); NULL);
gtk_box_pack_start(GTK_BOX(g_vbox0), button_cancel_sync, FALSE, FALSE, 3);
/* "Backup" button in left column */
button_backup = gtk_button_new(); set_tooltip(show_tooltips,
gtk_signal_connect(GTK_OBJECT(button_backup), "clicked", button_cancel_sync, _("Stop Sync process"));
GTK_SIGNAL_FUNC(cb_sync),
GINT_TO_POINTER /* "Backup" button in left column */
(skip_plugins ? SYNC_NO_PLUGINS | SYNC_FULL_BACKUP button_backup = gtk_button_new();
: SYNC_FULL_BACKUP)); g_signal_connect(G_OBJECT(button_backup), "clicked",
gtk_box_pack_start(GTK_BOX(g_vbox0), button_backup, FALSE, FALSE, 3); G_CALLBACK(cb_sync),
GINT_TO_POINTER
set_tooltip(show_tooltips, glob_tooltips, (skip_plugins ? SYNC_NO_PLUGINS | SYNC_FULL_BACKU
button_backup, _("Sync your palm to the desktop\n" P
"and then do a backup"), NULL); : SYNC_FULL_BACKUP));
gtk_box_pack_start(GTK_BOX(g_vbox0), button_backup, FALSE, FALSE, 3);
/* Separator */
separator = gtk_hseparator_new(); set_tooltip(show_tooltips,
gtk_box_pack_start(GTK_BOX(g_vbox0), separator, FALSE, TRUE, 5); button_backup, _("Sync your palm to the desktop\n"
"and then do a backup"));
/* Creates the 2 main boxes that are changeable */
create_main_boxes(); /* Separator */
separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
gtk_widget_show_all(window); gtk_box_pack_start(GTK_BOX(g_vbox0), separator, FALSE, TRUE, 5);
gtk_widget_show(window);
/* Creates the 2 main boxes that are changeable */
style = gtk_widget_get_style(window); create_main_boxes();
/* Jpilot Icon pixmap */ gtk_widget_show_all(window);
pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, jpilot_ico gtk_widget_show(window);
n4_xpm);
gdk_window_set_icon(window->window, NULL, pixmap, mask); //gtk2 style = gtk_widget_get_style(window);
gdk_window_set_icon_name(window->window, PN);
/* Jpilot Icon pixbuf */
/* Create "Datebook" pixmap */ //pixbuf = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, jpilot_
pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, icon4_xpm);
&style->bg[GTK_STATE_NORMAL], //this method no longer exists in gtk3. X11 handles this anyway.
datebook_xpm); // gdk_window_set_icon(window->window, NULL, pixbuf, mask);
#ifdef __APPLE__ gdk_window_set_icon_name(gtk_widget_get_window(window), PN);
mask = NULL;
#endif /* Create "Datebook" pixbuf */
pixmapwid = gtk_pixmap_new(pixmap, mask); pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) datebook_xpm);
gtk_widget_show(pixmapwid); pixbufwid = gtk_image_new_from_pixbuf(pixbuf);
gtk_container_add(GTK_CONTAINER(button_datebook), pixmapwid); gtk_widget_show(pixbufwid);
gtk_button_set_relief(GTK_BUTTON(button_datebook), GTK_RELIEF_NONE); gtk_container_add(GTK_CONTAINER(button_datebook), pixbufwid);
gtk_button_set_relief(GTK_BUTTON(button_datebook), GTK_RELIEF_NONE);
/* Create "Address" pixmap */
pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, /* Create "Address" pixbuf */
&style->bg[GTK_STATE_NORMAL], pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) address_xpm);
address_xpm); pixbufwid = gtk_image_new_from_pixbuf(pixbuf);
#ifdef __APPLE__ gtk_widget_show(pixbufwid);
mask = NULL; gtk_container_add(GTK_CONTAINER(button_address), pixbufwid);
#endif gtk_button_set_relief(GTK_BUTTON(button_address), GTK_RELIEF_NONE);
pixmapwid = gtk_pixmap_new(pixmap, mask);
gtk_widget_show(pixmapwid); /* Create "Todo" pixbuf */
gtk_container_add(GTK_CONTAINER(button_address), pixmapwid); pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) todo_xpm);
gtk_button_set_relief(GTK_BUTTON(button_address), GTK_RELIEF_NONE); pixbufwid = gtk_image_new_from_pixbuf(pixbuf);
gtk_widget_show(pixbufwid);
/* Create "Todo" pixmap */ gtk_container_add(GTK_CONTAINER(button_todo), pixbufwid);
pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, gtk_button_set_relief(GTK_BUTTON(button_todo), GTK_RELIEF_NONE);
&style->bg[GTK_STATE_NORMAL],
todo_xpm); /* Create "Memo" pixbuf */
#ifdef __APPLE__ pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) memo_xpm);
mask = NULL; pixbufwid = gtk_image_new_from_pixbuf(pixbuf);
#endif gtk_widget_show(pixbufwid);
pixmapwid = gtk_pixmap_new(pixmap, mask); gtk_container_add(GTK_CONTAINER(button_memo), pixbufwid);
gtk_widget_show(pixmapwid); gtk_button_set_relief(GTK_BUTTON(button_memo), GTK_RELIEF_NONE);
gtk_container_add(GTK_CONTAINER(button_todo), pixmapwid);
gtk_button_set_relief(GTK_BUTTON(button_todo), GTK_RELIEF_NONE);
/* Create "Memo" pixmap */
pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask,
&style->bg[GTK_STATE_NORMAL],
memo_xpm);
#ifdef __APPLE__
mask = NULL;
#endif
pixmapwid = gtk_pixmap_new(pixmap, mask);
gtk_widget_show(pixmapwid);
gtk_container_add(GTK_CONTAINER(button_memo), pixmapwid);
gtk_button_set_relief(GTK_BUTTON(button_memo), GTK_RELIEF_NONE);
/* Show locked/unlocked/masked button */ /* Show locked/unlocked/masked button */
#ifdef ENABLE_PRIVATE #ifdef ENABLE_PRIVATE
gtk_widget_show(button_locked); gtk_widget_show(button_locked);
gtk_widget_hide(button_masklocked); gtk_widget_hide(button_masklocked);
gtk_widget_hide(button_unlocked); gtk_widget_hide(button_unlocked);
#else #else
gtk_widget_hide(button_locked); gtk_widget_hide(button_locked);
gtk_widget_hide(button_masklocked); gtk_widget_hide(button_masklocked);
gtk_widget_show(button_unlocked); gtk_widget_show(button_unlocked);
#endif #endif
/* Create "locked" pixmap */ /* Create "locked" pixbuf */
pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) locked_xpm);
&style->bg[GTK_STATE_NORMAL], pixbufwid = gtk_image_new_from_pixbuf(pixbuf);
locked_xpm); gtk_widget_show(pixbufwid);
#ifdef __APPLE__ gtk_container_add(GTK_CONTAINER(button_locked), pixbufwid);
mask = NULL;
#endif /* Create "masked" pixbuf */
pixmapwid = gtk_pixmap_new(pixmap, mask); pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) masklocked_xpm);
gtk_widget_show(pixmapwid); pixbufwid = gtk_image_new_from_pixbuf(pixbuf);
gtk_container_add(GTK_CONTAINER(button_locked), pixmapwid); gtk_widget_show(pixbufwid);
gtk_container_add(GTK_CONTAINER(button_masklocked), pixbufwid);
/* Create "masked" pixmap */
pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, /* Create "unlocked" pixbuf */
&style->bg[GTK_STATE_NORMAL], pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) unlocked_xpm);
masklocked_xpm); pixbufwid = gtk_image_new_from_pixbuf(pixbuf);
#ifdef __APPLE__ gtk_widget_show(pixbufwid);
mask = NULL; gtk_container_add(GTK_CONTAINER(button_unlocked), pixbufwid);
#endif
pixmapwid = gtk_pixmap_new(pixmap, mask); /* Create "sync" pixbuf */
gtk_widget_show(pixmapwid); pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) sync_xpm);
gtk_container_add(GTK_CONTAINER(button_masklocked), pixmapwid); pixbufwid = gtk_image_new_from_pixbuf(pixbuf);
gtk_widget_show(pixbufwid);
/* Create "unlocked" pixmap */ gtk_container_add(GTK_CONTAINER(button_sync), pixbufwid);
pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask,
&style->bg[GTK_STATE_NORMAL], /* Create "cancel sync" pixbuf */
unlocked_xpm); /* Hide until sync process started */
#ifdef __APPLE__ gtk_widget_hide(button_cancel_sync);
mask = NULL; pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) cancel_sync_xpm);
#endif pixbufwid = gtk_image_new_from_pixbuf(pixbuf);
pixmapwid = gtk_pixmap_new(pixmap, mask); gtk_widget_show(pixbufwid);
gtk_widget_show(pixmapwid); gtk_container_add(GTK_CONTAINER(button_cancel_sync), pixbufwid);
gtk_container_add(GTK_CONTAINER(button_unlocked), pixmapwid);
/* Create "backup" pixbuf */
/* Create "sync" pixmap */ gtk_widget_hide(button_cancel_sync);
pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) backup_xpm);
&style->bg[GTK_STATE_NORMAL], pixbufwid = gtk_image_new_from_pixbuf(pixbuf);
sync_xpm); gtk_widget_show(pixbufwid);
#ifdef __APPLE__ gtk_container_add(GTK_CONTAINER(button_backup), pixbufwid);
mask = NULL;
#endif set_tooltip(show_tooltips, button_datebook, _("Datebook/Go to Today"));
pixmapwid = gtk_pixmap_new(pixmap, mask); set_tooltip(show_tooltips, button_address, _("Address Book"));
gtk_widget_show(pixmapwid); set_tooltip(show_tooltips, button_todo, _("ToDo List"));
gtk_container_add(GTK_CONTAINER(button_sync), pixmapwid); set_tooltip(show_tooltips, button_memo, _("Memo Pad"));
/* Create "cancel sync" pixmap */ /* Set a callback for our pipe from the sync child process */
/* Hide until sync process started */ GIOChannel *channel = g_io_channel_unix_new(pipe_from_child);
gtk_widget_hide(button_cancel_sync); g_io_add_watch(channel,
pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, G_IO_IN | G_IO_HUP | G_IO_ERR,
&style->bg[GTK_STATE_NORMAL], cb_read_pipe_from_child,
cancel_sync_xpm); window);
#ifdef __APPLE__
mask = NULL; //gtk2 gdk_input_add(pipe_from_child, GDK_INPUT_READ, cb_read_pipe_from_chil
#endif d, window);
pixmapwid = gtk_pixmap_new(pixmap, mask);
gtk_widget_show(pixmapwid); get_pref(PREF_LAST_APP, &ivalue, NULL);
gtk_container_add(GTK_CONTAINER(button_cancel_sync), pixmapwid); /* We don't want to start up to a plugin because the plugin might
* repeatedly segfault. Of course main apps can do that, but since I
/* Create "backup" pixmap */ * handle the email support... */
pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, if ((ivalue == ADDRESS) ||
&style->bg[GTK_STATE_NORMAL], (ivalue == DATEBOOK) ||
backup_xpm); (ivalue == TODO) ||
#ifdef __APPLE__ (ivalue == MEMO)) {
mask = NULL; cb_app_button(NULL, GINT_TO_POINTER(ivalue));
#endif }
pixmapwid = gtk_pixmap_new(pixmap, mask);
gtk_widget_show(pixmapwid); /* Set the pane size */
gtk_container_add(GTK_CONTAINER(button_backup), pixmapwid); height = 0;
// width = gdk_window_get_width(gtk_widget_get_window(window));
set_tooltip(show_tooltips, glob_tooltips, button_datebook, _("Datebook/Go to height = gdk_window_get_height(gtk_widget_get_window(window));
Today"), NULL); gtk_paned_set_position(GTK_PANED(output_pane), height);
set_tooltip(show_tooltips, glob_tooltips, button_address, _("Address Book"),
NULL); alarms_init(skip_past_alarms, skip_all_alarms);
set_tooltip(show_tooltips, glob_tooltips, button_todo, _("ToDo List"), NULL);
set_tooltip(show_tooltips, glob_tooltips, button_memo, _("Memo Pad"), NULL); /* In-line code to switch user to UTF-8 encoding.
* Should probably be made a subroutine */
/* Set a callback for our pipe from the sync child process */ {
gdk_input_add(pipe_from_child, GDK_INPUT_READ, cb_read_pipe_from_child, windo long utf_encoding;
w); char *button_text[] =
{N_("Do it now"), N_("Remind me later"), N_("Don't tell me again
get_pref(PREF_LAST_APP, &ivalue, NULL); !")};
/* We don't want to start up to a plugin because the plugin might
* repeatedly segfault. Of course main apps can do that, but since I /* check if a UTF-8 one is used */
* handle the email support... */ if (char_set >= CHAR_SET_UTF)
if ((ivalue==ADDRESS) || set_pref(PREF_UTF_ENCODING, 1, NULL, TRUE);
(ivalue==DATEBOOK) ||
(ivalue==TODO) || get_pref(PREF_UTF_ENCODING, &utf_encoding, NULL);
(ivalue==MEMO)) { if (0 == utf_encoding) {
cb_app_button(NULL, GINT_TO_POINTER(ivalue)); /* user has not switched to UTF */
} int ret;
char text[1000];
/* Set the pane size */
width = height = 0; g_snprintf(text, sizeof(text),
gdk_window_get_size(window->window, &width, &height); _("J-Pilot uses the GTK2 graphical toolkit. "
gtk_paned_set_position(GTK_PANED(output_pane), height); "This version of the toolkit uses UTF-8 to encode chara
cters.\n"
alarms_init(skip_past_alarms, skip_all_alarms); "You should select a UTF-8 charset so that you can see
non-ASCII characters (accents for example).\n"
/* In-line code to switch user to UTF-8 encoding. "\n"
* Should probably be made a subroutine */ /* Coded to reuse existing i18n strings */
{ "Go to the menu \"%s\" and change the \"%s\"."), _("/Fi
long utf_encoding; le/Preferences"), _("Character Set"));
char *button_text[] = ret = dialog_generic(GTK_WINDOW(window),
{ N_("Do it now"), N_("Remind me later"), N_("Don't tell me again!") }; _("Select a UTF-8 encoding"), DIALOG_QUESTION,
text, 3, button_text);
/* check if a UTF-8 one is used */
if (char_set >= CHAR_SET_UTF) switch (ret) {
set_pref(PREF_UTF_ENCODING, 1, NULL, TRUE); case DIALOG_SAID_1:
cb_prefs_gui(NULL, window);
get_pref(PREF_UTF_ENCODING, &utf_encoding, NULL); break;
if (0 == utf_encoding) { case DIALOG_SAID_2:
/* user has not switched to UTF */ /* Do nothing and remind user at next program invocation */
int ret; break;
char text[1000]; case DIALOG_SAID_3:
set_pref(PREF_UTF_ENCODING, 1, NULL, TRUE);
g_snprintf(text, sizeof(text), break;
_("J-Pilot uses the GTK2 graphical toolkit. " }
"This version of the toolkit uses UTF-8 to encode characters.\n" }
"You should select a UTF-8 charset so that you can see non-ASCII char }
acters (accents for example).\n"
"\n"
/* Coded to reuse existing i18n strings */
"Go to the menu \"%s\" and change the \"%s\"."), _("/File/Preferences
"), _("Character Set"));
ret = dialog_generic(GTK_WINDOW(window),
_("Select a UTF-8 encoding"), DIALOG_QUESTION, text, 3, button_text)
;
switch (ret) {
case DIALOG_SAID_1:
cb_prefs_gui(NULL, window);
break;
case DIALOG_SAID_2:
/* Do nothing and remind user at next program invocation */
break;
case DIALOG_SAID_3:
set_pref(PREF_UTF_ENCODING, 1, NULL, TRUE);
break;
}
}
}
gtk_idle_add(cb_check_version, window); g_idle_add(cb_check_version, window);
gtk_main(); gtk_main();
otherconv_free(); otherconv_free();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
 End of changes. 182 change blocks. 
1883 lines changed or deleted 1816 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)