Re: [evolution-patches] patch for e-categories-dialog widget (#38804)
- From: Rodrigo Moya <rodrigo novell com>
- To: JP Rosevear <jpr novell com>
- Cc: Evolution Patches <evolution-patches lists ximian com>
- Subject: Re: [evolution-patches] patch for e-categories-dialog widget (#38804)
- Date: Fri, 25 Feb 2005 17:36:24 +0100
On Thu, 2005-02-24 at 21:24 -0500, JP Rosevear wrote:
> I believe this breaks the string freeze and it doesn't really let the
> user know what characters aren't allowed. Maybe we could just filter
> the ',' keystrokes out of the entry?
>
right, attached patch does that, not adding new strings at all. Also, as
talked on IRC, this fixes also #73011
--
Rodrigo Moya <rodrigo novell com>
? e-cal-editor-page.c
? e-cal-editor-page.h
? e-cal-editor.c
? e-cal-editor.h
? e-cal-editor.loT
? e-categories-dialog.gladep
? test-contact-store
? test-name-selector
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/ChangeLog,v
retrieving revision 1.30
diff -u -p -r1.30 ChangeLog
--- ChangeLog 23 Feb 2005 18:52:12 -0000 1.30
+++ ChangeLog 25 Feb 2005 16:37:52 -0000
@@ -1,3 +1,13 @@
+2005-02-25 Rodrigo Moya <rodrigo novell com>
+
+ Fixes #38408, #73011
+
+ * e-categories-dialog.c (check_category_name): new function to check
+ categories entered by the user for invalid characters.
+ (new_button_clicked_cb): added missing argument to gtk_list_store_set
+ call and category name checking. Also, run the dialog continously while
+ there are validation errors.
+
2005-02-23 Hans Petter Jansson <hpj novell com>
* Makefile.am (libedataserverui_1_2_la_SOURCES)
Index: e-categories-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/e-categories-dialog.c,v
retrieving revision 1.11
diff -u -p -r1.11 e-categories-dialog.c
--- e-categories-dialog.c 3 Feb 2005 16:35:02 -0000 1.11
+++ e-categories-dialog.c 25 Feb 2005 16:37:52 -0000
@@ -211,6 +211,29 @@ entry_changed_cb (GtkEditable *editable,
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE);
}
+static char *
+check_category_name (const char *name)
+{
+ GString *str = NULL;
+ char *p = (char *) name;
+
+ str = g_string_new ("");
+ while (*p) {
+ switch (*p) {
+ case ',' :
+ break;
+ default :
+ str = g_string_append_c (str, *p);
+ }
+ p++;
+ }
+
+ p = str->str;
+ g_string_free (str, FALSE);
+
+ return p;
+}
+
static void
new_button_clicked_cb (GtkButton *button, gpointer user_data)
{
@@ -223,37 +246,50 @@ new_button_clicked_cb (GtkButton *button
if (!prop_dialog)
return;
- if (gtk_dialog_run (GTK_DIALOG (prop_dialog->the_dialog)) == GTK_RESPONSE_OK) {
- const char *category_name, *category_icon;
- GtkTreeIter iter;
-
- category_name = gtk_entry_get_text (GTK_ENTRY (prop_dialog->category_name));
- if (e_categories_exist (category_name)) {
- GtkWidget *error_dialog;
-
- error_dialog = gtk_message_dialog_new (
- GTK_WINDOW (prop_dialog->the_dialog),
- 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- _("There is already a category '%s' in the configuration. Please use another name"),
- category_name);
-
- gtk_dialog_run (GTK_DIALOG (error_dialog));
- gtk_widget_destroy (error_dialog);
- } else {
- /* FIXME: get color */
- category_icon = gtk_entry_get_text (
- GTK_ENTRY (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (prop_dialog->category_icon))));
-
- e_categories_add (category_name, NULL, category_icon ? category_icon : NULL, TRUE);
-
- gtk_list_store_append (
- GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (prop_dialog->parent->priv->categories_list))),
- &iter);
- gtk_list_store_set (
- GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (prop_dialog->parent->priv->categories_list))),
- 0, FALSE, 1, category_name, -1);
- }
- }
+ do {
+ if (gtk_dialog_run (GTK_DIALOG (prop_dialog->the_dialog)) == GTK_RESPONSE_OK) {
+ const char *category_name, *category_icon;
+ char *correct_category_name;
+ GtkTreeIter iter;
+
+ category_name = gtk_entry_get_text (GTK_ENTRY (prop_dialog->category_name));
+ correct_category_name = check_category_name (category_name);
+
+ if (e_categories_exist (correct_category_name)) {
+ GtkWidget *error_dialog;
+
+ error_dialog = gtk_message_dialog_new (
+ GTK_WINDOW (prop_dialog->the_dialog),
+ 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+ _("There is already a category '%s' in the configuration. Please use another name"),
+ category_name);
+
+ gtk_dialog_run (GTK_DIALOG (error_dialog));
+ gtk_widget_destroy (error_dialog);
+ g_free (correct_category_name);
+ } else {
+ /* FIXME: get color */
+ category_icon = gtk_entry_get_text (
+ GTK_ENTRY (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (prop_dialog->category_icon))));
+
+ e_categories_add (correct_category_name, NULL, category_icon ? category_icon : NULL, TRUE);
+
+ gtk_list_store_append (
+ GTK_LIST_STORE (gtk_tree_view_get_model (
+ GTK_TREE_VIEW (prop_dialog->parent->priv->categories_list))),
+ &iter);
+ gtk_list_store_set (
+ GTK_LIST_STORE (gtk_tree_view_get_model (
+ GTK_TREE_VIEW (prop_dialog->parent->priv->categories_list))),
+ &iter, 0, FALSE, 1, correct_category_name, -1);
+
+ g_free (correct_category_name);
+
+ break;
+ }
+ } else
+ break;
+ } while (TRUE);
free_properties_dialog (prop_dialog);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]