mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-08-10 00:04:29 -04:00
add a temp hack to set the properties. (glade_property_get): ditto to get
2001-08-07 Chema Celorio <chema@celorio.com> * src/glade-widget.c (glade_widget_property_changed_cb): add a temp hack to set the properties. (glade_property_get): ditto to get the properties from a widget. (glade_widget_toplevel_delete_event_cb): handle the delete event for toplevels (glade_widget_connect_other_signals): impl. * src/glade-property.c (glade_property_get_type): glade property is now an object and emits a changed signal. * src/glade-property-class.c (glade_property_class_new_from_node): load before deciding if this prop will be loading with paramspec * src/glade-project-view.c (glade_project_view_button_press_cb): implement. Double clicking on a widget on the list gtk_widget_show's it. * src/glade-gtk.c (glade_gtk_entry_set_text): preserve the cursor position. * src/glade-editor.c (glade_editor_property_connect_signals): impl. (glade_editor_property_changed_cb): impl. * src/glade-property.h: add -> loading * src/glade-editor.h (struct _GladeEditorTable): remove ->loading * src/glade-editor.c (glade_editor_property_load_text): when loading text preserve the cursor position. * src/glade-editor.c : use property->loading and not property->property->loading
This commit is contained in:
parent
ca932a90f7
commit
b2a8539ccb
13
BUGS
13
BUGS
@ -6,4 +6,15 @@ spinbutton:setvalue does not seem to work
|
||||
gtkentry:text (or contents) not exposed
|
||||
gtkadjustment not exposing any properties
|
||||
gtkoptionmenu::items not exposed
|
||||
gtkprogress::set_format not exposed
|
||||
gtkprogress::set_format not exposed
|
||||
|
||||
|
||||
gtk+ stuff
|
||||
----------
|
||||
GtkTables have an "options" property, GtkBoxes have boolean values for
|
||||
each property.
|
||||
|
||||
gtk+ wishes
|
||||
-----------
|
||||
Change pack_type enum to be inversed, see glade-packing pack_start_set
|
||||
|
||||
|
86
ChangeLog
86
ChangeLog
@ -1,3 +1,89 @@
|
||||
2001-08-07 Chema Celorio <chema@celorio.com>
|
||||
|
||||
* src/glade-widget.c (glade_widget_property_changed_cb): add a temp hack to set
|
||||
the properties.
|
||||
(glade_property_get): ditto to get the properties from a widget.
|
||||
(glade_widget_toplevel_delete_event_cb): handle the delete event for toplevels
|
||||
(glade_widget_connect_other_signals): impl.
|
||||
|
||||
* src/glade-property.c (glade_property_get_type): glade property is now an object
|
||||
and emits a changed signal.
|
||||
|
||||
* src/glade-property-class.c (glade_property_class_new_from_node): load before
|
||||
deciding if this prop will be loading with paramspec
|
||||
|
||||
* src/glade-project-view.c (glade_project_view_button_press_cb): implement.
|
||||
Double clicking on a widget on the list gtk_widget_show's it.
|
||||
|
||||
* src/glade-gtk.c (glade_gtk_entry_set_text): preserve the cursor position.
|
||||
|
||||
* src/glade-editor.c (glade_editor_property_connect_signals): impl.
|
||||
(glade_editor_property_changed_cb): impl.
|
||||
|
||||
* src/glade-property.h: add -> loading
|
||||
|
||||
* src/glade-editor.h (struct _GladeEditorTable): remove ->loading
|
||||
|
||||
* src/glade-editor.c (glade_editor_property_load_text): when loading text
|
||||
preserve the cursor position.
|
||||
* src/glade-editor.c : use property->loading and not property->property->loading
|
||||
|
||||
2001-08-06 Chema Celorio <chema@celorio.com>
|
||||
|
||||
* src/glade-widget.c (glade_widget_set_default_options_real): handle the case
|
||||
where the property is queried from the gtkwidget v.s. setting a default one.
|
||||
(glade_widget_free): implement.
|
||||
(glade_widget_delete): add content.
|
||||
(glade_widget_write): when saving a widget, add the packing properties too.
|
||||
|
||||
* src/glade-signal.c (glade_signal_free): impl.
|
||||
|
||||
* src/glade-signal-editor.c (glade_signal_editor_load_widget): handle a
|
||||
widget->class = NULL for clearing the signal editor.
|
||||
|
||||
* src/glade-property.c (glade_property_new_from_class): handle properties
|
||||
that the default is fetched from the gtkwidget itself, not set.
|
||||
(glade_property_free): implement.
|
||||
|
||||
* src/glade-project.c (glade_project_selection_changed): implement.
|
||||
(glade_project_remove_widget_real): impl.
|
||||
(glade_project_remove_widget): impl.
|
||||
|
||||
* src/glade-project-window.c (gpw_delete_cb): implement.
|
||||
|
||||
* src/glade-project-view.h (struct _GladeProjectView): add the remove
|
||||
signal id to the struct.
|
||||
|
||||
* src/glade-project-view.c (glade_project_view_remove_item): implement
|
||||
for "Delete"
|
||||
(glade_project_view_remove_widget_cb): ditto
|
||||
(glade_project_view_set_project): connect and disconnect ->remove_item
|
||||
|
||||
* src/glade-placeholder.c (glade_placeholder_replace_$x): where
|
||||
x are all the containers. Modify this functions so that we can
|
||||
use them to replace a placeholder with a widget and the other
|
||||
way arround. We need this when we delete a widget and want to
|
||||
put a placeholder where the widget was.
|
||||
|
||||
* src/glade-packing.c (glade_packing_container_set_flag): impl.
|
||||
(glade_packing_container_set_integer): impl.
|
||||
(glade_packing_container_set_boolean): impl.
|
||||
(glade_packing_table_set_flag): impl.
|
||||
(glade_packing_table_set_integer): impl.
|
||||
(glade_packing_box_set_boolean): impl.
|
||||
(glade_packing_box_set_integer): impl.
|
||||
(glade_packing_box_position_get): impl.
|
||||
(glade_packing_box_position_set): when setting the pos of a child update the
|
||||
property->value of the rest, cause it has (most likely) changed.
|
||||
(table_props): add the rest of the properties
|
||||
(box_props): ditto
|
||||
|
||||
* src/glade-editor.c (glade_editor_load_widget_page): handle a NULL class to
|
||||
clear the page
|
||||
(glade_editor_load_common_page): ditto
|
||||
(glade_editor_load_item): ditto
|
||||
(glade_editor_select_item_real): ditto
|
||||
|
||||
2001-08-05 Fatih Demir <kabalak@gtranslator.org>
|
||||
|
||||
* configure.in: Added "tr" to the languages list.
|
||||
|
10
TODO
10
TODO
@ -13,10 +13,6 @@ TODO
|
||||
|
||||
OPEN ITEMS [PLease let me know before starting working on any of this]
|
||||
----------
|
||||
- Implement glade_widget_delete inside glade-widget.c, delete can already
|
||||
be called from the popup menu.
|
||||
- Implement the popup menu option "Select", it needs to create submenus for
|
||||
every parent widget and a "Select" option inside it. Inside glade-popup.c
|
||||
- Implement file opened history feature.
|
||||
- Implement gtk stock buttons.
|
||||
- gtklabels can't be selected. This looks like a fun thing and maybe tricky
|
||||
@ -26,7 +22,7 @@ be called from the popup menu.
|
||||
- Implement the menu bar widget and the menu editor.
|
||||
- Implement the glade-property type "File". For example to be used with a pixmap
|
||||
that specifies a file.
|
||||
- Implement tooltips for the "Widget" page of the widget editor.
|
||||
- Implement tooltips for the editor.
|
||||
- The tree view does not remember if the "leafs" are opened or closed
|
||||
when switching between projects, or when reconstructing it. The tree view
|
||||
should remember the states of the leafs. Some of this functionality might
|
||||
@ -60,6 +56,10 @@ DONE [just as a reference]
|
||||
function : glade_editor_create_input_text.
|
||||
(Shane)
|
||||
- Signal editor
|
||||
- Implement the popup menu option "Select", it needs to create submenus for
|
||||
every parent widget and a "Select" option inside it. Inside glade-popup.c
|
||||
- Implement glade_widget_delete inside glade-widget.c, delete can already
|
||||
be called from the popup menu.
|
||||
|
||||
NOT YET (Items that we need to do, but are not a priority right now)
|
||||
-------
|
||||
|
@ -239,7 +239,7 @@ glade_editor_property_changed_text (GtkWidget *entry,
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
|
||||
if (property->loading)
|
||||
if (property->property->loading)
|
||||
return;
|
||||
|
||||
text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
|
||||
@ -259,7 +259,7 @@ glade_editor_property_changed_text_view (GtkTextBuffer *buffer,
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
|
||||
if (property->loading)
|
||||
if (property->property->loading)
|
||||
return;
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &start, 0);
|
||||
@ -281,7 +281,7 @@ glade_editor_property_changed_choice (GtkWidget *menu_item,
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
|
||||
if (property->loading)
|
||||
if (property->property->loading)
|
||||
return;
|
||||
|
||||
choice = gtk_object_get_data (GTK_OBJECT (menu_item),
|
||||
@ -305,7 +305,7 @@ glade_editor_property_changed_enabled (GtkWidget *button,
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
|
||||
if (property->loading)
|
||||
if (property->property->loading)
|
||||
return;
|
||||
|
||||
/* Ok, this is hackish but i can't think of a better way
|
||||
@ -340,7 +340,7 @@ glade_editor_property_changed_numeric (GtkWidget *spin,
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
|
||||
if (property->loading)
|
||||
if (property->property->loading)
|
||||
return;
|
||||
|
||||
numeric_type = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (spin), "NumericType"));
|
||||
@ -373,7 +373,7 @@ glade_editor_property_changed_boolean (GtkWidget *button,
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
|
||||
if (property->loading)
|
||||
if (property->property->loading)
|
||||
return;
|
||||
|
||||
state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
|
||||
@ -1019,18 +1019,21 @@ glade_editor_property_load_boolean (GladeEditorProperty *property)
|
||||
static void
|
||||
glade_editor_property_load_text (GladeEditorProperty *property)
|
||||
{
|
||||
gint pos = 0;
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->property != NULL);
|
||||
g_return_if_fail (property->property->value != NULL);
|
||||
g_return_if_fail (property->input != NULL);
|
||||
|
||||
|
||||
if (GTK_IS_EDITABLE (property->input)) {
|
||||
gtk_editable_delete_text (GTK_EDITABLE (property->input), 0, -1);
|
||||
gtk_editable_insert_text (GTK_EDITABLE (property->input),
|
||||
property->property->value, strlen (property->property->value), &pos);
|
||||
GtkEditable *editable = GTK_EDITABLE (property->input);
|
||||
gint pos, insert_pos = 0;
|
||||
pos = gtk_editable_get_position (editable);
|
||||
gtk_editable_delete_text (editable, 0, -1);
|
||||
gtk_editable_insert_text (editable,
|
||||
property->property->value,
|
||||
strlen (property->property->value),
|
||||
&insert_pos);
|
||||
gtk_editable_set_position (editable, pos);
|
||||
} else if (GTK_IS_TEXT_VIEW (property->input)) {
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
@ -1077,7 +1080,7 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
|
||||
g_return_if_fail (property->property != NULL);
|
||||
g_return_if_fail (property->property->class == property->class);
|
||||
|
||||
property->loading = TRUE;
|
||||
property->property->loading = TRUE;
|
||||
|
||||
switch (class->type) {
|
||||
case GLADE_PROPERTY_TYPE_TEXT:
|
||||
@ -1109,7 +1112,7 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
|
||||
class->type);
|
||||
}
|
||||
|
||||
property->loading = FALSE;
|
||||
property->property->loading = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1172,7 +1175,27 @@ glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
|
||||
|
||||
old = table;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glade_editor_property_changed_cb (GladeProperty *property,
|
||||
GladeEditorProperty *editor_property)
|
||||
{
|
||||
g_return_if_fail (property == editor_property->property);
|
||||
|
||||
glade_editor_property_load (editor_property, property->widget);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_editor_property_connect_signals (GladeEditorProperty *editor_property,
|
||||
GladeWidget *widget)
|
||||
{
|
||||
GladeProperty *property = editor_property->property;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (property), "changed",
|
||||
GTK_SIGNAL_FUNC (glade_editor_property_changed_cb),
|
||||
editor_property);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_editor_load_item (GladeEditor *editor, GladeWidget *item)
|
||||
{
|
||||
@ -1201,6 +1224,7 @@ glade_editor_load_item (GladeEditor *editor, GladeWidget *item)
|
||||
for (; list != NULL; list = list->next) {
|
||||
property = list->data;
|
||||
glade_editor_property_load (property, item);
|
||||
glade_editor_property_connect_signals (property, item);
|
||||
}
|
||||
|
||||
/* Load each GladeEditorProperty for the common tab*/
|
||||
@ -1237,7 +1261,7 @@ glade_editor_load_item (GladeEditor *editor, GladeWidget *item)
|
||||
static void
|
||||
glade_editor_select_item_real (GladeEditor *editor, GladeWidget *widget)
|
||||
{
|
||||
GladeEditorTable *table;
|
||||
GladeEditorTable *table;
|
||||
|
||||
if (editor->loaded_widget == widget)
|
||||
return;
|
||||
|
@ -159,12 +159,13 @@ struct _GladeEditorProperty
|
||||
* depending on the property type.
|
||||
* [see glade-property.h and glade-property-class.h]
|
||||
*/
|
||||
|
||||
#if 0
|
||||
gboolean loading; /* We set this flag when we are loading a new GladeProperty
|
||||
* into this GladeEditorProperty. This flag is used so that
|
||||
* when we receive a "changed" signal we know that nothing has
|
||||
* really changed, we just loaded a new glade widget
|
||||
*/
|
||||
#endif
|
||||
|
||||
GList *children; /* Used for class->type = OBJECT. Where a sigle entry corresponds
|
||||
* to a number of inputs
|
||||
|
@ -26,20 +26,37 @@
|
||||
#include "glade.h"
|
||||
#include "glade-property-class.h"
|
||||
|
||||
static void
|
||||
glade_gtk_entry_set_text (GObject *object, const gchar *text)
|
||||
{
|
||||
GtkEntry *entry = GTK_ENTRY (object);
|
||||
|
||||
g_return_if_fail (GTK_IS_ENTRY (entry));
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (object), text);
|
||||
static void
|
||||
glade_gtk_entry_set_text (GObject *object, const gchar *string)
|
||||
{
|
||||
GtkEditable *editable = GTK_EDITABLE (object);
|
||||
gint pos;
|
||||
gint insert_pos = 0;
|
||||
|
||||
g_return_if_fail (GTK_IS_EDITABLE (object));
|
||||
|
||||
pos = gtk_editable_get_position (editable);
|
||||
gtk_editable_delete_text (editable, 0, -1);
|
||||
/* FIXME: will not work with multibyte languages (strlen) */
|
||||
gtk_editable_insert_text (editable,
|
||||
string,
|
||||
strlen (string),
|
||||
&insert_pos);
|
||||
gtk_editable_set_position (editable, pos);
|
||||
}
|
||||
|
||||
static void
|
||||
static gchar *
|
||||
glade_gtk_entry_get_text (GObject *object)
|
||||
{
|
||||
glade_implement_me ();
|
||||
GtkEntry *entry = GTK_ENTRY (object);
|
||||
const gchar *text;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
|
||||
|
||||
text = gtk_entry_get_text (entry);
|
||||
|
||||
return g_strdup (text);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -101,6 +118,7 @@ glade_gtk_adjustment_set_max (GObject *object, const gchar *string)
|
||||
gtk_adjustment_changed (adjustment);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glade_gtk_adjustment_set_min (GObject *object, const gchar *string)
|
||||
{
|
||||
@ -193,7 +211,6 @@ GladeGtkFunction functions [] = {
|
||||
{"glade_gtk_adjustment_set_step_increment", &glade_gtk_adjustment_set_step_increment},
|
||||
{"glade_gtk_adjustment_set_page_increment", &glade_gtk_adjustment_set_page_increment},
|
||||
{"glade_gtk_adjustment_set_page_size", &glade_gtk_adjustment_set_page_size},
|
||||
|
||||
};
|
||||
|
||||
static gpointer
|
||||
|
@ -287,6 +287,8 @@ glade_placeholder_on_destroy (GladePlaceholder *widget, gpointer not_used)
|
||||
{
|
||||
}
|
||||
|
||||
#define GLADE_PLACEHOLDER_SIZE 16
|
||||
|
||||
GladePlaceholder *
|
||||
glade_placeholder_new (GladeWidget *parent)
|
||||
{
|
||||
@ -300,7 +302,9 @@ glade_placeholder_new (GladeWidget *parent)
|
||||
| GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK
|
||||
| GDK_BUTTON_RELEASE_MASK
|
||||
| GDK_POINTER_MOTION_MASK | GDK_BUTTON1_MOTION_MASK);
|
||||
|
||||
gtk_widget_set_usize (GTK_WIDGET (placeholder),
|
||||
GLADE_PLACEHOLDER_SIZE,
|
||||
GLADE_PLACEHOLDER_SIZE);
|
||||
gtk_widget_show (GTK_WIDGET (placeholder));
|
||||
|
||||
glade_placeholder_connect_draw_signals (placeholder);
|
||||
@ -362,10 +366,13 @@ glade_placeholder_add (GladeWidgetClass *class,
|
||||
for (row = 0; row < rows; row++) {
|
||||
for (col = 0; col < cols; col++) {
|
||||
placeholder = glade_placeholder_new (widget);
|
||||
gtk_table_attach_defaults (GTK_TABLE (widget->widget),
|
||||
GTK_WIDGET (placeholder),
|
||||
col, col+1,
|
||||
row, row+1);
|
||||
gtk_table_attach (GTK_TABLE (widget->widget),
|
||||
GTK_WIDGET (placeholder),
|
||||
col, col+1,
|
||||
row, row+1,
|
||||
GTK_EXPAND | GTK_FILL,
|
||||
GTK_EXPAND | GTK_FILL,
|
||||
0, 0);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -340,6 +340,36 @@ glade_project_view_selection_changed_cb (GtkTreeSelection *selection,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
glade_project_view_button_press_cb (GtkTreeView *view, GdkEventButton *event)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
|
||||
model = gtk_tree_view_get_model (view);
|
||||
|
||||
if (event->type == GDK_2BUTTON_PRESS) {
|
||||
GtkTreePath * path = gtk_tree_path_new ();
|
||||
GtkTreeIter iter;
|
||||
GladeWidget *widget;
|
||||
|
||||
if (!gtk_tree_view_get_path_at_pos (view,
|
||||
event->window,
|
||||
event->x, event->y,
|
||||
&path, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
if (!gtk_tree_model_get_iter (model, &iter, path))
|
||||
return FALSE;
|
||||
|
||||
gtk_tree_model_get (model, &iter, WIDGET_COLUMN, &widget, -1);
|
||||
gtk_tree_path_free (path);
|
||||
if (!widget)
|
||||
return FALSE;
|
||||
gtk_widget_show (widget->widget);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
glade_project_view_create_widget (GladeProjectView *view)
|
||||
{
|
||||
@ -355,6 +385,9 @@ glade_project_view_create_widget (GladeProjectView *view)
|
||||
|
||||
glade_project_view_populate_model (model, view);
|
||||
widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
|
||||
g_signal_connect_data (G_OBJECT (widget), "button_press_event",
|
||||
G_CALLBACK (glade_project_view_button_press_cb),
|
||||
NULL, NULL, 0);
|
||||
|
||||
cell = gtk_cell_renderer_text_pixbuf_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Widget", cell, NULL);
|
||||
@ -413,24 +446,24 @@ glade_project_view_selection_changed (GladeProjectView *view, GladeWidget *item)
|
||||
|
||||
static void
|
||||
glade_project_view_add_widget_cb (GladeProject *project,
|
||||
GladeWidget *widget,
|
||||
GladeProjectView *view)
|
||||
GladeWidget *widget,
|
||||
GladeProjectView *view)
|
||||
{
|
||||
GLADE_PROJECT_VIEW_CLASS (GTK_OBJECT_GET_CLASS(view))->add_item (view, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_project_view_remove_widget_cb (GladeProject *project,
|
||||
GladeWidget *widget,
|
||||
GladeProjectView *view)
|
||||
GladeWidget *widget,
|
||||
GladeProjectView *view)
|
||||
{
|
||||
GLADE_PROJECT_VIEW_CLASS (GTK_OBJECT_GET_CLASS(view))->remove_item (view, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_project_view_widget_name_changed_cb (GladeProject *project,
|
||||
GladeWidget *widget,
|
||||
GladeProjectView *view)
|
||||
GladeWidget *widget,
|
||||
GladeProjectView *view)
|
||||
{
|
||||
GLADE_PROJECT_VIEW_CLASS (GTK_OBJECT_GET_CLASS(view))->widget_name_changed (view, widget);
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ glade_project_new (void)
|
||||
GladeProject *project;
|
||||
static gint i = 1;
|
||||
|
||||
project = GLADE_PROJECT (gtk_type_new (glade_project_get_type()));
|
||||
project = GLADE_PROJECT (gtk_type_new (glade_project_get_type ()));
|
||||
project->name = g_strdup_printf ("Untitled %i", i++);
|
||||
|
||||
return project;
|
||||
|
@ -589,6 +589,12 @@ glade_property_class_new_from_node (GladeXmlNode *node, GladeWidgetClass *widget
|
||||
/* Will this property go in the common tab ? */
|
||||
property_class->common = glade_xml_property_get_boolean (node, GLADE_TAG_COMMON, FALSE);
|
||||
property_class->def = glade_xml_get_property_string (node, GLADE_TAG_DEFAULT);
|
||||
|
||||
/* Now get the list of signals that we should listen to */
|
||||
property_class->update_signals = glade_xml_read_list (node,
|
||||
GLADE_TAG_UPDATE_SIGNALS,
|
||||
GLADE_TAG_SIGNAL_NAME);
|
||||
|
||||
|
||||
/* Should we load this property from the ParamSpec ?
|
||||
* We can have a property like ... ParamSpec="TRUE">
|
||||
@ -667,11 +673,6 @@ glade_property_class_new_from_node (GladeXmlNode *node, GladeWidgetClass *widget
|
||||
g_free (content);
|
||||
}
|
||||
|
||||
/* Now get the list of signals that we should listen to */
|
||||
property_class->update_signals = glade_xml_read_list (node,
|
||||
GLADE_TAG_UPDATE_SIGNALS,
|
||||
GLADE_TAG_SIGNAL_NAME);
|
||||
|
||||
return property_class;
|
||||
}
|
||||
|
||||
|
@ -31,16 +31,93 @@
|
||||
#include "glade-parameter.h"
|
||||
#include "glade-widget-class.h"
|
||||
|
||||
|
||||
static void glade_property_class_init (GladePropertyObjectClass * klass);
|
||||
static void glade_property_init (GladeProperty *property);
|
||||
static void glade_property_destroy (GtkObject *object);
|
||||
|
||||
enum
|
||||
{
|
||||
CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint glade_property_signals[LAST_SIGNAL] = {0};
|
||||
static GtkObjectClass *parent_class = NULL;
|
||||
|
||||
guint
|
||||
glade_property_get_type (void)
|
||||
{
|
||||
static guint type = 0;
|
||||
|
||||
if (!type)
|
||||
{
|
||||
GtkTypeInfo info =
|
||||
{
|
||||
"GladeProperty",
|
||||
sizeof (GladeProperty),
|
||||
sizeof (GladePropertyObjectClass),
|
||||
(GtkClassInitFunc) glade_property_class_init,
|
||||
(GtkObjectInitFunc) glade_property_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL,
|
||||
};
|
||||
|
||||
type = gtk_type_unique (gtk_object_get_type (),
|
||||
&info);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_property_class_init (GladePropertyObjectClass * klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (gtk_object_get_type ());
|
||||
|
||||
glade_property_signals[CHANGED] =
|
||||
gtk_signal_new ("changed",
|
||||
GTK_RUN_LAST,
|
||||
GTK_CLASS_TYPE (object_class),
|
||||
GTK_SIGNAL_OFFSET (GladePropertyObjectClass, changed),
|
||||
gtk_marshal_VOID__VOID,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
klass->changed = NULL;
|
||||
|
||||
object_class->destroy = glade_property_destroy;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glade_property_init (GladeProperty *property)
|
||||
{
|
||||
|
||||
property->class = NULL;
|
||||
property->value = NULL;
|
||||
property->enabled = TRUE;
|
||||
property->child = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_property_destroy (GtkObject *object)
|
||||
{
|
||||
GladeProperty *property;
|
||||
|
||||
property = GLADE_PROPERTY (object);
|
||||
}
|
||||
|
||||
static GladeProperty *
|
||||
glade_property_new (void)
|
||||
{
|
||||
GladeProperty *property;
|
||||
|
||||
property = g_new0 (GladeProperty, 1);
|
||||
property->class = NULL;
|
||||
property->value = NULL;
|
||||
property->enabled = TRUE;
|
||||
property->child = NULL;
|
||||
property = GLADE_PROPERTY (gtk_type_new (glade_property_get_type ()));
|
||||
|
||||
return property;
|
||||
}
|
||||
@ -237,6 +314,12 @@ glade_property_get_from_id (GList *settings_list, const gchar *id)
|
||||
|
||||
|
||||
|
||||
static void
|
||||
glade_property_emit_changed (GladeProperty *property)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (property),
|
||||
glade_property_signals [CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
glade_property_changed_text (GladeProperty *property,
|
||||
@ -248,14 +331,18 @@ glade_property_changed_text (GladeProperty *property,
|
||||
g_return_if_fail (property->value != NULL);
|
||||
g_return_if_fail (property->widget != NULL);
|
||||
g_return_if_fail (property->widget->widget != NULL);
|
||||
|
||||
|
||||
temp = property->value;
|
||||
property->value = g_strdup (text);
|
||||
g_free (temp);
|
||||
|
||||
#if 0
|
||||
/* Why is this here ????? Chema */
|
||||
if (property->class->id == NULL)
|
||||
return;
|
||||
#endif
|
||||
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id,
|
||||
@ -263,6 +350,9 @@ glade_property_changed_text (GladeProperty *property,
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
|
||||
glade_property_emit_changed (property);
|
||||
}
|
||||
|
||||
void
|
||||
@ -274,12 +364,14 @@ glade_property_changed_integer (GladeProperty *property, gint val)
|
||||
g_free (property->value);
|
||||
property->value = g_strdup_printf ("%i", val);
|
||||
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id, val, NULL);
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -291,12 +383,14 @@ glade_property_changed_float (GladeProperty *property, gfloat val)
|
||||
g_free (property->value);
|
||||
property->value = g_strdup_printf ("%g", val);
|
||||
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id, val, NULL);
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
|
||||
}
|
||||
|
||||
@ -358,6 +452,7 @@ glade_property_changed_boolean (GladeProperty *property, gboolean val)
|
||||
g_free (property->value);
|
||||
property->value = g_strdup_printf ("%s", val ? GLADE_TAG_TRUE : GLADE_TAG_FALSE);
|
||||
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id,
|
||||
@ -366,6 +461,9 @@ glade_property_changed_boolean (GladeProperty *property, gboolean val)
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
|
||||
glade_property_emit_changed (property);
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,15 +4,19 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GLADE_PROPERTY(p) ((GladeProperty *)p)
|
||||
#define GLADE_IS_PROPERTY(p) (p != NULL)
|
||||
#define GLADE_PROPERTY(obj) GTK_CHECK_CAST (obj, glade_property_get_type (), GladeProperty)
|
||||
#define GLADE_PROPERTY_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, glade_property_get_type (), GladePropertyClass)
|
||||
#define GLADE_IS_PROPERTY(obj) GTK_CHECK_TYPE (obj, glade_property_get_type ())
|
||||
|
||||
typedef struct _GladePropertyObjectClass GladePropertyObjectClass;
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
struct _GladeProperty {
|
||||
|
||||
GObject object;
|
||||
|
||||
GladePropertyClass *class; /* A pointer to the GladeProperty that this
|
||||
* setting specifies
|
||||
@ -38,7 +42,15 @@ struct _GladeProperty {
|
||||
GList *views; /* A list of GladePropertyView items */
|
||||
|
||||
GladeWidget *child; /* A GladeProperty of type object has a child */
|
||||
|
||||
|
||||
gboolean loading;
|
||||
};
|
||||
|
||||
struct _GladePropertyObjectClass
|
||||
{
|
||||
GtkObjectClass parent_class;
|
||||
|
||||
void (*changed) (GladeProperty *property, const gchar *value);
|
||||
};
|
||||
|
||||
struct _GladePropertyQuery {
|
||||
@ -51,6 +63,8 @@ struct _GladePropertyQueryResult {
|
||||
};
|
||||
|
||||
|
||||
guint glade_property_get_type (void);
|
||||
|
||||
GList * glade_property_list_new_from_widget_class (GladeWidgetClass *class,
|
||||
GladeWidget *widget);
|
||||
GladeProperty * glade_property_new_from_class (GladePropertyClass *class, GladeWidget *widget);
|
||||
|
@ -343,7 +343,9 @@ glade_widget_set_default_options_real (GladeWidget *widget, gboolean packing)
|
||||
property->value = temp;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
property->loading = TRUE;
|
||||
|
||||
switch (property->class->type) {
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
glade_property_changed_boolean (property,
|
||||
@ -387,6 +389,7 @@ glade_widget_set_default_options_real (GladeWidget *widget, gboolean packing)
|
||||
g_warning ("Implement set default for this type [%s]\n", property->class->name);
|
||||
break;
|
||||
}
|
||||
property->loading = FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
@ -574,10 +577,68 @@ glade_widget_set_contents (GladeWidget *widget)
|
||||
glade_property_changed_text (property, widget->name);
|
||||
}
|
||||
|
||||
static void
|
||||
foo (GtkWidget *w)
|
||||
static gchar *
|
||||
glade_property_get (GladeProperty *property)
|
||||
{
|
||||
g_print ("Foo\n");
|
||||
gchar *resp;
|
||||
|
||||
if (property->class->get_function)
|
||||
resp = (*property->class->get_function)
|
||||
(G_OBJECT (property->widget->widget));
|
||||
else {
|
||||
gboolean bool;
|
||||
switch (property->class->type) {
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
gtk_object_get (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id,
|
||||
&bool,
|
||||
NULL);
|
||||
resp = bool ?
|
||||
g_strdup (GLADE_TAG_TRUE) :
|
||||
g_strdup (GLADE_TAG_FALSE);
|
||||
break;
|
||||
default:
|
||||
resp = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_widget_property_changed_cb (GtkWidget *w)
|
||||
{
|
||||
GladeProperty *property;
|
||||
GladeWidget *widget;
|
||||
gchar *new = NULL;
|
||||
|
||||
widget = glade_widget_get_from_gtk_widget (w);
|
||||
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
||||
property = gtk_object_get_data (GTK_OBJECT (w),
|
||||
GLADE_MODIFY_PROPERTY_DATA);
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
|
||||
if (property->loading)
|
||||
return;
|
||||
|
||||
new = glade_property_get (property);
|
||||
|
||||
switch (property->class->type) {
|
||||
case GLADE_PROPERTY_TYPE_TEXT:
|
||||
glade_property_changed_text (property, new);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
if (new && strcmp (new, GLADE_TAG_TRUE) == 0)
|
||||
glade_property_changed_boolean (property, TRUE);
|
||||
else
|
||||
glade_property_changed_boolean (property, FALSE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (new);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -593,11 +654,15 @@ glade_widget_connect_edit_signals_with_class (GladeWidget *widget,
|
||||
|
||||
list = class->update_signals;
|
||||
for (; list != NULL; list = list->next) {
|
||||
gtk_signal_connect (GTK_OBJECT (widget->widget), list->data,
|
||||
GTK_SIGNAL_FUNC (foo), property);
|
||||
gtk_signal_connect_after (GTK_OBJECT (widget->widget), list->data,
|
||||
GTK_SIGNAL_FUNC (glade_widget_property_changed_cb),
|
||||
property);
|
||||
gtk_object_set_data (GTK_OBJECT (widget->widget),
|
||||
GLADE_MODIFY_PROPERTY_DATA, property);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glade_widget_connect_edit_signals (GladeWidget *widget)
|
||||
{
|
||||
@ -613,6 +678,24 @@ glade_widget_connect_edit_signals (GladeWidget *widget)
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
glade_widget_toplevel_delete_event_cb (GtkWidget *widget, gpointer not_used)
|
||||
{
|
||||
gtk_widget_hide (widget);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_widget_connect_other_signals (GladeWidget *widget)
|
||||
{
|
||||
if (GLADE_WIDGET_IS_TOPLEVEL (widget)) {
|
||||
gtk_signal_connect (GTK_OBJECT (widget->widget), "delete_event",
|
||||
GTK_SIGNAL_FUNC (glade_widget_toplevel_delete_event_cb),
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static GladeWidget *
|
||||
glade_widget_create_gtk_widget (GladeProject *project,
|
||||
GladeWidgetClass *class,
|
||||
@ -654,7 +737,13 @@ glade_widget_create_gtk_widget (GladeProject *project,
|
||||
glade_widget_connect_mouse_signals (glade_widget);
|
||||
glade_widget_connect_draw_signals (glade_widget);
|
||||
glade_widget_connect_edit_signals (glade_widget);
|
||||
|
||||
glade_widget_connect_other_signals (glade_widget);
|
||||
|
||||
if (GTK_IS_TABLE (glade_widget->widget)) {
|
||||
g_print ("Is table\n");
|
||||
gtk_table_set_homogeneous (GTK_TABLE (glade_widget->widget),
|
||||
FALSE);
|
||||
}
|
||||
return glade_widget;
|
||||
}
|
||||
|
||||
@ -720,10 +809,14 @@ glade_widget_new_from_class (GladeWidgetClass *class, GladeWidget *parent)
|
||||
GladeWidget *
|
||||
glade_widget_new_toplevel (GladeProject *project, GladeWidgetClass *class)
|
||||
{
|
||||
GladeWidget *widget;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
|
||||
g_return_val_if_fail (GLADE_IS_WIDGET_CLASS (class), NULL);
|
||||
|
||||
return glade_widget_new_from_class_full (class, project, NULL);
|
||||
widget = glade_widget_new_from_class_full (class, project, NULL);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,7 +94,6 @@ GladeProperty * glade_widget_get_property_from_class (GladeWidget *widget,
|
||||
|
||||
void glade_widget_set_name (GladeWidget *widget, const gchar *name);
|
||||
|
||||
|
||||
/* Widget functions */
|
||||
typedef void (*GladeWidgetFunction) (GladeWidget *widget);
|
||||
|
||||
|
@ -67,6 +67,7 @@ gchar * _ (gchar * name);
|
||||
#define GLADE_WIDGET_DATA_TAG "GladeWidgetDataTag"
|
||||
|
||||
#define GLADE_GET_DEFAULT_FROM_WIDGET "GladeGetDefaultFromWidget"
|
||||
#define GLADE_MODIFY_PROPERTY_DATA "GladeModifyPropertyData"
|
||||
|
||||
#define GLADE_XML_TAG_PROJECT "glade-interface"
|
||||
#define GLADE_XML_TAG_WIDGET "widget"
|
||||
|
@ -7,7 +7,12 @@
|
||||
|
||||
<Property Id="border-width"/>
|
||||
<Property Id="label"/>
|
||||
<Property Id="active"/>
|
||||
<Property Id="active">
|
||||
<UpdateSignals>
|
||||
<SignalName>toggled</SignalName>
|
||||
</UpdateSignals>
|
||||
</Property>
|
||||
|
||||
<Property Id="draw-indicator" Default="True"/>
|
||||
|
||||
</Properties>
|
||||
|
@ -17,7 +17,40 @@
|
||||
<Property Id="yalign"/>
|
||||
<Property Id="xpad"/>
|
||||
<Property Id="ypad"/>
|
||||
|
||||
<Property Common="TRUE" Id="x"/>
|
||||
<Property Common="TRUE" Id="y"/>
|
||||
<Property Common="TRUE" Id="width"/>
|
||||
<Property Common="TRUE" Id="height"/>
|
||||
<Property Common="TRUE" Id="visible" Default="True"/>
|
||||
<Property Common="TRUE" Id="sensitive"/>
|
||||
<Property Common="TRUE" Id="can-default"/>
|
||||
<Property Common="TRUE" Id="has-default"/>
|
||||
<Property Common="TRUE" Id="can-focus"/>
|
||||
<!-- Not yet implemented
|
||||
<Property Common="TRUE" Id="events"/>
|
||||
-->
|
||||
<Property Common="TRUE" Id="extension-events"/>
|
||||
|
||||
</Properties>
|
||||
|
||||
<PackingDefaults>
|
||||
|
||||
<PackingDefault id="GtkTable">
|
||||
<Property Id="xexpand" Value="True"/>
|
||||
<Property Id="yexpand" Value="False"/>
|
||||
<Property Id="xshrink" Value="True"/>
|
||||
<Property Id="yshrink" Value="False"/>
|
||||
<Property Id="xfill" Value="False"/>
|
||||
<Property Id="yfill" Value="True"/>
|
||||
</PackingDefault>
|
||||
|
||||
<PackingDefault id="GtkHBox">
|
||||
<Property Id="expand" Value="True"/>
|
||||
<Property Id="fill" Value="False"/>
|
||||
<Property Id="packstart" Value="False"/>
|
||||
</PackingDefault>
|
||||
|
||||
</PackingDefaults>
|
||||
|
||||
</GladeWidgetClass>
|
||||
|
@ -7,6 +7,12 @@
|
||||
|
||||
<Property Id="border-width"/>
|
||||
<Property Id="label"/>
|
||||
<Property Id="active">
|
||||
<UpdateSignals>
|
||||
<SignalName>toggled</SignalName>
|
||||
</UpdateSignals>
|
||||
</Property>
|
||||
|
||||
<Property Id="relief"/>
|
||||
<Property Id="draw-indicator"/>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user