#include "gtkscrolledwindow.h"
#include "gtkintl.h"
#include "gtkaccessible.h"
-#include "gtkprivate.h"
#include "gtkbuildable.h"
+#include "gtkprivate.h"
-struct _GtkFontSelectionPriv
+struct _GtkFontSelectionPrivate
{
GtkWidget *font_entry; /* Used _get_family_entry() for consistency, -mr */
GtkWidget *font_style_entry; /* Used _get_face_entry() for consistency, -mr */
};
-struct _GtkFontSelectionDialogPriv
+struct _GtkFontSelectionDialogPrivate
{
GtkWidget *fontsel;
_(PREVIEW_TEXT),
GTK_PARAM_READWRITE));
- g_type_class_add_private (klass, sizeof (GtkFontSelectionPriv));
+ g_type_class_add_private (klass, sizeof (GtkFontSelectionPrivate));
}
static void
static gboolean
list_row_activated (GtkWidget *widget)
{
+ GtkWidget *default_widget, *focus_widget;
GtkWindow *window;
window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget)));
if (!gtk_widget_is_toplevel (GTK_WIDGET (window)))
window = NULL;
-
- if (window
- && widget != window->default_widget
- && !(widget == window->focus_widget &&
- (!window->default_widget || !gtk_widget_get_sensitive (window->default_widget))))
+
+ if (window)
{
- gtk_window_activate_default (window);
+ default_widget = gtk_window_get_default_widget (window);
+ focus_widget = gtk_window_get_focus (window);
+
+ if (widget != default_widget &&
+ !(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget))))
+ gtk_window_activate_default (window);
}
-
+
return TRUE;
}
static void
gtk_font_selection_init (GtkFontSelection *fontsel)
{
- GtkFontSelectionPriv *priv;
+ GtkFontSelectionPrivate *priv;
GtkWidget *scrolled_win;
GtkWidget *text_box;
GtkWidget *table, *label;
fontsel->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontsel,
GTK_TYPE_FONT_SELECTION,
- GtkFontSelectionPriv);
+ GtkFontSelectionPrivate);
priv = fontsel->priv;
gtk_widget_push_composite_child ();
atk_relation_set_add (relation_set, relation);
}
g_object_unref (relation_set);
- }
-
+ }
- vbox = gtk_vbox_new (FALSE, 6);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (fontsel), vbox, FALSE, TRUE, 0);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
-
- text_box = gtk_hbox_new (FALSE, 0);
+
+ text_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show (text_box);
gtk_box_pack_start (GTK_BOX (vbox), text_box, FALSE, TRUE, 0);
gtk_font_selection_ref_family (GtkFontSelection *fontsel,
PangoFontFamily *family)
{
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
if (family)
family = g_object_ref (family);
static void gtk_font_selection_ref_face (GtkFontSelection *fontsel,
PangoFontFace *face)
{
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
if (face)
face = g_object_ref (face);
static void
gtk_font_selection_scroll_to_selection (GtkFontSelection *fontsel)
{
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
/* Try to scroll the font family list to the selected item */
scroll_to_selection (GTK_TREE_VIEW (priv->family_list));
gpointer data)
{
GtkFontSelection *fontsel;
- GtkFontSelectionPriv *priv;
+ GtkFontSelectionPrivate *priv;
GtkTreeModel *model;
GtkTreeIter iter;
#ifdef INCLUDE_FONT_ENTRIES
static void
gtk_font_selection_show_available_fonts (GtkFontSelection *fontsel)
{
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
GtkListStore *model;
PangoFontFamily **families;
PangoFontFamily *match_family = NULL;
static void
gtk_font_selection_show_available_styles (GtkFontSelection *fontsel)
{
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
gint n_faces, i;
PangoFontFace **faces;
PangoFontDescription *old_desc;
gtk_font_selection_select_best_style (GtkFontSelection *fontsel,
gboolean use_first)
{
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
GtkTreeIter iter;
GtkTreeModel *model;
gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel,
gboolean first_time)
{
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
gint i;
GtkListStore *model;
gchar buffer[128];
gtk_font_selection_set_size (GtkFontSelection *fontsel,
gint new_size)
{
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
if (priv->size != new_size)
{
gpointer data)
{
GtkFontSelection *fontsel = GTK_FONT_SELECTION (data);
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
gint new_size;
const gchar *text;
gpointer data)
{
GtkFontSelection *fontsel = GTK_FONT_SELECTION (data);
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
gint new_size;
const gchar *text;
static PangoFontDescription *
gtk_font_selection_get_font_description (GtkFontSelection *fontsel)
{
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
PangoFontDescription *font_desc;
if (priv->face)
static void
gtk_font_selection_update_preview (GtkFontSelection *fontsel)
{
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
GtkRcStyle *rc_style;
gint new_height;
- GtkRequisition old_requisition;
+ GtkRequisition old_requisition, new_requisition;
GtkWidget *preview_entry = priv->preview_entry;
const gchar *text;
- gtk_widget_get_child_requisition (preview_entry, &old_requisition);
-
+ gtk_widget_get_preferred_size (preview_entry, &old_requisition, NULL);
+
rc_style = gtk_rc_style_new ();
rc_style->font_desc = gtk_font_selection_get_font_description (fontsel);
gtk_widget_modify_style (preview_entry, rc_style);
g_object_unref (rc_style);
- gtk_widget_size_request (preview_entry, NULL);
+ gtk_widget_get_preferred_size (preview_entry, &new_requisition, NULL);
/* We don't ever want to be over MAX_PREVIEW_HEIGHT pixels high. */
- new_height = CLAMP (preview_entry->requisition.height, INITIAL_PREVIEW_HEIGHT, MAX_PREVIEW_HEIGHT);
+ new_height = CLAMP (new_requisition.height, INITIAL_PREVIEW_HEIGHT, MAX_PREVIEW_HEIGHT);
if (new_height > old_requisition.height || new_height < old_requisition.height - 30)
gtk_widget_set_size_request (preview_entry, -1, new_height);
*
* This returns the #GtkTreeView that lists font families, for
* example, 'Sans', 'Serif', etc.
- *
- * Return value: A #GtkWidget that is part of @fontsel
+ *
+ * Return value: (transfer none): A #GtkWidget that is part of @fontsel
*
* Since: 2.14
*/
* This returns the #GtkTreeView which lists all styles available for
* the selected font. For example, 'Regular', 'Bold', etc.
*
- * Return value: A #GtkWidget that is part of @fontsel
+ * Return value: (transfer none): A #GtkWidget that is part of @fontsel
*
* Since: 2.14
*/
* @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 that is part of @fontsel
+ * number manually instead of selecting it from the list of font sizes.
+ *
+ * Return value: (transfer none): A #GtkWidget that is part of @fontsel
*
* Since: 2.14
*/
* gtk_font_selection_get_size_list:
* @fontsel: a #GtkFontSelection
*
- * This returns the #GtkTreeeView used to list font sizes.
- *
- * Return value: A #GtkWidget that is part of @fontsel
+ * This returns the #GtkTreeeView used to list font sizes.
+ *
+ * Return value: (transfer none): A #GtkWidget that is part of @fontsel
*
* Since: 2.14
*/
/**
* 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 that is part of @fontsel
+ * Return value: (transfer none): A #GtkWidget that is part of @fontsel
*
* Since: 2.14
*/
/**
* 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. The
- * returned object is owned by @fontsel and must not be modified
- * or freed.
+ * Return value: (transfer none): A #PangoFontFamily representing the
+ * selected font family. Font families are a collection of font
+ * faces. The returned object is owned by @fontsel and must not
+ * be modified or freed.
*
* Since: 2.14
*/
/**
* gtk_font_selection_get_face:
* @fontsel: a #GtkFontSelection
- *
+ *
* Gets the #PangoFontFace representing the selected font group
- * details (i.e. family, slant, weight, width, etc).
+ * details (i.e. family, slant, weight, width, etc).
*
- * Return value: A #PangoFontFace representing the selected font
- * group details. The returned object is owned by @fontsel and
- * must not be modified or freed.
+ * Return value: (transfer none): A #PangoFontFace representing the
+ * selected font group details. The returned object is owned by
+ * @fontsel and must not be modified or freed.
*
* Since: 2.14
*/
/**
* gtk_font_selection_get_size:
* @fontsel: a #GtkFontSelection
- *
+ *
* The selected font size.
*
- * Return value: A n integer representing the selected font size,
+ * Return value: A n integer representing the selected font size,
* or -1 if no font size is selected.
*
* Since: 2.14
PangoFontFamily **pfamily,
PangoFontFace **pface)
{
- GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkFontSelectionPrivate *priv = fontsel->priv;
PangoFontFamily *new_family = NULL;
PangoFontFace *new_face = NULL;
PangoFontFace *fallback_face = NULL;
G_CONST_RETURN gchar*
gtk_font_selection_get_preview_text (GtkFontSelection *fontsel)
{
- GtkFontSelectionPriv *priv;
+ GtkFontSelectionPrivate *priv;
g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL);
gtk_font_selection_set_preview_text (GtkFontSelection *fontsel,
const gchar *text)
{
- GtkFontSelectionPriv *priv;
+ GtkFontSelectionPrivate *priv;
g_return_if_fail (GTK_IS_FONT_SELECTION (fontsel));
g_return_if_fail (text != NULL);
static void
gtk_font_selection_dialog_class_init (GtkFontSelectionDialogClass *klass)
{
- g_type_class_add_private (klass, sizeof (GtkFontSelectionDialogPriv));
+ g_type_class_add_private (klass, sizeof (GtkFontSelectionDialogPrivate));
}
static void
gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag)
{
- GtkFontSelectionDialogPriv *priv;
+ GtkFontSelectionDialogPrivate *priv;
GtkDialog *dialog = GTK_DIALOG (fontseldiag);
GtkWidget *action_area, *content_area;
fontseldiag->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontseldiag,
GTK_TYPE_FONT_SELECTION_DIALOG,
- GtkFontSelectionDialogPriv);
+ GtkFontSelectionDialogPrivate);
priv = fontseldiag->priv;
content_area = gtk_dialog_get_content_area (dialog);
action_area = gtk_dialog_get_action_area (dialog);
- gtk_dialog_set_has_separator (dialog, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
_("Font Selection"));
gtk_widget_pop_composite_child ();
-
- _gtk_dialog_set_ignore_separator (dialog, TRUE);
}
/**
/**
* gtk_font_selection_dialog_get_font_selection:
- * @colorsel: a #GtkFontSelectionDialog
+ * @fsd: a #GtkFontSelectionDialog
*
* Retrieves the #GtkFontSelection widget embedded in the dialog.
*
- * Returns: the embedded #GtkFontSelection
+ * Returns: (transfer none): the embedded #GtkFontSelection
*
* Since: 2.22
**/
*
* Gets the 'OK' button.
*
- * Return value: the #GtkWidget used in the dialog for the 'OK' button.
+ * Return value: (transfer none): the #GtkWidget used in the dialog
+ * for the 'OK' button.
*
* Since: 2.14
*/
*
* Gets the 'Cancel' button.
*
- * Return value: the #GtkWidget used in the dialog for the 'Cancel' button.
+ * Return value: (transfer none): the #GtkWidget used in the dialog
+ * for the 'Cancel' button.
*
* Since: 2.14
*/
GtkBuilder *builder,
const gchar *childname)
{
- GtkFontSelectionDialogPriv *priv;
+ GtkFontSelectionDialogPrivate *priv;
priv = GTK_FONT_SELECTION_DIALOG (buildable)->priv;
gchar*
gtk_font_selection_dialog_get_font_name (GtkFontSelectionDialog *fsd)
{
- GtkFontSelectionDialogPriv *priv;
+ GtkFontSelectionDialogPrivate *priv;
g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd,
const gchar *fontname)
{
- GtkFontSelectionDialogPriv *priv;
+ GtkFontSelectionDialogPrivate *priv;
g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), FALSE);
g_return_val_if_fail (fontname, FALSE);
G_CONST_RETURN gchar*
gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd)
{
- GtkFontSelectionDialogPriv *priv;
+ GtkFontSelectionDialogPrivate *priv;
g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL);
gtk_font_selection_dialog_set_preview_text (GtkFontSelectionDialog *fsd,
const gchar *text)
{
- GtkFontSelectionDialogPriv *priv;
+ GtkFontSelectionDialogPrivate *priv;
g_return_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd));
g_return_if_fail (text != NULL);