patch for gnomecal



Here's a patch for two bugs (or least, infelicities) in gnomecal.

1) Under the preferences menu, you get to set a chosen starting hour
for the calendar day (e.g. 8am).  But regardless of this choice, when
you open a day view in gnomecal the visible day starts at midnight --
and so, unless you have a very tall window, the relevant portion of
the day will be out of sight.  There is code in gnomecal which seems
to be intended to pre-scroll the window so that the relevant portion
of the day is visible, but it's ineffective.  So far as I can see it
just burns CPU cycles.

2) Gnomecal offers a "--geometry=" command line option, but it throws
away most of the information a user might supply via that means (after
burning some CPU cycles to parse it).

I have given the patch both inline and as an attachment, because it's
small, and the original lines are long.

Allin Cottrell
Wake Forest University

diff -ur gncal-orig/gncal-day-panel.c gncal/gncal-day-panel.c
--- gncal-orig/gncal-day-panel.c	Tue Oct 19 21:04:47 1999
+++ gncal/gncal-day-panel.c	Mon Aug 27 21:05:58 2001
@@ -12,6 +12,7 @@
 #include "main.h"
 #include "timeutil.h"

+static gfloat vadj_value;

 guint
 gncal_day_panel_get_type (void)
@@ -51,19 +52,27 @@
 }

 static void
+set_vadj_value (GtkWidget *widget, gpointer *data, GncalDayPanel *dpanel)
+{
+        GtkAdjustment *adj;
+
+        adj = gtk_scrolled_window_get_vadjustment (dpanel->fullday_sw);
+        if (vadj_value != adj->value) {
+                gtk_adjustment_set_value(adj, vadj_value);
+        }
+}
+
+static void
 full_day_size_allocated (GtkWidget *widget, GtkAllocation *allocation, GncalDayPanel *dpanel)
 {
 	GtkAdjustment *adj;
 	int yoffset;
-	gfloat newval;

 	adj = gtk_scrolled_window_get_vadjustment (dpanel->fullday_sw);

 	yoffset = gncal_full_day_get_day_start_yoffset (GNCAL_FULL_DAY (widget));

-	newval = adj->lower + (adj->upper - adj->lower) * (double) yoffset / allocation->height;
-	if (newval != adj->value)
-		gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
+	vadj_value = adj->lower + (adj->upper - adj->lower) * (double) yoffset / allocation->height;
 }

 static void
@@ -153,6 +162,9 @@
 	gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "size_allocate",
 			    (GtkSignalFunc) full_day_size_allocated,
 			    dpanel);
+        gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "map_event",
+                            (GtkSignalFunc) set_vadj_value,
+                            dpanel);

 	/* Create vertical pane */

diff -ur gncal-orig/main.c gncal/main.c
--- gncal-orig/main.c	Sun Feb 25 22:26:16 2001
+++ gncal/main.c	Mon Aug 27 21:01:00 2001
@@ -713,18 +713,19 @@
 	g_snprintf(title, 128, _("%s%s"), full_name, _("'s calendar"));

 	toplevel = gnome_calendar_new (title);
-
-	if (gnome_parse_geometry (geometry, &xpos, &ypos, &width, &height)){
-		if (xpos != -1)
-			gtk_widget_set_uposition (toplevel, xpos, ypos);
-#if 0
-	if (width != -1)
-		gtk_widget_set_usize (toplevel, width, 600);
-#endif
-	}
-#if 0
- 	gtk_widget_set_usize (toplevel, width, 600);
-#endif
+
+        if (gnome_parse_geometry (geometry, &xpos, &ypos, &width, &height)){
+
+                if (xpos != -1 && ypos != -1)
+                        gtk_widget_set_uposition (toplevel, xpos, ypos);
+                if (width != -1 && height != -1)
+                    gtk_widget_set_usize (toplevel, width, height);
+                else if (width != -1)
+                    gtk_widget_set_usize (toplevel, width, 480);
+                else if (height != -1)
+                    gtk_widget_set_usize (toplevel, height, 420);
+
+        }

 	setup_appbar (toplevel);
 	setup_menu (toplevel);


diff -ur gncal-orig/gncal-day-panel.c gncal/gncal-day-panel.c
--- gncal-orig/gncal-day-panel.c	Tue Oct 19 21:04:47 1999
+++ gncal/gncal-day-panel.c	Mon Aug 27 21:05:58 2001
@@ -12,6 +12,7 @@
 #include "main.h"
 #include "timeutil.h"
 
+static gfloat vadj_value;
 
 guint
 gncal_day_panel_get_type (void)
@@ -51,19 +52,27 @@
 }
 
 static void
+set_vadj_value (GtkWidget *widget, gpointer *data, GncalDayPanel *dpanel)
+{
+        GtkAdjustment *adj;
+
+        adj = gtk_scrolled_window_get_vadjustment (dpanel->fullday_sw);
+        if (vadj_value != adj->value) {
+                gtk_adjustment_set_value(adj, vadj_value);
+        }
+}
+
+static void
 full_day_size_allocated (GtkWidget *widget, GtkAllocation *allocation, GncalDayPanel *dpanel)
 {
 	GtkAdjustment *adj;
 	int yoffset;
-	gfloat newval;
 
 	adj = gtk_scrolled_window_get_vadjustment (dpanel->fullday_sw);
 
 	yoffset = gncal_full_day_get_day_start_yoffset (GNCAL_FULL_DAY (widget));
 
-	newval = adj->lower + (adj->upper - adj->lower) * (double) yoffset / allocation->height;
-	if (newval != adj->value)
-		gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
+	vadj_value = adj->lower + (adj->upper - adj->lower) * (double) yoffset / allocation->height;
 }
 
 static void
@@ -153,6 +162,9 @@
 	gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "size_allocate",
 			    (GtkSignalFunc) full_day_size_allocated,
 			    dpanel);
+        gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "map_event",
+                            (GtkSignalFunc) set_vadj_value,
+                            dpanel);
 
 	/* Create vertical pane */
 	
diff -ur gncal-orig/main.c gncal/main.c
--- gncal-orig/main.c	Sun Feb 25 22:26:16 2001
+++ gncal/main.c	Mon Aug 27 21:01:00 2001
@@ -713,18 +713,19 @@
 	g_snprintf(title, 128, _("%s%s"), full_name, _("'s calendar"));
 
 	toplevel = gnome_calendar_new (title);
-	
-	if (gnome_parse_geometry (geometry, &xpos, &ypos, &width, &height)){
-		if (xpos != -1)
-			gtk_widget_set_uposition (toplevel, xpos, ypos);
-#if 0
-	if (width != -1)
-		gtk_widget_set_usize (toplevel, width, 600);
-#endif
-	}
-#if 0
- 	gtk_widget_set_usize (toplevel, width, 600); 
-#endif
+
+        if (gnome_parse_geometry (geometry, &xpos, &ypos, &width, &height)){
+
+                if (xpos != -1 && ypos != -1)
+                        gtk_widget_set_uposition (toplevel, xpos, ypos);
+                if (width != -1 && height != -1)
+                    gtk_widget_set_usize (toplevel, width, height);
+                else if (width != -1)
+                    gtk_widget_set_usize (toplevel, width, 480);
+                else if (height != -1)
+                    gtk_widget_set_usize (toplevel, height, 420);
+
+        }
 
 	setup_appbar (toplevel);
 	setup_menu (toplevel);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]