Пример #1
0
void
glade_gtk_color_button_set_property (GladeWidgetAdaptor * adaptor,
                                     GObject * object,
                                     const gchar * id, const GValue * value)
{
  GladeProperty *property;
  GladeWidget *gwidget = glade_widget_get_from_gobject (object);

  if (!strcmp (id, "color"))
    {
      if ((property = glade_widget_get_property (gwidget, "color")) != NULL &&
	  glade_property_get_enabled (property) && g_value_get_boxed (value))
	{
	  GdkColor *color = g_value_get_boxed (value);
	  GdkRGBA copy;

	  copy.red   = color->red   / 65535.0;
	  copy.green = color->green / 65535.0;
	  copy.blue  = color->blue  / 65535.0;
	  copy.alpha = 1.0;

	  gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (object), &copy);
	}
    }
  else if (!strcmp (id, "rgba"))
    {
      if ((property = glade_widget_get_property (gwidget, "rgba")) != NULL &&
	  glade_property_get_enabled (property) && g_value_get_boxed (value))
	gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (object),
				    (GdkRGBA *) g_value_get_boxed (value));
    }
  else
    GWA_GET_CLASS (GTK_TYPE_BUTTON)->set_property (adaptor, object, id, value);
}
Пример #2
0
/* ----------------------------- GtkColorButton ------------------------------ */
static void
glade_gtk_color_button_refresh_color (GtkColorButton * button,
                                      GladeWidget * gbutton)
{
  GladeProperty *property;
  GdkRGBA rgba = { 0, };

  gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &rgba);

  if ((property = glade_widget_get_property (gbutton, "color")) != NULL)
    {
      if (glade_property_get_enabled (property))
	{
	  GdkColor color = { 0, };

	  color.red   = (gint16) (rgba.red * 65535);
	  color.green = (gint16) (rgba.green * 65535);
	  color.blue  = (gint16) (rgba.blue * 65535);

	  glade_command_set_property (property, &color);
	}
    }

  if ((property = glade_widget_get_property (gbutton, "rgba")) != NULL)
    {
      if (glade_property_get_enabled (property))
	glade_command_set_property (property, &rgba);
    }
}
Пример #3
0
static void
glade_property_fix_state (GladeProperty * property)
{
  property->priv->state = GLADE_STATE_NORMAL;

  /* Properties are 'changed' state if they are not default, or if 
   * they are optional and enabled, optional enabled properties
   * are saved regardless of default value
   */
  if (glade_property_class_optional (property->priv->klass))
    {
      if (glade_property_get_enabled (property))
	property->priv->state |= GLADE_STATE_CHANGED;
    }
  else if (!glade_property_original_default (property))
    property->priv->state |= GLADE_STATE_CHANGED;

  if (property->priv->support_warning)
    property->priv->state |= GLADE_STATE_UNSUPPORTED;

  if (property->priv->support_disabled)
    property->priv->state |= GLADE_STATE_SUPPORT_DISABLED;

  g_object_notify_by_pspec (G_OBJECT (property), properties[PROP_STATE]);
}
Пример #4
0
/* Shared with other classes */
void
glade_gtk_write_icon_size (GladeWidget     *widget,
                           GladeXmlContext *context,
                           GladeXmlNode    *node,
                           const gchar     *prop_name)
{
  GladeXmlNode *prop_node;
  GladeProperty *size_prop;
  GtkIconSize icon_size;
  gchar *value;

  /* We have to save icon-size as an integer, the core will take care of 
   * loading the int value though.
   */
  size_prop = glade_widget_get_property (widget, prop_name);
  if (glade_property_get_enabled (size_prop) &&
      !glade_property_original_default (size_prop))
    {
      gchar *write_prop_name = g_strdup (prop_name);

      glade_util_replace (write_prop_name, '-', '_');

      prop_node = glade_xml_node_new (context, GLADE_TAG_PROPERTY);
      glade_xml_node_append_child (node, prop_node);

      glade_xml_node_set_property_string (prop_node, GLADE_TAG_NAME, write_prop_name);

      glade_property_get (size_prop, &icon_size);
      value = g_strdup_printf ("%d", icon_size);
      glade_xml_set_content (prop_node, value);
      g_free (value);
      g_free (write_prop_name);
    }
}
Пример #5
0
void
glade_gtk_widget_write_widget (GladeWidgetAdaptor * adaptor,
                               GladeWidget * widget,
                               GladeXmlContext * context, GladeXmlNode * node)
{
  GladeProperty *prop;

  if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) ||
	glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE)))
    return;

  /* Make sure use-action-appearance and related-action properties are
   * ordered in a sane way and are only saved if there is an action */
  prop = glade_widget_get_property (widget, "use-action-appearance");
  if (prop && glade_property_get_enabled (prop))
    glade_property_write (prop, context, node);

  prop = glade_widget_get_property (widget, "related-action");
  if (prop && glade_property_get_enabled (prop))
    glade_property_write (prop, context, node);

  /* Finally chain up and read in all the normal properties.. */
  GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
}
Пример #6
0
static void
glade_property_get_real_property (GObject * object,
                                  guint prop_id,
                                  GValue * value, GParamSpec * pspec)
{
  GladeProperty *property = GLADE_PROPERTY (object);

  switch (prop_id)
    {
      case PROP_CLASS:
        g_value_set_pointer (value, property->priv->klass);
        break;
      case PROP_ENABLED:
        g_value_set_boolean (value, glade_property_get_enabled (property));
        break;
      case PROP_SENSITIVE:
        g_value_set_boolean (value, glade_property_get_sensitive (property));
        break;
      case PROP_I18N_TRANSLATABLE:
        g_value_set_boolean (value,
                             glade_property_i18n_get_translatable (property));
        break;
      case PROP_I18N_CONTEXT:
        g_value_set_string (value, glade_property_i18n_get_context (property));
        break;
      case PROP_I18N_COMMENT:
        g_value_set_string (value, glade_property_i18n_get_comment (property));
        break;
      case PROP_STATE:
        g_value_set_int (value, property->priv->state);
        break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
    }
}