forked from AuroraMiddleware/gtk
Add properties for labels, mnemonics and stock items. Added C accessor
2001-08-26 Alexander Larsson <alla@lysator.liu.se> * gtk/gtkbutton.[ch]: Add properties for labels, mnemonics and stock items. Added C accessor functions for the properties. Removed deprecated button->child. * gtk/gtkradiobutton.c: * gtk/gtktogglebutton.c: Update to use the functions in GtkButton. * gtk/gtkcheckbutton.c: Update to use the functions in GtkButton. Changed size allocation of child. Now only gets as much space as it requests. * gtk/gtkclist.c: Don't use GtkButton->child * gtk/gtklabel.c: Fixed typo in docs
This commit is contained in:
parent
8d00215d9e
commit
f9e666244f
22
ChangeLog
22
ChangeLog
@ -1,3 +1,25 @@
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkbutton.[ch]:
|
||||
Add properties for labels, mnemonics and stock items.
|
||||
Added C accessor functions for the properties.
|
||||
Removed deprecated button->child.
|
||||
|
||||
* gtk/gtkradiobutton.c:
|
||||
* gtk/gtktogglebutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
|
||||
* gtk/gtkcheckbutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
Changed size allocation of child. Now only gets as much
|
||||
space as it requests.
|
||||
|
||||
* gtk/gtkclist.c:
|
||||
Don't use GtkButton->child
|
||||
|
||||
* gtk/gtklabel.c:
|
||||
Fixed typo in docs
|
||||
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* tests/testgtk.c:
|
||||
|
@ -1,3 +1,25 @@
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkbutton.[ch]:
|
||||
Add properties for labels, mnemonics and stock items.
|
||||
Added C accessor functions for the properties.
|
||||
Removed deprecated button->child.
|
||||
|
||||
* gtk/gtkradiobutton.c:
|
||||
* gtk/gtktogglebutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
|
||||
* gtk/gtkcheckbutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
Changed size allocation of child. Now only gets as much
|
||||
space as it requests.
|
||||
|
||||
* gtk/gtkclist.c:
|
||||
Don't use GtkButton->child
|
||||
|
||||
* gtk/gtklabel.c:
|
||||
Fixed typo in docs
|
||||
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* tests/testgtk.c:
|
||||
|
@ -1,3 +1,25 @@
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkbutton.[ch]:
|
||||
Add properties for labels, mnemonics and stock items.
|
||||
Added C accessor functions for the properties.
|
||||
Removed deprecated button->child.
|
||||
|
||||
* gtk/gtkradiobutton.c:
|
||||
* gtk/gtktogglebutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
|
||||
* gtk/gtkcheckbutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
Changed size allocation of child. Now only gets as much
|
||||
space as it requests.
|
||||
|
||||
* gtk/gtkclist.c:
|
||||
Don't use GtkButton->child
|
||||
|
||||
* gtk/gtklabel.c:
|
||||
Fixed typo in docs
|
||||
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* tests/testgtk.c:
|
||||
|
@ -1,3 +1,25 @@
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkbutton.[ch]:
|
||||
Add properties for labels, mnemonics and stock items.
|
||||
Added C accessor functions for the properties.
|
||||
Removed deprecated button->child.
|
||||
|
||||
* gtk/gtkradiobutton.c:
|
||||
* gtk/gtktogglebutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
|
||||
* gtk/gtkcheckbutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
Changed size allocation of child. Now only gets as much
|
||||
space as it requests.
|
||||
|
||||
* gtk/gtkclist.c:
|
||||
Don't use GtkButton->child
|
||||
|
||||
* gtk/gtklabel.c:
|
||||
Fixed typo in docs
|
||||
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* tests/testgtk.c:
|
||||
|
@ -1,3 +1,25 @@
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkbutton.[ch]:
|
||||
Add properties for labels, mnemonics and stock items.
|
||||
Added C accessor functions for the properties.
|
||||
Removed deprecated button->child.
|
||||
|
||||
* gtk/gtkradiobutton.c:
|
||||
* gtk/gtktogglebutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
|
||||
* gtk/gtkcheckbutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
Changed size allocation of child. Now only gets as much
|
||||
space as it requests.
|
||||
|
||||
* gtk/gtkclist.c:
|
||||
Don't use GtkButton->child
|
||||
|
||||
* gtk/gtklabel.c:
|
||||
Fixed typo in docs
|
||||
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* tests/testgtk.c:
|
||||
|
@ -1,3 +1,25 @@
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkbutton.[ch]:
|
||||
Add properties for labels, mnemonics and stock items.
|
||||
Added C accessor functions for the properties.
|
||||
Removed deprecated button->child.
|
||||
|
||||
* gtk/gtkradiobutton.c:
|
||||
* gtk/gtktogglebutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
|
||||
* gtk/gtkcheckbutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
Changed size allocation of child. Now only gets as much
|
||||
space as it requests.
|
||||
|
||||
* gtk/gtkclist.c:
|
||||
Don't use GtkButton->child
|
||||
|
||||
* gtk/gtklabel.c:
|
||||
Fixed typo in docs
|
||||
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* tests/testgtk.c:
|
||||
|
@ -1,3 +1,25 @@
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkbutton.[ch]:
|
||||
Add properties for labels, mnemonics and stock items.
|
||||
Added C accessor functions for the properties.
|
||||
Removed deprecated button->child.
|
||||
|
||||
* gtk/gtkradiobutton.c:
|
||||
* gtk/gtktogglebutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
|
||||
* gtk/gtkcheckbutton.c:
|
||||
Update to use the functions in GtkButton.
|
||||
Changed size allocation of child. Now only gets as much
|
||||
space as it requests.
|
||||
|
||||
* gtk/gtkclist.c:
|
||||
Don't use GtkButton->child
|
||||
|
||||
* gtk/gtklabel.c:
|
||||
Fixed typo in docs
|
||||
|
||||
2001-08-26 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* tests/testgtk.c:
|
||||
|
371
gtk/gtkbutton.c
371
gtk/gtkbutton.c
@ -58,7 +58,9 @@ enum {
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_LABEL,
|
||||
PROP_RELIEF
|
||||
PROP_RELIEF,
|
||||
PROP_USE_UNDERLINE,
|
||||
PROP_USE_STOCK
|
||||
};
|
||||
|
||||
static void gtk_button_class_init (GtkButtonClass *klass);
|
||||
@ -91,19 +93,20 @@ static gint gtk_button_enter_notify (GtkWidget *widget,
|
||||
GdkEventCrossing *event);
|
||||
static gint gtk_button_leave_notify (GtkWidget *widget,
|
||||
GdkEventCrossing *event);
|
||||
static void gtk_button_add (GtkContainer *container,
|
||||
GtkWidget *widget);
|
||||
static void gtk_button_remove (GtkContainer *container,
|
||||
GtkWidget *widget);
|
||||
static void gtk_real_button_pressed (GtkButton *button);
|
||||
static void gtk_real_button_released (GtkButton *button);
|
||||
static void gtk_real_button_activate (GtkButton *button);
|
||||
static void gtk_button_update_state (GtkButton *button);
|
||||
static GtkType gtk_button_child_type (GtkContainer *container);
|
||||
|
||||
static void gtk_button_finish_activate (GtkButton *button,
|
||||
gboolean do_it);
|
||||
|
||||
static GObject* gtk_button_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_params);
|
||||
static void gtk_button_construct_child (GtkButton *button);
|
||||
|
||||
|
||||
static GtkBinClass *parent_class = NULL;
|
||||
static guint button_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
@ -137,18 +140,21 @@ gtk_button_get_type (void)
|
||||
static void
|
||||
gtk_button_class_init (GtkButtonClass *klass)
|
||||
{
|
||||
GObjectClass *g_object_class;
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkContainerClass *container_class;
|
||||
|
||||
g_object_class = G_OBJECT_CLASS (klass);
|
||||
object_class = (GtkObjectClass*) klass;
|
||||
widget_class = (GtkWidgetClass*) klass;
|
||||
container_class = (GtkContainerClass*) klass;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
G_OBJECT_CLASS(object_class)->set_property = gtk_button_set_property;
|
||||
G_OBJECT_CLASS(object_class)->get_property = gtk_button_get_property;
|
||||
g_object_class->constructor = gtk_button_constructor;
|
||||
g_object_class->set_property = gtk_button_set_property;
|
||||
g_object_class->get_property = gtk_button_get_property;
|
||||
|
||||
widget_class->realize = gtk_button_realize;
|
||||
widget_class->unrealize = gtk_button_unrealize;
|
||||
@ -161,8 +167,6 @@ gtk_button_class_init (GtkButtonClass *klass)
|
||||
widget_class->enter_notify_event = gtk_button_enter_notify;
|
||||
widget_class->leave_notify_event = gtk_button_leave_notify;
|
||||
|
||||
container_class->add = gtk_button_add;
|
||||
container_class->remove = gtk_button_remove;
|
||||
container_class->child_type = gtk_button_child_type;
|
||||
|
||||
klass->pressed = gtk_real_button_pressed;
|
||||
@ -178,7 +182,23 @@ gtk_button_class_init (GtkButtonClass *klass)
|
||||
_("Label"),
|
||||
_("Text of the label widget inside the button, if the button contains a label widget."),
|
||||
NULL,
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (G_OBJECT_CLASS(object_class),
|
||||
PROP_USE_UNDERLINE,
|
||||
g_param_spec_boolean ("use_underline",
|
||||
_("Use underline"),
|
||||
_("If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key"),
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (G_OBJECT_CLASS(object_class),
|
||||
PROP_USE_STOCK,
|
||||
g_param_spec_boolean ("use_stock",
|
||||
_("Use stock"),
|
||||
_("If set, the label is used to pick a stock item instead of being displayed"),
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (G_OBJECT_CLASS(object_class),
|
||||
PROP_RELIEF,
|
||||
@ -270,13 +290,39 @@ gtk_button_init (GtkButton *button)
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_FOCUS | GTK_RECEIVES_DEFAULT);
|
||||
GTK_WIDGET_UNSET_FLAGS (button, GTK_NO_WINDOW);
|
||||
|
||||
button->child = NULL;
|
||||
button->label_text = NULL;
|
||||
|
||||
button->constructed = FALSE;
|
||||
button->in_button = FALSE;
|
||||
button->button_down = FALSE;
|
||||
button->relief = GTK_RELIEF_NORMAL;
|
||||
button->use_stock = FALSE;
|
||||
button->use_underline = FALSE;
|
||||
button->depressed = FALSE;
|
||||
}
|
||||
|
||||
static GObject*
|
||||
gtk_button_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_params)
|
||||
{
|
||||
GObject *object;
|
||||
GtkButton *button;
|
||||
|
||||
object = (* G_OBJECT_CLASS (parent_class)->constructor) (type,
|
||||
n_construct_properties,
|
||||
construct_params);
|
||||
|
||||
button = GTK_BUTTON (object);
|
||||
button->constructed = TRUE;
|
||||
|
||||
if (button->label_text != NULL)
|
||||
gtk_button_construct_child (button);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
static GtkType
|
||||
gtk_button_child_type (GtkContainer *container)
|
||||
{
|
||||
@ -298,24 +344,18 @@ gtk_button_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
case PROP_LABEL:
|
||||
child = GTK_BIN (button)->child;
|
||||
if (!child)
|
||||
child = gtk_widget_new (GTK_TYPE_LABEL,
|
||||
"visible", TRUE,
|
||||
"parent", button,
|
||||
NULL);
|
||||
if (GTK_IS_LABEL (child))
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (child),
|
||||
g_value_get_string (value) ? g_value_get_string (value) : "");
|
||||
}
|
||||
gtk_button_set_label (button, g_value_get_string (value));
|
||||
break;
|
||||
case PROP_RELIEF:
|
||||
gtk_button_set_relief (button, g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_USE_UNDERLINE:
|
||||
gtk_button_set_use_underline (button, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_USE_STOCK:
|
||||
gtk_button_set_use_stock (button, g_value_get_boolean (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -335,14 +375,17 @@ gtk_button_get_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_LABEL:
|
||||
if (GTK_BIN (button)->child && GTK_IS_LABEL (GTK_BIN (button)->child))
|
||||
g_value_set_string (value, GTK_LABEL (GTK_BIN (button)->child)->label);
|
||||
else
|
||||
g_value_set_string (value, NULL);
|
||||
g_value_set_string (value, button->label_text);
|
||||
break;
|
||||
case PROP_RELIEF:
|
||||
g_value_set_enum (value, gtk_button_get_relief (button));
|
||||
break;
|
||||
case PROP_USE_UNDERLINE:
|
||||
g_value_set_boolean (value, button->use_underline);
|
||||
break;
|
||||
case PROP_USE_STOCK:
|
||||
g_value_set_boolean (value, button->use_stock);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -355,20 +398,63 @@ gtk_button_new (void)
|
||||
return GTK_WIDGET (gtk_type_new (gtk_button_get_type ()));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_construct_child (GtkButton *button)
|
||||
{
|
||||
GtkStockItem item;
|
||||
GtkWidget *label;
|
||||
GtkWidget *image;
|
||||
GtkWidget *hbox;
|
||||
|
||||
if (!button->constructed)
|
||||
return;
|
||||
|
||||
if (button->label_text == NULL)
|
||||
return;
|
||||
|
||||
if (GTK_BIN (button)->child)
|
||||
gtk_container_remove (GTK_CONTAINER (button),
|
||||
GTK_BIN (button)->child);
|
||||
|
||||
|
||||
if (button->use_stock &&
|
||||
gtk_stock_lookup (button->label_text, &item))
|
||||
{
|
||||
label = gtk_label_new_with_mnemonic (item.label);
|
||||
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
|
||||
|
||||
image = gtk_image_new_from_stock (button->label_text, GTK_ICON_SIZE_BUTTON);
|
||||
hbox = gtk_hbox_new (FALSE, 1);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (button), hbox);
|
||||
gtk_widget_show_all (hbox);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (button->use_underline)
|
||||
{
|
||||
label = gtk_label_new_with_mnemonic (button->label_text);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
|
||||
}
|
||||
else
|
||||
label = gtk_label_new (button->label_text);
|
||||
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
|
||||
|
||||
gtk_widget_show (label);
|
||||
gtk_container_add (GTK_CONTAINER (button), label);
|
||||
}
|
||||
|
||||
|
||||
GtkWidget*
|
||||
gtk_button_new_with_label (const gchar *label)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkWidget *label_widget;
|
||||
|
||||
button = gtk_button_new ();
|
||||
label_widget = gtk_label_new (label);
|
||||
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.5, 0.5);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (button), label_widget);
|
||||
gtk_widget_show (label_widget);
|
||||
|
||||
return button;
|
||||
return g_object_new (GTK_TYPE_BUTTON, "label", label, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -383,36 +469,7 @@ gtk_button_new_with_label (const gchar *label)
|
||||
GtkWidget*
|
||||
gtk_button_new_from_stock (const gchar *stock_id)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkStockItem item;
|
||||
|
||||
if (gtk_stock_lookup (stock_id, &item))
|
||||
{
|
||||
GtkWidget *label;
|
||||
GtkWidget *image;
|
||||
GtkWidget *hbox;
|
||||
|
||||
button = gtk_button_new ();
|
||||
|
||||
label = gtk_label_new_with_mnemonic (item.label);
|
||||
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
|
||||
|
||||
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
|
||||
hbox = gtk_hbox_new (FALSE, 1);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (button), hbox);
|
||||
gtk_widget_show_all (hbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
button = gtk_button_new_with_mnemonic (stock_id);
|
||||
}
|
||||
|
||||
return button;
|
||||
return g_object_new (GTK_TYPE_BUTTON, "label", stock_id, "use_stock", TRUE, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -429,19 +486,7 @@ gtk_button_new_from_stock (const gchar *stock_id)
|
||||
GtkWidget*
|
||||
gtk_button_new_with_mnemonic (const gchar *label)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkWidget *label_widget;
|
||||
|
||||
button = gtk_button_new ();
|
||||
|
||||
label_widget = gtk_label_new_with_mnemonic (label);
|
||||
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label_widget), button);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (button), label_widget);
|
||||
gtk_widget_show (label_widget);
|
||||
|
||||
return button;
|
||||
return g_object_new (GTK_TYPE_BUTTON, "label", label, "use_underline", TRUE, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -934,32 +979,6 @@ gtk_button_leave_notify (GtkWidget *widget,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_add (GtkContainer *container,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (container != NULL);
|
||||
g_return_if_fail (widget != NULL);
|
||||
|
||||
if (GTK_CONTAINER_CLASS (parent_class)->add)
|
||||
GTK_CONTAINER_CLASS (parent_class)->add (container, widget);
|
||||
|
||||
GTK_BUTTON (container)->child = GTK_BIN (container)->child;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_remove (GtkContainer *container,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (container != NULL);
|
||||
g_return_if_fail (widget != NULL);
|
||||
|
||||
if (GTK_CONTAINER_CLASS (parent_class)->remove)
|
||||
GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
|
||||
|
||||
GTK_BUTTON (container)->child = GTK_BIN (container)->child;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_real_button_pressed (GtkButton *button)
|
||||
{
|
||||
@ -1041,6 +1060,140 @@ gtk_button_finish_activate (GtkButton *button,
|
||||
gtk_button_clicked (button);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_button_set_label:
|
||||
* @button: a #GtkButton
|
||||
* @label: a string
|
||||
*
|
||||
* Sets the text of the label of the button to @str. This text is
|
||||
* also used to select the stock item if gtk_button_set_use_stock()
|
||||
* is used.
|
||||
*
|
||||
* This will also clear any previously set labels.
|
||||
**/
|
||||
void
|
||||
gtk_button_set_label (GtkButton *button,
|
||||
const gchar *label)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_BUTTON (button));
|
||||
|
||||
g_free (button->label_text);
|
||||
button->label_text = g_strdup (label);
|
||||
|
||||
gtk_button_construct_child (button);
|
||||
|
||||
g_object_notify (G_OBJECT (button), "label");
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_button_get_label:
|
||||
* @button: a #GtkButton
|
||||
*
|
||||
* Fetches the text from the label of the button, as set by
|
||||
* gtk_button_set_label().
|
||||
*
|
||||
* Return value: the text of the label widget. This string is
|
||||
* owned by the widget and must not be modified or freed.
|
||||
* If the label text has not been set the return value
|
||||
* will be NULL. This will be the case if you create an
|
||||
* empty button with gtk_button_new() to use as a container.
|
||||
**/
|
||||
G_CONST_RETURN gchar *
|
||||
gtk_button_get_label (GtkButton *button)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
|
||||
|
||||
return button->label_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_button_set_use_underline:
|
||||
* @button: a #GtkButton
|
||||
* @use_underline: %TRUE if underlines in the text indicate mnemonics
|
||||
*
|
||||
* If true, an underline in the text of the button label indicates
|
||||
* the next character should be used for the mnemonic accelerator key.
|
||||
*/
|
||||
void
|
||||
gtk_button_set_use_underline (GtkButton *button,
|
||||
gboolean use_underline)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_BUTTON (button));
|
||||
|
||||
use_underline = use_underline != FALSE;
|
||||
|
||||
if (use_underline != button->use_underline)
|
||||
{
|
||||
button->use_underline = use_underline;
|
||||
|
||||
gtk_button_construct_child (button);
|
||||
|
||||
g_object_notify (G_OBJECT (button), "use_underline");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_button_get_use_underline:
|
||||
* @label: a #GtkButton
|
||||
*
|
||||
* Returns whether an embedded underline in the button label indicates a
|
||||
* mnemonic. See gtk_button_set_use_underline ().
|
||||
*
|
||||
* Return value: %TRUE if an embedded underline in the button label
|
||||
* indicates the mnemonic accelerator keys.
|
||||
**/
|
||||
gboolean
|
||||
gtk_button_get_use_underline (GtkButton *button)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_BUTTON (button), FALSE);
|
||||
|
||||
return button->use_underline;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_button_set_use_stock:
|
||||
* @button: a #GtkButton
|
||||
* @use_stock: %TRUE if the button should use a stock item
|
||||
*
|
||||
* If true, the label set on the button is used as a
|
||||
* stock id to select the stock item for the button.
|
||||
*/
|
||||
void
|
||||
gtk_button_set_use_stock (GtkButton *button,
|
||||
gboolean use_stock)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_BUTTON (button));
|
||||
|
||||
use_stock = use_stock != FALSE;
|
||||
|
||||
if (use_stock != button->use_stock)
|
||||
{
|
||||
button->use_stock = use_stock;
|
||||
|
||||
gtk_button_construct_child (button);
|
||||
|
||||
g_object_notify (G_OBJECT (button), "use_stock");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_button_get_use_stock:
|
||||
* @button: a #GtkButton
|
||||
*
|
||||
* Returns whether the button label is a stock item.
|
||||
*
|
||||
* Return value: %TRUE if the button label is used to
|
||||
* select a stock item instead of being
|
||||
* used directly as the label text.
|
||||
*/
|
||||
gboolean
|
||||
gtk_button_get_use_stock (GtkButton *button)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_BUTTON (button), FALSE);
|
||||
|
||||
return button->use_stock;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_button_set_depressed:
|
||||
* @button: a #GtkButton
|
||||
|
@ -52,15 +52,16 @@ struct _GtkButton
|
||||
{
|
||||
GtkBin bin;
|
||||
|
||||
GtkWidget *child /* deprecapted field,
|
||||
* use GTK_BIN (button)->child instead
|
||||
*/;
|
||||
gchar *label_text;
|
||||
|
||||
guint activate_timeout;
|
||||
|
||||
guint constructed : 1;
|
||||
guint in_button : 1;
|
||||
guint button_down : 1;
|
||||
guint relief : 2;
|
||||
guint use_underline : 1;
|
||||
guint use_stock : 1;
|
||||
guint depressed : 1;
|
||||
};
|
||||
|
||||
@ -90,8 +91,18 @@ void gtk_button_leave (GtkButton *button);
|
||||
void gtk_button_set_relief (GtkButton *button,
|
||||
GtkReliefStyle newstyle);
|
||||
GtkReliefStyle gtk_button_get_relief (GtkButton *button);
|
||||
void _gtk_button_set_depressed (GtkButton *button,
|
||||
gboolean depressed);
|
||||
|
||||
void gtk_button_set_label (GtkButton *button,
|
||||
const gchar *label);
|
||||
G_CONST_RETURN gchar *gtk_button_get_label (GtkButton *button);
|
||||
void gtk_button_set_use_underline (GtkButton *button,
|
||||
gboolean value);
|
||||
gboolean gtk_button_get_use_underline (GtkButton *button);
|
||||
void gtk_button_set_use_stock (GtkButton *button,
|
||||
gboolean value);
|
||||
gboolean gtk_button_get_use_stock (GtkButton *button);
|
||||
void _gtk_button_set_depressed (GtkButton *button,
|
||||
gboolean depressed);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -126,17 +126,7 @@ gtk_check_button_new (void)
|
||||
GtkWidget*
|
||||
gtk_check_button_new_with_label (const gchar *label)
|
||||
{
|
||||
GtkWidget *check_button;
|
||||
GtkWidget *label_widget;
|
||||
|
||||
check_button = gtk_check_button_new ();
|
||||
label_widget = gtk_label_new (label);
|
||||
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (check_button), label_widget);
|
||||
gtk_widget_show (label_widget);
|
||||
|
||||
return check_button;
|
||||
return g_object_new (GTK_TYPE_CHECK_BUTTON, "label", label, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,17 +142,7 @@ gtk_check_button_new_with_label (const gchar *label)
|
||||
GtkWidget*
|
||||
gtk_check_button_new_with_mnemonic (const gchar *label)
|
||||
{
|
||||
GtkWidget *check_button;
|
||||
GtkWidget *label_widget;
|
||||
|
||||
check_button = gtk_check_button_new ();
|
||||
label_widget = gtk_label_new_with_mnemonic (label);
|
||||
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (check_button), label_widget);
|
||||
gtk_widget_show (label_widget);
|
||||
|
||||
return check_button;
|
||||
return g_object_new (GTK_TYPE_CHECK_BUTTON, "label", label, "use_underline", TRUE, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -306,10 +286,11 @@ gtk_check_button_size_allocate (GtkWidget *widget,
|
||||
child_allocation.x = (border_width + indicator_size + indicator_spacing * 3 + 1 +
|
||||
widget->allocation.x);
|
||||
child_allocation.y = border_width + 1 + widget->allocation.y;
|
||||
child_allocation.width = MAX (1, allocation->width -
|
||||
(border_width + indicator_size + indicator_spacing * 3 + 1) -
|
||||
border_width - 1);
|
||||
child_allocation.height = MAX (1, allocation->height - (border_width + 1) * 2);
|
||||
child_allocation.width = MIN (GTK_BIN (button)->child->requisition.width,
|
||||
allocation->width -
|
||||
((border_width + 1) * 2 + indicator_size + indicator_spacing * 3));
|
||||
child_allocation.height = MIN (GTK_BIN (button)->child->requisition.height,
|
||||
allocation->height - (border_width + 1) * 2);
|
||||
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
||||
child_allocation.x = allocation->x + allocation->width
|
||||
|
@ -1572,7 +1572,7 @@ gtk_clist_get_column_widget (GtkCList *clist,
|
||||
return NULL;
|
||||
|
||||
if (clist->column[column].button)
|
||||
return GTK_BUTTON (clist->column[column].button)->child;
|
||||
return GTK_BIN (clist->column[column].button)->child;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2309,7 +2309,7 @@ gtk_label_set_use_underline (GtkLabel *label,
|
||||
* gtk_label_get_use_underline:
|
||||
* @label: a #GtkLabel
|
||||
*
|
||||
* Returns whether an embedded underline in thef label indicates a
|
||||
* Returns whether an embedded underline in the label indicates a
|
||||
* mnemonic. See gtk_label_set_use_underline ().
|
||||
*
|
||||
* Return value: %TRUE whether an embedded underline in the label indicates
|
||||
|
@ -216,14 +216,11 @@ gtk_radio_button_new_with_label (GSList *group,
|
||||
const gchar *label)
|
||||
{
|
||||
GtkWidget *radio_button;
|
||||
GtkWidget *label_widget;
|
||||
|
||||
radio_button = gtk_radio_button_new (group);
|
||||
label_widget = gtk_label_new (label);
|
||||
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5);
|
||||
radio_button = g_object_new (GTK_TYPE_CHECK_BUTTON, "label", label, NULL) ;
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (radio_button), label_widget);
|
||||
gtk_widget_show (label_widget);
|
||||
if (group)
|
||||
gtk_radio_button_set_group (radio_button, group);
|
||||
|
||||
return radio_button;
|
||||
}
|
||||
@ -245,14 +242,11 @@ gtk_radio_button_new_with_mnemonic (GSList *group,
|
||||
const gchar *label)
|
||||
{
|
||||
GtkWidget *radio_button;
|
||||
GtkWidget *label_widget;
|
||||
|
||||
radio_button = gtk_radio_button_new (group);
|
||||
label_widget = gtk_label_new_with_mnemonic (label);
|
||||
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5);
|
||||
radio_button = g_object_new (GTK_TYPE_CHECK_BUTTON, "label", label, "use_underline", TRUE, NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (radio_button), label_widget);
|
||||
gtk_widget_show (label_widget);
|
||||
if (group)
|
||||
gtk_radio_button_set_group (radio_button, group);
|
||||
|
||||
return radio_button;
|
||||
}
|
||||
|
@ -187,17 +187,7 @@ gtk_toggle_button_new (void)
|
||||
GtkWidget*
|
||||
gtk_toggle_button_new_with_label (const gchar *label)
|
||||
{
|
||||
GtkWidget *toggle_button;
|
||||
GtkWidget *label_widget;
|
||||
|
||||
toggle_button = gtk_toggle_button_new ();
|
||||
label_widget = gtk_label_new (label);
|
||||
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.5, 0.5);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (toggle_button), label_widget);
|
||||
gtk_widget_show (label_widget);
|
||||
|
||||
return toggle_button;
|
||||
return g_object_new (GTK_TYPE_TOGGLE_BUTTON, "label", label, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,17 +203,7 @@ gtk_toggle_button_new_with_label (const gchar *label)
|
||||
GtkWidget*
|
||||
gtk_toggle_button_new_with_mnemonic (const gchar *label)
|
||||
{
|
||||
GtkWidget *toggle_button;
|
||||
GtkWidget *label_widget;
|
||||
|
||||
toggle_button = gtk_toggle_button_new ();
|
||||
label_widget = gtk_label_new_with_mnemonic (label);
|
||||
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.5, 0.5);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (toggle_button), label_widget);
|
||||
gtk_widget_show (label_widget);
|
||||
|
||||
return toggle_button;
|
||||
return g_object_new (GTK_TYPE_TOGGLE_BUTTON, "label", label, "use_underline", TRUE, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user