Tags: squeeze sid patch

The patch I provided in my last mail fixes the bug I originally
described, but didn't completely fix the original problem of the
original source using some invalid methods to grab a localized month
string; in particular editing a pre-existing alarm with include/exclude
dates showed up as "(null) 20" or whatever even though they showed up as
"August 20" while originally creating (and are respected as such when
triggering alarms).

This patch includes the changes from my previous patch, and fixes the
display problem when editing pre-existing events (ie: ignore the
previous patch and just use this one).

Hopefully this helps!
-- 
--Kris

叶ってしまう夢は本当の夢と言えん。
[A dream that comes true can't really be called a dream.]

--- alarm-clock-1.2.5/src/schedule.c	2009-08-06 08:05:33.000000000 +0900
+++ alarm-clock-1.2.5-krisp/src/schedule.c	2010-09-06 20:56:45.540864769 +0900
@@ -194,11 +194,18 @@ show_schedule_editor(void)
 	GtkWidget *combo = GTK_WIDGET (gtk_builder_get_object (gxml, "month_combo"));
 	GtkWidget *tree = GTK_WIDGET (gtk_builder_get_object (gxml, "schedule_dates_tree"));
 	gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
-	gchar **split, **date_split, *buffer;
+	gchar **split, **date_split, *buffer, month_string[100];
 	gboolean bool_buffer;
 	gint i = 0;
 	gint month, day;
 	GtkTreeIter iter, parent;
+	GDate *gdate;
+	GTimeVal gtimenow;
+
+	g_get_current_time(&gtimenow); //grab time for the current year	
+
+	gdate=g_date_new();
+	g_date_set_time_val(gdate,&gtimenow);
 
 	deselect_all_months ();
 	deselect_all_weekdays ();
@@ -262,9 +269,11 @@ show_schedule_editor(void)
 
 		g_strfreev(date_split);
 		
-		gtk_combo_box_set_active(GTK_COMBO_BOX(combo), month - 1);
+		g_date_set_day(gdate,day);
+		g_date_set_month(gdate,month);
 
-		buffer = g_strdup_printf("%s %i", gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)), day);
+		g_date_strftime(month_string,100,"%B",gdate);
+		buffer = g_strdup_printf("%s %d", month_string,day);
 		
 		gtk_tree_store_append(GTK_TREE_STORE(schedule_dates_store), &iter, &parent);
 		gtk_tree_store_set(GTK_TREE_STORE(schedule_dates_store), &iter, 
@@ -300,9 +309,11 @@ show_schedule_editor(void)
 
 		g_strfreev(date_split);
 		
-		gtk_combo_box_set_active(GTK_COMBO_BOX(combo), month - 1);
+		g_date_set_day(gdate,day);
+		g_date_set_month(gdate,month);
 
-		buffer = g_strdup_printf("%s %i", gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)), day);
+		g_date_strftime(month_string,100,"%B",gdate);
+		buffer = g_strdup_printf("%s %d", month_string,day);
 		
 		gtk_tree_store_append(GTK_TREE_STORE(schedule_dates_store), &iter, &parent);
 		gtk_tree_store_set(GTK_TREE_STORE(schedule_dates_store), &iter, 
@@ -420,22 +431,26 @@ schedule_date_ok(void)
 	GtkWidget *radio_exclude = GTK_WIDGET (gtk_builder_get_object (gxml, "exclude_date_radio"));
 	GtkWidget *notebook = GTK_WIDGET (gtk_builder_get_object (gxml, "notebook6"));
 	GtkWidget *month_combo = GTK_WIDGET (gtk_builder_get_object (gxml, "month_combo"));
-	guint day, month;
-	gchar *date, *month_string, *path;
+	guint day, month, year;
+	gchar month_string[100], *date, *path;
 	GtkTreeIter iter, parent;
+	GDate *gdate;
 	
-	month_string = gtk_combo_box_get_active_text(GTK_COMBO_BOX(month_combo));
-	month = gtk_combo_box_get_active(GTK_COMBO_BOX(month_combo));
-	gtk_calendar_get_date(GTK_CALENDAR(calendar), NULL, NULL, &day);
+	gtk_calendar_get_date(GTK_CALENDAR(calendar), &year, &month, &day);
+	gdate=g_date_new_dmy(day,month+1,year);
+	g_date_strftime(month_string,100,"%B",gdate);
+	date = g_strdup_printf("%s %d", month_string,day);
 
 	date_exists = FALSE;
 
 	ex_day = day;
 	ex_mon = month + 1;
-	
+
+
 	gtk_tree_model_foreach(GTK_TREE_MODEL(schedule_dates_store),
 	                       check_foreach, NULL);
 
+
 	if (date_exists)
 	{
 		GtkWidget *error_dialog = gtk_message_dialog_new(GTK_WINDOW(dialog),
@@ -453,9 +468,7 @@ schedule_date_ok(void)
 		return;
 	}
 	
-	
-	date = g_strdup_printf("%s %i", month_string, day);
-	
+		
 	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_include)))
 	    path = g_strdup("0");
 	else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_exclude)))
@@ -480,7 +493,6 @@ schedule_date_ok(void)
 	gtk_tree_view_expand_all(GTK_TREE_VIEW(schedule_dates_tree));
 	
 	g_free(date);
-	g_free(month_string);
 	g_free(path);
 }
 

Reply via email to