[evolution-patches] fix for calendar bug #57818



http://bugzilla.ximian.com/show_bug.cgi?id=57818

the attached patch makes it so that you can limit which option menu
items you actually want to display in the component's search bar using a
bitfield.

I've also created macros for the default Tasks/Calendar menus.

Jeff

-- 
Jeffrey Stedfast
Evolution Hacker - Novell, Inc.
fejj ximian com  - www.novell.com
? 57818.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2351
diff -u -r1.2351 ChangeLog
--- ChangeLog	26 May 2004 19:51:49 -0000	1.2351
+++ ChangeLog	26 May 2004 21:11:57 -0000
@@ -1,5 +1,17 @@
 2004-05-26  Jeffrey Stedfast  <fejj novell com>
 
+	Fix for bug #57818.
+
+	* gui/e-tasks.c (setup_widgets): Same.
+
+	* gui/gnome-cal.c (setup_widgets): Updated to pass a set of
+	bitflags to cal_search_bar_new().
+
+	* gui/cal-search-bar.c (cal_search_bar_new): Now takes a bit flag
+	argument specifying which search options to present.
+	(cal_search_bar_construct): Same as above. Construct the search
+	menu to use based on the bit flags.
+
 	* gui/apps_evolution_calendar.schemas.in.in: Changed the default
 	"Tasks due today" colour to be a light-blue (one of the default
 	colour values in the colour picker dialog). Fixes bug #53412.
Index: gui/cal-search-bar.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/cal-search-bar.c,v
retrieving revision 1.22
diff -u -r1.22 cal-search-bar.c
--- gui/cal-search-bar.c	28 Apr 2004 01:51:40 -0000	1.22
+++ gui/cal-search-bar.c	26 May 2004 21:11:57 -0000
@@ -33,7 +33,6 @@
 #include <gal/util/e-util.h>
 #include "cal-search-bar.h"
 
-
 
 /* IDs and option items for the ESearchBar */
 enum {
@@ -42,7 +41,7 @@
 	SEARCH_DESCRIPTION_CONTAINS,
 	SEARCH_COMMENT_CONTAINS,
 	SEARCH_LOCATION_CONTAINS,
-	SEARCH_CATEGORY_IS,
+	SEARCH_CATEGORY_IS
 };
 
 /* Comments are disabled because they are kind of useless right now, see bug 33247 */
@@ -50,12 +49,9 @@
 	{ N_("Any field contains"), SEARCH_ANY_FIELD_CONTAINS, NULL },
 	{ N_("Summary contains"), SEARCH_SUMMARY_CONTAINS, NULL },
 	{ N_("Description contains"), SEARCH_DESCRIPTION_CONTAINS, NULL },
-#if 0
 	{ N_("Comment contains"), SEARCH_COMMENT_CONTAINS, NULL },
-#endif
 	{ N_("Location contains"), SEARCH_LOCATION_CONTAINS, NULL },
 	{ N_("Category is"), SEARCH_CATEGORY_IS, NULL },
-	{ NULL, -1, NULL }
 };
 
 /* IDs for the categories suboptions */
@@ -401,18 +397,36 @@
 /**
  * cal_search_bar_construct:
  * @cal_search: A calendar search bar.
+ * @flags: bitfield of items to appear in the search menu
  * 
  * Constructs a calendar search bar by binding its menu and option items.
  * 
  * Return value: The same value as @cal_search.
  **/
 CalSearchBar *
-cal_search_bar_construct (CalSearchBar *cal_search)
+cal_search_bar_construct (CalSearchBar *cal_search, guint32 flags)
 {
-	g_return_val_if_fail (cal_search != NULL, NULL);
+	ESearchBarItem *items;
+	guint32 bit = 0x1;
+	int i, j;
+	
 	g_return_val_if_fail (IS_CAL_SEARCH_BAR (cal_search), NULL);
-
-	e_search_bar_construct (E_SEARCH_BAR (cal_search), NULL, search_option_items);
+	
+	items = g_alloca ((G_N_ELEMENTS (search_option_items) + 1) * sizeof (ESearchBarItem));
+	for (i = 0, j = 0; i < G_N_ELEMENTS (search_option_items); i++, bit <<= 1) {
+		if ((flags & bit) != 0) {
+			items[j].text = search_option_items[i].text;
+			items[j].id = search_option_items[i].id;
+			items[j].subitems = search_option_items[i].subitems;
+			j++;
+		}
+	}
+	
+	items[j].text = NULL;
+	items[j].id = -1;
+	items[j].subitems = NULL;
+	
+	e_search_bar_construct (E_SEARCH_BAR (cal_search), NULL, items);
 	make_suboptions (cal_search);
 
 	e_search_bar_set_ids (E_SEARCH_BAR (cal_search), SEARCH_CATEGORY_IS, CATEGORIES_ALL);
@@ -422,6 +436,7 @@
 
 /**
  * cal_search_bar_new:
+ * flags: bitfield of items to appear in the search menu
  * 
  * Creates a new calendar search bar.
  * 
@@ -429,12 +444,12 @@
  * "sexp_changed" signal to monitor changes in the generated sexps.
  **/
 GtkWidget *
-cal_search_bar_new (void)
+cal_search_bar_new (guint32 flags)
 {
 	CalSearchBar *cal_search;
 
 	cal_search = g_object_new (TYPE_CAL_SEARCH_BAR, NULL);
-	return GTK_WIDGET (cal_search_bar_construct (cal_search));
+	return GTK_WIDGET (cal_search_bar_construct (cal_search, flags));
 }
 
 /* Used from qsort() */
@@ -485,7 +500,6 @@
 {
 	CalSearchBarPrivate *priv;
 
-	g_return_if_fail (cal_search != NULL);
 	g_return_if_fail (IS_CAL_SEARCH_BAR (cal_search));
 	g_return_if_fail (categories != NULL);
 
Index: gui/cal-search-bar.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/cal-search-bar.h,v
retrieving revision 1.4
diff -u -r1.4 cal-search-bar.h
--- gui/cal-search-bar.h	7 Nov 2002 22:47:41 -0000	1.4
+++ gui/cal-search-bar.h	26 May 2004 21:11:57 -0000
@@ -37,6 +37,19 @@
 
 typedef struct CalSearchBarPrivate CalSearchBarPrivate;
 
+enum {
+	CAL_SEARCH_ANY_FIELD_CONTAINS    = (1 << 0),
+	CAL_SEARCH_SUMMARY_CONTAINS      = (1 << 1),
+	CAL_SEARCH_DESCRIPTION_CONTAINS  = (1 << 2),
+	CAL_SEARCH_COMMENT_CONTAINS      = (1 << 3),
+	CAL_SEARCH_LOCATION_CONTAINS     = (1 << 4),
+	CAL_SEARCH_CATEGORY_IS           = (1 << 5)
+};
+
+#define CAL_SEARCH_ALL (0xff)
+#define CAL_SEARCH_CALENDAR_DEFAULT (0x37)
+#define CAL_SEARCH_TASKS_DEFAULT    (0x27)
+
 typedef struct {
 	ESearchBar search_bar;
 
@@ -55,9 +68,9 @@
 
 GtkType cal_search_bar_get_type (void);
 
-CalSearchBar *cal_search_bar_construct (CalSearchBar *cal_search);
+CalSearchBar *cal_search_bar_construct (CalSearchBar *cal_search, guint32 flags);
 
-GtkWidget *cal_search_bar_new (void);
+GtkWidget *cal_search_bar_new (guint32 flags);
 
 void cal_search_bar_set_categories (CalSearchBar *cal_search, GPtrArray *categories);
 
Index: gui/e-tasks.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-tasks.c,v
retrieving revision 1.93
diff -u -r1.93 e-tasks.c
--- gui/e-tasks.c	25 May 2004 20:41:32 -0000	1.93
+++ gui/e-tasks.c	26 May 2004 21:11:57 -0000
@@ -345,7 +345,7 @@
 
 	priv = tasks->priv;
 
-	priv->search_bar = cal_search_bar_new ();
+	priv->search_bar = cal_search_bar_new (CAL_SEARCH_TASKS_DEFAULT);
 	g_signal_connect (priv->search_bar, "sexp_changed",
 			  G_CALLBACK (search_bar_sexp_changed_cb), tasks);
 	g_signal_connect (priv->search_bar, "category_changed",
Index: gui/gnome-cal.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/gnome-cal.c,v
retrieving revision 1.329
diff -u -r1.329 gnome-cal.c
--- gui/gnome-cal.c	26 May 2004 16:07:41 -0000	1.329
+++ gui/gnome-cal.c	26 May 2004 21:11:57 -0000
@@ -1015,7 +1015,7 @@
 
 	priv = gcal->priv;
 
-	priv->search_bar = cal_search_bar_new ();
+	priv->search_bar = cal_search_bar_new (CAL_SEARCH_CALENDAR_DEFAULT);
 	g_signal_connect (priv->search_bar, "sexp_changed",
 			  G_CALLBACK (search_bar_sexp_changed_cb), gcal);
 	g_signal_connect (priv->search_bar, "category_changed",

Attachment: smime.p7s
Description: S/MIME cryptographic signature



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