[Glade-devel] Oops! Here's the patch
- From: bighead users sourceforge net (Archit Baweja)
- Subject: [Glade-devel] Oops! Here's the patch
- Date: Fri, 17 Dec 2004 17:16:57 -0500
--Boundary_(ID_JHQXlbvjrr4iQdB1uoK/eg)
Content-type: text/plain
Content-transfer-encoding: 7BIT
Here's the patch.
Archit
--Boundary_(ID_JHQXlbvjrr4iQdB1uoK/eg)
Content-type: text/x-patch; name=glade3-cleanup-and-query-popup-fix.diff;
charset=UTF-8
Content-transfer-encoding: 7BIT
Content-disposition: attachment;
filename=glade3-cleanup-and-query-popup-fix.diff
? depcomp
? install-sh
? stamp-h1
? test.glade3
? src/foo.glade
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 17 Dec 2004 22:13:47 -0000
@@ -1,3 +1,33 @@
+2004-12-17 Archit Baweja <bighead users sourceforge net>
+
+ * 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: autogen.sh
===================================================================
RCS file: /cvs/gnome/glade3/autogen.sh,v
retrieving revision 1.5
diff -u -r1.5 autogen.sh
--- autogen.sh 16 Dec 2004 21:24:02 -0000 1.5
+++ autogen.sh 17 Dec 2004 22:13:47 -0000
@@ -39,7 +39,7 @@
exit 1
fi
-automake_version=1.7
+automake_version=
case `uname` in
CYGWIN*)
# automake 1.4 of cygwin does not define EGREP in libtool.m4, and
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 17 Dec 2004 22:13:48 -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 17 Dec 2004 22:13:48 -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 17 Dec 2004 22:13:49 -0000
@@ -677,8 +677,8 @@
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));
@@ -698,42 +698,38 @@
{
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);
}
/**
+ * glade_command_create:
+ * @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.
+ *
* 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:
- *
- * TODO: write me
- */
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 +746,6 @@
return;
glade_command_create_delete_common (widget, placeholder, TRUE);
-
- /* reset the palette */
- glade_palette_unselect_widget (gpw->palette);
}
typedef enum {
@@ -1020,16 +1013,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 +1044,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-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 17 Dec 2004 22:13:50 -0000
@@ -58,12 +58,6 @@
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);
@@ -1636,7 +1630,7 @@
}
-void
+gboolean
glade_editor_query_popup (GladeEditor *editor, GladeWidget *widget)
{
GtkWidget *dialog;
@@ -1644,34 +1638,46 @@
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 17 Dec 2004 22:13:50 -0000
@@ -194,7 +194,7 @@
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_popup (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 17 Dec 2004 22:13:51 -0000
@@ -298,28 +298,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 17 Dec 2004 22:13:52 -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-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 17 Dec 2004 22:13:52 -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 17 Dec 2004 22:13:53 -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_popup (gpw->editor, widget))
+ return NULL;
}
/* Properties that have custom set_functions on them need to be
--Boundary_(ID_JHQXlbvjrr4iQdB1uoK/eg)--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]