glade3 r2029 - in trunk: . gladeui src
- From: tvb svn gnome org
- To: svn-commits-list gnome org
- Subject: glade3 r2029 - in trunk: . gladeui src
- Date: Sat, 15 Nov 2008 18:54:54 +0000 (UTC)
Author: tvb
Date: Sat Nov 15 18:54:53 2008
New Revision: 2029
URL: http://svn.gnome.org/viewvc/glade3?rev=2029&view=rev
Log:
* src/glade-window.c: Update glade-app accel group.
* gladeui/glade-project.[ch], gladeui/glade-app.c: Remove accel group notion from projects
* gladeui/glade-base-editor.c:
- Use global accel group (with keypress editor hijack in place)
- No longer modal
- added "container" property on the editor
- dedicated dialogs self destruct if their container changes
Modified:
trunk/ChangeLog
trunk/gladeui/glade-app.c
trunk/gladeui/glade-base-editor.c
trunk/gladeui/glade-project.c
trunk/gladeui/glade-project.h
trunk/src/glade-window.c
Modified: trunk/gladeui/glade-app.c
==============================================================================
--- trunk/gladeui/glade-app.c (original)
+++ trunk/gladeui/glade-app.c Sat Nov 15 18:54:53 2008
@@ -954,9 +954,6 @@
g_signal_connect (G_OBJECT (project), "selection_changed",
G_CALLBACK (on_project_selection_changed_cb), app);
- /* add acceleration groups to every top level widget */
- if (app->priv->accel_group)
- glade_project_set_accel_group (project, app->priv->accel_group);
glade_app_set_project (project);
@@ -1349,8 +1346,6 @@
glade_app_command_delete_clipboard (void)
{
GladeClipboard *clipboard;
- GladeWidget *gwidget;
- GList *list;
clipboard = glade_app_get_clipboard ();
@@ -1396,23 +1391,16 @@
* glade_app_set_accel_group:
*
* Sets @accel_group to app.
- * The acceleration group will be attached to every toplevel widget in this application.
+ * The acceleration group will made available for editor dialog windows
+ * from the plugin backend.
*/
void
glade_app_set_accel_group (GtkAccelGroup *accel_group)
{
GladeApp *app;
- GList *l;
- GladeProject *project;
g_return_if_fail(GTK_IS_ACCEL_GROUP (accel_group));
app = glade_app_get ();
-
- for (l = app->priv->projects; l; l = l->next)
- {
- project = l->data;
- glade_project_set_accel_group (project, accel_group);
- }
app->priv->accel_group = accel_group;
}
Modified: trunk/gladeui/glade-base-editor.c
==============================================================================
--- trunk/gladeui/glade-base-editor.c (original)
+++ trunk/gladeui/glade-base-editor.c Sat Nov 15 18:54:53 2008
@@ -33,6 +33,7 @@
#include "glade-marshallers.h"
#include "glade-editor-property.h"
#include "glade-base-editor.h"
+#include "glade-app.h"
#include "glade-accumulators.h"
#include <string.h>
@@ -83,10 +84,7 @@
guint properties_idle;
};
-typedef struct _GladeBaseEditorSignal GladeBaseEditorSignal;
-
-typedef enum _GladeBaseEditorSignalType
-{
+enum {
SIGNAL_CHILD_SELECTED,
SIGNAL_CHANGE_TYPE,
SIGNAL_GET_DISPLAY_NAME,
@@ -94,13 +92,14 @@
SIGNAL_DELETE_CHILD,
SIGNAL_MOVE_CHILD,
LAST_SIGNAL
-} GladeBaseEditorSignalType;
+};
-struct _GladeBaseEditorSignal
-{
- GladeBaseEditor *object;
+enum {
+ PROP_0,
+ PROP_CONTAINER,
};
+
static guint glade_base_editor_signals [LAST_SIGNAL] = { 0 };
static GtkVBoxClass *parent_class = NULL;
@@ -1032,6 +1031,7 @@
gtk_list_store_clear (e->children);
gtk_widget_set_sensitive (e->paned, FALSE);
glade_base_editor_block_callbacks (editor, FALSE);
+ g_object_notify (G_OBJECT (editor), "container");
return;
}
@@ -1060,6 +1060,8 @@
g_signal_connect (e->project, "changed",
G_CALLBACK (glade_base_editor_project_changed),
editor);
+
+ g_object_notify (G_OBJECT (editor), "container");
}
/*************************** GladeBaseEditor Class ****************************/
@@ -1076,6 +1078,45 @@
G_OBJECT_CLASS(parent_class)->finalize(object);
}
+static void
+glade_base_editor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GladeBaseEditor *editor = GLADE_BASE_EDITOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_CONTAINER:
+ glade_base_editor_set_container (editor, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+glade_base_editor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GladeBaseEditor *editor = GLADE_BASE_EDITOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_CONTAINER:
+ g_value_set_object (value, editor->priv->gcontainer->object);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
/* Default handlers */
static gboolean
glade_base_editor_change_type (GladeBaseEditor *editor,
@@ -1216,13 +1257,22 @@
GObjectClass *object_class = G_OBJECT_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
- object_class->finalize = glade_base_editor_finalize;
- klass->change_type = glade_base_editor_change_type;
+ object_class->finalize = glade_base_editor_finalize;
+ object_class->set_property = glade_base_editor_set_property;
+ object_class->get_property = glade_base_editor_get_property;
+
+ klass->change_type = glade_base_editor_change_type;
klass->get_display_name = glade_base_editor_get_display_name_impl;
- klass->build_child = glade_base_editor_build_child;
- klass->delete_child = glade_base_editor_delete_child_impl;
- klass->move_child = glade_base_editor_move_child;
+ klass->build_child = glade_base_editor_build_child;
+ klass->delete_child = glade_base_editor_delete_child_impl;
+ klass->move_child = glade_base_editor_move_child;
+
+ g_object_class_install_property (object_class, PROP_CONTAINER,
+ g_param_spec_object
+ ("container", _("Container"),
+ _("The container object this editor is currently editing"),
+ G_TYPE_OBJECT, G_PARAM_READWRITE));
/**
* GladeBaseEditor::child-selected:
@@ -1481,7 +1531,7 @@
/* ScrolledWindow */
scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scroll);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_NONE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
@@ -1867,13 +1917,36 @@
gtk_widget_destroy (dialog);
}
+/* This function is meant to be attached to key-press-event of a toplevel,
+ * it simply allows the window contents to treat key events /before/
+ * accelerator keys come into play (this way widgets dont get deleted
+ * when cutting text in an entry etc.).
+ */
+static gint
+hijack_key_press (GtkWindow *window,
+ GdkEventKey *event,
+ gpointer user_data)
+{
+ if (window->focus_widget &&
+ (event->keyval == GDK_Delete || /* Filter Delete from accelerator keys */
+ ((event->state & GDK_CONTROL_MASK) && /* CNTL keys... */
+ ((event->keyval == GDK_c || event->keyval == GDK_C) || /* CNTL-C (copy) */
+ (event->keyval == GDK_x || event->keyval == GDK_X) || /* CNTL-X (cut) */
+ (event->keyval == GDK_v || event->keyval == GDK_V))))) /* CNTL-V (paste) */
+ {
+ return gtk_widget_event (window->focus_widget,
+ (GdkEvent *)event);
+ }
+ return FALSE;
+}
+
/**
* glade_base_editor_pack_new_window:
* @editor: a #GladeBaseEditor
* @title: the window title
* @help_markup: the help text
*
- * This convenience function create a new modal window and packs @editor in it.
+ * This convenience function create a new dialog window and packs @editor in it.
*
* Returns: the newly created window
*/
@@ -1889,7 +1962,6 @@
/* Window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_modal (GTK_WINDOW (window), TRUE);
gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DIALOG);
if (title)
@@ -1899,6 +1971,9 @@
gtk_window_set_title (GTK_WINDOW (window), real_title);
g_free (real_title);
}
+
+ g_signal_connect_swapped (G_OBJECT (editor), "notify::container",
+ G_CALLBACK (gtk_widget_destroy), window);
/* Button Box */
buttonbox = gtk_hbutton_box_new ();
@@ -1907,14 +1982,6 @@
gtk_box_set_spacing (GTK_BOX (buttonbox), 8);
gtk_box_pack_start (GTK_BOX (editor), buttonbox, FALSE, TRUE, 0);
- button = glade_app_undo_button_new ();
- gtk_widget_show (button);
- gtk_container_add (GTK_CONTAINER (buttonbox), button);
-
- button = glade_app_redo_button_new ();
- gtk_widget_show (button);
- gtk_container_add (GTK_CONTAINER (buttonbox), button);
-
button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
gtk_widget_show (button);
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
@@ -1930,7 +1997,16 @@
gtk_container_add (GTK_CONTAINER (buttonbox), button);
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (buttonbox), button, TRUE);
}
-
+
+ if (glade_app_get_accel_group ())
+ {
+ gtk_window_add_accel_group (GTK_WINDOW (window),
+ glade_app_get_accel_group ());
+ g_signal_connect (G_OBJECT (window), "key-press-event",
+ G_CALLBACK (hijack_key_press), NULL);
+ }
+
+
gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (editor));
Modified: trunk/gladeui/glade-project.c
==============================================================================
--- trunk/gladeui/glade-project.c (original)
+++ trunk/gladeui/glade-project.c Sat Nov 15 18:54:53 2008
@@ -3091,37 +3091,6 @@
}
/**
- * glade_project_set_accel_group:
- * @project: A #GladeProject
- * @accel_group: The @GtkAccelGroup
- *
- * Set @accel_group to every top level widget in @project.
- */
-void
-glade_project_set_accel_group (GladeProject *project, GtkAccelGroup *accel_group)
-{
- GList *objects;
-
- g_return_if_fail (GLADE_IS_PROJECT (project) && GTK_IS_ACCEL_GROUP (accel_group));
-
- objects = project->priv->objects;
- while (objects)
- {
- if(GTK_IS_WINDOW (objects->data))
- {
- if (project->priv->accel_group)
- gtk_window_remove_accel_group (GTK_WINDOW (objects->data), project->priv->accel_group);
-
- gtk_window_add_accel_group (GTK_WINDOW (objects->data), accel_group);
- }
-
- objects = objects->next;
- }
-
- project->priv->accel_group = accel_group;
-}
-
-/**
* glade_project_resource_fullpath:
* @project: The #GladeProject.
* @resource: The resource basename
Modified: trunk/gladeui/glade-project.h
==============================================================================
--- trunk/gladeui/glade-project.h (original)
+++ trunk/gladeui/glade-project.h Sat Nov 15 18:54:53 2008
@@ -152,9 +152,6 @@
gboolean glade_project_get_has_selection (GladeProject *project);
-void glade_project_set_accel_group (GladeProject *project,
- GtkAccelGroup *accel_group);
-
gchar *glade_project_resource_fullpath (GladeProject *project,
const gchar *resource);
Modified: trunk/src/glade-window.c
==============================================================================
--- trunk/src/glade-window.c (original)
+++ trunk/src/glade-window.c Sat Nov 15 18:54:53 2008
@@ -2314,7 +2314,9 @@
gtk_ui_manager_insert_action_group (window->priv->ui, window->priv->projects_list_menu_actions, 3);
gtk_window_add_accel_group (GTK_WINDOW (window),
- gtk_ui_manager_get_accel_group (window->priv->ui));
+ gtk_ui_manager_get_accel_group (window->priv->ui));
+
+ glade_app_set_accel_group (gtk_ui_manager_get_accel_group (window->priv->ui));
if (!gtk_ui_manager_add_ui_from_string (window->priv->ui, ui_info, -1, &error))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]