Ejemplo n.º 1
0
static void
gnm_font_button_class_init (GnmFontButtonClass *klass)
{
  GObjectClass *gobject_class;
  GtkButtonClass *button_class;

  gnm_font_button_parent_class = g_type_class_peek_parent (klass);

  gobject_class = (GObjectClass *) klass;
  button_class = (GtkButtonClass *) klass;

  gobject_class->finalize = gnm_font_button_finalize;
  gobject_class->set_property = gnm_font_button_set_property;
  gobject_class->get_property = gnm_font_button_get_property;

  button_class->clicked = gnm_font_button_clicked;

  klass->font_set = NULL;

  _gtk_font_chooser_install_properties (gobject_class);

  g_object_class_install_property (gobject_class,
                                   PROP_DIALOG_TYPE,
                                   g_param_spec_gtype ("dialog-type",
						       _("Dialog Type"),
						       _("The type of the dialog"),
						       GTK_TYPE_FONT_CHOOSER,
						       (G_PARAM_READABLE |
							G_PARAM_WRITABLE)));


  /**
   * GnmFontButton:title:
   *
   * The title of the font chooser dialog.
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_TITLE,
                                   g_param_spec_string ("title",
                                                        _("Title"),
                                                        _("The title of the font chooser dialog"),
                                                        _("Pick a Font"),
                                                        (G_PARAM_READABLE |
                                                         G_PARAM_WRITABLE)));

  /**
   * GnmFontButton:font-name:
   *
   * The name of the currently selected font.
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_FONT_NAME,
                                   g_param_spec_string ("font-name",
                                                        _("Font name"),
                                                        _("The name of the selected font"),
                                                        _("Sans 12"),
                                                        (G_PARAM_READABLE |
                                                         G_PARAM_WRITABLE)));

  /**
   * GnmFontButton:use-font:
   *
   * If this property is set to %TRUE, the label will be drawn
   * in the selected font.
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_USE_FONT,
                                   g_param_spec_boolean ("use-font",
                                                         _("Use font in label"),
                                                         _("Whether the label is drawn in the selected font"),
                                                         FALSE,
                                                         G_PARAM_READWRITE));

  /**
   * GnmFontButton:use-size:
   *
   * If this property is set to %TRUE, the label will be drawn
   * with the selected font size.
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_USE_SIZE,
                                   g_param_spec_boolean ("use-size",
                                                         _("Use size in label"),
                                                         _("Whether the label is drawn with the selected font size"),
                                                         FALSE,
                                                         G_PARAM_READWRITE));

  /**
   * GnmFontButton:show-style:
   *
   * If this property is set to %TRUE, the name of the selected font style
   * will be shown in the label. For a more WYSIWYG way to show the selected
   * style, see the ::use-font property.
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_SHOW_STYLE,
                                   g_param_spec_boolean ("show-style",
                                                         _("Show style"),
                                                         _("Whether the selected font style is shown in the label"),
                                                         TRUE,
                                                         G_PARAM_READWRITE));
  /**
   * GnmFontButton:show-size:
   *
   * If this property is set to %TRUE, the selected font size will be shown
   * in the label. For a more WYSIWYG way to show the selected size, see the
   * ::use-size property.
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_SHOW_SIZE,
                                   g_param_spec_boolean ("show-size",
                                                         _("Show size"),
                                                         _("Whether selected font size is shown in the label"),
                                                         TRUE,
                                                         G_PARAM_READWRITE));

  /**
   * GnmFontButton::font-set:
   * @widget: the object which received the signal.
   *
   * The ::font-set signal is emitted when the user selects a font.
   * When handling this signal, use gnm_font_button_get_font_name()
   * to find out which font was just selected.
   *
   * Note that this signal is only emitted when the <emphasis>user</emphasis>
   * changes the font. If you need to react to programmatic font changes
   * as well, use the notify::font-name signal.
   *
   * Since: 2.4
   */
  font_button_signals[FONT_SET] = g_signal_new (("font-set"),
                                                G_TYPE_FROM_CLASS (gobject_class),
                                                G_SIGNAL_RUN_FIRST,
                                                G_STRUCT_OFFSET (GnmFontButtonClass, font_set),
                                                NULL, NULL,
                                                g_cclosure_marshal_VOID__VOID,
                                                G_TYPE_NONE, 0);

  g_type_class_add_private (gobject_class, sizeof (GnmFontButtonPrivate));
}
Ejemplo n.º 2
0
static void
gtk_font_button_class_init (GtkFontButtonClass *klass)
{
  GObjectClass *gobject_class;
  GtkWidgetClass *widget_class;
  GtkButtonClass *button_class;
  
  gobject_class = (GObjectClass *) klass;
  widget_class = (GtkWidgetClass *) klass;
  button_class = (GtkButtonClass *) klass;

  gobject_class->finalize = gtk_font_button_finalize;
  gobject_class->set_property = gtk_font_button_set_property;
  gobject_class->get_property = gtk_font_button_get_property;
  
  button_class->clicked = gtk_font_button_clicked;
  
  klass->font_set = NULL;

  _gtk_font_chooser_install_properties (gobject_class);

  /**
   * GtkFontButton:title:
   * 
   * The title of the font chooser dialog.
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_TITLE,
                                   g_param_spec_string ("title",
                                                        P_("Title"),
                                                        P_("The title of the font chooser dialog"),
                                                        _("Pick a Font"),
                                                        GTK_PARAM_READWRITE));

  /**
   * GtkFontButton:font-name:
   * 
   * The name of the currently selected font.
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_FONT_NAME,
                                   g_param_spec_string ("font-name",
                                                        P_("Font name"),
                                                        P_("The name of the selected font"),
                                                        P_("Sans 12"),
                                                        GTK_PARAM_READWRITE));

  /**
   * GtkFontButton:use-font:
   * 
   * If this property is set to %TRUE, the label will be drawn 
   * in the selected font.
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_USE_FONT,
                                   g_param_spec_boolean ("use-font",
                                                         P_("Use font in label"),
                                                         P_("Whether the label is drawn in the selected font"),
                                                         FALSE,
                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));

  /**
   * GtkFontButton:use-size:
   * 
   * If this property is set to %TRUE, the label will be drawn 
   * with the selected font size.
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_USE_SIZE,
                                   g_param_spec_boolean ("use-size",
                                                         P_("Use size in label"),
                                                         P_("Whether the label is drawn with the selected font size"),
                                                         FALSE,
                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));

  /**
   * GtkFontButton:show-style:
   * 
   * If this property is set to %TRUE, the name of the selected font style 
   * will be shown in the label. For a more WYSIWYG way to show the selected 
   * style, see the ::use-font property. 
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_SHOW_STYLE,
                                   g_param_spec_boolean ("show-style",
                                                         P_("Show style"),
                                                         P_("Whether the selected font style is shown in the label"),
                                                         TRUE,
                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
  /**
   * GtkFontButton:show-size:
   * 
   * If this property is set to %TRUE, the selected font size will be shown 
   * in the label. For a more WYSIWYG way to show the selected size, see the 
   * ::use-size property. 
   *
   * Since: 2.4
   */
  g_object_class_install_property (gobject_class,
                                   PROP_SHOW_SIZE,
                                   g_param_spec_boolean ("show-size",
                                                         P_("Show size"),
                                                         P_("Whether selected font size is shown in the label"),
                                                         TRUE,
                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));

  /**
   * GtkFontButton::font-set:
   * @widget: the object which received the signal.
   * 
   * The ::font-set signal is emitted when the user selects a font. 
   * When handling this signal, use gtk_font_button_get_font_name() 
   * to find out which font was just selected.
   *
   * Note that this signal is only emitted when the user
   * changes the font. If you need to react to programmatic font changes
   * as well, use the notify::font-name signal.
   *
   * Since: 2.4
   */
  font_button_signals[FONT_SET] = g_signal_new (I_("font-set"),
                                                G_TYPE_FROM_CLASS (gobject_class),
                                                G_SIGNAL_RUN_FIRST,
                                                G_STRUCT_OFFSET (GtkFontButtonClass, font_set),
                                                NULL, NULL,
                                                g_cclosure_marshal_VOID__VOID,
                                                G_TYPE_NONE, 0);

  /* Bind class to template
   */
  gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkfontbutton.ui");
  gtk_widget_class_bind_template_child_private (widget_class, GtkFontButton, font_label);
  gtk_widget_class_bind_template_child_private (widget_class, GtkFontButton, size_label);
  gtk_widget_class_bind_template_child_private (widget_class, GtkFontButton, font_size_box);

  gtk_widget_class_set_css_name (widget_class, "button");
}