示例#1
0
static void
sync_row_positions (GtkListBox *listbox)
{
  GList *l, *rows;
  int position;
  static gboolean recursion = FALSE;

  /* Avoid feedback loop */
  if (recursion)
    return;

  rows = gtk_container_get_children (GTK_CONTAINER (listbox));

  position = 0;
  for (l = rows; l; l = g_list_next (l))
    {
      gint old_position;

      glade_widget_pack_property_get (glade_widget_get_from_gobject (l->data),
                                      "position", &old_position);
      if (position != old_position)
        {
          /* Update glade with the new value */
          recursion = TRUE;
          glade_widget_pack_property_set (glade_widget_get_from_gobject (l->data),
                                          "position", position);
          recursion = FALSE;
        }

      position++;
    }

  g_list_free (rows);
}
void
glade_gtk_header_bar_add_child (GladeWidgetAdaptor *adaptor,
                                GObject *parent,
                                GObject *child)
{
  GladeWidget *gbox, *gchild;
  gint size;
  gchar *special_child_type;

  gchild = glade_widget_get_from_gobject (child);
  if (gchild)
    glade_widget_set_pack_action_visible (gchild, "remove_slot", FALSE);

  special_child_type = g_object_get_data (child, "special-child-type");

  d(g_message ("Add %s %p (special: %s)",
	       GLADE_IS_PLACEHOLDER (child) ? "placeholder" : "child",
	       child, special_child_type));

  if (special_child_type && !strcmp (special_child_type, "title"))
    {
      gtk_header_bar_set_custom_title (GTK_HEADER_BAR (parent), GTK_WIDGET (child));
      return;
    }

  GWA_GET_CLASS (GTK_TYPE_CONTAINER)->add (adaptor, parent, child);
  
  gbox = glade_widget_get_from_gobject (parent);
  if (!glade_widget_superuser ())
    {
      glade_widget_property_get (gbox, "size", &size);
      glade_widget_property_set (gbox, "size", size);
    }
}
示例#3
0
static gint
sort_box_children (GtkWidget * widget_a, GtkWidget * widget_b, GtkWidget *box)
{
  GladeWidget *gwidget_a, *gwidget_b;
  gint position_a, position_b;

  gwidget_a = glade_widget_get_from_gobject (widget_a);
  gwidget_b = glade_widget_get_from_gobject (widget_b);

  /* Indirect children might be internal children, sort internal children before any other children */
  if (box != gtk_widget_get_parent (widget_a))
    return -1;
  if (box != gtk_widget_get_parent (widget_b))
    return 1;

  if (gtk_box_get_center_widget (GTK_BOX (box)) == widget_a)
    return -1;
  if (gtk_box_get_center_widget (GTK_BOX (box)) == widget_b)
    return -1;

  /* XXX Sometimes the packing "position" property doesnt exist here, why ?
   */
  if (gwidget_a)
    glade_widget_pack_property_get (gwidget_a, "position", &position_a);
  else
    gtk_container_child_get (GTK_CONTAINER (box),
                             widget_a, "position", &position_a, NULL);

  if (gwidget_b)
    glade_widget_pack_property_get (gwidget_b, "position", &position_b);
  else
    gtk_container_child_get (GTK_CONTAINER (box),
                             widget_b, "position", &position_b, NULL);
  return position_a - position_b;
}
static gint
sort_children (GtkWidget * widget_a, GtkWidget * widget_b, GtkWidget *box)
{
  GladeWidget *gwidget_a, *gwidget_b;
  gint position_a, position_b;

  gwidget_a = glade_widget_get_from_gobject (widget_a);
  gwidget_b = glade_widget_get_from_gobject (widget_b);

  /* Sort internal children before any other children */
  if (box != gtk_widget_get_parent (widget_a))
    return -1;
  if (box != gtk_widget_get_parent (widget_b))
    return 1;

  if (gtk_action_bar_get_center_widget (GTK_ACTION_BAR (box)) == widget_a)
    return -1;
  if (gtk_action_bar_get_center_widget (GTK_ACTION_BAR (box)) == widget_b)
    return -1;

  if (gwidget_a)
    glade_widget_pack_property_get (gwidget_a, "position", &position_a);
  else
    gtk_container_child_get (GTK_CONTAINER (box),
                             widget_a, "position", &position_a, NULL);

  if (gwidget_b)
    glade_widget_pack_property_get (gwidget_b, "position", &position_b);
  else
    gtk_container_child_get (GTK_CONTAINER (box),
                             widget_b, "position", &position_b, NULL);

  return position_a - position_b;
}
示例#5
0
static void
glade_property_update_prop_refs (GladeProperty * property,
                                 const GValue * old_value,
                                 const GValue * new_value)
{
  GladeWidget *gold, *gnew;
  GObject *old_object, *new_object;
  GList *old_list, *new_list, *list, *removed, *added;

  if (GLADE_IS_PARAM_SPEC_OBJECTS (glade_property_class_get_pspec (property->priv->klass)))
    {
      /* Make our own copies incase we're walking an
       * unstable list
       */
      old_list = g_value_dup_boxed (old_value);
      new_list = g_value_dup_boxed (new_value);

      /* Diff up the GList */
      removed = glade_util_removed_from_list (old_list, new_list);
      added = glade_util_added_in_list (old_list, new_list);

      /* Adjust the appropriate prop refs */
      for (list = removed; list; list = list->next)
        {
          old_object = list->data;
          gold = glade_widget_get_from_gobject (old_object);
          if (gold != NULL)
            glade_widget_remove_prop_ref (gold, property);
        }
      for (list = added; list; list = list->next)
        {
          new_object = list->data;
          gnew = glade_widget_get_from_gobject (new_object);
          if (gnew != NULL)
            glade_widget_add_prop_ref (gnew, property);
        }

      g_list_free (removed);
      g_list_free (added);
      g_list_free (old_list);
      g_list_free (new_list);
    }
  else
    {
      if ((old_object = g_value_get_object (old_value)) != NULL)
        {
          gold = glade_widget_get_from_gobject (old_object);
          g_return_if_fail (gold != NULL);
          glade_widget_remove_prop_ref (gold, property);
        }

      if ((new_object = g_value_get_object (new_value)) != NULL)
        {
          gnew = glade_widget_get_from_gobject (new_object);
          g_return_if_fail (gnew != NULL);
          glade_widget_add_prop_ref (gnew, property);
        }
    }
}
static void
glade_gtk_header_bar_set_size (GObject * object,
                               const GValue * value)
{
  GList *l, *next, *children;
  GtkWidget *child;
  guint new_size, old_size, i;

  g_return_if_fail (GTK_IS_HEADER_BAR (object));

  d(g_message ("Setting size to %d", g_value_get_int (value)));

  if (glade_util_object_is_loading (object))
    return;

  children = gtk_container_get_children (GTK_CONTAINER (object));
  l = children;
  while (l)
    {
      next = l->next;
      if (l->data == gtk_header_bar_get_custom_title (GTK_HEADER_BAR (object)) ||
          (!glade_widget_get_from_gobject (l->data) && !GLADE_IS_PLACEHOLDER (l->data)))
        children = g_list_delete_link (children, l);
      l = next;
    }
 
  old_size = g_list_length (children);
  new_size = g_value_get_int (value);

  if (old_size == new_size)
    {
      g_list_free (children);
      return;
    }

  for (i = old_size; i < new_size; i++)
    {
      GtkWidget *placeholder = glade_placeholder_new ();
      gtk_header_bar_pack_start (GTK_HEADER_BAR (object), placeholder);
    }
  for (l = g_list_last (children); l && old_size > new_size; l = l->prev)
    {
      child = l->data;
      if (glade_widget_get_from_gobject (child) || !GLADE_IS_PLACEHOLDER (child))
        continue;

      gtk_container_remove (GTK_CONTAINER (object), child);
      old_size--;
    }

  g_list_free (children);
}
void
glade_gtk_action_bar_add_child (GladeWidgetAdaptor * adaptor,
                                GObject * object,
                                GObject * child)
{
  GladeWidget *gbox, *gchild;
  gint num_children;
  gchar *special_child_type;

  gbox = glade_widget_get_from_gobject (object);

  special_child_type = g_object_get_data (child, "special-child-type");
  if (special_child_type && !strcmp (special_child_type, "center"))
    {
      gtk_action_bar_set_center_widget (GTK_ACTION_BAR (object), GTK_WIDGET (child));
       return;
    }

  /*
     Try to remove the last placeholder if any, this way GtkBox`s size 
     will not be changed.
   */
  if (!glade_widget_superuser () && !GLADE_IS_PLACEHOLDER (child))
    {
      GList *l, *children;

      children = gtk_container_get_children (GTK_CONTAINER (object));
      for (l = g_list_last (children); l; l = g_list_previous (l))
        {
          GtkWidget *child_widget = l->data;
          if (GLADE_IS_PLACEHOLDER (child_widget))
            {
              gtk_container_remove (GTK_CONTAINER (object), child_widget);
              break;
            }
        }
      g_list_free (children);
    }

  gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
  num_children = glade_gtk_action_bar_get_num_children (object);
  glade_widget_property_set (gbox, "size", num_children);

  if (glade_widget_superuser ())
    return;
  
  gchild = glade_widget_get_from_gobject (child);

  /* Packing props arent around when parenting during a glade_widget_dup() */
  if (gchild && glade_widget_get_packing_properties (gchild))
    glade_widget_pack_property_set (gchild, "position", num_children - 1);
}
示例#8
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);
}
static void
glade_gtk_tool_button_set_image_mode (GObject * object, const GValue * value)
{
  GladeWidget *gbutton;

  g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
  gbutton = glade_widget_get_from_gobject (object);

  glade_widget_property_set_sensitive (gbutton, "stock-id", FALSE, NOT_SELECTED_MSG);
  glade_widget_property_set_sensitive (gbutton, "icon-name", FALSE, NOT_SELECTED_MSG);
  glade_widget_property_set_sensitive (gbutton, "icon-widget", FALSE, NOT_SELECTED_MSG);

  switch (g_value_get_int (value))
    {
      case GLADE_TB_MODE_STOCK:
        glade_widget_property_set_sensitive (gbutton, "stock-id", TRUE, NULL);
        break;
      case GLADE_TB_MODE_ICON:
        glade_widget_property_set_sensitive (gbutton, "icon-name", TRUE, NULL);
        break;
      case GLADE_TB_MODE_CUSTOM:
        glade_widget_property_set_sensitive (gbutton, "icon-widget", TRUE, NULL);
        break;
      default:
        break;
    }
}
示例#10
0
void
glade_gtk_box_post_create (GladeWidgetAdaptor * adaptor,
                           GObject * container, GladeCreateReason reason)
{
  GladeWidget *gwidget = glade_widget_get_from_gobject (container);
  GladeProject *project = glade_widget_get_project (gwidget);

  /* Implement drag in GtkBox but not resize.
   */
  g_object_set (gwidget, "can-resize", FALSE, NULL);

  g_signal_connect (G_OBJECT (gwidget), "configure-child",
                    G_CALLBACK (glade_gtk_box_configure_child), container);

  g_signal_connect (G_OBJECT (gwidget), "configure-begin",
                    G_CALLBACK (glade_gtk_box_configure_begin), container);

  g_signal_connect (G_OBJECT (gwidget), "configure-end",
                    G_CALLBACK (glade_gtk_box_configure_end), container);

  if (reason == GLADE_CREATE_LOAD)
    {
      g_signal_connect_object (project, "parse-finished",
                               G_CALLBACK (glade_gtk_box_parse_finished),
                               gwidget, 0);
    }
}
示例#11
0
void
glade_gtk_treeview_replace_child (GladeWidgetAdaptor * adaptor,
                                  GObject * container,
                                  GObject * current, GObject * new_column)
{
  GtkTreeView *view = GTK_TREE_VIEW (container);
  GList *columns;
  GtkTreeViewColumn *column;
  GladeWidget *gcolumn;
  gint index;

  if (!GTK_IS_TREE_VIEW_COLUMN (current))
    return;

  column = GTK_TREE_VIEW_COLUMN (current);

  columns = gtk_tree_view_get_columns (view);
  index = g_list_index (columns, column);
  g_list_free (columns);

  gtk_tree_view_remove_column (view, column);
  column = GTK_TREE_VIEW_COLUMN (new_column);

  gtk_tree_view_insert_column (view, column, index);

  if (gtk_tree_view_get_fixed_height_mode (view))
    {
      gcolumn = glade_widget_get_from_gobject (column);
      glade_widget_property_set (gcolumn, "sizing", GTK_TREE_VIEW_COLUMN_FIXED);
      glade_widget_property_set_sensitive (gcolumn, "sizing", FALSE,
                                           INSENSITIVE_COLUMN_SIZING_MSG);
    }

  glade_gtk_cell_layout_sync_attributes (G_OBJECT (column));
}
示例#12
0
void
glade_gtk_action_bar_remove_child (GladeWidgetAdaptor * adaptor,
                                   GObject * object,
                                   GObject * child)
{
  GladeWidget *gbox;
  gint size;
  gchar *special_child_type;

  gbox = glade_widget_get_from_gobject (object);

  special_child_type = g_object_get_data (child, "special-child-type");
  if (special_child_type && !strcmp (special_child_type, "center"))
    {
      GtkWidget *w;

      w = glade_placeholder_new ();
      g_object_set_data (G_OBJECT (w), "special-child-type", "center");
      gtk_action_bar_set_center_widget (GTK_ACTION_BAR (object), w);
      return;
    }

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

  if (!glade_widget_superuser ())
    {
      glade_widget_property_get (gbox, "size", &size);
      glade_widget_property_set (gbox, "size", size);
    }
}
示例#13
0
static gboolean
glade_gtk_action_bar_verify_size (GObject *object, const GValue *value)
{
  GList *child, *children;
  gint old_size, count = 0;
  gint new_size = g_value_get_int (value);
  
  children = gtk_container_get_children (GTK_CONTAINER (object));
  children = g_list_remove (children, gtk_action_bar_get_center_widget (GTK_ACTION_BAR (object)));
  old_size = g_list_length (children);

  for (child = g_list_last (children);
       child && old_size > new_size;
       child = g_list_previous (child))
    {
      GtkWidget *widget = child->data;
      if (glade_widget_get_from_gobject (widget) != NULL)
        count++;
      else
        old_size--;
    }

  g_list_free (children);

  return count > new_size ? FALSE : new_size >= 0;
}
示例#14
0
static void
glade_gtk_grid_set_n_common (GObject      *object,
                             const GValue *value,
                             gboolean      for_rows)
{
  GladeWidget *widget;
  GtkGrid *grid;
  guint new_size, n_columns, n_rows;

  grid = GTK_GRID (object);
  widget = glade_widget_get_from_gobject (GTK_WIDGET (grid));

  glade_widget_property_get (widget, "n-columns", &n_columns);
  glade_widget_property_get (widget, "n-rows", &n_rows);

  new_size = g_value_get_uint (value);

  if (new_size < 1)
    return;

  if (glade_gtk_grid_widget_exceeds_bounds
      (grid, for_rows ? new_size : n_rows, for_rows ? n_columns : new_size))
    /* Refuse to shrink if it means orphaning widgets */
    return;

  /* Fill grid with placeholders */
  glade_gtk_grid_refresh_placeholders (grid, FALSE);
}
示例#15
0
static gboolean
glade_gtk_box_configure_end (GladeFixed * fixed,
                             GladeWidget * child, GtkWidget * box)
{
  GList *list, *l, *children;
  GList *prop_list = NULL;

  children = gtk_container_get_children (GTK_CONTAINER (box));

  for (list = children; list; list = list->next)
    {
      GtkWidget *bchild = list->data;

      for (l = glade_gtk_box_original_positions; l; l = l->next)
        {
          GladeGtkBoxChild *gbchild = l->data;
          GladeWidget *gchild = glade_widget_get_from_gobject (gbchild->widget);


          if (bchild == gbchild->widget)
            {
              GCSetPropData *prop_data = g_new0 (GCSetPropData, 1);
              prop_data->property =
                  glade_widget_get_pack_property (gchild, "position");

              prop_data->old_value = g_new0 (GValue, 1);
              prop_data->new_value = g_new0 (GValue, 1);

              glade_property_get_value (prop_data->property,
                                        prop_data->new_value);

              g_value_init (prop_data->old_value, G_TYPE_INT);
              g_value_set_int (prop_data->old_value, gbchild->position);

              prop_list = g_list_prepend (prop_list, prop_data);
              break;
            }
        }
    }

  g_list_free (children);

  glade_command_push_group (_("Ordering children of %s"),
                            glade_widget_get_name (GLADE_WIDGET (fixed)));
  glade_property_push_superuser ();
  if (prop_list)
    glade_command_set_properties_list (glade_widget_get_project (GLADE_WIDGET (fixed)),
                                       prop_list);
  glade_property_pop_superuser ();
  glade_command_pop_group ();

  for (l = glade_gtk_box_original_positions; l; l = l->next)
    g_free (l->data);

  glade_gtk_box_original_positions =
      (g_list_free (glade_gtk_box_original_positions), NULL);


  return TRUE;
}
示例#16
0
static void
glade_gtk_listbox_child_insert_action (GladeWidgetAdaptor *adaptor,
                                       GObject            *container,
                                       GObject            *object,
                                       const gchar        *group_format,
                                       gboolean            after)
{
  GladeWidget *parent;
  GladeWidget *gchild;
  gint position;

  parent = glade_widget_get_from_gobject (container);
  glade_command_push_group (group_format, glade_widget_get_name (parent));

  position = gtk_list_box_row_get_index (GTK_LIST_BOX_ROW (object));
  if (after)
    position++;

  gchild = glade_command_create (glade_widget_adaptor_get_by_type (GTK_TYPE_LIST_BOX_ROW),
                                 parent,
                                 NULL,
                                 glade_widget_get_project (parent));
  glade_widget_pack_property_set (gchild, "position", position);

  glade_command_pop_group ();
}
示例#17
0
static void
glade_gtk_size_group_write_widgets (GladeWidget * widget,
                                    GladeXmlContext * context,
                                    GladeXmlNode * node)
{
  GladeXmlNode *widgets_node, *widget_node;
  GList *widgets = NULL, *list;
  GladeWidget *awidget;

  widgets_node = glade_xml_node_new (context, GLADE_TAG_SIZEGROUP_WIDGETS);

  if (glade_widget_property_get (widget, "widgets", &widgets))
    {
      for (list = widgets; list; list = list->next)
        {
          awidget = glade_widget_get_from_gobject (list->data);
          widget_node =
              glade_xml_node_new (context, GLADE_TAG_SIZEGROUP_WIDGET);
          glade_xml_node_append_child (widgets_node, widget_node);
          glade_xml_node_set_property_string (widget_node, GLADE_TAG_NAME,
                                              glade_widget_get_name (awidget));
        }
    }

  if (!glade_xml_node_get_children (widgets_node))
    glade_xml_node_delete (widgets_node);
  else
    glade_xml_node_append_child (node, widgets_node);

}
示例#18
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);
}
示例#19
0
void
glade_gtk_button_post_create (GladeWidgetAdaptor * adaptor,
                              GObject * button, GladeCreateReason reason)
{
  GladeWidget *gbutton = glade_widget_get_from_gobject (button);

  g_return_if_fail (GTK_IS_BUTTON (button));
  g_return_if_fail (GLADE_IS_WIDGET (gbutton));

  if (GTK_IS_FONT_BUTTON (button))
    g_signal_connect
        (button, "font-set",
         G_CALLBACK (glade_gtk_font_button_refresh_font_name), gbutton);
  else if (GTK_IS_COLOR_BUTTON (button))
    g_signal_connect
        (button, "color-set",
         G_CALLBACK (glade_gtk_color_button_refresh_color), gbutton);

  /* Disabled response-id until its in an action area */
  glade_widget_property_set_sensitive (gbutton, "response-id", FALSE,
                                       RESPID_INSENSITIVE_MSG);

  if (reason == GLADE_CREATE_USER)
    glade_gtk_button_update_stock (gbutton);
}
void
glade_gtk_tool_palette_add_child (GladeWidgetAdaptor * adaptor,
				  GObject * object, GObject * child)
{
  GtkToolPalette *palette;
  GtkToolItemGroup *group;

  g_return_if_fail (GTK_IS_TOOL_PALETTE (object));
  g_return_if_fail (GTK_IS_TOOL_ITEM_GROUP (child));

  palette = GTK_TOOL_PALETTE (object);
  group   = GTK_TOOL_ITEM_GROUP (child);

  gtk_container_add (GTK_CONTAINER (palette), GTK_WIDGET (group));

  if (glade_util_object_is_loading (object))
    {
      GladeWidget *gchild = glade_widget_get_from_gobject (child);

      /* Packing props arent around when parenting during a glade_widget_dup() */
      if (gchild && glade_widget_get_packing_properties (gchild))
	glade_widget_pack_property_set (gchild, "position",
					gtk_tool_palette_get_group_position (palette, group));
    }
}
示例#21
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);
}
示例#22
0
static void
glade_gtk_window_write_accel_groups (GladeWidget * widget,
                                     GladeXmlContext * context,
                                     GladeXmlNode * node)
{
  GladeXmlNode *groups_node, *group_node;
  GList *groups = NULL, *list;
  GladeWidget *agroup;

  groups_node = glade_xml_node_new (context, GLADE_TAG_ACCEL_GROUPS);

  if (glade_widget_property_get (widget, "accel-groups", &groups))
    {
      for (list = groups; list; list = list->next)
        {
          agroup = glade_widget_get_from_gobject (list->data);
          group_node = glade_xml_node_new (context, GLADE_TAG_ACCEL_GROUP);
          glade_xml_node_append_child (groups_node, group_node);
          glade_xml_node_set_property_string (group_node, GLADE_TAG_NAME,
                                              glade_widget_get_name (agroup));
        }
    }

  if (!glade_xml_node_get_children (groups_node))
    glade_xml_node_delete (groups_node);
  else
    glade_xml_node_append_child (node, groups_node);

}
示例#23
0
static void
glade_gtk_grid_parse_finished (GladeProject *project, GObject *container)
{
  GladeWidget *gwidget = glade_widget_get_from_gobject (container);
  GladeGridAttachments attach;
  GList *list, *children;
  gint row = 0, column = 0, n_row = 0, n_column = 0;

  children = gtk_container_get_children (GTK_CONTAINER (container));

  for (list = children; list; list = list->next)
    {
      GtkWidget *widget = list->data;

      if (GLADE_IS_PLACEHOLDER (widget)) continue;

      glade_gtk_grid_get_child_attachments (GTK_WIDGET (container), widget, &attach);

      n_row = attach.top_attach + attach.height;
      n_column = attach.left_attach + attach.width;

      if (row < n_row) row = n_row;
      if (column < n_column) column = n_column;
    }

  if (column) glade_widget_property_set (gwidget, "n-columns", column);
  if (row) glade_widget_property_set (gwidget, "n-rows", row);

  g_list_free (children);

  /* Refresh placeholders only once after the project is finished parsing */
  glade_gtk_grid_refresh_placeholders (GTK_GRID (container), TRUE);
}
示例#24
0
void
glade_gtk_box_remove_child (GladeWidgetAdaptor * adaptor,
                            GObject * object, GObject * child)
{
  GladeWidget *gbox;
  gint size;
  gchar *special_child_type;

  g_return_if_fail (GTK_IS_BOX (object));
  g_return_if_fail (GTK_IS_WIDGET (child));

  gbox = glade_widget_get_from_gobject (object);

  special_child_type = g_object_get_data (child, "special-child-type");
  if (special_child_type && !strcmp (special_child_type, "center"))
    {
      GtkWidget *w;

      w = glade_placeholder_new ();
      g_object_set_data (G_OBJECT (w), "special-child-type", "center");
      gtk_box_set_center_widget (GTK_BOX (object), w);
      return;
    }

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

  if (glade_widget_superuser () == FALSE)
    {
      glade_widget_property_get (gbox, "size", &size);
      glade_widget_property_set (gbox, "size", size);
    }

  fix_response_id_on_child (gbox, child, FALSE);
}
示例#25
0
static void
on_template_checkbutton_toggled (GtkToggleButton        *togglebutton,
                                 GladeProjectProperties *properties)
{
  GladeProjectPropertiesPrivate *priv = properties->priv;

  if (priv->ignore_ui_cb)
    return;
  
  if (gtk_toggle_button_get_active (togglebutton))
    {
      gboolean composite = FALSE;
      GList *l;

      for (l = glade_project_toplevels (priv->project); l; l = l->next)
	{
	  GObject *object = l->data;
	  GladeWidget *gwidget;

	  gwidget = glade_widget_get_from_gobject (object);

	  if (GTK_IS_WIDGET (object))
	    {
	      glade_command_set_project_template (priv->project, gwidget);
	      composite = TRUE;
	      break;
	    }
	}

      if (!composite)
	gtk_toggle_button_set_active (togglebutton, FALSE);
    }
  else
    glade_command_set_project_template (priv->project, NULL);
}
示例#26
0
void
glade_gtk_header_bar_set_property (GladeWidgetAdaptor * adaptor,
                                   GObject * object,
                                   const gchar * id,
                                   const GValue * value)
{
  if (!strcmp (id, "use-custom-title"))
    glade_gtk_header_bar_set_use_custom_title (object, g_value_get_boolean (value));
  else if (!strcmp (id, "show-close-button"))
    {
      GladeWidget *gwidget = glade_widget_get_from_gobject (object);

      /* We don't set the property to 'ignore' so that we catch this in the adaptor,
       * but we also do not apply the property to the runtime object here, thus
       * avoiding showing the close button which would in turn close glade itself
       * when clicked.
       */
      glade_widget_property_set_sensitive (gwidget, "decoration-layout",
					   g_value_get_boolean (value),
					   _("The decoration layout does not apply to header bars "
					     "which do no show window controls"));
    }
  else if (!strcmp (id, "size"))
    glade_gtk_header_bar_set_size (object, value);
  else
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value);
}
示例#27
0
static gboolean
glade_gtk_box_configure_begin (GladeFixed * fixed,
                               GladeWidget * child, GtkWidget * box)
{
  GList *list, *children;
  GtkWidget *bchild;

  g_assert (glade_gtk_box_original_positions == NULL);

  children = gtk_container_get_children (GTK_CONTAINER (box));

  for (list = children; list; list = list->next)
    {
      GladeGtkBoxChild *gbchild;
      GladeWidget *gchild;

      bchild = list->data;
      if ((gchild = glade_widget_get_from_gobject (bchild)) == NULL)
        continue;

      gbchild = g_new0 (GladeGtkBoxChild, 1);
      gbchild->widget = bchild;
      glade_widget_pack_property_get (gchild, "position", &gbchild->position);

      glade_gtk_box_original_positions =
          g_list_prepend (glade_gtk_box_original_positions, gbchild);
    }

  g_list_free (children);

  return TRUE;
}
示例#28
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);
}
示例#29
0
void
glade_gtk_menu_item_action_activate (GladeWidgetAdaptor * adaptor,
                                     GObject * object,
                                     const gchar * action_path)
{
  GObject *obj = NULL, *shell = NULL;
  GladeWidget *w = glade_widget_get_from_gobject (object);

  while ((w = glade_widget_get_parent (w)))
    {
      obj = glade_widget_get_object (w);
      if (GTK_IS_MENU_SHELL (obj))
        shell = obj;
    }

  if (strcmp (action_path, "launch_editor") == 0)
    {
      if (shell)
        object = shell;

      if (GTK_IS_MENU_BAR (object))
        glade_gtk_menu_shell_launch_editor (object, _("Edit Menu Bar"));
      else if (GTK_IS_MENU (object))
        glade_gtk_menu_shell_launch_editor (object, _("Edit Menu"));
    }
  else
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
                                                         object, action_path);

  if (shell)
    gtk_menu_shell_deactivate (GTK_MENU_SHELL (shell));
}
示例#30
0
static void
glade_gtk_fixed_layout_sync_size_requests (GtkWidget *widget)
{
  GList *children, *l;

  if ((children = gtk_container_get_children (GTK_CONTAINER (widget))) != NULL)
    {
      for (l = children; l; l = l->next)
        {
          GtkWidget *child = l->data;
          GladeWidget *gchild = glade_widget_get_from_gobject (child);
          gint width = -1, height = -1;

          if (!gchild)
            continue;

          glade_widget_property_get (gchild, "width-request", &width);
          glade_widget_property_get (gchild, "height-request", &height);

          gtk_widget_set_size_request (child, width, height);

        }
      g_list_free (children);
    }
}