"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "monthview_gui.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.

monthview_gui.c  (jpilot-1.8.2):monthview_gui.c  (jpilot-2_0_1)
skipping to change at line 42 skipping to change at line 42
#include "prefs.h" #include "prefs.h"
#include "log.h" #include "log.h"
#include "datebook.h" #include "datebook.h"
#include "calendar.h" #include "calendar.h"
#include "print.h" #include "print.h"
#include "jpilot.h" #include "jpilot.h"
/******************************* Global vars **********************************/ /******************************* Global vars **********************************/
extern int datebk_category; extern int datebk_category;
extern int glob_app; extern int glob_app;
extern GtkTooltips *glob_tooltips;
GtkWidget *monthview_window=NULL; GtkWidget *monthview_window=NULL;
static GtkWidget *month_day_label[37]; static char glob_str_dow[7][32];
static GtkWidget *month_day[37];
static GObject *month_day_buffer[37];
static GObject *all_appts_buffer; static GObject *all_appts_buffer;
static GtkWidget *month_month_label; static GtkWidget *month_month_label;
static GtkWidget *glob_last_hbox_row;
static int glob_offset; static int glob_offset;
static struct tm glob_month_date; static struct tm glob_month_date;
/*
* The calendar display is 6 rows and 7 columns
* and contains this data.
*/
typedef struct {
GtkWidget *label;
GtkWidget *tv;
GObject *buffer;
} c_day;
static c_day glob_days[42];
/****************************** Prototypes ************************************/ /****************************** Prototypes ************************************/
static int display_months_appts(struct tm *glob_month_date, GtkWidget **glob_mon static int display_months_appts(struct tm *glob_month_date);
th_texts); static void set_day_labels(void);
static void hide_show_month_boxes(void);
/****************************** Main Code *************************************/ /****************************** Main Code *************************************/
static gboolean cb_destroy(GtkWidget *widget) static gboolean cb_destroy(GtkWidget *widget)
{ {
int n; int n;
GString *gstr; GString *gstr;
GtkWidget *text; GtkWidget *text;
/* FIXME: Do we need to do free buffers? If so do for all_appts_buffer; */
monthview_window = NULL; monthview_window = NULL;
for (n=0; n<37; n++) { for (n=0; n<4; n++) {
text = month_day[n]; text = glob_days[n].tv;
gstr = gtk_object_get_data(GTK_OBJECT(text), "gstr"); gstr = g_object_get_data(G_OBJECT(text), "gstr");
if (gstr) { if (gstr) {
g_string_free(gstr, TRUE); g_string_free(gstr, TRUE);
gtk_object_remove_data(GTK_OBJECT(text), "gstr"); g_object_set_data(G_OBJECT(text), "gstr", NULL);
} }
} }
return FALSE; return FALSE;
} }
void cb_monthview_quit(GtkWidget *widget, gpointer data) void cb_monthview_quit(GtkWidget *widget, gpointer data)
{ {
int w, h; int w, h;
gdk_window_get_size(monthview_window->window, &w, &h); w = gdk_window_get_width(gtk_widget_get_window(monthview_window));
h = gdk_window_get_height(gtk_widget_get_window(monthview_window));
set_pref(PREF_MONTHVIEW_WIDTH, w, NULL, FALSE); set_pref(PREF_MONTHVIEW_WIDTH, w, NULL, FALSE);
set_pref(PREF_MONTHVIEW_HEIGHT, h, NULL, FALSE); set_pref(PREF_MONTHVIEW_HEIGHT, h, NULL, FALSE);
gtk_widget_destroy(monthview_window); gtk_widget_destroy(monthview_window);
} }
static void cb_month_move(GtkWidget *widget, gpointer data) static void cb_month_move(GtkWidget *widget, gpointer data)
{ {
if (GPOINTER_TO_INT(data)==-1) { if (GPOINTER_TO_INT(data)==-1) {
glob_month_date.tm_mday=15; glob_month_date.tm_mday=15;
sub_days_from_date(&glob_month_date, 30); sub_days_from_date(&glob_month_date, 30);
} }
if (GPOINTER_TO_INT(data)==1) { if (GPOINTER_TO_INT(data)==1) {
glob_month_date.tm_mday=15; glob_month_date.tm_mday=15;
add_days_to_date(&glob_month_date, 30); add_days_to_date(&glob_month_date, 30);
} }
hide_show_month_boxes(); set_day_labels();
display_months_appts(&glob_month_date, month_day); display_months_appts(&glob_month_date);
} }
static void cb_month_print(GtkWidget *widget, gpointer data) static void cb_month_print(GtkWidget *widget, gpointer data)
{ {
long paper_size; long paper_size;
jp_logf(JP_LOG_DEBUG, "cb_month_print called\n"); jp_logf(JP_LOG_DEBUG, "cb_month_print called\n");
if (print_gui(monthview_window, DATEBOOK, 3, 0x04) == DIALOG_SAID_PRINT) { if (print_gui(monthview_window, DATEBOOK, 3, 0x04) == DIALOG_SAID_PRINT) {
get_pref(PREF_PAPER_SIZE, &paper_size, NULL); get_pref(PREF_PAPER_SIZE, &paper_size, NULL);
if (paper_size==1) { if (paper_size==1) {
skipping to change at line 130 skipping to change at line 140
static int prev_day=-1; static int prev_day=-1;
GtkWidget *textview; GtkWidget *textview;
GString *gstr; GString *gstr;
if (prev_day==GPOINTER_TO_INT(data)+1-glob_offset) { if (prev_day==GPOINTER_TO_INT(data)+1-glob_offset) {
return; return;
} }
prev_day = GPOINTER_TO_INT(data)+1-glob_offset; prev_day = GPOINTER_TO_INT(data)+1-glob_offset;
textview = gtk_bin_get_child(GTK_BIN(widget)); textview = gtk_bin_get_child(GTK_BIN(widget));
gstr = gtk_object_get_data(GTK_OBJECT(textview), "gstr"); gstr = g_object_get_data(G_OBJECT(textview), "gstr");
if (gstr) { if (gstr) {
gtk_text_buffer_set_text(GTK_TEXT_BUFFER(all_appts_buffer), gstr->str, -1) ; gtk_text_buffer_set_text(GTK_TEXT_BUFFER(all_appts_buffer), gstr->str, -1) ;
} else { } else {
gtk_text_buffer_set_text(GTK_TEXT_BUFFER(all_appts_buffer), "", -1); gtk_text_buffer_set_text(GTK_TEXT_BUFFER(all_appts_buffer), "", -1);
} }
} }
/* Called when a day is clicked on in the month view */ /* Called when a day is clicked on in the month view */
static void cb_enter_selected_day(GtkWidget *widget, static void cb_enter_selected_day(GtkWidget *widget,
GdkEvent *event, GdkEvent *event,
skipping to change at line 153 skipping to change at line 163
int day = GPOINTER_TO_INT(data) + 1 - glob_offset; int day = GPOINTER_TO_INT(data) + 1 - glob_offset;
if (glob_app != DATEBOOK) if (glob_app != DATEBOOK)
return; return;
/* Redisplay the day view based on the date the user clicked on */ /* Redisplay the day view based on the date the user clicked on */
datebook_gui_setdate(glob_month_date.tm_year, glob_month_date.tm_mon, day); datebook_gui_setdate(glob_month_date.tm_year, glob_month_date.tm_mon, day);
} }
/* /*
* Hide, or show month boxes (days) according to the month. * Relabel shown day labels according to the month.
* Also, set a global offset for indexing day 1. * Also, set a global offset for indexing day 1.
* Also relabel day labels.
*/ */
static void hide_show_month_boxes(void) static void set_day_labels(void)
{ {
int n; int n;
int dow, ndim; int dow, ndim;
int now_today; int now_today;
long fdow; long fdow;
char str[40]; char str[64];
int d; int d;
GtkWidget *text; GtkWidget *text;
char *markup_str; char *markup_str;
/* Determine today for highlighting */ /* Determine today for highlighting */
now_today = get_highlighted_today(&glob_month_date); now_today = get_highlighted_today(&glob_month_date);
get_month_info(glob_month_date.tm_mon, 1, glob_month_date.tm_year, &dow, &ndi m); get_month_info(glob_month_date.tm_mon, 1, glob_month_date.tm_year, &dow, &ndi m);
get_pref(PREF_FDOW, &fdow, NULL); get_pref(PREF_FDOW, &fdow, NULL);
glob_offset = (7+dow-fdow)%7; glob_offset = (7+dow-fdow)%7;
d = 1 - glob_offset; d = 1 - glob_offset;
if (glob_offset + ndim > 35) { for (n=0; n<42; n++, d++) {
gtk_widget_show(GTK_WIDGET(glob_last_hbox_row)); text = glob_days[n].tv;
} else { /* Clear the calendar day entry */
gtk_widget_hide(GTK_WIDGET(glob_last_hbox_row)); gtk_text_buffer_set_text(GTK_TEXT_BUFFER(glob_days[n].buffer), "", -1);
} if ((d<1) || (d>ndim)) {
str[0]='\0';
for (n=0; n<37; n++, d++) { gtk_widget_set_sensitive(glob_days[n].tv, FALSE);
text = month_day[n]; } else {
g_snprintf(str, sizeof(str), "%d", d); snprintf(str, sizeof(str), "%d - %s", d, glob_str_dow[n%7]);
str[sizeof(str)-1]='\0';
gtk_widget_set_sensitive(glob_days[n].tv, TRUE);
}
if (d == now_today) if (d == now_today)
{ {
/* Make today's text bold */
markup_str = g_markup_printf_escaped("<b>%s</b>", str); markup_str = g_markup_printf_escaped("<b>%s</b>", str);
gtk_widget_set_name(text, "today"); gtk_widget_set_name(text, "today");
} else { } else {
markup_str = g_markup_printf_escaped("%s", str); markup_str = g_markup_printf_escaped("%s", str);
gtk_widget_set_name(text, ""); gtk_widget_set_name(text, "");
} }
gtk_label_set_markup(GTK_LABEL(month_day_label[n]), markup_str); gtk_label_set_markup(GTK_LABEL(glob_days[n].label), markup_str);
g_free(markup_str); g_free(markup_str);
if (n<7) {
if (d>0) {
gtk_widget_show(GTK_WIDGET(text));
gtk_widget_show(GTK_WIDGET(month_day_label[n]));
} else {
gtk_widget_hide(GTK_WIDGET(text));
gtk_widget_hide(GTK_WIDGET(month_day_label[n]));
}
}
if (n>27) {
if (d<=ndim) {
gtk_widget_show(GTK_WIDGET(text));
gtk_widget_show(GTK_WIDGET(month_day_label[n]));
} else {
gtk_widget_hide(GTK_WIDGET(text));
gtk_widget_hide(GTK_WIDGET(month_day_label[n]));
}
}
} }
} }
static void create_month_boxes_texts(GtkWidget *month_vbox) static void create_month_boxes_texts(GtkWidget *grid)
{ {
int i, j, n; int x, y;
GtkWidget *hbox_row; int count;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *text; GtkWidget *tv;
GtkWidget *event_box; GtkWidget *label;
char str[80]; GtkWidget *event_box;
n=0; count = 0;
for (i=0; i<6; i++) { /* 6 Rows of 7 days for a month */
hbox_row = gtk_hbox_new(TRUE, 0); for (y=0; y<6; y++) {
gtk_box_pack_start(GTK_BOX(month_vbox), hbox_row, TRUE, TRUE, 0); for (x=0; x<7; x++, count++) {
for (j=0; j<7; j++) {
vbox = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox_row), vbox, TRUE, TRUE, 2);
n=i*7+j;
if (n<37) {
sprintf(str, "%d", n + 1);
/* Day of month labels */ /* Day of month labels */
month_day_label[n] = gtk_label_new(str); /* label variable only used to save some typing */
gtk_misc_set_alignment(GTK_MISC(month_day_label[n]), 0.0, 0.5); label = glob_days[count].label = gtk_label_new("");
gtk_box_pack_start(GTK_BOX(vbox), month_day_label[n], FALSE, FALSE, gtk_widget_set_halign(GTK_WIDGET(label), GTK_ALIGN_START);
0); vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(vbox), x, y, 1, 1);
/* text variable only used to save some typing */ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
text = month_day[n] = gtk_text_view_new();
month_day_buffer[n] = /* tv variable only used to save some typing */
G_OBJECT(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text))); tv = glob_days[count].tv = gtk_text_view_new();
gtk_widget_set_usize(GTK_WIDGET(text), 10, 10); glob_days[count].buffer = G_OBJECT(gtk_text_view_get_buffer(GTK_TEXT
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE); _VIEW(tv)));
gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); gtk_widget_set_halign(tv, GTK_ALIGN_FILL);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); gtk_widget_set_valign(tv, GTK_ALIGN_FILL);
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(tv), FALSE);
gtk_text_view_set_editable(GTK_TEXT_VIEW(tv), FALSE);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tv), GTK_WRAP_CHAR);
/* textview widget does not support window events such as /* textview widget does not support window events such as
* enter_notify. The widget must be wrapped in an event box * enter_notify. The widget must be wrapped in an event box
* in order to work correctly. */ * in order to work correctly. */
event_box = gtk_event_box_new(); event_box = gtk_event_box_new();
gtk_container_add(GTK_CONTAINER(event_box), text); gtk_widget_set_halign(event_box, GTK_ALIGN_FILL);
gtk_widget_set_valign(event_box, GTK_ALIGN_FILL);
gtk_signal_connect(GTK_OBJECT(event_box), "enter_notify_event",
GTK_SIGNAL_FUNC(cb_enter_notify), GINT_TO_POINTER
(n));
gtk_signal_connect(GTK_OBJECT(text), "button_release_event",
GTK_SIGNAL_FUNC(cb_enter_selected_day),
GINT_TO_POINTER(n));
gtk_box_pack_start(GTK_BOX(vbox), event_box, TRUE, TRUE, 0); /* Use a scrolled window to keep the main window from expanding */
GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
} gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_PO
} LICY_NEVER, GTK_POLICY_AUTOMATIC);
}
glob_last_hbox_row = hbox_row; gtk_container_add(GTK_CONTAINER(scrolled), tv);
text = gtk_text_view_new(); gtk_container_add(GTK_CONTAINER(event_box), scrolled);
all_appts_buffer = G_OBJECT(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)));
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE); g_signal_connect(G_OBJECT(event_box), "enter_notify_event",
gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); G_CALLBACK(cb_enter_notify), GINT_TO_POINTER(count)
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); );
gtk_widget_set_usize(GTK_WIDGET(text), 10, 10); g_signal_connect(G_OBJECT(tv), "button_release_event",
gtk_box_pack_start(GTK_BOX(month_vbox), text, TRUE, TRUE, 4); G_CALLBACK(cb_enter_selected_day),
GINT_TO_POINTER(count));
gtk_box_pack_start(GTK_BOX(vbox), event_box, TRUE, TRUE, 2);
}
}
/* Draw the text viewer at the botton */
tv = gtk_text_view_new();
all_appts_buffer = G_OBJECT(gtk_text_view_get_buffer(GTK_TEXT_VIEW(tv)));
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(tv), FALSE);
gtk_text_view_set_editable(GTK_TEXT_VIEW(tv), FALSE);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tv), GTK_WRAP_WORD);
gtk_widget_set_size_request(GTK_WIDGET(tv), 10, 10);
gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(tv), 0, y, 7, 1);
} }
static int display_months_appts(struct tm *date_in, GtkWidget **day_texts) static int display_months_appts(struct tm *date_in)
{ {
CalendarEventList *ce_list; CalendarEventList *ce_list;
CalendarEventList *temp_cel; CalendarEventList *temp_cel;
struct tm date; struct tm date;
GtkWidget **texts;
GObject **text_buffers;
char desc[100]; char desc[100];
char datef[20]; char datef[20];
char str[80]; char str[64];
int dow; int dow;
int ndim; int ndim;
int n; int n;
int mask; int mask;
int num_shown; int num_shown;
#ifdef ENABLE_DATEBK #ifdef ENABLE_DATEBK
int ret; int ret;
int cat_bit; int cat_bit;
int db3_type; int db3_type;
long use_db3_tags; long use_db3_tags;
struct db4_struct db4; struct db4_struct db4;
#endif #endif
GString *gstr; GString *gstr;
GtkWidget *temp_text; GtkWidget *temp_text;
long datebook_version; long datebook_version;
texts = &day_texts[glob_offset];
text_buffers = &month_day_buffer[glob_offset];
ce_list = NULL; ce_list = NULL;
mask=0; mask=0;
get_pref(PREF_DATEBOOK_VERSION, &datebook_version, NULL); get_pref(PREF_DATEBOOK_VERSION, &datebook_version, NULL);
for (n=0; n<37; n++) { /* Clear all of the boxes */
temp_text = month_day[n]; for (n=0; n<42; n++) {
gstr = gtk_object_get_data(GTK_OBJECT(temp_text), "gstr"); temp_text = glob_days[n].tv;
gstr = g_object_get_data(G_OBJECT(temp_text), "gstr");
if (gstr) { if (gstr) {
g_string_free(gstr, TRUE); g_string_free(gstr, TRUE);
gtk_object_remove_data(GTK_OBJECT(temp_text), "gstr"); g_object_set_data(G_OBJECT(temp_text), "gstr", NULL);
} }
} }
/* Set Month name label */ /* Set month name label */
jp_strftime(str, sizeof(str), "%B %Y", date_in); jp_strftime(str, sizeof(str), "%B %Y", date_in);
gtk_label_set_text(GTK_LABEL(month_month_label), str); gtk_label_set_text(GTK_LABEL(month_month_label), str);
memcpy(&date, date_in, sizeof(struct tm)); memcpy(&date, date_in, sizeof(struct tm));
/* Get all of the appointments */ /* Get all of the appointments */
get_days_calendar_events2(&ce_list, NULL, 2, 2, 2, CATEGORY_ALL, NULL); get_days_calendar_events2(&ce_list, NULL, 2, 2, 2, CATEGORY_ALL, NULL);
get_month_info(date.tm_mon, 1, date.tm_year, &dow, &ndim); get_month_info(date.tm_mon, 1, date.tm_year, &dow, &ndim);
weed_calendar_event_list(&ce_list, date.tm_mon, date.tm_year, 0, &mask); weed_calendar_event_list(&ce_list, date.tm_mon, date.tm_year, 0, &mask);
for (n=0, date.tm_mday=1; date.tm_mday<=ndim; date.tm_mday++, n++) { /* Cycle through every day in the selected month, starting at dow (day of wee
k) for the first day */
for (n=dow, date.tm_mday=1; date.tm_mday<=ndim; date.tm_mday++, n++) {
gstr=NULL; gstr=NULL;
date.tm_sec=0; date.tm_sec=0;
date.tm_min=0; date.tm_min=0;
date.tm_hour=11; date.tm_hour=11;
date.tm_isdst=-1; date.tm_isdst=-1;
date.tm_wday=0; date.tm_wday=0;
date.tm_yday=1; date.tm_yday=1;
mktime(&date); mktime(&date);
gtk_text_buffer_set_text(GTK_TEXT_BUFFER(text_buffers[n]), "", -1); /* Clear all of the text buffers */
gtk_text_buffer_set_text(GTK_TEXT_BUFFER(glob_days[n].buffer), "", -1);
num_shown = 0; num_shown = 0;
for (temp_cel = ce_list; temp_cel; temp_cel=temp_cel->next) { for (temp_cel = ce_list; temp_cel; temp_cel=temp_cel->next) {
#ifdef ENABLE_DATEBK #ifdef ENABLE_DATEBK
get_pref(PREF_USE_DB3, &use_db3_tags, NULL); get_pref(PREF_USE_DB3, &use_db3_tags, NULL);
if (use_db3_tags) { if (use_db3_tags) {
ret = db3_parse_tag(temp_cel->mcale.cale.note, &db3_type, &db4); ret = db3_parse_tag(temp_cel->mcale.cale.note, &db3_type, &db4);
jp_logf(JP_LOG_DEBUG, "category = 0x%x\n", db4.category); jp_logf(JP_LOG_DEBUG, "category = 0x%x\n, ret=%d", db4.category, ret );
cat_bit=1<<db4.category; cat_bit=1<<db4.category;
if (!(cat_bit & datebk_category)) { if (!(cat_bit & datebk_category)) {
jp_logf(JP_LOG_DEBUG, "skipping rec not in this category\n"); jp_logf(JP_LOG_DEBUG, "skipping rec not in this category\n");
continue; continue;
} }
} }
#endif #endif
if (calendar_isApptOnDate(&(temp_cel->mcale.cale), &date)) { if (calendar_isApptOnDate(&(temp_cel->mcale.cale), &date)) {
if (num_shown) { if (num_shown) {
gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(text_buffers[n]) /* Set each text buffer */
, "\n", -1); gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(glob_days[n].buf
fer), "\n", -1);
g_string_append(gstr, "\n"); g_string_append(gstr, "\n");
} else { } else {
gstr=g_string_new(""); gstr=g_string_new("");
} }
num_shown++; num_shown++;
if (temp_cel->mcale.cale.event) { if (temp_cel->mcale.cale.event) {
strcpy(desc, "*"); strcpy(desc, "*");
} else { } else {
get_pref_time_no_secs(datef); get_pref_time_no_secs(datef);
jp_strftime(desc, sizeof(desc), datef, &(temp_cel->mcale.cale.beg in)); jp_strftime(desc, sizeof(desc), datef, &(temp_cel->mcale.cale.beg in));
skipping to change at line 394 skipping to change at line 391
/* FIXME: This kind of truncation is bad for UTF-8 */ /* FIXME: This kind of truncation is bad for UTF-8 */
desc[35]='\0'; desc[35]='\0';
} }
/* FIXME: Add location in parentheses (loc) as the Palm does. /* FIXME: Add location in parentheses (loc) as the Palm does.
* We would need to check strlen, etc., before adding */ * We would need to check strlen, etc., before adding */
remove_cr_lfs(desc); remove_cr_lfs(desc);
/* Append number of anniversary years if enabled & appropriate */ /* Append number of anniversary years if enabled & appropriate */
append_anni_years(desc, 35, &date, NULL, &temp_cel->mcale.cale); append_anni_years(desc, 35, &date, NULL, &temp_cel->mcale.cale);
gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(text_buffers[n]), d esc, -1); gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(glob_days[n].buffer ), desc, -1);
} }
} }
gtk_object_set_data(GTK_OBJECT(texts[n]), "gstr", gstr); g_object_set_data(G_OBJECT(glob_days[n].tv), "gstr", gstr);
} }
free_CalendarEventList(&ce_list); free_CalendarEventList(&ce_list);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
void monthview_gui(struct tm *date_in) void monthview_gui(struct tm *date_in)
{ {
struct tm date; struct tm date;
GtkWidget *label; GtkWidget *grid1;
GtkWidget *grid2;
GtkWidget *button; GtkWidget *button;
GtkWidget *align;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *hbox_temp;
GtkAccelGroup *accel_group; GtkAccelGroup *accel_group;
int i; int i;
char str[256]; char str[64];
char str_dow[256];
long fdow; long fdow;
char title[200]; char title[200];
long w, h, show_tooltips; long w, h, show_tooltips;
if (monthview_window) { if (monthview_window) {
/* Delete any existing window to ensure that new window is biased /* Delete any existing window to ensure that new window is biased
* around currently selected date and so that the new window * around currently selected date and so that the new window
* contents are updated with any changes on the day view. */ * contents are updated with any changes on the day view. */
gtk_widget_destroy(monthview_window); gtk_widget_destroy(monthview_window);
} }
skipping to change at line 447 skipping to change at line 441
monthview_window = gtk_widget_new(GTK_TYPE_WINDOW, monthview_window = gtk_widget_new(GTK_TYPE_WINDOW,
"type", GTK_WINDOW_TOPLEVEL, "type", GTK_WINDOW_TOPLEVEL,
"title", title, "title", title,
NULL); NULL);
gtk_window_set_default_size(GTK_WINDOW(monthview_window), w, h); gtk_window_set_default_size(GTK_WINDOW(monthview_window), w, h);
gtk_container_set_border_width(GTK_CONTAINER(monthview_window), 10); gtk_container_set_border_width(GTK_CONTAINER(monthview_window), 10);
gtk_signal_connect(GTK_OBJECT(monthview_window), "destroy", g_signal_connect(G_OBJECT(monthview_window), "destroy",
GTK_SIGNAL_FUNC(cb_destroy), monthview_window); G_CALLBACK(cb_destroy), monthview_window);
/* Use a grid instead of boxes */
grid1 = gtk_grid_new();
gtk_grid_set_row_spacing(GTK_GRID(grid1), 5);
gtk_grid_set_column_spacing(GTK_GRID(grid1), 5);
grid2 = gtk_grid_new();
gtk_grid_set_row_spacing(GTK_GRID(grid2), 5);
gtk_grid_set_column_spacing(GTK_GRID(grid2), 5);
gtk_grid_set_row_homogeneous(GTK_GRID(grid2), TRUE);
gtk_grid_set_column_homogeneous(GTK_GRID(grid2), TRUE);
gtk_widget_set_halign(grid2, GTK_ALIGN_FILL);
gtk_widget_set_valign(grid2, GTK_ALIGN_FILL);
gtk_widget_set_hexpand(grid2, TRUE);
gtk_widget_set_vexpand(grid2, TRUE);
vbox = gtk_vbox_new(FALSE, 0); vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add(GTK_CONTAINER(monthview_window), vbox); gtk_container_add(GTK_CONTAINER(monthview_window), vbox);
gtk_box_pack_start(GTK_BOX(vbox), grid1, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), grid2, TRUE, TRUE, 0);
/* Make accelerators for some buttons window */ /* Make accelerators for some buttons window */
accel_group = gtk_accel_group_new(); accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(gtk_widget_get_toplevel(vbox)), accel_g roup); gtk_window_add_accel_group(GTK_WINDOW(gtk_widget_get_toplevel(vbox)), accel_g roup);
/* This box has the close button and arrows in it */
align = gtk_alignment_new(0.5, 0.5, 0, 0);
gtk_box_pack_start(GTK_BOX(vbox), align, FALSE, FALSE, 0);
hbox_temp = gtk_hbutton_box_new();
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbox_temp), 6);
gtk_container_set_border_width(GTK_CONTAINER(hbox_temp), 6);
gtk_container_add(GTK_CONTAINER(align), hbox_temp);
/* Make a left arrow for going back a week */ /* Make a left arrow for going back a week */
button = gtk_button_new_from_stock(GTK_STOCK_GO_BACK); button = gtk_button_new_with_label("Back");
gtk_signal_connect(GTK_OBJECT(button), "clicked", g_signal_connect(G_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(cb_month_move), G_CALLBACK(cb_month_move),
GINT_TO_POINTER(-1)); GINT_TO_POINTER(-1));
gtk_box_pack_start(GTK_BOX(hbox_temp), button, FALSE, FALSE, 3); gtk_grid_attach(GTK_GRID(grid1), GTK_WIDGET(button), 0, 0, 1, 1);
/* Accelerator key for left arrow */ /* Accelerator key for left arrow */
gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel_group, gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel_group,
GDK_Left, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); GDK_KEY_Left, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE);
set_tooltip(show_tooltips, glob_tooltips, set_tooltip(show_tooltips, button, _("Last month Alt+LeftArrow"));
button, _("Last month Alt+LeftArrow"), NULL);
/* Close button */ /* Close button */
button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); button = gtk_button_new_with_label("Close");
gtk_signal_connect(GTK_OBJECT(button), "clicked", g_signal_connect(G_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(cb_monthview_quit), monthview_window); G_CALLBACK(cb_monthview_quit), monthview_window);
/* Closing the window via a delete event uses the same cleanup routine */ /* Closing the window via a delete event uses the same cleanup routine */
gtk_signal_connect(GTK_OBJECT(monthview_window), "delete_event", g_signal_connect(G_OBJECT(monthview_window), "delete_event",
GTK_SIGNAL_FUNC(cb_monthview_quit), NULL); G_CALLBACK(cb_monthview_quit), NULL);
gtk_box_pack_start(GTK_BOX(hbox_temp), button, FALSE, FALSE, 0); gtk_grid_attach(GTK_GRID(grid1), GTK_WIDGET(button), 1, 0, 1, 1);
/* Print button */ /* Print button */
button = gtk_button_new_from_stock(GTK_STOCK_PRINT); button = gtk_button_new_with_label("Print");
gtk_signal_connect(GTK_OBJECT(button), "clicked", g_signal_connect(G_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(cb_month_print), monthview_window); G_CALLBACK(cb_month_print), monthview_window);
gtk_box_pack_start(GTK_BOX(hbox_temp), button, FALSE, FALSE, 0); gtk_grid_attach(GTK_GRID(grid1), GTK_WIDGET(button), 2, 0, 1, 1);
/* Make a right arrow for going forward a week */ /* Make a right arrow for going forward a week */
button = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD); button = gtk_button_new_with_label("Forward");
gtk_signal_connect(GTK_OBJECT(button), "clicked", g_signal_connect(G_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(cb_month_move), G_CALLBACK(cb_month_move),
GINT_TO_POINTER(1)); GINT_TO_POINTER(1));
gtk_box_pack_start(GTK_BOX(hbox_temp), button, FALSE, FALSE, 3); gtk_grid_attach(GTK_GRID(grid1), GTK_WIDGET(button), 3, 0, 1, 1);
/* Accelerator key for right arrow */ /* Accelerator key for right arrow */
gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel_group, gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel_group,
GDK_Right, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); GDK_KEY_Right, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE);
set_tooltip(show_tooltips, glob_tooltips, set_tooltip(show_tooltips, button, _("Next month Alt+RightArrow"));
button, _("Next month Alt+RightArrow"), NULL);
/* Month name label */ /* Month name label */
jp_strftime(str, sizeof(str), "%B %Y", &glob_month_date); jp_strftime(str, sizeof(str), "%B %Y", &glob_month_date);
month_month_label = gtk_label_new(str); month_month_label = gtk_label_new(str);
gtk_box_pack_start(GTK_BOX(vbox), month_month_label, FALSE, FALSE, 0); gtk_grid_attach(GTK_GRID(grid1), GTK_WIDGET(month_month_label), 0, 1, 7, 1);
/* We know this is on a Sunday */ /* Use a date that we know is on a Sunday */
memset(&date, 0, sizeof(date)); memset(&date, 0, sizeof(date));
date.tm_hour=12; date.tm_hour=12;
date.tm_mday=3; date.tm_mday=3;
date.tm_mon=1; date.tm_mon=1;
date.tm_year=80; date.tm_year=80;
mktime(&date); mktime(&date);
/* Get to the first day of week */ /* Get to the first day of week.
* 0 for Sunday, 1 for Monday, etc.
* Move the date to the firs day of the week according to settings.
*/
if (fdow) add_days_to_date(&date, fdow); if (fdow) add_days_to_date(&date, fdow);
/* Days of the week */ /* Make strings for the days of the week, i.e. Sunday, Monday... */
hbox = gtk_hbox_new(TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
for (i=0; i<7; i++) { for (i=0; i<7; i++) {
jp_strftime(str_dow, sizeof(str_dow), "%A", &date); jp_strftime(glob_str_dow[i], sizeof(glob_str_dow[i]), "%A", &date);
label = gtk_label_new(str_dow);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
add_days_to_date(&date, 1); add_days_to_date(&date, 1);
} }
create_month_boxes_texts(vbox); /* Attach 6 rows of 7 boxes for the calendar text views.
* Also one large text view at the bottom.
*/
create_month_boxes_texts(grid2);
gtk_widget_show_all(monthview_window); gtk_widget_show_all(monthview_window);
hide_show_month_boxes(); set_day_labels();
display_months_appts(&glob_month_date, month_day); display_months_appts(&glob_month_date);
} }
 End of changes. 62 change blocks. 
176 lines changed or deleted 179 lines changed or added

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