forked from AuroraMiddleware/gtk
Add an image property
This commit is contained in:
parent
5c53411e77
commit
7f371df51a
@ -1,3 +1,8 @@
|
|||||||
|
2006-05-09 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtk.symbols:
|
||||||
|
* gtk/gtkmessagedialog.[hc]: Add an image property. (#337306, Alex Graveley)
|
||||||
|
|
||||||
2006-05-09 Carlos Garnacho <carlosg@gnome.org>
|
2006-05-09 Carlos Garnacho <carlosg@gnome.org>
|
||||||
|
|
||||||
* gtk/gtknotebook.c: create an independent GdkWindow to behave nicely
|
* gtk/gtknotebook.c: create an independent GdkWindow to behave nicely
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2006-05-09 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtk.symbols:
|
||||||
|
* gtk/gtkmessagedialog.[hc]: Add an image property. (#337306, Alex Graveley)
|
||||||
|
|
||||||
2006-05-09 Carlos Garnacho <carlosg@gnome.org>
|
2006-05-09 Carlos Garnacho <carlosg@gnome.org>
|
||||||
|
|
||||||
* gtk/gtknotebook.c: create an independent GdkWindow to behave nicely
|
* gtk/gtknotebook.c: create an independent GdkWindow to behave nicely
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2006-05-09 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtk-sections.txt: Add gtk_message_dialog_set_image.
|
||||||
|
|
||||||
2006-05-08 Matthias Clasen <mclasen@redhat.com>
|
2006-05-08 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* gtk/question_index.sgml (reference): Update the internationalization
|
* gtk/question_index.sgml (reference): Update the internationalization
|
||||||
|
@ -2323,6 +2323,7 @@ GtkButtonsType
|
|||||||
gtk_message_dialog_new
|
gtk_message_dialog_new
|
||||||
gtk_message_dialog_new_with_markup
|
gtk_message_dialog_new_with_markup
|
||||||
gtk_message_dialog_set_markup
|
gtk_message_dialog_set_markup
|
||||||
|
gtk_message_dialog_set_image
|
||||||
gtk_message_dialog_format_secondary_text
|
gtk_message_dialog_format_secondary_text
|
||||||
gtk_message_dialog_format_secondary_markup
|
gtk_message_dialog_format_secondary_markup
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
|
@ -2301,6 +2301,7 @@ gtk_message_dialog_get_type G_GNUC_CONST
|
|||||||
gtk_message_dialog_new G_GNUC_PRINTF(5,6)
|
gtk_message_dialog_new G_GNUC_PRINTF(5,6)
|
||||||
gtk_message_dialog_new_with_markup G_GNUC_PRINTF(5,6)
|
gtk_message_dialog_new_with_markup G_GNUC_PRINTF(5,6)
|
||||||
gtk_message_dialog_set_markup
|
gtk_message_dialog_set_markup
|
||||||
|
gtk_message_dialog_set_image
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -46,8 +46,9 @@ typedef struct _GtkMessageDialogPrivate GtkMessageDialogPrivate;
|
|||||||
struct _GtkMessageDialogPrivate
|
struct _GtkMessageDialogPrivate
|
||||||
{
|
{
|
||||||
GtkWidget *secondary_label;
|
GtkWidget *secondary_label;
|
||||||
gboolean has_primary_markup;
|
guint message_type : 3;
|
||||||
gboolean has_secondary_text;
|
guint has_primary_markup : 1;
|
||||||
|
guint has_secondary_text : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gtk_message_dialog_style_set (GtkWidget *widget,
|
static void gtk_message_dialog_style_set (GtkWidget *widget,
|
||||||
@ -71,7 +72,8 @@ enum {
|
|||||||
PROP_TEXT,
|
PROP_TEXT,
|
||||||
PROP_USE_MARKUP,
|
PROP_USE_MARKUP,
|
||||||
PROP_SECONDARY_TEXT,
|
PROP_SECONDARY_TEXT,
|
||||||
PROP_SECONDARY_USE_MARKUP
|
PROP_SECONDARY_USE_MARKUP,
|
||||||
|
PROP_IMAGE
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (GtkMessageDialog, gtk_message_dialog, GTK_TYPE_DIALOG);
|
G_DEFINE_TYPE (GtkMessageDialog, gtk_message_dialog, GTK_TYPE_DIALOG);
|
||||||
@ -99,7 +101,7 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
|
|||||||
12,
|
12,
|
||||||
GTK_PARAM_READABLE));
|
GTK_PARAM_READABLE));
|
||||||
/**
|
/**
|
||||||
* GtkMessageDialog::use_separator
|
* GtkMessageDialog:use-separator:
|
||||||
*
|
*
|
||||||
* Whether to draw a separator line between the message label and the buttons
|
* Whether to draw a separator line between the message label and the buttons
|
||||||
* in the dialog.
|
* in the dialog.
|
||||||
@ -112,6 +114,13 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
|
|||||||
P_("Whether to put a separator between the message dialog's text and the buttons"),
|
P_("Whether to put a separator between the message dialog's text and the buttons"),
|
||||||
FALSE,
|
FALSE,
|
||||||
GTK_PARAM_READABLE));
|
GTK_PARAM_READABLE));
|
||||||
|
/**
|
||||||
|
* GtkMessageDialog:message-type:
|
||||||
|
*
|
||||||
|
* The type of the message. The type is used to determine
|
||||||
|
* the image that is shown in the dialog, unless the image is
|
||||||
|
* explicitly set by the ::image property.
|
||||||
|
*/
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_MESSAGE_TYPE,
|
PROP_MESSAGE_TYPE,
|
||||||
g_param_spec_enum ("message-type",
|
g_param_spec_enum ("message-type",
|
||||||
@ -192,6 +201,21 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
|
|||||||
FALSE,
|
FALSE,
|
||||||
GTK_PARAM_READWRITE));
|
GTK_PARAM_READWRITE));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GtkMessageDialog:image:
|
||||||
|
*
|
||||||
|
* The image for this dialog.
|
||||||
|
*
|
||||||
|
* Since: 2.10
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_IMAGE,
|
||||||
|
g_param_spec_object ("image",
|
||||||
|
P_("Image"),
|
||||||
|
P_("The image"),
|
||||||
|
GTK_TYPE_WIDGET,
|
||||||
|
GTK_PARAM_READWRITE));
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class,
|
g_type_class_add_private (gobject_class,
|
||||||
sizeof (GtkMessageDialogPrivate));
|
sizeof (GtkMessageDialogPrivate));
|
||||||
}
|
}
|
||||||
@ -255,35 +279,6 @@ gtk_message_dialog_init (GtkMessageDialog *dialog)
|
|||||||
_gtk_dialog_set_ignore_separator (GTK_DIALOG (dialog), TRUE);
|
_gtk_dialog_set_ignore_separator (GTK_DIALOG (dialog), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkMessageType
|
|
||||||
gtk_message_dialog_get_message_type (GtkMessageDialog *dialog)
|
|
||||||
{
|
|
||||||
const gchar* stock_id = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_MESSAGE_DIALOG (dialog), GTK_MESSAGE_INFO);
|
|
||||||
g_return_val_if_fail (GTK_IS_IMAGE(dialog->image), GTK_MESSAGE_INFO);
|
|
||||||
|
|
||||||
stock_id = GTK_IMAGE(dialog->image)->data.stock.stock_id;
|
|
||||||
|
|
||||||
/* Look at the stock id of the image to guess the
|
|
||||||
* GtkMessageType value that was used to choose it
|
|
||||||
* in setup_type()
|
|
||||||
*/
|
|
||||||
if (strcmp (stock_id, GTK_STOCK_DIALOG_INFO) == 0)
|
|
||||||
return GTK_MESSAGE_INFO;
|
|
||||||
else if (strcmp (stock_id, GTK_STOCK_DIALOG_QUESTION) == 0)
|
|
||||||
return GTK_MESSAGE_QUESTION;
|
|
||||||
else if (strcmp (stock_id, GTK_STOCK_DIALOG_WARNING) == 0)
|
|
||||||
return GTK_MESSAGE_WARNING;
|
|
||||||
else if (strcmp (stock_id, GTK_STOCK_DIALOG_ERROR) == 0)
|
|
||||||
return GTK_MESSAGE_ERROR;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_assert_not_reached ();
|
|
||||||
return GTK_MESSAGE_INFO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_primary_label_font (GtkMessageDialog *dialog)
|
setup_primary_label_font (GtkMessageDialog *dialog)
|
||||||
{
|
{
|
||||||
@ -311,8 +306,10 @@ static void
|
|||||||
setup_type (GtkMessageDialog *dialog,
|
setup_type (GtkMessageDialog *dialog,
|
||||||
GtkMessageType type)
|
GtkMessageType type)
|
||||||
{
|
{
|
||||||
|
GtkMessageDialogPrivate *priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (dialog);
|
||||||
const gchar *stock_id = NULL;
|
const gchar *stock_id = NULL;
|
||||||
GtkStockItem item;
|
|
||||||
|
priv->message_type = type;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@ -332,19 +329,17 @@ setup_type (GtkMessageDialog *dialog,
|
|||||||
stock_id = GTK_STOCK_DIALOG_ERROR;
|
stock_id = GTK_STOCK_DIALOG_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GTK_MESSAGE_OTHER:
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
g_warning ("Unknown GtkMessageType %d", type);
|
g_warning ("Unknown GtkMessageType %d", type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stock_id == NULL)
|
if (stock_id)
|
||||||
stock_id = GTK_STOCK_DIALOG_INFO;
|
|
||||||
|
|
||||||
if (gtk_stock_lookup (stock_id, &item))
|
|
||||||
gtk_image_set_from_stock (GTK_IMAGE (dialog->image), stock_id,
|
gtk_image_set_from_stock (GTK_IMAGE (dialog->image), stock_id,
|
||||||
GTK_ICON_SIZE_DIALOG);
|
GTK_ICON_SIZE_DIALOG);
|
||||||
else
|
|
||||||
g_warning ("Stock dialog ID doesn't exist?");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -376,7 +371,7 @@ gtk_message_dialog_set_property (GObject *object,
|
|||||||
g_value_get_string (value));
|
g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
case PROP_USE_MARKUP:
|
case PROP_USE_MARKUP:
|
||||||
priv->has_primary_markup = g_value_get_boolean (value);
|
priv->has_primary_markup = g_value_get_boolean (value) != FALSE;
|
||||||
gtk_label_set_use_markup (GTK_LABEL (dialog->label),
|
gtk_label_set_use_markup (GTK_LABEL (dialog->label),
|
||||||
priv->has_primary_markup);
|
priv->has_primary_markup);
|
||||||
setup_primary_label_font (dialog);
|
setup_primary_label_font (dialog);
|
||||||
@ -407,6 +402,9 @@ gtk_message_dialog_set_property (GObject *object,
|
|||||||
gtk_label_set_use_markup (GTK_LABEL (priv->secondary_label),
|
gtk_label_set_use_markup (GTK_LABEL (priv->secondary_label),
|
||||||
g_value_get_boolean (value));
|
g_value_get_boolean (value));
|
||||||
break;
|
break;
|
||||||
|
case PROP_IMAGE:
|
||||||
|
gtk_message_dialog_set_image (dialog, (GtkWidget *)g_value_get_object (value));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -429,7 +427,7 @@ gtk_message_dialog_get_property (GObject *object,
|
|||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_MESSAGE_TYPE:
|
case PROP_MESSAGE_TYPE:
|
||||||
g_value_set_enum (value, gtk_message_dialog_get_message_type (dialog));
|
g_value_set_enum (value, (GtkMessageType) priv->message_type);
|
||||||
break;
|
break;
|
||||||
case PROP_TEXT:
|
case PROP_TEXT:
|
||||||
g_value_set_string (value, gtk_label_get_label (GTK_LABEL (dialog->label)));
|
g_value_set_string (value, gtk_label_get_label (GTK_LABEL (dialog->label)));
|
||||||
@ -451,6 +449,9 @@ gtk_message_dialog_get_property (GObject *object,
|
|||||||
else
|
else
|
||||||
g_value_set_boolean (value, FALSE);
|
g_value_set_boolean (value, FALSE);
|
||||||
break;
|
break;
|
||||||
|
case PROP_IMAGE:
|
||||||
|
g_value_set_object (value, dialog->image);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -596,6 +597,38 @@ gtk_message_dialog_new_with_markup (GtkWindow *parent,
|
|||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_message_dialog_set_image:
|
||||||
|
* @dialog: a #GtkMessageDialog
|
||||||
|
* @image: the image
|
||||||
|
*
|
||||||
|
* Sets the dialog's image to @image.
|
||||||
|
*
|
||||||
|
* Since: 2.10
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gtk_message_dialog_set_image (GtkMessageDialog *dialog,
|
||||||
|
GtkWidget *image)
|
||||||
|
{
|
||||||
|
GtkMessageDialogPrivate *priv;
|
||||||
|
GtkWidget *parent;
|
||||||
|
|
||||||
|
g_return_if_fail (GTK_IS_MESSAGE_DIALOG (dialog));
|
||||||
|
|
||||||
|
priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (dialog);
|
||||||
|
|
||||||
|
priv->message_type = GTK_MESSAGE_OTHER;
|
||||||
|
|
||||||
|
parent = dialog->image->parent;
|
||||||
|
gtk_container_add (GTK_CONTAINER (parent), image);
|
||||||
|
gtk_container_remove (GTK_CONTAINER (parent), dialog->image);
|
||||||
|
gtk_box_reorder_child (GTK_BOX (parent), image, 0);
|
||||||
|
|
||||||
|
dialog->image = image;
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (dialog), "image");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_message_dialog_set_markup:
|
* gtk_message_dialog_set_markup:
|
||||||
* @message_dialog: a #GtkMessageDialog
|
* @message_dialog: a #GtkMessageDialog
|
||||||
|
@ -37,7 +37,8 @@ typedef enum
|
|||||||
GTK_MESSAGE_INFO,
|
GTK_MESSAGE_INFO,
|
||||||
GTK_MESSAGE_WARNING,
|
GTK_MESSAGE_WARNING,
|
||||||
GTK_MESSAGE_QUESTION,
|
GTK_MESSAGE_QUESTION,
|
||||||
GTK_MESSAGE_ERROR
|
GTK_MESSAGE_ERROR,
|
||||||
|
GTK_MESSAGE_OTHER
|
||||||
} GtkMessageType;
|
} GtkMessageType;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
@ -97,6 +98,9 @@ GtkWidget* gtk_message_dialog_new_with_markup (GtkWindow *parent,
|
|||||||
const gchar *message_format,
|
const gchar *message_format,
|
||||||
...) G_GNUC_PRINTF (5, 6);
|
...) G_GNUC_PRINTF (5, 6);
|
||||||
|
|
||||||
|
void gtk_message_dialog_set_image (GtkMessageDialog *dialog,
|
||||||
|
GtkWidget *image);
|
||||||
|
|
||||||
void gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
|
void gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
|
||||||
const gchar *str);
|
const gchar *str);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user