mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-09-24 00:04:33 -04:00
Added autogenerated keysyms (but not autogenerating them at the moment).
* src/Makefile.am, src/glade-keysyms.c: Added autogenerated keysyms (but not autogenerating them at the moment). * src/glade-builtins.[ch]: Added GLADE_TYPE_ACCEL_GLIST, GLADE_PARAM_SPEC_ACCEL and some convenience funcs. * src/glade-editor-property.c: Added GladeEpropAccel. * src/glade-editor.c: take accel props into account * src/glade-parser.c: Make strings for GdkModifierType in dump_widget. * src/glade-property-class.c, src/glade-widget-class.c: o Now you can get the GladeWidgetClass from the GladePropertyClass o Added string conversion from GladeParamSpecAccel properties (but vise versa) o GladeWidgetClassSignal --> GladeSignalClass, not GSignalQuery struct is included too. * src/glade-property.c, src/glade-widget.c: Load/save support for accel properties.
This commit is contained in:
parent
52ac2c4117
commit
26620fb9cb
23
ChangeLog
23
ChangeLog
@ -1,3 +1,26 @@
|
||||
2006-06-05 Tristan Van Berkom <tvb@gnome.org>
|
||||
|
||||
* src/Makefile.am, src/glade-keysyms.c: Added autogenerated keysyms
|
||||
(but not autogenerating them at the moment).
|
||||
|
||||
* src/glade-builtins.[ch]: Added GLADE_TYPE_ACCEL_GLIST, GLADE_PARAM_SPEC_ACCEL
|
||||
and some convenience funcs.
|
||||
|
||||
* src/glade-editor-property.c: Added GladeEpropAccel.
|
||||
|
||||
* src/glade-editor.c: take accel props into account
|
||||
|
||||
* src/glade-parser.c: Make strings for GdkModifierType in dump_widget.
|
||||
|
||||
* src/glade-property-class.c, src/glade-widget-class.c:
|
||||
o Now you can get the GladeWidgetClass from the GladePropertyClass
|
||||
o Added string conversion from GladeParamSpecAccel properties
|
||||
(but vise versa)
|
||||
o GladeWidgetClassSignal --> GladeSignalClass, not GSignalQuery struct
|
||||
is included too.
|
||||
|
||||
* src/glade-property.c, src/glade-widget.c: Load/save support for accel properties.
|
||||
|
||||
2006-06-03 Vincent Geddes <vgeddes@metroweb.co.za>
|
||||
|
||||
* src/glade-project-window.c, src/glade-app.[ch],
|
||||
|
@ -81,7 +81,8 @@ libgladeui_1_la_SOURCES = \
|
||||
glade-parser.c \
|
||||
glade-builtins.c \
|
||||
glade-fixed-manager.c \
|
||||
glade-app.c
|
||||
glade-app.c \
|
||||
glade-keysyms.c
|
||||
|
||||
libgladeui_1_la_CFLAGS = \
|
||||
-DINSIDE_LIBGLADEUI \
|
||||
|
@ -29,14 +29,25 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <string.h>
|
||||
#include "glade-builtins.h"
|
||||
|
||||
|
||||
|
||||
struct _GladeParamSpecObjects {
|
||||
GParamSpec parent_instance;
|
||||
|
||||
GType type;
|
||||
GType type; /* Object or interface type accepted
|
||||
* in this object list.
|
||||
*/
|
||||
};
|
||||
|
||||
struct _GladeParamSpecAccel {
|
||||
GParamSpec parent_instance;
|
||||
|
||||
GType type; /* The type this accel key is for; this allows
|
||||
* us to verify the validity of any signals for
|
||||
* this type.
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
@ -114,12 +125,74 @@ glade_glist_get_type (void)
|
||||
return type_id;
|
||||
}
|
||||
|
||||
GList *
|
||||
glade_accel_list_copy (GList *accels)
|
||||
{
|
||||
GList *ret = NULL, *list;
|
||||
GladeAccelInfo *info, *dup_info;
|
||||
|
||||
for (list = accels; list; list = list->next)
|
||||
{
|
||||
info = list->data;
|
||||
|
||||
dup_info = g_new0 (GladeAccelInfo, 1);
|
||||
dup_info->signal = g_strdup (info->signal);
|
||||
dup_info->key = info->key;
|
||||
dup_info->modifiers = info->modifiers;
|
||||
|
||||
ret = g_list_prepend (ret, dup_info);
|
||||
}
|
||||
|
||||
return g_list_reverse (ret);
|
||||
}
|
||||
|
||||
void
|
||||
glade_accel_list_free (GList *accels)
|
||||
{
|
||||
GList *list;
|
||||
GladeAccelInfo *info;
|
||||
|
||||
for (list = accels; list; list = list->next)
|
||||
{
|
||||
info = list->data;
|
||||
|
||||
g_free (info->signal);
|
||||
g_free (info);
|
||||
}
|
||||
g_list_free (accels);
|
||||
}
|
||||
|
||||
GType
|
||||
glade_accel_glist_get_type (void)
|
||||
{
|
||||
static GType type_id = 0;
|
||||
|
||||
if (!type_id)
|
||||
type_id = g_boxed_type_register_static
|
||||
("GladeAccelGList",
|
||||
(GBoxedCopyFunc) glade_accel_list_copy,
|
||||
(GBoxedFreeFunc) glade_accel_list_free);
|
||||
return type_id;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Built-in GladeParamSpecAccel for accelerator properties *
|
||||
****************************************************************/
|
||||
#if 0
|
||||
gboolean
|
||||
glade_keyval_valid (guint val)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; GladeKeys[i].name != NULL; i++)
|
||||
{
|
||||
if (GladeKeys[i].value == val)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
param_accel_init (GParamSpec *pspec)
|
||||
{
|
||||
@ -129,7 +202,7 @@ param_accel_init (GParamSpec *pspec)
|
||||
|
||||
static void
|
||||
param_accel_set_default (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
GValue *value)
|
||||
{
|
||||
if (value->data[0].v_pointer != NULL)
|
||||
{
|
||||
@ -142,30 +215,29 @@ static gboolean
|
||||
param_accel_validate (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
{
|
||||
GladeParamSpecAccel *ospec = GLADE_PARAM_SPEC_ACCEL (pspec);
|
||||
//GladeParamSpecAccel *aspec = GLADE_PARAM_SPEC_ACCEL (pspec);
|
||||
GList *accels, *list, *toremove = NULL;
|
||||
GladeAccelInfo *info;
|
||||
|
||||
accel = value->data[0].v_pointer;
|
||||
accels = value->data[0].v_pointer;
|
||||
|
||||
for (list = accels; list; list = list->next)
|
||||
{
|
||||
info = list->data;
|
||||
|
||||
/* Is it a valid key ? */
|
||||
if (info->key /* XXX */ ||
|
||||
/* Is it an invalid key ? */
|
||||
if (glade_keyval_valid (info->key) == FALSE ||
|
||||
/* Does the modifier contain any unwanted bits ? */
|
||||
info->modifier & GLADE_MODIFIER_MASK ||
|
||||
info->modifiers & GDK_MODIFIER_MASK ||
|
||||
/* Do we have a signal ? */
|
||||
/* FIXME: Check if the signal is valid for 'type' */
|
||||
info->signal == NULL)
|
||||
toremove = g_list_prepend (toremove, info);
|
||||
}
|
||||
|
||||
for (list = toremove; list; list = list->next)
|
||||
{
|
||||
object = list->data;
|
||||
accels = g_list_remove (accels, object);
|
||||
}
|
||||
accels = g_list_remove (accels, list->data);
|
||||
|
||||
if (toremove) g_list_free (toremove);
|
||||
|
||||
value->data[0].v_pointer = accels;
|
||||
@ -203,7 +275,7 @@ glade_param_accel_get_type (void)
|
||||
param_accel_validate, /* value_validate */
|
||||
param_accel_values_cmp, /* values_cmp */
|
||||
};
|
||||
pspec_info.value_type = GLADE_TYPE_GLIST;
|
||||
pspec_info.value_type = GLADE_TYPE_ACCEL_GLIST;
|
||||
|
||||
accel_type = g_param_type_register_static
|
||||
("GladeParamAccel", &pspec_info);
|
||||
@ -215,7 +287,7 @@ GParamSpec *
|
||||
glade_param_spec_accel (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
GType accepted_type,
|
||||
GType widget_type,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GladeParamSpecAccel *pspec;
|
||||
@ -223,10 +295,9 @@ glade_param_spec_accel (const gchar *name,
|
||||
pspec = g_param_spec_internal (GLADE_TYPE_PARAM_ACCEL,
|
||||
name, nick, blurb, flags);
|
||||
|
||||
pspec->type = accepted_type;
|
||||
pspec->type = widget_type;
|
||||
return G_PARAM_SPEC (pspec);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************
|
||||
* Built-in GladeParamSpecObjects for object list properties *
|
||||
@ -385,6 +456,16 @@ glade_standard_gdkcolor_spec (void)
|
||||
G_PARAM_READWRITE);
|
||||
}
|
||||
|
||||
/* Accelerator spec */
|
||||
GParamSpec *
|
||||
glade_standard_accel_spec (void)
|
||||
{
|
||||
return glade_param_spec_accel ("accelerators", _("Accelerators"),
|
||||
_("A list of accelerator keys"),
|
||||
GTK_TYPE_WIDGET,
|
||||
G_PARAM_READWRITE);
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
* Basic types follow *
|
||||
****************************************************************/
|
||||
@ -438,3 +519,28 @@ glade_standard_boolean_spec (void)
|
||||
_("A boolean value"), FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
}
|
||||
|
||||
guint
|
||||
glade_builtin_key_from_string (const gchar *string)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (string != NULL, 0);
|
||||
|
||||
for (i = 0; GladeKeys[i].name != NULL; i++)
|
||||
if (!strcmp (string, GladeKeys[i].name))
|
||||
return GladeKeys[i].value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
glade_builtin_string_from_key (guint key)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; GladeKeys[i].name != NULL; i++)
|
||||
if (GladeKeys[i].value == key)
|
||||
return GladeKeys[i].name;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -7,21 +7,26 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GLADE_TYPE_STOCK (glade_standard_stock_get_type())
|
||||
typedef struct _GladeParamSpecObjects GladeParamSpecObjects;
|
||||
typedef struct _GladeParamSpecAccel GladeParamSpecAccel;
|
||||
|
||||
LIBGLADEUI_API GType glade_standard_stock_get_type (void);
|
||||
typedef struct _GladeKey GladeKey;
|
||||
struct _GladeKey {
|
||||
guint value;
|
||||
gchar *name;
|
||||
};
|
||||
|
||||
#define GLADE_IS_PARAM_SPEC_STOCK(pspec) \
|
||||
extern const GladeKey GladeKeys[];
|
||||
|
||||
#define GLADE_TYPE_STOCK (glade_standard_stock_get_type())
|
||||
#define GLADE_TYPE_GLIST (glade_glist_get_type())
|
||||
#define GLADE_TYPE_ACCEL_GLIST (glade_accel_glist_get_type())
|
||||
#define GLADE_TYPE_PARAM_OBJECTS (glade_param_objects_get_type())
|
||||
#define GLADE_TYPE_PARAM_ACCEL (glade_param_accel_get_type())
|
||||
|
||||
#define GLADE_IS_STOCK(pspec) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GLADE_TYPE_STOCK))
|
||||
|
||||
|
||||
|
||||
typedef struct _GladeParamSpecObjects GladeParamSpecObjects;
|
||||
|
||||
|
||||
#define GLADE_TYPE_GLIST (glade_glist_get_type())
|
||||
|
||||
#define GLADE_TYPE_PARAM_OBJECTS (glade_param_objects_get_type())
|
||||
#define GLADE_IS_PARAM_SPEC_OBJECTS(pspec) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((pspec), \
|
||||
GLADE_TYPE_PARAM_OBJECTS))
|
||||
@ -29,16 +34,39 @@ typedef struct _GladeParamSpecObjects GladeParamSpecObjects;
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((pspec), \
|
||||
GLADE_TYPE_PARAM_OBJECTS, GladeParamSpecObjects))
|
||||
|
||||
#define GLADE_IS_PARAM_SPEC_ACCEL(pspec) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((pspec), \
|
||||
GLADE_TYPE_PARAM_ACCEL))
|
||||
#define GLADE_PARAM_SPEC_ACCEL(pspec) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((pspec), \
|
||||
GLADE_TYPE_PARAM_ACCEL, GladeParamSpecAccel))
|
||||
|
||||
LIBGLADEUI_API GType glade_standard_stock_get_type (void) G_GNUC_CONST;
|
||||
LIBGLADEUI_API GType glade_glist_get_type (void) G_GNUC_CONST;
|
||||
|
||||
LIBGLADEUI_API GType glade_accel_glist_get_type (void) G_GNUC_CONST;
|
||||
LIBGLADEUI_API GType glade_param_objects_get_type (void) G_GNUC_CONST;
|
||||
LIBGLADEUI_API GType glade_param_accel_get_type (void) G_GNUC_CONST;
|
||||
|
||||
LIBGLADEUI_API guint glade_builtin_key_from_string (const gchar *string);
|
||||
LIBGLADEUI_API const gchar *glade_builtin_string_from_key (guint key);
|
||||
|
||||
|
||||
LIBGLADEUI_API GList *glade_accel_list_copy (GList *accels);
|
||||
LIBGLADEUI_API void glade_accel_list_free (GList *accels);
|
||||
|
||||
|
||||
LIBGLADEUI_API GParamSpec *glade_param_spec_objects (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
GType accepted_type,
|
||||
GParamFlags flags);
|
||||
|
||||
LIBGLADEUI_API GParamSpec *glade_param_spec_accel (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
GType widget_type,
|
||||
GParamFlags flags);
|
||||
|
||||
LIBGLADEUI_API void glade_param_spec_objects_set_type (GladeParamSpecObjects *pspec,
|
||||
GType type);
|
||||
LIBGLADEUI_API GType glade_param_spec_objects_get_type (GladeParamSpecObjects *pspec);
|
||||
@ -49,13 +77,16 @@ LIBGLADEUI_API GParamSpec *glade_standard_pixbuf_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_gdkcolor_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_objects_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_stock_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_accel_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_int_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_uint_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_uint_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_string_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_strv_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_float_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_boolean_spec (void);
|
||||
|
||||
LIBGLADEUI_API gboolean glade_keyval_valid (guint val);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GLADE_BUILTINS_H__ */
|
||||
|
@ -235,13 +235,15 @@ static void
|
||||
glade_editor_property_info_clicked_cb (GtkWidget *info,
|
||||
GladeEditorProperty *eprop)
|
||||
{
|
||||
GladeWidgetClass *wclass;
|
||||
gchar *search;
|
||||
|
||||
search = g_strdup_printf ("The %s property", eprop->property->class->id);
|
||||
wclass = glade_widget_class_from_pclass (eprop->class);
|
||||
search = g_strdup_printf ("The %s property", eprop->class->id);
|
||||
|
||||
g_signal_emit (G_OBJECT (eprop),
|
||||
glade_editor_property_signals[GTK_DOC_SEARCH],
|
||||
0, eprop->class->book,
|
||||
0, wclass->book,
|
||||
g_type_name (eprop->class->pspec->owner_type), search);
|
||||
|
||||
g_free (search);
|
||||
@ -866,6 +868,10 @@ GLADE_MAKE_EPROP (GladeEPropFlags, glade_eprop_flags)
|
||||
static void
|
||||
glade_eprop_flags_finalize (GObject *object)
|
||||
{
|
||||
GladeEPropFlags *eprop_flags = GLADE_EPROP_FLAGS(object);
|
||||
|
||||
g_object_unref (G_OBJECT (eprop_flags->model));
|
||||
|
||||
/* Chain up */
|
||||
G_OBJECT_CLASS (editor_property_class)->finalize (object);
|
||||
}
|
||||
@ -2224,6 +2230,9 @@ glade_eprop_object_view (GladeEditorProperty *eprop,
|
||||
g_object_set_data (G_OBJECT (model), "radio-list", GINT_TO_POINTER (radio));
|
||||
|
||||
view_widget = gtk_tree_view_new_with_model (model);
|
||||
|
||||
/* Pass ownership to the view */
|
||||
g_object_unref (G_OBJECT (model));
|
||||
g_object_set (G_OBJECT (view_widget), "enable-search", FALSE, NULL);
|
||||
|
||||
/********************* fake invisible column *********************/
|
||||
@ -2490,9 +2499,9 @@ glade_eprop_objects_load (GladeEditorProperty *eprop, GladeProperty *property)
|
||||
|
||||
gboolean
|
||||
glade_eprop_objects_selected_widget (GtkTreeModel *model,
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
GList **ret)
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
GList **ret)
|
||||
{
|
||||
gboolean selected;
|
||||
GladeWidget *widget;
|
||||
@ -2574,8 +2583,6 @@ glade_eprop_objects_show_dialog (GtkWidget *dialog_button,
|
||||
(GtkTreeModelForeachFunc)
|
||||
glade_eprop_objects_selected_widget, &selected);
|
||||
|
||||
|
||||
|
||||
value = glade_property_class_make_gvalue
|
||||
(eprop->class, selected);
|
||||
|
||||
@ -2889,6 +2896,615 @@ glade_eprop_adjustment_create_input (GladeEditorProperty *eprop)
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
GladeEditorPropertyAccelClass
|
||||
*******************************************************************************/
|
||||
enum {
|
||||
ACCEL_COLUMN_SIGNAL = 0,
|
||||
ACCEL_COLUMN_REAL_SIGNAL,
|
||||
ACCEL_COLUMN_KEY,
|
||||
ACCEL_COLUMN_MOD_SHIFT,
|
||||
ACCEL_COLUMN_MOD_CNTL,
|
||||
ACCEL_COLUMN_MOD_ALT,
|
||||
ACCEL_COLUMN_IS_CLASS,
|
||||
ACCEL_COLUMN_IS_SIGNAL,
|
||||
ACCEL_COLUMN_KEY_ENTERED,
|
||||
ACCEL_COLUMN_KEY_SLOT,
|
||||
ACCEL_NUM_COLUMNS
|
||||
};
|
||||
|
||||
enum {
|
||||
ACCEL_COMBO_COLUMN_TEXT = 0,
|
||||
ACCEL_COMBO_NUM_COLUMNS,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
GladeEditorProperty parent_instance;
|
||||
|
||||
GtkWidget *entry;
|
||||
GList *parent_iters;
|
||||
GtkTreeModel *model;
|
||||
} GladeEPropAccel;
|
||||
|
||||
typedef struct {
|
||||
GtkTreeIter *iter;
|
||||
gchar *name; /* <-- dont free */
|
||||
} GladeEpropIterTab;
|
||||
|
||||
|
||||
static GtkTreeModel *keysyms_model = NULL;
|
||||
|
||||
GLADE_MAKE_EPROP (GladeEPropAccel, glade_eprop_accel)
|
||||
#define GLADE_TYPE_EPROP_ACCEL (glade_eprop_accel_get_type())
|
||||
#define GLADE_EPROP_ACCEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_EPROP_ACCEL, GladeEPropAccel))
|
||||
#define GLADE_EPROP_ACCEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_EPROP_ACCEL, GladeEPropAccelClass))
|
||||
#define GLADE_IS_EPROP_ACCEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_ACCEL))
|
||||
#define GLADE_IS_EPROP_ACCEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_ACCEL))
|
||||
#define GLADE_EPROP_ACCEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_ACCEL, GladeEPropAccelClass))
|
||||
|
||||
|
||||
GtkTreeModel *
|
||||
create_keysyms_model (void)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gint i;
|
||||
|
||||
model = (GtkTreeModel *)gtk_list_store_new
|
||||
(ACCEL_COMBO_NUM_COLUMNS,
|
||||
G_TYPE_STRING); /* The Key charachter name */
|
||||
|
||||
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
||||
gtk_list_store_set
|
||||
(GTK_LIST_STORE (model), &iter,
|
||||
ACCEL_COMBO_COLUMN_TEXT, _("None"), -1);
|
||||
|
||||
for (i = 0; GladeKeys[i].name != NULL; i++)
|
||||
{
|
||||
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
||||
gtk_list_store_set
|
||||
(GTK_LIST_STORE (model), &iter,
|
||||
ACCEL_COMBO_COLUMN_TEXT, GladeKeys[i].name, -1);
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_eprop_accel_finalize (GObject *object)
|
||||
{
|
||||
/* Chain up */
|
||||
G_OBJECT_CLASS (editor_property_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_eprop_accel_load (GladeEditorProperty *eprop,
|
||||
GladeProperty *property)
|
||||
{
|
||||
GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
|
||||
gchar *accels;
|
||||
|
||||
/* Chain up first */
|
||||
editor_property_class->load (eprop, property);
|
||||
|
||||
if (property == NULL) return;
|
||||
|
||||
if ((accels = glade_property_class_make_string_from_gvalue
|
||||
(eprop->class, property->value)) != NULL)
|
||||
{
|
||||
gtk_entry_set_text (GTK_ENTRY (eprop_accel->entry), accels);
|
||||
g_free (accels);
|
||||
}
|
||||
else
|
||||
gtk_entry_set_text (GTK_ENTRY (eprop_accel->entry), "");
|
||||
|
||||
}
|
||||
|
||||
static gint
|
||||
eprop_find_iter (GladeEpropIterTab *iter_tab,
|
||||
gchar *name)
|
||||
{
|
||||
return strcmp (iter_tab->name, name);
|
||||
}
|
||||
|
||||
static void
|
||||
iter_tab_free (GladeEpropIterTab *iter_tab)
|
||||
{
|
||||
gtk_tree_iter_free (iter_tab->iter);
|
||||
g_free (iter_tab);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_eprop_accel_populate_view (GladeEditorProperty *eprop,
|
||||
GtkTreeView *view)
|
||||
{
|
||||
GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
|
||||
GladeSignalClass *sclass;
|
||||
GladeWidgetClass *wclass = glade_widget_class_from_pclass (eprop->class);
|
||||
GtkTreeStore *model = (GtkTreeStore *)gtk_tree_view_get_model (view);
|
||||
GtkTreeIter iter;
|
||||
GladeEpropIterTab *parent_tab;
|
||||
GladeAccelInfo *info;
|
||||
GList *list, *l, *found, *accelerators;
|
||||
gchar *name;
|
||||
|
||||
accelerators = g_value_get_boxed (eprop->property->value);
|
||||
|
||||
/* First make parent iters...
|
||||
*/
|
||||
for (list = wclass->signals; list; list = list->next)
|
||||
{
|
||||
sclass = list->data;
|
||||
|
||||
/* Only action signals have accelerators. */
|
||||
if ((sclass->query.signal_flags & G_SIGNAL_ACTION) == 0)
|
||||
continue;
|
||||
|
||||
if (g_list_find_custom (eprop_accel->parent_iters,
|
||||
sclass->type,
|
||||
(GCompareFunc)eprop_find_iter) == NULL)
|
||||
{
|
||||
gtk_tree_store_append (model, &iter, NULL);
|
||||
gtk_tree_store_set (model, &iter,
|
||||
ACCEL_COLUMN_SIGNAL, sclass->type,
|
||||
ACCEL_COLUMN_IS_CLASS, TRUE,
|
||||
ACCEL_COLUMN_IS_SIGNAL, FALSE,
|
||||
-1);
|
||||
|
||||
parent_tab = g_new0 (GladeEpropIterTab, 1);
|
||||
parent_tab->name = sclass->type;
|
||||
parent_tab->iter = gtk_tree_iter_copy (&iter);
|
||||
|
||||
eprop_accel->parent_iters =
|
||||
g_list_prepend (eprop_accel->parent_iters,
|
||||
parent_tab);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now we populate...
|
||||
*/
|
||||
for (list = wclass->signals; list; list = list->next)
|
||||
{
|
||||
sclass = list->data;
|
||||
|
||||
/* Only action signals have accelerators. */
|
||||
if ((sclass->query.signal_flags & G_SIGNAL_ACTION) == 0)
|
||||
continue;
|
||||
|
||||
if ((found = g_list_find_custom (eprop_accel->parent_iters,
|
||||
sclass->type,
|
||||
(GCompareFunc)eprop_find_iter)) != NULL)
|
||||
{
|
||||
parent_tab = found->data;
|
||||
name = g_strdup_printf (" %s", sclass->name);
|
||||
|
||||
/* Populate from accelerator list
|
||||
*/
|
||||
for (l = accelerators; l; l = l->next)
|
||||
{
|
||||
info = l->data;
|
||||
|
||||
if (strcmp (info->signal, sclass->name))
|
||||
continue;
|
||||
|
||||
gtk_tree_store_append (model, &iter, parent_tab->iter);
|
||||
gtk_tree_store_set
|
||||
(model, &iter,
|
||||
ACCEL_COLUMN_SIGNAL, name,
|
||||
ACCEL_COLUMN_REAL_SIGNAL, sclass->name,
|
||||
ACCEL_COLUMN_IS_CLASS, FALSE,
|
||||
ACCEL_COLUMN_IS_SIGNAL, TRUE,
|
||||
ACCEL_COLUMN_MOD_SHIFT,
|
||||
(info->modifiers & GDK_SHIFT_MASK) != 0,
|
||||
ACCEL_COLUMN_MOD_CNTL,
|
||||
(info->modifiers & GDK_CONTROL_MASK) != 0,
|
||||
ACCEL_COLUMN_MOD_ALT,
|
||||
(info->modifiers & GDK_MOD1_MASK) != 0,
|
||||
ACCEL_COLUMN_KEY,
|
||||
glade_builtin_string_from_key (info->key),
|
||||
ACCEL_COLUMN_KEY_ENTERED, TRUE,
|
||||
ACCEL_COLUMN_KEY_SLOT, FALSE,
|
||||
-1);
|
||||
}
|
||||
|
||||
/* Append a new empty slot at the end */
|
||||
gtk_tree_store_append (model, &iter, parent_tab->iter);
|
||||
gtk_tree_store_set
|
||||
(model, &iter,
|
||||
ACCEL_COLUMN_SIGNAL, name,
|
||||
ACCEL_COLUMN_REAL_SIGNAL, sclass->name,
|
||||
ACCEL_COLUMN_IS_CLASS, FALSE,
|
||||
ACCEL_COLUMN_IS_SIGNAL, TRUE,
|
||||
ACCEL_COLUMN_MOD_SHIFT, FALSE,
|
||||
ACCEL_COLUMN_MOD_CNTL, FALSE,
|
||||
ACCEL_COLUMN_MOD_ALT, FALSE,
|
||||
ACCEL_COLUMN_KEY, _("<choose a key>"),
|
||||
ACCEL_COLUMN_KEY_ENTERED, FALSE,
|
||||
ACCEL_COLUMN_KEY_SLOT, TRUE,
|
||||
-1);
|
||||
|
||||
g_free (name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
key_edited (GtkCellRendererText *cell,
|
||||
const gchar *path_string,
|
||||
const gchar *new_text,
|
||||
GladeEditorProperty *eprop)
|
||||
{
|
||||
GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
|
||||
gboolean key_was_set;
|
||||
gchar *signal;
|
||||
GtkTreeIter iter, parent_iter, new_iter;
|
||||
|
||||
if (!gtk_tree_model_get_iter_from_string (eprop_accel->model,
|
||||
&iter, path_string))
|
||||
return;
|
||||
|
||||
gtk_tree_model_get
|
||||
(eprop_accel->model, &iter,
|
||||
ACCEL_COLUMN_KEY_ENTERED, &key_was_set,
|
||||
ACCEL_COLUMN_SIGNAL, &signal,
|
||||
-1);
|
||||
|
||||
/* If user selects "none"; remove old entry or ignore new one.
|
||||
*/
|
||||
if (strcmp (new_text, _("None")) == 0)
|
||||
{
|
||||
if (key_was_set)
|
||||
gtk_tree_store_remove
|
||||
(GTK_TREE_STORE (eprop_accel->model), &iter);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_tree_store_set
|
||||
(GTK_TREE_STORE (eprop_accel->model), &iter,
|
||||
ACCEL_COLUMN_KEY, new_text,
|
||||
ACCEL_COLUMN_KEY_ENTERED, TRUE,
|
||||
ACCEL_COLUMN_KEY_SLOT, FALSE,
|
||||
-1);
|
||||
|
||||
/* Append a new one if needed
|
||||
*/
|
||||
if (key_was_set == FALSE &&
|
||||
gtk_tree_model_iter_parent (eprop_accel->model,
|
||||
&parent_iter, &iter))
|
||||
{
|
||||
/* Append a new empty slot at the end */
|
||||
gtk_tree_store_insert_after (GTK_TREE_STORE (eprop_accel->model),
|
||||
&new_iter, &parent_iter, &iter);
|
||||
gtk_tree_store_set
|
||||
(GTK_TREE_STORE (eprop_accel->model), &new_iter,
|
||||
ACCEL_COLUMN_SIGNAL, signal,
|
||||
ACCEL_COLUMN_IS_CLASS, FALSE,
|
||||
ACCEL_COLUMN_IS_SIGNAL, TRUE,
|
||||
ACCEL_COLUMN_MOD_SHIFT, FALSE,
|
||||
ACCEL_COLUMN_MOD_CNTL, FALSE,
|
||||
ACCEL_COLUMN_MOD_ALT, FALSE,
|
||||
ACCEL_COLUMN_KEY, _("<choose a key>"),
|
||||
ACCEL_COLUMN_KEY_ENTERED, FALSE,
|
||||
ACCEL_COLUMN_KEY_SLOT, TRUE,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
modifier_toggled (GtkCellRendererToggle *cell,
|
||||
gchar *path_string,
|
||||
GladeEditorProperty *eprop)
|
||||
{
|
||||
GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
|
||||
GtkTreeIter iter;
|
||||
gint column;
|
||||
gboolean active, key_entered;
|
||||
|
||||
if (!gtk_tree_model_get_iter_from_string (eprop_accel->model,
|
||||
&iter, path_string))
|
||||
return;
|
||||
|
||||
column = GPOINTER_TO_INT (g_object_get_data
|
||||
(G_OBJECT (cell), "model-column"));
|
||||
|
||||
gtk_tree_model_get
|
||||
(eprop_accel->model, &iter,
|
||||
ACCEL_COLUMN_KEY_ENTERED, &key_entered,
|
||||
column, &active, -1);
|
||||
|
||||
if (key_entered)
|
||||
gtk_tree_store_set
|
||||
(GTK_TREE_STORE (eprop_accel->model), &iter,
|
||||
column, !active, -1);
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
glade_eprop_accel_view (GladeEditorProperty *eprop)
|
||||
{
|
||||
GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
|
||||
GtkWidget *view_widget;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
|
||||
eprop_accel->model = (GtkTreeModel *)gtk_tree_store_new
|
||||
(ACCEL_NUM_COLUMNS,
|
||||
G_TYPE_STRING, /* The GSignal name formatted for display */
|
||||
G_TYPE_STRING, /* The GSignal name */
|
||||
G_TYPE_STRING, /* The Gdk keycode */
|
||||
G_TYPE_BOOLEAN, /* The shift modifier */
|
||||
G_TYPE_BOOLEAN, /* The cntl modifier */
|
||||
G_TYPE_BOOLEAN, /* The alt modifier */
|
||||
G_TYPE_BOOLEAN, /* Whether this is a class entry */
|
||||
G_TYPE_BOOLEAN, /* Whether this is a signal entry (oposite of above) */
|
||||
G_TYPE_BOOLEAN, /* Whether the key has been entered for this row */
|
||||
G_TYPE_BOOLEAN); /* Oposite of above */
|
||||
|
||||
view_widget = gtk_tree_view_new_with_model (eprop_accel->model);
|
||||
g_object_set (G_OBJECT (view_widget), "enable-search", FALSE, NULL);
|
||||
|
||||
/********************* fake invisible column *********************/
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_object_set (G_OBJECT (renderer), "editable", FALSE, "visible", FALSE, NULL);
|
||||
|
||||
column = gtk_tree_view_column_new_with_attributes (NULL, renderer, NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
|
||||
|
||||
gtk_tree_view_column_set_visible (column, FALSE);
|
||||
gtk_tree_view_set_expander_column (GTK_TREE_VIEW (view_widget), column);
|
||||
|
||||
/********************* signal name column *********************/
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_object_set (G_OBJECT (renderer),
|
||||
"editable", FALSE,
|
||||
"weight", PANGO_WEIGHT_BOLD,
|
||||
NULL);
|
||||
|
||||
column = gtk_tree_view_column_new_with_attributes
|
||||
(_("Signal"), renderer,
|
||||
"text", ACCEL_COLUMN_SIGNAL,
|
||||
"weight-set", ACCEL_COLUMN_IS_CLASS,
|
||||
NULL);
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
|
||||
|
||||
/********************* key name column *********************/
|
||||
if (keysyms_model == NULL)
|
||||
keysyms_model = create_keysyms_model ();
|
||||
|
||||
renderer = gtk_cell_renderer_combo_new ();
|
||||
g_object_set (G_OBJECT (renderer),
|
||||
"editable", TRUE,
|
||||
"model", keysyms_model,
|
||||
"text-column", ACCEL_COMBO_COLUMN_TEXT,
|
||||
"has-entry", FALSE,
|
||||
"style", PANGO_STYLE_ITALIC,
|
||||
"foreground", "Gray",
|
||||
NULL);
|
||||
|
||||
g_signal_connect (renderer, "edited",
|
||||
G_CALLBACK (key_edited), eprop);
|
||||
|
||||
column = gtk_tree_view_column_new_with_attributes
|
||||
(_("Key"), renderer,
|
||||
"text", ACCEL_COLUMN_KEY,
|
||||
"style-set", ACCEL_COLUMN_KEY_SLOT,
|
||||
"foreground-set", ACCEL_COLUMN_KEY_SLOT,
|
||||
"visible", ACCEL_COLUMN_IS_SIGNAL,
|
||||
NULL);
|
||||
|
||||
g_object_set (G_OBJECT (column), "expand", TRUE, NULL);
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
|
||||
|
||||
/********************* shift modifier column *********************/
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes
|
||||
(_("Shift"), renderer,
|
||||
"visible", ACCEL_COLUMN_IS_SIGNAL,
|
||||
"sensitive", ACCEL_COLUMN_KEY_ENTERED,
|
||||
"active", ACCEL_COLUMN_MOD_SHIFT,
|
||||
NULL);
|
||||
|
||||
g_object_set_data (G_OBJECT (renderer), "model-column",
|
||||
GINT_TO_POINTER (ACCEL_COLUMN_MOD_SHIFT));
|
||||
g_signal_connect (G_OBJECT (renderer), "toggled",
|
||||
G_CALLBACK (modifier_toggled), eprop);
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
|
||||
|
||||
/********************* control modifier column *********************/
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes
|
||||
(_("Control"), renderer,
|
||||
"visible", ACCEL_COLUMN_IS_SIGNAL,
|
||||
"sensitive", ACCEL_COLUMN_KEY_ENTERED,
|
||||
"active", ACCEL_COLUMN_MOD_CNTL,
|
||||
NULL);
|
||||
|
||||
g_object_set_data (G_OBJECT (renderer), "model-column",
|
||||
GINT_TO_POINTER (ACCEL_COLUMN_MOD_CNTL));
|
||||
g_signal_connect (G_OBJECT (renderer), "toggled",
|
||||
G_CALLBACK (modifier_toggled), eprop);
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
|
||||
|
||||
/********************* alt modifier column *********************/
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes
|
||||
(_("Alt"), renderer,
|
||||
"visible", ACCEL_COLUMN_IS_SIGNAL,
|
||||
"sensitive", ACCEL_COLUMN_KEY_ENTERED,
|
||||
"active", ACCEL_COLUMN_MOD_ALT,
|
||||
NULL);
|
||||
|
||||
g_object_set_data (G_OBJECT (renderer), "model-column",
|
||||
GINT_TO_POINTER (ACCEL_COLUMN_MOD_ALT));
|
||||
g_signal_connect (G_OBJECT (renderer), "toggled",
|
||||
G_CALLBACK (modifier_toggled), eprop);
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
|
||||
|
||||
return view_widget;
|
||||
}
|
||||
|
||||
gboolean
|
||||
glade_eprop_accel_accum_accelerators (GtkTreeModel *model,
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
GList **ret)
|
||||
{
|
||||
GladeAccelInfo *info;
|
||||
gchar *signal;
|
||||
gchar *key_str;
|
||||
gboolean shift, cntl, alt, entered;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
ACCEL_COLUMN_REAL_SIGNAL, &signal,
|
||||
ACCEL_COLUMN_KEY, &key_str,
|
||||
ACCEL_COLUMN_MOD_SHIFT, &shift,
|
||||
ACCEL_COLUMN_MOD_CNTL, &cntl,
|
||||
ACCEL_COLUMN_MOD_ALT, &alt,
|
||||
ACCEL_COLUMN_KEY_ENTERED, &entered,
|
||||
-1);
|
||||
|
||||
if (entered)
|
||||
{
|
||||
info = g_new0 (GladeAccelInfo, 1);
|
||||
info->signal = g_strdup (signal);
|
||||
info->key = glade_builtin_key_from_string (key_str);
|
||||
info->modifiers =
|
||||
(shift ? GDK_SHIFT_MASK : 0) |
|
||||
(cntl ? GDK_CONTROL_MASK : 0) |
|
||||
(alt ? GDK_MOD1_MASK : 0);
|
||||
|
||||
*ret = g_list_prepend (*ret, info);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glade_eprop_accel_show_dialog (GtkWidget *dialog_button,
|
||||
GladeEditorProperty *eprop)
|
||||
{
|
||||
GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
|
||||
GtkWidget *dialog, *parent, *vbox, *sw, *tree_view;
|
||||
GladeProject *project;
|
||||
GValue *value;
|
||||
GList *accelerators = NULL;
|
||||
gint res;
|
||||
|
||||
project = glade_widget_get_project (eprop->property->widget);
|
||||
parent = gtk_widget_get_toplevel (GTK_WIDGET (eprop));
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons (_("Choose accelerator keys..."),
|
||||
GTK_WINDOW (parent),
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_STOCK_CLEAR, GLADE_RESPONSE_CLEAR,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
|
||||
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 6);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), GLADE_GENERIC_BORDER_WIDTH);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, TRUE, TRUE, 0);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (sw);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
|
||||
gtk_widget_set_size_request (sw, 400, 200);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
|
||||
|
||||
tree_view = glade_eprop_accel_view (eprop);
|
||||
glade_eprop_accel_populate_view (eprop, GTK_TREE_VIEW (tree_view));
|
||||
|
||||
gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
|
||||
|
||||
gtk_widget_show (tree_view);
|
||||
gtk_container_add (GTK_CONTAINER (sw), tree_view);
|
||||
|
||||
/* Run the dialog */
|
||||
res = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
if (res == GTK_RESPONSE_OK)
|
||||
{
|
||||
gtk_tree_model_foreach
|
||||
(gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)),
|
||||
(GtkTreeModelForeachFunc)
|
||||
glade_eprop_accel_accum_accelerators, &accelerators);
|
||||
|
||||
value = g_new0 (GValue, 1);
|
||||
g_value_init (value, GLADE_TYPE_ACCEL_GLIST);
|
||||
g_value_take_boxed (value, accelerators);
|
||||
|
||||
glade_editor_property_commit (eprop, value);
|
||||
|
||||
g_value_unset (value);
|
||||
g_free (value);
|
||||
}
|
||||
else if (res == GLADE_RESPONSE_CLEAR)
|
||||
{
|
||||
value = g_new0 (GValue, 1);
|
||||
g_value_init (value, GLADE_TYPE_ACCEL_GLIST);
|
||||
g_value_set_boxed (value, NULL);
|
||||
|
||||
glade_editor_property_commit (eprop, value);
|
||||
|
||||
g_value_unset (value);
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
/* Clean up ...
|
||||
*/
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
g_object_unref (G_OBJECT (eprop_accel->model));
|
||||
eprop_accel->model = NULL;
|
||||
|
||||
if (eprop_accel->parent_iters)
|
||||
{
|
||||
g_list_foreach (eprop_accel->parent_iters, (GFunc)iter_tab_free, NULL);
|
||||
g_list_free (eprop_accel->parent_iters);
|
||||
eprop_accel->parent_iters = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
glade_eprop_accel_create_input (GladeEditorProperty *eprop)
|
||||
{
|
||||
GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *button;
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
eprop_accel->entry = gtk_entry_new ();
|
||||
gtk_entry_set_editable (GTK_ENTRY (eprop_accel->entry), FALSE);
|
||||
gtk_widget_show (eprop_accel->entry);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), eprop_accel->entry, TRUE, TRUE, 0);
|
||||
|
||||
button = gtk_button_new_with_label ("...");
|
||||
gtk_widget_show (button);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (glade_eprop_accel_show_dialog),
|
||||
eprop);
|
||||
|
||||
return hbox;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
Misc static stuff
|
||||
*******************************************************************************/
|
||||
@ -2940,6 +3556,9 @@ glade_editor_property_type (GParamSpec *pspec)
|
||||
}
|
||||
else if (GLADE_IS_PARAM_SPEC_OBJECTS(pspec))
|
||||
type = GLADE_TYPE_EPROP_OBJECTS;
|
||||
else if (GLADE_IS_PARAM_SPEC_ACCEL(pspec))
|
||||
type = GLADE_TYPE_EPROP_ACCEL;
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -3076,7 +3695,6 @@ glade_editor_property_load_by_widget (GladeEditorProperty *eprop,
|
||||
glade_editor_property_load (eprop, property);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* glade_editor_property_show_info:
|
||||
* @eprop: A #GladeEditorProperty
|
||||
@ -3086,10 +3704,14 @@ glade_editor_property_load_by_widget (GladeEditorProperty *eprop,
|
||||
void
|
||||
glade_editor_property_show_info (GladeEditorProperty *eprop)
|
||||
{
|
||||
GladeWidgetClass *wclass;
|
||||
|
||||
g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
|
||||
|
||||
wclass = glade_widget_class_from_pclass (eprop->class);
|
||||
|
||||
if (eprop->class->virtual == FALSE &&
|
||||
eprop->class->book != NULL)
|
||||
wclass->book != NULL)
|
||||
gtk_widget_show (eprop->info);
|
||||
else
|
||||
{
|
||||
|
@ -541,11 +541,13 @@ glade_editor_table_append_items (GladeEditorTable *table,
|
||||
else if (type == TABLE_TYPE_GENERAL && property_class->common)
|
||||
continue;
|
||||
else if (type == TABLE_TYPE_ATK &&
|
||||
property_class->atk_type == GPC_ATK_NONE)
|
||||
continue;
|
||||
(property_class->type == GPC_NORMAL ||
|
||||
property_class->type == GPC_ACCEL_PROPERTY))
|
||||
continue;
|
||||
else if (type != TABLE_TYPE_ATK &&
|
||||
property_class->atk_type != GPC_ATK_NONE)
|
||||
continue;
|
||||
(property_class->type != GPC_NORMAL &&
|
||||
property_class->type != GPC_ACCEL_PROPERTY))
|
||||
continue;
|
||||
|
||||
property = glade_editor_table_append_item (table, property_class,
|
||||
type == TABLE_TYPE_QUERY);
|
||||
@ -1105,7 +1107,8 @@ glade_editor_populate_reset_view (GladeEditor *editor,
|
||||
if (glade_property_class_is_visible (property->class) == FALSE)
|
||||
continue;
|
||||
|
||||
if (property->class->atk_type != GPC_ATK_NONE)
|
||||
if (property->class->type != GPC_NORMAL &&
|
||||
property->class->type != GPC_ACCEL_PROPERTY)
|
||||
iter = &atk_iter;
|
||||
else if (property->class->common)
|
||||
iter = &common_iter;
|
||||
|
1358
src/glade-keysyms.c
Normal file
1358
src/glade-keysyms.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1247,6 +1247,102 @@ glade_parser_parse_buffer(const gchar *buffer, gint len, const gchar *domain)
|
||||
return state.interface;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
modifier_string_from_bits (GdkModifierType modifiers)
|
||||
{
|
||||
GString *string = g_string_new ("");
|
||||
|
||||
if (modifiers & GDK_SHIFT_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_SHIFT_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_LOCK_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_LOCK_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_CONTROL_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_CONTROL_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_MOD1_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_MOD1_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_MOD2_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_MOD2_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_MOD3_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_MOD3_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_MOD4_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_MOD4_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_MOD5_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_MOD5_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_BUTTON1_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_BUTTON1_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_BUTTON2_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_BUTTON2_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_BUTTON3_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_BUTTON3_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_BUTTON4_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_BUTTON4_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_BUTTON5_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_BUTTON5_MASK");
|
||||
}
|
||||
|
||||
if (modifiers & GDK_RELEASE_MASK) {
|
||||
if (string->len > 0)
|
||||
g_string_append (string, " | ");
|
||||
g_string_append (string, "GDK_RELEASE_MASK");
|
||||
}
|
||||
|
||||
if (string->len > 0)
|
||||
return g_string_free (string, FALSE);
|
||||
|
||||
g_string_free (string, TRUE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
dump_widget(xmlNode *parent, GladeWidgetInfo *info, gint indent)
|
||||
{
|
||||
@ -1369,16 +1465,22 @@ dump_widget(xmlNode *parent, GladeWidgetInfo *info, gint indent)
|
||||
|
||||
for (i = 0; i < info->n_accels; i++) {
|
||||
xmlNode *node;
|
||||
gchar *modifiers;
|
||||
|
||||
modifiers = modifier_string_from_bits (info->accels[i].modifiers);
|
||||
|
||||
for (j = 0; j < indent + 1; j++)
|
||||
xmlNodeAddContent(widget, BAD_CAST(" "));
|
||||
|
||||
node = xmlNewNode(NULL, BAD_CAST("accelerator"));
|
||||
xmlSetProp(node, BAD_CAST("key"), BAD_CAST(gdk_keyval_name(info->accels[i].key)));
|
||||
xmlSetProp(node, BAD_CAST("modifier"), BAD_CAST("something")/*info->accels[i].modifiers*/);
|
||||
xmlSetProp(node, BAD_CAST("modifiers"), BAD_CAST(modifiers));
|
||||
xmlSetProp(node, BAD_CAST("signal"), BAD_CAST(info->accels[i].signal));
|
||||
xmlAddChild(widget, node);
|
||||
xmlNodeAddContent(widget, BAD_CAST("\n"));
|
||||
|
||||
if (modifiers)
|
||||
g_free (modifiers);
|
||||
}
|
||||
|
||||
for (i = 0; i < info->n_children; i++) {
|
||||
|
@ -136,20 +136,21 @@ glade_property_class_atk_realname (const gchar *atk_name)
|
||||
|
||||
/**
|
||||
* glade_property_class_new:
|
||||
* @handle: A generic pointer (i.e. a #GladeWidgetClass)
|
||||
*
|
||||
* Returns: a new #GladePropertyClass
|
||||
*/
|
||||
GladePropertyClass *
|
||||
glade_property_class_new (const gchar *book)
|
||||
glade_property_class_new (gpointer handle)
|
||||
{
|
||||
GladePropertyClass *property_class;
|
||||
|
||||
property_class = g_new0 (GladePropertyClass, 1);
|
||||
property_class->handle = handle;
|
||||
property_class->pspec = NULL;
|
||||
property_class->id = NULL;
|
||||
property_class->name = NULL;
|
||||
property_class->tooltip = NULL;
|
||||
property_class->book = book; /* <-- dont free */
|
||||
property_class->def = NULL;
|
||||
property_class->orig_def = NULL;
|
||||
property_class->parameters = NULL;
|
||||
@ -168,7 +169,7 @@ glade_property_class_new (const gchar *book)
|
||||
property_class->ignore = FALSE;
|
||||
property_class->resource = FALSE;
|
||||
property_class->translatable = FALSE;
|
||||
property_class->atk_type = GPC_ATK_NONE;
|
||||
property_class->type = GPC_NORMAL;
|
||||
property_class->virtual = TRUE;
|
||||
|
||||
return property_class;
|
||||
@ -433,6 +434,41 @@ glade_property_class_make_string_from_objects (GladePropertyClass *property_clas
|
||||
return string;
|
||||
}
|
||||
|
||||
/* This is not used to save in the glade file... and its a one-way conversion.
|
||||
* its only usefull to show the values in the UI.
|
||||
*/
|
||||
static gchar *
|
||||
glade_property_class_make_string_from_accels (GladePropertyClass *property_class,
|
||||
GList *accels)
|
||||
{
|
||||
GladeAccelInfo *info;
|
||||
GString *string;
|
||||
GList *list;
|
||||
|
||||
string = g_string_new ("");
|
||||
|
||||
for (list = accels; list; list = list->next)
|
||||
{
|
||||
info = list->data;
|
||||
|
||||
if (info->modifiers & GDK_SHIFT_MASK)
|
||||
g_string_append (string, "SHIFT-");
|
||||
|
||||
if (info->modifiers & GDK_CONTROL_MASK)
|
||||
g_string_append (string, "CNTL-");
|
||||
|
||||
if (info->modifiers & GDK_MOD1_MASK)
|
||||
g_string_append (string, "ALT-");
|
||||
|
||||
g_string_append (string, glade_builtin_string_from_key (info->key));
|
||||
|
||||
if (list->next)
|
||||
g_string_append (string, ", ");
|
||||
}
|
||||
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_property_class_make_string_from_gvalue:
|
||||
* @property_class: A #GladePropertyClass
|
||||
@ -447,7 +483,7 @@ glade_property_class_make_string_from_gvalue (GladePropertyClass *property_class
|
||||
gchar *string = NULL, **strv;
|
||||
GObject *object;
|
||||
GdkColor *color;
|
||||
GList *objects;
|
||||
GList *objects, *accels;
|
||||
|
||||
if (G_IS_PARAM_SPEC_ENUM(property_class->pspec))
|
||||
{
|
||||
@ -546,6 +582,12 @@ glade_property_class_make_string_from_gvalue (GladePropertyClass *property_class
|
||||
string = glade_property_class_make_string_from_objects
|
||||
(property_class, objects);
|
||||
}
|
||||
else if (GLADE_IS_PARAM_SPEC_ACCEL (property_class->pspec))
|
||||
{
|
||||
accels = g_value_get_boxed (value);
|
||||
string = glade_property_class_make_string_from_accels
|
||||
(property_class, accels);
|
||||
}
|
||||
else
|
||||
g_critical ("Unsupported pspec type %s",
|
||||
g_type_name(G_PARAM_SPEC_TYPE (property_class->pspec)));
|
||||
@ -1034,12 +1076,14 @@ glade_property_class_get_from_gvalue (GladePropertyClass *class,
|
||||
|
||||
/**
|
||||
* glade_property_class_list_atk_relations:
|
||||
* @handle: A generic pointer (i.e. a #GladeWidgetClass)
|
||||
* @owner_type: The #GType of the owning widget class.
|
||||
*
|
||||
* Returns: a #GList of newly created atk relation #GladePropertyClass.
|
||||
*/
|
||||
GList *
|
||||
glade_property_class_list_atk_relations (GType owner_type)
|
||||
glade_property_class_list_atk_relations (gpointer handle,
|
||||
GType owner_type)
|
||||
{
|
||||
const GPCAtkPropertyTab *relation_tab = NULL;
|
||||
GladePropertyClass *property_class;
|
||||
@ -1051,7 +1095,7 @@ glade_property_class_list_atk_relations (GType owner_type)
|
||||
{
|
||||
relation_tab = &relation_names_table[i];
|
||||
|
||||
property_class = glade_property_class_new (NULL);
|
||||
property_class = glade_property_class_new (handle);
|
||||
property_class->pspec =
|
||||
glade_param_spec_objects (relation_tab->id,
|
||||
_(relation_tab->name),
|
||||
@ -1063,7 +1107,7 @@ glade_property_class_list_atk_relations (GType owner_type)
|
||||
property_class->id = g_strdup (relation_tab->id);
|
||||
property_class->name = g_strdup (_(relation_tab->name));
|
||||
property_class->tooltip = g_strdup (_(relation_tab->tooltip));
|
||||
property_class->atk_type = GPC_ATK_RELATION;
|
||||
property_class->type = GPC_ATK_RELATION;
|
||||
property_class->visible_lines = 2;
|
||||
property_class->ignore = TRUE;
|
||||
|
||||
@ -1081,17 +1125,68 @@ glade_property_class_list_atk_relations (GType owner_type)
|
||||
return g_list_reverse (list);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_property_class_accel_property:
|
||||
* @handle: A generic pointer (i.e. a #GladeWidgetClass)
|
||||
* @owner_type: The #GType of the owning widget class.
|
||||
*
|
||||
* Returns: a newly created #GladePropertyClass for accelerators
|
||||
* of the prescribed @owner_type.
|
||||
*/
|
||||
GladePropertyClass *
|
||||
glade_property_class_accel_property (gpointer handle,
|
||||
GType owner_type)
|
||||
{
|
||||
GladePropertyClass *property_class;
|
||||
GValue *def_value;
|
||||
|
||||
property_class = glade_property_class_new (handle);
|
||||
property_class->pspec =
|
||||
glade_param_spec_accel ("accelerators", _("Accelerators"),
|
||||
_("A list of accelerator keys"),
|
||||
owner_type,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
|
||||
property_class->pspec->owner_type = owner_type;
|
||||
property_class->id = g_strdup (g_param_spec_get_name
|
||||
(property_class->pspec));
|
||||
property_class->name = g_strdup (g_param_spec_get_nick
|
||||
(property_class->pspec));
|
||||
property_class->tooltip = g_strdup (g_param_spec_get_blurb
|
||||
(property_class->pspec));
|
||||
|
||||
property_class->type = GPC_ACCEL_PROPERTY;
|
||||
property_class->ignore = TRUE;
|
||||
property_class->common = TRUE;
|
||||
|
||||
/* Setup default */
|
||||
def_value = g_new0 (GValue, 1);
|
||||
g_value_init (def_value, GLADE_TYPE_ACCEL_GLIST);
|
||||
g_value_set_boxed (def_value, NULL);
|
||||
property_class->def = def_value;
|
||||
|
||||
/* Setup original default */
|
||||
def_value = g_new0 (GValue, 1);
|
||||
g_value_init (def_value, GLADE_TYPE_ACCEL_GLIST);
|
||||
g_value_set_boxed (def_value, NULL);
|
||||
property_class->orig_def = def_value;
|
||||
|
||||
return property_class;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* glade_property_class_new_from_spec:
|
||||
* @handle: A generic pointer (i.e. a #GladeWidgetClass)
|
||||
* @spec: A #GParamSpec
|
||||
*
|
||||
* Returns: a newly created #GladePropertyClass based on @spec
|
||||
* or %NULL if its unsupported.
|
||||
*/
|
||||
GladePropertyClass *
|
||||
glade_property_class_new_from_spec (GParamSpec *spec,
|
||||
const gchar *book)
|
||||
glade_property_class_new_from_spec (gpointer handle,
|
||||
GParamSpec *spec)
|
||||
{
|
||||
GObjectClass *gtk_widget_class;
|
||||
GladePropertyClass *property_class;
|
||||
@ -1102,7 +1197,7 @@ glade_property_class_new_from_spec (GParamSpec *spec,
|
||||
/* Only properties that are _new_from_spec() are
|
||||
* not virtual properties
|
||||
*/
|
||||
property_class = glade_property_class_new (book);
|
||||
property_class = glade_property_class_new (handle);
|
||||
property_class->virtual = FALSE;
|
||||
property_class->pspec = spec;
|
||||
|
||||
@ -1132,8 +1227,8 @@ glade_property_class_new_from_spec (GParamSpec *spec,
|
||||
|
||||
if (g_type_is_a (spec->owner_type, ATK_TYPE_OBJECT))
|
||||
{
|
||||
property_class->atk_type = GPC_ATK_PROPERTY;
|
||||
property_class->ignore = TRUE;
|
||||
property_class->type = GPC_ATK_PROPERTY;
|
||||
property_class->ignore = TRUE;
|
||||
|
||||
/* We only use the name and desctription props,
|
||||
* they are both translatable.
|
||||
@ -1534,9 +1629,9 @@ glade_property_class_update_from_node (GladeXmlNode *node,
|
||||
/* No atk introspection here.
|
||||
*/
|
||||
if (glade_xml_get_property_boolean (node, GLADE_TAG_ATK_ACTION, FALSE))
|
||||
class->atk_type = GPC_ATK_ACTION;
|
||||
class->type = GPC_ATK_ACTION;
|
||||
else if (glade_xml_get_property_boolean (node, GLADE_TAG_ATK_PROPERTY, FALSE))
|
||||
class->atk_type = GPC_ATK_PROPERTY;
|
||||
class->type = GPC_ATK_PROPERTY;
|
||||
|
||||
/* Special case pixbuf here.
|
||||
*/
|
||||
|
@ -17,18 +17,19 @@ G_BEGIN_DECLS
|
||||
typedef struct _GladePropertyClass GladePropertyClass;
|
||||
|
||||
/**
|
||||
* GPCAtkType:
|
||||
* GPCType:
|
||||
* @GPC_ATK_NONE: is not an atk property
|
||||
* @GPC_ATK_PROPERTY: is a property of an #AtkImplementor object
|
||||
* @GPC_ATK_RELATION: is an atk relation set property
|
||||
* @GPC_ATK_ACTION: is an atk action property
|
||||
*/
|
||||
typedef enum {
|
||||
GPC_ATK_NONE,
|
||||
GPC_NORMAL,
|
||||
GPC_ATK_PROPERTY,
|
||||
GPC_ATK_RELATION,
|
||||
GPC_ATK_ACTION
|
||||
} GPCAtkType;
|
||||
GPC_ATK_ACTION,
|
||||
GPC_ACCEL_PROPERTY
|
||||
} GPCType;
|
||||
|
||||
/**
|
||||
* GladeVerifyPropertyFunc:
|
||||
@ -71,6 +72,13 @@ typedef void (* GladeGetPropertyFunc) (GObject *object,
|
||||
|
||||
struct _GladePropertyClass
|
||||
{
|
||||
GPCType type; /* A symbolic type used to load/save properties differently
|
||||
*/
|
||||
|
||||
gpointer handle; /* The GladeWidgetClass that this property class
|
||||
* was created for.
|
||||
*/
|
||||
|
||||
GParamSpec *pspec; /* The Parameter Specification for this property.
|
||||
*/
|
||||
|
||||
@ -85,10 +93,6 @@ struct _GladePropertyClass
|
||||
gchar *tooltip; /* The default tooltip for the property editor rows.
|
||||
*/
|
||||
|
||||
const gchar *book; /* A property class level pointer to the GladeWidgetClass
|
||||
* book member.
|
||||
*/
|
||||
|
||||
gboolean virtual; /* Whether this is a virtual property with its pspec supplied
|
||||
* via the catalog (or hard code-paths); or FALSE if its a real
|
||||
* GObject introspected property
|
||||
@ -136,12 +140,7 @@ struct _GladePropertyClass
|
||||
gboolean common; /* Common properties go in the common tab */
|
||||
gboolean packing; /* Packing properties go in the packing tab */
|
||||
|
||||
|
||||
GPCAtkType atk_type; /* Whether this is an atk property and if so;
|
||||
* whether its a relation, action or atkobject
|
||||
* property
|
||||
*/
|
||||
|
||||
|
||||
gboolean translatable; /* The property should be translatable, which
|
||||
* means that it needs extra parameters in the
|
||||
* UI.
|
||||
@ -201,12 +200,17 @@ struct _GladePropertyClass
|
||||
};
|
||||
|
||||
LIBGLADEUI_API
|
||||
GladePropertyClass *glade_property_class_new (const gchar *book);
|
||||
GladePropertyClass *glade_property_class_new (gpointer handle);
|
||||
LIBGLADEUI_API
|
||||
GladePropertyClass *glade_property_class_new_from_spec (GParamSpec *spec,
|
||||
const gchar *book);
|
||||
GladePropertyClass *glade_property_class_new_from_spec (gpointer handle,
|
||||
GParamSpec *spec);
|
||||
LIBGLADEUI_API
|
||||
GList *glade_property_class_list_atk_relations (GType owner_type);
|
||||
GList *glade_property_class_list_atk_relations (gpointer handle,
|
||||
GType owner_type);
|
||||
LIBGLADEUI_API
|
||||
GladePropertyClass *glade_property_class_accel_property (gpointer handle,
|
||||
GType owner_type);
|
||||
|
||||
LIBGLADEUI_API
|
||||
GladePropertyClass *glade_property_class_clone (GladePropertyClass *property_class);
|
||||
LIBGLADEUI_API
|
||||
|
@ -362,7 +362,7 @@ glade_property_load_impl (GladeProperty *property)
|
||||
|
||||
if (property->widget == NULL ||
|
||||
property->class->packing ||
|
||||
property->class->atk_type != GPC_ATK_NONE)
|
||||
property->class->type != GPC_NORMAL)
|
||||
return;
|
||||
object = glade_widget_get_object (property->widget);
|
||||
oclass = G_OBJECT_GET_CLASS (object);
|
||||
@ -378,6 +378,7 @@ glade_property_write_impl (GladeProperty *property,
|
||||
{
|
||||
GladePropInfo info = { 0, };
|
||||
GladeAtkActionInfo ainfo = { 0, };
|
||||
GList *list;
|
||||
gchar *name, *value, **split, *tmp;
|
||||
gint i;
|
||||
|
||||
@ -395,7 +396,7 @@ glade_property_write_impl (GladeProperty *property,
|
||||
|
||||
/* we should change each '-' by '_' on the name of the property
|
||||
* (<property name="...">) */
|
||||
if (property->class->atk_type != GPC_ATK_NONE)
|
||||
if (property->class->type != GPC_NORMAL)
|
||||
{
|
||||
|
||||
tmp = (gchar *)glade_property_class_atk_realname (property->class->id);
|
||||
@ -407,21 +408,22 @@ glade_property_write_impl (GladeProperty *property,
|
||||
}
|
||||
|
||||
/* convert the value of this property to a string */
|
||||
if ((value = glade_property_class_make_string_from_gvalue
|
||||
if (property->class->type == GPC_ACCEL_PROPERTY ||
|
||||
(value = glade_property_class_make_string_from_gvalue
|
||||
(property->class, property->value)) == NULL)
|
||||
/* make sure we keep the empty string, also... upcomming
|
||||
* funcs that may not like NULL.
|
||||
*/
|
||||
value = g_strdup ("");
|
||||
|
||||
switch (property->class->atk_type)
|
||||
switch (property->class->type)
|
||||
{
|
||||
case GPC_ATK_PROPERTY:
|
||||
tmp = g_strdup_printf ("AtkObject::%s", name);
|
||||
g_free (name);
|
||||
name = tmp;
|
||||
/* Dont break here ... */
|
||||
case GPC_ATK_NONE:
|
||||
case GPC_NORMAL:
|
||||
info.name = glade_xml_alloc_propname(interface, name);
|
||||
info.value = glade_xml_alloc_string(interface, value);
|
||||
|
||||
@ -440,7 +442,7 @@ glade_property_write_impl (GladeProperty *property,
|
||||
{
|
||||
for (i = 0; split[i] != NULL; i++)
|
||||
{
|
||||
GladeAtkRelationInfo rinfo = { 0, };
|
||||
GladeAtkRelationInfo rinfo = { 0, };
|
||||
rinfo.type = glade_xml_alloc_string(interface, name);
|
||||
rinfo.target = glade_xml_alloc_string(interface, split[i]);
|
||||
g_array_append_val (props, rinfo);
|
||||
@ -453,6 +455,20 @@ glade_property_write_impl (GladeProperty *property,
|
||||
ainfo.description = glade_xml_alloc_string(interface, value);
|
||||
g_array_append_val (props, ainfo);
|
||||
break;
|
||||
case GPC_ACCEL_PROPERTY:
|
||||
for (list = g_value_get_boxed (property->value);
|
||||
list; list = list->next)
|
||||
{
|
||||
GladeAccelInfo *accel = list->data;
|
||||
GladeAccelInfo accel_info = { 0, };
|
||||
|
||||
accel_info.signal = glade_xml_alloc_string(interface, accel->signal);
|
||||
accel_info.key = accel->key;
|
||||
accel_info.modifiers = accel->modifiers;
|
||||
|
||||
g_array_append_val (props, accel_info);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -937,6 +953,49 @@ glade_property_read_atk_action (GladeProperty *property,
|
||||
return gvalue;
|
||||
}
|
||||
|
||||
static GValue *
|
||||
glade_property_read_accel_prop (GladeProperty *property,
|
||||
GladePropertyClass *pclass,
|
||||
GladeProject *project,
|
||||
GladeWidgetInfo *info,
|
||||
gboolean free_value)
|
||||
{
|
||||
GValue *gvalue = NULL;
|
||||
GList *accels = NULL;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < info->n_accels; ++i)
|
||||
{
|
||||
GladeAccelInfo *ainfo = info->accels + i;
|
||||
|
||||
GladeAccelInfo *ainfo_dup = g_new0 (GladeAccelInfo, 1);
|
||||
|
||||
ainfo_dup = g_new0 (GladeAccelInfo, 1);
|
||||
ainfo_dup->signal = g_strdup (ainfo->signal);
|
||||
ainfo_dup->key = ainfo->key;
|
||||
ainfo_dup->modifiers = ainfo->modifiers;
|
||||
|
||||
accels = g_list_prepend (accels, ainfo_dup);
|
||||
}
|
||||
|
||||
gvalue = g_new0 (GValue, 1);
|
||||
g_value_init (gvalue, GLADE_TYPE_ACCEL_GLIST);
|
||||
g_value_take_boxed (gvalue, accels);
|
||||
|
||||
if (property)
|
||||
GLADE_PROPERTY_GET_KLASS
|
||||
(property)->set_value (property, gvalue);
|
||||
|
||||
if (free_value)
|
||||
{
|
||||
g_value_unset (gvalue);
|
||||
g_free (gvalue);
|
||||
}
|
||||
|
||||
return gvalue;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
API
|
||||
*******************************************************************************/
|
||||
@ -1275,9 +1334,9 @@ glade_property_read (GladeProperty *property,
|
||||
ret = glade_property_read_packing
|
||||
(property, pclass, project, (GladeChildInfo *)info, free_value);
|
||||
}
|
||||
else switch (pclass->atk_type)
|
||||
else switch (pclass->type)
|
||||
{
|
||||
case GPC_ATK_NONE:
|
||||
case GPC_NORMAL:
|
||||
ret = glade_property_read_normal
|
||||
(property, pclass, project, (GladeWidgetInfo *)info, free_value);
|
||||
break;
|
||||
@ -1293,6 +1352,10 @@ glade_property_read (GladeProperty *property,
|
||||
ret = glade_property_read_atk_action
|
||||
(property, pclass, project, (GladeWidgetInfo *)info, free_value);
|
||||
break;
|
||||
case GPC_ACCEL_PROPERTY:
|
||||
ret = glade_property_read_accel_prop
|
||||
(property, pclass, project, (GladeWidgetInfo *)info, free_value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor,
|
||||
*/
|
||||
for (list = editor->class->signals; list; list = list->next)
|
||||
{
|
||||
GladeWidgetClassSignal *signal = (GladeWidgetClassSignal *) list->data;
|
||||
GladeSignalClass *signal = (GladeSignalClass *) list->data;
|
||||
|
||||
/* Add class name that this signal belongs to.
|
||||
*/
|
||||
|
@ -129,8 +129,7 @@ gwc_props_from_pspecs (GladeWidgetClass *class,
|
||||
for (i = 0; i < n_specs; i++)
|
||||
{
|
||||
if ((property_class =
|
||||
glade_property_class_new_from_spec (specs[i],
|
||||
class->book)) != NULL)
|
||||
glade_property_class_new_from_spec (class, specs[i])) != NULL)
|
||||
list = g_list_prepend (list, property_class);
|
||||
}
|
||||
return g_list_reverse (list);
|
||||
@ -159,10 +158,12 @@ glade_widget_class_list_properties (GladeWidgetClass *class)
|
||||
list = gwc_props_from_pspecs (class, specs, n_specs);
|
||||
g_free (specs);
|
||||
|
||||
list = g_list_append (list, glade_property_class_accel_property (class, class->type));
|
||||
|
||||
/* list the (hard-coded) atk relation properties if applicable */
|
||||
if (glade_util_class_implements_interface (class->type,
|
||||
ATK_TYPE_IMPLEMENTOR))
|
||||
atk_list = glade_property_class_list_atk_relations (class->type);
|
||||
atk_list = glade_property_class_list_atk_relations (class, class->type);
|
||||
|
||||
return g_list_concat (list, atk_list);
|
||||
}
|
||||
@ -248,7 +249,7 @@ glade_widget_class_list_signals (GladeWidgetClass *class)
|
||||
guint count;
|
||||
guint *sig_ids;
|
||||
guint num_signals;
|
||||
GladeWidgetClassSignal *cur;
|
||||
GladeSignalClass *cur;
|
||||
|
||||
g_return_val_if_fail (class->type != 0, NULL);
|
||||
|
||||
@ -261,11 +262,19 @@ glade_widget_class_list_signals (GladeWidgetClass *class)
|
||||
|
||||
for (count = 0; count < num_signals; count++)
|
||||
{
|
||||
cur = g_new0 (GladeWidgetClassSignal, 1);
|
||||
cur->name = (gchar *) g_signal_name (sig_ids[count]);
|
||||
cur = g_new0 (GladeSignalClass, 1);
|
||||
|
||||
g_signal_query (sig_ids[count], &(cur->query));
|
||||
|
||||
/* Since glib gave us this signal id... it should
|
||||
* exist no matter what.
|
||||
*/
|
||||
g_assert (cur->query.signal_id != 0);
|
||||
|
||||
cur->name = (cur->query.signal_name);
|
||||
cur->type = (gchar *) g_type_name (type);
|
||||
|
||||
signals = g_list_append (signals, (GladeWidgetClassSignal *) cur);
|
||||
signals = g_list_prepend (signals, cur);
|
||||
}
|
||||
g_free (sig_ids);
|
||||
}
|
||||
@ -273,7 +282,7 @@ glade_widget_class_list_signals (GladeWidgetClass *class)
|
||||
type = g_type_parent (type);
|
||||
}
|
||||
|
||||
return signals;
|
||||
return g_list_reverse (signals);
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
@ -358,7 +367,7 @@ glade_widget_class_update_properties_from_node (GladeXmlNode *node,
|
||||
}
|
||||
else
|
||||
{
|
||||
property_class = glade_property_class_new (widget_class->book);
|
||||
property_class = glade_property_class_new (widget_class);
|
||||
property_class->id = g_strdup (id);
|
||||
*properties = g_list_append (*properties, property_class);
|
||||
list = g_list_last (*properties);
|
||||
|
@ -10,14 +10,13 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GLADE_WIDGET_CLASS(gwc) ((GladeWidgetClass *) gwc)
|
||||
#define GLADE_IS_WIDGET_CLASS(gwc) (gwc != NULL)
|
||||
#define GLADE_VALID_CREATE_REASON(reason) (reason >= 0 && reason < GLADE_CREATE_REASONS)
|
||||
|
||||
typedef struct _GladeWidgetClass GladeWidgetClass;
|
||||
typedef struct _GladeSupportedChild GladeSupportedChild;
|
||||
typedef struct _GladeWidgetClassSignal GladeWidgetClassSignal;
|
||||
typedef struct _GladeSignalClass GladeSignalClass;
|
||||
|
||||
|
||||
/**
|
||||
@ -187,7 +186,7 @@ struct _GladeWidgetClass
|
||||
* editor.
|
||||
*/
|
||||
|
||||
GList *signals; /* List of GladeWidgetClassSignal objects */
|
||||
GList *signals; /* List of GladeSignalClass objects */
|
||||
|
||||
|
||||
GList *children; /* List of GladeSupportedChild objects */
|
||||
@ -251,14 +250,17 @@ struct _GladeSupportedChild
|
||||
};
|
||||
|
||||
|
||||
/* GladeWidgetClassSignal contains all the info we need for a given signal, such as
|
||||
/* GladeSignalClass contains all the info we need for a given signal, such as
|
||||
* the signal name, and maybe more in the future
|
||||
*/
|
||||
struct _GladeWidgetClassSignal
|
||||
struct _GladeSignalClass
|
||||
{
|
||||
GSignalQuery query;
|
||||
|
||||
gchar *name; /* Name of the signal, eg clicked */
|
||||
gchar *type; /* Name of the object class that this signal belongs to
|
||||
* eg GtkButton */
|
||||
|
||||
};
|
||||
|
||||
LIBGLADEUI_API
|
||||
@ -329,6 +331,9 @@ GladePackingDefault *glade_widget_class_get_packing_default (GladeWidgetC
|
||||
GladeWidgetClass *container_class,
|
||||
const gchar *propert_id);
|
||||
|
||||
#define glade_widget_class_from_pclass(pclass) \
|
||||
((pclass) ? (GladeWidgetClass *)((GladePropertyClass *)(pclass))->handle : NULL)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GLADE_WIDGET_CLASS_H__ */
|
||||
|
@ -590,7 +590,7 @@ glade_widget_template_params (GladeWidget *widget,
|
||||
continue;
|
||||
|
||||
pclass = glade_property->class;
|
||||
|
||||
|
||||
/* Ignore properties based on some criteria
|
||||
*/
|
||||
if (pclass == NULL || /* Unaccounted for in the builder */
|
||||
@ -2614,7 +2614,7 @@ glade_widget_write (GladeWidget *widget, GladeInterface *interface)
|
||||
{
|
||||
WriteSignalsContext write_signals_context;
|
||||
GladeWidgetInfo *info;
|
||||
GArray *props, *atk_props, *atk_actions, *atk_relations, *children;
|
||||
GArray *props, *atk_props, *atk_actions, *atk_relations, *accels, *children;
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
|
||||
@ -2629,6 +2629,7 @@ glade_widget_write (GladeWidget *widget, GladeInterface *interface)
|
||||
atk_props = g_array_new (FALSE, FALSE, sizeof (GladePropInfo));
|
||||
atk_relations = g_array_new (FALSE, FALSE, sizeof (GladeAtkRelationInfo));
|
||||
atk_actions = g_array_new (FALSE, FALSE, sizeof (GladeAtkActionInfo));
|
||||
accels = g_array_new (FALSE, FALSE, sizeof (GladeAccelInfo));
|
||||
|
||||
for (list = widget->properties; list; list = list->next)
|
||||
{
|
||||
@ -2638,9 +2639,9 @@ glade_widget_write (GladeWidget *widget, GladeInterface *interface)
|
||||
if (property->class->packing)
|
||||
continue;
|
||||
|
||||
switch (property->class->atk_type)
|
||||
switch (property->class->type)
|
||||
{
|
||||
case GPC_ATK_NONE:
|
||||
case GPC_NORMAL:
|
||||
glade_property_write (property, interface, props);
|
||||
break;
|
||||
case GPC_ATK_PROPERTY:
|
||||
@ -2652,6 +2653,9 @@ glade_widget_write (GladeWidget *widget, GladeInterface *interface)
|
||||
case GPC_ATK_ACTION:
|
||||
glade_property_write (property, interface, atk_actions);
|
||||
break;
|
||||
case GPC_ACCEL_PROPERTY:
|
||||
glade_property_write (property, interface, accels);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -2677,6 +2681,10 @@ glade_widget_write (GladeWidget *widget, GladeInterface *interface)
|
||||
info->n_atk_actions = atk_actions->len;
|
||||
g_array_free(atk_actions, FALSE);
|
||||
|
||||
/* Accels */
|
||||
info->accels = (GladeAccelInfo *) accels->data;
|
||||
info->n_accels = accels->len;
|
||||
g_array_free(accels, FALSE);
|
||||
|
||||
/* Signals */
|
||||
write_signals_context.interface = interface;
|
||||
|
@ -761,6 +761,7 @@ glade_xml_load_sym_from_node (GladeXmlNode *node_in,
|
||||
* its a good point... makeing a bugzilla entry.
|
||||
* -Tristan
|
||||
*
|
||||
* XXX http://bugzilla.gnome.org/show_bug.cgi?id=331797
|
||||
*/
|
||||
if (!g_module_symbol (module, buff, sym_location))
|
||||
if (!g_module_symbol (self, buff, sym_location))
|
||||
|
@ -29,7 +29,6 @@ typedef struct _GladeWidget GladeWidget;
|
||||
typedef struct _GladeProperty GladeProperty;
|
||||
typedef struct _GladeProject GladeProject;
|
||||
|
||||
|
||||
#include "glade-widget-class.h"
|
||||
#include "glade-widget.h"
|
||||
#include "glade-property-class.h"
|
||||
|
@ -68,8 +68,8 @@
|
||||
<spec>glade_standard_string_spec</spec>
|
||||
<visible-lines>2</visible-lines>
|
||||
</property>
|
||||
|
||||
</properties>
|
||||
|
||||
</glade-widget-class>
|
||||
|
||||
<glade-widget-class name="GtkContainer" _title="Container">
|
||||
|
Loading…
x
Reference in New Issue
Block a user