mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-09-24 00:04:33 -04:00
Added glade builtin pspec types for general purpose use in the plugin.
* src/Makefile.am, src/glade-plugin.h, src/glade-buildtins.[ch], widgets/gtk+.xml: Added glade builtin pspec types for general purpose use in the plugin. This also features a "stock" enum type which is generated with gtk_stock_list_ids. * src/glade-editor.[ch]: Implemented "stock item" menus (works with GLADE_TYPE_STOCK) * src/glade-gtk.c: Removed all the custom pspec (in favor of the builtins) and implemented stock buttons properly (they rock by the way :-p ) * src/glade-property-class.[ch]: "visible" xml tag is simply a boolean describing if it is visible or not in the editor (visible properties now will also be written in the editor if they are not default, custom or disable with the "save" xml tag).
This commit is contained in:
parent
e6d2660b65
commit
1091ad43ed
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
||||
2005-07-29 Tristan Van Berkom <tvb@gnome.org>
|
||||
|
||||
* src/Makefile.am, src/glade-plugin.h, src/glade-buildtins.[ch], widgets/gtk+.xml:
|
||||
Added glade builtin pspec types for general purpose use in the plugin.
|
||||
This also features a "stock" enum type which is generated with gtk_stock_list_ids.
|
||||
|
||||
* src/glade-editor.[ch]: Implemented "stock item" menus (works with GLADE_TYPE_STOCK)
|
||||
|
||||
* src/glade-gtk.c: Removed all the custom pspec (in favor of the builtins) and implemented
|
||||
stock buttons properly (they rock by the way :-p )
|
||||
|
||||
* src/glade-property-class.[ch]: "visible" xml tag is simply a boolean describing
|
||||
if it is visible or not in the editor (visible properties now will also be written
|
||||
in the editor if they are not default, custom or disable with the "save" xml tag).
|
||||
|
||||
|
||||
2005-07-29 Tristan Van Berkom <tvb@gnome.org>
|
||||
|
||||
* src/glade-gtk.c: Simplified code with convenience functions
|
||||
|
@ -58,6 +58,7 @@ libgladeui_1_la_SOURCES = \
|
||||
glade-id-allocator.c \
|
||||
glade-marshallers.c \
|
||||
glade-parser.c \
|
||||
glade-builtins.c \
|
||||
glade-app.c
|
||||
|
||||
libgladeui_1_la_CFLAGS = -DINSIDE_LIBGLADEUI $(AM_CFLAGS)
|
||||
@ -96,6 +97,7 @@ libgladeuiinclude_HEADERS = \
|
||||
glade-parser.h \
|
||||
glade-app.h \
|
||||
glade-plugin.h \
|
||||
glade-builtins.c \
|
||||
fixed_bg.xpm
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
122
src/glade-builtins.c
Normal file
122
src/glade-builtins.c
Normal file
@ -0,0 +1,122 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* glade-clipboard.c - An object for handling Cut/Copy/Paste.
|
||||
*
|
||||
* Copyright (C) 2001 The GNOME Foundation.
|
||||
*
|
||||
* Author(s):
|
||||
* Tristan Van Berkom <tvb@gnome.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include "glade-builtins.h"
|
||||
|
||||
/* Generate the GType dynamicly from the gtk stock engine
|
||||
*/
|
||||
GType
|
||||
glade_standard_stock_get_type (void)
|
||||
{
|
||||
static GType etype = 0;
|
||||
if (etype == 0) {
|
||||
|
||||
GtkStockItem item;
|
||||
GSList *l, *stock_list;
|
||||
gchar *stock_id;
|
||||
gint stock_enum = 0;
|
||||
GEnumValue value;
|
||||
GArray *values =
|
||||
g_array_new (TRUE, TRUE, sizeof (GEnumValue));
|
||||
|
||||
/* We have ownership of the retuened list & the
|
||||
* strings within
|
||||
*/
|
||||
stock_list = gtk_stock_list_ids ();
|
||||
|
||||
/* Add first "no stock" element */
|
||||
value.value_nick = g_strdup ("glade-none"); // Passing ownership here.
|
||||
value.value_name = g_strdup ("None");
|
||||
value.value = stock_enum++;
|
||||
values = g_array_append_val (values, value);
|
||||
|
||||
for (l = stock_list; l; l = l->next)
|
||||
{
|
||||
stock_id = l->data;
|
||||
if (!gtk_stock_lookup (stock_id, &item))
|
||||
continue;
|
||||
|
||||
value.value = stock_enum++;
|
||||
value.value_name = g_strdup (item.label);
|
||||
value.value_nick = stock_id; // Passing ownership here.
|
||||
values = g_array_append_val (values, value);
|
||||
}
|
||||
|
||||
etype = g_enum_register_static ("GladeGtkStockType", (GEnumValue *)values->data);
|
||||
|
||||
g_slist_free (stock_list);
|
||||
}
|
||||
return etype;
|
||||
}
|
||||
|
||||
GParamSpec *
|
||||
glade_standard_stock_spec (void)
|
||||
{
|
||||
return g_param_spec_enum ("stock", _("Stock"),
|
||||
_("A builtin stock item"),
|
||||
glade_standard_stock_get_type (),
|
||||
0, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
|
||||
}
|
||||
|
||||
GParamSpec *
|
||||
glade_standard_int_spec (void)
|
||||
{
|
||||
static GParamSpec *int_spec = NULL;
|
||||
if (!int_spec)
|
||||
int_spec = g_param_spec_int ("int", _("Integer"),
|
||||
_("An integer value"),
|
||||
0, G_MAXINT,
|
||||
0, G_PARAM_READWRITE);
|
||||
return int_spec;
|
||||
}
|
||||
|
||||
GParamSpec *
|
||||
glade_standard_string_spec (void)
|
||||
{
|
||||
static GParamSpec *str_spec = NULL;
|
||||
if (!str_spec)
|
||||
str_spec = g_param_spec_string ("string", _("String"),
|
||||
_("An entry"), "",
|
||||
G_PARAM_READWRITE);
|
||||
return str_spec;
|
||||
}
|
||||
|
||||
GParamSpec *
|
||||
glade_standard_float_spec (void)
|
||||
{
|
||||
static GParamSpec *float_spec = NULL;
|
||||
if (!float_spec)
|
||||
float_spec = g_param_spec_float ("float", _("Float"),
|
||||
_("A floating point entry"),
|
||||
0.0F, G_MAXFLOAT, 0.0F,
|
||||
G_PARAM_READWRITE);
|
||||
return float_spec;
|
||||
}
|
18
src/glade-builtins.h
Normal file
18
src/glade-builtins.h
Normal file
@ -0,0 +1,18 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
#ifndef __GLADE_BUILTINS_H__
|
||||
#define __GLADE_BUILTINS_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include "glade.h"
|
||||
|
||||
#define GLADE_TYPE_STOCK (glade_standard_stock_get_type())
|
||||
|
||||
LIBGLADEUI_API GType glade_standard_stock_get_type (void);
|
||||
|
||||
#define GLADE_IS_PARAM_SPEC_STOCK(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GLADE_TYPE_STOCK))
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_stock_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_int_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_string_spec (void);
|
||||
LIBGLADEUI_API GParamSpec *glade_standard_float_spec (void);
|
||||
|
||||
#endif /* __GLADE_BUILTINS_H__ */
|
@ -43,6 +43,7 @@
|
||||
#include "glade-menu-editor.h"
|
||||
#include "glade-project.h"
|
||||
#include "glade-utils.h"
|
||||
#include "glade-builtins.h"
|
||||
|
||||
|
||||
static GtkNotebookClass *parent_class = NULL;
|
||||
@ -835,7 +836,26 @@ glade_editor_create_input_enum_item (GladeEditorProperty *property,
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
glade_editor_create_input_enum (GladeEditorProperty *property)
|
||||
glade_editor_create_input_stock_item (GladeEditorProperty *property,
|
||||
const gchar *id,
|
||||
gint value)
|
||||
{
|
||||
GtkWidget *menu_item;
|
||||
|
||||
menu_item = gtk_image_menu_item_new_from_stock (id, NULL);
|
||||
|
||||
g_signal_connect (G_OBJECT (menu_item), "activate",
|
||||
G_CALLBACK (glade_editor_property_changed_enum),
|
||||
property);
|
||||
|
||||
g_object_set_data (G_OBJECT (menu_item), GLADE_ENUM_DATA_TAG, GINT_TO_POINTER(value));
|
||||
|
||||
return menu_item;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
glade_editor_create_input_enum (GladeEditorProperty *property,
|
||||
gboolean stock)
|
||||
{
|
||||
GladePropertyClass *class;
|
||||
GtkWidget *menu_item;
|
||||
@ -861,9 +881,15 @@ glade_editor_create_input_enum (GladeEditorProperty *property)
|
||||
(class, eclass->values[i].value);
|
||||
if (value_name == NULL) value_name = eclass->values[i].value_name;
|
||||
|
||||
menu_item = glade_editor_create_input_enum_item (property,
|
||||
value_name,
|
||||
eclass->values[i].value);
|
||||
if (stock && strcmp (eclass->values[i].value_nick, "glade-none"))
|
||||
menu_item = glade_editor_create_input_stock_item
|
||||
(property,
|
||||
eclass->values[i].value_nick,
|
||||
eclass->values[i].value);
|
||||
else
|
||||
menu_item = glade_editor_create_input_enum_item
|
||||
(property, value_name, eclass->values[i].value);
|
||||
|
||||
gtk_widget_show (menu_item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||
}
|
||||
@ -876,6 +902,7 @@ glade_editor_create_input_enum (GladeEditorProperty *property)
|
||||
return option_menu;
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
glade_editor_create_input_flags (GladeEditorProperty *property)
|
||||
{
|
||||
@ -1119,8 +1146,10 @@ glade_editor_append_item_real (GladeEditorTable *table,
|
||||
|
||||
class = property->class;
|
||||
|
||||
if (G_IS_PARAM_SPEC_ENUM(class->pspec))
|
||||
input = glade_editor_create_input_enum (property);
|
||||
if (class->pspec->value_type == GLADE_TYPE_STOCK)
|
||||
input = glade_editor_create_input_enum (property, TRUE);
|
||||
else if (G_IS_PARAM_SPEC_ENUM(class->pspec))
|
||||
input = glade_editor_create_input_enum (property, FALSE);
|
||||
else if (G_IS_PARAM_SPEC_FLAGS(class->pspec))
|
||||
input = glade_editor_create_input_flags (property);
|
||||
else if (G_IS_PARAM_SPEC_BOOLEAN(class->pspec))
|
||||
@ -1756,7 +1785,8 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
|
||||
|
||||
property->property->loading = TRUE;
|
||||
|
||||
if (G_IS_PARAM_SPEC_ENUM(class->pspec))
|
||||
if (class->pspec->value_type == GLADE_TYPE_STOCK ||
|
||||
G_IS_PARAM_SPEC_ENUM(class->pspec))
|
||||
glade_editor_property_load_enum (property);
|
||||
else if (G_IS_PARAM_SPEC_FLAGS(class->pspec))
|
||||
glade_editor_property_load_flags (property);
|
||||
@ -1781,7 +1811,7 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
|
||||
|
||||
|
||||
|
||||
/* Set insensitive and hook cb here XXX */
|
||||
/* Set insensitive and hook cb here */
|
||||
if (property->sensitive_id > 0)
|
||||
g_signal_handler_disconnect (property->sensitive_prop,
|
||||
property->sensitive_id);
|
||||
|
255
src/glade-gtk.c
255
src/glade-gtk.c
@ -42,67 +42,6 @@
|
||||
#define FIXED_DEFAULT_CHILD_HEIGHT 60
|
||||
|
||||
|
||||
|
||||
/* ---------------------------- Custom Property definitions ------------------------ */
|
||||
static GType
|
||||
glade_gtk_stock_get_type (void)
|
||||
{
|
||||
static GType etype = 0;
|
||||
if (etype == 0) {
|
||||
|
||||
static const GEnumValue values[] = {
|
||||
{ 0, "None", "glade-none" },
|
||||
{ 1, "Ok", "gtk-ok" },
|
||||
{ 2, "Cancel", "gtk-cancel" },
|
||||
{ 3, "Apply", "gtk-apply" },
|
||||
{ 4, "Close", "gtk-close" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
etype = g_enum_register_static ("GladeGtkStockType", values);
|
||||
}
|
||||
return etype;
|
||||
}
|
||||
|
||||
GLADEGTK_API GParamSpec *
|
||||
glade_gtk_stock_spec (void)
|
||||
{
|
||||
return g_param_spec_enum ("stock", "stock", "stock",
|
||||
glade_gtk_stock_get_type (),
|
||||
0, G_PARAM_READWRITE);
|
||||
}
|
||||
|
||||
GLADEGTK_API GParamSpec *
|
||||
glade_gtk_standard_int_spec (void)
|
||||
{
|
||||
static GParamSpec *int_spec = NULL;
|
||||
if (!int_spec)
|
||||
int_spec = g_param_spec_int ("int", "int", "int",
|
||||
0, G_MAXINT,
|
||||
0, G_PARAM_READWRITE);
|
||||
return int_spec;
|
||||
}
|
||||
|
||||
GLADEGTK_API GParamSpec *
|
||||
glade_gtk_standard_string_spec (void)
|
||||
{
|
||||
static GParamSpec *str_spec = NULL;
|
||||
if (!str_spec)
|
||||
str_spec = g_param_spec_string ("string", "string", "string",
|
||||
"", G_PARAM_READWRITE);
|
||||
return str_spec;
|
||||
}
|
||||
|
||||
GLADEGTK_API GParamSpec *
|
||||
glade_gtk_standard_float_spec (void)
|
||||
{
|
||||
static GParamSpec *float_spec = NULL;
|
||||
if (!float_spec)
|
||||
float_spec = g_param_spec_float ("float", "float", "float",
|
||||
0.0F, G_MAXFLOAT, 0.0F,
|
||||
G_PARAM_READWRITE);
|
||||
return float_spec;
|
||||
}
|
||||
|
||||
/* ------------------------------------ Custom Properties ------------------------------ */
|
||||
/**
|
||||
* glade_gtk_option_menu_set_items:
|
||||
@ -149,33 +88,6 @@ glade_gtk_option_menu_set_items (GObject *object, GValue *value)
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_gtk_widget_condition:
|
||||
* @klass:
|
||||
*
|
||||
* TODO: write me
|
||||
*/
|
||||
gint GLADEGTK_API
|
||||
glade_gtk_widget_condition (GladeWidgetClass *klass)
|
||||
{
|
||||
GtkObject *object = (GtkObject*)g_object_new (klass->type, NULL);
|
||||
gboolean result;
|
||||
|
||||
/* 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. */
|
||||
result = (!GTK_WIDGET_NO_WINDOW (object) ||
|
||||
GTK_IS_BUTTON (object) ||
|
||||
GTK_IS_MENU_ITEM (object));
|
||||
|
||||
gtk_object_ref (object);
|
||||
gtk_object_sink (object);
|
||||
gtk_object_unref (object);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_gtk_widget_set_tooltip:
|
||||
* @object:
|
||||
@ -832,13 +744,52 @@ glade_gtk_table_verify_n_columns (GObject *object, GValue *value)
|
||||
return glade_gtk_table_verify_n_common (object, value, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_gtk_button_set_stock:
|
||||
* @object:
|
||||
* @value:
|
||||
*
|
||||
* TODO: write me
|
||||
*/
|
||||
static void
|
||||
glade_gtk_button_ensure_glabel (GtkWidget *button)
|
||||
{
|
||||
GladeWidgetClass *wclass;
|
||||
GladeWidget *gbutton, *glabel;
|
||||
GtkWidget *child;
|
||||
|
||||
gbutton = glade_widget_get_from_gobject (button);
|
||||
|
||||
/* If we didnt put this object here... (or its a placeholder) */
|
||||
if ((child = gtk_bin_get_child (GTK_BIN (button))) == NULL ||
|
||||
(glade_widget_get_from_gobject (child) == NULL))
|
||||
{
|
||||
wclass = glade_widget_class_get_by_type (GTK_TYPE_LABEL);
|
||||
glabel = glade_widget_new (gbutton, wclass,
|
||||
glade_widget_get_project (gbutton));
|
||||
|
||||
glade_widget_property_set
|
||||
(glabel, "label", gbutton->widget_class->generic_name);
|
||||
|
||||
if (child) gtk_container_remove (GTK_CONTAINER (button), child);
|
||||
gtk_container_add (GTK_CONTAINER (button), GTK_WIDGET (glabel->object));
|
||||
|
||||
glade_project_add_object (gbutton->project, glabel->object);
|
||||
gtk_widget_show (GTK_WIDGET (glabel->object));
|
||||
}
|
||||
|
||||
glade_widget_property_set_sensitive
|
||||
(gbutton, "stock", FALSE,
|
||||
_("There must be no children in the button"));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
glade_gtk_button_ensure_glabel_idle (gpointer data)
|
||||
{
|
||||
GladeWidget *gbutton;
|
||||
GtkWidget *button;
|
||||
g_return_val_if_fail (GLADE_IS_WIDGET (data), FALSE);
|
||||
|
||||
gbutton = GLADE_WIDGET (data);
|
||||
button = GTK_WIDGET (gbutton->object);
|
||||
|
||||
glade_gtk_button_ensure_glabel (button);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void GLADEGTK_API
|
||||
glade_gtk_button_set_stock (GObject *object, GValue *value)
|
||||
{
|
||||
@ -850,13 +801,12 @@ glade_gtk_button_set_stock (GObject *object, GValue *value)
|
||||
|
||||
gwidget = glade_widget_get_from_gobject (object);
|
||||
g_return_if_fail (GTK_IS_BUTTON (object));
|
||||
g_return_if_fail (gwidget != NULL);
|
||||
g_return_if_fail (GLADE_IS_WIDGET (gwidget));
|
||||
|
||||
val = g_value_get_enum (value);
|
||||
if (val == GPOINTER_TO_INT (g_object_get_data (object, "stock")))
|
||||
if (val == GPOINTER_TO_INT (g_object_get_data (G_OBJECT (gwidget), "stock")))
|
||||
return;
|
||||
|
||||
g_return_if_fail (gwidget != NULL);
|
||||
g_object_set_data (G_OBJECT (gwidget), "stock", GINT_TO_POINTER (val));
|
||||
|
||||
property = glade_widget_get_property (gwidget, "stock");
|
||||
eclass = g_type_class_ref (property->class->pspec->value_type);
|
||||
@ -869,13 +819,28 @@ glade_gtk_button_set_stock (GObject *object, GValue *value)
|
||||
return;
|
||||
}
|
||||
|
||||
glade_widget_property_set (gwidget, "use-stock", TRUE);
|
||||
glade_widget_property_set (gwidget, "label", eclass->values[i].value_nick);
|
||||
glade_widget_property_set_sensitive
|
||||
(gwidget, "label", FALSE, _("Jolly rancher"));
|
||||
/* setting to "none", ensure an appropriate label */
|
||||
if (val == 0)
|
||||
{
|
||||
glade_widget_property_set (gwidget, "use-stock", FALSE);
|
||||
glade_widget_property_set (gwidget, "label", NULL);
|
||||
g_idle_add (glade_gtk_button_ensure_glabel_idle, gwidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* GtkButton doesn't seem to take care of this automaticly.
|
||||
*/
|
||||
if (GTK_BIN (object)->child)
|
||||
gtk_container_remove (GTK_CONTAINER (object),
|
||||
GTK_BIN (object)->child);
|
||||
|
||||
/* Here we should remove any previously added GladeWidgets manualy
|
||||
* and from the project, not to leak them.
|
||||
*/
|
||||
glade_widget_property_set (gwidget, "use-stock", TRUE);
|
||||
glade_widget_property_set (gwidget, "label", eclass->values[i].value_nick);
|
||||
}
|
||||
g_type_class_unref (eclass);
|
||||
g_object_set_data (object, "stock", GINT_TO_POINTER (val));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1271,39 +1236,6 @@ glade_gtk_frame_post_create (GObject *frame)
|
||||
|
||||
}
|
||||
|
||||
static gboolean
|
||||
glade_gtk_button_create_idle (gpointer data)
|
||||
{
|
||||
GladeWidget *gbutton, *glabel;
|
||||
GtkWidget *widget, *button;
|
||||
GladeWidgetClass *wclass;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_WIDGET (data), FALSE);
|
||||
g_return_val_if_fail (GTK_IS_BUTTON (GLADE_WIDGET (data)->object), FALSE);
|
||||
gbutton = GLADE_WIDGET (data);
|
||||
button = GTK_WIDGET (gbutton->object);
|
||||
|
||||
/* If we didnt put this object here... */
|
||||
if ((widget = gtk_bin_get_child (GTK_BIN (button))) == NULL ||
|
||||
(glade_widget_get_from_gobject (widget) == NULL))
|
||||
{
|
||||
wclass = glade_widget_class_get_by_type (GTK_TYPE_LABEL);
|
||||
glabel = glade_widget_new (gbutton, wclass,
|
||||
glade_widget_get_project (gbutton));
|
||||
|
||||
glade_widget_property_set
|
||||
(glabel, "label", gbutton->widget_class->generic_name);
|
||||
|
||||
if (widget)
|
||||
gtk_container_remove (GTK_CONTAINER (button), widget);
|
||||
gtk_container_add (GTK_CONTAINER (button), GTK_WIDGET (glabel->object));
|
||||
|
||||
glade_project_add_object (gbutton->project, glabel->object);
|
||||
gtk_widget_show (GTK_WIDGET (glabel->object));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_gtk_button_post_create:
|
||||
* @object:
|
||||
@ -1313,14 +1245,37 @@ glade_gtk_button_create_idle (gpointer data)
|
||||
void GLADEGTK_API
|
||||
glade_gtk_button_post_create (GObject *button)
|
||||
{
|
||||
GladeWidget *gbutton;
|
||||
gboolean use_stock = FALSE;
|
||||
gchar *label = NULL;
|
||||
GladeWidget *gbutton =
|
||||
gbutton = glade_widget_get_from_gobject (button);
|
||||
GEnumValue *eval;
|
||||
GEnumClass *eclass;
|
||||
|
||||
g_return_if_fail (GTK_IS_BUTTON (button));
|
||||
if ((gbutton = glade_widget_get_from_gobject (button)) != NULL)
|
||||
g_idle_add (glade_gtk_button_create_idle, gbutton);
|
||||
g_return_if_fail (GLADE_IS_WIDGET (gbutton));
|
||||
|
||||
eclass = g_type_class_ref (GLADE_TYPE_STOCK);
|
||||
|
||||
glade_widget_property_get (gbutton, "use-stock", &use_stock);
|
||||
if (use_stock)
|
||||
{
|
||||
glade_widget_property_get (gbutton, "label", &label);
|
||||
|
||||
eval = g_enum_get_value_by_nick (eclass, label);
|
||||
g_object_set_data (G_OBJECT (gbutton), "stock", GINT_TO_POINTER (eval->value));
|
||||
|
||||
if (label != NULL && strcmp (label, "glade-none") != 0)
|
||||
glade_widget_property_set (gbutton, "stock", eval->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_idle_add (glade_gtk_button_ensure_glabel_idle, gbutton);
|
||||
}
|
||||
g_type_class_unref (eclass);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------ Replace child functions ------------------------ */
|
||||
/**
|
||||
* glade_gtk_container_replace_child:
|
||||
@ -1454,6 +1409,26 @@ glade_gtk_frame_replace_child (GtkWidget *container,
|
||||
glade_gtk_container_replace_child (container, current, new);
|
||||
}
|
||||
|
||||
void GLADEGTK_API
|
||||
glade_gtk_button_replace_child (GtkWidget *container,
|
||||
GtkWidget *current,
|
||||
GtkWidget *new)
|
||||
{
|
||||
GladeWidget *gbutton = glade_widget_get_from_gobject (container);
|
||||
|
||||
g_return_if_fail (GLADE_IS_WIDGET (gbutton));
|
||||
glade_gtk_container_replace_child (container, current, new);
|
||||
|
||||
if (GLADE_IS_PLACEHOLDER (new))
|
||||
glade_widget_property_set_sensitive (gbutton,
|
||||
"stock",
|
||||
TRUE, NULL);
|
||||
else
|
||||
glade_widget_property_set_sensitive
|
||||
(gbutton, "stock", FALSE,
|
||||
_("There must be no children in the button"));
|
||||
}
|
||||
|
||||
/* -------------------------- Fill Empty functions -------------------------- */
|
||||
/**
|
||||
* glade_gtk_container_fill_empty:
|
||||
|
@ -13,5 +13,6 @@
|
||||
#include "glade-property-class.h"
|
||||
#include "glade-types.h"
|
||||
#include "glade-palette.h"
|
||||
#include "glade-builtins.h"
|
||||
|
||||
#endif
|
||||
|
@ -63,12 +63,11 @@ glade_property_class_new (void)
|
||||
property_class->common = FALSE;
|
||||
property_class->packing = FALSE;
|
||||
property_class->save = TRUE;
|
||||
property_class->editable = TRUE;
|
||||
property_class->is_modified = FALSE;
|
||||
property_class->verify_function = NULL;
|
||||
property_class->set_function = NULL;
|
||||
property_class->get_function = NULL;
|
||||
property_class->visible = FALSE;
|
||||
property_class->visible = TRUE;
|
||||
property_class->translatable = TRUE;
|
||||
|
||||
return property_class;
|
||||
@ -594,10 +593,7 @@ glade_property_class_new_from_spec (GParamSpec *spec)
|
||||
gboolean
|
||||
glade_property_class_is_visible (GladePropertyClass *property_class, GladeWidgetClass *widget_class)
|
||||
{
|
||||
if (property_class->visible)
|
||||
return property_class->visible (widget_class);
|
||||
|
||||
return TRUE;
|
||||
return property_class->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -697,7 +693,6 @@ 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,15 +719,6 @@ glade_property_class_update_from_node (GladeXmlNode *node,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
visible = glade_xml_get_property_string (node, GLADE_TAG_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)
|
||||
@ -750,7 +736,12 @@ glade_property_class_update_from_node (GladeXmlNode *node,
|
||||
|
||||
/* ... get the tooltip from the pspec ... */
|
||||
if (class->pspec)
|
||||
{
|
||||
class->tooltip = g_strdup (g_param_spec_get_blurb (class->pspec));
|
||||
|
||||
if (class->pspec->flags & G_PARAM_CONSTRUCT_ONLY)
|
||||
class->construct_only = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (!class->pspec)
|
||||
{
|
||||
@ -821,11 +812,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, FALSE);
|
||||
class->common = glade_xml_get_property_boolean (node, GLADE_TAG_COMMON, class->common);
|
||||
class->optional = glade_xml_get_property_boolean (node, GLADE_TAG_OPTIONAL, FALSE);
|
||||
class->query = glade_xml_get_property_boolean (node, GLADE_TAG_QUERY, FALSE);
|
||||
class->save = glade_xml_get_property_boolean (node, GLADE_TAG_SAVE, FALSE);
|
||||
class->editable = glade_xml_get_property_boolean (node, GLADE_TAG_EDITABLE, FALSE);
|
||||
class->save = glade_xml_get_property_boolean (node, GLADE_TAG_SAVE, TRUE);
|
||||
class->visible = glade_xml_get_property_boolean (node, GLADE_TAG_VISIBLE, TRUE);
|
||||
|
||||
|
||||
if (class->optional)
|
||||
class->optional_default =
|
||||
|
@ -145,34 +145,36 @@ struct _GladePropertyClass
|
||||
gboolean save; /* Whether we should save to the glade file or not
|
||||
* (mostly just for custom glade properties)
|
||||
*/
|
||||
gboolean editable; /* Whether or not to show this property in the editor
|
||||
gboolean visible; /* Whether or not to show this property in the editor
|
||||
*/
|
||||
|
||||
gboolean is_modified; /* If true, this property_class has been "modified" from the
|
||||
* the standard property by a xml file. */
|
||||
|
||||
/* Delagate to verify if this is a valid value for this property,
|
||||
* if this function exists and returns FALSE, then glade_property_set
|
||||
* will abort before making any changes
|
||||
*/
|
||||
gboolean (*verify_function) (GObject *object,
|
||||
const GValue *value);
|
||||
/* Delagate to verify if this is a valid value for this property,
|
||||
* if this function exists and returns FALSE, then glade_property_set
|
||||
* will abort before making any changes
|
||||
*/
|
||||
|
||||
/* If this property can't be set with g_object_set then
|
||||
* we need to implement it inside glade. This is a pointer
|
||||
* to the function that can set this property. The functions
|
||||
* to work arround these problems are inside glade-gtk.c
|
||||
*/
|
||||
void (*set_function) (GObject *object,
|
||||
const GValue *value);
|
||||
/* If this property can't be set with g_object_set then
|
||||
* we need to implement it inside glade. This is a pointer
|
||||
* to the function that can set this property. The functions
|
||||
* to work arround these problems are inside glade-gtk.c
|
||||
*/
|
||||
|
||||
/* If this property can't be get with g_object_get then
|
||||
* 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
|
||||
*/
|
||||
void (*get_function) (GObject *object,
|
||||
GValue *value);
|
||||
/* If this property can't be get with g_object_get then
|
||||
* 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
|
||||
*/
|
||||
gboolean (*visible) (GladeWidgetClass *widget_class);
|
||||
|
||||
|
||||
};
|
||||
|
||||
GladePropertyClass * glade_property_class_new (void);
|
||||
|
@ -229,10 +229,6 @@ glade_property_write_impl (GladeProperty *property,
|
||||
if (!property->class->save || !property->enabled)
|
||||
return FALSE;
|
||||
|
||||
if (!glade_property_class_is_visible (property->class,
|
||||
glade_widget_get_class (property->widget)))
|
||||
return FALSE;
|
||||
|
||||
/* we should change each '-' by '_' on the name of the property
|
||||
* (<property name="...">) */
|
||||
tmp = g_strdup (property->class->id);
|
||||
@ -422,7 +418,7 @@ glade_property_cinfo_init (GladePropertyCinfo *prop_class)
|
||||
prop_class->write = glade_property_write_impl;
|
||||
prop_class->get_tooltip = glade_property_get_tooltip_impl;
|
||||
prop_class->value_changed = NULL;
|
||||
prop_class->tooltip_changed = NULL;
|
||||
prop_class->tooltip_changed = NULL;
|
||||
|
||||
/* Properties */
|
||||
g_object_class_install_property
|
||||
|
@ -3,7 +3,7 @@
|
||||
<!-- Gtk+ Base -->
|
||||
<glade-widget-class name="GtkWidget">
|
||||
<properties>
|
||||
<property common="True" id="visible">
|
||||
<property id="visible" common="True">
|
||||
<set-function>ignore</set-function>
|
||||
<get-function>ignore</get-function>
|
||||
</property>
|
||||
@ -12,8 +12,8 @@
|
||||
|
||||
<property common="True" optional="True" optional-default="False" default="0" id="height-request"/>
|
||||
|
||||
<property common="True" id="tooltip" name="Tooltip" visible="glade_gtk_widget_condition" default="">
|
||||
<spec>glade_gtk_standard_string_spec</spec>
|
||||
<property common="True" id="tooltip" name="Tooltip" default="">
|
||||
<spec>glade_standard_string_spec</spec>
|
||||
<set-function>glade_gtk_widget_set_tooltip</set-function>
|
||||
<get-function>glade_gtk_widget_get_tooltip</get-function>
|
||||
</property>
|
||||
@ -94,7 +94,7 @@
|
||||
|
||||
<properties>
|
||||
<property id="size" name="Number of items" query="TRUE" default="3">
|
||||
<spec>glade_gtk_standard_int_spec</spec>
|
||||
<spec>glade_standard_int_spec</spec>
|
||||
<tooltip>The number of items in the box</tooltip>
|
||||
<parameters>
|
||||
<parameter key="Min" value="1"/>
|
||||
@ -211,7 +211,7 @@
|
||||
<properties>
|
||||
|
||||
<property id="size" name="Size" default="3" query="TRUE">
|
||||
<spec>glade_gtk_standard_int_spec</spec>
|
||||
<spec>glade_standard_int_spec</spec>
|
||||
<tooltip>The number of items in the toolbar</tooltip>
|
||||
<parameters>
|
||||
<parameter key="Min" value="0"/>
|
||||
@ -328,14 +328,16 @@
|
||||
<glade-widget-class name="GtkButton" generic-name="button" title="Button">
|
||||
<post-create-function>glade_gtk_button_post_create</post-create-function>
|
||||
<properties>
|
||||
|
||||
<property id="stock" name="Stock Button" default="glade-none">
|
||||
<spec>glade_gtk_stock_spec</spec>
|
||||
<property id="use-underline" disabled="TRUE"/>
|
||||
<property id="label" visible="FALSE"/>
|
||||
<property id="use-stock" visible="FALSE"/>
|
||||
<property id="stock" name="Stock Button" save="FALSE">
|
||||
<spec>glade_standard_stock_spec</spec>
|
||||
<set-function>glade_gtk_button_set_stock</set-function>
|
||||
</property>
|
||||
|
||||
<property id="response-id" name="Response ID" default="0" common="False">
|
||||
<spec>glade_gtk_standard_int_spec</spec>
|
||||
<spec>glade_standard_int_spec</spec>
|
||||
<tooltip>The response ID of this button in a dialog (it's NOT useful if this button is not in a GtkDialog)</tooltip>
|
||||
<set-function>ignore</set-function>
|
||||
<get-function>ignore</get-function>
|
||||
@ -354,6 +356,7 @@
|
||||
<child>
|
||||
<type>GtkWidget</type>
|
||||
<add-child-function>glade_gtk_button_add_child</add-child-function>
|
||||
<replace-child-function>glade_gtk_button_replace_child</replace-child-function>
|
||||
<fill-empty-function>empty</fill-empty-function>
|
||||
</child>
|
||||
</children>
|
||||
@ -381,7 +384,7 @@
|
||||
<properties>
|
||||
<property id="draw-indicator" default="True"/>
|
||||
<property id="group" name="Group" default="True">
|
||||
<spec>glade_gtk_standard_string_spec</spec>
|
||||
<spec>glade_standard_string_spec</spec>
|
||||
<set-function>glade_gtk_radio_button_set_group</set-function>
|
||||
<get-function>glade_gtk_radio_button_get_group</get-function>
|
||||
</property>
|
||||
@ -429,7 +432,7 @@
|
||||
<property id="file" translatable="False"/>
|
||||
<property id="stock" translatable="False"/>
|
||||
<property id="pixbuf" name="Image file" translatable="False" default="">
|
||||
<spec>glade_gtk_standard_string_spec</spec>
|
||||
<spec>glade_standard_string_spec</spec>
|
||||
<set-function>glade_gtk_image_set_pixbuf</set-function>
|
||||
</property>
|
||||
</properties>
|
||||
@ -460,7 +463,7 @@
|
||||
<!--
|
||||
<properties>
|
||||
<property id="response-id" name="Response ID" default="0" common="False">
|
||||
<spec>glade_gtk_standard_int_spec</spec>
|
||||
<spec>glade_standard_int_spec</spec>
|
||||
<tooltip>The response ID of this button in the dialog</tooltip>
|
||||
<set-function>ignore</set-function>
|
||||
<get-function>ignore</get-function>
|
||||
@ -531,7 +534,7 @@
|
||||
<glade-widget-class name="GtkNotebook" generic-name="notebook" title="Notebook">
|
||||
<properties>
|
||||
<property id="pages" name="Number of pages" default="3" query="TRUE">
|
||||
<spec>glade_gtk_standard_int_spec</spec>
|
||||
<spec>glade_standard_int_spec</spec>
|
||||
<tooltip>The number of pages in the notebook</tooltip>
|
||||
<parameters>
|
||||
<parameter key="Min" value="1"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user