Add a title property to GtkStatusIcon

This can be used to give ATs a string to display for tray icons.
See bug 585802.
This commit is contained in:
Matthias Clasen 2009-06-20 13:53:32 -04:00
parent 3d527afadb
commit 374aa04954
4 changed files with 102 additions and 1 deletions

View File

@ -3595,6 +3595,8 @@ gtk_status_icon_set_tooltip_markup
gtk_status_icon_get_tooltip_markup
gtk_status_icon_set_has_tooltip
gtk_status_icon_get_has_tooltip
gtk_status_icon_set_title
gtk_status_icon_get_title
gtk_status_icon_set_visible
gtk_status_icon_get_visible
gtk_status_icon_set_blinking

View File

@ -1213,6 +1213,8 @@ gtk_status_icon_is_embedded
gtk_status_icon_position_menu
gtk_status_icon_get_geometry
gtk_status_icon_get_x11_window_id
gtk_status_icon_get_title
gtk_status_icon_set_title
#endif
#endif

View File

@ -82,7 +82,8 @@ enum
PROP_BLINKING,
PROP_HAS_TOOLTIP,
PROP_TOOLTIP_TEXT,
PROP_TOOLTIP_MARKUP
PROP_TOOLTIP_MARKUP,
PROP_TITLE
};
enum
@ -116,12 +117,14 @@ struct _GtkStatusIconPrivate
gint last_click_x, last_click_y;
GtkOrientation orientation;
gchar *tooltip_text;
gchar *title;
#endif
#ifdef GDK_WINDOWING_QUARTZ
GtkWidget *dummy_widget;
GtkQuartzStatusIcon *status_item;
gchar *tooltip_text;
gchar *title;
#endif
gint size;
@ -402,6 +405,23 @@ gtk_status_icon_class_init (GtkStatusIconClass *class)
GTK_PARAM_READWRITE));
/**
* GtkStatusIcon:title:
*
* The title of this tray icon. This should be a short, human-readable,
* localized string describing the tray icon. It may be used by tools
* like screen readers to render the tray icon.
*
* Since: 2.18
*/
g_object_class_install_property (gobject_class,
PROP_TITLE,
g_param_spec_string ("title",
P_("Title"),
P_("The title of this tray icon"),
NULL,
GTK_PARAM_READWRITE));
/**
* GtkStatusIcon::activate:
* @status_icon: the object which received the signal
@ -1029,6 +1049,9 @@ gtk_status_icon_set_property (GObject *object,
case PROP_TOOLTIP_MARKUP:
gtk_status_icon_set_tooltip_markup (status_icon, g_value_get_string (value));
break;
case PROP_TITLE:
gtk_status_icon_set_title (status_icon, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1111,6 +1134,9 @@ gtk_status_icon_get_property (GObject *object,
case PROP_TOOLTIP_MARKUP:
g_value_set_string (value, gtk_status_icon_get_tooltip_markup (status_icon));
break;
case PROP_TITLE:
g_value_set_string (value, gtk_status_icon_get_title (status_icon));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -2871,5 +2897,73 @@ gtk_status_icon_get_x11_window_id (GtkStatusIcon *status_icon)
#endif
}
/**
* gtk_status_icon_set_title:
* @status_icon: a #GtkStatusIcon
* @title: the title
*
* Sets the title of this tray icon.
* This should be a short, human-readable, localized string
* describing the tray icon. It may be used by tools like screen
* readers to render the tray icon.
*
* Since: 2.18
*/
void
gtk_status_icon_set_title (GtkStatusIcon *status_icon,
const gchar *title)
{
GtkStatusIconPrivate *priv;
g_return_if_fail (GTK_IS_STATUS_ICON (status_icon));
priv = status_icon->priv;
#ifdef GDK_WINDOWING_X11
gtk_window_set_title (GTK_WINDOW (priv->tray_icon), title);
#endif
#ifdef GDK_WINDOWING_QUARTZ
g_free (priv->title);
priv->title = g_strdup (title);
#endif
#ifdef GDK_WINDOWING_WIN32
g_free (priv->title);
priv->title = g_strdup (title);
#endif
g_object_notify (G_OBJECT (status_icon), "title");
}
/**
* gtk_status_icon_get_title:
* @status_icon: a #GtkStatusIcon
*
* Gets the title of this tray icon. See gtk_status_icon_set_title().
*
* Returns: the title of the status icon
*
* Since: 2.18
*/
G_CONST_RETURN gchar *
gtk_status_icon_get_title (GtkStatusIcon *status_icon)
{
GtkStatusIconPrivate *priv;
g_return_if_fail (GTK_IS_STATUS_ICON (status_icon));
priv = status_icon->priv;
#ifdef GDK_WINDOWING_X11
return gtk_window_get_title (GTK_WINDOW (priv->tray_icon));
#endif
#ifdef GDK_WINDOWING_QUARTZ
return priv->title;
#endif
#ifdef GDK_WINDOWING_WIN32
return priv->title;
#endif
}
#define __GTK_STATUS_ICON_C__
#include "gtkaliasdef.c"

View File

@ -120,6 +120,9 @@ void gtk_status_icon_set_tooltip_text (GtkStatusIcon *st
const gchar *text);
void gtk_status_icon_set_tooltip_markup (GtkStatusIcon *status_icon,
const gchar *markup);
void gtk_status_icon_set_title (GtkStatusIcon *status_icon,
const gchar *title);
G_CONST_RETURN gchar *gtk_status_icon_get_title (GtkStatusIcon *status_icon);
void gtk_status_icon_set_visible (GtkStatusIcon *status_icon,
gboolean visible);
gboolean gtk_status_icon_get_visible (GtkStatusIcon *status_icon);