summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2009-06-20 13:53:32 -0400
committerMatthias Clasen <mclasen@redhat.com>2009-06-20 13:53:32 -0400
commit374aa049545516f1fd4dcdf43325fb992400129d (patch)
tree2b1e0e34cc0e4a5bfe417562b4595a42115905bb /gtk
parent3d527afadb802c9027365480023f8aeda18e7ad7 (diff)
downloadgtk+-374aa049545516f1fd4dcdf43325fb992400129d.tar.gz
Add a title property to GtkStatusIcon
This can be used to give ATs a string to display for tray icons. See bug 585802.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtk.symbols2
-rw-r--r--gtk/gtkstatusicon.c96
-rwxr-xr-xgtk/gtkstatusicon.h3
3 files changed, 100 insertions, 1 deletions
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index ac4fa2cf72..3fdbb67703 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -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
diff --git a/gtk/gtkstatusicon.c b/gtk/gtkstatusicon.c
index 3e89f5362c..f7fa009010 100644
--- a/gtk/gtkstatusicon.c
+++ b/gtk/gtkstatusicon.c
@@ -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;
@@ -403,6 +406,23 @@ gtk_status_icon_class_init (GtkStatusIconClass *class)
/**
+ * 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"
diff --git a/gtk/gtkstatusicon.h b/gtk/gtkstatusicon.h
index 19db689a30..e850c64c79 100755
--- a/gtk/gtkstatusicon.h
+++ b/gtk/gtkstatusicon.h
@@ -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);