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

gEDA-cvs: branch: master updated (1.1.2.20070818-4-gb018b88)



The branch, master has been updated
       via  b018b88a1f2a88d246af850a67a15be5b19825b2 (commit)
      from  5a67f8a879c0f5bcfaa14daf6847064beebaf783 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gschem/include/prototype.h |    1 +
 gschem/src/x_attribedit.c  |    6 ++++++
 gschem/src/x_dialog.c      |   35 +++++++++++++++++++++++++++++++++++
 gschem/src/x_multiattrib.c |   23 ++++++++++++++++++++++-
 4 files changed, 64 insertions(+), 1 deletions(-)


=================
 Commit Messages
=================

commit b018b88a1f2a88d246af850a67a15be5b19825b2
Author: Ales Hvezda <ahvezda@xxxxxxxx>
Date:   Sun Sep 2 20:54:49 2007 -0400

    Fix for Bug# 1782032: Blank attibute name when attribute value starts with " "
    
    In order to fix this bug, we needed to validate the input attribute when:
    1) input an attribute using the single attribute editor,
    2) Add an attribute in the multi-attribute editor
    3) Modify the name or value of an attribute in the multi-attribute editor
    An attribute is not valid if the name or value are empty, name ends with a
    space, and/or value starts with a space.  o_attrib_get_name_value does
    this validation throughout gaf.

:100644 100644 9fe43fd... dbe3837... M	gschem/include/prototype.h
:100644 100644 0fb8f5a... cfcff5b... M	gschem/src/x_attribedit.c
:100644 100644 3a2fe3f... 1c1b910... M	gschem/src/x_dialog.c
:100644 100644 ff5a8ff... 81cf244... M	gschem/src/x_multiattrib.c

=========
 Changes
=========

commit b018b88a1f2a88d246af850a67a15be5b19825b2
Author: Ales Hvezda <ahvezda@xxxxxxxx>
Date:   Sun Sep 2 20:54:49 2007 -0400

    Fix for Bug# 1782032: Blank attibute name when attribute value starts with " "
    
    In order to fix this bug, we needed to validate the input attribute when:
    1) input an attribute using the single attribute editor,
    2) Add an attribute in the multi-attribute editor
    3) Modify the name or value of an attribute in the multi-attribute editor
    An attribute is not valid if the name or value are empty, name ends with a
    space, and/or value starts with a space.  o_attrib_get_name_value does
    this validation throughout gaf.

diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 9fe43fd..dbe3837 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -780,6 +780,7 @@ void show_text_dialog(TOPLEVEL *w_current);
 void major_changed_dialog(TOPLEVEL* w_current);
 void x_dialog_close_changed_page (TOPLEVEL *toplevel, PAGE *page);
 gboolean x_dialog_close_window (TOPLEVEL *toplevel);
+int x_dialog_validate_attribute(GtkWindow* parent, char *attribute);
 /* x_event.c */
 gint x_event_expose(GtkWidget *widget, GdkEventExpose *event, TOPLEVEL *w_current);
 gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event, TOPLEVEL *w_current);
diff --git a/gschem/src/x_attribedit.c b/gschem/src/x_attribedit.c
index 0fb8f5a..cfcff5b 100644
--- a/gschem/src/x_attribedit.c
+++ b/gschem/src/x_attribedit.c
@@ -101,6 +101,12 @@ void attrib_edit_dialog_ok(GtkWidget * w, TOPLEVEL * w_current)
   label = gtk_entry_get_text(name_entry);
   newtext = g_strconcat (label, "=", value, NULL);
 
+  if (!x_dialog_validate_attribute(GTK_WINDOW(w_current->aewindow), newtext))
+  {
+    g_free(newtext);
+    return;
+  }
+  
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(visbutton)))
   vis = VISIBLE;
   else
diff --git a/gschem/src/x_dialog.c b/gschem/src/x_dialog.c
index 3a2fe3f..1c1b910 100644
--- a/gschem/src/x_dialog.c
+++ b/gschem/src/x_dialog.c
@@ -4073,3 +4073,38 @@ x_dialog_close_window (TOPLEVEL *toplevel)
 
 /***************** End of Close Confirmation dialog box **************/
 
+
+/***************** Start of misc helper dialog boxes **************/
+/*! \brief Validate the input attribute 
+ *  \par Function Description
+ *  This function validates the attribute and if it isn't valid
+ *  pops up an error message box.
+ *
+ *  \param parent The parent window which spawned this dialog box.
+ *  \param attribute The attribute to be validated.
+ *  \returns TRUE if the attribute is valid, FALSE otherwise.
+ */
+int x_dialog_validate_attribute(GtkWindow* parent, char *attribute)
+{
+  GtkWidget* message_box;
+  char *name_ptr, *value_ptr;
+
+  /* validate the new attribute */
+  if (!o_attrib_get_name_value(attribute, &name_ptr, &value_ptr)) {
+      message_box = gtk_message_dialog_new_with_markup (parent,
+                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                  GTK_MESSAGE_ERROR,
+                                  GTK_BUTTONS_CLOSE,
+                                  _("<span weight=\"bold\" size=\"larger\">The input attribute \"%s\" is invalid\nPlease correct in order to continue</span>\n\nThe name and value must be non-empty.\nThe name cannot end with a space.\nThe value cannot start with a space."),
+                                  attribute);
+     gtk_window_set_title(GTK_WINDOW(message_box), _("Invalid Attribute"));
+     gtk_dialog_run (GTK_DIALOG (message_box));
+     gtk_widget_destroy (message_box);
+     return FALSE;
+  }
+  g_free(name_ptr);
+  g_free(value_ptr);
+  return TRUE;
+}
+/***************** End of misc helper dialog boxes **************/
+
diff --git a/gschem/src/x_multiattrib.c b/gschem/src/x_multiattrib.c
index ff5a8ff..81cf244 100644
--- a/gschem/src/x_multiattrib.c
+++ b/gschem/src/x_multiattrib.c
@@ -470,6 +470,7 @@ static void multiattrib_popup_menu (Multiattrib *multiattrib,
  */
 static void multiattrib_action_add_attribute(TOPLEVEL *toplevel,
 					     OBJECT *object,
+                                             Multiattrib *multiattrib,
 					     const gchar *name,
 					     const gchar *value,
 					     gint visible,
@@ -480,6 +481,11 @@ static void multiattrib_action_add_attribute(TOPLEVEL *toplevel,
   
   newtext = g_strdup_printf ("%s=%s", name, value);
 
+  if (!x_dialog_validate_attribute(GTK_WINDOW(multiattrib), newtext)) {
+    g_free(newtext);
+    return;
+  }
+
   /* create a new attribute and link it */
   o_attrib = o_attrib_add_attrib (toplevel, newtext,
                                   visible, show_name_value, object);
@@ -723,6 +729,14 @@ static void multiattrib_callback_edited_name(GtkCellRendererText *cellrendererte
 
   o_attrib_get_name_value (o_attrib->text->string, &name, &value);
   newtext = g_strdup_printf ("%s=%s", arg2, value);
+
+  if (!x_dialog_validate_attribute(GTK_WINDOW(multiattrib), newtext)) {
+    if (name) g_free (name);
+    if (value) g_free (value);
+    g_free(newtext);
+    return;
+  }
+
   
   /* actually modifies the attribute */
   o_text_change (toplevel, o_attrib,
@@ -765,6 +779,13 @@ static void multiattrib_callback_edited_value(GtkCellRendererText *cell_renderer
 
   o_attrib_get_name_value (o_attrib->text->string, &name, &value);
   newtext = g_strdup_printf ("%s=%s", name, arg2);
+
+  if (!x_dialog_validate_attribute(GTK_WINDOW(multiattrib), newtext)) {
+    if (name) g_free (name);
+    if (value) g_free (value);
+    g_free(newtext);
+    return;
+  }
   
   /* actually modifies the attribute */
   o_text_change (toplevel, o_attrib,
@@ -1161,7 +1182,7 @@ static void multiattrib_callback_button_add(GtkButton *button,
     return;
   }
 
-  multiattrib_action_add_attribute (toplevel, object,
+  multiattrib_action_add_attribute (toplevel, object, multiattrib, 
                                     name, value,
                                     visible, shownv);
   g_free (value);




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs