mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-09-24 00:04:33 -04:00
Added glade_command_set_properties_list().
* src/glade-command.[ch]: Added glade_command_set_properties_list(). * src/glade-editor.[ch]: Added reset dialog, used property_class->visible_lines instead of GladeParams * src/glade-project-window.c: Minor GUI touchups. * src/glade-property-class.[ch], src/glade.h: Implemented visible_lines tag loading, touched up comments. * src/glade-property.[ch]: Added glade_property_get_default() * src/glade-signal-editor.c: Removed the search box from the non-searchable treeview. * src/glade-xml-utils.c: fixed up allocator confusions a bit. * widgets/gtk+.xml: Made GtkLabel's label property multi-lined.
This commit is contained in:
parent
ca4ca12829
commit
357743fc47
20
ChangeLog
20
ChangeLog
@ -1,3 +1,23 @@
|
||||
2005-08-01 Tristan Van Berkom <tvb@gnome.org>
|
||||
|
||||
* src/glade-command.[ch]: Added glade_command_set_properties_list().
|
||||
|
||||
* src/glade-editor.[ch]: Added reset dialog, used property_class->visible_lines
|
||||
instead of GladeParams
|
||||
|
||||
* src/glade-project-window.c: Minor GUI touchups.
|
||||
|
||||
* src/glade-property-class.[ch], src/glade.h: Implemented visible_lines tag loading,
|
||||
touched up comments.
|
||||
|
||||
* src/glade-property.[ch]: Added glade_property_get_default()
|
||||
|
||||
* src/glade-signal-editor.c: Removed the search box from the non-searchable treeview.
|
||||
|
||||
* src/glade-xml-utils.c: fixed up allocator confusions a bit.
|
||||
|
||||
* widgets/gtk+.xml: Made GtkLabel's label property multi-lined.
|
||||
|
||||
2005-08-31 Tristan Van Berkom <tvb@gnome.org>
|
||||
|
||||
* TODO: Added note about TODO list not being maintained, please
|
||||
|
@ -284,11 +284,6 @@ glade_command_push_undo (GladeProject *project, GladeCommand *cmd)
|
||||
|
||||
/* create a new GladeCommandSetProperty class. Objects of this class will
|
||||
* encapsulate a "set property" operation */
|
||||
typedef struct {
|
||||
GladeProperty *property;
|
||||
GValue *new_value;
|
||||
GValue *old_value;
|
||||
} SetPropData;
|
||||
|
||||
typedef struct {
|
||||
GladeCommand parent;
|
||||
@ -325,7 +320,7 @@ glade_command_set_property_execute (GladeCommand *cmd)
|
||||
for (l = me->sdata; l; l = l->next)
|
||||
{
|
||||
GValue new_value = { 0, };
|
||||
SetPropData *sdata = l->data;
|
||||
GCSetPropData *sdata = l->data;
|
||||
|
||||
g_value_init (&new_value, G_VALUE_TYPE (sdata->new_value));
|
||||
g_value_copy (sdata->new_value, &new_value);
|
||||
@ -358,7 +353,7 @@ glade_command_set_property_finalize (GObject *obj)
|
||||
|
||||
for (l = me->sdata; l; l = l->next)
|
||||
{
|
||||
SetPropData *sdata = l->data;
|
||||
GCSetPropData *sdata = l->data;
|
||||
|
||||
if (sdata->property)
|
||||
g_object_unref (G_OBJECT (sdata->property));
|
||||
@ -390,8 +385,8 @@ glade_command_set_property_unifies (GladeCommand *this, GladeCommand *other)
|
||||
|
||||
return (g_list_length (cmd1->sdata) == 1 &&
|
||||
g_list_length (cmd2->sdata) == 1 &&
|
||||
((SetPropData *)cmd1->sdata->data)->property ==
|
||||
((SetPropData *)cmd2->sdata->data)->property);
|
||||
((GCSetPropData *)cmd1->sdata->data)->property ==
|
||||
((GCSetPropData *)cmd2->sdata->data)->property);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@ -414,7 +409,7 @@ glade_command_set_property_collapse (GladeCommand *this, GladeCommand *other)
|
||||
static gchar *
|
||||
glade_command_set_property_description (GladeCommandSetProperty *me)
|
||||
{
|
||||
SetPropData *sdata;
|
||||
GCSetPropData *sdata;
|
||||
gchar *description = NULL;
|
||||
gchar *value_name;
|
||||
|
||||
@ -445,33 +440,61 @@ glade_command_set_property_description (GladeCommandSetProperty *me)
|
||||
|
||||
|
||||
void
|
||||
glade_command_set_properties (GladeProperty *property, const GValue *old_value, const GValue *new_value, ...)
|
||||
glade_command_set_properties_list (GladeProject *project, GList *props)
|
||||
{
|
||||
GladeCommandSetProperty *me;
|
||||
GladeCommand *cmd;
|
||||
SetPropData *sdata;
|
||||
GladeProperty *prop;
|
||||
GValue *ovalue, *nvalue;
|
||||
va_list vl;
|
||||
GCSetPropData *sdata;
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
g_return_if_fail (G_IS_VALUE (old_value));
|
||||
g_return_if_fail (G_IS_VALUE (new_value));
|
||||
g_return_if_fail (G_VALUE_TYPE (new_value) == G_VALUE_TYPE (old_value));
|
||||
g_return_if_fail (GLADE_IS_PROJECT (project));
|
||||
g_return_if_fail (props);
|
||||
|
||||
me = (GladeCommandSetProperty*) g_object_new (GLADE_COMMAND_SET_PROPERTY_TYPE, NULL);
|
||||
cmd = GLADE_COMMAND (me);
|
||||
|
||||
/* Ref all props */
|
||||
for (list = props; list; list = list->next)
|
||||
{
|
||||
sdata = list->data;
|
||||
g_object_ref (G_OBJECT (sdata->property));
|
||||
}
|
||||
|
||||
me->sdata = props;
|
||||
cmd->description = glade_command_set_property_description (me);
|
||||
g_assert (cmd->description);
|
||||
|
||||
/* Push onto undo stack only if it executes successfully. */
|
||||
if (glade_command_set_property_execute (GLADE_COMMAND (me)))
|
||||
glade_command_push_undo (GLADE_PROJECT (project),
|
||||
GLADE_COMMAND (me));
|
||||
else
|
||||
/* No leaks on my shift! */
|
||||
g_object_unref (G_OBJECT (me));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glade_command_set_properties (GladeProperty *property, const GValue *old_value, const GValue *new_value, ...)
|
||||
{
|
||||
GCSetPropData *sdata;
|
||||
GladeProperty *prop;
|
||||
GValue *ovalue, *nvalue;
|
||||
GList *list = NULL;
|
||||
va_list vl;
|
||||
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
|
||||
/* Add first set */
|
||||
sdata = g_new (SetPropData, 1);
|
||||
sdata->property = g_object_ref (G_OBJECT (property));
|
||||
sdata = g_new (GCSetPropData, 1);
|
||||
sdata->property = property;
|
||||
sdata->old_value = g_new0 (GValue, 1);
|
||||
sdata->new_value = g_new0 (GValue, 1);
|
||||
g_value_init (sdata->old_value, G_VALUE_TYPE (old_value));
|
||||
g_value_init (sdata->new_value, G_VALUE_TYPE (new_value));
|
||||
g_value_copy (old_value, sdata->old_value);
|
||||
g_value_copy (new_value, sdata->new_value);
|
||||
me->sdata = g_list_prepend (me->sdata, sdata);
|
||||
list = g_list_prepend (list, sdata);
|
||||
|
||||
va_start (vl, new_value);
|
||||
while ((prop = va_arg (vl, GladeProperty *)) != NULL)
|
||||
@ -483,7 +506,7 @@ glade_command_set_properties (GladeProperty *property, const GValue *old_value,
|
||||
g_assert (G_IS_VALUE (ovalue));
|
||||
g_assert (G_IS_VALUE (nvalue));
|
||||
|
||||
sdata = g_new (SetPropData, 1);
|
||||
sdata = g_new (GCSetPropData, 1);
|
||||
sdata->property = g_object_ref (G_OBJECT (prop));
|
||||
sdata->old_value = g_new0 (GValue, 1);
|
||||
sdata->new_value = g_new0 (GValue, 1);
|
||||
@ -491,20 +514,11 @@ glade_command_set_properties (GladeProperty *property, const GValue *old_value,
|
||||
g_value_init (sdata->new_value, G_VALUE_TYPE (nvalue));
|
||||
g_value_copy (ovalue, sdata->old_value);
|
||||
g_value_copy (nvalue, sdata->new_value);
|
||||
me->sdata = g_list_prepend (me->sdata, sdata);
|
||||
list = g_list_prepend (list, sdata);
|
||||
}
|
||||
va_end (vl);
|
||||
|
||||
cmd->description = glade_command_set_property_description (me);
|
||||
g_assert (cmd->description);
|
||||
|
||||
/* Push onto undo stack only if it executes successfully. */
|
||||
if (glade_command_set_property_execute (GLADE_COMMAND (me)))
|
||||
glade_command_push_undo (GLADE_PROJECT (property->widget->project),
|
||||
GLADE_COMMAND (me));
|
||||
else
|
||||
/* No leaks on my shift! */
|
||||
g_object_unref (G_OBJECT (me));
|
||||
glade_command_set_properties_list (property->widget->project, list);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -19,9 +19,15 @@ G_BEGIN_DECLS
|
||||
#define GLADE_IS_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_COMMAND))
|
||||
#define GLADE_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_COMMAND, GladeCommandClass))
|
||||
|
||||
typedef struct _GladeCommand GladeCommand;
|
||||
typedef struct _GladeCommand GladeCommand;
|
||||
typedef struct _GladeCommandClass GladeCommandClass;
|
||||
typedef struct _GCSetPropData GCSetPropData;
|
||||
|
||||
struct _GCSetPropData {
|
||||
GladeProperty *property;
|
||||
GValue *new_value;
|
||||
GValue *old_value;
|
||||
};
|
||||
|
||||
struct _GladeCommand
|
||||
{
|
||||
@ -53,6 +59,9 @@ LIBGLADEUI_API void glade_command_set_properties(GladeProperty *prop
|
||||
const GValue *old_value,
|
||||
const GValue *new_value, ...);
|
||||
|
||||
LIBGLADEUI_API void glade_command_set_properties_list (GladeProject *project,
|
||||
GList *props); // list of GCSetPropData
|
||||
|
||||
LIBGLADEUI_API void glade_command_set_name (GladeWidget *glade_widget, const gchar *name);
|
||||
|
||||
LIBGLADEUI_API void glade_command_delete (GList *widgets);
|
||||
|
@ -56,6 +56,9 @@ static void glade_editor_property_load (GladeEditorProperty *property, GladeWidg
|
||||
static void glade_editor_property_load_flags (GladeEditorProperty *property);
|
||||
static void glade_editor_property_load_text (GladeEditorProperty *property);
|
||||
|
||||
static void glade_editor_reset_dialog (GladeEditor *editor);
|
||||
|
||||
|
||||
static void
|
||||
glade_editor_class_init (GladeEditorClass *class)
|
||||
{
|
||||
@ -682,7 +685,7 @@ glade_editor_property_show_i18n_dialog (GtkWidget *entry,
|
||||
vbox = gtk_vbox_new (FALSE, 6);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
|
||||
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);
|
||||
|
||||
@ -926,7 +929,6 @@ glade_editor_create_input_flags (GladeEditorProperty *property)
|
||||
static GtkWidget *
|
||||
glade_editor_create_input_text (GladeEditorProperty *property)
|
||||
{
|
||||
gint lines = 1;
|
||||
GladePropertyClass *class;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_EDITOR_PROPERTY (property), NULL);
|
||||
@ -934,12 +936,7 @@ glade_editor_create_input_text (GladeEditorProperty *property)
|
||||
|
||||
class = property->class;
|
||||
|
||||
/* XXX Make this class data GladeParamater can be used just for the plugin, if the
|
||||
* data gets treated in the core, we dont need to special case this like this.
|
||||
*/
|
||||
glade_parameter_get_integer (class->parameters, GLADE_TAG_VISIBLE_LINES, &lines);
|
||||
|
||||
if (lines < 2) {
|
||||
if (class->visible_lines < 2) {
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *button;
|
||||
@ -965,18 +962,31 @@ glade_editor_create_input_text (GladeEditorProperty *property)
|
||||
G_CALLBACK (glade_editor_property_show_i18n_dialog),
|
||||
property);
|
||||
}
|
||||
|
||||
property->text_entry = entry;
|
||||
|
||||
return hbox;
|
||||
} else {
|
||||
GtkWidget *hbox;
|
||||
GtkTextView *view;
|
||||
GtkWidget *button;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *view;
|
||||
GtkWidget *viewport;
|
||||
GtkWidget *swindow;
|
||||
GtkWidget *button;
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
swindow = gtk_scrolled_window_new (NULL, NULL);
|
||||
viewport = gtk_viewport_new (NULL, NULL);
|
||||
view = gtk_text_view_new ();
|
||||
|
||||
view = GTK_TEXT_VIEW (gtk_text_view_new ());
|
||||
gtk_text_view_set_editable (view, TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (view), TRUE, TRUE, 0);
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), TRUE);
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow), GTK_SHADOW_IN);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (viewport), view);
|
||||
gtk_container_add (GTK_CONTAINER (swindow), viewport);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (swindow), TRUE, TRUE, 0);
|
||||
|
||||
g_signal_connect (G_OBJECT (view), "focus-out-event",
|
||||
G_CALLBACK (glade_editor_text_view_focus_out),
|
||||
@ -991,6 +1001,8 @@ glade_editor_create_input_text (GladeEditorProperty *property)
|
||||
property);
|
||||
}
|
||||
|
||||
property->text_entry = view;
|
||||
|
||||
return hbox;
|
||||
}
|
||||
|
||||
@ -1296,7 +1308,7 @@ glade_editor_on_edit_menu_click (GtkButton *button, GladeEditor *editor)
|
||||
menubar = GTK_WIDGET(editor->loaded_widget->object);
|
||||
g_return_if_fail (GTK_IS_MENU_BAR (menubar));
|
||||
|
||||
project = GLADE_PROJECT (editor->loaded_widget->project);
|
||||
project = GLADE_PROJECT (glade_widget_get_project (editor->loaded_widget));
|
||||
g_return_if_fail (project != NULL);
|
||||
|
||||
menu_editor = glade_menu_editor_new (project, GTK_MENU_SHELL (menubar));
|
||||
@ -1324,12 +1336,21 @@ glade_editor_table_new (void)
|
||||
return table;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_editor_on_reset_click (GtkButton *button,
|
||||
GladeEditor *editor)
|
||||
{
|
||||
glade_editor_reset_dialog (editor);
|
||||
}
|
||||
|
||||
|
||||
static GladeEditorTable *
|
||||
glade_editor_table_create (GladeEditor *editor,
|
||||
GladeWidgetClass *class,
|
||||
GladeEditorTableType type)
|
||||
{
|
||||
GladeEditorTable *table;
|
||||
GtkWidget *hbox, *button;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_EDITOR (editor), NULL);
|
||||
g_return_val_if_fail (GLADE_IS_WIDGET_CLASS (class), NULL);
|
||||
@ -1349,17 +1370,37 @@ glade_editor_table_create (GladeEditor *editor,
|
||||
&table->properties, type))
|
||||
return NULL;
|
||||
|
||||
/* Hack: We don't have currently a way to put a "Edit Menus..." button through the
|
||||
* xml files. */
|
||||
if (type == TABLE_TYPE_GENERAL && !strcmp (class->name, "GtkMenuBar")) {
|
||||
GtkWidget *edit_menu_button = gtk_button_new_with_label (_("Edit Menus..."));
|
||||
|
||||
g_signal_connect (G_OBJECT (edit_menu_button), "clicked",
|
||||
G_CALLBACK (glade_editor_on_edit_menu_click), editor);
|
||||
gtk_table_attach (GTK_TABLE (table->table_widget), edit_menu_button,
|
||||
if (type == TABLE_TYPE_GENERAL)
|
||||
{
|
||||
hbox = gtk_hbutton_box_new ();
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table->table_widget), hbox,
|
||||
0, 2, table->rows, table->rows + 1,
|
||||
GTK_EXPAND, 0, 0, 0);
|
||||
table->rows++;
|
||||
|
||||
button = gtk_button_new_with_label (_("Set Defaults..."));
|
||||
gtk_container_set_border_width (GTK_CONTAINER (button),
|
||||
GLADE_GENERIC_BORDER_WIDTH);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (glade_editor_on_reset_click), editor);
|
||||
|
||||
/* Hack: We don't have currently a way to put a "Edit Menus..." button through the
|
||||
* xml files. */
|
||||
if (!strcmp (class->name, "GtkMenuBar")) {
|
||||
|
||||
button = gtk_button_new_with_label (_("Edit Menus..."));
|
||||
gtk_container_set_border_width (GTK_CONTAINER (button),
|
||||
GLADE_GENERIC_BORDER_WIDTH);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (glade_editor_on_edit_menu_click), editor);
|
||||
table->rows++;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_show_all (table->table_widget);
|
||||
@ -1669,20 +1710,14 @@ glade_editor_property_load_boolean (GladeEditorProperty *property)
|
||||
static void
|
||||
glade_editor_property_load_text (GladeEditorProperty *property)
|
||||
{
|
||||
GtkBoxChild *child;
|
||||
GtkWidget *widget;
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property->property));
|
||||
g_return_if_fail (property->property->value != NULL);
|
||||
g_return_if_fail (property->input != NULL);
|
||||
|
||||
/* The entry/textview is the first child. */
|
||||
child = GTK_BOX (property->input)->children->data;
|
||||
widget = child->widget;
|
||||
|
||||
if (GTK_IS_EDITABLE (widget)) {
|
||||
GtkEditable *editable = GTK_EDITABLE (widget);
|
||||
if (GTK_IS_EDITABLE (property->text_entry)) {
|
||||
GtkEditable *editable = GTK_EDITABLE (property->text_entry);
|
||||
gint pos, insert_pos = 0;
|
||||
const gchar *text;
|
||||
text = g_value_get_string (property->property->value);
|
||||
@ -1695,19 +1730,19 @@ glade_editor_property_load_text (GladeEditorProperty *property)
|
||||
&insert_pos);
|
||||
|
||||
gtk_editable_set_position (editable, pos);
|
||||
} else if (GTK_IS_TEXT_VIEW (widget)) {
|
||||
} else if (GTK_IS_TEXT_VIEW (property->text_entry)) {
|
||||
GtkTextBuffer *buffer;
|
||||
const gchar *text;
|
||||
|
||||
text = g_value_get_string (property->property->value);
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (property->text_entry));
|
||||
|
||||
gtk_text_buffer_set_text (buffer,
|
||||
text ? text : "",
|
||||
text ? g_utf8_strlen (text, -1) : 0);
|
||||
|
||||
} else {
|
||||
g_warning ("Invalid Text Widget type.");
|
||||
g_warning ("BUG! Invalid Text Widget type.");
|
||||
}
|
||||
|
||||
g_object_set_data (G_OBJECT (property->input), "user_data", property);
|
||||
@ -2107,3 +2142,433 @@ glade_editor_editable_property (GParamSpec *pspec)
|
||||
G_IS_PARAM_SPEC_UINT64(pspec) ||
|
||||
G_IS_PARAM_SPEC_UNICHAR(pspec)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
||||
enum {
|
||||
COLUMN_ENABLED = 0,
|
||||
COLUMN_PROP_NAME,
|
||||
COLUMN_PROPERTY,
|
||||
COLUMN_PARENT,
|
||||
COLUMN_DEFAULT,
|
||||
COLUMN_NDEFAULT,
|
||||
COLUMN_DEFSTRING,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
glade_editor_reset_toggled (GtkCellRendererToggle *cell,
|
||||
gchar *path_str,
|
||||
GtkTreeModel *model)
|
||||
{
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
|
||||
GtkTreeIter iter;
|
||||
gboolean enabled;
|
||||
|
||||
/* get toggled iter */
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
gtk_tree_model_get (model, &iter,
|
||||
COLUMN_ENABLED, &enabled, -1);
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
|
||||
COLUMN_ENABLED, !enabled, -1);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
glade_editor_reset_view (GladeEditor *editor)
|
||||
{
|
||||
GtkWidget *view_widget;
|
||||
GtkTreeModel *model;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
|
||||
model = (GtkTreeModel *)gtk_tree_store_new (NUM_COLUMNS,
|
||||
G_TYPE_BOOLEAN, /* Enabled value */
|
||||
G_TYPE_STRING, /* Property name */
|
||||
GLADE_TYPE_PROPERTY, /* The property */
|
||||
G_TYPE_BOOLEAN, /* Parent node ? */
|
||||
G_TYPE_BOOLEAN, /* Has default value */
|
||||
G_TYPE_BOOLEAN, /* Doesn't have defaut */
|
||||
G_TYPE_STRING); /* Default string */
|
||||
|
||||
view_widget = gtk_tree_view_new_with_model (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);
|
||||
|
||||
/************************ enabled column ************************/
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
g_object_set (G_OBJECT (renderer),
|
||||
"mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
|
||||
"activatable", TRUE,
|
||||
NULL);
|
||||
g_signal_connect (renderer, "toggled",
|
||||
G_CALLBACK (glade_editor_reset_toggled), model);
|
||||
gtk_tree_view_insert_column_with_attributes
|
||||
(GTK_TREE_VIEW (view_widget), COLUMN_ENABLED,
|
||||
_("Reset"), renderer,
|
||||
"visible", COLUMN_NDEFAULT,
|
||||
"active", COLUMN_ENABLED,
|
||||
NULL);
|
||||
|
||||
/********************* property name column *********************/
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_object_set (G_OBJECT (renderer),
|
||||
"editable", FALSE,
|
||||
"weight", PANGO_WEIGHT_BOLD, NULL);
|
||||
gtk_tree_view_insert_column_with_attributes
|
||||
(GTK_TREE_VIEW (view_widget), COLUMN_PROP_NAME,
|
||||
_("Property"), renderer,
|
||||
"text", COLUMN_PROP_NAME,
|
||||
"weight-set", COLUMN_PARENT,
|
||||
NULL);
|
||||
|
||||
/******************* default indicator column *******************/
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_object_set (G_OBJECT (renderer),
|
||||
"editable", FALSE,
|
||||
"style", PANGO_STYLE_ITALIC,
|
||||
"foreground", "Gray", NULL);
|
||||
gtk_tree_view_insert_column_with_attributes
|
||||
(GTK_TREE_VIEW (view_widget), COLUMN_DEFSTRING,
|
||||
NULL, renderer,
|
||||
"text", COLUMN_DEFSTRING,
|
||||
NULL);
|
||||
|
||||
return view_widget;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_editor_populate_reset_view (GladeEditor *editor,
|
||||
GtkTreeView *tree_view)
|
||||
{
|
||||
GtkTreeStore *model = (GtkTreeStore *)gtk_tree_view_get_model (tree_view);
|
||||
GtkTreeIter property_iter, general_iter, packing_iter, common_iter, *iter;
|
||||
GList *list;
|
||||
GladeProperty *property;
|
||||
gboolean def;
|
||||
|
||||
g_return_if_fail (editor->loaded_widget != NULL);
|
||||
|
||||
gtk_tree_store_append (model, &general_iter, NULL);
|
||||
gtk_tree_store_set (model, &general_iter,
|
||||
COLUMN_PROP_NAME, _("General"),
|
||||
COLUMN_PROPERTY, NULL,
|
||||
COLUMN_PARENT, TRUE,
|
||||
COLUMN_DEFAULT, FALSE,
|
||||
COLUMN_NDEFAULT, FALSE,
|
||||
-1);
|
||||
|
||||
gtk_tree_store_append (model, &common_iter, NULL);
|
||||
gtk_tree_store_set (model, &common_iter,
|
||||
COLUMN_PROP_NAME, _("Common"),
|
||||
COLUMN_PROPERTY, NULL,
|
||||
COLUMN_PARENT, TRUE,
|
||||
COLUMN_DEFAULT, FALSE,
|
||||
COLUMN_NDEFAULT, FALSE,
|
||||
-1);
|
||||
|
||||
/* General & Common */
|
||||
for (list = editor->loaded_widget->properties; list; list = list->next)
|
||||
{
|
||||
property = list->data;
|
||||
|
||||
if (property->class->common)
|
||||
iter = &common_iter;
|
||||
else
|
||||
iter = &general_iter;
|
||||
|
||||
def = glade_property_default (property);
|
||||
|
||||
gtk_tree_store_append (model, &property_iter, iter);
|
||||
gtk_tree_store_set (model, &property_iter,
|
||||
COLUMN_ENABLED, !def,
|
||||
COLUMN_PROP_NAME, property->class->name,
|
||||
COLUMN_PROPERTY, property,
|
||||
COLUMN_PARENT, FALSE,
|
||||
COLUMN_DEFAULT, def,
|
||||
COLUMN_NDEFAULT, !def,
|
||||
COLUMN_DEFSTRING, _("(default)"),
|
||||
-1);
|
||||
}
|
||||
|
||||
/* Packing */
|
||||
if (editor->loaded_widget->packing_properties)
|
||||
{
|
||||
gtk_tree_store_append (model, &packing_iter, NULL);
|
||||
gtk_tree_store_set (model, &packing_iter,
|
||||
COLUMN_PROP_NAME, _("Packing"),
|
||||
COLUMN_PROPERTY, NULL,
|
||||
COLUMN_PARENT, TRUE,
|
||||
COLUMN_DEFAULT, FALSE,
|
||||
COLUMN_NDEFAULT, FALSE,
|
||||
-1);
|
||||
|
||||
for (list = editor->loaded_widget->packing_properties; list; list = list->next)
|
||||
{
|
||||
property = list->data;
|
||||
|
||||
def = glade_property_default (property);
|
||||
|
||||
gtk_tree_store_append (model, &property_iter, &packing_iter);
|
||||
gtk_tree_store_set (model, &property_iter,
|
||||
COLUMN_ENABLED, FALSE,
|
||||
COLUMN_PROP_NAME, property->class->name,
|
||||
COLUMN_PROPERTY, property,
|
||||
COLUMN_PARENT, FALSE,
|
||||
COLUMN_DEFAULT, def,
|
||||
COLUMN_NDEFAULT, !def,
|
||||
COLUMN_DEFSTRING, _("(default)"),
|
||||
-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
glade_editor_reset_selection_changed_cb (GtkTreeSelection *selection,
|
||||
GtkTextView *desc_view)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GladeProperty *property = NULL;
|
||||
GtkTreeModel *model = NULL;
|
||||
GtkTextBuffer *text_buffer;
|
||||
|
||||
const gchar *message =
|
||||
_("Select the properties that you want to reset to their default values");
|
||||
|
||||
/* Find selected data and show property blurb here */
|
||||
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||
{
|
||||
text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (desc_view));
|
||||
gtk_tree_model_get (model, &iter, COLUMN_PROPERTY, &property, -1);
|
||||
gtk_text_buffer_set_text (text_buffer,
|
||||
property ? glade_property_get_tooltip (property) : message,
|
||||
-1);
|
||||
if (property)
|
||||
g_object_unref (G_OBJECT (property));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
glade_editor_reset_foreach_selection (GtkTreeModel *model,
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
gboolean select)
|
||||
{
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model), iter, COLUMN_ENABLED, select, -1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glade_editor_reset_select_all_clicked (GtkButton *button,
|
||||
GtkTreeView *tree_view)
|
||||
{
|
||||
GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
|
||||
gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc)
|
||||
glade_editor_reset_foreach_selection,
|
||||
GINT_TO_POINTER (TRUE));
|
||||
}
|
||||
|
||||
static void
|
||||
glade_editor_reset_unselect_all_clicked (GtkButton *button,
|
||||
GtkTreeView *tree_view)
|
||||
{
|
||||
GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
|
||||
gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc)
|
||||
glade_editor_reset_foreach_selection,
|
||||
GINT_TO_POINTER (FALSE));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
glade_editor_reset_accumulate_selected_props (GtkTreeModel *model,
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
GList **accum)
|
||||
{
|
||||
GladeProperty *property;
|
||||
gboolean enabled, def;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
COLUMN_PROPERTY, &property,
|
||||
COLUMN_ENABLED, &enabled,
|
||||
COLUMN_DEFAULT, &def,
|
||||
-1);
|
||||
|
||||
if (property && enabled && !def)
|
||||
*accum = g_list_prepend (*accum, property);
|
||||
|
||||
|
||||
if (property)
|
||||
g_object_unref (G_OBJECT (property));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GList *
|
||||
glade_editor_reset_get_selected_props (GtkTreeModel *model)
|
||||
{
|
||||
GList *ret = NULL;
|
||||
|
||||
gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc)
|
||||
glade_editor_reset_accumulate_selected_props, &ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_editor_reset_properties (GList *props)
|
||||
{
|
||||
GList *list, *sdata_list = NULL;
|
||||
GCSetPropData *sdata;
|
||||
GladeProperty *prop;
|
||||
GladeProject *project = NULL;
|
||||
|
||||
for (list = props; list; list = list->next)
|
||||
{
|
||||
prop = list->data;
|
||||
|
||||
project = glade_widget_get_project (prop->widget);
|
||||
|
||||
sdata = g_new (GCSetPropData, 1);
|
||||
sdata->property = prop;
|
||||
|
||||
sdata->old_value = g_new0 (GValue, 1);
|
||||
sdata->new_value = g_new0 (GValue, 1);
|
||||
|
||||
glade_property_get_value (prop, sdata->old_value);
|
||||
glade_property_get_default (prop, sdata->new_value);
|
||||
|
||||
sdata_list = g_list_prepend (sdata_list, sdata);
|
||||
}
|
||||
|
||||
if (project)
|
||||
/* GladeCommand takes ownership of allocated list, ugly but practicle */
|
||||
glade_command_set_properties_list (project, sdata_list);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
glade_editor_reset_dialog (GladeEditor *editor)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
GtkWidget *dialog, *parent;
|
||||
GtkWidget *vbox, *hbox, *label, *sw, *button;
|
||||
GtkWidget *tree_view, *description_view;
|
||||
gint res;
|
||||
GList *list;
|
||||
|
||||
parent = gtk_widget_get_toplevel (GTK_WIDGET (editor));
|
||||
dialog = gtk_dialog_new_with_buttons (_("Reset Widget Properties"),
|
||||
GTK_WINDOW (parent),
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
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);
|
||||
|
||||
/* Checklist */
|
||||
label = gtk_label_new_with_mnemonic (_("_Properties:"));
|
||||
gtk_widget_show (label);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 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_editor_reset_view (editor);
|
||||
glade_editor_populate_reset_view (editor, GTK_TREE_VIEW (tree_view));
|
||||
gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
|
||||
|
||||
gtk_widget_show (tree_view);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), tree_view);
|
||||
gtk_container_add (GTK_CONTAINER (sw), tree_view);
|
||||
|
||||
/* Select all / Unselect all */
|
||||
hbox = gtk_hbutton_box_new ();
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
|
||||
gtk_widget_show (hbox);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
|
||||
|
||||
button = gtk_button_new_with_mnemonic (_("_Select All"));
|
||||
gtk_widget_show (button);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (button), GLADE_GENERIC_BORDER_WIDTH);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (glade_editor_reset_select_all_clicked), tree_view);
|
||||
|
||||
button = gtk_button_new_with_mnemonic (_("_Unselect All"));
|
||||
gtk_widget_show (button);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (button), GLADE_GENERIC_BORDER_WIDTH);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (glade_editor_reset_unselect_all_clicked), tree_view);
|
||||
|
||||
|
||||
/* Description */
|
||||
label = gtk_label_new_with_mnemonic (_("Property _Description:"));
|
||||
gtk_widget_show (label);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 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, 80);
|
||||
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);
|
||||
|
||||
description_view = gtk_text_view_new ();
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (description_view), FALSE);
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (description_view), GTK_WRAP_WORD);
|
||||
|
||||
gtk_widget_show (description_view);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), description_view);
|
||||
gtk_container_add (GTK_CONTAINER (sw), description_view);
|
||||
|
||||
/* Update description */
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
|
||||
g_signal_connect (G_OBJECT (selection), "changed",
|
||||
G_CALLBACK (glade_editor_reset_selection_changed_cb),
|
||||
description_view);
|
||||
|
||||
|
||||
|
||||
/* Run the dialog */
|
||||
res = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
if (res == GTK_RESPONSE_OK) {
|
||||
|
||||
/* get all selected properties and reset properties through glade_command */
|
||||
if ((list = glade_editor_reset_get_selected_props
|
||||
(gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)))) != NULL)
|
||||
{
|
||||
glade_editor_reset_properties (list);
|
||||
g_list_free (list);
|
||||
}
|
||||
}
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
@ -194,6 +194,8 @@ struct _GladeEditorProperty
|
||||
|
||||
GtkWidget *eventbox; /* Keep a hold of this for tooltips */
|
||||
GtkWidget *item_label; /* control visual label state manually */
|
||||
|
||||
GtkWidget *text_entry; /* Keep a hold of either the entry or textview. */
|
||||
};
|
||||
|
||||
LIBGLADEUI_API GType glade_editor_get_type (void);
|
||||
|
@ -749,7 +749,8 @@ gpw_create_editor (GladeProjectWindow *gpw)
|
||||
gtk_window_set_title (gpw->priv->editor_window, _("Properties"));
|
||||
gtk_window_move (gpw->priv->editor_window, 350, 0);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (gpw->priv->editor_window), GTK_WIDGET (glade_app_get_editor (GLADE_APP(gpw))));
|
||||
gtk_container_add (GTK_CONTAINER (gpw->priv->editor_window),
|
||||
GTK_WIDGET (glade_app_get_editor (GLADE_APP(gpw))));
|
||||
|
||||
/* Delete event, don't destroy it */
|
||||
g_signal_connect (G_OBJECT (gpw->priv->editor_window), "delete_event",
|
||||
@ -812,12 +813,26 @@ gpw_create_widget_tree_contents (GladeProjectWindow *gpw)
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view), GTK_SHADOW_IN);
|
||||
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (view), GLADE_GENERIC_BORDER_WIDTH);
|
||||
|
||||
/* Add control buttons to the treeview. */
|
||||
hbox = gtk_hbox_new (TRUE, 0);
|
||||
hbox = gtk_hbutton_box_new ();
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
expand = gtk_button_new_with_label (_("Expand all"));
|
||||
collapse = gtk_button_new_with_label (_("Collapse all"));
|
||||
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_START);
|
||||
|
||||
|
||||
expand = gtk_button_new_with_mnemonic (_("E_xpand all"));
|
||||
gtk_container_set_border_width (GTK_CONTAINER (expand),
|
||||
GLADE_GENERIC_BORDER_WIDTH);
|
||||
|
||||
collapse = gtk_button_new_with_mnemonic (_("_Collapse all"));
|
||||
gtk_container_set_border_width (GTK_CONTAINER (collapse),
|
||||
GLADE_GENERIC_BORDER_WIDTH);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), expand, FALSE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), collapse, FALSE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (view), TRUE, TRUE, 0);
|
||||
@ -948,9 +963,11 @@ gpw_toggle_clipboard_cb (GtkAction *action, GladeProjectWindow *gpw)
|
||||
static void gpw_about_cb (GtkAction *action, GladeProjectWindow *gpw)
|
||||
{
|
||||
gchar *authors[] =
|
||||
{ "Joaquin Cuenca Abela",
|
||||
{ "Joaquin Cuenca Abela <e98cuenc@yahoo.com>",
|
||||
"Chema Celorio <chema@ximian.com>",
|
||||
"Paolo Borelli <pborelli@katamail.com>",
|
||||
"Archit Baweja <bighead@users.sourceforge.net>",
|
||||
"Shane Butler <shane_b@operamail.com>",
|
||||
"Tristan Van Berkom <tvb@gnome.org>",
|
||||
NULL };
|
||||
|
||||
@ -1050,9 +1067,9 @@ static const gchar *ui_info =
|
||||
|
||||
static GtkActionEntry entries[] = {
|
||||
{ "FileMenu", NULL, "_File" },
|
||||
{ "EditMenu", NULL, "Edit" },
|
||||
{ "ViewMenu", NULL, "View" },
|
||||
{ "ProjectMenu", NULL, "Project" },
|
||||
{ "EditMenu", NULL, "_Edit" },
|
||||
{ "ViewMenu", NULL, "_View" },
|
||||
{ "ProjectMenu", NULL, "_Project" },
|
||||
{ "HelpMenu", NULL, "_Help" },
|
||||
|
||||
/* FileMenu */
|
||||
@ -1279,7 +1296,7 @@ glade_project_window_create (GladeProjectWindow *gpw)
|
||||
|
||||
app = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_move (GTK_WINDOW (app), 0, 0);
|
||||
gtk_window_set_default_size (GTK_WINDOW (app), 280, 220);
|
||||
gtk_window_set_default_size (GTK_WINDOW (app), 300, 450);
|
||||
filename = g_build_filename (glade_icon_dir, "glade-3.png", NULL);
|
||||
gtk_window_set_default_icon_from_file (filename, NULL);
|
||||
g_free (filename);
|
||||
|
@ -882,7 +882,10 @@ glade_property_class_update_from_node (GladeXmlNode *node,
|
||||
|
||||
g_type_class_unref(fclass);
|
||||
}
|
||||
|
||||
|
||||
/* Visible lines */
|
||||
glade_xml_get_value_int (node, GLADE_TAG_VISIBLE_LINES, &class->visible_lines);
|
||||
|
||||
/* Get the Parameters */
|
||||
child = glade_xml_search_child (node, GLADE_TAG_PARAMETERS);
|
||||
if (child)
|
||||
@ -895,12 +898,12 @@ glade_property_class_update_from_node (GladeXmlNode *node,
|
||||
class->translatable = glade_xml_get_property_boolean (node, GLADE_TAG_TRANSLATABLE, TRUE);
|
||||
|
||||
/* common, optional, etc */
|
||||
class->common = glade_xml_get_property_boolean (node, GLADE_TAG_COMMON, class->common);
|
||||
class->optional = glade_xml_get_property_boolean (node, GLADE_TAG_OPTIONAL, class->optional);
|
||||
class->query = glade_xml_get_property_boolean (node, GLADE_TAG_QUERY, class->query);
|
||||
class->save = glade_xml_get_property_boolean (node, GLADE_TAG_SAVE, class->save);
|
||||
class->visible = glade_xml_get_property_boolean (node, GLADE_TAG_VISIBLE, class->visible);
|
||||
class->ignore = glade_xml_get_property_boolean (node, GLADE_TAG_IGNORE, class->ignore);
|
||||
class->common = glade_xml_get_property_boolean (node, GLADE_TAG_COMMON, class->common);
|
||||
class->optional = glade_xml_get_property_boolean (node, GLADE_TAG_OPTIONAL, class->optional);
|
||||
class->query = glade_xml_get_property_boolean (node, GLADE_TAG_QUERY, class->query);
|
||||
class->save = glade_xml_get_property_boolean (node, GLADE_TAG_SAVE, class->save);
|
||||
class->visible = glade_xml_get_property_boolean (node, GLADE_TAG_VISIBLE, class->visible);
|
||||
class->ignore = glade_xml_get_property_boolean (node, GLADE_TAG_IGNORE, class->ignore);
|
||||
|
||||
if (class->optional)
|
||||
class->optional_default =
|
||||
|
@ -4,84 +4,9 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* The GladeProperty object describes a settable parameter of a widget.
|
||||
* All entries that the user can change in the first page of the GladeEditor
|
||||
* make are a GladeProperty (except for the widget name)
|
||||
* GladeProperties can be of any type of GladePropertyType
|
||||
|
||||
Sample xml
|
||||
|
||||
Integer Type : (float is very similar)
|
||||
|
||||
<Property>
|
||||
<Type>Integer</Type>
|
||||
<Name>Border Width</Name>
|
||||
<Tooltip>The width of the border arround the container</Tooltip>
|
||||
<GtkArg>border</GtkArg>
|
||||
<Parameters>
|
||||
<Parameter Key="Min" Value="0"/>
|
||||
<Parameter Key="Max" Value="10000"/>
|
||||
<Parameter Key="Default" Value="0"/>
|
||||
<Parameter Key="StepIncrement" Value="1"/>
|
||||
<Parameter Key="PageIncrement" Value="10"/>
|
||||
<Parameter Key="ClibmRate" Value="1"/>
|
||||
</Parameters>
|
||||
</Property>
|
||||
|
||||
Text Type :
|
||||
|
||||
<Property>
|
||||
<Type>Text</Type>
|
||||
<Name>Title</Name>
|
||||
<Tooltip>The title of the window</Tooltip>
|
||||
<GtkArg>title</GtkArg>
|
||||
<Parameters>
|
||||
<Parameter Key="VisibleLines" Value="1"/>
|
||||
<Parameter Key="Default" Value=""/>
|
||||
</Parameters>
|
||||
</Property>
|
||||
|
||||
Boolean Type :
|
||||
|
||||
<Property>
|
||||
<Type>Boolean</Type>
|
||||
<Name>Grow</Name>
|
||||
<Tooltip>If the window can be enlarged</Tooltip>
|
||||
<GtkArg>fixme</GtkArg>
|
||||
<Parameters>
|
||||
<Parameter Key="Default" Value="True"/>
|
||||
</Parameters>
|
||||
</Property>
|
||||
|
||||
|
||||
Enum Type :
|
||||
|
||||
<Property>
|
||||
<Type>Choice</Type>
|
||||
<Name>Position</Name>
|
||||
<Tooltip>The initial position of the window</Tooltip>
|
||||
<GtkArg>fixme</GtkArg>
|
||||
<Parameters>
|
||||
<Parameter Key="Default" Value="GTK_WIN_POS_NONE"/>
|
||||
</Parameters>
|
||||
<Enums>
|
||||
<Enum>String Equiv</Enum>
|
||||
<Choices>
|
||||
<Choice>
|
||||
<Name>None</Name>
|
||||
<Symbol>GTK_WIN_POS_NONE</Symbol>
|
||||
</Choice>
|
||||
<Choice>
|
||||
<Name>Center</Name>
|
||||
<Symbol>GTK_WIN_POS_CENTER</Symbol>
|
||||
</Choice>
|
||||
<Choice>
|
||||
<Name>Mouse</Name>
|
||||
<Symbol>GTK_WIN_POS_MOUSE</Symbol>
|
||||
</Choice>
|
||||
</Choices>
|
||||
</Property>
|
||||
|
||||
/* The GladePropertyClass structure parameters of a GladeProperty.
|
||||
* All entries in the GladeEditor are GladeProperties (except signals)
|
||||
* All GladeProperties are associated with a GParamSpec.
|
||||
*/
|
||||
|
||||
#define GLADE_PROPERTY_CLASS(gpc) ((GladePropertyClass *) gpc)
|
||||
@ -146,6 +71,10 @@ struct _GladePropertyClass
|
||||
* UI.
|
||||
*/
|
||||
|
||||
gint visible_lines; /* When this pspec calls for a text editor, how many
|
||||
* lines should be visible in the editor.
|
||||
*/
|
||||
|
||||
/* These three are the master switches for the glade-file output,
|
||||
* property editor availability & live object updates in the glade environment.
|
||||
*/
|
||||
@ -181,6 +110,11 @@ struct _GladePropertyClass
|
||||
* we need to implement it inside glade. This is a pointer
|
||||
* to the function that can get this property. The functions
|
||||
* to work arround these problems are inside glade-gtk.c
|
||||
*
|
||||
* Note that since glade knows what the property values are
|
||||
* at all times regardless of the objects copy, this is currently
|
||||
* only used to obtain the values of packing properties that are
|
||||
* set by the said object's parent at "container_add" time.
|
||||
*/
|
||||
void (*get_function) (GObject *object,
|
||||
GValue *value);
|
||||
|
@ -182,6 +182,14 @@ glade_property_get_value_impl (GladeProperty *property, GValue *value)
|
||||
g_value_copy (property->value, value);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_property_get_default_impl (GladeProperty *property, GValue *value)
|
||||
{
|
||||
|
||||
g_value_init (value, property->class->pspec->value_type);
|
||||
g_value_copy (property->class->def, value);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_property_sync_impl (GladeProperty *property)
|
||||
{
|
||||
@ -444,6 +452,7 @@ glade_property_klass_init (GladePropertyKlass *prop_class)
|
||||
prop_class->def = glade_property_default_impl;
|
||||
prop_class->set_value = glade_property_set_value_impl;
|
||||
prop_class->get_value = glade_property_get_value_impl;
|
||||
prop_class->get_default = glade_property_get_default_impl;
|
||||
prop_class->sync = glade_property_sync_impl;
|
||||
prop_class->write = glade_property_write_impl;
|
||||
prop_class->get_tooltip = glade_property_get_tooltip_impl;
|
||||
@ -733,6 +742,21 @@ glade_property_get_value (GladeProperty *property, GValue *value)
|
||||
GLADE_PROPERTY_GET_KLASS (property)->get_value (property, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_property_get_default:
|
||||
* @property: a #GladeProperty
|
||||
* @value: a #GValue
|
||||
*
|
||||
* TODO: write me
|
||||
*/
|
||||
void
|
||||
glade_property_get_default (GladeProperty *property, GValue *value)
|
||||
{
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
g_return_if_fail (value != NULL);
|
||||
GLADE_PROPERTY_GET_KLASS (property)->get_default (property, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_property_get_va_list:
|
||||
* @property: a #GladeProperty
|
||||
|
@ -13,7 +13,6 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GladePropertyKlass GladePropertyKlass;
|
||||
|
||||
|
||||
/* A GladeProperty is an instance of a GladePropertyClass.
|
||||
* There will be one GladePropertyClass for "GtkLabel->label" but one
|
||||
* GladeProperty for each GtkLabel in the GladeProject.
|
||||
@ -71,6 +70,7 @@ struct _GladePropertyKlass
|
||||
gboolean (* def) (GladeProperty *);
|
||||
void (* set_value) (GladeProperty *, const GValue *);
|
||||
void (* get_value) (GladeProperty *, GValue *);
|
||||
void (* get_default) (GladeProperty *, GValue *);
|
||||
void (* sync) (GladeProperty *);
|
||||
gboolean (* write) (GladeProperty *, GladeInterface *, GArray *);
|
||||
G_CONST_RETURN gchar * (* get_tooltip) (GladeProperty *);
|
||||
@ -96,6 +96,8 @@ LIBGLADEUI_API void glade_property_set (Gla
|
||||
...);
|
||||
LIBGLADEUI_API void glade_property_get_value (GladeProperty *property,
|
||||
GValue *value);
|
||||
LIBGLADEUI_API void glade_property_get_default (GladeProperty *property,
|
||||
GValue *value);
|
||||
LIBGLADEUI_API void glade_property_get_va_list (GladeProperty *property,
|
||||
va_list vl);
|
||||
LIBGLADEUI_API void glade_property_get (GladeProperty *property,
|
||||
|
@ -514,6 +514,8 @@ glade_signal_editor_construct_signals_list (GladeSignalEditor *editor)
|
||||
model = GTK_TREE_MODEL (editor->model);
|
||||
|
||||
view_widget = gtk_tree_view_new_with_model (model);
|
||||
g_object_set (G_OBJECT (view_widget), "enable-search", FALSE, NULL);
|
||||
|
||||
view = GTK_TREE_VIEW (view_widget);
|
||||
|
||||
/* the view now holds a reference, we can get rid of our own */
|
||||
|
@ -47,6 +47,16 @@ struct _GladeXmlContext {
|
||||
(strcmp ( ((xmlNodePtr)node)->name, "comment") == 0)) { \
|
||||
node = ((xmlNodePtr)node)->next; continue ; };
|
||||
|
||||
|
||||
static gchar *
|
||||
claim_string (xmlChar *string)
|
||||
{
|
||||
gchar *ret;
|
||||
ret = g_strdup (string);
|
||||
xmlFree (string);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_xml_set_value:
|
||||
* @node_in: a #GladeXmlNode
|
||||
@ -81,15 +91,10 @@ glade_xml_set_value (GladeXmlNode *node_in, const char *name, const char *val)
|
||||
gchar *
|
||||
glade_xml_get_content (GladeXmlNode *node_in)
|
||||
{
|
||||
xmlNodePtr node = (xmlNodePtr) node_in;
|
||||
gchar *ret;
|
||||
char *val;
|
||||
xmlNodePtr node = (xmlNodePtr) node_in;
|
||||
xmlChar *val = xmlNodeGetContent(node);
|
||||
|
||||
val = xmlNodeGetContent(node);
|
||||
ret = g_strdup (val);
|
||||
xmlFree (val);
|
||||
|
||||
return ret;
|
||||
return claim_string (val);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,27 +120,14 @@ glade_xml_set_content (GladeXmlNode *node_in, const gchar *content)
|
||||
* (taken from gnumeric )
|
||||
*
|
||||
*/
|
||||
static char *
|
||||
static gchar *
|
||||
glade_xml_get_value (xmlNodePtr node, const char *name)
|
||||
{
|
||||
char *ret, *val;
|
||||
xmlNodePtr child;
|
||||
|
||||
for (child = node->children; child; child = child->next)
|
||||
{
|
||||
if (!strcmp (child->name, name))
|
||||
{
|
||||
/*
|
||||
* !!! Inefficient, but ...
|
||||
*/
|
||||
val = xmlNodeGetContent(child);
|
||||
if (val != NULL) {
|
||||
ret = g_strdup (val);
|
||||
xmlFree (val);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return claim_string (xmlNodeGetContent(child));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -251,21 +243,18 @@ gchar *
|
||||
glade_xml_get_value_string (GladeXmlNode *node_in, const char *name)
|
||||
{
|
||||
xmlNodePtr node = (xmlNodePtr) node_in;
|
||||
return glade_xml_get_value (node, name);
|
||||
return claim_string (glade_xml_get_value (node, name));
|
||||
}
|
||||
|
||||
static char *
|
||||
glade_xml_get_property (xmlNodePtr node, const char *name)
|
||||
{
|
||||
char *ret, *val;
|
||||
xmlChar *val;
|
||||
|
||||
val = xmlGetProp (node, name);
|
||||
|
||||
val = (char *) xmlGetProp (node, name);
|
||||
if (val)
|
||||
{
|
||||
ret = g_strdup (val);
|
||||
xmlFree (val);
|
||||
return ret;
|
||||
}
|
||||
return claim_string (val);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ typedef struct _GladeProject GladeProject;
|
||||
#define GLADE_TAG_TRUE "True"
|
||||
#define GLADE_TAG_YES "Yes"
|
||||
#define GLADE_TAG_NO "No"
|
||||
#define GLADE_TAG_VISIBLE_LINES "VisibleLines"
|
||||
#define GLADE_ENUM_DATA_TAG "GladeEnumDataTag"
|
||||
#define GLADE_TAG_IN_PALETTE "InPalette"
|
||||
|
||||
@ -130,11 +129,13 @@ typedef struct _GladeProject GladeProject;
|
||||
#define GLADE_TAG_SAVE "save"
|
||||
#define GLADE_TAG_EDITABLE "editable"
|
||||
#define GLADE_TAG_IGNORE "ignore"
|
||||
#define GLADE_TAG_VISIBLE_LINES "visible-lines"
|
||||
|
||||
#define GLADE_NUMERICAL_STEP_INCREMENT 1
|
||||
#define GLADE_FLOATING_STEP_INCREMENT 0.01F
|
||||
#define GLADE_NUMERICAL_PAGE_INCREMENT 10
|
||||
#define GLADE_NUMERICAL_PAGE_SIZE 1
|
||||
#define GLADE_GENERIC_BORDER_WIDTH 8
|
||||
|
||||
LIBGLADEUI_API gboolean glade_verbose;
|
||||
|
||||
|
@ -248,9 +248,11 @@
|
||||
<glade-widget-class name="GtkLabel" generic-name="label" title="Label">
|
||||
<properties>
|
||||
<property id="selectable" ignore="True"/>
|
||||
<property id="label" default="label"/>
|
||||
<property id="pattern" default=""/>
|
||||
<property id="max-width-chars" name="Maximun Width"/>
|
||||
<property id="label" default="label">
|
||||
<visible-lines>2</visible-lines>
|
||||
</property>
|
||||
<property id="justify">
|
||||
<displayable-values>
|
||||
<value id="GTK_JUSTIFY_LEFT" name="Left"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user