[Glade-devel] [PATCH]: Some cleanup, Query dialog cancel button fix, Bug fix for #157667



--Boundary_(ID_8P0Uj1NiZSlnXJFBU8uz5A)
Content-type: text/plain
Content-transfer-encoding: 7BIT

Hey ho!

Ok here's the patch. What it includes...

1) Some minor cleanups
2) Query dialog cancel button fix. The Query dialogs were missing the
cancel button.
3) Bug fix for #157667 (see for places where "from_query_dialog" makes
an appearance in the diff)

Sorry for integrating this patch with my previous cleanup
+query-dialog-cancel-fix patch. 

Please review.

Archit


--Boundary_(ID_8P0Uj1NiZSlnXJFBU8uz5A)
Content-type: text/x-patch;
 name=glade3-cleanup-and-query-dialog-and-property-set-fix.diff; charset=UTF-8
Content-transfer-encoding: 7BIT
Content-disposition: attachment;
 filename=glade3-cleanup-and-query-dialog-and-property-set-fix.diff

? depcomp
? install-sh
? stamp-h1
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/glade3/ChangeLog,v
retrieving revision 1.325
diff -u -r1.325 ChangeLog
--- ChangeLog   16 Dec 2004 21:24:02 -0000      1.325
+++ ChangeLog   18 Dec 2004 21:26:04 -0000
@@ -1,3 +1,66 @@
+2004-12-18  Archit Baweja  <bighead users sourceforge net>
+
+       * src/glade-editor.c (glade_editor_table_append_item): Added
+       gboolean from_query_dialog parameter to function definition.
+       All callers changed.
+       (glade_editor_property_changed_text_common): added from_query_dialog
+       parameter.
+
+       * src/glade-command.c (glade_command_set_property): push action onto
+       undo stack only if execute is successful AND its not from a query
+       query dialog.
+       Added a "from_query_dialog" parameter to function definition.
+       All callers changed.
+       
+       * src/glade-editor.c: removed prototypes for glade_editor_init() 
+       and glade_editor_class_init() and moved definition of
+       glade_editor_get_type lower().
+
+       * src/glade-command.c (glade_command_set_name): push action onto undo
+       stack only if execute is successfully.
+
+       * src/glade-editor.c (glade_editor_query_dialog): renamed from 
+       glade_editor_query_popup(). I feel a *_popup() is mis-named (atleast
+       from a Gtk+ point of view, since a popup in Gtk+ is a right click menu)
+       All callers changed.
+
+2004-12-17  Archit Baweja  <bighead users sourceforge net>
+
+       * src/glade-command.c (glade_command_create_delete_common): there
+       was a semi-colon immediately after the if-statement on the same line.
+       So glade_command_push_undo go called no matter what. Fixed.
+
+       * src/glade-project.c (glade_project_selection_set): no need to get
+       GladeProjectWindow ptr.
+       (glade_project_selection_add): likewise.
+
+       * src/glade-editor.c (glade_editor_query_popup): don't set a default
+       size for query popup dialogs.
+       Show a "Cancel" button to cancel operation.
+       Also, if "Cancel" button pressed, return FALSE to stop "create" command
+       (glade_editor_table_append_items): we're not using this recursively.
+       Remove prototype.
+       * src/glade-widget.c (glade_widget_new): if glade_editor_query_popup
+       returns FALSE, stop "create" command.
+
+       * src/glade-clipboard-view.c (glade_clipboard_view_construct): use 
+       named constants instead of "magic numbers" for the height and width of
+       the clipboard view window.
+       * src/glade-project-window.c (gpw_create_widget_tree): don't use magic
+       numbers for gtk_window_set_default_size(). Use named constants.
+
+       * src/glade-placeholder.c (glade_placeholder_button_press): since
+       we can, why not extract the GladeProject for calling
+       glade_command_create instead of leave it to glade_command_create to get
+       project.
+       (glade_placeholder_button_press): reset palette here. No need to do it
+       in glade_command_create.
+
+       * src/glade-command.c (glade_command_cut): notify the user if user
+       tries to cut a widget which is internal to a composite widget.
+       (glade_command_copy): likewise.
+       (glade_command_delete): likewise.
+
 2004-12-16  Archit Baweja  <bighead users sourceforge net>
 
        * widgets/gtk-obsolete.xml: added entry for GtkFileSelection
Index: src/glade-clipboard-view.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-clipboard-view.c,v
retrieving revision 1.12
diff -u -r1.12 glade-clipboard-view.c
--- src/glade-clipboard-view.c  4 Oct 2004 15:45:22 -0000       1.12
+++ src/glade-clipboard-view.c  18 Dec 2004 21:26:04 -0000
@@ -29,6 +29,9 @@
 #include "glade-widget-class.h"
 
 
+const gint GLADE_CLIPBOARD_VIEW_WIDTH  = 230;
+const gint GLADE_CLIPBOARD_VIEW_HEIGHT = 200;
+
 static void
 glade_clipboard_view_class_init (GladeClipboardViewClass *class)
 {
@@ -189,7 +192,10 @@
        gtk_container_add (GTK_CONTAINER (scrolled_window), view->widget);
        gtk_container_add (GTK_CONTAINER (view), scrolled_window);
 
-       gtk_window_set_default_size (GTK_WINDOW (view), 272, 130);
+       gtk_window_set_default_size (GTK_WINDOW (view),
+                                    GLADE_CLIPBOARD_VIEW_WIDTH,
+                                    GLADE_CLIPBOARD_VIEW_HEIGHT);
+
        gtk_window_set_type_hint (GTK_WINDOW (view), GDK_WINDOW_TYPE_HINT_UTILITY);
 
        gtk_widget_show_all (scrolled_window);
Index: src/glade-clipboard.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-clipboard.c,v
retrieving revision 1.16
diff -u -r1.16 glade-clipboard.c
--- src/glade-clipboard.c       7 Oct 2004 15:20:34 -0000       1.16
+++ src/glade-clipboard.c       18 Dec 2004 21:26:04 -0000
@@ -93,7 +93,7 @@
  * @widget: a #GladeWidget
  * 
  * Adds @widget to @clipboard.
- * This increses the reference count of @widget.
+ * This increases the reference count of @widget.
  */
 void
 glade_clipboard_add (GladeClipboard *clipboard, GladeWidget *widget)
Index: src/glade-command.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-command.c,v
retrieving revision 1.34
diff -u -r1.34 glade-command.c
--- src/glade-command.c 5 Nov 2004 19:44:21 -0000       1.34
+++ src/glade-command.c 18 Dec 2004 21:26:05 -0000
@@ -371,7 +371,8 @@
 #define MAX_UNDO_MENU_ITEM_VALUE_LEN   10
 
 void
-glade_command_set_property (GladeProperty *property, const GValue* pvalue)
+glade_command_set_property (GladeProperty *property, const GValue* pvalue,
+                           gboolean from_query_dialog)
 {
        GladeCommandSetProperty *me;
        GladeCommand *cmd;
@@ -408,8 +409,13 @@
        g_assert (cmd->description);
        g_free (value_name);
 
-       glade_command_set_property_execute (GLADE_COMMAND (me));
-       glade_command_push_undo (gwidget->project, GLADE_COMMAND (me));
+       /*
+        * Push onto undo stack only if it executes successfully AND
+        * its not a set property action from a Query Dialog.
+        */ 
+       if (glade_command_set_property_execute (GLADE_COMMAND (me))
+           && !from_query_dialog)
+               glade_command_push_undo (gwidget->project, GLADE_COMMAND (me));
 }
 
 /**************************************************/
@@ -536,8 +542,8 @@
 
        g_debug(("Pushing: %s\n", cmd->description));
 
-       glade_command_set_name_execute (GLADE_COMMAND (me));
-       glade_command_push_undo (widget->project, GLADE_COMMAND (me));
+       if (glade_command_set_name_execute (GLADE_COMMAND (me)))
+               glade_command_push_undo (widget->project, GLADE_COMMAND (me));
 }
 
 /***************************************************
@@ -677,13 +683,13 @@
        me->create       = create;
        me->placeholder  = placeholder;
        cmd->description =
-               g_strdup_printf (_("%s %s"), create ?
-                                "Create" : "Delete", widget->name);
-       
+               g_strdup_printf ("%s %s", (create ? _("Create") : _("Delete")),
+                                widget->name);
+
        if (placeholder)
                g_object_ref (G_OBJECT (placeholder));
 
-       if (glade_command_create_delete_execute (GLADE_COMMAND (me)));
+       if (glade_command_create_delete_execute (GLADE_COMMAND (me)))
                glade_command_push_undo (widget->project, GLADE_COMMAND (me));
 }
 
@@ -698,42 +704,36 @@
 {
        g_return_if_fail (GLADE_IS_WIDGET (widget));
 
-       /* internal children cannot be deleted. Should we notify the user? */
+       /* internal children cannot be deleted. Notify the user. */
        if (widget->internal)
+       {
+               glade_util_ui_warn (glade_project_window_get()->window, _("You cannot delete a widget 
internal to a composite widget."));
                return;
+       }
 
        glade_command_create_delete_common (widget, NULL, FALSE);
 }
 
 /**
- * Creates a new widget.  In placeholder we expect the placeholder that will
- * be substituted by the new widget (if any), and in project the project that
- * the new widget will be assigned to (if NULL, the project will be extracted
- * from the placeholder).
- */
-/**
  * glade_command_create:
- * @class:
- * @placeholder:
- * @project:
+ * @class:             the class of the widget (GtkWindow or GtkButton)
+ * @placeholder:       the placeholder which will be substituted by the widget
+ * @project:            the project his widget belongs to.
  *
- * TODO: write me
+ * Creates a new widget of @class and put in place of the @placeholder
+ * in the @project
  */
 void
 glade_command_create (GladeWidgetClass *class,
                      GladePlaceholder *placeholder,
                      GladeProject *project)
 {
-       GladeProjectWindow *gpw;
        GladeWidget *widget;
        GladeWidget *parent = NULL;
 
        g_return_if_fail (GLADE_IS_WIDGET_CLASS (class));
        g_return_if_fail (placeholder != NULL || GLADE_IS_PROJECT (project));
 
-       gpw = glade_project_window_get ();
-       g_return_if_fail (GLADE_IS_PALETTE (gpw->palette));
-
        if (placeholder)
        {
                parent = glade_util_get_parent (GTK_WIDGET (placeholder));
@@ -750,9 +750,6 @@
                return;
 
        glade_command_create_delete_common (widget, placeholder, TRUE);
-
-       /* reset the palette */
-       glade_palette_unselect_widget (gpw->palette);
 }
 
 typedef enum {
@@ -992,7 +989,8 @@
 
        gpw = glade_project_window_get ();
 
-       if (!placeholder) {
+       if (!placeholder)
+       {
                glade_util_ui_warn (gpw->window, _("Placeholder not selected!"));
                return;
        }
@@ -1020,16 +1018,20 @@
 
        gpw = glade_project_window_get ();
 
-       if (!widget) {
+       if (!widget)
+       {
                glade_util_ui_warn (gpw->window, _("No widget selected!"));
                return;
        }
 
        g_return_if_fail (GLADE_IS_WIDGET (widget));
 
-       /* internal children cannot be cut. Should we notify the user? */
+       /* internal children cannot be cut. Notify the user. */
        if (widget->internal)
+       {
+               glade_util_ui_warn (gpw->window, _("You cannot cut a widget internal to a composite 
widget."));
                return;
+       }
 
        glade_command_cut_copy_paste_common (widget, NULL, widget->project, GLADE_CUT);
 }
@@ -1047,16 +1049,20 @@
 
        gpw = glade_project_window_get ();
 
-       if (!widget) {
+       if (!widget)
+       {
                glade_util_ui_warn (gpw->window, _("No widget selected!"));
                return;
        }
 
        g_return_if_fail (GLADE_IS_WIDGET (widget));
 
-       /* internal children cannot be cut. Should we notify the user? */
+       /* internal children cannot be copied. Notify the user */
        if (widget->internal)
+       {
+               glade_util_ui_warn (gpw->window, _("You cannot copy a widget internal to a composite 
widget."));
                return;
+       }
 
        glade_command_cut_copy_paste_common (widget, NULL, widget->project, GLADE_COPY);
 }
Index: src/glade-command.h
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-command.h,v
retrieving revision 1.11
diff -u -r1.11 glade-command.h
--- src/glade-command.h 5 Nov 2004 19:44:21 -0000       1.11
+++ src/glade-command.h 18 Dec 2004 21:26:05 -0000
@@ -44,7 +44,7 @@
 void glade_command_undo                        (GladeProject *project);
 void glade_command_redo                        (GladeProject *project);
 
-void glade_command_set_property                (GladeProperty *property, const GValue *value);
+void glade_command_set_property                (GladeProperty *property, const GValue *value, gboolean 
from_query_dialog);
 void glade_command_set_name            (GladeWidget *glade_widget, const gchar *name);
 
 void glade_command_delete              (GladeWidget *glade_widget);
Index: src/glade-editor.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-editor.c,v
retrieving revision 1.61
diff -u -r1.61 glade-editor.c
--- src/glade-editor.c  15 Nov 2004 18:37:33 -0000      1.61
+++ src/glade-editor.c  18 Dec 2004 21:26:06 -0000
@@ -44,8 +44,13 @@
 #include "glade-project.h"
 #include "glade-utils.h"
 
-static void glade_editor_class_init (GladeEditorClass *class);
-static void glade_editor_init (GladeEditor *editor);
+       /*
+        * FIXME: Using GtkWidgets which are part of the GtkEditorTable
+        * means, that a a GladeCommand gets set on the undo_stack, if the
+        * user changes a value in the query dialog for a property e.g.
+        * the number of children for a GtkBox. This is the source of a few
+        * problems.
+        */
 
 enum
 {
@@ -58,47 +63,10 @@
 
 static GtkNotebookClass *parent_class = NULL;
 
-/* We use this function recursively so we need to declare it */
-static gboolean glade_editor_table_append_items (GladeEditorTable *table,
-                                                GladeWidgetClass *class,
-                                                GList **list,
-                                                GladeEditorTableType type);
-
 static void glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget);
 
 static void glade_editor_property_load_flags (GladeEditorProperty *property);
 
-/**
- * glade_editor_get_type:
- *
- * Creates the typecode for the #GladeEditor object type.
- *
- * Returns: the typecode for the #GladeEditor object type
- */
-GType
-glade_editor_get_type (void)
-{
-       static GType type = 0;
-
-       if (!type) {
-               static const GTypeInfo info = {
-                       sizeof (GladeEditorClass),
-                       (GBaseInitFunc) NULL,
-                       (GBaseFinalizeFunc) NULL,
-                       (GClassInitFunc) glade_editor_class_init,
-                       (GClassFinalizeFunc) NULL,
-                       NULL,
-                       sizeof (GladeEditor),
-                       0,
-                       (GInstanceInitFunc) glade_editor_init
-               };
-
-               type = g_type_register_static (GTK_TYPE_NOTEBOOK, "GladeEditor", &info, 0);
-       }
-
-       return type;
-}
-
 static void
 glade_editor_class_init (GladeEditorClass *class)
 {
@@ -170,6 +138,37 @@
 }
 
 /**
+ * glade_editor_get_type:
+ *
+ * Creates the typecode for the #GladeEditor object type.
+ *
+ * Returns: the typecode for the #GladeEditor object type
+ */
+GType
+glade_editor_get_type (void)
+{
+       static GType type = 0;
+
+       if (!type) {
+               static const GTypeInfo info = {
+                       sizeof (GladeEditorClass),
+                       (GBaseInitFunc) NULL,
+                       (GBaseFinalizeFunc) NULL,
+                       (GClassInitFunc) glade_editor_class_init,
+                       (GClassFinalizeFunc) NULL,
+                       NULL,
+                       sizeof (GladeEditor),
+                       0,
+                       (GInstanceInitFunc) glade_editor_init
+               };
+
+               type = g_type_register_static (GTK_TYPE_NOTEBOOK, "GladeEditor", &info, 0);
+       }
+
+       return type;
+}
+
+/**
  * glade_editor_new:
  *
  * Returns: a new #GladeEditor
@@ -214,14 +213,15 @@
 /* ============================ Property Changed ============================ */
 static void
 glade_editor_property_changed_text_common (GladeProperty *property,
-                                          const gchar *text)
+                                          const gchar *text,
+                                          gboolean from_query_dialog)
 {
        GValue val = { 0, };
 
        g_value_init (&val, G_TYPE_STRING);
        g_value_set_string (&val, text);
 
-       glade_command_set_property (property, &val);
+       glade_command_set_property (property, &val, from_query_dialog);
 
        g_value_unset (&val);
 }
@@ -239,7 +239,8 @@
        
        text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
 
-       glade_editor_property_changed_text_common (property->property, text);
+       glade_editor_property_changed_text_common (property->property, text,
+                                                  property->from_query_dialog);
 
        g_free (text);
 
@@ -265,7 +266,8 @@
 
        text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
 
-       glade_editor_property_changed_text_common (property->property, text);
+       glade_editor_property_changed_text_common (property->property, text,
+                                                  property->from_query_dialog);
 
        g_free (text);
 
@@ -292,7 +294,7 @@
 
        g_value_init (&val, gproperty->class->pspec->value_type);
        g_value_set_enum (&val, ival);
-       glade_command_set_property (gproperty, &val);
+       glade_command_set_property (gproperty, &val, property->from_query_dialog);
 
        g_value_unset (&val);
 
@@ -379,7 +381,8 @@
                g_warning ("Unsupported type %s\n",
                           g_type_name(property->class->pspec->value_type));
 
-       glade_command_set_property (property->property, &val);
+       glade_command_set_property (property->property, &val,
+                                   property->from_query_dialog);
 
        g_value_unset (&val);
 
@@ -406,7 +409,7 @@
 
        g_value_init (&val, G_TYPE_BOOLEAN);
        g_value_set_boolean (&val, state);
-       glade_command_set_property (property->property, &val);
+       glade_command_set_property (property->property, &val, property->from_query_dialog);
 
        g_value_unset (&val);
 
@@ -434,7 +437,7 @@
 
        g_value_init (&val, G_TYPE_UINT);
        g_value_set_uint (&val, unich);
-       glade_command_set_property (property->property, &val);
+       glade_command_set_property (property->property, &val, property->from_query_dialog);
 
        g_value_unset (&val);
        g_free (text);
@@ -627,7 +630,7 @@
 
                        g_value_init (&val, G_VALUE_TYPE (property->property->value));
                        g_value_set_flags (&val, new_value);
-                       glade_command_set_property (property->property, &val);
+                       glade_command_set_property (property->property, &val, property->from_query_dialog);
                        g_value_unset (&val);
 
                        /* Update the entry in the property editor. */
@@ -921,7 +924,8 @@
 
 static GladeEditorProperty *
 glade_editor_table_append_item (GladeEditorTable *table,
-                               GladePropertyClass *class)
+                               GladePropertyClass *class,
+                               gboolean from_query_dialog)
 {
        GladeEditorProperty *property;
 
@@ -930,9 +934,12 @@
        property->class = class;
        property->children = NULL;
 
+       /* Set this before creating the widget. */
+       property->from_query_dialog = from_query_dialog;
        property->input = glade_editor_append_item_real (table, property);
        property->property = NULL;
 
+
        return property;
 }
 
@@ -996,7 +1003,11 @@
                else if (type == TABLE_TYPE_COMMON && property_class->common == FALSE)
                        continue;
 
-               property = glade_editor_table_append_item (table, property_class);
+               if (type == TABLE_TYPE_QUERY)
+                       property = glade_editor_table_append_item (table, property_class, TRUE);
+               else
+                       property = glade_editor_table_append_item (table, property_class, FALSE);
+                       
                if (property != NULL)
                        new_list = g_list_prepend (new_list, property);
        }
@@ -1532,7 +1543,7 @@
                                continue;
 
                        g_assert (property_class->packing == TRUE);
-                       editor_property = glade_editor_table_append_item (table, property_class);
+                       editor_property = glade_editor_table_append_item (table, property_class, FALSE);
                        old_props = g_list_prepend (old_props, editor_property);
                        glade_editor_property_load (editor_property, widget);
                }
@@ -1635,43 +1646,54 @@
                       widget_name, widget_type, signal_id, callback_name);
 }
 
-
-void
-glade_editor_query_popup (GladeEditor *editor, GladeWidget *widget)
+gboolean
+glade_editor_query_dialog (GladeEditor *editor, GladeWidget *widget)
 {
        GtkWidget           *dialog;
        GladeEditorTable    *table;
        gchar               *title;
        GList               *list;
        GladeEditorProperty *property;
+       gint                 answer;
+       gboolean             retval = TRUE;
 
        title = g_strdup_printf (_("Create a %s"), widget->widget_class->name);
 
        dialog = gtk_dialog_new_with_buttons
                (title, NULL,
                 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT |
-                GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
+                GTK_DIALOG_NO_SEPARATOR,
+                GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                GTK_STOCK_OK, GTK_RESPONSE_OK,
+                NULL);
        g_free (title);
 
        table = glade_editor_get_table_from_class (editor,
                                                   widget->widget_class,
                                                   TABLE_TYPE_QUERY);
 
-       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table->table_widget,
+       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
+                           table->table_widget,
                            TRUE, TRUE, 4);
-       
        for (list = table->properties; list; list = list->next)
        {
                property = list->data;
                glade_editor_property_load (property, widget);
        }
 
-       gtk_window_set_default_size (GTK_WINDOW(dialog), 300, -1);
+       answer = gtk_dialog_run (GTK_DIALOG (dialog));
 
-       gtk_dialog_run (GTK_DIALOG (dialog));
+       /*
+        * If user cancel's we cancel the whole "create operation" by
+        * return FALSE. glade_widget_new() will see the FALSE, and
+        * take care of canceling the "create" operation.
+        */
+       if (answer == GTK_RESPONSE_CANCEL)
+               retval = FALSE;
 
        gtk_container_remove (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
                              table->table_widget);
        
        gtk_widget_destroy (dialog);
+       return retval;
 }
Index: src/glade-editor.h
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-editor.h,v
retrieving revision 1.17
diff -u -r1.17 glade-editor.h
--- src/glade-editor.h  3 Nov 2004 05:53:04 -0000       1.17
+++ src/glade-editor.h  18 Dec 2004 21:26:06 -0000
@@ -163,8 +163,8 @@
 struct _GladeEditorProperty
 {
        GladePropertyClass *class; /* The class this property
-                                                  * corresponds to.
-                                                  */
+                                   * corresponds to.
+                                   */
 
        GladeProperty *property; /* The loaded GladeProperty
                                  */
@@ -185,6 +185,10 @@
        GList *children; /* Used for class->type = OBJECT. Where a sigle entry corresponds
                          * to a number of inputs
                          */
+
+       gboolean from_query_dialog; /* If this input is part of a query dialog
+                                    * this is TRUE.
+                                    */
 };
 
 GType glade_editor_get_type (void);
@@ -194,7 +198,8 @@
 void glade_editor_load_widget (GladeEditor *editor, GladeWidget *widget);
 void glade_editor_add_signal (GladeEditor *editor, guint id_signal, const char *callback_name);
 void glade_editor_update_widget_name (GladeEditor *editor);
-void glade_editor_query_popup (GladeEditor *editor, GladeWidget *widget);
+
+gboolean glade_editor_query_dialog (GladeEditor *editor, GladeWidget *widget);
 
 
 G_END_DECLS
Index: src/glade-placeholder.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-placeholder.c,v
retrieving revision 1.56
diff -u -r1.56 glade-placeholder.c
--- src/glade-placeholder.c     4 Oct 2004 15:45:22 -0000       1.56
+++ src/glade-placeholder.c     18 Dec 2004 21:26:07 -0000
@@ -26,6 +26,7 @@
 #include "glade-project-window.h"
 #include "glade-project.h"
 #include "glade-command.h"
+#include "glade-palette.h"
 #include "glade-popup.h"
 #include "glade-cursor.h"
 #include "glade-widget.h"
@@ -298,28 +299,32 @@
 {
        GladeProjectWindow *gpw;
        GladePlaceholder *placeholder;
+       GladeProject *project;
 
        g_return_val_if_fail (GLADE_IS_PLACEHOLDER (widget), FALSE);
 
        gpw = glade_project_window_get ();
        placeholder = GLADE_PLACEHOLDER (widget);
+       project = glade_placeholder_get_project (placeholder);
 
        if (!GTK_WIDGET_HAS_FOCUS (widget))
                gtk_widget_grab_focus (widget);
 
        if (event->button == 1 && event->type == GDK_BUTTON_PRESS)
        {
-               if (gpw->add_class != NULL) {
+               if (gpw->add_class != NULL)
+               {
                        /* A widget type is selected in the palette.
                         * Add a new widget of that type.
                         */
-                       glade_command_create (gpw->add_class, placeholder, NULL);
+                       glade_command_create (gpw->add_class, placeholder,
+                                             project);
+
+                       /* reset the palette */
+                       glade_palette_unselect_widget (gpw->palette);
                }
                else
                {
-                       GladeProject *project;
-
-                       project = glade_placeholder_get_project (placeholder);
                        glade_project_selection_set (project, GTK_WIDGET (placeholder), TRUE);
                }
        }
Index: src/glade-project-window.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-project-window.c,v
retrieving revision 1.88
diff -u -r1.88 glade-project-window.c
--- src/glade-project-window.c  16 Dec 2004 21:24:02 -0000      1.88
+++ src/glade-project-window.c  18 Dec 2004 21:26:07 -0000
@@ -47,6 +47,8 @@
 #include <gtk/gtkstock.h>
 
 const gchar *WINDOW_TITLE = "Glade-3 GUI Builder";
+const gint   GLADE_WIDGET_TREE_WIDTH  = 230;
+const gint   GLADE_WIDGET_TREE_HEIGHT = 300;
 
 static void
 gpw_refresh_title (GladeProjectWindow *gpw)
@@ -715,7 +717,9 @@
        GtkWidget *widget_tree_item;
 
        widget_tree = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-       gtk_window_set_default_size (GTK_WINDOW (widget_tree), 230, 300);
+       gtk_window_set_default_size (GTK_WINDOW (widget_tree),
+                                    GLADE_WIDGET_TREE_WIDTH,
+                                    GLADE_WIDGET_TREE_HEIGHT);
        gtk_window_set_title (GTK_WINDOW (widget_tree), _("Widget Tree"));
 
        view = glade_project_view_new (GLADE_PROJECT_VIEW_TREE);
Index: src/glade-project.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-project.c,v
retrieving revision 1.57
diff -u -r1.57 glade-project.c
--- src/glade-project.c 5 Nov 2004 19:44:21 -0000       1.57
+++ src/glade-project.c 18 Dec 2004 21:26:08 -0000
@@ -618,13 +618,10 @@
                             GtkWidget *widget,
                             gboolean emit_signal)
 {
-       GladeProjectWindow *gpw;
        gboolean            has_nodes;
        g_return_if_fail (GLADE_IS_PROJECT (project));
        g_return_if_fail (GTK_IS_WIDGET (widget));
 
-       gpw       = glade_project_window_get ();
-
        if (glade_util_has_nodes (widget))
                return;
 
@@ -653,12 +650,9 @@
                             GtkWidget *widget,
                             gboolean emit_signal)
 {
-       GladeProjectWindow *gpw;
        g_return_if_fail (GLADE_IS_PROJECT (project));
        g_return_if_fail (GTK_IS_WIDGET (widget));
 
-       gpw    = glade_project_window_get ();
-       
        if (glade_util_has_nodes (widget))
                return;
            
Index: src/glade-property-class.h
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-property-class.h,v
retrieving revision 1.35
diff -u -r1.35 glade-property-class.h
--- src/glade-property-class.h  15 Nov 2004 18:37:33 -0000      1.35
+++ src/glade-property-class.h  18 Dec 2004 21:26:08 -0000
@@ -124,7 +124,7 @@
        gboolean optional; /* Some properties are optional by nature like
                            * default width. It can be set or not set. A
                            * default property has a check box in the
-                           * left that enables/disables de input
+                           * left that enables/disables the input
                            */
 
        gboolean optional_default; /* For optional values, what the default is */
Index: src/glade-widget.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-widget.c,v
retrieving revision 1.122
diff -u -r1.122 glade-widget.c
--- src/glade-widget.c  15 Nov 2004 18:37:33 -0000      1.122
+++ src/glade-widget.c  18 Dec 2004 21:26:09 -0000
@@ -472,7 +472,10 @@
                if (widget->query_user)
                {
                        GladeProjectWindow *gpw = glade_project_window_get ();
-                       glade_editor_query_popup (gpw->editor, widget);
+
+                       /* If user pressed cancel on query popup. */
+                       if (!glade_editor_query_dialog (gpw->editor, widget))
+                               return NULL;
                }
 
                /* Properties that have custom set_functions on them need to be

--Boundary_(ID_8P0Uj1NiZSlnXJFBU8uz5A)--




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