Remove the accelerator label.

2004-05-05  Joaquin Cuenca Abela  <e98cuenc@yahoo.com>

	* widgets/gtk-base.xml: Remove the accelerator label.

	* widgets/gtkdialog.xml, gtkmessagedialog.xml, gtkwindow.xml: Remove
	the tooltip property. Now it's only specified in gtk-widget.xml.

	* widgets/gtkwidget.xml: Add a tooltip property.

	* pixmaps/hpaned.png,vpaned.png: swap these two icons.

	* src/glade-gtk.c: Implement glade_gtk_widget_set_tooltip, still not
	finished.

	* src/glade-editor.c: Don't show "invisible" properties.

	* src/glade-property-class.[c,h]: Remove GladePropertyQuery. Now the
	queries are done in glade-gtk.c. Add a glade_property_class_is_visible
	function, that says if a property should be visible in the properties
	editor. The difference with Disabled is that the visible status
	will be checked when the property is added to the editor (and thus
	the check is done against the real GladeWidgetClass, say "GtkLabel")
	and Disabled is checked at the creation of GladePropertyQuery
	(and thus the check is done with a possibly abstract GladeWidgetClass,
	as "GtkWidget"). In addition, "Visible" specify a function that
	returns true or false in function of the GladeWidgetClass passed.
	That way implementing "tooltips" property becomes much less cumbersome.

	* src/glade-project.[c,h]: Add a GtkTooltips to the project.

	* src/glade_plugin.def: Add to two new functions to be used by glade-gtk.c
This commit is contained in:
Joaquin Cuenca Abela 2004-05-06 06:19:25 +00:00 committed by Joaquín Cuenca Abela
parent 635a2b0f54
commit d647d15f3d
17 changed files with 137 additions and 86 deletions

View File

@ -1,3 +1,35 @@
2004-05-05 Joaquin Cuenca Abela <e98cuenc@yahoo.com>
* widgets/gtk-base.xml: Remove the accelerator label.
* widgets/gtkdialog.xml, gtkmessagedialog.xml, gtkwindow.xml: Remove
the tooltip property. Now it's only specified in gtk-widget.xml.
* widgets/gtkwidget.xml: Add a tooltip property.
* pixmaps/hpaned.png,vpaned.png: swap these two icons.
* src/glade-gtk.c: Implement glade_gtk_widget_set_tooltip, still not
finished.
* src/glade-editor.c: Don't show "invisible" properties.
* src/glade-property-class.[c,h]: Remove GladePropertyQuery. Now the
queries are done in glade-gtk.c. Add a glade_property_class_is_visible
function, that says if a property should be visible in the properties
editor. The difference with Disabled is that the visible status
will be checked when the property is added to the editor (and thus
the check is done against the real GladeWidgetClass, say "GtkLabel")
and Disabled is checked at the creation of GladePropertyQuery
(and thus the check is done with a possibly abstract GladeWidgetClass,
as "GtkWidget"). In addition, "Visible" specify a function that
returns true or false in function of the GladeWidgetClass passed.
That way implementing "tooltips" property becomes much less cumbersome.
* src/glade-project.[c,h]: Add a GtkTooltips to the project.
* src/glade_plugin.def: Add to two new functions to be used by glade-gtk.c
2004-05-05 Damon Chaplin <damon@gnome.org>
* src/glade-widget.c (glade_widget_find_inside_container): don't

2
TODO
View File

@ -36,7 +36,7 @@ Difficult or Big tasks:
pixmap that specifies a file.
[X] Undo/Redo infrastructure.
[X] Undo/Redo for add/delete, cut/paste, set name, set property.
[ ] Undo/Redo for add/remove signal.
[X] Undo/Redo for add/remove signal.
[X] Cut/Copy/Paste.
[X] The packing tab of the editor. This is done, but it may turn out that we
want to override some of the packing properties from the xml file.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 787 B

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 655 B

After

Width:  |  Height:  |  Size: 787 B

View File

@ -1027,8 +1027,11 @@ glade_editor_table_append_items (GladeEditorTable *table,
list = class->properties;
for (; list != NULL; list = list->next) {
for (; list != NULL; list = list->next)
{
property_class = (GladePropertyClass *) list->data;
if (!glade_property_class_is_visible (property_class, class))
continue;
if (common != property_class->common)
continue;
property = glade_editor_table_append_item (table, property_class);
@ -1126,7 +1129,8 @@ glade_editor_get_table_from_class (GladeEditor *editor,
GladeEditorTable *table;
GList *list;
for (list = editor->widget_tables; list; list = list->next) {
for (list = editor->widget_tables; list; list = list->next)
{
table = list->data;
if (common != table->common)
continue;

View File

@ -95,6 +95,49 @@ glade_gtk_option_menu_set_items (GObject *object, GValue *value)
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
}
int GLADEGTK_API
glade_gtk_widget_condition (GladeWidgetClass *klass)
{
GObject *object = g_object_new (klass->type, NULL);
/* Only widgets with windows can have tooltips at present. Though
buttons seem to be a special case, as they are NO_WINDOW widgets
but have InputOnly windows, so tooltip still work. In GTK+ 2
menuitems are like buttons. */
if (!GTK_WIDGET_NO_WINDOW (object) || GTK_IS_BUTTON (object) || GTK_IS_MENU_ITEM (object))
{
gtk_object_destroy (GTK_OBJECT (object));
return TRUE;
}
else
{
gtk_object_destroy (GTK_OBJECT (object));
return FALSE;
}
}
void GLADEGTK_API
glade_gtk_widget_set_tooltip (GObject *object, GValue *value)
{
GladeWidget *glade_widget = glade_widget_get_from_gtk_widget (GTK_WIDGET (object));
GladeProject *project = glade_widget_get_project (glade_widget);
GtkTooltips *tooltips = glade_project_get_tooltips (project);
const char *tooltip;
/* TODO: handle GtkToolItems with gtk_tool_item_set_tooltip() */
tooltip = g_value_get_string (value);
if (tooltip && *tooltip)
gtk_tooltips_set_tip (tooltips, GTK_WIDGET (object), tooltip, "tip_private");
/* else
gtk_tooltips_remove ? */
}
void GLADEGTK_API
glade_gtk_widget_get_tooltip (GObject *object, GValue *value)
{
g_print ("get_tooltip\n");
}
void GLADEGTK_API
glade_gtk_progress_bar_set_format (GObject *object, GValue *value)
{

View File

@ -150,6 +150,7 @@ glade_project_init (GladeProject *project)
project->prev_redo_item = NULL;
project->widget_names_allocator = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) glade_id_allocator_free);
project->widget_old_names = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_free);
project->tooltips = gtk_tooltips_new ();
}
GladeProject *
@ -189,11 +190,13 @@ glade_project_dispose (GObject *object)
glade_project_list_unref (project->undo_stack);
glade_project_list_unref (project->prev_redo_item);
glade_project_list_unref (project->widgets);
g_object_unref (project->tooltips);
project->undo_stack = NULL;
project->prev_redo_item = NULL;
project->widgets = NULL;
project->tooltips = NULL;
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@ -734,3 +737,8 @@ glade_project_save (GladeProject *project, const gchar *path)
return TRUE;
}
GtkTooltips *glade_project_get_tooltips (GladeProject *project)
{
return project->tooltips;
}

View File

@ -48,6 +48,7 @@ struct _GladeProject
GList *prev_redo_item; /* Points to the item previous to the redo items */
GHashTable *widget_names_allocator; /* hash table with the used widget names */
GHashTable *widget_old_names; /* widget -> old name of the widget */
GtkTooltips *tooltips;
};
struct _GladeProjectClass
@ -78,6 +79,7 @@ GladeWidget *glade_project_get_widget_by_name (GladeProject *project, const char
char *glade_project_new_widget_name (GladeProject *project, const char *base_name);
void glade_project_widget_name_changed (GladeProject *project, GladeWidget *widget, const char *old_name);
GtkTooltips *glade_project_get_tooltips (GladeProject *project);
/* Selection */
void glade_project_selection_set (GladeProject *project, GtkWidget *widget, gboolean emit_signal);

View File

@ -97,46 +97,6 @@ glade_property_type_enum_to_string (GladePropertyType type)
return NULL;
}
static GladePropertyQuery *
glade_query_new_from_node (GladeXmlNode *node)
{
GladePropertyQuery *query;
if (!glade_xml_node_verify (node, GLADE_TAG_QUERY))
return NULL;
query = g_new0 (GladePropertyQuery, 1);
query->question = glade_xml_get_value_string_required (node, GLADE_TAG_QUESTION, NULL);
if (!query->question)
return NULL;
return query;
}
static GladePropertyQuery *
glade_property_query_clone (GladePropertyQuery *query)
{
GladePropertyQuery *clone;
g_return_val_if_fail (query != NULL, NULL);
g_return_val_if_fail (query->question != NULL, NULL);
clone = g_new0 (GladePropertyQuery, 1);
clone->question = g_strdup (query->question);
return clone;
}
static void
glade_property_query_free (GladePropertyQuery *query)
{
if (query == NULL)
return;
g_free (query->question);
g_free (query);
}
GladePropertyClass *
glade_property_class_new (void)
{
@ -203,9 +163,6 @@ glade_property_class_clone (GladePropertyClass *property_class)
choice->data = glade_choice_clone ((GladeChoice*) choice->data);
}
if (clon->query)
clon->query = glade_property_query_clone (clon->query);
/* ok, wtf? what is the child member for? */
/* if (clon->child)
clon->child = glade_widget_class_clone (clon->child); */
@ -234,7 +191,6 @@ glade_property_class_free (GladePropertyClass *class)
g_list_free (class->parameters);
g_list_foreach (class->choices, (GFunc) glade_choice_free, NULL);
g_list_free (class->choices);
glade_property_query_free (class->query);
glade_widget_class_free (class->child);
g_free (class);
}
@ -686,6 +642,15 @@ lblError:
return NULL;
}
gboolean
glade_property_class_is_visible (GladePropertyClass *property_class, GladeWidgetClass *widget_class)
{
if (property_class->visible)
return property_class->visible (widget_class);
return TRUE;
}
/**
* glade_property_class_update_from_node:
* @node: the <property> node
@ -705,6 +670,7 @@ glade_property_class_update_from_node (GladeXmlNode *node,
{
GladePropertyClass *class;
gchar *buff;
char *visible;
GladeXmlNode *child;
g_return_val_if_fail (property_class != NULL, FALSE);
@ -724,22 +690,34 @@ glade_property_class_update_from_node (GladeXmlNode *node,
/* If Disabled="TRUE" we set *property_class to NULL, but we return TRUE.
* The caller may want to remove this property from its list.
*/
if (glade_xml_get_property_boolean (node, GLADE_TAG_DISABLED, FALSE)) {
if (glade_xml_get_property_boolean (node, GLADE_TAG_DISABLED, FALSE))
{
glade_property_class_free (class);
*property_class = NULL;
return TRUE;
}
visible = glade_xml_get_property_string (node, "Visible");
if (visible)
{
if (!g_module_symbol (widget_class->module, visible, (void **) &class->visible))
g_warning ("Could not find %s\n", visible);
g_free (visible);
}
/* If needed, update the name... */
buff = glade_xml_get_property_string (node, GLADE_TAG_NAME);
if (buff) {
if (buff)
{
g_free (class->name);
class->name = buff;
}
/* ...the type... */
buff = glade_xml_get_value_string (node, GLADE_TAG_TYPE);
if (buff) {
if (buff)
{
GladePropertyType type;
type = glade_property_type_str_to_enum (buff);
g_free (buff);
@ -750,7 +728,8 @@ glade_property_class_update_from_node (GladeXmlNode *node,
/* ...and the tooltip */
buff = glade_xml_get_value_string (node, GLADE_TAG_TOOLTIP);
if (buff) {
if (buff)
{
g_free (class->tooltip);
class->tooltip = buff;
}
@ -806,11 +785,6 @@ glade_property_class_update_from_node (GladeXmlNode *node,
return FALSE;
}
/* Get the Query */
child = glade_xml_search_child (node, GLADE_TAG_QUERY);
if (child)
class->query = glade_query_new_from_node (child);
/* common, optional, etc */
class->common = glade_xml_get_property_boolean (node, GLADE_TAG_COMMON, FALSE);
class->optional = glade_xml_get_property_boolean (node, GLADE_TAG_OPTIONAL, FALSE);

View File

@ -177,25 +177,16 @@ struct _GladePropertyClass
* to the function that can set this property. The functions
* to work arround this problems are inside glade-gtk.c
*/
};
/**
* For now it only contains a string with the question for the query,
* since we only support numerical queries... when we add support for
* others queries it should contain something more complicated, maybe
* a whole GtkWidget (look at the query you get when creating a GtkDialog
* in glade-2
*/
struct _GladePropertyQuery
{
gchar *question;
gboolean (*visible) (GladeWidgetClass *widget_class);
};
GladePropertyClass * glade_property_class_new (void);
GladePropertyClass * glade_property_class_new_from_spec (GParamSpec *spec);
GladePropertyClass *glade_property_class_clone (GladePropertyClass *property_class);
void glade_property_class_free (GladePropertyClass *class);
void glade_property_class_free (GladePropertyClass *property_class);
gboolean glade_property_class_is_visible (GladePropertyClass *property_class, GladeWidgetClass *widget_class);
gchar * glade_property_type_enum_to_string (GladePropertyType type);

View File

@ -20,3 +20,5 @@ EXPORTS
glade_project_window_new_project @17
glade_project_window_open_project @18
glade_property_set @19
glade_project_get_tooltips @20
glade_widget_get_project @21

View File

@ -12,7 +12,6 @@
<GladeWidget name="GtkHandleBox" generic_name="handlebox" palette_name="Handle Box" />
<GladeWidget name="GtkLabel" generic_name="label" palette_name="Label" filename="gtklabel.xml"/>
<GladeWidget name="GtkAccelLabel" generic_name="accellabel" palette_name="Label with accelerator"/>
<GladeWidget name="GtkEntry" generic_name="entry" palette_name="Text Entry"/>
<GladeWidget name="GtkTextView" generic_name="textview" palette_name="Text View"/>

View File

@ -24,6 +24,7 @@
</Property>
<Property Id="label" Default="button"/>
</Properties>
</GladeWidgetClass>

View File

@ -11,11 +11,6 @@
</Property>
<Property Id="default-width" Default="0" Optional="True" OptionalDefault="False"/>
<Property Id="default-height" Default="0" Optional="True" OptionalDefault="False"/>
<Property Common="True" Id="tooltip" Name="Tooltip">
<Type>String</Type>
<SetFunction>ignore</SetFunction>
<GetFunction>ignore</GetFunction>
</Property>
</Properties>
<!-- That's supported, and IMO is the right way to handle response-id (and it works),

View File

@ -11,11 +11,6 @@
<Property Id="default-height" Default="0" Optional="True" OptionalDefault="False"/>
<Property Common="True" Id="sensitive"/>
<Property Common="True" Id="tooltip" Name="Tooltip">
<Type>String</Type>
<SetFunction>ignore</SetFunction>
<GetFunction>ignore</GetFunction>
</Property>
<Property Common="True" Id="can-default"/>
<Property Common="True" Id="has-default"/>
<Property Common="True" Id="can-focus"/>

View File

@ -1,11 +1,21 @@
<GladeWidgetClass>
<Properties>
<Property Common="True" Id="visible">
<SetFunction>ignore</SetFunction>
<GetFunction>ignore</GetFunction>
</Property>
<Property Common="True" Optional="True" OptionalDefault="False" Default="0" Id="width-request"/>
<Property Common="True" Optional="True" OptionalDefault="False" Default="0" Id="height-request"/>
<Property Common="True" Id="tooltip" Name="Tooltip" Visible="glade_gtk_widget_condition">
<Type>String</Type>
<SetFunction>glade_gtk_widget_set_tooltip</SetFunction>
<GetFunction>glade_gtk_widget_get_tooltip</GetFunction>
</Property>
<Property Common="True" Id="events">
<SetFunction>ignore</SetFunction>
<GetFunction>ignore</GetFunction>

View File

@ -9,11 +9,6 @@
</Property>
<Property Id="default-width" Default="0" Optional="True" OptionalDefault="False"/>
<Property Id="default-height" Default="0" Optional="True" OptionalDefault="False"/>
<Property Common="True" Id="tooltip" Name="Tooltip">
<Type>String</Type>
<SetFunction>ignore</SetFunction>
<GetFunction>ignore</GetFunction>
</Property>
<Property Id="type-hint">
<SetFunction>ignore</SetFunction>
<GetFunction>ignore</GetFunction>