Esempio n. 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);
}
Esempio n. 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);
    }
}
Esempio n. 3
0
static void
label_widget_toggled (GtkWidget *widget, GladeToolItemGroupEditor *group_editor)
{
  GladeProperty *property;
  GladeWidget   *gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (group_editor));

  if (glade_editable_loading (GLADE_EDITABLE (group_editor)) || !gwidget)
    return;

  if (!gtk_toggle_button_get_active
      (GTK_TOGGLE_BUTTON (group_editor->label_widget_radio)))
    return;

  glade_editable_block (GLADE_EDITABLE (group_editor));

  glade_command_push_group (_("Setting %s to use a custom label widget"),
                            glade_widget_get_name (gwidget));

  property = glade_widget_get_property (gwidget, "label");
  glade_command_set_property (property, NULL);
  property = glade_widget_get_property (gwidget, "custom-label");
  glade_command_set_property (property, TRUE);

  glade_command_pop_group ();

  glade_editable_unblock (GLADE_EDITABLE (group_editor));

  /* reload buttons and sensitivity and stuff... */
  glade_editable_load (GLADE_EDITABLE (group_editor), gwidget);
}
Esempio n. 4
0
static void
icon_file_toggled (GtkWidget         *widget,
		   GladeWindowEditor *window_editor)
{
  GladeWindowEditorPrivate *priv = window_editor->priv;
  GladeWidget   *gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (window_editor));
  GladeProperty *property;

  if (glade_editable_loading (GLADE_EDITABLE (window_editor)) || !gwidget)
    return;

  if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->icon_file_radio)))
    return;

  glade_editable_block (GLADE_EDITABLE (window_editor));

  glade_command_push_group (_("Setting %s to use an icon file"),
                            glade_widget_get_name (gwidget));

  property = glade_widget_get_property (gwidget, "icon-name");
  glade_command_set_property (property, NULL);
  property = glade_widget_get_property (gwidget, "icon");
  glade_command_set_property (property, NULL);
  property = glade_widget_get_property (gwidget, "glade-window-icon-name");
  glade_command_set_property (property, FALSE);

  glade_command_pop_group ();

  glade_editable_unblock (GLADE_EDITABLE (window_editor));

  /* reload buttons and sensitivity and stuff... */
  glade_editable_load (GLADE_EDITABLE (window_editor), gwidget);
}
Esempio n. 5
0
static void
glade_gtk_widget_write_atk_actions (GladeWidget * widget,
                                    GladeXmlContext * context,
                                    GladeXmlNode * node)
{
  GladeProperty *property;

  if ((property = glade_widget_get_property (widget, "atk-click")) != NULL)
    glade_gtk_widget_write_atk_action (property, context, node);
  if ((property = glade_widget_get_property (widget, "atk-activate")) != NULL)
    glade_gtk_widget_write_atk_action (property, context, node);
  if ((property = glade_widget_get_property (widget, "atk-press")) != NULL)
    glade_gtk_widget_write_atk_action (property, context, node);
  if ((property = glade_widget_get_property (widget, "atk-release")) != NULL)
    glade_gtk_widget_write_atk_action (property, context, node);
}
Esempio n. 6
0
static void
glade_gtk_widget_add2group_cb (GtkMenuItem * item, GladeWidget * gwidget)
{
  GladeWidget *group =
      g_object_get_data (G_OBJECT (item), "glade-group-widget");
  GladeWidgetAdaptor *adaptor =
      glade_widget_adaptor_get_by_type (GTK_TYPE_SIZE_GROUP);
  GList *widget_list = NULL, *new_list;
  GladeProperty *property;

  if (group)
    glade_command_push_group (_("Adding %s to Size Group %s"), 
			      glade_widget_get_name (gwidget),
                              glade_widget_get_name (group));
  else
    glade_command_push_group (_("Adding %s to a new Size Group"),
                              glade_widget_get_name (gwidget));

  if (!group)
    /* Cant cancel a size group */
    group =
        glade_command_create (adaptor, NULL, NULL,
                              glade_widget_get_project (gwidget));

  property = glade_widget_get_property (group, "widgets");
  glade_property_get (property, &widget_list);
  new_list = g_list_copy (widget_list);
  if (!g_list_find (widget_list, glade_widget_get_object (gwidget)))
    new_list = g_list_append (new_list, glade_widget_get_object (gwidget));
  glade_command_set_property (property, new_list);

  g_list_free (new_list);

  glade_command_pop_group ();
}
Esempio n. 7
0
static void
glade_gtk_widget_read_atk_props (GladeWidget * widget, GladeXmlNode * node)
{
  GladeXmlNode *atk_node;
  GladeProperty *property;
  gint i;

  glade_gtk_parse_atk_props_gtkbuilder (widget, node);

  if ((atk_node = glade_xml_search_child (node, GLADE_TAG_A11Y_A11Y)) != NULL)
    {
      /* Properties & actions */
      glade_gtk_parse_atk_props (widget, atk_node);

      /* Relations */
      for (i = 0; atk_relations_list[i]; i++)
        {
          if ((property =
               glade_widget_get_property (widget, atk_relations_list[i])))
            glade_gtk_parse_atk_relation (property, atk_node);
          else
            g_warning ("Couldnt find atk relation %s", atk_relations_list[i]);
        }
    }
}
Esempio n. 8
0
void
glade_gtk_progress_bar_set_property (GladeWidgetAdaptor * adaptor,
					GObject * object,
					const gchar * id, const GValue * value)
{
  GladeWidget *widget = glade_widget_get_from_gobject (object);
  GladeProperty *property = glade_widget_get_property (widget, id);

  if (strcmp (id, "show-text") == 0)
    {
      if (g_value_get_boolean (value))
	{
	  glade_widget_property_set_sensitive (widget, "text", TRUE, NULL);
	  glade_widget_property_set_sensitive (widget, "ellipsize", TRUE, NULL);
	}
      else
	{
	  glade_widget_property_set_sensitive (widget, "text", FALSE, TEXT_DISABLED_MSG);
	  glade_widget_property_set_sensitive (widget, "ellipsize", FALSE, TEXT_DISABLED_MSG);
	}
    }

  if (GPC_VERSION_CHECK (glade_property_get_class (property), gtk_major_version, gtk_minor_version + 1))
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value);
}
Esempio n. 9
0
void
glade_gtk_scale_set_property (GladeWidgetAdaptor *adaptor,
                              GObject            *object,
                              const gchar        *id,
                              const GValue       *value)
{
  GladeWidget *widget = glade_widget_get_from_gobject (object);
  GladeProperty *property = glade_widget_get_property (widget, id);

  if (strcmp (id, "draw-value") == 0)
    {
      if (g_value_get_boolean (value))
        {
          glade_widget_property_set_sensitive (widget, "digits", TRUE, NULL);
          glade_widget_property_set_sensitive (widget, "value-pos", TRUE, NULL);
        }
      else
        {
          glade_widget_property_set_sensitive (widget, "digits", FALSE, DRAW_VALUE_DISABLED_MSG);
          glade_widget_property_set_sensitive (widget, "value-pos", FALSE, DRAW_VALUE_DISABLED_MSG);
        }
    }

  if (GPC_VERSION_CHECK (glade_property_get_class (property), gtk_major_version, gtk_minor_version + 1))
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value);
}
Esempio n. 10
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);
    }
}
Esempio n. 11
0
void
glade_gtk_treeview_set_property (GladeWidgetAdaptor * adaptor,
				 GObject * object,
				 const gchar * id, const GValue * value)
{
  GladeWidget *widget = glade_widget_get_from_gobject (object);
  GladeProperty *property = glade_widget_get_property (widget, id);

  if (strcmp (id, "enable-search") == 0)
    {
      if (g_value_get_boolean (value))
	glade_widget_property_set_sensitive (widget, "search-column", TRUE, NULL);
      else
	glade_widget_property_set_sensitive (widget, "search-column", FALSE, _("Search is disabled"));
    }
  else if (strcmp (id, "headers-visible") == 0)
    {
      if (g_value_get_boolean (value))
	glade_widget_property_set_sensitive (widget, "headers-clickable", TRUE, NULL);
      else
	glade_widget_property_set_sensitive (widget, "headers-clickable", FALSE, _("Headers are invisible"));
    }
  else if (strcmp (id, "show-expanders") == 0)
    {
      if (g_value_get_boolean (value))
	glade_widget_property_set_sensitive (widget, "expander-column", TRUE, NULL);
      else
	glade_widget_property_set_sensitive (widget, "expander-column", FALSE, _("Expanders are not shown"));
    }

  if (GPC_VERSION_CHECK (glade_property_get_class (property), gtk_major_version, gtk_minor_version + 1))
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value);
}
Esempio n. 12
0
void
glade_gtk_read_accels (GladeWidget * widget,
                       GladeXmlNode * node, gboolean require_signal)
{
  GladeProperty *property;
  GladeXmlNode *prop;
  GladeAccelInfo *ainfo;
  GValue *value = NULL;
  GList *accels = NULL;

  for (prop = glade_xml_node_get_children (node);
       prop; prop = glade_xml_node_next (prop))
    {
      if (!glade_xml_node_verify_silent (prop, GLADE_TAG_ACCEL))
        continue;

      if ((ainfo = glade_accel_read (prop, require_signal)) != NULL)
        accels = g_list_prepend (accels, ainfo);
    }

  if (accels)
    {
      value = g_new0 (GValue, 1);
      g_value_init (value, GLADE_TYPE_ACCEL_GLIST);
      g_value_take_boxed (value, accels);

      property = glade_widget_get_property (widget, "accelerator");
      glade_property_set_value (property, value);

      g_value_unset (value);
      g_free (value);
    }
}
Esempio n. 13
0
static void
markup_toggled (GtkWidget         *widget,
		GladeWidgetEditor *widget_editor)
{
  GladeProperty *property;
  GladeWidget *gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (widget_editor));
  gboolean active;


  if (glade_editable_loading (GLADE_EDITABLE (widget_editor)) || !gwidget)
    return;

  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));

  glade_editable_block (GLADE_EDITABLE (widget_editor));

  if (active)
    {
      glade_command_push_group (_("Setting %s to use tooltip markup"),
				glade_widget_get_name (gwidget));

      transfer_text_property (gwidget, "tooltip-text", "tooltip-markup");

      property = glade_widget_get_property (gwidget, "glade-tooltip-markup");
      glade_command_set_property (property, TRUE);

      glade_command_pop_group ();
    }
  else
    {
      glade_command_push_group (_("Setting %s to not use tooltip markup"),
				glade_widget_get_name (gwidget));

      transfer_text_property (gwidget, "tooltip-markup", "tooltip-text");

      property = glade_widget_get_property (gwidget, "glade-tooltip-markup");
      glade_command_set_property (property, FALSE);

      glade_command_pop_group ();
    }

  glade_editable_unblock (GLADE_EDITABLE (widget_editor));

  /* reload widgets and sensitivity and stuff... */
  glade_editable_load (GLADE_EDITABLE (widget_editor), gwidget);
}
Esempio n. 14
0
static void
glade_gtk_widget_add2group_cb (GtkMenuItem * item, GladeWidget * gwidget)
{
  GladeWidget *group =
      g_object_get_data (G_OBJECT (item), "glade-group-widget");
  GladeWidgetAdaptor *adaptor =
      glade_widget_adaptor_get_by_type (GTK_TYPE_SIZE_GROUP);
  GList *widget_list = NULL, *new_list;
  GladeProperty *property;
  const gchar *current_name;
  const gchar *size_group_name = NULL;
  gchar *widget_name;

  /* Display "(unnamed)" for unnamed size groups */
  if (group)
    {
      size_group_name = glade_widget_get_name (group);
      if (g_str_has_prefix (size_group_name, GLADE_UNNAMED_PREFIX))
	size_group_name = _("(unnamed)");
    }

  /* Ensure the widget has a name if it's going to be referred to by a size group */
  current_name = glade_widget_get_name (gwidget);
  if (g_str_has_prefix (current_name, GLADE_UNNAMED_PREFIX))
    widget_name = glade_project_new_widget_name (glade_widget_get_project (gwidget), NULL,
						 glade_widget_adaptor_get_generic_name (glade_widget_get_adaptor (gwidget)));
  else
    widget_name = g_strdup (current_name);

  if (group)
    glade_command_push_group (_("Adding %s to Size Group %s"),
			      widget_name,
                              size_group_name);
  else
    glade_command_push_group (_("Adding %s to a new Size Group"),
                              widget_name);

  glade_command_set_name (gwidget, widget_name);

  if (!group)
    /* Cant cancel a size group */
    group =
        glade_command_create (adaptor, NULL, NULL,
                              glade_widget_get_project (gwidget));

  property = glade_widget_get_property (group, "widgets");
  glade_property_get (property, &widget_list);
  new_list = g_list_copy (widget_list);
  if (!g_list_find (widget_list, glade_widget_get_object (gwidget)))
    new_list = g_list_append (new_list, glade_widget_get_object (gwidget));
  glade_command_set_property (property, new_list);

  g_list_free (new_list);
  g_free (widget_name);

  glade_command_pop_group ();
}
Esempio n. 15
0
/* Use the font-buttons launch dialog to actually set the font-name
 * glade property through the glade-command api.
 */
static void
glade_gtk_font_button_refresh_font_name (GtkFontButton * button,
                                         GladeWidget * gbutton)
{
  GladeProperty *property;

  if ((property = glade_widget_get_property (gbutton, "font-name")) != NULL)
    glade_command_set_property (property,
                                gtk_font_button_get_font_name (button));
}
Esempio n. 16
0
static void
glade_gtk_widget_write_atk_properties (GladeWidget * widget,
                                       GladeXmlContext * context,
                                       GladeXmlNode * node)
{
  GladeXmlNode *child_node, *object_node;
  GladeProperty *name_prop, *desc_prop;

  name_prop = glade_widget_get_property (widget, "AtkObject::accessible-name");
  desc_prop =
      glade_widget_get_property (widget, "AtkObject::accessible-description");

  /* Create internal child here if any of these properties are non-null */
  if (!glade_property_default (name_prop) ||
      !glade_property_default (desc_prop))
    {
      gchar *atkname = g_strdup_printf ("%s-atkobject", glade_widget_get_name (widget));

      child_node = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
      glade_xml_node_append_child (node, child_node);

      glade_xml_node_set_property_string (child_node,
                                          GLADE_XML_TAG_INTERNAL_CHILD,
                                          GLADE_TAG_A11Y_INTERNAL_NAME);

      object_node = glade_xml_node_new (context, GLADE_XML_TAG_WIDGET);
      glade_xml_node_append_child (child_node, object_node);

      glade_xml_node_set_property_string (object_node,
                                          GLADE_XML_TAG_CLASS, "AtkObject");

      glade_xml_node_set_property_string (object_node,
                                          GLADE_XML_TAG_ID, atkname);

      if (!glade_property_default (name_prop))
        glade_gtk_widget_write_atk_property (name_prop, context, object_node);
      if (!glade_property_default (desc_prop))
        glade_gtk_widget_write_atk_property (desc_prop, context, object_node);

      g_free (atkname);
    }

}
Esempio n. 17
0
static void
use_center_child_toggled (GtkWidget            * widget,
                          GladeActionBarEditor * box_editor)
{
  GladeActionBarEditorPrivate *priv = box_editor->priv;
  GladeWidget   *gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (box_editor));
  GladeWidget   *gcenter = NULL;
  GtkWidget     *box;
  GtkWidget     *center;
  GladeProperty *property;
  gboolean       use_center_child;

  if (glade_editable_loading (GLADE_EDITABLE (box_editor)) || !gwidget)
    return;

  /* Get new desired property state */
  use_center_child = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->use_center_child));

  /* Get any existing center child */
  box = (GtkWidget *)glade_widget_get_object (gwidget);
  center = gtk_action_bar_get_center_widget (GTK_ACTION_BAR (box));

  if (center && !GLADE_IS_PLACEHOLDER (center))
    gcenter = glade_widget_get_from_gobject (center);

  glade_editable_block (GLADE_EDITABLE (box_editor));

  if (use_center_child)
    glade_command_push_group (_("Setting %s to use a center child"),
                              glade_widget_get_name (gwidget));
  else
    glade_command_push_group (_("Setting %s to not use a center child"),
                              glade_widget_get_name (gwidget));

  /* If a project widget exists when were disabling center child, it needs
   * to be removed first as a part of the issuing GladeCommand group
   */
  if (gcenter)
    {
      GList list;
      list.prev = list.next = NULL;
      list.data = gcenter;
      glade_command_delete (&list);
    }

  property = glade_widget_get_property (gwidget, "use-center-child");
  glade_command_set_property (property, use_center_child);

  glade_command_pop_group ();

  glade_editable_unblock (GLADE_EDITABLE (box_editor));

  /* reload buttons and sensitivity and stuff... */
  glade_editable_load (GLADE_EDITABLE (box_editor), gwidget);
}
Esempio n. 18
0
void
glade_gtk_tool_item_set_property (GladeWidgetAdaptor * adaptor,
                                  GObject * object,
                                  const gchar * id, const GValue * value)
{
  GladeWidget *gwidget = glade_widget_get_from_gobject (object);
  GladeProperty *property = glade_widget_get_property (gwidget, id);

  if (GPC_VERSION_CHECK
      (glade_property_get_class (property), gtk_major_version, gtk_minor_version + 1))
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id,
                                                      value);
}
Esempio n. 19
0
static void
transfer_text_property (GladeWidget *gwidget,
			const gchar *from,
			const gchar *to)
{
  gchar *value = NULL;
  gchar *comment = NULL, *context = NULL;
  gboolean translatable = FALSE;
  GladeProperty *prop_from;
  GladeProperty *prop_to;

  prop_from = glade_widget_get_property (gwidget, from);
  prop_to   = glade_widget_get_property (gwidget, to);
  g_assert (prop_from);
  g_assert (prop_to);

  glade_property_get (prop_from, &value);
  comment      = (gchar *)glade_property_i18n_get_comment (prop_from);
  context      = (gchar *)glade_property_i18n_get_context (prop_from);
  translatable = glade_property_i18n_get_translatable (prop_from);

  /* Get our own copies */
  value   = g_strdup (value);
  context = g_strdup (context);
  comment = g_strdup (comment);

  /* Set target values */
  glade_command_set_property (prop_to, value);
  glade_command_set_i18n (prop_to, translatable, context, comment);

  /* Clear source values */
  glade_command_set_property (prop_from, NULL);
  glade_command_set_i18n (prop_from, TRUE, NULL, NULL);

  g_free (value);
  g_free (comment);
  g_free (context);
}
Esempio n. 20
0
void
glade_gtk_image_read_widget (GladeWidgetAdaptor *adaptor,
                             GladeWidget        *widget,
                             GladeXmlNode       *node)
{
  GladeProperty *property;

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

  /* First chain up and read in all the normal properties.. */
  GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node);

  if (glade_widget_property_original_default (widget, "icon-name") == FALSE)
    {
      property = glade_widget_get_property (widget, "icon-name");
      glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_ICON);
    }
  else if (glade_widget_property_original_default (widget, "resource") == FALSE)
    {
      property = glade_widget_get_property (widget, "resource");
      glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_RESOURCE);
    }
  else if (glade_widget_property_original_default (widget, "pixbuf") == FALSE)
    {
      property = glade_widget_get_property (widget, "pixbuf");
      glade_widget_property_set (widget, "image-mode",
                                 GLADE_IMAGE_MODE_FILENAME);
    }
  else  /*  if (glade_widget_property_original_default (widget, "stock") == FALSE) */
    {
      property = glade_widget_get_property (widget, "stock");
      glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_STOCK);
    }

  glade_property_sync (property);
}
Esempio n. 21
0
void
glade_gtk_header_bar_child_action_activate (GladeWidgetAdaptor * adaptor,
                                            GObject * container,
                                            GObject * object,
                                            const gchar * action_path)
{
  if (strcmp (action_path, "remove_slot") == 0)
    {
      GladeWidget *parent;
      GladeProperty *property;

      parent = glade_widget_get_from_gobject (container);
      glade_command_push_group (_("Remove placeholder from %s"), glade_widget_get_name (parent));

      if (g_object_get_data (object, "special-child-type"))
        {
          property = glade_widget_get_property (parent, "use-custom-title");
          glade_command_set_property (property, FALSE);
        }
      else
        {
          gint size;

          gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (object));

          property = glade_widget_get_property (parent, "size");
          glade_property_get (property, &size);
          glade_command_set_property (property, size - 1);
        }

      glade_command_pop_group ();
    }
  else
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_action_activate (adaptor,
                                                               container,
                                                               object,
                                                               action_path);
}
Esempio n. 22
0
static void
glade_gtk_size_group_read_widgets (GladeWidget * widget, GladeXmlNode * node)
{
  GladeXmlNode *widgets_node;
  GladeProperty *property;
  gchar *string = NULL;

  if ((widgets_node =
       glade_xml_search_child (node, GLADE_TAG_SIZEGROUP_WIDGETS)) != NULL)
    {
      GladeXmlNode *node;

      for (node = glade_xml_node_get_children (widgets_node);
           node; node = glade_xml_node_next (node))
        {
          gchar *widget_name, *tmp;

          if (!glade_xml_node_verify (node, GLADE_TAG_SIZEGROUP_WIDGET))
            continue;

          widget_name = glade_xml_get_property_string_required
              (node, GLADE_TAG_NAME, NULL);

          if (string == NULL)
            string = widget_name;
          else if (widget_name != NULL)
            {
              tmp =
                  g_strdup_printf ("%s%s%s", string, GPC_OBJECT_DELIMITER,
                                   widget_name);
              string = (g_free (string), tmp);
              g_free (widget_name);
            }
        }
    }


  if (string)
    {
      property = glade_widget_get_property (widget, "widgets");
      g_assert (property);

      /* we must synchronize this directly after loading this project
       * (i.e. lookup the actual objects after they've been parsed and
       * are present).
       */
      g_object_set_data_full (G_OBJECT (property),
                              "glade-loaded-object", string, g_free);
    }
}
Esempio n. 23
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);
}
Esempio n. 24
0
void
glade_gtk_button_set_property (GladeWidgetAdaptor * adaptor,
                               GObject * object,
                               const gchar * id, const GValue * value)
{
  GladeWidget *widget = glade_widget_get_from_gobject (object);
  GladeProperty *property = glade_widget_get_property (widget, id);

  if (strcmp (id, "custom-child") == 0)
    {
      GtkWidget *child = gtk_bin_get_child (GTK_BIN (object));
      gboolean custom_child = g_value_get_boolean (value);

      /* Avoid removing a child if we already have a custom child */
      if (custom_child && (child && glade_widget_get_from_gobject (child)))
        return;

      if (custom_child)
        {
          if (child)
            gtk_container_remove (GTK_CONTAINER (object), child);

          gtk_container_add (GTK_CONTAINER (object), glade_placeholder_new ());
        }
      else if (child && GLADE_IS_PLACEHOLDER (child))
        gtk_container_remove (GTK_CONTAINER (object), child);
    }
  else if (strcmp (id, "stock") == 0)
    {
      gboolean use_stock = FALSE;
      glade_widget_property_get (widget, "use-stock", &use_stock);

      if (use_stock)
        gtk_button_set_label (GTK_BUTTON (object), g_value_get_string (value));
    }
  else if (strcmp (id, "use-stock") == 0)
    {
      /* I guess its my bug in GTK+, we need to resync the appearance property
       * on GtkButton when the GtkButton:use-stock property changes.
       */
      GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
                                                        id, value);
      glade_gtk_sync_use_appearance (widget);
    }
  else if (GPC_VERSION_CHECK (glade_property_get_class (property), gtk_major_version, gtk_minor_version + 1))
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value);
}
Esempio n. 25
0
void
glade_gtk_menu_item_set_property (GladeWidgetAdaptor * adaptor,
                                  GObject * object,
                                  const gchar * id, const GValue * value)
{
  GladeWidget *gwidget = glade_widget_get_from_gobject (object);
  GladeProperty *property = glade_widget_get_property (gwidget, id);

  if (!strcmp (id, "use-underline"))
    glade_gtk_menu_item_set_use_underline (object, value);
  else if (!strcmp (id, "label"))
    glade_gtk_menu_item_set_label (object, value);
  else if (GPC_VERSION_CHECK
           (glade_property_get_class (property), gtk_major_version, gtk_minor_version + 1))
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id,
                                                      value);
}
Esempio n. 26
0
static void
glade_gtk_widget_write_atk_relations (GladeWidget * widget,
                                      GladeXmlContext * context,
                                      GladeXmlNode * node)
{
  GladeProperty *property;
  gint i;

  for (i = 0; atk_relations_list[i]; i++)
    {
      if ((property =
           glade_widget_get_property (widget, atk_relations_list[i])))
        glade_gtk_widget_write_atk_relation (property, context, node);
      else
        g_warning ("Couldnt find atk relation %s on widget %s",
                   atk_relations_list[i], glade_widget_get_name (widget));
    }
}
Esempio n. 27
0
/* Shared with other classes */
void 
glade_gtk_sync_use_appearance (GladeWidget *gwidget)
{
  GladeProperty *prop;
  gboolean       use_appearance;

  /* This is the kind of thing we avoid doing at project load time ;-) */
  if (glade_widget_superuser ())
    return;

  prop = glade_widget_get_property (gwidget, "use-action-appearance");
  use_appearance = FALSE;
  
  glade_property_get (prop, &use_appearance);
  if (use_appearance)
    {
      glade_property_set (prop, FALSE);
      glade_property_set (prop, TRUE);
    }
}
Esempio n. 28
0
void
glade_gtk_write_accels (GladeWidget * widget,
                        GladeXmlContext * context,
                        GladeXmlNode * node, gboolean write_signal)
{
  GladeXmlNode *accel_node;
  GladeProperty *property;
  GList *list;

  /* Some child widgets may have disabled the property */
  if (!(property = glade_widget_get_property (widget, "accelerator")))
    return;

  for (list = g_value_get_boxed (glade_property_inline_value (property)); list; list = list->next)
    {
      GladeAccelInfo *accel = list->data;

      accel_node = glade_accel_write (accel, context, write_signal);
      glade_xml_node_append_child (node, accel_node);
    }
}
Esempio n. 29
0
static void
glade_gtk_entry_changed (GtkEditable * editable, GladeWidget * gentry)
{
  const gchar *text, *text_prop;
  GladeProperty *prop;
  gboolean use_buffer;

  if (glade_widget_superuser ())
    return;

  text = gtk_entry_get_text (GTK_ENTRY (editable));

  glade_widget_property_get (gentry, "text", &text_prop);
  glade_widget_property_get (gentry, "use-entry-buffer", &use_buffer);

  if (use_buffer == FALSE && g_strcmp0 (text, text_prop))
    {
      if ((prop = glade_widget_get_property (gentry, "text")))
        glade_command_set_property (prop, text);
    }
}
Esempio n. 30
0
void
glade_gtk_button_write_widget (GladeWidgetAdaptor * adaptor,
                               GladeWidget * widget,
                               GladeXmlContext * context, GladeXmlNode * node)
{
  GladeProperty *prop;
  gboolean use_stock;
  gchar *stock = NULL;

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

  /* Do not save GtkColorButton GtkFontButton and GtkScaleButton label property */
  if (!(GTK_IS_COLOR_BUTTON (glade_widget_get_object (widget)) ||
	GTK_IS_FONT_BUTTON (glade_widget_get_object (widget)) ||
	GTK_IS_SCALE_BUTTON (glade_widget_get_object (widget))))
    {
      /* Make a copy of the GladeProperty, 
       * override its value and ensure non-translatable if use-stock is TRUE
       */
      prop = glade_widget_get_property (widget, "label");
      prop = glade_property_dup (prop, widget);
      glade_widget_property_get (widget, "use-stock", &use_stock);
      if (use_stock)
        {
          glade_widget_property_get (widget, "stock", &stock);
          glade_property_i18n_set_translatable (prop, FALSE);
          glade_property_set (prop, stock);
        }
      glade_property_write (prop, context, node);
      g_object_unref (G_OBJECT (prop));
    }

  /* Write out other normal properties and any other class derived custom properties after ... */
  GWA_GET_CLASS (GTK_TYPE_CONTAINER)->write_widget (adaptor, widget, context,
                                                    node);

}