]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfontsel.c
Bug 534979 – GtkImageMenuItem is a bin but has two children.
[~andy/gtk] / gtk / gtkfontsel.c
index ddf0ba6cd8f2359abf9925e52d29b216032e9e24..a4a81410255f106c990708f85b7a4ee8eece6a50 100644 (file)
@@ -29,7 +29,7 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <config.h>
+#include "config.h"
 #include <stdlib.h>
 #include <glib/gprintf.h>
 #include <string.h>
@@ -235,7 +235,7 @@ static void gtk_font_selection_get_property (GObject         *object,
   switch (prop_id)
     {
     case PROP_FONT_NAME:
-      g_value_set_string (value, gtk_font_selection_get_font_name (fontsel));
+      g_value_take_string (value, gtk_font_selection_get_font_name (fontsel));
       break;
     case PROP_FONT:
       g_value_set_boxed (value, gtk_font_selection_get_font_internal (fontsel));
@@ -1087,7 +1087,7 @@ gtk_font_selection_update_preview (GtkFontSelection *fontsel)
   rc_style->font_desc = gtk_font_selection_get_font_description (fontsel);
   
   gtk_widget_modify_style (preview_entry, rc_style);
-  gtk_rc_style_unref (rc_style);
+  g_object_unref (rc_style);
 
   gtk_widget_size_request (preview_entry, NULL);
   
@@ -1122,9 +1122,208 @@ gtk_font_selection_get_font_internal (GtkFontSelection *fontsel)
  * These functions are the main public interface for getting/setting the font.
  *****************************************************************************/
 
-GdkFont*
+/**
+ * gtk_font_selection_get_family_entry:
+ * @fontsel: a #GtkFontSelection
+ *
+ * This returns the #GtkEntry that allows the user to manually enter
+ * the font family they want to use.
+ * 
+ * Return value: A #GtkWidget.
+ *
+ * Since: 2.14
+ **/
+GtkWidget *
+gtk_font_selection_get_family_entry (GtkFontSelection *fontsel)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  
+  return fontsel->font_entry;
+}
+
+/**
+ * gtk_font_selection_get_family_list:
+ * @fontsel: a #GtkFontSelection
+ *
+ * This returns the #GtkTreeView that lists font families, for
+ * example, 'Sans', 'Serif', etc.
+ * 
+ * Return value: A #GtkWidget. 
+ *
+ * Since: 2.14
+ **/
+GtkWidget *
+gtk_font_selection_get_family_list (GtkFontSelection *fontsel)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  
+  return fontsel->family_list;
+}
+
+/**
+ * gtk_font_selection_get_face_entry:
+ * @fontsel: a #GtkFontSelection
+ *
+ * This returns the #GtkEntry responsible for allowing manual
+ * configuration of the font style.
+ * 
+ * Return value: A #GtkWidget. 
+ *
+ * Since: 2.14
+ **/
+GtkWidget *
+gtk_font_selection_get_face_entry (GtkFontSelection *fontsel)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  
+  return fontsel->font_style_entry;
+}
+
+/**
+ * gtk_font_selection_get_face_list:
+ * @fontsel: a #GtkFontSelection
+ *
+ * This returns the #GtkTreeView which lists all styles available for
+ * the selected font. For example, 'Regular', 'Bold', etc.
+ * 
+ * Return value: A #GtkWidget. 
+ *
+ * Since: 2.14
+ **/
+GtkWidget *
+gtk_font_selection_get_face_list (GtkFontSelection *fontsel)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  
+  return fontsel->face_list;
+}
+
+/**
+ * gtk_font_selection_get_size_entry:
+ * @fontsel: a #GtkFontSelection
+ *
+ * This returns the #GtkEntry used to allow the user to edit the font
+ * number manually instead of selecting it from the list of font sizes. 
+ * 
+ * Return value: A #GtkWidget. 
+ *
+ * Since: 2.14
+ **/
+GtkWidget *
+gtk_font_selection_get_size_entry (GtkFontSelection *fontsel)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  
+  return fontsel->size_entry;
+}
+
+/**
+ * gtk_font_selection_get_size_list:
+ * @fontsel: a #GtkFontSelection
+ *
+ * This returns the #GtkTreeeView used to list font sizes. 
+ * 
+ * Return value: A #GtkWidget. 
+ *
+ * Since: 2.14
+ **/
+GtkWidget *
+gtk_font_selection_get_size_list (GtkFontSelection *fontsel)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  
+  return fontsel->size_list;
+}
+
+/**
+ * gtk_font_selection_get_preview_entry:
+ * @fontsel: a #GtkFontSelection
+ * 
+ * This returns the #GtkEntry used to display the font as a preview.
+ *
+ * Return value: A #GtkWidget. 
+ *
+ * Since: 2.14
+ **/
+GtkWidget *
+gtk_font_selection_get_preview_entry (GtkFontSelection *fontsel)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  
+  return fontsel->preview_entry;
+}
+
+/**
+ * gtk_font_selection_get_family:
+ * @fontsel: a #GtkFontSelection
+ * 
+ * Gets the #PangoFontFamily representing the selected font family.
+ *
+ * Return value: A #PangoFontFamily representing the selected font
+ * family. Font families are a collection of font faces.
+ *
+ * Since: 2.14
+ **/
+PangoFontFamily *
+gtk_font_selection_get_family (GtkFontSelection *fontsel)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  
+  return fontsel->family;
+}
+
+/**
+ * gtk_font_selection_get_face:
+ * @fontsel: a #GtkFontSelection
+ * 
+ * Gets the #PangoFontFace representing the selected font group
+ * details (i.e. family, slant, weight, width, etc).   
+ *
+ * Return value: A #PangoFontFace representing the selected font group
+ *     details 
+ *
+ * Since: 2.14
+ **/
+PangoFontFace *
+gtk_font_selection_get_face (GtkFontSelection *fontsel)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+  
+  return fontsel->face;
+}
+
+/**
+ * gtk_font_selection_get_size:
+ * @fontsel: a #GtkFontSelection
+ * 
+ * The selected font size.
+ *
+ * Return value: A #gint representing the font size selected, or -1
+ * if not.
+ *
+ * Since: 2.14
+ **/
+gint
+gtk_font_selection_get_size (GtkFontSelection *fontsel)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), -1);
+  
+  return fontsel->size;
+}
+
+/**
+ * gtk_font_selection_get_font:
+ * @fontsel: a #GtkFontSelection
+ *
+ * Return value: A #GdkFont.
+ *
+ * Deprecated: 2.0: Use gtk_font_selection_get_font_name() instead.
+ **/
+GdkFont *
 gtk_font_selection_get_font (GtkFontSelection *fontsel)
 {
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+
   return gtk_font_selection_get_font_internal (fontsel);
 }
 
@@ -1273,21 +1472,40 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
   return TRUE;
 }
 
-
-/* This returns the text in the preview entry. You should copy the returned
-   text if you need it. */
+/**
+ * gtk_font_selection_get_preview_text:
+ * @fontsel: a #GtkFontSelection
+ *
+ * The text returned is the preview text used to show how the selected
+ * font looks.  
+ * 
+ * Return value: pointer to the preview text string. This string
+ * points to internally allocated storage in the widget and must not
+ * be freed, modified or stored. 
+ **/
 G_CONST_RETURN gchar*
-gtk_font_selection_get_preview_text  (GtkFontSelection *fontsel)
+gtk_font_selection_get_preview_text (GtkFontSelection *fontsel)
 {
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
+
   return gtk_entry_get_text (GTK_ENTRY (fontsel->preview_entry));
 }
 
 
-/* This sets the text in the preview entry. */
+/**
+ * gtk_font_selection_set_preview_text:
+ * @fontsel: a #GtkFontSelection
+ * @text: a pointer to a string
+ *
+ * The @text is used to show how the selected font looks.
+ **/
 void
 gtk_font_selection_set_preview_text  (GtkFontSelection *fontsel,
-                                     const gchar         *text)
+                                     const gchar      *text)
 {
+  g_return_if_fail (GTK_IS_FONT_SELECTION (fontsel));
+  g_return_if_fail (text != NULL);
+
   gtk_entry_set_text (GTK_ENTRY (fontsel->preview_entry), text);
 }
 
@@ -1366,6 +1584,16 @@ gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag)
   _gtk_dialog_set_ignore_separator (dialog, TRUE);
 }
 
+/**
+ * gtk_font_selection_dialog_new:
+ * @title: a pointer to a string
+ *
+ * The @title is used to set the title of the #GtkFontSelectionDialog
+ * returned. This #GtkDialog is specifically catered with widgets for
+ * selecting a font from those installed. 
+ *
+ * Return value: a new #GtkFontSelectionDialog.
+ */
 GtkWidget*
 gtk_font_selection_dialog_new (const gchar *title)
 {
@@ -1379,6 +1607,58 @@ gtk_font_selection_dialog_new (const gchar *title)
   return GTK_WIDGET (fontseldiag);
 }
 
+/**
+ * gtk_font_selection_dialog_get_ok_button:
+ * @fsd: a #GtkFontSelectionDialog
+ *
+ * Gets the 'OK' button.
+ *
+ * Return value: the #GtkWidget used in the dialog for the 'OK' button.
+ *
+ * Since: 2.14
+ */
+GtkWidget *
+gtk_font_selection_dialog_get_ok_button (GtkFontSelectionDialog *fsd)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
+
+  return fsd->ok_button;
+}
+
+/**
+ * gtk_font_selection_dialog_get_apply_button:
+ * @fsd: a #GtkFontSelectionDialog
+ *
+ * Gets the 'Apply' button.
+ *
+ * Return value: the #GtkWidget used in the dialog for the 'Apply' button.
+ *
+ * Since: 2.14
+ */
+GtkWidget *
+gtk_font_selection_dialog_get_apply_button (GtkFontSelectionDialog *fsd)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
+
+  return fsd->apply_button;
+}
+
+/**
+ * gtk_font_selection_dialog_get_cancel_button:
+ * @fsd: a #GtkFontSelectionDialog
+ *
+ * Gets the 'Cancel' button.
+ *
+ * Return value: the #GtkWidget used in the dialog for the 'Cancel' button.
+ */
+GtkWidget *
+gtk_font_selection_dialog_get_cancel_button (GtkFontSelectionDialog *fsd)
+{
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
+
+  return fsd->cancel_button;
+}
+
 static void
 gtk_font_selection_dialog_buildable_interface_init (GtkBuildableIface *iface)
 {
@@ -1420,32 +1700,81 @@ gtk_font_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
 gchar*
 gtk_font_selection_dialog_get_font_name (GtkFontSelectionDialog *fsd)
 {
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
+
   return gtk_font_selection_get_font_name (GTK_FONT_SELECTION (fsd->fontsel));
 }
 
+/**
+ * gtk_font_selection_dialog_get_font:
+ * @fsd: a #GtkFontSelectionDialog
+ *
+ * Return value: the #GdkFont from the #GtkFontSelection for the
+ * currently selected font in the dialog.
+ *
+ * Deprecated: 2.0: Use gtk_font_selection_dialog_get_font_name() instead.
+ */
 GdkFont*
 gtk_font_selection_dialog_get_font (GtkFontSelectionDialog *fsd)
 {
-  return gtk_font_selection_get_font (GTK_FONT_SELECTION (fsd->fontsel));
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
+
+  return gtk_font_selection_get_font_internal (GTK_FONT_SELECTION (fsd->fontsel));
 }
 
+/**
+ * gtk_font_selection_dialog_set_font_name:
+ * @fsd: a #GtkFontSelectionDialog
+ * @fontname: a pointer to a string
+ *
+ * Sets the currently selected font. 
+ * 
+ * Return value: %TRUE if the font selected in @fsd is now the
+ * @fontname specified. %FALSE otherwise. 
+ */
 gboolean
 gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd,
-                                        const gchar      *fontname)
+                                        const gchar            *fontname)
 {
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), FALSE);
+  g_return_val_if_fail (fontname, FALSE);
+
   return gtk_font_selection_set_font_name (GTK_FONT_SELECTION (fsd->fontsel), fontname);
 }
 
+/**
+ * gtk_font_selection_dialog_get_preview_text:
+ * @fsd: a #GtkFontSelectionDialog
+ *
+ * The text returned is the preview text used to show how the selected
+ * font looks.  
+ *
+ * Return value: pointer to the preview text string. This string
+ * points to internally allocated storage in the widget and must not
+ * be freed, modified or stored. 
+ */
 G_CONST_RETURN gchar*
 gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd)
 {
+  g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
+
   return gtk_font_selection_get_preview_text (GTK_FONT_SELECTION (fsd->fontsel));
 }
 
+/**
+ * gtk_font_selection_dialog_set_preview_text:
+ * @fsd: a #GtkFontSelectionDialog
+ * @text: a pointer to a string
+
+ * The @text is used to show how the selected font looks.
+ */
 void
 gtk_font_selection_dialog_set_preview_text (GtkFontSelectionDialog *fsd,
                                            const gchar            *text)
 {
+  g_return_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd));
+  g_return_if_fail (text != NULL);
+
   gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (fsd->fontsel), text);
 }