forked from AuroraMiddleware/gtk
Fixes for #82099:
Thu Feb 19 23:41:06 2004 Matthias Clasen <maclas@gmx.de> Fixes for #82099: * gdk/x11/gdkevents-x11.c: Introduce new XSettings "Gtk/ButtonImages" and "Gtk/MenuImages" and map them to "gtk-button-images" and "gtk-menu-images". * gtk/gtkimagemenuitem.c: Add a boolean setting "gtk-menu-images" and use it to set the visibility of the embedded image. * gtk/gtkbutton.c: Add a boolean setting "gtk-button-images" and use it to set the visibility of an embedded image.
This commit is contained in:
parent
bce0b90f7c
commit
add52ebbbf
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
Thu Feb 19 23:41:06 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Fixes for #82099:
|
||||
|
||||
* gdk/x11/gdkevents-x11.c: Introduce new XSettings "Gtk/ButtonImages"
|
||||
and "Gtk/MenuImages" and map them to "gtk-button-images" and
|
||||
"gtk-menu-images".
|
||||
|
||||
* gtk/gtkimagemenuitem.c: Add a boolean setting "gtk-menu-images" and use
|
||||
it to set the visibility of the embedded image.
|
||||
|
||||
* gtk/gtkbutton.c: Add a boolean setting "gtk-button-images" and use
|
||||
it to set the visibility of an embedded image.
|
||||
|
||||
Thu Feb 19 21:26:10 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full):
|
||||
|
@ -1,3 +1,17 @@
|
||||
Thu Feb 19 23:41:06 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Fixes for #82099:
|
||||
|
||||
* gdk/x11/gdkevents-x11.c: Introduce new XSettings "Gtk/ButtonImages"
|
||||
and "Gtk/MenuImages" and map them to "gtk-button-images" and
|
||||
"gtk-menu-images".
|
||||
|
||||
* gtk/gtkimagemenuitem.c: Add a boolean setting "gtk-menu-images" and use
|
||||
it to set the visibility of the embedded image.
|
||||
|
||||
* gtk/gtkbutton.c: Add a boolean setting "gtk-button-images" and use
|
||||
it to set the visibility of an embedded image.
|
||||
|
||||
Thu Feb 19 21:26:10 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full):
|
||||
|
@ -1,3 +1,17 @@
|
||||
Thu Feb 19 23:41:06 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Fixes for #82099:
|
||||
|
||||
* gdk/x11/gdkevents-x11.c: Introduce new XSettings "Gtk/ButtonImages"
|
||||
and "Gtk/MenuImages" and map them to "gtk-button-images" and
|
||||
"gtk-menu-images".
|
||||
|
||||
* gtk/gtkimagemenuitem.c: Add a boolean setting "gtk-menu-images" and use
|
||||
it to set the visibility of the embedded image.
|
||||
|
||||
* gtk/gtkbutton.c: Add a boolean setting "gtk-button-images" and use
|
||||
it to set the visibility of an embedded image.
|
||||
|
||||
Thu Feb 19 21:26:10 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full):
|
||||
|
@ -1,3 +1,17 @@
|
||||
Thu Feb 19 23:41:06 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Fixes for #82099:
|
||||
|
||||
* gdk/x11/gdkevents-x11.c: Introduce new XSettings "Gtk/ButtonImages"
|
||||
and "Gtk/MenuImages" and map them to "gtk-button-images" and
|
||||
"gtk-menu-images".
|
||||
|
||||
* gtk/gtkimagemenuitem.c: Add a boolean setting "gtk-menu-images" and use
|
||||
it to set the visibility of the embedded image.
|
||||
|
||||
* gtk/gtkbutton.c: Add a boolean setting "gtk-button-images" and use
|
||||
it to set the visibility of an embedded image.
|
||||
|
||||
Thu Feb 19 21:26:10 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full):
|
||||
|
@ -1,3 +1,17 @@
|
||||
Thu Feb 19 23:41:06 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
Fixes for #82099:
|
||||
|
||||
* gdk/x11/gdkevents-x11.c: Introduce new XSettings "Gtk/ButtonImages"
|
||||
and "Gtk/MenuImages" and map them to "gtk-button-images" and
|
||||
"gtk-menu-images".
|
||||
|
||||
* gtk/gtkimagemenuitem.c: Add a boolean setting "gtk-menu-images" and use
|
||||
it to set the visibility of the embedded image.
|
||||
|
||||
* gtk/gtkbutton.c: Add a boolean setting "gtk-button-images" and use
|
||||
it to set the visibility of an embedded image.
|
||||
|
||||
Thu Feb 19 21:26:10 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full):
|
||||
|
@ -2627,6 +2627,8 @@ static struct
|
||||
{ "Net/CursorBlinkTime", "gtk-cursor-blink-time" },
|
||||
{ "Net/ThemeName", "gtk-theme-name" },
|
||||
{ "Net/IconThemeName", "gtk-icon-theme-name" },
|
||||
{ "Gtk/ButtonImages", "gtk-button-images" },
|
||||
{ "Gtk/MenuImages", "gtk-menu-images" },
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -41,7 +41,7 @@
|
||||
static const GtkBorder default_default_border = { 1, 1, 1, 1 };
|
||||
static const GtkBorder default_default_outside_border = { 0, 0, 0, 0 };
|
||||
|
||||
/* Time out before giving up on getting a key release when animatng
|
||||
/* Time out before giving up on getting a key release when animating
|
||||
* the close button.
|
||||
*/
|
||||
#define ACTIVATE_TIMEOUT 250
|
||||
@ -72,8 +72,11 @@ typedef struct _GtkButtonPrivate GtkButtonPrivate;
|
||||
|
||||
struct _GtkButtonPrivate
|
||||
{
|
||||
gfloat xalign;
|
||||
gfloat yalign;
|
||||
gfloat xalign;
|
||||
gfloat yalign;
|
||||
GtkSettings *settings;
|
||||
guint show_image_connection;
|
||||
GtkWidget *image;
|
||||
};
|
||||
|
||||
static void gtk_button_class_init (GtkButtonClass *klass);
|
||||
@ -87,6 +90,8 @@ static void gtk_button_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_button_screen_changed (GtkWidget *widget,
|
||||
GdkScreen *previous_screen);
|
||||
static void gtk_button_realize (GtkWidget *widget);
|
||||
static void gtk_button_unrealize (GtkWidget *widget);
|
||||
static void gtk_button_map (GtkWidget *widget);
|
||||
@ -120,7 +125,7 @@ static void gtk_button_finish_activate (GtkButton *button,
|
||||
static GObject* gtk_button_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_params);
|
||||
static void gtk_button_construct_child (GtkButton *button);
|
||||
static void gtk_button_construct_child (GtkButton *button);
|
||||
|
||||
|
||||
static GtkBinClass *parent_class = NULL;
|
||||
@ -175,6 +180,7 @@ gtk_button_class_init (GtkButtonClass *klass)
|
||||
|
||||
object_class->destroy = gtk_button_destroy;
|
||||
|
||||
widget_class->screen_changed = gtk_button_screen_changed;
|
||||
widget_class->realize = gtk_button_realize;
|
||||
widget_class->unrealize = gtk_button_unrealize;
|
||||
widget_class->map = gtk_button_map;
|
||||
@ -365,6 +371,12 @@ gtk_button_class_init (GtkButtonClass *klass)
|
||||
0,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gtk_settings_install_property (g_param_spec_boolean ("gtk-button-images",
|
||||
P_("Show button images"),
|
||||
P_("Whether stock icons should be shown in buttons"),
|
||||
TRUE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_type_class_add_private (gobject_class, sizeof (GtkButtonPrivate));
|
||||
}
|
||||
|
||||
@ -547,15 +559,25 @@ gtk_button_new (void)
|
||||
return g_object_new (GTK_TYPE_BUTTON, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
show_image (GtkButton *button)
|
||||
{
|
||||
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (button));
|
||||
gboolean show;
|
||||
|
||||
g_object_get (settings, "gtk-button-images", &show, NULL);
|
||||
|
||||
return show;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_construct_child (GtkButton *button)
|
||||
{
|
||||
GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (button);
|
||||
GtkStockItem item;
|
||||
GtkWidget *label;
|
||||
GtkWidget *image;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *align;
|
||||
GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (button);
|
||||
|
||||
if (!button->constructed)
|
||||
return;
|
||||
@ -574,12 +596,16 @@ gtk_button_construct_child (GtkButton *button)
|
||||
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
|
||||
|
||||
image = gtk_image_new_from_stock (button->label_text, GTK_ICON_SIZE_BUTTON);
|
||||
priv->image = gtk_image_new_from_stock (button->label_text, GTK_ICON_SIZE_BUTTON);
|
||||
g_object_set (priv->image,
|
||||
"visible", show_image (button),
|
||||
"no_show_all", TRUE,
|
||||
NULL);
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
|
||||
align = gtk_alignment_new (priv->xalign, priv->yalign, 0.0, 0.0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), priv->image, FALSE, FALSE, 0);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (button), align);
|
||||
@ -657,6 +683,7 @@ gtk_button_pressed (GtkButton *button)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_BUTTON (button));
|
||||
|
||||
|
||||
g_signal_emit (button, button_signals[PRESSED], 0);
|
||||
}
|
||||
|
||||
@ -1513,3 +1540,50 @@ gtk_button_update_state (GtkButton *button)
|
||||
_gtk_button_set_depressed (button, depressed);
|
||||
gtk_widget_set_state (GTK_WIDGET (button), new_state);
|
||||
}
|
||||
|
||||
static void
|
||||
show_image_change_notify (GtkButton *button)
|
||||
{
|
||||
GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (button);
|
||||
|
||||
if (priv->image)
|
||||
g_object_set (priv->image, "visible", show_image (button), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_screen_changed (GtkWidget *widget,
|
||||
GdkScreen *previous_screen)
|
||||
{
|
||||
GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (widget);
|
||||
GtkSettings *settings;
|
||||
|
||||
if (gtk_widget_has_screen (widget))
|
||||
settings = gtk_widget_get_settings (widget);
|
||||
else
|
||||
settings = NULL;
|
||||
|
||||
if (settings == priv->settings)
|
||||
return;
|
||||
|
||||
if (priv->settings)
|
||||
{
|
||||
g_signal_handler_disconnect (priv->settings, priv->show_image_connection);
|
||||
g_object_unref (priv->settings);
|
||||
}
|
||||
|
||||
if (settings)
|
||||
{
|
||||
priv->show_image_connection =
|
||||
g_signal_connect_swapped (settings,
|
||||
"notify::gtk-button-images",
|
||||
G_CALLBACK (show_image_change_notify),
|
||||
widget);
|
||||
|
||||
g_object_ref (settings);
|
||||
priv->settings = settings;
|
||||
}
|
||||
else
|
||||
priv->settings = NULL;
|
||||
|
||||
show_image_change_notify (GTK_BUTTON (widget));
|
||||
}
|
||||
|
@ -31,6 +31,16 @@
|
||||
#include "gtkiconfactory.h"
|
||||
#include "gtkimage.h"
|
||||
|
||||
typedef struct _GtkImageMenuItemPrivate GtkImageMenuItemPrivate;
|
||||
|
||||
struct _GtkImageMenuItemPrivate
|
||||
{
|
||||
GtkSettings *settings;
|
||||
guint show_image_connection;
|
||||
};
|
||||
|
||||
#define GTK_IMAGE_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_IMAGE_MENU_ITEM, GtkImageMenuItemPrivate))
|
||||
|
||||
static void gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass);
|
||||
static void gtk_image_menu_item_init (GtkImageMenuItem *image_menu_item);
|
||||
static void gtk_image_menu_item_size_request (GtkWidget *widget,
|
||||
@ -55,6 +65,8 @@ static void gtk_image_menu_item_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_image_menu_item_screen_changed (GtkWidget *widget,
|
||||
GdkScreen *previous_screen);
|
||||
|
||||
|
||||
enum {
|
||||
@ -107,6 +119,7 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
widget_class->screen_changed = gtk_image_menu_item_screen_changed;
|
||||
widget_class->size_request = gtk_image_menu_item_size_request;
|
||||
widget_class->size_allocate = gtk_image_menu_item_size_allocate;
|
||||
|
||||
@ -125,6 +138,14 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
|
||||
P_("Child widget to appear next to the menu text"),
|
||||
GTK_TYPE_WIDGET,
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
|
||||
gtk_settings_install_property (g_param_spec_boolean ("gtk-menu-images",
|
||||
P_("Show menu images"),
|
||||
P_("Whether images should be shown in menus"),
|
||||
TRUE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_type_class_add_private (gobject_class, sizeof (GtkImageMenuItemPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -177,6 +198,16 @@ gtk_image_menu_item_get_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
show_image (GtkImageMenuItem *image_menu_item)
|
||||
{
|
||||
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (image_menu_item));
|
||||
gboolean show;
|
||||
|
||||
g_object_get (settings, "gtk-menu-images", &show, NULL);
|
||||
|
||||
return show;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
||||
@ -186,7 +217,7 @@ gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
||||
|
||||
*requisition = 0;
|
||||
|
||||
if (image_menu_item->image)
|
||||
if (image_menu_item->image && show_image (image_menu_item))
|
||||
{
|
||||
guint image_width = image_menu_item->image->requisition.width;
|
||||
|
||||
@ -212,7 +243,9 @@ gtk_image_menu_item_size_request (GtkWidget *widget,
|
||||
|
||||
image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
|
||||
|
||||
if (image_menu_item->image && GTK_WIDGET_VISIBLE (image_menu_item->image))
|
||||
if (image_menu_item->image &&
|
||||
GTK_WIDGET_VISIBLE (image_menu_item->image) &&
|
||||
show_image (image_menu_item))
|
||||
{
|
||||
GtkRequisition child_requisition;
|
||||
|
||||
@ -245,7 +278,7 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
|
||||
|
||||
(* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
|
||||
|
||||
if (image_menu_item->image)
|
||||
if (image_menu_item->image && show_image (image_menu_item))
|
||||
{
|
||||
gint width, height, x, y, offset;
|
||||
GtkAllocation child_allocation;
|
||||
@ -456,6 +489,10 @@ gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
|
||||
return;
|
||||
|
||||
gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item));
|
||||
g_object_set (image,
|
||||
"visible", show_image (image_menu_item),
|
||||
"no_show_all", TRUE,
|
||||
NULL);
|
||||
|
||||
g_object_notify (G_OBJECT (image_menu_item), "image");
|
||||
}
|
||||
@ -504,4 +541,47 @@ gtk_image_menu_item_remove (GtkContainer *container,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
show_image_change_notify (GtkImageMenuItem *image_menu_item)
|
||||
{
|
||||
if (image_menu_item->image)
|
||||
g_object_set (image_menu_item->image, "visible", show_image (image_menu_item), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_image_menu_item_screen_changed (GtkWidget *widget,
|
||||
GdkScreen *previous_screen)
|
||||
{
|
||||
GtkImageMenuItemPrivate *priv = GTK_IMAGE_MENU_ITEM_GET_PRIVATE (widget);
|
||||
GtkSettings *settings;
|
||||
|
||||
if (gtk_widget_has_screen (widget))
|
||||
settings = gtk_widget_get_settings (widget);
|
||||
else
|
||||
settings = NULL;
|
||||
|
||||
if (settings == priv->settings)
|
||||
return;
|
||||
|
||||
if (priv->settings)
|
||||
{
|
||||
g_signal_handler_disconnect (priv->settings, priv->show_image_connection);
|
||||
g_object_unref (priv->settings);
|
||||
}
|
||||
|
||||
if (settings)
|
||||
{
|
||||
priv->show_image_connection =
|
||||
g_signal_connect_swapped (settings,
|
||||
"notify::gtk-menu-images",
|
||||
G_CALLBACK (show_image_change_notify),
|
||||
widget);
|
||||
|
||||
g_object_ref (settings);
|
||||
priv->settings = settings;
|
||||
}
|
||||
else
|
||||
priv->settings = NULL;
|
||||
|
||||
show_image_change_notify (GTK_IMAGE_MENU_ITEM (widget));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user