aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/cal-search-bar.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-08-04 11:13:43 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-08-04 11:13:43 +0800
commita874d1e407014751ae72957679c89dc6bbe2f679 (patch)
tree123900863eecd47e98f7c2b807fde5dd20a2d8ef /calendar/gui/cal-search-bar.c
parent9e199f467ba7f403dc487b9eaa10aa551d45496a (diff)
downloadgsoc2013-evolution-a874d1e407014751ae72957679c89dc6bbe2f679.tar
gsoc2013-evolution-a874d1e407014751ae72957679c89dc6bbe2f679.tar.gz
gsoc2013-evolution-a874d1e407014751ae72957679c89dc6bbe2f679.tar.bz2
gsoc2013-evolution-a874d1e407014751ae72957679c89dc6bbe2f679.tar.lz
gsoc2013-evolution-a874d1e407014751ae72957679c89dc6bbe2f679.tar.xz
gsoc2013-evolution-a874d1e407014751ae72957679c89dc6bbe2f679.tar.zst
gsoc2013-evolution-a874d1e407014751ae72957679c89dc6bbe2f679.zip
New function; stops further notification from happening. This is needed
2001-08-03 Federico Mena Quintero <federico@ximian.com> * cal-client/query-listener.c (query_listener_stop_notification): New function; stops further notification from happening. This is needed since the listener is destroyed asynchronously from the Wombat and the corresponding CalQuery may already have died. (impl_notifyObjUpdated): Do not notify if requested. (impl_notifyObjRemoved): Likewise. (impl_notifyQueryDone): Likewise. (impl_notifyEvalError): Likewise. * cal-client/cal-query.c (cal_query_destroy): Use query_listener_stop_notification(). * cal-client/cal-listener.c (cal_listener_destroy): Nullify the pointers to the callback functions. * gui/e-day-view.c (update_query): Commit our state of no longer having a query before unrefing it. We may reenter from the ORBit main loop and we *really* want this information to be committed. * gui/e-week-view.c (update_query): Likewise. * gui/calendar-model.c (update_query): Likewise. * gui/tag-calendar.c (tag_calendar_by_comp): Added a "clear_first" argument that indicates whether the ECalendar should be cleared of any marks first. * gui/calendar-commands.c (calendar_control_activate): Removed ifdefed-out view buttons code from the Gnomecal days. * gui/gnome-cal.c (client_categories_changed_cb): Merge the categories of the calendar and tasks clients so that we can display the categories in both sets. (gnome_calendar_construct): Connect to "categories_changed" on both clients. (gnome_calendar_on_date_navigator_selection_changed): Removed call to gnome_calendar_update_view_buttons(). (gnome_calendar_update_view_buttons): Removed. We cannot have this until Bonobo supports radio toolbar items. (gnome_calendar_set_view_buttons): Removed. (gnome_calendar_dayjump): Do not use priv->day_button. (GnomeCalendarPrivate): Removed the {day,work_week,week,month}_button fields. (gnome_calendar_set_query): Start a retagging process of the date navigator so that it reflects the current query. (update_query): New function to restart a query for the date navigator. (initial_load): Use update_query() instead of tagging the date navigator directly. (gnome_calendar_on_date_navigator_date_range_changed): Likewise. (client_cal_opened_cb): Use update_query() instead of initial_load(). (initial_load): Removed. (client_obj_updated_cb): Removed. (client_obj_removed_cb): Removed. (gnome_calendar_new_appointment_for): Set the default category of the new component. (search_bar_category_changed_cb): Set the default category for the calendar views. * gui/cal-search-bar.c (cal_search_bar_set_categories): Sort the categories before creating the menu. * gui/e-day-view.c (adjust_query_sexp): Return NULL instead of "#f" if the time range is not set yet. (update_query): Do not start a query if the time range is not set. (e_day_view_set_default_category): New function. (e_day_view_key_press): Set the default category on the new component. * gui/e-week-view.c (adjust_query_sexp): Analogous to the above. (update_query): Analogous to the above. (e_week_view_set_default_category): Analogous to the above. (e_week_view_key_press): Analogous to the above. svn path=/trunk/; revision=11646
Diffstat (limited to 'calendar/gui/cal-search-bar.c')
-rw-r--r--calendar/gui/cal-search-bar.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/calendar/gui/cal-search-bar.c b/calendar/gui/cal-search-bar.c
index e5cfcf95e9..a112409412 100644
--- a/calendar/gui/cal-search-bar.c
+++ b/calendar/gui/cal-search-bar.c
@@ -23,6 +23,7 @@
#include <config.h>
#endif
+#include <stdlib.h>
#include <glib.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenuitem.h>
@@ -401,6 +402,39 @@ item_destroyed_cb (GtkObject *object, gpointer data)
g_free (category);
}
+/* Used from qsort() */
+static int
+compare_categories_cb (const void *a, const void *b)
+{
+ const char **ca, **cb;
+
+ ca = (const char **) a;
+ cb = (const char **) b;
+
+ /* FIXME: should use some utf8 strcoll() thingy */
+ return strcmp (*ca, *cb);
+}
+
+/* Creates a sorted array of categories based on the original one; does not
+ * duplicate the string values.
+ */
+static GPtrArray *
+sort_categories (GPtrArray *categories)
+{
+ GPtrArray *c;
+ int i;
+
+ c = g_ptr_array_new ();
+ g_ptr_array_set_size (c, categories->len);
+
+ for (i = 0; i < categories->len; i++)
+ c->pdata[i] = categories->pdata[i];
+
+ qsort (c->pdata, c->len, sizeof (gpointer), compare_categories_cb);
+
+ return c;
+}
+
/**
* cal_search_bar_set_categories:
* @cal_search: A calendar search bar.
@@ -417,6 +451,7 @@ cal_search_bar_set_categories (CalSearchBar *cal_search, GPtrArray *categories)
CalSearchBarPrivate *priv;
GtkMenu *menu;
GtkWidget *item;
+ GPtrArray *sorted;
int i;
g_return_if_fail (cal_search != NULL);
@@ -450,19 +485,21 @@ cal_search_bar_set_categories (CalSearchBar *cal_search, GPtrArray *categories)
/* Categories items */
- for (i = 0; i < categories->len; i++) {
+ sorted = sort_categories (categories);
+
+ for (i = 0; i < sorted->len; i++) {
char *str;
/* FIXME: Put the category icons here */
- str = e_utf8_to_gtk_string (GTK_WIDGET (menu), categories->pdata[i]);
+ str = e_utf8_to_gtk_string (GTK_WIDGET (menu), sorted->pdata[i]);
if (!str)
continue;
item = gtk_menu_item_new_with_label (str);
g_free (str);
- gtk_object_set_user_data (GTK_OBJECT (item), g_strdup (categories->pdata[i]));
+ gtk_object_set_user_data (GTK_OBJECT (item), g_strdup (sorted->pdata[i]));
gtk_signal_connect (GTK_OBJECT (item), "destroy",
GTK_SIGNAL_FUNC (item_destroyed_cb),
NULL);
@@ -471,6 +508,8 @@ cal_search_bar_set_categories (CalSearchBar *cal_search, GPtrArray *categories)
gtk_widget_show (item);
}
+ g_ptr_array_free (sorted, TRUE);
+
/* Set the new menu; the old one will be destroyed automatically */
gtk_option_menu_set_menu (priv->categories_omenu, GTK_WIDGET (menu));