[gtk+] Add a title property to GtkStatusIcon



commit 374aa049545516f1fd4dcdf43325fb992400129d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 20 13:53:32 2009 -0400

    Add a title property to GtkStatusIcon
    
    This can be used to give ATs a string to display for tray icons.
    See bug 585802.

 docs/reference/gtk/gtk-sections.txt |    2 +
 gtk/gtk.symbols                     |    2 +
 gtk/gtkstatusicon.c                 |   96 ++++++++++++++++++++++++++++++++++-
 gtk/gtkstatusicon.h                 |    3 +
 4 files changed, 102 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt
index 992f03d..3d93755 100644
--- a/docs/reference/gtk/gtk-sections.txt
+++ b/docs/reference/gtk/gtk-sections.txt
@@ -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
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index ac4fa2c..3fdbb67 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 3e89f53..f7fa009 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 19db689..e850c64 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]