Ejemplo n.º 1
0
void
glade_popup_property_pop (GladeProperty *property, GdkEventButton *event)
{

  GladeWidgetAdaptor *adaptor, *prop_adaptor;
  GladePropertyClass *pclass;
  GParamSpec         *pspec;
  GtkWidget *popup_menu;
  gint button;
  gint event_time;

  pclass       = glade_property_get_class (property);
  pspec        = glade_property_class_get_pspec (pclass);
  prop_adaptor = glade_property_class_get_adaptor (pclass);
  adaptor      = glade_widget_adaptor_from_pspec (prop_adaptor, pspec);

  g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));

  popup_menu = gtk_menu_new ();

  glade_popup_append_item (popup_menu, _("Set default value"), TRUE,
                           glade_popup_clear_property_cb, property);

  if (!glade_property_class_get_virtual (pclass) &&
      glade_widget_adaptor_get_book (adaptor) &&
      glade_util_have_devhelp ())
    {
      glade_popup_append_item (popup_menu, _("Read _documentation"), TRUE,
                               glade_popup_property_docs_cb, property);
    }

  if (event)
    {
      button = event->button;
      event_time = event->time;
    }
  else
    {
      button = 0;
      event_time = gtk_get_current_event_time ();
    }

  gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
                  NULL, NULL, button, event_time);
}
Ejemplo n.º 2
0
static void
glade_property_load_impl (GladeProperty * property)
{
  GObject *object;
  GObjectClass *oclass;
  GParamSpec *pspec;

  pspec = glade_property_class_get_pspec (property->priv->klass);

  if (property->priv->widget == NULL ||
      glade_property_class_get_virtual (property->priv->klass) ||
      glade_property_class_get_is_packing (property->priv->klass) ||
      glade_property_class_get_ignore (property->priv->klass) ||
      !(pspec->flags & G_PARAM_READABLE) || G_IS_PARAM_SPEC_OBJECT (pspec))
    return;

  object = glade_widget_get_object (property->priv->widget);
  oclass = G_OBJECT_GET_CLASS (object);

  if (g_object_class_find_property (oclass, glade_property_class_id (property->priv->klass)))
    glade_widget_object_get_property (property->priv->widget, 
				      glade_property_class_id (property->priv->klass),
                                      property->priv->value);
}
Ejemplo n.º 3
0
static void
glade_property_sync_impl (GladeProperty * property)
{
  /* Heh, here are the many reasons not to
   * sync a property ;-)
   */
  if (/* the class can be NULL during object,
       * construction this is just a temporary state */
       property->priv->klass == NULL ||
       /* optional properties that are disabled */
       property->priv->enabled == FALSE ||
       /* explicit "never sync" flag */
       glade_property_class_get_ignore (property->priv->klass) ||
       /* recursion guards */
       property->priv->syncing >= property->priv->sync_tolerance ||
       /* No widget owns this property yet */
       property->priv->widget == NULL)
    return;

  /* Only the properties from widget->properties should affect the runtime widget.
   * (other properties may be used for convenience in the plugin).
   */
  if ((glade_property_class_get_is_packing (property->priv->klass) &&
       !glade_widget_get_pack_property (property->priv->widget, 
					glade_property_class_id (property->priv->klass)))
      || !glade_widget_get_property (property->priv->widget, 
				     glade_property_class_id (property->priv->klass)))
    return;

  property->priv->syncing++;

  /* In the case of construct_only, the widget instance must be rebuilt
   * to apply the property
   */
  if (glade_property_class_get_construct_only (property->priv->klass) && 
      property->priv->syncing == 1)
    {
      /* Virtual properties can be construct only, in which
       * case they are allowed to trigger a rebuild, and in
       * the process are allowed to get "synced" after the
       * instance is rebuilt.
       */
      if (glade_property_class_get_virtual (property->priv->klass))
        property->priv->sync_tolerance++;

      glade_widget_rebuild (property->priv->widget);

      if (glade_property_class_get_virtual (property->priv->klass))
        property->priv->sync_tolerance--;
    }
  else if (glade_property_class_get_is_packing (property->priv->klass))
    glade_widget_child_set_property (glade_widget_get_parent (property->priv->widget),
                                     property->priv->widget,
                                     glade_property_class_id (property->priv->klass), 
				     property->priv->value);
  else
    glade_widget_object_set_property (property->priv->widget,
                                      glade_property_class_id (property->priv->klass), 
				      property->priv->value);

  property->priv->syncing--;
}